@barefootjs/mojolicious 0.33.4 → 0.34.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/emit-context.d.ts +11 -1
- package/dist/adapter/emit-context.d.ts.map +1 -1
- package/dist/adapter/expr/emitters.d.ts +11 -1
- package/dist/adapter/expr/emitters.d.ts.map +1 -1
- package/dist/adapter/index.js +33 -23
- package/dist/adapter/mojo-adapter.d.ts +14 -0
- package/dist/adapter/mojo-adapter.d.ts.map +1 -1
- package/dist/conformance-pins.d.ts.map +1 -1
- package/dist/index.js +37 -25
- package/dist/render-divergences.d.ts.map +1 -1
- package/dist/vite.js +197 -135
- 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 +5 -5
- package/src/adapter/emit-context.ts +12 -1
- package/src/adapter/expr/emitters.ts +33 -0
- package/src/adapter/mojo-adapter.ts +37 -43
- package/src/conformance-pins.ts +11 -0
- package/src/render-divergences.ts +2 -0
|
@@ -17,13 +17,23 @@
|
|
|
17
17
|
* genuinely needs it, so the seam documents the real cross-module coupling
|
|
18
18
|
* rather than re-exposing the whole adapter.
|
|
19
19
|
*/
|
|
20
|
-
import type { ParsedExpr, CompilerError, IRMetadata } from '@barefootjs/jsx';
|
|
20
|
+
import type { ParsedExpr, CompilerError, IRMetadata, LoweringMatcher } from '@barefootjs/jsx';
|
|
21
21
|
export interface MojoEmitContext {
|
|
22
22
|
/**
|
|
23
23
|
* (#1922) Local binding names the request-scoped `searchParams()` env signal
|
|
24
24
|
* is imported under. Non-empty enables the env-signal method-call lowering.
|
|
25
25
|
*/
|
|
26
26
|
readonly _searchParamsLocals: Set<string>;
|
|
27
|
+
/**
|
|
28
|
+
* Registered lowering-plugin matchers (#2057), bound to this component's
|
|
29
|
+
* metadata at init. Read by `MojoTopLevelEmitter`'s `lowering` seam (#2843)
|
|
30
|
+
* so a registered call — the built-in `queryHref`, or any userland plugin —
|
|
31
|
+
* is recognised no matter where it sits in an expression tree (a ternary
|
|
32
|
+
* branch, a template-literal interpolation, …), not only when it's the call
|
|
33
|
+
* the adapter's own top-level conversion entry point
|
|
34
|
+
* (`convertExpressionToPerl`) is asked to lower directly.
|
|
35
|
+
*/
|
|
36
|
+
readonly _loweringMatchers: readonly LoweringMatcher[];
|
|
27
37
|
/**
|
|
28
38
|
* Inline a module-scope pure string-literal const by name as the resolved
|
|
29
39
|
* literal value, or null when the name is not such a const.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emit-context.d.ts","sourceRoot":"","sources":["../../src/adapter/emit-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"emit-context.d.ts","sourceRoot":"","sources":["../../src/adapter/emit-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAE7F,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,QAAQ,CAAC,mBAAmB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IAEzC;;;;;;;;OAQG;IACH,QAAQ,CAAC,iBAAiB,EAAE,SAAS,eAAe,EAAE,CAAA;IAEtD;;;OAGG;IACH,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;IAErD,mFAAmF;IACnF,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;IAEhD;;;OAGG;IACH,0BAA0B,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;IAE1E,uEAAuE;IACvE,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAA;IAEzC,wDAAwD;IACxD,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAExD,wEAAwE;IACxE,2BAA2B,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;CACrE;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,iBAAiB;IAChC,uDAAuD;IACvD,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;IAE9B,kEAAkE;IAClE,QAAQ,CAAC,MAAM,EAAE,aAAa,EAAE,CAAA;IAEhC,0EAA0E;IAC1E,QAAQ,CAAC,cAAc,EAAE,UAAU,CAAC,gBAAgB,CAAC,CAAA;IAErD,sEAAsE;IACtE,QAAQ,CAAC,WAAW,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;IAExC;;;;;;;;;OASG;IACH,uBAAuB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,UAAU,GAAG,MAAM,CAAA;CACtE;AAED;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;;;;;;;;;OAYG;IACH,uBAAuB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,UAAU,EAAE,GAAG,CAAC,EAAE,UAAU,GAAG,OAAO,GAAG,MAAM,CAAA;CAClG"}
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* - `MojoTopLevelEmitter` — top-level / stash context; depends on the
|
|
11
11
|
* adapter only through the narrow `MojoEmitContext` seam.
|
|
12
12
|
*/
|
|
13
|
-
import { type ParsedExprEmitter, type ArrayMethod, type LiteralType, type ParsedExpr, type ObjectLiteralProperty, type FlatDepth, type TemplatePart } from '@barefootjs/jsx';
|
|
13
|
+
import { type ParsedExprEmitter, type ArrayMethod, type LiteralType, type ParsedExpr, type ObjectLiteralProperty, type FlatDepth, type TemplatePart, type LoweringEmitter } from '@barefootjs/jsx';
|
|
14
14
|
import type { MojoEmitContext } from '../emit-context.ts';
|
|
15
15
|
export declare class MojoFilterEmitter implements ParsedExprEmitter {
|
|
16
16
|
private readonly param;
|
|
@@ -55,6 +55,16 @@ export declare class MojoFilterEmitter implements ParsedExprEmitter {
|
|
|
55
55
|
export declare class MojoTopLevelEmitter implements ParsedExprEmitter {
|
|
56
56
|
private readonly ctx;
|
|
57
57
|
constructor(ctx: MojoEmitContext);
|
|
58
|
+
/**
|
|
59
|
+
* Registered-lowering seam (#2843): `emitParsedExpr`'s shared `call` case
|
|
60
|
+
* tries every matcher here BEFORE `call()` itself, so a registered call
|
|
61
|
+
* (the built-in `queryHref`, or any userland plugin) is recognised no
|
|
62
|
+
* matter where it sits in the tree. `render` is what used to live inline
|
|
63
|
+
* in `MojoAdapter.convertExpressionToPerl` before the object-literal
|
|
64
|
+
* support-gate refusal (`checkSupport`'s `call` arm, now itself
|
|
65
|
+
* registry-aware) made the pre-gate special case unnecessary.
|
|
66
|
+
*/
|
|
67
|
+
get lowering(): LoweringEmitter;
|
|
58
68
|
identifier(name: string): string;
|
|
59
69
|
literal(value: string | number | boolean | null, literalType: LiteralType): string;
|
|
60
70
|
member(object: ParsedExpr, property: string, _computed: boolean, _optional: boolean, emit: (e: ParsedExpr) => string): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emitters.d.ts","sourceRoot":"","sources":["../../../src/adapter/expr/emitters.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAGL,KAAK,iBAAiB,EAEtB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,qBAAqB,EAC1B,KAAK,SAAS,EACd,KAAK,YAAY,
|
|
1
|
+
{"version":3,"file":"emitters.d.ts","sourceRoot":"","sources":["../../../src/adapter/expr/emitters.ts"],"names":[],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AAM,GAC9B,MAAM,CAER;IAED,UAAU,CACR,MAAM,EAAE,UAAU,EAClB,KAAK,EAAE,SAAS,GAAG;QAAE,IAAI,EAAE,UAAU,CAAA;KAAE,EACvC,IAAI,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,MAAM,GAC9B,MAAM,CAER;IAED,WAAW,CACT,IAAI,EAAE,UAAU,EAChB,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE,UAAU,EACrB,IAAI,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,MAAM,GAC9B,MAAM,CAER;IAED,eAAe,CAAC,KAAK,EAAE,YAAY,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,MAAM,GAAG,MAAM,CA6B9E;IAED,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,MAAM,GAAG,MAAM,CAOpF;IAED,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAK1B;IAED,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAOjD;IAED,aAAa,CAAC,UAAU,EAAE,qBAAqB,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,MAAM,GAAG,MAAM,CAoBxG;CACF"}
|
package/dist/adapter/index.js
CHANGED
|
@@ -17,8 +17,6 @@ import {
|
|
|
17
17
|
lookupStaticRecordLiteral,
|
|
18
18
|
searchParamsLocalNames,
|
|
19
19
|
prepareLoweringMatchers,
|
|
20
|
-
queryHrefArgs,
|
|
21
|
-
isValidHelperId,
|
|
22
20
|
sortComparatorFromArrow as sortComparatorFromArrow2,
|
|
23
21
|
isLowerableLoopDestructure,
|
|
24
22
|
isDangerousInnerHtmlAttr,
|
|
@@ -27,7 +25,8 @@ import {
|
|
|
27
25
|
dangerousInnerHtmlDiagnostic,
|
|
28
26
|
resolveStaticLoopSource,
|
|
29
27
|
derivesScopeFromSlot,
|
|
30
|
-
BindingScope
|
|
28
|
+
BindingScope,
|
|
29
|
+
buildImportAliasMap
|
|
31
30
|
} from "@barefootjs/jsx";
|
|
32
31
|
|
|
33
32
|
// src/adapter/boolean-result.ts
|
|
@@ -362,7 +361,9 @@ import {
|
|
|
362
361
|
identifierPath,
|
|
363
362
|
matchSearchParamsMethodCall,
|
|
364
363
|
sortComparatorFromArrow,
|
|
365
|
-
asCallbackMethodCall
|
|
364
|
+
asCallbackMethodCall,
|
|
365
|
+
queryHrefArgs,
|
|
366
|
+
isValidHelperId
|
|
366
367
|
} from "@barefootjs/jsx";
|
|
367
368
|
|
|
368
369
|
// src/adapter/expr/operand.ts
|
|
@@ -524,6 +525,21 @@ class MojoTopLevelEmitter {
|
|
|
524
525
|
constructor(ctx) {
|
|
525
526
|
this.ctx = ctx;
|
|
526
527
|
}
|
|
528
|
+
get lowering() {
|
|
529
|
+
return {
|
|
530
|
+
matchers: this.ctx._loweringMatchers,
|
|
531
|
+
render: (node, emit) => {
|
|
532
|
+
if (node.kind === "guard-list" && node.helper === "query") {
|
|
533
|
+
const qArgs = queryHrefArgs(node, emit);
|
|
534
|
+
return `bf->query(${qArgs.join(", ")})`;
|
|
535
|
+
}
|
|
536
|
+
if (node.kind === "helper-call" && isValidHelperId(node.helper)) {
|
|
537
|
+
return `bf->${node.helper}(${node.args.map(emit).join(", ")})`;
|
|
538
|
+
}
|
|
539
|
+
return null;
|
|
540
|
+
}
|
|
541
|
+
};
|
|
542
|
+
}
|
|
527
543
|
identifier(name) {
|
|
528
544
|
if (name === "undefined" || name === "null")
|
|
529
545
|
return "undef";
|
|
@@ -1031,6 +1047,7 @@ class MojoAdapter extends BaseAdapter {
|
|
|
1031
1047
|
localConstants = [];
|
|
1032
1048
|
scope = BindingScope.EMPTY;
|
|
1033
1049
|
nullableOptionalProps = new Set;
|
|
1050
|
+
importAliases = new Map;
|
|
1034
1051
|
constructor(options = {}) {
|
|
1035
1052
|
super();
|
|
1036
1053
|
this.options = {
|
|
@@ -1051,6 +1068,7 @@ class MojoAdapter extends BaseAdapter {
|
|
|
1051
1068
|
this._searchParamsLocals = searchParamsLocalNames(ir.metadata);
|
|
1052
1069
|
this._loweringMatchers = prepareLoweringMatchers(ir.metadata);
|
|
1053
1070
|
this.localConstants = ir.metadata.localConstants ?? [];
|
|
1071
|
+
this.importAliases = buildImportAliasMap(ir.metadata.imports ?? []);
|
|
1054
1072
|
this.scope = BindingScope.EMPTY;
|
|
1055
1073
|
this.errors = [];
|
|
1056
1074
|
this.childrenCaptureCounter = 0;
|
|
@@ -1099,7 +1117,9 @@ class MojoAdapter extends BaseAdapter {
|
|
|
1099
1117
|
return null;
|
|
1100
1118
|
return {
|
|
1101
1119
|
condition: exprToString(parsed.test),
|
|
1102
|
-
consequent: exprToString(parsed.consequent)
|
|
1120
|
+
consequent: exprToString(parsed.consequent),
|
|
1121
|
+
testParsed: parsed.test,
|
|
1122
|
+
consequentParsed: parsed.consequent
|
|
1103
1123
|
};
|
|
1104
1124
|
}
|
|
1105
1125
|
resolveLiteralConst(name) {
|
|
@@ -1557,7 +1577,8 @@ ${renderedChildren}` : renderedChildren;
|
|
|
1557
1577
|
childrenCaptureCounter = 0;
|
|
1558
1578
|
presenceVarCounter = 0;
|
|
1559
1579
|
toTemplateName(componentName) {
|
|
1560
|
-
|
|
1580
|
+
const declaredName = this.importAliases.get(componentName) ?? componentName;
|
|
1581
|
+
return declaredName.replace(/([A-Z])/g, "_$1").toLowerCase().replace(/^_/, "");
|
|
1561
1582
|
}
|
|
1562
1583
|
renderIfStatement(ifStmt) {
|
|
1563
1584
|
const condition = this.convertExpressionToPerl(ifStmt.condition);
|
|
@@ -1626,8 +1647,8 @@ ${children}`;
|
|
|
1626
1647
|
{
|
|
1627
1648
|
const m = this.parseUndefinedAlternateTernary(value.expr);
|
|
1628
1649
|
if (m) {
|
|
1629
|
-
const cond = this.convertExpressionToPerl(m.
|
|
1630
|
-
const val = this.convertExpressionToPerl(m.
|
|
1650
|
+
const cond = this.convertExpressionToPerl("", m.testParsed);
|
|
1651
|
+
const val = this.convertExpressionToPerl("", m.consequentParsed);
|
|
1631
1652
|
return `<% if (${cond}) { %>${name}="<%= ${val} %>"<% } %>`;
|
|
1632
1653
|
}
|
|
1633
1654
|
}
|
|
@@ -1756,7 +1777,7 @@ ${children}`;
|
|
|
1756
1777
|
if (!startsAsObjectLiteral && !hasTaggedTemplate)
|
|
1757
1778
|
return false;
|
|
1758
1779
|
const parsed = parseExpression2(expr.trim());
|
|
1759
|
-
const support = isSupported(parsed);
|
|
1780
|
+
const support = isSupported(parsed, { loweringMatchers: this._loweringMatchers });
|
|
1760
1781
|
if (parsed.kind !== "unsupported" && support.supported)
|
|
1761
1782
|
return false;
|
|
1762
1783
|
const reason = support.reason ?? (parsed.kind === "unsupported" ? parsed.reason : undefined);
|
|
@@ -1776,6 +1797,7 @@ ${reason}` : "";
|
|
|
1776
1797
|
get emitCtx() {
|
|
1777
1798
|
return {
|
|
1778
1799
|
_searchParamsLocals: this._searchParamsLocals,
|
|
1800
|
+
_loweringMatchers: this._loweringMatchers,
|
|
1779
1801
|
resolveModuleStringConst: (name) => this.resolveModuleStringConst(name),
|
|
1780
1802
|
resolveLiteralConst: (name) => this.resolveLiteralConst(name),
|
|
1781
1803
|
resolveStaticRecordLiteral: (o, k) => this.resolveStaticRecordLiteral(o, k),
|
|
@@ -1806,20 +1828,8 @@ ${reason}` : "";
|
|
|
1806
1828
|
return "''";
|
|
1807
1829
|
parsed = parseExpression2(trimmed);
|
|
1808
1830
|
}
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
const node = matcher(parsed.callee, parsed.args);
|
|
1812
|
-
if (node?.kind === "guard-list" && node.helper === "query") {
|
|
1813
|
-
const argsGo = queryHrefArgs(node, (n) => this.renderParsedExprToPerl(n));
|
|
1814
|
-
return `bf->query(${argsGo.join(", ")})`;
|
|
1815
|
-
}
|
|
1816
|
-
if (node?.kind === "helper-call" && isValidHelperId(node.helper)) {
|
|
1817
|
-
const argsX = node.args.map((a) => this.renderParsedExprToPerl(a));
|
|
1818
|
-
return `bf->${node.helper}(${argsX.join(", ")})`;
|
|
1819
|
-
}
|
|
1820
|
-
}
|
|
1821
|
-
}
|
|
1822
|
-
const support = pos === "value" ? isSupportedValue(parsed) : isSupported(parsed);
|
|
1831
|
+
const supportOpts = { loweringMatchers: this._loweringMatchers };
|
|
1832
|
+
const support = pos === "value" ? isSupportedValue(parsed, supportOpts) : isSupported(parsed, supportOpts);
|
|
1823
1833
|
if (!support.supported) {
|
|
1824
1834
|
this.errors.push({
|
|
1825
1835
|
code: "BF101",
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import type { ComponentIR, IRNode, IRElement, IRText, IRExpression, IRConditional, IRLoop, IRComponent, IRFragment, IRSlot, IRIfStatement, IRProvider, IRAsync, TemplatePrimitiveRegistry } from '@barefootjs/jsx';
|
|
7
7
|
import { BaseAdapter, type AdapterOutput, type AdapterGenerateOptions, type IRNodeEmitter, type EmitIRNode } from '@barefootjs/jsx';
|
|
8
|
+
import type { ParsedExpr } from '@barefootjs/jsx';
|
|
8
9
|
import type { MojoRenderCtx } from './lib/types.ts';
|
|
9
10
|
export type { MojoAdapterOptions } from './lib/types.ts';
|
|
10
11
|
import type { MojoAdapterOptions } from './lib/types.ts';
|
|
@@ -122,6 +123,17 @@ export declare class MojoAdapter extends BaseAdapter implements IRNodeEmitter<Mo
|
|
|
122
123
|
* excluded and always emit unconditionally.
|
|
123
124
|
*/
|
|
124
125
|
private nullableOptionalProps;
|
|
126
|
+
/**
|
|
127
|
+
* Local alias -> declared/exported name for imported components (#2822,
|
|
128
|
+
* the SSR-side counterpart of #2777's client-JS registry-key fix). A
|
|
129
|
+
* child referenced under an import alias (`import { Foo as Bar }`,
|
|
130
|
+
* `<Bar/>`) must build its cross-template call against the child's own
|
|
131
|
+
* declared name (`Foo`, what `foo.tsx` registers its Mojo partial as) —
|
|
132
|
+
* never the caller-local binding. Built once per compile from
|
|
133
|
+
* `ir.metadata.imports` via the shared `buildImportAliasMap`
|
|
134
|
+
* (`@barefootjs/jsx`) and read by `toTemplateName`.
|
|
135
|
+
*/
|
|
136
|
+
private importAliases;
|
|
125
137
|
constructor(options?: MojoAdapterOptions);
|
|
126
138
|
generate(ir: ComponentIR, options?: AdapterGenerateOptions): AdapterOutput;
|
|
127
139
|
/**
|
|
@@ -151,6 +163,8 @@ export declare class MojoAdapter extends BaseAdapter implements IRNodeEmitter<Mo
|
|
|
151
163
|
parseUndefinedAlternateTernary(expr: string): {
|
|
152
164
|
condition: string;
|
|
153
165
|
consequent: string;
|
|
166
|
+
testParsed: ParsedExpr;
|
|
167
|
+
consequentParsed: ParsedExpr;
|
|
154
168
|
} | null;
|
|
155
169
|
/**
|
|
156
170
|
* Inline a const (any scope) whose initializer is a pure numeric or
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mojo-adapter.d.ts","sourceRoot":"","sources":["../../src/adapter/mojo-adapter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EACV,WAAW,EAEX,MAAM,EACN,SAAS,EACT,MAAM,EACN,YAAY,EACZ,aAAa,EACb,MAAM,EACN,WAAW,EACX,UAAU,EACV,MAAM,EACN,aAAa,EACb,UAAU,EACV,OAAO,EAMP,yBAAyB,EAE1B,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,WAAW,EACX,KAAK,aAAa,EAClB,KAAK,sBAAsB,EAE3B,KAAK,aAAa,EAClB,KAAK,UAAU,
|
|
1
|
+
{"version":3,"file":"mojo-adapter.d.ts","sourceRoot":"","sources":["../../src/adapter/mojo-adapter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EACV,WAAW,EAEX,MAAM,EACN,SAAS,EACT,MAAM,EACN,YAAY,EACZ,aAAa,EACb,MAAM,EACN,WAAW,EAC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;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEtD,eAAO,MAAM,eAAe,EAAE,
|
|
1
|
+
{"version":3,"file":"conformance-pins.d.ts","sourceRoot":"","sources":["../src/conformance-pins.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEtD,eAAO,MAAM,eAAe,EAAE,eA0D7B,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -17,8 +17,6 @@ import {
|
|
|
17
17
|
lookupStaticRecordLiteral,
|
|
18
18
|
searchParamsLocalNames,
|
|
19
19
|
prepareLoweringMatchers,
|
|
20
|
-
queryHrefArgs,
|
|
21
|
-
isValidHelperId,
|
|
22
20
|
sortComparatorFromArrow as sortComparatorFromArrow2,
|
|
23
21
|
isLowerableLoopDestructure,
|
|
24
22
|
isDangerousInnerHtmlAttr,
|
|
@@ -27,7 +25,8 @@ import {
|
|
|
27
25
|
dangerousInnerHtmlDiagnostic,
|
|
28
26
|
resolveStaticLoopSource,
|
|
29
27
|
derivesScopeFromSlot,
|
|
30
|
-
BindingScope
|
|
28
|
+
BindingScope,
|
|
29
|
+
buildImportAliasMap
|
|
31
30
|
} from "@barefootjs/jsx";
|
|
32
31
|
|
|
33
32
|
// src/adapter/boolean-result.ts
|
|
@@ -362,7 +361,9 @@ import {
|
|
|
362
361
|
identifierPath,
|
|
363
362
|
matchSearchParamsMethodCall,
|
|
364
363
|
sortComparatorFromArrow,
|
|
365
|
-
asCallbackMethodCall
|
|
364
|
+
asCallbackMethodCall,
|
|
365
|
+
queryHrefArgs,
|
|
366
|
+
isValidHelperId
|
|
366
367
|
} from "@barefootjs/jsx";
|
|
367
368
|
|
|
368
369
|
// src/adapter/expr/operand.ts
|
|
@@ -524,6 +525,21 @@ class MojoTopLevelEmitter {
|
|
|
524
525
|
constructor(ctx) {
|
|
525
526
|
this.ctx = ctx;
|
|
526
527
|
}
|
|
528
|
+
get lowering() {
|
|
529
|
+
return {
|
|
530
|
+
matchers: this.ctx._loweringMatchers,
|
|
531
|
+
render: (node, emit) => {
|
|
532
|
+
if (node.kind === "guard-list" && node.helper === "query") {
|
|
533
|
+
const qArgs = queryHrefArgs(node, emit);
|
|
534
|
+
return `bf->query(${qArgs.join(", ")})`;
|
|
535
|
+
}
|
|
536
|
+
if (node.kind === "helper-call" && isValidHelperId(node.helper)) {
|
|
537
|
+
return `bf->${node.helper}(${node.args.map(emit).join(", ")})`;
|
|
538
|
+
}
|
|
539
|
+
return null;
|
|
540
|
+
}
|
|
541
|
+
};
|
|
542
|
+
}
|
|
527
543
|
identifier(name) {
|
|
528
544
|
if (name === "undefined" || name === "null")
|
|
529
545
|
return "undef";
|
|
@@ -1031,6 +1047,7 @@ class MojoAdapter extends BaseAdapter {
|
|
|
1031
1047
|
localConstants = [];
|
|
1032
1048
|
scope = BindingScope.EMPTY;
|
|
1033
1049
|
nullableOptionalProps = new Set;
|
|
1050
|
+
importAliases = new Map;
|
|
1034
1051
|
constructor(options = {}) {
|
|
1035
1052
|
super();
|
|
1036
1053
|
this.options = {
|
|
@@ -1051,6 +1068,7 @@ class MojoAdapter extends BaseAdapter {
|
|
|
1051
1068
|
this._searchParamsLocals = searchParamsLocalNames(ir.metadata);
|
|
1052
1069
|
this._loweringMatchers = prepareLoweringMatchers(ir.metadata);
|
|
1053
1070
|
this.localConstants = ir.metadata.localConstants ?? [];
|
|
1071
|
+
this.importAliases = buildImportAliasMap(ir.metadata.imports ?? []);
|
|
1054
1072
|
this.scope = BindingScope.EMPTY;
|
|
1055
1073
|
this.errors = [];
|
|
1056
1074
|
this.childrenCaptureCounter = 0;
|
|
@@ -1099,7 +1117,9 @@ class MojoAdapter extends BaseAdapter {
|
|
|
1099
1117
|
return null;
|
|
1100
1118
|
return {
|
|
1101
1119
|
condition: exprToString(parsed.test),
|
|
1102
|
-
consequent: exprToString(parsed.consequent)
|
|
1120
|
+
consequent: exprToString(parsed.consequent),
|
|
1121
|
+
testParsed: parsed.test,
|
|
1122
|
+
consequentParsed: parsed.consequent
|
|
1103
1123
|
};
|
|
1104
1124
|
}
|
|
1105
1125
|
resolveLiteralConst(name) {
|
|
@@ -1557,7 +1577,8 @@ ${renderedChildren}` : renderedChildren;
|
|
|
1557
1577
|
childrenCaptureCounter = 0;
|
|
1558
1578
|
presenceVarCounter = 0;
|
|
1559
1579
|
toTemplateName(componentName) {
|
|
1560
|
-
|
|
1580
|
+
const declaredName = this.importAliases.get(componentName) ?? componentName;
|
|
1581
|
+
return declaredName.replace(/([A-Z])/g, "_$1").toLowerCase().replace(/^_/, "");
|
|
1561
1582
|
}
|
|
1562
1583
|
renderIfStatement(ifStmt) {
|
|
1563
1584
|
const condition = this.convertExpressionToPerl(ifStmt.condition);
|
|
@@ -1626,8 +1647,8 @@ ${children}`;
|
|
|
1626
1647
|
{
|
|
1627
1648
|
const m = this.parseUndefinedAlternateTernary(value.expr);
|
|
1628
1649
|
if (m) {
|
|
1629
|
-
const cond = this.convertExpressionToPerl(m.
|
|
1630
|
-
const val = this.convertExpressionToPerl(m.
|
|
1650
|
+
const cond = this.convertExpressionToPerl("", m.testParsed);
|
|
1651
|
+
const val = this.convertExpressionToPerl("", m.consequentParsed);
|
|
1631
1652
|
return `<% if (${cond}) { %>${name}="<%= ${val} %>"<% } %>`;
|
|
1632
1653
|
}
|
|
1633
1654
|
}
|
|
@@ -1756,7 +1777,7 @@ ${children}`;
|
|
|
1756
1777
|
if (!startsAsObjectLiteral && !hasTaggedTemplate)
|
|
1757
1778
|
return false;
|
|
1758
1779
|
const parsed = parseExpression2(expr.trim());
|
|
1759
|
-
const support = isSupported(parsed);
|
|
1780
|
+
const support = isSupported(parsed, { loweringMatchers: this._loweringMatchers });
|
|
1760
1781
|
if (parsed.kind !== "unsupported" && support.supported)
|
|
1761
1782
|
return false;
|
|
1762
1783
|
const reason = support.reason ?? (parsed.kind === "unsupported" ? parsed.reason : undefined);
|
|
@@ -1776,6 +1797,7 @@ ${reason}` : "";
|
|
|
1776
1797
|
get emitCtx() {
|
|
1777
1798
|
return {
|
|
1778
1799
|
_searchParamsLocals: this._searchParamsLocals,
|
|
1800
|
+
_loweringMatchers: this._loweringMatchers,
|
|
1779
1801
|
resolveModuleStringConst: (name) => this.resolveModuleStringConst(name),
|
|
1780
1802
|
resolveLiteralConst: (name) => this.resolveLiteralConst(name),
|
|
1781
1803
|
resolveStaticRecordLiteral: (o, k) => this.resolveStaticRecordLiteral(o, k),
|
|
@@ -1806,20 +1828,8 @@ ${reason}` : "";
|
|
|
1806
1828
|
return "''";
|
|
1807
1829
|
parsed = parseExpression2(trimmed);
|
|
1808
1830
|
}
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
const node = matcher(parsed.callee, parsed.args);
|
|
1812
|
-
if (node?.kind === "guard-list" && node.helper === "query") {
|
|
1813
|
-
const argsGo = queryHrefArgs(node, (n) => this.renderParsedExprToPerl(n));
|
|
1814
|
-
return `bf->query(${argsGo.join(", ")})`;
|
|
1815
|
-
}
|
|
1816
|
-
if (node?.kind === "helper-call" && isValidHelperId(node.helper)) {
|
|
1817
|
-
const argsX = node.args.map((a) => this.renderParsedExprToPerl(a));
|
|
1818
|
-
return `bf->${node.helper}(${argsX.join(", ")})`;
|
|
1819
|
-
}
|
|
1820
|
-
}
|
|
1821
|
-
}
|
|
1822
|
-
const support = pos === "value" ? isSupportedValue(parsed) : isSupported(parsed);
|
|
1831
|
+
const supportOpts = { loweringMatchers: this._loweringMatchers };
|
|
1832
|
+
const support = pos === "value" ? isSupportedValue(parsed, supportOpts) : isSupported(parsed, supportOpts);
|
|
1823
1833
|
if (!support.supported) {
|
|
1824
1834
|
this.errors.push({
|
|
1825
1835
|
code: "BF101",
|
|
@@ -1900,11 +1910,13 @@ var conformancePins = {
|
|
|
1900
1910
|
"date-method-uncatalogued": [{ code: "BF021", severity: "error", issue: "https://github.com/piconic-ai/barefootjs/issues/2356" }],
|
|
1901
1911
|
"rich-prop-client-read": [{ code: "BF049", severity: "error", issue: "https://github.com/piconic-ai/barefootjs/issues/2648" }],
|
|
1902
1912
|
"jsx-element-prop-ternary": [{ code: "BF021", severity: "error", issue: "https://github.com/piconic-ai/barefootjs/issues/2667" }],
|
|
1903
|
-
"jsx-element-prop-array": [{ code: "BF021", severity: "error", issue: "https://github.com/piconic-ai/barefootjs/issues/2667" }]
|
|
1913
|
+
"jsx-element-prop-array": [{ code: "BF021", severity: "error", issue: "https://github.com/piconic-ai/barefootjs/issues/2667" }],
|
|
1914
|
+
"namespace-import-primitive": [{ code: "BF013", severity: "error", issue: "https://github.com/piconic-ai/barefootjs/issues/2771" }]
|
|
1904
1915
|
};
|
|
1905
1916
|
// src/render-divergences.ts
|
|
1906
1917
|
var renderDivergences = {
|
|
1907
|
-
"children-passthrough-renamed": "A renamed `children` destructure emits the local alias as a template variable; the stash defines only `children`, so the Perl render dies (#2788)."
|
|
1918
|
+
"children-passthrough-renamed": "A renamed `children` destructure emits the local alias as a template variable; the stash defines only `children`, so the Perl render dies (#2788).",
|
|
1919
|
+
"aliased-loop-source": "A `.map()` loop whose source is a local const alias of a signal getter (`const items__alias = items`) dies inside `Mojo::Template::process` on real Mojolicious — the seeded loop data is keyed by the signal's real name (`items`), and the alias hop is never resolved when deciding what to seed under `items__alias`. This is the SSR-side twin of #2778 (fixed for the CSR client-JS template in the same PR that added this fixture) — that fix only touches client-JS emission, not SSR data-seeding. Tracked at https://github.com/piconic-ai/barefootjs/issues/2813; graduate by resolving the alias hop at SSR-seeding time using the same `resolveAliasOrigin`/`resolveGetterAliases` mechanism #2778 introduced, rather than a third alias-hop walker."
|
|
1908
1920
|
};
|
|
1909
1921
|
export {
|
|
1910
1922
|
renderDivergences,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-divergences.d.ts","sourceRoot":"","sources":["../src/render-divergences.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAkBxD,eAAO,MAAM,iBAAiB,EAAE,
|
|
1
|
+
{"version":3,"file":"render-divergences.d.ts","sourceRoot":"","sources":["../src/render-divergences.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAkBxD,eAAO,MAAM,iBAAiB,EAAE,iBAK/B,CAAA"}
|