Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@tko/utils.parser

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tko/utils.parser - npm Package Compare versions

Comparing version
4.0.0-alpha9.0
to
4.0.0-beta1.0
+18
dist/Arguments.js
// @tko/utils.parser 🥊 4.0.0-beta1.0 ESM
import Node from "./Node";
export default class Arguments {
constructor(parser, args) {
this.parser = parser;
this.args = args;
}
get_value(parent, context, globals, node) {
var deReffedArgs = [];
for (var i = 0, j = this.args.length; i < j; ++i) {
deReffedArgs.push(Node.value_of(this.args[i], context, globals, node));
}
return deReffedArgs;
}
get [Node.isExpressionOrIdentifierSymbol]() {
return true;
}
}
{
"version": 3,
"sources": ["../src/Arguments.ts"],
"sourcesContent": ["\nimport Node from './Node'\n\nexport default class Arguments {\n constructor (parser, args) {\n this.parser = parser\n this.args = args\n }\n\n get_value (parent, context, globals, node) {\n var deReffedArgs = []\n for (var i = 0, j = this.args.length; i < j; ++i) {\n deReffedArgs.push(Node.value_of(this.args[i], context, globals, node))\n }\n return deReffedArgs\n };\n\n get [Node.isExpressionOrIdentifierSymbol] () { return true }\n}\n"],
"mappings": ";AACA;AAEA,qBAAqB,UAAU;AAAA,EAC7B,YAAa,QAAQ,MAAM;AACzB,SAAK,SAAS;AACd,SAAK,OAAO;AAAA,EACd;AAAA,EAEA,UAAW,QAAQ,SAAS,SAAS,MAAM;AACzC,QAAI,eAAe,CAAC;AACpB,aAAS,IAAI,GAAG,IAAI,KAAK,KAAK,QAAQ,IAAI,GAAG,EAAE,GAAG;AAChD,mBAAa,KAAK,KAAK,SAAS,KAAK,KAAK,IAAI,SAAS,SAAS,IAAI,CAAC;AAAA,IACvE;AACA,WAAO;AAAA,EACT;AAAA,OAEK,KAAK,kCAAmC;AAAE,WAAO;AAAA,EAAK;AAC7D;",
"names": []
}
// @tko/utils.parser 🥊 4.0.0-beta1.0 ESM
import Node from "./Node";
export default class Expression {
constructor(nodes) {
this.nodes = nodes;
this.root = Node.create_root(nodes);
}
get_value(parent, context, globals, node) {
if (!this.root) {
this.root = Node.create_root(this.nodes);
}
return this.root.get_value(parent, context, globals, node);
}
}
Expression.prototype[Node.isExpressionOrIdentifierSymbol] = true;
{
"version": 3,
"sources": ["../src/Expression.ts"],
"sourcesContent": ["\nimport Node from './Node'\n\nexport default class Expression {\n constructor (nodes) {\n this.nodes = nodes\n this.root = Node.create_root(nodes)\n }\n\n /**\n * Return the value of `this` Expression instance.\n */\n get_value (parent, context, globals, node) {\n if (!this.root) {\n this.root = Node.create_root(this.nodes)\n }\n return this.root.get_value(parent, context, globals, node)\n }\n}\n\nExpression.prototype[Node.isExpressionOrIdentifierSymbol] = true\n"],
"mappings": ";AACA;AAEA,qBAAqB,WAAW;AAAA,EAC9B,YAAa,OAAO;AAClB,SAAK,QAAQ;AACb,SAAK,OAAO,KAAK,YAAY,KAAK;AAAA,EACpC;AAAA,EAKA,UAAW,QAAQ,SAAS,SAAS,MAAM;AACzC,QAAI,CAAC,KAAK,MAAM;AACd,WAAK,OAAO,KAAK,YAAY,KAAK,KAAK;AAAA,IACzC;AACA,WAAO,KAAK,KAAK,UAAU,QAAQ,SAAS,SAAS,IAAI;AAAA,EAC3D;AACF;AAEA,WAAW,UAAU,KAAK,kCAAkC;",
"names": []
}
// @tko/utils.parser 🥊 4.0.0-beta1.0 ESM
import Node from "./Node";
import Arguments from "./Arguments";
import { hasOwnProperty, isObjectLike } from "@tko/utils";
import {
isWriteableObservable,
isObservable
} from "@tko/observable";
import {
IDStart,
IDContinue
} from "./identifierExpressions";
export default class Identifier {
constructor(parser, token, dereferences) {
this.token = token;
this.dereferences = dereferences;
this.parser = parser;
}
dereference(value, $context, globals, node) {
let member;
let refs = this.dereferences || [];
const $data = $context.$data || {};
let lastValue;
let i, n;
for (i = 0, n = refs.length; i < n; ++i) {
member = Node.value_of(refs[i], $context, globals, node);
if (typeof value === "function" && refs[i] instanceof Arguments) {
value = value.apply(lastValue || $data, member);
lastValue = value;
} else if (value === null || value === void 0) {
throw new Error(`dereference of null value in ${JSON.stringify(this, null, 2)} context: ${JSON.stringify($context, null, 2)}`);
} else {
lastValue = value;
value = Node.value_of(value[member], $context, globals, node);
}
}
if (typeof value === "function" && n > 0 && lastValue !== value && !hasOwnProperty(lastValue, member)) {
return value.bind(lastValue);
}
return value;
}
get_value(parent, context, globals, node) {
const intermediate = parent && !(parent instanceof Identifier) ? Node.value_of(parent, context, globals, node)[this.token] : context.lookup(this.token, globals, node);
return this.dereference(intermediate, context, globals, node);
}
assign(object, property, value) {
if (isWriteableObservable(object[property])) {
object[property](value);
} else if (!isObservable(object[property])) {
object[property] = value;
}
}
set_value(new_value, $context, globals) {
const $data = $context.$data || {};
const refs = this.dereferences || [];
let leaf = this.token;
let i, n, root;
if (isObjectLike($data) && leaf in $data) {
root = $data;
} else if (leaf in $context) {
root = $context;
} else if (leaf in globals) {
root = globals;
} else {
throw new Error("Identifier::set_value -- The property '" + leaf + "' does not exist on the $data, $context, or globals.");
}
n = refs.length;
if (n === 0) {
this.assign(root, leaf, new_value);
return;
}
root = root[leaf];
for (i = 0; i < n - 1; ++i) {
leaf = refs[i];
if (leaf instanceof Arguments) {
root = root();
} else {
root = root[Node.value_of(leaf)];
}
}
if (refs[i] === true) {
throw new Error("Cannot assign a value to a function.");
}
if (refs[i]) {
this.assign(root, Node.value_of(refs[i]), new_value);
}
}
static is_valid_start_char(ch) {
return IDStart.test(ch);
}
static is_valid_continue_char(ch) {
return IDContinue.test(ch);
}
get [Node.isExpressionOrIdentifierSymbol]() {
return true;
}
}
{
"version": 3,
"sources": ["../src/Identifier.ts"],
"sourcesContent": ["\nimport Node from './Node'\nimport Arguments from './Arguments'\n\nimport { hasOwnProperty, isObjectLike } from '@tko/utils'\n\nimport {\n isWriteableObservable, isObservable\n} from '@tko/observable'\n\nimport {\n IDStart, IDContinue\n} from './identifierExpressions'\n\nexport default class Identifier {\n constructor (parser, token, dereferences) {\n this.token = token\n this.dereferences = dereferences\n this.parser = parser\n }\n\n /**\n * Apply all () and [] functions on the identifier to the lhs value e.g.\n * a()[3] has deref functions that are essentially this:\n * [_deref_call, _deref_this where this=3]\n *\n * @param {mixed} value Should be an object.\n * @return {mixed} The dereferenced value.\n *\n * [1] We want to bind any function that is a method of an object, but not\n * corrupt any values (e.g. computed()s). e.g. Running x.bind(obj) where\n * we're given `data-bind='binding: obj.x'` and x is a computed will\n * break the computed's `this` and it will stop working as expected.\n *\n * The test `!last_value.hasOwnProperty(member)`\n * distinguishes between functions on the prototype chain (prototypal\n * members) and value-members added directly to the object. This may\n * not be the canonical test for this relationship, but it succeeds\n * in the known test cases.\n *\n * See: `this` tests of our dereference function.\n */\n dereference (value, $context, globals, node) {\n let member\n let refs = this.dereferences || []\n const $data = $context.$data || {}\n let lastValue // becomes `this` in function calls to object properties.\n let i, n\n\n for (i = 0, n = refs.length; i < n; ++i) {\n member = Node.value_of(refs[i], $context, globals, node)\n\n if (typeof value === 'function' && refs[i] instanceof Arguments) {\n // fn(args)\n value = value.apply(lastValue || $data, member)\n lastValue = value\n } else if (value === null || value === undefined) {\n throw new Error(`dereference of null value in ${JSON.stringify(this, null, 2)} context: ${JSON.stringify($context, null, 2)}`)\n } else {\n // obj[x] or obj.x dereference. Note that obj may be a function.\n lastValue = value\n value = Node.value_of(value[member], $context, globals, node)\n }\n }\n\n // [1] See note above.\n if (typeof value === 'function' && n > 0 && lastValue !== value &&\n !hasOwnProperty(lastValue, member)) {\n return value.bind(lastValue)\n }\n\n return value\n };\n\n /**\n * Return the value as one would get it from the top-level i.e.\n * $data.token/$context.token/globals.token; this does not return intermediate\n * values on a chain of members i.e. $data.hello.there -- requesting the\n * Identifier('there').value will return $data/$context/globals.there.\n *\n * This will dereference using () or [arg] member.\n * @param {object | Identifier | Expression} parent\n * @return {mixed} Return the primitive or an accessor.\n */\n get_value (parent, context, globals, node) {\n const intermediate = parent && !(parent instanceof Identifier)\n ? Node.value_of(parent, context, globals, node)[this.token]\n : context.lookup(this.token, globals, node)\n return this.dereference(intermediate, context, globals, node)\n }\n\n assign (object, property, value) {\n if (isWriteableObservable(object[property])) {\n object[property](value)\n } else if (!isObservable(object[property])) {\n object[property] = value\n }\n };\n\n /**\n * Set the value of the Identifier.\n *\n * @param {Mixed} new_value The value that Identifier is to be set to.\n */\n set_value (new_value, $context, globals) {\n const $data = $context.$data || {}\n const refs = this.dereferences || []\n let leaf = this.token\n let i, n, root\n\n if (isObjectLike($data) && leaf in $data) {\n root = $data\n } else if (leaf in $context) {\n root = $context\n } else if (leaf in globals) {\n root = globals\n } else {\n throw new Error('Identifier::set_value -- ' +\n \"The property '\" + leaf + \"' does not exist \" +\n 'on the $data, $context, or globals.')\n }\n\n // Degenerate case. {$data|$context|global}[leaf] = something;\n n = refs.length\n if (n === 0) {\n this.assign(root, leaf, new_value)\n return\n }\n\n // First dereference is {$data|$context|global}[token].\n root = root[leaf]\n\n // We cannot use this.dereference because that gives the leaf; to evoke\n // the ES5 setter we have to call `obj[leaf] = new_value`\n for (i = 0; i < n - 1; ++i) {\n leaf = refs[i]\n if (leaf instanceof Arguments) {\n root = root()\n } else {\n root = root[Node.value_of(leaf)]\n }\n }\n\n // We indicate that a dereference is a function when it is `true`.\n if (refs[i] === true) {\n throw new Error('Cannot assign a value to a function.')\n }\n\n // Call the setter for the leaf.\n if (refs[i]) {\n this.assign(root, Node.value_of(refs[i]), new_value)\n }\n };\n\n /**\n * Determine if a character is a valid item in an identifier.\n * Note that we do not check whether the first item is a number, nor do we\n * support unicode identifiers here.\n *\n * From: http://stackoverflow.com/a/9337047\n * @param {String} ch The character\n * @return {Boolean} True if this is a valid identifier\n */\n // function is_identifier_char(ch) {\n // return (ch >= 'A' && ch <= 'Z') ||\n // (ch >= 'a' && ch <= 'z') ||\n // (ch >= '0' && ch <= 9) ||\n // ch === '_' || ch === '$';\n // }\n static is_valid_start_char (ch) {\n return IDStart.test(ch)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AAA,SAEO,uBAAwB,IAAI;AACjC,WAAO,WAAW,KAAK,EAAE;AAAA,EAC3B;AAAA,OAEK,KAAK,kCAAmC;AAAE,WAAO;AAAA,EAAK;AAC7D;",
"names": []
}
// @tko/utils.parser 🥊 4.0.0-beta1.0 ESM
export var IDStart = /[\$A-Z_a-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B4\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AD\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/;
export var IDContinue = /[\$0-9A-Z_a-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0-\u08B4\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D01-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFC-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AD\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C4\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/;
{
"version": 3,
"sources": ["../src/identifierExpressions.ts"],
"sourcesContent": ["/**\n * The following regular expressions were generated by\n * https://mathiasbynens.be/demo/javascript-identifier-regex\n */\nexport var IDStart = /[\\$A-Z_a-z\\xAA\\xB5\\xBA\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0370-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u037F\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u048A-\\u052F\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u05D0-\\u05EA\\u05F0-\\u05F2\\u0620-\\u064A\\u066E\\u066F\\u0671-\\u06D3\\u06D5\\u06E5\\u06E6\\u06EE\\u06EF\\u06FA-\\u06FC\\u06FF\\u0710\\u0712-\\u072F\\u074D-\\u07A5\\u07B1\\u07CA-\\u07EA\\u07F4\\u07F5\\u07FA\\u0800-\\u0815\\u081A\\u0824\\u0828\\u0840-\\u0858\\u08A0-\\u08B4\\u0904-\\u0939\\u093D\\u0950\\u0958-\\u0961\\u0971-\\u0980\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BD\\u09CE\\u09DC\\u09DD\\u09DF-\\u09E1\\u09F0\\u09F1\\u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u0A35\\u0A36\\u0A38\\u0A39\\u0A59-\\u0A5C\\u0A5E\\u0A72-\\u0A74\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2\\u0AB3\\u0AB5-\\u0AB9\\u0ABD\\u0AD0\\u0AE0\\u0AE1\\u0AF9\\u0B05-\\u0B0C\\u0B0F\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32\\u0B33\\u0B35-\\u0B39\\u0B3D\\u0B5C\\u0B5D\\u0B5F-\\u0B61\\u0B71\\u0B83\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99\\u0B9A\\u0B9C\\u0B9E\\u0B9F\\u0BA3\\u0BA4\\u0BA8-\\u0BAA\\u0BAE-\\u0BB9\\u0BD0\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2A-\\u0C39\\u0C3D\\u0C58-\\u0C5A\\u0C60\\u0C61\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBD\\u0CDE\\u0CE0\\u0CE1\\u0CF1\\u0CF2\\u0D05-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D3A\\u0D3D\\u0D4E\\u0D5F-\\u0D61\\u0D7A-\\u0D7F\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0E01-\\u0E30\\u0E32\\u0E33\\u0E40-\\u0E46\\u0E81\\u0E82\\u0E84\\u0E87\\u0E88\\u0E8A\\u0E8D\\u0E94-\\u0E97\\u0E99-\\u0E9F\\u0EA1-\\u0EA3\\u0EA5\\u0EA7\\u0EAA\\u0EAB\\u0EAD-\\u0EB0\\u0EB2\\u0EB3\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EDC-\\u0EDF\\u0F00\\u0F40-\\u0F47\\u0F49-\\u0F6C\\u0F88-\\u0F8C\\u1000-\\u102A\\u103F\\u1050-\\u1055\\u105A-\\u105D\\u1061\\u1065\\u1066\\u106E-\\u1070\\u1075-\\u1081\\u108E\\u10A0-\\u10C5\\u10C7\\u10CD\\u10D0-\\u10FA\\u10FC-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u1380-\\u138F\\u13A0-\\u13F5\\u13F8-\\u13FD\\u1401-\\u166C\\u166F-\\u167F\\u1681-\\u169A\\u16A0-\\u16EA\\u16EE-\\u16F8\\u1700-\\u170C\\u170E-\\u1711\\u1720-\\u1731\\u1740-\\u1751\\u1760-\\u176C\\u176E-\\u1770\\u1780-\\u17B3\\u17D7\\u17DC\\u1820-\\u1877\\u1880-\\u18A8\\u18AA\\u18B0-\\u18F5\\u1900-\\u191E\\u1950-\\u196D\\u1970-\\u1974\\u1980-\\u19AB\\u19B0-\\u19C9\\u1A00-\\u1A16\\u1A20-\\u1A54\\u1AA7\\u1B05-\\u1B33\\u1B45-\\u1B4B\\u1B83-\\u1BA0\\u1BAE\\u1BAF\\u1BBA-\\u1BE5\\u1C00-\\u1C23\\u1C4D-\\u1C4F\\u1C5A-\\u1C7D\\u1CE9-\\u1CEC\\u1CEE-\\u1CF1\\u1CF5\\u1CF6\\u1D00-\\u1DBF\\u1E00-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u2071\\u207F\\u2090-\\u209C\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2160-\\u2188\\u2C00-\\u2C2E\\u2C30-\\u2C5E\\u2C60-\\u2CE4\\u2CEB-\\u2CEE\\u2CF2\\u2CF3\\u2D00-\\u2D25\\u2D27\\u2D2D\\u2D30-\\u2D67\\u2D6F\\u2D80-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2E2F\\u3005-\\u3007\\u3021-\\u3029\\u3031-\\u3035\\u3038-\\u303C\\u3041-\\u3096\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312D\\u3131-\\u318E\\u31A0-\\u31BA\\u31F0-\\u31FF\\u3400-\\u4DB5\\u4E00-\\u9FD5\\uA000-\\uA48C\\uA4D0-\\uA4FD\\uA500-\\uA60C\\uA610-\\uA61F\\uA62A\\uA62B\\uA640-\\uA66E\\uA67F-\\uA69D\\uA6A0-\\uA6EF\\uA717-\\uA71F\\uA722-\\uA788\\uA78B-\\uA7AD\\uA7B0-\\uA7B7\\uA7F7-\\uA801\\uA803-\\uA805\\uA807-\\uA80A\\uA80C-\\uA822\\uA840-\\uA873\\uA882-\\uA8B3\\uA8F2-\\uA8F7\\uA8FB\\uA8FD\\uA90A-\\uA925\\uA930-\\uA946\\uA960-\\uA97C\\uA984-\\uA9B2\\uA9CF\\uA9E0-\\uA9E4\\uA9E6-\\uA9EF\\uA9FA-\\uA9FE\\uAA00-\\uAA28\\uAA40-\\uAA42\\uAA44-\\uAA4B\\uAA60-\\uAA76\\uAA7A\\uAA7E-\\uAAAF\\uAAB1\\uAAB5\\uAAB6\\uAAB9-\\uAABD\\uAAC0\\uAAC2\\uAADB-\\uAADD\\uAAE0-\\uAAEA\\uAAF2-\\uAAF4\\uAB01-\\uAB06\\uAB09-\\uAB0E\\uAB11-\\uAB16\\uAB20-\\uAB26\\uAB28-\\uAB2E\\uAB30-\\uAB5A\\uAB5C-\\uAB65\\uAB70-\\uABE2\\uAC00-\\uD7A3\\uD7B0-\\uD7C6\\uD7CB-\\uD7FB\\uF900-\\uFA6D\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D\\uFB1F-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40\\uFB41\\uFB43\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF21-\\uFF3A\\uFF41-\\uFF5A\\uFF66-\\uFFBE\\uFFC2-\\uFFC7\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC]/\n\nexport var IDContinue = /[\\$0-9A-Z_a-z\\xAA\\xB5\\xBA\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0300-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u037F\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u0483-\\u0487\\u048A-\\u052F\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u0591-\\u05BD\\u05BF\\u05C1\\u05C2\\u05C4\\u05C5\\u05C7\\u05D0-\\u05EA\\u05F0-\\u05F2\\u0610-\\u061A\\u0620-\\u0669\\u066E-\\u06D3\\u06D5-\\u06DC\\u06DF-\\u06E8\\u06EA-\\u06FC\\u06FF\\u0710-\\u074A\\u074D-\\u07B1\\u07C0-\\u07F5\\u07FA\\u0800-\\u082D\\u0840-\\u085B\\u08A0-\\u08B4\\u08E3-\\u0963\\u0966-\\u096F\\u0971-\\u0983\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BC-\\u09C4\\u09C7\\u09C8\\u09CB-\\u09CE\\u09D7\\u09DC\\u09DD\\u09DF-\\u09E3\\u09E6-\\u09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CB9\\u0CBC-\\u0CC4\\u0CC6-\\u0CC8\\u0CCA-\\u0CCD\\u0CD5\\u0CD6\\u0CDE\\u0CE0-\\u0CE3\\u0CE6-\\u0CEF\\u0CF1\\u0CF2\\u0D01-\\u0D03\\u0D05-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D3A\\u0D3D-\\u0D44\\u0D46-\\u0D48\\u0D4A-\\u0D4E\\u0D57\\u0D5F-\\u0D63\\u0D66-\\u0D6F\\u0D7A-\\u0D7F\\u0D82\\u0D83\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0DCA\\u0DCF-\\u0DD4\\u0DD6\\u0DD8-\\u0DDF\\u0DE6-\\u0DEF\\u0DF2\\u0DF3\\u0E01-\\u0E3A\\u0E40-\\u0E4E\\u0E50-\\u0E59\\u0E81\\u0E82\\u0E84\\u0E87\\u0E88\\u0E8A\\u0E8D\\u0E94-\\u0E97\\u0E99-\\u0E9F\\u0EA1-\\u0EA3\\u0EA5\\u0EA7\\u0EAA\\u0EAB\\u0EAD-\\u0EB9\\u0EBB-\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EC8-\\u0ECD\\u0ED0-\\u0ED9\\u0EDC-\\u0EDF\\u0F00\\u0F18\\u0F19\\u0F20-\\u0F29\\u0F35\\u0F37\\u0F39\\u0F3E-\\u0F47\\u0F49-\\u0F6C\\u0F71-\\u0F84\\u0F86-\\u0F97\\u0F99-\\u0FBC\\u0FC6\\u1000-\\u1049\\u1050-\\u109D\\u10A0-\\u10C5\\u10C7\\u10CD\\u10D0-\\u10FA\\u10FC-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u135D-\\u135F\\u1380-\\u138F\\u13A0-\\u13F5\\u13F8-\\u13FD\\u1401-\\u166C\\u166F-\\u167F\\u1681-\\u169A\\u16A0-\\u16EA\\u16EE-\\u16F8\\u1700-\\u170C\\u170E-\\u1714\\u1720-\\u1734\\u1740-\\u1753\\u1760-\\u176C\\u176E-\\u1770\\u1772\\u1773\\u1780-\\u17D3\\u17D7\\u17DC\\u17DD\\u17E0-\\u17E9\\u180B-\\u180D\\u1810-\\u1819\\u1820-\\u1877\\u1880-\\u18AA\\u18B0-\\u18F5\\u1900-\\u191E\\u1920-\\u192B\\u1930-\\u193B\\u1946-\\u196D\\u1970-\\u1974\\u1980-\\u19AB\\u19B0-\\u19C9\\u19D0-\\u19D9\\u1A00-\\u1A1B\\u1A20-\\u1A5E\\u1A60-\\u1A7C\\u1A7F-\\u1A89\\u1A90-\\u1A99\\u1AA7\\u1AB0-\\u1ABD\\u1B00-\\u1B4B\\u1B50-\\u1B59\\u1B6B-\\u1B73\\u1B80-\\u1BF3\\u1C00-\\u1C37\\u1C40-\\u1C49\\u1C4D-\\u1C7D\\u1CD0-\\u1CD2\\u1CD4-\\u1CF6\\u1CF8\\u1CF9\\u1D00-\\u1DF5\\u1DFC-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u200C\\u200D\\u203F\\u2040\\u2054\\u2071\\u207F\\u2090-\\u209C\\u20D0-\\u20DC\\u20E1\\u20E5-\\u20F0\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2160-\\u2188\\u2C00-\\u2C2E\\u2C30-\\u2C5E\\u2C60-\\u2CE4\\u2CEB-\\u2CF3\\u2D00-\\u2D25\\u2D27\\u2D2D\\u2D30-\\u2D67\\u2D6F\\u2D7F-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2DE0-\\u2DFF\\u2E2F\\u3005-\\u3007\\u3021-\\u302F\\u3031-\\u3035\\u3038-\\u303C\\u3041-\\u3096\\u3099\\u309A\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312D\\u3131-\\u318E\\u31A0-\\u31BA\\u31F0-\\u31FF\\u3400-\\u4DB5\\u4E00-\\u9FD5\\uA000-\\uA48C\\uA4D0-\\uA4FD\\uA500-\\uA60C\\uA610-\\uA62B\\uA640-\\uA66F\\uA674-\\uA67D\\uA67F-\\uA6F1\\uA717-\\uA71F\\uA722-\\uA788\\uA78B-\\uA7AD\\uA7B0-\\uA7B7\\uA7F7-\\uA827\\uA840-\\uA873\\uA880-\\uA8C4\\uA8D0-\\uA8D9\\uA8E0-\\uA8F7\\uA8FB\\uA8FD\\uA900-\\uA92D\\uA930-\\uA953\\uA960-\\uA97C\\uA980-\\uA9C0\\uA9CF-\\uA9D9\\uA9E0-\\uA9FE\\uAA00-\\uAA36\\uAA40-\\uAA4D\\uAA50-\\uAA59\\uAA60-\\uAA76\\uAA7A-\\uAAC2\\uAADB-\\uAADD\\uAAE0-\\uAAEF\\uAAF2-\\uAAF6\\uAB01-\\uAB06\\uAB09-\\uAB0E\\uAB11-\\uAB16\\uAB20-\\uAB26\\uAB28-\\uAB2E\\uAB30-\\uAB5A\\uAB5C-\\uAB65\\uAB70-\\uABEA\\uABEC\\uABED\\uABF0-\\uABF9\\uAC00-\\uD7A3\\uD7B0-\\uD7C6\\uD7CB-\\uD7FB\\uF900-\\uFA6D\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40\\uFB41\\uFB43\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE00-\\uFE0F\\uFE20-\\uFE2F\\uFE33\\uFE34\\uFE4D-\\uFE4F\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF10-\\uFF19\\uFF21-\\uFF3A\\uFF3F\\uFF41-\\uFF5A\\uFF66-\\uFFBE\\uFFC2-\\uFFC7\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC]/\n"],
"mappings": ";AAIO,WAAI,UAAU;AAEd,WAAI,aAAa;",
"names": []
}

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

// @tko/utils.parser 🥊 4.0.0-beta1.0 ESM
export { default as Parser } from "./Parser";
export { default as Identifier } from "./Identifier";
export { default as Arguments } from "./Arguments";
export { default as Ternary } from "./Ternary";
export { default as Node } from "./Node";
export { default as parseObjectLiteral } from "./preparse";
{
"version": 3,
"sources": ["../src/index.ts"],
"sourcesContent": ["\nexport {default as Parser} from './Parser'\nexport {default as Identifier} from './Identifier'\nexport {default as Arguments} from './Arguments'\nexport {default as Ternary} from './Ternary'\nexport {default as Node} from './Node'\n\nexport {default as parseObjectLiteral} from './preparse'\n"],
"mappings": ";AACA;AACA;AACA;AACA;AACA;AAEA;",
"names": []
}
// @tko/utils.parser 🥊 4.0.0-beta1.0 MJS
export { default as Parser } from "./Parser";
export { default as Identifier } from "./Identifier";
export { default as Arguments } from "./Arguments";
export { default as Ternary } from "./Ternary";
export { default as Node } from "./Node";
export { default as parseObjectLiteral } from "./preparse";
{
"version": 3,
"sources": ["../src/index.ts"],
"sourcesContent": ["\nexport {default as Parser} from './Parser'\nexport {default as Identifier} from './Identifier'\nexport {default as Arguments} from './Arguments'\nexport {default as Ternary} from './Ternary'\nexport {default as Node} from './Node'\n\nexport {default as parseObjectLiteral} from './preparse'\n"],
"mappings": ";AACA;AACA;AACA;AACA;AACA;AAEA;",
"names": []
}
// @tko/utils.parser 🥊 4.0.0-beta1.0 ESM
import {
unwrap
} from "@tko/observable";
import {
default as operators,
LAMBDA
} from "./operators";
const IS_EXPR_OR_IDENT = Symbol("Node - Is Expression Or Identifier");
export default class Node {
constructor(lhs, op, rhs) {
this.lhs = lhs;
this.op = op;
this.rhs = rhs;
}
static get operators() {
return operators;
}
get_leaf_value(leaf, context, globals, node) {
if (typeof leaf === "function") {
return unwrap(leaf());
}
if (typeof leaf !== "object" || leaf === null) {
return leaf;
}
if (leaf[Node.isExpressionOrIdentifierSymbol]) {
return unwrap(leaf.get_value(void 0, context, globals, node));
}
return leaf;
}
get_value(notused, context, globals, node) {
var node = this;
if (node.op === LAMBDA) {
return (...args) => {
let lambdaContext = context;
if (node.lhs) {
lambdaContext = node.lhs.extendContext(context, args);
}
return node.get_leaf_value(node.rhs, lambdaContext, globals, node);
};
}
const lhv = node.get_leaf_value(node.lhs, context, globals, node);
const earlyOut = node.op.earlyOut;
if (earlyOut && earlyOut(lhv)) {
return lhv;
}
const rhv = node.get_leaf_value(node.rhs, context, globals, node);
return node.op(lhv, rhv, context, globals);
}
static get isExpressionOrIdentifierSymbol() {
return IS_EXPR_OR_IDENT;
}
get [IS_EXPR_OR_IDENT]() {
return true;
}
static value_of(item, context, globals, node) {
if (item && item[Node.isExpressionOrIdentifierSymbol]) {
return item.get_value(item, context, globals, node);
}
return item;
}
static create_root(nodes, debug = false) {
const out = [];
const ops = [];
for (let i = 0; i < nodes.length; i += 2) {
out.push(nodes[i]);
const op = nodes[i + 1];
const prec = (op == null ? void 0 : op.precedence) || 0;
while (ops.length && prec <= ops[ops.length - 1].precedence) {
const rhs = out.pop();
const lhs = out.pop();
out.push(new Node(lhs, ops.pop(), rhs));
}
ops.push(op);
}
if (out.length !== 1) {
throw new Error(`unexpected nodes remain in shunting yard output stack: ${out}`);
}
return out[0];
}
}
operators["?"] = function ternary(a, b, context, globals, node) {
return Node.value_of(a ? b.yes : b.no, context, globals, node);
};
operators["?"].precedence = 4;
{
"version": 3,
"sources": ["../src/Node.ts"],
"sourcesContent": ["\nimport {\n unwrap\n} from '@tko/observable'\n\nimport {\n default as operators,\n LAMBDA\n} from './operators'\n\nconst IS_EXPR_OR_IDENT = Symbol('Node - Is Expression Or Identifier')\n\nexport default class Node {\n constructor (lhs, op, rhs) {\n this.lhs = lhs\n this.op = op\n this.rhs = rhs\n }\n\n static get operators () { return operators }\n\n get_leaf_value (leaf, context, globals, node) {\n if (typeof leaf === 'function') {\n // Expressions on observables are nonsensical, so we unwrap any\n // function values (e.g. identifiers).\n return unwrap(leaf())\n }\n\n // primitives\n if (typeof leaf !== 'object' || leaf === null) { return leaf }\n\n // Identifiers and Expressions\n if (leaf[Node.isExpressionOrIdentifierSymbol]) {\n // lhs is passed in as the parent of the leaf. It will be defined in\n // cases like a.b.c as 'a' for 'b' then as 'b' for 'c'.\n return unwrap(leaf.get_value(undefined, context, globals, node))\n }\n\n // Plain object/class.\n return leaf\n }\n\n /**\n * Return a function that calculates and returns an expression's value\n * when called.\n * @param {array} ops The operations to perform\n * @return {function} The function that calculates the expression.\n *\n * Note that for a lambda, we do not evaluate the RHS expression until\n * the lambda is called.\n */\n get_value (notused, context, globals, node) {\n var node = this\n\n if (node.op === LAMBDA) {\n return (...args) => {\n let lambdaContext = context\n if (node.lhs) {\n lambdaContext = node.lhs.extendContext(context, args)\n }\n return node.get_leaf_value(node.rhs, lambdaContext, globals, node)\n }\n }\n\n const lhv = node.get_leaf_value(node.lhs, context, globals, node)\n const earlyOut = node.op.earlyOut\n\n if (earlyOut && earlyOut(lhv)) { return lhv }\n const rhv = node.get_leaf_value(node.rhs, context, globals, node)\n\n return node.op(lhv, rhv, context, globals)\n }\n\n //\n // Class variables.\n //\n static get isExpressionOrIdentifierSymbol () { return IS_EXPR_OR_IDENT }\n get [IS_EXPR_OR_IDENT] () { return true }\n\n static value_of (item, context, globals, node) {\n if (item && item[Node.isExpressionOrIdentifierSymbol]) {\n return item.get_value(item, context, globals, node)\n }\n return item\n }\n\n /**\n * Convert an array of nodes to an executable tree.\n * @return {object} An object with a `lhs`, `rhs` and `op` key, corresponding\n * to the left hand side, right hand side, and\n * operation function.\n */\n static create_root (nodes, debug=false) {\n // shunting yard algorithm with output to an abstact syntax tree of Nodes\n const out = []\n const ops = []\n for (let i = 0; i < nodes.length; i += 2) {\n out.push(nodes[i]) // next value\n const op = nodes[i+1]\n\n // only left-associative operators are currently defined and handled here\n const prec = op?.precedence || 0 // no op for last value\n while (ops.length && prec <= ops[ops.length-1].precedence) {\n const rhs = out.pop()\n const lhs = out.pop()\n out.push(new Node(lhs, ops.pop(), rhs))\n }\n ops.push(op)\n }\n if (out.length !== 1) {\n throw new Error(`unexpected nodes remain in shunting yard output stack: ${out}`)\n }\n return out[0]\n }\n}\n\n/**\n * Because of cyclical dependencies on operators <-> Node <-> value_of,\n * we need to patch this in here.\n */\noperators['?'] = function ternary (a, b, context, globals, node) {\n return Node.value_of(a ? b.yes : b.no, context, globals, node)\n}\noperators['?'].precedence = 4\n"],
"mappings": ";AACA;AAAA;AAAA;AAIA;AAAA;AAAA;AAAA;AAKA,MAAM,mBAAmB,OAAO,oCAAoC;AAEpE,qBAAqB,KAAK;AAAA,EACxB,YAAa,KAAK,IAAI,KAAK;AACzB,SAAK,MAAM;AACX,SAAK,KAAK;AACV,SAAK,MAAM;AAAA,EACb;AAAA,aAEW,YAAa;AAAE,WAAO;AAAA,EAAU;AAAA,EAE3C,eAAgB,MAAM,SAAS,SAAS,MAAM;AAC5C,QAAI,OAAO,SAAS,YAAY;AAG9B,aAAO,OAAO,KAAK,CAAC;AAAA,IACtB;AAGA,QAAI,OAAO,SAAS,YAAY,SAAS,MAAM;AAA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QAAQ,IAAI,IAAI,SAAO,GAAG,YAAY;AACzD,cAAM,MAAM,IAAI,IAAI;AACpB,cAAM,MAAM,IAAI,IAAI;AACpB,YAAI,KAAK,IAAI,KAAK,KAAK,IAAI,IAAI,GAAG,GAAG,CAAC;AAAA,MACxC;AACA,UAAI,KAAK,EAAE;AAAA,IACb;AACA,QAAI,IAAI,WAAW,GAAG;AACpB,YAAM,IAAI,MAAM,0DAA0D,KAAK;AAAA,IACjF;AACA,WAAO,IAAI;AAAA,EACb;AACF;AAMA,UAAU,OAAO,iBAAkB,GAAG,GAAG,SAAS,SAAS,MAAM;AAC/D,SAAO,KAAK,SAAS,IAAI,EAAE,MAAM,EAAE,IAAI,SAAS,SAAS,IAAI;AAC/D;AACA,UAAU,KAAK,aAAa;",
"names": []
}
// @tko/utils.parser 🥊 4.0.0-beta1.0 ESM
import {
unwrap
} from "@tko/observable";
export function LAMBDA() {
}
function unwrapOrCall(a, b) {
while (typeof b === "function") {
b = b();
}
return b;
}
const operators = {
"@": unwrapOrCall,
"#": (a, b) => () => unwrap(b),
"=>": LAMBDA,
"!": function not(a, b) {
return !b;
},
"!!": function notnot(a, b) {
return !!b;
},
"++": function preinc(a, b) {
return ++b;
},
"--": function preinc2(a, b) {
return --b;
},
"*": function mul(a, b) {
return a * b;
},
"/": function div(a, b) {
return a / b;
},
"%": function mod(a, b) {
return a % b;
},
"+": function add(a, b) {
return a + b;
},
"-": function sub(a, b) {
return (a || 0) - (b || 0);
},
"&-": function neg(a, b) {
return -1 * b;
},
"<": function lt(a, b) {
return a < b;
},
"<=": function le(a, b) {
return a <= b;
},
">": function gt(a, b) {
return a > b;
},
">=": function ge(a, b) {
return a >= b;
},
"==": function equal(a, b) {
return a === b;
},
"!=": function ne(a, b) {
return a !== b;
},
"===": function sequal(a, b) {
return a === b;
},
"!==": function sne(a, b) {
return a !== b;
},
"&": function bitAnd(a, b) {
return a & b;
},
"^": function xor(a, b) {
return a ^ b;
},
"|": function bitOr(a, b) {
return a | b;
},
"&&": function logicAnd(a, b) {
return a && b;
},
"||": function logicOr(a, b) {
return a || b;
},
".": function member(a, b) {
return a[b];
},
"[": function member2(a, b) {
return a[b];
},
",": function comma(a, b) {
return b;
},
"call": function callOp(a, b) {
return a.apply(null, b);
}
};
operators["@"].precedence = 21;
operators["#"].precedence = 21;
operators["."].precedence = 19;
operators["["].precedence = 19;
operators["!"].precedence = 16;
operators["!!"].precedence = 16;
operators["++"].precedence = 16;
operators["--"].precedence = 16;
operators["&-"].precedence = 16;
operators["%"].precedence = 14;
operators["*"].precedence = 14;
operators["/"].precedence = 14;
operators["+"].precedence = 13;
operators["-"].precedence = 13;
operators["|"].precedence = 12;
operators["^"].precedence = 11;
operators["&"].precedence = 10;
operators["<"].precedence = 11;
operators["<="].precedence = 11;
operators[">"].precedence = 11;
operators[">="].precedence = 11;
operators["=="].precedence = 10;
operators["!="].precedence = 10;
operators["==="].precedence = 10;
operators["!=="].precedence = 10;
operators["&&"].precedence = 6;
operators["||"].precedence = 5;
operators["&&"].earlyOut = (a) => !a;
operators["||"].earlyOut = (a) => a;
operators[","].precedence = 2;
operators["call"].precedence = 1;
operators["=>"].precedence = 1;
export { operators as default };
{
"version": 3,
"sources": ["../src/operators.ts"],
"sourcesContent": ["import {\n unwrap\n} from '@tko/observable'\n\nexport function LAMBDA () {}\n\n/**\n * @ operator - recursively call the identifier if it's a function\n * @param {operand} a ignored\n * @param {operand} b The variable to be called (if a function) and unwrapped\n * @return {value} The result.\n */\nfunction unwrapOrCall (a, b) {\n while (typeof b === 'function') { b = b() }\n return b\n}\n\nconst operators = {\n // unary\n '@': unwrapOrCall,\n '#': (a, b) => () => unwrap(b), // Convert to read-only.\n '=>': LAMBDA,\n '!': function not (a, b) { return !b },\n '!!': function notnot (a, b) { return !!b },\n '++': function preinc (a, b) { return ++b },\n '--': function preinc (a, b) { return --b },\n // mul/div\n '*': function mul (a, b) { return a * b },\n '/': function div (a, b) { return a / b },\n '%': function mod (a, b) { return a % b },\n // sub/add\n '+': function add (a, b) { return a + b },\n '-': function sub (a, b) { return (a || 0) - (b || 0) },\n '&-': function neg (a, b) { return -1 * b },\n // relational\n '<': function lt (a, b) { return a < b },\n '<=': function le (a, b) { return a <= b },\n '>': function gt (a, b) { return a > b },\n '>=': function ge (a, b) { return a >= b },\n // TODO: 'in': function (a, b) { return a in b; },\n // TODO: 'instanceof': function (a, b) { return a instanceof b; },\n // equality\n '==': function equal (a, b) { return a === b },\n '!=': function ne (a, b) { return a !== b },\n '===': function sequal (a, b) { return a === b },\n '!==': function sne (a, b) { return a !== b },\n // bitwise\n '&': function bitAnd (a, b) { return a & b },\n '^': function xor (a, b) { return a ^ b },\n '|': function bitOr (a, b) { return a | b },\n // logic\n '&&': function logicAnd (a, b) { return a && b },\n '||': function logicOr (a, b) { return a || b },\n // Access\n '.': function member (a, b) { return a[b] },\n '[': function member (a, b) { return a[b] },\n ',': function comma (a, b) { return b },\n // conditional/ternary\n // '?': ternary See Node.js\n // Function-Call\n 'call': function callOp (a, b) { return a.apply(null, b) }\n}\n\n/* Order of precedence from:\nhttps://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence#Table\n*/\n\n // Our operator - unwrap/call\noperators['@'].precedence = 21\noperators['#'].precedence = 21\n\n // Member\noperators['.'].precedence = 19\noperators['['].precedence = 19\n\n // Logical not\noperators['!'].precedence = 16\noperators['!!'].precedence = 16 // explicit double-negative\n\n // Prefix inc/dec\noperators['++'].precedence = 16\noperators['--'].precedence = 16\noperators['&-'].precedence = 16\n\n // mul/div/remainder\noperators['%'].precedence = 14\noperators['*'].precedence = 14\noperators['/'].precedence = 14\n\n // add/sub\noperators['+'].precedence = 13\noperators['-'].precedence = 13\n\n // bitwise\noperators['|'].precedence = 12\noperators['^'].precedence = 11\noperators['&'].precedence = 10\n\n // comparison\noperators['<'].precedence = 11\noperators['<='].precedence = 11\noperators['>'].precedence = 11\noperators['>='].precedence = 11\n\n // operators['in'].precedence = 8;\n // operators['instanceof'].precedence = 8;\n // equality\noperators['=='].precedence = 10\noperators['!='].precedence = 10\noperators['==='].precedence = 10\noperators['!=='].precedence = 10\n\n // logic\noperators['&&'].precedence = 6\noperators['||'].precedence = 5\n\noperators['&&'].earlyOut = (a) => !a\noperators['||'].earlyOut = (a) => a\n\n // multiple values\noperators[','].precedence = 2\n\n // Call a function\noperators['call'].precedence = 1\n\n // lambda\noperators['=>'].precedence = 1\n\nexport { operators as default }\n"],
"mappings": ";AAAA;AAAA;AAAA;AAIO,yBAAmB;AAAC;AAQ3B,sBAAuB,GAAG,GAAG;AAC3B,SAAO,OAAO,MAAM,YAAY;AAAE,QAAI,EAAE;AAAA,EAAE;AAC1C,SAAO;AACT;AAEA,MAAM,YAAY;AAAA,EAEhB,KAAK;AAAA,EACL,KAAK,CAAC,GAAG,MAAM,MAAM,OAAO,CAAC;AAAA,EAC7B,MAAM;AAAA,EACN,KAAK,aAAc,GAAG,GAAG;AAAE,WAAO,CAAC;AAAA,EAAE;AAAA,EACrC,MAAM,gBAAiB,GAAG,GAAG;AAAE,WAAO,CAAC,CAAC;AAAA,EAAE;AAAA,EAC1C,MAAM,gBAAiB,GAAG,GAAG;AAAE,WAAO,EAAE;AAAA,EAAE;AAAA,EAC1C,MAAM,iBAAiB,GAAG,GAAG;AAAE,WAAO,EAAE;AAAA,EAAE;AAAA,EAE1C,KAAK,aAAc,GAAG,GAAG;AAAE,WAAO,IAAI;AAAA,EAAE;AAAA,EACxC,KAAK,aAAc,GAAG,GAAG;AAAE,WAAO,IAAI;AAAA,EAAE;AAAA,EACxC,KAAK,aAAc,GAAG,GAAG;AAAE,WAAO,IAAI;AAAA,EAAE;AAAA,EAExC,KAAK,aAAc,GAAG,GAAG;AAAE,WAAO,IAAI;AAAA,EAAE;AAAA,EACxC,KAAK,aAAc,GAAG,GAAG;AAAE,WAAQ,MAAK,KAAM,MAAK;AAAA,EAAG;AAAA,EACtD,MAAM,aAAc,GAAG,GAAG;AAAE,WAAO,KAAK;AAAA,EA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;AAG5B,UAAU,KAAK,aAAa;AAC5B,UAAU,KAAK,aAAa;AAG5B,UAAU,KAAK,aAAa;AAC5B,UAAU,MAAM,aAAa;AAG7B,UAAU,MAAM,aAAa;AAC7B,UAAU,MAAM,aAAa;AAC7B,UAAU,MAAM,aAAa;AAG7B,UAAU,KAAK,aAAa;AAC5B,UAAU,KAAK,aAAa;AAC5B,UAAU,KAAK,aAAa;AAG5B,UAAU,KAAK,aAAa;AAC5B,UAAU,KAAK,aAAa;AAG5B,UAAU,KAAK,aAAa;AAC5B,UAAU,KAAK,aAAa;AAC5B,UAAU,KAAK,aAAa;AAG5B,UAAU,KAAK,aAAa;AAC5B,UAAU,MAAM,aAAa;AAC7B,UAAU,KAAK,aAAa;AAC5B,UAAU,MAAM,aAAa;AAK7B,UAAU,MAAM,aAAa;AAC7B,UAAU,MAAM,aAAa;AAC7B,UAAU,OAAO,aAAa;AAC9B,UAAU,OAAO,aAAa;AAG9B,UAAU,MAAM,aAAa;AAC7B,UAAU,MAAM,aAAa;AAE7B,UAAU,MAAM,WAAW,CAAC,MAAM,CAAC;AACnC,UAAU,MAAM,WAAW,CAAC,MAAM;AAGlC,UAAU,KAAK,aAAa;AAG5B,UAAU,QAAQ,aAAa;AAG/B,UAAU,MAAM,aAAa;AAE7B;",
"names": []
}
// @tko/utils.parser 🥊 4.0.0-beta1.0 ESM
import operators from "./operators";
import Node from "./Node";
import Expression from "./Expression";
import Identifier from "./Identifier";
export default class Parameters {
constructor(parser, node) {
if (node instanceof Expression) {
node = node.root;
}
try {
this.names = Parameters.nodeTreeToNames(node);
} catch (e) {
parser.error(e);
}
}
extendContext(context, args) {
if (!this.names) {
return context;
} else {
const newValues = {};
this.names.forEach((name, index) => {
newValues[name] = args[index];
});
return context.extend(newValues);
}
}
get [Node.isExpressionOrIdentifierSymbol]() {
return true;
}
static nodeTreeToNames(node) {
const names = [];
while (node) {
if (node instanceof Identifier) {
names.push(node.token);
node = null;
} else if (this.isCommaNode(node)) {
names.push(node.rhs.token);
node = node.lhs;
} else {
throw new Error(`only simple identifiers allowed in lambda parameter list but found ${JSON.stringify(node, null, 2)}`);
}
}
names.reverse();
return names;
}
static isCommaNode(node) {
return node instanceof Node && node.op === operators[","] && node.rhs instanceof Identifier;
}
}
{
"version": 3,
"sources": ["../src/Parameters.ts"],
"sourcesContent": ["import operators from './operators'\nimport Node from './Node'\nimport Expression from './Expression'\nimport Identifier from './Identifier'\n\nexport default class Parameters {\n constructor (parser, node) {\n // convert a node of comma-separated Identifiers to Parameters\n if (node instanceof Expression) {\n node = node.root\n }\n try {\n this.names = Parameters.nodeTreeToNames(node)\n } catch (e) {\n parser.error(e)\n }\n }\n\n extendContext (context, args) {\n if (!this.names) {\n return context\n } else {\n const newValues = {}\n this.names.forEach((name, index) => {\n newValues[name] = args[index]\n })\n return context.extend(newValues)\n }\n }\n\n get [Node.isExpressionOrIdentifierSymbol] () { return true }\n\n static nodeTreeToNames (node) {\n // left-associative series of commas produces a tree with children only on the lhs, so we can extract the leaves with a simplified depth-first traversal\n const names = []\n while (node) {\n if (node instanceof Identifier) {\n names.push(node.token)\n node = null\n } else if (this.isCommaNode(node)) {\n names.push(node.rhs.token)\n node = node.lhs\n } else {\n throw new Error(`only simple identifiers allowed in lambda parameter list but found ${JSON.stringify(node, null, 2)}`)\n }\n }\n names.reverse()\n return names\n }\n\n static isCommaNode (node) {\n return (\n (node instanceof Node) &&\n node.op === operators[','] &&\n (node.rhs instanceof Identifier)\n )\n }\n}\n"],
"mappings": ";AAAA;AACA;AACA;AACA;AAEA,qBAAqB,WAAW;AAAA,EAC9B,YAAa,QAAQ,MAAM;AAEzB,QAAI,gBAAgB,YAAY;AAC9B,aAAO,KAAK;AAAA,IACd;AACA,QAAI;AACF,WAAK,QAAQ,WAAW,gBAAgB,IAAI;AAAA,IAC9C,SAAS,GAAP;AACA,aAAO,MAAM,CAAC;AAAA,IAChB;AAAA,EACF;AAAA,EAEA,cAAe,SAAS,MAAM;AAC5B,QAAI,CAAC,KAAK,OAAO;AACf,aAAO;AAAA,IACT,OAAO;AACL,YAAM,YAAY,CAAC;AACnB,WAAK,MAAM,QAAQ,CAAC,MAAM,UAAU;AAClC,kBAAU,QAAQ,KAAK;AAAA,MACzB,CAAC;AACD,aAAO,QAAQ,OAAO,SAAS;AAAA,IACjC;AAAA,EACF;AAAA,OAEK,KAAK,kCAAmC;AAAE,WAAO;AAAA,EAAK;AAAA,SAEpD,gBAAiB,MAAM;AAE5B,UAAM,QAAQ,CAAC;AACf,WAAO,MAAM;AACX,UAAI,gBAAgB,YAAY;AAC9B,cAAM,KAAK,KAAK,KAAK;AACrB,eAAO;AAAA,MACT,WAAW,KAAK,YAAY,IAAI,GAAG;AACjC,cAAM,KAAK,KAAK,IAAI,KAAK;AACzB,eAAO,KAAK;AAAA,MACd,OAAO;AACL,cAAM,IAAI,MAAM,sEAAsE,KAAK,UAAU,MAAM,MAAM,CAAC,GAAG;AAAA,MACvH;AAAA,IACF;AACA,UAAM,QAAQ;AACd,WAAO;AAAA,EACT;AAAA,SAEO,YAAa,MAAM;AACxB,WACG,gBAAgB,QACjB,KAAK,OAAO,UAAU,QACrB,KAAK,eAAe;AAAA,EAEzB;AACF;",
"names": []
}
// @tko/utils.parser 🥊 4.0.0-beta1.0 ESM
import {
options,
objectForEach,
clonePlainObjectDeep,
extend,
hasOwnProperty
} from "@tko/utils";
import { default as Expression } from "./Expression";
import { default as Identifier } from "./Identifier";
import { default as Arguments } from "./Arguments";
import { default as Parameters } from "./Parameters";
import { default as Ternary } from "./Ternary";
import { default as Node } from "./Node";
import { default as operators } from "./operators";
const escapee = {
"'": "'",
'"': '"',
"`": "`",
"\\": "\\",
"/": "/",
"$": "$",
b: "\b",
f: "\f",
n: "\n",
r: "\r",
t: " "
};
export default class Parser {
white() {
var ch = this.ch;
while (ch && ch <= " ") {
ch = this.next();
}
return this.comment(ch);
}
comment(ch) {
if (ch !== "/") {
return ch;
}
var p = this.at;
var second = this.lookahead();
if (second === "/") {
while (ch) {
ch = this.next();
if (ch === "\n" || ch === "\r") {
break;
}
}
ch = this.next();
} else if (second === "*") {
while (ch) {
ch = this.next();
if (ch === "*" && this.lookahead() === "/") {
this.next();
break;
}
}
if (!ch) {
this.error("Unclosed comment, starting at character " + p);
}
this.next();
return this.white();
}
return ch;
}
next(c) {
if (c && c !== this.ch) {
this.error("Expected '" + c + "' but got '" + this.ch + "'");
}
this.ch = this.text.charAt(this.at);
this.at += 1;
return this.ch;
}
lookahead() {
return this.text[this.at];
}
error(m) {
if (m instanceof Error) {
throw m;
}
let [name, msg] = m.name ? [m.name, m.message] : [m, ""];
const message = `
${name} ${msg} of
${this.text}
` + Array(this.at).join(" ") + "_/ \u{1F525} \\_\n";
throw new Error(message);
}
name() {
var name = "";
var enclosedBy;
this.white();
var ch = this.ch;
if (ch === "'" || ch === '"') {
enclosedBy = ch;
ch = this.next();
}
while (ch) {
if (enclosedBy && ch === enclosedBy) {
this.white();
ch = this.next();
if (ch !== ":" && ch !== ",") {
this.error("Object name: " + name + " missing closing " + enclosedBy);
}
return name;
} else if (ch === ":" || ch <= " " || ch === "," || ch === "|") {
return name;
}
name += ch;
ch = this.next();
}
return name;
}
number() {
let number;
let string = "";
let ch = this.ch;
if (ch === "-") {
string = "-";
ch = this.next("-");
}
while (ch >= "0" && ch <= "9") {
string += ch;
ch = this.next();
}
if (ch === ".") {
string += ".";
ch = this.next();
while (ch && ch >= "0" && ch <= "9") {
string += ch;
ch = this.next();
}
}
if (ch === "e" || ch === "E") {
string += ch;
ch = this.next();
if (ch === "-" || ch === "+") {
string += ch;
ch = this.next();
}
while (ch >= "0" && ch <= "9") {
string += ch;
ch = this.next();
}
}
number = +string;
if (!isFinite(number)) {
options.onError(new Error("Bad number: " + number + " in " + string));
} else {
return number;
}
}
objectAddValue(object, key, value) {
if (value && value[Node.isExpressionOrIdentifierSymbol]) {
Object.defineProperty(object, key, {
get: () => Node.value_of(value, ...this.currentContextGlobals),
enumerable: true
});
} else if (Array.isArray(value)) {
Object.defineProperty(object, key, {
get: () => value.map((v) => Node.value_of(v, ...this.currentContextGlobals)),
enumerable: true
});
} else {
object[key] = value;
}
}
object() {
let key;
let object = {};
let ch = this.ch;
if (ch === "{") {
this.next("{");
ch = this.white();
if (ch === "}") {
ch = this.next("}");
return object;
}
while (ch) {
if (ch === '"' || ch === "'" || ch === "`") {
key = this.string();
} else {
key = this.name();
}
if (hasOwnProperty(object, key)) {
this.error('Duplicate key "' + key + '"');
}
if (this.white() === ":") {
ch = this.next(":");
this.objectAddValue(object, key, this.singleValueExpression());
} else {
const objectKeyIsValue = new Identifier(this, key, []);
this.objectAddValue(object, key, objectKeyIsValue);
}
ch = this.white();
if (ch === "}") {
ch = this.next("}");
return object;
}
this.next(",");
ch = this.white();
if (ch === "}") {
ch = this.next("}");
return object;
}
}
}
this.error("Bad object");
}
readString(delim) {
let string = "";
let nodes = [""];
let plusOp = operators["+"];
let hex;
let i;
let uffff;
let interpolate = delim === "`";
let ch = this.next();
while (ch) {
if (ch === delim) {
ch = this.next();
if (interpolate) {
nodes.push(plusOp);
}
nodes.push(string);
return nodes;
}
if (ch === "\\") {
ch = this.next();
if (ch === "u") {
uffff = 0;
for (i = 0; i < 4; i += 1) {
hex = parseInt(ch = this.next(), 16);
if (!isFinite(hex)) {
break;
}
uffff = uffff * 16 + hex;
}
string += String.fromCharCode(uffff);
} else if (typeof escapee[ch] === "string") {
string += escapee[ch];
} else {
break;
}
} else if (interpolate && ch === "$") {
ch = this.next();
if (ch === "{") {
this.next("{");
nodes.push(plusOp);
nodes.push(string);
nodes.push(plusOp);
nodes.push(this.expression());
string = "";
} else {
string += "$" + ch;
}
} else {
string += ch;
}
ch = this.next();
}
this.error("Bad string");
}
string() {
var ch = this.ch;
if (ch === '"') {
return this.readString('"').join("");
} else if (ch === "'") {
return this.readString("'").join("");
} else if (ch === "`") {
return Node.create_root(this.readString("`"));
}
this.error("Bad string");
}
array() {
let array = [];
let ch = this.ch;
if (ch === "[") {
ch = this.next("[");
this.white();
if (ch === "]") {
ch = this.next("]");
return array;
}
while (ch) {
array.push(this.singleValueExpression());
ch = this.white();
if (ch === "]") {
ch = this.next("]");
return array;
}
this.next(",");
ch = this.white();
}
}
this.error("Bad array");
}
value() {
this.white();
let ch = this.ch;
switch (ch) {
case "{":
return this.object();
case "[":
return this.array();
case '"':
case "'":
case "`":
return this.string();
case "-":
return this.number();
default:
return ch >= "0" && ch <= "9" ? this.number() : this.identifier();
}
}
operator(opts) {
let op = "";
let opFn;
let ch = this.white();
let isIdentifierChar = Identifier.is_valid_start_char;
while (ch) {
if (isIdentifierChar(ch) || ch <= " " || ch === "" || ch === '"' || ch === "'" || ch === "{" || ch === "(" || ch === "`" || ch === ")" || ch <= "9" && ch >= "0") {
break;
}
if (!opts.not_an_array && ch === "[") {
break;
}
op += ch;
ch = this.next();
if (ch === "@") {
break;
}
isIdentifierChar = Identifier.is_valid_continue_char;
}
if (op !== "") {
if (opts.prefix && op === "-") {
op = "&-";
}
opFn = operators[op];
if (!opFn) {
this.error("Bad operator: '" + op + "'.");
}
}
return opFn;
}
filter() {
let ch = this.next();
let args = [];
let nextFilter = function(v) {
return v;
};
let name = this.name();
if (!options.filters[name]) {
options.onError("Cannot find filter by the name of: " + name);
}
ch = this.white();
while (ch) {
if (ch === ":") {
ch = this.next();
args.push(this.singleValueExpression("|"));
}
if (ch === "|") {
nextFilter = this.filter();
break;
}
if (ch === ",") {
break;
}
ch = this.white();
}
var filter = function filter2(value, ignored, context, globals, node) {
var argValues = [value];
for (var i = 0, j = args.length; i < j; ++i) {
argValues.push(Node.value_of(args[i], context, globals, node));
}
return nextFilter(options.filters[name].apply(null, argValues));
};
filter.precedence = 1;
return filter;
}
expression(filterable = false, allowMultipleValues = true) {
let op;
let nodes = [];
let ch = this.white();
while (ch) {
op = this.operator({ prefix: true });
if (op) {
nodes.push(void 0);
nodes.push(op);
ch = this.white();
}
if (ch === "(") {
this.next();
nodes.push(this.expression());
this.next(")");
} else {
nodes.push(this.value());
}
ch = this.white();
if (ch === ":" || ch === "}" || ch === "]" || ch === ")" || ch === "" || ch === "`" || ch === "|" && filterable === "|" || ch === "," && !allowMultipleValues) {
break;
}
if (ch === "|" && this.lookahead() !== "|" && filterable) {
nodes.push(this.filter());
nodes.push(void 0);
break;
}
op = this.operator({ not_an_array: true });
if (op === operators["?"]) {
this.ternary(nodes);
break;
} else if (op === operators["."]) {
nodes.push(op);
nodes.push(this.member());
op = null;
} else if (op === operators["["]) {
nodes.push(op);
nodes.push(this.expression());
ch = this.next("]");
op = null;
} else if (op === operators["=>"]) {
nodes[nodes.length - 1] = new Parameters(this, nodes[nodes.length - 1]);
nodes.push(op);
} else if (op) {
nodes.push(op);
}
ch = this.white();
if (ch === "]" || !op && ch === "(") {
break;
}
}
if (nodes.length === 0) {
return void 0;
}
var dereferences = this.dereferences();
if (nodes.length === 1 && !dereferences.length) {
return nodes[0];
}
for (var i = 0, j = dereferences.length; i < j; ++i) {
var deref = dereferences[i];
if (deref.constructor === Arguments) {
nodes.push(operators.call);
} else {
nodes.push(operators["."]);
}
nodes.push(deref);
}
return new Expression(nodes);
}
singleValueExpression(filterable) {
return this.expression(filterable, false);
}
ternary(nodes) {
var ternary = new Ternary();
ternary.yes = this.singleValueExpression();
this.next(":");
ternary.no = this.singleValueExpression();
nodes.push(operators["?"]);
nodes.push(ternary);
}
funcArguments() {
let args = [];
let ch = this.next("(");
while (ch) {
ch = this.white();
if (ch === ")") {
this.next(")");
return new Arguments(this, args);
} else {
args.push(this.singleValueExpression());
ch = this.white();
}
if (ch !== ")") {
this.next(",");
}
}
this.error("Bad arguments to function");
}
member() {
let member = "";
let ch = this.white();
let isIdentifierChar = Identifier.is_valid_start_char;
while (ch) {
if (!isIdentifierChar(ch)) {
break;
}
member += ch;
ch = this.next();
isIdentifierChar = Identifier.is_valid_continue_char;
}
return member;
}
dereference() {
let member;
let ch = this.white();
while (ch) {
if (ch === "(") {
return this.funcArguments();
} else if (ch === "[") {
this.next("[");
member = this.expression();
this.white();
this.next("]");
return member;
} else if (ch === ".") {
this.next(".");
return this.member();
} else {
break;
}
}
}
dereferences() {
let ch = this.white();
let dereferences = [];
let deref;
while (ch) {
deref = this.dereference();
if (deref !== void 0) {
dereferences.push(deref);
} else {
break;
}
}
return dereferences;
}
identifier() {
let token = "";
let isIdentifierChar = Identifier.is_valid_start_char;
let ch = this.white();
while (ch) {
if (!isIdentifierChar(ch)) {
break;
}
token += ch;
ch = this.next();
isIdentifierChar = Identifier.is_valid_continue_char;
}
switch (token) {
case "true":
return true;
case "false":
return false;
case "null":
return null;
case "undefined":
return void 0;
case "function":
throw new Error("Knockout: Anonymous functions are no longer supported, but `=>` lambdas are. In: " + this.text);
}
return new Identifier(this, token, this.dereferences());
}
readBindings() {
let key;
let bindings = {};
let sep;
let expr;
let ch = this.ch;
while (ch) {
key = this.name();
sep = this.white();
if (!sep || sep === ",") {
if (sep) {
ch = this.next(",");
} else {
ch = "";
}
bindings[key] = null;
} else {
if (key.indexOf(".") !== -1) {
key = key.split(".");
bindings[key[0]] = bindings[key[0]] || {};
if (key.length !== 2) {
options.onError("Binding " + key + " should have two parts (a.b).");
} else if (bindings[key[0]].constructor !== Object) {
options.onError("Binding " + key[0] + "." + key[1] + " paired with a non-object.");
}
ch = this.next(":");
this.objectAddValue(bindings[key[0]], key[1], this.singleValueExpression(true));
} else {
ch = this.next(":");
if (bindings[key] && typeof bindings[key] === "object" && bindings[key].constructor === Object) {
expr = this.singleValueExpression(true);
if (typeof expr !== "object" || expr.constructor !== Object) {
options.onError("Expected plain object for " + key + " value.");
} else {
extend(bindings[key], expr);
}
} else {
bindings[key] = this.singleValueExpression(true);
}
}
this.white();
if (this.ch) {
ch = this.next(",");
} else {
ch = "";
}
}
}
return bindings;
}
valueAsAccessor(value, context, globals, node) {
if (!value) {
return () => value;
}
if (typeof value === "function") {
return value;
}
if (value[Node.isExpressionOrIdentifierSymbol]) {
return () => Node.value_of(value, context, globals, node);
}
if (Array.isArray(value)) {
return () => value.map((v) => Node.value_of(v, context, globals, node));
}
if (typeof value !== "function") {
return () => clonePlainObjectDeep(value);
}
throw new Error("Value has cannot be converted to accessor: " + value);
}
convertToAccessors(result, context, globals, node) {
objectForEach(result, (name, value) => {
if (value instanceof Identifier) {
Object.defineProperty(result, name, {
value: function(optionalValue, options2) {
const currentValue = value.get_value(void 0, context, globals, node);
if (arguments.length === 0) {
return currentValue;
}
const unchanged = optionalValue === currentValue;
if (options2 && options2.onlyIfChanged && unchanged) {
return;
}
return value.set_value(optionalValue, context, globals);
}
});
} else {
result[name] = this.valueAsAccessor(value, context, globals, node);
}
});
return result;
}
preparse(source = "") {
const preparsers = options.bindingStringPreparsers || [];
return preparsers.reduce((acc, fn) => fn(acc), source.trim());
}
runParse(source, fn) {
this.text = this.preparse(source);
this.at = 0;
this.ch = " ";
try {
var result = fn();
this.white();
if (this.ch) {
this.error("Syntax Error");
}
return result;
} catch (e) {
options.onError(e);
}
}
parse(source, context = {}, globals = {}, node) {
if (!source) {
return () => null;
}
this.currentContextGlobals = [context, globals, node];
const parseFn = () => this.readBindings();
const bindingAccessors = this.runParse(source, parseFn);
return this.convertToAccessors(bindingAccessors, context, globals, node);
}
parseExpression(source, context = {}, globals = {}, node) {
if (!source) {
return () => "";
}
this.currentContextGlobals = [context, globals, node];
const parseFn = () => this.singleValueExpression(true);
const bindingAccessors = this.runParse(source, parseFn);
return this.valueAsAccessor(bindingAccessors, context, globals, node);
}
}
{
"version": 3,
"sources": ["../src/Parser.ts"],
"sourcesContent": ["/**\n * Originally based on (public domain):\n * https://github.com/douglascrockford/JSON-js/blob/master/json_parse.js\n */\n\nimport {\n options, objectForEach, clonePlainObjectDeep, extend, hasOwnProperty\n} from '@tko/utils'\n\nimport {default as Expression} from './Expression'\nimport {default as Identifier} from './Identifier'\nimport {default as Arguments} from './Arguments'\nimport {default as Parameters} from './Parameters'\nimport {default as Ternary} from './Ternary'\nimport {default as Node} from './Node'\nimport {default as operators} from './operators'\n\nconst escapee = {\n \"'\": \"'\",\n '\"': '\"',\n '`': '`',\n '\\\\': '\\\\',\n '/': '/',\n '$': '$',\n b: '\\b',\n f: '\\f',\n n: '\\n',\n r: '\\r',\n t: '\\t'\n}\n\n/**\n * Construct a new Parser instance with new Parser(node, context)\n * @param {Node} node The DOM element from which we parsed the\n * content.\n * @param {object} context The Knockout context.\n * @param {object} globals An object containing any desired globals.\n */\nexport default class Parser {\n white () {\n var ch = this.ch\n while (ch && ch <= ' ') {\n ch = this.next()\n }\n return this.comment(ch)\n }\n\n/**\n * Slurp any C or C++ style comments\n */\n comment (ch) {\n if (ch !== '/') { return ch }\n var p = this.at\n var second = this.lookahead()\n if (second === '/') {\n while (ch) {\n ch = this.next()\n if (ch === '\\n' || ch === '\\r') { break }\n }\n ch = this.next()\n } else if (second === '*') {\n while (ch) {\n ch = this.next()\n if (ch === '*' && this.lookahead() === '/') {\n this.next()\n break\n }\n }\n if (!ch) {\n this.error('Unclosed comment, starting at character ' + p)\n }\n this.next()\n return this.white()\n }\n return ch\n };\n\n next (c) {\n if (c && c !== this.ch) {\n this.error(\"Expected '\" + c + \"' but got '\" + this.ch + \"'\")\n }\n this.ch = this.text.charAt(this.at)\n this.at += 1\n return this.ch\n }\n\n lookahead () {\n return this.text[this.at]\n }\n\n error (m) {\n if (m instanceof Error) { throw m }\n let [name, msg] = m.name ? [m.name, m.message] : [m, '']\n const message = `\\n${name} ${msg} of\n ${this.text}\\n` + Array(this.at).join(' ') + '_/ \uD83D\uDD25 \\\\_\\n'\n throw new Error(message)\n }\n\n name () {\n // A name of a binding\n var name = ''\n var enclosedBy\n this.white()\n\n var ch = this.ch\n\n if (ch === \"'\" || ch === '\"') {\n enclosedBy = ch\n ch = this.next()\n }\n\n while (ch) {\n if (enclosedBy && ch === enclosedBy) {\n this.white()\n ch = this.next()\n if (ch !== ':' && ch !== ',') {\n this.error(\n 'Object name: ' + name + ' missing closing ' + enclosedBy\n )\n }\n return name\n } else if (ch === ':' || ch <= ' ' || ch === ',' || ch === '|') {\n return name\n }\n name += ch\n ch = this.next()\n }\n\n return name\n }\n\n number () {\n let number\n let string = ''\n let ch = this.ch\n\n if (ch === '-') {\n string = '-'\n ch = this.next('-')\n }\n while (ch >= '0' && ch <= '9') {\n string += ch\n ch = this.next()\n }\n if (ch === '.') {\n string += '.'\n ch = this.next()\n while (ch && ch >= '0' && ch <= '9') {\n string += ch\n ch = this.next()\n }\n }\n if (ch === 'e' || ch === 'E') {\n string += ch\n ch = this.next()\n if (ch === '-' || ch === '+') {\n string += ch\n ch = this.next()\n }\n while (ch >= '0' && ch <= '9') {\n string += ch\n ch = this.next()\n }\n }\n number = +string\n if (!isFinite(number)) {\n options.onError(new Error('Bad number: ' + number + ' in ' + string))\n } else {\n return number\n }\n }\n\n/**\n * Add a property to 'object' that equals the given value.\n * @param {Object} object The object to add the value to.\n * @param {String} key object[key] is set to the given value.\n * @param {mixed} value The value, may be a primitive or a function. If a\n * function it is unwrapped as a property.\n */\n objectAddValue (object, key, value) {\n if (value && value[Node.isExpressionOrIdentifierSymbol]) {\n Object.defineProperty(object, key, {\n get: () => Node.value_of(value, ...this.currentContextGlobals),\n enumerable: true\n })\n } else if (Array.isArray(value)) {\n Object.defineProperty(object, key, {\n get: () => value.map(v => Node.value_of(v, ...this.currentContextGlobals)),\n enumerable: true\n })\n } else {\n // primitives\n object[key] = value\n }\n }\n\n object () {\n let key\n let object = {}\n let ch = this.ch\n\n if (ch === '{') {\n this.next('{')\n ch = this.white()\n if (ch === '}') {\n ch = this.next('}')\n return object\n }\n while (ch) {\n if (ch === '\"' || ch === \"'\" || ch === '`') {\n key = this.string()\n } else {\n key = this.name()\n }\n if (hasOwnProperty(object, key)) {\n this.error('Duplicate key \"' + key + '\"')\n }\n if (this.white() === ':') {\n ch = this.next(':')\n this.objectAddValue(object, key, this.singleValueExpression())\n } else {\n const objectKeyIsValue = new Identifier(this, key, [])\n this.objectAddValue(object, key, objectKeyIsValue)\n }\n\n ch = this.white()\n if (ch === '}') {\n ch = this.next('}')\n return object\n }\n\n this.next(',')\n ch = this.white()\n if (ch === '}') {\n ch = this.next('}')\n return object\n }\n }\n }\n this.error('Bad object')\n }\n\n/**\n * Read up to delim and return the string\n * @param {string} delim The delimiter, either ' or \"\n * @return {string} The string read.\n */\n readString (delim) {\n let string = ''\n let nodes = ['']\n let plusOp = operators['+']\n let hex\n let i\n let uffff\n let interpolate = delim === '`'\n let ch = this.next()\n\n while (ch) {\n if (ch === delim) {\n ch = this.next()\n if (interpolate) { nodes.push(plusOp) }\n nodes.push(string)\n return nodes\n }\n if (ch === '\\\\') {\n ch = this.next()\n if (ch === 'u') {\n uffff = 0\n for (i = 0; i < 4; i += 1) {\n hex = parseInt(ch = this.next(), 16)\n if (!isFinite(hex)) {\n break\n }\n uffff = uffff * 16 + hex\n }\n string += String.fromCharCode(uffff)\n } else if (typeof escapee[ch] === 'string') {\n string += escapee[ch]\n } else {\n break\n }\n } else if (interpolate && ch === '$') {\n ch = this.next()\n if (ch === '{') {\n this.next('{')\n nodes.push(plusOp)\n nodes.push(string)\n nodes.push(plusOp)\n nodes.push(this.expression())\n string = ''\n // this.next('}');\n } else {\n string += '$' + ch\n }\n } else {\n string += ch\n }\n ch = this.next()\n }\n\n this.error('Bad string')\n }\n\n string () {\n var ch = this.ch\n if (ch === '\"') {\n return this.readString('\"').join('')\n } else if (ch === \"'\") {\n return this.readString(\"'\").join('')\n } else if (ch === '`') {\n return Node.create_root(this.readString('`'))\n }\n\n this.error('Bad string')\n }\n\n array () {\n let array = []\n let ch = this.ch\n\n if (ch === '[') {\n ch = this.next('[')\n this.white()\n if (ch === ']') {\n ch = this.next(']')\n return array\n }\n while (ch) {\n array.push(this.singleValueExpression())\n ch = this.white()\n if (ch === ']') {\n ch = this.next(']')\n return array\n }\n this.next(',')\n ch = this.white()\n }\n }\n this.error('Bad array')\n }\n\n value () {\n this.white()\n let ch = this.ch\n switch (ch) {\n case '{': return this.object()\n case '[': return this.array()\n case '\"': case \"'\": case '`': return this.string()\n case '-': return this.number()\n default:\n return ch >= '0' && ch <= '9' ? this.number() : this.identifier()\n }\n }\n\n/**\n * Get the function for the given operator.\n * A `.precedence` value is added to the function, with increasing\n * precedence having a higher number.\n * @return {function} The function that performs the infix operation\n */\n operator (opts) {\n let op = ''\n let opFn\n let ch = this.white()\n let isIdentifierChar = Identifier.is_valid_start_char\n\n while (ch) {\n if (isIdentifierChar(ch) || ch <= ' ' || ch === '' ||\n ch === '\"' || ch === \"'\" || ch === '{' || ch === '(' ||\n ch === '`' || ch === ')' || (ch <= '9' && ch >= '0')) {\n break\n }\n\n if (!opts.not_an_array && ch === '[') {\n break\n }\n\n op += ch\n ch = this.next()\n\n // An infix followed by the prefix e.g. a + @b\n // TODO: other prefix unary operators\n if (ch === '@') {\n break\n }\n\n isIdentifierChar = Identifier.is_valid_continue_char\n }\n\n if (op !== '') {\n if (opts.prefix && op === '-') { op = '&-' }\n opFn = operators[op]\n\n if (!opFn) {\n this.error(\"Bad operator: '\" + op + \"'.\")\n }\n }\n\n return opFn\n }\n\n/**\n * Filters\n * Returns what the Node interprets as an \"operator\".\n * e.g.\n * <span data-bind=\"text: name | fit:20 | uppercase\"></span>\n */\n filter () {\n let ch = this.next()\n let args = []\n let nextFilter = function (v) { return v }\n let name = this.name()\n\n if (!options.filters[name]) {\n options.onError('Cannot find filter by the name of: ' + name)\n }\n\n ch = this.white()\n\n while (ch) {\n if (ch === ':') {\n ch = this.next()\n args.push(this.singleValueExpression('|'))\n }\n\n if (ch === '|') {\n nextFilter = this.filter()\n break\n }\n\n if (ch === ',') { break }\n\n ch = this.white()\n }\n\n var filter = function filter (value, ignored, context, globals, node) {\n var argValues = [value]\n\n for (var i = 0, j = args.length; i < j; ++i) {\n argValues.push(Node.value_of(args[i], context, globals, node))\n }\n\n return nextFilter(options.filters[name].apply(null, argValues))\n }\n\n // Lowest precedence.\n filter.precedence = 1\n return filter\n }\n\n/**\n * Parse an expression \u2013 builds an operator tree, in something like\n * Shunting-Yard.\n * See: http://en.wikipedia.org/wiki/Shunting-yard_algorithm\n *\n * @param filterable - Whether the expression can include jinga-style filters.\n * An argument of '|' is used only by the filter() method to parse subsequent\n * filters.\n * @param allowMultipleValues - Whether multiple values separated by commas are\n * allowed in this expression. When true (default), this method consumes\n * subsequent comma-separated values.\n * @see {@link Parser.singleValueExpression}\n * \n * @returns a function that computes the value of the expression\n * when called or a primitive.\n */\n expression (filterable: string | bool = false, allowMultipleValues: bool = true) {\n let op\n let nodes = []\n let ch = this.white()\n\n while (ch) {\n // unary prefix operators\n op = this.operator({ prefix: true })\n if (op) {\n nodes.push(undefined) // LHS Tree node.\n nodes.push(op)\n ch = this.white()\n }\n\n if (ch === '(') {\n this.next()\n nodes.push(this.expression())\n this.next(')')\n } else {\n nodes.push(this.value())\n }\n ch = this.white()\n\n if (ch === ':' || ch === '}' || ch === ']' ||\n ch === ')' || ch === '' || ch === '`' ||\n (ch === '|' && filterable === '|') ||\n (ch === ',' && !allowMultipleValues)) {\n break\n }\n\n // filters\n if (ch === '|' && this.lookahead() !== '|' && filterable) {\n nodes.push(this.filter())\n nodes.push(undefined)\n break\n }\n\n // infix or postfix operators\n op = this.operator({ not_an_array: true })\n\n if (op === operators['?']) {\n this.ternary(nodes)\n break\n } else if (op === operators['.']) {\n nodes.push(op)\n nodes.push(this.member())\n op = null\n } else if (op === operators['[']) {\n nodes.push(op)\n nodes.push(this.expression())\n ch = this.next(']')\n op = null\n } else if (op === operators['=>']) {\n // convert the last node to Parameters\n nodes[nodes.length-1] = new Parameters(this, nodes[nodes.length-1])\n nodes.push(op)\n } else if (op) {\n nodes.push(op)\n }\n\n ch = this.white()\n\n if (ch === ']' || (!op && ch === '(')) { break }\n }\n\n if (nodes.length === 0) {\n return undefined\n }\n\n var dereferences = this.dereferences()\n\n if (nodes.length === 1 && !dereferences.length) {\n return nodes[0]\n }\n\n for (var i = 0, j = dereferences.length; i < j; ++i) {\n var deref = dereferences[i]\n if (deref.constructor === Arguments) {\n nodes.push(operators.call)\n } else {\n nodes.push(operators['.'])\n }\n nodes.push(deref)\n }\n\n return new Expression(nodes)\n }\n\n/**\n * Use this method to parse expressions that can be followed by additional markup\n * seperated by a comma, such as in bindings strings.\n * \n * @returns an expression that cannot contain multiple values separated by commas.\n * @see {@link Parser.expression}\n */\n singleValueExpression (filterable: bool | string) {\n return this.expression(filterable, false)\n }\n\n ternary (nodes) {\n var ternary = new Ternary()\n ternary.yes = this.singleValueExpression()\n this.next(':')\n ternary.no = this.singleValueExpression()\n nodes.push(operators['?'])\n nodes.push(ternary)\n }\n\n/**\n * Parse the arguments to a function, returning an Array.\n *\n */\n funcArguments () {\n let args = []\n let ch = this.next('(')\n\n while (ch) {\n ch = this.white()\n if (ch === ')') {\n this.next(')')\n return new Arguments(this, args)\n } else {\n args.push(this.singleValueExpression())\n ch = this.white()\n }\n if (ch !== ')') { this.next(',') }\n }\n\n this.error('Bad arguments to function')\n }\n\n/**\n * The literal string reference `abc` in an `x.abc` expression.\n */\n member () {\n let member = ''\n let ch = this.white()\n let isIdentifierChar = Identifier.is_valid_start_char\n\n while (ch) {\n if (!isIdentifierChar(ch)) {\n break\n }\n member += ch\n ch = this.next()\n isIdentifierChar = Identifier.is_valid_continue_char\n }\n return member\n }\n\n/**\n * A dereference applies to an identifer, being either a function\n * call \"()\" or a membership lookup with square brackets \"[member]\".\n * @return {fn or undefined} Dereference function to be applied to the\n * Identifier\n */\n dereference () {\n let member\n let ch = this.white()\n\n while (ch) {\n if (ch === '(') {\n // a(...) function call\n return this.funcArguments()\n } else if (ch === '[') {\n // a[x] membership\n this.next('[')\n member = this.expression()\n this.white()\n this.next(']')\n\n return member\n } else if (ch === '.') {\n // a.x membership\n this.next('.')\n return this.member()\n } else {\n break\n }\n }\n }\n\n dereferences () {\n let ch = this.white()\n let dereferences = []\n let deref\n\n while (ch) {\n deref = this.dereference()\n if (deref !== undefined) {\n dereferences.push(deref)\n } else {\n break\n }\n }\n return dereferences\n }\n\n identifier () {\n let token = ''\n let isIdentifierChar = Identifier.is_valid_start_char\n let ch = this.white()\n\n while (ch) {\n if (!isIdentifierChar(ch)) {\n break\n }\n token += ch\n ch = this.next()\n isIdentifierChar = Identifier.is_valid_continue_char\n }\n switch (token) {\n case 'true': return true\n case 'false': return false\n case 'null': return null\n case 'undefined': return void 0\n case 'function':\n throw new Error('Knockout: Anonymous functions are no longer supported, but `=>` lambdas are. In: ' + this.text)\n // return this.anonymous_fn();\n }\n return new Identifier(this, token, this.dereferences())\n }\n\n readBindings () {\n let key\n let bindings = {}\n let sep\n let expr\n let ch = this.ch\n\n while (ch) {\n key = this.name()\n sep = this.white()\n\n if (!sep || sep === ',') {\n if (sep) {\n ch = this.next(',')\n } else {\n ch = ''\n }\n // A \"bare\" binding e.g. \"text\"; substitute value of 'null'\n // so it becomes \"text: null\".\n bindings[key] = null\n } else {\n if (key.indexOf('.') !== -1) {\n // Namespaced \u2013 i.e.\n // `attr.css: x` becomes `attr: { css: x }`\n // ^^^ - key\n key = key.split('.')\n bindings[key[0]] = bindings[key[0]] || {}\n\n if (key.length !== 2) {\n options.onError('Binding ' + key + ' should have two parts (a.b).')\n } else if (bindings[key[0]].constructor !== Object) {\n options.onError('Binding ' + key[0] + '.' + key[1] + ' paired with a non-object.')\n }\n\n ch = this.next(':')\n this.objectAddValue(bindings[key[0]], key[1], this.singleValueExpression(true))\n } else {\n ch = this.next(':')\n if (bindings[key] && typeof bindings[key] === 'object' && bindings[key].constructor === Object) {\n // Extend a namespaced bindings e.g. we've previously seen\n // on.x, now we're seeing on: { 'abc' }.\n expr = this.singleValueExpression(true)\n if (typeof expr !== 'object' || expr.constructor !== Object) {\n options.onError('Expected plain object for ' + key + ' value.')\n } else {\n extend(bindings[key], expr)\n }\n } else {\n bindings[key] = this.singleValueExpression(true)\n }\n }\n\n this.white()\n if (this.ch) {\n ch = this.next(',')\n } else {\n ch = ''\n }\n }\n }\n return bindings\n }\n\n valueAsAccessor (value, context, globals, node) {\n if (!value) { return () => value }\n if (typeof value === 'function') { return value }\n\n if (value[Node.isExpressionOrIdentifierSymbol]) {\n return () => Node.value_of(value, context, globals, node)\n }\n\n if (Array.isArray(value)) {\n return () => value.map(v => Node.value_of(v, context, globals, node))\n }\n\n if (typeof (value) !== 'function') {\n return () => clonePlainObjectDeep(value)\n }\n\n throw new Error('Value has cannot be converted to accessor: ' + value)\n }\n\n /**\n * Convert result[name] from a value to a function (i.e. `valueAccessor()`)\n * @param {object} result [Map of top-level names to values]\n * @return {object} [Map of top-level names to functions]\n *\n * Accessors may be one of (below) constAccessor, identifierAccessor,\n * expressionAccessor, or nodeAccessor.\n */\n convertToAccessors (result, context, globals, node) {\n objectForEach(result, (name, value) => {\n if (value instanceof Identifier) {\n // Return a function that, with no arguments returns\n // the value of the identifier, otherwise sets the\n // value of the identifier to the first given argument.\n Object.defineProperty(result, name, {\n value: function (optionalValue, options) {\n const currentValue = value.get_value(undefined, context, globals, node)\n if (arguments.length === 0) { return currentValue }\n const unchanged = optionalValue === currentValue\n if (options && options.onlyIfChanged && unchanged) { return }\n return value.set_value(optionalValue, context, globals)\n }\n })\n } else {\n result[name] = this.valueAsAccessor(value, context, globals, node)\n }\n })\n return result\n }\n\n preparse (source = '') {\n const preparsers = options.bindingStringPreparsers || []\n return preparsers.reduce((acc, fn) => fn(acc), source.trim())\n }\n\n runParse (source, fn) {\n this.text = this.preparse(source)\n this.at = 0\n this.ch = ' '\n\n try {\n var result = fn()\n this.white()\n if (this.ch) {\n this.error('Syntax Error')\n }\n return result\n } catch (e) {\n options.onError(e)\n }\n }\n\n /**\n * Get the bindings as name: accessor()\n * @param {string} source The binding string to parse.\n * @return {object} Map of name to accessor function.\n */\n parse (source, context = {}, globals = {}, node) {\n if (!source) { return () => null }\n this.currentContextGlobals = [context, globals, node]\n const parseFn = () => this.readBindings()\n const bindingAccessors = this.runParse(source, parseFn)\n return this.convertToAccessors(bindingAccessors, context, globals, node)\n }\n\n /**\n * Return a function that evaluates and returns the result of the expression.\n */\n parseExpression (source, context = {}, globals = {}, node) {\n if (!source) { return () => '' }\n this.currentContextGlobals = [context, globals, node]\n const parseFn = () => this.singleValueExpression(true)\n const bindingAccessors = this.runParse(source, parseFn)\n return this.valueAsAccessor(bindingAccessors, context, globals, node)\n }\n}\n"],
"mappings": ";AAKA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,MAAM,UAAU;AAAA,EACd,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,MAAM;AAAA,EACN,KAAK;AAAA,EACL,KAAK;AAAA,EACL,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AACL;AASA,qBAAqB,OAAO;AAAA,EAC1B,QAAS;AACP,QAAI,KAAK,KAAK;AACd,WAAO,MAAM,MAAM,KAAK;AACtB,WAAK,KAAK,KAAK;AAAA,IACjB;AACA,WAAO,KAAK,QAAQ,EAAE;AAAA,EACxB;AAAA,EAKA,QAAS,IAAI;AACX,QAAI,OAAO,KAAK;AAAE,aAAO;AAAA,IAAG;AAC5B,QAAI,IAAI,KAAK;AACb,QAAI,SAAS,KAAK,UAAU;AAC5B,QAAI,WAAW,KAAK;AAClB,aAAO,IAAI;AACT,aAAK,KAAK,KAAK;AACf,YAAI,OAAO,QAAQ,OAAO,MAAM;AAAE;AAAA,QAAM;AAAA,MAC1C;AACA,WAAK,KAAK,KAAK;AAAA,IACjB,WAAW,WAAW,KAAK;AACzB,aAAO,IAAI;AACT,aAAK,KAAK,KAAK;AACf,YAAI,OAAO,OAAO,KAAK,UAAU,MAAM,KAAK;AAC1C,eAAK,KAAK;AACV;AAAA,QACF;AAAA,MACF;AACA,UAAI,CAAC,IAAI;AACP,aAAK,MAAM,6CAA6C,CAAC;AAAA,MAC3D;AACA,WAAK,KAAK;AACV,aAAO,KAAK,MAAM;AAAA,IACpB;AACA,WAAO;AAAA,EACT;AAAA,EAEA,KAAM,GAAG;AACP,QAAI,KAAK,MAAM,K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.|[^/])+/\\w*",
"[^\\s:,/][^" + specials + "]*[^\\s" + specials + "]",
"[^\\s]"
].join("|"), "g");
const divisionLookBehind = /[\])"'A-Za-z0-9_$]+$/;
const keywordRegexLookBehind = { "in": 1, "return": 1, "typeof": 1 };
export default function parseObjectLiteral(objectLiteralString) {
var str = stringTrim(objectLiteralString);
if (str.charCodeAt(0) === 123)
str = str.slice(1, -1);
str += "\n,";
var result = [];
var toks = str.match(bindingToken);
var key;
var values = [];
var depth = 0;
if (toks.length <= 1) {
return [];
}
for (var i = 0, tok; tok = toks[i]; ++i) {
var c = tok.charCodeAt(0);
if (c === 44) {
if (depth <= 0) {
result.push(key && values.length ? {
key,
value: values.join("")
} : {
"unknown": key || values.join("")
});
key = depth = 0;
values = [];
continue;
}
} else if (c === 58) {
if (!depth && !key && values.length === 1) {
key = values.pop();
continue;
}
} else if (c === 47 && tok.length > 1 && (tok.charCodeAt(1) === 47 || tok.charCodeAt(1) === 42)) {
continue;
} else if (c === 47 && i && tok.length > 1) {
var match = toks[i - 1].match(divisionLookBehind);
if (match && !keywordRegexLookBehind[match[0]]) {
str = str.substr(str.indexOf(tok) + 1);
toks = str.match(bindingToken);
i = -1;
tok = "/";
}
} else if (c === 40 || c === 123 || c === 91) {
++depth;
} else if (c === 41 || c === 125 || c === 93) {
--depth;
} else if (!key && !values.length && (c === 34 || c === 39)) {
tok = tok.slice(1, -1);
}
values.push(tok);
}
return result;
}
{
"version": 3,
"sources": ["../src/preparse.ts"],
"sourcesContent": ["import {\n stringTrim\n} from '@tko/utils'\n\n/* eslint no-cond-assign: 0 */\n\n// The following regular expressions will be used to split an object-literal string into tokens\n\n// These characters have special meaning to the parser and must not appear in the middle of a\n// token, except as part of a string.\nconst specials = ',\"\\'`{}()/:[\\\\]'\nconst bindingToken = RegExp([\n // These match strings, either with double quotes, single quotes, or backticks\n '\"(?:\\\\\\\\.|[^\"])*\"',\n \"'(?:\\\\\\\\.|[^'])*'\",\n '`(?:\\\\\\\\.|[^`])*`',\n // Match C style comments\n '/\\\\*(?:[^*]|\\\\*+[^*/])*\\\\*+/',\n // Match C++ style comments\n '//.*\\n',\n // Match a regular expression (text enclosed by slashes), but will also match sets of divisions\n // as a regular expression (this is handled by the parsing loop below).\n '/(?:\\\\\\\\.|[^/])+/\\\\w*',\n // Match text (at least two characters) that does not contain any of the above special characters,\n // although some of the special characters are allowed to start it (all but the colon and comma).\n // The text can contain spaces, but leading or trailing spaces are skipped.\n '[^\\\\s:,/][^' + specials + ']*[^\\\\s' + specials + ']',\n // Match any non-space character not matched already. This will match colons and commas, since they're\n // not matched by \"everyThingElse\", but will also match any other single character that wasn't already\n // matched (for example: in \"a: 1, b: 2\", each of the non-space characters will be matched by oneNotSpace).\n '[^\\\\s]'\n].join('|'), 'g')\n\n // Match end of previous token to determine whether a slash is a division or regex.\nconst divisionLookBehind = /[\\])\"'A-Za-z0-9_$]+$/\nconst keywordRegexLookBehind = { 'in': 1, 'return': 1, 'typeof': 1 }\n\n/**\n * Break a binding string (data-bind='x: val, y: ..') into a stable array\n * of {key: value}.\n */\nexport default function parseObjectLiteral (objectLiteralString) {\n // Trim leading and trailing spaces from the string\n var str = stringTrim(objectLiteralString)\n\n // Trim braces '{' surrounding the whole object literal\n if (str.charCodeAt(0) === 123) str = str.slice(1, -1)\n\n // Add a newline to correctly match a C++ style comment at the end of the string and\n // add a comma so that we don't need a separate code block to deal with the last item\n str += '\\n,'\n\n // Split into tokens\n var result = []\n var toks = str.match(bindingToken)\n var key\n var values = []\n var depth = 0\n\n if (toks.length <= 1) { return [] }\n\n for (var i = 0, tok; tok = toks[i]; ++i) {\n var c = tok.charCodeAt(0)\n // A comma signals the end of a key/value pair if depth is zero\n if (c === 44) { // \",\"\n if (depth <= 0) {\n result.push((key && values.length) ? {\n key: key,\n value: values.join('')\n } : {\n 'unknown': key || values.join('')\n })\n key = depth = 0\n values = []\n continue\n }\n // Simply skip the colon that separates the name and value\n } else if (c === 58) { // \":\"\n if (!depth && !key && values.length === 1) {\n key = values.pop()\n continue\n }\n // A set of slashes is initially matched as a regular expression, but could be division\n } else if (c === 47 && tok.length > 1 && (tok.charCodeAt(1) === 47 || tok.charCodeAt(1) === 42)) { // \"//\" or \"/*\"\n // skip comments\n continue\n } else if (c === 47 && i && tok.length > 1) { // \"/\"\n // Look at the end of the previous token to determine if the slash is actually division\n var match = toks[i - 1].match(divisionLookBehind)\n if (match && !keywordRegexLookBehind[match[0]]) {\n // The slash is actually a division punctuator; re-parse the remainder of the string (not including the slash)\n str = str.substr(str.indexOf(tok) + 1)\n toks = str.match(bindingToken)\n i = -1\n // Continue with just the slash\n tok = '/'\n }\n // Increment depth for parentheses, braces, and brackets so that interior commas are ignored\n } else if (c === 40 || c === 123 || c === 91) { // '(', '{', '['\n ++depth\n } else if (c === 41 || c === 125 || c === 93) { // ')', '}', ']'\n --depth\n // The key will be the first token; if it's a string, trim the quotes\n } else if (!key && !values.length && (c === 34 || c === 39)) { // '\"', \"'\"\n tok = tok.slice(1, -1)\n }\n values.push(tok)\n }\n\n return result\n}\n"],
"mappings": ";AAAA;AAAA;AAAA;AAUA,MAAM,WAAW;AACjB,MAAM,eAAe,OAAO;AAAA,EAE1B;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EAEA;AAAA,EAGA;AAAA,EAIA,gBAAgB,WAAW,YAAY,WAAW;AAAA,EAIlD;AACF,EAAE,KAAK,GAAG,GAAG,GAAG;AAGhB,MAAM,qBAAqB;AAC3B,MAAM,yBAAyB,EAAE,MAAM,GAAG,UAAU,GAAG,UAAU,EAAE;AAMnE,2CAA4C,qBAAqB;AAE/D,MAAI,MAAM,WAAW,mBAAmB;AAGxC,MAAI,IAAI,WAAW,CAAC,MAAM;AAAK,UAAM,IAAI,MAAM,GAAG,EAAE;AAIpD,SAAO;AAGP,MAAI,SAAS,CAAC;AACd,MAAI,OAAO,IAAI,MAAM,YAAY;AACjC,MAAI;AACJ,MAAI,SAAS,CAAC;AACd,MAAI,QAAQ;AAEZ,MAAI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names": []
}
// @tko/utils.parser 🥊 4.0.0-beta1.0 ESM
import Node from "./Node";
export default class Ternary {
constructor(yes, no) {
Object.assign(this, { yes, no });
}
get_value() {
return this;
}
get [Node.isExpressionOrIdentifierSymbol]() {
return true;
}
}
{
"version": 3,
"sources": ["../src/Ternary.ts"],
"sourcesContent": ["\nimport Node from './Node'\n\nexport default class Ternary {\n constructor (yes, no) {\n Object.assign(this, {yes, no})\n }\n\n get_value () { return this }\n\n get [Node.isExpressionOrIdentifierSymbol] () { return true }\n}\n"],
"mappings": ";AACA;AAEA,qBAAqB,QAAQ;AAAA,EAC3B,YAAa,KAAK,IAAI;AACpB,WAAO,OAAO,MAAM,EAAC,KAAK,GAAE,CAAC;AAAA,EAC/B;AAAA,EAEA,YAAa;AAAE,WAAO;AAAA,EAAK;AAAA,OAEtB,KAAK,kCAAmC;AAAE,WAAO;AAAA,EAAK;AAC7D;",
"names": []
}
+22
-24
{
"version": "4.0.0-beta1.0",
"name": "@tko/utils.parser",
"version": "4.0.0-alpha9.0",
"description": "Parse the Javascript-like language used in data-bind and other HTML attributes (CSP-safe)",

@@ -12,7 +12,7 @@ "module": "dist/utils.parser.js",

"dependencies": {
"@tko/observable": "^4.0.0-alpha8.0",
"@tko/utils": "^4.0.0-alpha8.0",
"tslib": "^1.8.0"
"@tko/observable": "^4.0.0-beta1.0",
"@tko/utils": "^4.0.0-beta1.0",
"tslib": "^2.2.0"
},
"devDependencies": {
"peerDependencies": {
"@tko/bind": "^4.0.0-alpha9.0",

@@ -29,19 +29,2 @@ "@tko/binding.core": "^4.0.0-alpha9.0",

},
"scripts": {
"test": "npx karma start ../../karma.conf.js --once",
"build": "npx rollup -c ../../rollup.config.js",
"watch": "npx karma start ../../karma.conf.js",
"prepare": "npx rollup -c ../../rollup.config.js"
},
"standard": {
"env": [
"browser",
"jasmine",
"mocha"
]
},
"__about__shared.package.json": "These properties are copied into all packages/*/package.json. Run `yarn repackage`",
"publishConfig": {
"access": "public"
},
"homepage": "https://tko.io",

@@ -51,6 +34,21 @@ "licenses": [

"type": "MIT",
"url": "http://www.opensource.org/licenses/mit-license.php"
"url": "https://opensource.org/licenses/MIT"
}
],
"gitHead": "90cdb597db01d50725c567810af092e70a5b32d9"
"exports": {
".": {
"require": "./dist/index.cjs",
"import": "./dist/index.js"
},
"./helpers/*": "./helpers/*"
},
"bugs": {
"url": "https://github.com/knockout/tko/issues"
},
"author": "The Knockout Team",
"repository": {
"type": "git",
"url": "git+https://github.com/knockout/tko.git"
},
"gitHead": "99114c4deded3fc5dbddd5c7c9c63c845a18263b"
}
/*!
* Parse the Javascript-like language used in data-bind and other HTML attributes (CSP-safe) 🥊 @tko/utils.parser@4.0.0-alpha9.0
* (c) The Knockout.js Team - https://tko.io
* License: MIT (http://www.opensource.org/licenses/mit-license.php)
*/
import { unwrap, isWriteableObservable, isObservable } from '@tko/observable';
import { hasOwnProperty, options, objectForEach, clonePlainObjectDeep, extend, stringTrim } from '@tko/utils';
function LAMBDA () {}
/**
* @ operator - recursively call the identifier if it's a function
* @param {operand} a ignored
* @param {operand} b The variable to be called (if a function) and unwrapped
* @return {value} The result.
*/
function unwrapOrCall (a, b) {
while (typeof b === 'function') { b = b(); }
return b
}
const operators = {
// unary
'@': unwrapOrCall,
'#': (a, b) => () => unwrap(b), // Convert to read-only.
'=>': LAMBDA,
'!': function not (a, b) { return !b },
'!!': function notnot (a, b) { return !!b },
'++': function preinc (a, b) { return ++b },
'--': function preinc (a, b) { return --b },
// mul/div
'*': function mul (a, b) { return a * b },
'/': function div (a, b) { return a / b },
'%': function mod (a, b) { return a % b },
// sub/add
'+': function add (a, b) { return a + b },
'-': function sub (a, b) { return (a || 0) - (b || 0) },
'&-': function neg (a, b) { return -1 * b },
// relational
'<': function lt (a, b) { return a < b },
'<=': function le (a, b) { return a <= b },
'>': function gt (a, b) { return a > b },
'>=': function ge (a, b) { return a >= b },
// TODO: 'in': function (a, b) { return a in b; },
// TODO: 'instanceof': function (a, b) { return a instanceof b; },
// equality
'==': function equal (a, b) { return a === b },
'!=': function ne (a, b) { return a !== b },
'===': function sequal (a, b) { return a === b },
'!==': function sne (a, b) { return a !== b },
// bitwise
'&': function bitAnd (a, b) { return a & b },
'^': function xor (a, b) { return a ^ b },
'|': function bitOr (a, b) { return a | b },
// logic
'&&': function logicAnd (a, b) { return a && b },
'||': function logicOr (a, b) { return a || b },
// Access
'.': function member (a, b) { return a[b] },
'[': function member (a, b) { return a[b] },
// conditional/ternary
// '?': ternary See Node.js
// Function-Call
'call': function callOp (a, b) { return a.apply(null, b) }
};
/* Order of precedence from:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence#Table
*/
// Our operator - unwrap/call
operators['@'].precedence = 21;
operators['#'].precedence = 21;
// lambda
operators['=>'].precedence = 20;
// Member
operators['.'].precedence = 19;
operators['['].precedence = 19;
// Logical not
operators['!'].precedence = 16;
operators['!!'].precedence = 16; // explicit double-negative
// Prefix inc/dec
operators['++'].precedence = 16;
operators['--'].precedence = 16;
operators['&-'].precedence = 16;
// mul/div/remainder
operators['%'].precedence = 14;
operators['*'].precedence = 14;
operators['/'].precedence = 14;
// add/sub
operators['+'].precedence = 13;
operators['-'].precedence = 13;
// bitwise
operators['|'].precedence = 12;
operators['^'].precedence = 11;
operators['&'].precedence = 10;
// comparison
operators['<'].precedence = 11;
operators['<='].precedence = 11;
operators['>'].precedence = 11;
operators['>='].precedence = 11;
// operators['in'].precedence = 8;
// operators['instanceof'].precedence = 8;
// equality
operators['=='].precedence = 10;
operators['!='].precedence = 10;
operators['==='].precedence = 10;
operators['!=='].precedence = 10;
// logic
operators['&&'].precedence = 6;
operators['||'].precedence = 5;
operators['&&'].earlyOut = (a) => !a;
operators['||'].earlyOut = (a) => a;
// Call a function
operators['call'].precedence = 1;
const IS_EXPR_OR_IDENT = Symbol('Node - Is Expression Or Identifier');
class Node {
constructor (lhs, op, rhs) {
this.lhs = lhs;
this.op = op;
this.rhs = rhs;
}
static get operators () { return operators }
get_leaf_value (leaf, context, globals, node) {
if (typeof leaf === 'function') {
// Expressions on observables are nonsensical, so we unwrap any
// function values (e.g. identifiers).
return unwrap(leaf())
}
// primitives
if (typeof leaf !== 'object' || leaf === null) { return leaf }
// Identifiers and Expressions
if (leaf[Node.isExpressionOrIdentifierSymbol]) {
// lhs is passed in as the parent of the leaf. It will be defined in
// cases like a.b.c as 'a' for 'b' then as 'b' for 'c'.
return unwrap(leaf.get_value(undefined, context, globals, node))
}
// Plain object/class.
return leaf
}
/**
* Return a function that calculates and returns an expression's value
* when called.
* @param {array} ops The operations to perform
* @return {function} The function that calculates the expression.
*
* Note that for a lambda, we do not evaluate the RHS expression until
* the lambda is called.
*/
get_value (notused, context, globals, node) {
var node = this;
if (node.op === LAMBDA) {
return () => node.get_leaf_value(node.rhs, context, globals, node)
}
const lhv = node.get_leaf_value(node.lhs, context, globals, node);
const earlyOut = node.op.earlyOut;
if (earlyOut && earlyOut(lhv)) { return lhv }
const rhv = node.get_leaf_value(node.rhs, context, globals, node);
return node.op(lhv, rhv, context, globals)
}
//
// Class variables.
//
static get isExpressionOrIdentifierSymbol () { return IS_EXPR_OR_IDENT }
get [IS_EXPR_OR_IDENT] () { return true }
static value_of (item, context, globals, node) {
if (item && item[Node.isExpressionOrIdentifierSymbol]) {
return item.get_value(item, context, globals, node)
}
return item
}
/**
* Convert an array of nodes to an executable tree.
* @return {object} An object with a `lhs`, `rhs` and `op` key, corresponding
* to the left hand side, right hand side, and
* operation function.
*/
static create_root (nodes) {
var root, leaf, op, value;
// Prime the leaf = root node.
leaf = root = new Node(nodes.shift(), nodes.shift(), nodes.shift());
while (true) {
op = nodes.shift();
value = nodes.shift();
if (!op) {
break
}
if (op.precedence < root.op.precedence) {
// rebase
root = new Node(root, op, value);
leaf = root;
} else {
leaf.rhs = new Node(leaf.rhs, op, value);
leaf = leaf.rhs;
}
}
// console.log('tree', root)
return root
}
}
/**
* Because of cyclical dependencies on operators <-> Node <-> value_of,
* we need to patch this in here.
*/
operators['?'] = function ternary (a, b, context, globals, node) {
return Node.value_of(a ? b.yes : b.no, context, globals, node)
};
operators['?'].precedence = 4;
class Expression {
constructor (nodes) {
this.nodes = nodes;
this.root = Node.create_root(nodes);
}
/**
* Return the value of `this` Expression instance.
*/
get_value (parent, context, globals, node) {
if (!this.root) {
this.root = Node.create_root(this.nodes);
}
return this.root.get_value(parent, context, globals, node)
}
}
Expression.prototype[Node.isExpressionOrIdentifierSymbol] = true;
class Arguments {
constructor (parser, args) {
this.parser = parser;
this.args = args;
}
get_value (parent, context, globals, node) {
var deReffedArgs = [];
for (var i = 0, j = this.args.length; i < j; ++i) {
deReffedArgs.push(Node.value_of(this.args[i], context, globals, node));
}
return deReffedArgs
};
get [Node.isExpressionOrIdentifierSymbol] () { return true }
}
/**
* The following regular expressions were generated by
* https://mathiasbynens.be/demo/javascript-identifier-regex
*/
var IDStart = /[\$A-Z_a-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B4\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AD\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/;
var IDContinue = /[\$0-9A-Z_a-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0-\u08B4\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\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u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFC-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AD\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C4\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/;
class Identifier {
constructor (parser, token, dereferences) {
this.token = token;
this.dereferences = dereferences;
this.parser = parser;
}
/**
* Apply all () and [] functions on the identifier to the lhs value e.g.
* a()[3] has deref functions that are essentially this:
* [_deref_call, _deref_this where this=3]
*
* @param {mixed} value Should be an object.
* @return {mixed} The dereferenced value.
*
* [1] We want to bind any function that is a method of an object, but not
* corrupt any values (e.g. computed()s). e.g. Running x.bind(obj) where
* we're given `data-bind='binding: obj.x'` and x is a computed will
* break the computed's `this` and it will stop working as expected.
*
* The test `!last_value.hasOwnProperty(member)`
* distinguishes between functions on the prototype chain (prototypal
* members) and value-members added directly to the object. This may
* not be the canonical test for this relationship, but it succeeds
* in the known test cases.
*
* See: `this` tests of our dereference function.
*/
dereference (value, $context, globals, node) {
let member;
let refs = this.dereferences || [];
const $data = $context.$data || {};
let lastValue; // becomes `this` in function calls to object properties.
let i, n;
for (i = 0, n = refs.length; i < n; ++i) {
member = Node.value_of(refs[i], $context, globals, node);
if (typeof value === 'function' && refs[i] instanceof Arguments) {
// fn(args)
value = value.apply(lastValue || $data, member);
lastValue = value;
} else {
// obj[x] or obj.x dereference. Note that obj may be a function.
lastValue = value;
value = Node.value_of(value[member], $context, globals, node);
}
}
// [1] See note above.
if (typeof value === 'function' && n > 0 && lastValue !== value &&
!hasOwnProperty(lastValue, member)) {
return value.bind(lastValue)
}
return value
};
/**
* Return the value as one would get it from the top-level i.e.
* $data.token/$context.token/globals.token; this does not return intermediate
* values on a chain of members i.e. $data.hello.there -- requesting the
* Identifier('there').value will return $data/$context/globals.there.
*
* This will dereference using () or [arg] member.
* @param {object | Identifier | Expression} parent
* @return {mixed} Return the primitive or an accessor.
*/
get_value (parent, context, globals, node) {
const intermediate = parent && !(parent instanceof Identifier)
? Node.value_of(parent, context, globals, node)[this.token]
: context.lookup(this.token, globals, node);
return this.dereference(intermediate, context, globals, node)
}
assign (object, property, value) {
if (isWriteableObservable(object[property])) {
object[property](value);
} else if (!isObservable(object[property])) {
object[property] = value;
}
};
/**
* Set the value of the Identifier.
*
* @param {Mixed} new_value The value that Identifier is to be set to.
*/
set_value (new_value, $context, globals) {
const $data = $context.$data || {};
const refs = this.dereferences || [];
let leaf = this.token;
let i, n, root;
if (hasOwnProperty($data, leaf)) {
root = $data;
} else if (hasOwnProperty($context, leaf)) {
root = $context;
} else if (hasOwnProperty(globals, leaf)) {
root = globals;
} else {
throw new Error('Identifier::set_value -- ' +
"The property '" + leaf + "' does not exist " +
'on the $data, $context, or globals.')
}
// Degenerate case. {$data|$context|global}[leaf] = something;
n = refs.length;
if (n === 0) {
this.assign(root, leaf, new_value);
return
}
// First dereference is {$data|$context|global}[token].
root = root[leaf];
// We cannot use this.dereference because that gives the leaf; to evoke
// the ES5 setter we have to call `obj[leaf] = new_value`
for (i = 0; i < n - 1; ++i) {
leaf = refs[i];
if (leaf instanceof Arguments) {
root = root();
} else {
root = root[Node.value_of(leaf)];
}
}
// We indicate that a dereference is a function when it is `true`.
if (refs[i] === true) {
throw new Error('Cannot assign a value to a function.')
}
// Call the setter for the leaf.
if (refs[i]) {
this.assign(root, Node.value_of(refs[i]), new_value);
}
};
/**
* Determine if a character is a valid item in an identifier.
* Note that we do not check whether the first item is a number, nor do we
* support unicode identifiers here.
*
* From: http://stackoverflow.com/a/9337047
* @param {String} ch The character
* @return {Boolean} True if this is a valid identifier
*/
// function is_identifier_char(ch) {
// return (ch >= 'A' && ch <= 'Z') ||
// (ch >= 'a' && ch <= 'z') ||
// (ch >= '0' && ch <= 9) ||
// ch === '_' || ch === '$';
// }
static is_valid_start_char (ch) {
return IDStart.test(ch)
}
static is_valid_continue_char (ch) {
return IDContinue.test(ch)
}
get [Node.isExpressionOrIdentifierSymbol] () { return true }
}
class Ternary {
constructor (yes, no) {
Object.assign(this, {yes, no});
}
get_value () { return this }
get [Node.isExpressionOrIdentifierSymbol] () { return true }
}
/**
* Originally based on (public domain):
* https://github.com/douglascrockford/JSON-js/blob/master/json_parse.js
*/
const escapee = {
"'": "'",
'"': '"',
'`': '`',
'\\': '\\',
'/': '/',
'$': '$',
b: '\b',
f: '\f',
n: '\n',
r: '\r',
t: '\t'
};
/**
* Construct a new Parser instance with new Parser(node, context)
* @param {Node} node The DOM element from which we parsed the
* content.
* @param {object} context The Knockout context.
* @param {object} globals An object containing any desired globals.
*/
class Parser {
white () {
var ch = this.ch;
while (ch && ch <= ' ') {
ch = this.next();
}
return this.comment(ch)
}
/**
* Slurp any C or C++ style comments
*/
comment (ch) {
if (ch !== '/') { return ch }
var p = this.at;
var second = this.lookahead();
if (second === '/') {
while (ch) {
ch = this.next();
if (ch === '\n' || ch === '\r') { break }
}
ch = this.next();
} else if (second === '*') {
while (ch) {
ch = this.next();
if (ch === '*' && this.lookahead() === '/') {
this.next();
break
}
}
if (!ch) {
this.error('Unclosed comment, starting at character ' + p);
}
this.next();
return this.white()
}
return ch
};
next (c) {
if (c && c !== this.ch) {
this.error("Expected '" + c + "' but got '" + this.ch + "'");
}
this.ch = this.text.charAt(this.at);
this.at += 1;
return this.ch
}
lookahead () {
return this.text[this.at]
}
error (m) {
if (m instanceof Error) { throw m }
let [name, msg] = m.name ? [m.name, m.message] : [m, ''];
const message = `\n${name} ${msg} of
${this.text}\n` + Array(this.at).join(' ') + '_/ 🔥 \\_\n';
throw new Error(message)
}
name () {
// A name of a binding
var name = '';
var enclosedBy;
this.white();
var ch = this.ch;
if (ch === "'" || ch === '"') {
enclosedBy = ch;
ch = this.next();
}
while (ch) {
if (enclosedBy && ch === enclosedBy) {
this.white();
ch = this.next();
if (ch !== ':' && ch !== ',') {
this.error(
'Object name: ' + name + ' missing closing ' + enclosedBy
);
}
return name
} else if (ch === ':' || ch <= ' ' || ch === ',' || ch === '|') {
return name
}
name += ch;
ch = this.next();
}
return name
}
number () {
let number;
let string = '';
let ch = this.ch;
if (ch === '-') {
string = '-';
ch = this.next('-');
}
while (ch >= '0' && ch <= '9') {
string += ch;
ch = this.next();
}
if (ch === '.') {
string += '.';
ch = this.next();
while (ch && ch >= '0' && ch <= '9') {
string += ch;
ch = this.next();
}
}
if (ch === 'e' || ch === 'E') {
string += ch;
ch = this.next();
if (ch === '-' || ch === '+') {
string += ch;
ch = this.next();
}
while (ch >= '0' && ch <= '9') {
string += ch;
ch = this.next();
}
}
number = +string;
if (!isFinite(number)) {
options.onError(new Error('Bad number: ' + number + ' in ' + string));
} else {
return number
}
}
/**
* Add a property to 'object' that equals the given value.
* @param {Object} object The object to add the value to.
* @param {String} key object[key] is set to the given value.
* @param {mixed} value The value, may be a primitive or a function. If a
* function it is unwrapped as a property.
*/
objectAddValue (object, key, value) {
if (value && value[Node.isExpressionOrIdentifierSymbol]) {
Object.defineProperty(object, key, {
get: () => Node.value_of(value, ...this.currentContextGlobals),
enumerable: true
});
} else if (Array.isArray(value)) {
Object.defineProperty(object, key, {
get: () => value.map(v => Node.value_of(v, ...this.currentContextGlobals)),
enumerable: true
});
} else {
// primitives
object[key] = value;
}
}
object () {
let key;
let object = {};
let ch = this.ch;
if (ch === '{') {
this.next('{');
ch = this.white();
if (ch === '}') {
ch = this.next('}');
return object
}
while (ch) {
if (ch === '"' || ch === "'" || ch === '`') {
key = this.string();
} else {
key = this.name();
}
if (hasOwnProperty(object, key)) {
this.error('Duplicate key "' + key + '"');
}
if (this.white() === ':') {
ch = this.next(':');
this.objectAddValue(object, key, this.expression());
} else {
const objectKeyIsValue = new Identifier(this, key, []);
this.objectAddValue(object, key, objectKeyIsValue);
}
ch = this.white();
if (ch === '}') {
ch = this.next('}');
return object
}
this.next(',');
ch = this.white();
if (ch === '}') {
ch = this.next('}');
return object
}
}
}
this.error('Bad object');
}
/**
* Read up to delim and return the string
* @param {string} delim The delimiter, either ' or "
* @return {string} The string read.
*/
readString (delim) {
let string = '';
let nodes = [''];
let plusOp = operators['+'];
let hex;
let i;
let uffff;
let interpolate = delim === '`';
let ch = this.next();
while (ch) {
if (ch === delim) {
ch = this.next();
if (interpolate) { nodes.push(plusOp); }
nodes.push(string);
return nodes
}
if (ch === '\\') {
ch = this.next();
if (ch === 'u') {
uffff = 0;
for (i = 0; i < 4; i += 1) {
hex = parseInt(ch = this.next(), 16);
if (!isFinite(hex)) {
break
}
uffff = uffff * 16 + hex;
}
string += String.fromCharCode(uffff);
} else if (typeof escapee[ch] === 'string') {
string += escapee[ch];
} else {
break
}
} else if (interpolate && ch === '$') {
ch = this.next();
if (ch === '{') {
this.next('{');
nodes.push(plusOp);
nodes.push(string);
nodes.push(plusOp);
nodes.push(this.expression());
string = '';
// this.next('}');
} else {
string += '$' + ch;
}
} else {
string += ch;
}
ch = this.next();
}
this.error('Bad string');
}
string () {
var ch = this.ch;
if (ch === '"') {
return this.readString('"').join('')
} else if (ch === "'") {
return this.readString("'").join('')
} else if (ch === '`') {
return Node.create_root(this.readString('`'))
}
this.error('Bad string');
}
array () {
let array = [];
let ch = this.ch;
if (ch === '[') {
ch = this.next('[');
this.white();
if (ch === ']') {
ch = this.next(']');
return array
}
while (ch) {
array.push(this.expression());
ch = this.white();
if (ch === ']') {
ch = this.next(']');
return array
}
this.next(',');
ch = this.white();
}
}
this.error('Bad array');
}
value () {
var ch;
this.white();
ch = this.ch;
switch (ch) {
case '{': return this.object()
case '[': return this.array()
case '"': case "'": case '`': return this.string()
case '-': return this.number()
default:
return ch >= '0' && ch <= '9' ? this.number() : this.identifier()
}
}
/**
* Get the function for the given operator.
* A `.precedence` value is added to the function, with increasing
* precedence having a higher number.
* @return {function} The function that performs the infix operation
*/
operator (opts) {
let op = '';
let opFn;
let ch = this.white();
let isIdentifierChar = Identifier.is_valid_start_char;
while (ch) {
if (isIdentifierChar(ch) || ch <= ' ' || ch === '' ||
ch === '"' || ch === "'" || ch === '{' || ch === '(' ||
ch === '`' || ch === ')' || (ch <= '9' && ch >= '0')) {
break
}
if (!opts.not_an_array && ch === '[') {
break
}
op += ch;
ch = this.next();
// An infix followed by the prefix e.g. a + @b
// TODO: other prefix unary operators
if (ch === '@') {
break
}
isIdentifierChar = Identifier.is_valid_continue_char;
}
if (op !== '') {
if (opts.prefix && op === '-') { op = '&-'; }
opFn = operators[op];
if (!opFn) {
this.error("Bad operator: '" + op + "'.");
}
}
return opFn
}
/**
* Filters
* Returns what the Node interprets as an "operator".
* e.g.
* <span data-bind="text: name | fit:20 | uppercase"></span>
*/
filter () {
let ch = this.next();
let args = [];
let nextFilter = function (v) { return v };
let name = this.name();
if (!options.filters[name]) {
options.onError('Cannot find filter by the name of: ' + name);
}
ch = this.white();
while (ch) {
if (ch === ':') {
ch = this.next();
args.push(this.expression('|'));
}
if (ch === '|') {
nextFilter = this.filter();
break
}
if (ch === ',') { break }
ch = this.white();
}
var filter = function filter (value, ignored, context, globals, node) {
var argValues = [value];
for (var i = 0, j = args.length; i < j; ++i) {
argValues.push(Node.value_of(args[i], context, globals, node));
}
return nextFilter(options.filters[name].apply(null, argValues))
};
// Lowest precedence.
filter.precedence = 1;
return filter
}
/**
* Parse an expression – builds an operator tree, in something like
* Shunting-Yard.
* See: http://en.wikipedia.org/wiki/Shunting-yard_algorithm
*
* @return {function} A function that computes the value of the expression
* when called or a primitive.
*/
expression (filterable) {
let op;
let nodes = [];
let ch = this.white();
while (ch) {
// unary prefix operators
op = this.operator({ prefix: true });
if (op) {
nodes.push(undefined); // LHS Tree node.
nodes.push(op);
ch = this.white();
}
if (ch === '(') {
this.next();
nodes.push(this.expression());
this.next(')');
} else {
nodes.push(this.value());
}
ch = this.white();
if (ch === ':' || ch === '}' || ch === ',' || ch === ']' ||
ch === ')' || ch === '' || ch === '`' || (ch === '|' && filterable === '|')) {
break
}
// filters
if (ch === '|' && this.lookahead() !== '|' && filterable) {
nodes.push(this.filter());
nodes.push(undefined);
break
}
// infix or postfix operators
op = this.operator({ not_an_array: true });
if (op === operators['?']) {
this.ternary(nodes);
break
} else if (op === operators['.']) {
nodes.push(op);
nodes.push(this.member());
op = null;
} else if (op === operators['[']) {
nodes.push(op);
nodes.push(this.expression());
ch = this.next(']');
op = null;
} else if (op) {
nodes.push(op);
}
ch = this.white();
if (ch === ']' || (!op && ch === '(')) { break }
}
if (nodes.length === 0) {
return undefined
}
var dereferences = this.dereferences();
if (nodes.length === 1 && !dereferences.length) {
return nodes[0]
}
for (var i = 0, j = dereferences.length; i < j; ++i) {
var deref = dereferences[i];
if (deref.constructor === Arguments) {
nodes.push(operators.call);
} else {
nodes.push(operators['.']);
}
nodes.push(deref);
}
return new Expression(nodes)
}
ternary (nodes) {
var ternary = new Ternary();
ternary.yes = this.expression();
this.next(':');
ternary.no = this.expression();
nodes.push(operators['?']);
nodes.push(ternary);
}
/**
* Parse the arguments to a function, returning an Array.
*
*/
funcArguments () {
let args = [];
let ch = this.next('(');
while (ch) {
ch = this.white();
if (ch === ')') {
this.next(')');
return new Arguments(this, args)
} else {
args.push(this.expression());
ch = this.white();
}
if (ch !== ')') { this.next(','); }
}
this.error('Bad arguments to function');
}
/**
* The literal string reference `abc` in an `x.abc` expression.
*/
member () {
let member = '';
let ch = this.white();
let isIdentifierChar = Identifier.is_valid_start_char;
while (ch) {
if (!isIdentifierChar(ch)) {
break
}
member += ch;
ch = this.next();
isIdentifierChar = Identifier.is_valid_continue_char;
}
return member
}
/**
* A dereference applies to an identifer, being either a function
* call "()" or a membership lookup with square brackets "[member]".
* @return {fn or undefined} Dereference function to be applied to the
* Identifier
*/
dereference () {
let member;
let ch = this.white();
while (ch) {
if (ch === '(') {
// a(...) function call
return this.funcArguments()
} else if (ch === '[') {
// a[x] membership
this.next('[');
member = this.expression();
this.white();
this.next(']');
return member
} else if (ch === '.') {
// a.x membership
this.next('.');
return this.member()
} else {
break
}
}
}
dereferences () {
let ch = this.white();
let dereferences = [];
let deref;
while (ch) {
deref = this.dereference();
if (deref !== undefined) {
dereferences.push(deref);
} else {
break
}
}
return dereferences
}
identifier () {
let token = '';
let isIdentifierChar = Identifier.is_valid_start_char;
let ch = this.white();
while (ch) {
if (!isIdentifierChar(ch)) {
break
}
token += ch;
ch = this.next();
isIdentifierChar = Identifier.is_valid_continue_char;
}
switch (token) {
case 'true': return true
case 'false': return false
case 'null': return null
case 'undefined': return void 0
case 'function':
throw new Error('Knockout: Anonymous functions are no longer supported, but `=>` lambdas are.')
// return this.anonymous_fn();
}
return new Identifier(this, token, this.dereferences())
}
readBindings () {
let key;
let bindings = {};
let sep;
let expr;
let ch = this.ch;
while (ch) {
key = this.name();
sep = this.white();
if (!sep || sep === ',') {
if (sep) {
ch = this.next(',');
} else {
ch = '';
}
// A "bare" binding e.g. "text"; substitute value of 'null'
// so it becomes "text: null".
bindings[key] = null;
} else {
if (key.indexOf('.') !== -1) {
// Namespaced – i.e.
// `attr.css: x` becomes `attr: { css: x }`
// ^^^ - key
key = key.split('.');
bindings[key[0]] = bindings[key[0]] || {};
if (key.length !== 2) {
options.onError('Binding ' + key + ' should have two parts (a.b).');
} else if (bindings[key[0]].constructor !== Object) {
options.onError('Binding ' + key[0] + '.' + key[1] + ' paired with a non-object.');
}
ch = this.next(':');
this.objectAddValue(bindings[key[0]], key[1], this.expression(true));
} else {
ch = this.next(':');
if (bindings[key] && typeof bindings[key] === 'object' && bindings[key].constructor === Object) {
// Extend a namespaced bindings e.g. we've previously seen
// on.x, now we're seeing on: { 'abc' }.
expr = this.expression(true);
if (typeof expr !== 'object' || expr.constructor !== Object) {
options.onError('Expected plain object for ' + key + ' value.');
} else {
extend(bindings[key], expr);
}
} else {
bindings[key] = this.expression(true);
}
}
this.white();
if (this.ch) {
ch = this.next(',');
} else {
ch = '';
}
}
}
return bindings
}
valueAsAccessor (value, context, globals, node) {
if (!value) { return () => value }
if (typeof value === 'function') { return value }
if (value[Node.isExpressionOrIdentifierSymbol]) {
return () => Node.value_of(value, context, globals, node)
}
if (Array.isArray(value)) {
return () => value.map(v => Node.value_of(v, context, globals, node))
}
if (typeof (value) !== 'function') {
return () => clonePlainObjectDeep(value)
}
throw new Error('Value has cannot be converted to accessor: ' + value)
}
/**
* Convert result[name] from a value to a function (i.e. `valueAccessor()`)
* @param {object} result [Map of top-level names to values]
* @return {object} [Map of top-level names to functions]
*
* Accessors may be one of (below) constAccessor, identifierAccessor,
* expressionAccessor, or nodeAccessor.
*/
convertToAccessors (result, context, globals, node) {
objectForEach(result, (name, value) => {
if (value instanceof Identifier) {
// Return a function that, with no arguments returns
// the value of the identifier, otherwise sets the
// value of the identifier to the first given argument.
Object.defineProperty(result, name, {
value: function (optionalValue, options$$1) {
const currentValue = value.get_value(undefined, context, globals, node);
if (arguments.length === 0) { return currentValue }
const unchanged = optionalValue === currentValue;
if (options$$1 && options$$1.onlyIfChanged && unchanged) { return }
return value.set_value(optionalValue, context, globals)
}
});
} else {
result[name] = this.valueAsAccessor(value, context, globals, node);
}
});
return result
}
preparse (source = '') {
const preparsers = options.bindingStringPreparsers || [];
return preparsers.reduce((acc, fn) => fn(acc), source.trim())
}
runParse (source, fn) {
this.text = this.preparse(source);
this.at = 0;
this.ch = ' ';
try {
var result = fn();
this.white();
if (this.ch) {
this.error('Syntax Error');
}
return result
} catch (e) {
options.onError(e);
}
}
/**
* Get the bindings as name: accessor()
* @param {string} source The binding string to parse.
* @return {object} Map of name to accessor function.
*/
parse (source, context = {}, globals = {}, node) {
if (!source) { return () => null }
this.currentContextGlobals = [context, globals, node];
const parseFn = () => this.readBindings();
const bindingAccessors = this.runParse(source, parseFn);
return this.convertToAccessors(bindingAccessors, context, globals, node)
}
/**
* Return a function that evaluates and returns the result of the expression.
*/
parseExpression (source, context = {}, globals = {}, node) {
if (!source) { return () => '' }
this.currentContextGlobals = [context, globals, node];
const parseFn = () => this.expression(true);
const bindingAccessors = this.runParse(source, parseFn);
return this.valueAsAccessor(bindingAccessors, context, globals, node)
}
}
/* eslint no-cond-assign: 0 */
// The following regular expressions will be used to split an object-literal string into tokens
// These characters have special meaning to the parser and must not appear in the middle of a
// token, except as part of a string.
const specials = ',"\'`{}()/:[\\]';
const bindingToken = RegExp([
// These match strings, either with double quotes, single quotes, or backticks
'"(?:\\\\.|[^"])*"',
"'(?:\\\\.|[^'])*'",
'`(?:\\\\.|[^`])*`',
// Match C style comments
'/\\*(?:[^*]|\\*+[^*/])*\\*+/',
// Match C++ style comments
'//.*\n',
// Match a regular expression (text enclosed by slashes), but will also match sets of divisions
// as a regular expression (this is handled by the parsing loop below).
'/(?:\\\\.|[^/])+/\\w*',
// Match text (at least two characters) that does not contain any of the above special characters,
// although some of the special characters are allowed to start it (all but the colon and comma).
// The text can contain spaces, but leading or trailing spaces are skipped.
'[^\\s:,/][^' + specials + ']*[^\\s' + specials + ']',
// Match any non-space character not matched already. This will match colons and commas, since they're
// not matched by "everyThingElse", but will also match any other single character that wasn't already
// matched (for example: in "a: 1, b: 2", each of the non-space characters will be matched by oneNotSpace).
'[^\\s]'
].join('|'), 'g');
// Match end of previous token to determine whether a slash is a division or regex.
const divisionLookBehind = /[\])"'A-Za-z0-9_$]+$/;
const keywordRegexLookBehind = { 'in': 1, 'return': 1, 'typeof': 1 };
/**
* Break a binding string (data-bind='x: val, y: ..') into a stable array
* of {key: value}.
*/
function parseObjectLiteral (objectLiteralString) {
// Trim leading and trailing spaces from the string
var str = stringTrim(objectLiteralString);
// Trim braces '{' surrounding the whole object literal
if (str.charCodeAt(0) === 123) str = str.slice(1, -1);
// Add a newline to correctly match a C++ style comment at the end of the string and
// add a comma so that we don't need a separate code block to deal with the last item
str += '\n,';
// Split into tokens
var result = [];
var toks = str.match(bindingToken);
var key;
var values = [];
var depth = 0;
if (toks.length <= 1) { return [] }
for (var i = 0, tok; tok = toks[i]; ++i) {
var c = tok.charCodeAt(0);
// A comma signals the end of a key/value pair if depth is zero
if (c === 44) { // ","
if (depth <= 0) {
result.push((key && values.length) ? {
key: key,
value: values.join('')
} : {
'unknown': key || values.join('')
});
key = depth = 0;
values = [];
continue
}
// Simply skip the colon that separates the name and value
} else if (c === 58) { // ":"
if (!depth && !key && values.length === 1) {
key = values.pop();
continue
}
// A set of slashes is initially matched as a regular expression, but could be division
} else if (c === 47 && tok.length > 1 && (tok.charCodeAt(1) === 47 || tok.charCodeAt(1) === 42)) { // "//" or "/*"
// skip comments
continue
} else if (c === 47 && i && tok.length > 1) { // "/"
// Look at the end of the previous token to determine if the slash is actually division
var match = toks[i - 1].match(divisionLookBehind);
if (match && !keywordRegexLookBehind[match[0]]) {
// The slash is actually a division punctuator; re-parse the remainder of the string (not including the slash)
str = str.substr(str.indexOf(tok) + 1);
toks = str.match(bindingToken);
i = -1;
// Continue with just the slash
tok = '/';
}
// Increment depth for parentheses, braces, and brackets so that interior commas are ignored
} else if (c === 40 || c === 123 || c === 91) { // '(', '{', '['
++depth;
} else if (c === 41 || c === 125 || c === 93) { // ')', '}', ']'
--depth;
// The key will be the first token; if it's a string, trim the quotes
} else if (!key && !values.length && (c === 34 || c === 39)) { // '"', "'"
tok = tok.slice(1, -1);
}
values.push(tok);
}
return result
}
export { Parser, Identifier, Arguments, Node, parseObjectLiteral };
//# sourceMappingURL=utils.parser.es6.js.map

Sorry, the diff of this file is too big to display

/*!
* Parse the Javascript-like language used in data-bind and other HTML attributes (CSP-safe) 🥊 @tko/utils.parser@4.0.0-alpha9.0
* (c) The Knockout.js Team - https://tko.io
* License: MIT (http://www.opensource.org/licenses/mit-license.php)
*/
import { unwrap, isWriteableObservable, isObservable } from '@tko/observable';
import { hasOwnProperty, options, objectForEach, clonePlainObjectDeep, extend, stringTrim } from '@tko/utils';
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
function __read(o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
}
function __spread() {
for (var ar = [], i = 0; i < arguments.length; i++)
ar = ar.concat(__read(arguments[i]));
return ar;
}
function LAMBDA() { }
/**
* @ operator - recursively call the identifier if it's a function
* @param {operand} a ignored
* @param {operand} b The variable to be called (if a function) and unwrapped
* @return {value} The result.
*/
function unwrapOrCall(a, b) {
while (typeof b === 'function') {
b = b();
}
return b;
}
var operators = {
// unary
'@': unwrapOrCall,
'#': function (a, b) { return function () { return unwrap(b); }; },
'=>': LAMBDA,
'!': function not(a, b) { return !b; },
'!!': function notnot(a, b) { return !!b; },
'++': function preinc(a, b) { return ++b; },
'--': function preinc(a, b) { return --b; },
// mul/div
'*': function mul(a, b) { return a * b; },
'/': function div(a, b) { return a / b; },
'%': function mod(a, b) { return a % b; },
// sub/add
'+': function add(a, b) { return a + b; },
'-': function sub(a, b) { return (a || 0) - (b || 0); },
'&-': function neg(a, b) { return -1 * b; },
// relational
'<': function lt(a, b) { return a < b; },
'<=': function le(a, b) { return a <= b; },
'>': function gt(a, b) { return a > b; },
'>=': function ge(a, b) { return a >= b; },
// TODO: 'in': function (a, b) { return a in b; },
// TODO: 'instanceof': function (a, b) { return a instanceof b; },
// equality
'==': function equal(a, b) { return a === b; },
'!=': function ne(a, b) { return a !== b; },
'===': function sequal(a, b) { return a === b; },
'!==': function sne(a, b) { return a !== b; },
// bitwise
'&': function bitAnd(a, b) { return a & b; },
'^': function xor(a, b) { return a ^ b; },
'|': function bitOr(a, b) { return a | b; },
// logic
'&&': function logicAnd(a, b) { return a && b; },
'||': function logicOr(a, b) { return a || b; },
// Access
'.': function member(a, b) { return a[b]; },
'[': function member(a, b) { return a[b]; },
// conditional/ternary
// '?': ternary See Node.js
// Function-Call
'call': function callOp(a, b) { return a.apply(null, b); }
};
/* Order of precedence from:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence#Table
*/
// Our operator - unwrap/call
operators['@'].precedence = 21;
operators['#'].precedence = 21;
// lambda
operators['=>'].precedence = 20;
// Member
operators['.'].precedence = 19;
operators['['].precedence = 19;
// Logical not
operators['!'].precedence = 16;
operators['!!'].precedence = 16; // explicit double-negative
// Prefix inc/dec
operators['++'].precedence = 16;
operators['--'].precedence = 16;
operators['&-'].precedence = 16;
// mul/div/remainder
operators['%'].precedence = 14;
operators['*'].precedence = 14;
operators['/'].precedence = 14;
// add/sub
operators['+'].precedence = 13;
operators['-'].precedence = 13;
// bitwise
operators['|'].precedence = 12;
operators['^'].precedence = 11;
operators['&'].precedence = 10;
// comparison
operators['<'].precedence = 11;
operators['<='].precedence = 11;
operators['>'].precedence = 11;
operators['>='].precedence = 11;
// operators['in'].precedence = 8;
// operators['instanceof'].precedence = 8;
// equality
operators['=='].precedence = 10;
operators['!='].precedence = 10;
operators['==='].precedence = 10;
operators['!=='].precedence = 10;
// logic
operators['&&'].precedence = 6;
operators['||'].precedence = 5;
operators['&&'].earlyOut = function (a) { return !a; };
operators['||'].earlyOut = function (a) { return a; };
// Call a function
operators['call'].precedence = 1;
var IS_EXPR_OR_IDENT = Symbol('Node - Is Expression Or Identifier');
var Node = /** @class */ (function () {
function Node(lhs, op, rhs) {
this.lhs = lhs;
this.op = op;
this.rhs = rhs;
}
Object.defineProperty(Node, "operators", {
get: function () { return operators; },
enumerable: true,
configurable: true
});
Node.prototype.get_leaf_value = function (leaf, context, globals, node) {
if (typeof leaf === 'function') {
// Expressions on observables are nonsensical, so we unwrap any
// function values (e.g. identifiers).
return unwrap(leaf());
}
// primitives
if (typeof leaf !== 'object' || leaf === null) {
return leaf;
}
// Identifiers and Expressions
if (leaf[Node.isExpressionOrIdentifierSymbol]) {
// lhs is passed in as the parent of the leaf. It will be defined in
// cases like a.b.c as 'a' for 'b' then as 'b' for 'c'.
return unwrap(leaf.get_value(undefined, context, globals, node));
}
// Plain object/class.
return leaf;
};
/**
* Return a function that calculates and returns an expression's value
* when called.
* @param {array} ops The operations to perform
* @return {function} The function that calculates the expression.
*
* Note that for a lambda, we do not evaluate the RHS expression until
* the lambda is called.
*/
Node.prototype.get_value = function (notused, context, globals, node) {
var node = this;
if (node.op === LAMBDA) {
return function () { return node.get_leaf_value(node.rhs, context, globals, node); };
}
var lhv = node.get_leaf_value(node.lhs, context, globals, node);
var earlyOut = node.op.earlyOut;
if (earlyOut && earlyOut(lhv)) {
return lhv;
}
var rhv = node.get_leaf_value(node.rhs, context, globals, node);
return node.op(lhv, rhv, context, globals);
};
Object.defineProperty(Node, "isExpressionOrIdentifierSymbol", {
//
// Class variables.
//
get: function () { return IS_EXPR_OR_IDENT; },
enumerable: true,
configurable: true
});
Object.defineProperty(Node.prototype, IS_EXPR_OR_IDENT, {
get: function () { return true; },
enumerable: true,
configurable: true
});
Node.value_of = function (item, context, globals, node) {
if (item && item[Node.isExpressionOrIdentifierSymbol]) {
return item.get_value(item, context, globals, node);
}
return item;
};
/**
* Convert an array of nodes to an executable tree.
* @return {object} An object with a `lhs`, `rhs` and `op` key, corresponding
* to the left hand side, right hand side, and
* operation function.
*/
Node.create_root = function (nodes) {
var root, leaf, op, value;
// Prime the leaf = root node.
leaf = root = new Node(nodes.shift(), nodes.shift(), nodes.shift());
while (true) {
op = nodes.shift();
value = nodes.shift();
if (!op) {
break;
}
if (op.precedence < root.op.precedence) {
// rebase
root = new Node(root, op, value);
leaf = root;
}
else {
leaf.rhs = new Node(leaf.rhs, op, value);
leaf = leaf.rhs;
}
}
// console.log('tree', root)
return root;
};
return Node;
}());
/**
* Because of cyclical dependencies on operators <-> Node <-> value_of,
* we need to patch this in here.
*/
operators['?'] = function ternary(a, b, context, globals, node) {
return Node.value_of(a ? b.yes : b.no, context, globals, node);
};
operators['?'].precedence = 4;
var Expression = /** @class */ (function () {
function Expression(nodes) {
this.nodes = nodes;
this.root = Node.create_root(nodes);
}
/**
* Return the value of `this` Expression instance.
*/
Expression.prototype.get_value = function (parent, context, globals, node) {
if (!this.root) {
this.root = Node.create_root(this.nodes);
}
return this.root.get_value(parent, context, globals, node);
};
return Expression;
}());
Expression.prototype[Node.isExpressionOrIdentifierSymbol] = true;
var Arguments = /** @class */ (function () {
function Arguments(parser, args) {
this.parser = parser;
this.args = args;
}
Arguments.prototype.get_value = function (parent, context, globals, node) {
var deReffedArgs = [];
for (var i = 0, j = this.args.length; i < j; ++i) {
deReffedArgs.push(Node.value_of(this.args[i], context, globals, node));
}
return deReffedArgs;
};
Object.defineProperty(Arguments.prototype, Node.isExpressionOrIdentifierSymbol, {
get: function () { return true; },
enumerable: true,
configurable: true
});
return Arguments;
}());
/**
* The following regular expressions were generated by
* https://mathiasbynens.be/demo/javascript-identifier-regex
*/
var IDStart = /[\$A-Z_a-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B4\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AD\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/;
var IDContinue = /[\$0-9A-Z_a-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0-\u08B4\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\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0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFC-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AD\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C4\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/;
var Identifier = /** @class */ (function () {
function Identifier(parser, token, dereferences) {
this.token = token;
this.dereferences = dereferences;
this.parser = parser;
}
/**
* Apply all () and [] functions on the identifier to the lhs value e.g.
* a()[3] has deref functions that are essentially this:
* [_deref_call, _deref_this where this=3]
*
* @param {mixed} value Should be an object.
* @return {mixed} The dereferenced value.
*
* [1] We want to bind any function that is a method of an object, but not
* corrupt any values (e.g. computed()s). e.g. Running x.bind(obj) where
* we're given `data-bind='binding: obj.x'` and x is a computed will
* break the computed's `this` and it will stop working as expected.
*
* The test `!last_value.hasOwnProperty(member)`
* distinguishes between functions on the prototype chain (prototypal
* members) and value-members added directly to the object. This may
* not be the canonical test for this relationship, but it succeeds
* in the known test cases.
*
* See: `this` tests of our dereference function.
*/
Identifier.prototype.dereference = function (value, $context, globals, node) {
var member;
var refs = this.dereferences || [];
var $data = $context.$data || {};
var lastValue; // becomes `this` in function calls to object properties.
var i, n;
for (i = 0, n = refs.length; i < n; ++i) {
member = Node.value_of(refs[i], $context, globals, node);
if (typeof value === 'function' && refs[i] instanceof Arguments) {
// fn(args)
value = value.apply(lastValue || $data, member);
lastValue = value;
}
else {
// obj[x] or obj.x dereference. Note that obj may be a function.
lastValue = value;
value = Node.value_of(value[member], $context, globals, node);
}
}
// [1] See note above.
if (typeof value === 'function' && n > 0 && lastValue !== value &&
!hasOwnProperty(lastValue, member)) {
return value.bind(lastValue);
}
return value;
};
/**
* Return the value as one would get it from the top-level i.e.
* $data.token/$context.token/globals.token; this does not return intermediate
* values on a chain of members i.e. $data.hello.there -- requesting the
* Identifier('there').value will return $data/$context/globals.there.
*
* This will dereference using () or [arg] member.
* @param {object | Identifier | Expression} parent
* @return {mixed} Return the primitive or an accessor.
*/
Identifier.prototype.get_value = function (parent, context, globals, node) {
var intermediate = parent && !(parent instanceof Identifier)
? Node.value_of(parent, context, globals, node)[this.token]
: context.lookup(this.token, globals, node);
return this.dereference(intermediate, context, globals, node);
};
Identifier.prototype.assign = function (object, property, value) {
if (isWriteableObservable(object[property])) {
object[property](value);
}
else if (!isObservable(object[property])) {
object[property] = value;
}
};
/**
* Set the value of the Identifier.
*
* @param {Mixed} new_value The value that Identifier is to be set to.
*/
Identifier.prototype.set_value = function (new_value, $context, globals) {
var $data = $context.$data || {};
var refs = this.dereferences || [];
var leaf = this.token;
var i, n, root;
if (hasOwnProperty($data, leaf)) {
root = $data;
}
else if (hasOwnProperty($context, leaf)) {
root = $context;
}
else if (hasOwnProperty(globals, leaf)) {
root = globals;
}
else {
throw new Error('Identifier::set_value -- ' +
"The property '" + leaf + "' does not exist " +
'on the $data, $context, or globals.');
}
// Degenerate case. {$data|$context|global}[leaf] = something;
n = refs.length;
if (n === 0) {
this.assign(root, leaf, new_value);
return;
}
// First dereference is {$data|$context|global}[token].
root = root[leaf];
// We cannot use this.dereference because that gives the leaf; to evoke
// the ES5 setter we have to call `obj[leaf] = new_value`
for (i = 0; i < n - 1; ++i) {
leaf = refs[i];
if (leaf instanceof Arguments) {
root = root();
}
else {
root = root[Node.value_of(leaf)];
}
}
// We indicate that a dereference is a function when it is `true`.
if (refs[i] === true) {
throw new Error('Cannot assign a value to a function.');
}
// Call the setter for the leaf.
if (refs[i]) {
this.assign(root, Node.value_of(refs[i]), new_value);
}
};
/**
* Determine if a character is a valid item in an identifier.
* Note that we do not check whether the first item is a number, nor do we
* support unicode identifiers here.
*
* From: http://stackoverflow.com/a/9337047
* @param {String} ch The character
* @return {Boolean} True if this is a valid identifier
*/
// function is_identifier_char(ch) {
// return (ch >= 'A' && ch <= 'Z') ||
// (ch >= 'a' && ch <= 'z') ||
// (ch >= '0' && ch <= 9) ||
// ch === '_' || ch === '$';
// }
Identifier.is_valid_start_char = function (ch) {
return IDStart.test(ch);
};
Identifier.is_valid_continue_char = function (ch) {
return IDContinue.test(ch);
};
Object.defineProperty(Identifier.prototype, Node.isExpressionOrIdentifierSymbol, {
get: function () { return true; },
enumerable: true,
configurable: true
});
return Identifier;
}());
var Ternary = /** @class */ (function () {
function Ternary(yes, no) {
Object.assign(this, { yes: yes, no: no });
}
Ternary.prototype.get_value = function () { return this; };
Object.defineProperty(Ternary.prototype, Node.isExpressionOrIdentifierSymbol, {
get: function () { return true; },
enumerable: true,
configurable: true
});
return Ternary;
}());
/**
* Originally based on (public domain):
* https://github.com/douglascrockford/JSON-js/blob/master/json_parse.js
*/
var escapee = {
"'": "'",
'"': '"',
'`': '`',
'\\': '\\',
'/': '/',
'$': '$',
b: '\b',
f: '\f',
n: '\n',
r: '\r',
t: '\t'
};
/**
* Construct a new Parser instance with new Parser(node, context)
* @param {Node} node The DOM element from which we parsed the
* content.
* @param {object} context The Knockout context.
* @param {object} globals An object containing any desired globals.
*/
var Parser = /** @class */ (function () {
function Parser() {
}
Parser.prototype.white = function () {
var ch = this.ch;
while (ch && ch <= ' ') {
ch = this.next();
}
return this.comment(ch);
};
/**
* Slurp any C or C++ style comments
*/
Parser.prototype.comment = function (ch) {
if (ch !== '/') {
return ch;
}
var p = this.at;
var second = this.lookahead();
if (second === '/') {
while (ch) {
ch = this.next();
if (ch === '\n' || ch === '\r') {
break;
}
}
ch = this.next();
}
else if (second === '*') {
while (ch) {
ch = this.next();
if (ch === '*' && this.lookahead() === '/') {
this.next();
break;
}
}
if (!ch) {
this.error('Unclosed comment, starting at character ' + p);
}
this.next();
return this.white();
}
return ch;
};
Parser.prototype.next = function (c) {
if (c && c !== this.ch) {
this.error("Expected '" + c + "' but got '" + this.ch + "'");
}
this.ch = this.text.charAt(this.at);
this.at += 1;
return this.ch;
};
Parser.prototype.lookahead = function () {
return this.text[this.at];
};
Parser.prototype.error = function (m) {
if (m instanceof Error) {
throw m;
}
var _a = __read(m.name ? [m.name, m.message] : [m, ''], 2), name = _a[0], msg = _a[1];
var message = "\n" + name + " " + msg + " of\n " + this.text + "\n" + Array(this.at).join(' ') + '_/ 🔥 \\_\n';
throw new Error(message);
};
Parser.prototype.name = function () {
// A name of a binding
var name = '';
var enclosedBy;
this.white();
var ch = this.ch;
if (ch === "'" || ch === '"') {
enclosedBy = ch;
ch = this.next();
}
while (ch) {
if (enclosedBy && ch === enclosedBy) {
this.white();
ch = this.next();
if (ch !== ':' && ch !== ',') {
this.error('Object name: ' + name + ' missing closing ' + enclosedBy);
}
return name;
}
else if (ch === ':' || ch <= ' ' || ch === ',' || ch === '|') {
return name;
}
name += ch;
ch = this.next();
}
return name;
};
Parser.prototype.number = function () {
var number;
var string = '';
var ch = this.ch;
if (ch === '-') {
string = '-';
ch = this.next('-');
}
while (ch >= '0' && ch <= '9') {
string += ch;
ch = this.next();
}
if (ch === '.') {
string += '.';
ch = this.next();
while (ch && ch >= '0' && ch <= '9') {
string += ch;
ch = this.next();
}
}
if (ch === 'e' || ch === 'E') {
string += ch;
ch = this.next();
if (ch === '-' || ch === '+') {
string += ch;
ch = this.next();
}
while (ch >= '0' && ch <= '9') {
string += ch;
ch = this.next();
}
}
number = +string;
if (!isFinite(number)) {
options.onError(new Error('Bad number: ' + number + ' in ' + string));
}
else {
return number;
}
};
/**
* Add a property to 'object' that equals the given value.
* @param {Object} object The object to add the value to.
* @param {String} key object[key] is set to the given value.
* @param {mixed} value The value, may be a primitive or a function. If a
* function it is unwrapped as a property.
*/
Parser.prototype.objectAddValue = function (object, key, value) {
var _this = this;
if (value && value[Node.isExpressionOrIdentifierSymbol]) {
Object.defineProperty(object, key, {
get: function () { return Node.value_of.apply(Node, __spread([value], _this.currentContextGlobals)); },
enumerable: true
});
}
else if (Array.isArray(value)) {
Object.defineProperty(object, key, {
get: function () { return value.map(function (v) { return Node.value_of.apply(Node, __spread([v], _this.currentContextGlobals)); }); },
enumerable: true
});
}
else {
// primitives
object[key] = value;
}
};
Parser.prototype.object = function () {
var key;
var object = {};
var ch = this.ch;
if (ch === '{') {
this.next('{');
ch = this.white();
if (ch === '}') {
ch = this.next('}');
return object;
}
while (ch) {
if (ch === '"' || ch === "'" || ch === '`') {
key = this.string();
}
else {
key = this.name();
}
if (hasOwnProperty(object, key)) {
this.error('Duplicate key "' + key + '"');
}
if (this.white() === ':') {
ch = this.next(':');
this.objectAddValue(object, key, this.expression());
}
else {
var objectKeyIsValue = new Identifier(this, key, []);
this.objectAddValue(object, key, objectKeyIsValue);
}
ch = this.white();
if (ch === '}') {
ch = this.next('}');
return object;
}
this.next(',');
ch = this.white();
if (ch === '}') {
ch = this.next('}');
return object;
}
}
}
this.error('Bad object');
};
/**
* Read up to delim and return the string
* @param {string} delim The delimiter, either ' or "
* @return {string} The string read.
*/
Parser.prototype.readString = function (delim) {
var string = '';
var nodes = [''];
var plusOp = operators['+'];
var hex;
var i;
var uffff;
var interpolate = delim === '`';
var ch = this.next();
while (ch) {
if (ch === delim) {
ch = this.next();
if (interpolate) {
nodes.push(plusOp);
}
nodes.push(string);
return nodes;
}
if (ch === '\\') {
ch = this.next();
if (ch === 'u') {
uffff = 0;
for (i = 0; i < 4; i += 1) {
hex = parseInt(ch = this.next(), 16);
if (!isFinite(hex)) {
break;
}
uffff = uffff * 16 + hex;
}
string += String.fromCharCode(uffff);
}
else if (typeof escapee[ch] === 'string') {
string += escapee[ch];
}
else {
break;
}
}
else if (interpolate && ch === '$') {
ch = this.next();
if (ch === '{') {
this.next('{');
nodes.push(plusOp);
nodes.push(string);
nodes.push(plusOp);
nodes.push(this.expression());
string = '';
// this.next('}');
}
else {
string += '$' + ch;
}
}
else {
string += ch;
}
ch = this.next();
}
this.error('Bad string');
};
Parser.prototype.string = function () {
var ch = this.ch;
if (ch === '"') {
return this.readString('"').join('');
}
else if (ch === "'") {
return this.readString("'").join('');
}
else if (ch === '`') {
return Node.create_root(this.readString('`'));
}
this.error('Bad string');
};
Parser.prototype.array = function () {
var array = [];
var ch = this.ch;
if (ch === '[') {
ch = this.next('[');
this.white();
if (ch === ']') {
ch = this.next(']');
return array;
}
while (ch) {
array.push(this.expression());
ch = this.white();
if (ch === ']') {
ch = this.next(']');
return array;
}
this.next(',');
ch = this.white();
}
}
this.error('Bad array');
};
Parser.prototype.value = function () {
var ch;
this.white();
ch = this.ch;
switch (ch) {
case '{': return this.object();
case '[': return this.array();
case '"':
case "'":
case '`': return this.string();
case '-': return this.number();
default:
return ch >= '0' && ch <= '9' ? this.number() : this.identifier();
}
};
/**
* Get the function for the given operator.
* A `.precedence` value is added to the function, with increasing
* precedence having a higher number.
* @return {function} The function that performs the infix operation
*/
Parser.prototype.operator = function (opts) {
var op = '';
var opFn;
var ch = this.white();
var isIdentifierChar = Identifier.is_valid_start_char;
while (ch) {
if (isIdentifierChar(ch) || ch <= ' ' || ch === '' ||
ch === '"' || ch === "'" || ch === '{' || ch === '(' ||
ch === '`' || ch === ')' || (ch <= '9' && ch >= '0')) {
break;
}
if (!opts.not_an_array && ch === '[') {
break;
}
op += ch;
ch = this.next();
// An infix followed by the prefix e.g. a + @b
// TODO: other prefix unary operators
if (ch === '@') {
break;
}
isIdentifierChar = Identifier.is_valid_continue_char;
}
if (op !== '') {
if (opts.prefix && op === '-') {
op = '&-';
}
opFn = operators[op];
if (!opFn) {
this.error("Bad operator: '" + op + "'.");
}
}
return opFn;
};
/**
* Filters
* Returns what the Node interprets as an "operator".
* e.g.
* <span data-bind="text: name | fit:20 | uppercase"></span>
*/
Parser.prototype.filter = function () {
var ch = this.next();
var args = [];
var nextFilter = function (v) { return v; };
var name = this.name();
if (!options.filters[name]) {
options.onError('Cannot find filter by the name of: ' + name);
}
ch = this.white();
while (ch) {
if (ch === ':') {
ch = this.next();
args.push(this.expression('|'));
}
if (ch === '|') {
nextFilter = this.filter();
break;
}
if (ch === ',') {
break;
}
ch = this.white();
}
var filter = function filter(value, ignored, context, globals, node) {
var argValues = [value];
for (var i = 0, j = args.length; i < j; ++i) {
argValues.push(Node.value_of(args[i], context, globals, node));
}
return nextFilter(options.filters[name].apply(null, argValues));
};
// Lowest precedence.
filter.precedence = 1;
return filter;
};
/**
* Parse an expression – builds an operator tree, in something like
* Shunting-Yard.
* See: http://en.wikipedia.org/wiki/Shunting-yard_algorithm
*
* @return {function} A function that computes the value of the expression
* when called or a primitive.
*/
Parser.prototype.expression = function (filterable) {
var op;
var nodes = [];
var ch = this.white();
while (ch) {
// unary prefix operators
op = this.operator({ prefix: true });
if (op) {
nodes.push(undefined); // LHS Tree node.
nodes.push(op);
ch = this.white();
}
if (ch === '(') {
this.next();
nodes.push(this.expression());
this.next(')');
}
else {
nodes.push(this.value());
}
ch = this.white();
if (ch === ':' || ch === '}' || ch === ',' || ch === ']' ||
ch === ')' || ch === '' || ch === '`' || (ch === '|' && filterable === '|')) {
break;
}
// filters
if (ch === '|' && this.lookahead() !== '|' && filterable) {
nodes.push(this.filter());
nodes.push(undefined);
break;
}
// infix or postfix operators
op = this.operator({ not_an_array: true });
if (op === operators['?']) {
this.ternary(nodes);
break;
}
else if (op === operators['.']) {
nodes.push(op);
nodes.push(this.member());
op = null;
}
else if (op === operators['[']) {
nodes.push(op);
nodes.push(this.expression());
ch = this.next(']');
op = null;
}
else if (op) {
nodes.push(op);
}
ch = this.white();
if (ch === ']' || (!op && ch === '(')) {
break;
}
}
if (nodes.length === 0) {
return undefined;
}
var dereferences = this.dereferences();
if (nodes.length === 1 && !dereferences.length) {
return nodes[0];
}
for (var i = 0, j = dereferences.length; i < j; ++i) {
var deref = dereferences[i];
if (deref.constructor === Arguments) {
nodes.push(operators.call);
}
else {
nodes.push(operators['.']);
}
nodes.push(deref);
}
return new Expression(nodes);
};
Parser.prototype.ternary = function (nodes) {
var ternary = new Ternary();
ternary.yes = this.expression();
this.next(':');
ternary.no = this.expression();
nodes.push(operators['?']);
nodes.push(ternary);
};
/**
* Parse the arguments to a function, returning an Array.
*
*/
Parser.prototype.funcArguments = function () {
var args = [];
var ch = this.next('(');
while (ch) {
ch = this.white();
if (ch === ')') {
this.next(')');
return new Arguments(this, args);
}
else {
args.push(this.expression());
ch = this.white();
}
if (ch !== ')') {
this.next(',');
}
}
this.error('Bad arguments to function');
};
/**
* The literal string reference `abc` in an `x.abc` expression.
*/
Parser.prototype.member = function () {
var member = '';
var ch = this.white();
var isIdentifierChar = Identifier.is_valid_start_char;
while (ch) {
if (!isIdentifierChar(ch)) {
break;
}
member += ch;
ch = this.next();
isIdentifierChar = Identifier.is_valid_continue_char;
}
return member;
};
/**
* A dereference applies to an identifer, being either a function
* call "()" or a membership lookup with square brackets "[member]".
* @return {fn or undefined} Dereference function to be applied to the
* Identifier
*/
Parser.prototype.dereference = function () {
var member;
var ch = this.white();
while (ch) {
if (ch === '(') {
// a(...) function call
return this.funcArguments();
}
else if (ch === '[') {
// a[x] membership
this.next('[');
member = this.expression();
this.white();
this.next(']');
return member;
}
else if (ch === '.') {
// a.x membership
this.next('.');
return this.member();
}
else {
break;
}
}
};
Parser.prototype.dereferences = function () {
var ch = this.white();
var dereferences = [];
var deref;
while (ch) {
deref = this.dereference();
if (deref !== undefined) {
dereferences.push(deref);
}
else {
break;
}
}
return dereferences;
};
Parser.prototype.identifier = function () {
var token = '';
var isIdentifierChar = Identifier.is_valid_start_char;
var ch = this.white();
while (ch) {
if (!isIdentifierChar(ch)) {
break;
}
token += ch;
ch = this.next();
isIdentifierChar = Identifier.is_valid_continue_char;
}
switch (token) {
case 'true': return true;
case 'false': return false;
case 'null': return null;
case 'undefined': return void 0;
case 'function':
throw new Error('Knockout: Anonymous functions are no longer supported, but `=>` lambdas are.');
// return this.anonymous_fn();
}
return new Identifier(this, token, this.dereferences());
};
Parser.prototype.readBindings = function () {
var key;
var bindings = {};
var sep;
var expr;
var ch = this.ch;
while (ch) {
key = this.name();
sep = this.white();
if (!sep || sep === ',') {
if (sep) {
ch = this.next(',');
}
else {
ch = '';
}
// A "bare" binding e.g. "text"; substitute value of 'null'
// so it becomes "text: null".
bindings[key] = null;
}
else {
if (key.indexOf('.') !== -1) {
// Namespaced – i.e.
// `attr.css: x` becomes `attr: { css: x }`
// ^^^ - key
key = key.split('.');
bindings[key[0]] = bindings[key[0]] || {};
if (key.length !== 2) {
options.onError('Binding ' + key + ' should have two parts (a.b).');
}
else if (bindings[key[0]].constructor !== Object) {
options.onError('Binding ' + key[0] + '.' + key[1] + ' paired with a non-object.');
}
ch = this.next(':');
this.objectAddValue(bindings[key[0]], key[1], this.expression(true));
}
else {
ch = this.next(':');
if (bindings[key] && typeof bindings[key] === 'object' && bindings[key].constructor === Object) {
// Extend a namespaced bindings e.g. we've previously seen
// on.x, now we're seeing on: { 'abc' }.
expr = this.expression(true);
if (typeof expr !== 'object' || expr.constructor !== Object) {
options.onError('Expected plain object for ' + key + ' value.');
}
else {
extend(bindings[key], expr);
}
}
else {
bindings[key] = this.expression(true);
}
}
this.white();
if (this.ch) {
ch = this.next(',');
}
else {
ch = '';
}
}
}
return bindings;
};
Parser.prototype.valueAsAccessor = function (value, context, globals, node) {
if (!value) {
return function () { return value; };
}
if (typeof value === 'function') {
return value;
}
if (value[Node.isExpressionOrIdentifierSymbol]) {
return function () { return Node.value_of(value, context, globals, node); };
}
if (Array.isArray(value)) {
return function () { return value.map(function (v) { return Node.value_of(v, context, globals, node); }); };
}
if (typeof (value) !== 'function') {
return function () { return clonePlainObjectDeep(value); };
}
throw new Error('Value has cannot be converted to accessor: ' + value);
};
/**
* Convert result[name] from a value to a function (i.e. `valueAccessor()`)
* @param {object} result [Map of top-level names to values]
* @return {object} [Map of top-level names to functions]
*
* Accessors may be one of (below) constAccessor, identifierAccessor,
* expressionAccessor, or nodeAccessor.
*/
Parser.prototype.convertToAccessors = function (result, context, globals, node) {
var _this = this;
objectForEach(result, function (name, value) {
if (value instanceof Identifier) {
// Return a function that, with no arguments returns
// the value of the identifier, otherwise sets the
// value of the identifier to the first given argument.
Object.defineProperty(result, name, {
value: function (optionalValue, options$$1) {
var currentValue = value.get_value(undefined, context, globals, node);
if (arguments.length === 0) {
return currentValue;
}
var unchanged = optionalValue === currentValue;
if (options$$1 && options$$1.onlyIfChanged && unchanged) {
return;
}
return value.set_value(optionalValue, context, globals);
}
});
}
else {
result[name] = _this.valueAsAccessor(value, context, globals, node);
}
});
return result;
};
Parser.prototype.preparse = function (source) {
if (source === void 0) { source = ''; }
var preparsers = options.bindingStringPreparsers || [];
return preparsers.reduce(function (acc, fn) { return fn(acc); }, source.trim());
};
Parser.prototype.runParse = function (source, fn) {
this.text = this.preparse(source);
this.at = 0;
this.ch = ' ';
try {
var result = fn();
this.white();
if (this.ch) {
this.error('Syntax Error');
}
return result;
}
catch (e) {
options.onError(e);
}
};
/**
* Get the bindings as name: accessor()
* @param {string} source The binding string to parse.
* @return {object} Map of name to accessor function.
*/
Parser.prototype.parse = function (source, context, globals, node) {
var _this = this;
if (context === void 0) { context = {}; }
if (globals === void 0) { globals = {}; }
if (!source) {
return function () { return null; };
}
this.currentContextGlobals = [context, globals, node];
var parseFn = function () { return _this.readBindings(); };
var bindingAccessors = this.runParse(source, parseFn);
return this.convertToAccessors(bindingAccessors, context, globals, node);
};
/**
* Return a function that evaluates and returns the result of the expression.
*/
Parser.prototype.parseExpression = function (source, context, globals, node) {
var _this = this;
if (context === void 0) { context = {}; }
if (globals === void 0) { globals = {}; }
if (!source) {
return function () { return ''; };
}
this.currentContextGlobals = [context, globals, node];
var parseFn = function () { return _this.expression(true); };
var bindingAccessors = this.runParse(source, parseFn);
return this.valueAsAccessor(bindingAccessors, context, globals, node);
};
return Parser;
}());
/* eslint no-cond-assign: 0 */
// The following regular expressions will be used to split an object-literal string into tokens
// These characters have special meaning to the parser and must not appear in the middle of a
// token, except as part of a string.
var specials = ',"\'`{}()/:[\\]';
var bindingToken = RegExp([
// These match strings, either with double quotes, single quotes, or backticks
'"(?:\\\\.|[^"])*"',
"'(?:\\\\.|[^'])*'",
'`(?:\\\\.|[^`])*`',
// Match C style comments
'/\\*(?:[^*]|\\*+[^*/])*\\*+/',
// Match C++ style comments
'//.*\n',
// Match a regular expression (text enclosed by slashes), but will also match sets of divisions
// as a regular expression (this is handled by the parsing loop below).
'/(?:\\\\.|[^/])+/\\w*',
// Match text (at least two characters) that does not contain any of the above special characters,
// although some of the special characters are allowed to start it (all but the colon and comma).
// The text can contain spaces, but leading or trailing spaces are skipped.
'[^\\s:,/][^' + specials + ']*[^\\s' + specials + ']',
// Match any non-space character not matched already. This will match colons and commas, since they're
// not matched by "everyThingElse", but will also match any other single character that wasn't already
// matched (for example: in "a: 1, b: 2", each of the non-space characters will be matched by oneNotSpace).
'[^\\s]'
].join('|'), 'g');
// Match end of previous token to determine whether a slash is a division or regex.
var divisionLookBehind = /[\])"'A-Za-z0-9_$]+$/;
var keywordRegexLookBehind = { 'in': 1, 'return': 1, 'typeof': 1 };
/**
* Break a binding string (data-bind='x: val, y: ..') into a stable array
* of {key: value}.
*/
function parseObjectLiteral(objectLiteralString) {
// Trim leading and trailing spaces from the string
var str = stringTrim(objectLiteralString);
// Trim braces '{' surrounding the whole object literal
if (str.charCodeAt(0) === 123)
str = str.slice(1, -1);
// Add a newline to correctly match a C++ style comment at the end of the string and
// add a comma so that we don't need a separate code block to deal with the last item
str += '\n,';
// Split into tokens
var result = [];
var toks = str.match(bindingToken);
var key;
var values = [];
var depth = 0;
if (toks.length <= 1) {
return [];
}
for (var i = 0, tok; tok = toks[i]; ++i) {
var c = tok.charCodeAt(0);
// A comma signals the end of a key/value pair if depth is zero
if (c === 44) { // ","
if (depth <= 0) {
result.push((key && values.length) ? {
key: key,
value: values.join('')
} : {
'unknown': key || values.join('')
});
key = depth = 0;
values = [];
continue;
}
// Simply skip the colon that separates the name and value
}
else if (c === 58) { // ":"
if (!depth && !key && values.length === 1) {
key = values.pop();
continue;
}
// A set of slashes is initially matched as a regular expression, but could be division
}
else if (c === 47 && tok.length > 1 && (tok.charCodeAt(1) === 47 || tok.charCodeAt(1) === 42)) { // "//" or "/*"
// skip comments
continue;
}
else if (c === 47 && i && tok.length > 1) { // "/"
// Look at the end of the previous token to determine if the slash is actually division
var match = toks[i - 1].match(divisionLookBehind);
if (match && !keywordRegexLookBehind[match[0]]) {
// The slash is actually a division punctuator; re-parse the remainder of the string (not including the slash)
str = str.substr(str.indexOf(tok) + 1);
toks = str.match(bindingToken);
i = -1;
// Continue with just the slash
tok = '/';
}
// Increment depth for parentheses, braces, and brackets so that interior commas are ignored
}
else if (c === 40 || c === 123 || c === 91) { // '(', '{', '['
++depth;
}
else if (c === 41 || c === 125 || c === 93) { // ')', '}', ']'
--depth;
// The key will be the first token; if it's a string, trim the quotes
}
else if (!key && !values.length && (c === 34 || c === 39)) { // '"', "'"
tok = tok.slice(1, -1);
}
values.push(tok);
}
return result;
}
export { Parser, Identifier, Arguments, Node, parseObjectLiteral };
//# sourceMappingURL=utils.parser.js.map
{"version":3,"file":"utils.parser.js","sources":["../../../node_modules/tslib/tslib.es6.js"],"sourcesContent":["/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation. All rights reserved.\r\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use\r\nthis file except in compliance with the License. You may obtain a copy of the\r\nLicense at http://www.apache.org/licenses/LICENSE-2.0\r\n\r\nTHIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\r\nKIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED\r\nWARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,\r\nMERCHANTABLITY OR NON-INFRINGEMENT.\r\n\r\nSee the Apache Version 2.0 License for specific language governing permissions\r\nand limitations under the License.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport function __exportStar(m, exports) {\r\n for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\r\n}\r\n\r\nexport function __values(o) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator], i = 0;\r\n if (m) return m.call(o);\r\n return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n};\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\r\n result.default = mod;\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n"],"names":[],"mappings":";;;;;;;;;AAAA;;;;;;;;;;;;;;AAcA;AAyGA,SAAgB,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE;IACzB,IAAI,CAAC,GAAG,OAAO,MAAM,KAAK,UAAU,IAAI,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC3D,IAAI,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;IACjB,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;IACjC,IAAI;QACA,OAAO,CAAC,CAAC,KAAK,KAAK,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;KAC9E;IACD,OAAO,KAAK,EAAE,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAE;YAC/B;QACJ,IAAI;YACA,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACp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