@barefootjs/rust 0.31.4 → 0.31.5

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.
@@ -187314,8 +187314,8 @@ import {
187314
187314
  dangerousInnerHtmlMetacharViolation,
187315
187315
  dangerousInnerHtmlDiagnostic,
187316
187316
  resolveStaticLoopSource,
187317
- collectLoopBoundNames,
187318
- derivesScopeFromSlot
187317
+ derivesScopeFromSlot,
187318
+ BindingScope
187319
187319
  } from "@barefootjs/jsx";
187320
187320
 
187321
187321
  // src/adapter/boolean-result.ts
@@ -188315,8 +188315,7 @@ class MinijinjaAdapter extends BaseAdapter {
188315
188315
  _searchParamsLocals = new Set;
188316
188316
  _loweringMatchers = [];
188317
188317
  localConstants = [];
188318
- staticLoopSourceBoundNames = new Set;
188319
- loopBoundNames = new Map;
188318
+ scope = BindingScope.EMPTY;
188320
188319
  nullableOptionalProps = new Set;
188321
188320
  constructor(options = {}) {
188322
188321
  super();
@@ -188332,8 +188331,7 @@ class MinijinjaAdapter extends BaseAdapter {
188332
188331
  this.propsParams = ir.metadata.propsParams.map((p) => ({ name: p.name }));
188333
188332
  this.booleanTypedProps = collectBooleanTypedProps(ir);
188334
188333
  this.localConstants = ir.metadata.localConstants ?? [];
188335
- this.staticLoopSourceBoundNames = collectLoopBoundNames(ir);
188336
- this.loopBoundNames.clear();
188334
+ this.scope = BindingScope.EMPTY;
188337
188335
  this.nullableOptionalProps = collectNullableOptionalProps(ir);
188338
188336
  this.stringValueNames = collectStringValueNames(ir);
188339
188337
  this.moduleStringConsts = collectModuleStringConsts(ir.metadata.localConstants);
@@ -188627,7 +188625,7 @@ ${whenTrue}
188627
188625
  });
188628
188626
  }
188629
188627
  const staticItems = resolveStaticLoopSource(loop.arrayParsed, this.localConstants, {
188630
- isNameShadowed: (name) => this.staticLoopSourceBoundNames.has(name)
188628
+ isNameShadowed: this.scope.asShadowPredicate()
188631
188629
  });
188632
188630
  const staticArray = staticItems !== null ? staticValueToMinijinja(staticItems) : null;
188633
188631
  const arrayName = loop.array.trim();
@@ -188681,42 +188679,15 @@ ${whenTrue}
188681
188679
  this.inLoop = true;
188682
188680
  const prevLoopKeyDepth = this.currentLoopKeyDepth;
188683
188681
  this.currentLoopKeyDepth = loop.depth;
188682
+ const prevScope = this.scope;
188683
+ this.scope = prevScope.enterLoopRow(loop);
188684
188684
  const preambleLines = (loop.preamble?.declarations ?? []).map((d) => `{% set ${minijinjaIdent(d.name)} = ${this.convertExpressionToJinja(d.raw, d.valueParsed)} %}`);
188685
- const loopBound = [];
188686
- if (loop.objectIteration === "entries") {
188687
- loopBound.push(loop.index ?? param, param);
188688
- } else if (loop.objectIteration === "keys") {
188689
- loopBound.push(param, "__bf_v");
188690
- } else if (loop.objectIteration === "values") {
188691
- loopBound.push("__bf_k", param);
188692
- } else if (loop.iterationShape === "keys") {
188693
- loopBound.push("__bf_item", param);
188694
- } else if (supportableDestructure) {
188695
- loopBound.push("__bf_item", ...(loop.paramBindings ?? []).map((b) => b.name));
188696
- if (loop.index)
188697
- loopBound.push(loop.index);
188698
- } else {
188699
- loopBound.push(param);
188700
- if (loop.index)
188701
- loopBound.push(loop.index);
188702
- }
188703
- for (const d of loop.preamble?.declarations ?? [])
188704
- loopBound.push(d.name);
188705
- for (const n of loopBound) {
188706
- this.loopBoundNames.set(n, (this.loopBoundNames.get(n) ?? 0) + 1);
188707
- }
188708
188685
  const childrenUnderLoop = this.renderChildren(loop.children);
