@barefootjs/mojolicious 0.30.4 → 0.30.6

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.
@@ -11,13 +11,22 @@
11
11
  * `isStringTypedOperand` (#2176); `emitIndexAccessPerl` stays Mojo-specific
12
12
  * (Perl's `->[]` vs `->{}` split has no Kolon equivalent).
13
13
  */
14
- import { type ParsedExpr } from '@barefootjs/jsx';
14
+ import type { ParsedExpr } from '@barefootjs/jsx';
15
15
  /**
16
- * Lower `arr[index]` to a Perl deref. Perl distinguishes array
17
- * (`->[$i]`) from hash (`->{$k}`) access, which JS's single `[]` does
18
- * not so we pick by the index expression's type: a string-typed key
19
- * derefs the hash, anything else (the common loop-index / arithmetic
20
- * case, e.g. `selected()[index]`) derefs the array. #1897.
16
+ * Lower `arr[index]` to the runtime's polymorphic `bf->get` accessor
17
+ * (`BarefootJS.pm`, adapter-perl) rather than guessing at compile time
18
+ * whether `index` is a string key or a numeric index (#2491). Perl
19
+ * distinguishes array (`->[$i]`) from hash (`->{$k}`) access, which
20
+ * JS's single `[]` does not — the previous compile-time guess (string-
21
+ * typed key → hash deref, else → array deref) FAILS FATALLY
22
+ * ("Not an ARRAY reference") whenever a dynamic key of unknowable type
23
+ * (e.g. a destructured `.map()` param used as a key, `tone[k]` — the
24
+ * shared analyzer types it `{kind:'unknown'}`) is applied to a hash-
25
+ * shaped row, because the guess defaults to the array branch. `bf->get`
26
+ * dispatches on the receiver's RUNTIME `ref` instead, so it's a strict
27
+ * superset of the two hand-picked deref forms this used to emit — the
28
+ * common loop-index case (`selected()[index]`, #1897) keeps working
29
+ * unchanged.
21
30
  */
22
31
  export declare function emitIndexAccessPerl(object: ParsedExpr, index: ParsedExpr, emit: (e: ParsedExpr) => string, isStringName: (n: string) => boolean): string;
23
32
  //# sourceMappingURL=operand.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"operand.d.ts","sourceRoot":"","sources":["../../../src/adapter/expr/operand.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAwB,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEvE;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,UAAU,EAClB,KAAK,EAAE,UAAU,EACjB,IAAI,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,MAAM,EAC/B,YAAY,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,OAAO,GACnC,MAAM,CAKR"}
1
+ {"version":3,"file":"operand.d.ts","sourceRoot":"","sources":["../../../src/adapter/expr/operand.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEjD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,UAAU,EAClB,KAAK,EAAE,UAAU,EACjB,IAAI,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,MAAM,EAC/B,YAAY,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,OAAO,GACnC,MAAM,CAER"}
@@ -384,7 +384,7 @@ function staticValueToPerl(value) {
384
384
  // src/adapter/expr/emitters.ts
385
385
  import {
386
386
  groupBinaryOperand,
387
- isStringTypedOperand as isStringTypedOperand2,
387
+ isStringTypedOperand,
388
388
  isStringConcatBinary,
389
389
  emitParsedExpr,
390
390
  identifierPath,
@@ -394,10 +394,8 @@ import {
394
394
  } from "@barefootjs/jsx";
395
395
 
396
396
  // src/adapter/expr/operand.ts
397
- import { isStringTypedOperand } from "@barefootjs/jsx";
398
397
  function emitIndexAccessPerl(object, index, emit, isStringName) {
399
- const i = emit(index);
400
- return isStringTypedOperand(index, isStringName) ? `${emit(object)}->{${i}}` : `${emit(object)}->[${i}]`;
398
+ return `bf->get(${emit(object)}, ${emit(index)})`;
401
399
  }
402
400
 
403
401
  // src/adapter/expr/emitters.ts
@@ -467,7 +465,7 @@ class MojoFilterEmitter {
467
465
  binary(op, left, right, emit) {
468
466
  const l = groupBinaryOperand(left, emit(left));
469
467
  const r = groupBinaryOperand(right, emit(right));
470
- const isStr = (e) => isStringTypedOperand2(e, this.isStringName);
468
+ const isStr = (e) => isStringTypedOperand(e, this.isStringName);
471
469
  const stringCmp = isStr(left) || isStr(right);
472
470
  if ((op === "===" || op === "==") && stringCmp) {
473
471
  return `${l} eq ${r}`;
@@ -585,7 +583,7 @@ class MojoTopLevelEmitter {
585
583
  }
586
584
  const obj = emit(object);
587
585
  if (property === "length") {
588
- const isStr = (e) => isStringTypedOperand2(e, (n) => this.ctx._isStringValueName(n));
586
+ const isStr = (e) => isStringTypedOperand(e, (n) => this.ctx._isStringValueName(n));
589
587
  const isStringReceiver = isStr(object) || object.kind === "identifier" && this.ctx._isStringValueName(object.name);
590
588
  if (isStringReceiver)
591
589
  return `bf->length(${obj})`;
@@ -628,7 +626,7 @@ class MojoTopLevelEmitter {
628
626
  binary(op, left, right, emit) {
629
627
  const l = groupBinaryOperand(left, emit(left));
630
628
  const r = groupBinaryOperand(right, emit(right));
631
- const isStr = (e) => isStringTypedOperand2(e, (n) => this.ctx._isStringValueName(n));
629
+ const isStr = (e) => isStringTypedOperand(e, (n) => this.ctx._isStringValueName(n));
632
630
  const stringCmp = isStr(left) || isStr(right);
633
631
  if ((op === "===" || op === "==") && stringCmp) {
634
632
  return `${l} eq ${r}`;
package/dist/build.js CHANGED
@@ -384,7 +384,7 @@ function staticValueToPerl(value) {
384
384
  // src/adapter/expr/emitters.ts
385
385
  import {
386
386
  groupBinaryOperand,
387
- isStringTypedOperand as isStringTypedOperand2,
387
+ isStringTypedOperand,
388
388
  isStringConcatBinary,
389
389
  emitParsedExpr,
390
390
  identifierPath,
@@ -394,10 +394,8 @@ import {
394
394
  } from "@barefootjs/jsx";
395
395
 
396
396
  // src/adapter/expr/operand.ts
397
- import { isStringTypedOperand } from "@barefootjs/jsx";
398
397
  function emitIndexAccessPerl(object, index, emit, isStringName) {
399
- const i = emit(index);
400
- return isStringTypedOperand(index, isStringName) ? `${emit(object)}->{${i}}` : `${emit(object)}->[${i}]`;
398
+ return `bf->get(${emit(object)}, ${emit(index)})`;
401
399
  }
402
400
 
403
401
  // src/adapter/expr/emitters.ts
@@ -467,7 +465,7 @@ class MojoFilterEmitter {
467
465
  binary(op, left, right, emit) {
468
466
  const l = groupBinaryOperand(left, emit(left));
469
467
  const r = groupBinaryOperand(right, emit(right));
470
- const isStr = (e) => isStringTypedOperand2(e, this.isStringName);
468
+ const isStr = (e) => isStringTypedOperand(e, this.isStringName);
471
469
  const stringCmp = isStr(left) || isStr(right);
472
470
  if ((op === "===" || op === "==") && stringCmp) {
473
471
  return `${l} eq ${r}`;
@@ -585,7 +583,7 @@ class MojoTopLevelEmitter {
585
583
  }
586
584
  const obj = emit(object);
587
585
  if (property === "length") {
588
- const isStr = (e) => isStringTypedOperand2(e, (n) => this.ctx._isStringValueName(n));
586
+ const isStr = (e) => isStringTypedOperand(e, (n) => this.ctx._isStringValueName(n));
589
587
  const isStringReceiver = isStr(object) || object.kind === "identifier" && this.ctx._isStringValueName(object.name);
590
588
  if (isStringReceiver)
591
589
  return `bf->length(${obj})`;
@@ -628,7 +626,7 @@ class MojoTopLevelEmitter {
628
626
  binary(op, left, right, emit) {
629
627
  const l = groupBinaryOperand(left, emit(left));
630
628
  const r = groupBinaryOperand(right, emit(right));
631
- const isStr = (e) => isStringTypedOperand2(e, (n) => this.ctx._isStringValueName(n));
629
+ const isStr = (e) => isStringTypedOperand(e, (n) => this.ctx._isStringValueName(n));
632
630
  const stringCmp = isStr(left) || isStr(right);
633
631
  if ((op === "===" || op === "==") && stringCmp) {
634
632
  return `${l} eq ${r}`;
package/dist/index.js CHANGED
@@ -384,7 +384,7 @@ function staticValueToPerl(value) {
384
384
  // src/adapter/expr/emitters.ts
385
385
  import {
386
386
  groupBinaryOperand,
387
- isStringTypedOperand as isStringTypedOperand2,
387
+ isStringTypedOperand,
388
388
  isStringConcatBinary,
389
389
  emitParsedExpr,
390
390
  identifierPath,
@@ -394,10 +394,8 @@ import {
394
394
  } from "@barefootjs/jsx";
395
395
 
396
396
  // src/adapter/expr/operand.ts
397
- import { isStringTypedOperand } from "@barefootjs/jsx";
398
397
  function emitIndexAccessPerl(object, index, emit, isStringName) {
399
- const i = emit(index);
400
- return isStringTypedOperand(index, isStringName) ? `${emit(object)}->{${i}}` : `${emit(object)}->[${i}]`;
398
+ return `bf->get(${emit(object)}, ${emit(index)})`;
401
399
  }
402
400
 
403
401
  // src/adapter/expr/emitters.ts
@@ -467,7 +465,7 @@ class MojoFilterEmitter {
467
465
  binary(op, left, right, emit) {
468
466
  const l = groupBinaryOperand(left, emit(left));
469
467
  const r = groupBinaryOperand(right, emit(right));
470
- const isStr = (e) => isStringTypedOperand2(e, this.isStringName);
468
+ const isStr = (e) => isStringTypedOperand(e, this.isStringName);
471
469
  const stringCmp = isStr(left) || isStr(right);
472
470
  if ((op === "===" || op === "==") && stringCmp) {
473
471
  return `${l} eq ${r}`;
@@ -585,7 +583,7 @@ class MojoTopLevelEmitter {
585
583
  }
586
584
  const obj = emit(object);
587
585
  if (property === "length") {
588
- const isStr = (e) => isStringTypedOperand2(e, (n) => this.ctx._isStringValueName(n));
586
+ const isStr = (e) => isStringTypedOperand(e, (n) => this.ctx._isStringValueName(n));
589
587
  const isStringReceiver = isStr(object) || object.kind === "identifier" && this.ctx._isStringValueName(object.name);
590
588
  if (isStringReceiver)
591
589
  return `bf->length(${obj})`;
@@ -628,7 +626,7 @@ class MojoTopLevelEmitter {
628
626
  binary(op, left, right, emit) {
629
627
  const l = groupBinaryOperand(left, emit(left));
630
628
  const r = groupBinaryOperand(right, emit(right));
631
- const isStr = (e) => isStringTypedOperand2(e, (n) => this.ctx._isStringValueName(n));
629
+ const isStr = (e) => isStringTypedOperand(e, (n) => this.ctx._isStringValueName(n));
632
630
  const stringCmp = isStr(left) || isStr(right);
633
631
  if ((op === "===" || op === "==") && stringCmp) {
634
632
  return `${l} eq ${r}`;
@@ -1936,9 +1934,8 @@ var conformancePins = {
1936
1934
  };
1937
1935
  // src/render-divergences.ts
1938
1936
  var renderDivergences = {
1939
- "aliased-destructured-prop": "aliased destructured prop `{ n: count }` loses its rename — template vars, ssr-defaults, and the props bridge all key off the local name, so the prop is always undefined (https://github.com/piconic-ai/barefootjs/issues/2460)",
1940
- "composite-row-child-aliased-prop": "same #2460 defect as `aliased-destructured-prop`, inside a keyed `.map()` loop row: the nested child's renamed prop (`{ n: count }`) is always undefined, so both rows render an empty count (https://github.com/piconic-ai/barefootjs/issues/2460)",
1941
- "loop-param-shadows-record-template-span": "a dynamic-key element access on a loop row (`tone[k]`) diverges on real Mojolicious at render time (same silent-empty family as ERB/Go/Twig; the Perl-side mechanism needs a dig) (https://github.com/piconic-ai/barefootjs/issues/2491)"
1937
+ "aliased-destructured-prop": "aliased destructured prop `{ n: count }` loses its rename — template vars, ssr-defaults, and the props bridge all key off the local name, so the prop is always undefined (https://github.com/piconic-ai/barefootjs/issues/2524)",
1938
+ "composite-row-child-aliased-prop": "same defect as `aliased-destructured-prop` (#2524), inside a keyed `.map()` loop row: the nested child's renamed prop (`{ n: count }`) is always undefined, so both rows render an empty count (https://github.com/piconic-ai/barefootjs/issues/2524)"
1942
1939
  };
1943
1940
  export {
1944
1941
  renderDivergences,
@@ -1 +1 @@
1
- {"version":3,"file":"render-divergences.d.ts","sourceRoot":"","sources":["../src/render-divergences.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAExD,eAAO,MAAM,iBAAiB,EAAE,iBAqB/B,CAAA"}
1
+ {"version":3,"file":"render-divergences.d.ts","sourceRoot":"","sources":["../src/render-divergences.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAExD,eAAO,MAAM,iBAAiB,EAAE,iBAsB/B,CAAA"}
@@ -1,5 +1,5 @@
1
1
  package BarefootJS::Backend::Mojo;
2
- our $VERSION = "0.30.2";
2
+ our $VERSION = "0.30.5";
3
3
  use Mojo::Base -base, -signatures;
4
4
 
5
5
  use Mojo::ByteStream qw(b);
@@ -1,5 +1,5 @@
1
1
  package Mojolicious::Plugin::BarefootJS::DevReload;
2
- our $VERSION = "0.30.2";
2
+ our $VERSION = "0.30.5";
3
3
  use Mojo::Base 'Mojolicious::Plugin', -signatures;
4
4
 
5
5
  =head1 NAME
@@ -1,5 +1,5 @@
1
1
  package Mojolicious::Plugin::BarefootJS;
2
- our $VERSION = "0.30.2";
2
+ our $VERSION = "0.30.5";
3
3
  use Mojo::Base 'Mojolicious::Plugin', -signatures;
4
4
 
5
5
  use Mojo::File qw(path);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barefootjs/mojolicious",
3
- "version": "0.30.4",
3
+ "version": "0.30.6",
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,7 +52,7 @@
52
52
  "directory": "packages/adapter-mojolicious"
53
53
  },
54
54
  "dependencies": {
55
- "@barefootjs/shared": "0.30.4"
55
+ "@barefootjs/shared": "0.30.6"
56
56
  },
57
57
  "peerDependencies": {
58
58
  "@barefootjs/jsx": ">=0.2.0",
@@ -60,6 +60,6 @@
60
60
  },
61
61
  "devDependencies": {
62
62
  "@barefootjs/adapter-tests": "0.1.0",
63
- "@barefootjs/jsx": "0.30.4"
63
+ "@barefootjs/jsx": "0.30.6"
64
64
  }
65
65
  }
@@ -12,14 +12,23 @@
12
12
  * (Perl's `->[]` vs `->{}` split has no Kolon equivalent).
13
13
  */
14
14
 
15
- import { isStringTypedOperand, type ParsedExpr } from '@barefootjs/jsx'
15
+ import type { ParsedExpr } from '@barefootjs/jsx'
16
16
 
17
17
  /**
18
- * Lower `arr[index]` to a Perl deref. Perl distinguishes array
19
- * (`->[$i]`) from hash (`->{$k}`) access, which JS's single `[]` does
20
- * not so we pick by the index expression's type: a string-typed key
21
- * derefs the hash, anything else (the common loop-index / arithmetic
22
- * case, e.g. `selected()[index]`) derefs the array. #1897.
18
+ * Lower `arr[index]` to the runtime's polymorphic `bf->get` accessor
19
+ * (`BarefootJS.pm`, adapter-perl) rather than guessing at compile time
20
+ * whether `index` is a string key or a numeric index (#2491). Perl
21
+ * distinguishes array (`->[$i]`) from hash (`->{$k}`) access, which
22
+ * JS's single `[]` does not — the previous compile-time guess (string-
23
+ * typed key → hash deref, else → array deref) FAILS FATALLY
24
+ * ("Not an ARRAY reference") whenever a dynamic key of unknowable type
25
+ * (e.g. a destructured `.map()` param used as a key, `tone[k]` — the
26
+ * shared analyzer types it `{kind:'unknown'}`) is applied to a hash-
27
+ * shaped row, because the guess defaults to the array branch. `bf->get`
28
+ * dispatches on the receiver's RUNTIME `ref` instead, so it's a strict
29
+ * superset of the two hand-picked deref forms this used to emit — the
30
+ * common loop-index case (`selected()[index]`, #1897) keeps working
31
+ * unchanged.
23
32
  */
24
33
  export function emitIndexAccessPerl(
25
34
  object: ParsedExpr,
@@ -27,8 +36,5 @@ export function emitIndexAccessPerl(
27
36
  emit: (e: ParsedExpr) => string,
28
37
  isStringName: (n: string) => boolean,
29
38
  ): string {
30
- const i = emit(index)
31
- return isStringTypedOperand(index, isStringName)
32
- ? `${emit(object)}->{${i}}`
33
- : `${emit(object)}->[${i}]`
39
+ return `bf->get(${emit(object)}, ${emit(index)})`
34
40
  }
@@ -20,19 +20,20 @@ export const renderDivergences: RenderDivergences = {
20
20
  // instead of a fixed regex-shape catalogue) now correctly seeds `todos`
21
21
  // from `(props.initialTodos ?? []).map(t => ({ ...t, editing: false }))`.
22
22
 
23
- // Onboarding TSX-fidelity fixtures (PR #2461): `expectedHtml` is
24
- // hand-authored to the CORRECT output because the emission bug lives in
23
+ // Onboarding TSX-fidelity fixtures (PR #2461): `expectedHtml` was
24
+ // hand-authored to the CORRECT output while the emission bug lived in
25
25
  // the shared compiler layer — every adapter, including the Hono
26
- // reference, currently emits the broken form (verified against this
27
- // adapter's emitted template; see each fixture's docstring). Graduate
28
- // by fixing the shared emission, regenerating `expectedHtml` from the
29
- // fixed reference, and deleting these lines (and the matching hono
30
- // `skipJsx` entries).
26
+ // reference, used to emit the broken form. That shared-layer defect
27
+ // (#2460) is now FIXED (b4f5075): `expectedHtml` is generated from the
28
+ // Hono reference like any other fixture. The remaining gap is
29
+ // per-template-adapter this adapter still keys its template vars /
30
+ // ssr-defaults / props bridge off the local binding instead of
31
+ // `sourceName ?? name` — tracked by #2524 (the 7 silent template
32
+ // adapters). Graduate by applying the same `sourceName ?? name` fix to
33
+ // this adapter's emission path and deleting these lines (and the
34
+ // matching hono `skipJsx` entries, already gone).
31
35
  'aliased-destructured-prop':
32
- 'aliased destructured prop `{ n: count }` loses its rename — template vars, ssr-defaults, and the props bridge all key off the local name, so the prop is always undefined (https://github.com/piconic-ai/barefootjs/issues/2460)',
36
+ 'aliased destructured prop `{ n: count }` loses its rename — template vars, ssr-defaults, and the props bridge all key off the local name, so the prop is always undefined (https://github.com/piconic-ai/barefootjs/issues/2524)',
33
37
  'composite-row-child-aliased-prop':
34
- 'same #2460 defect as `aliased-destructured-prop`, inside a keyed `.map()` loop row: the nested child\'s renamed prop (`{ n: count }`) is always undefined, so both rows render an empty count (https://github.com/piconic-ai/barefootjs/issues/2460)',
35
-
36
- 'loop-param-shadows-record-template-span':
37
- 'a dynamic-key element access on a loop row (`tone[k]`) diverges on real Mojolicious at render time (same silent-empty family as ERB/Go/Twig; the Perl-side mechanism needs a dig) (https://github.com/piconic-ai/barefootjs/issues/2491)',
38
+ 'same defect as `aliased-destructured-prop` (#2524), inside a keyed `.map()` loop row: the nested child\'s renamed prop (`{ n: count }`) is always undefined, so both rows render an empty count (https://github.com/piconic-ai/barefootjs/issues/2524)',
38
39
  }