@barefootjs/erb 0.18.3 → 0.18.5
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/erb-adapter.d.ts +8 -0
- package/dist/adapter/erb-adapter.d.ts.map +1 -1
- package/dist/adapter/expr/array-method.d.ts.map +1 -1
- package/dist/adapter/expr/emitters.d.ts +2 -2
- package/dist/adapter/expr/emitters.d.ts.map +1 -1
- package/dist/adapter/index.js +71 -27
- package/dist/adapter/lib/constants.d.ts.map +1 -1
- package/dist/build.js +71 -27
- package/dist/conformance-pins.d.ts.map +1 -1
- package/dist/index.js +73 -43
- package/dist/render-divergences.d.ts.map +1 -1
- package/lib/barefoot_js/backend/erb.rb +24 -15
- package/lib/barefoot_js/evaluator.rb +14 -1
- package/lib/barefoot_js.rb +111 -6
- package/package.json +3 -3
- package/src/__tests__/erb-adapter.test.ts +21 -0
- package/src/adapter/erb-adapter.ts +81 -11
- package/src/adapter/expr/array-method.ts +22 -0
- package/src/adapter/expr/emitters.ts +15 -2
- package/src/adapter/lib/constants.ts +3 -0
- package/src/conformance-pins.ts +0 -5
- package/src/render-divergences.ts +1 -26
|
@@ -62,6 +62,14 @@ export declare class ErbAdapter extends BaseAdapter implements IRNodeEmitter<Erb
|
|
|
62
62
|
private options;
|
|
63
63
|
private errors;
|
|
64
64
|
private inLoop;
|
|
65
|
+
/**
|
|
66
|
+
* `IRLoop.depth` of the loop currently being rendered (save/restore
|
|
67
|
+
* around `renderChildren(loop.children)`, mirroring `inLoop` above).
|
|
68
|
+
* `renderAttributes` reads this to derive the `key` → `data-key`/
|
|
69
|
+
* `data-key-N` suffix — the depth is IR-computed (jsx-to-ir.ts), not
|
|
70
|
+
* re-derived here (#2168 nested-loop-outer-binding).
|
|
71
|
+
*/
|
|
72
|
+
private currentLoopKeyDepth;
|
|
65
73
|
/**
|
|
66
74
|
* SolidJS-style props identifier (`function(props: P)`) and the
|
|
67
75
|
* analyzer-extracted prop names. Stashed at `generate()` entry so the
|
|
@@ -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,EAyBhB,MAAM,iBAAiB,CAAA;AAKxB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAmClD,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AACvD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAoBvD,qBAAa,UAAW,SAAQ,WAAY,YAAW,aAAa,CAAC,YAAY,CAAC;IAChF,IAAI,SAAQ;IACZ,SAAS,SAAS;IAClB,qBAAqB,UAAO;IAI5B,kBAAkB,EAAG,cAAc,CAAS;IAE5C;;;;;;OAMG;IACH,kBAAkB,EAAE,yBAAyB,CAAyB;IAEtE,OAAO,CAAC,aAAa,CAAa;IAClC;;;;oDAIgD;IAChD,OAAO,CAAC,cAAc,CAAyB;IAC/C,OAAO,CAAC,OAAO,CAA6B;IAC5C,OAAO,CAAC,MAAM,CAAsB;IACpC,OAAO,CAAC,MAAM,CAAiB;IAC/B;;;;;OAKG;IACH,OAAO,CAAC,eAAe,CAAsB;IAC7C,OAAO,CAAC,WAAW,CAAyB;IAC5C,OAAO,CAAC,iBAAiB,CAAyB;IAClD;;;;;;OAMG;IACH,OAAO,CAAC,iBAAiB,CA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AAsB;IAI9B;uEACmE;IACnE,OAAO,CAAC,kBAAkB;IAI1B,OAAO,CAAC,gBAAgB;IAcxB,iFAAiF;IACjF,OAAO,CAAC,2BAA2B;CAGpC;AAED,eAAO,MAAM,UAAU,YAAmB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array-method.d.ts","sourceRoot":"","sources":["../../../src/adapter/expr/array-method.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAMH,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EACX,cAAc,EACd,SAAS,EACV,MAAM,iBAAiB,CAAA;AAGxB;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,WAAW,EACnB,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,UAAU,EAAE,EAClB,IAAI,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,MAAM,GAC9B,MAAM,
|
|
1
|
+
{"version":3,"file":"array-method.d.ts","sourceRoot":"","sources":["../../../src/adapter/expr/array-method.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAMH,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EACX,cAAc,EACd,SAAS,EACV,MAAM,iBAAiB,CAAA;AAGxB;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,WAAW,EACnB,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,UAAU,EAAE,EAClB,IAAI,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,MAAM,GAC9B,MAAM,CA6MR;AAuBD;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,MAAM,EAAE,EAChB,IAAI,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,MAAM,GAC9B,MAAM,GAAG,IAAI,CAOf;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAA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ructor(param: string, localVarMap: Map<string, string>, isLoopBoundOuter?: (n: string) => boolean, isStringName?: (n: string) => boolean, onUnsupported?: ((message: string, reason?: string) => void) | undefined);
|
|
43
43
|
identifier(name: string): string;
|
|
44
44
|
literal(value: string | number | boolean | null, literalType: LiteralType): string;
|
|
45
|
-
member(object: ParsedExpr, property: string, _computed: boolean, emit: (e: ParsedExpr) => string): string;
|
|
45
|
+
member(object: ParsedExpr, property: string, _computed: boolean, optional: boolean, emit: (e: ParsedExpr) => string): string;
|
|
46
46
|
indexAccess(object: ParsedExpr, index: ParsedExpr, emit: (e: ParsedExpr) => string): string;
|
|
47
47
|
call(callee: ParsedExpr, args: ParsedExpr[], emit: (e: ParsedExpr) => string): string;
|
|
48
48
|
unary(op: string, argument: ParsedExpr, emit: (e: ParsedExpr) => string): string;
|
|
@@ -77,7 +77,7 @@ export declare class ErbTopLevelEmitter implements ParsedExprEmitter {
|
|
|
77
77
|
constructor(ctx: ErbEmitContext);
|
|
78
78
|
identifier(name: string): string;
|
|
79
79
|
literal(value: string | number | boolean | null, literalType: LiteralType): string;
|
|
80
|
-
member(object: ParsedExpr, property: string, _computed: boolean, emit: (e: ParsedExpr) => string): string;
|
|
80
|
+
member(object: ParsedExpr, property: string, _computed: boolean, optional: boolean, emit: (e: ParsedExpr) => string): string;
|
|
81
81
|
indexAccess(object: ParsedExpr, index: ParsedExpr, emit: (e: ParsedExpr) => string): string;
|
|
82
82
|
call(callee: ParsedExpr, args: ParsedExpr[], emit: (e: ParsedExpr) => string): string;
|
|
83
83
|
unary(op: string, argument: ParsedExpr, emit: (e: ParsedExpr) => string): string;
|
|
@@ -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,EA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U,CAAA;KAAE,EACvC,IAAI,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,MAAM,GAC9B,MAAM,CAER;IAED,WAAW,CACT,IAAI,EAAE,UAAU,EAChB,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE,UAAU,EACrB,IAAI,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,MAAM,GAC9B,MAAM,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,KAAK,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,MAAM,GAAG,MAAM,CAWzG;CACF"}
|
package/dist/adapter/index.js
CHANGED
|
@@ -187371,7 +187371,7 @@ function isExplicitStringCall(expr) {
|
|
|
187371
187371
|
}
|
|
187372
187372
|
|
|
187373
187373
|
// src/adapter/erb-adapter.ts
|
|
187374
|
-
import { BF_SLOT, BF_COND, BF_REGION } from "@barefootjs/shared";
|
|
187374
|
+
import { BF_SLOT, BF_COND, BF_REGION, escapeHtml } from "@barefootjs/shared";
|
|
187375
187375
|
|
|
187376
187376
|
// src/adapter/lib/constants.ts
|
|
187377
187377
|
var ERB_TEMPLATE_PRIMITIVES = {
|
|
@@ -187380,7 +187380,10 @@ var ERB_TEMPLATE_PRIMITIVES = {
|
|
|
187380
187380
|
Number: { arity: 1, emit: (args) => `bf.number(${args[0]})` },
|
|
187381
187381
|
"Math.floor": { arity: 1, emit: (args) => `bf.floor(${args[0]})` },
|
|
187382
187382
|
"Math.ceil": { arity: 1, emit: (args) => `bf.ceil(${args[0]})` },
|
|
187383
|
-
"Math.round": { arity: 1, emit: (args) => `bf.round(${args[0]})` }
|
|
187383
|
+
"Math.round": { arity: 1, emit: (args) => `bf.round(${args[0]})` },
|
|
187384
|
+
"Math.min": { arity: 2, emit: (args) => `bf.min(${args[0]}, ${args[1]})` },
|
|
187385
|
+
"Math.max": { arity: 2, emit: (args) => `bf.max(${args[0]}, ${args[1]})` },
|
|
187386
|
+
"Math.abs": { arity: 1, emit: (args) => `bf.abs(${args[0]})` }
|
|
187384
187387
|
};
|
|
187385
187388
|
var ERB_PRIMITIVE_EMIT_MAP = Object.fromEntries(Object.entries(ERB_TEMPLATE_PRIMITIVES).map(([k, v]) => [k, v.emit]));
|
|
187386
187389
|
|
|
@@ -187548,6 +187551,12 @@ function renderArrayMethod(method, object, args, emit) {
|
|
|
187548
187551
|
const recv = emit(object);
|
|
187549
187552
|
return `bf.trim(${recv})`;
|
|
187550
187553
|
}
|
|
187554
|
+
case "trimStart":
|
|
187555
|
+
case "trimEnd": {
|
|
187556
|
+
const fn = method === "trimStart" ? "trim_start" : "trim_end";
|
|
187557
|
+
const recv = emit(object);
|
|
187558
|
+
return `bf.${fn}(${recv})`;
|
|
187559
|
+
}
|
|
187551
187560
|
case "toFixed": {
|
|
187552
187561
|
const recv = emit(object);
|
|
187553
187562
|
const digits = args.length >= 1 ? emit(args[0]) : "0";
|
|
@@ -187581,6 +187590,12 @@ function renderArrayMethod(method, object, args, emit) {
|
|
|
187581
187590
|
const newS = emit(args[1]);
|
|
187582
187591
|
return `bf.replace(${recv}, ${oldS}, ${newS})`;
|
|
187583
187592
|
}
|
|
187593
|
+
case "replaceAll": {
|
|
187594
|
+
const recv = emit(object);
|
|
187595
|
+
const oldS = emit(args[0]);
|
|
187596
|
+
const newS = emit(args[1]);
|
|
187597
|
+
return `bf.replace_all(${recv}, ${oldS}, ${newS})`;
|
|
187598
|
+
}
|
|
187584
187599
|
case "repeat": {
|
|
187585
187600
|
const recv = emit(object);
|
|
187586
187601
|
const count = args.length === 0 ? "0" : emit(args[0]);
|
|
@@ -187749,9 +187764,11 @@ class ErbFilterEmitter {
|
|
|
187749
187764
|
return "nil";
|
|
187750
187765
|
return String(value);
|
|
187751
187766
|
}
|
|
187752
|
-
member(object, property, _computed, emit) {
|
|
187767
|
+
member(object, property, _computed, optional, emit) {
|
|
187753
187768
|
if (property === "length")
|
|
187754
187769
|
return `${emit(object)}.length`;
|
|
187770
|
+
if (optional)
|
|
187771
|
+
return `${emit(object)}&.[](${rubySymbolLiteral(property)})`;
|
|
187755
187772
|
return `${emit(object)}[${rubySymbolLiteral(property)}]`;
|
|
187756
187773
|
}
|
|
187757
187774
|
indexAccess(object, index, emit) {
|
|
@@ -187873,7 +187890,7 @@ class ErbTopLevelEmitter {
|
|
|
187873
187890
|
return "nil";
|
|
187874
187891
|
return String(value);
|
|
187875
187892
|
}
|
|
187876
|
-
member(object, property, _computed, emit) {
|
|
187893
|
+
member(object, property, _computed, optional, emit) {
|
|
187877
187894
|
if (object.kind === "identifier" && object.name === "props") {
|
|
187878
187895
|
return `v[${rubySymbolLiteral(property)}]`;
|
|
187879
187896
|
}
|
|
@@ -187885,6 +187902,8 @@ class ErbTopLevelEmitter {
|
|
|
187885
187902
|
const obj = emit(object);
|
|
187886
187903
|
if (property === "length")
|
|
187887
187904
|
return `${obj}.length`;
|
|
187905
|
+
if (optional)
|
|
187906
|
+
return `${obj}&.[](${rubySymbolLiteral(property)})`;
|
|
187888
187907
|
return `${obj}[${rubySymbolLiteral(property)}]`;
|
|
187889
187908
|
}
|
|
187890
187909
|
indexAccess(object, index, emit) {
|
|
@@ -188316,6 +188335,7 @@ class ErbAdapter extends BaseAdapter {
|
|
|
188316
188335
|
options;
|
|
188317
188336
|
errors = [];
|
|
188318
188337
|
inLoop = false;
|
|
188338
|
+
currentLoopKeyDepth = 0;
|
|
188319
188339
|
propsObjectName = null;
|
|
188320
188340
|
propsParams = [];
|
|
188321
188341
|
booleanTypedProps = new Set;
|
|
@@ -188456,7 +188476,7 @@ class ErbAdapter extends BaseAdapter {
|
|
|
188456
188476
|
return this.renderElement(node);
|
|
188457
188477
|
}
|
|
188458
188478
|
emitText(node) {
|
|
188459
|
-
return node.value;
|
|
188479
|
+
return escapeHtml(node.value);
|
|
188460
188480
|
}
|
|
188461
188481
|
emitExpression(node) {
|
|
188462
188482
|
return this.renderExpression(node);
|
|
@@ -188697,13 +188717,16 @@ ${whenTrue}
|
|
|
188697
188717
|
}
|
|
188698
188718
|
const param = loop.param;
|
|
188699
188719
|
const indexVar = loop.iterationShape === "keys" ? rubyLocal(param) : rubyLocal(loop.index ?? "_i");
|
|
188700
|
-
const loopBound = loop.iterationShape === "keys" ? [param] : supportableDestructure ? ["__bf_item", ...(loop.paramBindings ?? []).map((b) => b.name), loop.index ?? "_i"] : [param, loop.index ?? "_i"];
|
|
188720
|
+
const loopBound = loop.objectIteration === "entries" ? [param, loop.index ?? "_k"] : loop.objectIteration === "keys" || loop.objectIteration === "values" || loop.iterationShape === "keys" ? [param] : supportableDestructure ? ["__bf_item", ...(loop.paramBindings ?? []).map((b) => b.name), loop.index ?? "_i"] : [param, loop.index ?? "_i"];
|
|
188701
188721
|
for (const n of loopBound) {
|
|
188702
188722
|
this.loopBoundNames.set(n, (this.loopBoundNames.get(n) ?? 0) + 1);
|
|
188703
188723
|
}
|
|
188704
188724
|
const prevInLoop = this.inLoop;
|
|
188705
188725
|
this.inLoop = true;
|
|
188726
|
+
const prevLoopKeyDepth = this.currentLoopKeyDepth;
|
|
188727
|
+
this.currentLoopKeyDepth = loop.depth;
|
|
188706
188728
|
const renderedChildren = this.renderChildren(loop.children);
|
|
188729
|
+
this.currentLoopKeyDepth = prevLoopKeyDepth;
|
|
188707
188730
|
this.inLoop = prevInLoop;
|
|
188708
188731
|
const children = loop.bodyIsItemConditional && loop.key ? `<%= bf.comment("loop-i:" + bf.string(${this.convertExpressionToRuby(loop.key)})) %>
|
|
188709
188732
|
${renderedChildren}` : renderedChildren;
|
|
@@ -188737,23 +188760,29 @@ ${renderedChildren}` : renderedChildren;
|
|
|
188737
188760
|
}
|
|
188738
188761
|
lines.push(`<%- ${sortedHoist} = ${sorted} -%>`);
|
|
188739
188762
|
}
|
|
188740
|
-
|
|
188741
|
-
|
|
188742
|
-
|
|
188743
|
-
|
|
188744
|
-
|
|
188745
|
-
|
|
188746
|
-
|
|
188747
|
-
|
|
188748
|
-
|
|
188749
|
-
|
|
188750
|
-
|
|
188751
|
-
|
|
188752
|
-
|
|
188763
|
+
if (loop.objectIteration) {
|
|
188764
|
+
const method = loop.objectIteration === "entries" ? "each_pair" : loop.objectIteration === "keys" ? "each_key" : "each_value";
|
|
188765
|
+
const blockParams = loop.objectIteration === "entries" ? `${rubyLocal(loop.index ?? param)}, ${rubyLocal(param)}` : rubyLocal(param);
|
|
188766
|
+
lines.push(`<%- ${array}.${method} do |${blockParams}| -%>`);
|
|
188767
|
+
} else {
|
|
188768
|
+
lines.push(`<%- (0...${array}.length).each do |${indexVar}| -%>`);
|
|
188769
|
+
if (loop.iterationShape !== "keys") {
|
|
188770
|
+
if (supportableDestructure) {
|
|
188771
|
+
lines.push(`<%- __bf_item = ${array}[${indexVar}] -%>`);
|
|
188772
|
+
for (const b of loop.paramBindings ?? []) {
|
|
188773
|
+
const accessor = rubyAccessorFromSegments("__bf_item", b.segments ?? []);
|
|
188774
|
+
if (b.rest?.kind === "array") {
|
|
188775
|
+
lines.push(`<%- ${rubyLocal(b.name)} = bf.slice(${accessor}, ${b.rest.from}) -%>`);
|
|
188776
|
+
} else if (b.rest?.kind === "object") {
|
|
188777
|
+
const excludeSyms = b.rest.exclude.map((k) => rubySymbolLiteral(k.key)).join(", ");
|
|
188778
|
+
lines.push(`<%- ${rubyLocal(b.name)} = ${accessor}.except(${excludeSyms}) -%>`);
|
|
188779
|
+
} else {
|
|
188780
|
+
lines.push(`<%- ${rubyLocal(b.name)} = ${accessor} -%>`);
|
|
188781
|
+
}
|
|
188753
188782
|
}
|
|
188783
|
+
} else {
|
|
188784
|
+
lines.push(`<%- ${rubyLocal(param)} = ${array}[${indexVar}] -%>`);
|
|
188754
188785
|
}
|
|
188755
|
-
} else {
|
|
188756
|
-
lines.push(`<%- ${rubyLocal(param)} = ${array}[${indexVar}] -%>`);
|
|
188757
188786
|
}
|
|
188758
188787
|
}
|
|
188759
188788
|
if (loop.filterPredicate) {
|
|
@@ -188805,9 +188834,23 @@ ${renderedChildren}` : renderedChildren;
|
|
|
188805
188834
|
};
|
|
188806
188835
|
renderComponent(comp) {
|
|
188807
188836
|
const propParts = [];
|
|
188837
|
+
const namedSlotCaptures = [];
|
|
188808
188838
|
for (const p of comp.props) {
|
|
188809
188839
|
if ((p.name.match(/^on[A-Z]/) || p.name === "ref") && p.value.kind === "expression")
|
|
188810
188840
|
continue;
|
|
188841
|
+
if (p.value.kind === "jsx-children" && p.name !== "children") {
|
|
188842
|
+
const prevInLoop = this.inLoop;
|
|
188843
|
+
this.inLoop = false;
|
|
188844
|
+
const slotBody = this.renderChildren(p.value.children);
|
|
188845
|
+
this.inLoop = prevInLoop;
|
|
188846
|
+
const suffix = `${this.childrenCaptureCounter++}`;
|
|
188847
|
+
const lenVar = `__bf_len_${suffix}`;
|
|
188848
|
+
const rawVar = `__bf_praw_${suffix}`;
|
|
188849
|
+
const capVar = `__bf_prop_${suffix}`;
|
|
188850
|
+
namedSlotCaptures.push(`<% ${lenVar} = _erbout.length %>${slotBody}<% ${rawVar} = _erbout.slice!(${lenVar}..); ${capVar} = bf.backend.mark_raw(${rawVar}) %>`);
|
|
188851
|
+
propParts.push(`${rubySymbolKey(p.name)} ${capVar}`);
|
|
188852
|
+
continue;
|
|
188853
|
+
}
|
|
188811
188854
|
const lowered = emitAttrValue(p.value, this.componentPropEmitter, p.name);
|
|
188812
188855
|
if (lowered)
|
|
188813
188856
|
propParts.push(lowered);
|
|
@@ -188826,10 +188869,10 @@ ${renderedChildren}` : renderedChildren;
|
|
|
188826
188869
|
const lenVar = `__bf_len_${suffix}`;
|
|
188827
188870
|
const capVar = `__bf_children_${suffix}`;
|
|
188828
188871
|
const propsHash2 = `{ ${[...propParts, `children: ${capVar}`].join(", ")} }`;
|
|
188829
|
-
return
|
|
188872
|
+
return `${namedSlotCaptures.join("")}<% ${lenVar} = _erbout.length %>${childrenBody}<% ${capVar} = _erbout.slice!(${lenVar}..) %><%= bf.render_child('${tplName}', ${propsHash2}) %>`;
|
|
188830
188873
|
}
|
|
188831
188874
|
const propsHash = propParts.length > 0 ? `{ ${propParts.join(", ")} }` : "{}";
|
|
188832
|
-
return
|
|
188875
|
+
return `${namedSlotCaptures.join("")}<%= bf.render_child('${tplName}', ${propsHash}) %>`;
|
|
188833
188876
|
}
|
|
188834
188877
|
childrenCaptureCounter = 0;
|
|
188835
188878
|
toTemplateName(componentName) {
|
|
@@ -188874,7 +188917,7 @@ ${alternate}
|
|
|
188874
188917
|
${children}`;
|
|
188875
188918
|
}
|
|
188876
188919
|
elementAttrEmitter = {
|
|
188877
|
-
emitLiteral: (value, name) => `${name}="${value.value}"`,
|
|
188920
|
+
emitLiteral: (value, name) => `${name}="${escapeHtml(value.value)}"`,
|
|
188878
188921
|
emitExpression: (value, name) => {
|
|
188879
188922
|
if (name === "style") {
|
|
188880
188923
|
const css = this.tryLowerStyleObject(value.expr);
|
|
@@ -188969,9 +189012,10 @@ ${children}`;
|
|
|
188969
189012
|
let attrName;
|
|
188970
189013
|
if (attr.name === "className")
|
|
188971
189014
|
attrName = "class";
|
|
188972
|
-
else if (attr.name === "key")
|
|
188973
|
-
|
|
188974
|
-
|
|
189015
|
+
else if (attr.name === "key") {
|
|
189016
|
+
const depth = this.currentLoopKeyDepth;
|
|
189017
|
+
attrName = depth > 0 ? `data-key-${depth}` : "data-key";
|
|
189018
|
+
} else
|
|
188975
189019
|
attrName = attr.name;
|
|
188976
189020
|
const lowered = emitAttrValue(attr.value, this.elementAttrEmitter, attrName);
|
|
188977
189021
|
if (lowered)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/adapter/lib/constants.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAE/C;;;;;;;;;;GAUG;AACH,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/adapter/lib/constants.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAE/C;;;;;;;;;;GAUG;AACH,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAUjE,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,MAAM,CAG3E,CAAA"}
|
package/dist/build.js
CHANGED
|
@@ -187371,7 +187371,7 @@ function isExplicitStringCall(expr) {
|
|
|
187371
187371
|
}
|
|
187372
187372
|
|
|
187373
187373
|
// src/adapter/erb-adapter.ts
|
|
187374
|
-
import { BF_SLOT, BF_COND, BF_REGION } from "@barefootjs/shared";
|
|
187374
|
+
import { BF_SLOT, BF_COND, BF_REGION, escapeHtml } from "@barefootjs/shared";
|
|
187375
187375
|
|
|
187376
187376
|
// src/adapter/lib/constants.ts
|
|
187377
187377
|
var ERB_TEMPLATE_PRIMITIVES = {
|
|
@@ -187380,7 +187380,10 @@ var ERB_TEMPLATE_PRIMITIVES = {
|
|
|
187380
187380
|
Number: { arity: 1, emit: (args) => `bf.number(${args[0]})` },
|
|
187381
187381
|
"Math.floor": { arity: 1, emit: (args) => `bf.floor(${args[0]})` },
|
|
187382
187382
|
"Math.ceil": { arity: 1, emit: (args) => `bf.ceil(${args[0]})` },
|
|
187383
|
-
"Math.round": { arity: 1, emit: (args) => `bf.round(${args[0]})` }
|
|
187383
|
+
"Math.round": { arity: 1, emit: (args) => `bf.round(${args[0]})` },
|
|
187384
|
+
"Math.min": { arity: 2, emit: (args) => `bf.min(${args[0]}, ${args[1]})` },
|
|
187385
|
+
"Math.max": { arity: 2, emit: (args) => `bf.max(${args[0]}, ${args[1]})` },
|
|
187386
|
+
"Math.abs": { arity: 1, emit: (args) => `bf.abs(${args[0]})` }
|
|
187384
187387
|
};
|
|
187385
187388
|
var ERB_PRIMITIVE_EMIT_MAP = Object.fromEntries(Object.entries(ERB_TEMPLATE_PRIMITIVES).map(([k, v]) => [k, v.emit]));
|
|
187386
187389
|
|
|
@@ -187548,6 +187551,12 @@ function renderArrayMethod(method, object, args, emit) {
|
|
|
187548
187551
|
const recv = emit(object);
|
|
187549
187552
|
return `bf.trim(${recv})`;
|
|
187550
187553
|
}
|
|
187554
|
+
case "trimStart":
|
|
187555
|
+
case "trimEnd": {
|
|
187556
|
+
const fn = method === "trimStart" ? "trim_start" : "trim_end";
|
|
187557
|
+
const recv = emit(object);
|
|
187558
|
+
return `bf.${fn}(${recv})`;
|
|
187559
|
+
}
|
|
187551
187560
|
case "toFixed": {
|
|
187552
187561
|
const recv = emit(object);
|
|
187553
187562
|
const digits = args.length >= 1 ? emit(args[0]) : "0";
|
|
@@ -187581,6 +187590,12 @@ function renderArrayMethod(method, object, args, emit) {
|
|
|
187581
187590
|
const newS = emit(args[1]);
|
|
187582
187591
|
return `bf.replace(${recv}, ${oldS}, ${newS})`;
|
|
187583
187592
|
}
|
|
187593
|
+
case "replaceAll": {
|
|
187594
|
+
const recv = emit(object);
|
|
187595
|
+
const oldS = emit(args[0]);
|
|
187596
|
+
const newS = emit(args[1]);
|
|
187597
|
+
return `bf.replace_all(${recv}, ${oldS}, ${newS})`;
|
|
187598
|
+
}
|
|
187584
187599
|
case "repeat": {
|
|
187585
187600
|
const recv = emit(object);
|
|
187586
187601
|
const count = args.length === 0 ? "0" : emit(args[0]);
|
|
@@ -187749,9 +187764,11 @@ class ErbFilterEmitter {
|
|
|
187749
187764
|
return "nil";
|
|
187750
187765
|
return String(value);
|
|
187751
187766
|
}
|
|
187752
|
-
member(object, property, _computed, emit) {
|
|
187767
|
+
member(object, property, _computed, optional, emit) {
|
|
187753
187768
|
if (property === "length")
|
|
187754
187769
|
return `${emit(object)}.length`;
|
|
187770
|
+
if (optional)
|
|
187771
|
+
return `${emit(object)}&.[](${rubySymbolLiteral(property)})`;
|
|
187755
187772
|
return `${emit(object)}[${rubySymbolLiteral(property)}]`;
|
|
187756
187773
|
}
|
|
187757
187774
|
indexAccess(object, index, emit) {
|
|
@@ -187873,7 +187890,7 @@ class ErbTopLevelEmitter {
|
|
|
187873
187890
|
return "nil";
|
|
187874
187891
|
return String(value);
|
|
187875
187892
|
}
|
|
187876
|
-
member(object, property, _computed, emit) {
|
|
187893
|
+
member(object, property, _computed, optional, emit) {
|
|
187877
187894
|
if (object.kind === "identifier" && object.name === "props") {
|
|
187878
187895
|
return `v[${rubySymbolLiteral(property)}]`;
|
|
187879
187896
|
}
|
|
@@ -187885,6 +187902,8 @@ class ErbTopLevelEmitter {
|
|
|
187885
187902
|
const obj = emit(object);
|
|
187886
187903
|
if (property === "length")
|
|
187887
187904
|
return `${obj}.length`;
|
|
187905
|
+
if (optional)
|
|
187906
|
+
return `${obj}&.[](${rubySymbolLiteral(property)})`;
|
|
187888
187907
|
return `${obj}[${rubySymbolLiteral(property)}]`;
|
|
187889
187908
|
}
|
|
187890
187909
|
indexAccess(object, index, emit) {
|
|
@@ -188316,6 +188335,7 @@ class ErbAdapter extends BaseAdapter {
|
|
|
188316
188335
|
options;
|
|
188317
188336
|
errors = [];
|
|
188318
188337
|
inLoop = false;
|
|
188338
|
+
currentLoopKeyDepth = 0;
|
|
188319
188339
|
propsObjectName = null;
|
|
188320
188340
|
propsParams = [];
|
|
188321
188341
|
booleanTypedProps = new Set;
|
|
@@ -188456,7 +188476,7 @@ class ErbAdapter extends BaseAdapter {
|
|
|
188456
188476
|
return this.renderElement(node);
|
|
188457
188477
|
}
|
|
188458
188478
|
emitText(node) {
|
|
188459
|
-
return node.value;
|
|
188479
|
+
return escapeHtml(node.value);
|
|
188460
188480
|
}
|
|
188461
188481
|
emitExpression(node) {
|
|
188462
188482
|
return this.renderExpression(node);
|
|
@@ -188697,13 +188717,16 @@ ${whenTrue}
|
|
|
188697
188717
|
}
|
|
188698
188718
|
const param = loop.param;
|
|
188699
188719
|
const indexVar = loop.iterationShape === "keys" ? rubyLocal(param) : rubyLocal(loop.index ?? "_i");
|
|
188700
|
-
const loopBound = loop.iterationShape === "keys" ? [param] : supportableDestructure ? ["__bf_item", ...(loop.paramBindings ?? []).map((b) => b.name), loop.index ?? "_i"] : [param, loop.index ?? "_i"];
|
|
188720
|
+
const loopBound = loop.objectIteration === "entries" ? [param, loop.index ?? "_k"] : loop.objectIteration === "keys" || loop.objectIteration === "values" || loop.iterationShape === "keys" ? [param] : supportableDestructure ? ["__bf_item", ...(loop.paramBindings ?? []).map((b) => b.name), loop.index ?? "_i"] : [param, loop.index ?? "_i"];
|
|
188701
188721
|
for (const n of loopBound) {
|
|
188702
188722
|
this.loopBoundNames.set(n, (this.loopBoundNames.get(n) ?? 0) + 1);
|
|
188703
188723
|
}
|
|
188704
188724
|
const prevInLoop = this.inLoop;
|
|
188705
188725
|
this.inLoop = true;
|
|
188726
|
+
const prevLoopKeyDepth = this.currentLoopKeyDepth;
|
|
188727
|
+
this.currentLoopKeyDepth = loop.depth;
|
|
188706
188728
|
const renderedChildren = this.renderChildren(loop.children);
|
|
188729
|
+
this.currentLoopKeyDepth = prevLoopKeyDepth;
|
|
188707
188730
|
this.inLoop = prevInLoop;
|
|
188708
188731
|
const children = loop.bodyIsItemConditional && loop.key ? `<%= bf.comment("loop-i:" + bf.string(${this.convertExpressionToRuby(loop.key)})) %>
|
|
188709
188732
|
${renderedChildren}` : renderedChildren;
|
|
@@ -188737,23 +188760,29 @@ ${renderedChildren}` : renderedChildren;
|
|
|
188737
188760
|
}
|
|
188738
188761
|
lines.push(`<%- ${sortedHoist} = ${sorted} -%>`);
|
|
188739
188762
|
}
|
|
188740
|
-
|
|
188741
|
-
|
|
188742
|
-
|
|
188743
|
-
|
|
188744
|
-
|
|
188745
|
-
|
|
188746
|
-
|
|
188747
|
-
|
|
188748
|
-
|
|
188749
|
-
|
|
188750
|
-
|
|
188751
|
-
|
|
188752
|
-
|
|
188763
|
+
if (loop.objectIteration) {
|
|
188764
|
+
const method = loop.objectIteration === "entries" ? "each_pair" : loop.objectIteration === "keys" ? "each_key" : "each_value";
|
|
188765
|
+
const blockParams = loop.objectIteration === "entries" ? `${rubyLocal(loop.index ?? param)}, ${rubyLocal(param)}` : rubyLocal(param);
|
|
188766
|
+
lines.push(`<%- ${array}.${method} do |${blockParams}| -%>`);
|
|
188767
|
+
} else {
|
|
188768
|
+
lines.push(`<%- (0...${array}.length).each do |${indexVar}| -%>`);
|
|
188769
|
+
if (loop.iterationShape !== "keys") {
|
|
188770
|
+
if (supportableDestructure) {
|
|
188771
|
+
lines.push(`<%- __bf_item = ${array}[${indexVar}] -%>`);
|
|
188772
|
+
for (const b of loop.paramBindings ?? []) {
|
|
188773
|
+
const accessor = rubyAccessorFromSegments("__bf_item", b.segments ?? []);
|
|
188774
|
+
if (b.rest?.kind === "array") {
|
|
188775
|
+
lines.push(`<%- ${rubyLocal(b.name)} = bf.slice(${accessor}, ${b.rest.from}) -%>`);
|
|
188776
|
+
} else if (b.rest?.kind === "object") {
|
|
188777
|
+
const excludeSyms = b.rest.exclude.map((k) => rubySymbolLiteral(k.key)).join(", ");
|
|
188778
|
+
lines.push(`<%- ${rubyLocal(b.name)} = ${accessor}.except(${excludeSyms}) -%>`);
|
|
188779
|
+
} else {
|
|
188780
|
+
lines.push(`<%- ${rubyLocal(b.name)} = ${accessor} -%>`);
|
|
188781
|
+
}
|
|
188753
188782
|
}
|
|
188783
|
+
} else {
|
|
188784
|
+
lines.push(`<%- ${rubyLocal(param)} = ${array}[${indexVar}] -%>`);
|
|
188754
188785
|
}
|
|
188755
|
-
} else {
|
|
188756
|
-
lines.push(`<%- ${rubyLocal(param)} = ${array}[${indexVar}] -%>`);
|
|
188757
188786
|
}
|
|
188758
188787
|
}
|
|
188759
188788
|
if (loop.filterPredicate) {
|
|
@@ -188805,9 +188834,23 @@ ${renderedChildren}` : renderedChildren;
|
|
|
188805
188834
|
};
|
|
188806
188835
|
renderComponent(comp) {
|
|
188807
188836
|
const propParts = [];
|
|
188837
|
+
const namedSlotCaptures = [];
|
|
188808
188838
|
for (const p of comp.props) {
|
|
188809
188839
|
if ((p.name.match(/^on[A-Z]/) || p.name === "ref") && p.value.kind === "expression")
|
|
188810
188840
|
continue;
|
|
188841
|
+
if (p.value.kind === "jsx-children" && p.name !== "children") {
|
|
188842
|
+
const prevInLoop = this.inLoop;
|
|
188843
|
+
this.inLoop = false;
|
|
188844
|
+
const slotBody = this.renderChildren(p.value.children);
|
|
188845
|
+
this.inLoop = prevInLoop;
|
|
188846
|
+
const suffix = `${this.childrenCaptureCounter++}`;
|
|
188847
|
+
const lenVar = `__bf_len_${suffix}`;
|
|
188848
|
+
const rawVar = `__bf_praw_${suffix}`;
|
|
188849
|
+
const capVar = `__bf_prop_${suffix}`;
|
|
188850
|
+
namedSlotCaptures.push(`<% ${lenVar} = _erbout.length %>${slotBody}<% ${rawVar} = _erbout.slice!(${lenVar}..); ${capVar} = bf.backend.mark_raw(${rawVar}) %>`);
|
|
188851
|
+
propParts.push(`${rubySymbolKey(p.name)} ${capVar}`);
|
|
188852
|
+
continue;
|
|
188853
|
+
}
|
|
188811
188854
|
const lowered = emitAttrValue(p.value, this.componentPropEmitter, p.name);
|
|
188812
188855
|
if (lowered)
|
|
188813
188856
|
propParts.push(lowered);
|
|
@@ -188826,10 +188869,10 @@ ${renderedChildren}` : renderedChildren;
|
|
|
188826
188869
|
const lenVar = `__bf_len_${suffix}`;
|
|
188827
188870
|
const capVar = `__bf_children_${suffix}`;
|
|
188828
188871
|
const propsHash2 = `{ ${[...propParts, `children: ${capVar}`].join(", ")} }`;
|
|
188829
|
-
return
|
|
188872
|
+
return `${namedSlotCaptures.join("")}<% ${lenVar} = _erbout.length %>${childrenBody}<% ${capVar} = _erbout.slice!(${lenVar}..) %><%= bf.render_child('${tplName}', ${propsHash2}) %>`;
|
|
188830
188873
|
}
|
|
188831
188874
|
const propsHash = propParts.length > 0 ? `{ ${propParts.join(", ")} }` : "{}";
|
|
188832
|
-
return
|
|
188875
|
+
return `${namedSlotCaptures.join("")}<%= bf.render_child('${tplName}', ${propsHash}) %>`;
|
|
188833
188876
|
}
|
|
188834
188877
|
childrenCaptureCounter = 0;
|
|
188835
188878
|
toTemplateName(componentName) {
|
|
@@ -188874,7 +188917,7 @@ ${alternate}
|
|
|
188874
188917
|
${children}`;
|
|
188875
188918
|
}
|
|
188876
188919
|
elementAttrEmitter = {
|
|
188877
|
-
emitLiteral: (value, name) => `${name}="${value.value}"`,
|
|
188920
|
+
emitLiteral: (value, name) => `${name}="${escapeHtml(value.value)}"`,
|
|
188878
188921
|
emitExpression: (value, name) => {
|
|
188879
188922
|
if (name === "style") {
|
|
188880
188923
|
const css = this.tryLowerStyleObject(value.expr);
|
|
@@ -188969,9 +189012,10 @@ ${children}`;
|
|
|
188969
189012
|
let attrName;
|
|
188970
189013
|
if (attr.name === "className")
|
|
188971
189014
|
attrName = "class";
|
|
188972
|
-
else if (attr.name === "key")
|
|
188973
|
-
|
|
188974
|
-
|
|
189015
|
+
else if (attr.name === "key") {
|
|
189016
|
+
const depth = this.currentLoopKeyDepth;
|
|
189017
|
+
attrName = depth > 0 ? `data-key-${depth}` : "data-key";
|
|
189018
|
+
} else
|
|
188975
189019
|
attrName = attr.name;
|
|
188976
189020
|
const lowered = emitAttrValue(attr.value, this.elementAttrEmitter, attrName);
|
|
188977
189021
|
if (lowered)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conformance-pins.d.ts","sourceRoot":"","sources":["../src/conformance-pins.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;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;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEtD,eAAO,MAAM,eAAe,EAAE,eA4F7B,CAAA"}
|