tutuca 0.9.25 → 0.9.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/tutuca-cli.js +109 -94
- package/dist/tutuca-dev.js +110 -91
- package/dist/tutuca-dev.min.js +2 -2
- package/dist/tutuca-extra.js +84 -84
- package/dist/tutuca-extra.min.js +2 -2
- package/dist/tutuca.js +84 -84
- package/dist/tutuca.min.js +2 -2
- package/package.json +1 -1
package/dist/tutuca-cli.js
CHANGED
|
@@ -739,13 +739,10 @@ class ValParser {
|
|
|
739
739
|
switch (charCode) {
|
|
740
740
|
case 94: {
|
|
741
741
|
const newS = px.frame.macroVars?.[s.slice(1)];
|
|
742
|
-
if (newS !== undefined)
|
|
742
|
+
if (newS !== undefined)
|
|
743
743
|
return this.parse(newS, px);
|
|
744
|
-
}
|
|
745
744
|
return null;
|
|
746
745
|
}
|
|
747
|
-
case 126:
|
|
748
|
-
return this.okStrTpl ? parseConst(s.slice(1), px) : null;
|
|
749
746
|
case 39:
|
|
750
747
|
return this.okStrTpl ? parseConst(s.slice(1, -1), px) : null;
|
|
751
748
|
case 64:
|
|
@@ -858,7 +855,7 @@ function getValSubType(s) {
|
|
|
858
855
|
return open === 1 && close === 1 ? VAL_SUB_TYPE_SEQ_ACCESS : VAL_SUB_TYPE_INVALID;
|
|
859
856
|
return -1;
|
|
860
857
|
}
|
|
861
|
-
var VALID_VAL_ID_RE, isValidValId = (name) => VALID_VAL_ID_RE.test(name), VALID_FLOAT_RE, parseStrTemplate = (v, px) => StrTplVal.parse(v, px), parseConst = (v, _) => new ConstVal(v), parseName = (v, _) => isValidValId(v) ? new NameVal(v) : null, parseType = (v, _) => isValidValId(v) ? new TypeVal(v) : null, parseBind = (v, _) => isValidValId(v) ? new BindVal(v) : null, parseDyn = (v, _) => isValidValId(v) ? new DynVal(v) : null, parseField = (v, _) => isValidValId(v) ? new FieldVal(v) : null, parseComp = (v, _) => isValidValId(v) ? new ComputedVal(v) : null, parseReq = (v, _) => isValidValId(v) ? new RequestVal(v) : null, ConstVal, VarVal, StrTplVal, NameVal, InputHandlerNameVal, AlterHandlerNameVal, mk404Handler = (type, name) => function(...args) {
|
|
858
|
+
var VALID_VAL_ID_RE, isValidValId = (name) => VALID_VAL_ID_RE.test(name), VALID_FLOAT_RE, STR_TPL_SPLIT_RE, parseStrTemplate = (v, px) => StrTplVal.parse(v, px), parseConst = (v, _) => new ConstVal(v), parseName = (v, _) => isValidValId(v) ? new NameVal(v) : null, parseType = (v, _) => isValidValId(v) ? new TypeVal(v) : null, parseBind = (v, _) => isValidValId(v) ? new BindVal(v) : null, parseDyn = (v, _) => isValidValId(v) ? new DynVal(v) : null, parseField = (v, _) => isValidValId(v) ? new FieldVal(v) : null, parseComp = (v, _) => isValidValId(v) ? new ComputedVal(v) : null, parseReq = (v, _) => isValidValId(v) ? new RequestVal(v) : null, ConstVal, VarVal, StrTplVal, NameVal, InputHandlerNameVal, AlterHandlerNameVal, mk404Handler = (type, name) => function(...args) {
|
|
862
859
|
console.warn("handler not found", { type, name, args }, this);
|
|
863
860
|
return this;
|
|
864
861
|
}, TypeVal, RequestVal, RawFieldVal, RenderVal, RenderNameVal, BindVal, DynVal, FieldVal, ComputedVal, SeqAccessVal, VAL_SUB_TYPE_STRING_TEMPLATE = 0, VAL_SUB_TYPE_SEQ_ACCESS = 1, VAL_SUB_TYPE_INVALID = 2, VAL_SUB_TYPE_CONST_STRING = 3, vp;
|
|
@@ -866,6 +863,7 @@ var init_value = __esm(() => {
|
|
|
866
863
|
init_path();
|
|
867
864
|
VALID_VAL_ID_RE = /^[a-zA-Z][a-zA-Z0-9_]*$/;
|
|
868
865
|
VALID_FLOAT_RE = /^-?[0-9]+(\.[0-9]+)?$/;
|
|
866
|
+
STR_TPL_SPLIT_RE = /(\{[^}]+\})/g;
|
|
869
867
|
ConstVal = class ConstVal extends BaseVal {
|
|
870
868
|
constructor(val) {
|
|
871
869
|
super();
|
|
@@ -899,7 +897,7 @@ var init_value = __esm(() => {
|
|
|
899
897
|
return strs.join("");
|
|
900
898
|
}
|
|
901
899
|
static parse(s, px) {
|
|
902
|
-
const parts = s.split(
|
|
900
|
+
const parts = s.split(STR_TPL_SPLIT_RE);
|
|
903
901
|
const vals = new Array(parts.length);
|
|
904
902
|
let allConsts = true;
|
|
905
903
|
for (let i = 0;i < parts.length; i++) {
|
|
@@ -1333,9 +1331,8 @@ function optimizeChilds(childs) {
|
|
|
1333
1331
|
}
|
|
1334
1332
|
}
|
|
1335
1333
|
function optimizeNode(node) {
|
|
1336
|
-
if (node.isConstant())
|
|
1334
|
+
if (node.isConstant())
|
|
1337
1335
|
return new RenderOnceNode(node);
|
|
1338
|
-
}
|
|
1339
1336
|
node.optimize();
|
|
1340
1337
|
return node;
|
|
1341
1338
|
}
|
|
@@ -1401,12 +1398,6 @@ class ParseContext {
|
|
|
1401
1398
|
newDOMParser() {
|
|
1402
1399
|
return new this.DOMParser;
|
|
1403
1400
|
}
|
|
1404
|
-
isTextNode(v) {
|
|
1405
|
-
return v instanceof this.Text;
|
|
1406
|
-
}
|
|
1407
|
-
isCommentNode(v) {
|
|
1408
|
-
return v instanceof this.Comment;
|
|
1409
|
-
}
|
|
1410
1401
|
addNodeIf(Class, val, extra) {
|
|
1411
1402
|
if (val !== null) {
|
|
1412
1403
|
const nodeId = this.nodes.length;
|
|
@@ -1425,21 +1416,18 @@ class ParseContext {
|
|
|
1425
1416
|
newMacroNode(macroName, mAttrs, childs) {
|
|
1426
1417
|
const anySlot = [];
|
|
1427
1418
|
const slots = { _: new FragmentNode(anySlot) };
|
|
1428
|
-
for (const child of childs)
|
|
1429
|
-
if (child instanceof SlotNode)
|
|
1419
|
+
for (const child of childs)
|
|
1420
|
+
if (child instanceof SlotNode)
|
|
1430
1421
|
slots[child.val.val] = child.node;
|
|
1431
|
-
|
|
1422
|
+
else if (!(child instanceof TextNode) || !child.isWhiteSpace())
|
|
1432
1423
|
anySlot.push(child);
|
|
1433
|
-
}
|
|
1434
|
-
}
|
|
1435
1424
|
const node = new MacroNode(macroName, mAttrs, slots, this);
|
|
1436
1425
|
this.macroNodes.push(node);
|
|
1437
1426
|
return node;
|
|
1438
1427
|
}
|
|
1439
1428
|
compile(scope) {
|
|
1440
|
-
for (let i = 0;i < this.macroNodes.length; i++)
|
|
1429
|
+
for (let i = 0;i < this.macroNodes.length; i++)
|
|
1441
1430
|
this.macroNodes[i].compile(scope);
|
|
1442
|
-
}
|
|
1443
1431
|
}
|
|
1444
1432
|
*genEventNames() {
|
|
1445
1433
|
for (const event of this.events)
|
|
@@ -1490,12 +1478,11 @@ class NodeEvents {
|
|
|
1490
1478
|
}
|
|
1491
1479
|
getHandlersFor(eventName) {
|
|
1492
1480
|
let r = null;
|
|
1493
|
-
for (const handler of this.handlers)
|
|
1481
|
+
for (const handler of this.handlers)
|
|
1494
1482
|
if (handler.handlesEventName(eventName)) {
|
|
1495
1483
|
r ??= [];
|
|
1496
1484
|
r.push(handler);
|
|
1497
1485
|
}
|
|
1498
|
-
}
|
|
1499
1486
|
return r;
|
|
1500
1487
|
}
|
|
1501
1488
|
}
|
|
@@ -1629,9 +1616,9 @@ var init_anode = __esm(() => {
|
|
|
1629
1616
|
return ANode.fromDOM(nodes[0] ?? new px.Text(""), px);
|
|
1630
1617
|
}
|
|
1631
1618
|
static fromDOM(node, px) {
|
|
1632
|
-
if (px.
|
|
1619
|
+
if (node instanceof px.Text)
|
|
1633
1620
|
return new TextNode(node.textContent);
|
|
1634
|
-
else if (px.
|
|
1621
|
+
else if (node instanceof px.Comment)
|
|
1635
1622
|
return new CommentNode(node.textContent);
|
|
1636
1623
|
const { childNodes, attributes: attrs, tagName: tag } = node;
|
|
1637
1624
|
const childs = new Array(childNodes.length);
|
|
@@ -1697,9 +1684,9 @@ var init_anode = __esm(() => {
|
|
|
1697
1684
|
if (this.px.isInsideMacro(name))
|
|
1698
1685
|
throw new Error(`Recursive macro expansion: ${name}`);
|
|
1699
1686
|
const macro = scope.lookupMacro(name);
|
|
1700
|
-
if (macro === null)
|
|
1687
|
+
if (macro === null)
|
|
1701
1688
|
this.node = new CommentNode(`bad macro: ${name}`);
|
|
1702
|
-
|
|
1689
|
+
else {
|
|
1703
1690
|
const vars = { ...macro.defaults, ...attrs };
|
|
1704
1691
|
this.node = macro.expand(this.px.enterMacro(name, vars, slots));
|
|
1705
1692
|
for (const key in this.dataAttrs)
|
|
@@ -1870,10 +1857,8 @@ var init_anode = __esm(() => {
|
|
|
1870
1857
|
|
|
1871
1858
|
// src/cache.js
|
|
1872
1859
|
class NullDomCache {
|
|
1873
|
-
get(
|
|
1874
|
-
set(
|
|
1875
|
-
get2(_k1, _k2, _cacheKey) {}
|
|
1876
|
-
set2(_k1, _k2, _cacheKey, _v) {}
|
|
1860
|
+
get(_keys, _cacheKey) {}
|
|
1861
|
+
set(_keys, _cacheKey, _v) {}
|
|
1877
1862
|
evict() {
|
|
1878
1863
|
return { hit: 0, miss: 0, badKey: 0 };
|
|
1879
1864
|
}
|
|
@@ -1882,7 +1867,7 @@ class NullDomCache {
|
|
|
1882
1867
|
class WeakMapDomCache {
|
|
1883
1868
|
constructor() {
|
|
1884
1869
|
this.hit = this.miss = this.badKey = 0;
|
|
1885
|
-
this.
|
|
1870
|
+
this.keysByLen = new Map;
|
|
1886
1871
|
}
|
|
1887
1872
|
_returnValue(r) {
|
|
1888
1873
|
if (r === undefined)
|
|
@@ -1891,41 +1876,51 @@ class WeakMapDomCache {
|
|
|
1891
1876
|
this.hit += 1;
|
|
1892
1877
|
return r;
|
|
1893
1878
|
}
|
|
1894
|
-
get(
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
cur
|
|
1901
|
-
|
|
1902
|
-
|
|
1879
|
+
get(keys, cacheKey) {
|
|
1880
|
+
const len = keys.length;
|
|
1881
|
+
let cur = this.keysByLen.get(len);
|
|
1882
|
+
if (!cur)
|
|
1883
|
+
return this._returnValue(undefined);
|
|
1884
|
+
for (let i = 0;i < len - 1; i++) {
|
|
1885
|
+
cur = cur.get(keys[i]);
|
|
1886
|
+
if (!cur)
|
|
1887
|
+
return this._returnValue(undefined);
|
|
1888
|
+
}
|
|
1889
|
+
return this._returnValue(cur.get(keys[len - 1])?.[cacheKey]);
|
|
1890
|
+
}
|
|
1891
|
+
set(keys, cacheKey, v) {
|
|
1892
|
+
const len = keys.length;
|
|
1893
|
+
let cur = this.keysByLen.get(len);
|
|
1894
|
+
if (!cur) {
|
|
1895
|
+
cur = new WeakMap;
|
|
1896
|
+
this.keysByLen.set(len, cur);
|
|
1897
|
+
}
|
|
1898
|
+
for (let i = 0;i < len - 1; i++) {
|
|
1899
|
+
const key = keys[i];
|
|
1900
|
+
let next = cur.get(key);
|
|
1901
|
+
if (!next) {
|
|
1902
|
+
if (typeof key !== "object") {
|
|
1903
|
+
this.badKey += 1;
|
|
1904
|
+
return;
|
|
1905
|
+
}
|
|
1906
|
+
next = new WeakMap;
|
|
1907
|
+
cur.set(key, next);
|
|
1908
|
+
}
|
|
1909
|
+
cur = next;
|
|
1910
|
+
}
|
|
1911
|
+
const lastKey = keys[len - 1];
|
|
1912
|
+
const leaf = cur.get(lastKey);
|
|
1913
|
+
if (leaf)
|
|
1914
|
+
leaf[cacheKey] = v;
|
|
1915
|
+
else if (typeof lastKey === "object")
|
|
1916
|
+
cur.set(lastKey, { [cacheKey]: v });
|
|
1903
1917
|
else
|
|
1904
1918
|
this.badKey += 1;
|
|
1905
1919
|
}
|
|
1906
|
-
get2(k1, k2, cacheKey) {
|
|
1907
|
-
return this._returnValue(this.map.get(k1)?.get?.(k2)?.[cacheKey]);
|
|
1908
|
-
}
|
|
1909
|
-
set2(k1, k2, cacheKey, v) {
|
|
1910
|
-
const cur1 = this.map.get(k1);
|
|
1911
|
-
if (cur1) {
|
|
1912
|
-
const cur = cur1.get(k2);
|
|
1913
|
-
if (cur)
|
|
1914
|
-
cur[cacheKey] = v;
|
|
1915
|
-
else
|
|
1916
|
-
cur1.set(k2, { [cacheKey]: v });
|
|
1917
|
-
} else if (typeof k1 === "object" && typeof k2 === "object") {
|
|
1918
|
-
const cur = new WeakMap;
|
|
1919
|
-
cur.set(k2, { [cacheKey]: v });
|
|
1920
|
-
this.map.set(k1, cur);
|
|
1921
|
-
} else {
|
|
1922
|
-
this.badKey += 1;
|
|
1923
|
-
}
|
|
1924
|
-
}
|
|
1925
1920
|
evict() {
|
|
1926
1921
|
const { hit, miss, badKey } = this;
|
|
1927
1922
|
this.hit = this.miss = this.badKey = 0;
|
|
1928
|
-
this.
|
|
1923
|
+
this.keysByLen = new Map;
|
|
1929
1924
|
return { hit, miss, badKey };
|
|
1930
1925
|
}
|
|
1931
1926
|
}
|
|
@@ -2047,8 +2042,8 @@ class ComponentStack {
|
|
|
2047
2042
|
return this.macros[name] ?? this.parent?.lookupMacro(name) ?? null;
|
|
2048
2043
|
}
|
|
2049
2044
|
}
|
|
2050
|
-
function defaultOnStackEnter(
|
|
2051
|
-
return
|
|
2045
|
+
function defaultOnStackEnter() {
|
|
2046
|
+
return null;
|
|
2052
2047
|
}
|
|
2053
2048
|
var init_components = __esm(() => {
|
|
2054
2049
|
init_attribute();
|
|
@@ -2075,6 +2070,21 @@ function checkView(lx, view, Comp, referencedAlters, referencedComputed) {
|
|
|
2075
2070
|
checkRenderItInLoop(lx, view);
|
|
2076
2071
|
checkEventModifiers(lx, view);
|
|
2077
2072
|
checkKnownHandlerNames(lx, view, Comp, referencedAlters, referencedComputed);
|
|
2073
|
+
checkMacroCallArgs(lx, view, Comp);
|
|
2074
|
+
}
|
|
2075
|
+
function checkMacroCallArgs(lx, view, Comp) {
|
|
2076
|
+
const { scope } = Comp;
|
|
2077
|
+
for (const macroNode of view.ctx.macroNodes) {
|
|
2078
|
+
const macro = scope.lookupMacro(macroNode.name);
|
|
2079
|
+
if (macro === null)
|
|
2080
|
+
continue;
|
|
2081
|
+
const { defaults } = macro;
|
|
2082
|
+
for (const argName in macroNode.attrs) {
|
|
2083
|
+
if (!(argName in defaults)) {
|
|
2084
|
+
lx.error(UNKNOWN_MACRO_ARG, { name: argName, macroName: macroNode.name });
|
|
2085
|
+
}
|
|
2086
|
+
}
|
|
2087
|
+
}
|
|
2078
2088
|
}
|
|
2079
2089
|
function checkRenderItInLoop(lx, view) {
|
|
2080
2090
|
let hasRenderIt = false;
|
|
@@ -2124,7 +2134,7 @@ function checkEventModifiers(lx, view) {
|
|
|
2124
2134
|
const modWrappers = MOD_WRAPPERS_BY_EVENT[name] ?? NO_WRAPPERS;
|
|
2125
2135
|
for (const modifier of modifiers) {
|
|
2126
2136
|
if (modWrappers[modifier] === undefined) {
|
|
2127
|
-
lx.
|
|
2137
|
+
lx.error(UNKNOWN_EVENT_MODIFIER, { name, modifier, handler, event });
|
|
2128
2138
|
}
|
|
2129
2139
|
}
|
|
2130
2140
|
}
|
|
@@ -2160,7 +2170,7 @@ function checkEventHandlersHaveImpls(lx, Comp, referencedInputs) {
|
|
|
2160
2170
|
if (hvName === "InputHandlerNameVal") {
|
|
2161
2171
|
referencedInputs?.add(handlerVal.name);
|
|
2162
2172
|
if (input[handlerVal.name] === undefined) {
|
|
2163
|
-
lx.
|
|
2173
|
+
lx.error(INPUT_HANDLER_NOT_IMPLEMENTED, {
|
|
2164
2174
|
name: handlerVal.name,
|
|
2165
2175
|
handler,
|
|
2166
2176
|
event
|
|
@@ -2176,7 +2186,7 @@ function checkEventHandlersHaveImpls(lx, Comp, referencedInputs) {
|
|
|
2176
2186
|
} else if (hvName === "RawFieldVal") {
|
|
2177
2187
|
referencedInputs?.add(handlerVal.name);
|
|
2178
2188
|
if (proto[handlerVal.name] === undefined) {
|
|
2179
|
-
lx.
|
|
2189
|
+
lx.error(INPUT_HANDLER_METHOD_NOT_IMPLEMENTED, {
|
|
2180
2190
|
name: handlerVal.name,
|
|
2181
2191
|
handler,
|
|
2182
2192
|
event
|
|
@@ -2213,15 +2223,15 @@ function checkConsistentAttrVal(lx, val, fields, proto, computed, scope, alter,
|
|
|
2213
2223
|
checkConsistentAttrVal(lx, val.keyVal, fields, proto, computed, scope, alter, referencedAlters, referencedComputed, skipNameVal);
|
|
2214
2224
|
} else if (valName === "RequestVal") {
|
|
2215
2225
|
if (scope.lookupRequest(val.name) === null) {
|
|
2216
|
-
lx.
|
|
2226
|
+
lx.error(UNKNOWN_REQUEST_NAME, { name: val.name });
|
|
2217
2227
|
}
|
|
2218
2228
|
} else if (valName === "TypeVal") {
|
|
2219
2229
|
if (scope.lookupComponent(val.name) === null) {
|
|
2220
|
-
lx.
|
|
2230
|
+
lx.error(UNKNOWN_COMPONENT_NAME, { name: val.name });
|
|
2221
2231
|
}
|
|
2222
2232
|
} else if (valName === "NameVal") {
|
|
2223
2233
|
if (!skipNameVal && !isKnownHandlerName(val.name)) {
|
|
2224
|
-
lx.
|
|
2234
|
+
lx.error(UNKNOWN_HANDLER_ARG_NAME, { name: val.name });
|
|
2225
2235
|
}
|
|
2226
2236
|
} else if (valName === "StrTplVal") {
|
|
2227
2237
|
for (const subVal of val.vals) {
|
|
@@ -2230,7 +2240,7 @@ function checkConsistentAttrVal(lx, val, fields, proto, computed, scope, alter,
|
|
|
2230
2240
|
} else if (valName === "AlterHandlerNameVal") {
|
|
2231
2241
|
referencedAlters?.add(val.name);
|
|
2232
2242
|
if (alter[val.name] === undefined) {
|
|
2233
|
-
lx.
|
|
2243
|
+
lx.error(ALT_HANDLER_NOT_DEFINED, { name: val.name });
|
|
2234
2244
|
}
|
|
2235
2245
|
} else if (valName !== "ConstVal" && valName !== "BindVal") {
|
|
2236
2246
|
console.log(val);
|
|
@@ -2334,7 +2344,7 @@ class LintContext {
|
|
|
2334
2344
|
this.reports.push({ id, info, level, context: { ...this.frame } });
|
|
2335
2345
|
}
|
|
2336
2346
|
}
|
|
2337
|
-
var ALT_HANDLER_NOT_DEFINED = "ALT_HANDLER_NOT_DEFINED", ALT_HANDLER_NOT_REFERENCED = "ALT_HANDLER_NOT_REFERENCED", RENDER_IT_OUTSIDE_OF_LOOP = "RENDER_IT_OUTSIDE_OF_LOOP", UNKNOWN_EVENT_MODIFIER = "UNKNOWN_EVENT_MODIFIER", UNKNOWN_HANDLER_ARG_NAME = "UNKNOWN_HANDLER_ARG_NAME", INPUT_HANDLER_NOT_IMPLEMENTED = "INPUT_HANDLER_NOT_IMPLEMENTED", INPUT_HANDLER_NOT_REFERENCED = "INPUT_HANDLER_NOT_REFERENCED", INPUT_HANDLER_METHOD_NOT_IMPLEMENTED = "INPUT_HANDLER_METHOD_NOT_IMPLEMENTED", INPUT_HANDLER_FOR_INPUT_HANDLER_METHOD = "INPUT_HANDLER_FOR_INPUT_HANDLER_METHOD", INPUT_HANDLER_METHOD_FOR_INPUT_HANDLER = "INPUT_HANDLER_METHOD_FOR_INPUT_HANDLER", FIELD_VAL_NOT_DEFINED = "FIELD_VAL_NOT_DEFINED", COMPUTED_VAL_NOT_DEFINED = "COMPUTED_VAL_NOT_DEFINED", COMPUTED_NOT_REFERENCED = "COMPUTED_NOT_REFERENCED", UNKNOWN_REQUEST_NAME = "UNKNOWN_REQUEST_NAME", UNKNOWN_COMPONENT_NAME = "UNKNOWN_COMPONENT_NAME", LEVEL_WARN = "warn", LEVEL_ERROR = "error", LEVEL_HINT = "hint", NO_WRAPPERS, KNOWN_HANDLER_NAMES, LintParseContext;
|
|
2347
|
+
var ALT_HANDLER_NOT_DEFINED = "ALT_HANDLER_NOT_DEFINED", ALT_HANDLER_NOT_REFERENCED = "ALT_HANDLER_NOT_REFERENCED", RENDER_IT_OUTSIDE_OF_LOOP = "RENDER_IT_OUTSIDE_OF_LOOP", UNKNOWN_EVENT_MODIFIER = "UNKNOWN_EVENT_MODIFIER", UNKNOWN_HANDLER_ARG_NAME = "UNKNOWN_HANDLER_ARG_NAME", INPUT_HANDLER_NOT_IMPLEMENTED = "INPUT_HANDLER_NOT_IMPLEMENTED", INPUT_HANDLER_NOT_REFERENCED = "INPUT_HANDLER_NOT_REFERENCED", INPUT_HANDLER_METHOD_NOT_IMPLEMENTED = "INPUT_HANDLER_METHOD_NOT_IMPLEMENTED", INPUT_HANDLER_FOR_INPUT_HANDLER_METHOD = "INPUT_HANDLER_FOR_INPUT_HANDLER_METHOD", INPUT_HANDLER_METHOD_FOR_INPUT_HANDLER = "INPUT_HANDLER_METHOD_FOR_INPUT_HANDLER", FIELD_VAL_NOT_DEFINED = "FIELD_VAL_NOT_DEFINED", COMPUTED_VAL_NOT_DEFINED = "COMPUTED_VAL_NOT_DEFINED", COMPUTED_NOT_REFERENCED = "COMPUTED_NOT_REFERENCED", UNKNOWN_REQUEST_NAME = "UNKNOWN_REQUEST_NAME", UNKNOWN_COMPONENT_NAME = "UNKNOWN_COMPONENT_NAME", UNKNOWN_MACRO_ARG = "UNKNOWN_MACRO_ARG", LEVEL_WARN = "warn", LEVEL_ERROR = "error", LEVEL_HINT = "hint", NO_WRAPPERS, KNOWN_HANDLER_NAMES, LintParseContext;
|
|
2338
2348
|
var init_lint_check = __esm(() => {
|
|
2339
2349
|
init_anode();
|
|
2340
2350
|
NO_WRAPPERS = {};
|
|
@@ -2451,7 +2461,7 @@ class Stack {
|
|
|
2451
2461
|
this.ctx = ctx;
|
|
2452
2462
|
}
|
|
2453
2463
|
_enrichOnEnter() {
|
|
2454
|
-
return this.comps.getOnEnterFor(this.it).call(this.it
|
|
2464
|
+
return this.withDynamicBindings(this.comps.getOnEnterFor(this.it).call(this.it));
|
|
2455
2465
|
}
|
|
2456
2466
|
upToFrameBinds() {
|
|
2457
2467
|
const { comps, binds, dynBinds, views, viewsId, ctx } = this;
|
|
@@ -2466,7 +2476,8 @@ class Stack {
|
|
|
2466
2476
|
enter(it, bindings = {}, isFrame = true) {
|
|
2467
2477
|
const { comps, binds, dynBinds, views, viewsId, ctx } = this;
|
|
2468
2478
|
const newBinds = [new BindFrame(it, bindings, isFrame), binds];
|
|
2469
|
-
|
|
2479
|
+
const stack = new Stack(comps, it, newBinds, dynBinds, views, viewsId, ctx);
|
|
2480
|
+
return isFrame ? stack._enrichOnEnter() : stack;
|
|
2470
2481
|
}
|
|
2471
2482
|
pushViewName(name) {
|
|
2472
2483
|
const { comps, it, binds, dynBinds, views, ctx } = this;
|
|
@@ -2474,17 +2485,26 @@ class Stack {
|
|
|
2474
2485
|
return new Stack(comps, it, binds, dynBinds, newViews, computeViewsId(newViews), ctx);
|
|
2475
2486
|
}
|
|
2476
2487
|
withDynamicBindings(dynamics) {
|
|
2488
|
+
if (dynamics == null || dynamics.length === 0)
|
|
2489
|
+
return this;
|
|
2477
2490
|
const dynObj = {};
|
|
2478
2491
|
const comp = this.comps.getCompFor(this.it);
|
|
2479
2492
|
for (const dynName of dynamics)
|
|
2480
2493
|
comp.dynamic[dynName].evalAndBind(this, dynObj);
|
|
2481
|
-
const { comps, it, binds, views, viewsId, ctx } = this;
|
|
2482
2494
|
const newDynBinds = [new ObjectFrame(dynObj), this.dynBinds];
|
|
2495
|
+
const { comps, it, binds, views, viewsId, ctx } = this;
|
|
2483
2496
|
return new Stack(comps, it, binds, newDynBinds, views, viewsId, ctx);
|
|
2484
2497
|
}
|
|
2498
|
+
_pushDynBindValuesToArray(arr, dyns) {
|
|
2499
|
+
for (const k in dyns)
|
|
2500
|
+
arr.push(this._lookupDynamicWithDynVal(dyns[k]));
|
|
2501
|
+
}
|
|
2502
|
+
_lookupDynamicWithDynVal(d) {
|
|
2503
|
+
return lookup(this.dynBinds, d.getSymbol(this)) ?? d.val.eval(this);
|
|
2504
|
+
}
|
|
2485
2505
|
lookupDynamic(name) {
|
|
2486
2506
|
const d = this.comps.getCompFor(this.it)?.dynamic[name];
|
|
2487
|
-
return d ?
|
|
2507
|
+
return d ? this._lookupDynamicWithDynVal(d) : null;
|
|
2488
2508
|
}
|
|
2489
2509
|
lookupBind(name) {
|
|
2490
2510
|
return lookup(this.binds, name);
|
|
@@ -7725,13 +7745,15 @@ class Renderer {
|
|
|
7725
7745
|
}
|
|
7726
7746
|
_rValComp(stack, val, comp, nid, key, viewName) {
|
|
7727
7747
|
const cacheKey = `${viewName ?? stack.viewsId ?? ""}${nid}-${key}`;
|
|
7728
|
-
const
|
|
7748
|
+
const cachePath = [val];
|
|
7749
|
+
stack._pushDynBindValuesToArray(cachePath, comp.dynamic);
|
|
7750
|
+
const cachedNode = this.cache.get(cachePath, cacheKey);
|
|
7729
7751
|
if (cachedNode)
|
|
7730
7752
|
return cachedNode;
|
|
7731
7753
|
const view = viewName ? comp.getView(viewName) : stack.lookupBestView(comp.views, "main");
|
|
7732
7754
|
const meta = this._renderMetadata({ $: "Comp", nid });
|
|
7733
7755
|
const dom = new VFragment([meta, this.renderView(view, stack)]);
|
|
7734
|
-
this.cache.set(
|
|
7756
|
+
this.cache.set(cachePath, cacheKey, dom);
|
|
7735
7757
|
return dom;
|
|
7736
7758
|
}
|
|
7737
7759
|
pushEachEntry(r, nid, attrName, key, dom) {
|
|
@@ -7743,8 +7765,7 @@ class Renderer {
|
|
|
7743
7765
|
const iterData = loopWith.call(stack.it, seq);
|
|
7744
7766
|
this.getSeqInfo(seq)(seq, (key, value, attrName) => {
|
|
7745
7767
|
if (filter.call(stack.it, key, value, iterData)) {
|
|
7746
|
-
const
|
|
7747
|
-
const dom = this.renderIt(newStack, nodeId, key, viewName);
|
|
7768
|
+
const dom = this.renderIt(stack.enter(value, { key }, true), nodeId, key, viewName);
|
|
7748
7769
|
this.pushEachEntry(r, nodeId, attrName, key, dom);
|
|
7749
7770
|
}
|
|
7750
7771
|
});
|
|
@@ -7757,25 +7778,19 @@ class Renderer {
|
|
|
7757
7778
|
const it = stack.it;
|
|
7758
7779
|
this.getSeqInfo(seq)(seq, (key, value, attrName) => {
|
|
7759
7780
|
if (filter.call(it, key, value, iterData)) {
|
|
7781
|
+
const cachePath = enricher ? [it, value] : [value];
|
|
7760
7782
|
const bindings = { key, value };
|
|
7761
7783
|
const cacheKey = `${nid}-${key}`;
|
|
7762
|
-
|
|
7763
|
-
if (enricher) {
|
|
7784
|
+
if (enricher)
|
|
7764
7785
|
enricher.call(it, bindings, key, value, iterData);
|
|
7765
|
-
|
|
7766
|
-
|
|
7767
|
-
cachedNode = this.cache.get(value, cacheKey);
|
|
7768
|
-
if (cachedNode) {
|
|
7786
|
+
const cachedNode = this.cache.get(cachePath, cacheKey);
|
|
7787
|
+
if (cachedNode)
|
|
7769
7788
|
this.pushEachEntry(r, nid, attrName, key, cachedNode);
|
|
7770
|
-
|
|
7789
|
+
else {
|
|
7790
|
+
const dom = this.renderView(view, stack.enter(value, bindings, false));
|
|
7791
|
+
this.pushEachEntry(r, nid, attrName, key, dom);
|
|
7792
|
+
this.cache.set(cachePath, cacheKey, dom);
|
|
7771
7793
|
}
|
|
7772
|
-
const newStack = stack.enter(value, bindings, false);
|
|
7773
|
-
const dom = this.renderView(view, newStack);
|
|
7774
|
-
this.pushEachEntry(r, nid, attrName, key, dom);
|
|
7775
|
-
if (enricher)
|
|
7776
|
-
this.cache.set2(it, value, cacheKey, dom);
|
|
7777
|
-
else
|
|
7778
|
-
this.cache.set(value, cacheKey, dom);
|
|
7779
7794
|
}
|
|
7780
7795
|
});
|
|
7781
7796
|
return r;
|
|
@@ -8582,7 +8597,7 @@ function pickFormatter(name) {
|
|
|
8582
8597
|
async function formatResult(formatName, result, options = {}) {
|
|
8583
8598
|
const f = pickFormatter(formatName);
|
|
8584
8599
|
const kind = result.constructor.name;
|
|
8585
|
-
if (!f.supports
|
|
8600
|
+
if (!f.supports?.has(kind)) {
|
|
8586
8601
|
throw new Error(`Formatter "${formatName}" does not support ${kind}`);
|
|
8587
8602
|
}
|
|
8588
8603
|
return await f.format(result, options);
|