@barefootjs/erb 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/erb-adapter.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 +22 -8
- package/dist/adapter/lib/ruby-naming.d.ts +3 -0
- package/dist/adapter/lib/ruby-naming.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 +22 -8
- package/dist/render-divergences.d.ts.map +1 -1
- package/dist/vite.js +114 -44
- package/lib/barefoot_js/evaluator.rb +19 -1
- package/package.json +5 -5
- package/src/__tests__/erb-adapter.test.ts +14 -0
- package/src/adapter/emit-context.ts +5 -2
- package/src/adapter/erb-adapter.ts +8 -3
- package/src/adapter/expr/emitters.ts +23 -12
- package/src/adapter/lib/ruby-naming.ts +8 -2
- package/src/adapter/memo/seed.ts +2 -1
- package/src/adapter/spread/spread-codegen.ts +4 -0
- package/src/render-divergences.ts +7 -2
- package/src/test-render.ts +9 -24
|
@@ -100,8 +100,11 @@ export interface ErbMemoContext {
|
|
|
100
100
|
* re-parsing `expr` — mirrors go-template's
|
|
101
101
|
* `convertExpressionToGo(jsExpr, out?, preParsed?)`. With `preParsed` set,
|
|
102
102
|
* `expr` is unused for parsing (the converter derives any diagnostic text
|
|
103
|
-
* from the tree), so callers may pass `''`.
|
|
103
|
+
* from the tree), so callers may pass `''`. `pos` (default `'rendered'`)
|
|
104
|
+
* must be `'value'` for a derived-seed RHS — an assignment, not a render —
|
|
105
|
+
* so the internal support gate matches the `isSupportedValue`
|
|
106
|
+
* classification the seed plan already used.
|
|
104
107
|
*/
|
|
105
|
-
convertExpressionToRuby(expr: string, preParsed?: ParsedExpr): string;
|
|
108
|
+
convertExpressionToRuby(expr: string, preParsed?: ParsedExpr, pos?: 'rendered' | 'value'): string;
|
|
106
109
|
}
|
|
107
110
|
//# sourceMappingURL=emit-context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emit-context.d.ts","sourceRoot":"","sources":["../../src/adapter/emit-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE5E,MAAM,WAAW,cAAc;IAC7B;;;OAGG;IACH,QAAQ,CAAC,mBAAmB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IAEzC;;;OAGG;IACH,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;IAErD,mFAAmF;IACnF,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;IAEhD;;;OAGG;IACH,0BAA0B,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;IAE1E;;;;;;;;;OASG;IACH,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAA;IAEtC,uEAAuE;IACvE,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAA;IAEzC,wDAAwD;IACxD,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAExD,wEAAwE;IACxE,2BAA2B,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;CACrE;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,gBAAgB;IAC/B,uDAAuD;IACvD,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;IAE9B,kEAAkE;IAClE,QAAQ,CAAC,MAAM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AU,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;CACrE;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,gBAAgB;IAC/B,uDAAuD;IACvD,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;IAE9B,kEAAkE;IAClE,QAAQ,CAAC,MAAM,EAAE,aAAa,EAAE,CAAA;IAEhC,0EAA0E;IAC1E,QAAQ,CAAC,cAAc,EAAE,UAAU,CAAC,gBAAgB,CAAC,CAAA;IAErD,sEAAsE;IACtE,QAAQ,CAAC,WAAW,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;IAExC;;;;;;;;;OASG;IACH,uBAAuB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,UAAU,GAAG,MAAM,CAAA;CACtE;AAED;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;;;;;;;;;OAYG;IACH,uBAAuB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,UAAU,EAAE,GAAG,CAAC,EAAE,UAAU,GAAG,OAAO,GAAG,MAAM,CAAA;CAClG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"erb-adapter.d.ts","sourceRoot":"","sources":["../../src/adapter/erb-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,KAAK,EACV,WAAW,EAEX,MAAM,EACN,SAAS,EACT,MAAM,EACN,YAAY,EACZ,aAAa,EACb,MAAM,EACN,WAAW,EACX,UAAU,EACV,MAAM,EACN,aAAa,EACb,UAAU,EACV,OAAO,EAMP,yBAAyB,EAC1B,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,WAAW,EACX,KAAK,aAAa,EAClB,KAAK,sBAAsB,EAE3B,KAAK,aAAa,EAClB,KAAK,UAAU,
|
|
1
|
+
{"version":3,"file":"erb-adapter.d.ts","sourceRoot":"","sources":["../../src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E;IACnE,OAAO,CAAC,kBAAkB;IAI1B;;;;;;;;OAQG;IACH,OAAO,CAAC,gBAAgB;IAexB,iFAAiF;IACjF,OAAO,CAAC,2BAA2B;CAGpC;AAED,eAAO,MAAM,UAAU,YAAmB,CAAA"}
|
|
@@ -98,6 +98,6 @@ export declare class ErbTopLevelEmitter implements ParsedExprEmitter {
|
|
|
98
98
|
arrow(_params: string[], _body: ParsedExpr, _emit: (e: ParsedExpr) => string): string;
|
|
99
99
|
regex(_raw: string): string;
|
|
100
100
|
unsupported(_raw: string, _reason: string): string;
|
|
101
|
-
objectLiteral(properties: ObjectLiteralProperty[], _raw: string,
|
|
101
|
+
objectLiteral(properties: ObjectLiteralProperty[], _raw: string, emit: (e: ParsedExpr) => string): string;
|
|
102
102
|
}
|
|
103
103
|
//# sourceMappingURL=emitters.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emitters.d.ts","sourceRoot":"","sources":["../../../src/adapter/expr/emitters.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,EACL,KAAK,iBAAiB,EAEtB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,qBAAqB,EAC1B,KAAK,SAAS,EACd,KAAK,YAAY,
|
|
1
|
+
{"version":3,"file":"emitters.d.ts","sourceRoot":"","sources":["../../../src/adapter/expr/emitters.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,EACL,KAAK,iBAAiB,EAEtB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,qBAAqB,EAC1B,KAAK,SAAS,EACd,KAAK,YAAY,EAMlB,MAAM,iBAAiB,CAAA;AAExB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAwCxD,qBAAa,gBAAiB,YAAW,iBAAiB;IASx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WAAW,CACT,IAAI,EAAE,UAAU,EAChB,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE,UAAU,EACrB,IAAI,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,MAAM,GAC9B,MAAM,CAGR;IAED,eAAe,CAAC,KAAK,EAAE,YAAY,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,MAAM,GAAG,MAAM,CAiB9E;IAED,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,MAAM,GAAG,MAAM,CAOpF;IAED,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE1B;IAED,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAKjD;IAED,aAAa,CAAC,UAAU,EAAE,qBAAqB,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,MAAM,GAAG,MAAM,CAqBxG;CACF"}
|
package/dist/adapter/index.js
CHANGED
|
@@ -187295,6 +187295,7 @@ import {
|
|
|
187295
187295
|
stringifyParsedExpr as stringifyParsedExpr2,
|
|
187296
187296
|
parseStyleObjectEntries,
|
|
187297
187297
|
isSupported,
|
|
187298
|
+
isSupportedValue,
|
|
187298
187299
|
exprToString,
|
|
187299
187300
|
parseProviderObjectLiteral,
|
|
187300
187301
|
emitParsedExpr as emitParsedExpr2,
|
|
@@ -187455,11 +187456,14 @@ function rubyStringLiteral(s) {
|
|
|
187455
187456
|
return `'${escapeRubySingleQuoted(s)}'`;
|
|
187456
187457
|
}
|
|
187457
187458
|
var VALID_RUBY_SYMBOL = /^[A-Za-z_][A-Za-z0-9_]*[?!]?$/;
|
|
187459
|
+
function escapeRubyDoubleQuoted(s) {
|
|
187460
|
+
return s.replace(/\\/g, "\\\\").replace(/"/g, "\\\"");
|
|
187461
|
+
}
|
|
187458
187462
|
function rubySymbolKey(name) {
|
|
187459
|
-
return VALID_RUBY_SYMBOL.test(name) ? `${name}:` : `"${name
|
|
187463
|
+
return VALID_RUBY_SYMBOL.test(name) ? `${name}:` : `"${escapeRubyDoubleQuoted(name)}":`;
|
|
187460
187464
|
}
|
|
187461
187465
|
function rubySymbolLiteral(name) {
|
|
187462
|
-
return VALID_RUBY_SYMBOL.test(name) ? `:${name}` : `:"${name
|
|
187466
|
+
return VALID_RUBY_SYMBOL.test(name) ? `:${name}` : `:"${escapeRubyDoubleQuoted(name)}"`;
|
|
187463
187467
|
}
|
|
187464
187468
|
function rubyIdentifierFromMarkerId(markerId) {
|
|
187465
187469
|
return markerId.replace(/[^a-zA-Z0-9]/g, (ch) => ch === "_" ? "__" : `_x${ch.charCodeAt(0).toString(16)}`);
|
|
@@ -187736,6 +187740,7 @@ function staticValueToRuby(value) {
|
|
|
187736
187740
|
// src/adapter/expr/emitters.ts
|
|
187737
187741
|
import {
|
|
187738
187742
|
emitParsedExpr,
|
|
187743
|
+
groupObjectLiteralSegments,
|
|
187739
187744
|
identifierPath,
|
|
187740
187745
|
matchSearchParamsMethodCall,
|
|
187741
187746
|
sortComparatorFromArrow
|
|
@@ -188110,8 +188115,15 @@ class ErbTopLevelEmitter {
|
|
|
188110
188115
|
unsupported(_raw, _reason) {
|
|
188111
188116
|
return "''";
|
|
188112
188117
|
}
|
|
188113
|
-
objectLiteral(properties, _raw,
|
|
188114
|
-
|
|
188118
|
+
objectLiteral(properties, _raw, emit) {
|
|
188119
|
+
if (properties.length === 0)
|
|
188120
|
+
return "{}";
|
|
188121
|
+
const literalOf = (run) => `{ ${run.map((p) => `${rubySymbolKey(p.key)} ${emit(p.value)}`).join(", ")} }`;
|
|
188122
|
+
if (!properties.some((p) => p.kind === "spread")) {
|
|
188123
|
+
return literalOf(properties);
|
|
188124
|
+
}
|
|
188125
|
+
const segments = groupObjectLiteralSegments(properties, literalOf, emit);
|
|
188126
|
+
return `{}.merge(${segments.join(", ")})`;
|
|
188115
188127
|
}
|
|
188116
188128
|
}
|
|
188117
188129
|
|
|
@@ -188225,6 +188237,8 @@ function objectLiteralExprToRubyHash(ctx, expr) {
|
|
|
188225
188237
|
function objectLiteralToRubyHash(ctx, obj) {
|
|
188226
188238
|
const entries = [];
|
|
188227
188239
|
for (const prop of obj.properties) {
|
|
188240
|
+
if (prop.kind === "spread")
|
|
188241
|
+
return null;
|
|
188228
188242
|
if (prop.shorthand)
|
|
188229
188243
|
return null;
|
|
188230
188244
|
if (prop.keyKind === "numeric")
|
|
@@ -188296,7 +188310,7 @@ function generateDerivedMemoSeed(ctx, ir) {
|
|
|
188296
188310
|
for (const step of plan.steps) {
|
|
188297
188311
|
if (step.kind !== "derived")
|
|
188298
188312
|
continue;
|
|
188299
|
-
const ruby = ctx.convertExpressionToRuby(step.expr, step.parsed);
|
|
188313
|
+
const ruby = ctx.convertExpressionToRuby(step.expr, step.parsed, "value");
|
|
188300
188314
|
if (ruby === "" || !/v\[:[A-Za-z_]\w*\]/.test(ruby))
|
|
188301
188315
|
continue;
|
|
188302
188316
|
lines.push(`<% v[:${step.name}] = ${ruby} %>`);
|
|
@@ -189165,9 +189179,9 @@ ${reason}` : "";
|
|
|
189165
189179
|
};
|
|
189166
189180
|
}
|
|
189167
189181
|
get memoCtx() {
|
|
189168
|
-
return { convertExpressionToRuby: (e, preParsed) => this.convertExpressionToRuby(e, preParsed) };
|
|
189182
|
+
return { convertExpressionToRuby: (e, preParsed, pos) => this.convertExpressionToRuby(e, preParsed, pos) };
|
|
189169
189183
|
}
|
|
189170
|
-
convertExpressionToRuby(expr, preParsed) {
|
|
189184
|
+
convertExpressionToRuby(expr, preParsed, pos = "rendered") {
|
|
189171
189185
|
let parsed;
|
|
189172
189186
|
if (preParsed) {
|
|
189173
189187
|
parsed = preParsed;
|
|
@@ -189190,7 +189204,7 @@ ${reason}` : "";
|
|
|
189190
189204
|
}
|
|
189191
189205
|
}
|
|
189192
189206
|
}
|
|
189193
|
-
const support = isSupported(parsed);
|
|
189207
|
+
const support = pos === "value" ? isSupportedValue(parsed) : isSupported(parsed);
|
|
189194
189208
|
if (!support.supported) {
|
|
189195
189209
|
this.errors.push({
|
|
189196
189210
|
code: "BF101",
|
|
@@ -35,6 +35,9 @@ export declare function rubyLocal(name: string): string;
|
|
|
35
35
|
export declare function escapeRubySingleQuoted(s: string): string;
|
|
36
36
|
/** Wrap a raw string value as a Ruby single-quoted literal. */
|
|
37
37
|
export declare function rubyStringLiteral(s: string): string;
|
|
38
|
+
/** Escape a string for a Ruby double-quoted literal: backslash first (so
|
|
39
|
+
* it doesn't double-escape the quote we add next), then the quote. */
|
|
40
|
+
export declare function escapeRubyDoubleQuoted(s: string): string;
|
|
38
41
|
/**
|
|
39
42
|
* Render `name` as a Ruby Hash literal SYMBOL key in `key: value` position.
|
|
40
43
|
* A JSX attribute / prop name like `data-slot` isn't a valid bare Ruby
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ruby-naming.d.ts","sourceRoot":"","sources":["../../../src/adapter/lib/ruby-naming.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAoCH;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAQ9C;AAED;uEACuE;AACvE,wBAAgB,sBAAsB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAExD;AAED,+DAA+D;AAC/D,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAEnD;AAKD;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAElD;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED;;;;;;;;;GASG;AACH,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAInE"}
|
|
1
|
+
{"version":3,"file":"ruby-naming.d.ts","sourceRoot":"","sources":["../../../src/adapter/lib/ruby-naming.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAoCH;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAQ9C;AAED;uEACuE;AACvE,wBAAgB,sBAAsB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAExD;AAED,+DAA+D;AAC/D,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAEnD;AAKD;uEACuE;AACvE,wBAAgB,sBAAsB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAExD;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAElD;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED;;;;;;;;;GASG;AACH,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAInE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"seed.d.ts","sourceRoot":"","sources":["../../../src/adapter/memo/seed.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,eAAe,EAGrB,MAAM,iBAAiB,CAAA;AAExB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAGxD,qEAAqE;AACrE,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,eAAe,GAAG,MAAM,CAM7D;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,EAAE,EAAE,WAAW,GAAG,MAAM,CAWnE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,cAAc,EAAE,EAAE,EAAE,WAAW,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"seed.d.ts","sourceRoot":"","sources":["../../../src/adapter/memo/seed.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,eAAe,EAGrB,MAAM,iBAAiB,CAAA;AAExB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAGxD,qEAAqE;AACrE,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,eAAe,GAAG,MAAM,CAM7D;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,EAAE,EAAE,WAAW,GAAG,MAAM,CAWnE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,cAAc,EAAE,EAAE,EAAE,WAAW,GAAG,MAAM,CAcpF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spread-codegen.d.ts","sourceRoot":"","sources":["../../../src/adapter/spread/spread-codegen.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAG1D;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,GAAG,EAAE,gBAAgB,EACrB,IAAI,EAAE,UAAU,GAAG,SAAS,GAC3B,MAAM,GAAG,IAAI,CAiBf;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CACzC,GAAG,EAAE,gBAAgB,EACrB,IAAI,EAAE,UAAU,GAAG,SAAS,GAC3B,MAAM,GAAG,IAAI,CAGf;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,GAAG,EAAE,gBAAgB,EACrB,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;;;;;;;;;;;;;;;;;;;;;GAqBG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAG1D;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,GAAG,EAAE,gBAAgB,EACrB,IAAI,EAAE,UAAU,GAAG,SAAS,GAC3B,MAAM,GAAG,IAAI,CAiBf;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CACzC,GAAG,EAAE,gBAAgB,EACrB,IAAI,EAAE,UAAU,GAAG,SAAS,GAC3B,MAAM,GAAG,IAAI,CAGf;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,GAAG,EAAE,gBAAgB,EACrB,GAAG,EAAE,OAAO,CAAC,UAAU,EAAE;IAAE,IAAI,EAAE,gBAAgB,CAAA;CAAE,CAAC,GACnD,MAAM,GAAG,IAAI,CA8Cf;AAUD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,gBAAgB,EAAE,GAAG,EAAE,UAAU,GAAG,MAAM,GAAG,IAAI,CA4B7F"}
|
package/dist/index.js
CHANGED
|
@@ -187295,6 +187295,7 @@ import {
|
|
|
187295
187295
|
stringifyParsedExpr as stringifyParsedExpr2,
|
|
187296
187296
|
parseStyleObjectEntries,
|
|
187297
187297
|
isSupported,
|
|
187298
|
+
isSupportedValue,
|
|
187298
187299
|
exprToString,
|
|
187299
187300
|
parseProviderObjectLiteral,
|
|
187300
187301
|
emitParsedExpr as emitParsedExpr2,
|
|
@@ -187455,11 +187456,14 @@ function rubyStringLiteral(s) {
|
|
|
187455
187456
|
return `'${escapeRubySingleQuoted(s)}'`;
|
|
187456
187457
|
}
|
|
187457
187458
|
var VALID_RUBY_SYMBOL = /^[A-Za-z_][A-Za-z0-9_]*[?!]?$/;
|
|
187459
|
+
function escapeRubyDoubleQuoted(s) {
|
|
187460
|
+
return s.replace(/\\/g, "\\\\").replace(/"/g, "\\\"");
|
|
187461
|
+
}
|
|
187458
187462
|
function rubySymbolKey(name) {
|
|
187459
|
-
return VALID_RUBY_SYMBOL.test(name) ? `${name}:` : `"${name
|
|
187463
|
+
return VALID_RUBY_SYMBOL.test(name) ? `${name}:` : `"${escapeRubyDoubleQuoted(name)}":`;
|
|
187460
187464
|
}
|
|
187461
187465
|
function rubySymbolLiteral(name) {
|
|
187462
|
-
return VALID_RUBY_SYMBOL.test(name) ? `:${name}` : `:"${name
|
|
187466
|
+
return VALID_RUBY_SYMBOL.test(name) ? `:${name}` : `:"${escapeRubyDoubleQuoted(name)}"`;
|
|
187463
187467
|
}
|
|
187464
187468
|
function rubyIdentifierFromMarkerId(markerId) {
|
|
187465
187469
|
return markerId.replace(/[^a-zA-Z0-9]/g, (ch) => ch === "_" ? "__" : `_x${ch.charCodeAt(0).toString(16)}`);
|
|
@@ -187736,6 +187740,7 @@ function staticValueToRuby(value) {
|
|
|
187736
187740
|
// src/adapter/expr/emitters.ts
|
|
187737
187741
|
import {
|
|
187738
187742
|
emitParsedExpr,
|
|
187743
|
+
groupObjectLiteralSegments,
|
|
187739
187744
|
identifierPath,
|
|
187740
187745
|
matchSearchParamsMethodCall,
|
|
187741
187746
|
sortComparatorFromArrow
|
|
@@ -188110,8 +188115,15 @@ class ErbTopLevelEmitter {
|
|
|
188110
188115
|
unsupported(_raw, _reason) {
|
|
188111
188116
|
return "''";
|
|
188112
188117
|
}
|
|
188113
|
-
objectLiteral(properties, _raw,
|
|
188114
|
-
|
|
188118
|
+
objectLiteral(properties, _raw, emit) {
|
|
188119
|
+
if (properties.length === 0)
|
|
188120
|
+
return "{}";
|
|
188121
|
+
const literalOf = (run) => `{ ${run.map((p) => `${rubySymbolKey(p.key)} ${emit(p.value)}`).join(", ")} }`;
|
|
188122
|
+
if (!properties.some((p) => p.kind === "spread")) {
|
|
188123
|
+
return literalOf(properties);
|
|
188124
|
+
}
|
|
188125
|
+
const segments = groupObjectLiteralSegments(properties, literalOf, emit);
|
|
188126
|
+
return `{}.merge(${segments.join(", ")})`;
|
|
188115
188127
|
}
|
|
188116
188128
|
}
|
|
188117
188129
|
|
|
@@ -188225,6 +188237,8 @@ function objectLiteralExprToRubyHash(ctx, expr) {
|
|
|
188225
188237
|
function objectLiteralToRubyHash(ctx, obj) {
|
|
188226
188238
|
const entries = [];
|
|
188227
188239
|
for (const prop of obj.properties) {
|
|
188240
|
+
if (prop.kind === "spread")
|
|
188241
|
+
return null;
|
|
188228
188242
|
if (prop.shorthand)
|
|
188229
188243
|
return null;
|
|
188230
188244
|
if (prop.keyKind === "numeric")
|
|
@@ -188296,7 +188310,7 @@ function generateDerivedMemoSeed(ctx, ir) {
|
|
|
188296
188310
|
for (const step of plan.steps) {
|
|
188297
188311
|
if (step.kind !== "derived")
|
|
188298
188312
|
continue;
|
|
188299
|
-
const ruby = ctx.convertExpressionToRuby(step.expr, step.parsed);
|
|
188313
|
+
const ruby = ctx.convertExpressionToRuby(step.expr, step.parsed, "value");
|
|
188300
188314
|
if (ruby === "" || !/v\[:[A-Za-z_]\w*\]/.test(ruby))
|
|
188301
188315
|
continue;
|
|
188302
188316
|
lines.push(`<% v[:${step.name}] = ${ruby} %>`);
|
|
@@ -189165,9 +189179,9 @@ ${reason}` : "";
|
|
|
189165
189179
|
};
|
|
189166
189180
|
}
|
|
189167
189181
|
get memoCtx() {
|
|
189168
|
-
return { convertExpressionToRuby: (e, preParsed) => this.convertExpressionToRuby(e, preParsed) };
|
|
189182
|
+
return { convertExpressionToRuby: (e, preParsed, pos) => this.convertExpressionToRuby(e, preParsed, pos) };
|
|
189169
189183
|
}
|
|
189170
|
-
convertExpressionToRuby(expr, preParsed) {
|
|
189184
|
+
convertExpressionToRuby(expr, preParsed, pos = "rendered") {
|
|
189171
189185
|
let parsed;
|
|
189172
189186
|
if (preParsed) {
|
|
189173
189187
|
parsed = preParsed;
|
|
@@ -189190,7 +189204,7 @@ ${reason}` : "";
|
|
|
189190
189204
|
}
|
|
189191
189205
|
}
|
|
189192
189206
|
}
|
|
189193
|
-
const support = isSupported(parsed);
|
|
189207
|
+
const support = pos === "value" ? isSupportedValue(parsed) : isSupported(parsed);
|
|
189194
189208
|
if (!support.supported) {
|
|
189195
189209
|
this.errors.push({
|
|
189196
189210
|
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;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":
|
|
@@ -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) {
|
|
@@ -4571,6 +4594,26 @@ export default ${this.componentName}` : "";
|
|
|
4571
4594
|
}
|
|
4572
4595
|
var testAdapter = new TestAdapter;
|
|
4573
4596
|
// ../jsx/src/adapters/parsed-expr-emitter.ts
|
|
4597
|
+
function groupObjectLiteralSegments(properties, literalOf, emit) {
|
|
4598
|
+
const segments = [];
|
|
4599
|
+
let run = [];
|
|
4600
|
+
const flushRun = () => {
|
|
4601
|
+
if (run.length > 0) {
|
|
4602
|
+
segments.push(literalOf(run));
|
|
4603
|
+
run = [];
|
|
4604
|
+
}
|
|
4605
|
+
};
|
|
4606
|
+
for (const p of properties) {
|
|
4607
|
+
if (p.kind === "spread") {
|
|
4608
|
+
flushRun();
|
|
4609
|
+
segments.push(emit(p.expr));
|
|
4610
|
+
} else {
|
|
4611
|
+
run.push(p);
|
|
4612
|
+
}
|
|
4613
|
+
}
|
|
4614
|
+
flushRun();
|
|
4615
|
+
return segments;
|
|
4616
|
+
}
|
|
4574
4617
|
function emitParsedExpr(expr, emitter) {
|
|
4575
4618
|
const emit = (child) => emitParsedExpr(child, emitter);
|
|
4576
4619
|
switch (expr.kind) {
|
|
@@ -4651,6 +4694,17 @@ function evaluateStaticLiteral(expr, bindings) {
|
|
|
4651
4694
|
case "object-literal": {
|
|
4652
4695
|
const out = {};
|
|
4653
4696
|
for (const prop of expr.properties) {
|
|
4697
|
+
if (prop.kind === "spread") {
|
|
4698
|
+
const resolved2 = evaluateStaticLiteral(prop.expr, bindings);
|
|
4699
|
+
if (!resolved2)
|
|
4700
|
+
return null;
|
|
4701
|
+
if (resolved2.value === null || resolved2.value === undefined)
|
|
4702
|
+
continue;
|
|
4703
|
+
if (typeof resolved2.value !== "object" || Array.isArray(resolved2.value))
|
|
4704
|
+
return null;
|
|
4705
|
+
Object.assign(out, resolved2.value);
|
|
4706
|
+
continue;
|
|
4707
|
+
}
|
|
4654
4708
|
const resolved = evaluateStaticLiteral(prop.value, bindings);
|
|
4655
4709
|
if (!resolved)
|
|
4656
4710
|
return null;
|
|
@@ -4717,6 +4771,8 @@ function matchQueryHrefCall(callee, args, localNames) {
|
|
|
4717
4771
|
return null;
|
|
4718
4772
|
const triples = [];
|
|
4719
4773
|
for (const p of obj.properties) {
|
|
4774
|
+
if (p.kind === "spread")
|
|
4775
|
+
return null;
|
|
4720
4776
|
const v = p.value;
|
|
4721
4777
|
if (v.kind === "conditional" && isOmitBranch(v.alternate)) {
|
|
4722
4778
|
triples.push({ guard: v.test, key: p.key, value: v.consequent });
|
|
@@ -4904,6 +4960,8 @@ function htmlPropValue(parsed) {
|
|
|
4904
4960
|
if (parsed.properties.length !== 1)
|
|
4905
4961
|
return null;
|
|
4906
4962
|
const [prop] = parsed.properties;
|
|
4963
|
+
if (prop.kind === "spread")
|
|
4964
|
+
return null;
|
|
4907
4965
|
if (prop.key !== "__html")
|
|
4908
4966
|
return null;
|
|
4909
4967
|
return prop.value;
|
|
@@ -5220,11 +5278,14 @@ function rubyStringLiteral(s) {
|
|
|
5220
5278
|
return `'${escapeRubySingleQuoted(s)}'`;
|
|
5221
5279
|
}
|
|
5222
5280
|
var VALID_RUBY_SYMBOL = /^[A-Za-z_][A-Za-z0-9_]*[?!]?$/;
|
|
5281
|
+
function escapeRubyDoubleQuoted(s) {
|
|
5282
|
+
return s.replace(/\\/g, "\\\\").replace(/"/g, "\\\"");
|
|
5283
|
+
}
|
|
5223
5284
|
function rubySymbolKey(name) {
|
|
5224
|
-
return VALID_RUBY_SYMBOL.test(name) ? `${name}:` : `"${name
|
|
5285
|
+
return VALID_RUBY_SYMBOL.test(name) ? `${name}:` : `"${escapeRubyDoubleQuoted(name)}":`;
|
|
5225
5286
|
}
|
|
5226
5287
|
function rubySymbolLiteral(name) {
|
|
5227
|
-
return VALID_RUBY_SYMBOL.test(name) ? `:${name}` : `:"${name
|
|
5288
|
+
return VALID_RUBY_SYMBOL.test(name) ? `:${name}` : `:"${escapeRubyDoubleQuoted(name)}"`;
|
|
5228
5289
|
}
|
|
5229
5290
|
function rubyIdentifierFromMarkerId(markerId) {
|
|
5230
5291
|
return markerId.replace(/[^a-zA-Z0-9]/g, (ch) => ch === "_" ? "__" : `_x${ch.charCodeAt(0).toString(16)}`);
|
|
@@ -5863,8 +5924,15 @@ class ErbTopLevelEmitter {
|
|
|
5863
5924
|
unsupported(_raw, _reason) {
|
|
5864
5925
|
return "''";
|
|
5865
5926
|
}
|
|
5866
|
-
objectLiteral(properties, _raw,
|
|
5867
|
-
|
|
5927
|
+
objectLiteral(properties, _raw, emit) {
|
|
5928
|
+
if (properties.length === 0)
|
|
5929
|
+
return "{}";
|
|
5930
|
+
const literalOf = (run) => `{ ${run.map((p) => `${rubySymbolKey(p.key)} ${emit(p.value)}`).join(", ")} }`;
|
|
5931
|
+
if (!properties.some((p) => p.kind === "spread")) {
|
|
5932
|
+
return literalOf(properties);
|
|
5933
|
+
}
|
|
5934
|
+
const segments = groupObjectLiteralSegments(properties, literalOf, emit);
|
|
5935
|
+
return `{}.merge(${segments.join(", ")})`;
|
|
5868
5936
|
}
|
|
5869
5937
|
}
|
|
5870
5938
|
|
|
@@ -5977,6 +6045,8 @@ function objectLiteralExprToRubyHash(ctx, expr) {
|
|
|
5977
6045
|
function objectLiteralToRubyHash(ctx, obj) {
|
|
5978
6046
|
const entries = [];
|
|
5979
6047
|
for (const prop of obj.properties) {
|
|
6048
|
+
if (prop.kind === "spread")
|
|
6049
|
+
return null;
|
|
5980
6050
|
if (prop.shorthand)
|
|
5981
6051
|
return null;
|
|
5982
6052
|
if (prop.keyKind === "numeric")
|
|
@@ -6044,7 +6114,7 @@ function generateDerivedMemoSeed(ctx, ir) {
|
|
|
6044
6114
|
for (const step of plan.steps) {
|
|
6045
6115
|
if (step.kind !== "derived")
|
|
6046
6116
|
continue;
|
|
6047
|
-
const ruby = ctx.convertExpressionToRuby(step.expr, step.parsed);
|
|
6117
|
+
const ruby = ctx.convertExpressionToRuby(step.expr, step.parsed, "value");
|
|
6048
6118
|
if (ruby === "" || !/v\[:[A-Za-z_]\w*\]/.test(ruby))
|
|
6049
6119
|
continue;
|
|
6050
6120
|
lines.push(`<% v[:${step.name}] = ${ruby} %>`);
|
|
@@ -6913,9 +6983,9 @@ ${reason}` : "";
|
|
|
6913
6983
|
};
|
|
6914
6984
|
}
|
|
6915
6985
|
get memoCtx() {
|
|
6916
|
-
return { convertExpressionToRuby: (e, preParsed) => this.convertExpressionToRuby(e, preParsed) };
|
|
6986
|
+
return { convertExpressionToRuby: (e, preParsed, pos) => this.convertExpressionToRuby(e, preParsed, pos) };
|
|
6917
6987
|
}
|
|
6918
|
-
convertExpressionToRuby(expr, preParsed) {
|
|
6988
|
+
convertExpressionToRuby(expr, preParsed, pos = "rendered") {
|
|
6919
6989
|
let parsed;
|
|
6920
6990
|
if (preParsed) {
|
|
6921
6991
|
parsed = preParsed;
|
|
@@ -6938,7 +7008,7 @@ ${reason}` : "";
|
|
|
6938
7008
|
}
|
|
6939
7009
|
}
|
|
6940
7010
|
}
|
|
6941
|
-
const support = isSupported(parsed);
|
|
7011
|
+
const support = pos === "value" ? isSupportedValue(parsed) : isSupported(parsed);
|
|
6942
7012
|
if (!support.supported) {
|
|
6943
7013
|
this.errors.push({
|
|
6944
7014
|
code: "BF101",
|
|
@@ -100,8 +100,26 @@ module BarefootJS
|
|
|
100
100
|
when 'array-literal'
|
|
101
101
|
(node[:elements] || []).map { |e| evaluate(e, env) }
|
|
102
102
|
when 'object-literal'
|
|
103
|
+
# Each entry carries its own `kind` ('prop' | 'spread', #2696 Step
|
|
104
|
+
# 2) -- the same encoding the Go/Perl/Python evaluators and the raw
|
|
105
|
+
# ParsedExpr shape the eval-vectors.json golden corpus carry. A
|
|
106
|
+
# 'spread' evaluates its `expr` and shallow-merges the result's own
|
|
107
|
+
# keys (a non-Hash result -- including a null/undefined JS spread
|
|
108
|
+
# source -- is a no-op). Every hash this evaluator builds uses
|
|
109
|
+
# SYMBOL keys (`read_property` below always looks up `key.to_sym`),
|
|
110
|
+
# so a spread's keys are symbolized on merge for the same reason a
|
|
111
|
+
# `prop` key already is, regardless of whether the spread source's
|
|
112
|
+
# own keys started out as symbols or strings. Later entries win on
|
|
113
|
+
# a shared key, in source order, matching JS object-spread exactly.
|
|
103
114
|
out = {}
|
|
104
|
-
(node[:properties] || []).each
|
|
115
|
+
(node[:properties] || []).each do |prop|
|
|
116
|
+
if (prop[:kind] || '') == 'spread'
|
|
117
|
+
spread = evaluate(prop[:expr], env)
|
|
118
|
+
spread.each { |k, v| out[k.to_sym] = v } if spread.is_a?(Hash)
|
|
119
|
+
next
|
|
120
|
+
end
|
|
121
|
+
out[prop[:key].to_sym] = evaluate(prop[:value], env)
|
|
122
|
+
end
|
|
105
123
|
out
|
|
106
124
|
when 'array-method'
|
|
107
125
|
args = node[:args] || []
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@barefootjs/erb",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.33.0",
|
|
4
4
|
"description": "ERB (Embedded Ruby) adapter for BarefootJS — compiles IR to .erb templates and ships the Ruby rendering backend; runs under any Rack app (Sinatra, Rails)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"directory": "packages/adapter-erb"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@barefootjs/shared": "0.
|
|
57
|
+
"@barefootjs/shared": "0.33.0"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
60
|
"@barefootjs/jsx": ">=0.2.0",
|
|
@@ -71,9 +71,9 @@
|
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
73
73
|
"@barefootjs/adapter-tests": "0.1.0",
|
|
74
|
-
"@barefootjs/jsx": "0.
|
|
75
|
-
"@barefootjs/vite": "0.
|
|
76
|
-
"@barefootjs/client": "0.
|
|
74
|
+
"@barefootjs/jsx": "0.33.0",
|
|
75
|
+
"@barefootjs/vite": "0.33.0",
|
|
76
|
+
"@barefootjs/client": "0.33.0",
|
|
77
77
|
"typescript": "^5.0.0",
|
|
78
78
|
"vite": "^6.0.0"
|
|
79
79
|
}
|
|
@@ -27,6 +27,7 @@ import { renderErbComponent, ErbNotAvailableError } from '../test-render'
|
|
|
27
27
|
import { compileJSX, type ComponentIR } from '@barefootjs/jsx'
|
|
28
28
|
import { conformancePins } from '../conformance-pins'
|
|
29
29
|
import { renderDivergences } from '../render-divergences'
|
|
30
|
+
import { escapeRubyDoubleQuoted, rubySymbolKey } from '../adapter/lib/ruby-naming'
|
|
30
31
|
|
|
31
32
|
runAdapterConformanceTests({
|
|
32
33
|
name: 'erb',
|
|
@@ -655,3 +656,16 @@ export function Counter() {
|
|
|
655
656
|
expect(template).not.toContain('<link')
|
|
656
657
|
})
|
|
657
658
|
})
|
|
659
|
+
|
|
660
|
+
// A backslash ahead of a quote must be escaped first, or the doubled
|
|
661
|
+
// quote-escape eats the closing quote instead of round-tripping the
|
|
662
|
+
// original bytes (PR #2698 review).
|
|
663
|
+
describe('ErbAdapter - Ruby double-quote escaping order (#2698 review)', () => {
|
|
664
|
+
test('escapeRubyDoubleQuoted doubles a backslash before escaping a quote', () => {
|
|
665
|
+
expect(escapeRubyDoubleQuoted('a\\"b')).toBe('a\\\\\\"b')
|
|
666
|
+
})
|
|
667
|
+
|
|
668
|
+
test('rubySymbolKey applies the same backslash-first rule to a non-identifier key', () => {
|
|
669
|
+
expect(rubySymbolKey('a\\"b')).toBe('"a\\\\\\"b":')
|
|
670
|
+
})
|
|
671
|
+
})
|
|
@@ -113,7 +113,10 @@ export interface ErbMemoContext {
|
|
|
113
113
|
* re-parsing `expr` — mirrors go-template's
|
|
114
114
|
* `convertExpressionToGo(jsExpr, out?, preParsed?)`. With `preParsed` set,
|
|
115
115
|
* `expr` is unused for parsing (the converter derives any diagnostic text
|
|
116
|
-
* from the tree), so callers may pass `''`.
|
|
116
|
+
* from the tree), so callers may pass `''`. `pos` (default `'rendered'`)
|
|
117
|
+
* must be `'value'` for a derived-seed RHS — an assignment, not a render —
|
|
118
|
+
* so the internal support gate matches the `isSupportedValue`
|
|
119
|
+
* classification the seed plan already used.
|
|
117
120
|
*/
|
|
118
|
-
convertExpressionToRuby(expr: string, preParsed?: ParsedExpr): string
|
|
121
|
+
convertExpressionToRuby(expr: string, preParsed?: ParsedExpr, pos?: 'rendered' | 'value'): string
|
|
119
122
|
}
|
|
@@ -70,6 +70,7 @@ import {
|
|
|
70
70
|
stringifyParsedExpr,
|
|
71
71
|
parseStyleObjectEntries,
|
|
72
72
|
isSupported,
|
|
73
|
+
isSupportedValue,
|
|
73
74
|
exprToString,
|
|
74
75
|
parseProviderObjectLiteral,
|
|
75
76
|
emitParsedExpr,
|
|
@@ -1865,10 +1866,10 @@ export class ErbAdapter extends BaseAdapter implements IRNodeEmitter<ErbRenderCt
|
|
|
1865
1866
|
|
|
1866
1867
|
/** Build the narrow context the extracted memo seeding depends on. */
|
|
1867
1868
|
private get memoCtx(): ErbMemoContext {
|
|
1868
|
-
return { convertExpressionToRuby: (e, preParsed) => this.convertExpressionToRuby(e, preParsed) }
|
|
1869
|
+
return { convertExpressionToRuby: (e, preParsed, pos) => this.convertExpressionToRuby(e, preParsed, pos) }
|
|
1869
1870
|
}
|
|
1870
1871
|
|
|
1871
|
-
private convertExpressionToRuby(expr: string, preParsed?: ParsedExpr): string {
|
|
1872
|
+
private convertExpressionToRuby(expr: string, preParsed?: ParsedExpr, pos: 'rendered' | 'value' = 'rendered'): string {
|
|
1872
1873
|
// Parse-first lowering — parity with the Go adapter's
|
|
1873
1874
|
// `convertExpressionToGo`. Parse the JS expression once, gate it on
|
|
1874
1875
|
// the shared `isSupported`, and render every supported shape through
|
|
@@ -1925,7 +1926,11 @@ export class ErbAdapter extends BaseAdapter implements IRNodeEmitter<ErbRenderCt
|
|
|
1925
1926
|
}
|
|
1926
1927
|
}
|
|
1927
1928
|
|
|
1928
|
-
|
|
1929
|
+
// `pos` distinguishes a derived-seed RHS (an assignment, checked via
|
|
1930
|
+
// `isSupportedValue`) from every other, genuinely rendered call site —
|
|
1931
|
+
// the rendered gate would otherwise re-refuse a tree the seed plan
|
|
1932
|
+
// already classified `derived` at value position (#2696 review).
|
|
1933
|
+
const support = pos === 'value' ? isSupportedValue(parsed) : isSupported(parsed)
|
|
1929
1934
|
if (!support.supported) {
|
|
1930
1935
|
this.errors.push({
|
|
1931
1936
|
code: 'BF101',
|
|
@@ -42,6 +42,7 @@ import {
|
|
|
42
42
|
type FlatDepth,
|
|
43
43
|
type TemplatePart,
|
|
44
44
|
emitParsedExpr,
|
|
45
|
+
groupObjectLiteralSegments,
|
|
45
46
|
identifierPath,
|
|
46
47
|
matchSearchParamsMethodCall,
|
|
47
48
|
sortComparatorFromArrow,
|
|
@@ -49,7 +50,7 @@ import {
|
|
|
49
50
|
|
|
50
51
|
import type { ErbEmitContext } from '../emit-context.ts'
|
|
51
52
|
import { ERB_TEMPLATE_PRIMITIVES } from '../lib/constants.ts'
|
|
52
|
-
import { rubyLocal, rubyStringLiteral, rubySymbolLiteral } from '../lib/ruby-naming.ts'
|
|
53
|
+
import { rubyLocal, rubyStringLiteral, rubySymbolLiteral, rubySymbolKey } from '../lib/ruby-naming.ts'
|
|
53
54
|
import { emitIndexAccessRuby } from './operand.ts'
|
|
54
55
|
import {
|
|
55
56
|
renderArrayMethod,
|
|
@@ -675,16 +676,26 @@ export class ErbTopLevelEmitter implements ParsedExprEmitter {
|
|
|
675
676
|
return "''"
|
|
676
677
|
}
|
|
677
678
|
|
|
678
|
-
objectLiteral(properties: ObjectLiteralProperty[], _raw: string,
|
|
679
|
-
//
|
|
680
|
-
//
|
|
681
|
-
//
|
|
682
|
-
//
|
|
683
|
-
//
|
|
684
|
-
//
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
679
|
+
objectLiteral(properties: ObjectLiteralProperty[], _raw: string, emit: (e: ParsedExpr) => string): string {
|
|
680
|
+
// Reachable here in VALUE position (a `.map()` receiver/callback body, an
|
|
681
|
+
// array-literal element, …) since `isSupportedValue` admits an object
|
|
682
|
+
// literal whose every property value is itself supported
|
|
683
|
+
// (expression-parser.ts, `checkSupport`'s `pos` parameter). Emit a Ruby
|
|
684
|
+
// Hash literal, keyed the same way `objectLiteralToRubyHash` quotes the
|
|
685
|
+
// spread-path literal.
|
|
686
|
+
if (properties.length === 0) return '{}'
|
|
687
|
+
const literalOf = (run: readonly Extract<ObjectLiteralProperty, { kind: 'prop' }>[]) =>
|
|
688
|
+
`{ ${run.map(p => `${rubySymbolKey(p.key)} ${emit(p.value)}`).join(', ')} }`
|
|
689
|
+
if (!properties.some(p => p.kind === 'spread')) {
|
|
690
|
+
return literalOf(properties as Extract<ObjectLiteralProperty, { kind: 'prop' }>[])
|
|
691
|
+
}
|
|
692
|
+
// Spread (`{ ...t, editing: false }`, #2696 Step 2): `Hash#merge` has
|
|
693
|
+
// accepted multiple hash arguments since Ruby 2.6 (this gem requires
|
|
694
|
+
// >= 3.1), overriding left-to-right — exactly JS spread's semantics.
|
|
695
|
+
// Starting from a fresh `{}` (rather than the first segment) means the
|
|
696
|
+
// fold works uniformly whether the FIRST entry is a `prop` run or a
|
|
697
|
+
// `spread` — no special-casing which segment is the merge "receiver".
|
|
698
|
+
const segments = groupObjectLiteralSegments(properties, literalOf, emit)
|
|
699
|
+
return `{}.merge(${segments.join(', ')})`
|
|
689
700
|
}
|
|
690
701
|
}
|
|
@@ -88,6 +88,12 @@ export function rubyStringLiteral(s: string): string {
|
|
|
88
88
|
/** A syntactically valid bare Ruby hash-key / symbol identifier. */
|
|
89
89
|
const VALID_RUBY_SYMBOL = /^[A-Za-z_][A-Za-z0-9_]*[?!]?$/
|
|
90
90
|
|
|
91
|
+
/** Escape a string for a Ruby double-quoted literal: backslash first (so
|
|
92
|
+
* it doesn't double-escape the quote we add next), then the quote. */
|
|
93
|
+
export function escapeRubyDoubleQuoted(s: string): string {
|
|
94
|
+
return s.replace(/\\/g, '\\\\').replace(/"/g, '\\"')
|
|
95
|
+
}
|
|
96
|
+
|
|
91
97
|
/**
|
|
92
98
|
* Render `name` as a Ruby Hash literal SYMBOL key in `key: value` position.
|
|
93
99
|
* A JSX attribute / prop name like `data-slot` isn't a valid bare Ruby
|
|
@@ -98,7 +104,7 @@ const VALID_RUBY_SYMBOL = /^[A-Za-z_][A-Za-z0-9_]*[?!]?$/
|
|
|
98
104
|
* unquoted (`size: value`) for readability.
|
|
99
105
|
*/
|
|
100
106
|
export function rubySymbolKey(name: string): string {
|
|
101
|
-
return VALID_RUBY_SYMBOL.test(name) ? `${name}:` : `"${name
|
|
107
|
+
return VALID_RUBY_SYMBOL.test(name) ? `${name}:` : `"${escapeRubyDoubleQuoted(name)}":`
|
|
102
108
|
}
|
|
103
109
|
|
|
104
110
|
/**
|
|
@@ -107,7 +113,7 @@ export function rubySymbolKey(name: string): string {
|
|
|
107
113
|
* `rubySymbolKey`'s `key: value` Hash-literal position.
|
|
108
114
|
*/
|
|
109
115
|
export function rubySymbolLiteral(name: string): string {
|
|
110
|
-
return VALID_RUBY_SYMBOL.test(name) ? `:${name}` : `:"${name
|
|
116
|
+
return VALID_RUBY_SYMBOL.test(name) ? `:${name}` : `:"${escapeRubyDoubleQuoted(name)}"`
|
|
111
117
|
}
|
|
112
118
|
|
|
113
119
|
/**
|
package/src/adapter/memo/seed.ts
CHANGED
|
@@ -67,7 +67,8 @@ export function generateDerivedMemoSeed(ctx: ErbMemoContext, ir: ComponentIR): s
|
|
|
67
67
|
const lines: string[] = []
|
|
68
68
|
for (const step of plan.steps) {
|
|
69
69
|
if (step.kind !== 'derived') continue
|
|
70
|
-
|
|
70
|
+
// `'value'` — this RHS is an assignment, not a render (#2696 review).
|
|
71
|
+
const ruby = ctx.convertExpressionToRuby(step.expr, step.parsed, 'value')
|
|
71
72
|
if (ruby === '' || !/v\[:[A-Za-z_]\w*\]/.test(ruby)) continue
|
|
72
73
|
lines.push(`<% v[:${step.name}] = ${ruby} %>`)
|
|
73
74
|
}
|
|
@@ -82,6 +82,10 @@ export function objectLiteralToRubyHash(
|
|
|
82
82
|
): string | null {
|
|
83
83
|
const entries: string[] = []
|
|
84
84
|
for (const prop of obj.properties) {
|
|
85
|
+
// A spread (`{ ...t }`, #2696 Step 2) isn't a per-key entry this
|
|
86
|
+
// conditional-spread inline lowering can express — bail, same as any
|
|
87
|
+
// other unsupported shape (the caller falls back to the generic path).
|
|
88
|
+
if (prop.kind === 'spread') return null
|
|
85
89
|
// Shorthand `{ a }` was a `ShorthandPropertyAssignment` (not a
|
|
86
90
|
// `PropertyAssignment`), so the former parser rejected it — keep refusing.
|
|
87
91
|
if (prop.shorthand) return null
|
|
@@ -9,5 +9,10 @@
|
|
|
9
9
|
|
|
10
10
|
import type { RenderDivergences } from '@barefootjs/jsx'
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
}
|
|
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 = {}
|
package/src/test-render.ts
CHANGED
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
* regression test.
|
|
37
37
|
*/
|
|
38
38
|
|
|
39
|
-
import { compileJSX, extractSsrDefaults, deriveStashFromDefaults, importsSearchParams
|
|
39
|
+
import { compileJSX, extractSsrDefaults, deriveStashFromDefaults, importsSearchParams } from '@barefootjs/jsx'
|
|
40
40
|
import type { ComponentIR, SsrDefault } from '@barefootjs/jsx'
|
|
41
41
|
import { mkdir, rm } from 'node:fs/promises'
|
|
42
42
|
import { resolve } from 'node:path'
|
|
@@ -600,37 +600,22 @@ function buildRubyProps(
|
|
|
600
600
|
}
|
|
601
601
|
}
|
|
602
602
|
|
|
603
|
-
//
|
|
603
|
+
// No initializer re-evaluation against raw props — production's
|
|
604
|
+
// before_render seeds only from `deriveStashFromDefaults` (#2696).
|
|
604
605
|
for (const signal of ir.metadata.signals) {
|
|
605
606
|
// Env signals (#2057 / #1922) are bound below via `search_params('')`,
|
|
606
607
|
// not from a static initial value.
|
|
607
608
|
if (signal.envReader) continue
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
// 'Default')`) already got the correct RAW-prop seed above via
|
|
611
|
-
// `derivedProps` / `obj[param.name]` — `extractSsrDefaults` marks that
|
|
612
|
-
// with a `propName`-carrying entry (see its docstring's invariant).
|
|
613
|
-
// Re-seeding here with this harness's OWN recompute
|
|
614
|
-
// (`evaluateSignalInit`) would clobber the correctly-derived caller
|
|
615
|
-
// value with the harness's evaluated-from-static-props number, papering
|
|
616
|
-
// over the exact production bug this fixture exists to catch.
|
|
617
|
-
if (rootSsrDefaults[signal.getter]?.propName !== undefined) continue
|
|
618
|
-
const value = evaluateSignalInit(signal.initialValue.trim(), props)
|
|
619
|
-
if (value !== null) {
|
|
620
|
-
obj[signal.getter] = value
|
|
609
|
+
if (Object.prototype.hasOwnProperty.call(derivedProps, signal.getter)) {
|
|
610
|
+
obj[signal.getter] = derivedProps[signal.getter]
|
|
621
611
|
}
|
|
622
612
|
}
|
|
623
613
|
|
|
624
|
-
//
|
|
625
|
-
// as the production plugin's before_render hook.
|
|
614
|
+
// No `?? 0` for entries the manifest lacks — production seeds nothing there (#2696).
|
|
626
615
|
for (const memo of ir.metadata.memos) {
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
// value (which for a non-idempotent derivation is already the WRONG,
|
|
631
|
-
// double-applied number).
|
|
632
|
-
if (rootSsrDefaults[memo.name]?.propName !== undefined) continue
|
|
633
|
-
obj[memo.name] = rootSsrDefaults[memo.name]?.value ?? 0
|
|
616
|
+
if (Object.prototype.hasOwnProperty.call(derivedProps, memo.name)) {
|
|
617
|
+
obj[memo.name] = derivedProps[memo.name]
|
|
618
|
+
}
|
|
634
619
|
}
|
|
635
620
|
|
|
636
621
|
const needsSearchParams = importsSearchParams(ir.metadata)
|