188709
- for (const n of loopBound) {
188710
- const c = (this.loopBoundNames.get(n) ?? 1) - 1;
188711
- if (c <= 0)
188712
- this.loopBoundNames.delete(n);
188713
- else
188714
- this.loopBoundNames.set(n, c);
188715
- }
188716
188686
  this.currentLoopKeyDepth = prevLoopKeyDepth;
188717
188687
  this.inLoop = prevInLoop;
188718
188688
  const bodyChildren = loop.bodyIsItemConditional && loop.key ? `{{ bf.comment("loop-i:" ~ bf.string(${this.convertExpressionToJinja(loop.key)})) | safe }}
188719
188689
  ${childrenUnderLoop}` : childrenUnderLoop;
188690
+ this.scope = prevScope;
188720
188691
  const lines = [];
188721
188692
  lines.push(`{{ bf.comment("loop:${loop.markerId}") | safe }}`);
188722
188693
  const forHeader = loop.objectIteration === "entries" ? `{% for ${minijinjaIdent(loop.index ?? param)}, ${minijinjaIdent(param)} in ${array}|items %}` : loop.objectIteration === "keys" ? `{% for ${minijinjaIdent(param)}, __bf_v in ${array}|items %}` : loop.objectIteration === "values" ? `{% for __bf_k, ${minijinjaIdent(param)} in ${array}|items %}` : `{% for ${minijinjaIdent(loopVar)} in ${array} %}`;
@@ -188948,7 +188919,7 @@ ${name}="{{ bf.string(${val}) }}"
188948
188919
  if (ternaryDict !== null) {
188949
188920
  return `{{ bf.spread_attrs(${ternaryDict}) | safe }}`;
188950
188921
  }
