.',
+ list[i]
);
}
}
- addAttr(el, name, JSON.stringify(value));
+ 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');
+ addProp(el, name, 'true', list[i]);
}
}
}
@@ -46204,10 +47525,9 @@ function makeAttrsMap (attrs) {
var map = {};
for (var i = 0, l = attrs.length; i < l; i++) {
if (
- "development" !== 'production' &&
map[attrs[i].name] && !isIE && !isEdge
) {
- warn$2('duplicate attribute: ' + attrs[i].name);
+ warn$2('duplicate attribute: ' + attrs[i].name, attrs[i]);
}
map[attrs[i].name] = attrs[i].value;
}
@@ -46254,7 +47574,8 @@ function checkForAliasModel (el, 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."
+ "Consider using an array of objects and use v-model on an object property instead.",
+ el.rawAttrsMap['v-model']
);
}
_el = _el.parent;
@@ -46263,16 +47584,6 @@ function checkForAliasModel (el, value) {
/* */
-/**
- * Expand input[v-model] with dyanmic type bindings into v-if-else chains
- * Turn this:
- *
- * into this:
- *
- *
- *
- */
-
function preTransformNode (el, options) {
if (el.tag === 'input') {
var map = el.attrsMap;
@@ -46339,21 +47650,21 @@ function cloneASTElement (el) {
return createASTElement(el.tag, el.attrsList.slice(), el.parent)
}
-var model$2 = {
+var model$1 = {
preTransformNode: preTransformNode
-}
+};
var modules$1 = [
klass$1,
style$1,
- model$2
-]
+ model$1
+];
/* */
function text (el, dir) {
if (dir.value) {
- addProp(el, 'textContent', ("_s(" + (dir.value) + ")"));
+ addProp(el, 'textContent', ("_s(" + (dir.value) + ")"), dir);
}
}
@@ -46361,7 +47672,7 @@ function text (el, dir) {
function html (el, dir) {
if (dir.value) {
- addProp(el, 'innerHTML', ("_s(" + (dir.value) + ")"));
+ addProp(el, 'innerHTML', ("_s(" + (dir.value) + ")"), dir);
}
}
@@ -46369,7 +47680,7 @@ var directives$1 = {
model: model,
text: text,
html: html
-}
+};
/* */
@@ -46416,7 +47727,7 @@ function optimize (root, options) {
function genStaticKeys$1 (keys) {
return makeMap(
- 'type,tag,attrsList,attrsMap,plain,parent,children,attrs' +
+ 'type,tag,attrsList,attrsMap,plain,parent,children,attrs,start,end,rawAttrsMap' +
(keys ? ',' + keys : '')
)
}
@@ -46515,7 +47826,8 @@ function isDirectChildOfTemplateFor (node) {
/* */
-var fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function\s*\(/;
+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
@@ -46533,16 +47845,19 @@ var keyCodes = {
// KeyboardEvent.key aliases
var keyNames = {
- esc: 'Escape',
+ // #7880: IE11 and Edge use `Esc` for Escape key name.
+ esc: ['Esc', 'Escape'],
tab: 'Tab',
enter: 'Enter',
- space: ' ',
+ // #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'],
- 'delete': ['Backspace', 'Delete']
+ // #9112: IE11 uses `Del` for Delete key name.
+ 'delete': ['Backspace', 'Delete', 'Del']
};
// #4868: modifiers that prevent the execution of the listener
@@ -46565,37 +47880,45 @@ var modifierCode = {
function genHandlers (
events,
- isNative,
- warn
+ isNative
) {
- var res = isNative ? 'nativeOn:{' : 'on:{';
+ var prefix = isNative ? 'nativeOn:' : 'on:';
+ var staticHandlers = "";
+ var dynamicHandlers = "";
for (var name in events) {
- res += "\"" + name + "\":" + (genHandler(name, events[name])) + ",";
+ 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
}
- return res.slice(0, -1) + '}'
}
-function genHandler (
- name,
- handler
-) {
+function genHandler (handler) {
if (!handler) {
return 'function(){}'
}
if (Array.isArray(handler)) {
- return ("[" + (handler.map(function (handler) { return genHandler(name, handler); }).join(',')) + "]")
+ 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
}
- /* istanbul ignore if */
- return ("function($event){" + (handler.value) + "}") // inline statement
+ return ("function($event){" + (isFunctionInvocation ? ("return " + (handler.value)) : handler.value) + "}") // inline statement
} else {
var code = '';
var genModifierCode = '';
@@ -46630,14 +47953,21 @@ function genHandler (
? ("return " + (handler.value) + "($event)")
: isFunctionExpression
? ("return (" + (handler.value) + ")($event)")
- : handler.value;
- /* istanbul ignore if */
+ : isFunctionInvocation
+ ? ("return " + (handler.value))
+ : handler.value;
return ("function($event){" + code + handlerCode + "}")
}
}
function genKeyFilter (keys) {
- return ("if(!('button' in $event)&&" + (keys.map(genFilterCode).join('&&')) + ")return null;")
+ 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) {
@@ -46660,7 +47990,7 @@ function genFilterCode (key) {
/* */
function on (el, dir) {
- if ("development" !== 'production' && dir.modifiers) {
+ if (dir.modifiers) {
warn("v-on without argument does not support modifiers.");
}
el.wrapListeners = function (code) { return ("_g(" + code + "," + (dir.value) + ")"); };
@@ -46680,10 +48010,14 @@ var baseDirectives = {
on: on,
bind: bind$1,
cloak: noop
-}
+};
/* */
+
+
+
+
var CodegenState = function CodegenState (options) {
this.options = options;
this.warn = options.warn || baseWarn;
@@ -46691,9 +48025,10 @@ var CodegenState = function CodegenState (options) {
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.maybeComponent = function (el) { return !!el.component || !isReservedTag(el.tag); };
this.onceId = 0;
this.staticRenderFns = [];
+ this.pre = false;
};
@@ -46711,6 +48046,10 @@ function generate (
}
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) {
@@ -46719,7 +48058,7 @@ function genElement (el, state) {
return genFor(el, state)
} else if (el.if && !el.ifProcessed) {
return genIf(el, state)
- } else if (el.tag === 'template' && !el.slotTarget) {
+ } else if (el.tag === 'template' && !el.slotTarget && !state.pre) {
return genChildren(el, state) || 'void 0'
} else if (el.tag === 'slot') {
return genSlot(el, state)
@@ -46729,7 +48068,10 @@ function genElement (el, state) {
if (el.component) {
code = genComponent(el.component, el, state);
} else {
- var data = el.plain ? undefined : genData$2(el, state);
+ 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) : '') + ")";
@@ -46745,7 +48087,15 @@ function genElement (el, state) {
// 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' : '') + ")")
}
@@ -46765,8 +48115,9 @@ function genOnce (el, state) {
parent = parent.parent;
}
if (!key) {
- "development" !== 'production' && state.warn(
- "v-once can only be used inside v-for that is keyed. "
+ state.warn(
+ "v-once can only be used inside v-for that is keyed. ",
+ el.rawAttrsMap['v-once']
);
return genElement(el, state)
}
@@ -46824,8 +48175,7 @@ function genFor (
var iterator1 = el.iterator1 ? ("," + (el.iterator1)) : '';
var iterator2 = el.iterator2 ? ("," + (el.iterator2)) : '';
- if ("development" !== 'production' &&
- state.maybeComponent(el) &&
+ if (state.maybeComponent(el) &&
el.tag !== 'slot' &&
el.tag !== 'template' &&
!el.key
@@ -46834,6 +48184,7 @@ function genFor (
"<" + (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 */
);
}
@@ -46878,18 +48229,18 @@ function genData$2 (el, state) {
}
// attributes
if (el.attrs) {
- data += "attrs:{" + (genProps(el.attrs)) + "},";
+ data += "attrs:" + (genProps(el.attrs)) + ",";
}
// DOM props
if (el.props) {
- data += "domProps:{" + (genProps(el.props)) + "},";
+ data += "domProps:" + (genProps(el.props)) + ",";
}
// event handlers
if (el.events) {
- data += (genHandlers(el.events, false, state.warn)) + ",";
+ data += (genHandlers(el.events, false)) + ",";
}
if (el.nativeEvents) {
- data += (genHandlers(el.nativeEvents, true, state.warn)) + ",";
+ data += (genHandlers(el.nativeEvents, true)) + ",";
}
// slot target
// only for non-scoped slots
@@ -46898,7 +48249,7 @@ function genData$2 (el, state) {
}
// scoped slots
if (el.scopedSlots) {
- data += (genScopedSlots(el.scopedSlots, state)) + ",";
+ data += (genScopedSlots(el, el.scopedSlots, state)) + ",";
}
// component v-model
if (el.model) {
@@ -46912,6 +48263,12 @@ function genData$2 (el, state) {
}
}
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);
@@ -46940,7 +48297,7 @@ function genDirectives (el, state) {
}
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))) : '') + "},";
+ 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) {
@@ -46950,57 +48307,114 @@ function genDirectives (el, state) {
function genInlineTemplate (el, state) {
var ast = el.children[0];
- if ("development" !== 'production' && (
- el.children.length !== 1 || ast.type !== 1
- )) {
- state.warn('Inline-template components must have exactly one child element.');
+ if (el.children.length !== 1 || ast.type !== 1) {
+ state.warn(
+ 'Inline-template components must have exactly one child element.',
+ { start: el.start }
+ );
}
- if (ast.type === 1) {
+ 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
) {
- return ("scopedSlots:_u([" + (Object.keys(slots).map(function (key) {
- return genScopedSlot(key, slots[key], state)
- }).join(',')) + "])")
+ // 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 (
- key,
el,
state
) {
- if (el.for && !el.forProcessed) {
- return genForScopedSlot(key, el, state)
+ var isLegacySyntax = el.attrsMap['slot-scope'];
+ if (el.if && !el.ifProcessed && !isLegacySyntax) {
+ return genIf(el, state, genScopedSlot, "null")
}
- var fn = "function(" + (String(el.slotScope)) + "){" +
+ 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
- ? ((el.if) + "?" + (genChildren(el, state) || 'undefined') + ":undefined")
+ ? el.if && isLegacySyntax
+ ? ("(" + (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)) +
- '})'
+ // reverse proxy v-slot without scope on this.$slots
+ var reverseProxy = slotScope ? "" : ",proxy:true";
+ return ("{key:" + (el.slotTarget || "\"default\"") + ",fn:" + fn + reverseProxy + "}")
}
function genChildren (
@@ -47019,13 +48433,16 @@ function genChildren (
el$1.tag !== 'template' &&
el$1.tag !== 'slot'
) {
- return (altGenElement || genElement)(el$1, state)
+ var normalizationType = checkSkip
+ ? state.maybeComponent(el$1) ? ",1" : ",0"
+ : "";
+ return ("" + ((altGenElement || genElement)(el$1, state)) + normalizationType)
}
- var normalizationType = checkSkip
+ var normalizationType$1 = checkSkip
? getNormalizationType(children, state.maybeComponent)
: 0;
var gen = altGenNode || genNode;
- return ("[" + (children.map(function (c) { return gen(c, state); }).join(',')) + "]" + (normalizationType ? ("," + normalizationType) : ''))
+ return ("[" + (children.map(function (c) { return gen(c, state); }).join(',')) + "]" + (normalizationType$1 ? ("," + normalizationType$1) : ''))
}
}
@@ -47063,7 +48480,7 @@ function needsNormalization (el) {
function genNode (node, state) {
if (node.type === 1) {
return genElement(node, state)
- } if (node.type === 3 && node.isComment) {
+ } else if (node.type === 3 && node.isComment) {
return genComment(node)
} else {
return genText(node)
@@ -47084,7 +48501,14 @@ 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 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";
@@ -47109,15 +48533,23 @@ function genComponent (
}
function genProps (props) {
- var res = '';
+ var staticProps = "";
+ var dynamicProps = "";
for (var i = 0; i < props.length; i++) {
var prop = props[i];
- /* istanbul ignore if */
- {
- res += "\"" + (prop.name) + "\":" + (transformSpecialNewlines(prop.value)) + ",";
+ var value = transformSpecialNewlines(prop.value);
+ if (prop.dynamic) {
+ dynamicProps += (prop.name) + "," + value + ",";
+ } else {
+ staticProps += "\"" + (prop.name) + "\":" + value + ",";
}
}
- return res.slice(0, -1)
+ staticProps = "{" + (staticProps.slice(0, -1)) + "}";
+ if (dynamicProps) {
+ return ("_d(" + staticProps + ",[" + (dynamicProps.slice(0, -1)) + "])")
+ } else {
+ return staticProps
+ }
}
// #3895, #4268
@@ -47129,6 +48561,8 @@ function transformSpecialNewlines (text) {
/* */
+
+
// these keywords should not appear inside expressions, but operators like
// typeof, instanceof and in are allowed
var prohibitedKeywordRE = new RegExp('\\b' + (
@@ -47146,89 +48580,92 @@ var unaryOperatorsRE = new RegExp('\\b' + (
var stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
// detect problematic expressions in a template
-function detectErrors (ast) {
- var errors = [];
+function detectErrors (ast, warn) {
if (ast) {
- checkNode(ast, errors);
+ checkNode(ast, warn);
}
- return errors
}
-function checkNode (node, errors) {
+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 + "\""), errors);
+ checkFor(node, ("v-for=\"" + value + "\""), warn, range);
} else if (onRE.test(name)) {
- checkEvent(value, (name + "=\"" + value + "\""), errors);
+ checkEvent(value, (name + "=\"" + value + "\""), warn, range);
} else {
- checkExpression(value, (name + "=\"" + value + "\""), errors);
+ checkExpression(value, (name + "=\"" + value + "\""), warn, range);
}
}
}
}
if (node.children) {
for (var i = 0; i < node.children.length; i++) {
- checkNode(node.children[i], errors);
+ checkNode(node.children[i], warn);
}
}
} else if (node.type === 2) {
- checkExpression(node.expression, node.text, errors);
+ checkExpression(node.expression, node.text, warn, node);
}
}
-function checkEvent (exp, text, errors) {
+function checkEvent (exp, text, warn, range) {
var stipped = exp.replace(stripStringRE, '');
var keywordMatch = stipped.match(unaryOperatorsRE);
if (keywordMatch && stipped.charAt(keywordMatch.index - 1) !== '$') {
- errors.push(
+ warn(
"avoid using JavaScript unary operator as property name: " +
- "\"" + (keywordMatch[0]) + "\" in expression " + (text.trim())
+ "\"" + (keywordMatch[0]) + "\" in expression " + (text.trim()),
+ range
);
}
- checkExpression(exp, text, errors);
+ checkExpression(exp, text, warn, range);
}
-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 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,
- errors
+ warn,
+ range
) {
if (typeof ident === 'string') {
try {
new Function(("var " + ident + "=_"));
} catch (e) {
- errors.push(("invalid " + type + " \"" + ident + "\" in expression: " + (text.trim())));
+ warn(("invalid " + type + " \"" + ident + "\" in expression: " + (text.trim())), range);
}
}
}
-function checkExpression (exp, text, errors) {
+function checkExpression (exp, text, warn, range) {
try {
new Function(("return " + exp));
} catch (e) {
var keywordMatch = exp.replace(stripStringRE, '').match(prohibitedKeywordRE);
if (keywordMatch) {
- errors.push(
+ warn(
"avoid using JavaScript keyword as property name: " +
- "\"" + (keywordMatch[0]) + "\"\n Raw expression: " + (text.trim())
+ "\"" + (keywordMatch[0]) + "\"\n Raw expression: " + (text.trim()),
+ range
);
} else {
- errors.push(
+ warn(
"invalid expression: " + (e.message) + " in\n\n" +
" " + exp + "\n\n" +
- " Raw expression: " + (text.trim()) + "\n"
+ " Raw expression: " + (text.trim()) + "\n",
+ range
);
}
}
@@ -47236,6 +48673,62 @@ function checkExpression (exp, text, errors) {
/* */
+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)
@@ -47258,7 +48751,7 @@ function createCompileToFunctionFn (compile) {
delete options.warn;
/* istanbul ignore if */
- if (true) {
+ {
// detect possible CSP restriction
try {
new Function('return 1');
@@ -47287,16 +48780,30 @@ function createCompileToFunctionFn (compile) {
var compiled = compile(template, options);
// check compilation errors/tips
- if (true) {
+ {
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 (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) {
- compiled.tips.forEach(function (msg) { return tip(msg, vm); });
+ if (options.outputSourceRange) {
+ compiled.tips.forEach(function (e) { return tip(e.msg, vm); });
+ } else {
+ compiled.tips.forEach(function (msg) { return tip(msg, vm); });
+ }
}
}
@@ -47312,7 +48819,7 @@ function createCompileToFunctionFn (compile) {
// this should only happen if there is a bug in the compiler itself.
// mostly for codegen development use
/* istanbul ignore if */
- if (true) {
+ {
if ((!compiled.errors || !compiled.errors.length) && fnGenErrors.length) {
warn$$1(
"Failed to generate render function:\n\n" +
@@ -47342,11 +48849,29 @@ function createCompilerCreator (baseCompile) {
var finalOptions = Object.create(baseOptions);
var errors = [];
var tips = [];
- finalOptions.warn = function (msg, tip) {
+
+ 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 =
@@ -47367,9 +48892,11 @@ function createCompilerCreator (baseCompile) {
}
}
- var compiled = baseCompile(template, finalOptions);
- if (true) {
- errors.push.apply(errors, detectErrors(compiled.ast));
+ finalOptions.warn = warn;
+
+ var compiled = baseCompile(template.trim(), finalOptions);
+ {
+ detectErrors(compiled.ast, warn);
}
compiled.errors = errors;
compiled.tips = tips;
@@ -47407,6 +48934,7 @@ var createCompiler = createCompilerCreator(function baseCompile (
/* */
var ref$1 = createCompiler(baseOptions);
+var compile = ref$1.compile;
var compileToFunctions = ref$1.compileToFunctions;
/* */
@@ -47440,7 +48968,7 @@ Vue.prototype.$mount = function (
/* istanbul ignore if */
if (el === document.body || el === document.documentElement) {
- "development" !== 'production' && warn(
+ warn(
"Do not mount Vue to or - mount to normal elements instead."
);
return this
@@ -47455,7 +48983,7 @@ Vue.prototype.$mount = function (
if (template.charAt(0) === '#') {
template = idToTemplate(template);
/* istanbul ignore if */
- if ("development" !== 'production' && !template) {
+ if (!template) {
warn(
("Template element not found or is empty: " + (options.template)),
this
@@ -47465,7 +48993,7 @@ Vue.prototype.$mount = function (
} else if (template.nodeType) {
template = template.innerHTML;
} else {
- if (true) {
+ {
warn('invalid template option:' + template, this);
}
return this
@@ -47475,11 +49003,12 @@ Vue.prototype.$mount = function (
}
if (template) {
/* istanbul ignore if */
- if ("development" !== 'production' && config.performance && mark) {
+ if (config.performance && mark) {
mark('compile');
}
var ref = compileToFunctions(template, {
+ outputSourceRange: "development" !== 'production',
shouldDecodeNewlines: shouldDecodeNewlines,
shouldDecodeNewlinesForHref: shouldDecodeNewlinesForHref,
delimiters: options.delimiters,
@@ -47491,7 +49020,7 @@ Vue.prototype.$mount = function (
options.staticRenderFns = staticRenderFns;
/* istanbul ignore if */
- if ("development" !== 'production' && config.performance && mark) {
+ if (config.performance && mark) {
mark('compile end');
measure(("vue " + (this._name) + " compile"), 'compile', 'compile end');
}
@@ -47518,10 +49047,10 @@ Vue.compile = compileToFunctions;
module.exports = Vue;
-/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1), __webpack_require__(42).setImmediate))
+/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1), __webpack_require__(43).setImmediate))
/***/ }),
-/* 42 */
+/* 43 */
/***/ (function(module, exports, __webpack_require__) {
/* WEBPACK VAR INJECTION */(function(global) {var scope = (typeof global !== "undefined" && global) ||
@@ -47577,7 +49106,7 @@ exports._unrefActive = exports.active = function(item) {
};
// setimmediate attaches itself to the global object
-__webpack_require__(43);
+__webpack_require__(44);
// On some exotic environments, it's not clear which object `setimmediate` was
// able to install onto. Search each possibility in the same order as the
// `setimmediate` library.
@@ -47591,7 +49120,7 @@ exports.clearImmediate = (typeof self !== "undefined" && self.clearImmediate) ||
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1)))
/***/ }),
-/* 43 */
+/* 44 */
/***/ (function(module, exports, __webpack_require__) {
/* WEBPACK VAR INJECTION */(function(global, process) {(function (global, undefined) {
@@ -47784,7 +49313,7 @@ exports.clearImmediate = (typeof self !== "undefined" && self.clearImmediate) ||
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1), __webpack_require__(6)))
/***/ }),
-/* 44 */
+/* 45 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
@@ -50409,15 +51938,15 @@ if (inBrowser && window.Vue) {
/***/ }),
-/* 45 */
+/* 46 */
/***/ (function(module, exports, __webpack_require__) {
var disposed = false
-var normalizeComponent = __webpack_require__(46)
+var normalizeComponent = __webpack_require__(47)
/* script */
-var __vue_script__ = __webpack_require__(47)
+var __vue_script__ = __webpack_require__(48)
/* template */
-var __vue_template__ = __webpack_require__(48)
+var __vue_template__ = __webpack_require__(49)
/* template functional */
var __vue_template_functional__ = false
/* styles */
@@ -50456,7 +51985,7 @@ module.exports = Component.exports
/***/ }),
-/* 46 */
+/* 47 */
/***/ (function(module, exports) {
/* globals __VUE_SSR_CONTEXT__ */
@@ -50565,12 +52094,40 @@ module.exports = function normalizeComponent (
/***/ }),
-/* 47 */
+/* 48 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
-/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_vue_trading_view__ = __webpack_require__(51);
+/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_vue_trading_view__ = __webpack_require__(52);
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
//
//
//
@@ -50722,6 +52279,16 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
console.log('Error: ', e.response.data);
});
},
+ fetchBalance: function fetchBalance() {
+ var _this2 = this;
+
+ axios.get('/api/3commas/getbalance').then(function (response) {
+ _this2.balance = response.data, _this2.balance_btc_amount = _this2.balance[0].btc_amount, _this2.day_profit_btc = _this2.balance[0].day_profit_btc, _this2.day_profit_btc_percentage = _this2.balance[0].day_profit_btc_percentage, _this2.btc_to_trade = _this2.balance[0].available_for_trading.BTC, _this2.balance_usd_amount = _this2.balance[0].usd_amount, _this2.day_profit_usd = _this2.balance[0].day_profit_usd, _this2.day_profit_usd_percentage = _this2.balance[0].day_profit_usd_percentage, _this2.usd_to_trade = _this2.balance[0].available_for_trading.USDT;
+ // console.log(this.balance[0].available_for_trading.BTC)
+ }).catch(function (e) {
+ console.log('Error: ', e.response.data);
+ });
+ },
formatPrice: function formatPrice(num) {
if (/\d+\.?\d*e[\+\-]*\d+/i.test(num)) {
var zero = '0',
@@ -50745,19 +52312,21 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
return num;
},
financial: function financial(x) {
- return Number.parseFloat(x).toFixed(8);
+ var y = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 8;
+
+ return Number.parseFloat(x).toFixed(y);
}
},
computed: {
sortedTrades: function sortedTrades() {
- var _this2 = this;
+ var _this3 = this;
return [].slice.call(this.trades).sort(function (a, b) {
var modifier = 1;
- if (_this2.currentSortDir === 'desc') modifier = -1;
- if (a[_this2.currentSort] < b[_this2.currentSort]) return -1 * modifier;
- if (a[_this2.currentSort] > b[_this2.currentSort]) return 1 * modifier;
+ if (_this3.currentSortDir === 'desc') modifier = -1;
+ if (a[_this3.currentSort] < b[_this3.currentSort]) return -1 * modifier;
+ if (a[_this3.currentSort] > b[_this3.currentSort]) return 1 * modifier;
return 0;
});
},
@@ -50768,17 +52337,21 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
},
created: function created() {
- var _this3 = this;
+ var _this4 = this;
this.fetchTrades();
+ this.fetchBalance();
setInterval(function () {
- return _this3.fetchTrades();
+ return _this4.fetchBalance();
+ }, 10000);
+ setInterval(function () {
+ return _this4.fetchTrades();
}, 10000);
}
});
/***/ }),
-/* 48 */
+/* 49 */
/***/ (function(module, exports, __webpack_require__) {
var render = function() {
@@ -50798,7 +52371,7 @@ var render = function() {
_c(
"div",
{
- staticClass: "column is-11 tv-top-column",
+ staticClass: "column is-9 tv-top-column",
class: { expand: _vm.tvTopContainerExpand }
},
[
@@ -50836,6 +52409,88 @@ var render = function() {
on: { click: _vm.expandTvTopContainer }
})
])
+ ]),
+ _vm._v(" "),
+ _c("div", { staticClass: "column is-2" }, [
+ _vm._v(
+ "\n 24 Hour Stats\n "
+ ),
+ _c("div", { staticClass: "columns" }, [
+ _vm._m(1),
+ _vm._v(" "),
+ _c(
+ "div",
+ { staticClass: "column is-three-quarters" },
+ [
+ _c(
+ "big",
+ {
+ staticClass: "text-primary",
+ staticStyle: {
+ "font-weight": "600",
+ "font-size": "2.5rem"
+ }
+ },
+ [_vm._v(_vm._s(_vm.financial(_vm.balance_btc_amount, 3)))]
+ ),
+ _c("br"),
+ _vm._v(" "),
+ _c(
+ "span",
+ {
+ class: {
+ "text-error": _vm.day_profit_btc < 0,
+ "text-success": _vm.day_profit_btc > 0
+ }
+ },
+ [_vm._v(_vm._s(_vm.financial(_vm.day_profit_btc, 6)))]
+ ),
+ _vm._v(" "),
+ _c("span", [
+ _vm._v(_vm._s(_vm.day_profit_btc_percentage) + "%")
+ ]),
+ _c("br"),
+ _vm._v("\n AVAIL: "),
+ _c("span", { staticClass: "text-secondary" }, [
+ _vm._v(_vm._s(_vm.btc_to_trade))
+ ]),
+ _vm._v(" "),
+ _c("br"),
+ _c("br"),
+ _vm._v(" "),
+ _c(
+ "big",
+ {
+ staticClass: "text-primary",
+ staticStyle: { "font-weight": "600" }
+ },
+ [_vm._v(_vm._s(_vm.financial(_vm.balance_usd_amount, 2)))]
+ ),
+ _c("br"),
+ _vm._v(" "),
+ _c(
+ "span",
+ {
+ class: {
+ "text-error": _vm.day_profit_usd < 0,
+ "text-success": _vm.day_profit_usd > 0
+ }
+ },
+ [_vm._v(_vm._s(_vm.financial(_vm.day_profit_usd, 2)))]
+ ),
+ _vm._v(" "),
+ _c("span", [
+ _vm._v(_vm._s(_vm.day_profit_usd_percentage) + "%")
+ ]),
+ _c("br"),
+ _vm._v("\n AVAIL: "),
+ _c("span", { staticClass: "text-secondary" }, [
+ _vm._v(_vm._s(_vm.financial(_vm.usd_to_trade, 2)))
+ ])
+ ],
+ 1
+ )
+ ])
])
])
])
@@ -50858,7 +52513,7 @@ var render = function() {
1
),
_vm._v(" "),
- _vm._m(1)
+ _vm._m(2)
])
]),
_vm._v(" "),
@@ -50907,7 +52562,7 @@ var render = function() {
_vm._v(" "),
_c("span", [
_vm._v(
- "\n Profit %\n "
+ "\n Profit %\n "
)
])
]
@@ -50919,7 +52574,7 @@ var render = function() {
staticClass: "button is-dark",
on: {
click: function($event) {
- _vm.sort("id")
+ return _vm.sort("id")
}
}
},
@@ -50932,7 +52587,7 @@ var render = function() {
staticClass: "button is-dark",
on: {
click: function($event) {
- _vm.sort("to_currency_code")
+ return _vm.sort("to_currency_code")
}
}
},
@@ -51026,7 +52681,8 @@ var render = function() {
])
]
)
- })
+ }),
+ 0
)
])
])
@@ -51041,6 +52697,19 @@ var staticRenderFns = [
_c("i", { staticClass: "mdi mdi-24px mdi-arrow-expand-all" })
])
},
+ function() {
+ var _vm = this
+ var _h = _vm.$createElement
+ var _c = _vm._self._c || _h
+ return _c("div", { staticClass: "column is-one-quarter" }, [
+ _c("img", {
+ attrs: {
+ src: "/images/cryptocurrency-icons/svg/color/btc.svg",
+ alt: ""
+ }
+ })
+ ])
+ },
function() {
var _vm = this
var _h = _vm.$createElement
@@ -51064,14 +52733,14 @@ if (false) {
}
/***/ }),
-/* 49 */
+/* 50 */
/***/ (function(module, exports) {
// removed by extract-text-webpack-plugin
/***/ }),
-/* 50 */,
-/* 51 */
+/* 51 */,
+/* 52 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
diff --git a/resources/js/components/Trades3commasComponent.vue b/resources/js/components/Trades3commasComponent.vue
index 4f1a1d6..7b2687a 100644
--- a/resources/js/components/Trades3commasComponent.vue
+++ b/resources/js/components/Trades3commasComponent.vue
@@ -3,15 +3,15 @@
-
+
+ symbol: 'BINANCE:BTCUSDT',
+ theme: 'dark',
+ allow_symbol_change: true,
+ autosize: true,
+ interval: 60,
+ hide_side_toolbar: false,
+ }" />
@@ -24,6 +24,31 @@
+
+ 24 Hour Stats
+
+
+
+

+
+
+ {{financial(balance_btc_amount, 3)}}
+ {{financial(day_profit_btc, 6)}}
+ {{day_profit_btc_percentage}}%
+ AVAIL: {{btc_to_trade}}
+
+ {{financial(balance_usd_amount, 2)}}
+ {{financial(day_profit_usd, 2)}}
+ {{day_profit_usd_percentage}}%
+ AVAIL: {{financial(usd_to_trade, 2)}}
+
+
+
+
@@ -53,12 +78,13 @@
@@ -76,12 +102,14 @@
-
![]()
+
{{ trade.to_currency_code }}
- {{trade.profit_percentage}}%
+ {{trade.profit_percentage}}%
@@ -151,6 +179,25 @@
})
},
+ fetchBalance() {
+ axios.get('/api/3commas/getbalance')
+ .then(response => {
+ this.balance = response.data,
+ this.balance_btc_amount = this.balance[0].btc_amount,
+ this.day_profit_btc = this.balance[0].day_profit_btc,
+ this.day_profit_btc_percentage = this.balance[0].day_profit_btc_percentage,
+ this.btc_to_trade = this.balance[0].available_for_trading.BTC,
+ this.balance_usd_amount = this.balance[0].usd_amount,
+ this.day_profit_usd = this.balance[0].day_profit_usd,
+ this.day_profit_usd_percentage = this.balance[0].day_profit_usd_percentage,
+ this.usd_to_trade = this.balance[0].available_for_trading.USDT
+ // console.log(this.balance[0].available_for_trading.BTC)
+ })
+ .catch(e => {
+ console.log('Error: ', e.response.data)
+ })
+ },
+
formatPrice(num) {
if (/\d+\.?\d*e[\+\-]*\d+/i.test(num)) {
var zero = '0',
@@ -171,8 +218,8 @@
return num;
},
- financial(x) {
- return Number.parseFloat(x).toFixed(8);
+ financial(x, y = 8) {
+ return Number.parseFloat(x).toFixed(y);
}
},
@@ -195,6 +242,8 @@
created() {
this.fetchTrades();
+ this.fetchBalance();
+ setInterval(() => this.fetchBalance(), 10000);
setInterval(() => this.fetchTrades(), 10000);
}
diff --git a/routes/api.php b/routes/api.php
index aadaba0..8518cd6 100644
--- a/routes/api.php
+++ b/routes/api.php
@@ -18,4 +18,5 @@ Route::middleware('auth:api')->get('/user', function (Request $request) {
});
Route::get('3commas/gettrades', 'ThreeCommasController@getTrades');
+Route::get('3commas/getbalance', 'ThreeCommasController@getBalance');
Route::get('getsignals', 'ThreeCommasController@getSignals');