@barefootjs/xslate 0.31.4 → 0.31.6
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/adapter/index.js +14 -42
- package/dist/adapter/xslate-adapter.d.ts +33 -37
- package/dist/adapter/xslate-adapter.d.ts.map +1 -1
- package/dist/conformance-pins.d.ts.map +1 -1
- package/dist/index.js +25 -47
- package/dist/vite.js +145 -125
- package/lib/BarefootJS/Backend/Xslate.pm +1 -1
- package/package.json +5 -5
- package/src/__tests__/xslate-adapter.test.ts +58 -20
- package/src/adapter/xslate-adapter.ts +78 -85
- package/src/conformance-pins.ts +14 -5
package/dist/adapter/index.js
CHANGED
|
@@ -187314,8 +187314,8 @@ import {
|
|
|
187314
187314
|
dangerousInnerHtmlMetacharViolation,
|
|
187315
187315
|
dangerousInnerHtmlDiagnostic,
|
|
187316
187316
|
resolveStaticLoopSource,
|
|
187317
|
-
|
|
187318
|
-
|
|
187317
|
+
derivesScopeFromSlot,
|
|
187318
|
+
BindingScope
|
|
187319
187319
|
} from "@barefootjs/jsx";
|
|
187320
187320
|
|
|
187321
187321
|
// src/adapter/boolean-result.ts
|
|
@@ -188280,8 +188280,7 @@ class XslateAdapter extends BaseAdapter {
|
|
|
188280
188280
|
_searchParamsLocals = new Set;
|
|
188281
188281
|
_loweringMatchers = [];
|
|
188282
188282
|
localConstants = [];
|
|
188283
|
-
|
|
188284
|
-
loopBoundNames = new Map;
|
|
188283
|
+
scope = BindingScope.EMPTY;
|
|
188285
188284
|
nullableOptionalProps = new Set;
|
|
188286
188285
|
constructor(options = {}) {
|
|
188287
188286
|
super();
|
|
@@ -188297,8 +188296,7 @@ class XslateAdapter extends BaseAdapter {
|
|
|
188297
188296
|
this.propsParams = ir.metadata.propsParams.map((p) => ({ name: p.name }));
|
|
188298
188297
|
this.booleanTypedProps = collectBooleanTypedProps(ir);
|
|
188299
188298
|
this.localConstants = ir.metadata.localConstants ?? [];
|
|
188300
|
-
this.
|
|
188301
|
-
this.loopBoundNames.clear();
|
|
188299
|
+
this.scope = BindingScope.EMPTY;
|
|
188302
188300
|
this.nullableOptionalProps = collectNullableOptionalProps(ir);
|
|
188303
188301
|
this.stringValueNames = collectStringValueNames(ir);
|
|
188304
188302
|
this.moduleStringConsts = collectModuleStringConsts(ir.metadata.localConstants);
|
|
@@ -188581,7 +188579,7 @@ ${whenTrue}
|
|
|
188581
188579
|
});
|
|
188582
188580
|
}
|
|
188583
188581
|
const staticItems = resolveStaticLoopSource(loop.arrayParsed, this.localConstants, {
|
|
188584
|
-
isNameShadowed:
|
|
188582
|
+
isNameShadowed: this.scope.asShadowPredicate()
|
|
188585
188583
|
});
|
|
188586
188584
|
const staticArray = staticItems !== null ? staticValueToKolon(staticItems) : null;
|
|
188587
188585
|
const arrayName = loop.array.trim();
|
|
@@ -188594,7 +188592,8 @@ ${whenTrue}
|
|
|
188594
188592
|
message: `Loop array \`${arrayName}\` is a local computed value (\`${arrayConst.value}\`) that the Xslate adapter cannot bind as a template variable — only numeric/string-literal locals inline at their use site.`,
|
|
188595
188593
|
loc: loop.loc ?? { file: this.componentName + ".tsx", start: { line: 1, column: 0 }, end: { line: 1, column: 0 } },
|
|
188596
188594
|
suggestion: {
|
|
188597
|
-
message: "Pre-compute the array server-side and pass it as a prop, or mark the loop position as @client-only so it runs in JS on the client."
|
|
188595
|
+
message: "Pre-compute the array server-side and pass it as a prop, or mark the loop position as @client-only so it runs in JS on the client.",
|
|
188596
|
+
escape: [{ kind: "prop-precompute" }, { kind: "client-directive" }]
|
|
188598
188597
|
}
|
|
188599
188598
|
});
|
|
188600
188599
|
}
|
|
@@ -188638,40 +188637,15 @@ ${whenTrue}
|
|
|
188638
188637
|
this.inLoop = true;
|
|
188639
188638
|
const prevLoopKeyDepth = this.currentLoopKeyDepth;
|
|
188640
188639
|
this.currentLoopKeyDepth = loop.depth;
|
|
188640
|
+
const prevScope = this.scope;
|
|
188641
|
+
this.scope = prevScope.enterLoopRow(loop);
|
|
188641
188642
|
const preambleLines = (loop.preamble?.declarations ?? []).map((d) => `: my $${d.name} = ${this.convertExpressionToKolon(d.raw, d.valueParsed)};`);
|
|
188642
|
-
const loopBound = [];
|
|
188643
|
-
if (loop.objectIteration === "entries") {
|
|
188644
|
-
loopBound.push("__bf_pair", loop.index ?? param, param);
|
|
188645
|
-
} else if (loop.objectIteration === "keys" || loop.objectIteration === "values") {
|
|
188646
|
-
loopBound.push(param);
|
|
188647
|
-
} else if (loop.iterationShape === "keys") {
|
|
188648
|
-
loopBound.push("__bf_item", param);
|
|
188649
|
-
} else if (supportableDestructure) {
|
|
188650
|
-
loopBound.push("__bf_item", ...(loop.paramBindings ?? []).map((b) => b.name));
|
|
188651
|
-
if (loop.index)
|
|
188652
|
-
loopBound.push(loop.index);
|
|
188653
|
-
} else {
|
|
188654
|
-
loopBound.push(param);
|
|
188655
|
-
if (loop.index)
|
|
188656
|
-
loopBound.push(loop.index);
|
|
188657
|
-
}
|
|
188658
|
-
for (const d of loop.preamble?.declarations ?? [])
|
|
188659
|
-
loopBound.push(d.name);
|
|
188660
|
-
for (const n of loopBound) {
|
|
188661
|
-
this.loopBoundNames.set(n, (this.loopBoundNames.get(n) ?? 0) + 1);
|
|
188662
|
-
}
|
|
188663
188643
|
const childrenUnderLoop = this.renderChildren(loop.children);
|
|
188664
|
-
for (const n of loopBound) {
|
|
188665
|
-
const c = (this.loopBoundNames.get(n) ?? 1) - 1;
|
|
188666
|
-
if (c <= 0)
|
|
188667
|
-
this.loopBoundNames.delete(n);
|
|
188668
|
-
else
|
|
188669
|
-
this.loopBoundNames.set(n, c);
|
|
188670
|
-
}
|
|
188671
188644
|
this.currentLoopKeyDepth = prevLoopKeyDepth;
|
|
188672
188645
|
this.inLoop = prevInLoop;
|
|
188673
188646
|
const bodyChildren = loop.bodyIsItemConditional && loop.key ? `<: $bf.comment("loop-i:" ~ ${this.convertExpressionToKolon(loop.key)}) | mark_raw :>
|
|
188674
188647
|
${childrenUnderLoop}` : childrenUnderLoop;
|
|
188648
|
+
this.scope = prevScope;
|
|
188675
188649
|
const lines = [];
|
|
188676
188650
|
lines.push(`<: $bf.comment("loop:${loop.markerId}") | mark_raw :>`);
|
|
188677
188651
|
const forHeader = loop.objectIteration === "entries" ? `: for ${array}.kv() -> $${loopVar} {` : loop.objectIteration === "keys" ? `: for ${array}.keys() -> $${loopVar} {` : loop.objectIteration === "values" ? `: for ${array}.values() -> $${loopVar} {` : `: for ${array} -> $${loopVar} {`;
|
|
@@ -188901,7 +188875,7 @@ ${name}="<: ${val} :>"
|
|
|
188901
188875
|
if (ternaryHashref !== null) {
|
|
188902
188876
|
return `<: $bf.spread_attrs(${ternaryHashref}) | mark_raw :>`;
|
|
188903
188877
|
}
|
|
188904
|
-
if (/^[A-Za-z_$][\w$]*$/.test(trimmed) && !this.
|
|
188878
|
+
if (/^[A-Za-z_$][\w$]*$/.test(trimmed) && !this.scope.isBound(trimmed)) {
|
|
188905
188879
|
const localConst = (this.localConstants ?? []).find((c) => c.name === trimmed && !c.isModule);
|
|
188906
188880
|
if (localConst?.value !== undefined) {
|
|
188907
188881
|
const initTrimmed = localConst.value.trim();
|
|
@@ -189125,10 +189099,10 @@ Options:
|
|
|
189125
189099
|
return this.booleanTypedProps.has(bare);
|
|
189126
189100
|
}
|
|
189127
189101
|
isLoopBoundName(name) {
|
|
189128
|
-
return this.
|
|
189102
|
+
return this.scope.isBound(name);
|
|
189129
189103
|
}
|
|
189130
189104
|
_resolveLiteralConst(name) {
|
|
189131
|
-
if (this.
|
|
189105
|
+
if (this.scope.isBound(name))
|
|
189132
189106
|
return null;
|
|
189133
189107
|
const c = (this.localConstants ?? []).find((lc) => lc.name === name);
|
|
189134
189108
|
if (c?.value === undefined)
|
|
@@ -189142,9 +189116,7 @@ Options:
|
|
|
189142
189116
|
return null;
|
|
189143
189117
|
}
|
|
189144
189118
|
_resolveStaticRecordLiteral(objectName, key) {
|
|
189145
|
-
|
|
189146
|
-
return null;
|
|
189147
|
-
const hit = lookupStaticRecordLiteral(objectName, key, this.localConstants);
|
|
189119
|
+
const hit = lookupStaticRecordLiteral(objectName, key, this.localConstants, (name) => this.scope.isBound(name));
|
|
189148
189120
|
if (!hit)
|
|
189149
189121
|
return null;
|
|
189150
189122
|
return hit.kind === "number" ? hit.text : `'${hit.text.replace(/[\\']/g, (m) => `\\${m}`)}'`;
|
|
@@ -104,29 +104,24 @@ export declare class XslateAdapter extends BaseAdapter implements IRNodeEmitter<
|
|
|
104
104
|
*/
|
|
105
105
|
private localConstants;
|
|
106
106
|
/**
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
* `
|
|
122
|
-
*
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
* local-const fallback (#2489) need to know whether a name is loop-bound
|
|
126
|
-
* AT THIS POSITION, because for those the coarse fallback would silently
|
|
127
|
-
* mis-render a genuine occurrence of the same name outside the loop too.
|
|
128
|
-
*/
|
|
129
|
-
private loopBoundNames;
|
|
107
|
+
* The one canonical, position-accurate "names bound by an enclosing loop
|
|
108
|
+
* callback" service (#2482 Stage 2) — replaces the two ad-hoc devices
|
|
109
|
+
* this adapter used to carry side by side: a coarse whole-component
|
|
110
|
+
* shadow-name Set (built once at `generate()` entry, used only to guard
|
|
111
|
+
* static-const inlining) and a ref-counted, position-accurate live map
|
|
112
|
+
* (pushed/popped around `renderLoop`'s body, used for the boolean-prop/
|
|
113
|
+
* nullable-optional classification sites (#2488) and `emitSpread`'s
|
|
114
|
+
* local-const fallback (#2489)). Both consulted the "is this name
|
|
115
|
+
* loop-bound" question with DIFFERENT meanings — the coarse/live drift
|
|
116
|
+
* #2482 Stage 2 ends. Every shadow-guard site now reads this ONE
|
|
117
|
+
* threaded, immutable scope: `enterLoopRow`/pop-by-reference around
|
|
118
|
+
* `renderChildren(loop.children)` in `renderLoop`, mirroring the Stage
|
|
119
|
+
* 1a/1b `ctx.scope` precedent in `jsx-to-ir.ts`. `IRLoop` already
|
|
120
|
+
* structurally satisfies `LoopBindingSource`
|
|
121
|
+
* (`param`/`index`/`paramBindings`/`preamble`), so `renderLoop` passes
|
|
122
|
+
* the loop node straight to `enterLoopRow`.
|
|
123
|
+
*/
|
|
124
|
+
private scope;
|
|
130
125
|
/**
|
|
131
126
|
* Optional, no-default props that are `undef` when the caller omits them.
|
|
132
127
|
* Their bare-reference attribute emission is guarded with Kolon `defined` so
|
|
@@ -339,7 +334,7 @@ export declare class XslateAdapter extends BaseAdapter implements IRNodeEmitter<
|
|
|
339
334
|
consequent: string;
|
|
340
335
|
} | null;
|
|
341
336
|
isBooleanTypedPropRef(expr: string): boolean;
|
|
342
|
-
/** Position-accurate loop-bound-name check — see `
|
|
337
|
+
/** Position-accurate loop-bound-name check — see `this.scope`'s docstring. */
|
|
343
338
|
private isLoopBoundName;
|
|
344
339
|
/**
|
|
345
340
|
* Inline a const (any scope) whose initializer is a pure numeric or
|
|
@@ -348,14 +343,13 @@ export declare class XslateAdapter extends BaseAdapter implements IRNodeEmitter<
|
|
|
348
343
|
* stash, so a bare `$totalPages` renders empty.
|
|
349
344
|
*
|
|
350
345
|
* The lookup is a flat name match with no notion of AST scope, so a
|
|
351
|
-
* name
|
|
352
|
-
* inlines (#2221) — the occurrence may be the
|
|
353
|
-
* binding, and substituting the outer const's
|
|
354
|
-
* iteration with the same hard-coded literal.
|
|
355
|
-
*
|
|
356
|
-
*
|
|
357
|
-
*
|
|
358
|
-
* `collectStringValueNames`.
|
|
346
|
+
* name bound by the CURRENTLY ENCLOSING loop's item/index/destructure/
|
|
347
|
+
* preamble param never inlines (#2221) — the occurrence may be the
|
|
348
|
+
* loop's own (shadowing) binding, and substituting the outer const's
|
|
349
|
+
* value there renders every iteration with the same hard-coded literal.
|
|
350
|
+
* Position-accurate via the threaded `this.scope` (#2482 Stage 2) — a
|
|
351
|
+
* same-named const elsewhere in the component, outside any loop that
|
|
352
|
+
* shadows it, still inlines.
|
|
359
353
|
*/
|
|
360
354
|
private _resolveLiteralConst;
|
|
361
355
|
/**
|
|
@@ -366,11 +360,13 @@ export declare class XslateAdapter extends BaseAdapter implements IRNodeEmitter<
|
|
|
366
360
|
* scope, so an enclosing loop callback's own param of the same name
|
|
367
361
|
* (`.map((cfg) => <li>{cfg.x}</li>)` shadowing a module `const cfg = {…}`)
|
|
368
362
|
* still resolved to the OUTER const's member value at every iteration
|
|
369
|
-
* (#2237) — the sibling hazard to #2221's `_resolveLiteralConst`.
|
|
370
|
-
*
|
|
371
|
-
*
|
|
372
|
-
*
|
|
373
|
-
* correctly at the
|
|
363
|
+
* (#2237) — the sibling hazard to #2221's `_resolveLiteralConst`.
|
|
364
|
+
* Position-accurate via the threaded `this.scope` (#2482 Stage 2), passed
|
|
365
|
+
* as `lookupStaticRecordLiteral`'s required guard: a name the CURRENTLY
|
|
366
|
+
* ENCLOSING loop binds never inlines, falling back to the bare `$cfg.x`
|
|
367
|
+
* member expression (which an Xslate `: for` loop binds correctly at the
|
|
368
|
+
* shadowed occurrence); a same-named const elsewhere, outside any loop
|
|
369
|
+
* that shadows it, still inlines.
|
|
374
370
|
*/
|
|
375
371
|
private _resolveStaticRecordLiteral;
|
|
376
372
|
private _resolveModuleStringConst;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xslate-adapter.d.ts","sourceRoot":"","sources":["../../src/adapter/xslate-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,MAAM,EACN,SAAS,EACT,MAAM,EACN,YAAY,EACZ,aAAa,EACb,MAAM,EACN,WAAW,EACX,UAAU,EACV,MAAM,EACN,aAAa,EACb,UAAU,EACV,OAAO,EAKP,yBAAyB,EAG1B,MAAM,iBAAiB,CAAA;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3,"file":"conformance-pins.d.ts","sourceRoot":"","sources":["../src/conformance-pins.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEtD,eAAO,MAAM,eAAe,EAAE,
|
|
1
|
+
{"version":3,"file":"conformance-pins.d.ts","sourceRoot":"","sources":["../src/conformance-pins.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEtD,eAAO,MAAM,eAAe,EAAE,eAkK7B,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -187314,8 +187314,8 @@ import {
|
|
|
187314
187314
|
dangerousInnerHtmlMetacharViolation,
|
|
187315
187315
|
dangerousInnerHtmlDiagnostic,
|
|
187316
187316
|
resolveStaticLoopSource,
|
|
187317
|
-
|
|
187318
|
-
|
|
187317
|
+
derivesScopeFromSlot,
|
|
187318
|
+
BindingScope
|
|
187319
187319
|
} from "@barefootjs/jsx";
|
|
187320
187320
|
|
|
187321
187321
|
// src/adapter/boolean-result.ts
|
|
@@ -188280,8 +188280,7 @@ class XslateAdapter extends BaseAdapter {
|
|
|
188280
188280
|
_searchParamsLocals = new Set;
|
|
188281
188281
|
_loweringMatchers = [];
|
|
188282
188282
|
localConstants = [];
|
|
188283
|
-
|
|
188284
|
-
loopBoundNames = new Map;
|
|
188283
|
+
scope = BindingScope.EMPTY;
|
|
188285
188284
|
nullableOptionalProps = new Set;
|
|
188286
188285
|
constructor(options = {}) {
|
|
188287
188286
|
super();
|
|
@@ -188297,8 +188296,7 @@ class XslateAdapter extends BaseAdapter {
|
|
|
188297
188296
|
this.propsParams = ir.metadata.propsParams.map((p) => ({ name: p.name }));
|
|
188298
188297
|
this.booleanTypedProps = collectBooleanTypedProps(ir);
|
|
188299
188298
|
this.localConstants = ir.metadata.localConstants ?? [];
|
|
188300
|
-
this.
|
|
188301
|
-
this.loopBoundNames.clear();
|
|
188299
|
+
this.scope = BindingScope.EMPTY;
|
|
188302
188300
|
this.nullableOptionalProps = collectNullableOptionalProps(ir);
|
|
188303
188301
|
this.stringValueNames = collectStringValueNames(ir);
|
|
188304
188302
|
this.moduleStringConsts = collectModuleStringConsts(ir.metadata.localConstants);
|
|
@@ -188581,7 +188579,7 @@ ${whenTrue}
|
|
|
188581
188579
|
});
|
|
188582
188580
|
}
|
|
188583
188581
|
const staticItems = resolveStaticLoopSource(loop.arrayParsed, this.localConstants, {
|
|
188584
|
-
isNameShadowed:
|
|
188582
|
+
isNameShadowed: this.scope.asShadowPredicate()
|
|
188585
188583
|
});
|
|
188586
188584
|
const staticArray = staticItems !== null ? staticValueToKolon(staticItems) : null;
|
|
188587
188585
|
const arrayName = loop.array.trim();
|
|
@@ -188594,7 +188592,8 @@ ${whenTrue}
|
|
|
188594
188592
|
message: `Loop array \`${arrayName}\` is a local computed value (\`${arrayConst.value}\`) that the Xslate adapter cannot bind as a template variable — only numeric/string-literal locals inline at their use site.`,
|
|
188595
188593
|
loc: loop.loc ?? { file: this.componentName + ".tsx", start: { line: 1, column: 0 }, end: { line: 1, column: 0 } },
|
|
188596
188594
|
suggestion: {
|
|
188597
|
-
message: "Pre-compute the array server-side and pass it as a prop, or mark the loop position as @client-only so it runs in JS on the client."
|
|
188595
|
+
message: "Pre-compute the array server-side and pass it as a prop, or mark the loop position as @client-only so it runs in JS on the client.",
|
|
188596
|
+
escape: [{ kind: "prop-precompute" }, { kind: "client-directive" }]
|
|
188598
188597
|
}
|
|
188599
188598
|
});
|
|
188600
188599
|
}
|
|
@@ -188638,40 +188637,15 @@ ${whenTrue}
|
|
|
188638
188637
|
this.inLoop = true;
|
|
188639
188638
|
const prevLoopKeyDepth = this.currentLoopKeyDepth;
|
|
188640
188639
|
this.currentLoopKeyDepth = loop.depth;
|
|
188640
|
+
const prevScope = this.scope;
|
|
188641
|
+
this.scope = prevScope.enterLoopRow(loop);
|
|
188641
188642
|
const preambleLines = (loop.preamble?.declarations ?? []).map((d) => `: my $${d.name} = ${this.convertExpressionToKolon(d.raw, d.valueParsed)};`);
|
|
188642
|
-
const loopBound = [];
|
|
188643
|
-
if (loop.objectIteration === "entries") {
|
|
188644
|
-
loopBound.push("__bf_pair", loop.index ?? param, param);
|
|
188645
|
-
} else if (loop.objectIteration === "keys" || loop.objectIteration === "values") {
|
|
188646
|
-
loopBound.push(param);
|
|
188647
|
-
} else if (loop.iterationShape === "keys") {
|
|
188648
|
-
loopBound.push("__bf_item", param);
|
|
188649
|
-
} else if (supportableDestructure) {
|
|
188650
|
-
loopBound.push("__bf_item", ...(loop.paramBindings ?? []).map((b) => b.name));
|
|
188651
|
-
if (loop.index)
|
|
188652
|
-
loopBound.push(loop.index);
|
|
188653
|
-
} else {
|
|
188654
|
-
loopBound.push(param);
|
|
188655
|
-
if (loop.index)
|
|
188656
|
-
loopBound.push(loop.index);
|
|
188657
|
-
}
|
|
188658
|
-
for (const d of loop.preamble?.declarations ?? [])
|
|
188659
|
-
loopBound.push(d.name);
|
|
188660
|
-
for (const n of loopBound) {
|
|
188661
|
-
this.loopBoundNames.set(n, (this.loopBoundNames.get(n) ?? 0) + 1);
|
|
188662
|
-
}
|
|
188663
188643
|
const childrenUnderLoop = this.renderChildren(loop.children);
|
|
188664
|
-
for (const n of loopBound) {
|
|
188665
|
-
const c = (this.loopBoundNames.get(n) ?? 1) - 1;
|
|
188666
|
-
if (c <= 0)
|
|
188667
|
-
this.loopBoundNames.delete(n);
|
|
188668
|
-
else
|
|
188669
|
-
this.loopBoundNames.set(n, c);
|
|
188670
|
-
}
|
|
188671
188644
|
this.currentLoopKeyDepth = prevLoopKeyDepth;
|
|
188672
188645
|
this.inLoop = prevInLoop;
|
|
188673
188646
|
const bodyChildren = loop.bodyIsItemConditional && loop.key ? `<: $bf.comment("loop-i:" ~ ${this.convertExpressionToKolon(loop.key)}) | mark_raw :>
|
|
188674
188647
|
${childrenUnderLoop}` : childrenUnderLoop;
|
|
188648
|
+
this.scope = prevScope;
|
|
188675
188649
|
const lines = [];
|
|
188676
188650
|
lines.push(`<: $bf.comment("loop:${loop.markerId}") | mark_raw :>`);
|
|
188677
188651
|
const forHeader = loop.objectIteration === "entries" ? `: for ${array}.kv() -> $${loopVar} {` : loop.objectIteration === "keys" ? `: for ${array}.keys() -> $${loopVar} {` : loop.objectIteration === "values" ? `: for ${array}.values() -> $${loopVar} {` : `: for ${array} -> $${loopVar} {`;
|
|
@@ -188901,7 +188875,7 @@ ${name}="<: ${val} :>"
|
|
|
188901
188875
|
if (ternaryHashref !== null) {
|
|
188902
188876
|
return `<: $bf.spread_attrs(${ternaryHashref}) | mark_raw :>`;
|
|
188903
188877
|
}
|
|
188904
|
-
if (/^[A-Za-z_$][\w$]*$/.test(trimmed) && !this.
|
|
188878
|
+
if (/^[A-Za-z_$][\w$]*$/.test(trimmed) && !this.scope.isBound(trimmed)) {
|
|
188905
188879
|
const localConst = (this.localConstants ?? []).find((c) => c.name === trimmed && !c.isModule);
|
|
188906
188880
|
if (localConst?.value !== undefined) {
|
|
188907
188881
|
const initTrimmed = localConst.value.trim();
|
|
@@ -189125,10 +189099,10 @@ Options:
|
|
|
189125
189099
|
return this.booleanTypedProps.has(bare);
|
|
189126
189100
|
}
|
|
189127
189101
|
isLoopBoundName(name) {
|
|
189128
|
-
return this.
|
|
189102
|
+
return this.scope.isBound(name);
|
|
189129
189103
|
}
|
|
189130
189104
|
_resolveLiteralConst(name) {
|
|
189131
|
-
if (this.
|
|
189105
|
+
if (this.scope.isBound(name))
|
|
189132
189106
|
return null;
|
|
189133
189107
|
const c = (this.localConstants ?? []).find((lc) => lc.name === name);
|
|
189134
189108
|
if (c?.value === undefined)
|
|
@@ -189142,9 +189116,7 @@ Options:
|
|
|
189142
189116
|
return null;
|
|
189143
189117
|
}
|
|
189144
189118
|
_resolveStaticRecordLiteral(objectName, key) {
|
|
189145
|
-
|
|
189146
|
-
return null;
|
|
189147
|
-
const hit = lookupStaticRecordLiteral(objectName, key, this.localConstants);
|
|
189119
|
+
const hit = lookupStaticRecordLiteral(objectName, key, this.localConstants, (name) => this.scope.isBound(name));
|
|
189148
189120
|
if (!hit)
|
|
189149
189121
|
return null;
|
|
189150
189122
|
return hit.kind === "number" ? hit.text : `'${hit.text.replace(/[\\']/g, (m) => `\\${m}`)}'`;
|
|
@@ -189194,17 +189166,23 @@ var conformancePins = {
|
|
|
189194
189166
|
"tag-cloud": [{ code: "BF021", severity: "error" }],
|
|
189195
189167
|
"preamble-cells": [{ code: "BF021", severity: "error" }],
|
|
189196
189168
|
"static-array-from-props": [
|
|
189197
|
-
{
|
|
189169
|
+
{
|
|
189170
|
+
code: "BF101",
|
|
189171
|
+
severity: "error",
|
|
189172
|
+
issue: "https://github.com/piconic-ai/barefootjs/issues/2321"
|
|
189173
|
+
}
|
|
189198
189174
|
],
|
|
189199
189175
|
"static-array-from-props-with-component": [
|
|
189200
|
-
{
|
|
189176
|
+
{
|
|
189177
|
+
code: "BF101",
|
|
189178
|
+
severity: "error",
|
|
189179
|
+
issue: "https://github.com/piconic-ai/barefootjs/issues/2321"
|
|
189180
|
+
}
|
|
189201
189181
|
],
|
|
189202
189182
|
"filter-nested-callback-predicate": [
|
|
189203
189183
|
{ code: "BF101", severity: "error", issue: "https://github.com/piconic-ai/barefootjs/issues/2320" }
|
|
189204
189184
|
],
|
|
189205
|
-
"filter-nested-find-predicate": [
|
|
189206
|
-
{ code: "BF101", severity: "error", issue: "https://github.com/piconic-ai/barefootjs/issues/2320" }
|
|
189207
|
-
],
|
|
189185
|
+
"filter-nested-find-predicate": [{ code: "BF101", severity: "error", issue: "https://github.com/piconic-ai/barefootjs/issues/2320" }],
|
|
189208
189186
|
"date-method-uncatalogued": [{ code: "BF021", severity: "error", issue: "https://github.com/piconic-ai/barefootjs/issues/2356" }]
|
|
189209
189187
|
};
|
|
189210
189188
|
// src/render-divergences.ts
|