@barefootjs/xslate 0.31.10 → 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 +5 -2
- 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/memo/seed.d.ts.map +1 -1
- package/dist/adapter/spread/spread-codegen.d.ts.map +1 -1
- package/dist/adapter/xslate-adapter.d.ts.map +1 -1
- package/dist/index.js +17 -6
- package/dist/render-divergences.d.ts.map +1 -1
- package/dist/vite.js +109 -42
- package/lib/BarefootJS/Backend/Xslate.pm +1 -1
- package/package.json +5 -5
- package/src/adapter/emit-context.ts +5 -2
- package/src/adapter/expr/emitters.ts +22 -11
- package/src/adapter/memo/seed.ts +2 -1
- package/src/adapter/spread/spread-codegen.ts +4 -0
- package/src/adapter/xslate-adapter.ts +8 -3
- package/src/render-divergences.ts +6 -0
- package/src/test-render.ts +9 -26
|
@@ -89,8 +89,11 @@ export interface XslateMemoContext {
|
|
|
89
89
|
* re-parsing `expr` — mirrors go-template's
|
|
90
90
|
* `convertExpressionToGo(jsExpr, out?, preParsed?)`. With `preParsed` set,
|
|
91
91
|
* `expr` is unused for parsing (the converter derives any diagnostic text
|
|
92
|
-
* from the tree), so callers may pass `''`.
|
|
92
|
+
* from the tree), so callers may pass `''`. `pos` (default `'rendered'`)
|
|
93
|
+
* must be `'value'` for a derived-seed RHS — an assignment, not a render —
|
|
94
|
+
* so the internal support gate matches the `isSupportedValue`
|
|
95
|
+
* classification the seed plan already used.
|
|
93
96
|
*/
|
|
94
|
-
convertExpressionToKolon(expr: string, preParsed?: ParsedExpr): string;
|
|
97
|
+
convertExpressionToKolon(expr: string, preParsed?: ParsedExpr, pos?: 'rendered' | 'value'): string;
|
|
95
98
|
}
|
|
96
99
|
//# sourceMappingURL=emit-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C,gBAAgB,CAAC,CAAA;IAErD,sEAAsE;IACtE,QAAQ,CAAC,WAAW,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;IAExC;;;;;;;;;OASG;IACH,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,UAAU,GAAG,MAAM,CAAA;CACvE;AAED;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;;;;;;;;;OAYG;IACH,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,UAAU,EAAE,GAAG,CAAC,EAAE,UAAU,GAAG,OAAO,GAAG,MAAM,CAAA;CACnG"}
|
|
@@ -95,6 +95,6 @@ export declare class XslateTopLevelEmitter implements ParsedExprEmitter {
|
|
|
95
95
|
arrow(_params: string[], _body: ParsedExpr): string;
|
|
96
96
|
regex(_raw: string): string;
|
|
97
97
|
unsupported(_raw: string, _reason: string): string;
|
|
98
|
-
objectLiteral(properties: ObjectLiteralProperty[], _raw: string,
|
|
98
|
+
objectLiteral(properties: ObjectLiteralProperty[], _raw: string, emit: (e: ParsedExpr) => string): string;
|
|
99
99
|
}
|
|
100
100
|
//# sourceMappingURL=emitters.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emitters.d.ts","sourceRoot":"","sources":["../../../src/adapter/expr/emitters.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"emitters.d.ts","sourceRoot":"","sources":["../../../src/adapter/expr/emitters.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAGL,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,iBAAiB,E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,MAAM,GAC9B,MAAM,CAER;IAED,eAAe,CAAC,KAAK,EAAE,YAAY,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,MAAM,GAAG,MAAM,CAoB9E;IAED,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,UAAU,GAAG,MAAM,CAKlD;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,
|
|
@@ -187667,6 +187668,7 @@ function staticValueToKolon(value) {
|
|
|
187667
187668
|
// src/adapter/expr/emitters.ts
|
|
187668
187669
|
import {
|
|
187669
187670
|
groupBinaryOperand,
|
|
187671
|
+
groupObjectLiteralSegments,
|
|
187670
187672
|
isStringConcatBinary,
|
|
187671
187673
|
identifierPath,
|
|
187672
187674
|
matchSearchParamsMethodCall,
|
|
@@ -188009,8 +188011,15 @@ class XslateTopLevelEmitter {
|
|
|
188009
188011
|
unsupported(_raw, _reason) {
|
|
188010
188012
|
return "''";
|
|
188011
188013
|
}
|
|
188012
|
-
objectLiteral(properties, _raw,
|
|
188013
|
-
|
|
188014
|
+
objectLiteral(properties, _raw, emit) {
|
|
188015
|
+
if (properties.length === 0)
|
|
188016
|
+
return "{}";
|
|
188017
|
+
const literalOf = (run) => `{ ${run.map((p) => `'${escapeKolonSingleQuoted(p.key)}' => ${emit(p.value)}`).join(", ")} }`;
|
|
188018
|
+
if (!properties.some((p) => p.kind === "spread")) {
|
|
188019
|
+
return literalOf(properties);
|
|
188020
|
+
}
|
|
188021
|
+
const segments = groupObjectLiteralSegments(properties, literalOf, emit);
|
|
188022
|
+
return segments.reduce((acc, seg) => `${acc}.merge(${seg})`);
|
|
188014
188023
|
}
|
|
188015
188024
|
}
|
|
188016
188025
|
|
|
@@ -188124,6 +188133,8 @@ function objectLiteralExprToKolonHashref(ctx, expr) {
|
|
|
188124
188133
|
function objectLiteralToKolonHashref(ctx, obj) {
|
|
188125
188134
|
const entries = [];
|
|
188126
188135
|
for (const prop of obj.properties) {
|
|
188136
|
+
if (prop.kind === "spread")
|
|
188137
|
+
return null;
|
|
188127
188138
|
if (prop.shorthand)
|
|
188128
188139
|
return null;
|
|
188129
188140
|
if (prop.keyKind === "numeric")
|
|
@@ -188195,7 +188206,7 @@ function generateDerivedMemoSeed(ctx, ir) {
|
|
|
188195
188206
|
for (const step of plan.steps) {
|
|
188196
188207
|
if (step.kind !== "derived")
|
|
188197
188208
|
continue;
|
|
188198
|
-
const kolon = ctx.convertExpressionToKolon(step.expr, step.parsed);
|
|
188209
|
+
const kolon = ctx.convertExpressionToKolon(step.expr, step.parsed, "value");
|
|
188199
188210
|
if (kolon === "" || !/\$[A-Za-z_]\w*/.test(kolon))
|
|
188200
188211
|
continue;
|
|
188201
188212
|
if (new RegExp(`\\$${step.name}\\b`).test(kolon)) {
|
|
@@ -189026,9 +189037,9 @@ ${reason}` : "";
|
|
|
189026
189037
|
};
|
|
189027
189038
|
}
|
|
189028
189039
|
get memoCtx() {
|
|
189029
|
-
return { convertExpressionToKolon: (e, preParsed) => this.convertExpressionToKolon(e, preParsed) };
|
|
189040
|
+
return { convertExpressionToKolon: (e, preParsed, pos) => this.convertExpressionToKolon(e, preParsed, pos) };
|
|
189030
189041
|
}
|
|
189031
|
-
convertExpressionToKolon(expr, preParsed) {
|
|
189042
|
+
convertExpressionToKolon(expr, preParsed, pos = "rendered") {
|
|
189032
189043
|
let parsed;
|
|
189033
189044
|
if (preParsed) {
|
|
189034
189045
|
parsed = preParsed;
|
|
@@ -189051,7 +189062,7 @@ ${reason}` : "";
|
|
|
189051
189062
|
}
|
|
189052
189063
|
}
|
|
189053
189064
|
}
|
|
189054
|
-
const support = isSupported(parsed);
|
|
189065
|
+
const support = pos === "value" ? isSupportedValue(parsed) : isSupported(parsed);
|
|
189055
189066
|
if (!support.supported) {
|
|
189056
189067
|
this.errors.push({
|
|
189057
189068
|
code: "BF101",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"seed.d.ts","sourceRoot":"","sources":["../../../src/adapter/memo/seed.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,eAAe,EAGrB,MAAM,iBAAiB,CAAA;AAExB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAE3D,sEAAsE;AACtE,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,eAAe,GAAG,MAAM,CAM9D;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,EAAE,EAAE,WAAW,GAAG,MAAM,CAWnE;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,iBAAiB,EAAE,EAAE,EAAE,WAAW,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"seed.d.ts","sourceRoot":"","sources":["../../../src/adapter/memo/seed.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,eAAe,EAGrB,MAAM,iBAAiB,CAAA;AAExB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAE3D,sEAAsE;AACtE,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,eAAe,GAAG,MAAM,CAM9D;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,EAAE,EAAE,WAAW,GAAG,MAAM,CAWnE;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,iBAAiB,EAAE,EAAE,EAAE,WAAW,GAAG,MAAM,CA6BvF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spread-codegen.d.ts","sourceRoot":"","sources":["../../../src/adapter/spread/spread-codegen.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEjD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAG7D;;;;;;;;;;;GAWG;AACH,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,mBAAmB,EACxB,IAAI,EAAE,UAAU,GAAG,SAAS,GAC3B,MAAM,GAAG,IAAI,CAef;AAED;;;;;GAKG;AACH,wBAAgB,+BAA+B,CAC7C,GAAG,EAAE,mBAAmB,EACxB,IAAI,EAAE,UAAU,GAAG,SAAS,GAC3B,MAAM,GAAG,IAAI,CAGf;AAED;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CACzC,GAAG,EAAE,mBAAmB,EACxB,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;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEjD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAG7D;;;;;;;;;;;GAWG;AACH,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,mBAAmB,EACxB,IAAI,EAAE,UAAU,GAAG,SAAS,GAC3B,MAAM,GAAG,IAAI,CAef;AAED;;;;;GAKG;AACH,wBAAgB,+BAA+B,CAC7C,GAAG,EAAE,mBAAmB,EACxB,IAAI,EAAE,UAAU,GAAG,SAAS,GAC3B,MAAM,GAAG,IAAI,CAGf;AAED;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CACzC,GAAG,EAAE,mBAAmB,EACxB,GAAG,EAAE,OAAO,CAAC,UAAU,EAAE;IAAE,IAAI,EAAE,gBAAgB,CAAA;CAAE,CAAC,GACnD,MAAM,GAAG,IAAI,CAiDf;AAUD;;;;;;;;;;;GAWG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,mBAAmB,EAAE,GAAG,EAAE,UAAU,GAAG,MAAM,GAAG,IAAI,CAwBjG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xslate-adapter.d.ts","sourceRoot":"","sources":["../../src/adapter/xslate-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,MAAM,EACN,SAAS,EACT,MAAM,EACN,YAAY,EACZ,aAAa,EACb,MAAM,EACN,WAAW,EACX,UAAU,EACV,MAAM,EACN,aAAa,EACb,UAAU,EACV,OAAO,EAKP,yBAAyB,EAG1B,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,WAAW,EACX,KAAK,aAAa,EAClB,KAAK,sBAAsB,EAE3B,KAAK,aAAa,EAClB,KAAK,UAAU,
|
|
1
|
+
{"version":3,"file":"xslate-adapter.d.ts","sourceRoot":"","sources":["../../src/adapter/xslate-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,MAAM,EACN,SAAS,EACT,MAAM,EACN,YAAY,EACZ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187298
|
parseStyleObjectEntries,
|
|
187299
187299
|
isSupported,
|
|
187300
|
+
isSupportedValue,
|
|
187300
187301
|
emitParsedExpr,
|
|
187301
187302
|
emitIRNode,
|
|
187302
187303
|
emitAttrValue,
|
|
@@ -187667,6 +187668,7 @@ function staticValueToKolon(value) {
|
|
|
187667
187668
|
// src/adapter/expr/emitters.ts
|
|
187668
187669
|
import {
|
|
187669
187670
|
groupBinaryOperand,
|
|
187671
|
+
groupObjectLiteralSegments,
|
|
187670
187672
|
isStringConcatBinary,
|
|
187671
187673
|
identifierPath,
|
|
187672
187674
|
matchSearchParamsMethodCall,
|
|
@@ -188009,8 +188011,15 @@ class XslateTopLevelEmitter {
|
|
|
188009
188011
|
unsupported(_raw, _reason) {
|
|
188010
188012
|
return "''";
|
|
188011
188013
|
}
|
|
188012
|
-
objectLiteral(properties, _raw,
|
|
188013
|
-
|
|
188014
|
+
objectLiteral(properties, _raw, emit) {
|
|
188015
|
+
if (properties.length === 0)
|
|
188016
|
+
return "{}";
|
|
188017
|
+
const literalOf = (run) => `{ ${run.map((p) => `'${escapeKolonSingleQuoted(p.key)}' => ${emit(p.value)}`).join(", ")} }`;
|
|
188018
|
+
if (!properties.some((p) => p.kind === "spread")) {
|
|
188019
|
+
return literalOf(properties);
|
|
188020
|
+
}
|
|
188021
|
+
const segments = groupObjectLiteralSegments(properties, literalOf, emit);
|
|
188022
|
+
return segments.reduce((acc, seg) => `${acc}.merge(${seg})`);
|
|
188014
188023
|
}
|
|
188015
188024
|
}
|
|
188016
188025
|
|
|
@@ -188124,6 +188133,8 @@ function objectLiteralExprToKolonHashref(ctx, expr) {
|
|
|
188124
188133
|
function objectLiteralToKolonHashref(ctx, obj) {
|
|
188125
188134
|
const entries = [];
|
|
188126
188135
|
for (const prop of obj.properties) {
|
|
188136
|
+
if (prop.kind === "spread")
|
|
188137
|
+
return null;
|
|
188127
188138
|
if (prop.shorthand)
|
|
188128
188139
|
return null;
|
|
188129
188140
|
if (prop.keyKind === "numeric")
|
|
@@ -188195,7 +188206,7 @@ function generateDerivedMemoSeed(ctx, ir) {
|
|
|
188195
188206
|
for (const step of plan.steps) {
|
|
188196
188207
|
if (step.kind !== "derived")
|
|
188197
188208
|
continue;
|
|
188198
|
-
const kolon = ctx.convertExpressionToKolon(step.expr, step.parsed);
|
|
188209
|
+
const kolon = ctx.convertExpressionToKolon(step.expr, step.parsed, "value");
|
|
188199
188210
|
if (kolon === "" || !/\$[A-Za-z_]\w*/.test(kolon))
|
|
188200
188211
|
continue;
|
|
188201
188212
|
if (new RegExp(`\\$${step.name}\\b`).test(kolon)) {
|
|
@@ -189026,9 +189037,9 @@ ${reason}` : "";
|
|
|
189026
189037
|
};
|
|
189027
189038
|
}
|
|
189028
189039
|
get memoCtx() {
|
|
189029
|
-
return { convertExpressionToKolon: (e, preParsed) => this.convertExpressionToKolon(e, preParsed) };
|
|
189040
|
+
return { convertExpressionToKolon: (e, preParsed, pos) => this.convertExpressionToKolon(e, preParsed, pos) };
|
|
189030
189041
|
}
|
|
189031
|
-
convertExpressionToKolon(expr, preParsed) {
|
|
189042
|
+
convertExpressionToKolon(expr, preParsed, pos = "rendered") {
|
|
189032
189043
|
let parsed;
|
|
189033
189044
|
if (preParsed) {
|
|
189034
189045
|
parsed = preParsed;
|
|
@@ -189051,7 +189062,7 @@ ${reason}` : "";
|
|
|
189051
189062
|
}
|
|
189052
189063
|
}
|
|
189053
189064
|
}
|
|
189054
|
-
const support = isSupported(parsed);
|
|
189065
|
+
const support = pos === "value" ? isSupportedValue(parsed) : isSupported(parsed);
|
|
189055
189066
|
if (!support.supported) {
|
|
189056
189067
|
this.errors.push({
|
|
189057
189068
|
code: "BF101",
|
|
@@ -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;AAexD,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":
|
|
@@ -1657,7 +1671,7 @@ function freeVarsInBody(body, params) {
|
|
|
1657
1671
|
return;
|
|
1658
1672
|
case "object-literal":
|
|
1659
1673
|
for (const p of e.properties)
|
|
1660
|
-
visit(p.value, bound);
|
|
1674
|
+
visit(p.kind === "spread" ? p.expr : p.value, bound);
|
|
1661
1675
|
return;
|
|
1662
1676
|
case "array-method":
|
|
1663
1677
|
if (e.method === "includes" || e.method === "join") {
|
|
@@ -1732,7 +1746,7 @@ function freeIdentifiers(expr) {
|
|
|
1732
1746
|
return true;
|
|
1733
1747
|
case "object-literal":
|
|
1734
1748
|
for (const p of e.properties)
|
|
1735
|
-
if (!visit(p.value, bound))
|
|
1749
|
+
if (!visit(p.kind === "spread" ? p.expr : p.value, bound))
|
|
1736
1750
|
return false;
|
|
1737
1751
|
return true;
|
|
1738
1752
|
case "arrow": {
|
|
@@ -1879,10 +1893,17 @@ function toEvalNode(e) {
|
|
|
1879
1893
|
case "object-literal": {
|
|
1880
1894
|
const properties = [];
|
|
1881
1895
|
for (const p of e.properties) {
|
|
1896
|
+
if (p.kind === "spread") {
|
|
1897
|
+
const spreadExpr = toEvalNode(p.expr);
|
|
1898
|
+
if (!spreadExpr)
|
|
1899
|
+
return null;
|
|
1900
|
+
properties.push({ kind: "spread", expr: spreadExpr });
|
|
1901
|
+
continue;
|
|
1902
|
+
}
|
|
1882
1903
|
const value = toEvalNode(p.value);
|
|
1883
1904
|
if (!value)
|
|
1884
1905
|
return null;
|
|
1885
|
-
properties.push({ key: p.key, value });
|
|
1906
|
+
properties.push({ kind: "prop", key: p.key, value });
|
|
1886
1907
|
}
|
|
1887
1908
|
return { kind: "object-literal", properties };
|
|
1888
1909
|
}
|
|
@@ -2915,6 +2936,8 @@ function matchToLocaleDateStringCall(callee, args, metadata) {
|
|
|
2915
2936
|
let tz = null;
|
|
2916
2937
|
const probeOptions = {};
|
|
2917
2938
|
for (const prop of options.properties) {
|
|
2939
|
+
if (prop.kind === "spread")
|
|
2940
|
+
return null;
|
|
2918
2941
|
if (prop.value.kind !== "literal" || prop.value.literalType !== "string")
|
|
2919
2942
|
return null;
|
|
2920
2943
|
const value = String(prop.value.value);
|
|
@@ -3905,7 +3928,7 @@ function parseRecordIndexAccess(val, localConstants, propsParams, resolveKey) {
|
|
|
3905
3928
|
|
|
3906
3929
|
// ../jsx/src/ssr-seed-plan.ts
|
|
3907
3930
|
function classify(name, origin, expr, parsed, available) {
|
|
3908
|
-
if (!
|
|
3931
|
+
if (!isSupportedValue(parsed).supported)
|
|
3909
3932
|
return { kind: "opaque", name, origin };
|
|
3910
3933
|
const frees = freeIdentifiers(parsed);
|
|
3911
3934
|
if (frees === null)
|
|
@@ -3968,7 +3991,7 @@ function computeSsrSeedPlan(metadata) {
|
|
|
3968
3991
|
}
|
|
3969
3992
|
}
|
|
3970
3993
|
const expr = signal.initialValue.trim();
|
|
3971
|
-
steps.push(expr === "" ? { kind: "opaque", name: signal.getter, origin: "signal" } : classify(signal.getter, "signal", expr, resolveThroughLocalConsts(parseExpression(expr), localConsts), available));
|
|
3994
|
+
steps.push(expr === "" ? { kind: "opaque", name: signal.getter, origin: "signal" } : classify(signal.getter, "signal", expr, resolveThroughLocalConsts(signal.parsed ?? parseExpression(`(${expr})`), localConsts), available));
|
|
3972
3995
|
available.add(signal.getter);
|
|
3973
3996
|
}
|
|
3974
3997
|
for (const memo of metadata.memos) {
|
|
@@ -4595,6 +4618,26 @@ function isStringConcatBinary(op, left, right, isStringName) {
|
|
|
4595
4618
|
function groupBinaryOperand(operand, emitted) {
|
|
4596
4619
|
return operand.kind === "binary" || operand.kind === "logical" || operand.kind === "conditional" ? `(${emitted})` : emitted;
|
|
4597
4620
|
}
|
|
4621
|
+
function groupObjectLiteralSegments(properties, literalOf, emit) {
|
|
4622
|
+
const segments = [];
|
|
4623
|
+
let run = [];
|
|
4624
|
+
const flushRun = () => {
|
|
4625
|
+
if (run.length > 0) {
|
|
4626
|
+
segments.push(literalOf(run));
|
|
4627
|
+
run = [];
|
|
4628
|
+
}
|
|
4629
|
+
};
|
|
4630
|
+
for (const p of properties) {
|
|
4631
|
+
if (p.kind === "spread") {
|
|
4632
|
+
flushRun();
|
|
4633
|
+
segments.push(emit(p.expr));
|
|
4634
|
+
} else {
|
|
4635
|
+
run.push(p);
|
|
4636
|
+
}
|
|
4637
|
+
}
|
|
4638
|
+
flushRun();
|
|
4639
|
+
return segments;
|
|
4640
|
+
}
|
|
4598
4641
|
function emitParsedExpr(expr, emitter) {
|
|
4599
4642
|
const emit = (child) => emitParsedExpr(child, emitter);
|
|
4600
4643
|
switch (expr.kind) {
|
|
@@ -4741,6 +4784,17 @@ function evaluateStaticLiteral(expr, bindings) {
|
|
|
4741
4784
|
case "object-literal": {
|
|
4742
4785
|
const out = {};
|
|
4743
4786
|
for (const prop of expr.properties) {
|
|
4787
|
+
if (prop.kind === "spread") {
|
|
4788
|
+
const resolved2 = evaluateStaticLiteral(prop.expr, bindings);
|
|
4789
|
+
if (!resolved2)
|
|
4790
|
+
return null;
|
|
4791
|
+
if (resolved2.value === null || resolved2.value === undefined)
|
|
4792
|
+
continue;
|
|
4793
|
+
if (typeof resolved2.value !== "object" || Array.isArray(resolved2.value))
|
|
4794
|
+
return null;
|
|
4795
|
+
Object.assign(out, resolved2.value);
|
|
4796
|
+
continue;
|
|
4797
|
+
}
|
|
4744
4798
|
const resolved = evaluateStaticLiteral(prop.value, bindings);
|
|
4745
4799
|
if (!resolved)
|
|
4746
4800
|
return null;
|
|
@@ -4807,6 +4861,8 @@ function matchQueryHrefCall(callee, args, localNames) {
|
|
|
4807
4861
|
return null;
|
|
4808
4862
|
const triples = [];
|
|
4809
4863
|
for (const p of obj.properties) {
|
|
4864
|
+
if (p.kind === "spread")
|
|
4865
|
+
return null;
|
|
4810
4866
|
const v = p.value;
|
|
4811
4867
|
if (v.kind === "conditional" && isOmitBranch(v.alternate)) {
|
|
4812
4868
|
triples.push({ guard: v.test, key: p.key, value: v.consequent });
|
|
@@ -4994,6 +5050,8 @@ function htmlPropValue(parsed) {
|
|
|
4994
5050
|
if (parsed.properties.length !== 1)
|
|
4995
5051
|
return null;
|
|
4996
5052
|
const [prop] = parsed.properties;
|
|
5053
|
+
if (prop.kind === "spread")
|
|
5054
|
+
return null;
|
|
4997
5055
|
if (prop.key !== "__html")
|
|
4998
5056
|
return null;
|
|
4999
5057
|
return prop.value;
|
|
@@ -5853,8 +5911,15 @@ class XslateTopLevelEmitter {
|
|
|
5853
5911
|
unsupported(_raw, _reason) {
|
|
5854
5912
|
return "''";
|
|
5855
5913
|
}
|
|
5856
|
-
objectLiteral(properties, _raw,
|
|
5857
|
-
|
|
5914
|
+
objectLiteral(properties, _raw, emit) {
|
|
5915
|
+
if (properties.length === 0)
|
|
5916
|
+
return "{}";
|
|
5917
|
+
const literalOf = (run) => `{ ${run.map((p) => `'${escapeKolonSingleQuoted(p.key)}' => ${emit(p.value)}`).join(", ")} }`;
|
|
5918
|
+
if (!properties.some((p) => p.kind === "spread")) {
|
|
5919
|
+
return literalOf(properties);
|
|
5920
|
+
}
|
|
5921
|
+
const segments = groupObjectLiteralSegments(properties, literalOf, emit);
|
|
5922
|
+
return segments.reduce((acc, seg) => `${acc}.merge(${seg})`);
|
|
5858
5923
|
}
|
|
5859
5924
|
}
|
|
5860
5925
|
|
|
@@ -5967,6 +6032,8 @@ function objectLiteralExprToKolonHashref(ctx, expr) {
|
|
|
5967
6032
|
function objectLiteralToKolonHashref(ctx, obj) {
|
|
5968
6033
|
const entries = [];
|
|
5969
6034
|
for (const prop of obj.properties) {
|
|
6035
|
+
if (prop.kind === "spread")
|
|
6036
|
+
return null;
|
|
5970
6037
|
if (prop.shorthand)
|
|
5971
6038
|
return null;
|
|
5972
6039
|
if (prop.keyKind === "numeric")
|
|
@@ -6034,7 +6101,7 @@ function generateDerivedMemoSeed(ctx, ir) {
|
|
|
6034
6101
|
for (const step of plan.steps) {
|
|
6035
6102
|
if (step.kind !== "derived")
|
|
6036
6103
|
continue;
|
|
6037
|
-
const kolon = ctx.convertExpressionToKolon(step.expr, step.parsed);
|
|
6104
|
+
const kolon = ctx.convertExpressionToKolon(step.expr, step.parsed, "value");
|
|
6038
6105
|
if (kolon === "" || !/\$[A-Za-z_]\w*/.test(kolon))
|
|
6039
6106
|
continue;
|
|
6040
6107
|
if (new RegExp(`\\$${step.name}\\b`).test(kolon)) {
|
|
@@ -6861,9 +6928,9 @@ ${reason}` : "";
|
|
|
6861
6928
|
};
|
|
6862
6929
|
}
|
|
6863
6930
|
get memoCtx() {
|
|
6864
|
-
return { convertExpressionToKolon: (e, preParsed) => this.convertExpressionToKolon(e, preParsed) };
|
|
6931
|
+
return { convertExpressionToKolon: (e, preParsed, pos) => this.convertExpressionToKolon(e, preParsed, pos) };
|
|
6865
6932
|
}
|
|
6866
|
-
convertExpressionToKolon(expr, preParsed) {
|
|
6933
|
+
convertExpressionToKolon(expr, preParsed, pos = "rendered") {
|
|
6867
6934
|
let parsed;
|
|
6868
6935
|
if (preParsed) {
|
|
6869
6936
|
parsed = preParsed;
|
|
@@ -6886,7 +6953,7 @@ ${reason}` : "";
|
|
|
6886
6953
|
}
|
|
6887
6954
|
}
|
|
6888
6955
|
}
|
|
6889
|
-
const support = isSupported(parsed);
|
|
6956
|
+
const support = pos === "value" ? isSupportedValue(parsed) : isSupported(parsed);
|
|
6890
6957
|
if (!support.supported) {
|
|
6891
6958
|
this.errors.push({
|
|
6892
6959
|
code: "BF101",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@barefootjs/xslate",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.33.0",
|
|
4
4
|
"description": "Text::Xslate (Kolon) adapter for BarefootJS — compiles IR to .tx templates and ships the Xslate rendering backend; runs under any PSGI/Plack app",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"directory": "packages/adapter-xslate"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@barefootjs/shared": "0.
|
|
58
|
+
"@barefootjs/shared": "0.33.0"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
61
|
"@barefootjs/jsx": ">=0.2.0",
|
|
@@ -72,9 +72,9 @@
|
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"@barefootjs/adapter-tests": "0.1.0",
|
|
75
|
-
"@barefootjs/jsx": "0.
|
|
76
|
-
"@barefootjs/vite": "0.
|
|
77
|
-
"@barefootjs/client": "0.
|
|
75
|
+
"@barefootjs/jsx": "0.33.0",
|
|
76
|
+
"@barefootjs/vite": "0.33.0",
|
|
77
|
+
"@barefootjs/client": "0.33.0",
|
|
78
78
|
"typescript": "^5.0.0",
|
|
79
79
|
"vite": "^6.0.0"
|
|
80
80
|
}
|
|
@@ -101,7 +101,10 @@ export interface XslateMemoContext {
|
|
|
101
101
|
* re-parsing `expr` — mirrors go-template's
|
|
102
102
|
* `convertExpressionToGo(jsExpr, out?, preParsed?)`. With `preParsed` set,
|
|
103
103
|
* `expr` is unused for parsing (the converter derives any diagnostic text
|
|
104
|
-
* from the tree), so callers may pass `''`.
|
|
104
|
+
* from the tree), so callers may pass `''`. `pos` (default `'rendered'`)
|
|
105
|
+
* must be `'value'` for a derived-seed RHS — an assignment, not a render —
|
|
106
|
+
* so the internal support gate matches the `isSupportedValue`
|
|
107
|
+
* classification the seed plan already used.
|
|
105
108
|
*/
|
|
106
|
-
convertExpressionToKolon(expr: string, preParsed?: ParsedExpr): string
|
|
109
|
+
convertExpressionToKolon(expr: string, preParsed?: ParsedExpr, pos?: 'rendered' | 'value'): string
|
|
107
110
|
}
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
import { groupBinaryOperand,
|
|
15
|
+
groupObjectLiteralSegments,
|
|
15
16
|
isStringConcatBinary,
|
|
16
17
|
type ParsedExprEmitter,
|
|
17
18
|
type HigherOrderMethod,
|
|
@@ -28,6 +29,7 @@ import { groupBinaryOperand,
|
|
|
28
29
|
|
|
29
30
|
import type { XslateEmitContext } from '../emit-context.ts'
|
|
30
31
|
import { XSLATE_TEMPLATE_PRIMITIVES } from '../lib/constants.ts'
|
|
32
|
+
import { escapeKolonSingleQuoted } from '../lib/kolon-naming.ts'
|
|
31
33
|
import {
|
|
32
34
|
renderArrayMethod,
|
|
33
35
|
renderSortMethod,
|
|
@@ -590,16 +592,25 @@ export class XslateTopLevelEmitter implements ParsedExprEmitter {
|
|
|
590
592
|
return "''"
|
|
591
593
|
}
|
|
592
594
|
|
|
593
|
-
objectLiteral(properties: ObjectLiteralProperty[], _raw: string,
|
|
594
|
-
//
|
|
595
|
-
//
|
|
596
|
-
//
|
|
597
|
-
//
|
|
598
|
-
// literal,
|
|
599
|
-
//
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
595
|
+
objectLiteral(properties: ObjectLiteralProperty[], _raw: string, emit: (e: ParsedExpr) => string): string {
|
|
596
|
+
// Reachable here in VALUE position (a `.map()` receiver/callback body, an
|
|
597
|
+
// array-literal element, …) since `isSupportedValue` admits an object
|
|
598
|
+
// literal whose every property value is itself supported
|
|
599
|
+
// (expression-parser.ts, `checkSupport`'s `pos` parameter). Emit a Kolon
|
|
600
|
+
// hashref literal, quoted the same way `objectLiteralToKolonHashref`
|
|
601
|
+
// quotes the spread-path literal.
|
|
602
|
+
if (properties.length === 0) return '{}'
|
|
603
|
+
const literalOf = (run: readonly Extract<ObjectLiteralProperty, { kind: 'prop' }>[]) =>
|
|
604
|
+
`{ ${run.map(p => `'${escapeKolonSingleQuoted(p.key)}' => ${emit(p.value)}`).join(', ')} }`
|
|
605
|
+
if (!properties.some(p => p.kind === 'spread')) {
|
|
606
|
+
return literalOf(properties as Extract<ObjectLiteralProperty, { kind: 'prop' }>[])
|
|
607
|
+
}
|
|
608
|
+
// Spread (`{ ...t, editing: false }`, #2696 Step 2): Kolon's builtin
|
|
609
|
+
// `$hashref.merge($v)` method (Text::Xslate::Manual::Builtin) returns a
|
|
610
|
+
// new hashref of the receiver overridden by `$v`'s keys — chaining it
|
|
611
|
+
// across every segment folds ANY interleaving of `prop`/`spread`
|
|
612
|
+
// entries left-to-right, later segments winning, matching JS spread.
|
|
613
|
+
const segments = groupObjectLiteralSegments(properties, literalOf, emit)
|
|
614
|
+
return segments.reduce((acc, seg) => `${acc}.merge(${seg})`)
|
|
604
615
|
}
|
|
605
616
|
}
|
package/src/adapter/memo/seed.ts
CHANGED
|
@@ -75,7 +75,8 @@ export function generateDerivedMemoSeed(ctx: XslateMemoContext, ir: ComponentIR)
|
|
|
75
75
|
const lines: string[] = []
|
|
76
76
|
for (const step of plan.steps) {
|
|
77
77
|
if (step.kind !== 'derived') continue
|
|
78
|
-
|
|
78
|
+
// `'value'` — this RHS is an assignment, not a render (#2696 review).
|
|
79
|
+
const kolon = ctx.convertExpressionToKolon(step.expr, step.parsed, 'value')
|
|
79
80
|
if (kolon === '' || !/\$[A-Za-z_]\w*/.test(kolon)) continue
|
|
80
81
|
if (new RegExp(`\\$${step.name}\\b`).test(kolon)) {
|
|
81
82
|
// Self-referencing lowering (#2679): capture the RHS into a
|
|
@@ -88,6 +88,10 @@ export function objectLiteralToKolonHashref(
|
|
|
88
88
|
): string | null {
|
|
89
89
|
const entries: string[] = []
|
|
90
90
|
for (const prop of obj.properties) {
|
|
91
|
+
// A spread (`{ ...t }`, #2696 Step 2) isn't a per-key entry this
|
|
92
|
+
// conditional-spread inline lowering can express — bail, same as any
|
|
93
|
+
// other unsupported shape (the caller falls back to the generic path).
|
|
94
|
+
if (prop.kind === 'spread') return null
|
|
91
95
|
// Shorthand `{ a }` was a `ShorthandPropertyAssignment` (not a
|
|
92
96
|
// `PropertyAssignment`), so the former parser rejected it — keep refusing.
|
|
93
97
|
if (prop.shorthand) return null
|
|
@@ -57,6 +57,7 @@ import {
|
|
|
57
57
|
parseProviderObjectLiteral,
|
|
58
58
|
parseStyleObjectEntries,
|
|
59
59
|
isSupported,
|
|
60
|
+
isSupportedValue,
|
|
60
61
|
emitParsedExpr,
|
|
61
62
|
emitIRNode,
|
|
62
63
|
emitAttrValue,
|
|
@@ -1692,10 +1693,10 @@ export class XslateAdapter extends BaseAdapter implements IRNodeEmitter<XslateRe
|
|
|
1692
1693
|
|
|
1693
1694
|
/** Build the narrow context the extracted memo seeding depends on. */
|
|
1694
1695
|
private get memoCtx(): XslateMemoContext {
|
|
1695
|
-
return { convertExpressionToKolon: (e, preParsed) => this.convertExpressionToKolon(e, preParsed) }
|
|
1696
|
+
return { convertExpressionToKolon: (e, preParsed, pos) => this.convertExpressionToKolon(e, preParsed, pos) }
|
|
1696
1697
|
}
|
|
1697
1698
|
|
|
1698
|
-
private convertExpressionToKolon(expr: string, preParsed?: ParsedExpr): string {
|
|
1699
|
+
private convertExpressionToKolon(expr: string, preParsed?: ParsedExpr, pos: 'rendered' | 'value' = 'rendered'): string {
|
|
1699
1700
|
// Parse-first lowering — parity with the Mojo adapter's
|
|
1700
1701
|
// `convertExpressionToPerl`. Parse the JS expression once, gate it on the
|
|
1701
1702
|
// shared `isSupported`, and render every supported shape through the AST
|
|
@@ -1747,7 +1748,11 @@ export class XslateAdapter extends BaseAdapter implements IRNodeEmitter<XslateRe
|
|
|
1747
1748
|
}
|
|
1748
1749
|
}
|
|
1749
1750
|
|
|
1750
|
-
|
|
1751
|
+
// `pos` distinguishes a derived-seed RHS (an assignment, checked via
|
|
1752
|
+
// `isSupportedValue`) from every other, genuinely rendered call site —
|
|
1753
|
+
// the rendered gate would otherwise re-refuse a tree the seed plan
|
|
1754
|
+
// already classified `derived` at value position (#2696 review).
|
|
1755
|
+
const support = pos === 'value' ? isSupportedValue(parsed) : isSupported(parsed)
|
|
1751
1756
|
if (!support.supported) {
|
|
1752
1757
|
this.errors.push({
|
|
1753
1758
|
code: 'BF101',
|
|
@@ -9,6 +9,12 @@
|
|
|
9
9
|
|
|
10
10
|
import type { RenderDivergences } from '@barefootjs/jsx'
|
|
11
11
|
|
|
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.
|
|
12
18
|
// #2679 graduated (capture-before-shadow in `generateDerivedMemoSeed`,
|
|
13
19
|
// packages/adapter-xslate/src/adapter/memo/seed.ts): a self-referencing
|
|
14
20
|
// derived signal/memo now seeds a throwaway `__bf_seed_<name>` local from
|
package/src/test-render.ts
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* than the Mojo harness's literal `test_<sN>`.
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
import { compileJSX, extractSsrDefaults, deriveStashFromDefaults, importsSearchParams
|
|
20
|
+
import { compileJSX, extractSsrDefaults, deriveStashFromDefaults, importsSearchParams } from '@barefootjs/jsx'
|
|
21
21
|
import type { ComponentIR, SsrDefault } from '@barefootjs/jsx'
|
|
22
22
|
import { mkdir, rm } from 'node:fs/promises'
|
|
23
23
|
import { resolve } from 'node:path'
|
|
@@ -563,39 +563,22 @@ function buildPerlProps(
|
|
|
563
563
|
}
|
|
564
564
|
}
|
|
565
565
|
|
|
566
|
-
//
|
|
566
|
+
// No initializer re-evaluation against raw props — production's
|
|
567
|
+
// before_render seeds only from `deriveStashFromDefaults` (#2696).
|
|
567
568
|
for (const signal of ir.metadata.signals) {
|
|
568
569
|
// Env signals (#2057) are bound below via `search_params('')`, not from a
|
|
569
570
|
// static initial value.
|
|
570
571
|
if (signal.envReader) continue
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
// 'Default')`) already got the correct RAW-prop seed above via
|
|
574
|
-
// `derivedProps` / the user-props loop — `extractSsrDefaults` marks that
|
|
575
|
-
// with a `propName`-carrying entry (see its docstring's invariant).
|
|
576
|
-
// Re-seeding here with this harness's OWN recompute
|
|
577
|
-
// (`evaluateSignalInit`) would clobber the correctly-derived caller
|
|
578
|
-
// value with the harness's evaluated-from-static-props number, papering
|
|
579
|
-
// over the exact production bug this fixture exists to catch.
|
|
580
|
-
if (rootSsrDefaults[signal.getter]?.propName !== undefined) continue
|
|
581
|
-
const value = evaluateSignalInit(signal.initialValue.trim(), props)
|
|
582
|
-
if (value !== null) {
|
|
583
|
-
entries.push(`${signal.getter} => ${toPerlLiteral(value)}`)
|
|
572
|
+
if (Object.prototype.hasOwnProperty.call(derivedProps, signal.getter)) {
|
|
573
|
+
entries.push(`${signal.getter} => ${toPerlLiteral(derivedProps[signal.getter])}`)
|
|
584
574
|
}
|
|
585
575
|
}
|
|
586
576
|
|
|
587
|
-
//
|
|
588
|
-
// as the production plugin's before_render hook.
|
|
577
|
+
// No `?? 0` for entries the manifest lacks — production seeds nothing there (#2696).
|
|
589
578
|
for (const memo of ir.metadata.memos) {
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
// value (which for a non-idempotent derivation is already the WRONG,
|
|
594
|
-
// double-applied number).
|
|
595
|
-
if (rootSsrDefaults[memo.name]?.propName !== undefined) continue
|
|
596
|
-
const entry = rootSsrDefaults[memo.name]
|
|
597
|
-
const value = entry ? entry.value : 0
|
|
598
|
-
entries.push(`${memo.name} => ${toPerlLiteral(value ?? 0)}`)
|
|
579
|
+
if (Object.prototype.hasOwnProperty.call(derivedProps, memo.name)) {
|
|
580
|
+
entries.push(`${memo.name} => ${toPerlLiteral(derivedProps[memo.name])}`)
|
|
581
|
+
}
|
|
599
582
|
}
|
|
600
583
|
|
|
601
584
|
// (#1922) Request-scoped `searchParams()`: bind `$searchParams` to an
|