@barefootjs/jinja 0.32.0 → 0.33.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.
- package/dist/adapter/emit-context.d.ts +4 -1
- package/dist/adapter/emit-context.d.ts.map +1 -1
- package/dist/adapter/expr/emitters.d.ts +1 -1
- package/dist/adapter/expr/emitters.d.ts.map +1 -1
- package/dist/adapter/index.js +17 -6
- package/dist/adapter/jinja-adapter.d.ts.map +1 -1
- package/dist/adapter/memo/seed.d.ts.map +1 -1
- package/dist/adapter/spread/spread-codegen.d.ts.map +1 -1
- package/dist/index.js +18 -11
- package/dist/render-divergences.d.ts.map +1 -1
- package/dist/vite.js +110 -43
- package/package.json +5 -5
- package/python/barefootjs/evaluator.py +14 -0
- package/src/adapter/emit-context.ts +4 -1
- package/src/adapter/expr/emitters.ts +22 -12
- package/src/adapter/jinja-adapter.ts +8 -3
- package/src/adapter/memo/seed.ts +2 -1
- package/src/adapter/spread/spread-codegen.ts +4 -0
- package/src/render-divergences.ts +7 -8
|
@@ -88,8 +88,11 @@ export interface JinjaMemoContext {
|
|
|
88
88
|
/**
|
|
89
89
|
* Lower a JS expression to its Jinja form (the core recursive entry). See
|
|
90
90
|
* `JinjaSpreadContext.convertExpressionToJinja` for the `preParsed` contract.
|
|
91
|
+
* `pos` (default `'rendered'`) must be `'value'` for a derived-seed RHS —
|
|
92
|
+
* an assignment, not a render — so the internal support gate matches the
|
|
93
|
+
* `isSupportedValue` classification the seed plan already used.
|
|
91
94
|
*/
|
|
92
|
-
convertExpressionToJinja(expr: string, preParsed?: ParsedExpr): string;
|
|
95
|
+
convertExpressionToJinja(expr: string, preParsed?: ParsedExpr, pos?: 'rendered' | 'value'): string;
|
|
93
96
|
/**
|
|
94
97
|
* Per-compile diagnostic list `convertExpressionToJinja` appends to on an
|
|
95
98
|
* unsupported shape (`_recordExprBF101`). `memo/seed.ts`'s
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":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AAA;KAAE,EAAE,CAAA;IAExC;;;;;;;;OAQG;IACH,wBAAwB,CAAC,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"}
|
|
@@ -138,6 +138,6 @@ export declare class JinjaTopLevelEmitter implements ParsedExprEmitter {
|
|
|
138
138
|
arrow(_params: string[], _body: ParsedExpr): string;
|
|
139
139
|
regex(_raw: string): string;
|
|
140
140
|
unsupported(_raw: string, _reason: string): string;
|
|
141
|
-
objectLiteral(properties: ObjectLiteralProperty[], _raw: string,
|
|
141
|
+
objectLiteral(properties: ObjectLiteralProperty[], _raw: string, emit: (e: ParsedExpr) => string): string;
|
|
142
142
|
}
|
|
143
143
|
//# sourceMappingURL=emitters.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emitters.d.ts","sourceRoot":"","sources":["../../../src/adapter/expr/emitters.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"emitters.d.ts","sourceRoot":"","sources":["../../../src/adapter/expr/emitters.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AAEH,OAAO,EAEL,KAAK,iBAAiB,EAE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,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,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,MAAM,GAAG,MAAM,CAoBxG;CACF"}
|
package/dist/adapter/index.js
CHANGED
|
@@ -187297,6 +187297,7 @@ import {
|
|
|
187297
187297
|
parseProviderObjectLiteral,
|
|
187298
187298
|
parseStyleObjectEntries,
|
|
187299
187299
|
isSupported,
|
|
187300
|
+
isSupportedValue,
|
|
187300
187301
|
emitParsedExpr,
|
|
187301
187302
|
emitIRNode,
|
|
187302
187303
|
emitAttrValue,
|
|
@@ -187742,6 +187743,7 @@ function staticValueToJinja(value) {
|
|
|
187742
187743
|
// src/adapter/expr/emitters.ts
|
|
187743
187744
|
import {
|
|
187744
187745
|
groupBinaryOperand,
|
|
187746
|
+
groupObjectLiteralSegments,
|
|
187745
187747
|
identifierPath,
|
|
187746
187748
|
matchSearchParamsMethodCall,
|
|
187747
187749
|
sortComparatorFromArrow
|
|
@@ -188063,8 +188065,15 @@ class JinjaTopLevelEmitter {
|
|
|
188063
188065
|
unsupported(_raw, _reason) {
|
|
188064
188066
|
return "''";
|
|
188065
188067
|
}
|
|
188066
|
-
objectLiteral(properties, _raw,
|
|
188067
|
-
|
|
188068
|
+
objectLiteral(properties, _raw, emit) {
|
|
188069
|
+
if (properties.length === 0)
|
|
188070
|
+
return "{}";
|
|
188071
|
+
const literalOf = (run) => `{${run.map((p) => `${jinjaHashKey(p.key)}: ${emit(p.value)}`).join(", ")}}`;
|
|
188072
|
+
if (!properties.some((p) => p.kind === "spread")) {
|
|
188073
|
+
return literalOf(properties);
|
|
188074
|
+
}
|
|
188075
|
+
const segments = groupObjectLiteralSegments(properties, literalOf, emit);
|
|
188076
|
+
return segments.reduce((acc, seg) => `dict(${acc}, **${seg.includes(" ") ? `(${seg})` : seg})`);
|
|
188068
188077
|
}
|
|
188069
188078
|
}
|
|
188070
188079
|
|
|
@@ -188178,6 +188187,8 @@ function objectLiteralExprToJinjaDict(ctx, expr) {
|
|
|
188178
188187
|
function objectLiteralToJinjaDict(ctx, obj) {
|
|
188179
188188
|
const entries = [];
|
|
188180
188189
|
for (const prop of obj.properties) {
|
|
188190
|
+
if (prop.kind === "spread")
|
|
188191
|
+
return null;
|
|
188181
188192
|
if (prop.shorthand)
|
|
188182
188193
|
return null;
|
|
188183
188194
|
if (prop.keyKind === "numeric")
|
|
@@ -188253,7 +188264,7 @@ function generateDerivedMemoSeed(ctx, ir) {
|
|
|
188253
188264
|
continue;
|
|
188254
188265
|
const materialized = materializeGetterCalls(step.parsed, knownGetterNames);
|
|
188255
188266
|
const errorsBefore = ctx.errors.length;
|
|
188256
|
-
const jinja = ctx.convertExpressionToJinja("", materialized);
|
|
188267
|
+
const jinja = ctx.convertExpressionToJinja("", materialized, "value");
|
|
188257
188268
|
if (ctx.errors.length > errorsBefore) {
|
|
188258
188269
|
ctx.errors.length = errorsBefore;
|
|
188259
188270
|
continue;
|
|
@@ -189074,11 +189085,11 @@ ${reason}` : "";
|
|
|
189074
189085
|
}
|
|
189075
189086
|
get memoCtx() {
|
|
189076
189087
|
return {
|
|
189077
|
-
convertExpressionToJinja: (e, preParsed) => this.convertExpressionToJinja(e, preParsed),
|
|
189088
|
+
convertExpressionToJinja: (e, preParsed, pos) => this.convertExpressionToJinja(e, preParsed, pos),
|
|
189078
189089
|
errors: this.errors
|
|
189079
189090
|
};
|
|
189080
189091
|
}
|
|
189081
|
-
convertExpressionToJinja(expr, preParsed) {
|
|
189092
|
+
convertExpressionToJinja(expr, preParsed, pos = "rendered") {
|
|
189082
189093
|
let parsed;
|
|
189083
189094
|
if (preParsed) {
|
|
189084
189095
|
parsed = preParsed;
|
|
@@ -189101,7 +189112,7 @@ ${reason}` : "";
|
|
|
189101
189112
|
}
|
|
189102
189113
|
}
|
|
189103
189114
|
}
|
|
189104
|
-
const support = isSupported(parsed);
|
|
189115
|
+
const support = pos === "value" ? isSupportedValue(parsed) : isSupported(parsed);
|
|
189105
189116
|
if (!support.supported) {
|
|
189106
189117
|
this.errors.push({
|
|
189107
189118
|
code: "BF101",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jinja-adapter.d.ts","sourceRoot":"","sources":["../../src/adapter/jinja-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwFG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,MAAM,EACN,SAAS,EACT,MAAM,EACN,YAAY,EACZ,aAAa,EACb,MAAM,EACN,WAAW,EACX,UAAU,EACV,MAAM,EACN,aAAa,EACb,UAAU,EACV,OAAO,EAKP,yBAAyB,EAE1B,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,WAAW,EACX,KAAK,aAAa,EAClB,KAAK,sBAAsB,EAE3B,KAAK,aAAa,EAClB,KAAK,U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;;;;;;;;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,YAAY,cAAqB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"seed.d.ts","sourceRoot":"","sources":["../../../src/adapter/memo/seed.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,eAAe,EAIrB,MAAM,iBAAiB,CAAA;AAExB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAI1D,sEAAsE;AACtE,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,eAAe,GAAG,MAAM,CAM9D;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,EAAE,EAAE,WAAW,GAAG,MAAM,CAWnE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,gBAAgB,EAAE,EAAE,EAAE,WAAW,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"seed.d.ts","sourceRoot":"","sources":["../../../src/adapter/memo/seed.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,eAAe,EAIrB,MAAM,iBAAiB,CAAA;AAExB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAI1D,sEAAsE;AACtE,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,eAAe,GAAG,MAAM,CAM9D;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,EAAE,EAAE,WAAW,GAAG,MAAM,CAWnE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,gBAAgB,EAAE,EAAE,EAAE,WAAW,GAAG,MAAM,CAuBtF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spread-codegen.d.ts","sourceRoot":"","sources":["../../../src/adapter/spread/spread-codegen.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEjD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AAG5D;;;;;;;;;GASG;AACH,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,kBAAkB,EACvB,IAAI,EAAE,UAAU,GAAG,SAAS,GAC3B,MAAM,GAAG,IAAI,CAcf;AAED;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAC1C,GAAG,EAAE,kBAAkB,EACvB,IAAI,EAAE,UAAU,GAAG,SAAS,GAC3B,MAAM,GAAG,IAAI,CAGf;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,kBAAkB,EACvB,GAAG,EAAE,OAAO,CAAC,UAAU,EAAE;IAAE,IAAI,EAAE,gBAAgB,CAAA;CAAE,CAAC,GACnD,MAAM,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"spread-codegen.d.ts","sourceRoot":"","sources":["../../../src/adapter/spread/spread-codegen.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEjD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AAG5D;;;;;;;;;GASG;AACH,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,kBAAkB,EACvB,IAAI,EAAE,UAAU,GAAG,SAAS,GAC3B,MAAM,GAAG,IAAI,CAcf;AAED;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAC1C,GAAG,EAAE,kBAAkB,EACvB,IAAI,EAAE,UAAU,GAAG,SAAS,GAC3B,MAAM,GAAG,IAAI,CAGf;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,kBAAkB,EACvB,GAAG,EAAE,OAAO,CAAC,UAAU,EAAE;IAAE,IAAI,EAAE,gBAAgB,CAAA;CAAE,CAAC,GACnD,MAAM,GAAG,IAAI,CA8Cf;AAUD;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,kBAAkB,EAAE,GAAG,EAAE,UAAU,GAAG,MAAM,GAAG,IAAI,CAuBhG"}
|
package/dist/index.js
CHANGED
|
@@ -187297,6 +187297,7 @@ import {
|
|
|
187297
187297
|
parseProviderObjectLiteral,
|
|
187298
187298
|
parseStyleObjectEntries,
|
|
187299
187299
|
isSupported,
|
|
187300
|
+
isSupportedValue,
|
|
187300
187301
|
emitParsedExpr,
|
|
187301
187302
|
emitIRNode,
|
|
187302
187303
|
emitAttrValue,
|
|
@@ -187742,6 +187743,7 @@ function staticValueToJinja(value) {
|
|
|
187742
187743
|
// src/adapter/expr/emitters.ts
|
|
187743
187744
|
import {
|
|
187744
187745
|
groupBinaryOperand,
|
|
187746
|
+
groupObjectLiteralSegments,
|
|
187745
187747
|
identifierPath,
|
|
187746
187748
|
matchSearchParamsMethodCall,
|
|
187747
187749
|
sortComparatorFromArrow
|
|
@@ -188063,8 +188065,15 @@ class JinjaTopLevelEmitter {
|
|
|
188063
188065
|
unsupported(_raw, _reason) {
|
|
188064
188066
|
return "''";
|
|
188065
188067
|
}
|
|
188066
|
-
objectLiteral(properties, _raw,
|
|
188067
|
-
|
|
188068
|
+
objectLiteral(properties, _raw, emit) {
|
|
188069
|
+
if (properties.length === 0)
|
|
188070
|
+
return "{}";
|
|
188071
|
+
const literalOf = (run) => `{${run.map((p) => `${jinjaHashKey(p.key)}: ${emit(p.value)}`).join(", ")}}`;
|
|
188072
|
+
if (!properties.some((p) => p.kind === "spread")) {
|
|
188073
|
+
return literalOf(properties);
|
|
188074
|
+
}
|
|
188075
|
+
const segments = groupObjectLiteralSegments(properties, literalOf, emit);
|
|
188076
|
+
return segments.reduce((acc, seg) => `dict(${acc}, **${seg.includes(" ") ? `(${seg})` : seg})`);
|
|
188068
188077
|
}
|
|
188069
188078
|
}
|
|
188070
188079
|
|
|
@@ -188178,6 +188187,8 @@ function objectLiteralExprToJinjaDict(ctx, expr) {
|
|
|
188178
188187
|
function objectLiteralToJinjaDict(ctx, obj) {
|
|
188179
188188
|
const entries = [];
|
|
188180
188189
|
for (const prop of obj.properties) {
|
|
188190
|
+
if (prop.kind === "spread")
|
|
188191
|
+
return null;
|
|
188181
188192
|
if (prop.shorthand)
|
|
188182
188193
|
return null;
|
|
188183
188194
|
if (prop.keyKind === "numeric")
|
|
@@ -188253,7 +188264,7 @@ function generateDerivedMemoSeed(ctx, ir) {
|
|
|
188253
188264
|
continue;
|
|
188254
188265
|
const materialized = materializeGetterCalls(step.parsed, knownGetterNames);
|
|
188255
188266
|
const errorsBefore = ctx.errors.length;
|
|
188256
|
-
const jinja = ctx.convertExpressionToJinja("", materialized);
|
|
188267
|
+
const jinja = ctx.convertExpressionToJinja("", materialized, "value");
|
|
188257
188268
|
if (ctx.errors.length > errorsBefore) {
|
|
188258
188269
|
ctx.errors.length = errorsBefore;
|
|
188259
188270
|
continue;
|
|
@@ -189074,11 +189085,11 @@ ${reason}` : "";
|
|
|
189074
189085
|
}
|
|
189075
189086
|
get memoCtx() {
|
|
189076
189087
|
return {
|
|
189077
|
-
convertExpressionToJinja: (e, preParsed) => this.convertExpressionToJinja(e, preParsed),
|
|
189088
|
+
convertExpressionToJinja: (e, preParsed, pos) => this.convertExpressionToJinja(e, preParsed, pos),
|
|
189078
189089
|
errors: this.errors
|
|
189079
189090
|
};
|
|
189080
189091
|
}
|
|
189081
|
-
convertExpressionToJinja(expr, preParsed) {
|
|
189092
|
+
convertExpressionToJinja(expr, preParsed, pos = "rendered") {
|
|
189082
189093
|
let parsed;
|
|
189083
189094
|
if (preParsed) {
|
|
189084
189095
|
parsed = preParsed;
|
|
@@ -189101,7 +189112,7 @@ ${reason}` : "";
|
|
|
189101
189112
|
}
|
|
189102
189113
|
}
|
|
189103
189114
|
}
|
|
189104
|
-
const support = isSupported(parsed);
|
|
189115
|
+
const support = pos === "value" ? isSupportedValue(parsed) : isSupported(parsed);
|
|
189105
189116
|
if (!support.supported) {
|
|
189106
189117
|
this.errors.push({
|
|
189107
189118
|
code: "BF101",
|
|
@@ -189254,11 +189265,7 @@ var conformancePins = {
|
|
|
189254
189265
|
"rich-prop-client-read": [{ code: "BF049", severity: "error", issue: "https://github.com/piconic-ai/barefootjs/issues/2648" }]
|
|
189255
189266
|
};
|
|
189256
189267
|
// src/render-divergences.ts
|
|
189257
|
-
var renderDivergences = {
|
|
189258
|
-
"todo-app": "the `todos` signal seeds from `(props.initialTodos ?? []).map(t => ({ ...t, editing: false }))` — a different-prop-derived `.map()` chain `extractSsrDefaults` cannot statically resolve, and `computeSsrSeedPlan` classifies it opaque (no in-template recompute), so it seeds `None`; the non-`/* @client */`-marked `{todos().length > 0 && ...}` toggle-all block SSRs as if there are zero todos regardless of `initialTodos` (https://github.com/piconic-ai/barefootjs/issues/2696)",
|
|
189259
|
-
"todo-app-ssr": "same root cause as `todo-app` (https://github.com/piconic-ai/barefootjs/issues/2696), but this fixture's todo-list loop carries no `/* @client */` marker — the compiled `{% for todo in todos %}` iterates the null-seeded `todos` directly and Jinja2 raises `TypeError: 'NoneType' object is not iterable` instead of rendering",
|
|
189260
|
-
"callback-param-shadows-prop": "the `first` signal seeds from `[{ a: 'p' }].map((title) => title.a).join(',')` — a constant expression `extractSsrDefaults` still cannot statically resolve (`.map()` is unsupported for any receiver) and, unlike the sibling `joined` memo's structurally similar chain, gets no in-template recompute (`computeSsrSeedPlan` classifies it opaque too); `<span>{first()}</span>` SSRs empty instead of `p` (https://github.com/piconic-ai/barefootjs/issues/2696)"
|
|
189261
|
-
};
|
|
189268
|
+
var renderDivergences = {};
|
|
189262
189269
|
export {
|
|
189263
189270
|
renderDivergences,
|
|
189264
189271
|
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;
|
|
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
|
@@ -263,7 +263,7 @@ function convertNode(node, raw) {
|
|
|
263
263
|
}
|
|
264
264
|
if (n === undefined || Number.isNaN(n)) {
|
|
265
265
|
const parsedDepth = convertNode(depthNode, raw);
|
|
266
|
-
if (checkSupport(parsedDepth).supported) {
|
|
266
|
+
if (checkSupport(parsedDepth, "rendered").supported) {
|
|
267
267
|
depthExpr = parsedDepth;
|
|
268
268
|
flatDepth = 1;
|
|
269
269
|
} else {
|
|
@@ -357,10 +357,12 @@ function convertNode(node, raw) {
|
|
|
357
357
|
const k = objectLiteralKeyName(prop.name);
|
|
358
358
|
if (k === null)
|
|
359
359
|
return { kind: "unsupported", raw, reason: `Unsupported syntax: ${ts.SyntaxKind[node.kind]}` };
|
|
360
|
-
properties.push({ key: k.key, keyKind: k.keyKind, shorthand: false, value: convertNode(prop.initializer, raw) });
|
|
360
|
+
properties.push({ kind: "prop", key: k.key, keyKind: k.keyKind, shorthand: false, value: convertNode(prop.initializer, raw) });
|
|
361
361
|
} else if (ts.isShorthandPropertyAssignment(prop)) {
|
|
362
362
|
const key = prop.name.text;
|
|
363
|
-
properties.push({ key, keyKind: "identifier", shorthand: true, value: { kind: "identifier", name: key } });
|
|
363
|
+
properties.push({ kind: "prop", key, keyKind: "identifier", shorthand: true, value: { kind: "identifier", name: key } });
|
|
364
|
+
} else if (ts.isSpreadAssignment(prop)) {
|
|
365
|
+
properties.push({ kind: "spread", expr: convertNode(prop.expression, raw) });
|
|
364
366
|
} else {
|
|
365
367
|
return { kind: "unsupported", raw, reason: `Unsupported syntax: ${ts.SyntaxKind[node.kind]}` };
|
|
366
368
|
}
|
|
@@ -1040,14 +1042,26 @@ function getUnaryOperatorString(op) {
|
|
|
1040
1042
|
}
|
|
1041
1043
|
}
|
|
1042
1044
|
function isSupported(expr) {
|
|
1043
|
-
return checkSupport(expr);
|
|
1045
|
+
return checkSupport(expr, "rendered");
|
|
1044
1046
|
}
|
|
1045
|
-
function
|
|
1047
|
+
function isSupportedValue(expr) {
|
|
1048
|
+
return checkSupport(expr, "value");
|
|
1049
|
+
}
|
|
1050
|
+
function checkSupport(expr, pos) {
|
|
1046
1051
|
switch (expr.kind) {
|
|
1047
1052
|
case "unsupported":
|
|
1048
1053
|
return { supported: false, reason: expr.reason };
|
|
1049
|
-
case "object-literal":
|
|
1050
|
-
|
|
1054
|
+
case "object-literal": {
|
|
1055
|
+
if (pos !== "value") {
|
|
1056
|
+
return { supported: false, reason: "Unsupported syntax: ObjectLiteralExpression" };
|
|
1057
|
+
}
|
|
1058
|
+
for (const prop of expr.properties) {
|
|
1059
|
+
const propSupport = checkSupport(prop.kind === "spread" ? prop.expr : prop.value, pos);
|
|
1060
|
+
if (!propSupport.supported)
|
|
1061
|
+
return propSupport;
|
|
1062
|
+
}
|
|
1063
|
+
return { supported: true, level: "L2" };
|
|
1064
|
+
}
|
|
1051
1065
|
case "identifier":
|
|
1052
1066
|
return { supported: true, level: "L1" };
|
|
1053
1067
|
case "literal":
|
|
@@ -1057,7 +1071,7 @@ function checkSupport(expr) {
|
|
|
1057
1071
|
return { supported: false, reason: "Standalone arrow functions / regex literals are not supported" };
|
|
1058
1072
|
case "array-literal": {
|
|
1059
1073
|
for (const el of expr.elements) {
|
|
1060
|
-
const elSupport = checkSupport(el);
|
|
1074
|
+
const elSupport = checkSupport(el, pos);
|
|
1061
1075
|
if (!elSupport.supported)
|
|
1062
1076
|
return elSupport;
|
|
1063
1077
|
}
|
|
@@ -1070,16 +1084,16 @@ function checkSupport(expr) {
|
|
|
1070
1084
|
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 */`
|
|
1071
1085
|
};
|
|
1072
1086
|
}
|
|
1073
|
-
const objSupport = checkSupport(expr.object);
|
|
1087
|
+
const objSupport = checkSupport(expr.object, pos);
|
|
1074
1088
|
if (!objSupport.supported)
|
|
1075
1089
|
return objSupport;
|
|
1076
1090
|
for (const arg of expr.args) {
|
|
1077
|
-
const argSupport = checkSupport(arg);
|
|
1091
|
+
const argSupport = checkSupport(arg, pos);
|
|
1078
1092
|
if (!argSupport.supported)
|
|
1079
1093
|
return argSupport;
|
|
1080
1094
|
}
|
|
1081
1095
|
if (expr.method === "flat" && expr.depthExpr) {
|
|
1082
|
-
const depthSupport = checkSupport(expr.depthExpr);
|
|
1096
|
+
const depthSupport = checkSupport(expr.depthExpr, pos);
|
|
1083
1097
|
if (!depthSupport.supported)
|
|
1084
1098
|
return depthSupport;
|
|
1085
1099
|
}
|
|
@@ -1088,10 +1102,10 @@ function checkSupport(expr) {
|
|
|
1088
1102
|
case "call": {
|
|
1089
1103
|
const cb = asCallbackMethodCall(expr);
|
|
1090
1104
|
if (cb) {
|
|
1091
|
-
const objSupport = checkSupport(cb.object);
|
|
1105
|
+
const objSupport = checkSupport(cb.object, pos);
|
|
1092
1106
|
if (!objSupport.supported)
|
|
1093
1107
|
return objSupport;
|
|
1094
|
-
const bodySupport = checkSupport(cb.arrow.body);
|
|
1108
|
+
const bodySupport = checkSupport(cb.arrow.body, pos);
|
|
1095
1109
|
if (!bodySupport.supported) {
|
|
1096
1110
|
return {
|
|
1097
1111
|
supported: false,
|
|
@@ -1100,13 +1114,13 @@ function checkSupport(expr) {
|
|
|
1100
1114
|
};
|
|
1101
1115
|
}
|
|
1102
1116
|
for (const rest of cb.args) {
|
|
1103
|
-
const restSupport = checkSupport(rest);
|
|
1117
|
+
const restSupport = checkSupport(rest, pos);
|
|
1104
1118
|
if (!restSupport.supported)
|
|
1105
1119
|
return restSupport;
|
|
1106
1120
|
}
|
|
1107
1121
|
return { supported: true, level: "L5" };
|
|
1108
1122
|
}
|
|
1109
|
-
const calleeSupport = checkSupport(expr.callee);
|
|
1123
|
+
const calleeSupport = checkSupport(expr.callee, pos);
|
|
1110
1124
|
if (!calleeSupport.supported) {
|
|
1111
1125
|
return calleeSupport;
|
|
1112
1126
|
}
|
|
@@ -1125,7 +1139,7 @@ function checkSupport(expr) {
|
|
|
1125
1139
|
return { supported: true, level: "L1" };
|
|
1126
1140
|
}
|
|
1127
1141
|
for (const arg of expr.args) {
|
|
1128
|
-
const argSupport = checkSupport(arg);
|
|
1142
|
+
const argSupport = checkSupport(arg, pos);
|
|
1129
1143
|
if (!argSupport.supported) {
|
|
1130
1144
|
return argSupport;
|
|
1131
1145
|
}
|
|
@@ -1133,7 +1147,7 @@ function checkSupport(expr) {
|
|
|
1133
1147
|
return { supported: true, level: "L2" };
|
|
1134
1148
|
}
|
|
1135
1149
|
case "member": {
|
|
1136
|
-
const objSupport = checkSupport(expr.object);
|
|
1150
|
+
const objSupport = checkSupport(expr.object, pos);
|
|
1137
1151
|
if (!objSupport.supported) {
|
|
1138
1152
|
return objSupport;
|
|
1139
1153
|
}
|
|
@@ -1143,19 +1157,19 @@ function checkSupport(expr) {
|
|
|
1143
1157
|
return { supported: true, level: "L2" };
|
|
1144
1158
|
}
|
|
1145
1159
|
case "index-access": {
|
|
1146
|
-
const objSupport = checkSupport(expr.object);
|
|
1160
|
+
const objSupport = checkSupport(expr.object, pos);
|
|
1147
1161
|
if (!objSupport.supported)
|
|
1148
1162
|
return objSupport;
|
|
1149
|
-
const indexSupport = checkSupport(expr.index);
|
|
1163
|
+
const indexSupport = checkSupport(expr.index, pos);
|
|
1150
1164
|
if (!indexSupport.supported)
|
|
1151
1165
|
return indexSupport;
|
|
1152
1166
|
return { supported: true, level: "L2" };
|
|
1153
1167
|
}
|
|
1154
1168
|
case "binary": {
|
|
1155
|
-
const leftSupport = checkSupport(expr.left);
|
|
1169
|
+
const leftSupport = checkSupport(expr.left, pos);
|
|
1156
1170
|
if (!leftSupport.supported)
|
|
1157
1171
|
return leftSupport;
|
|
1158
|
-
const rightSupport = checkSupport(expr.right);
|
|
1172
|
+
const rightSupport = checkSupport(expr.right, pos);
|
|
1159
1173
|
if (!rightSupport.supported)
|
|
1160
1174
|
return rightSupport;
|
|
1161
1175
|
if (["===", "==", "!==", "!=", ">", "<", ">=", "<="].includes(expr.op)) {
|
|
@@ -1167,7 +1181,7 @@ function checkSupport(expr) {
|
|
|
1167
1181
|
return { supported: false, reason: `Unknown operator: ${expr.op}` };
|
|
1168
1182
|
}
|
|
1169
1183
|
case "unary": {
|
|
1170
|
-
const argSupport = checkSupport(expr.argument);
|
|
1184
|
+
const argSupport = checkSupport(expr.argument, pos);
|
|
1171
1185
|
if (!argSupport.supported)
|
|
1172
1186
|
return argSupport;
|
|
1173
1187
|
if (expr.op === "!") {
|
|
@@ -1179,25 +1193,25 @@ function checkSupport(expr) {
|
|
|
1179
1193
|
return { supported: false, reason: `Unsupported unary operator: ${expr.op}` };
|
|
1180
1194
|
}
|
|
1181
1195
|
case "logical": {
|
|
1182
|
-
const leftSupport = checkSupport(expr.left);
|
|
1196
|
+
const leftSupport = checkSupport(expr.left, pos);
|
|
1183
1197
|
if (!leftSupport.supported)
|
|
1184
1198
|
return leftSupport;
|
|
1185
1199
|
if (expr.op === "??" && expr.right.kind === "object-literal" && expr.right.properties.length === 0) {
|
|
1186
1200
|
return { supported: true, level: "L4" };
|
|
1187
1201
|
}
|
|
1188
|
-
const rightSupport = checkSupport(expr.right);
|
|
1202
|
+
const rightSupport = checkSupport(expr.right, pos);
|
|
1189
1203
|
if (!rightSupport.supported)
|
|
1190
1204
|
return rightSupport;
|
|
1191
1205
|
return { supported: true, level: "L4" };
|
|
1192
1206
|
}
|
|
1193
1207
|
case "conditional": {
|
|
1194
|
-
const testSupport = checkSupport(expr.test);
|
|
1208
|
+
const testSupport = checkSupport(expr.test, pos);
|
|
1195
1209
|
if (!testSupport.supported)
|
|
1196
1210
|
return testSupport;
|
|
1197
|
-
const consSupport = checkSupport(expr.consequent);
|
|
1211
|
+
const consSupport = checkSupport(expr.consequent, pos);
|
|
1198
1212
|
if (!consSupport.supported)
|
|
1199
1213
|
return consSupport;
|
|
1200
|
-
const altSupport = checkSupport(expr.alternate);
|
|
1214
|
+
const altSupport = checkSupport(expr.alternate, pos);
|
|
1201
1215
|
if (!altSupport.supported)
|
|
1202
1216
|
return altSupport;
|
|
1203
1217
|
return { supported: true, level: "L4" };
|
|
@@ -1205,7 +1219,7 @@ function checkSupport(expr) {
|
|
|
1205
1219
|
case "template-literal": {
|
|
1206
1220
|
for (const part of expr.parts) {
|
|
1207
1221
|
if (part.type === "expression") {
|
|
1208
|
-
const partSupport = checkSupport(part.expr);
|
|
1222
|
+
const partSupport = checkSupport(part.expr, pos);
|
|
1209
1223
|
if (!partSupport.supported)
|
|
1210
1224
|
return partSupport;
|
|
1211
1225
|
}
|
|
@@ -1321,7 +1335,7 @@ function isPureInit(e, pureCallNames) {
|
|
|
1321
1335
|
case "array-literal":
|
|
1322
1336
|
return e.elements.every(pure);
|
|
1323
1337
|
case "object-literal":
|
|
1324
|
-
return e.properties.every((p) => pure(p.value));
|
|
1338
|
+
return e.properties.every((p) => pure(p.kind === "spread" ? p.expr : p.value));
|
|
1325
1339
|
case "call":
|
|
1326
1340
|
return e.callee.kind === "identifier" && e.args.length === 0 && pureCallNames !== undefined && pureCallNames.has(e.callee.name);
|
|
1327
1341
|
case "array-method":
|
|
@@ -1375,7 +1389,7 @@ function usesPerPath(name, expr) {
|
|
|
1375
1389
|
}
|
|
1376
1390
|
return add(walk(e.object), sum(e.args));
|
|
1377
1391
|
case "object-literal":
|
|
1378
|
-
return sum(e.properties.map((p) => p.value));
|
|
1392
|
+
return sum(e.properties.map((p) => p.kind === "spread" ? p.expr : p.value));
|
|
1379
1393
|
case "arrow":
|
|
1380
1394
|
return walk(e.body).max > 0 ? { min: 0, max: Number.POSITIVE_INFINITY } : { min: 0, max: 0 };
|
|
1381
1395
|
}
|
|
@@ -1441,7 +1455,7 @@ function inlineBinding(expr, name, value) {
|
|
|
1441
1455
|
case "object-literal":
|
|
1442
1456
|
return {
|
|
1443
1457
|
kind: "object-literal",
|
|
1444
|
-
properties: e.properties.map((p) => ({ ...p, value: walk(p.value, enclosing) })
|
|
1458
|
+
properties: e.properties.map((p) => p.kind === "spread" ? { ...p, expr: walk(p.expr, enclosing) } : { ...p, value: walk(p.value, enclosing) }),
|
|
1445
1459
|
raw: e.raw
|
|
1446
1460
|
};
|
|
1447
1461
|
case "literal":
|
|
@@ -1651,7 +1665,7 @@ function materializeGetterCalls(expr, names) {
|
|
|
1651
1665
|
return {
|
|
1652
1666
|
kind: "object-literal",
|
|
1653
1667
|
raw: expr.raw,
|
|
1654
|
-
properties: expr.properties.map((p) => ({ ...p, value: rw(p.value) })
|
|
1668
|
+
properties: expr.properties.map((p) => p.kind === "spread" ? { ...p, expr: rw(p.expr) } : { ...p, value: rw(p.value) })
|
|
1655
1669
|
};
|
|
1656
1670
|
case "arrow":
|
|
1657
1671
|
return { kind: "arrow", params: expr.params, body: rw(expr.body) };
|
|
@@ -1709,7 +1723,7 @@ function freeVarsInBody(body, params) {
|
|
|
1709
1723
|
return;
|
|
1710
1724
|
case "object-literal":
|
|
1711
1725
|
for (const p of e.properties)
|
|
1712
|
-
visit(p.value, bound);
|
|
1726
|
+
visit(p.kind === "spread" ? p.expr : p.value, bound);
|
|
1713
1727
|
return;
|
|
1714
1728
|
case "array-method":
|
|
1715
1729
|
if (e.method === "includes" || e.method === "join") {
|
|
@@ -1784,7 +1798,7 @@ function freeIdentifiers(expr) {
|
|
|
1784
1798
|
return true;
|
|
1785
1799
|
case "object-literal":
|
|
1786
1800
|
for (const p of e.properties)
|
|
1787
|
-
if (!visit(p.value, bound))
|
|
1801
|
+
if (!visit(p.kind === "spread" ? p.expr : p.value, bound))
|
|
1788
1802
|
return false;
|
|
1789
1803
|
return true;
|
|
1790
1804
|
case "arrow": {
|
|
@@ -1931,10 +1945,17 @@ function toEvalNode(e) {
|
|
|
1931
1945
|
case "object-literal": {
|
|
1932
1946
|
const properties = [];
|
|
1933
1947
|
for (const p of e.properties) {
|
|
1948
|
+
if (p.kind === "spread") {
|
|
1949
|
+
const spreadExpr = toEvalNode(p.expr);
|
|
1950
|
+
if (!spreadExpr)
|
|
1951
|
+
return null;
|
|
1952
|
+
properties.push({ kind: "spread", expr: spreadExpr });
|
|
1953
|
+
continue;
|
|
1954
|
+
}
|
|
1934
1955
|
const value = toEvalNode(p.value);
|
|
1935
1956
|
if (!value)
|
|
1936
1957
|
return null;
|
|
1937
|
-
properties.push({ key: p.key, value });
|
|
1958
|
+
properties.push({ kind: "prop", key: p.key, value });
|
|
1938
1959
|
}
|
|
1939
1960
|
return { kind: "object-literal", properties };
|
|
1940
1961
|
}
|
|
@@ -2967,6 +2988,8 @@ function matchToLocaleDateStringCall(callee, args, metadata) {
|
|
|
2967
2988
|
let tz = null;
|
|
2968
2989
|
const probeOptions = {};
|
|
2969
2990
|
for (const prop of options.properties) {
|
|
2991
|
+
if (prop.kind === "spread")
|
|
2992
|
+
return null;
|
|
2970
2993
|
if (prop.value.kind !== "literal" || prop.value.literalType !== "string")
|
|
2971
2994
|
return null;
|
|
2972
2995
|
const value = String(prop.value.value);
|
|
@@ -3957,7 +3980,7 @@ function parseRecordIndexAccess(val, localConstants, propsParams, resolveKey) {
|
|
|
3957
3980
|
|
|
3958
3981
|
// ../jsx/src/ssr-seed-plan.ts
|
|
3959
3982
|
function classify(name, origin, expr, parsed, available) {
|
|
3960
|
-
if (!
|
|
3983
|
+
if (!isSupportedValue(parsed).supported)
|
|
3961
3984
|
return { kind: "opaque", name, origin };
|
|
3962
3985
|
const frees = freeIdentifiers(parsed);
|
|
3963
3986
|
if (frees === null)
|
|
@@ -4020,7 +4043,7 @@ function computeSsrSeedPlan(metadata) {
|
|
|
4020
4043
|
}
|
|
4021
4044
|
}
|
|
4022
4045
|
const expr = signal.initialValue.trim();
|
|
4023
|
-
steps.push(expr === "" ? { kind: "opaque", name: signal.getter, origin: "signal" } : classify(signal.getter, "signal", expr, resolveThroughLocalConsts(parseExpression(expr), localConsts), available));
|
|
4046
|
+
steps.push(expr === "" ? { kind: "opaque", name: signal.getter, origin: "signal" } : classify(signal.getter, "signal", expr, resolveThroughLocalConsts(signal.parsed ?? parseExpression(`(${expr})`), localConsts), available));
|
|
4024
4047
|
available.add(signal.getter);
|
|
4025
4048
|
}
|
|
4026
4049
|
for (const memo of metadata.memos) {
|
|
@@ -4626,6 +4649,26 @@ var testAdapter = new TestAdapter;
|
|
|
4626
4649
|
function groupBinaryOperand(operand, emitted) {
|
|
4627
4650
|
return operand.kind === "binary" || operand.kind === "logical" || operand.kind === "conditional" ? `(${emitted})` : emitted;
|
|
4628
4651
|
}
|
|
4652
|
+
function groupObjectLiteralSegments(properties, literalOf, emit) {
|
|
4653
|
+
const segments = [];
|
|
4654
|
+
let run = [];
|
|
4655
|
+
const flushRun = () => {
|
|
4656
|
+
if (run.length > 0) {
|
|
4657
|
+
segments.push(literalOf(run));
|
|
4658
|
+
run = [];
|
|
4659
|
+
}
|
|
4660
|
+
};
|
|
4661
|
+
for (const p of properties) {
|
|
4662
|
+
if (p.kind === "spread") {
|
|
4663
|
+
flushRun();
|
|
4664
|
+
segments.push(emit(p.expr));
|
|
4665
|
+
} else {
|
|
4666
|
+
run.push(p);
|
|
4667
|
+
}
|
|
4668
|
+
}
|
|
4669
|
+
flushRun();
|
|
4670
|
+
return segments;
|
|
4671
|
+
}
|
|
4629
4672
|
function emitParsedExpr(expr, emitter) {
|
|
4630
4673
|
const emit = (child) => emitParsedExpr(child, emitter);
|
|
4631
4674
|
switch (expr.kind) {
|
|
@@ -4706,6 +4749,17 @@ function evaluateStaticLiteral(expr, bindings) {
|
|
|
4706
4749
|
case "object-literal": {
|
|
4707
4750
|
const out = {};
|
|
4708
4751
|
for (const prop of expr.properties) {
|
|
4752
|
+
if (prop.kind === "spread") {
|
|
4753
|
+
const resolved2 = evaluateStaticLiteral(prop.expr, bindings);
|
|
4754
|
+
if (!resolved2)
|
|
4755
|
+
return null;
|
|
4756
|
+
if (resolved2.value === null || resolved2.value === undefined)
|
|
4757
|
+
continue;
|
|
4758
|
+
if (typeof resolved2.value !== "object" || Array.isArray(resolved2.value))
|
|
4759
|
+
return null;
|
|
4760
|
+
Object.assign(out, resolved2.value);
|
|
4761
|
+
continue;
|
|
4762
|
+
}
|
|
4709
4763
|
const resolved = evaluateStaticLiteral(prop.value, bindings);
|
|
4710
4764
|
if (!resolved)
|
|
4711
4765
|
return null;
|
|
@@ -4772,6 +4826,8 @@ function matchQueryHrefCall(callee, args, localNames) {
|
|
|
4772
4826
|
return null;
|
|
4773
4827
|
const triples = [];
|
|
4774
4828
|
for (const p of obj.properties) {
|
|
4829
|
+
if (p.kind === "spread")
|
|
4830
|
+
return null;
|
|
4775
4831
|
const v = p.value;
|
|
4776
4832
|
if (v.kind === "conditional" && isOmitBranch(v.alternate)) {
|
|
4777
4833
|
triples.push({ guard: v.test, key: p.key, value: v.consequent });
|
|
@@ -4959,6 +5015,8 @@ function htmlPropValue(parsed) {
|
|
|
4959
5015
|
if (parsed.properties.length !== 1)
|
|
4960
5016
|
return null;
|
|
4961
5017
|
const [prop] = parsed.properties;
|
|
5018
|
+
if (prop.kind === "spread")
|
|
5019
|
+
return null;
|
|
4962
5020
|
if (prop.key !== "__html")
|
|
4963
5021
|
return null;
|
|
4964
5022
|
return prop.value;
|
|
@@ -5873,8 +5931,15 @@ class JinjaTopLevelEmitter {
|
|
|
5873
5931
|
unsupported(_raw, _reason) {
|
|
5874
5932
|
return "''";
|
|
5875
5933
|
}
|
|
5876
|
-
objectLiteral(properties, _raw,
|
|
5877
|
-
|
|
5934
|
+
objectLiteral(properties, _raw, emit) {
|
|
5935
|
+
if (properties.length === 0)
|
|
5936
|
+
return "{}";
|
|
5937
|
+
const literalOf = (run) => `{${run.map((p) => `${jinjaHashKey(p.key)}: ${emit(p.value)}`).join(", ")}}`;
|
|
5938
|
+
if (!properties.some((p) => p.kind === "spread")) {
|
|
5939
|
+
return literalOf(properties);
|
|
5940
|
+
}
|
|
5941
|
+
const segments = groupObjectLiteralSegments(properties, literalOf, emit);
|
|
5942
|
+
return segments.reduce((acc, seg) => `dict(${acc}, **${seg.includes(" ") ? `(${seg})` : seg})`);
|
|
5878
5943
|
}
|
|
5879
5944
|
}
|
|
5880
5945
|
|
|
@@ -5987,6 +6052,8 @@ function objectLiteralExprToJinjaDict(ctx, expr) {
|
|
|
5987
6052
|
function objectLiteralToJinjaDict(ctx, obj) {
|
|
5988
6053
|
const entries = [];
|
|
5989
6054
|
for (const prop of obj.properties) {
|
|
6055
|
+
if (prop.kind === "spread")
|
|
6056
|
+
return null;
|
|
5990
6057
|
if (prop.shorthand)
|
|
5991
6058
|
return null;
|
|
5992
6059
|
if (prop.keyKind === "numeric")
|
|
@@ -6057,7 +6124,7 @@ function generateDerivedMemoSeed(ctx, ir) {
|
|
|
6057
6124
|
continue;
|
|
6058
6125
|
const materialized = materializeGetterCalls(step.parsed, knownGetterNames);
|
|
6059
6126
|
const errorsBefore = ctx.errors.length;
|
|
6060
|
-
const jinja = ctx.convertExpressionToJinja("", materialized);
|
|
6127
|
+
const jinja = ctx.convertExpressionToJinja("", materialized, "value");
|
|
6061
6128
|
if (ctx.errors.length > errorsBefore) {
|
|
6062
6129
|
ctx.errors.length = errorsBefore;
|
|
6063
6130
|
continue;
|
|
@@ -6877,11 +6944,11 @@ ${reason}` : "";
|
|
|
6877
6944
|
}
|
|
6878
6945
|
get memoCtx() {
|
|
6879
6946
|
return {
|
|
6880
|
-
convertExpressionToJinja: (e, preParsed) => this.convertExpressionToJinja(e, preParsed),
|
|
6947
|
+
convertExpressionToJinja: (e, preParsed, pos) => this.convertExpressionToJinja(e, preParsed, pos),
|
|
6881
6948
|
errors: this.errors
|
|
6882
6949
|
};
|
|
6883
6950
|
}
|
|
6884
|
-
convertExpressionToJinja(expr, preParsed) {
|
|
6951
|
+
convertExpressionToJinja(expr, preParsed, pos = "rendered") {
|
|
6885
6952
|
let parsed;
|
|
6886
6953
|
if (preParsed) {
|
|
6887
6954
|
parsed = preParsed;
|
|
@@ -6904,7 +6971,7 @@ ${reason}` : "";
|
|
|
6904
6971
|
}
|
|
6905
6972
|
}
|
|
6906
6973
|
}
|
|
6907
|
-
const support = isSupported(parsed);
|
|
6974
|
+
const support = pos === "value" ? isSupportedValue(parsed) : isSupported(parsed);
|
|
6908
6975
|
if (!support.supported) {
|
|
6909
6976
|
this.errors.push({
|
|
6910
6977
|
code: "BF101",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@barefootjs/jinja",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.33.0",
|
|
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.33.0"
|
|
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.33.0",
|
|
74
|
+
"@barefootjs/vite": "0.33.0",
|
|
75
|
+
"@barefootjs/client": "0.33.0",
|
|
76
76
|
"typescript": "^5.0.0",
|
|
77
77
|
"vite": "^6.0.0"
|
|
78
78
|
}
|
|
@@ -143,8 +143,22 @@ def evaluate(node: Any, env: dict) -> Any:
|
|
|
143
143
|
if kind == "array-literal":
|
|
144
144
|
return [evaluate(e, env) for e in node.get("elements") or []]
|
|
145
145
|
if kind == "object-literal":
|
|
146
|
+
# Each entry carries its own "kind" ("prop" | "spread", #2696 Step
|
|
147
|
+
# 2) -- the same encoding the Go evaluator (eval.go) and the raw
|
|
148
|
+
# ParsedExpr shape the eval-vectors.json golden corpus carry, so
|
|
149
|
+
# this one decoder serves both a compiled `*_eval` payload and the
|
|
150
|
+
# golden-vector JSON directly. A "spread" evaluates its "expr" and
|
|
151
|
+
# shallow-merges the result's own keys (a non-dict result --
|
|
152
|
+
# including a null/undefined JS spread source -- is a no-op); a
|
|
153
|
+
# "prop" sets one key. Later entries win on a shared key, in source
|
|
154
|
+
# order, matching JS object-spread exactly.
|
|
146
155
|
out: dict = {}
|
|
147
156
|
for prop in node.get("properties") or []:
|
|
157
|
+
if (prop.get("kind") or "") == "spread":
|
|
158
|
+
spread = evaluate(prop.get("expr"), env)
|
|
159
|
+
if isinstance(spread, dict):
|
|
160
|
+
out.update(spread)
|
|
161
|
+
continue
|
|
148
162
|
out[prop.get("key")] = evaluate(prop.get("value"), env)
|
|
149
163
|
return out
|
|
150
164
|
if kind == "array-method":
|
|
@@ -100,8 +100,11 @@ export interface JinjaMemoContext {
|
|
|
100
100
|
/**
|
|
101
101
|
* Lower a JS expression to its Jinja form (the core recursive entry). See
|
|
102
102
|
* `JinjaSpreadContext.convertExpressionToJinja` for the `preParsed` contract.
|
|
103
|
+
* `pos` (default `'rendered'`) must be `'value'` for a derived-seed RHS —
|
|
104
|
+
* an assignment, not a render — so the internal support gate matches the
|
|
105
|
+
* `isSupportedValue` classification the seed plan already used.
|
|
103
106
|
*/
|
|
104
|
-
convertExpressionToJinja(expr: string, preParsed?: ParsedExpr): string
|
|
107
|
+
convertExpressionToJinja(expr: string, preParsed?: ParsedExpr, pos?: 'rendered' | 'value'): string
|
|
105
108
|
|
|
106
109
|
/**
|
|
107
110
|
* Per-compile diagnostic list `convertExpressionToJinja` appends to on an
|
|
@@ -49,6 +49,7 @@
|
|
|
49
49
|
*/
|
|
50
50
|
|
|
51
51
|
import { groupBinaryOperand,
|
|
52
|
+
groupObjectLiteralSegments,
|
|
52
53
|
type ParsedExprEmitter,
|
|
53
54
|
type HigherOrderMethod,
|
|
54
55
|
type ArrayMethod,
|
|
@@ -64,7 +65,7 @@ import { groupBinaryOperand,
|
|
|
64
65
|
|
|
65
66
|
import type { JinjaEmitContext } from '../emit-context.ts'
|
|
66
67
|
import { JINJA_TEMPLATE_PRIMITIVES } from '../lib/constants.ts'
|
|
67
|
-
import { jinjaIdent, escapeJinjaSingleQuoted } from '../lib/jinja-naming.ts'
|
|
68
|
+
import { jinjaIdent, escapeJinjaSingleQuoted, jinjaHashKey } from '../lib/jinja-naming.ts'
|
|
68
69
|
import { isBooleanResultParsed } from '../boolean-result.ts'
|
|
69
70
|
import {
|
|
70
71
|
renderArrayMethod,
|
|
@@ -636,16 +637,25 @@ export class JinjaTopLevelEmitter implements ParsedExprEmitter {
|
|
|
636
637
|
return "''"
|
|
637
638
|
}
|
|
638
639
|
|
|
639
|
-
objectLiteral(properties: ObjectLiteralProperty[], _raw: string,
|
|
640
|
-
//
|
|
641
|
-
//
|
|
642
|
-
//
|
|
643
|
-
//
|
|
644
|
-
//
|
|
645
|
-
//
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
640
|
+
objectLiteral(properties: ObjectLiteralProperty[], _raw: string, emit: (e: ParsedExpr) => string): string {
|
|
641
|
+
// Reachable here in VALUE position (a `.map()` receiver/callback body, an
|
|
642
|
+
// array-literal element, …) since `isSupportedValue` admits an object
|
|
643
|
+
// literal whose every property value is itself supported
|
|
644
|
+
// (expression-parser.ts, `checkSupport`'s `pos` parameter). Emit a Jinja
|
|
645
|
+
// dict literal, keyed the same way `objectLiteralToJinjaDict` quotes the
|
|
646
|
+
// spread-path literal.
|
|
647
|
+
if (properties.length === 0) return '{}'
|
|
648
|
+
const literalOf = (run: readonly Extract<ObjectLiteralProperty, { kind: 'prop' }>[]) =>
|
|
649
|
+
`{${run.map(p => `${jinjaHashKey(p.key)}: ${emit(p.value)}`).join(', ')}}`
|
|
650
|
+
if (!properties.some(p => p.kind === 'spread')) {
|
|
651
|
+
return literalOf(properties as Extract<ObjectLiteralProperty, { kind: 'prop' }>[])
|
|
652
|
+
}
|
|
653
|
+
// Spread (`{ ...t, editing: false }`, #2696 Step 2): real Jinja2
|
|
654
|
+
// (unlike minijinja) supports `**expr` kwargs-unpacking at a call site,
|
|
655
|
+
// so `dict(base, **override)` — Python's own dict-merge idiom, which
|
|
656
|
+
// Jinja2's `dict()` global mirrors exactly — folds ANY segment onto the
|
|
657
|
+
// accumulator, later segments winning, matching JS spread left-to-right.
|
|
658
|
+
const segments = groupObjectLiteralSegments(properties, literalOf, emit)
|
|
659
|
+
return segments.reduce((acc, seg) => `dict(${acc}, **${seg.includes(' ') ? `(${seg})` : seg})`)
|
|
650
660
|
}
|
|
651
661
|
}
|
|
@@ -124,6 +124,7 @@ import {
|
|
|
124
124
|
parseProviderObjectLiteral,
|
|
125
125
|
parseStyleObjectEntries,
|
|
126
126
|
isSupported,
|
|
127
|
+
isSupportedValue,
|
|
127
128
|
emitParsedExpr,
|
|
128
129
|
emitIRNode,
|
|
129
130
|
emitAttrValue,
|
|
@@ -1731,12 +1732,12 @@ export class JinjaAdapter extends BaseAdapter implements IRNodeEmitter<JinjaRend
|
|
|
1731
1732
|
/** Build the narrow context the extracted memo seeding depends on. */
|
|
1732
1733
|
private get memoCtx(): JinjaMemoContext {
|
|
1733
1734
|
return {
|
|
1734
|
-
convertExpressionToJinja: (e, preParsed) => this.convertExpressionToJinja(e, preParsed),
|
|
1735
|
+
convertExpressionToJinja: (e, preParsed, pos) => this.convertExpressionToJinja(e, preParsed, pos),
|
|
1735
1736
|
errors: this.errors,
|
|
1736
1737
|
}
|
|
1737
1738
|
}
|
|
1738
1739
|
|
|
1739
|
-
private convertExpressionToJinja(expr: string, preParsed?: ParsedExpr): string {
|
|
1740
|
+
private convertExpressionToJinja(expr: string, preParsed?: ParsedExpr, pos: 'rendered' | 'value' = 'rendered'): string {
|
|
1740
1741
|
// Parse-first lowering — parity with the Xslate adapter's
|
|
1741
1742
|
// `convertExpressionToKolon`. Parse the JS expression once, gate it on the
|
|
1742
1743
|
// shared `isSupported`, and render every supported shape through the AST
|
|
@@ -1788,7 +1789,11 @@ export class JinjaAdapter extends BaseAdapter implements IRNodeEmitter<JinjaRend
|
|
|
1788
1789
|
}
|
|
1789
1790
|
}
|
|
1790
1791
|
|
|
1791
|
-
|
|
1792
|
+
// `pos` distinguishes a derived-seed RHS (an assignment, checked via
|
|
1793
|
+
// `isSupportedValue`) from every other, genuinely rendered call site —
|
|
1794
|
+
// the rendered gate would otherwise re-refuse a tree the seed plan
|
|
1795
|
+
// already classified `derived` at value position (#2696 review).
|
|
1796
|
+
const support = pos === 'value' ? isSupportedValue(parsed) : isSupported(parsed)
|
|
1792
1797
|
if (!support.supported) {
|
|
1793
1798
|
this.errors.push({
|
|
1794
1799
|
code: 'BF101',
|
package/src/adapter/memo/seed.ts
CHANGED
|
@@ -120,7 +120,8 @@ export function generateDerivedMemoSeed(ctx: JinjaMemoContext, ir: ComponentIR):
|
|
|
120
120
|
if (step.kind !== 'derived') continue
|
|
121
121
|
const materialized = materializeGetterCalls(step.parsed, knownGetterNames)
|
|
122
122
|
const errorsBefore = ctx.errors.length
|
|
123
|
-
|
|
123
|
+
// `'value'` — this RHS is an assignment, not a render (#2696 review).
|
|
124
|
+
const jinja = ctx.convertExpressionToJinja('', materialized, 'value')
|
|
124
125
|
if (ctx.errors.length > errorsBefore) {
|
|
125
126
|
ctx.errors.length = errorsBefore
|
|
126
127
|
continue
|
|
@@ -80,6 +80,10 @@ export function objectLiteralToJinjaDict(
|
|
|
80
80
|
): string | null {
|
|
81
81
|
const entries: string[] = []
|
|
82
82
|
for (const prop of obj.properties) {
|
|
83
|
+
// A spread (`{ ...t }`, #2696 Step 2) isn't a per-key entry this
|
|
84
|
+
// conditional-spread inline lowering can express — bail, same as any
|
|
85
|
+
// other unsupported shape (the caller falls back to the generic path).
|
|
86
|
+
if (prop.kind === 'spread') return null
|
|
83
87
|
// Shorthand `{ a }` was a `ShorthandPropertyAssignment` (not a
|
|
84
88
|
// `PropertyAssignment`), so the former parser rejected it — keep refusing.
|
|
85
89
|
if (prop.shorthand) return null
|
|
@@ -9,11 +9,10 @@
|
|
|
9
9
|
|
|
10
10
|
import type { RenderDivergences } from '@barefootjs/jsx'
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
12
|
+
// #2696 graduated: `todo-app` / `todo-app-ssr` seeded `todos` opaque
|
|
13
|
+
// because their `.map(t => ({ ...t, editing: false }))` callback body's
|
|
14
|
+
// object-literal SPREAD refused (`checkSupport`). Step 2 admits a spread
|
|
15
|
+
// at value position and the runtime evaluator's `object-literal` case
|
|
16
|
+
// now merges it, so the seed classifies `derived` and SSRs identically
|
|
17
|
+
// to Hono.
|
|
18
|
+
export const renderDivergences: RenderDivergences = {}
|