@barefootjs/mojolicious 0.30.4 → 0.30.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/expr/operand.d.ts +15 -6
- package/dist/adapter/expr/operand.d.ts.map +1 -1
- package/dist/adapter/index.js +5 -7
- package/dist/build.js +5 -7
- package/dist/index.js +6 -9
- package/dist/render-divergences.d.ts.map +1 -1
- package/lib/BarefootJS/Backend/Mojo.pm +1 -1
- package/lib/Mojolicious/Plugin/BarefootJS/DevReload.pm +1 -1
- package/lib/Mojolicious/Plugin/BarefootJS.pm +1 -1
- package/package.json +3 -3
- package/src/adapter/expr/operand.ts +16 -10
- package/src/render-divergences.ts +0 -2
|
@@ -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 {
|
|
14
|
+
import type { ParsedExpr } from '@barefootjs/jsx';
|
|
15
15
|
/**
|
|
16
|
-
* Lower `arr[index]` to
|
|
17
|
-
* (
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
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,
|
|
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"}
|
package/dist/adapter/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
|
|
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
|
-
|
|
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) =>
|
|
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) =>
|
|
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) =>
|
|
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
|
|
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
|
-
|
|
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) =>
|
|
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) =>
|
|
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) =>
|
|
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
|
|
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
|
-
|
|
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) =>
|
|
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) =>
|
|
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) =>
|
|
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}`;
|
|
@@ -1937,8 +1935,7 @@ var conformancePins = {
|
|
|
1937
1935
|
// src/render-divergences.ts
|
|
1938
1936
|
var renderDivergences = {
|
|
1939
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/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)"
|
|
1938
|
+
"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)"
|
|
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,
|
|
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,iBAmB/B,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@barefootjs/mojolicious",
|
|
3
|
-
"version": "0.30.
|
|
3
|
+
"version": "0.30.5",
|
|
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.
|
|
55
|
+
"@barefootjs/shared": "0.30.5"
|
|
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.
|
|
63
|
+
"@barefootjs/jsx": "0.30.5"
|
|
64
64
|
}
|
|
65
65
|
}
|
|
@@ -12,14 +12,23 @@
|
|
|
12
12
|
* (Perl's `->[]` vs `->{}` split has no Kolon equivalent).
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import {
|
|
15
|
+
import type { ParsedExpr } from '@barefootjs/jsx'
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
|
-
* Lower `arr[index]` to
|
|
19
|
-
* (
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
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
|
-
|
|
31
|
-
return isStringTypedOperand(index, isStringName)
|
|
32
|
-
? `${emit(object)}->{${i}}`
|
|
33
|
-
: `${emit(object)}->[${i}]`
|
|
39
|
+
return `bf->get(${emit(object)}, ${emit(index)})`
|
|
34
40
|
}
|
|
@@ -33,6 +33,4 @@ export const renderDivergences: RenderDivergences = {
|
|
|
33
33
|
'composite-row-child-aliased-prop':
|
|
34
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
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
36
|
}
|