@barefootjs/mojolicious 0.1.2 → 0.2.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.
@@ -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
- lines.push(`% my $${param} = ${array}->[${indexVar}];`);
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) {
@@ -702,7 +704,7 @@ ${reason}` : "";
702
704
  return true;
703
705
  }
704
706
  convertExpressionToPerl(expr) {
705
- if (/\.\s*(?:filter|every|some|reduce|reduceRight|forEach|flatMap|flat|findLast|findLastIndex)\s*\(/.test(expr)) {
707
+ if (/\.\s*(?:filter|every|some|reduce|reduceRight|forEach|flatMap|flat)\s*\(/.test(expr)) {
706
708
  return this.convertHigherOrderExpr(expr);
707
709
  }
708
710
  if (/\.\s*(?:includes|indexOf|lastIndexOf|at|concat|slice|reverse|toReversed|toLowerCase|toUpperCase|trim)\s*\(/.test(expr)) {
@@ -711,7 +713,7 @@ ${reason}` : "";
711
713
  if (/\.\s*join\s*\(/.test(expr)) {
712
714
  return this.convertHigherOrderExpr(expr);
713
715
  }
714
- const mojoOnlyMatch = /\.\s*(?<method>find|findIndex)\s*\(/.exec(expr);
716
+ const mojoOnlyMatch = /\.\s*(?<method>find|findIndex|findLast|findLastIndex)\s*\(/.exec(expr);
715
717
  if (mojoOnlyMatch) {
716
718
  const methodName = mojoOnlyMatch.groups.method;
717
719
  this.errors.push({
@@ -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,UAAU,EAYhB,MAAM,iBAAiB,CAAA;AAGxB;;;;;;GAMG;AACH,KAAK,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;AAC1C,OAAO,KAAK,EAAE,UAAU,EAAiD,MAAM,iBAAiB,CAAA;AAkEhG,MAAM,WAAW,kBAAkB;IACjC,qEAAqE;IACrE,gBAAgB,CAAC,EAAE,MAAM,CAAA;IAEzB,8EAA8E;IAC9E,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB;AAED,qBAAa,WAAY,SAAQ,WAAY,YAAW,aAAa,CAAC,aAAa,CAAC;IAClF,IAAI,SAAgB;IACpB,SAAS,SAAa;IACtB,qBAAqB,UAAO;IAE5B;;;;;;;;;;;OAWG;IACH,kBAAkB,EAAE,yBAAyB,CAA0B;IAEvE,OAAO,CAAC,aAAa,CAAa;IAClC,OAAO,CAAC,OAAO,CAA8B;IAC7C,OAAO,CAAC,MAAM,CAAsB;IACpC,OAAO,CAAC,MAAM,CAAiB;IAC/B;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,mBAAmB,CAAyB;IACpD;;;;;;OAMG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O,CAAC,cAAc;IAQtB,OAAO,CAAC,UAAU;IAIlB,WAAW,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAgBjC;IAMD;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CA8FlC;IAED,OAAO,CAAC,gBAAgB;IA0BxB,iBAAiB,CAAC,eAAe,EAAE,MAAM,GAAG,MAAM,CAIjD;IAED,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEvC;IAED,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEvC;IAMD;;;;;OAKG;IACH,OAAO,CAAC,oBAAoB;IAqB5B;;;OAGG;IACH,OAAO,CAAC,wBAAwB;IAuBhC,OAAO,CAAC,kBAAkB;IAiC1B,OAAO,CAAC,wBAAwB;IAsBhC,OAAO,CAAC,mBAAmB;IAe3B,OAAO,CAAC,iCAAiC;IAmCzC;;;;;;;OAOG;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
- lines.push(`% my $${param} = ${array}->[${indexVar}];`);
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) {
@@ -702,7 +704,7 @@ ${reason}` : "";
702
704
  return true;
703
705
  }
704
706
  convertExpressionToPerl(expr) {
705
- if (/\.\s*(?:filter|every|some|reduce|reduceRight|forEach|flatMap|flat|findLast|findLastIndex)\s*\(/.test(expr)) {
707
+ if (/\.\s*(?:filter|every|some|reduce|reduceRight|forEach|flatMap|flat)\s*\(/.test(expr)) {
706
708
  return this.convertHigherOrderExpr(expr);
707
709
  }
708
710
  if (/\.\s*(?:includes|indexOf|lastIndexOf|at|concat|slice|reverse|toReversed|toLowerCase|toUpperCase|trim)\s*\(/.test(expr)) {
@@ -711,7 +713,7 @@ ${reason}` : "";
711
713
  if (/\.\s*join\s*\(/.test(expr)) {
712
714
  return this.convertHigherOrderExpr(expr);
713
715
  }
714
- const mojoOnlyMatch = /\.\s*(?<method>find|findIndex)\s*\(/.exec(expr);
716
+ const mojoOnlyMatch = /\.\s*(?<method>find|findIndex|findLast|findLastIndex)\s*\(/.exec(expr);
715
717
  if (mojoOnlyMatch) {
716
718
  const methodName = mojoOnlyMatch.groups.method;
717
719
  this.errors.push({
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
- lines.push(`% my $${param} = ${array}->[${indexVar}];`);
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) {
@@ -702,7 +704,7 @@ ${reason}` : "";
702
704
  return true;
703
705
  }
704
706
  convertExpressionToPerl(expr) {
705
- if (/\.\s*(?:filter|every|some|reduce|reduceRight|forEach|flatMap|flat|findLast|findLastIndex)\s*\(/.test(expr)) {
707
+ if (/\.\s*(?:filter|every|some|reduce|reduceRight|forEach|flatMap|flat)\s*\(/.test(expr)) {
706
708
  return this.convertHigherOrderExpr(expr);
707
709
  }
708
710
  if (/\.\s*(?:includes|indexOf|lastIndexOf|at|concat|slice|reverse|toReversed|toLowerCase|toUpperCase|trim)\s*\(/.test(expr)) {
@@ -711,7 +713,7 @@ ${reason}` : "";
711
713
  if (/\.\s*join\s*\(/.test(expr)) {
712
714
  return this.convertHigherOrderExpr(expr);
713
715
  }
714
- const mojoOnlyMatch = /\.\s*(?<method>find|findIndex)\s*\(/.exec(expr);
716
+ const mojoOnlyMatch = /\.\s*(?<method>find|findIndex|findLast|findLastIndex)\s*\(/.exec(expr);
715
717
  if (mojoOnlyMatch) {
716
718
  const methodName = mojoOnlyMatch.groups.method;
717
719
  this.errors.push({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barefootjs/mojolicious",
3
- "version": "0.1.2",
3
+ "version": "0.2.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.1.2"
55
+ "@barefootjs/shared": "0.2.0"
56
56
  },
57
57
  "peerDependencies": {
58
- "@barefootjs/jsx": "0.1.2"
58
+ "@barefootjs/jsx": "0.2.0"
59
59
  },
60
60
  "devDependencies": {
61
61
  "@barefootjs/adapter-tests": "0.1.0",
62
- "@barefootjs/jsx": "0.1.2",
62
+ "@barefootjs/jsx": "0.2.0",
63
63
  "typescript": "^5.0.0"
64
64
  }
65
65
  }
@@ -162,6 +162,8 @@ runAdapterConformanceTests({
162
162
  // text-expression form is routed through the same AST path.
163
163
  'array-find': [{ code: 'BF101', severity: 'error' }],
164
164
  'array-findIndex': [{ code: 'BF101', severity: 'error' }],
165
+ 'array-findLast': [{ code: 'BF101', severity: 'error' }],
166
+ 'array-findLastIndex': [{ code: 'BF101', severity: 'error' }],
165
167
  },
166
168
  // `JSON_STRINGIFY_VIA_CONST` and `MATH_FLOOR_VIA_CONST` now pass
167
169
  // via `MojoAdapter.templatePrimitives` (#1189). The two remaining
@@ -893,6 +895,10 @@ import { fixture as arraySortFieldDescFixture } from '../../../adapter-tests/fix
893
895
  import { fixture as arraySortPrimitiveFixture } from '../../../adapter-tests/fixtures/methods/array-sort-primitive'
894
896
  import { fixture as arraySortLocaleFixture } from '../../../adapter-tests/fixtures/methods/array-sort-locale'
895
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'
896
902
 
897
903
  describe('MojoAdapter - #1448 Tier A/B fixture-driven lowering pins', () => {
898
904
  const cases = [
@@ -918,6 +924,13 @@ describe('MojoAdapter - #1448 Tier A/B fixture-driven lowering pins', () => {
918
924
  { fixture: arraySortPrimitiveFixture, expect: `bf->sort($nums, { key_kind => 'self', compare_type => 'numeric', direction => 'asc' })` },
919
925
  { fixture: arraySortLocaleFixture, expect: `bf->sort($names, { key_kind => 'self', compare_type => 'string', direction => 'asc' })` },
920
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];' },
921
934
  ]
922
935
 
923
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
- const indexVar = loop.index ? `$${loop.index}` : '$_i'
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
- lines.push(`% my $${param} = ${array}->[${indexVar}];`)
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) {
@@ -1184,12 +1191,14 @@ export class MojoAdapter extends BaseAdapter implements IRNodeEmitter<MojoRender
1184
1191
  private convertExpressionToPerl(expr: string): string {
1185
1192
  // Handle higher-order array methods via ParsedExpr AST.
1186
1193
  // `filter|every|some` lower to Embedded Perl (grep). The rest
1187
- // (`reduce|reduceRight|forEach|flatMap|flat|findLast|findLastIndex`)
1188
- // can't lower to EP at all — route them through the same AST path
1189
- // so `convertHigherOrderExpr`'s `isSupported` gate emits BF101
1194
+ // (`reduce|reduceRight|forEach|flatMap|flat`) can't lower to EP
1195
+ // at all — route them through the same AST path so
1196
+ // `convertHigherOrderExpr`'s `isSupported` gate emits BF101
1190
1197
  // instead of falling into the regex pipeline that mangles
1191
1198
  // `$items->{reduce}->{...}` etc.
1192
- if (/\.\s*(?:filter|every|some|reduce|reduceRight|forEach|flatMap|flat|findLast|findLastIndex)\s*\(/.test(expr)) {
1199
+ // `findLast|findLastIndex` are caught by the explicit Mojo-gap
1200
+ // refusal below (alongside `find|findIndex`).
1201
+ if (/\.\s*(?:filter|every|some|reduce|reduceRight|forEach|flatMap|flat)\s*\(/.test(expr)) {
1193
1202
  return this.convertHigherOrderExpr(expr)
1194
1203
  }
1195
1204
 
@@ -1215,13 +1224,13 @@ export class MojoAdapter extends BaseAdapter implements IRNodeEmitter<MojoRender
1215
1224
  return this.convertHigherOrderExpr(expr)
1216
1225
  }
1217
1226
 
1218
- // #1448 catalog — Mojo-specific gap: `.find` / `.findIndex`
1219
- // have no AST lowering yet (no `array-method` IR variant, no
1220
- // emitter), and the regex pipeline silently mangles them into
1221
- // `${obj}->{find}(...)` hash lookups. Emit BF101 here until
1222
- // either a parser-level `array-method` extension or a
1223
- // `convertHigherOrderExpr` carve-out lands.
1224
- const mojoOnlyMatch = /\.\s*(?<method>find|findIndex)\s*\(/.exec(expr)
1227
+ // #1448 catalog — Mojo-specific gap: `.find` / `.findIndex` /
1228
+ // `.findLast` / `.findLastIndex` have no AST lowering yet (no
1229
+ // `array-method` IR variant, no emitter), and the regex pipeline
1230
+ // silently mangles them into `${obj}->{find}(...)` hash lookups.
1231
+ // Emit BF101 here until either a parser-level `array-method`
1232
+ // extension or a `convertHigherOrderExpr` carve-out lands.
1233
+ const mojoOnlyMatch = /\.\s*(?<method>find|findIndex|findLast|findLastIndex)\s*\(/.exec(expr)
1225
1234
  if (mojoOnlyMatch) {
1226
1235
  const methodName = mojoOnlyMatch.groups!.method!
1227
1236
  this.errors.push({