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.js
CHANGED
|
@@ -8142,6 +8142,7 @@ var G_BOOL = K_FIELD | K_METHOD | K_BIND | K_DYN | K_CONST;
|
|
|
8142
8142
|
var G_TEXT = G_BOOL | K_STRTPL;
|
|
8143
8143
|
var G_COMPONENT = K_FIELD | K_SEQ | K_DYN;
|
|
8144
8144
|
var G_SEQUENCE = K_FIELD | K_DYN;
|
|
8145
|
+
var G_PROVIDE = K_FIELD | K_SEQ;
|
|
8145
8146
|
var G_FIELD = K_FIELD | K_METHOD | K_CONST | K_STR | K_SEQ;
|
|
8146
8147
|
var G_VALUE = K_FIELD | K_METHOD | K_BIND | K_DYN | K_NAME | K_TYPE | K_REQUEST | K_CONST;
|
|
8147
8148
|
var G_PRED_ARG = G_BOOL | K_STR;
|
|
@@ -8260,6 +8261,9 @@ class ValParser {
|
|
|
8260
8261
|
parseField(s, px) {
|
|
8261
8262
|
return this._parseSingle(s, px, G_FIELD);
|
|
8262
8263
|
}
|
|
8264
|
+
parseProvide(s, px) {
|
|
8265
|
+
return this._parseSingle(s, px, G_PROVIDE);
|
|
8266
|
+
}
|
|
8263
8267
|
parseHandlerArg(s, px) {
|
|
8264
8268
|
return this._parseSingle(s, px, G_HANDLER_ARG);
|
|
8265
8269
|
}
|
|
@@ -9246,21 +9250,22 @@ function h(tagName, properties, children, namespace) {
|
|
|
9246
9250
|
}
|
|
9247
9251
|
|
|
9248
9252
|
// src/anode.js
|
|
9249
|
-
function resolveDynProducer(comp,
|
|
9250
|
-
|
|
9251
|
-
|
|
9252
|
-
|
|
9253
|
-
|
|
9254
|
-
|
|
9255
|
-
producerComp = comp.scope?.lookupComponent(dyn.compName);
|
|
9256
|
-
producerDyn = producerComp?.dynamic?.[dyn.dynName];
|
|
9253
|
+
function resolveDynProducer(comp, name) {
|
|
9254
|
+
let producerComp, producerProvide;
|
|
9255
|
+
const lk = comp?.lookup?.[name];
|
|
9256
|
+
if (lk != null) {
|
|
9257
|
+
producerComp = comp.scope?.lookupComponent(lk.compName);
|
|
9258
|
+
producerProvide = producerComp?.provide?.[lk.provideName];
|
|
9257
9259
|
} else {
|
|
9260
|
+
const p = comp?.provide?.[name];
|
|
9261
|
+
if (p == null)
|
|
9262
|
+
return null;
|
|
9258
9263
|
producerComp = comp;
|
|
9259
|
-
|
|
9264
|
+
producerProvide = p;
|
|
9260
9265
|
}
|
|
9261
|
-
if (producerComp == null ||
|
|
9266
|
+
if (producerComp == null || producerProvide == null)
|
|
9262
9267
|
return null;
|
|
9263
|
-
const pi =
|
|
9268
|
+
const pi = producerProvide.val?.toPathItem?.() ?? null;
|
|
9264
9269
|
return { producerCompId: producerComp.id, producerSteps: pi ? [pi] : [] };
|
|
9265
9270
|
}
|
|
9266
9271
|
|
|
@@ -12385,7 +12390,7 @@ function closestName(name, candidates, maxDistance = 2) {
|
|
|
12385
12390
|
}
|
|
12386
12391
|
|
|
12387
12392
|
// tools/core/lint-check.js
|
|
12388
|
-
var KNOWN_COMPONENT_SPEC_KEYS = new Set("name view style commonStyle globalStyle input receive bubble response alter
|
|
12393
|
+
var KNOWN_COMPONENT_SPEC_KEYS = new Set("name view style commonStyle globalStyle input receive bubble response alter views provide lookup fields methods statics".split(" "));
|
|
12389
12394
|
var EMPTY_SET2 = new Set;
|
|
12390
12395
|
var KNOWN_DIRECTIVE_NAMES = new Set([
|
|
12391
12396
|
"dangerouslysetinnerhtml",
|
|
@@ -12405,6 +12410,9 @@ var ALT_HANDLER_NOT_DEFINED = "ALT_HANDLER_NOT_DEFINED";
|
|
|
12405
12410
|
var ALT_HANDLER_NOT_REFERENCED = "ALT_HANDLER_NOT_REFERENCED";
|
|
12406
12411
|
var DYN_VAL_NOT_DEFINED = "DYN_VAL_NOT_DEFINED";
|
|
12407
12412
|
var DYN_ALIAS_NOT_REFERENCED = "DYN_ALIAS_NOT_REFERENCED";
|
|
12413
|
+
var PROVIDE_NOT_ADDRESSABLE = "PROVIDE_NOT_ADDRESSABLE";
|
|
12414
|
+
var LOOKUP_BAD_SHAPE = "LOOKUP_BAD_SHAPE";
|
|
12415
|
+
var LOOKUP_TARGET_MALFORMED = "LOOKUP_TARGET_MALFORMED";
|
|
12408
12416
|
var RENDER_IT_OUTSIDE_OF_LOOP = "RENDER_IT_OUTSIDE_OF_LOOP";
|
|
12409
12417
|
var UNKNOWN_EVENT_MODIFIER = "UNKNOWN_EVENT_MODIFIER";
|
|
12410
12418
|
var UNKNOWN_HANDLER_ARG_NAME = "UNKNOWN_HANDLER_ARG_NAME";
|
|
@@ -12491,8 +12499,6 @@ function classifyBadValue(value) {
|
|
|
12491
12499
|
const s = value.trim();
|
|
12492
12500
|
if (s === "")
|
|
12493
12501
|
return null;
|
|
12494
|
-
if (/\{[^}]*\}/.test(s) && !s.startsWith("$'"))
|
|
12495
|
-
return "legacy-template";
|
|
12496
12502
|
if (/\s\?\s.+\s:\s/.test(s))
|
|
12497
12503
|
return "ternary";
|
|
12498
12504
|
if (/===|!==|==|!=|<=|>=|\s<\s|\s>\s/.test(s))
|
|
@@ -12504,7 +12510,6 @@ function classifyBadValue(value) {
|
|
|
12504
12510
|
return null;
|
|
12505
12511
|
}
|
|
12506
12512
|
var UNSUPPORTED_EXPR_GUIDANCE = {
|
|
12507
|
-
"legacy-template": "Unquoted {...} string templates are no longer supported. Wrap the value in $'...', e.g. $'flex {.color}'.",
|
|
12508
12513
|
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'.",
|
|
12509
12514
|
comparison: "Comparisons aren't supported in dynamic attributes. Define a method like 'isFooSelected' that returns the boolean, then reference it as '$isFooSelected'.",
|
|
12510
12515
|
logical: "Logical operators aren't supported in dynamic attributes. Combine the conditions in a method on the component and reference it as '$methodName'.",
|
|
@@ -12514,6 +12519,8 @@ function checkComponent(Comp, lx = new LintContext, { wellKnownExtras = EMPTY_SE
|
|
|
12514
12519
|
return lx.push({ componentName: Comp.name }, () => {
|
|
12515
12520
|
checkUnknownSpecKeys(lx, Comp, wellKnownExtras);
|
|
12516
12521
|
checkFieldDeclarations(lx, Comp);
|
|
12522
|
+
checkProvidesAreAddressable(lx, Comp);
|
|
12523
|
+
checkLookupShapes(lx, Comp);
|
|
12517
12524
|
const referencedAlters = new Set;
|
|
12518
12525
|
const referencedInputs = new Set;
|
|
12519
12526
|
const referencedDynamics = new Set;
|
|
@@ -12694,10 +12701,11 @@ function checkKnownHandlerNames(lx, view, Comp, referencedAlters, referencedDyna
|
|
|
12694
12701
|
}
|
|
12695
12702
|
}
|
|
12696
12703
|
function mkAttrValEnv(Comp, referencedAlters, referencedDynamics) {
|
|
12697
|
-
const { scope, alter,
|
|
12704
|
+
const { scope, alter, provide, lookup, Class } = Comp;
|
|
12698
12705
|
const { prototype: proto } = Class;
|
|
12699
12706
|
const { fields } = Class.getMetaClass();
|
|
12700
|
-
|
|
12707
|
+
const dynamicMap = { ...provide, ...lookup };
|
|
12708
|
+
return { fields, proto, scope, alter, referencedAlters, dynamicMap, referencedDynamics };
|
|
12701
12709
|
}
|
|
12702
12710
|
function checkEventHandlersHaveImpls(lx, Comp, referencedInputs) {
|
|
12703
12711
|
const { input, views, Class } = Comp;
|
|
@@ -13011,10 +13019,51 @@ function checkUnreferencedInputHandlers(lx, Comp, referencedInputs) {
|
|
|
13011
13019
|
}
|
|
13012
13020
|
}
|
|
13013
13021
|
}
|
|
13022
|
+
function checkProvidesAreAddressable(lx, Comp) {
|
|
13023
|
+
for (const name in Comp._rawProvide) {
|
|
13024
|
+
if (Comp.provide[name] === undefined) {
|
|
13025
|
+
lx.error(PROVIDE_NOT_ADDRESSABLE, { name, value: Comp._rawProvide[name] });
|
|
13026
|
+
}
|
|
13027
|
+
}
|
|
13028
|
+
}
|
|
13029
|
+
var KNOWN_LOOKUP_KEYS = new Set(["for", "default"]);
|
|
13030
|
+
function checkLookupShapes(lx, Comp) {
|
|
13031
|
+
for (const name in Comp._rawLookup) {
|
|
13032
|
+
const raw = Comp._rawLookup[name];
|
|
13033
|
+
let target;
|
|
13034
|
+
if (typeof raw === "string") {
|
|
13035
|
+
target = raw;
|
|
13036
|
+
} else if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
|
|
13037
|
+
lx.error(LOOKUP_BAD_SHAPE, {
|
|
13038
|
+
name,
|
|
13039
|
+
problem: 'must be a "Producer.provideName" string or a { for, default } object'
|
|
13040
|
+
});
|
|
13041
|
+
continue;
|
|
13042
|
+
} else {
|
|
13043
|
+
const extra = Object.keys(raw).filter((k) => !KNOWN_LOOKUP_KEYS.has(k));
|
|
13044
|
+
if (extra.length > 0) {
|
|
13045
|
+
lx.error(LOOKUP_BAD_SHAPE, { name, problem: `unknown key(s): ${extra.join(", ")}` });
|
|
13046
|
+
continue;
|
|
13047
|
+
}
|
|
13048
|
+
if (typeof raw.for !== "string") {
|
|
13049
|
+
lx.error(LOOKUP_BAD_SHAPE, { name, problem: "'for' is required and must be a string" });
|
|
13050
|
+
continue;
|
|
13051
|
+
}
|
|
13052
|
+
if (raw.default !== undefined && typeof raw.default !== "string") {
|
|
13053
|
+
lx.error(LOOKUP_BAD_SHAPE, { name, problem: "'default' must be a string" });
|
|
13054
|
+
continue;
|
|
13055
|
+
}
|
|
13056
|
+
target = raw.for;
|
|
13057
|
+
}
|
|
13058
|
+
const parts = target.split(".");
|
|
13059
|
+
if (parts.length !== 2 || !parts[0] || !parts[1]) {
|
|
13060
|
+
lx.error(LOOKUP_TARGET_MALFORMED, { name, target });
|
|
13061
|
+
}
|
|
13062
|
+
}
|
|
13063
|
+
}
|
|
13014
13064
|
function checkUnreferencedDynamics(lx, Comp, referencedDynamics) {
|
|
13015
|
-
for (const name in Comp.
|
|
13016
|
-
|
|
13017
|
-
if (dyn.constructor.name === "DynamicAlias" && !referencedDynamics.has(name)) {
|
|
13065
|
+
for (const name in Comp.lookup) {
|
|
13066
|
+
if (!referencedDynamics.has(name)) {
|
|
13018
13067
|
lx.hint(DYN_ALIAS_NOT_REFERENCED, { name });
|
|
13019
13068
|
}
|
|
13020
13069
|
}
|
|
@@ -13496,7 +13545,6 @@ function reportTestReportToConsole(report) {
|
|
|
13496
13545
|
|
|
13497
13546
|
// tools/format/lint.js
|
|
13498
13547
|
var UNSUPPORTED_EXPR_LABEL = {
|
|
13499
|
-
"legacy-template": "string template",
|
|
13500
13548
|
ternary: "ternary expression",
|
|
13501
13549
|
comparison: "comparison",
|
|
13502
13550
|
logical: "logical expression",
|
|
@@ -13616,7 +13664,13 @@ function lintIdToMessage(id, info) {
|
|
|
13616
13664
|
case "DYN_VAL_NOT_DEFINED":
|
|
13617
13665
|
return `Dynamic variable '*${info.name}' is not defined${fmtOriginSuffix(info)}`;
|
|
13618
13666
|
case "DYN_ALIAS_NOT_REFERENCED":
|
|
13619
|
-
return `
|
|
13667
|
+
return `Lookup '${info.name}' is defined but never used — remove it or reference it as '*${info.name}' in a view`;
|
|
13668
|
+
case "PROVIDE_NOT_ADDRESSABLE":
|
|
13669
|
+
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`;
|
|
13670
|
+
case "LOOKUP_BAD_SHAPE":
|
|
13671
|
+
return `Lookup '${info.name}' has an invalid shape: ${info.problem}`;
|
|
13672
|
+
case "LOOKUP_TARGET_MALFORMED":
|
|
13673
|
+
return `Lookup '${info.name}' target '${info.target}' must be 'Producer.provideName' (a string, or the 'for' of { for, default })`;
|
|
13620
13674
|
case "UNKNOWN_MACRO_ARG":
|
|
13621
13675
|
return `Argument '${info.name}' is not declared in macro '${info.macroName}'`;
|
|
13622
13676
|
case "UNKNOWN_DIRECTIVE":
|
|
@@ -13746,9 +13800,6 @@ class Components {
|
|
|
13746
13800
|
getCompFor(v) {
|
|
13747
13801
|
return v?.[this.getComponentSymbol]?.() ?? null;
|
|
13748
13802
|
}
|
|
13749
|
-
getOnEnterFor(v) {
|
|
13750
|
-
return this.getCompFor(v)?.on.stackEnter ?? defaultOnStackEnter;
|
|
13751
|
-
}
|
|
13752
13803
|
getHandlerFor(v, name, key) {
|
|
13753
13804
|
return this.getCompFor(v)?.[key][name] ?? null;
|
|
13754
13805
|
}
|
|
@@ -13780,6 +13831,7 @@ class ComponentStack {
|
|
|
13780
13831
|
for (let i = 0;i < comps.length; i++) {
|
|
13781
13832
|
const comp = comps[i];
|
|
13782
13833
|
comp.scope = this.enter();
|
|
13834
|
+
comp.Class.scope = comp.scope;
|
|
13783
13835
|
this.comps.registerComponent(comp);
|
|
13784
13836
|
this.byName[comp.name] = comp;
|
|
13785
13837
|
}
|
|
@@ -13817,36 +13869,30 @@ class ComponentStack {
|
|
|
13817
13869
|
}
|
|
13818
13870
|
}
|
|
13819
13871
|
|
|
13820
|
-
class
|
|
13872
|
+
class ProvideInfo {
|
|
13821
13873
|
constructor(name, val, symbol) {
|
|
13822
13874
|
this.name = name;
|
|
13823
13875
|
this.val = val;
|
|
13824
13876
|
this.symbol = symbol;
|
|
13825
13877
|
}
|
|
13826
|
-
getSymbol(_stack) {
|
|
13827
|
-
return this.symbol;
|
|
13828
|
-
}
|
|
13829
|
-
evalAndBind(stack, binds) {
|
|
13830
|
-
binds[this.getSymbol(stack)] = this.val.eval(stack);
|
|
13831
|
-
}
|
|
13832
13878
|
}
|
|
13833
13879
|
|
|
13834
|
-
class
|
|
13835
|
-
constructor(name,
|
|
13836
|
-
|
|
13880
|
+
class LookupInfo {
|
|
13881
|
+
constructor(name, compName, provideName, val) {
|
|
13882
|
+
this.name = name;
|
|
13837
13883
|
this.compName = compName;
|
|
13838
|
-
this.
|
|
13839
|
-
|
|
13840
|
-
|
|
13841
|
-
return stack.lookupType(this.compName)?.dynamic[this.dynName]?.symbol ?? null;
|
|
13884
|
+
this.provideName = provideName;
|
|
13885
|
+
this.val = val;
|
|
13886
|
+
this._sym = undefined;
|
|
13842
13887
|
}
|
|
13843
|
-
|
|
13844
|
-
this.
|
|
13845
|
-
|
|
13888
|
+
getProducerSymbol(stack) {
|
|
13889
|
+
if (this._sym === undefined)
|
|
13890
|
+
this._sym = stack.lookupType(this.compName)?.provide?.[this.provideName]?.symbol ?? null;
|
|
13891
|
+
return this._sym;
|
|
13846
13892
|
}
|
|
13847
13893
|
}
|
|
13848
13894
|
var isString = (v) => typeof v === "string";
|
|
13849
|
-
var _rawSpecKeys = "name view style commonStyle globalStyle input receive bubble response alter
|
|
13895
|
+
var _rawSpecKeys = "name view style commonStyle globalStyle input receive bubble response alter views provide lookup fields methods statics";
|
|
13850
13896
|
var KNOWN_SPEC_KEYS = new Set(_rawSpecKeys.split(" "));
|
|
13851
13897
|
var _compId = 0;
|
|
13852
13898
|
|
|
@@ -13863,35 +13909,47 @@ class Component {
|
|
|
13863
13909
|
this.bubble = o.bubble ?? {};
|
|
13864
13910
|
this.response = o.response ?? {};
|
|
13865
13911
|
this.alter = o.alter ?? {};
|
|
13866
|
-
this.on = { stackEnter: o.on?.stackEnter ?? defaultOnStackEnter };
|
|
13867
13912
|
for (const name in o.views ?? {}) {
|
|
13868
13913
|
const v = o.views[name];
|
|
13869
13914
|
const { view, style } = isString(v) ? { view: v } : v;
|
|
13870
13915
|
this.views[name] = new View(name, view, style);
|
|
13871
13916
|
}
|
|
13872
|
-
this.
|
|
13873
|
-
this.
|
|
13917
|
+
this._rawProvide = o.provide ?? {};
|
|
13918
|
+
this._rawLookup = o.lookup ?? {};
|
|
13919
|
+
this.provide = {};
|
|
13920
|
+
this.lookup = {};
|
|
13874
13921
|
this.scope = null;
|
|
13922
|
+
this.spec = o;
|
|
13875
13923
|
this.extra = {};
|
|
13876
13924
|
for (const key of Object.keys(o))
|
|
13877
13925
|
if (!KNOWN_SPEC_KEYS.has(key))
|
|
13878
13926
|
this.extra[key] = o[key];
|
|
13879
13927
|
}
|
|
13928
|
+
clone() {
|
|
13929
|
+
return Component.fromSpec(this.spec);
|
|
13930
|
+
}
|
|
13880
13931
|
compile(ParseContext2) {
|
|
13881
13932
|
for (const name in this.views)
|
|
13882
13933
|
this.views[name].compile(new ParseContext2, this.scope, this.id);
|
|
13883
|
-
|
|
13884
|
-
|
|
13885
|
-
|
|
13886
|
-
|
|
13887
|
-
this.
|
|
13888
|
-
|
|
13889
|
-
|
|
13890
|
-
|
|
13891
|
-
|
|
13892
|
-
|
|
13893
|
-
|
|
13934
|
+
const ctx = this.views.main.ctx;
|
|
13935
|
+
for (const key in this._rawProvide) {
|
|
13936
|
+
const val = vp.parseProvide(this._rawProvide[key], ctx);
|
|
13937
|
+
if (val)
|
|
13938
|
+
this.provide[key] = new ProvideInfo(key, val, Symbol(key));
|
|
13939
|
+
}
|
|
13940
|
+
for (const key in this._rawLookup) {
|
|
13941
|
+
const linfo = this._rawLookup[key];
|
|
13942
|
+
const forStr = isString(linfo) ? linfo : isString(linfo?.for) ? linfo.for : null;
|
|
13943
|
+
const [compName, provideName] = forStr === null ? [] : forStr.split(".");
|
|
13944
|
+
if (!isString(compName) || !isString(provideName))
|
|
13945
|
+
continue;
|
|
13946
|
+
const defStr = isString(linfo?.default) ? linfo.default : null;
|
|
13947
|
+
const val = defStr === null ? null : vp.parseField(defStr, ctx);
|
|
13948
|
+
this.lookup[key] = new LookupInfo(key, compName, provideName, val);
|
|
13894
13949
|
}
|
|
13950
|
+
for (const key in this.lookup)
|
|
13951
|
+
if (this.provide[key] !== undefined)
|
|
13952
|
+
console.warn("name declared in both provide and lookup", this.name, key);
|
|
13895
13953
|
}
|
|
13896
13954
|
make(args, opts) {
|
|
13897
13955
|
return this.Class.make(args, opts ?? { scope: this.scope });
|
|
@@ -13919,9 +13977,6 @@ class Component {
|
|
|
13919
13977
|
`);
|
|
13920
13978
|
}
|
|
13921
13979
|
}
|
|
13922
|
-
function defaultOnStackEnter() {
|
|
13923
|
-
return null;
|
|
13924
|
-
}
|
|
13925
13980
|
|
|
13926
13981
|
// src/stack.js
|
|
13927
13982
|
var STOP = Symbol("STOP");
|
|
@@ -13980,47 +14035,61 @@ class Stack2 {
|
|
|
13980
14035
|
this.viewsId = viewsId;
|
|
13981
14036
|
this.ctx = ctx;
|
|
13982
14037
|
}
|
|
13983
|
-
|
|
13984
|
-
|
|
14038
|
+
_pushProvides() {
|
|
14039
|
+
const provide = this.comps.getCompFor(this.it)?.provide;
|
|
14040
|
+
if (provide == null)
|
|
14041
|
+
return this;
|
|
14042
|
+
const dynObj = {};
|
|
14043
|
+
let has2 = false;
|
|
14044
|
+
for (const k in provide) {
|
|
14045
|
+
dynObj[provide[k].symbol] = provide[k].val.eval(this);
|
|
14046
|
+
has2 = true;
|
|
14047
|
+
}
|
|
14048
|
+
if (!has2)
|
|
14049
|
+
return this;
|
|
14050
|
+
const newDynBinds = [new ObjectFrame(dynObj), this.dynBinds];
|
|
14051
|
+
const { comps, it, binds, views, viewsId, ctx } = this;
|
|
14052
|
+
return new Stack2(comps, it, binds, newDynBinds, views, viewsId, ctx);
|
|
13985
14053
|
}
|
|
13986
14054
|
static root(comps, it, ctx) {
|
|
13987
14055
|
const binds = [new BindFrame(it, { it }, true), null];
|
|
13988
14056
|
const dynBinds = [new ObjectFrame({}), null];
|
|
13989
14057
|
const views = ["main", null];
|
|
13990
|
-
return new Stack2(comps, it, binds, dynBinds, views, "", ctx).
|
|
14058
|
+
return new Stack2(comps, it, binds, dynBinds, views, "", ctx)._pushProvides();
|
|
13991
14059
|
}
|
|
13992
14060
|
enter(it, bindings = {}, isFrame = true) {
|
|
13993
14061
|
const { comps, binds, dynBinds, views, viewsId, ctx } = this;
|
|
13994
14062
|
const newBinds = [new BindFrame(it, bindings, isFrame), binds];
|
|
13995
14063
|
const stack = new Stack2(comps, it, newBinds, dynBinds, views, viewsId, ctx);
|
|
13996
|
-
return isFrame ? stack.
|
|
14064
|
+
return isFrame ? stack._pushProvides() : stack;
|
|
13997
14065
|
}
|
|
13998
14066
|
pushViewName(name) {
|
|
13999
14067
|
const { comps, it, binds, dynBinds, views, ctx } = this;
|
|
14000
14068
|
const newViews = [name, views];
|
|
14001
14069
|
return new Stack2(comps, it, binds, dynBinds, newViews, computeViewsId(newViews), ctx);
|
|
14002
14070
|
}
|
|
14003
|
-
|
|
14004
|
-
|
|
14005
|
-
|
|
14006
|
-
const
|
|
14007
|
-
|
|
14008
|
-
for (const dynName of dynamics)
|
|
14009
|
-
comp.dynamic[dynName].evalAndBind(this, dynObj);
|
|
14010
|
-
const newDynBinds = [new ObjectFrame(dynObj), this.dynBinds];
|
|
14011
|
-
const { comps, it, binds, views, viewsId, ctx } = this;
|
|
14012
|
-
return new Stack2(comps, it, binds, newDynBinds, views, viewsId, ctx);
|
|
14071
|
+
_pushDynBindValuesToArray(arr, comp) {
|
|
14072
|
+
for (const k in comp.provide)
|
|
14073
|
+
arr.push(this._lookupProvide(comp.provide[k]));
|
|
14074
|
+
for (const k in comp.lookup)
|
|
14075
|
+
arr.push(this._lookupAlias(comp.lookup[k]));
|
|
14013
14076
|
}
|
|
14014
|
-
|
|
14015
|
-
|
|
14016
|
-
arr.push(this._lookupDynamicWithDynVal(dyns[k]));
|
|
14077
|
+
_lookupProvide(p) {
|
|
14078
|
+
return lookup(this.dynBinds, p.symbol) ?? p.val.eval(this) ?? null;
|
|
14017
14079
|
}
|
|
14018
|
-
|
|
14019
|
-
|
|
14080
|
+
_lookupAlias(lk) {
|
|
14081
|
+
const sym = lk.getProducerSymbol(this);
|
|
14082
|
+
return (sym != null ? lookup(this.dynBinds, sym) : null) ?? lk.val?.eval(this) ?? null;
|
|
14020
14083
|
}
|
|
14021
14084
|
lookupDynamic(name) {
|
|
14022
|
-
const
|
|
14023
|
-
|
|
14085
|
+
const comp = this.comps.getCompFor(this.it);
|
|
14086
|
+
if (comp == null)
|
|
14087
|
+
return null;
|
|
14088
|
+
const lk = comp.lookup[name];
|
|
14089
|
+
if (lk !== undefined)
|
|
14090
|
+
return this._lookupAlias(lk);
|
|
14091
|
+
const p = comp.provide[name];
|
|
14092
|
+
return p !== undefined ? this._lookupProvide(p) : null;
|
|
14024
14093
|
}
|
|
14025
14094
|
lookupBind(name) {
|
|
14026
14095
|
return lookup(this.binds, name);
|
|
@@ -14952,10 +15021,11 @@ class ClassBuilder {
|
|
|
14952
15021
|
this._statics = {
|
|
14953
15022
|
make: function(inArgs = {}, opts = {}) {
|
|
14954
15023
|
const args = {};
|
|
15024
|
+
const scope = opts.scope ?? this.scope;
|
|
14955
15025
|
for (const key in inArgs) {
|
|
14956
15026
|
const field = fields[key];
|
|
14957
15027
|
if (compFields.has(key))
|
|
14958
|
-
args[key] = mkCompField(field,
|
|
15028
|
+
args[key] = mkCompField(field, scope, inArgs[key]);
|
|
14959
15029
|
else if (field === undefined)
|
|
14960
15030
|
console.warn("extra argument to constructor:", name, key, inArgs);
|
|
14961
15031
|
else
|
|
@@ -14963,7 +15033,7 @@ class ClassBuilder {
|
|
|
14963
15033
|
}
|
|
14964
15034
|
for (const key of compFields)
|
|
14965
15035
|
if (args[key] === undefined)
|
|
14966
|
-
args[key] = mkCompField(fields[key],
|
|
15036
|
+
args[key] = mkCompField(fields[key], scope, inArgs[key]);
|
|
14967
15037
|
return this(args);
|
|
14968
15038
|
}
|
|
14969
15039
|
};
|
|
@@ -15050,7 +15120,8 @@ function classFromData(name, { fields = {}, methods, statics }) {
|
|
|
15050
15120
|
b.statics(statics);
|
|
15051
15121
|
return b.build();
|
|
15052
15122
|
}
|
|
15053
|
-
|
|
15123
|
+
Component.fromSpec = (opts) => new Component(classFromData(opts.name, opts), opts);
|
|
15124
|
+
var component = (opts) => Component.fromSpec(opts);
|
|
15054
15125
|
|
|
15055
15126
|
// src/cache.js
|
|
15056
15127
|
class NullDomCache {
|
|
@@ -15169,7 +15240,7 @@ class Renderer {
|
|
|
15169
15240
|
_rValComp(stack, val, comp, node, key, viewName) {
|
|
15170
15241
|
const cacheKey = `${viewName ?? stack.viewsId ?? ""}-${key}`;
|
|
15171
15242
|
const cachePath = [node, val];
|
|
15172
|
-
stack._pushDynBindValuesToArray(cachePath, comp
|
|
15243
|
+
stack._pushDynBindValuesToArray(cachePath, comp);
|
|
15173
15244
|
const cachedNode = this.cache.get(cachePath, cacheKey);
|
|
15174
15245
|
if (cachedNode)
|
|
15175
15246
|
return cachedNode;
|
|
@@ -15774,6 +15845,7 @@ export {
|
|
|
15774
15845
|
REDUNDANT_TEMPLATE_STRING,
|
|
15775
15846
|
ParseContext,
|
|
15776
15847
|
PairSorting,
|
|
15848
|
+
PROVIDE_NOT_ADDRESSABLE,
|
|
15777
15849
|
PLACEHOLDERLESS_TEMPLATE_STRING,
|
|
15778
15850
|
OrderedSet,
|
|
15779
15851
|
OrderedMap,
|
|
@@ -15793,6 +15865,8 @@ export {
|
|
|
15793
15865
|
LintContext,
|
|
15794
15866
|
LintComponentResult,
|
|
15795
15867
|
LintClassCollectorCtx,
|
|
15868
|
+
LOOKUP_TARGET_MALFORMED,
|
|
15869
|
+
LOOKUP_BAD_SHAPE,
|
|
15796
15870
|
KList,
|
|
15797
15871
|
Set2 as ISet,
|
|
15798
15872
|
INPUT_HANDLER_NOT_REFERENCED,
|