@barefootjs/go-template 0.1.3 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapter/go-template-adapter.d.ts +1 -0
- package/dist/adapter/go-template-adapter.d.ts.map +1 -1
- package/dist/adapter/index.js +37 -4
- package/dist/build.js +37 -4
- package/dist/index.js +37 -4
- package/package.json +3 -3
- package/src/__tests__/go-template-adapter.test.ts +35 -0
- package/src/adapter/go-template-adapter.ts +49 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"go-template-adapter.d.ts","sourceRoot":"","sources":["../../src/adapter/go-template-adapter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EACV,WAAW,EACX,MAAM,EACN,SAAS,EACT,MAAM,EACN,YAAY,EACZ,aAAa,EACb,MAAM,EAEN,WAAW,EACX,UAAU,EACV,MAAM,EAMN,UAAU,EAEV,cAAc,EACd,YAAY,EACZ,aAAa,EACb,UAAU,EACV,OAAO,EACP,yBAAyB,EAC1B,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,WAAW,EACX,KAAK,aAAa,EAClB,KAAK,sBAAsB,EAE3B,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,UAAU,EAUhB,MAAM,iBAAiB,CAAA;AAGxB;;;;;GAKG;AACH,KAAK,WAAW,GAAG;IACjB,uBAAuB,CAAC,EAAE,OAAO,CAAA;CAClC,CAAA;AA2ED,MAAM,WAAW,wBAAwB;IACvC,kEAAkE;IAClE,WAAW,CAAC,EAAE,MAAM,CAAA;IAEpB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAA;IAEzB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB;AAoFD,qBAAa,iBAAkB,SAAQ,WAAY,YAAW,iBAAiB,EAAE,aAAa,CAA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E,UAAU,CAAC,WAAW,CAAC,GAAG,MAAM,CAE7F;IAED,YAAY,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,UAAU,CAAC,WAAW,CAAC,GAAG,MAAM,CAExF;IAED,SAAS,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,UAAU,CAAC,WAAW,CAAC,GAAG,MAAM,CAElF;IAED,aAAa,CAAC,OAAO,EAAE,SAAS,GAAG,MAAM,CAuBxC;IAED,gBAAgB,CAAC,IAAI,EAAE,YAAY,GAAG,MAAM,CA6B3C;IAED;;;;OAIG;IACH,OAAO,CAAC,2BAA2B;IAQnC;;;;;OAKG;IACH,OAAO,CAAC,gBAAgB;IAQxB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"go-template-adapter.d.ts","sourceRoot":"","sources":["../../src/adapter/go-template-adapter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EACV,WAAW,EACX,MAAM,EACN,SAAS,EACT,MAAM,EACN,YAAY,EACZ,aAAa,EACb,MAAM,EAEN,WAAW,EACX,UAAU,EACV,MAAM,EAMN,UAAU,EAEV,cAAc,EACd,YAAY,EACZ,aAAa,EACb,UAAU,EACV,OAAO,EACP,yBAAyB,EAC1B,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,WAAW,EACX,KAAK,aAAa,EAClB,KAAK,sBAAsB,EAE3B,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,UAAU,EAUhB,MAAM,iBAAiB,CAAA;AAGxB;;;;;GAKG;AACH,KAAK,WAAW,GAAG;IACjB,uBAAuB,CAAC,EAAE,OAAO,CAAA;CAClC,CAAA;AA2ED,MAAM,WAAW,wBAAwB;IACvC,kEAAkE;IAClE,WAAW,CAAC,E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C,OAAO;IAQf,OAAO,CAAC,iBAAiB;IAqCzB,iBAAiB,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,CA0D7C;IAED;;;;OAIG;IACH,OAAO,CAAC,oBAAoB;IAyB5B,OAAO,CAAC,mBAAmB;IAiJ3B,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAiI/B;IAED;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAmB1B,eAAe,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,CAAC,EAAE;QAAE,uBAAuB,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,MAAM,CAyBtF;IAED;;;;;;OAMG;IACH,OAAO,CAAC,qBAAqB;IAqB7B,OAAO,CAAC,cAAc;IAStB,OAAO,CAAC,UAAU;IAMlB,WAAW,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAMjC;IAED,OAAO,CAAC,cAAc;IAItB;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAyElC;IAED,OAAO,CAAC,gBAAgB;IAsBxB;;;;;;;;;;;;;;;;OAgBG;IACH,OAAO,CAAC,0BAA0B;IA4BlC;;;;;;;;OAQG;IACH,OAAO,CAAC,cAAc;IAStB,OAAO,CAAC,0BAA0B;IAiClC,iBAAiB,CAAC,eAAe,EAAE,MAAM,GAAG,MAAM,CAKjD;IAED,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEvC;IAED,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEvC;IAED,OAAO,CAAC,kBAAkB;CAmB3B;AAED,eAAO,MAAM,iBAAiB,mBAA0B,CAAA"}
|
package/dist/adapter/index.js
CHANGED
|
@@ -80,6 +80,7 @@ class GoTemplateAdapter extends BaseAdapter {
|
|
|
80
80
|
options;
|
|
81
81
|
inLoop = false;
|
|
82
82
|
loopParamStack = [];
|
|
83
|
+
loopVarRefCount = new Map;
|
|
83
84
|
errors = [];
|
|
84
85
|
propsObjectName = null;
|
|
85
86
|
restPropsName = null;
|
|
@@ -1534,6 +1535,11 @@ ${goFields.join(`
|
|
|
1534
1535
|
return emitParsedExpr(expr, this);
|
|
1535
1536
|
}
|
|
1536
1537
|
identifier(name) {
|
|
1538
|
+
const currentLoopParam = this.loopParamStack[this.loopParamStack.length - 1];
|
|
1539
|
+
if (currentLoopParam && name === currentLoopParam)
|
|
1540
|
+
return ".";
|
|
1541
|
+
if (this.loopVarRefCount.has(name))
|
|
1542
|
+
return `$${name}`;
|
|
1537
1543
|
return `.${this.capitalizeFieldName(name)}`;
|
|
1538
1544
|
}
|
|
1539
1545
|
literal(value, literalType) {
|
|
@@ -2323,6 +2329,9 @@ Options:
|
|
|
2323
2329
|
if (currentLoopParam && expr.name === currentLoopParam) {
|
|
2324
2330
|
return plain(".");
|
|
2325
2331
|
}
|
|
2332
|
+
if (this.loopVarRefCount.has(expr.name)) {
|
|
2333
|
+
return plain(`$${expr.name}`);
|
|
2334
|
+
}
|
|
2326
2335
|
}
|
|
2327
2336
|
return plain(`.${this.capitalizeFieldName(expr.name)}`);
|
|
2328
2337
|
case "literal":
|
|
@@ -2465,14 +2474,38 @@ Options:
|
|
|
2465
2474
|
}
|
|
2466
2475
|
let goArray = this.convertExpressionToGo(loop.array);
|
|
2467
2476
|
const param = loop.param;
|
|
2468
|
-
|
|
2477
|
+
let index = loop.index || "_";
|
|
2478
|
+
let rangeIndex = index;
|
|
2479
|
+
let rangeValue = param;
|
|
2480
|
+
if (loop.iterationShape === "keys") {
|
|
2481
|
+
rangeIndex = param;
|
|
2482
|
+
rangeValue = "_";
|
|
2483
|
+
}
|
|
2469
2484
|
const childComponent = this.findChildComponent(loop.children);
|
|
2470
2485
|
if (childComponent) {
|
|
2471
2486
|
goArray = `.${childComponent.name}s`;
|
|
2472
2487
|
}
|
|
2473
2488
|
this.inLoop = true;
|
|
2474
|
-
|
|
2489
|
+
const addedLoopVars = [];
|
|
2490
|
+
if (loop.iterationShape === "keys") {
|
|
2491
|
+
this.loopParamStack.push("");
|
|
2492
|
+
this.loopVarRefCount.set(param, (this.loopVarRefCount.get(param) ?? 0) + 1);
|
|
2493
|
+
addedLoopVars.push(param);
|
|
2494
|
+
} else {
|
|
2495
|
+
this.loopParamStack.push(param);
|
|
2496
|
+
if (rangeIndex !== "_") {
|
|
2497
|
+
this.loopVarRefCount.set(rangeIndex, (this.loopVarRefCount.get(rangeIndex) ?? 0) + 1);
|
|
2498
|
+
addedLoopVars.push(rangeIndex);
|
|
2499
|
+
}
|
|
2500
|
+
}
|
|
2475
2501
|
const children = this.renderChildren(loop.children);
|
|
2502
|
+
for (const v of addedLoopVars) {
|
|
2503
|
+
const rc = (this.loopVarRefCount.get(v) ?? 1) - 1;
|
|
2504
|
+
if (rc <= 0)
|
|
2505
|
+
this.loopVarRefCount.delete(v);
|
|
2506
|
+
else
|
|
2507
|
+
this.loopVarRefCount.set(v, rc);
|
|
2508
|
+
}
|
|
2476
2509
|
this.loopParamStack.pop();
|
|
2477
2510
|
this.inLoop = false;
|
|
2478
2511
|
if (loop.sortComparator) {
|
|
@@ -2488,10 +2521,10 @@ Options:
|
|
|
2488
2521
|
filterCond = "true";
|
|
2489
2522
|
}
|
|
2490
2523
|
const itemMarker2 = loop.bodyIsMultiRoot ? `{{bfComment "bf-loop-i"}}` : "";
|
|
2491
|
-
return `{{bfComment "loop:${loop.markerId}"}}{{range $${
|
|
2524
|
+
return `{{bfComment "loop:${loop.markerId}"}}{{range $${rangeIndex}, $${rangeValue} := ${goArray}}}{{if ${filterCond}}}${itemMarker2}${children}{{end}}{{end}}{{bfComment "/loop:${loop.markerId}"}}`;
|
|
2492
2525
|
}
|
|
2493
2526
|
const itemMarker = loop.bodyIsMultiRoot ? `{{bfComment "bf-loop-i"}}` : "";
|
|
2494
|
-
return `{{bfComment "loop:${loop.markerId}"}}{{range $${
|
|
2527
|
+
return `{{bfComment "loop:${loop.markerId}"}}{{range $${rangeIndex}, $${rangeValue} := ${goArray}}}${itemMarker}${children}{{end}}{{bfComment "/loop:${loop.markerId}"}}`;
|
|
2495
2528
|
}
|
|
2496
2529
|
findChildComponent(nodes) {
|
|
2497
2530
|
for (const node of nodes) {
|
package/dist/build.js
CHANGED
|
@@ -420,6 +420,7 @@ class GoTemplateAdapter extends BaseAdapter {
|
|
|
420
420
|
options;
|
|
421
421
|
inLoop = false;
|
|
422
422
|
loopParamStack = [];
|
|
423
|
+
loopVarRefCount = new Map;
|
|
423
424
|
errors = [];
|
|
424
425
|
propsObjectName = null;
|
|
425
426
|
restPropsName = null;
|
|
@@ -1874,6 +1875,11 @@ ${goFields.join(`
|
|
|
1874
1875
|
return emitParsedExpr(expr, this);
|
|
1875
1876
|
}
|
|
1876
1877
|
identifier(name) {
|
|
1878
|
+
const currentLoopParam = this.loopParamStack[this.loopParamStack.length - 1];
|
|
1879
|
+
if (currentLoopParam && name === currentLoopParam)
|
|
1880
|
+
return ".";
|
|
1881
|
+
if (this.loopVarRefCount.has(name))
|
|
1882
|
+
return `$${name}`;
|
|
1877
1883
|
return `.${this.capitalizeFieldName(name)}`;
|
|
1878
1884
|
}
|
|
1879
1885
|
literal(value, literalType) {
|
|
@@ -2663,6 +2669,9 @@ Options:
|
|
|
2663
2669
|
if (currentLoopParam && expr.name === currentLoopParam) {
|
|
2664
2670
|
return plain(".");
|
|
2665
2671
|
}
|
|
2672
|
+
if (this.loopVarRefCount.has(expr.name)) {
|
|
2673
|
+
return plain(`$${expr.name}`);
|
|
2674
|
+
}
|
|
2666
2675
|
}
|
|
2667
2676
|
return plain(`.${this.capitalizeFieldName(expr.name)}`);
|
|
2668
2677
|
case "literal":
|
|
@@ -2805,14 +2814,38 @@ Options:
|
|
|
2805
2814
|
}
|
|
2806
2815
|
let goArray = this.convertExpressionToGo(loop.array);
|
|
2807
2816
|
const param = loop.param;
|
|
2808
|
-
|
|
2817
|
+
let index = loop.index || "_";
|
|
2818
|
+
let rangeIndex = index;
|
|
2819
|
+
let rangeValue = param;
|
|
2820
|
+
if (loop.iterationShape === "keys") {
|
|
2821
|
+
rangeIndex = param;
|
|
2822
|
+
rangeValue = "_";
|
|
2823
|
+
}
|
|
2809
2824
|
const childComponent = this.findChildComponent(loop.children);
|
|
2810
2825
|
if (childComponent) {
|
|
2811
2826
|
goArray = `.${childComponent.name}s`;
|
|
2812
2827
|
}
|
|
2813
2828
|
this.inLoop = true;
|
|
2814
|
-
|
|
2829
|
+
const addedLoopVars = [];
|
|
2830
|
+
if (loop.iterationShape === "keys") {
|
|
2831
|
+
this.loopParamStack.push("");
|
|
2832
|
+
this.loopVarRefCount.set(param, (this.loopVarRefCount.get(param) ?? 0) + 1);
|
|
2833
|
+
addedLoopVars.push(param);
|
|
2834
|
+
} else {
|
|
2835
|
+
this.loopParamStack.push(param);
|
|
2836
|
+
if (rangeIndex !== "_") {
|
|
2837
|
+
this.loopVarRefCount.set(rangeIndex, (this.loopVarRefCount.get(rangeIndex) ?? 0) + 1);
|
|
2838
|
+
addedLoopVars.push(rangeIndex);
|
|
2839
|
+
}
|
|
2840
|
+
}
|
|
2815
2841
|
const children = this.renderChildren(loop.children);
|
|
2842
|
+
for (const v of addedLoopVars) {
|
|
2843
|
+
const rc = (this.loopVarRefCount.get(v) ?? 1) - 1;
|
|
2844
|
+
if (rc <= 0)
|
|
2845
|
+
this.loopVarRefCount.delete(v);
|
|
2846
|
+
else
|
|
2847
|
+
this.loopVarRefCount.set(v, rc);
|
|
2848
|
+
}
|
|
2816
2849
|
this.loopParamStack.pop();
|
|
2817
2850
|
this.inLoop = false;
|
|
2818
2851
|
if (loop.sortComparator) {
|
|
@@ -2828,10 +2861,10 @@ Options:
|
|
|
2828
2861
|
filterCond = "true";
|
|
2829
2862
|
}
|
|
2830
2863
|
const itemMarker2 = loop.bodyIsMultiRoot ? `{{bfComment "bf-loop-i"}}` : "";
|
|
2831
|
-
return `{{bfComment "loop:${loop.markerId}"}}{{range $${
|
|
2864
|
+
return `{{bfComment "loop:${loop.markerId}"}}{{range $${rangeIndex}, $${rangeValue} := ${goArray}}}{{if ${filterCond}}}${itemMarker2}${children}{{end}}{{end}}{{bfComment "/loop:${loop.markerId}"}}`;
|
|
2832
2865
|
}
|
|
2833
2866
|
const itemMarker = loop.bodyIsMultiRoot ? `{{bfComment "bf-loop-i"}}` : "";
|
|
2834
|
-
return `{{bfComment "loop:${loop.markerId}"}}{{range $${
|
|
2867
|
+
return `{{bfComment "loop:${loop.markerId}"}}{{range $${rangeIndex}, $${rangeValue} := ${goArray}}}${itemMarker}${children}{{end}}{{bfComment "/loop:${loop.markerId}"}}`;
|
|
2835
2868
|
}
|
|
2836
2869
|
findChildComponent(nodes) {
|
|
2837
2870
|
for (const node of nodes) {
|
package/dist/index.js
CHANGED
|
@@ -80,6 +80,7 @@ class GoTemplateAdapter extends BaseAdapter {
|
|
|
80
80
|
options;
|
|
81
81
|
inLoop = false;
|
|
82
82
|
loopParamStack = [];
|
|
83
|
+
loopVarRefCount = new Map;
|
|
83
84
|
errors = [];
|
|
84
85
|
propsObjectName = null;
|
|
85
86
|
restPropsName = null;
|
|
@@ -1534,6 +1535,11 @@ ${goFields.join(`
|
|
|
1534
1535
|
return emitParsedExpr(expr, this);
|
|
1535
1536
|
}
|
|
1536
1537
|
identifier(name) {
|
|
1538
|
+
const currentLoopParam = this.loopParamStack[this.loopParamStack.length - 1];
|
|
1539
|
+
if (currentLoopParam && name === currentLoopParam)
|
|
1540
|
+
return ".";
|
|
1541
|
+
if (this.loopVarRefCount.has(name))
|
|
1542
|
+
return `$${name}`;
|
|
1537
1543
|
return `.${this.capitalizeFieldName(name)}`;
|
|
1538
1544
|
}
|
|
1539
1545
|
literal(value, literalType) {
|
|
@@ -2323,6 +2329,9 @@ Options:
|
|
|
2323
2329
|
if (currentLoopParam && expr.name === currentLoopParam) {
|
|
2324
2330
|
return plain(".");
|
|
2325
2331
|
}
|
|
2332
|
+
if (this.loopVarRefCount.has(expr.name)) {
|
|
2333
|
+
return plain(`$${expr.name}`);
|
|
2334
|
+
}
|
|
2326
2335
|
}
|
|
2327
2336
|
return plain(`.${this.capitalizeFieldName(expr.name)}`);
|
|
2328
2337
|
case "literal":
|
|
@@ -2465,14 +2474,38 @@ Options:
|
|
|
2465
2474
|
}
|
|
2466
2475
|
let goArray = this.convertExpressionToGo(loop.array);
|
|
2467
2476
|
const param = loop.param;
|
|
2468
|
-
|
|
2477
|
+
let index = loop.index || "_";
|
|
2478
|
+
let rangeIndex = index;
|
|
2479
|
+
let rangeValue = param;
|
|
2480
|
+
if (loop.iterationShape === "keys") {
|
|
2481
|
+
rangeIndex = param;
|
|
2482
|
+
rangeValue = "_";
|
|
2483
|
+
}
|
|
2469
2484
|
const childComponent = this.findChildComponent(loop.children);
|
|
2470
2485
|
if (childComponent) {
|
|
2471
2486
|
goArray = `.${childComponent.name}s`;
|
|
2472
2487
|
}
|
|
2473
2488
|
this.inLoop = true;
|
|
2474
|
-
|
|
2489
|
+
const addedLoopVars = [];
|
|
2490
|
+
if (loop.iterationShape === "keys") {
|
|
2491
|
+
this.loopParamStack.push("");
|
|
2492
|
+
this.loopVarRefCount.set(param, (this.loopVarRefCount.get(param) ?? 0) + 1);
|
|
2493
|
+
addedLoopVars.push(param);
|
|
2494
|
+
} else {
|
|
2495
|
+
this.loopParamStack.push(param);
|
|
2496
|
+
if (rangeIndex !== "_") {
|
|
2497
|
+
this.loopVarRefCount.set(rangeIndex, (this.loopVarRefCount.get(rangeIndex) ?? 0) + 1);
|
|
2498
|
+
addedLoopVars.push(rangeIndex);
|
|
2499
|
+
}
|
|
2500
|
+
}
|
|
2475
2501
|
const children = this.renderChildren(loop.children);
|
|
2502
|
+
for (const v of addedLoopVars) {
|
|
2503
|
+
const rc = (this.loopVarRefCount.get(v) ?? 1) - 1;
|
|
2504
|
+
if (rc <= 0)
|
|
2505
|
+
this.loopVarRefCount.delete(v);
|
|
2506
|
+
else
|
|
2507
|
+
this.loopVarRefCount.set(v, rc);
|
|
2508
|
+
}
|
|
2476
2509
|
this.loopParamStack.pop();
|
|
2477
2510
|
this.inLoop = false;
|
|
2478
2511
|
if (loop.sortComparator) {
|
|
@@ -2488,10 +2521,10 @@ Options:
|
|
|
2488
2521
|
filterCond = "true";
|
|
2489
2522
|
}
|
|
2490
2523
|
const itemMarker2 = loop.bodyIsMultiRoot ? `{{bfComment "bf-loop-i"}}` : "";
|
|
2491
|
-
return `{{bfComment "loop:${loop.markerId}"}}{{range $${
|
|
2524
|
+
return `{{bfComment "loop:${loop.markerId}"}}{{range $${rangeIndex}, $${rangeValue} := ${goArray}}}{{if ${filterCond}}}${itemMarker2}${children}{{end}}{{end}}{{bfComment "/loop:${loop.markerId}"}}`;
|
|
2492
2525
|
}
|
|
2493
2526
|
const itemMarker = loop.bodyIsMultiRoot ? `{{bfComment "bf-loop-i"}}` : "";
|
|
2494
|
-
return `{{bfComment "loop:${loop.markerId}"}}{{range $${
|
|
2527
|
+
return `{{bfComment "loop:${loop.markerId}"}}{{range $${rangeIndex}, $${rangeValue} := ${goArray}}}${itemMarker}${children}{{end}}{{bfComment "/loop:${loop.markerId}"}}`;
|
|
2495
2528
|
}
|
|
2496
2529
|
findChildComponent(nodes) {
|
|
2497
2530
|
for (const node of nodes) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@barefootjs/go-template",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Go html/template adapter for BarefootJS - generates Go template files from IR",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -49,11 +49,11 @@
|
|
|
49
49
|
"directory": "packages/adapter-go-template"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
|
-
"@barefootjs/jsx": "0.
|
|
52
|
+
"@barefootjs/jsx": ">=0.2.0",
|
|
53
53
|
"typescript": "^5.0.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@barefootjs/adapter-tests": "0.1.0",
|
|
57
|
-
"@barefootjs/jsx": "0.
|
|
57
|
+
"@barefootjs/jsx": "0.3.0"
|
|
58
58
|
}
|
|
59
59
|
}
|
|
@@ -1771,6 +1771,32 @@ export { A }`)
|
|
|
1771
1771
|
expect(result.template).toContain('bf_join (bf_concat .Left .Right) " "')
|
|
1772
1772
|
})
|
|
1773
1773
|
})
|
|
1774
|
+
|
|
1775
|
+
describe('.entries() / .keys() / .values() iteration shapes (#1448 Tier B)', () => {
|
|
1776
|
+
test('.entries().map(([i, v]) => ...) emits {{range $i, $v := .Items}}', () => {
|
|
1777
|
+
const result = compileAndGenerate(`function A({ items }: { items: string[] }) {
|
|
1778
|
+
return <ul>{items.entries().map(([i, v]) => <li key={i}>{i}: {v}</li>)}</ul>
|
|
1779
|
+
}
|
|
1780
|
+
export { A }`)
|
|
1781
|
+
expect(result.template).toContain('{{range $i, $v := .Items}}')
|
|
1782
|
+
})
|
|
1783
|
+
|
|
1784
|
+
test('.keys().map(k => ...) emits {{range $k, $_ := .Items}}', () => {
|
|
1785
|
+
const result = compileAndGenerate(`function A({ items }: { items: string[] }) {
|
|
1786
|
+
return <ul>{items.keys().map(k => <li key={k}>{k}</li>)}</ul>
|
|
1787
|
+
}
|
|
1788
|
+
export { A }`)
|
|
1789
|
+
expect(result.template).toContain('{{range $k, $_ := .Items}}')
|
|
1790
|
+
})
|
|
1791
|
+
|
|
1792
|
+
test('.values().map(v => ...) emits standard {{range $_, $v := .Items}}', () => {
|
|
1793
|
+
const result = compileAndGenerate(`function A({ items }: { items: string[] }) {
|
|
1794
|
+
return <ul>{items.values().map(v => <li key={v}>{v}</li>)}</ul>
|
|
1795
|
+
}
|
|
1796
|
+
export { A }`)
|
|
1797
|
+
expect(result.template).toContain('{{range $_, $v := .Items}}')
|
|
1798
|
+
})
|
|
1799
|
+
})
|
|
1774
1800
|
})
|
|
1775
1801
|
|
|
1776
1802
|
// =============================================================================
|
|
@@ -1808,6 +1834,10 @@ import { fixture as arraySortFieldDescFixture } from '../../../adapter-tests/fix
|
|
|
1808
1834
|
import { fixture as arraySortPrimitiveFixture } from '../../../adapter-tests/fixtures/methods/array-sort-primitive'
|
|
1809
1835
|
import { fixture as arraySortLocaleFixture } from '../../../adapter-tests/fixtures/methods/array-sort-locale'
|
|
1810
1836
|
import { fixture as arrayToSortedFixture } from '../../../adapter-tests/fixtures/methods/array-toSorted'
|
|
1837
|
+
// #1448 Tier B — .entries / .keys / .values iteration shapes.
|
|
1838
|
+
import { fixture as arrayEntriesFixture } from '../../../adapter-tests/fixtures/methods/array-entries'
|
|
1839
|
+
import { fixture as arrayKeysFixture } from '../../../adapter-tests/fixtures/methods/array-keys'
|
|
1840
|
+
import { fixture as arrayValuesFixture } from '../../../adapter-tests/fixtures/methods/array-values'
|
|
1811
1841
|
|
|
1812
1842
|
describe('GoTemplateAdapter - #1448 Tier A/B fixture-driven lowering pins', () => {
|
|
1813
1843
|
const cases = [
|
|
@@ -1838,6 +1868,11 @@ describe('GoTemplateAdapter - #1448 Tier A/B fixture-driven lowering pins', () =
|
|
|
1838
1868
|
{ fixture: arraySortPrimitiveFixture, expect: 'bf_sort .Nums "self" "" "numeric" "asc"' },
|
|
1839
1869
|
{ fixture: arraySortLocaleFixture, expect: 'bf_sort .Names "self" "" "string" "asc"' },
|
|
1840
1870
|
{ fixture: arrayToSortedFixture, expect: 'bf_sort .Nums "self" "" "numeric" "asc"' },
|
|
1871
|
+
// #1448 Tier B — iteration shapes. These are loop-level
|
|
1872
|
+
// patterns (range binding order), not helper function calls.
|
|
1873
|
+
{ fixture: arrayEntriesFixture, expect: '{{range $i, $v := .Items}}' },
|
|
1874
|
+
{ fixture: arrayKeysFixture, expect: '{{range $k, $_ := .Items}}' },
|
|
1875
|
+
{ fixture: arrayValuesFixture, expect: '{{range $_, $v := .Items}}' },
|
|
1841
1876
|
]
|
|
1842
1877
|
|
|
1843
1878
|
for (const { fixture, expect: expectedHelper } of cases) {
|
|
@@ -299,6 +299,7 @@ export class GoTemplateAdapter extends BaseAdapter implements ParsedExprEmitter,
|
|
|
299
299
|
private options: Required<GoTemplateAdapterOptions>
|
|
300
300
|
private inLoop: boolean = false
|
|
301
301
|
private loopParamStack: string[] = []
|
|
302
|
+
private loopVarRefCount: Map<string, number> = new Map()
|
|
302
303
|
private errors: CompilerError[] = []
|
|
303
304
|
private propsObjectName: string | null = null
|
|
304
305
|
/**
|
|
@@ -2474,6 +2475,9 @@ export class GoTemplateAdapter extends BaseAdapter implements ParsedExprEmitter,
|
|
|
2474
2475
|
// ===========================================================================
|
|
2475
2476
|
|
|
2476
2477
|
identifier(name: string): string {
|
|
2478
|
+
const currentLoopParam = this.loopParamStack[this.loopParamStack.length - 1]
|
|
2479
|
+
if (currentLoopParam && name === currentLoopParam) return '.'
|
|
2480
|
+
if (this.loopVarRefCount.has(name)) return `$${name}`
|
|
2477
2481
|
return `.${this.capitalizeFieldName(name)}`
|
|
2478
2482
|
}
|
|
2479
2483
|
|
|
@@ -3745,6 +3749,9 @@ export class GoTemplateAdapter extends BaseAdapter implements ParsedExprEmitter,
|
|
|
3745
3749
|
if (currentLoopParam && expr.name === currentLoopParam) {
|
|
3746
3750
|
return plain('.')
|
|
3747
3751
|
}
|
|
3752
|
+
if (this.loopVarRefCount.has(expr.name)) {
|
|
3753
|
+
return plain(`$${expr.name}`)
|
|
3754
|
+
}
|
|
3748
3755
|
}
|
|
3749
3756
|
return plain(`.${this.capitalizeFieldName(expr.name)}`)
|
|
3750
3757
|
|
|
@@ -3916,7 +3923,17 @@ export class GoTemplateAdapter extends BaseAdapter implements ParsedExprEmitter,
|
|
|
3916
3923
|
|
|
3917
3924
|
let goArray = this.convertExpressionToGo(loop.array)
|
|
3918
3925
|
const param = loop.param
|
|
3919
|
-
|
|
3926
|
+
let index = loop.index || '_'
|
|
3927
|
+
|
|
3928
|
+
// `.keys().map(k => ...)` — the callback param is the *index*, not
|
|
3929
|
+
// the value. Swap into the Go range's first binding slot so
|
|
3930
|
+
// `{{range $k, $_ := .Arr}}` makes `$k` the 0-based index.
|
|
3931
|
+
let rangeIndex = index
|
|
3932
|
+
let rangeValue = param
|
|
3933
|
+
if (loop.iterationShape === 'keys') {
|
|
3934
|
+
rangeIndex = param
|
|
3935
|
+
rangeValue = '_'
|
|
3936
|
+
}
|
|
3920
3937
|
|
|
3921
3938
|
// Check if the loop contains a component child
|
|
3922
3939
|
// If so, use .{ComponentName}s which has ScopeID for each item
|
|
@@ -3927,8 +3944,36 @@ export class GoTemplateAdapter extends BaseAdapter implements ParsedExprEmitter,
|
|
|
3927
3944
|
}
|
|
3928
3945
|
|
|
3929
3946
|
this.inLoop = true
|
|
3930
|
-
|
|
3947
|
+
// Track Go template loop variables. The range *value* variable
|
|
3948
|
+
// is the dot context (`.`) and goes on `loopParamStack`; the
|
|
3949
|
+
// range *index* variable needs `$name` notation and goes on
|
|
3950
|
+
// `loopVarRefCount`. For `.keys()`, the user's param IS the index
|
|
3951
|
+
// (in the `$k, $_` position), so it needs `$name` — don't push
|
|
3952
|
+
// it to loopParamStack (`.` would resolve to the value, not key).
|
|
3953
|
+
// Push `''` instead — falsy, so the `currentLoopParam &&` guard
|
|
3954
|
+
// in `identifier()` / `renderConditionExpr` short-circuits and
|
|
3955
|
+
// no name ever matches the empty string.
|
|
3956
|
+
// Uses ref-counting (not a flat Set) so nested loops with the
|
|
3957
|
+
// same index var name don't clobber the outer loop's entry on
|
|
3958
|
+
// cleanup.
|
|
3959
|
+
const addedLoopVars: string[] = []
|
|
3960
|
+
if (loop.iterationShape === 'keys') {
|
|
3961
|
+
this.loopParamStack.push('')
|
|
3962
|
+
this.loopVarRefCount.set(param, (this.loopVarRefCount.get(param) ?? 0) + 1)
|
|
3963
|
+
addedLoopVars.push(param)
|
|
3964
|
+
} else {
|
|
3965
|
+
this.loopParamStack.push(param)
|
|
3966
|
+
if (rangeIndex !== '_') {
|
|
3967
|
+
this.loopVarRefCount.set(rangeIndex, (this.loopVarRefCount.get(rangeIndex) ?? 0) + 1)
|
|
3968
|
+
addedLoopVars.push(rangeIndex)
|
|
3969
|
+
}
|
|
3970
|
+
}
|
|
3931
3971
|
const children = this.renderChildren(loop.children)
|
|
3972
|
+
for (const v of addedLoopVars) {
|
|
3973
|
+
const rc = (this.loopVarRefCount.get(v) ?? 1) - 1
|
|
3974
|
+
if (rc <= 0) this.loopVarRefCount.delete(v)
|
|
3975
|
+
else this.loopVarRefCount.set(v, rc)
|
|
3976
|
+
}
|
|
3932
3977
|
this.loopParamStack.pop()
|
|
3933
3978
|
this.inLoop = false
|
|
3934
3979
|
|
|
@@ -3963,11 +4008,11 @@ export class GoTemplateAdapter extends BaseAdapter implements ParsedExprEmitter,
|
|
|
3963
4008
|
|
|
3964
4009
|
// Per-item start marker for multi-root Fragment items (#1212).
|
|
3965
4010
|
const itemMarker = loop.bodyIsMultiRoot ? `{{bfComment "bf-loop-i"}}` : ''
|
|
3966
|
-
return `{{bfComment "loop:${loop.markerId}"}}{{range $${
|
|
4011
|
+
return `{{bfComment "loop:${loop.markerId}"}}{{range $${rangeIndex}, $${rangeValue} := ${goArray}}}{{if ${filterCond}}}${itemMarker}${children}{{end}}{{end}}{{bfComment "/loop:${loop.markerId}"}}`
|
|
3967
4012
|
}
|
|
3968
4013
|
|
|
3969
4014
|
const itemMarker = loop.bodyIsMultiRoot ? `{{bfComment "bf-loop-i"}}` : ''
|
|
3970
|
-
return `{{bfComment "loop:${loop.markerId}"}}{{range $${
|
|
4015
|
+
return `{{bfComment "loop:${loop.markerId}"}}{{range $${rangeIndex}, $${rangeValue} := ${goArray}}}${itemMarker}${children}{{end}}{{bfComment "/loop:${loop.markerId}"}}`
|
|
3971
4016
|
}
|
|
3972
4017
|
|
|
3973
4018
|
/**
|