@barefootjs/mojolicious 0.16.0 → 0.17.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/analysis/component-tree.d.ts +30 -0
- package/dist/adapter/analysis/component-tree.d.ts.map +1 -0
- package/dist/adapter/emit-context.d.ts +96 -0
- package/dist/adapter/emit-context.d.ts.map +1 -0
- package/dist/adapter/expr/array-method.d.ts +75 -0
- package/dist/adapter/expr/array-method.d.ts.map +1 -0
- package/dist/adapter/expr/emitters.d.ts +77 -0
- package/dist/adapter/expr/emitters.d.ts.map +1 -0
- package/dist/adapter/expr/operand.d.ts +34 -0
- package/dist/adapter/expr/operand.d.ts.map +1 -0
- package/dist/adapter/index.js +1490 -1336
- package/dist/adapter/lib/constants.d.ts +27 -0
- package/dist/adapter/lib/constants.d.ts.map +1 -0
- package/dist/adapter/lib/ir-scope.d.ts +40 -0
- package/dist/adapter/lib/ir-scope.d.ts.map +1 -0
- package/dist/adapter/lib/perl-naming.d.ts +29 -0
- package/dist/adapter/lib/perl-naming.d.ts.map +1 -0
- package/dist/adapter/lib/types.d.ts +28 -0
- package/dist/adapter/lib/types.d.ts.map +1 -0
- package/dist/adapter/memo/seed.d.ts +43 -0
- package/dist/adapter/memo/seed.d.ts.map +1 -0
- package/dist/adapter/mojo-adapter.d.ts +46 -104
- package/dist/adapter/mojo-adapter.d.ts.map +1 -1
- package/dist/adapter/props/prop-classes.d.ts +48 -0
- package/dist/adapter/props/prop-classes.d.ts.map +1 -0
- package/dist/adapter/spread/spread-codegen.d.ts +64 -0
- package/dist/adapter/spread/spread-codegen.d.ts.map +1 -0
- package/dist/adapter/value/parsed-literal.d.ts +26 -0
- package/dist/adapter/value/parsed-literal.d.ts.map +1 -0
- package/dist/build.js +1490 -1336
- package/dist/index.js +1490 -1336
- package/dist/test-render.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/__tests__/mojo-adapter.test.ts +124 -60
- package/src/__tests__/query-href.test.ts +94 -0
- package/src/adapter/analysis/component-tree.ts +128 -0
- package/src/adapter/emit-context.ts +107 -0
- package/src/adapter/expr/array-method.ts +408 -0
- package/src/adapter/expr/emitters.ts +607 -0
- package/src/adapter/expr/operand.ts +55 -0
- package/src/adapter/lib/constants.ts +39 -0
- package/src/adapter/lib/ir-scope.ts +70 -0
- package/src/adapter/lib/perl-naming.ts +36 -0
- package/src/adapter/lib/types.ts +31 -0
- package/src/adapter/memo/seed.ts +126 -0
- package/src/adapter/mojo-adapter.ts +223 -1476
- package/src/adapter/props/prop-classes.ts +87 -0
- package/src/adapter/spread/spread-codegen.ts +181 -0
- package/src/adapter/value/parsed-literal.ts +34 -0
- package/src/test-render.ts +2 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compile-time constant tables for the Mojolicious EP template adapter.
|
|
3
|
+
*
|
|
4
|
+
* Extracted from `mojo-adapter.ts` (domain-module refactor, issue #2018
|
|
5
|
+
* track D).
|
|
6
|
+
*/
|
|
7
|
+
import type { PrimitiveSpec } from './types.ts';
|
|
8
|
+
/**
|
|
9
|
+
* Single source of truth for the Mojolicious adapter's
|
|
10
|
+
* template-primitive surface. Each entry pairs the expected arity
|
|
11
|
+
* with the emit function. Adding / removing a primitive is a
|
|
12
|
+
* one-line change.
|
|
13
|
+
*
|
|
14
|
+
* The emit fn returns a Perl expression (no surrounding `<%= %>`)
|
|
15
|
+
* suitable for embedding inside the Mojo template action —
|
|
16
|
+
* `bf->json($val)`, `bf->floor($val)`, etc. Args arrive already
|
|
17
|
+
* Perl-rendered via `convertExpressionToPerl` recursion, so a
|
|
18
|
+
* caller passing `props.config` reaches the emit fn as `$config`.
|
|
19
|
+
*/
|
|
20
|
+
export declare const MOJO_TEMPLATE_PRIMITIVES: Record<string, PrimitiveSpec>;
|
|
21
|
+
/**
|
|
22
|
+
* Module-scope `templatePrimitives` map derived once from the spec
|
|
23
|
+
* record. Per-instance derivation would re-build the same Map on
|
|
24
|
+
* every `new MojoAdapter()` call.
|
|
25
|
+
*/
|
|
26
|
+
export declare const MOJO_PRIMITIVE_EMIT_MAP: Record<string, (args: string[]) => string>;
|
|
27
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/adapter/lib/constants.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAE/C;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,wBAAwB,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAOlE,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,MAAM,CAG5E,CAAA"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IR traversal helpers for the Mojolicious EP template adapter.
|
|
3
|
+
*
|
|
4
|
+
* Extracted from `mojo-adapter.ts` (domain-module refactor, issue #2018
|
|
5
|
+
* track D). Pure functions over the IR tree — no adapter instance state.
|
|
6
|
+
*
|
|
7
|
+
* SHARED CANDIDATE: the bodies here are byte-identical to the Xslate
|
|
8
|
+
* adapter's `lib/ir-scope.ts`. They are adapter-agnostic (no Perl/Kolon
|
|
9
|
+
* specifics), so they are the obvious first extraction into a shared
|
|
10
|
+
* Perl-family codegen module once one exists — the groundwork for the
|
|
11
|
+
* future Perl evaluator integration (issue #2018 track D). Kept per-adapter
|
|
12
|
+
* for now, matching the repo convention (the Go adapter keeps its own copy).
|
|
13
|
+
*/
|
|
14
|
+
import type { IRNode, IRProp } from '@barefootjs/jsx';
|
|
15
|
+
/**
|
|
16
|
+
* Find the `children` prop's `jsx-children` payload (#1326). Narrowed
|
|
17
|
+
* via the AttrValue `kind` discriminator so adapter code stays type-
|
|
18
|
+
* safe if the IR shape evolves — adding a new AttrValue variant or
|
|
19
|
+
* renaming `children` to `jsxChildren` becomes a TS compile error
|
|
20
|
+
* here instead of silently dropping the children at runtime.
|
|
21
|
+
*/
|
|
22
|
+
export declare function resolveJsxChildrenProp(props: readonly IRProp[]): IRNode[];
|
|
23
|
+
/**
|
|
24
|
+
* Collect the component's root scope element node(s) — the elements that
|
|
25
|
+
* become the rendered root and so carry `data-key` for a keyed loop item. A
|
|
26
|
+
* plain element root is itself; an `if-statement` (early-return) root
|
|
27
|
+
* contributes the top element of each branch (`consequent` + the `alternate`
|
|
28
|
+
* chain), since exactly one branch renders at runtime. Non-element branch
|
|
29
|
+
* tops (fragments / nested shapes) are walked one level so an
|
|
30
|
+
* `if (…) return <A/>` still resolves to `<A>`. (#1297)
|
|
31
|
+
*/
|
|
32
|
+
export declare function collectRootScopeNodes(node: IRNode): Set<IRNode>;
|
|
33
|
+
/**
|
|
34
|
+
* True when every `$var` the lowered (Perl / Kolon) expression references is
|
|
35
|
+
* in the available set — i.e. the template already has that var in scope.
|
|
36
|
+
* Guards in-template memo seeding from referencing an out-of-scope binding
|
|
37
|
+
* (which would trip Perl strict mode). (#1297)
|
|
38
|
+
*/
|
|
39
|
+
export declare function referencedVarsAreAvailable(expr: string, available: ReadonlySet<string>): boolean;
|
|
40
|
+
//# sourceMappingURL=ir-scope.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ir-scope.d.ts","sourceRoot":"","sources":["../../../src/adapter/lib/ir-scope.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAA6B,MAAM,iBAAiB,CAAA;AAEhF;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,EAAE,CAKzE;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAiB/D;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,OAAO,CAKhG"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Perl identifier / hash-key conventions for the Mojolicious EP adapter.
|
|
3
|
+
*
|
|
4
|
+
* Pure helpers extracted from `mojo-adapter.ts` (domain-module refactor,
|
|
5
|
+
* issue #2018 track D): none read adapter instance state, so they live at
|
|
6
|
+
* module scope as the single source of truth for Perl-identifier quoting
|
|
7
|
+
* and marker-id encoding.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* (#checkbox) Quote a `render_child` named-arg / hashref key when it isn't a
|
|
11
|
+
* bare Perl identifier. A JSX attribute name like `data-slot` would otherwise
|
|
12
|
+
* emit `data-slot => '...'`, which Perl parses as the subtraction
|
|
13
|
+
* `data - slot`. Identifier-safe names (`className`, `size`, `_bf_slot`) pass
|
|
14
|
+
* through unquoted to keep the generated template readable.
|
|
15
|
+
*/
|
|
16
|
+
export declare function perlHashKey(name: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* Encode an `IRLoop.markerId` into a Perl-identifier-safe suffix
|
|
19
|
+
* for the `bf_iter_…` hoist var. Collision-free for marker ids
|
|
20
|
+
* that differ in any character — `-` and `_` map to distinct
|
|
21
|
+
* encodings (`_x2d` vs `__`) so `l-0` and `l_0` stay distinct.
|
|
22
|
+
*
|
|
23
|
+
* Today the IR only emits `l<digits>` so the encoding is mostly
|
|
24
|
+
* an identity, but pinning collision-freeness up front avoids a
|
|
25
|
+
* silent variable-shadow bug if a future marker generator widens
|
|
26
|
+
* the alphabet.
|
|
27
|
+
*/
|
|
28
|
+
export declare function perlIdentifierFromMarkerId(markerId: string): string;
|
|
29
|
+
//# sourceMappingURL=perl-naming.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"perl-naming.d.ts","sourceRoot":"","sources":["../../../src/adapter/lib/perl-naming.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAInE"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared type aliases for the Mojolicious EP template adapter.
|
|
3
|
+
*
|
|
4
|
+
* Extracted from `mojo-adapter.ts` (domain-module refactor, issue #2018
|
|
5
|
+
* track D). Pure type declarations — no runtime behaviour — so the
|
|
6
|
+
* extracted emit modules and the main adapter share one definition
|
|
7
|
+
* rather than re-declaring the render context / options shape.
|
|
8
|
+
*/
|
|
9
|
+
/** A template-primitive spec: expected call arity + the emit fn. */
|
|
10
|
+
export interface PrimitiveSpec {
|
|
11
|
+
arity: number;
|
|
12
|
+
emit: (args: string[]) => string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Mojo adapter's IRNode render context. Mojo's lowering currently
|
|
16
|
+
* doesn't consume any render-position flags (`isRootOfClientComponent`
|
|
17
|
+
* is handled differently here than in Hono/Go), so the Ctx is empty.
|
|
18
|
+
* Kept as a named alias so future flags can extend it without changing
|
|
19
|
+
* the `IRNodeEmitter` interface.
|
|
20
|
+
*/
|
|
21
|
+
export type MojoRenderCtx = Record<string, never>;
|
|
22
|
+
export interface MojoAdapterOptions {
|
|
23
|
+
/** Base path for client JS files (default: '/static/components/') */
|
|
24
|
+
clientJsBasePath?: string;
|
|
25
|
+
/** Path to barefoot.js runtime (default: '/static/components/barefoot.js') */
|
|
26
|
+
barefootJsPath?: string;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/adapter/lib/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,oEAAoE;AACpE,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,MAAM,CAAA;CACjC;AAED;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;AAEjD,MAAM,WAAW,kBAAkB;IACjC,qEAAqE;IACrE,gBAAgB,CAAC,EAAE,MAAM,CAAA;IAEzB,8EAA8E;IAC9E,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-template memo / context seeding for the Mojolicious EP template adapter.
|
|
3
|
+
*
|
|
4
|
+
* Extracted from `mojo-adapter.ts` (domain-module refactor, issue #2018
|
|
5
|
+
* track D). Free functions taking a `MojoMemoContext` (built by the adapter's
|
|
6
|
+
* `memoCtx` getter) so the cluster depends only on the recursive expression entry, not
|
|
7
|
+
* the whole adapter class. These emit the `% my $x = ...;` seed lines that let
|
|
8
|
+
* the template body's bare `$x` resolve to a derived signal/memo value or an
|
|
9
|
+
* active context value at SSR time. Mirror of the Go adapter's `memo/*`.
|
|
10
|
+
*/
|
|
11
|
+
import { type ComponentIR, type ContextConsumer } from '@barefootjs/jsx';
|
|
12
|
+
import type { MojoMemoContext } from '../emit-context.ts';
|
|
13
|
+
/** Perl literal for a context-consumer's `createContext` default. */
|
|
14
|
+
export declare function contextDefaultPerl(c: ContextConsumer): string;
|
|
15
|
+
/**
|
|
16
|
+
* Emit one `% my $<local> = bf->use_context(...)` seed line per context
|
|
17
|
+
* consumer so the template body's bare `$<local>` resolves to the active
|
|
18
|
+
* provider value (or the `createContext` default). (#1297)
|
|
19
|
+
*/
|
|
20
|
+
export declare function generateContextConsumerSeed(ir: ComponentIR): string;
|
|
21
|
+
/**
|
|
22
|
+
* Seed memos whose SSR default is `null` (not statically evaluable) by
|
|
23
|
+
* computing them in-template from the already-seeded prop / signal vars.
|
|
24
|
+
* Targets the prop-derived memo shape (`createMemo(() => props.value * 10)`)
|
|
25
|
+
* that the static `extractSsrDefaults` evaluator can't fold — without this
|
|
26
|
+
* the memo's `$x` renders empty (the reason `props-reactivity-comparison`
|
|
27
|
+
* was skipped). Only emitted when the lowered expression references vars the
|
|
28
|
+
* template already has in scope (props params + signals + prior memos), so a
|
|
29
|
+
* memo over an out-of-scope binding stays on the null path rather than
|
|
30
|
+
* tripping Perl strict mode. (#1297)
|
|
31
|
+
*/
|
|
32
|
+
export declare function generateDerivedMemoSeed(ctx: MojoMemoContext, ir: ComponentIR): string;
|
|
33
|
+
/**
|
|
34
|
+
* Lower a signal init / memo body to Perl for an in-template SSR seed, or
|
|
35
|
+
* `null` when it shouldn't be seeded this way. Returns null — without
|
|
36
|
+
* recording a BF101 — when the expression isn't a supported shape
|
|
37
|
+
* (`isSupported` pre-check, so object/array literals don't fail the build),
|
|
38
|
+
* when the lowering references no in-scope var (a constant — keep the
|
|
39
|
+
* existing ssr-defaults seeding), or when it references an out-of-scope
|
|
40
|
+
* binding. (#1297)
|
|
41
|
+
*/
|
|
42
|
+
export declare function tryLowerToPerl(ctx: MojoMemoContext, expr: string, available: ReadonlySet<string>): string | null;
|
|
43
|
+
//# sourceMappingURL=seed.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"seed.d.ts","sourceRoot":"","sources":["../../../src/adapter/memo/seed.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,eAAe,EAKrB,MAAM,iBAAiB,CAAA;AAExB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAGzD,qEAAqE;AACrE,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,eAAe,GAAG,MAAM,CAM7D;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,EAAE,EAAE,WAAW,GAAG,MAAM,CAWnE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,eAAe,EAAE,EAAE,EAAE,WAAW,GAAG,MAAM,CA0CrF;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAC5B,GAAG,EAAE,eAAe,EACpB,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,WAAW,CAAC,MAAM,CAAC,GAC7B,MAAM,GAAG,IAAI,CAOf"}
|
|
@@ -5,21 +5,9 @@
|
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
* is handled differently here than in Hono/Go), so the Ctx is empty.
|
|
12
|
-
* Kept as a named alias so future flags can extend it without changing
|
|
13
|
-
* the `IRNodeEmitter` interface.
|
|
14
|
-
*/
|
|
15
|
-
type MojoRenderCtx = Record<string, never>;
|
|
16
|
-
import type { ParsedExpr } from '@barefootjs/jsx';
|
|
17
|
-
export interface MojoAdapterOptions {
|
|
18
|
-
/** Base path for client JS files (default: '/static/components/') */
|
|
19
|
-
clientJsBasePath?: string;
|
|
20
|
-
/** Path to barefoot.js runtime (default: '/static/components/barefoot.js') */
|
|
21
|
-
barefootJsPath?: string;
|
|
22
|
-
}
|
|
8
|
+
import type { MojoRenderCtx } from './lib/types.ts';
|
|
9
|
+
export type { MojoAdapterOptions } from './lib/types.ts';
|
|
10
|
+
import type { MojoAdapterOptions } from './lib/types.ts';
|
|
23
11
|
export declare class MojoAdapter extends BaseAdapter implements IRNodeEmitter<MojoRenderCtx> {
|
|
24
12
|
name: string;
|
|
25
13
|
extension: string;
|
|
@@ -58,6 +46,14 @@ export declare class MojoAdapter extends BaseAdapter implements IRNodeEmitter<Mo
|
|
|
58
46
|
private propsObjectName;
|
|
59
47
|
private propsParams;
|
|
60
48
|
private booleanTypedProps;
|
|
49
|
+
/**
|
|
50
|
+
* (#1971) Names that resolve to a real SSR template var — prop param, signal
|
|
51
|
+
* getter, or memo. A `<Ctx.Provider value>` member referencing a name NOT in
|
|
52
|
+
* this set is a client-only function (a local handler const like `scrollPrev`
|
|
53
|
+
* or a signal setter like `setCanScrollPrev`) with no SSR value: it would
|
|
54
|
+
* emit an undeclared `$var`, so it's lowered to `undef` instead.
|
|
55
|
+
*/
|
|
56
|
+
private providerDataNames;
|
|
61
57
|
/**
|
|
62
58
|
* Names (signal getters + props) whose value is a string, so `===`/`!==`
|
|
63
59
|
* against them lowers to Perl `eq`/`ne` rather than numeric `==`/`!=`.
|
|
@@ -73,7 +69,14 @@ export declare class MojoAdapter extends BaseAdapter implements IRNodeEmitter<Mo
|
|
|
73
69
|
* the generic hash deref. Set at `generate()` entry from `ir.metadata.imports`;
|
|
74
70
|
* read by the top-level ParsedExpr emitter.
|
|
75
71
|
*/
|
|
76
|
-
_searchParamsLocals
|
|
72
|
+
private _searchParamsLocals;
|
|
73
|
+
/**
|
|
74
|
+
* Call-lowering matchers active for this component (#2057). Bound at
|
|
75
|
+
* `generate()` entry via `prepareLoweringMatchers` and read by the top-level
|
|
76
|
+
* emitter. Covers both userland plugins and the compiler's built-in plugins
|
|
77
|
+
* (e.g. `queryHref` → `bf->query`, #2042) — one uniform path, no per-API branch.
|
|
78
|
+
*/
|
|
79
|
+
private _loweringMatchers;
|
|
77
80
|
/**
|
|
78
81
|
* Module-scope pure string-literal constants (`const X = 'literal'` at
|
|
79
82
|
* file top-level), keyed by name → resolved literal value. Populated at
|
|
@@ -155,11 +158,10 @@ export declare class MojoAdapter extends BaseAdapter implements IRNodeEmitter<Mo
|
|
|
155
158
|
* function-scope consts never reach the per-render stash, so a bare
|
|
156
159
|
* `$totalPages` faults under strict mode.
|
|
157
160
|
*/
|
|
158
|
-
resolveLiteralConst
|
|
159
|
-
resolveStaticRecordLiteral
|
|
160
|
-
resolveModuleStringConst
|
|
161
|
+
private resolveLiteralConst;
|
|
162
|
+
private resolveStaticRecordLiteral;
|
|
163
|
+
private resolveModuleStringConst;
|
|
161
164
|
private generateScriptRegistrations;
|
|
162
|
-
private hasClientInteractivity;
|
|
163
165
|
/**
|
|
164
166
|
* Public entry point for node rendering. Delegates to the shared
|
|
165
167
|
* `IRNodeEmitter` dispatcher (#1290 step 1); per-kind logic lives in
|
|
@@ -197,36 +199,15 @@ export declare class MojoAdapter extends BaseAdapter implements IRNodeEmitter<Mo
|
|
|
197
199
|
* the whole-expression path, which refuses those shapes with BF101.
|
|
198
200
|
*/
|
|
199
201
|
private providerObjectLiteralPerl;
|
|
200
|
-
/** Perl literal for a context-consumer's `createContext` default. */
|
|
201
|
-
private contextDefaultPerl;
|
|
202
|
-
/**
|
|
203
|
-
* Emit one `% my $<local> = bf->use_context(...)` seed line per context
|
|
204
|
-
* consumer so the template body's bare `$<local>` resolves to the active
|
|
205
|
-
* provider value (or the `createContext` default). (#1297)
|
|
206
|
-
*/
|
|
207
|
-
private generateContextConsumerSeed;
|
|
208
|
-
/**
|
|
209
|
-
* Seed memos whose SSR default is `null` (not statically evaluable) by
|
|
210
|
-
* computing them in-template from the already-seeded prop / signal vars.
|
|
211
|
-
* Targets the prop-derived memo shape (`createMemo(() => props.value * 10)`)
|
|
212
|
-
* that the static `extractSsrDefaults` evaluator can't fold — without this
|
|
213
|
-
* the memo's `$x` renders empty (the reason `props-reactivity-comparison`
|
|
214
|
-
* was skipped). Only emitted when the lowered expression references vars the
|
|
215
|
-
* template already has in scope (props params + signals + prior memos), so a
|
|
216
|
-
* memo over an out-of-scope binding stays on the null path rather than
|
|
217
|
-
* tripping Perl strict mode. (#1297)
|
|
218
|
-
*/
|
|
219
|
-
private generateDerivedMemoSeed;
|
|
220
202
|
/**
|
|
221
|
-
*
|
|
222
|
-
*
|
|
223
|
-
*
|
|
224
|
-
*
|
|
225
|
-
*
|
|
226
|
-
*
|
|
227
|
-
* binding. (#1297)
|
|
203
|
+
* (#1971) True when `src` is a bare identifier that doesn't resolve to a
|
|
204
|
+
* prop/signal/memo or an SSR-inlinable module string const — i.e. a
|
|
205
|
+
* client-only function reference in a context value (a local handler const
|
|
206
|
+
* like `scrollPrev`, or a signal setter like `setCanScrollPrev`). See
|
|
207
|
+
* `providerDataNames`. Module-scope string consts (`carouselClasses`) ARE
|
|
208
|
+
* SSR-resolvable via `moduleStringConsts`, so they're excluded here.
|
|
228
209
|
*/
|
|
229
|
-
private
|
|
210
|
+
private isClientOnlyContextIdentifier;
|
|
230
211
|
emitAsync(node: IRAsync, _ctx: MojoRenderCtx, _emit: EmitIRNode<MojoRenderCtx>): string;
|
|
231
212
|
renderElement(element: IRElement): string;
|
|
232
213
|
renderExpression(expr: IRExpression): string;
|
|
@@ -237,13 +218,6 @@ export declare class MojoAdapter extends BaseAdapter implements IRNodeEmitter<Mo
|
|
|
237
218
|
* If no element found, wrap with comment markers.
|
|
238
219
|
*/
|
|
239
220
|
private addCondMarkerToFirstElement;
|
|
240
|
-
/**
|
|
241
|
-
* Push a `BF103` diagnostic for every component reference inside a
|
|
242
|
-
* loop body whose name is imported from a relative-path module.
|
|
243
|
-
* Mirror of the Go adapter's check — the Mojo adapter has the same
|
|
244
|
-
* cross-template-registration constraint at request time.
|
|
245
|
-
*/
|
|
246
|
-
private checkImportedLoopChildComponents;
|
|
247
221
|
renderLoop(loop: IRLoop): string;
|
|
248
222
|
/**
|
|
249
223
|
* AttrValue lowering for component invocation props (Mojo / Perl
|
|
@@ -291,14 +265,6 @@ export declare class MojoAdapter extends BaseAdapter implements IRNodeEmitter<Mo
|
|
|
291
265
|
* any block-body local var aliases (#1250 phase 1B).
|
|
292
266
|
*/
|
|
293
267
|
private renderPerlFilterExpr;
|
|
294
|
-
/**
|
|
295
|
-
* Render a complex block body filter into a Perl condition.
|
|
296
|
-
* Handles patterns like: filter(t => { const f = filter(); if (...) return ...; })
|
|
297
|
-
*/
|
|
298
|
-
private renderBlockBodyCondition;
|
|
299
|
-
private collectReturnPaths;
|
|
300
|
-
private buildSinglePathCondition;
|
|
301
|
-
private renderConditionsAnd;
|
|
302
268
|
private convertTemplateLiteralPartsToPerl;
|
|
303
269
|
/**
|
|
304
270
|
* Translate `${EXPR}` interpolations in a static template-part string
|
|
@@ -328,46 +294,23 @@ export declare class MojoAdapter extends BaseAdapter implements IRNodeEmitter<Mo
|
|
|
328
294
|
*/
|
|
329
295
|
private refuseUnsupportedAttrExpression;
|
|
330
296
|
/**
|
|
331
|
-
*
|
|
332
|
-
*
|
|
333
|
-
*
|
|
334
|
-
*
|
|
335
|
-
*
|
|
336
|
-
*
|
|
337
|
-
* The condition is translated via `convertExpressionToPerl` (a bare
|
|
338
|
-
* prop ident becomes `$describedBy`; Perl truthiness handles the
|
|
339
|
-
* test). Object literals become Perl hashrefs with `=>`; string-
|
|
340
|
-
* literal keys are quoted, values resolve via `convertExpressionToPerl`.
|
|
341
|
-
*
|
|
342
|
-
* Returns null when the expression is NOT this shape, or when a part
|
|
343
|
-
* can't be faithfully lowered (non-static key, etc.) so the caller
|
|
344
|
-
* falls back to the standard `convertExpressionToPerl` path (which
|
|
345
|
-
* records BF101). Scoped strictly to ternary-of-object-literals so no
|
|
346
|
-
* other spread shape regresses.
|
|
297
|
+
* Build the EmitContext seam the top-level `ParsedExpr` emitter depends on.
|
|
298
|
+
* Built as a private object (the adapter does NOT `implements MojoEmitContext`)
|
|
299
|
+
* so the wrapped bookkeeping — `_searchParamsLocals`, the const/record
|
|
300
|
+
* resolvers, BF101 recording, the filter-predicate entry — stays private and
|
|
301
|
+
* off the exported adapter's public type, matching the Go adapter's
|
|
302
|
+
* `emitCtx` and the `spreadCtx` / `memoCtx` seams below.
|
|
347
303
|
*/
|
|
348
|
-
private
|
|
304
|
+
private get emitCtx();
|
|
349
305
|
/**
|
|
350
|
-
*
|
|
351
|
-
*
|
|
352
|
-
*
|
|
353
|
-
*
|
|
354
|
-
*/
|
|
355
|
-
private objectLiteralToPerlHashref;
|
|
356
|
-
/**
|
|
357
|
-
* Lower a spread-object VALUE of the form `IDENT[KEY]` where:
|
|
358
|
-
* - `IDENT` resolves via `localConstants` to a MODULE-scope object
|
|
359
|
-
* literal whose property values are all scalar (number/string)
|
|
360
|
-
* literals under static (string-literal or identifier) keys
|
|
361
|
-
* (a `Record<staticKeys, scalar>` map like `sizeMap`), AND
|
|
362
|
-
* - `KEY` is a bare identifier that is a prop.
|
|
363
|
-
* Emits an inline indexed Perl hashref:
|
|
364
|
-
* `{ 'sm' => 16, 'md' => 20, ... }->{$size}`
|
|
365
|
-
*
|
|
366
|
-
* Returns the Perl string when convertible, else `null` so the caller
|
|
367
|
-
* falls back to its normal value lowering (which records BF101 for an
|
|
368
|
-
* unsupported shape). Mirror of the Go adapter's `recordIndexAccessToGoMap`.
|
|
306
|
+
* Build the narrow context the extracted spread lowering depends on. Passing
|
|
307
|
+
* a purpose-built object (rather than `this`) keeps the adapter's bookkeeping
|
|
308
|
+
* members private — they stay internal implementation detail, not part of the
|
|
309
|
+
* exported class's public surface.
|
|
369
310
|
*/
|
|
370
|
-
private
|
|
311
|
+
private get spreadCtx();
|
|
312
|
+
/** Build the narrow context the extracted memo seeding depends on. */
|
|
313
|
+
private get memoCtx();
|
|
371
314
|
private convertExpressionToPerl;
|
|
372
315
|
/**
|
|
373
316
|
* Render a full ParsedExpr tree to Perl for top-level (non-filter)
|
|
@@ -383,11 +326,10 @@ export declare class MojoAdapter extends BaseAdapter implements IRNodeEmitter<Mo
|
|
|
383
326
|
*/
|
|
384
327
|
/** Whether `name` (a signal getter or prop) holds a string value, so an
|
|
385
328
|
* equality comparison against it should use Perl `eq`/`ne` (#1672). */
|
|
386
|
-
_isStringValueName
|
|
387
|
-
_recordExprBF101
|
|
329
|
+
private _isStringValueName;
|
|
330
|
+
private _recordExprBF101;
|
|
388
331
|
/** Internal hook for higher-order: predicate body re-uses the filter emitter. */
|
|
389
|
-
_renderPerlFilterExprPublic
|
|
332
|
+
private _renderPerlFilterExprPublic;
|
|
390
333
|
}
|
|
391
334
|
export declare const mojoAdapter: MojoAdapter;
|
|
392
|
-
export {};
|
|
393
335
|
//# sourceMappingURL=mojo-adapter.d.ts.map
|
|
@@ -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,EAC1B,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,WAAW,EACX,KAAK,aAAa,EAClB,KAAK,sBAAsB,
|
|
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,EAC1B,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,WAAW,EACX,KAAK,aAAa,EAClB,KAAK,sBAAsB,EAE3B,KAAK,aAAa,EAClB,KAAK,UAAU,EAwBhB,MAAM,iBAAiB,CAAA;AAKxB,OAAO,KAAK,E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8EAA8E;IAC9E,OAAO,CAAC,cAAc;IAStB,OAAO,CAAC,gBAAgB;IAiCxB,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;IAyB5B,OAAO,CAAC,iCAAiC;IAmCzC;;;;;;;OAOG;IACH,OAAO,CAAC,gCAAgC;IAmBxC;;;;;;;;;;;;;;;;OAgBG;IACH,OAAO,CAAC,+BAA+B;IA8BvC;;;;;;;OAOG;IACH,OAAO,KAAK,OAAO,GAUlB;IAED;;;;;OAKG;IACH,OAAO,KAAK,SAAS,GAQpB;IAED,sEAAsE;IACtE,OAAO,KAAK,OAAO,GAElB;IAED,OAAO,CAAC,uBAAuB;IAqE/B;;;;;OAKG;IACH,OAAO,CAAC,sBAAsB;IAI9B;;;;OAIG;IACH;4EACwE;IACxE,OAAO,CAAC,kBAAkB;IAI1B,OAAO,CAAC,gBAAgB;IAcxB,iFAAiF;IACjF,OAAO,CAAC,2BAA2B;CAGpC;AAED,eAAO,MAAM,WAAW,aAAoB,CAAA"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prop classification for the Mojolicious EP template adapter.
|
|
3
|
+
*
|
|
4
|
+
* Extracted from `mojo-adapter.ts` (domain-module refactor, issue #2018
|
|
5
|
+
* track D). Pure functions over `ir.metadata` that derive the per-compile
|
|
6
|
+
* prop/name sets the adapter consults during lowering. Mirror of the Go
|
|
7
|
+
* adapter's `props/prop-types.ts`. No adapter instance state.
|
|
8
|
+
*/
|
|
9
|
+
import type { ComponentIR } from '@barefootjs/jsx';
|
|
10
|
+
/**
|
|
11
|
+
* (#1971) SSR-resolvable context-value names: props, signal getters, memos.
|
|
12
|
+
* A `<Ctx.Provider value>` member NOT in this set is a client-only function
|
|
13
|
+
* with no SSR value, lowered to `undef`.
|
|
14
|
+
*/
|
|
15
|
+
export declare function collectProviderDataNames(ir: ComponentIR): Set<string>;
|
|
16
|
+
/**
|
|
17
|
+
* Props whose declared TS type is boolean — a bare binding of one
|
|
18
|
+
* (`data-active={props.isActive}`) must stringify as JS `String(boolean)`
|
|
19
|
+
* ("true"/"false"), not Perl's native `1`/`''` (#1897, pagination's
|
|
20
|
+
* data-active).
|
|
21
|
+
*/
|
|
22
|
+
export declare function collectBooleanTypedProps(ir: ComponentIR): Set<string>;
|
|
23
|
+
/**
|
|
24
|
+
* No-destructure-default props → `undef` when the caller omits them → guard
|
|
25
|
+
* their bare-reference attribute emission with Perl `defined` so the
|
|
26
|
+
* attribute drops instead of rendering `attr=""` (Hono-style nullish
|
|
27
|
+
* omission). A prop WITH a destructure default (`value = ''`) is never
|
|
28
|
+
* `undef` in the body and must stay unconditional, so it is excluded. This
|
|
29
|
+
* mirrors the Go adapter's nillable-field guard: there the witness is the
|
|
30
|
+
* resolved `interface{}` field type; here it is the absence of a default (the
|
|
31
|
+
* analyzer reports `rows` — a `TextareaHTMLAttributes` member destructured
|
|
32
|
+
* without a default — as no-default, `type.kind: 'unknown'`).
|
|
33
|
+
* Excludes concrete-primitive types (`string`/`number`/`boolean`) to match
|
|
34
|
+
* the Go adapter's scope, which guards only `interface{}` (nillable) fields
|
|
35
|
+
* and leaves concrete fields unconditional. So a required, no-default
|
|
36
|
+
* `string` prop still emits `attr=""` like Hono, and only nillable
|
|
37
|
+
* (`unknown`/object/array) no-default props guard.
|
|
38
|
+
*/
|
|
39
|
+
export declare function collectNullableOptionalProps(ir: ComponentIR): Set<string>;
|
|
40
|
+
/**
|
|
41
|
+
* String-typed signals and props, so equality comparisons against them lower
|
|
42
|
+
* to `eq`/`ne` (#1672). A signal is string-typed when its inferred type is
|
|
43
|
+
* `string` (the analyzer infers this from a string-literal initial value) or,
|
|
44
|
+
* defensively, when its initial value is a bare string literal; a prop when
|
|
45
|
+
* its annotated type is `string`.
|
|
46
|
+
*/
|
|
47
|
+
export declare function collectStringValueNames(ir: ComponentIR): Set<string>;
|
|
48
|
+
//# sourceMappingURL=prop-classes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prop-classes.d.ts","sourceRoot":"","sources":["../../../src/adapter/props/prop-classes.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAGlD;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,EAAE,EAAE,WAAW,GAAG,GAAG,CAAC,MAAM,CAAC,CAMrE;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,EAAE,EAAE,WAAW,GAAG,GAAG,CAAC,MAAM,CAAC,CAMrE;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,4BAA4B,CAAC,EAAE,EAAE,WAAW,GAAG,GAAG,CAAC,MAAM,CAAC,CAWzE;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,EAAE,EAAE,WAAW,GAAG,GAAG,CAAC,MAAM,CAAC,CAWpE"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Object-literal / conditional-spread → Perl hashref lowering for the
|
|
3
|
+
* Mojolicious EP template adapter.
|
|
4
|
+
*
|
|
5
|
+
* Extracted from `mojo-adapter.ts` (domain-module refactor, issue #2018
|
|
6
|
+
* track D). Free functions taking a `MojoSpreadContext` (built by the adapter's
|
|
7
|
+
* `spreadCtx` getter) so the cluster depends on the narrow seam — the recursive
|
|
8
|
+
* expression entry plus per-compile bookkeeping — rather than the whole
|
|
9
|
+
* adapter class. Mirror of the Go adapter's `spread/spread-codegen.ts`.
|
|
10
|
+
*
|
|
11
|
+
* The conditional-spread / object-literal entries read the IR-carried
|
|
12
|
+
* structured `ParsedExpr` tree (#2018, mirroring go-template's U5/U6) instead
|
|
13
|
+
* of re-parsing the source with `ts.createSourceFile`. The condition and scalar
|
|
14
|
+
* values are threaded straight into `ctx.convertExpressionToPerl` as its
|
|
15
|
+
* `preParsed` argument (cf. go-template's
|
|
16
|
+
* `convertExpressionToGo(jsExpr, out?, preParsed?)`), so no stringify→re-parse
|
|
17
|
+
* round-trip occurs — the emitted Perl is byte-identical to the former path
|
|
18
|
+
* because the carried tree is exactly what re-parsing the stringified text
|
|
19
|
+
* produced. The `ts.factory` rebuild in `recordIndexAccessToPerl` only
|
|
20
|
+
* reconstructs the `IDENT[KEY]` node the shared `parseRecordIndexAccess` parser
|
|
21
|
+
* accepts; no source-text re-parse. `stringifyParsedExpr` is retained solely for
|
|
22
|
+
* the BF101 diagnostic message (display purposes).
|
|
23
|
+
*/
|
|
24
|
+
import type { ParsedExpr } from '@barefootjs/jsx';
|
|
25
|
+
import type { MojoSpreadContext } from '../emit-context.ts';
|
|
26
|
+
/**
|
|
27
|
+
* Lower a `cond ? {…} : {…}` conditional-spread expression — carried as the
|
|
28
|
+
* IR's structured `ParsedExpr` tree — to a Perl ternary over two hashrefs, or
|
|
29
|
+
* null when it isn't that shape. `parseExpression` already strips redundant
|
|
30
|
+
* parentheses, so the conditional / object-literal shapes surface directly.
|
|
31
|
+
*/
|
|
32
|
+
export declare function conditionalSpreadToPerl(ctx: MojoSpreadContext, expr: ParsedExpr | undefined): string | null;
|
|
33
|
+
/**
|
|
34
|
+
* (#1971 Perl) Lower a bare object-literal expression (`{ align: 'start' }`),
|
|
35
|
+
* carried as the IR's structured `ParsedExpr` tree, to a Perl hashref via
|
|
36
|
+
* `objectLiteralToPerlHashref`, or null when it isn't a plain object literal.
|
|
37
|
+
* Used for inline object-literal child props (carousel `opts`).
|
|
38
|
+
*/
|
|
39
|
+
export declare function objectLiteralExprToPerlHashref(ctx: MojoSpreadContext, expr: ParsedExpr | undefined): string | null;
|
|
40
|
+
/**
|
|
41
|
+
* Convert a static object literal into a Perl hashref string for a
|
|
42
|
+
* conditional spread. Only static string/identifier keys are allowed;
|
|
43
|
+
* values resolve via `convertExpressionToPerl`. Returns null for any
|
|
44
|
+
* computed/spread/dynamic key. Empty object → `{}`.
|
|
45
|
+
*/
|
|
46
|
+
export declare function objectLiteralToPerlHashref(ctx: MojoSpreadContext, obj: Extract<ParsedExpr, {
|
|
47
|
+
kind: 'object-literal';
|
|
48
|
+
}>): string | null;
|
|
49
|
+
/**
|
|
50
|
+
* Lower a spread-object VALUE of the form `IDENT[KEY]` where:
|
|
51
|
+
* - `IDENT` resolves via `localConstants` to a MODULE-scope object
|
|
52
|
+
* literal whose property values are all scalar (number/string)
|
|
53
|
+
* literals under static (string-literal or identifier) keys
|
|
54
|
+
* (a `Record<staticKeys, scalar>` map like `sizeMap`), AND
|
|
55
|
+
* - `KEY` is a bare identifier that is a prop.
|
|
56
|
+
* Emits an inline indexed Perl hashref:
|
|
57
|
+
* `{ 'sm' => 16, 'md' => 20, ... }->{$size}`
|
|
58
|
+
*
|
|
59
|
+
* Returns the Perl string when convertible, else `null` so the caller
|
|
60
|
+
* falls back to its normal value lowering (which records BF101 for an
|
|
61
|
+
* unsupported shape). Mirror of the Go adapter's `recordIndexAccessToGoMap`.
|
|
62
|
+
*/
|
|
63
|
+
export declare function recordIndexAccessToPerl(ctx: MojoSpreadContext, val: ParsedExpr): string | null;
|
|
64
|
+
//# sourceMappingURL=spread-codegen.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spread-codegen.d.ts","sourceRoot":"","sources":["../../../src/adapter/spread/spread-codegen.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEjD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAE3D;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,GAAG,EAAE,iBAAiB,EACtB,IAAI,EAAE,UAAU,GAAG,SAAS,GAC3B,MAAM,GAAG,IAAI,CAef;AAED;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAC5C,GAAG,EAAE,iBAAiB,EACtB,IAAI,EAAE,UAAU,GAAG,SAAS,GAC3B,MAAM,GAAG,IAAI,CAGf;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CACxC,GAAG,EAAE,iBAAiB,EACtB,GAAG,EAAE,OAAO,CAAC,UAAU,EAAE;IAAE,IAAI,EAAE,gBAAgB,CAAA;CAAE,CAAC,GACnD,MAAM,GAAG,IAAI,CAiDf;AAUD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,iBAAiB,EAAE,GAAG,EAAE,UAAU,GAAG,MAAM,GAAG,IAAI,CA4B9F"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* String-type value helpers for the Mojolicious EP template adapter.
|
|
3
|
+
*
|
|
4
|
+
* Extracted from `mojo-adapter.ts` (domain-module refactor, issue #2018
|
|
5
|
+
* track D). Pure functions over analyzer type info / const-initializer text —
|
|
6
|
+
* no adapter instance state.
|
|
7
|
+
*
|
|
8
|
+
* SHARED CANDIDATE: `isStringTypeInfo` and `isBareStringLiteral` are
|
|
9
|
+
* byte-identical to the Xslate adapter's copies and adapter-agnostic —
|
|
10
|
+
* extraction candidates for a shared Perl-family codegen module (groundwork
|
|
11
|
+
* for the future Perl evaluator integration, issue #2018 track D).
|
|
12
|
+
*
|
|
13
|
+
* (#2018) The former `parsePureStringLiteral` (the file's only
|
|
14
|
+
* `ts.createSourceFile` re-parse) was removed: module-scope pure-string-const
|
|
15
|
+
* inlining is owned by the shared `collectModuleStringConsts` in
|
|
16
|
+
* `@barefootjs/jsx` (consumed via `moduleStringConsts`), so the adapter-local
|
|
17
|
+
* copy had no callers. Dropping it keeps the adapter free of emit-time source
|
|
18
|
+
* re-parsing without changing any output.
|
|
19
|
+
*/
|
|
20
|
+
import type { TypeInfo } from '@barefootjs/jsx';
|
|
21
|
+
/** True when `type` is the `string` primitive. */
|
|
22
|
+
export declare function isStringTypeInfo(type: TypeInfo | undefined): boolean;
|
|
23
|
+
/** True when `initialValue` is a bare string-literal expression (`'x'` /
|
|
24
|
+
* `"x"`), used as a fallback for signals whose type wasn't inferred. */
|
|
25
|
+
export declare function isBareStringLiteral(initialValue: string | undefined): boolean;
|
|
26
|
+
//# sourceMappingURL=parsed-literal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parsed-literal.d.ts","sourceRoot":"","sources":["../../../src/adapter/value/parsed-literal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAE/C,kDAAkD;AAClD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,QAAQ,GAAG,SAAS,GAAG,OAAO,CAEpE;AAED;yEACyE;AACzE,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAI7E"}
|