@barefootjs/erb 0.32.0 → 0.33.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapter/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/conformance-pins.d.ts.map +1 -1
- package/dist/index.js +26 -14
- package/dist/render-divergences.d.ts.map +1 -1
- package/dist/vite.js +116 -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/conformance-pins.ts +7 -0
- package/src/render-divergences.ts +7 -8
|
@@ -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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,OAAO,CAAC,sBAAsB;IAI9B;uEACmE;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,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AAK,MAAM,GAC9B,MAAM,CAER;IAED,WAAW,CACT,IAAI,EAAE,UAAU,EAChB,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE,UAAU,EACrB,IAAI,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,MAAM,GAC9B,MAAM,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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conformance-pins.d.ts","sourceRoot":"","sources":["../src/conformance-pins.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEtD,eAAO,MAAM,eAAe,EAAE,
|
|
1
|
+
{"version":3,"file":"conformance-pins.d.ts","sourceRoot":"","sources":["../src/conformance-pins.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEtD,eAAO,MAAM,eAAe,EAAE,eA+C7B,CAAA"}
|
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",
|
|
@@ -189270,14 +189284,12 @@ var conformancePins = {
|
|
|
189270
189284
|
],
|
|
189271
189285
|
"filter-nested-find-predicate": [{ code: "BF101", severity: "error", issue: "https://github.com/piconic-ai/barefootjs/issues/2320" }],
|
|
189272
189286
|
"date-method-uncatalogued": [{ code: "BF021", severity: "error", issue: "https://github.com/piconic-ai/barefootjs/issues/2356" }],
|
|
189273
|
-
"rich-prop-client-read": [{ code: "BF049", severity: "error", issue: "https://github.com/piconic-ai/barefootjs/issues/2648" }]
|
|
189287
|
+
"rich-prop-client-read": [{ code: "BF049", severity: "error", issue: "https://github.com/piconic-ai/barefootjs/issues/2648" }],
|
|
189288
|
+
"jsx-element-prop-ternary": [{ code: "BF021", severity: "error", issue: "https://github.com/piconic-ai/barefootjs/issues/2667" }],
|
|
189289
|
+
"jsx-element-prop-array": [{ code: "BF021", severity: "error", issue: "https://github.com/piconic-ai/barefootjs/issues/2667" }]
|
|
189274
189290
|
};
|
|
189275
189291
|
// src/render-divergences.ts
|
|
189276
|
-
var renderDivergences = {
|
|
189277
|
-
"todo-app": "the `todos` signal seeds from `(props.initialTodos ?? []).map(t => ({ ...t, editing: false }))` — a different-prop-derived `.map()` chain `extractSsrDefaults` cannot statically resolve, and `computeSsrSeedPlan` classifies it opaque (no in-template recompute), so it seeds `nil`; the non-`/* @client */`-marked `{todos().length > 0 && ...}` toggle-all block SSRs as if there are zero todos regardless of `initialTodos` (https://github.com/piconic-ai/barefootjs/issues/2696)",
|
|
189278
|
-
"todo-app-ssr": "same root cause as `todo-app` (https://github.com/piconic-ai/barefootjs/issues/2696), but this fixture's todo-list loop carries no `/* @client */` marker — the compiled ERB loop iterates the nil-seeded `todos` directly and raises `NoMethodError: undefined method 'length' for nil` instead of rendering",
|
|
189279
|
-
"callback-param-shadows-prop": "the `first` signal seeds from `[{ a: 'p' }].map((title) => title.a).join(',')` — a constant expression `extractSsrDefaults` still cannot statically resolve (`.map()` is unsupported for any receiver) and, unlike the sibling `joined` memo's structurally similar chain, gets no in-template recompute (`computeSsrSeedPlan` classifies it opaque too); `<span>{first()}</span>` SSRs empty instead of `p` (https://github.com/piconic-ai/barefootjs/issues/2696)"
|
|
189280
|
-
};
|
|
189292
|
+
var renderDivergences = {};
|
|
189281
189293
|
export {
|
|
189282
189294
|
renderDivergences,
|
|
189283
189295
|
erbAdapter,
|
|
@@ -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
|
}
|
|
@@ -2252,6 +2273,7 @@ var ErrorCodes = {
|
|
|
2252
2273
|
MISSING_KEY_IN_LIST: "BF023",
|
|
2253
2274
|
MISSING_KEY_IN_NESTED_LIST: "BF024",
|
|
2254
2275
|
UNSUPPORTED_DESTRUCTURE_REST: "BF025",
|
|
2276
|
+
RETURN_VALUE_NOT_JSX: "BF027",
|
|
2255
2277
|
PROPS_DESTRUCTURING: "BF043",
|
|
2256
2278
|
SIGNAL_GETTER_NOT_CALLED: "BF044",
|
|
2257
2279
|
JSX_IN_LOCAL_FUNCTION: "BF045",
|
|
@@ -2283,6 +2305,7 @@ var errorMessages = {
|
|
|
2283
2305
|
[ErrorCodes.MISSING_KEY_IN_LIST]: "Missing key attribute in list rendering. Add a key prop for efficient updates",
|
|
2284
2306
|
[ErrorCodes.MISSING_KEY_IN_NESTED_LIST]: "Nested .map() loop requires key attribute for event delegation. Add a key prop to elements in the inner loop",
|
|
2285
2307
|
[ErrorCodes.UNSUPPORTED_DESTRUCTURE_REST]: "Computed property key in .map() callback destructure is not supported. Rewrite the callback to destructure explicit bindings (e.g., `({ a, b }) => ...`) so the compiler can rewrite references to per-item signal accessors.",
|
|
2308
|
+
[ErrorCodes.RETURN_VALUE_NOT_JSX]: "Component's return value is not recognized as JSX — return the JSX expression directly instead of binding it to a local variable first.",
|
|
2286
2309
|
[ErrorCodes.PROPS_DESTRUCTURING]: "Props destructuring in function parameters breaks reactivity. Use props object directly.",
|
|
2287
2310
|
[ErrorCodes.SIGNAL_GETTER_NOT_CALLED]: "Signal/memo getter passed without calling it. Use getter() to read the value.",
|
|
2288
2311
|
[ErrorCodes.JSX_IN_LOCAL_FUNCTION]: "Local function returns JSX but cannot be inlined. Extract it as a top-level PascalCase component or use a single return statement.",
|
|
@@ -2915,6 +2938,8 @@ function matchToLocaleDateStringCall(callee, args, metadata) {
|
|
|
2915
2938
|
let tz = null;
|
|
2916
2939
|
const probeOptions = {};
|
|
2917
2940
|
for (const prop of options.properties) {
|
|
2941
|
+
if (prop.kind === "spread")
|
|
2942
|
+
return null;
|
|
2918
2943
|
if (prop.value.kind !== "literal" || prop.value.literalType !== "string")
|
|
2919
2944
|
return null;
|
|
2920
2945
|
const value = String(prop.value.value);
|
|
@@ -3905,7 +3930,7 @@ function parseRecordIndexAccess(val, localConstants, propsParams, resolveKey) {
|
|
|
3905
3930
|
|
|
3906
3931
|
// ../jsx/src/ssr-seed-plan.ts
|
|
3907
3932
|
function classify(name, origin, expr, parsed, available) {
|
|
3908
|
-
if (!
|
|
3933
|
+
if (!isSupportedValue(parsed).supported)
|
|
3909
3934
|
return { kind: "opaque", name, origin };
|
|
3910
3935
|
const frees = freeIdentifiers(parsed);
|
|
3911
3936
|
if (frees === null)
|
|
@@ -3968,7 +3993,7 @@ function computeSsrSeedPlan(metadata) {
|
|
|
3968
3993
|
}
|
|
3969
3994
|
}
|
|
3970
3995
|
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));
|
|
3996
|
+
steps.push(expr === "" ? { kind: "opaque", name: signal.getter, origin: "signal" } : classify(signal.getter, "signal", expr, resolveThroughLocalConsts(signal.parsed ?? parseExpression(`(${expr})`), localConsts), available));
|
|
3972
3997
|
available.add(signal.getter);
|
|
3973
3998
|
}
|
|
3974
3999
|
for (const memo of metadata.memos) {
|
|
@@ -4571,6 +4596,26 @@ export default ${this.componentName}` : "";
|
|
|
4571
4596
|
}
|
|
4572
4597
|
var testAdapter = new TestAdapter;
|
|
4573
4598
|
// ../jsx/src/adapters/parsed-expr-emitter.ts
|
|
4599
|
+
function groupObjectLiteralSegments(properties, literalOf, emit) {
|
|
4600
|
+
const segments = [];
|
|
4601
|
+
let run = [];
|
|
4602
|
+
const flushRun = () => {
|
|
4603
|
+
if (run.length > 0) {
|
|
4604
|
+
segments.push(literalOf(run));
|
|
4605
|
+
run = [];
|
|
4606
|
+
}
|
|
4607
|
+
};
|
|
4608
|
+
for (const p of properties) {
|
|
4609
|
+
if (p.kind === "spread") {
|
|
4610
|
+
flushRun();
|
|
4611
|
+
segments.push(emit(p.expr));
|
|
4612
|
+
} else {
|
|
4613
|
+
run.push(p);
|
|
4614
|
+
}
|
|
4615
|
+
}
|
|
4616
|
+
flushRun();
|
|
4617
|
+
return segments;
|
|
4618
|
+
}
|
|
4574
4619
|
function emitParsedExpr(expr, emitter) {
|
|
4575
4620
|
const emit = (child) => emitParsedExpr(child, emitter);
|
|
4576
4621
|
switch (expr.kind) {
|
|
@@ -4651,6 +4696,17 @@ function evaluateStaticLiteral(expr, bindings) {
|
|
|
4651
4696
|
case "object-literal": {
|
|
4652
4697
|
const out = {};
|
|
4653
4698
|
for (const prop of expr.properties) {
|
|
4699
|
+
if (prop.kind === "spread") {
|
|
4700
|
+
const resolved2 = evaluateStaticLiteral(prop.expr, bindings);
|
|
4701
|
+
if (!resolved2)
|
|
4702
|
+
return null;
|
|
4703
|
+
if (resolved2.value === null || resolved2.value === undefined)
|
|
4704
|
+
continue;
|
|
4705
|
+
if (typeof resolved2.value !== "object" || Array.isArray(resolved2.value))
|
|
4706
|
+
return null;
|
|
4707
|
+
Object.assign(out, resolved2.value);
|
|
4708
|
+
continue;
|
|
4709
|
+
}
|
|
4654
4710
|
const resolved = evaluateStaticLiteral(prop.value, bindings);
|
|
4655
4711
|
if (!resolved)
|
|
4656
4712
|
return null;
|
|
@@ -4717,6 +4773,8 @@ function matchQueryHrefCall(callee, args, localNames) {
|
|
|
4717
4773
|
return null;
|
|
4718
4774
|
const triples = [];
|
|
4719
4775
|
for (const p of obj.properties) {
|
|
4776
|
+
if (p.kind === "spread")
|
|
4777
|
+
return null;
|
|
4720
4778
|
const v = p.value;
|
|
4721
4779
|
if (v.kind === "conditional" && isOmitBranch(v.alternate)) {
|
|
4722
4780
|
triples.push({ guard: v.test, key: p.key, value: v.consequent });
|
|
@@ -4904,6 +4962,8 @@ function htmlPropValue(parsed) {
|
|
|
4904
4962
|
if (parsed.properties.length !== 1)
|
|
4905
4963
|
return null;
|
|
4906
4964
|
const [prop] = parsed.properties;
|
|
4965
|
+
if (prop.kind === "spread")
|
|
4966
|
+
return null;
|
|
4907
4967
|
if (prop.key !== "__html")
|
|
4908
4968
|
return null;
|
|
4909
4969
|
return prop.value;
|
|
@@ -5220,11 +5280,14 @@ function rubyStringLiteral(s) {
|
|
|
5220
5280
|
return `'${escapeRubySingleQuoted(s)}'`;
|
|
5221
5281
|
}
|
|
5222
5282
|
var VALID_RUBY_SYMBOL = /^[A-Za-z_][A-Za-z0-9_]*[?!]?$/;
|
|
5283
|
+
function escapeRubyDoubleQuoted(s) {
|
|
5284
|
+
return s.replace(/\\/g, "\\\\").replace(/"/g, "\\\"");
|
|
5285
|
+
}
|
|
5223
5286
|
function rubySymbolKey(name) {
|
|
5224
|
-
return VALID_RUBY_SYMBOL.test(name) ? `${name}:` : `"${name
|
|
5287
|
+
return VALID_RUBY_SYMBOL.test(name) ? `${name}:` : `"${escapeRubyDoubleQuoted(name)}":`;
|
|
5225
5288
|
}
|
|
5226
5289
|
function rubySymbolLiteral(name) {
|
|
5227
|
-
return VALID_RUBY_SYMBOL.test(name) ? `:${name}` : `:"${name
|
|
5290
|
+
return VALID_RUBY_SYMBOL.test(name) ? `:${name}` : `:"${escapeRubyDoubleQuoted(name)}"`;
|
|
5228
5291
|
}
|
|
5229
5292
|
function rubyIdentifierFromMarkerId(markerId) {
|
|
5230
5293
|
return markerId.replace(/[^a-zA-Z0-9]/g, (ch) => ch === "_" ? "__" : `_x${ch.charCodeAt(0).toString(16)}`);
|
|
@@ -5863,8 +5926,15 @@ class ErbTopLevelEmitter {
|
|
|
5863
5926
|
unsupported(_raw, _reason) {
|
|
5864
5927
|
return "''";
|
|
5865
5928
|
}
|
|
5866
|
-
objectLiteral(properties, _raw,
|
|
5867
|
-
|
|
5929
|
+
objectLiteral(properties, _raw, emit) {
|
|
5930
|
+
if (properties.length === 0)
|
|
5931
|
+
return "{}";
|
|
5932
|
+
const literalOf = (run) => `{ ${run.map((p) => `${rubySymbolKey(p.key)} ${emit(p.value)}`).join(", ")} }`;
|
|
5933
|
+
if (!properties.some((p) => p.kind === "spread")) {
|
|
5934
|
+
return literalOf(properties);
|
|
5935
|
+
}
|
|
5936
|
+
const segments = groupObjectLiteralSegments(properties, literalOf, emit);
|
|
5937
|
+
return `{}.merge(${segments.join(", ")})`;
|
|
5868
5938
|
}
|
|
5869
5939
|
}
|
|
5870
5940
|
|
|
@@ -5977,6 +6047,8 @@ function objectLiteralExprToRubyHash(ctx, expr) {
|
|
|
5977
6047
|
function objectLiteralToRubyHash(ctx, obj) {
|
|
5978
6048
|
const entries = [];
|
|
5979
6049
|
for (const prop of obj.properties) {
|
|
6050
|
+
if (prop.kind === "spread")
|
|
6051
|
+
return null;
|
|
5980
6052
|
if (prop.shorthand)
|
|
5981
6053
|
return null;
|
|
5982
6054
|
if (prop.keyKind === "numeric")
|
|
@@ -6044,7 +6116,7 @@ function generateDerivedMemoSeed(ctx, ir) {
|
|
|
6044
6116
|
for (const step of plan.steps) {
|
|
6045
6117
|
if (step.kind !== "derived")
|
|
6046
6118
|
continue;
|
|
6047
|
-
const ruby = ctx.convertExpressionToRuby(step.expr, step.parsed);
|
|
6119
|
+
const ruby = ctx.convertExpressionToRuby(step.expr, step.parsed, "value");
|
|
6048
6120
|
if (ruby === "" || !/v\[:[A-Za-z_]\w*\]/.test(ruby))
|
|
6049
6121
|
continue;
|
|
6050
6122
|
lines.push(`<% v[:${step.name}] = ${ruby} %>`);
|
|
@@ -6913,9 +6985,9 @@ ${reason}` : "";
|
|
|
6913
6985
|
};
|
|
6914
6986
|
}
|
|
6915
6987
|
get memoCtx() {
|
|
6916
|
-
return { convertExpressionToRuby: (e, preParsed) => this.convertExpressionToRuby(e, preParsed) };
|
|
6988
|
+
return { convertExpressionToRuby: (e, preParsed, pos) => this.convertExpressionToRuby(e, preParsed, pos) };
|
|
6917
6989
|
}
|
|
6918
|
-
convertExpressionToRuby(expr, preParsed) {
|
|
6990
|
+
convertExpressionToRuby(expr, preParsed, pos = "rendered") {
|
|
6919
6991
|
let parsed;
|
|
6920
6992
|
if (preParsed) {
|
|
6921
6993
|
parsed = preParsed;
|
|
@@ -6938,7 +7010,7 @@ ${reason}` : "";
|
|
|
6938
7010
|
}
|
|
6939
7011
|
}
|
|
6940
7012
|
}
|
|
6941
|
-
const support = isSupported(parsed);
|
|
7013
|
+
const support = pos === "value" ? isSupportedValue(parsed) : isSupported(parsed);
|
|
6942
7014
|
if (!support.supported) {
|
|
6943
7015
|
this.errors.push({
|
|
6944
7016
|
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.1",
|
|
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.1"
|
|
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.1",
|
|
75
|
+
"@barefootjs/vite": "0.33.1",
|
|
76
|
+
"@barefootjs/client": "0.33.1",
|
|
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
|
package/src/conformance-pins.ts
CHANGED
|
@@ -49,4 +49,11 @@ export const conformancePins: ConformancePins = {
|
|
|
49
49
|
'filter-nested-find-predicate': [{ code: 'BF101', severity: 'error', issue: 'https://github.com/piconic-ai/barefootjs/issues/2320' }],
|
|
50
50
|
'date-method-uncatalogued': [{ code: 'BF021', severity: 'error', issue: 'https://github.com/piconic-ai/barefootjs/issues/2356' }],
|
|
51
51
|
'rich-prop-client-read': [{ code: 'BF049', severity: 'error', issue: 'https://github.com/piconic-ai/barefootjs/issues/2648' }],
|
|
52
|
+
// #2667: a ternary/array LITERALLY WRAPPING JSX at a non-children prop
|
|
53
|
+
// position (e.g. `header={cond ? <a/> : <b/>}`) is refused ahead of
|
|
54
|
+
// `adapter.generate()` in the shared jsx-to-ir.ts phase, so it is pinned
|
|
55
|
+
// identically on every adapter (including Hono) — same reasoning as
|
|
56
|
+
// `rich-prop-client-read` above.
|
|
57
|
+
'jsx-element-prop-ternary': [{ code: 'BF021', severity: 'error', issue: 'https://github.com/piconic-ai/barefootjs/issues/2667' }],
|
|
58
|
+
'jsx-element-prop-array': [{ code: 'BF021', severity: 'error', issue: 'https://github.com/piconic-ai/barefootjs/issues/2667' }],
|
|
52
59
|
}
|
|
@@ -9,11 +9,10 @@
|
|
|
9
9
|
|
|
10
10
|
import type { RenderDivergences } from '@barefootjs/jsx'
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
12
|
+
// #2696 graduated: `todo-app` / `todo-app-ssr` seeded `todos` opaque
|
|
13
|
+
// because their `.map(t => ({ ...t, editing: false }))` callback body's
|
|
14
|
+
// object-literal SPREAD refused (`checkSupport`). Step 2 admits a spread
|
|
15
|
+
// at value position and the runtime evaluator's `object-literal` case
|
|
16
|
+
// now merges it, so the seed classifies `derived` and SSRs identically
|
|
17
|
+
// to Hono.
|
|
18
|
+
export const renderDivergences: RenderDivergences = {}
|