@barefootjs/mojolicious 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/index.js
CHANGED
|
@@ -396,7 +396,7 @@ ${whenTrue}
|
|
|
396
396
|
array = `$${sortedHoist}`;
|
|
397
397
|
}
|
|
398
398
|
const param = loop.param;
|
|
399
|
-
const indexVar = loop.index ? `$${loop.index}` : "$_i";
|
|
399
|
+
const indexVar = loop.iterationShape === "keys" ? `$${param}` : loop.index ? `$${loop.index}` : "$_i";
|
|
400
400
|
const prevInLoop = this.inLoop;
|
|
401
401
|
this.inLoop = true;
|
|
402
402
|
const children = this.renderChildren(loop.children);
|
|
@@ -407,7 +407,9 @@ ${whenTrue}
|
|
|
407
407
|
lines.push(`% my $${sortedHoist} = ${renderSortMethod(rawArray, loop.sortComparator)};`);
|
|
408
408
|
}
|
|
409
409
|
lines.push(`% for my ${indexVar} (0..$#{${array}}) {`);
|
|
410
|
-
|
|
410
|
+
if (loop.iterationShape !== "keys") {
|
|
411
|
+
lines.push(`% my $${param} = ${array}->[${indexVar}];`);
|
|
412
|
+
}
|
|
411
413
|
if (loop.filterPredicate) {
|
|
412
414
|
let filterCond;
|
|
413
415
|
if (loop.filterPredicate.blockBody) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mojo-adapter.d.ts","sourceRoot":"","sources":["../../src/adapter/mojo-adapter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,MAAM,EACN,SAAS,EACT,MAAM,EACN,YAAY,EACZ,aAAa,EACb,MAAM,EACN,WAAW,EACX,UAAU,EACV,MAAM,EACN,aAAa,EACb,UAAU,EACV,OAAO,EAKP,yBAAyB,EAC1B,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,WAAW,EACX,KAAK,aAAa,EAClB,KAAK,sBAAsB,EAM3B,KAAK,aAAa,EAClB,KAAK,UA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;IACH,OAAO,CAAC,gCAAgC;IAmBxC;;;;;;;;;;;;;;;;OAgBG;IACH,OAAO,CAAC,+BAA+B;IA+BvC,OAAO,CAAC,uBAAuB;IAwH/B;;;;;;;;;;;;;;;;;OAiBG;IACH,OAAO,CAAC,yBAAyB;IA8DjC;;;;;;;;OAQG;IACH,OAAO,CAAC,sBAAsB;IAgD9B;;;;;OAKG;IACH,OAAO,CAAC,sBAAsB;IAI9B,4EAA4E;IAC5E,8BAA8B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAElD;IAED,iFAAiF;IACjF,2BAA2B,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAEnE;CACF;AAydD,eAAO,MAAM,WAAW,aAAoB,CAAA"}
|
package/dist/build.js
CHANGED
|
@@ -396,7 +396,7 @@ ${whenTrue}
|
|
|
396
396
|
array = `$${sortedHoist}`;
|
|
397
397
|
}
|
|
398
398
|
const param = loop.param;
|
|
399
|
-
const indexVar = loop.index ? `$${loop.index}` : "$_i";
|
|
399
|
+
const indexVar = loop.iterationShape === "keys" ? `$${param}` : loop.index ? `$${loop.index}` : "$_i";
|
|
400
400
|
const prevInLoop = this.inLoop;
|
|
401
401
|
this.inLoop = true;
|
|
402
402
|
const children = this.renderChildren(loop.children);
|
|
@@ -407,7 +407,9 @@ ${whenTrue}
|
|
|
407
407
|
lines.push(`% my $${sortedHoist} = ${renderSortMethod(rawArray, loop.sortComparator)};`);
|
|
408
408
|
}
|
|
409
409
|
lines.push(`% for my ${indexVar} (0..$#{${array}}) {`);
|
|
410
|
-
|
|
410
|
+
if (loop.iterationShape !== "keys") {
|
|
411
|
+
lines.push(`% my $${param} = ${array}->[${indexVar}];`);
|
|
412
|
+
}
|
|
411
413
|
if (loop.filterPredicate) {
|
|
412
414
|
let filterCond;
|
|
413
415
|
if (loop.filterPredicate.blockBody) {
|
package/dist/index.js
CHANGED
|
@@ -396,7 +396,7 @@ ${whenTrue}
|
|
|
396
396
|
array = `$${sortedHoist}`;
|
|
397
397
|
}
|
|
398
398
|
const param = loop.param;
|
|
399
|
-
const indexVar = loop.index ? `$${loop.index}` : "$_i";
|
|
399
|
+
const indexVar = loop.iterationShape === "keys" ? `$${param}` : loop.index ? `$${loop.index}` : "$_i";
|
|
400
400
|
const prevInLoop = this.inLoop;
|
|
401
401
|
this.inLoop = true;
|
|
402
402
|
const children = this.renderChildren(loop.children);
|
|
@@ -407,7 +407,9 @@ ${whenTrue}
|
|
|
407
407
|
lines.push(`% my $${sortedHoist} = ${renderSortMethod(rawArray, loop.sortComparator)};`);
|
|
408
408
|
}
|
|
409
409
|
lines.push(`% for my ${indexVar} (0..$#{${array}}) {`);
|
|
410
|
-
|
|
410
|
+
if (loop.iterationShape !== "keys") {
|
|
411
|
+
lines.push(`% my $${param} = ${array}->[${indexVar}];`);
|
|
412
|
+
}
|
|
411
413
|
if (loop.filterPredicate) {
|
|
412
414
|
let filterCond;
|
|
413
415
|
if (loop.filterPredicate.blockBody) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@barefootjs/mojolicious",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Mojolicious EP template adapter for BarefootJS - generates .html.ep files from IR",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -52,14 +52,14 @@
|
|
|
52
52
|
"directory": "packages/adapter-mojolicious"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@barefootjs/shared": "0.
|
|
55
|
+
"@barefootjs/shared": "0.3.0"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
|
-
"@barefootjs/jsx": "0.
|
|
58
|
+
"@barefootjs/jsx": ">=0.2.0"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@barefootjs/adapter-tests": "0.1.0",
|
|
62
|
-
"@barefootjs/jsx": "0.
|
|
62
|
+
"@barefootjs/jsx": "0.3.0",
|
|
63
63
|
"typescript": "^5.0.0"
|
|
64
64
|
}
|
|
65
65
|
}
|
|
@@ -895,6 +895,10 @@ import { fixture as arraySortFieldDescFixture } from '../../../adapter-tests/fix
|
|
|
895
895
|
import { fixture as arraySortPrimitiveFixture } from '../../../adapter-tests/fixtures/methods/array-sort-primitive'
|
|
896
896
|
import { fixture as arraySortLocaleFixture } from '../../../adapter-tests/fixtures/methods/array-sort-locale'
|
|
897
897
|
import { fixture as arrayToSortedFixture } from '../../../adapter-tests/fixtures/methods/array-toSorted'
|
|
898
|
+
// #1448 Tier B — .entries / .keys / .values iteration shapes.
|
|
899
|
+
import { fixture as arrayEntriesFixture } from '../../../adapter-tests/fixtures/methods/array-entries'
|
|
900
|
+
import { fixture as arrayKeysFixture } from '../../../adapter-tests/fixtures/methods/array-keys'
|
|
901
|
+
import { fixture as arrayValuesFixture } from '../../../adapter-tests/fixtures/methods/array-values'
|
|
898
902
|
|
|
899
903
|
describe('MojoAdapter - #1448 Tier A/B fixture-driven lowering pins', () => {
|
|
900
904
|
const cases = [
|
|
@@ -920,6 +924,13 @@ describe('MojoAdapter - #1448 Tier A/B fixture-driven lowering pins', () => {
|
|
|
920
924
|
{ fixture: arraySortPrimitiveFixture, expect: `bf->sort($nums, { key_kind => 'self', compare_type => 'numeric', direction => 'asc' })` },
|
|
921
925
|
{ fixture: arraySortLocaleFixture, expect: `bf->sort($names, { key_kind => 'self', compare_type => 'string', direction => 'asc' })` },
|
|
922
926
|
{ fixture: arrayToSortedFixture, expect: `bf->sort($nums, { key_kind => 'self', compare_type => 'numeric', direction => 'asc' })` },
|
|
927
|
+
// #1448 Tier B — iteration shapes. These are loop-level patterns.
|
|
928
|
+
// .entries() → for loop with both $i index var and $v value var
|
|
929
|
+
{ fixture: arrayEntriesFixture, expect: '% my $v = $items->[$i];' },
|
|
930
|
+
// .keys() → for loop with $k as the index var, no value assignment
|
|
931
|
+
{ fixture: arrayKeysFixture, expect: '% for my $k (0..$#{$items})' },
|
|
932
|
+
// .values() → standard for loop (same as plain .map())
|
|
933
|
+
{ fixture: arrayValuesFixture, expect: '% my $v = $items->[$_i];' },
|
|
923
934
|
]
|
|
924
935
|
|
|
925
936
|
for (const { fixture, expect: expectedHelper } of cases) {
|
|
@@ -587,7 +587,12 @@ export class MojoAdapter extends BaseAdapter implements IRNodeEmitter<MojoRender
|
|
|
587
587
|
array = `$${sortedHoist}`
|
|
588
588
|
}
|
|
589
589
|
const param = loop.param
|
|
590
|
-
|
|
590
|
+
// `.keys().map(k => ...)` — the callback param is the index.
|
|
591
|
+
// Use it as the for-loop variable and skip the per-item value
|
|
592
|
+
// assignment.
|
|
593
|
+
const indexVar = loop.iterationShape === 'keys'
|
|
594
|
+
? `$${param}`
|
|
595
|
+
: loop.index ? `$${loop.index}` : '$_i'
|
|
591
596
|
const prevInLoop = this.inLoop
|
|
592
597
|
this.inLoop = true
|
|
593
598
|
const children = this.renderChildren(loop.children)
|
|
@@ -601,7 +606,9 @@ export class MojoAdapter extends BaseAdapter implements IRNodeEmitter<MojoRender
|
|
|
601
606
|
lines.push(`% my $${sortedHoist} = ${renderSortMethod(rawArray, loop.sortComparator)};`)
|
|
602
607
|
}
|
|
603
608
|
lines.push(`% for my ${indexVar} (0..$#{${array}}) {`)
|
|
604
|
-
|
|
609
|
+
if (loop.iterationShape !== 'keys') {
|
|
610
|
+
lines.push(`% my $${param} = ${array}->[${indexVar}];`)
|
|
611
|
+
}
|
|
605
612
|
|
|
606
613
|
// Handle filter().map() pattern by wrapping children in if-condition
|
|
607
614
|
if (loop.filterPredicate) {
|