188951
- if (/^[A-Za-z_$][\w$]*$/.test(trimmed) && !this.loopBoundNames.has(trimmed)) {
188922
+ if (/^[A-Za-z_$][\w$]*$/.test(trimmed) && !this.scope.isBound(trimmed)) {
188952
188923
  const localConst = (this.localConstants ?? []).find((c) => c.name === trimmed && !c.isModule);
188953
188924
  if (localConst?.value !== undefined) {
188954
188925
  const initTrimmed = localConst.value.trim();
@@ -189183,7 +189154,7 @@ Options:
189183
189154
  return this.booleanTypedProps.has(bare);
189184
189155
  }
189185
189156
  isLoopBoundName(name) {
189186
- return this.loopBoundNames.has(name);
189157
+ return this.scope.isBound(name);
189187
189158
  }
189188
189159
  shouldBoolStr(expr, name) {
189189
189160
  if (isExplicitStringCall(expr))
@@ -189191,7 +189162,7 @@ Options:
189191
189162
  return isBooleanResultExpr(expr) || isAriaBooleanAttr(name) || this.isBooleanTypedPropRef(expr);
189192
189163
  }
189193
189164
  _resolveLiteralConst(name) {
189194
- if (this.staticLoopSourceBoundNames.has(name))
189165
+ if (this.scope.isBound(name))
189195
189166
  return null;
189196
189167
  const c = (this.localConstants ?? []).find((lc) => lc.name === name);
189197
189168
  if (c?.value === undefined)
@@ -189205,9 +189176,7 @@ Options:
189205
189176
  return null;
189206
189177
  }
189207
189178
  _resolveStaticRecordLiteral(objectName, key) {
189208
- if (this.staticLoopSourceBoundNames.has(objectName))
189209
- return null;
189210
- const hit = lookupStaticRecordLiteral(objectName, key, this.localConstants);
189179
+ const hit = lookupStaticRecordLiteral(objectName, key, this.localConstants, (name) => this.scope.isBound(name));
189211
189180
  if (!hit)
189212
189181
  return null;
189213
189182
  return hit.kind === "number" ? hit.text : `'${escapeMinijinjaSingleQuoted(hit.text)}'`;
@@ -193,29 +193,24 @@ export declare class MinijinjaAdapter extends BaseAdapter implements IRNodeEmitt
193
193
  */
194
194
  private localConstants;
195
195
  /**
196
- * Every name a `.map()`/`.filter()` loop callback binds as its item/index
197
- * parameter anywhere in the component (#2208 fable review). A static
198
- * loop-SOURCE name (e.g. a function-scope `const items = [...]`) must
199
- * never resolve through `resolveStaticLoopSource` at a use site where a
200
- * DIFFERENT, enclosing loop's own callback param shadows it — same
201
- * shadowing hazard, and same coarse-but-safe mitigation, as #2212's
202
- * `collectLoopBoundNames` use in `collectStringValueNames`.
203
- */
204
- private staticLoopSourceBoundNames;
205
- /**
206
- * Names currently bound by an enclosing loop body — the block-param
207
- * locals `renderLoop` introduces (item, index, per-binding destructure
208
- * fields, `.map()` preamble declarations) — ref-counted so nested loops
209
- * compose. This is the POSITION-ACCURATE twin of the coarse
210
- * `staticLoopSourceBoundNames` above: that set is a whole-component
211
- * union used only to guard static-const inlining (safe to over-suppress
212
- * there — the fallback is just "don't inline"), whereas the boolean-prop
213
- * and nullable-optional classification sites (#2488) and `emitSpread`'s
214
- * local-const fallback (#2489) need to know whether a name is loop-bound
215
- * AT THIS POSITION, because for those the coarse fallback would silently
216
- * mis-render a genuine occurrence of the same name outside the loop too.
217
- */
218
- private loopBoundNames;
196
+ * The one canonical, position-accurate "names bound by an enclosing loop
197
+ * callback" service (#2482 Stage 2) replaces the two ad-hoc devices
198
+ * this adapter used to carry side by side: a coarse whole-component
199
+ * shadow-name Set (built once at `generate()` entry, used only to guard
200
+ * static-const inlining) and a ref-counted, position-accurate live map
201
+ * (pushed/popped around `renderLoop`'s body, used for the boolean-prop/
202
+ * nullable-optional classification sites (#2488) and `emitSpread`'s
203
+ * local-const fallback (#2489)). Both consulted the "is this name
204
+ * loop-bound" question with DIFFERENT meanings — the coarse/live drift
205
+ * #2482 Stage 2 ends. Every shadow-guard site now reads this ONE
206
+ * threaded, immutable scope: `enterLoopRow`/pop-by-reference around
207
+ * `renderChildren(loop.children)` in `renderLoop`, mirroring the Stage
208
+ * 1a/1b `ctx.scope` precedent in `jsx-to-ir.ts`. `IRLoop` already
209
+ * structurally satisfies `LoopBindingSource`
210
+ * (`param`/`index`/`paramBindings`/`preamble`), so `renderLoop` passes
211
+ * the loop node straight to `enterLoopRow`.
212
+ */
213
+ private scope;
219
214
  /**
220
215
  * Optional, no-default props that are `None` when the caller omits them.
221
216
  * Their bare-reference attribute emission is guarded with a Jinja
@@ -430,7 +425,7 @@ export declare class MinijinjaAdapter extends BaseAdapter implements IRNodeEmitt
430
425
  consequent: string;
431
426
  } | null;
432
427
  isBooleanTypedPropRef(expr: string): boolean;
433
- /** Position-accurate loop-bound-name check — see `loopBoundNames`'s docstring. */
428
+ /** Position-accurate loop-bound-name check — see `this.scope`'s docstring. */
434
429
  private isLoopBoundName;
435
430
  /**
436
431
  * Whether an attribute-value expression should route through
@@ -452,14 +447,13 @@ export declare class MinijinjaAdapter extends BaseAdapter implements IRNodeEmitt
452
447
  * context, so a bare reference would resolve to Undefined.
453
448
  *
454
449
  * The lookup is a flat name match with no notion of AST scope, so a
455
- * name that any loop callback binds as its item/index param never
456
- * inlines (#2221) — the occurrence may be the loop's own (shadowing)
457
- * binding, and substituting the outer const's value there renders every
458
- * iteration with the same hard-coded literal. Coarse (a genuinely
459
- * non-shadowed same-named const elsewhere in the component also stops
460
- * inlining, falling back to the bare identifier) but safe — the same
461
- * trade-off as #2212's `collectLoopBoundNames` use in
462
- * `collectStringValueNames`.
450
+ * name bound by the CURRENTLY ENCLOSING loop's item/index/destructure/
451
+ * preamble param never inlines (#2221) — the occurrence may be the
452
+ * loop's own (shadowing) binding, and substituting the outer const's
453
+ * value there renders every iteration with the same hard-coded literal.
454
+ * Position-accurate via the threaded `this.scope` (#2482 Stage 2) — a
455
+ * same-named const elsewhere in the component, outside any loop that
456
+ * shadows it, still inlines.
463
457
  */
464
458
  private _resolveLiteralConst;
465
459
  /**
@@ -470,11 +464,13 @@ export declare class MinijinjaAdapter extends BaseAdapter implements IRNodeEmitt
470
464
  * scope, so an enclosing loop callback's own param of the same name
471
465
  * (`.map((cfg) => <li>{cfg.x}</li>)` shadowing a module `const cfg = {…}`)
472
466
  * still resolved to the OUTER const's member value at every iteration
473
- * (#2237) — the sibling hazard to #2221's `_resolveLiteralConst`. Same
474
- * coarse-but-safe `staticLoopSourceBoundNames` guard: any name a loop
475
- * binds anywhere in the component never inlines, falling back to the bare
476
- * `cfg.x` member expression (which a minijinja `for` loop binds correctly
477
- * at the shadowed occurrences).
467
+ * (#2237) — the sibling hazard to #2221's `_resolveLiteralConst`.
468
+ * Position-accurate via the threaded `this.scope` (#2482 Stage 2), passed
469
+ * as `lookupStaticRecordLiteral`'s required guard: a name the CURRENTLY
470
+ * ENCLOSING loop binds never inlines, falling back to the bare `cfg.x`
471
+ * member expression (which a minijinja `for` loop binds correctly at the
472
+ * shadowed occurrence); a same-named const elsewhere, outside any loop
473
+ * that shadows it, still inlines.
478
474
  */
479
475
  private _resolveStaticRecordLiteral;
480
476
  private _resolveModuleStringConst;
@@ -1 +1 @@
1
- {"version":3,"file":"minijinja-adapter.d.ts","sourceRoot":"","sources":["../../src/adapter/minijinja-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiHG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,MAAM,E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AI,CAgBlD;IAED,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAW3C;IAED,8EAA8E;IAC9E,OAAO,CAAC,eAAe;IAIvB;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,aAAa;IAKrB;;;;;;;;;;;;;;OAcG;IACH,OAAO,CAAC,oBAAoB;IAW5B;;;;;;;;;;;;;;;OAeG;IACH,OAAO,CAAC,2BAA2B;IAQnC,OAAO,CAAC,yBAAyB;IAUjC,OAAO,CAAC,gBAAgB;IAcxB,iFAAiF;IACjF,OAAO,CAAC,4BAA4B;CAGrC;AAED,eAAO,MAAM,gBAAgB,kBAAyB,CAAA"}
package/dist/index.js CHANGED
@@ -187314,8 +187314,8 @@ import {
187314
187314
  dangerousInnerHtmlMetacharViolation,
187315
187315
  dangerousInnerHtmlDiagnostic,
187316
187316
  resolveStaticLoopSource,
187317
- collectLoopBoundNames,
187318
- derivesScopeFromSlot
187317
+ derivesScopeFromSlot,
187318
+ BindingScope
187319
187319
  } from "@barefootjs/jsx";
187320
187320
 
187321
187321
  // src/adapter/boolean-result.ts
@@ -188315,8 +188315,7 @@ class MinijinjaAdapter extends BaseAdapter {
188315
188315
  _searchParamsLocals = new Set;
188316
188316
  _loweringMatchers = [];
188317
188317
  localConstants = [];
188318
- staticLoopSourceBoundNames = new Set;
188319
- loopBoundNames = new Map;
188318
+ scope = BindingScope.EMPTY;
188320
188319
  nullableOptionalProps = new Set;
188321
188320
  constructor(options = {}) {
188322
188321
  super();
@@ -188332,8 +188331,7 @@ class MinijinjaAdapter extends BaseAdapter {
188332
188331
  this.propsParams = ir.metadata.propsParams.map((p) => ({ name: p.name }));
188333
188332
  this.booleanTypedProps = collectBooleanTypedProps(ir);
188334
188333
  this.localConstants = ir.metadata.localConstants ?? [];
188335
- this.staticLoopSourceBoundNames = collectLoopBoundNames(ir);
188336
- this.loopBoundNames.clear();
188334
+ this.scope = BindingScope.EMPTY;
188337
188335
  this.nullableOptionalProps = collectNullableOptionalProps(ir);
188338
188336
  this.stringValueNames = collectStringValueNames(ir);
188339
188337
  this.moduleStringConsts = collectModuleStringConsts(ir.metadata.localConstants);
@@ -188627,7 +188625,7 @@ ${whenTrue}
188627
188625
  });
188628
188626
  }
188629
188627
  const staticItems = resolveStaticLoopSource(loop.arrayParsed, this.localConstants, {
188630
- isNameShadowed: (name) => this.staticLoopSourceBoundNames.has(name)
188628
+ isNameShadowed: this.scope.asShadowPredicate()
188631
188629
  });
188632
188630
  const staticArray = staticItems !== null ? staticValueToMinijinja(staticItems) : null;
188633
188631
  const arrayName = loop.array.trim();
@@ -188681,42 +188679,15 @@ ${whenTrue}
188681
188679
  this.inLoop = true;
188682
188680
  const prevLoopKeyDepth = this.currentLoopKeyDepth;
188683
188681
  this.currentLoopKeyDepth = loop.depth;
188682
+ const prevScope = this.scope;
188683
+ this.scope = prevScope.enterLoopRow(loop);
188684
188684
  const preambleLines = (loop.preamble?.declarations ?? []).map((d) => `{% set ${minijinjaIdent(d.name)} = ${this.convertExpressionToJinja(d.raw, d.valueParsed)} %}`);
188685
- const loopBound = [];
188686
- if (loop.objectIteration === "entries") {
188687
- loopBound.push(loop.index ?? param, param);
188688
- } else if (loop.objectIteration === "keys") {
188689
- loopBound.push(param, "__bf_v");
188690
- } else if (loop.objectIteration === "values") {
188691
- loopBound.push("__bf_k", param);
188692
- } else if (loop.iterationShape === "keys") {
188693
- loopBound.push("__bf_item", param);
188694
- } else if (supportableDestructure) {
188695
- loopBound.push("__bf_item", ...(loop.paramBindings ?? []).map((b) => b.name));
188696
- if (loop.index)
188697
- loopBound.push(loop.index);
188698
- } else {
188699
- loopBound.push(param);
188700
- if (loop.index)
188701
- loopBound.push(loop.index);
188702
- }
188703
- for (const d of loop.preamble?.declarations ?? [])
188704
- loopBound.push(d.name);
188705
- for (const n of loopBound) {
188706
- this.loopBoundNames.set(n, (this.loopBoundNames.get(n) ?? 0) + 1);
188707
- }
188708
188685
  const childrenUnderLoop = this.renderChildren(loop.children);
188709
- for (const n of loopBound) {
188710
- const c = (this.loopBoundNames.get(n) ?? 1) - 1;
188711
- if (c <= 0)
188712
- this.loopBoundNames.delete(n);
188713
- else
188714
- this.loopBoundNames.set(n, c);
188715
- }
188716
188686
  this.currentLoopKeyDepth = prevLoopKeyDepth;
188717
188687
  this.inLoop = prevInLoop;
188718
188688
  const bodyChildren = loop.bodyIsItemConditional && loop.key ? `{{ bf.comment("loop-i:" ~ bf.string(${this.convertExpressionToJinja(loop.key)})) | safe }}
188719
188689
  ${childrenUnderLoop}` : childrenUnderLoop;
188690
+ this.scope = prevScope;
188720
188691
  const lines = [];
188721
188692
  lines.push(`{{ bf.comment("loop:${loop.markerId}") | safe }}`);
188722
188693
  const forHeader = loop.objectIteration === "entries" ? `{% for ${minijinjaIdent(loop.index ?? param)}, ${minijinjaIdent(param)} in ${array}|items %}` : loop.objectIteration === "keys" ? `{% for ${minijinjaIdent(param)}, __bf_v in ${array}|items %}` : loop.objectIteration === "values" ? `{% for __bf_k, ${minijinjaIdent(param)} in ${array}|items %}` : `{% for ${minijinjaIdent(loopVar)} in ${array} %}`;
@@ -188948,7 +188919,7 @@ ${name}="{{ bf.string(${val}) }}"
188948
188919
  if (ternaryDict !== null) {
188949
188920
  return `{{ bf.spread_attrs(${ternaryDict}) | safe }}`;
188950
188921
  }
188951
- if (/^[A-Za-z_$][\w$]*$/.test(trimmed) && !this.loopBoundNames.has(trimmed)) {
188922
+ if (/^[A-Za-z_$][\w$]*$/.test(trimmed) && !this.scope.isBound(trimmed)) {
188952
188923
  const localConst = (this.localConstants ?? []).find((c) => c.name === trimmed && !c.isModule);
188953
188924
  if (localConst?.value !== undefined) {
188954
188925
  const initTrimmed = localConst.value.trim();
@@ -189183,7 +189154,7 @@ Options:
189183
189154
  return this.booleanTypedProps.has(bare);
189184
189155
  }
189185
189156
  isLoopBoundName(name) {
189186
- return this.loopBoundNames.has(name);
189157
+ return this.scope.isBound(name);
189187
189158
  }
189188
189159
  shouldBoolStr(expr, name) {
189189
189160
  if (isExplicitStringCall(expr))
@@ -189191,7 +189162,7 @@ Options:
189191
189162
  return isBooleanResultExpr(expr) || isAriaBooleanAttr(name) || this.isBooleanTypedPropRef(expr);
189192
189163
  }
189193
189164
  _resolveLiteralConst(name) {
189194
- if (this.staticLoopSourceBoundNames.has(name))
189165
+ if (this.scope.isBound(name))
189195
189166
  return null;
189196
189167
  const c = (this.localConstants ?? []).find((lc) => lc.name === name);
189197
189168
  if (c?.value === undefined)
@@ -189205,9 +189176,7 @@ Options:
189205
189176
  return null;
189206
189177
  }
189207
189178
  _resolveStaticRecordLiteral(objectName, key) {
189208
- if (this.staticLoopSourceBoundNames.has(objectName))
189209
- return null;
189210
- const hit = lookupStaticRecordLiteral(objectName, key, this.localConstants);
189179
+ const hit = lookupStaticRecordLiteral(objectName, key, this.localConstants, (name) => this.scope.isBound(name));
189211
189180
  if (!hit)
189212
189181
  return null;
189213
189182
  return hit.kind === "number" ? hit.text : `'${escapeMinijinjaSingleQuoted(hit.text)}'`;