@barefootjs/jinja 0.34.0 → 0.35.1
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 +1 -1
- package/dist/adapter/jinja-adapter.d.ts.map +1 -1
- package/dist/conformance-pins.d.ts.map +1 -1
- package/dist/index.js +5 -7
- package/dist/render-divergences.d.ts.map +1 -1
- package/dist/vite.js +38 -30
- package/package.json +5 -5
- package/python/barefootjs/runtime.py +16 -0
- package/src/__tests__/jinja-adapter-unit.test.ts +2 -2
- package/src/adapter/jinja-adapter.ts +4 -1
- package/src/conformance-pins.ts +13 -7
- package/src/render-divergences.ts +1 -4
- package/src/test-render.ts +20 -0
package/dist/adapter/index.js
CHANGED
|
@@ -188692,7 +188692,7 @@ ${whenTrue}
|
|
|
188692
188692
|
const preambleLines = (loop.preamble?.declarations ?? []).map((d) => `{% set ${jinjaIdent(d.name)} = ${this.convertExpressionToJinja(d.raw, d.valueParsed)} %}`);
|
|
188693
188693
|
const childrenUnderLoop = this.renderChildren(loop.children);
|
|
188694
188694
|
this.inLoop = prevInLoop;
|
|
188695
|
-
const bodyChildren = loop.bodyIsItemConditional && loop.key ? `{{ bf.comment("loop-i:" ~ bf.
|
|
188695
|
+
const bodyChildren = loop.bodyIsItemConditional && loop.key ? `{{ bf.comment("loop-i:" ~ bf.escape_comment_key(${this.convertExpressionToJinja(loop.key)})) | safe }}
|
|
188696
188696
|
${childrenUnderLoop}` : childrenUnderLoop;
|
|
188697
188697
|
this.scope = prevScope;
|
|
188698
188698
|
const lines = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jinja-adapter.d.ts","sourceRoot":"","sources":["../../src/adapter/jinja-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwFG;AAEH,OAAO,KAAK,EAC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E,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;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEtD,eAAO,MAAM,eAAe,EAAE,eAuE7B,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -188692,7 +188692,7 @@ ${whenTrue}
|
|
|
188692
188692
|
const preambleLines = (loop.preamble?.declarations ?? []).map((d) => `{% set ${jinjaIdent(d.name)} = ${this.convertExpressionToJinja(d.raw, d.valueParsed)} %}`);
|
|
188693
188693
|
const childrenUnderLoop = this.renderChildren(loop.children);
|
|
188694
188694
|
this.inLoop = prevInLoop;
|
|
188695
|
-
const bodyChildren = loop.bodyIsItemConditional && loop.key ? `{{ bf.comment("loop-i:" ~ bf.
|
|
188695
|
+
const bodyChildren = loop.bodyIsItemConditional && loop.key ? `{{ bf.comment("loop-i:" ~ bf.escape_comment_key(${this.convertExpressionToJinja(loop.key)})) | safe }}
|
|
188696
188696
|
${childrenUnderLoop}` : childrenUnderLoop;
|
|
188697
188697
|
this.scope = prevScope;
|
|
188698
188698
|
const lines = [];
|
|
@@ -189239,14 +189239,12 @@ var conformancePins = {
|
|
|
189239
189239
|
"filter-nested-find-predicate": [{ code: "BF101", severity: "error", issue: "https://github.com/piconic-ai/barefootjs/issues/2320" }],
|
|
189240
189240
|
"date-method-uncatalogued": [{ code: "BF021", severity: "error", issue: "https://github.com/piconic-ai/barefootjs/issues/2356" }],
|
|
189241
189241
|
"rich-prop-client-read": [{ code: "BF049", severity: "error", issue: "https://github.com/piconic-ai/barefootjs/issues/2648" }],
|
|
189242
|
-
"jsx-element-prop-ternary": [{ code: "BF021", severity: "error"
|
|
189243
|
-
"jsx-element-prop-array": [{ code: "BF021", severity: "error"
|
|
189244
|
-
"namespace-import-primitive": [{ code: "BF013", severity: "error"
|
|
189242
|
+
"jsx-element-prop-ternary": [{ code: "BF021", severity: "error" }],
|
|
189243
|
+
"jsx-element-prop-array": [{ code: "BF021", severity: "error" }],
|
|
189244
|
+
"namespace-import-primitive": [{ code: "BF013", severity: "error" }]
|
|
189245
189245
|
};
|
|
189246
189246
|
// src/render-divergences.ts
|
|
189247
|
-
var renderDivergences = {
|
|
189248
|
-
"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>` on real Jinja2 — 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."
|
|
189249
|
-
};
|
|
189247
|
+
var renderDivergences = {};
|
|
189250
189248
|
export {
|
|
189251
189249
|
renderDivergences,
|
|
189252
189250
|
jinjaAdapter,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-divergences.d.ts","sourceRoot":"","sources":["../src/render-divergences.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAQxD,eAAO,MAAM,iBAAiB,EAAE,
|
|
1
|
+
{"version":3,"file":"render-divergences.d.ts","sourceRoot":"","sources":["../src/render-divergences.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAQxD,eAAO,MAAM,iBAAiB,EAAE,iBAAsB,CAAA"}
|
package/dist/vite.js
CHANGED
|
@@ -8,7 +8,7 @@ import { devModuleUrl, loadManifest, resolveDevOrigin, resolveScriptAssets, toPo
|
|
|
8
8
|
import ts25 from "typescript";
|
|
9
9
|
|
|
10
10
|
// ../jsx/src/analyzer.ts
|
|
11
|
-
import
|
|
11
|
+
import ts11 from "typescript";
|
|
12
12
|
|
|
13
13
|
// ../jsx/src/expression-parser.ts
|
|
14
14
|
import ts from "typescript";
|
|
@@ -2326,6 +2326,12 @@ class BindingScope {
|
|
|
2326
2326
|
}
|
|
2327
2327
|
}
|
|
2328
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
|
+
|
|
2329
2335
|
// ../jsx/src/ir-to-client-js/html-template.ts
|
|
2330
2336
|
var VOID_ELEMENTS = new Set([
|
|
2331
2337
|
"area",
|
|
@@ -2383,14 +2389,17 @@ function freshCounters() {
|
|
|
2383
2389
|
}
|
|
2384
2390
|
|
|
2385
2391
|
// ../jsx/src/analyzer-context.ts
|
|
2386
|
-
import
|
|
2392
|
+
import ts10 from "typescript";
|
|
2387
2393
|
|
|
2388
2394
|
// ../jsx/src/strip-types.ts
|
|
2389
2395
|
import ts8 from "typescript";
|
|
2390
2396
|
|
|
2397
|
+
// ../jsx/src/reactivity-checker.ts
|
|
2398
|
+
import ts9 from "typescript";
|
|
2399
|
+
|
|
2391
2400
|
// ../jsx/src/analyzer-context.ts
|
|
2392
|
-
var _typePrinter =
|
|
2393
|
-
var _blankTypeSourceFile =
|
|
2401
|
+
var _typePrinter = ts10.createPrinter({ removeComments: true, omitTrailingSemicolon: true });
|
|
2402
|
+
var _blankTypeSourceFile = ts10.createSourceFile("__bf_types__.ts", "", ts10.ScriptTarget.Latest);
|
|
2394
2403
|
|
|
2395
2404
|
// ../jsx/src/errors.ts
|
|
2396
2405
|
var ErrorCodes = {
|
|
@@ -2612,6 +2621,7 @@ var CLIENT_EXPORTS = new Set([
|
|
|
2612
2621
|
"isSSRPortal",
|
|
2613
2622
|
"findSiblingSlot",
|
|
2614
2623
|
"cleanupPortalPlaceholder",
|
|
2624
|
+
"trackPosition",
|
|
2615
2625
|
"createSearchParams",
|
|
2616
2626
|
"queryHref",
|
|
2617
2627
|
"formatDate",
|
|
@@ -2622,46 +2632,46 @@ function extractFreeIdentifiersFromNode(node) {
|
|
|
2622
2632
|
const ids = new Set;
|
|
2623
2633
|
const boundNames = new Set;
|
|
2624
2634
|
function addBindingNames(name, out) {
|
|
2625
|
-
if (
|
|
2635
|
+
if (ts11.isIdentifier(name))
|
|
2626
2636
|
out.push(name.text);
|
|
2627
|
-
else if (
|
|
2637
|
+
else if (ts11.isObjectBindingPattern(name))
|
|
2628
2638
|
name.elements.forEach((e) => addBindingNames(e.name, out));
|
|
2629
|
-
else if (
|
|
2639
|
+
else if (ts11.isArrayBindingPattern(name))
|
|
2630
2640
|
name.elements.forEach((e) => {
|
|
2631
|
-
if (!
|
|
2641
|
+
if (!ts11.isOmittedExpression(e))
|
|
2632
2642
|
addBindingNames(e.name, out);
|
|
2633
2643
|
});
|
|
2634
2644
|
}
|
|
2635
2645
|
function visit(n) {
|
|
2636
|
-
if (
|
|
2646
|
+
if (ts11.isTypeNode(n))
|
|
2637
2647
|
return;
|
|
2638
|
-
if (
|
|
2648
|
+
if (ts11.isIdentifier(n)) {
|
|
2639
2649
|
const parent = n.parent;
|
|
2640
|
-
if (parent &&
|
|
2650
|
+
if (parent && ts11.isPropertyAccessExpression(parent) && parent.name === n)
|
|
2641
2651
|
return;
|
|
2642
|
-
if (parent &&
|
|
2652
|
+
if (parent && ts11.isPropertyAssignment(parent) && parent.name === n)
|
|
2643
2653
|
return;
|
|
2644
|
-
if (parent &&
|
|
2654
|
+
if (parent && ts11.isParameter(parent) && parent.name === n)
|
|
2645
2655
|
return;
|
|
2646
|
-
if (parent &&
|
|
2656
|
+
if (parent && ts11.isVariableDeclaration(parent) && parent.name === n)
|
|
2647
2657
|
return;
|
|
2648
2658
|
if (boundNames.has(n.text))
|
|
2649
2659
|
return;
|
|
2650
2660
|
ids.add(n.text);
|
|
2651
2661
|
return;
|
|
2652
2662
|
}
|
|
2653
|
-
if (
|
|
2663
|
+
if (ts11.isArrowFunction(n)) {
|
|
2654
2664
|
const params = [];
|
|
2655
2665
|
for (const p of n.parameters)
|
|
2656
2666
|
addBindingNames(p.name, params);
|
|
2657
2667
|
for (const name of params)
|
|
2658
2668
|
boundNames.add(name);
|
|
2659
|
-
|
|
2669
|
+
ts11.forEachChild(n, visit);
|
|
2660
2670
|
for (const name of params)
|
|
2661
2671
|
boundNames.delete(name);
|
|
2662
2672
|
return;
|
|
2663
2673
|
}
|
|
2664
|
-
|
|
2674
|
+
ts11.forEachChild(n, visit);
|
|
2665
2675
|
}
|
|
2666
2676
|
visit(node);
|
|
2667
2677
|
return ids;
|
|
@@ -2672,7 +2682,8 @@ var BROWSER_ONLY_CLIENT_APIS = new Set([
|
|
|
2672
2682
|
"createPortal",
|
|
2673
2683
|
"isSSRPortal",
|
|
2674
2684
|
"findSiblingSlot",
|
|
2675
|
-
"cleanupPortalPlaceholder"
|
|
2685
|
+
"cleanupPortalPlaceholder",
|
|
2686
|
+
"trackPosition"
|
|
2676
2687
|
]);
|
|
2677
2688
|
var REACTIVE_PRIMITIVES = new Set([
|
|
2678
2689
|
"createSignal",
|
|
@@ -2734,7 +2745,7 @@ function preambleAnalysisTemplateText(p) {
|
|
|
2734
2745
|
}
|
|
2735
2746
|
|
|
2736
2747
|
// ../jsx/src/module-exports.ts
|
|
2737
|
-
import
|
|
2748
|
+
import ts12 from "typescript";
|
|
2738
2749
|
function formatParamWithType(p) {
|
|
2739
2750
|
const rest = p.isRest ? "..." : "";
|
|
2740
2751
|
const optional = p.optional ? "?" : "";
|
|
@@ -2769,21 +2780,21 @@ function findAssignedNames(bodyText, candidates) {
|
|
|
2769
2780
|
const assigned = new Set;
|
|
2770
2781
|
if (candidates.size === 0)
|
|
2771
2782
|
return assigned;
|
|
2772
|
-
const sf =
|
|
2783
|
+
const sf = ts12.createSourceFile("bf-assignment-scan.tsx", bodyText, ts12.ScriptTarget.Latest, false, ts12.ScriptKind.TSX);
|
|
2773
2784
|
const record = (target) => {
|
|
2774
|
-
if (
|
|
2785
|
+
if (ts12.isIdentifier(target) && candidates.has(target.text)) {
|
|
2775
2786
|
assigned.add(target.text);
|
|
2776
2787
|
}
|
|
2777
2788
|
};
|
|
2778
2789
|
const visit = (node) => {
|
|
2779
|
-
if (
|
|
2790
|
+
if (ts12.isBinaryExpression(node) && isAssignmentOperator(node.operatorToken.kind)) {
|
|
2780
2791
|
record(node.left);
|
|
2781
|
-
} else if ((
|
|
2792
|
+
} else if ((ts12.isPrefixUnaryExpression(node) || ts12.isPostfixUnaryExpression(node)) && (node.operator === ts12.SyntaxKind.PlusPlusToken || node.operator === ts12.SyntaxKind.MinusMinusToken)) {
|
|
2782
2793
|
record(node.operand);
|
|
2783
2794
|
}
|
|
2784
|
-
|
|
2795
|
+
ts12.forEachChild(node, visit);
|
|
2785
2796
|
};
|
|
2786
|
-
|
|
2797
|
+
ts12.forEachChild(sf, visit);
|
|
2787
2798
|
return assigned;
|
|
2788
2799
|
}
|
|
2789
2800
|
function closeOverWritersOfMutableBindings(primaryRefs, declarations, mutableNames) {
|
|
@@ -2806,12 +2817,9 @@ function closeOverWritersOfMutableBindings(primaryRefs, declarations, mutableNam
|
|
|
2806
2817
|
return reachable;
|
|
2807
2818
|
}
|
|
2808
2819
|
function isAssignmentOperator(kind) {
|
|
2809
|
-
return kind >=
|
|
2820
|
+
return kind >= ts12.SyntaxKind.FirstAssignment && kind <= ts12.SyntaxKind.LastAssignment;
|
|
2810
2821
|
}
|
|
2811
2822
|
|
|
2812
|
-
// ../jsx/src/reactivity-checker.ts
|
|
2813
|
-
import ts12 from "typescript";
|
|
2814
|
-
|
|
2815
2823
|
// ../jsx/src/free-refs.ts
|
|
2816
2824
|
import ts13 from "typescript";
|
|
2817
2825
|
var _bindingMapCache = new WeakMap;
|
|
@@ -6619,7 +6627,7 @@ ${whenTrue}
|
|
|
6619
6627
|
const preambleLines = (loop.preamble?.declarations ?? []).map((d) => `{% set ${jinjaIdent(d.name)} = ${this.convertExpressionToJinja(d.raw, d.valueParsed)} %}`);
|
|
6620
6628
|
const childrenUnderLoop = this.renderChildren(loop.children);
|
|
6621
6629
|
this.inLoop = prevInLoop;
|
|
6622
|
-
const bodyChildren = loop.bodyIsItemConditional && loop.key ? `{{ bf.comment("loop-i:" ~ bf.
|
|
6630
|
+
const bodyChildren = loop.bodyIsItemConditional && loop.key ? `{{ bf.comment("loop-i:" ~ bf.escape_comment_key(${this.convertExpressionToJinja(loop.key)})) | safe }}
|
|
6623
6631
|
${childrenUnderLoop}` : childrenUnderLoop;
|
|
6624
6632
|
this.scope = prevScope;
|
|
6625
6633
|
const lines = [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@barefootjs/jinja",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.35.1",
|
|
4
4
|
"description": "Jinja2 adapter for BarefootJS — compiles IR to .jinja templates and ships the Python BarefootJS rendering runtime; runs under any Python web framework (Flask, etc.)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"directory": "packages/adapter-jinja"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@barefootjs/shared": "0.
|
|
56
|
+
"@barefootjs/shared": "0.35.1"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
59
|
"@barefootjs/jsx": ">=0.2.0",
|
|
@@ -70,9 +70,9 @@
|
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"@barefootjs/adapter-tests": "0.1.0",
|
|
73
|
-
"@barefootjs/jsx": "0.
|
|
74
|
-
"@barefootjs/vite": "0.
|
|
75
|
-
"@barefootjs/client": "0.
|
|
73
|
+
"@barefootjs/jsx": "0.35.1",
|
|
74
|
+
"@barefootjs/vite": "0.35.1",
|
|
75
|
+
"@barefootjs/client": "0.35.1",
|
|
76
76
|
"typescript": "^5.0.0",
|
|
77
77
|
"vite": "^6.0.0"
|
|
78
78
|
}
|
|
@@ -659,6 +659,22 @@ class BarefootJS:
|
|
|
659
659
|
def comment(self, text: str) -> str:
|
|
660
660
|
return f"<!--bf-{text}-->"
|
|
661
661
|
|
|
662
|
+
def escape_comment_key(self, value: Any) -> str:
|
|
663
|
+
"""Neutralize a value for splicing into `comment`'s HTML comment
|
|
664
|
+
content (#2795 follow-up). `comment` itself does no escaping --
|
|
665
|
+
fine for every other caller (marker IDs like "cond-start:s0",
|
|
666
|
+
"loop:l0", ...), which are entirely compiler-generated, but the
|
|
667
|
+
whole-item-conditional loop's "loop-i:<key>" anchor carries a
|
|
668
|
+
user-controlled key. Standard HTML escaping doesn't help inside a
|
|
669
|
+
comment -- only the literal sequence "-->" terminates it early, and
|
|
670
|
+
&/</>/"/' are not special there. The key's exact text doesn't need
|
|
671
|
+
to round-trip (the client's mapArrayAnchored matches items
|
|
672
|
+
positionally and by its own JS-computed key, never by re-parsing
|
|
673
|
+
the anchor Comment.nodeValue), so replacing every "-" with the
|
|
674
|
+
visually-similar U+2010 is sufficient and needs no decoding.
|
|
675
|
+
"""
|
|
676
|
+
return self.string(value).replace("-", "‐")
|
|
677
|
+
|
|
662
678
|
# -----------------------------------------------------------------
|
|
663
679
|
# JS-equivalent value stringification
|
|
664
680
|
# -----------------------------------------------------------------
|
|
@@ -549,8 +549,8 @@ function Widget({ values }: { values: number[] }) {
|
|
|
549
549
|
return <ul>{values.map((label) => (label > 0 ? <li key={label}>{label}</li> : null))}</ul>
|
|
550
550
|
}
|
|
551
551
|
`)
|
|
552
|
-
expect(template).toContain('bf.comment("loop-i:" ~ bf.
|
|
553
|
-
expect(template).not.toContain("bf.comment(\"loop-i:\" ~ bf.
|
|
552
|
+
expect(template).toContain('bf.comment("loop-i:" ~ bf.escape_comment_key(label))')
|
|
553
|
+
expect(template).not.toContain("bf.comment(\"loop-i:\" ~ bf.escape_comment_key('x'))")
|
|
554
554
|
})
|
|
555
555
|
|
|
556
556
|
test('a loop param shadowing an outer const resolves to the row value inside a .map() preamble local initializer', () => {
|
|
@@ -993,9 +993,12 @@ export class JinjaAdapter extends BaseAdapter implements IRNodeEmitter<JinjaRend
|
|
|
993
993
|
// client's `mapArrayAnchored` can hydrate every SSR-rendered item by its
|
|
994
994
|
// anchor. Still under the row scope (see above) — `loop.key` is a
|
|
995
995
|
// per-row expression.
|
|
996
|
+
// `bf.escape_comment_key` (#2795 follow-up) both stringifies the key and
|
|
997
|
+
// neutralizes `-` so it can't spell `-->` and close the comment early —
|
|
998
|
+
// see its doc in `runtime.py`.
|
|
996
999
|
const bodyChildren =
|
|
997
1000
|
loop.bodyIsItemConditional && loop.key
|
|
998
|
-
? `{{ bf.comment("loop-i:" ~ bf.
|
|
1001
|
+
? `{{ bf.comment("loop-i:" ~ bf.escape_comment_key(${this.convertExpressionToJinja(loop.key)})) | safe }}\n${childrenUnderLoop}`
|
|
999
1002
|
: childrenUnderLoop
|
|
1000
1003
|
this.scope = prevScope
|
|
1001
1004
|
|
package/src/conformance-pins.ts
CHANGED
|
@@ -60,18 +60,24 @@ export const conformancePins: ConformancePins = {
|
|
|
60
60
|
// above is refused.
|
|
61
61
|
'date-method-uncatalogued': [{ code: 'BF021', severity: 'error', issue: 'https://github.com/piconic-ai/barefootjs/issues/2356' }],
|
|
62
62
|
'rich-prop-client-read': [{ code: 'BF049', severity: 'error', issue: 'https://github.com/piconic-ai/barefootjs/issues/2648' }],
|
|
63
|
-
//
|
|
63
|
+
// A ternary or array literal LITERALLY WRAPPING JSX at a non-children prop
|
|
64
64
|
// position (e.g. `header={cond ? <a/> : <b/>}`) is refused ahead of
|
|
65
65
|
// `adapter.generate()` in the shared jsx-to-ir.ts phase, so it is pinned
|
|
66
66
|
// identically on every adapter (including Hono) — same reasoning as
|
|
67
|
-
// `rich-prop-client-read` above.
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
//
|
|
67
|
+
// `rich-prop-client-read` above. This is the permanent, intended behavior
|
|
68
|
+
// (formerly tracked as #2667, closed): the issue's own acceptance criteria
|
|
69
|
+
// treated a loud refusal as fully resolving the silent-divergence bug, so
|
|
70
|
+
// no open issue tracks further work here.
|
|
71
|
+
'jsx-element-prop-ternary': [{ code: 'BF021', severity: 'error' }],
|
|
72
|
+
'jsx-element-prop-array': [{ code: 'BF021', severity: 'error' }],
|
|
73
|
+
// A reactive primitive invoked through a namespace import
|
|
71
74
|
// (`import * as bf from '@barefootjs/client'`, `bf.createSignal(...)`)
|
|
72
75
|
// that the analyzer's checker-less fast path cannot recognize refuses
|
|
73
76
|
// loudly (BF013) instead of silently dropping the declaration — fired
|
|
74
77
|
// in the shared analyzer pass ahead of any adapter's `adapter.generate()`,
|
|
75
|
-
// so all nine adapters (including Hono) pin this identically.
|
|
76
|
-
|
|
78
|
+
// so all nine adapters (including Hono) pin this identically. A compile
|
|
79
|
+
// that supplies a shared `ts.Program` (e.g. via `@barefootjs/vite`)
|
|
80
|
+
// resolves the primitive normally and never reaches this refusal (formerly
|
|
81
|
+
// tracked as #2771, closed) — no open issue tracks further work.
|
|
82
|
+
'namespace-import-primitive': [{ code: 'BF013', severity: 'error' }],
|
|
77
83
|
}
|
|
@@ -15,7 +15,4 @@ import type { RenderDivergences } from '@barefootjs/jsx'
|
|
|
15
15
|
// at value position and the runtime evaluator's `object-literal` case
|
|
16
16
|
// now merges it, so the seed classifies `derived` and SSRs identically
|
|
17
17
|
// to Hono.
|
|
18
|
-
export const renderDivergences: RenderDivergences = {
|
|
19
|
-
'aliased-loop-source':
|
|
20
|
-
'A `.map()` loop whose source is a local const alias of a signal getter (`const items__alias = items`) SSRs an empty `<ul>` on real Jinja2 — 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.',
|
|
21
|
-
}
|
|
18
|
+
export const renderDivergences: RenderDivergences = {}
|
package/src/test-render.ts
CHANGED
|
@@ -613,6 +613,26 @@ function buildPythonProps(
|
|
|
613
613
|
}
|
|
614
614
|
}
|
|
615
615
|
|
|
616
|
+
// #2813: `extractSsrDefaults` can seed an entry under a name that is
|
|
617
|
+
// none of `propsParams` / `signals` / `memos` above — a bare local-const
|
|
618
|
+
// alias of a signal/memo getter (`const items__alias = items`,
|
|
619
|
+
// `ssr-defaults.ts`) seeds `items__alias` alongside `items`. Production
|
|
620
|
+
// hands the whole manifest-derived stash straight through
|
|
621
|
+
// (`deriveStashFromDefaults` IS the production seeding mechanism here,
|
|
622
|
+
// not a harness stand-in), so any leftover `derivedProps` key must be
|
|
623
|
+
// pushed too, or this harness would silently omit what production
|
|
624
|
+
// actually provides, mismeasuring this conformance case.
|
|
625
|
+
const seededNames = new Set<string>([
|
|
626
|
+
...ir.metadata.propsParams.filter(p => !p.isRest).map(p => p.name),
|
|
627
|
+
...(restPropsName ? [restPropsName] : []),
|
|
628
|
+
...ir.metadata.signals.filter(s => !s.envReader).map(s => s.getter),
|
|
629
|
+
...ir.metadata.memos.map(m => m.name),
|
|
630
|
+
])
|
|
631
|
+
for (const [name, value] of Object.entries(derivedProps)) {
|
|
632
|
+
if (seededNames.has(name)) continue
|
|
633
|
+
fullEntries.push(`${pyStr(name)}: ${toPyLiteral(value)}`)
|
|
634
|
+
}
|
|
635
|
+
|
|
616
636
|
// (#1922) Request-scoped `searchParams()`: bind `searchParams` to an
|
|
617
637
|
// empty-query reader (so the render script needn't build one from a real
|
|
618
638
|
// request). The conformance harness issues no query string (the
|