tutuca 0.9.78 → 0.9.80
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/README.md +1 -1
- package/dist/tutuca-cli.js +132 -58
- package/dist/tutuca-dev.ext.js +155 -83
- package/dist/tutuca-dev.js +155 -83
- package/dist/tutuca-dev.min.js +3 -3
- package/dist/tutuca-extra.ext.js +92 -72
- package/dist/tutuca-extra.js +92 -72
- package/dist/tutuca-extra.min.js +3 -3
- package/dist/tutuca.ext.js +93 -73
- package/dist/tutuca.js +92 -72
- package/dist/tutuca.min.js +3 -3
- package/package.json +1 -1
- package/skill/tutuca/SKILL.md +4 -3
- package/skill/tutuca/advanced.md +22 -18
- package/skill/tutuca/core.md +57 -2
- package/skill/tutuca/patterns/README.md +42 -0
- package/skill/tutuca/patterns/bind-text-and-attributes.md +30 -0
- package/skill/tutuca/patterns/conditional-attribute-value.md +29 -0
- package/skill/tutuca/patterns/coordinate-components.md +26 -0
- package/skill/tutuca/patterns/edit-through-a-dynamic-target.md +27 -0
- package/skill/tutuca/patterns/enrich-each-item.md +25 -0
- package/skill/tutuca/patterns/filter-a-list.md +23 -0
- package/skill/tutuca/patterns/handle-events.md +27 -0
- package/skill/tutuca/patterns/iterate-a-list.md +18 -0
- package/skill/tutuca/patterns/paginate-a-list.md +27 -0
- package/skill/tutuca/patterns/render-a-child-component.md +20 -0
- package/skill/tutuca/patterns/reuse-markup-with-macros.md +35 -0
- package/skill/tutuca/patterns/share-state-without-prop-drilling.md +30 -0
- package/skill/tutuca/patterns/show-or-hide-content.md +22 -0
- package/skill/tutuca/patterns/switch-between-views.md +26 -0
- package/skill/tutuca/patterns/tabbed-interface.md +38 -0
- package/skill/tutuca/semantics.md +2 -2
- package/skill/tutuca-source/tutuca.ext.js +93 -73
package/dist/tutuca-dev.ext.js
CHANGED
|
@@ -477,6 +477,7 @@ var G_BOOL = K_FIELD | K_METHOD | K_BIND | K_DYN | K_CONST;
|
|
|
477
477
|
var G_TEXT = G_BOOL | K_STRTPL;
|
|
478
478
|
var G_COMPONENT = K_FIELD | K_SEQ | K_DYN;
|
|
479
479
|
var G_SEQUENCE = K_FIELD | K_DYN;
|
|
480
|
+
var G_PROVIDE = K_FIELD | K_SEQ;
|
|
480
481
|
var G_FIELD = K_FIELD | K_METHOD | K_CONST | K_STR | K_SEQ;
|
|
481
482
|
var G_VALUE = K_FIELD | K_METHOD | K_BIND | K_DYN | K_NAME | K_TYPE | K_REQUEST | K_CONST;
|
|
482
483
|
var G_PRED_ARG = G_BOOL | K_STR;
|
|
@@ -595,6 +596,9 @@ class ValParser {
|
|
|
595
596
|
parseField(s, px) {
|
|
596
597
|
return this._parseSingle(s, px, G_FIELD);
|
|
597
598
|
}
|
|
599
|
+
parseProvide(s, px) {
|
|
600
|
+
return this._parseSingle(s, px, G_PROVIDE);
|
|
601
|
+
}
|
|
598
602
|
parseHandlerArg(s, px) {
|
|
599
603
|
return this._parseSingle(s, px, G_HANDLER_ARG);
|
|
600
604
|
}
|
|
@@ -1581,21 +1585,22 @@ function h(tagName, properties, children, namespace) {
|
|
|
1581
1585
|
}
|
|
1582
1586
|
|
|
1583
1587
|
// src/anode.js
|
|
1584
|
-
function resolveDynProducer(comp,
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
producerComp = comp.scope?.lookupComponent(dyn.compName);
|
|
1591
|
-
producerDyn = producerComp?.dynamic?.[dyn.dynName];
|
|
1588
|
+
function resolveDynProducer(comp, name) {
|
|
1589
|
+
let producerComp, producerProvide;
|
|
1590
|
+
const lk = comp?.lookup?.[name];
|
|
1591
|
+
if (lk != null) {
|
|
1592
|
+
producerComp = comp.scope?.lookupComponent(lk.compName);
|
|
1593
|
+
producerProvide = producerComp?.provide?.[lk.provideName];
|
|
1592
1594
|
} else {
|
|
1595
|
+
const p = comp?.provide?.[name];
|
|
1596
|
+
if (p == null)
|
|
1597
|
+
return null;
|
|
1593
1598
|
producerComp = comp;
|
|
1594
|
-
|
|
1599
|
+
producerProvide = p;
|
|
1595
1600
|
}
|
|
1596
|
-
if (producerComp == null ||
|
|
1601
|
+
if (producerComp == null || producerProvide == null)
|
|
1597
1602
|
return null;
|
|
1598
|
-
const pi =
|
|
1603
|
+
const pi = producerProvide.val?.toPathItem?.() ?? null;
|
|
1599
1604
|
return { producerCompId: producerComp.id, producerSteps: pi ? [pi] : [] };
|
|
1600
1605
|
}
|
|
1601
1606
|
|
|
@@ -4720,7 +4725,7 @@ function closestName(name, candidates, maxDistance = 2) {
|
|
|
4720
4725
|
}
|
|
4721
4726
|
|
|
4722
4727
|
// tools/core/lint-check.js
|
|
4723
|
-
var KNOWN_COMPONENT_SPEC_KEYS = new Set("name view style commonStyle globalStyle input receive bubble response alter
|
|
4728
|
+
var KNOWN_COMPONENT_SPEC_KEYS = new Set("name view style commonStyle globalStyle input receive bubble response alter views provide lookup fields methods statics".split(" "));
|
|
4724
4729
|
var EMPTY_SET = new Set;
|
|
4725
4730
|
var KNOWN_DIRECTIVE_NAMES = new Set([
|
|
4726
4731
|
"dangerouslysetinnerhtml",
|
|
@@ -4740,6 +4745,9 @@ var ALT_HANDLER_NOT_DEFINED = "ALT_HANDLER_NOT_DEFINED";
|
|
|
4740
4745
|
var ALT_HANDLER_NOT_REFERENCED = "ALT_HANDLER_NOT_REFERENCED";
|
|
4741
4746
|
var DYN_VAL_NOT_DEFINED = "DYN_VAL_NOT_DEFINED";
|
|
4742
4747
|
var DYN_ALIAS_NOT_REFERENCED = "DYN_ALIAS_NOT_REFERENCED";
|
|
4748
|
+
var PROVIDE_NOT_ADDRESSABLE = "PROVIDE_NOT_ADDRESSABLE";
|
|
4749
|
+
var LOOKUP_BAD_SHAPE = "LOOKUP_BAD_SHAPE";
|
|
4750
|
+
var LOOKUP_TARGET_MALFORMED = "LOOKUP_TARGET_MALFORMED";
|
|
4743
4751
|
var RENDER_IT_OUTSIDE_OF_LOOP = "RENDER_IT_OUTSIDE_OF_LOOP";
|
|
4744
4752
|
var UNKNOWN_EVENT_MODIFIER = "UNKNOWN_EVENT_MODIFIER";
|
|
4745
4753
|
var UNKNOWN_HANDLER_ARG_NAME = "UNKNOWN_HANDLER_ARG_NAME";
|
|
@@ -4826,8 +4834,6 @@ function classifyBadValue(value) {
|
|
|
4826
4834
|
const s = value.trim();
|
|
4827
4835
|
if (s === "")
|
|
4828
4836
|
return null;
|
|
4829
|
-
if (/\{[^}]*\}/.test(s) && !s.startsWith("$'"))
|
|
4830
|
-
return "legacy-template";
|
|
4831
4837
|
if (/\s\?\s.+\s:\s/.test(s))
|
|
4832
4838
|
return "ternary";
|
|
4833
4839
|
if (/===|!==|==|!=|<=|>=|\s<\s|\s>\s/.test(s))
|
|
@@ -4839,7 +4845,6 @@ function classifyBadValue(value) {
|
|
|
4839
4845
|
return null;
|
|
4840
4846
|
}
|
|
4841
4847
|
var UNSUPPORTED_EXPR_GUIDANCE = {
|
|
4842
|
-
"legacy-template": "Unquoted {...} string templates are no longer supported. Wrap the value in $'...', e.g. $'flex {.color}'.",
|
|
4843
4848
|
ternary: "Ternary expressions aren't supported in dynamic attributes. Define a method or computed field on the component that returns the value, then reference it as '$methodName'.",
|
|
4844
4849
|
comparison: "Comparisons aren't supported in dynamic attributes. Define a method like 'isFooSelected' that returns the boolean, then reference it as '$isFooSelected'.",
|
|
4845
4850
|
logical: "Logical operators aren't supported in dynamic attributes. Combine the conditions in a method on the component and reference it as '$methodName'.",
|
|
@@ -4849,6 +4854,8 @@ function checkComponent(Comp, lx = new LintContext, { wellKnownExtras = EMPTY_SE
|
|
|
4849
4854
|
return lx.push({ componentName: Comp.name }, () => {
|
|
4850
4855
|
checkUnknownSpecKeys(lx, Comp, wellKnownExtras);
|
|
4851
4856
|
checkFieldDeclarations(lx, Comp);
|
|
4857
|
+
checkProvidesAreAddressable(lx, Comp);
|
|
4858
|
+
checkLookupShapes(lx, Comp);
|
|
4852
4859
|
const referencedAlters = new Set;
|
|
4853
4860
|
const referencedInputs = new Set;
|
|
4854
4861
|
const referencedDynamics = new Set;
|
|
@@ -5029,10 +5036,11 @@ function checkKnownHandlerNames(lx, view, Comp, referencedAlters, referencedDyna
|
|
|
5029
5036
|
}
|
|
5030
5037
|
}
|
|
5031
5038
|
function mkAttrValEnv(Comp, referencedAlters, referencedDynamics) {
|
|
5032
|
-
const { scope, alter,
|
|
5039
|
+
const { scope, alter, provide, lookup, Class } = Comp;
|
|
5033
5040
|
const { prototype: proto } = Class;
|
|
5034
5041
|
const { fields } = Class.getMetaClass();
|
|
5035
|
-
|
|
5042
|
+
const dynamicMap = { ...provide, ...lookup };
|
|
5043
|
+
return { fields, proto, scope, alter, referencedAlters, dynamicMap, referencedDynamics };
|
|
5036
5044
|
}
|
|
5037
5045
|
function checkEventHandlersHaveImpls(lx, Comp, referencedInputs) {
|
|
5038
5046
|
const { input, views, Class } = Comp;
|
|
@@ -5346,10 +5354,51 @@ function checkUnreferencedInputHandlers(lx, Comp, referencedInputs) {
|
|
|
5346
5354
|
}
|
|
5347
5355
|
}
|
|
5348
5356
|
}
|
|
5357
|
+
function checkProvidesAreAddressable(lx, Comp) {
|
|
5358
|
+
for (const name in Comp._rawProvide) {
|
|
5359
|
+
if (Comp.provide[name] === undefined) {
|
|
5360
|
+
lx.error(PROVIDE_NOT_ADDRESSABLE, { name, value: Comp._rawProvide[name] });
|
|
5361
|
+
}
|
|
5362
|
+
}
|
|
5363
|
+
}
|
|
5364
|
+
var KNOWN_LOOKUP_KEYS = new Set(["for", "default"]);
|
|
5365
|
+
function checkLookupShapes(lx, Comp) {
|
|
5366
|
+
for (const name in Comp._rawLookup) {
|
|
5367
|
+
const raw = Comp._rawLookup[name];
|
|
5368
|
+
let target;
|
|
5369
|
+
if (typeof raw === "string") {
|
|
5370
|
+
target = raw;
|
|
5371
|
+
} else if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
|
|
5372
|
+
lx.error(LOOKUP_BAD_SHAPE, {
|
|
5373
|
+
name,
|
|
5374
|
+
problem: 'must be a "Producer.provideName" string or a { for, default } object'
|
|
5375
|
+
});
|
|
5376
|
+
continue;
|
|
5377
|
+
} else {
|
|
5378
|
+
const extra = Object.keys(raw).filter((k) => !KNOWN_LOOKUP_KEYS.has(k));
|
|
5379
|
+
if (extra.length > 0) {
|
|
5380
|
+
lx.error(LOOKUP_BAD_SHAPE, { name, problem: `unknown key(s): ${extra.join(", ")}` });
|
|
5381
|
+
continue;
|
|
5382
|
+
}
|
|
5383
|
+
if (typeof raw.for !== "string") {
|
|
5384
|
+
lx.error(LOOKUP_BAD_SHAPE, { name, problem: "'for' is required and must be a string" });
|
|
5385
|
+
continue;
|
|
5386
|
+
}
|
|
5387
|
+
if (raw.default !== undefined && typeof raw.default !== "string") {
|
|
5388
|
+
lx.error(LOOKUP_BAD_SHAPE, { name, problem: "'default' must be a string" });
|
|
5389
|
+
continue;
|
|
5390
|
+
}
|
|
5391
|
+
target = raw.for;
|
|
5392
|
+
}
|
|
5393
|
+
const parts = target.split(".");
|
|
5394
|
+
if (parts.length !== 2 || !parts[0] || !parts[1]) {
|
|
5395
|
+
lx.error(LOOKUP_TARGET_MALFORMED, { name, target });
|
|
5396
|
+
}
|
|
5397
|
+
}
|
|
5398
|
+
}
|
|
5349
5399
|
function checkUnreferencedDynamics(lx, Comp, referencedDynamics) {
|
|
5350
|
-
for (const name in Comp.
|
|
5351
|
-
|
|
5352
|
-
if (dyn.constructor.name === "DynamicAlias" && !referencedDynamics.has(name)) {
|
|
5400
|
+
for (const name in Comp.lookup) {
|
|
5401
|
+
if (!referencedDynamics.has(name)) {
|
|
5353
5402
|
lx.hint(DYN_ALIAS_NOT_REFERENCED, { name });
|
|
5354
5403
|
}
|
|
5355
5404
|
}
|
|
@@ -5831,7 +5880,6 @@ function reportTestReportToConsole(report) {
|
|
|
5831
5880
|
|
|
5832
5881
|
// tools/format/lint.js
|
|
5833
5882
|
var UNSUPPORTED_EXPR_LABEL = {
|
|
5834
|
-
"legacy-template": "string template",
|
|
5835
5883
|
ternary: "ternary expression",
|
|
5836
5884
|
comparison: "comparison",
|
|
5837
5885
|
logical: "logical expression",
|
|
@@ -5951,7 +5999,13 @@ function lintIdToMessage(id, info) {
|
|
|
5951
5999
|
case "DYN_VAL_NOT_DEFINED":
|
|
5952
6000
|
return `Dynamic variable '*${info.name}' is not defined${fmtOriginSuffix(info)}`;
|
|
5953
6001
|
case "DYN_ALIAS_NOT_REFERENCED":
|
|
5954
|
-
return `
|
|
6002
|
+
return `Lookup '${info.name}' is defined but never used — remove it or reference it as '*${info.name}' in a view`;
|
|
6003
|
+
case "PROVIDE_NOT_ADDRESSABLE":
|
|
6004
|
+
return `Provide '${info.name}' value '${info.value}' must be a field ('.f') or seq-access ('.s[.k]') — a method/constant can't be a render target`;
|
|
6005
|
+
case "LOOKUP_BAD_SHAPE":
|
|
6006
|
+
return `Lookup '${info.name}' has an invalid shape: ${info.problem}`;
|
|
6007
|
+
case "LOOKUP_TARGET_MALFORMED":
|
|
6008
|
+
return `Lookup '${info.name}' target '${info.target}' must be 'Producer.provideName' (a string, or the 'for' of { for, default })`;
|
|
5955
6009
|
case "UNKNOWN_MACRO_ARG":
|
|
5956
6010
|
return `Argument '${info.name}' is not declared in macro '${info.macroName}'`;
|
|
5957
6011
|
case "UNKNOWN_DIRECTIVE":
|
|
@@ -6081,9 +6135,6 @@ class Components {
|
|
|
6081
6135
|
getCompFor(v) {
|
|
6082
6136
|
return v?.[this.getComponentSymbol]?.() ?? null;
|
|
6083
6137
|
}
|
|
6084
|
-
getOnEnterFor(v) {
|
|
6085
|
-
return this.getCompFor(v)?.on.stackEnter ?? defaultOnStackEnter;
|
|
6086
|
-
}
|
|
6087
6138
|
getHandlerFor(v, name, key) {
|
|
6088
6139
|
return this.getCompFor(v)?.[key][name] ?? null;
|
|
6089
6140
|
}
|
|
@@ -6153,36 +6204,30 @@ class ComponentStack {
|
|
|
6153
6204
|
}
|
|
6154
6205
|
}
|
|
6155
6206
|
|
|
6156
|
-
class
|
|
6207
|
+
class ProvideInfo {
|
|
6157
6208
|
constructor(name, val, symbol) {
|
|
6158
6209
|
this.name = name;
|
|
6159
6210
|
this.val = val;
|
|
6160
6211
|
this.symbol = symbol;
|
|
6161
6212
|
}
|
|
6162
|
-
getSymbol(_stack) {
|
|
6163
|
-
return this.symbol;
|
|
6164
|
-
}
|
|
6165
|
-
evalAndBind(stack, binds) {
|
|
6166
|
-
binds[this.getSymbol(stack)] = this.val.eval(stack);
|
|
6167
|
-
}
|
|
6168
6213
|
}
|
|
6169
6214
|
|
|
6170
|
-
class
|
|
6171
|
-
constructor(name,
|
|
6172
|
-
|
|
6215
|
+
class LookupInfo {
|
|
6216
|
+
constructor(name, compName, provideName, val) {
|
|
6217
|
+
this.name = name;
|
|
6173
6218
|
this.compName = compName;
|
|
6174
|
-
this.
|
|
6175
|
-
|
|
6176
|
-
|
|
6177
|
-
return stack.lookupType(this.compName)?.dynamic[this.dynName]?.symbol ?? null;
|
|
6219
|
+
this.provideName = provideName;
|
|
6220
|
+
this.val = val;
|
|
6221
|
+
this._sym = undefined;
|
|
6178
6222
|
}
|
|
6179
|
-
|
|
6180
|
-
this.
|
|
6181
|
-
|
|
6223
|
+
getProducerSymbol(stack) {
|
|
6224
|
+
if (this._sym === undefined)
|
|
6225
|
+
this._sym = stack.lookupType(this.compName)?.provide?.[this.provideName]?.symbol ?? null;
|
|
6226
|
+
return this._sym;
|
|
6182
6227
|
}
|
|
6183
6228
|
}
|
|
6184
6229
|
var isString = (v) => typeof v === "string";
|
|
6185
|
-
var _rawSpecKeys = "name view style commonStyle globalStyle input receive bubble response alter
|
|
6230
|
+
var _rawSpecKeys = "name view style commonStyle globalStyle input receive bubble response alter views provide lookup fields methods statics";
|
|
6186
6231
|
var KNOWN_SPEC_KEYS = new Set(_rawSpecKeys.split(" "));
|
|
6187
6232
|
var _compId = 0;
|
|
6188
6233
|
|
|
@@ -6199,35 +6244,47 @@ class Component {
|
|
|
6199
6244
|
this.bubble = o.bubble ?? {};
|
|
6200
6245
|
this.response = o.response ?? {};
|
|
6201
6246
|
this.alter = o.alter ?? {};
|
|
6202
|
-
this.on = { stackEnter: o.on?.stackEnter ?? defaultOnStackEnter };
|
|
6203
6247
|
for (const name in o.views ?? {}) {
|
|
6204
6248
|
const v = o.views[name];
|
|
6205
6249
|
const { view, style } = isString(v) ? { view: v } : v;
|
|
6206
6250
|
this.views[name] = new View(name, view, style);
|
|
6207
6251
|
}
|
|
6208
|
-
this.
|
|
6209
|
-
this.
|
|
6252
|
+
this._rawProvide = o.provide ?? {};
|
|
6253
|
+
this._rawLookup = o.lookup ?? {};
|
|
6254
|
+
this.provide = {};
|
|
6255
|
+
this.lookup = {};
|
|
6210
6256
|
this.scope = null;
|
|
6257
|
+
this.spec = o;
|
|
6211
6258
|
this.extra = {};
|
|
6212
6259
|
for (const key of Object.keys(o))
|
|
6213
6260
|
if (!KNOWN_SPEC_KEYS.has(key))
|
|
6214
6261
|
this.extra[key] = o[key];
|
|
6215
6262
|
}
|
|
6263
|
+
clone() {
|
|
6264
|
+
return Component.fromSpec(this.spec);
|
|
6265
|
+
}
|
|
6216
6266
|
compile(ParseContext2) {
|
|
6217
6267
|
for (const name in this.views)
|
|
6218
6268
|
this.views[name].compile(new ParseContext2, this.scope, this.id);
|
|
6219
|
-
|
|
6220
|
-
|
|
6221
|
-
|
|
6222
|
-
|
|
6223
|
-
this.
|
|
6224
|
-
|
|
6225
|
-
|
|
6226
|
-
|
|
6227
|
-
|
|
6228
|
-
|
|
6229
|
-
|
|
6269
|
+
const ctx = this.views.main.ctx;
|
|
6270
|
+
for (const key in this._rawProvide) {
|
|
6271
|
+
const val = vp.parseProvide(this._rawProvide[key], ctx);
|
|
6272
|
+
if (val)
|
|
6273
|
+
this.provide[key] = new ProvideInfo(key, val, Symbol(key));
|
|
6274
|
+
}
|
|
6275
|
+
for (const key in this._rawLookup) {
|
|
6276
|
+
const linfo = this._rawLookup[key];
|
|
6277
|
+
const forStr = isString(linfo) ? linfo : isString(linfo?.for) ? linfo.for : null;
|
|
6278
|
+
const [compName, provideName] = forStr === null ? [] : forStr.split(".");
|
|
6279
|
+
if (!isString(compName) || !isString(provideName))
|
|
6280
|
+
continue;
|
|
6281
|
+
const defStr = isString(linfo?.default) ? linfo.default : null;
|
|
6282
|
+
const val = defStr === null ? null : vp.parseField(defStr, ctx);
|
|
6283
|
+
this.lookup[key] = new LookupInfo(key, compName, provideName, val);
|
|
6230
6284
|
}
|
|
6285
|
+
for (const key in this.lookup)
|
|
6286
|
+
if (this.provide[key] !== undefined)
|
|
6287
|
+
console.warn("name declared in both provide and lookup", this.name, key);
|
|
6231
6288
|
}
|
|
6232
6289
|
make(args, opts) {
|
|
6233
6290
|
return this.Class.make(args, opts ?? { scope: this.scope });
|
|
@@ -6255,9 +6312,6 @@ class Component {
|
|
|
6255
6312
|
`);
|
|
6256
6313
|
}
|
|
6257
6314
|
}
|
|
6258
|
-
function defaultOnStackEnter() {
|
|
6259
|
-
return null;
|
|
6260
|
-
}
|
|
6261
6315
|
|
|
6262
6316
|
// src/stack.js
|
|
6263
6317
|
var STOP = Symbol("STOP");
|
|
@@ -6316,47 +6370,61 @@ class Stack {
|
|
|
6316
6370
|
this.viewsId = viewsId;
|
|
6317
6371
|
this.ctx = ctx;
|
|
6318
6372
|
}
|
|
6319
|
-
|
|
6320
|
-
|
|
6373
|
+
_pushProvides() {
|
|
6374
|
+
const provide = this.comps.getCompFor(this.it)?.provide;
|
|
6375
|
+
if (provide == null)
|
|
6376
|
+
return this;
|
|
6377
|
+
const dynObj = {};
|
|
6378
|
+
let has = false;
|
|
6379
|
+
for (const k in provide) {
|
|
6380
|
+
dynObj[provide[k].symbol] = provide[k].val.eval(this);
|
|
6381
|
+
has = true;
|
|
6382
|
+
}
|
|
6383
|
+
if (!has)
|
|
6384
|
+
return this;
|
|
6385
|
+
const newDynBinds = [new ObjectFrame(dynObj), this.dynBinds];
|
|
6386
|
+
const { comps, it, binds, views, viewsId, ctx } = this;
|
|
6387
|
+
return new Stack(comps, it, binds, newDynBinds, views, viewsId, ctx);
|
|
6321
6388
|
}
|
|
6322
6389
|
static root(comps, it, ctx) {
|
|
6323
6390
|
const binds = [new BindFrame(it, { it }, true), null];
|
|
6324
6391
|
const dynBinds = [new ObjectFrame({}), null];
|
|
6325
6392
|
const views = ["main", null];
|
|
6326
|
-
return new Stack(comps, it, binds, dynBinds, views, "", ctx).
|
|
6393
|
+
return new Stack(comps, it, binds, dynBinds, views, "", ctx)._pushProvides();
|
|
6327
6394
|
}
|
|
6328
6395
|
enter(it, bindings = {}, isFrame = true) {
|
|
6329
6396
|
const { comps, binds, dynBinds, views, viewsId, ctx } = this;
|
|
6330
6397
|
const newBinds = [new BindFrame(it, bindings, isFrame), binds];
|
|
6331
6398
|
const stack = new Stack(comps, it, newBinds, dynBinds, views, viewsId, ctx);
|
|
6332
|
-
return isFrame ? stack.
|
|
6399
|
+
return isFrame ? stack._pushProvides() : stack;
|
|
6333
6400
|
}
|
|
6334
6401
|
pushViewName(name) {
|
|
6335
6402
|
const { comps, it, binds, dynBinds, views, ctx } = this;
|
|
6336
6403
|
const newViews = [name, views];
|
|
6337
6404
|
return new Stack(comps, it, binds, dynBinds, newViews, computeViewsId(newViews), ctx);
|
|
6338
6405
|
}
|
|
6339
|
-
|
|
6340
|
-
|
|
6341
|
-
|
|
6342
|
-
const
|
|
6343
|
-
|
|
6344
|
-
for (const dynName of dynamics)
|
|
6345
|
-
comp.dynamic[dynName].evalAndBind(this, dynObj);
|
|
6346
|
-
const newDynBinds = [new ObjectFrame(dynObj), this.dynBinds];
|
|
6347
|
-
const { comps, it, binds, views, viewsId, ctx } = this;
|
|
6348
|
-
return new Stack(comps, it, binds, newDynBinds, views, viewsId, ctx);
|
|
6406
|
+
_pushDynBindValuesToArray(arr, comp) {
|
|
6407
|
+
for (const k in comp.provide)
|
|
6408
|
+
arr.push(this._lookupProvide(comp.provide[k]));
|
|
6409
|
+
for (const k in comp.lookup)
|
|
6410
|
+
arr.push(this._lookupAlias(comp.lookup[k]));
|
|
6349
6411
|
}
|
|
6350
|
-
|
|
6351
|
-
|
|
6352
|
-
arr.push(this._lookupDynamicWithDynVal(dyns[k]));
|
|
6412
|
+
_lookupProvide(p) {
|
|
6413
|
+
return lookup(this.dynBinds, p.symbol) ?? p.val.eval(this) ?? null;
|
|
6353
6414
|
}
|
|
6354
|
-
|
|
6355
|
-
|
|
6415
|
+
_lookupAlias(lk) {
|
|
6416
|
+
const sym = lk.getProducerSymbol(this);
|
|
6417
|
+
return (sym != null ? lookup(this.dynBinds, sym) : null) ?? lk.val?.eval(this) ?? null;
|
|
6356
6418
|
}
|
|
6357
6419
|
lookupDynamic(name) {
|
|
6358
|
-
const
|
|
6359
|
-
|
|
6420
|
+
const comp = this.comps.getCompFor(this.it);
|
|
6421
|
+
if (comp == null)
|
|
6422
|
+
return null;
|
|
6423
|
+
const lk = comp.lookup[name];
|
|
6424
|
+
if (lk !== undefined)
|
|
6425
|
+
return this._lookupAlias(lk);
|
|
6426
|
+
const p = comp.provide[name];
|
|
6427
|
+
return p !== undefined ? this._lookupProvide(p) : null;
|
|
6360
6428
|
}
|
|
6361
6429
|
lookupBind(name) {
|
|
6362
6430
|
return lookup(this.binds, name);
|
|
@@ -7391,7 +7459,8 @@ function classFromData(name, { fields = {}, methods, statics }) {
|
|
|
7391
7459
|
b.statics(statics);
|
|
7392
7460
|
return b.build();
|
|
7393
7461
|
}
|
|
7394
|
-
|
|
7462
|
+
Component.fromSpec = (opts) => new Component(classFromData(opts.name, opts), opts);
|
|
7463
|
+
var component = (opts) => Component.fromSpec(opts);
|
|
7395
7464
|
|
|
7396
7465
|
// src/renderer.js
|
|
7397
7466
|
import { isIndexed, isKeyed } from "immutable";
|
|
@@ -7513,7 +7582,7 @@ class Renderer {
|
|
|
7513
7582
|
_rValComp(stack, val, comp, node, key, viewName) {
|
|
7514
7583
|
const cacheKey = `${viewName ?? stack.viewsId ?? ""}-${key}`;
|
|
7515
7584
|
const cachePath = [node, val];
|
|
7516
|
-
stack._pushDynBindValuesToArray(cachePath, comp
|
|
7585
|
+
stack._pushDynBindValuesToArray(cachePath, comp);
|
|
7517
7586
|
const cachedNode = this.cache.get(cachePath, cacheKey);
|
|
7518
7587
|
if (cachedNode)
|
|
7519
7588
|
return cachedNode;
|
|
@@ -8171,6 +8240,7 @@ export {
|
|
|
8171
8240
|
REDUNDANT_TEMPLATE_STRING,
|
|
8172
8241
|
ParseContext,
|
|
8173
8242
|
PairSorting,
|
|
8243
|
+
PROVIDE_NOT_ADDRESSABLE,
|
|
8174
8244
|
PLACEHOLDERLESS_TEMPLATE_STRING,
|
|
8175
8245
|
OrderedSet,
|
|
8176
8246
|
OrderedMap2 as OrderedMap,
|
|
@@ -8190,6 +8260,8 @@ export {
|
|
|
8190
8260
|
LintContext,
|
|
8191
8261
|
LintComponentResult,
|
|
8192
8262
|
LintClassCollectorCtx,
|
|
8263
|
+
LOOKUP_TARGET_MALFORMED,
|
|
8264
|
+
LOOKUP_BAD_SHAPE,
|
|
8193
8265
|
KList,
|
|
8194
8266
|
Set3 as ISet,
|
|
8195
8267
|
INPUT_HANDLER_NOT_REFERENCED,
|