tutuca 0.9.77 → 0.9.79
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 +133 -58
- package/dist/tutuca-dev.ext.js +159 -85
- package/dist/tutuca-dev.js +159 -85
- package/dist/tutuca-dev.min.js +3 -3
- package/dist/tutuca-extra.ext.js +96 -74
- package/dist/tutuca-extra.js +96 -74
- package/dist/tutuca-extra.min.js +3 -3
- package/dist/tutuca.ext.js +97 -75
- package/dist/tutuca.js +96 -74
- package/dist/tutuca.min.js +3 -3
- package/package.json +1 -1
- package/skill/tutuca/advanced.md +22 -18
- package/skill/tutuca/core.md +51 -1
- package/skill/tutuca/semantics.md +2 -2
- package/skill/tutuca-source/tutuca.ext.js +97 -75
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
|
}
|
|
@@ -6115,6 +6166,7 @@ class ComponentStack {
|
|
|
6115
6166
|
for (let i = 0;i < comps.length; i++) {
|
|
6116
6167
|
const comp = comps[i];
|
|
6117
6168
|
comp.scope = this.enter();
|
|
6169
|
+
comp.Class.scope = comp.scope;
|
|
6118
6170
|
this.comps.registerComponent(comp);
|
|
6119
6171
|
this.byName[comp.name] = comp;
|
|
6120
6172
|
}
|
|
@@ -6152,36 +6204,30 @@ class ComponentStack {
|
|
|
6152
6204
|
}
|
|
6153
6205
|
}
|
|
6154
6206
|
|
|
6155
|
-
class
|
|
6207
|
+
class ProvideInfo {
|
|
6156
6208
|
constructor(name, val, symbol) {
|
|
6157
6209
|
this.name = name;
|
|
6158
6210
|
this.val = val;
|
|
6159
6211
|
this.symbol = symbol;
|
|
6160
6212
|
}
|
|
6161
|
-
getSymbol(_stack) {
|
|
6162
|
-
return this.symbol;
|
|
6163
|
-
}
|
|
6164
|
-
evalAndBind(stack, binds) {
|
|
6165
|
-
binds[this.getSymbol(stack)] = this.val.eval(stack);
|
|
6166
|
-
}
|
|
6167
6213
|
}
|
|
6168
6214
|
|
|
6169
|
-
class
|
|
6170
|
-
constructor(name,
|
|
6171
|
-
|
|
6215
|
+
class LookupInfo {
|
|
6216
|
+
constructor(name, compName, provideName, val) {
|
|
6217
|
+
this.name = name;
|
|
6172
6218
|
this.compName = compName;
|
|
6173
|
-
this.
|
|
6174
|
-
|
|
6175
|
-
|
|
6176
|
-
return stack.lookupType(this.compName)?.dynamic[this.dynName]?.symbol ?? null;
|
|
6219
|
+
this.provideName = provideName;
|
|
6220
|
+
this.val = val;
|
|
6221
|
+
this._sym = undefined;
|
|
6177
6222
|
}
|
|
6178
|
-
|
|
6179
|
-
this.
|
|
6180
|
-
|
|
6223
|
+
getProducerSymbol(stack) {
|
|
6224
|
+
if (this._sym === undefined)
|
|
6225
|
+
this._sym = stack.lookupType(this.compName)?.provide?.[this.provideName]?.symbol ?? null;
|
|
6226
|
+
return this._sym;
|
|
6181
6227
|
}
|
|
6182
6228
|
}
|
|
6183
6229
|
var isString = (v) => typeof v === "string";
|
|
6184
|
-
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";
|
|
6185
6231
|
var KNOWN_SPEC_KEYS = new Set(_rawSpecKeys.split(" "));
|
|
6186
6232
|
var _compId = 0;
|
|
6187
6233
|
|
|
@@ -6198,35 +6244,47 @@ class Component {
|
|
|
6198
6244
|
this.bubble = o.bubble ?? {};
|
|
6199
6245
|
this.response = o.response ?? {};
|
|
6200
6246
|
this.alter = o.alter ?? {};
|
|
6201
|
-
this.on = { stackEnter: o.on?.stackEnter ?? defaultOnStackEnter };
|
|
6202
6247
|
for (const name in o.views ?? {}) {
|
|
6203
6248
|
const v = o.views[name];
|
|
6204
6249
|
const { view, style } = isString(v) ? { view: v } : v;
|
|
6205
6250
|
this.views[name] = new View(name, view, style);
|
|
6206
6251
|
}
|
|
6207
|
-
this.
|
|
6208
|
-
this.
|
|
6252
|
+
this._rawProvide = o.provide ?? {};
|
|
6253
|
+
this._rawLookup = o.lookup ?? {};
|
|
6254
|
+
this.provide = {};
|
|
6255
|
+
this.lookup = {};
|
|
6209
6256
|
this.scope = null;
|
|
6257
|
+
this.spec = o;
|
|
6210
6258
|
this.extra = {};
|
|
6211
6259
|
for (const key of Object.keys(o))
|
|
6212
6260
|
if (!KNOWN_SPEC_KEYS.has(key))
|
|
6213
6261
|
this.extra[key] = o[key];
|
|
6214
6262
|
}
|
|
6263
|
+
clone() {
|
|
6264
|
+
return Component.fromSpec(this.spec);
|
|
6265
|
+
}
|
|
6215
6266
|
compile(ParseContext2) {
|
|
6216
6267
|
for (const name in this.views)
|
|
6217
6268
|
this.views[name].compile(new ParseContext2, this.scope, this.id);
|
|
6218
|
-
|
|
6219
|
-
|
|
6220
|
-
|
|
6221
|
-
|
|
6222
|
-
this.
|
|
6223
|
-
|
|
6224
|
-
|
|
6225
|
-
|
|
6226
|
-
|
|
6227
|
-
|
|
6228
|
-
|
|
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);
|
|
6229
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);
|
|
6230
6288
|
}
|
|
6231
6289
|
make(args, opts) {
|
|
6232
6290
|
return this.Class.make(args, opts ?? { scope: this.scope });
|
|
@@ -6254,9 +6312,6 @@ class Component {
|
|
|
6254
6312
|
`);
|
|
6255
6313
|
}
|
|
6256
6314
|
}
|
|
6257
|
-
function defaultOnStackEnter() {
|
|
6258
|
-
return null;
|
|
6259
|
-
}
|
|
6260
6315
|
|
|
6261
6316
|
// src/stack.js
|
|
6262
6317
|
var STOP = Symbol("STOP");
|
|
@@ -6315,47 +6370,61 @@ class Stack {
|
|
|
6315
6370
|
this.viewsId = viewsId;
|
|
6316
6371
|
this.ctx = ctx;
|
|
6317
6372
|
}
|
|
6318
|
-
|
|
6319
|
-
|
|
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);
|
|
6320
6388
|
}
|
|
6321
6389
|
static root(comps, it, ctx) {
|
|
6322
6390
|
const binds = [new BindFrame(it, { it }, true), null];
|
|
6323
6391
|
const dynBinds = [new ObjectFrame({}), null];
|
|
6324
6392
|
const views = ["main", null];
|
|
6325
|
-
return new Stack(comps, it, binds, dynBinds, views, "", ctx).
|
|
6393
|
+
return new Stack(comps, it, binds, dynBinds, views, "", ctx)._pushProvides();
|
|
6326
6394
|
}
|
|
6327
6395
|
enter(it, bindings = {}, isFrame = true) {
|
|
6328
6396
|
const { comps, binds, dynBinds, views, viewsId, ctx } = this;
|
|
6329
6397
|
const newBinds = [new BindFrame(it, bindings, isFrame), binds];
|
|
6330
6398
|
const stack = new Stack(comps, it, newBinds, dynBinds, views, viewsId, ctx);
|
|
6331
|
-
return isFrame ? stack.
|
|
6399
|
+
return isFrame ? stack._pushProvides() : stack;
|
|
6332
6400
|
}
|
|
6333
6401
|
pushViewName(name) {
|
|
6334
6402
|
const { comps, it, binds, dynBinds, views, ctx } = this;
|
|
6335
6403
|
const newViews = [name, views];
|
|
6336
6404
|
return new Stack(comps, it, binds, dynBinds, newViews, computeViewsId(newViews), ctx);
|
|
6337
6405
|
}
|
|
6338
|
-
|
|
6339
|
-
|
|
6340
|
-
|
|
6341
|
-
const
|
|
6342
|
-
|
|
6343
|
-
for (const dynName of dynamics)
|
|
6344
|
-
comp.dynamic[dynName].evalAndBind(this, dynObj);
|
|
6345
|
-
const newDynBinds = [new ObjectFrame(dynObj), this.dynBinds];
|
|
6346
|
-
const { comps, it, binds, views, viewsId, ctx } = this;
|
|
6347
|
-
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]));
|
|
6348
6411
|
}
|
|
6349
|
-
|
|
6350
|
-
|
|
6351
|
-
arr.push(this._lookupDynamicWithDynVal(dyns[k]));
|
|
6412
|
+
_lookupProvide(p) {
|
|
6413
|
+
return lookup(this.dynBinds, p.symbol) ?? p.val.eval(this) ?? null;
|
|
6352
6414
|
}
|
|
6353
|
-
|
|
6354
|
-
|
|
6415
|
+
_lookupAlias(lk) {
|
|
6416
|
+
const sym = lk.getProducerSymbol(this);
|
|
6417
|
+
return (sym != null ? lookup(this.dynBinds, sym) : null) ?? lk.val?.eval(this) ?? null;
|
|
6355
6418
|
}
|
|
6356
6419
|
lookupDynamic(name) {
|
|
6357
|
-
const
|
|
6358
|
-
|
|
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;
|
|
6359
6428
|
}
|
|
6360
6429
|
lookupBind(name) {
|
|
6361
6430
|
return lookup(this.binds, name);
|
|
@@ -7291,10 +7360,11 @@ class ClassBuilder {
|
|
|
7291
7360
|
this._statics = {
|
|
7292
7361
|
make: function(inArgs = {}, opts = {}) {
|
|
7293
7362
|
const args = {};
|
|
7363
|
+
const scope = opts.scope ?? this.scope;
|
|
7294
7364
|
for (const key in inArgs) {
|
|
7295
7365
|
const field = fields[key];
|
|
7296
7366
|
if (compFields.has(key))
|
|
7297
|
-
args[key] = mkCompField(field,
|
|
7367
|
+
args[key] = mkCompField(field, scope, inArgs[key]);
|
|
7298
7368
|
else if (field === undefined)
|
|
7299
7369
|
console.warn("extra argument to constructor:", name, key, inArgs);
|
|
7300
7370
|
else
|
|
@@ -7302,7 +7372,7 @@ class ClassBuilder {
|
|
|
7302
7372
|
}
|
|
7303
7373
|
for (const key of compFields)
|
|
7304
7374
|
if (args[key] === undefined)
|
|
7305
|
-
args[key] = mkCompField(fields[key],
|
|
7375
|
+
args[key] = mkCompField(fields[key], scope, inArgs[key]);
|
|
7306
7376
|
return this(args);
|
|
7307
7377
|
}
|
|
7308
7378
|
};
|
|
@@ -7389,7 +7459,8 @@ function classFromData(name, { fields = {}, methods, statics }) {
|
|
|
7389
7459
|
b.statics(statics);
|
|
7390
7460
|
return b.build();
|
|
7391
7461
|
}
|
|
7392
|
-
|
|
7462
|
+
Component.fromSpec = (opts) => new Component(classFromData(opts.name, opts), opts);
|
|
7463
|
+
var component = (opts) => Component.fromSpec(opts);
|
|
7393
7464
|
|
|
7394
7465
|
// src/renderer.js
|
|
7395
7466
|
import { isIndexed, isKeyed } from "immutable";
|
|
@@ -7511,7 +7582,7 @@ class Renderer {
|
|
|
7511
7582
|
_rValComp(stack, val, comp, node, key, viewName) {
|
|
7512
7583
|
const cacheKey = `${viewName ?? stack.viewsId ?? ""}-${key}`;
|
|
7513
7584
|
const cachePath = [node, val];
|
|
7514
|
-
stack._pushDynBindValuesToArray(cachePath, comp
|
|
7585
|
+
stack._pushDynBindValuesToArray(cachePath, comp);
|
|
7515
7586
|
const cachedNode = this.cache.get(cachePath, cacheKey);
|
|
7516
7587
|
if (cachedNode)
|
|
7517
7588
|
return cachedNode;
|
|
@@ -8169,6 +8240,7 @@ export {
|
|
|
8169
8240
|
REDUNDANT_TEMPLATE_STRING,
|
|
8170
8241
|
ParseContext,
|
|
8171
8242
|
PairSorting,
|
|
8243
|
+
PROVIDE_NOT_ADDRESSABLE,
|
|
8172
8244
|
PLACEHOLDERLESS_TEMPLATE_STRING,
|
|
8173
8245
|
OrderedSet,
|
|
8174
8246
|
OrderedMap2 as OrderedMap,
|
|
@@ -8188,6 +8260,8 @@ export {
|
|
|
8188
8260
|
LintContext,
|
|
8189
8261
|
LintComponentResult,
|
|
8190
8262
|
LintClassCollectorCtx,
|
|
8263
|
+
LOOKUP_TARGET_MALFORMED,
|
|
8264
|
+
LOOKUP_BAD_SHAPE,
|
|
8191
8265
|
KList,
|
|
8192
8266
|
Set3 as ISet,
|
|
8193
8267
|
INPUT_HANDLER_NOT_REFERENCED,
|