@barefootjs/rust 0.33.6 → 0.35.0

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.
@@ -19,13 +19,23 @@
19
19
  * genuinely needs it, so the seam documents the real cross-module coupling
20
20
  * rather than re-exposing the whole adapter.
21
21
  */
22
- import type { ParsedExpr, CompilerError, IRMetadata } from '@barefootjs/jsx';
22
+ import type { ParsedExpr, CompilerError, IRMetadata, LoweringMatcher } from '@barefootjs/jsx';
23
23
  export interface JinjaEmitContext {
24
24
  /**
25
25
  * (#1922) Local binding names the request-scoped `searchParams()` env signal
26
26
  * is imported under. Non-empty enables the env-signal method-call lowering.
27
27
  */
28
28
  readonly _searchParamsLocals: Set<string>;
29
+ /**
30
+ * Registered lowering-plugin matchers (#2057), bound to this component's
31
+ * metadata at init. Read by `JinjaTopLevelEmitter`'s `lowering` seam
32
+ * (#2843) so a registered call — the built-in `queryHref`, or any
33
+ * userland plugin — is recognised no matter where it sits in an
34
+ * expression tree (a ternary branch, a template-literal interpolation, …),
35
+ * not only when it's the call the adapter's own top-level conversion
36
+ * entry point (`convertExpressionToJinja`) is asked to lower directly.
37
+ */
38
+ readonly _loweringMatchers: readonly LoweringMatcher[];
29
39
  /**
30
40
  * Inline a module-scope pure string-literal const by name as the resolved
31
41
  * literal value, or null when the name is not such a const.
@@ -1 +1 @@
1
- {"version":3,"file":"emit-context.d.ts","sourceRoot":"","sources":["../../src/adapter/emit-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE5E,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,QAAQ,CAAC,mBAAmB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IAEzC;;;OAGG;IACH,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAA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,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,UAAU,GAAG,MAAM,CAAA;IAEtE;;;;;;OAMG;IACH,uBAAuB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,UAAU,GAAG,MAAM,CAAA;CACtE;AAED;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;;;OAMG;IACH,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,UAAU,EAAE,GAAG,CAAC,EAAE,UAAU,GAAG,OAAO,GAAG,MAAM,CAAA;IAElG;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,MAAM,EAAE,aAAa,EAAE,CAAA;CACjC"}
@@ -47,7 +47,7 @@
47
47
  * unaffected and still used for that path plus the filter-predicate
48
48
  * entry point `_renderJinjaFilterExprPublic`.
49
49
  */
50
- import { type ParsedExprEmitter, type ArrayMethod, type LiteralType, type ParsedExpr, type ObjectLiteralProperty, type FlatDepth, type TemplatePart } from '@barefootjs/jsx';
50
+ import { type ParsedExprEmitter, type ArrayMethod, type LiteralType, type ParsedExpr, type ObjectLiteralProperty, type FlatDepth, type TemplatePart, type LoweringEmitter } from '@barefootjs/jsx';
51
51
  import type { JinjaEmitContext } from '../emit-context.ts';
52
52
  /**
53
53
  * Route a condition-TEST position through `bf.truthy(...)` unless the node
@@ -110,6 +110,16 @@ export declare class JinjaFilterEmitter implements ParsedExprEmitter {
110
110
  export declare class JinjaTopLevelEmitter implements ParsedExprEmitter {
111
111
  private readonly ctx;
112
112
  constructor(ctx: JinjaEmitContext);
113
+ /**
114
+ * Registered-lowering seam (#2843): `emitParsedExpr`'s shared `call` case
115
+ * tries every matcher here BEFORE `call()` itself, so a registered call
116
+ * (the built-in `queryHref`, or any userland plugin) is recognised no
117
+ * matter where it sits in the tree. `render` is what used to live inline
118
+ * in `MinijinjaAdapter.convertExpressionToJinja` before the object-literal
119
+ * support-gate refusal (`checkSupport`'s `call` arm, now itself
120
+ * registry-aware) made the pre-gate special case unnecessary.
121
+ */
122
+ get lowering(): LoweringEmitter;
113
123
  identifier(name: string): string;
114
124
  literal(value: string | number | boolean | null, literalType: LiteralType): string;
115
125
  member(object: ParsedExpr, property: string, _computed: boolean, _optional: boolean, emit: (e: ParsedExpr) => string): string;
@@ -1 +1 @@
1
- {"version":3,"file":"emitters.d.ts","sourceRoot":"","sources":["../../../src/adapter/expr/emitters.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AAEH,OAAO,EACL,KAAK,iBAAiB,EAEtB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,qBAAqB,EAC1B,KAAK,SAAS,EACd,KAAK,YAAY,EAIlB,MAAM,iBAAiB,CAAA;AAExB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AA+B1D;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAErE;AAED;;;;;;;;;;;;GAYG;AACH,qBAAa,kBAAmB,YAAW,iBAAiB;IAS1D,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAQ;IAC9B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAqB;IACjD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAwB;IAIrD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC,CAA4C;IAE3E,YACE,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAChC,YAAY,GAAE,CAAC,CAAC,EAAE,MAAM,KAAK,OAAqB,EAClD,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,IAAI,EAM3D;IAED,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAK/B;IAED,OAAO,C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AAW,CACT,MAAM,EAAE,WAAW,EACnB,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,UAAU,EAAE,EAClB,IAAI,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,MAAM,GAC9B,MAAM,CAER;IAED,UAAU,CACR,MAAM,EAAE,UAAU,EAClB,KAAK,EAAE,SAAS,GAAG;QAAE,IAAI,EAAE,UAAU,CAAA;KAAE,EACvC,IAAI,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,MAAM,GAC9B,MAAM,CAER;IAED,WAAW,CACT,IAAI,EAAE,UAAU,EAChB,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE,UAAU,EACrB,IAAI,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,MAAM,GAC9B,MAAM,CAER;IAED,eAAe,CAAC,KAAK,EAAE,YAAY,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,MAAM,GAAG,MAAM,CAwB9E;IAED,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,UAAU,GAAG,MAAM,CAMlD;IAED,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAG1B;IAED,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAEjD;IAED,aAAa,CAAC,UAAU,EAAE,qBAAqB,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,MAAM,GAAG,MAAM,CAuCvG;CACF"}
@@ -187307,8 +187307,6 @@ import {
187307
187307
  lookupStaticRecordLiteral,
187308
187308
  searchParamsLocalNames,
187309
187309
  prepareLoweringMatchers,
187310
- queryHrefArgs,
187311
- isValidHelperId,
187312
187310
  sortComparatorFromArrow as sortComparatorFromArrow2,
187313
187311
  isDangerousInnerHtmlAttr,
187314
187312
  resolveDangerousInnerHtml,
@@ -187677,7 +187675,9 @@ import {
187677
187675
  groupBinaryOperand,
187678
187676
  identifierPath,
187679
187677
  matchSearchParamsMethodCall,
187680
- sortComparatorFromArrow
187678
+ sortComparatorFromArrow,
187679
+ queryHrefArgs,
187680
+ isValidHelperId
187681
187681
  } from "@barefootjs/jsx";
187682
187682
  var PREDICATE_METHODS = new Set([
187683
187683
  "filter",
@@ -187806,6 +187806,21 @@ class JinjaTopLevelEmitter {
187806
187806
  constructor(ctx) {
187807
187807
  this.ctx = ctx;
187808
187808
  }
187809
+ get lowering() {
187810
+ return {
187811
+ matchers: this.ctx._loweringMatchers,
187812
+ render: (node, emit) => {
187813
+ if (node.kind === "guard-list" && node.helper === "query") {
187814
+ const qArgs = queryHrefArgs(node, emit);
187815
+ return `bf.query(${qArgs.join(", ")})`;
187816
+ }
187817
+ if (node.kind === "helper-call" && isValidHelperId(node.helper)) {
187818
+ return `bf.${node.helper}(${node.args.map(emit).join(", ")})`;
187819
+ }
187820
+ return null;
187821
+ }
187822
+ };
187823
+ }
187809
187824
  identifier(name) {
187810
187825
  if (name === "undefined" || name === "null")
187811
187826
  return "none";
@@ -188677,7 +188692,7 @@ ${whenTrue}
188677
188692
  const preambleLines = (loop.preamble?.declarations ?? []).map((d) => `{% set ${minijinjaIdent(d.name)} = ${this.convertExpressionToJinja(d.raw, d.valueParsed)} %}`);
188678
188693
  const childrenUnderLoop = this.renderChildren(loop.children);
188679
188694
  this.inLoop = prevInLoop;
188680
- const bodyChildren = loop.bodyIsItemConditional && loop.key ? `{{ bf.comment("loop-i:" ~ bf.string(${this.convertExpressionToJinja(loop.key)})) | safe }}
188695
+ const bodyChildren = loop.bodyIsItemConditional && loop.key ? `{{ bf.comment("loop-i:" ~ bf.escape_comment_key(${this.convertExpressionToJinja(loop.key)})) | safe }}
188681
188696
  ${childrenUnderLoop}` : childrenUnderLoop;
188682
188697
  this.scope = prevScope;
188683
188698
  const lines = [];
@@ -188882,8 +188897,8 @@ ${body}
188882
188897
  {
188883
188898
  const m = this.parseUndefinedAlternateTernary(value.expr);
188884
188899
  if (m) {
188885
- const cond = this.convertConditionToJinja(m.condition);
188886
- const val = this.convertExpressionToJinja(m.consequent);
188900
+ const cond = this.convertConditionToJinja("", m.testParsed);
188901
+ const val = this.convertExpressionToJinja("", m.consequentParsed);
188887
188902
  return `
188888
188903
  {% if ${cond} %}
188889
188904
  ${name}="{{ bf.string(${val}) }}"
@@ -189016,7 +189031,7 @@ ${name}="{{ bf.string(${val}) }}"
189016
189031
  if (!startsAsObjectLiteral && !hasTaggedTemplate)
189017
189032
  return false;
189018
189033
  const parsed = parseExpression2(expr.trim());
189019
- const support = isSupported(parsed);
189034
+ const support = isSupported(parsed, { loweringMatchers: this._loweringMatchers });
189020
189035
  if (parsed.kind !== "unsupported" && support.supported)
189021
189036
  return false;
189022
189037
  const reason = support.reason ?? (parsed.kind === "unsupported" ? parsed.reason : undefined);
@@ -189036,6 +189051,7 @@ ${reason}` : "";
189036
189051
  get emitCtx() {
189037
189052
  return {
189038
189053
  _searchParamsLocals: this._searchParamsLocals,
189054
+ _loweringMatchers: this._loweringMatchers,
189039
189055
  _resolveModuleStringConst: (name) => this._resolveModuleStringConst(name),
189040
189056
  _resolveLiteralConst: (name) => this._resolveLiteralConst(name),
189041
189057
  _resolveStaticRecordLiteral: (o, k) => this._resolveStaticRecordLiteral(o, k),
@@ -189069,20 +189085,8 @@ ${reason}` : "";
189069
189085
  return "''";
189070
189086
  parsed = parseExpression2(trimmed);
189071
189087
  }
189072
- if (parsed.kind === "call") {
189073
- for (const matcher of this._loweringMatchers) {
189074
- const node = matcher(parsed.callee, parsed.args);
189075
- if (node?.kind === "guard-list" && node.helper === "query") {
189076
- const qArgs = queryHrefArgs(node, (n) => this.renderParsedExprToJinja(n));
189077
- return `bf.query(${qArgs.join(", ")})`;
189078
- }
189079
- if (node?.kind === "helper-call" && isValidHelperId(node.helper)) {
189080
- const argsX = node.args.map((a) => this.renderParsedExprToJinja(a));
189081
- return `bf.${node.helper}(${argsX.join(", ")})`;
189082
- }
189083
- }
189084
- }
189085
- const support = pos === "value" ? isSupportedValue(parsed) : isSupported(parsed);
189088
+ const supportOpts = { loweringMatchers: this._loweringMatchers };
189089
+ const support = pos === "value" ? isSupportedValue(parsed, supportOpts) : isSupported(parsed, supportOpts);
189086
189090
  if (!support.supported) {
189087
189091
  this.errors.push({
189088
189092
  code: "BF101",
@@ -189127,7 +189131,9 @@ Options:
189127
189131
  return null;
189128
189132
  return {
189129
189133
  condition: exprToString(parsed.test),
189130
- consequent: exprToString(parsed.consequent)
189134
+ consequent: exprToString(parsed.consequent),
189135
+ testParsed: parsed.test,
189136
+ consequentParsed: parsed.consequent
189131
189137
  };
189132
189138
  }
189133
189139
  isBooleanTypedPropRef(expr) {
@@ -114,6 +114,7 @@
114
114
  */
115
115
  import type { ComponentIR, IRNode, IRElement, IRText, IRExpression, IRConditional, IRLoop, IRComponent, IRFragment, IRSlot, IRIfStatement, IRProvider, IRAsync, TemplatePrimitiveRegistry } from '@barefootjs/jsx';
116
116
  import { BaseAdapter, type AdapterOutput, type AdapterGenerateOptions, type IRNodeEmitter, type EmitIRNode } from '@barefootjs/jsx';
117
+ import type { ParsedExpr } from '@barefootjs/jsx';
117
118
  import type { JinjaRenderCtx } from './lib/types.ts';
118
119
  export type { MinijinjaAdapterOptions } from './lib/types.ts';
119
120
  import type { MinijinjaAdapterOptions } from './lib/types.ts';
@@ -421,6 +422,8 @@ export declare class MinijinjaAdapter extends BaseAdapter implements IRNodeEmitt
421
422
  parseUndefinedAlternateTernary(expr: string): {
422
423
  condition: string;
423
424
  consequent: string;
425
+ testParsed: ParsedExpr;
426
+ consequentParsed: ParsedExpr;
424
427
  } | null;
425
428
  isBooleanTypedPropRef(expr: string): boolean;
426
429
  /** Position-accurate loop-bound-name check — see `this.scope`'s docstring. */
@@ -1 +1 @@
1
- {"version":3,"file":"minijinja-adapter.d.ts","sourceRoot":"","sources":["../../src/adapter/minijinja-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAS,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,UAAU,CAAC;QAAC,gBAAgB,EAAE,UAAU,CAAA;KAAE,GAAG,IAAI,CAmBxG;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"}
@@ -1 +1 @@
1
- {"version":3,"file":"conformance-pins.d.ts","sourceRoot":"","sources":["../src/conformance-pins.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEtD,eAAO,MAAM,eAAe,EAAE,eA8D7B,CAAA"}
1
+ {"version":3,"file":"conformance-pins.d.ts","sourceRoot":"","sources":["../src/conformance-pins.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEtD,eAAO,MAAM,eAAe,EAAE,eAkE7B,CAAA"}
package/dist/index.js CHANGED
@@ -187307,8 +187307,6 @@ import {
187307
187307
  lookupStaticRecordLiteral,
187308
187308
  searchParamsLocalNames,
187309
187309
  prepareLoweringMatchers,
187310
- queryHrefArgs,
187311
- isValidHelperId,
187312
187310
  sortComparatorFromArrow as sortComparatorFromArrow2,
187313
187311
  isDangerousInnerHtmlAttr,
187314
187312
  resolveDangerousInnerHtml,
@@ -187677,7 +187675,9 @@ import {
187677
187675
  groupBinaryOperand,
187678
187676
  identifierPath,
187679
187677
  matchSearchParamsMethodCall,
187680
- sortComparatorFromArrow
187678
+ sortComparatorFromArrow,
187679
+ queryHrefArgs,
187680
+ isValidHelperId
187681
187681
  } from "@barefootjs/jsx";
187682
187682
  var PREDICATE_METHODS = new Set([
187683
187683
  "filter",
@@ -187806,6 +187806,21 @@ class JinjaTopLevelEmitter {
187806
187806
  constructor(ctx) {
187807
187807
  this.ctx = ctx;
187808
187808
  }
187809
+ get lowering() {
187810
+ return {
187811
+ matchers: this.ctx._loweringMatchers,
187812
+ render: (node, emit) => {
187813
+ if (node.kind === "guard-list" && node.helper === "query") {
187814
+ const qArgs = queryHrefArgs(node, emit);
187815
+ return `bf.query(${qArgs.join(", ")})`;
187816
+ }
187817
+ if (node.kind === "helper-call" && isValidHelperId(node.helper)) {
187818
+ return `bf.${node.helper}(${node.args.map(emit).join(", ")})`;
187819
+ }
187820
+ return null;
187821
+ }
187822
+ };
187823
+ }
187809
187824
  identifier(name) {
187810
187825
  if (name === "undefined" || name === "null")
187811
187826
  return "none";
@@ -188677,7 +188692,7 @@ ${whenTrue}
188677
188692
  const preambleLines = (loop.preamble?.declarations ?? []).map((d) => `{% set ${minijinjaIdent(d.name)} = ${this.convertExpressionToJinja(d.raw, d.valueParsed)} %}`);
188678
188693
  const childrenUnderLoop = this.renderChildren(loop.children);
188679
188694
  this.inLoop = prevInLoop;
188680
- const bodyChildren = loop.bodyIsItemConditional && loop.key ? `{{ bf.comment("loop-i:" ~ bf.string(${this.convertExpressionToJinja(loop.key)})) | safe }}
188695
+ const bodyChildren = loop.bodyIsItemConditional && loop.key ? `{{ bf.comment("loop-i:" ~ bf.escape_comment_key(${this.convertExpressionToJinja(loop.key)})) | safe }}
188681
188696
  ${childrenUnderLoop}` : childrenUnderLoop;
188682
188697
  this.scope = prevScope;
188683
188698
  const lines = [];
@@ -188882,8 +188897,8 @@ ${body}
188882
188897
  {
188883
188898
  const m = this.parseUndefinedAlternateTernary(value.expr);
188884
188899
  if (m) {
188885
- const cond = this.convertConditionToJinja(m.condition);
188886
- const val = this.convertExpressionToJinja(m.consequent);
188900
+ const cond = this.convertConditionToJinja("", m.testParsed);
188901
+ const val = this.convertExpressionToJinja("", m.consequentParsed);
188887
188902
  return `
188888
188903
  {% if ${cond} %}
188889
188904
  ${name}="{{ bf.string(${val}) }}"
@@ -189016,7 +189031,7 @@ ${name}="{{ bf.string(${val}) }}"
189016
189031
  if (!startsAsObjectLiteral && !hasTaggedTemplate)
189017
189032
  return false;
189018
189033
  const parsed = parseExpression2(expr.trim());
189019
- const support = isSupported(parsed);
189034
+ const support = isSupported(parsed, { loweringMatchers: this._loweringMatchers });
189020
189035
  if (parsed.kind !== "unsupported" && support.supported)
189021
189036
  return false;
189022
189037
  const reason = support.reason ?? (parsed.kind === "unsupported" ? parsed.reason : undefined);
@@ -189036,6 +189051,7 @@ ${reason}` : "";
189036
189051
  get emitCtx() {
189037
189052
  return {
189038
189053
  _searchParamsLocals: this._searchParamsLocals,
189054
+ _loweringMatchers: this._loweringMatchers,
189039
189055
  _resolveModuleStringConst: (name) => this._resolveModuleStringConst(name),
189040
189056
  _resolveLiteralConst: (name) => this._resolveLiteralConst(name),
189041
189057
  _resolveStaticRecordLiteral: (o, k) => this._resolveStaticRecordLiteral(o, k),
@@ -189069,20 +189085,8 @@ ${reason}` : "";
189069
189085
  return "''";
189070
189086
  parsed = parseExpression2(trimmed);
189071
189087
  }
189072
- if (parsed.kind === "call") {
189073
- for (const matcher of this._loweringMatchers) {
189074
- const node = matcher(parsed.callee, parsed.args);
189075
- if (node?.kind === "guard-list" && node.helper === "query") {
189076
- const qArgs = queryHrefArgs(node, (n) => this.renderParsedExprToJinja(n));
189077
- return `bf.query(${qArgs.join(", ")})`;
189078
- }
189079
- if (node?.kind === "helper-call" && isValidHelperId(node.helper)) {
189080
- const argsX = node.args.map((a) => this.renderParsedExprToJinja(a));
189081
- return `bf.${node.helper}(${argsX.join(", ")})`;
189082
- }
189083
- }
189084
- }
189085
- const support = pos === "value" ? isSupportedValue(parsed) : isSupported(parsed);
189088
+ const supportOpts = { loweringMatchers: this._loweringMatchers };
189089
+ const support = pos === "value" ? isSupportedValue(parsed, supportOpts) : isSupported(parsed, supportOpts);
189086
189090
  if (!support.supported) {
189087
189091
  this.errors.push({
189088
189092
  code: "BF101",
@@ -189127,7 +189131,9 @@ Options:
189127
189131
  return null;
189128
189132
  return {
189129
189133
  condition: exprToString(parsed.test),
189130
- consequent: exprToString(parsed.consequent)
189134
+ consequent: exprToString(parsed.consequent),
189135
+ testParsed: parsed.test,
189136
+ consequentParsed: parsed.consequent
189131
189137
  };
189132
189138
  }
189133
189139
  isBooleanTypedPropRef(expr) {
@@ -189238,9 +189244,7 @@ var conformancePins = {
189238
189244
  "namespace-import-primitive": [{ code: "BF013", severity: "error", issue: "https://github.com/piconic-ai/barefootjs/issues/2771" }]
189239
189245
  };
189240
189246
  // src/render-divergences.ts
189241
- var renderDivergences = {
189242
- "aliased-loop-source": "A `.map()` loop whose source is a local const alias of a signal getter (`const items__alias = items`) SSRs an empty `<ul>` through real minijinja — the seeded loop data is keyed by the signal's real name (`items`), and the alias hop is never resolved when deciding what to seed under `items__alias`. This is the SSR-side twin of #2778 (fixed for the CSR client-JS template in the same PR that added this fixture) — that fix only touches client-JS emission, not SSR data-seeding. Tracked at https://github.com/piconic-ai/barefootjs/issues/2813; graduate by resolving the alias hop at SSR-seeding time using the same `resolveAliasOrigin`/`resolveGetterAliases` mechanism #2778 introduced, rather than a third alias-hop walker."
189243
- };
189247
+ var renderDivergences = {};
189244
189248
  export {
189245
189249
  renderDivergences,
189246
189250
  minijinjaAdapter,
@@ -1 +1 @@
1
- {"version":3,"file":"render-divergences.d.ts","sourceRoot":"","sources":["../src/render-divergences.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAQxD,eAAO,MAAM,iBAAiB,EAAE,iBAG/B,CAAA"}
1
+ {"version":3,"file":"render-divergences.d.ts","sourceRoot":"","sources":["../src/render-divergences.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAQxD,eAAO,MAAM,iBAAiB,EAAE,iBAAsB,CAAA"}
package/dist/vite.js CHANGED
@@ -12,6 +12,41 @@ import ts10 from "typescript";
12
12
 
13
13
  // ../jsx/src/expression-parser.ts
14
14
  import ts from "typescript";
15
+
16
+ // ../jsx/src/lowering-registry.ts
17
+ var plugins = [];
18
+ function registerLoweringPlugin(plugin) {
19
+ const existing = plugins.findIndex((p) => p.name === plugin.name);
20
+ if (existing >= 0)
21
+ plugins[existing] = plugin;
22
+ else
23
+ plugins.push(plugin);
24
+ }
25
+ function prepareLoweringMatchers(metadata) {
26
+ const matchers = [];
27
+ for (const plugin of plugins) {
28
+ const matcher = plugin.prepare(metadata);
29
+ if (matcher)
30
+ matchers.push(matcher);
31
+ }
32
+ return matchers;
33
+ }
34
+ function loweringNodeChildren(node) {
35
+ if (node.kind === "helper-call")
36
+ return [...node.args];
37
+ const children = [node.base];
38
+ for (const t of node.triples) {
39
+ if (t.guard)
40
+ children.push(t.guard);
41
+ children.push(t.value);
42
+ }
43
+ return children;
44
+ }
45
+ function isValidHelperId(helper) {
46
+ return /^[A-Za-z_][A-Za-z0-9_]*$/.test(helper);
47
+ }
48
+
49
+ // ../jsx/src/expression-parser.ts
15
50
  var UNSUPPORTED_METHODS = new Set([
16
51
  "filter",
17
52
  "map",
@@ -263,7 +298,7 @@ function convertNode(node, raw) {
263
298
  }
264
299
  if (n === undefined || Number.isNaN(n)) {
265
300
  const parsedDepth = convertNode(depthNode, raw);
266
- if (checkSupport(parsedDepth, "rendered").supported) {
301
+ if (checkSupport(parsedDepth, "rendered", []).supported) {
267
302
  depthExpr = parsedDepth;
268
303
  flatDepth = 1;
269
304
  } else {
@@ -1041,13 +1076,13 @@ function getUnaryOperatorString(op) {
1041
1076
  return "unknown";
1042
1077
  }
1043
1078
  }
1044
- function isSupported(expr) {
1045
- return checkSupport(expr, "rendered");
1079
+ function isSupported(expr, opts) {
1080
+ return checkSupport(expr, "rendered", opts?.loweringMatchers ?? []);
1046
1081
  }
1047
- function isSupportedValue(expr) {
1048
- return checkSupport(expr, "value");
1082
+ function isSupportedValue(expr, opts) {
1083
+ return checkSupport(expr, "value", opts?.loweringMatchers ?? []);
1049
1084
  }
1050
- function checkSupport(expr, pos) {
1085
+ function checkSupport(expr, pos, matchers) {
1051
1086
  switch (expr.kind) {
1052
1087
  case "unsupported":
1053
1088
  return { supported: false, reason: expr.reason };
@@ -1056,7 +1091,7 @@ function checkSupport(expr, pos) {
1056
1091
  return { supported: false, reason: "Unsupported syntax: ObjectLiteralExpression" };
1057
1092
  }
1058
1093
  for (const prop of expr.properties) {
1059
- const propSupport = checkSupport(prop.kind === "spread" ? prop.expr : prop.value, pos);
1094
+ const propSupport = checkSupport(prop.kind === "spread" ? prop.expr : prop.value, pos, matchers);
1060
1095
  if (!propSupport.supported)
1061
1096
  return propSupport;
1062
1097
  }
@@ -1071,7 +1106,7 @@ function checkSupport(expr, pos) {
1071
1106
  return { supported: false, reason: "Standalone arrow functions / regex literals are not supported" };
1072
1107
  case "array-literal": {
1073
1108
  for (const el of expr.elements) {
1074
- const elSupport = checkSupport(el, pos);
1109
+ const elSupport = checkSupport(el, pos, matchers);
1075
1110
  if (!elSupport.supported)
1076
1111
  return elSupport;
1077
1112
  }
@@ -1084,28 +1119,39 @@ function checkSupport(expr, pos) {
1084
1119
  reason: `String.prototype.${expr.method} supports only a string pattern + string replacement (the regex form is deferred); use a string pattern or wrap the expression in /* @client */`
1085
1120
  };
1086
1121
  }
1087
- const objSupport = checkSupport(expr.object, pos);
1122
+ const objSupport = checkSupport(expr.object, pos, matchers);
1088
1123
  if (!objSupport.supported)
1089
1124
  return objSupport;
1090
1125
  for (const arg of expr.args) {
1091
- const argSupport = checkSupport(arg, pos);
1126
+ const argSupport = checkSupport(arg, pos, matchers);
1092
1127
  if (!argSupport.supported)
1093
1128
  return argSupport;
1094
1129
  }
1095
1130
  if (expr.method === "flat" && expr.depthExpr) {
1096
- const depthSupport = checkSupport(expr.depthExpr, pos);
1131
+ const depthSupport = checkSupport(expr.depthExpr, pos, matchers);
1097
1132
  if (!depthSupport.supported)
1098
1133
  return depthSupport;
1099
1134
  }
1100
1135
  return { supported: true, level: "L2" };
1101
1136
  }
1102
1137
  case "call": {
1138
+ for (const matcher of matchers) {
1139
+ const node = matcher(expr.callee, expr.args);
1140
+ if (!node)
1141
+ continue;
1142
+ for (const child of loweringNodeChildren(node)) {
1143
+ const childSupport = checkSupport(child, pos, matchers);
1144
+ if (!childSupport.supported)
1145
+ return childSupport;
1146
+ }
1147
+ return { supported: true, level: "L2" };
1148
+ }
1103
1149
  const cb = asCallbackMethodCall(expr);
1104
1150
  if (cb) {
1105
- const objSupport = checkSupport(cb.object, pos);
1151
+ const objSupport = checkSupport(cb.object, pos, matchers);
1106
1152
  if (!objSupport.supported)
1107
1153
  return objSupport;
1108
- const bodySupport = checkSupport(cb.arrow.body, pos);
1154
+ const bodySupport = checkSupport(cb.arrow.body, pos, matchers);
1109
1155
  if (!bodySupport.supported) {
1110
1156
  return {
1111
1157
  supported: false,
@@ -1114,13 +1160,13 @@ function checkSupport(expr, pos) {
1114
1160
  };
1115
1161
  }
1116
1162
  for (const rest of cb.args) {
1117
- const restSupport = checkSupport(rest, pos);
1163
+ const restSupport = checkSupport(rest, pos, matchers);
1118
1164
  if (!restSupport.supported)
1119
1165
  return restSupport;
1120
1166
  }
1121
1167
  return { supported: true, level: "L5" };
1122
1168
  }
1123
- const calleeSupport = checkSupport(expr.callee, pos);
1169
+ const calleeSupport = checkSupport(expr.callee, pos, matchers);
1124
1170
  if (!calleeSupport.supported) {
1125
1171
  return calleeSupport;
1126
1172
  }
@@ -1139,7 +1185,7 @@ function checkSupport(expr, pos) {
1139
1185
  return { supported: true, level: "L1" };
1140
1186
  }
1141
1187
  for (const arg of expr.args) {
1142
- const argSupport = checkSupport(arg, pos);
1188
+ const argSupport = checkSupport(arg, pos, matchers);
1143
1189
  if (!argSupport.supported) {
1144
1190
  return argSupport;
1145
1191
  }
@@ -1147,7 +1193,7 @@ function checkSupport(expr, pos) {
1147
1193
  return { supported: true, level: "L2" };
1148
1194
  }
1149
1195
  case "member": {
1150
- const objSupport = checkSupport(expr.object, pos);
1196
+ const objSupport = checkSupport(expr.object, pos, matchers);
1151
1197
  if (!objSupport.supported) {
1152
1198
  return objSupport;
1153
1199
  }
@@ -1157,19 +1203,19 @@ function checkSupport(expr, pos) {
1157
1203
  return { supported: true, level: "L2" };
1158
1204
  }
1159
1205
  case "index-access": {
1160
- const objSupport = checkSupport(expr.object, pos);
1206
+ const objSupport = checkSupport(expr.object, pos, matchers);
1161
1207
  if (!objSupport.supported)
1162
1208
  return objSupport;
1163
- const indexSupport = checkSupport(expr.index, pos);
1209
+ const indexSupport = checkSupport(expr.index, pos, matchers);
1164
1210
  if (!indexSupport.supported)
1165
1211
  return indexSupport;
1166
1212
  return { supported: true, level: "L2" };
1167
1213
  }
1168
1214
  case "binary": {
1169
- const leftSupport = checkSupport(expr.left, pos);
1215
+ const leftSupport = checkSupport(expr.left, pos, matchers);
1170
1216
  if (!leftSupport.supported)
1171
1217
  return leftSupport;
1172
- const rightSupport = checkSupport(expr.right, pos);
1218
+ const rightSupport = checkSupport(expr.right, pos, matchers);
1173
1219
  if (!rightSupport.supported)
1174
1220
  return rightSupport;
1175
1221
  if (["===", "==", "!==", "!=", ">", "<", ">=", "<="].includes(expr.op)) {
@@ -1181,7 +1227,7 @@ function checkSupport(expr, pos) {
1181
1227
  return { supported: false, reason: `Unknown operator: ${expr.op}` };
1182
1228
  }
1183
1229
  case "unary": {
1184
- const argSupport = checkSupport(expr.argument, pos);
1230
+ const argSupport = checkSupport(expr.argument, pos, matchers);
1185
1231
  if (!argSupport.supported)
1186
1232
  return argSupport;
1187
1233
  if (expr.op === "!") {
@@ -1193,25 +1239,25 @@ function checkSupport(expr, pos) {
1193
1239
  return { supported: false, reason: `Unsupported unary operator: ${expr.op}` };
1194
1240
  }
1195
1241
  case "logical": {
1196
- const leftSupport = checkSupport(expr.left, pos);
1242
+ const leftSupport = checkSupport(expr.left, pos, matchers);
1197
1243
  if (!leftSupport.supported)
1198
1244
  return leftSupport;
1199
1245
  if (expr.op === "??" && expr.right.kind === "object-literal" && expr.right.properties.length === 0) {
1200
1246
  return { supported: true, level: "L4" };
1201
1247
  }
1202
- const rightSupport = checkSupport(expr.right, pos);
1248
+ const rightSupport = checkSupport(expr.right, pos, matchers);
1203
1249
  if (!rightSupport.supported)
1204
1250
  return rightSupport;
1205
1251
  return { supported: true, level: "L4" };
1206
1252
  }
1207
1253
  case "conditional": {
1208
- const testSupport = checkSupport(expr.test, pos);
1254
+ const testSupport = checkSupport(expr.test, pos, matchers);
1209
1255
  if (!testSupport.supported)
1210
1256
  return testSupport;
1211
- const consSupport = checkSupport(expr.consequent, pos);
1257
+ const consSupport = checkSupport(expr.consequent, pos, matchers);
1212
1258
  if (!consSupport.supported)
1213
1259
  return consSupport;
1214
- const altSupport = checkSupport(expr.alternate, pos);
1260
+ const altSupport = checkSupport(expr.alternate, pos, matchers);
1215
1261
  if (!altSupport.supported)
1216
1262
  return altSupport;
1217
1263
  return { supported: true, level: "L4" };
@@ -1219,7 +1265,7 @@ function checkSupport(expr, pos) {
1219
1265
  case "template-literal": {
1220
1266
  for (const part of expr.parts) {
1221
1267
  if (part.type === "expression") {
1222
- const partSupport = checkSupport(part.expr, pos);
1268
+ const partSupport = checkSupport(part.expr, pos, matchers);
1223
1269
  if (!partSupport.supported)
1224
1270
  return partSupport;
1225
1271
  }
@@ -2280,6 +2326,12 @@ class BindingScope {
2280
2326
  }
2281
2327
  }
2282
2328
 
2329
+ // ../jsx/src/ir-to-client-js/safe-html.ts
2330
+ function safeHtml(expr) {
2331
+ return expr;
2332
+ }
2333
+ var EMPTY_MARKUP = safeHtml("''");
2334
+
2283
2335
  // ../jsx/src/ir-to-client-js/html-template.ts
2284
2336
  var VOID_ELEMENTS = new Set([
2285
2337
  "area",
@@ -2566,6 +2618,7 @@ var CLIENT_EXPORTS = new Set([
2566
2618
  "isSSRPortal",
2567
2619
  "findSiblingSlot",
2568
2620
  "cleanupPortalPlaceholder",
2621
+ "trackPosition",
2569
2622
  "createSearchParams",
2570
2623
  "queryHref",
2571
2624
  "formatDate",
@@ -2626,7 +2679,8 @@ var BROWSER_ONLY_CLIENT_APIS = new Set([
2626
2679
  "createPortal",
2627
2680
  "isSSRPortal",
2628
2681
  "findSiblingSlot",
2629
- "cleanupPortalPlaceholder"
2682
+ "cleanupPortalPlaceholder",
2683
+ "trackPosition"
2630
2684
  ]);
2631
2685
  var REACTIVE_PRIMITIVES = new Set([
2632
2686
  "createSignal",
@@ -3225,30 +3279,6 @@ import ts16 from "typescript";
3225
3279
 
3226
3280
  // ../jsx/src/relocate.ts
3227
3281
  import ts18 from "typescript";
3228
-
3229
- // ../jsx/src/lowering-registry.ts
3230
- var plugins = [];
3231
- function registerLoweringPlugin(plugin) {
3232
- const existing = plugins.findIndex((p) => p.name === plugin.name);
3233
- if (existing >= 0)
3234
- plugins[existing] = plugin;
3235
- else
3236
- plugins.push(plugin);
3237
- }
3238
- function prepareLoweringMatchers(metadata) {
3239
- const matchers = [];
3240
- for (const plugin of plugins) {
3241
- const matcher = plugin.prepare(metadata);
3242
- if (matcher)
3243
- matchers.push(matcher);
3244
- }
3245
- return matchers;
3246
- }
3247
- function isValidHelperId(helper) {
3248
- return /^[A-Za-z_][A-Za-z0-9_]*$/.test(helper);
3249
- }
3250
-
3251
- // ../jsx/src/relocate.ts
3252
3282
  var REGISTRY_SAFE_BINDING_KINDS = new Set([
3253
3283
  "global",
3254
3284
  "module-import",
@@ -4695,6 +4725,17 @@ function emitParsedExpr(expr, emitter) {
4695
4725
  case "literal":
4696
4726
  return emitter.literal(expr.value, expr.literalType);
4697
4727
  case "call": {
4728
+ if (emitter.lowering) {
4729
+ for (const matcher of emitter.lowering.matchers) {
4730
+ const node = matcher(expr.callee, expr.args);
4731
+ if (!node)
4732
+ continue;
4733
+ const rendered = emitter.lowering.render(node, emit);
4734
+ if (rendered !== null)
4735
+ return rendered;
4736
+ break;
4737
+ }
4738
+ }
4698
4739
  const cb = asCallbackMethodCall(expr);
4699
4740
  if (cb)
4700
4741
  return emitter.callbackMethod(cb.method, cb.object, cb.arrow, cb.args, emit);
@@ -5690,6 +5731,21 @@ class JinjaTopLevelEmitter {
5690
5731
  constructor(ctx) {
5691
5732
  this.ctx = ctx;
5692
5733
  }
5734
+ get lowering() {
5735
+ return {
5736
+ matchers: this.ctx._loweringMatchers,
5737
+ render: (node, emit) => {
5738
+ if (node.kind === "guard-list" && node.helper === "query") {
5739
+ const qArgs = queryHrefArgs(node, emit);
5740
+ return `bf.query(${qArgs.join(", ")})`;
5741
+ }
5742
+ if (node.kind === "helper-call" && isValidHelperId(node.helper)) {
5743
+ return `bf.${node.helper}(${node.args.map(emit).join(", ")})`;
5744
+ }
5745
+ return null;
5746
+ }
5747
+ };
5748
+ }
5693
5749
  identifier(name) {
5694
5750
  if (name === "undefined" || name === "null")
5695
5751
  return "none";
@@ -6552,7 +6608,7 @@ ${whenTrue}
6552
6608
  const preambleLines = (loop.preamble?.declarations ?? []).map((d) => `{% set ${minijinjaIdent(d.name)} = ${this.convertExpressionToJinja(d.raw, d.valueParsed)} %}`);
6553
6609
  const childrenUnderLoop = this.renderChildren(loop.children);
6554
6610
  this.inLoop = prevInLoop;
6555
- const bodyChildren = loop.bodyIsItemConditional && loop.key ? `{{ bf.comment("loop-i:" ~ bf.string(${this.convertExpressionToJinja(loop.key)})) | safe }}
6611
+ const bodyChildren = loop.bodyIsItemConditional && loop.key ? `{{ bf.comment("loop-i:" ~ bf.escape_comment_key(${this.convertExpressionToJinja(loop.key)})) | safe }}
6556
6612
  ${childrenUnderLoop}` : childrenUnderLoop;
6557
6613
  this.scope = prevScope;
6558
6614
  const lines = [];
@@ -6757,8 +6813,8 @@ ${body}
6757
6813
  {
6758
6814
  const m = this.parseUndefinedAlternateTernary(value.expr);
6759
6815
  if (m) {
6760
- const cond = this.convertConditionToJinja(m.condition);
6761
- const val = this.convertExpressionToJinja(m.consequent);
6816
+ const cond = this.convertConditionToJinja("", m.testParsed);
6817
+ const val = this.convertExpressionToJinja("", m.consequentParsed);
6762
6818
  return `
6763
6819
  {% if ${cond} %}
6764
6820
  ${name}="{{ bf.string(${val}) }}"
@@ -6891,7 +6947,7 @@ ${name}="{{ bf.string(${val}) }}"
6891
6947
  if (!startsAsObjectLiteral && !hasTaggedTemplate)
6892
6948
  return false;
6893
6949
  const parsed = parseExpression(expr.trim());
6894
- const support = isSupported(parsed);
6950
+ const support = isSupported(parsed, { loweringMatchers: this._loweringMatchers });
6895
6951
  if (parsed.kind !== "unsupported" && support.supported)
6896
6952
  return false;
6897
6953
  const reason = support.reason ?? (parsed.kind === "unsupported" ? parsed.reason : undefined);
@@ -6911,6 +6967,7 @@ ${reason}` : "";
6911
6967
  get emitCtx() {
6912
6968
  return {
6913
6969
  _searchParamsLocals: this._searchParamsLocals,
6970
+ _loweringMatchers: this._loweringMatchers,
6914
6971
  _resolveModuleStringConst: (name) => this._resolveModuleStringConst(name),
6915
6972
  _resolveLiteralConst: (name) => this._resolveLiteralConst(name),
6916
6973
  _resolveStaticRecordLiteral: (o, k) => this._resolveStaticRecordLiteral(o, k),
@@ -6944,20 +7001,8 @@ ${reason}` : "";
6944
7001
  return "''";
6945
7002
  parsed = parseExpression(trimmed);
6946
7003
  }
6947
- if (parsed.kind === "call") {
6948
- for (const matcher of this._loweringMatchers) {
6949
- const node = matcher(parsed.callee, parsed.args);
6950
- if (node?.kind === "guard-list" && node.helper === "query") {
6951
- const qArgs = queryHrefArgs(node, (n) => this.renderParsedExprToJinja(n));
6952
- return `bf.query(${qArgs.join(", ")})`;
6953
- }
6954
- if (node?.kind === "helper-call" && isValidHelperId(node.helper)) {
6955
- const argsX = node.args.map((a) => this.renderParsedExprToJinja(a));
6956
- return `bf.${node.helper}(${argsX.join(", ")})`;
6957
- }
6958
- }
6959
- }
6960
- const support = pos === "value" ? isSupportedValue(parsed) : isSupported(parsed);
7004
+ const supportOpts = { loweringMatchers: this._loweringMatchers };
7005
+ const support = pos === "value" ? isSupportedValue(parsed, supportOpts) : isSupported(parsed, supportOpts);
6961
7006
  if (!support.supported) {
6962
7007
  this.errors.push({
6963
7008
  code: "BF101",
@@ -7002,7 +7047,9 @@ Options:
7002
7047
  return null;
7003
7048
  return {
7004
7049
  condition: exprToString(parsed.test),
7005
- consequent: exprToString(parsed.consequent)
7050
+ consequent: exprToString(parsed.consequent),
7051
+ testParsed: parsed.test,
7052
+ consequentParsed: parsed.consequent
7006
7053
  };
7007
7054
  }
7008
7055
  isBooleanTypedPropRef(expr) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barefootjs/rust",
3
- "version": "0.33.6",
3
+ "version": "0.35.0",
4
4
  "description": "minijinja (Rust) adapter for BarefootJS — compiles IR to .j2 templates and ships a Rust rendering runtime (packages/adapter-rust/runtime/); runs under any Rust web framework (axum, etc.)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -54,7 +54,7 @@
54
54
  "directory": "packages/adapter-rust"
55
55
  },
56
56
  "dependencies": {
57
- "@barefootjs/shared": "0.33.6"
57
+ "@barefootjs/shared": "0.35.0"
58
58
  },
59
59
  "peerDependencies": {
60
60
  "@barefootjs/jsx": ">=0.2.0",
@@ -71,9 +71,9 @@
71
71
  },
72
72
  "devDependencies": {
73
73
  "@barefootjs/adapter-tests": "0.1.0",
74
- "@barefootjs/jsx": "0.33.6",
75
- "@barefootjs/vite": "0.33.6",
76
- "@barefootjs/client": "0.33.6",
74
+ "@barefootjs/jsx": "0.35.0",
75
+ "@barefootjs/vite": "0.35.0",
76
+ "@barefootjs/client": "0.35.0",
77
77
  "typescript": "^5.0.0",
78
78
  "vite": "^6.0.0"
79
79
  }
@@ -1416,6 +1416,20 @@ impl Object for BfInstance {
1416
1416
 
1417
1417
  // -- Comment markers -------------------------------------------
1418
1418
  "comment" => Ok(safe(format!("<!--bf-{}-->", js_string(a(0))))),
1419
+ // Neutralize a value for splicing into `comment`'s HTML comment
1420
+ // content (#2795 follow-up). `comment` itself does no escaping --
1421
+ // fine for every other caller (marker IDs like "cond-start:s0",
1422
+ // "loop:l0", ...), which are entirely compiler-generated, but the
1423
+ // whole-item-conditional loop's "loop-i:<key>" anchor carries a
1424
+ // user-controlled key. Standard HTML escaping doesn't help inside
1425
+ // a comment -- only the literal sequence "-->" terminates it
1426
+ // early, and &/</>/"/' are not special there. The key's exact
1427
+ // text doesn't need to round-trip (the client's mapArrayAnchored
1428
+ // matches items positionally and by its own JS-computed key,
1429
+ // never by re-parsing the anchor Comment.nodeValue), so replacing
1430
+ // every "-" with the visually-similar U+2010 is sufficient and
1431
+ // needs no decoding.
1432
+ "escape_comment_key" => Ok(MjValue::from(js_string(a(0)).replace('-', "‐"))),
1419
1433
  "bool_str" => Ok(MjValue::from(js_bool_str(js_truthy(a(0))))),
1420
1434
  "text_start" => Ok(safe(format!("<!--bf:{}-->", js_string(a(0))))),
1421
1435
  "text_end" => Ok(safe("<!--/-->".to_string())),
@@ -550,8 +550,8 @@ function Widget({ values }: { values: number[] }) {
550
550
  return <ul>{values.map((label) => (label > 0 ? <li key={label}>{label}</li> : null))}</ul>
551
551
  }
552
552
  `)
553
- expect(template).toContain('bf.comment("loop-i:" ~ bf.string(label))')
554
- expect(template).not.toContain("bf.comment(\"loop-i:\" ~ bf.string('x'))")
553
+ expect(template).toContain('bf.comment("loop-i:" ~ bf.escape_comment_key(label))')
554
+ expect(template).not.toContain("bf.comment(\"loop-i:\" ~ bf.escape_comment_key('x'))")
555
555
  })
556
556
 
557
557
  test('a loop param shadowing an outer const resolves to the row value inside a .map() preamble local initializer', () => {
@@ -20,7 +20,7 @@
20
20
  * rather than re-exposing the whole adapter.
21
21
  */
22
22
 
23
- import type { ParsedExpr, CompilerError, IRMetadata } from '@barefootjs/jsx'
23
+ import type { ParsedExpr, CompilerError, IRMetadata, LoweringMatcher } from '@barefootjs/jsx'
24
24
 
25
25
  export interface JinjaEmitContext {
26
26
  /**
@@ -29,6 +29,17 @@ export interface JinjaEmitContext {
29
29
  */
30
30
  readonly _searchParamsLocals: Set<string>
31
31
 
32
+ /**
33
+ * Registered lowering-plugin matchers (#2057), bound to this component's
34
+ * metadata at init. Read by `JinjaTopLevelEmitter`'s `lowering` seam
35
+ * (#2843) so a registered call — the built-in `queryHref`, or any
36
+ * userland plugin — is recognised no matter where it sits in an
37
+ * expression tree (a ternary branch, a template-literal interpolation, …),
38
+ * not only when it's the call the adapter's own top-level conversion
39
+ * entry point (`convertExpressionToJinja`) is asked to lower directly.
40
+ */
41
+ readonly _loweringMatchers: readonly LoweringMatcher[]
42
+
32
43
  /**
33
44
  * Inline a module-scope pure string-literal const by name as the resolved
34
45
  * literal value, or null when the name is not such a const.
@@ -60,6 +60,10 @@ import { groupBinaryOperand,
60
60
  identifierPath,
61
61
  matchSearchParamsMethodCall,
62
62
  sortComparatorFromArrow,
63
+ type LoweringEmitter,
64
+ type LoweringNode,
65
+ queryHrefArgs,
66
+ isValidHelperId,
63
67
  } from '@barefootjs/jsx'
64
68
 
65
69
  import type { JinjaEmitContext } from '../emit-context.ts'
@@ -314,6 +318,35 @@ export class JinjaTopLevelEmitter implements ParsedExprEmitter {
314
318
  this.ctx = ctx
315
319
  }
316
320
 
321
+ /**
322
+ * Registered-lowering seam (#2843): `emitParsedExpr`'s shared `call` case
323
+ * tries every matcher here BEFORE `call()` itself, so a registered call
324
+ * (the built-in `queryHref`, or any userland plugin) is recognised no
325
+ * matter where it sits in the tree. `render` is what used to live inline
326
+ * in `MinijinjaAdapter.convertExpressionToJinja` before the object-literal
327
+ * support-gate refusal (`checkSupport`'s `call` arm, now itself
328
+ * registry-aware) made the pre-gate special case unnecessary.
329
+ */
330
+ get lowering(): LoweringEmitter {
331
+ return {
332
+ matchers: this.ctx._loweringMatchers,
333
+ render: (node: LoweringNode, emit: (e: ParsedExpr) => string): string | null => {
334
+ // `query` guard-list — `queryHref`-shaped.
335
+ if (node.kind === 'guard-list' && node.helper === 'query') {
336
+ const qArgs = queryHrefArgs(node, emit)
337
+ return `bf.query(${qArgs.join(', ')})`
338
+ }
339
+ // Generic `helper-call` (#2069) — a userland `LoweringPlugin`'s
340
+ // single runtime-helper invocation; `bf.<helper>(args…)` mirrors
341
+ // the `query` helper's own naming convention.
342
+ if (node.kind === 'helper-call' && isValidHelperId(node.helper)) {
343
+ return `bf.${node.helper}(${node.args.map(emit).join(', ')})`
344
+ }
345
+ return null
346
+ },
347
+ }
348
+ }
349
+
317
350
  identifier(name: string): string {
318
351
  // `undefined` / `null` nested inside a larger expression tree — Jinja
319
352
  // `none` (#1897).
@@ -163,8 +163,6 @@ import {
163
163
  lookupStaticRecordLiteral,
164
164
  searchParamsLocalNames,
165
165
  prepareLoweringMatchers,
166
- queryHrefArgs,
167
- isValidHelperId,
168
166
  sortComparatorFromArrow,
169
167
  isDangerousInnerHtmlAttr,
170
168
  resolveDangerousInnerHtml,
@@ -1039,9 +1037,12 @@ export class MinijinjaAdapter extends BaseAdapter implements IRNodeEmitter<Jinja
1039
1037
  // client's `mapArrayAnchored` can hydrate every SSR-rendered item by its
1040
1038
  // anchor. Still under the row scope (see above) — `loop.key` is a
1041
1039
  // per-row expression.
1040
+ // `bf.escape_comment_key` (#2795 follow-up) both stringifies the key and
1041
+ // neutralizes `-` so it can't spell `-->` and close the comment early —
1042
+ // see its doc in `runtime.rs`.
1042
1043
  const bodyChildren =
1043
1044
  loop.bodyIsItemConditional && loop.key
1044
- ? `{{ bf.comment("loop-i:" ~ bf.string(${this.convertExpressionToJinja(loop.key)})) | safe }}\n${childrenUnderLoop}`
1045
+ ? `{{ bf.comment("loop-i:" ~ bf.escape_comment_key(${this.convertExpressionToJinja(loop.key)})) | safe }}\n${childrenUnderLoop}`
1045
1046
  : childrenUnderLoop
1046
1047
  this.scope = prevScope
1047
1048
 
@@ -1482,8 +1483,8 @@ export class MinijinjaAdapter extends BaseAdapter implements IRNodeEmitter<Jinja
1482
1483
  {
1483
1484
  const m = this.parseUndefinedAlternateTernary(value.expr)
1484
1485
  if (m) {
1485
- const cond = this.convertConditionToJinja(m.condition)
1486
- const val = this.convertExpressionToJinja(m.consequent)
1486
+ const cond = this.convertConditionToJinja('', m.testParsed)
1487
+ const val = this.convertExpressionToJinja('', m.consequentParsed)
1487
1488
  return `\n{% if ${cond} %}\n${name}="{{ bf.string(${val}) }}"\n{% endif %}\n`
1488
1489
  }
1489
1490
  }
@@ -1751,7 +1752,7 @@ export class MinijinjaAdapter extends BaseAdapter implements IRNodeEmitter<Jinja
1751
1752
  const hasTaggedTemplate = /[A-Za-z_$][\w$]*\s*`/.test(probe)
1752
1753
  if (!startsAsObjectLiteral && !hasTaggedTemplate) return false
1753
1754
  const parsed = parseExpression(expr.trim())
1754
- const support = isSupported(parsed)
1755
+ const support = isSupported(parsed, { loweringMatchers: this._loweringMatchers })
1755
1756
  if (parsed.kind !== 'unsupported' && support.supported) return false
1756
1757
  const reason = support.reason ?? (parsed.kind === 'unsupported' ? parsed.reason : undefined)
1757
1758
  const reasonLine = reason ? `\n${reason}` : ''
@@ -1778,6 +1779,7 @@ export class MinijinjaAdapter extends BaseAdapter implements IRNodeEmitter<Jinja
1778
1779
  private get emitCtx(): JinjaEmitContext {
1779
1780
  return {
1780
1781
  _searchParamsLocals: this._searchParamsLocals,
1782
+ _loweringMatchers: this._loweringMatchers,
1781
1783
  _resolveModuleStringConst: (name) => this._resolveModuleStringConst(name),
1782
1784
  _resolveLiteralConst: (name) => this._resolveLiteralConst(name),
1783
1785
  _resolveStaticRecordLiteral: (o, k) => this._resolveStaticRecordLiteral(o, k),
@@ -1832,42 +1834,16 @@ export class MinijinjaAdapter extends BaseAdapter implements IRNodeEmitter<Jinja
1832
1834
  parsed = parseExpression(trimmed)
1833
1835
  }
1834
1836
 
1835
- // Registered call lowerings (#2057) — including the built-in `queryHref`
1836
- // plugin (#2042), which lowers `queryHref(base, { … })` to a neutral
1837
- // `guard-list` on the `query` helper → `bf.query(base, <triples>)`.
1838
- // Recognised before the support gate because the object-literal arg is
1839
- // otherwise `unsupported` (BF101). The `query` helper includes a pair iff its
1840
- // guard is truthy AND its value is a non-empty string (the client's
1841
- // `if (value)`): a plain `key: v` passes guard `true`, a conditional
1842
- // `key: cond ? v : undefined` passes the lowered cond. Only the `query`
1843
- // helper renders to `bf.query`; another guard-list helper must not be
1844
- // silently mis-rendered as a query.
1845
- if (parsed.kind === 'call') {
1846
- for (const matcher of this._loweringMatchers) {
1847
- const node = matcher(parsed.callee, parsed.args)
1848
- if (node?.kind === 'guard-list' && node.helper === 'query') {
1849
- const qArgs = queryHrefArgs(node, n => this.renderParsedExprToJinja(n))
1850
- return `bf.query(${qArgs.join(', ')})`
1851
- }
1852
- // Generic `helper-call` (#2069) — the neutral vocabulary's escape
1853
- // hatch for a userland `LoweringPlugin` that lowers to a single
1854
- // runtime-helper invocation. `bf.<helper>(args…)` mirrors the
1855
- // `query` helper's own naming convention exactly: the framework
1856
- // renders the call, the plugin author registers `<helper>` as a
1857
- // MiniJinja-callable function in their own runtime — same contract
1858
- // as `bf.query` itself, just not built in.
1859
- if (node?.kind === 'helper-call' && isValidHelperId(node.helper)) {
1860
- const argsX = node.args.map(a => this.renderParsedExprToJinja(a))
1861
- return `bf.${node.helper}(${argsX.join(', ')})`
1862
- }
1863
- }
1864
- }
1865
-
1866
1837
  // `pos` distinguishes a derived-seed RHS (an assignment, checked via
1867
1838
  // `isSupportedValue`) from every other, genuinely rendered call site —
1868
1839
  // the rendered gate would otherwise re-refuse a tree the seed plan
1869
1840
  // already classified `derived` at value position (#2696 review).
1870
- const support = pos === 'value' ? isSupportedValue(parsed) : isSupported(parsed)
1841
+ // Registered call lowerings (#2057) including the built-in `queryHref`
1842
+ // plugin — are consulted by this gate no matter where the call sits in
1843
+ // the tree (`JinjaTopLevelEmitter`'s `lowering` seam does the actual
1844
+ // rendering below, via `emitParsedExpr`'s shared `call` case).
1845
+ const supportOpts = { loweringMatchers: this._loweringMatchers }
1846
+ const support = pos === 'value' ? isSupportedValue(parsed, supportOpts) : isSupported(parsed, supportOpts)
1871
1847
  if (!support.supported) {
1872
1848
  this.errors.push({
1873
1849
  code: 'BF101',
@@ -1936,7 +1912,7 @@ export class MinijinjaAdapter extends BaseAdapter implements IRNodeEmitter<Jinja
1936
1912
  */
1937
1913
  parseUndefinedAlternateTernary(
1938
1914
  expr: string,
1939
- ): { condition: string; consequent: string } | null {
1915
+ ): { condition: string; consequent: string; testParsed: ParsedExpr; consequentParsed: ParsedExpr } | null {
1940
1916
  const parsed = parseExpression(expr.trim())
1941
1917
  if (parsed?.kind !== 'conditional') return null
1942
1918
  const alt = parsed.alternate
@@ -1944,13 +1920,16 @@ export class MinijinjaAdapter extends BaseAdapter implements IRNodeEmitter<Jinja
1944
1920
  (alt.kind === 'identifier' && (alt.name === 'undefined' || alt.name === 'null')) ||
1945
1921
  (alt.kind === 'literal' && (alt.value === null || alt.value === undefined))
1946
1922
  if (!isUndef) return null
1947
- // Serialise the parsed sub-expressions back to JS source rather than
1948
- // slicing `expr` text `indexOf('?')` / `lastIndexOf(':')` would
1949
- // mis-split when the consequent itself contains `?` / `:` inside a
1950
- // string or nested ternary (`cond ? 'a:b' : undefined`).
1923
+ // `condition`/`consequent` are DEBUG text only (`exprToString` renders an
1924
+ // unsupported nested shape like an object literal as non-reparseable
1925
+ // `[UNSUPPORTED: …]` text) callers that need to re-lower the
1926
+ // sub-expression must use `testParsed`/`consequentParsed` (the actual
1927
+ // parsed trees) as `preParsed`, not re-parse these strings.
1951
1928
  return {
1952
1929
  condition: exprToString(parsed.test),
1953
1930
  consequent: exprToString(parsed.consequent),
1931
+ testParsed: parsed.test,
1932
+ consequentParsed: parsed.consequent,
1954
1933
  }
1955
1934
  }
1956
1935
 
@@ -10,6 +10,10 @@
10
10
  import type { ConformancePins } from '@barefootjs/jsx'
11
11
 
12
12
  export const conformancePins: ConformancePins = {
13
+ // #2843: graduated — a registered lowering call inside a ternary
14
+ // attribute branch (or any nested value position) is now recognised via
15
+ // `JinjaTopLevelEmitter`'s `lowering` seam + the registry-aware support
16
+ // gate, matching the direct-call attribute path exactly.
13
17
  'filter-typeof-predicate': [{ code: 'BF021', severity: 'error' }],
14
18
  'map-array-builder-body': [{ code: 'BF021', severity: 'error' }],
15
19
  'map-array-builder-escaping': [{ code: 'BF021', severity: 'error' }],
@@ -17,7 +17,4 @@ import type { RenderDivergences } from '@barefootjs/jsx'
17
17
  // at value position and the runtime evaluator's `object-literal` case
18
18
  // now merges it, so the seed classifies `derived` and SSRs identically
19
19
  // to Hono.
20
- export const renderDivergences: RenderDivergences = {
21
- 'aliased-loop-source':
22
- 'A `.map()` loop whose source is a local const alias of a signal getter (`const items__alias = items`) SSRs an empty `<ul>` through real minijinja — the seeded loop data is keyed by the signal\'s real name (`items`), and the alias hop is never resolved when deciding what to seed under `items__alias`. This is the SSR-side twin of #2778 (fixed for the CSR client-JS template in the same PR that added this fixture) — that fix only touches client-JS emission, not SSR data-seeding. Tracked at https://github.com/piconic-ai/barefootjs/issues/2813; graduate by resolving the alias hop at SSR-seeding time using the same `resolveAliasOrigin`/`resolveGetterAliases` mechanism #2778 introduced, rather than a third alias-hop walker.',
23
- }
20
+ export const renderDivergences: RenderDivergences = {}
@@ -519,6 +519,20 @@ function buildVars(
519
519
  }
520
520
  }
521
521
 
522
+ // #2813: `extractSsrDefaults` can seed an entry under a name that is
523
+ // none of `propsParams` / `signals` / `memos` above — a bare local-const
524
+ // alias of a signal/memo getter (`const items__alias = items`,
525
+ // `ssr-defaults.ts`) seeds `items__alias` alongside `items`. Production
526
+ // hands the whole manifest-derived stash straight through
527
+ // (`deriveStashFromDefaults` IS the production seeding mechanism here,
528
+ // not a harness stand-in), so any leftover `derivedProps` key must be
529
+ // copied too, or this harness would silently omit what production
530
+ // actually provides, mismeasuring this conformance case.
531
+ for (const [name, value] of Object.entries(derivedProps)) {
532
+ if (Object.prototype.hasOwnProperty.call(vars, name)) continue
533
+ vars[name] = value
534
+ }
535
+
522
536
  return vars
523
537
  }
524
538