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, warn ) { var res = isNative ? 'nativeOn:{' : 'on:{'; for (var name in events) { res += "\"" + name + "\":" + (genHandler(name, events[name])) + ","; } return res.slice(0, -1) + '}' } function genHandler ( name, handler ) { if (!handler) { return 'function(){}' } if (Array.isArray(handler)) { return ("[" + (handler.map(function (handler) { return genHandler(name, handler); }).join(',')) + "]") } var isMethodPath = simplePathRE.test(handler.value); var isFunctionExpression = fnExpRE.test(handler.value); if (!handler.modifiers) { if (isMethodPath || isFunctionExpression) { return handler.value } /* istanbul ignore if */ return ("function($event){" + (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)") : handler.value; /* istanbul ignore if */ return ("function($event){" + code + handlerCode + "}") } } function genKeyFilter (keys) { return ("if(!('button' in $event)&&" + (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 (process.env.NODE_ENV !== 'production' && 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 !isReservedTag(el.tag); }; this.onceId = 0; this.staticRenderFns = []; }; 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.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) { 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 = el.plain ? undefined : 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; state.staticRenderFns.push(("with(this){return " + (genElement(el, state)) + "}")); 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) { process.env.NODE_ENV !== 'production' && state.warn( "v-once can only be used inside v-for that is keyed. " ); 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 (process.env.NODE_ENV !== 'production' && 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.", 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, state.warn)) + ","; } if (el.nativeEvents) { data += (genHandlers(el.nativeEvents, true, state.warn)) + ","; } // slot target // only for non-scoped slots if (el.slotTarget && !el.slotScope) { data += "slot:" + (el.slotTarget) + ","; } // scoped slots if (el.scopedSlots) { data += (genScopedSlots(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 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.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 (process.env.NODE_ENV !== 'production' && ( el.children.length !== 1 || ast.type !== 1 )) { state.warn('Inline-template components must have exactly one child element.'); } if (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 ( slots, state ) { return ("scopedSlots:_u([" + (Object.keys(slots).map(function (key) { return genScopedSlot(key, slots[key], state) }).join(',')) + "])") } function genScopedSlot ( key, el, state ) { if (el.for && !el.forProcessed) { return genForScopedSlot(key, el, state) } var fn = "function(" + (String(el.slotScope)) + "){" + "return " + (el.tag === 'template' ? el.if ? ((el.if) + "?" + (genChildren(el, state) || 'undefined') + ":undefined") : genChildren(el, state) || 'undefined' : genElement(el, state)) + "}"; return ("{key:" + key + ",fn:" + fn + "}") } function genForScopedSlot ( key, el, state ) { var exp = el.for; var alias = el.alias; var iterator1 = el.iterator1 ? ("," + (el.iterator1)) : ''; var iterator2 = el.iterator2 ? ("," + (el.iterator2)) : ''; el.forProcessed = true; // avoid recursion return "_l((" + exp + ")," + "function(" + alias + iterator1 + iterator2 + "){" + "return " + (genScopedSlot(key, el, state)) + '})' } 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' ) { return (altGenElement || genElement)(el$1, state) } var normalizationType = checkSkip ? getNormalizationType(children, state.maybeComponent) : 0; var gen = altGenNode || genNode; return ("[" + (children.map(function (c) { return gen(c, state); }).join(',')) + "]" + (normalizationType ? ("," + normalizationType) : '')) } } // 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) } 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.attrs.map(function (a) { return ((camelize(a.name)) + ":" + (a.value)); }).join(',')) + "}"); 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 res = ''; for (var i = 0; i < props.length; i++) { var prop = props[i]; /* istanbul ignore if */ { res += "\"" + (prop.name) + "\":" + (transformSpecialNewlines(prop.value)) + ","; } } return res.slice(0, -1) } // #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) { var errors = []; if (ast) { checkNode(ast, errors); } return errors } function checkNode (node, errors) { if (node.type === 1) { for (var name in node.attrsMap) { if (dirRE.test(name)) { var value = node.attrsMap[name]; if (value) { if (name === 'v-for') { checkFor(node, ("v-for=\"" + value + "\""), errors); } else if (onRE.test(name)) { checkEvent(value, (name + "=\"" + value + "\""), errors); } else { checkExpression(value, (name + "=\"" + value + "\""), errors); } } } } if (node.children) { for (var i = 0; i < node.children.length; i++) { checkNode(node.children[i], errors); } } } else if (node.type === 2) { checkExpression(node.expression, node.text, errors); } } function checkEvent (exp, text, errors) { var stipped = exp.replace(stripStringRE, ''); var keywordMatch = stipped.match(unaryOperatorsRE); if (keywordMatch && stipped.charAt(keywordMatch.index - 1) !== '$') { errors.push( "avoid using JavaScript unary operator as property name: " + "\"" + (keywordMatch[0]) + "\" in expression " + (text.trim()) ); } checkExpression(exp, text, errors); } function checkFor (node, text, errors) { checkExpression(node.for || '', text, errors); checkIdentifier(node.alias, 'v-for alias', text, errors); checkIdentifier(node.iterator1, 'v-for iterator', text, errors); checkIdentifier(node.iterator2, 'v-for iterator', text, errors); } function checkIdentifier ( ident, type, text, errors ) { if (typeof ident === 'string') { try { new Function(("var " + ident + "=_")); } catch (e) { errors.push(("invalid " + type + " \"" + ident + "\" in expression: " + (text.trim()))); } } } function checkExpression (exp, text, errors) { try { new Function(("return " + exp)); } catch (e) { var keywordMatch = exp.replace(stripStringRE, '').match(prohibitedKeywordRE); if (keywordMatch) { errors.push( "avoid using JavaScript keyword as property name: " + "\"" + (keywordMatch[0]) + "\"\n Raw expression: " + (text.trim()) ); } else { errors.push( "invalid expression: " + (e.message) + " in\n\n" + " " + exp + "\n\n" + " Raw expression: " + (text.trim()) + "\n" ); } } } /* */ 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 */ if (process.env.NODE_ENV !== 'production') { // 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 (process.env.NODE_ENV !== 'production') { if (compiled.errors && compiled.errors.length) { 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) { 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 (process.env.NODE_ENV !== 'production') { 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 = []; finalOptions.warn = function (msg, tip) { (tip ? tips : errors).push(msg); }; if (options) { // 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]; } } } var compiled = baseCompile(template, finalOptions); if (process.env.NODE_ENV !== 'production') { errors.push.apply(errors, detectErrors(compiled.ast)); } 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 = createCompiler(baseOptions); var compile = ref.compile; var compileToFunctions = ref.compileToFunctions; /* */ var isAttr = makeMap( 'accept,accept-charset,accesskey,action,align,alt,async,autocomplete,' + 'autofocus,autoplay,autosave,bgcolor,border,buffered,challenge,charset,' + 'checked,cite,class,code,codebase,color,cols,colspan,content,http-equiv,' + 'name,contenteditable,contextmenu,controls,coords,data,datetime,default,' + 'defer,dir,dirname,disabled,download,draggable,dropzone,enctype,method,for,' + 'form,formaction,headers,height,hidden,high,href,hreflang,http-equiv,' + 'icon,id,ismap,itemprop,keytype,kind,label,lang,language,list,loop,low,' + 'manifest,max,maxlength,media,method,GET,POST,min,multiple,email,file,' + 'muted,name,novalidate,open,optimum,pattern,ping,placeholder,poster,' + 'preload,radiogroup,readonly,rel,required,reversed,rows,rowspan,sandbox,' + 'scope,scoped,seamless,selected,shape,size,type,text,password,sizes,span,' + 'spellcheck,src,srcdoc,srclang,srcset,start,step,style,summary,tabindex,' + 'target,title,type,usemap,value,width,wrap' ); /* istanbul ignore next */ var isRenderableAttr = function (name) { return ( isAttr(name) || name.indexOf('data-') === 0 || name.indexOf('aria-') === 0 ) }; var propsToAttrMap = { acceptCharset: 'accept-charset', className: 'class', htmlFor: 'for', httpEquiv: 'http-equiv' }; var ESC = { '<': '&lt;', '>': '&gt;', '"': '&quot;', '&': '&amp;' }; function escape (s) { return s.replace(/[<>"&]/g, escapeChar) } function escapeChar (a) { return ESC[a] || a } /* */ var plainStringRE = /^"(?:[^"\\]|\\.)*"$|^'(?:[^'\\]|\\.)*'$/; // let the model AST transform translate v-model into appropriate // props bindings function applyModelTransform (el, state) { if (el.directives) { for (var i = 0; i < el.directives.length; i++) { var dir = el.directives[i]; if (dir.name === 'model') { state.directives.model(el, dir, state.warn); // remove value for textarea as its converted to text if (el.tag === 'textarea' && el.props) { el.props = el.props.filter(function (p) { return p.name !== 'value'; }); } break } } } } function genAttrSegments ( attrs ) { return attrs.map(function (ref) { var name = ref.name; var value = ref.value; return genAttrSegment(name, value); }) } function genDOMPropSegments ( props, attrs ) { var segments = []; props.forEach(function (ref) { var name = ref.name; var value = ref.value; name = propsToAttrMap[name] || name.toLowerCase(); if (isRenderableAttr(name) && !(attrs && attrs.some(function (a) { return a.name === name; })) ) { segments.push(genAttrSegment(name, value)); } }); return segments } function genAttrSegment (name, value) { if (plainStringRE.test(value)) { // force double quote value = value.replace(/^'|'$/g, '"'); // force enumerated attr to "true" if (isEnumeratedAttr(name) && value !== "\"false\"") { value = "\"true\""; } return { type: RAW, value: isBooleanAttr(name) ? (" " + name + "=\"" + name + "\"") : value === '""' ? (" " + name) : (" " + name + "=\"" + (JSON.parse(value)) + "\"") } } else { return { type: EXPRESSION, value: ("_ssrAttr(" + (JSON.stringify(name)) + "," + value + ")") } } } function genClassSegments ( staticClass, classBinding ) { if (staticClass && !classBinding) { return [{ type: RAW, value: (" class=" + staticClass) }] } else { return [{ type: EXPRESSION, value: ("_ssrClass(" + (staticClass || 'null') + "," + (classBinding || 'null') + ")") }] } } function genStyleSegments ( staticStyle, parsedStaticStyle, styleBinding, vShowExpression ) { if (staticStyle && !styleBinding && !vShowExpression) { return [{ type: RAW, value: (" style=" + (JSON.stringify(staticStyle))) }] } else { return [{ type: EXPRESSION, value: ("_ssrStyle(" + (parsedStaticStyle || 'null') + "," + (styleBinding || 'null') + ", " + (vShowExpression ? ("{ display: (" + vShowExpression + ") ? '' : 'none' }") : 'null') + ")") }] } } /* */ /** * In SSR, the vdom tree is generated only once and never patched, so * we can optimize most element / trees into plain string render functions. * The SSR optimizer walks the AST tree to detect optimizable elements and trees. * * The criteria for SSR optimizability is quite a bit looser than static tree * detection (which is designed for client re-render). In SSR we bail only for * components/slots/custom directives. */ // optimizability constants var optimizability = { FALSE: 0, // whole sub tree un-optimizable FULL: 1, // whole sub tree optimizable SELF: 2, // self optimizable but has some un-optimizable children CHILDREN: 3, // self un-optimizable but have fully optimizable children PARTIAL: 4 // self un-optimizable with some un-optimizable children }; var isPlatformReservedTag$1; function optimize$1 (root, options) { if (!root) { return } isPlatformReservedTag$1 = options.isReservedTag || no; walk(root, true); } function walk (node, isRoot) { if (isUnOptimizableTree(node)) { node.ssrOptimizability = optimizability.FALSE; return } // root node or nodes with custom directives should always be a VNode var selfUnoptimizable = isRoot || hasCustomDirective(node); var check = function (child) { if (child.ssrOptimizability !== optimizability.FULL) { node.ssrOptimizability = selfUnoptimizable ? optimizability.PARTIAL : optimizability.SELF; } }; if (selfUnoptimizable) { node.ssrOptimizability = optimizability.CHILDREN; } if (node.type === 1) { for (var i = 0, l = node.children.length; i < l; i++) { var child = node.children[i]; walk(child); check(child); } 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; walk(block, isRoot); check(block); } } if (node.ssrOptimizability == null || (!isRoot && (node.attrsMap['v-html'] || node.attrsMap['v-text'])) ) { node.ssrOptimizability = optimizability.FULL; } else { node.children = optimizeSiblings(node); } } else { node.ssrOptimizability = optimizability.FULL; } } function optimizeSiblings (el) { var children = el.children; var optimizedChildren = []; var currentOptimizableGroup = []; var pushGroup = function () { if (currentOptimizableGroup.length) { optimizedChildren.push({ type: 1, parent: el, tag: 'template', attrsList: [], attrsMap: {}, children: currentOptimizableGroup, ssrOptimizability: optimizability.FULL }); } currentOptimizableGroup = []; }; for (var i = 0; i < children.length; i++) { var c = children[i]; if (c.ssrOptimizability === optimizability.FULL) { currentOptimizableGroup.push(c); } else { // wrap fully-optimizable adjacent siblings inside a template tag // so that they can be optimized into a single ssrNode by codegen pushGroup(); optimizedChildren.push(c); } } pushGroup(); return optimizedChildren } function isUnOptimizableTree (node) { if (node.type === 2 || node.type === 3) { // text or expression return false } return ( isBuiltInTag(node.tag) || // built-in (slot, component) !isPlatformReservedTag$1(node.tag) || // custom component !!node.component || // "is" component isSelectWithModel(node) // <select v-model> requires runtime inspection ) } var isBuiltInDir = makeMap('text,html,show,on,bind,model,pre,cloak,once'); function hasCustomDirective (node) { return ( node.type === 1 && node.directives && node.directives.some(function (d) { return !isBuiltInDir(d.name); }) ) } // <select v-model> cannot be optimized because it requires a runtime check // to determine proper selected option function isSelectWithModel (node) { return ( node.type === 1 && node.tag === 'select' && node.directives != null && node.directives.some(function (d) { return d.name === 'model'; }) ) } /* */ // The SSR codegen is essentially extending the default codegen to handle // SSR-optimizable nodes and turn them into string render fns. In cases where // a node is not optimizable it simply falls back to the default codegen. // segment types var RAW = 0; var INTERPOLATION = 1; var EXPRESSION = 2; function generate$1 ( ast, options ) { var state = new CodegenState(options); var code = ast ? genSSRElement(ast, state) : '_c("div")'; return { render: ("with(this){return " + code + "}"), staticRenderFns: state.staticRenderFns } } function genSSRElement (el, state) { if (el.for && !el.forProcessed) { return genFor(el, state, genSSRElement) } else if (el.if && !el.ifProcessed) { return genIf(el, state, genSSRElement) } else if (el.tag === 'template' && !el.slotTarget) { return el.ssrOptimizability === optimizability.FULL ? genChildrenAsStringNode(el, state) : genSSRChildren(el, state) || 'void 0' } switch (el.ssrOptimizability) { case optimizability.FULL: // stringify whole tree return genStringElement(el, state) case optimizability.SELF: // stringify self and check children return genStringElementWithChildren(el, state) case optimizability.CHILDREN: // generate self as VNode and stringify children return genNormalElement(el, state, true) case optimizability.PARTIAL: // generate self as VNode and check children return genNormalElement(el, state, false) default: // bail whole tree return genElement(el, state) } } function genNormalElement (el, state, stringifyChildren) { var data = el.plain ? undefined : genData$2(el, state); var children = stringifyChildren ? ("[" + (genChildrenAsStringNode(el, state)) + "]") : genSSRChildren(el, state, true); return ("_c('" + (el.tag) + "'" + (data ? ("," + data) : '') + (children ? ("," + children) : '') + ")") } function genSSRChildren (el, state, checkSkip) { return genChildren(el, state, checkSkip, genSSRElement, genSSRNode) } function genSSRNode (el, state) { return el.type === 1 ? genSSRElement(el, state) : genText(el) } function genChildrenAsStringNode (el, state) { return el.children.length ? ("_ssrNode(" + (flattenSegments(childrenToSegments(el, state))) + ")") : '' } function genStringElement (el, state) { return ("_ssrNode(" + (elementToString(el, state)) + ")") } function genStringElementWithChildren (el, state) { var children = genSSRChildren(el, state, true); return ("_ssrNode(" + (flattenSegments(elementToOpenTagSegments(el, state))) + ",\"</" + (el.tag) + ">\"" + (children ? ("," + children) : '') + ")") } function elementToString (el, state) { return ("(" + (flattenSegments(elementToSegments(el, state))) + ")") } function elementToSegments (el, state) { // v-for / v-if if (el.for && !el.forProcessed) { el.forProcessed = true; return [{ type: EXPRESSION, value: genFor(el, state, elementToString, '_ssrList') }] } else if (el.if && !el.ifProcessed) { el.ifProcessed = true; return [{ type: EXPRESSION, value: genIf(el, state, elementToString, '"<!---->"') }] } else if (el.tag === 'template') { return childrenToSegments(el, state) } var openSegments = elementToOpenTagSegments(el, state); var childrenSegments = childrenToSegments(el, state); var ref = state.options; var isUnaryTag = ref.isUnaryTag; var close = (isUnaryTag && isUnaryTag(el.tag)) ? [] : [{ type: RAW, value: ("</" + (el.tag) + ">") }]; return openSegments.concat(childrenSegments, close) } function elementToOpenTagSegments (el, state) { applyModelTransform(el, state); var binding; var segments = [{ type: RAW, value: ("<" + (el.tag)) }]; // attrs if (el.attrs) { segments.push.apply(segments, genAttrSegments(el.attrs)); } // domProps if (el.props) { segments.push.apply(segments, genDOMPropSegments(el.props, el.attrs)); } // v-bind="object" if ((binding = el.attrsMap['v-bind'])) { segments.push({ type: EXPRESSION, value: ("_ssrAttrs(" + binding + ")") }); } // v-bind.prop="object" if ((binding = el.attrsMap['v-bind.prop'])) { segments.push({ type: EXPRESSION, value: ("_ssrDOMProps(" + binding + ")") }); } // class if (el.staticClass || el.classBinding) { segments.push.apply( segments, genClassSegments(el.staticClass, el.classBinding) ); } // style & v-show if (el.staticStyle || el.styleBinding || el.attrsMap['v-show']) { segments.push.apply( segments, genStyleSegments( el.attrsMap.style, el.staticStyle, el.styleBinding, el.attrsMap['v-show'] ) ); } // _scopedId if (state.options.scopeId) { segments.push({ type: RAW, value: (" " + (state.options.scopeId)) }); } segments.push({ type: RAW, value: ">" }); return segments } function childrenToSegments (el, state) { var binding; if ((binding = el.attrsMap['v-html'])) { return [{ type: EXPRESSION, value: ("_s(" + binding + ")") }] } if ((binding = el.attrsMap['v-text'])) { return [{ type: INTERPOLATION, value: ("_s(" + binding + ")") }] } if (el.tag === 'textarea' && (binding = el.attrsMap['v-model'])) { return [{ type: INTERPOLATION, value: ("_s(" + binding + ")") }] } return el.children ? nodesToSegments(el.children, state) : [] } function nodesToSegments ( children, state ) { var segments = []; for (var i = 0; i < children.length; i++) { var c = children[i]; if (c.type === 1) { segments.push.apply(segments, elementToSegments(c, state)); } else if (c.type === 2) { segments.push({ type: INTERPOLATION, value: c.expression }); } else if (c.type === 3) { segments.push({ type: RAW, value: escape(c.text) }); } } return segments } function flattenSegments (segments) { var mergedSegments = []; var textBuffer = ''; var pushBuffer = function () { if (textBuffer) { mergedSegments.push(JSON.stringify(textBuffer)); textBuffer = ''; } }; for (var i = 0; i < segments.length; i++) { var s = segments[i]; if (s.type === RAW) { textBuffer += s.value; } else if (s.type === INTERPOLATION) { pushBuffer(); mergedSegments.push(("_ssrEscape(" + (s.value) + ")")); } else if (s.type === EXPRESSION) { pushBuffer(); mergedSegments.push(("(" + (s.value) + ")")); } } pushBuffer(); return mergedSegments.join('+') } /* */ var createCompiler$1 = createCompilerCreator(function baseCompile ( template, options ) { var ast = parse(template.trim(), options); optimize$1(ast, options); var code = generate$1(ast, options); return { ast: ast, render: code.render, staticRenderFns: code.staticRenderFns } }); /* */ var ref$1 = createCompiler$1(baseOptions); var compile$1 = ref$1.compile; var compileToFunctions$1 = ref$1.compileToFunctions; /* */ exports.parseComponent = parseComponent; exports.compile = compile; exports.compileToFunctions = compileToFunctions; exports.ssrCompile = compile$1; exports.ssrCompileToFunctions = compileToFunctions$1; kodo - Gogs: Go Git Service

Нет описания

rsalg.py 1016B

    # -*- coding: utf-8 -*- import base64 import rsa from CodeConvert import CodeConvert as cc pubkey = rsa.PublicKey(7733936986002684982484845608354489436048239676995253266549456282870195715569430535348099548536388503919509506510435040149560886821029985877148893951171111, 65537) privkey = rsa.PrivateKey(7733936986002684982484845608354489436048239676995253266549456282870195715569430535348099548536388503919509506510435040149560886821029985877148893951171111, 65537, 316971401565576878144472516350155768882090601834219605321449556369521730928872332388800749109622843453327077688969025635980606763507018292148749534091473, 4517492317789178911663214752269837474466539823144998211438927363654134055916886851, 1711997816918835594017245862832442114582648667392542139046338517030653261) def rsa_encrypt(plaintext): return base64.urlsafe_b64encode(rsa.encrypt(cc.Convert2Utf8(plaintext), pubkey)) def rsa_decrypt(ciphertext): return rsa.decrypt(base64.urlsafe_b64decode(cc.Convert2Utf8(ciphertext)), privkey)