.',
- list[i]
- );
- }
- }
- addAttr(el, name, JSON.stringify(value), list[i]);
- // #6887 firefox doesn't update muted state if set via attribute
- // even immediately after element creation
- if (!el.component &&
- name === 'muted' &&
- platformMustUseProp(el.tag, el.attrsMap.type, name)) {
- addProp(el, name, 'true', list[i]);
- }
- }
- }
- }
-
- function checkInFor (el) {
- var parent = el;
- while (parent) {
- if (parent.for !== undefined) {
- return true
- }
- parent = parent.parent;
- }
- return false
- }
-
- function parseModifiers (name) {
- var match = name.match(modifierRE);
- if (match) {
- var ret = {};
- match.forEach(function (m) { ret[m.slice(1)] = true; });
- return ret
- }
- }
-
- function makeAttrsMap (attrs) {
- var map = {};
- for (var i = 0, l = attrs.length; i < l; i++) {
- if (
- map[attrs[i].name] && !isIE && !isEdge
- ) {
- warn$2('duplicate attribute: ' + attrs[i].name, attrs[i]);
- }
- map[attrs[i].name] = attrs[i].value;
- }
- return map
- }
-
- // for script (e.g. type="x/template") or style, do not decode content
- function isTextTag (el) {
- return el.tag === 'script' || el.tag === 'style'
- }
-
- function isForbiddenTag (el) {
- return (
- el.tag === 'style' ||
- (el.tag === 'script' && (
- !el.attrsMap.type ||
- el.attrsMap.type === 'text/javascript'
- ))
- )
- }
-
- var ieNSBug = /^xmlns:NS\d+/;
- var ieNSPrefix = /^NS\d+:/;
-
- /* istanbul ignore next */
- function guardIESVGBug (attrs) {
- var res = [];
- for (var i = 0; i < attrs.length; i++) {
- var attr = attrs[i];
- if (!ieNSBug.test(attr.name)) {
- attr.name = attr.name.replace(ieNSPrefix, '');
- res.push(attr);
- }
- }
- return res
- }
-
- function checkForAliasModel (el, value) {
- var _el = el;
- while (_el) {
- if (_el.for && _el.alias === value) {
- warn$2(
- "<" + (el.tag) + " v-model=\"" + value + "\">: " +
- "You are binding v-model directly to a v-for iteration alias. " +
- "This will not be able to modify the v-for source array because " +
- "writing to the alias is like modifying a function local variable. " +
- "Consider using an array of objects and use v-model on an object property instead.",
- el.rawAttrsMap['v-model']
- );
- }
- _el = _el.parent;
- }
- }
-
- /* */
-
- function preTransformNode (el, options) {
- if (el.tag === 'input') {
- var map = el.attrsMap;
- if (!map['v-model']) {
- return
- }
-
- var typeBinding;
- if (map[':type'] || map['v-bind:type']) {
- typeBinding = getBindingAttr(el, 'type');
- }
- if (!map.type && !typeBinding && map['v-bind']) {
- typeBinding = "(" + (map['v-bind']) + ").type";
- }
-
- if (typeBinding) {
- var ifCondition = getAndRemoveAttr(el, 'v-if', true);
- var ifConditionExtra = ifCondition ? ("&&(" + ifCondition + ")") : "";
- var hasElse = getAndRemoveAttr(el, 'v-else', true) != null;
- var elseIfCondition = getAndRemoveAttr(el, 'v-else-if', true);
- // 1. checkbox
- var branch0 = cloneASTElement(el);
- // process for on the main node
- processFor(branch0);
- addRawAttr(branch0, 'type', 'checkbox');
- processElement(branch0, options);
- branch0.processed = true; // prevent it from double-processed
- branch0.if = "(" + typeBinding + ")==='checkbox'" + ifConditionExtra;
- addIfCondition(branch0, {
- exp: branch0.if,
- block: branch0
- });
- // 2. add radio else-if condition
- var branch1 = cloneASTElement(el);
- getAndRemoveAttr(branch1, 'v-for', true);
- addRawAttr(branch1, 'type', 'radio');
- processElement(branch1, options);
- addIfCondition(branch0, {
- exp: "(" + typeBinding + ")==='radio'" + ifConditionExtra,
- block: branch1
- });
- // 3. other
- var branch2 = cloneASTElement(el);
- getAndRemoveAttr(branch2, 'v-for', true);
- addRawAttr(branch2, ':type', typeBinding);
- processElement(branch2, options);
- addIfCondition(branch0, {
- exp: ifCondition,
- block: branch2
- });
-
- if (hasElse) {
- branch0.else = true;
- } else if (elseIfCondition) {
- branch0.elseif = elseIfCondition;
- }
-
- return branch0
- }
- }
- }
-
- function cloneASTElement (el) {
- return createASTElement(el.tag, el.attrsList.slice(), el.parent)
- }
-
- var model$1 = {
- preTransformNode: preTransformNode
- };
-
- var modules$1 = [
- klass$1,
- style$1,
- model$1
- ];
-
- /* */
-
- function text (el, dir) {
- if (dir.value) {
- addProp(el, 'textContent', ("_s(" + (dir.value) + ")"), dir);
- }
- }
-
- /* */
-
- function html (el, dir) {
- if (dir.value) {
- addProp(el, 'innerHTML', ("_s(" + (dir.value) + ")"), dir);
- }
- }
-
- var directives$1 = {
- model: model,
- text: text,
- html: html
- };
-
- /* */
-
- var baseOptions = {
- expectHTML: true,
- modules: modules$1,
- directives: directives$1,
- isPreTag: isPreTag,
- isUnaryTag: isUnaryTag,
- mustUseProp: mustUseProp,
- canBeLeftOpenTag: canBeLeftOpenTag,
- isReservedTag: isReservedTag,
- getTagNamespace: getTagNamespace,
- staticKeys: genStaticKeys(modules$1)
- };
-
- /* */
-
- var isStaticKey;
- var isPlatformReservedTag;
-
- var genStaticKeysCached = cached(genStaticKeys$1);
-
- /**
- * Goal of the optimizer: walk the generated template AST tree
- * and detect sub-trees that are purely static, i.e. parts of
- * the DOM that never needs to change.
- *
- * Once we detect these sub-trees, we can:
- *
- * 1. Hoist them into constants, so that we no longer need to
- * create fresh nodes for them on each re-render;
- * 2. Completely skip them in the patching process.
- */
- function optimize (root, options) {
- if (!root) { return }
- isStaticKey = genStaticKeysCached(options.staticKeys || '');
- isPlatformReservedTag = options.isReservedTag || no;
- // first pass: mark all non-static nodes.
- markStatic$1(root);
- // second pass: mark static roots.
- markStaticRoots(root, false);
- }
-
- function genStaticKeys$1 (keys) {
- return makeMap(
- 'type,tag,attrsList,attrsMap,plain,parent,children,attrs,start,end,rawAttrsMap' +
- (keys ? ',' + keys : '')
- )
- }
-
- function markStatic$1 (node) {
- node.static = isStatic(node);
- if (node.type === 1) {
- // do not make component slot content static. this avoids
- // 1. components not able to mutate slot nodes
- // 2. static slot content fails for hot-reloading
- if (
- !isPlatformReservedTag(node.tag) &&
- node.tag !== 'slot' &&
- node.attrsMap['inline-template'] == null
- ) {
- return
- }
- for (var i = 0, l = node.children.length; i < l; i++) {
- var child = node.children[i];
- markStatic$1(child);
- if (!child.static) {
- node.static = false;
- }
- }
- if (node.ifConditions) {
- for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) {
- var block = node.ifConditions[i$1].block;
- markStatic$1(block);
- if (!block.static) {
- node.static = false;
- }
- }
- }
- }
- }
-
- function markStaticRoots (node, isInFor) {
- if (node.type === 1) {
- if (node.static || node.once) {
- node.staticInFor = isInFor;
- }
- // For a node to qualify as a static root, it should have children that
- // are not just static text. Otherwise the cost of hoisting out will
- // outweigh the benefits and it's better off to just always render it fresh.
- if (node.static && node.children.length && !(
- node.children.length === 1 &&
- node.children[0].type === 3
- )) {
- node.staticRoot = true;
- return
- } else {
- node.staticRoot = false;
- }
- if (node.children) {
- for (var i = 0, l = node.children.length; i < l; i++) {
- markStaticRoots(node.children[i], isInFor || !!node.for);
- }
- }
- if (node.ifConditions) {
- for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) {
- markStaticRoots(node.ifConditions[i$1].block, isInFor);
- }
- }
- }
- }
-
- function isStatic (node) {
- if (node.type === 2) { // expression
- return false
- }
- if (node.type === 3) { // text
- return true
- }
- return !!(node.pre || (
- !node.hasBindings && // no dynamic bindings
- !node.if && !node.for && // not v-if or v-for or v-else
- !isBuiltInTag(node.tag) && // not a built-in
- isPlatformReservedTag(node.tag) && // not a component
- !isDirectChildOfTemplateFor(node) &&
- Object.keys(node).every(isStaticKey)
- ))
- }
-
- function isDirectChildOfTemplateFor (node) {
- while (node.parent) {
- node = node.parent;
- if (node.tag !== 'template') {
- return false
- }
- if (node.for) {
- return true
- }
- }
- return false
- }
-
- /* */
-
- var fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function(?:\s+[\w$]+)?\s*\(/;
- var fnInvokeRE = /\([^)]*?\);*$/;
- var simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
-
- // KeyboardEvent.keyCode aliases
- var keyCodes = {
- esc: 27,
- tab: 9,
- enter: 13,
- space: 32,
- up: 38,
- left: 37,
- right: 39,
- down: 40,
- 'delete': [8, 46]
- };
-
- // KeyboardEvent.key aliases
- var keyNames = {
- // #7880: IE11 and Edge use `Esc` for Escape key name.
- esc: ['Esc', 'Escape'],
- tab: 'Tab',
- enter: 'Enter',
- // #9112: IE11 uses `Spacebar` for Space key name.
- space: [' ', 'Spacebar'],
- // #7806: IE11 uses key names without `Arrow` prefix for arrow keys.
- up: ['Up', 'ArrowUp'],
- left: ['Left', 'ArrowLeft'],
- right: ['Right', 'ArrowRight'],
- down: ['Down', 'ArrowDown'],
- // #9112: IE11 uses `Del` for Delete key name.
- 'delete': ['Backspace', 'Delete', 'Del']
- };
-
- // #4868: modifiers that prevent the execution of the listener
- // need to explicitly return null so that we can determine whether to remove
- // the listener for .once
- var genGuard = function (condition) { return ("if(" + condition + ")return null;"); };
-
- var modifierCode = {
- stop: '$event.stopPropagation();',
- prevent: '$event.preventDefault();',
- self: genGuard("$event.target !== $event.currentTarget"),
- ctrl: genGuard("!$event.ctrlKey"),
- shift: genGuard("!$event.shiftKey"),
- alt: genGuard("!$event.altKey"),
- meta: genGuard("!$event.metaKey"),
- left: genGuard("'button' in $event && $event.button !== 0"),
- middle: genGuard("'button' in $event && $event.button !== 1"),
- right: genGuard("'button' in $event && $event.button !== 2")
- };
-
- function genHandlers (
- events,
- isNative
- ) {
- var prefix = isNative ? 'nativeOn:' : 'on:';
- var staticHandlers = "";
- var dynamicHandlers = "";
- for (var name in events) {
- var handlerCode = genHandler(events[name]);
- if (events[name] && events[name].dynamic) {
- dynamicHandlers += name + "," + handlerCode + ",";
- } else {
- staticHandlers += "\"" + name + "\":" + handlerCode + ",";
- }
- }
- staticHandlers = "{" + (staticHandlers.slice(0, -1)) + "}";
- if (dynamicHandlers) {
- return prefix + "_d(" + staticHandlers + ",[" + (dynamicHandlers.slice(0, -1)) + "])"
- } else {
- return prefix + staticHandlers
- }
- }
-
- function genHandler (handler) {
- if (!handler) {
- return 'function(){}'
- }
-
- if (Array.isArray(handler)) {
- return ("[" + (handler.map(function (handler) { return genHandler(handler); }).join(',')) + "]")
- }
-
- var isMethodPath = simplePathRE.test(handler.value);
- var isFunctionExpression = fnExpRE.test(handler.value);
- var isFunctionInvocation = simplePathRE.test(handler.value.replace(fnInvokeRE, ''));
-
- if (!handler.modifiers) {
- if (isMethodPath || isFunctionExpression) {
- return handler.value
- }
- return ("function($event){" + (isFunctionInvocation ? ("return " + (handler.value)) : handler.value) + "}") // inline statement
- } else {
- var code = '';
- var genModifierCode = '';
- var keys = [];
- for (var key in handler.modifiers) {
- if (modifierCode[key]) {
- genModifierCode += modifierCode[key];
- // left/right
- if (keyCodes[key]) {
- keys.push(key);
- }
- } else if (key === 'exact') {
- var modifiers = (handler.modifiers);
- genModifierCode += genGuard(
- ['ctrl', 'shift', 'alt', 'meta']
- .filter(function (keyModifier) { return !modifiers[keyModifier]; })
- .map(function (keyModifier) { return ("$event." + keyModifier + "Key"); })
- .join('||')
- );
- } else {
- keys.push(key);
- }
- }
- if (keys.length) {
- code += genKeyFilter(keys);
- }
- // Make sure modifiers like prevent and stop get executed after key filtering
- if (genModifierCode) {
- code += genModifierCode;
- }
- var handlerCode = isMethodPath
- ? ("return " + (handler.value) + "($event)")
- : isFunctionExpression
- ? ("return (" + (handler.value) + ")($event)")
- : isFunctionInvocation
- ? ("return " + (handler.value))
- : handler.value;
- return ("function($event){" + code + handlerCode + "}")
- }
- }
-
- function genKeyFilter (keys) {
- return (
- // make sure the key filters only apply to KeyboardEvents
- // #9441: can't use 'keyCode' in $event because Chrome autofill fires fake
- // key events that do not have keyCode property...
- "if(!$event.type.indexOf('key')&&" +
- (keys.map(genFilterCode).join('&&')) + ")return null;"
- )
- }
-
- function genFilterCode (key) {
- var keyVal = parseInt(key, 10);
- if (keyVal) {
- return ("$event.keyCode!==" + keyVal)
- }
- var keyCode = keyCodes[key];
- var keyName = keyNames[key];
- return (
- "_k($event.keyCode," +
- (JSON.stringify(key)) + "," +
- (JSON.stringify(keyCode)) + "," +
- "$event.key," +
- "" + (JSON.stringify(keyName)) +
- ")"
- )
- }
-
- /* */
-
- function on (el, dir) {
- if (dir.modifiers) {
- warn("v-on without argument does not support modifiers.");
- }
- el.wrapListeners = function (code) { return ("_g(" + code + "," + (dir.value) + ")"); };
- }
-
- /* */
-
- function bind$1 (el, dir) {
- el.wrapData = function (code) {
- return ("_b(" + code + ",'" + (el.tag) + "'," + (dir.value) + "," + (dir.modifiers && dir.modifiers.prop ? 'true' : 'false') + (dir.modifiers && dir.modifiers.sync ? ',true' : '') + ")")
- };
- }
-
- /* */
-
- var baseDirectives = {
- on: on,
- bind: bind$1,
- cloak: noop
- };
-
- /* */
-
-
-
-
-
- var CodegenState = function CodegenState (options) {
- this.options = options;
- this.warn = options.warn || baseWarn;
- this.transforms = pluckModuleFunction(options.modules, 'transformCode');
- this.dataGenFns = pluckModuleFunction(options.modules, 'genData');
- this.directives = extend(extend({}, baseDirectives), options.directives);
- var isReservedTag = options.isReservedTag || no;
- this.maybeComponent = function (el) { return !!el.component || !isReservedTag(el.tag); };
- this.onceId = 0;
- this.staticRenderFns = [];
- this.pre = false;
- };
-
-
-
- function generate (
- ast,
- options
- ) {
- var state = new CodegenState(options);
- var code = ast ? genElement(ast, state) : '_c("div")';
- return {
- render: ("with(this){return " + code + "}"),
- staticRenderFns: state.staticRenderFns
- }
- }
-
- function genElement (el, state) {
- if (el.parent) {
- el.pre = el.pre || el.parent.pre;
- }
-
- if (el.staticRoot && !el.staticProcessed) {
- return genStatic(el, state)
- } else if (el.once && !el.onceProcessed) {
- return genOnce(el, state)
- } else if (el.for && !el.forProcessed) {
- return genFor(el, state)
- } else if (el.if && !el.ifProcessed) {
- return genIf(el, state)
- } else if (el.tag === 'template' && !el.slotTarget && !state.pre) {
- return genChildren(el, state) || 'void 0'
- } else if (el.tag === 'slot') {
- return genSlot(el, state)
- } else {
- // component or element
- var code;
- if (el.component) {
- code = genComponent(el.component, el, state);
- } else {
- var data;
- if (!el.plain || (el.pre && state.maybeComponent(el))) {
- data = genData$2(el, state);
- }
-
- var children = el.inlineTemplate ? null : genChildren(el, state, true);
- code = "_c('" + (el.tag) + "'" + (data ? ("," + data) : '') + (children ? ("," + children) : '') + ")";
- }
- // module transforms
- for (var i = 0; i < state.transforms.length; i++) {
- code = state.transforms[i](el, code);
- }
- return code
- }
- }
-
- // hoist static sub-trees out
- function genStatic (el, state) {
- el.staticProcessed = true;
- // Some elements (templates) need to behave differently inside of a v-pre
- // node. All pre nodes are static roots, so we can use this as a location to
- // wrap a state change and reset it upon exiting the pre node.
- var originalPreState = state.pre;
- if (el.pre) {
- state.pre = el.pre;
- }
- state.staticRenderFns.push(("with(this){return " + (genElement(el, state)) + "}"));
- state.pre = originalPreState;
- return ("_m(" + (state.staticRenderFns.length - 1) + (el.staticInFor ? ',true' : '') + ")")
- }
-
- // v-once
- function genOnce (el, state) {
- el.onceProcessed = true;
- if (el.if && !el.ifProcessed) {
- return genIf(el, state)
- } else if (el.staticInFor) {
- var key = '';
- var parent = el.parent;
- while (parent) {
- if (parent.for) {
- key = parent.key;
- break
- }
- parent = parent.parent;
- }
- if (!key) {
- state.warn(
- "v-once can only be used inside v-for that is keyed. ",
- el.rawAttrsMap['v-once']
- );
- return genElement(el, state)
- }
- return ("_o(" + (genElement(el, state)) + "," + (state.onceId++) + "," + key + ")")
- } else {
- return genStatic(el, state)
- }
- }
-
- function genIf (
- el,
- state,
- altGen,
- altEmpty
- ) {
- el.ifProcessed = true; // avoid recursion
- return genIfConditions(el.ifConditions.slice(), state, altGen, altEmpty)
- }
-
- function genIfConditions (
- conditions,
- state,
- altGen,
- altEmpty
- ) {
- if (!conditions.length) {
- return altEmpty || '_e()'
- }
-
- var condition = conditions.shift();
- if (condition.exp) {
- return ("(" + (condition.exp) + ")?" + (genTernaryExp(condition.block)) + ":" + (genIfConditions(conditions, state, altGen, altEmpty)))
- } else {
- return ("" + (genTernaryExp(condition.block)))
- }
-
- // v-if with v-once should generate code like (a)?_m(0):_m(1)
- function genTernaryExp (el) {
- return altGen
- ? altGen(el, state)
- : el.once
- ? genOnce(el, state)
- : genElement(el, state)
- }
- }
-
- function genFor (
- el,
- state,
- altGen,
- altHelper
- ) {
- var exp = el.for;
- var alias = el.alias;
- var iterator1 = el.iterator1 ? ("," + (el.iterator1)) : '';
- var iterator2 = el.iterator2 ? ("," + (el.iterator2)) : '';
-
- if (state.maybeComponent(el) &&
- el.tag !== 'slot' &&
- el.tag !== 'template' &&
- !el.key
- ) {
- state.warn(
- "<" + (el.tag) + " v-for=\"" + alias + " in " + exp + "\">: component lists rendered with " +
- "v-for should have explicit keys. " +
- "See https://vuejs.org/guide/list.html#key for more info.",
- el.rawAttrsMap['v-for'],
- true /* tip */
- );
- }
-
- el.forProcessed = true; // avoid recursion
- return (altHelper || '_l') + "((" + exp + ")," +
- "function(" + alias + iterator1 + iterator2 + "){" +
- "return " + ((altGen || genElement)(el, state)) +
- '})'
- }
-
- function genData$2 (el, state) {
- var data = '{';
-
- // directives first.
- // directives may mutate the el's other properties before they are generated.
- var dirs = genDirectives(el, state);
- if (dirs) { data += dirs + ','; }
-
- // key
- if (el.key) {
- data += "key:" + (el.key) + ",";
- }
- // ref
- if (el.ref) {
- data += "ref:" + (el.ref) + ",";
- }
- if (el.refInFor) {
- data += "refInFor:true,";
- }
- // pre
- if (el.pre) {
- data += "pre:true,";
- }
- // record original tag name for components using "is" attribute
- if (el.component) {
- data += "tag:\"" + (el.tag) + "\",";
- }
- // module data generation functions
- for (var i = 0; i < state.dataGenFns.length; i++) {
- data += state.dataGenFns[i](el);
- }
- // attributes
- if (el.attrs) {
- data += "attrs:" + (genProps(el.attrs)) + ",";
- }
- // DOM props
- if (el.props) {
- data += "domProps:" + (genProps(el.props)) + ",";
- }
- // event handlers
- if (el.events) {
- data += (genHandlers(el.events, false)) + ",";
- }
- if (el.nativeEvents) {
- data += (genHandlers(el.nativeEvents, true)) + ",";
- }
- // slot target
- // only for non-scoped slots
- if (el.slotTarget && !el.slotScope) {
- data += "slot:" + (el.slotTarget) + ",";
- }
- // scoped slots
- if (el.scopedSlots) {
- data += (genScopedSlots(el, el.scopedSlots, state)) + ",";
- }
- // component v-model
- if (el.model) {
- data += "model:{value:" + (el.model.value) + ",callback:" + (el.model.callback) + ",expression:" + (el.model.expression) + "},";
- }
- // inline-template
- if (el.inlineTemplate) {
- var inlineTemplate = genInlineTemplate(el, state);
- if (inlineTemplate) {
- data += inlineTemplate + ",";
- }
- }
- data = data.replace(/,$/, '') + '}';
- // v-bind dynamic argument wrap
- // v-bind with dynamic arguments must be applied using the same v-bind object
- // merge helper so that class/style/mustUseProp attrs are handled correctly.
- if (el.dynamicAttrs) {
- data = "_b(" + data + ",\"" + (el.tag) + "\"," + (genProps(el.dynamicAttrs)) + ")";
- }
- // v-bind data wrap
- if (el.wrapData) {
- data = el.wrapData(data);
- }
- // v-on data wrap
- if (el.wrapListeners) {
- data = el.wrapListeners(data);
- }
- return data
- }
-
- function genDirectives (el, state) {
- var dirs = el.directives;
- if (!dirs) { return }
- var res = 'directives:[';
- var hasRuntime = false;
- var i, l, dir, needRuntime;
- for (i = 0, l = dirs.length; i < l; i++) {
- dir = dirs[i];
- needRuntime = true;
- var gen = state.directives[dir.name];
- if (gen) {
- // compile-time directive that manipulates AST.
- // returns true if it also needs a runtime counterpart.
- needRuntime = !!gen(el, dir, state.warn);
- }
- if (needRuntime) {
- hasRuntime = true;
- res += "{name:\"" + (dir.name) + "\",rawName:\"" + (dir.rawName) + "\"" + (dir.value ? (",value:(" + (dir.value) + "),expression:" + (JSON.stringify(dir.value))) : '') + (dir.arg ? (",arg:" + (dir.isDynamicArg ? dir.arg : ("\"" + (dir.arg) + "\""))) : '') + (dir.modifiers ? (",modifiers:" + (JSON.stringify(dir.modifiers))) : '') + "},";
- }
- }
- if (hasRuntime) {
- return res.slice(0, -1) + ']'
- }
- }
-
- function genInlineTemplate (el, state) {
- var ast = el.children[0];
- if (el.children.length !== 1 || ast.type !== 1) {
- state.warn(
- 'Inline-template components must have exactly one child element.',
- { start: el.start }
- );
- }
- if (ast && ast.type === 1) {
- var inlineRenderFns = generate(ast, state.options);
- return ("inlineTemplate:{render:function(){" + (inlineRenderFns.render) + "},staticRenderFns:[" + (inlineRenderFns.staticRenderFns.map(function (code) { return ("function(){" + code + "}"); }).join(',')) + "]}")
- }
- }
-
- function genScopedSlots (
- el,
- slots,
- state
- ) {
- // by default scoped slots are considered "stable", this allows child
- // components with only scoped slots to skip forced updates from parent.
- // but in some cases we have to bail-out of this optimization
- // for example if the slot contains dynamic names, has v-if or v-for on them...
- var needsForceUpdate = el.for || Object.keys(slots).some(function (key) {
- var slot = slots[key];
- return (
- slot.slotTargetDynamic ||
- slot.if ||
- slot.for ||
- containsSlotChild(slot) // is passing down slot from parent which may be dynamic
- )
- });
-
- // #9534: if a component with scoped slots is inside a conditional branch,
- // it's possible for the same component to be reused but with different
- // compiled slot content. To avoid that, we generate a unique key based on
- // the generated code of all the slot contents.
- var needsKey = !!el.if;
-
- // OR when it is inside another scoped slot or v-for (the reactivity may be
- // disconnected due to the intermediate scope variable)
- // #9438, #9506
- // TODO: this can be further optimized by properly analyzing in-scope bindings
- // and skip force updating ones that do not actually use scope variables.
- if (!needsForceUpdate) {
- var parent = el.parent;
- while (parent) {
- if (
- (parent.slotScope && parent.slotScope !== emptySlotScopeToken) ||
- parent.for
- ) {
- needsForceUpdate = true;
- break
- }
- if (parent.if) {
- needsKey = true;
- }
- parent = parent.parent;
- }
- }
-
- var generatedSlots = Object.keys(slots)
- .map(function (key) { return genScopedSlot(slots[key], state); })
- .join(',');
-
- return ("scopedSlots:_u([" + generatedSlots + "]" + (needsForceUpdate ? ",null,true" : "") + (!needsForceUpdate && needsKey ? (",null,false," + (hash(generatedSlots))) : "") + ")")
- }
-
- function hash(str) {
- var hash = 5381;
- var i = str.length;
- while(i) {
- hash = (hash * 33) ^ str.charCodeAt(--i);
- }
- return hash >>> 0
- }
-
- function containsSlotChild (el) {
- if (el.type === 1) {
- if (el.tag === 'slot') {
- return true
- }
- return el.children.some(containsSlotChild)
- }
- return false
- }
-
- function genScopedSlot (
- el,
- state
- ) {
- var isLegacySyntax = el.attrsMap['slot-scope'];
- if (el.if && !el.ifProcessed && !isLegacySyntax) {
- return genIf(el, state, genScopedSlot, "null")
- }
- if (el.for && !el.forProcessed) {
- return genFor(el, state, genScopedSlot)
- }
- var slotScope = el.slotScope === emptySlotScopeToken
- ? ""
- : String(el.slotScope);
- var fn = "function(" + slotScope + "){" +
- "return " + (el.tag === 'template'
- ? el.if && isLegacySyntax
- ? ("(" + (el.if) + ")?" + (genChildren(el, state) || 'undefined') + ":undefined")
- : genChildren(el, state) || 'undefined'
- : genElement(el, state)) + "}";
- // reverse proxy v-slot without scope on this.$slots
- var reverseProxy = slotScope ? "" : ",proxy:true";
- return ("{key:" + (el.slotTarget || "\"default\"") + ",fn:" + fn + reverseProxy + "}")
- }
-
- function genChildren (
- el,
- state,
- checkSkip,
- altGenElement,
- altGenNode
- ) {
- var children = el.children;
- if (children.length) {
- var el$1 = children[0];
- // optimize single v-for
- if (children.length === 1 &&
- el$1.for &&
- el$1.tag !== 'template' &&
- el$1.tag !== 'slot'
- ) {
- var normalizationType = checkSkip
- ? state.maybeComponent(el$1) ? ",1" : ",0"
- : "";
- return ("" + ((altGenElement || genElement)(el$1, state)) + normalizationType)
- }
- var normalizationType$1 = checkSkip
- ? getNormalizationType(children, state.maybeComponent)
- : 0;
- var gen = altGenNode || genNode;
- return ("[" + (children.map(function (c) { return gen(c, state); }).join(',')) + "]" + (normalizationType$1 ? ("," + normalizationType$1) : ''))
- }
- }
-
- // determine the normalization needed for the children array.
- // 0: no normalization needed
- // 1: simple normalization needed (possible 1-level deep nested array)
- // 2: full normalization needed
- function getNormalizationType (
- children,
- maybeComponent
- ) {
- var res = 0;
- for (var i = 0; i < children.length; i++) {
- var el = children[i];
- if (el.type !== 1) {
- continue
- }
- if (needsNormalization(el) ||
- (el.ifConditions && el.ifConditions.some(function (c) { return needsNormalization(c.block); }))) {
- res = 2;
- break
- }
- if (maybeComponent(el) ||
- (el.ifConditions && el.ifConditions.some(function (c) { return maybeComponent(c.block); }))) {
- res = 1;
- }
- }
- return res
- }
-
- function needsNormalization (el) {
- return el.for !== undefined || el.tag === 'template' || el.tag === 'slot'
- }
-
- function genNode (node, state) {
- if (node.type === 1) {
- return genElement(node, state)
- } else if (node.type === 3 && node.isComment) {
- return genComment(node)
- } else {
- return genText(node)
- }
- }
-
- function genText (text) {
- return ("_v(" + (text.type === 2
- ? text.expression // no need for () because already wrapped in _s()
- : transformSpecialNewlines(JSON.stringify(text.text))) + ")")
- }
-
- function genComment (comment) {
- return ("_e(" + (JSON.stringify(comment.text)) + ")")
- }
-
- function genSlot (el, state) {
- var slotName = el.slotName || '"default"';
- var children = genChildren(el, state);
- var res = "_t(" + slotName + (children ? ("," + children) : '');
- var attrs = el.attrs || el.dynamicAttrs
- ? genProps((el.attrs || []).concat(el.dynamicAttrs || []).map(function (attr) { return ({
- // slot props are camelized
- name: camelize(attr.name),
- value: attr.value,
- dynamic: attr.dynamic
- }); }))
- : null;
- var bind$$1 = el.attrsMap['v-bind'];
- if ((attrs || bind$$1) && !children) {
- res += ",null";
- }
- if (attrs) {
- res += "," + attrs;
- }
- if (bind$$1) {
- res += (attrs ? '' : ',null') + "," + bind$$1;
- }
- return res + ')'
- }
-
- // componentName is el.component, take it as argument to shun flow's pessimistic refinement
- function genComponent (
- componentName,
- el,
- state
- ) {
- var children = el.inlineTemplate ? null : genChildren(el, state, true);
- return ("_c(" + componentName + "," + (genData$2(el, state)) + (children ? ("," + children) : '') + ")")
- }
-
- function genProps (props) {
- var staticProps = "";
- var dynamicProps = "";
- for (var i = 0; i < props.length; i++) {
- var prop = props[i];
- var value = transformSpecialNewlines(prop.value);
- if (prop.dynamic) {
- dynamicProps += (prop.name) + "," + value + ",";
- } else {
- staticProps += "\"" + (prop.name) + "\":" + value + ",";
- }
- }
- staticProps = "{" + (staticProps.slice(0, -1)) + "}";
- if (dynamicProps) {
- return ("_d(" + staticProps + ",[" + (dynamicProps.slice(0, -1)) + "])")
- } else {
- return staticProps
- }
- }
-
- // #3895, #4268
- function transformSpecialNewlines (text) {
- return text
- .replace(/\u2028/g, '\\u2028')
- .replace(/\u2029/g, '\\u2029')
- }
-
- /* */
-
-
-
- // these keywords should not appear inside expressions, but operators like
- // typeof, instanceof and in are allowed
- var prohibitedKeywordRE = new RegExp('\\b' + (
- 'do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' +
- 'super,throw,while,yield,delete,export,import,return,switch,default,' +
- 'extends,finally,continue,debugger,function,arguments'
- ).split(',').join('\\b|\\b') + '\\b');
-
- // these unary operators should not be used as property/method names
- var unaryOperatorsRE = new RegExp('\\b' + (
- 'delete,typeof,void'
- ).split(',').join('\\s*\\([^\\)]*\\)|\\b') + '\\s*\\([^\\)]*\\)');
-
- // strip strings in expressions
- var stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
-
- // detect problematic expressions in a template
- function detectErrors (ast, warn) {
- if (ast) {
- checkNode(ast, warn);
- }
- }
-
- function checkNode (node, warn) {
- if (node.type === 1) {
- for (var name in node.attrsMap) {
- if (dirRE.test(name)) {
- var value = node.attrsMap[name];
- if (value) {
- var range = node.rawAttrsMap[name];
- if (name === 'v-for') {
- checkFor(node, ("v-for=\"" + value + "\""), warn, range);
- } else if (name === 'v-slot' || name[0] === '#') {
- checkFunctionParameterExpression(value, (name + "=\"" + value + "\""), warn, range);
- } else if (onRE.test(name)) {
- checkEvent(value, (name + "=\"" + value + "\""), warn, range);
- } else {
- checkExpression(value, (name + "=\"" + value + "\""), warn, range);
- }
- }
- }
- }
- if (node.children) {
- for (var i = 0; i < node.children.length; i++) {
- checkNode(node.children[i], warn);
- }
- }
- } else if (node.type === 2) {
- checkExpression(node.expression, node.text, warn, node);
- }
- }
-
- function checkEvent (exp, text, warn, range) {
- var stripped = exp.replace(stripStringRE, '');
- var keywordMatch = stripped.match(unaryOperatorsRE);
- if (keywordMatch && stripped.charAt(keywordMatch.index - 1) !== '$') {
- warn(
- "avoid using JavaScript unary operator as property name: " +
- "\"" + (keywordMatch[0]) + "\" in expression " + (text.trim()),
- range
- );
- }
- checkExpression(exp, text, warn, range);
- }
-
- function checkFor (node, text, warn, range) {
- checkExpression(node.for || '', text, warn, range);
- checkIdentifier(node.alias, 'v-for alias', text, warn, range);
- checkIdentifier(node.iterator1, 'v-for iterator', text, warn, range);
- checkIdentifier(node.iterator2, 'v-for iterator', text, warn, range);
- }
-
- function checkIdentifier (
- ident,
- type,
- text,
- warn,
- range
- ) {
- if (typeof ident === 'string') {
- try {
- new Function(("var " + ident + "=_"));
- } catch (e) {
- warn(("invalid " + type + " \"" + ident + "\" in expression: " + (text.trim())), range);
- }
- }
- }
-
- function checkExpression (exp, text, warn, range) {
- try {
- new Function(("return " + exp));
- } catch (e) {
- var keywordMatch = exp.replace(stripStringRE, '').match(prohibitedKeywordRE);
- if (keywordMatch) {
- warn(
- "avoid using JavaScript keyword as property name: " +
- "\"" + (keywordMatch[0]) + "\"\n Raw expression: " + (text.trim()),
- range
- );
- } else {
- warn(
- "invalid expression: " + (e.message) + " in\n\n" +
- " " + exp + "\n\n" +
- " Raw expression: " + (text.trim()) + "\n",
- range
- );
- }
- }
- }
-
- function checkFunctionParameterExpression (exp, text, warn, range) {
- try {
- new Function(exp, '');
- } catch (e) {
- warn(
- "invalid function parameter expression: " + (e.message) + " in\n\n" +
- " " + exp + "\n\n" +
- " Raw expression: " + (text.trim()) + "\n",
- range
- );
- }
- }
-
- /* */
-
- var range = 2;
-
- function generateCodeFrame (
- source,
- start,
- end
- ) {
- if ( start === void 0 ) start = 0;
- if ( end === void 0 ) end = source.length;
-
- var lines = source.split(/\r?\n/);
- var count = 0;
- var res = [];
- for (var i = 0; i < lines.length; i++) {
- count += lines[i].length + 1;
- if (count >= start) {
- for (var j = i - range; j <= i + range || end > count; j++) {
- if (j < 0 || j >= lines.length) { continue }
- res.push(("" + (j + 1) + (repeat$1(" ", 3 - String(j + 1).length)) + "| " + (lines[j])));
- var lineLength = lines[j].length;
- if (j === i) {
- // push underline
- var pad = start - (count - lineLength) + 1;
- var length = end > count ? lineLength - pad : end - start;
- res.push(" | " + repeat$1(" ", pad) + repeat$1("^", length));
- } else if (j > i) {
- if (end > count) {
- var length$1 = Math.min(end - count, lineLength);
- res.push(" | " + repeat$1("^", length$1));
- }
- count += lineLength + 1;
- }
- }
- break
- }
- }
- return res.join('\n')
- }
-
- function repeat$1 (str, n) {
- var result = '';
- if (n > 0) {
- while (true) { // eslint-disable-line
- if (n & 1) { result += str; }
- n >>>= 1;
- if (n <= 0) { break }
- str += str;
- }
- }
- return result
- }
-
- /* */
-
-
-
- function createFunction (code, errors) {
- try {
- return new Function(code)
- } catch (err) {
- errors.push({ err: err, code: code });
- return noop
- }
- }
-
- function createCompileToFunctionFn (compile) {
- var cache = Object.create(null);
-
- return function compileToFunctions (
- template,
- options,
- vm
- ) {
- options = extend({}, options);
- var warn$$1 = options.warn || warn;
- delete options.warn;
-
- /* istanbul ignore if */
- {
- // detect possible CSP restriction
- try {
- new Function('return 1');
- } catch (e) {
- if (e.toString().match(/unsafe-eval|CSP/)) {
- warn$$1(
- 'It seems you are using the standalone build of Vue.js in an ' +
- 'environment with Content Security Policy that prohibits unsafe-eval. ' +
- 'The template compiler cannot work in this environment. Consider ' +
- 'relaxing the policy to allow unsafe-eval or pre-compiling your ' +
- 'templates into render functions.'
- );
- }
- }
- }
-
- // check cache
- var key = options.delimiters
- ? String(options.delimiters) + template
- : template;
- if (cache[key]) {
- return cache[key]
- }
-
- // compile
- var compiled = compile(template, options);
-
- // check compilation errors/tips
- {
- if (compiled.errors && compiled.errors.length) {
- if (options.outputSourceRange) {
- compiled.errors.forEach(function (e) {
- warn$$1(
- "Error compiling template:\n\n" + (e.msg) + "\n\n" +
- generateCodeFrame(template, e.start, e.end),
- vm
- );
- });
- } else {
- warn$$1(
- "Error compiling template:\n\n" + template + "\n\n" +
- compiled.errors.map(function (e) { return ("- " + e); }).join('\n') + '\n',
- vm
- );
- }
- }
- if (compiled.tips && compiled.tips.length) {
- if (options.outputSourceRange) {
- compiled.tips.forEach(function (e) { return tip(e.msg, vm); });
- } else {
- compiled.tips.forEach(function (msg) { return tip(msg, vm); });
- }
- }
- }
-
- // turn code into functions
- var res = {};
- var fnGenErrors = [];
- res.render = createFunction(compiled.render, fnGenErrors);
- res.staticRenderFns = compiled.staticRenderFns.map(function (code) {
- return createFunction(code, fnGenErrors)
- });
-
- // check function generation errors.
- // this should only happen if there is a bug in the compiler itself.
- // mostly for codegen development use
- /* istanbul ignore if */
- {
- if ((!compiled.errors || !compiled.errors.length) && fnGenErrors.length) {
- warn$$1(
- "Failed to generate render function:\n\n" +
- fnGenErrors.map(function (ref) {
- var err = ref.err;
- var code = ref.code;
-
- return ((err.toString()) + " in\n\n" + code + "\n");
- }).join('\n'),
- vm
- );
- }
- }
-
- return (cache[key] = res)
- }
- }
-
- /* */
-
- function createCompilerCreator (baseCompile) {
- return function createCompiler (baseOptions) {
- function compile (
- template,
- options
- ) {
- var finalOptions = Object.create(baseOptions);
- var errors = [];
- var tips = [];
-
- var warn = function (msg, range, tip) {
- (tip ? tips : errors).push(msg);
- };
-
- if (options) {
- if (options.outputSourceRange) {
- // $flow-disable-line
- var leadingSpaceLength = template.match(/^\s*/)[0].length;
-
- warn = function (msg, range, tip) {
- var data = { msg: msg };
- if (range) {
- if (range.start != null) {
- data.start = range.start + leadingSpaceLength;
- }
- if (range.end != null) {
- data.end = range.end + leadingSpaceLength;
- }
- }
- (tip ? tips : errors).push(data);
- };
- }
- // merge custom modules
- if (options.modules) {
- finalOptions.modules =
- (baseOptions.modules || []).concat(options.modules);
- }
- // merge custom directives
- if (options.directives) {
- finalOptions.directives = extend(
- Object.create(baseOptions.directives || null),
- options.directives
- );
- }
- // copy other options
- for (var key in options) {
- if (key !== 'modules' && key !== 'directives') {
- finalOptions[key] = options[key];
- }
- }
- }
-
- finalOptions.warn = warn;
-
- var compiled = baseCompile(template.trim(), finalOptions);
- {
- detectErrors(compiled.ast, warn);
- }
- compiled.errors = errors;
- compiled.tips = tips;
- return compiled
- }
-
- return {
- compile: compile,
- compileToFunctions: createCompileToFunctionFn(compile)
- }
- }
- }
-
- /* */
-
- // `createCompilerCreator` allows creating compilers that use alternative
- // parser/optimizer/codegen, e.g the SSR optimizing compiler.
- // Here we just export a default compiler using the default parts.
- var createCompiler = createCompilerCreator(function baseCompile (
- template,
- options
- ) {
- var ast = parse(template.trim(), options);
- if (options.optimize !== false) {
- optimize(ast, options);
- }
- var code = generate(ast, options);
- return {
- ast: ast,
- render: code.render,
- staticRenderFns: code.staticRenderFns
- }
- });
-
- /* */
-
- var ref$1 = createCompiler(baseOptions);
- var compile = ref$1.compile;
- var compileToFunctions = ref$1.compileToFunctions;
-
- /* */
-
- // check whether current browser encodes a char inside attribute values
- var div;
- function getShouldDecode (href) {
- div = div || document.createElement('div');
- div.innerHTML = href ? "
" : "";
- return div.innerHTML.indexOf('
') > 0
- }
-
- // #3663: IE encodes newlines inside attribute values while other browsers don't
- var shouldDecodeNewlines = inBrowser ? getShouldDecode(false) : false;
- // #6828: chrome encodes content in a[href]
- var shouldDecodeNewlinesForHref = inBrowser ? getShouldDecode(true) : false;
-
- /* */
-
- var idToTemplate = cached(function (id) {
- var el = query(id);
- return el && el.innerHTML
- });
-
- var mount = Vue.prototype.$mount;
- Vue.prototype.$mount = function (
- el,
- hydrating
- ) {
- el = el && query(el);
-
- /* istanbul ignore if */
- if (el === document.body || el === document.documentElement) {
- warn(
- "Do not mount Vue to or - mount to normal elements instead."
- );
- return this
- }
-
- var options = this.$options;
- // resolve template/el and convert to render function
- if (!options.render) {
- var template = options.template;
- if (template) {
- if (typeof template === 'string') {
- if (template.charAt(0) === '#') {
- template = idToTemplate(template);
- /* istanbul ignore if */
- if (!template) {
- warn(
- ("Template element not found or is empty: " + (options.template)),
- this
- );
- }
- }
- } else if (template.nodeType) {
- template = template.innerHTML;
- } else {
- {
- warn('invalid template option:' + template, this);
- }
- return this
- }
- } else if (el) {
- template = getOuterHTML(el);
- }
- if (template) {
- /* istanbul ignore if */
- if (config.performance && mark) {
- mark('compile');
- }
-
- var ref = compileToFunctions(template, {
- outputSourceRange: "development" !== 'production',
- shouldDecodeNewlines: shouldDecodeNewlines,
- shouldDecodeNewlinesForHref: shouldDecodeNewlinesForHref,
- delimiters: options.delimiters,
- comments: options.comments
- }, this);
- var render = ref.render;
- var staticRenderFns = ref.staticRenderFns;
- options.render = render;
- options.staticRenderFns = staticRenderFns;
-
- /* istanbul ignore if */
- if (config.performance && mark) {
- mark('compile end');
- measure(("vue " + (this._name) + " compile"), 'compile', 'compile end');
- }
- }
- }
- return mount.call(this, el, hydrating)
- };
-
- /**
- * Get outerHTML of elements, taking care
- * of SVG elements in IE as well.
- */
- function getOuterHTML (el) {
- if (el.outerHTML) {
- return el.outerHTML
- } else {
- var container = document.createElement('div');
- container.appendChild(el.cloneNode(true));
- return container.innerHTML
- }
- }
-
- Vue.compile = compileToFunctions;
-
- return Vue;
-
-}));
diff --git a/locale/zh-CN.json b/locale/zh-CN.json
new file mode 100644
index 0000000..e921bd4
--- /dev/null
+++ b/locale/zh-CN.json
@@ -0,0 +1,3 @@
+{
+ "Upgrading Core": "正在更新内核"
+}
\ No newline at end of file
diff --git a/main.js b/main.js
index 58743d8..b055b2d 100644
--- a/main.js
+++ b/main.js
@@ -1,27 +1,34 @@
// Modules to control application life and create native browser window
-const {app, BrowserWindow, screen} = require('electron')
+const os = require('os');
+const { app, BrowserWindow, screen } = require('electron')
const path = require('path')
-
-function createWindow () {
- // Create the browser window.
- let size = screen.getPrimaryDisplay().workAreaSize
- let width=parseInt(size.width * 0.7);
- let height=parseInt(size.height*0.9);
- const mainWindow = new BrowserWindow({
- width: width,
- height: height,
- webPreferences: {
- preload: path.join(__dirname, 'preload.js')
- },
- transparent: true,
- frame: false
- })
- mainWindow.webContents.openDevTools();
- //mainWindow.setSkipTaskbar(true);
- // and load the index.html of the app.
- mainWindow.loadFile('index.html')
- // Open the DevTools.
- // mainWindow.webContents.openDevTools()
+if (os.type() != 'Windows_NT') {
+ //Only support windows this version
+ app.exit();
+}
+function createWindow() {
+ global.sharedObject = {
+ language: app.getLocale()
+ }
+ // Create the browser window.
+ let size = screen.getPrimaryDisplay().workAreaSize
+ let width = parseInt(size.width * 0.5);
+ let height = parseInt(size.height * 0.6);
+ const mainWindow = new BrowserWindow({
+ width: width,
+ height: height,
+ webPreferences: {
+ preload: path.join(__dirname, 'preload.js')
+ },
+ transparent: true,
+ frame: false
+ })
+ mainWindow.webContents.openDevTools();
+ //mainWindow.setSkipTaskbar(true);
+ // and load the index.html of the app.
+ mainWindow.loadFile('index.html')
+ // Open the DevTools.
+ // mainWindow.webContents.openDevTools()
}
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
@@ -30,15 +37,15 @@ app.on('ready', createWindow)
// Quit when all windows are closed.
app.on('window-all-closed', function () {
- // On macOS it is common for applications and their menu bar
- // to stay active until the user quits explicitly with Cmd + Q
- if (process.platform !== 'darwin') app.quit()
+ // On macOS it is common for applications and their menu bar
+ // to stay active until the user quits explicitly with Cmd + Q
+ if (process.platform !== 'darwin') app.quit()
})
app.on('activate', function () {
- // On macOS it's common to re-create a window in the app when the
- // dock icon is clicked and there are no other windows open.
- if (BrowserWindow.getAllWindows().length === 0) createWindow()
+ // On macOS it's common to re-create a window in the app when the
+ // dock icon is clicked and there are no other windows open.
+ if (BrowserWindow.getAllWindows().length === 0) createWindow()
})
// In this file you can include the rest of your app's specific main process
diff --git a/node/core.js b/node/core.js
new file mode 100644
index 0000000..66e1825
--- /dev/null
+++ b/node/core.js
@@ -0,0 +1,83 @@
+var fs = require("fs");
+var tool = require("./tool")
+var execSync = require("child_process").execSync;
+var compressing = require("compressing");
+var fs = require("fs");
+var path = require("path");
+var translater = require("./translater")
+var S = new translater()
+
+async function installminetest(url) {
+ $("#description").text("更新minetest核心");
+ $("body").append(
+ '
'
+ );
+ await new tool.StreamDownload(
+ url,
+ "./tmp",
+ function (percentage) {
+ // 显示进度
+ $("#progressbar").attr("value", percentage);
+ }
+ );
+ $("#description").text("安装minetest核心");
+ await compressing.zip.uncompress("./tmp/" + path.basename(url), ".");
+ if (fs.existsSync(".minetest")) {
+ fs.rmdirSync(".minetest/bin");
+ fs.rmdirSync(".minetest/builtin");
+ fs.rmdirSync(".minetest/client");
+ fs.rmdirSync(".minetest/locale");
+ fs.renameSync("./tmp/" + path.basename(url, ".zip") + "/bin", ".minetest/bin");
+ fs.renameSync("./tmp/" + path.basename(url, ".zip") + "/builtin", ".minetest/builtin");
+ fs.renameSync("./tmp/" + path.basename(url, ".zip") + "/client", ".minetest/client");
+ fs.renameSync("./tmp/" + path.basename(url, ".zip") + "/locale", ".minetest/locale");
+ }
+ //fs.renameSync(path.basename(url, ".zip"), ".minetest");
+ fs.rmdirSync("./tmp/" + path.basename(url, ".zip"));
+ console.log("minetest installed");
+}
+
+async function upgrade() {
+ var cpu = tool.getCPU();
+ try {
+ var res = await tool.getsync(
+ "https://api.github.com/repos/minetest/minetest/releases/latest"
+ );
+ } catch (e) {
+ console.log("Network timeout,sikpping upgrade")
+ return;
+ }
+ if (fs.existsSync(".minetest")) {
+ //检查minetest是否安装及版本;
+ console.log("Core version:" + getMTversion());
+ if (getMTversion() != res["name"]) {
+ for (var i = 0, l = res["assets"].length; i < l; i++) {
+ if (res["assets"][i]["name"].indexOf(cpu) != -1) {
+ console.log("Upgrading to " + res["assets"][i]["name"])
+ await installminetest(res["assets"][i]["browser_download_url"]);
+ return;
+ }
+ }
+ console.log("No support new version for " + cpu)
+ } else {
+ console.log("The core is the latest version.");
+ }
+ } else {
+ for (var i = 0, l = res["assets"].length; i < l; i++) {
+ if (res["assets"][i]["name"].indexOf(cpu)) {
+ installminetest(res["assets"][i]["browser_download_url"]);
+ return;
+ }
+ }
+ console.log("No support new version for " + cpu)
+ }
+}
+
+function getMTversion() {
+ return execSync(".minetest\\bin\\minetest.exe --version", { encoding: "utf-8" }).substring(0, 14)
+}
+
+module.exports = {
+ upgrade,
+ getMTversion
+}
\ No newline at end of file
diff --git a/node/tool.js b/node/tool.js
new file mode 100644
index 0000000..b363669
--- /dev/null
+++ b/node/tool.js
@@ -0,0 +1,183 @@
+const fs = require('fs')
+var path = require("path");
+var request = require("request");
+var remote = require('electron').remote
+
+function getCPU() {
+ var agent = navigator.userAgent.toLowerCase();
+ if (agent.indexOf("win64") >= 0 || agent.indexOf("wow64") >= 0 || agent.indexOf("x64")) return "win64";
+ return "win32";
+}
+
+
+/**
+ * 允许被复制的文件后缀列表
+ * @type {string[]}
+ */
+const copyExt = ['.html', '.php']
+/**
+ * 复制一个文件夹下的文件到另一个文件夹
+ * @param src 源文件夹
+ * @param dst 目标文件夹
+ */
+const copyDir = function (src, dst) {
+ // 读取目录中的所有文件/目录
+ fs.readdir(src, function (err, paths) {
+ if (err) {
+ throw err
+ }
+ paths.forEach(function (path) {
+ const _src = src + '/' + path
+ const _dst = dst + '/' + path
+ let readable; let writable
+ fs.stat(_src, function (err, st) {
+ if (err) {
+ throw err
+ }
+ // 判断是否为文件
+ if (st.isFile()) {
+ // 创建读取流
+ readable = fs.createReadStream(_src)
+ // 创建写入流
+ writable = fs.createWriteStream(_dst)
+ // 通过管道来传输流
+ readable.pipe(writable)
+ }
+ // 如果是目录则递归调用自身
+ else if (st.isDirectory()) {
+ exists(_src, _dst, copyDir)
+ }
+ })
+ })
+ })
+}
+/**
+ * 在复制目录前需要判断该目录是否存在,
+ * 不存在需要先创建目录
+ * @param src
+ * @param dst
+ * @param callback
+ */
+const exists = function (src, dst, callback) {
+ // 如果路径存在,则返回 true,否则返回 false。
+ if (fs.existsSync(dst)) {
+ callback(src, dst)
+ } else {
+ fs.mkdir(dst, function () {
+ callback(src, dst)
+ })
+ }
+}
+function cp_r(src, dst) {
+ exists(src, dst, copyDir);
+}
+
+function StreamDownload(patchUrl, baseDir, callback) {
+ return new Promise(function (resolve, reject) {
+ let downloadCallback = callback; // 注册回调函数
+
+ const downloadFile = path.basename(patchUrl); // 下载文件名称,也可以从外部传进来
+
+ let receivedBytes = 0;
+ let totalBytes = 0;
+
+ const req = request({
+ method: "GET",
+ uri: patchUrl,
+ });
+
+ const out = fs.createWriteStream(path.join(baseDir, downloadFile));
+ req.pipe(out);
+
+ req.on("response", (data) => {
+ // 更新总文件字节大小
+ totalBytes = parseInt(data.headers["content-length"], 10);
+ });
+
+ req.on("data", (chunk) => {
+ // 更新下载的文件块字节大小
+ receivedBytes += chunk.length;
+ downloadCallback((receivedBytes * 100) / totalBytes)
+ });
+
+ req.on("end", () => {
+ resolve()
+ });
+ })
+}
+
+/*
+class StreamDownload {
+ constructor(patchUrl, baseDir, callback) {
+ this.downloadCallback = callback; // 注册回调函数
+
+ const downloadFile = path.basename(patchUrl); // 下载文件名称,也可以从外部传进来
+
+ let receivedBytes = 0;
+ let totalBytes = 0;
+
+ const req = request({
+ method: "GET",
+ uri: patchUrl,
+ });
+
+ const out = fs.createWriteStream(path.join(baseDir, downloadFile));
+ req.pipe(out);
+
+ req.on("response", (data) => {
+ // 更新总文件字节大小
+ totalBytes = parseInt(data.headers["content-length"], 10);
+ });
+
+ req.on("data", (chunk) => {
+ // 更新下载的文件块字节大小
+ receivedBytes += chunk.length;
+ this.showProgress(receivedBytes, totalBytes);
+ });
+
+ req.on("end", () => {
+ console.log("下载已完成,等待处理");
+ // TODO: 检查文件,部署文件,删除文件
+ this.downloadCallback("finished", 0);
+ });
+ }
+ showProgress(received, total) {
+ const percentage = (received * 100) / total;
+ // 用回调显示到界面上
+ this.downloadCallback("progress", (received * 100) / total);
+ }
+}
+*/
+function getsync(url) {
+ return new Promise(function (resolve, reject) {
+ request.get(
+ {
+ url: url,
+ headers: {
+ //设置请求头
+ "content-type": "application/json",
+ "user-agent": "MTArk",
+ },
+ timeout: 30000,
+ },
+ function (error, response, body) {
+ if (!error && response.statusCode == 200) {
+ resolve(JSON.parse(body));
+ } else
+ reject(error);
+ }
+ );
+ });
+}
+
+function getLanguage() {
+ return remote.getGlobal('sharedObject').language || "en";
+}
+
+module.exports = {
+ cp_r,
+ getsync,
+ StreamDownload,
+ getCPU,
+ getLanguage
+}
\ No newline at end of file
diff --git a/node/translater.js b/node/translater.js
new file mode 100644
index 0000000..849f74b
--- /dev/null
+++ b/node/translater.js
@@ -0,0 +1,12 @@
+var tool = require("./tool")
+class translator {
+ constructor() {
+ this.language = tool.getLanguage();
+ this.data = require("../locale/" + this.language + ".json");
+ }
+ get(src) {
+ return this.data[src] || src;
+ }
+}
+
+module.exports = translator;
\ No newline at end of file
diff --git a/preload.js b/preload.js
index 3e122d2..ba5e111 100644
--- a/preload.js
+++ b/preload.js
@@ -1,64 +1,18 @@
// All of the Node.js APIs are available in the preload process.
// It has the same sandbox as a Chrome extension.
-export * from './js/fsx'
-export * from './js/requestx'
-var compressing = require("compressing");
-var fs = require("fs");
-var path = require("path");
-var request = require("request");
-var execSync = require("child_process").execSync;
+var core = require("./node/core")
+//keep setImmediate alive
var _setImmediate = setImmediate;
process.once("loaded", function () {
- global.setImmediate = _setImmediate;
+ global.setImmediate = _setImmediate;
});
-function installminetest(url) {
- $("#title").text("下载minetest核心");
- $("body").append(
- '
'
- );
- StreamDownload.downloadFile(
- url,
- "./tmp",
- async function (arg, percentage) {
- if (arg === "progress") {
- // 显示进度
- $("#progressbar").attr("value", percentage);
- } else if (arg === "finished") {
- // 解压
- $("#title").text("安装minetest核心");
- await compressing.zip.uncompress("./tmp/"+path.basename(url), ".");
- fs.renameSync(path.basename(url,".zip"),".minetest");
- console.log("minetest installed");
- init();
- }
- }
- );
-}
-
-var StreamDownload = new StreamDownload();
async function init() {
- var res = await getsync(
- "https://api.github.com/repos/minetest/minetest/releases/latest"
- );
- //检查minetest安装情况
- if (fs.existsSync(".minetest")) {
- //检查minetest是否安装及版本;
- if (
- execSync(".minetest\\bin\\minetest.exe --version", {
- encoding: "utf-8",
- }).substring(0, 14) != res["name"]
- ) {
- console.log("version too low!");
- installminetest(res["assets"][1]["browser_download_url"]);
- } else {
- console.log("update done!");
- }
- } else {
- installminetest(res["assets"][1]["browser_download_url"]);
- }
+ //Upgrade Minetest
+ CreateLodingRing(20, 1, "#FFFFFF");
+ await core.upgrade();
}
window.addEventListener("load", function () {
- init();
-});
+ init();
+});
\ No newline at end of file
diff --git a/renderer.js b/renderer.js
index d3bdade..af07284 100644
--- a/renderer.js
+++ b/renderer.js
@@ -4,3 +4,70 @@
// `nodeIntegration` is turned off. Use `preload.js` to
// selectively enable features needed in the rendering
// process.
+/**
+ * @param {} size : int the rect clip width of the loding svg
+ * @param {} dotsize : int the r of a loading dot
+ * @param {} dotcolor : "#xxxxxx" the color of the dot
+ */
+CreateLodingRing = function (size, dotsize, dotcolor) {
+ //#region Create Element
+ var ring = Object();
+
+ let loadingring = document.createElementNS("http://www.w3.org/2000/svg", "svg");
+ loadingring.id = "winloding";
+ loadingring.setAttribute("viewBox", "0 0" + " " + size + " " + size);
+ loadingring.setAttribute("width", "10%")
+ loadingring.setAttribute("height", "10%")
+ loadingring.style.right = "2%";
+ loadingring.style.bottom = "2%";
+ loadingring.style.position = "absolute";
+ for (let i = 0; i < 6; i++) {
+ let dot = document.createElementNS("http://www.w3.org/2000/svg", "circle");
+ dot.style.transformOrigin = "center center";
+ dot.style.opacity = 0;
+ dot.setAttribute("class", "d" + (i + 1));
+ dot.setAttribute("fill", dotcolor);
+ dot.setAttribute("cx", size / 2);
+ dot.setAttribute("cy", dotsize + 2);
+ dot.setAttribute("r", dotsize);
+ loadingring.appendChild(dot);
+ }
+ document.body.appendChild(loadingring);
+ console.log(loadingring);
+
+ //#endregion
+ var tl = anime.timeline({
+ loop: true
+ });
+
+ for (let i = 0; i < 6; i++) {
+ let basevalue = -110 - 6 * i;
+
+ tl.add(
+ {
+ targets: "#winloding .d" + (i + 1),
+ rotate: [
+ { value: basevalue, duration: 0, easing: "cubicBezier(0.13,0.21,0.1,0.7)" },
+ { value: basevalue + 120, duration: 433, easing: "cubicBezier(0.02,0.33,0.38,0.77)" },
+ { value: basevalue + 203, duration: 767, easing: "linear" },
+ { value: basevalue + 315, duration: 417, easing: "cubicBezier(0.57,0.17,0.95,0.75)" },
+ { value: basevalue + 467, duration: 400, easing: "cubicBezier(0,0.19,0.07,0.72)" },
+ { value: basevalue + 549, duration: 766, easing: "linear" },
+ { value: basevalue + 695, duration: 434, easing: "cubicBezier(0,0,0.95,0.37)" }
+ ],
+ opacity: [
+ { value: 1, duration: 1, easing: "linear" },
+ { value: 1, duration: 3210, easing: "linear" },
+ { value: 0, duration: 10, easing: "linear" },
+ { value: 0, duration: 260, easing: "linear" }
+ ]
+ },
+ 167 * i
+ );
+ }
+
+ ring.timeline = tl;
+ ring.svgitem = loadingring;
+
+ return ring;
+}
\ No newline at end of file