@barefootjs/erb 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 +24 -0
- package/dist/adapter/analysis/component-tree.d.ts.map +1 -0
- package/dist/adapter/boolean-result.d.ts +66 -0
- package/dist/adapter/boolean-result.d.ts.map +1 -0
- package/dist/adapter/emit-context.d.ts +107 -0
- package/dist/adapter/emit-context.d.ts.map +1 -0
- package/dist/adapter/erb-adapter.d.ts +374 -0
- package/dist/adapter/erb-adapter.d.ts.map +1 -0
- package/dist/adapter/expr/array-method.d.ts +87 -0
- package/dist/adapter/expr/array-method.d.ts.map +1 -0
- package/dist/adapter/expr/emitters.d.ts +102 -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.d.ts +6 -0
- package/dist/adapter/index.d.ts.map +1 -0
- package/dist/adapter/index.js +189154 -0
- package/dist/adapter/lib/constants.d.ts +25 -0
- package/dist/adapter/lib/constants.d.ts.map +1 -0
- package/dist/adapter/lib/ir-scope.d.ts +27 -0
- package/dist/adapter/lib/ir-scope.d.ts.map +1 -0
- package/dist/adapter/lib/ruby-naming.d.ts +65 -0
- package/dist/adapter/lib/ruby-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 +35 -0
- package/dist/adapter/memo/seed.d.ts.map +1 -0
- package/dist/adapter/props/prop-classes.d.ts +50 -0
- package/dist/adapter/props/prop-classes.d.ts.map +1 -0
- package/dist/adapter/spread/spread-codegen.d.ts +63 -0
- package/dist/adapter/spread/spread-codegen.d.ts.map +1 -0
- package/dist/adapter/value/parsed-literal.d.ts +21 -0
- package/dist/adapter/value/parsed-literal.d.ts.map +1 -0
- package/dist/build.d.ts +28 -0
- package/dist/build.d.ts.map +1 -0
- package/dist/build.js +189174 -0
- package/dist/conformance-pins.d.ts +13 -0
- package/dist/conformance-pins.d.ts.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +189172 -0
- package/lib/barefoot_js/backend/erb.rb +123 -0
- package/lib/barefoot_js/dev_reload.rb +159 -0
- package/lib/barefoot_js/evaluator.rb +714 -0
- package/lib/barefoot_js/search_params.rb +63 -0
- package/lib/barefoot_js.rb +1155 -0
- package/package.json +67 -0
- package/src/__tests__/erb-adapter.test.ts +298 -0
- package/src/adapter/analysis/component-tree.ts +122 -0
- package/src/adapter/boolean-result.ts +157 -0
- package/src/adapter/emit-context.ts +119 -0
- package/src/adapter/erb-adapter.ts +1768 -0
- package/src/adapter/expr/array-method.ts +424 -0
- package/src/adapter/expr/emitters.ts +629 -0
- package/src/adapter/expr/operand.ts +55 -0
- package/src/adapter/index.ts +6 -0
- package/src/adapter/lib/constants.ts +37 -0
- package/src/adapter/lib/ir-scope.ts +51 -0
- package/src/adapter/lib/ruby-naming.ts +127 -0
- package/src/adapter/lib/types.ts +31 -0
- package/src/adapter/memo/seed.ts +75 -0
- package/src/adapter/props/prop-classes.ts +89 -0
- package/src/adapter/spread/spread-codegen.ts +176 -0
- package/src/adapter/value/parsed-literal.ts +29 -0
- package/src/build.ts +37 -0
- package/src/conformance-pins.ts +100 -0
- package/src/index.ts +9 -0
- package/src/test-render.ts +668 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compile-time constant tables for the ERB template adapter.
|
|
3
|
+
*
|
|
4
|
+
* Ported from the Mojolicious adapter's `lib/constants.ts`.
|
|
5
|
+
*/
|
|
6
|
+
import type { PrimitiveSpec } from './types.ts';
|
|
7
|
+
/**
|
|
8
|
+
* Single source of truth for the ERB adapter's template-primitive
|
|
9
|
+
* surface. Each entry pairs the expected arity with the emit function.
|
|
10
|
+
* Adding / removing a primitive is a one-line change.
|
|
11
|
+
*
|
|
12
|
+
* The emit fn returns a Ruby expression (no surrounding `<%= %>`)
|
|
13
|
+
* suitable for embedding inside the ERB template action —
|
|
14
|
+
* `bf.json(val)`, `bf.floor(val)`, etc. Args arrive already
|
|
15
|
+
* Ruby-rendered via `convertExpressionToRuby` recursion, so a caller
|
|
16
|
+
* passing `props.config` reaches the emit fn as `v[:config]`.
|
|
17
|
+
*/
|
|
18
|
+
export declare const ERB_TEMPLATE_PRIMITIVES: Record<string, PrimitiveSpec>;
|
|
19
|
+
/**
|
|
20
|
+
* Module-scope `templatePrimitives` map derived once from the spec
|
|
21
|
+
* record. Per-instance derivation would re-build the same Map on
|
|
22
|
+
* every `new ErbAdapter()` call.
|
|
23
|
+
*/
|
|
24
|
+
export declare const ERB_PRIMITIVE_EMIT_MAP: Record<string, (args: string[]) => string>;
|
|
25
|
+
//# 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;;;;GAIG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAE/C;;;;;;;;;;GAUG;AACH,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAOjE,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,MAAM,CAG3E,CAAA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IR traversal helpers for the ERB template adapter.
|
|
3
|
+
*
|
|
4
|
+
* Ported from the Mojolicious adapter's `lib/ir-scope.ts` (issue #2018
|
|
5
|
+
* track D lineage). Pure functions over the IR tree — no adapter instance
|
|
6
|
+
* state.
|
|
7
|
+
*/
|
|
8
|
+
import type { IRNode, IRProp } from '@barefootjs/jsx';
|
|
9
|
+
/**
|
|
10
|
+
* Find the `children` prop's `jsx-children` payload (#1326). Narrowed
|
|
11
|
+
* via the AttrValue `kind` discriminator so adapter code stays type-
|
|
12
|
+
* safe if the IR shape evolves — adding a new AttrValue variant or
|
|
13
|
+
* renaming `children` to `jsxChildren` becomes a TS compile error
|
|
14
|
+
* here instead of silently dropping the children at runtime.
|
|
15
|
+
*/
|
|
16
|
+
export declare function resolveJsxChildrenProp(props: readonly IRProp[]): IRNode[];
|
|
17
|
+
/**
|
|
18
|
+
* Collect the component's root scope element node(s) — the elements that
|
|
19
|
+
* become the rendered root and so carry `data-key` for a keyed loop item. A
|
|
20
|
+
* plain element root is itself; an `if-statement` (early-return) root
|
|
21
|
+
* contributes the top element of each branch (`consequent` + the `alternate`
|
|
22
|
+
* chain), since exactly one branch renders at runtime. Non-element branch
|
|
23
|
+
* tops (fragments / nested shapes) are walked one level so an
|
|
24
|
+
* `if (…) return <A/>` still resolves to `<A>`. (#1297)
|
|
25
|
+
*/
|
|
26
|
+
export declare function collectRootScopeNodes(node: IRNode): Set<IRNode>;
|
|
27
|
+
//# 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;;;;;;GAMG;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"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ruby identifier / literal / hash-key conventions for the ERB adapter.
|
|
3
|
+
*
|
|
4
|
+
* Pure helpers, ported from (and extending) the Mojolicious adapter's
|
|
5
|
+
* `lib/perl-naming.ts` for Ruby's syntax. None read adapter instance
|
|
6
|
+
* state, so they live at module scope as the single source of truth for
|
|
7
|
+
* Ruby-identifier quoting, literal escaping, and marker-id encoding.
|
|
8
|
+
*
|
|
9
|
+
* ## Variable model
|
|
10
|
+
*
|
|
11
|
+
* Templates receive exactly two locals: `bf` (runtime) and `v` (vars Hash,
|
|
12
|
+
* symbol keys). Every prop / signal / memo / module-constant reference
|
|
13
|
+
* lowers to `v[:name]` — never a bare Ruby local — which sidesteps Ruby
|
|
14
|
+
* identifier-validity and reserved-word issues for that whole class of
|
|
15
|
+
* names (a prop literally named `class` or `Foo` is a non-issue: it's a
|
|
16
|
+
* *symbol* key, not a variable reference).
|
|
17
|
+
*
|
|
18
|
+
* The ONE place a bare Ruby local is still needed is a loop/block
|
|
19
|
+
* parameter (`todos().map(todo => ...)` → `|todo|`) — `rubyLocal` is the
|
|
20
|
+
* single naming rule for that case, matching the ERB adapter's binding
|
|
21
|
+
* architecture doc.
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* Map a JS loop/block parameter name (`todo`, `index`, `class`, `Item`) to
|
|
25
|
+
* a safe bare Ruby local. Appends a trailing `_` when the name collides
|
|
26
|
+
* with a Ruby keyword; when the name isn't even a syntactically valid
|
|
27
|
+
* local (leading uppercase — parses as a constant — or another invalid
|
|
28
|
+
* leading character), prefixes `_` instead so the result still starts
|
|
29
|
+
* lowercase/underscore. Every loop-var / block-param emission site in the
|
|
30
|
+
* adapter goes through this one helper — no inline mangling.
|
|
31
|
+
*/
|
|
32
|
+
export declare function rubyLocal(name: string): string;
|
|
33
|
+
/** Escape a string for a Ruby single-quoted literal: backslash first (so
|
|
34
|
+
* it doesn't double-escape the quote we add next), then the quote. */
|
|
35
|
+
export declare function escapeRubySingleQuoted(s: string): string;
|
|
36
|
+
/** Wrap a raw string value as a Ruby single-quoted literal. */
|
|
37
|
+
export declare function rubyStringLiteral(s: string): string;
|
|
38
|
+
/**
|
|
39
|
+
* Render `name` as a Ruby Hash literal SYMBOL key in `key: value` position.
|
|
40
|
+
* A JSX attribute / prop name like `data-slot` isn't a valid bare Ruby
|
|
41
|
+
* identifier — Ruby's `"quoted": value` symbol-key syntax accepts an
|
|
42
|
+
* arbitrary string, so a non-identifier name still renders as a valid
|
|
43
|
+
* symbol key (`"data-slot": value` → `{:"data-slot" => value}`).
|
|
44
|
+
* Identifier-safe names (`className`, `size`, `_bf_slot`) pass through
|
|
45
|
+
* unquoted (`size: value`) for readability.
|
|
46
|
+
*/
|
|
47
|
+
export declare function rubySymbolKey(name: string): string;
|
|
48
|
+
/**
|
|
49
|
+
* Render `name` as a Ruby symbol LITERAL (`:name` / `:"data-slot"`) — used
|
|
50
|
+
* for a compile-time-known Hash key read (`item[:field]`), as opposed to
|
|
51
|
+
* `rubySymbolKey`'s `key: value` Hash-literal position.
|
|
52
|
+
*/
|
|
53
|
+
export declare function rubySymbolLiteral(name: string): string;
|
|
54
|
+
/**
|
|
55
|
+
* Encode an `IRLoop.markerId` into a Ruby-identifier-safe suffix for the
|
|
56
|
+
* `bf_iter_…` sort hoist local. Collision-free for marker ids that differ
|
|
57
|
+
* in any character — `-` and `_` map to distinct encodings (`_x2d` vs
|
|
58
|
+
* `__`) so `l-0` and `l_0` stay distinct.
|
|
59
|
+
*
|
|
60
|
+
* Today the IR only emits `l<digits>` so the encoding is mostly an
|
|
61
|
+
* identity, but pinning collision-freeness up front avoids a silent
|
|
62
|
+
* variable-shadow bug if a future marker generator widens the alphabet.
|
|
63
|
+
*/
|
|
64
|
+
export declare function rubyIdentifierFromMarkerId(markerId: string): string;
|
|
65
|
+
//# sourceMappingURL=ruby-naming.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ruby-naming.d.ts","sourceRoot":"","sources":["../../../src/adapter/lib/ruby-naming.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAoCH;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAQ9C;AAED;uEACuE;AACvE,wBAAgB,sBAAsB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAExD;AAED,+DAA+D;AAC/D,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAEnD;AAKD;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAElD;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED;;;;;;;;;GASG;AACH,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAInE"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared type aliases for the ERB template adapter.
|
|
3
|
+
*
|
|
4
|
+
* Ported from the Mojolicious adapter's `lib/types.ts`. Pure type
|
|
5
|
+
* declarations — no runtime behaviour — so the extracted emit modules and
|
|
6
|
+
* the main adapter share one definition rather than re-declaring the render
|
|
7
|
+
* 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
|
+
* ERB adapter's IRNode render context. The ERB lowering currently doesn't
|
|
16
|
+
* consume any render-position flags (`isRootOfClientComponent` is handled
|
|
17
|
+
* differently here than in Hono/Go), so the Ctx is empty. Kept as a named
|
|
18
|
+
* alias so future flags can extend it without changing the `IRNodeEmitter`
|
|
19
|
+
* interface.
|
|
20
|
+
*/
|
|
21
|
+
export type ErbRenderCtx = Record<string, never>;
|
|
22
|
+
export interface ErbAdapterOptions {
|
|
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,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;AAEhD,MAAM,WAAW,iBAAiB;IAChC,qEAAqE;IACrE,gBAAgB,CAAC,EAAE,MAAM,CAAA;IAEzB,8EAA8E;IAC9E,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-template memo / context seeding for the ERB template adapter.
|
|
3
|
+
*
|
|
4
|
+
* Ported from the Mojolicious adapter's `memo/seed.ts` (issue #2018 track D
|
|
5
|
+
* lineage). Free functions taking an `ErbMemoContext` (built by the
|
|
6
|
+
* adapter's `memoCtx` getter) so the cluster depends only on the recursive
|
|
7
|
+
* expression entry, not the whole adapter class. These emit `<% v[:x] =
|
|
8
|
+
* ...; %>` seed lines that let the template body's `v[:x]` resolve to a
|
|
9
|
+
* derived signal/memo value or an active context value at SSR time. Mirror
|
|
10
|
+
* of the Go adapter's `memo/*`, retargeted to the vars-Hash variable model.
|
|
11
|
+
*/
|
|
12
|
+
import { type ComponentIR, type ContextConsumer } from '@barefootjs/jsx';
|
|
13
|
+
import type { ErbMemoContext } from '../emit-context.ts';
|
|
14
|
+
/** Ruby literal for a context-consumer's `createContext` default. */
|
|
15
|
+
export declare function contextDefaultRuby(c: ContextConsumer): string;
|
|
16
|
+
/**
|
|
17
|
+
* Emit one `<% v[:<local>] = bf.use_context(...) %>` seed line per context
|
|
18
|
+
* consumer so the template body's `v[:<local>]` resolves to the active
|
|
19
|
+
* provider value (or the `createContext` default).
|
|
20
|
+
*/
|
|
21
|
+
export declare function generateContextConsumerSeed(ir: ComponentIR): string;
|
|
22
|
+
/**
|
|
23
|
+
* Emit `<% v[:<name>] = <ruby> %>` seed lines for every `derived` step of
|
|
24
|
+
* the backend-neutral SSR seed plan — the scope/availability/ordering
|
|
25
|
+
* analysis lives in `computeSsrSeedPlan` (packages/jsx/src/ssr-seed-plan.ts);
|
|
26
|
+
* this only lowers each step's expression to Ruby and applies the two
|
|
27
|
+
* backend-specific emit guards: skip an empty lowering, and skip a lowering
|
|
28
|
+
* that references no `v[:var]` at all (a constant init/body — e.g. a
|
|
29
|
+
* `derived` step with empty `frees` — keeps the existing static ssr-defaults
|
|
30
|
+
* seed instead). `env-reader` and `opaque` steps emit nothing (the runtime
|
|
31
|
+
* supplies the reader, or the adapter's ssr-defaults path already covers
|
|
32
|
+
* it). (#1297, #2075)
|
|
33
|
+
*/
|
|
34
|
+
export declare function generateDerivedMemoSeed(ctx: ErbMemoContext, ir: ComponentIR): string;
|
|
35
|
+
//# 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;;;;;;;;;;GAUG;AAEH,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,eAAe,EAGrB,MAAM,iBAAiB,CAAA;AAExB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAGxD,qEAAqE;AACrE,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,eAAe,GAAG,MAAM,CAM7D;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,EAAE,EAAE,WAAW,GAAG,MAAM,CAWnE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,cAAc,EAAE,EAAE,EAAE,WAAW,GAAG,MAAM,CAapF"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prop classification for the ERB template adapter.
|
|
3
|
+
*
|
|
4
|
+
* Ported from the Mojolicious adapter's `props/prop-classes.ts` (issue #2018
|
|
5
|
+
* track D lineage). Pure functions over `ir.metadata` that derive the
|
|
6
|
+
* per-compile prop/name sets the adapter consults during lowering. No
|
|
7
|
+
* adapter instance state.
|
|
8
|
+
*/
|
|
9
|
+
import type { ComponentIR } from '@barefootjs/jsx';
|
|
10
|
+
/**
|
|
11
|
+
* 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 `nil`.
|
|
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"), matching the `bf.bool_str` helper's output.
|
|
20
|
+
*/
|
|
21
|
+
export declare function collectBooleanTypedProps(ir: ComponentIR): Set<string>;
|
|
22
|
+
/**
|
|
23
|
+
* No-destructure-default props → `nil` when the caller omits them → guard
|
|
24
|
+
* their bare-reference attribute emission with a Ruby nil-check so the
|
|
25
|
+
* attribute drops instead of rendering `attr=""` (Hono-style nullish
|
|
26
|
+
* omission). A prop WITH a destructure default (`value = ''`) is never
|
|
27
|
+
* `nil` in the body and must stay unconditional, so it is excluded. Mirrors
|
|
28
|
+
* the Go adapter's nillable-field guard: there the witness is the resolved
|
|
29
|
+
* `interface{}` field type; here it is the absence of a default. Excludes
|
|
30
|
+
* concrete-primitive types (`string`/`number`/`boolean`) to match the Go
|
|
31
|
+
* adapter's scope, which guards only nillable fields and leaves concrete
|
|
32
|
+
* fields unconditional.
|
|
33
|
+
*/
|
|
34
|
+
export declare function collectNullableOptionalProps(ir: ComponentIR): Set<string>;
|
|
35
|
+
/**
|
|
36
|
+
* String-typed signals and props. A signal is string-typed when its inferred
|
|
37
|
+
* type is `string` (the analyzer infers this from a string-literal initial
|
|
38
|
+
* value) or, defensively, when its initial value is a bare string literal; a
|
|
39
|
+
* prop when its annotated type is `string`.
|
|
40
|
+
*
|
|
41
|
+
* Ruby's `==`/`!=` don't coerce operand types the way Perl's numeric `==`
|
|
42
|
+
* does, so this set does NOT drive equality-operator selection in the ERB
|
|
43
|
+
* adapter (unlike Mojo's `eq`/`ne` split). It still matters for **index
|
|
44
|
+
* access**: `obj[index]` lowers a string-typed `index` to a Hash lookup
|
|
45
|
+
* (`obj[index.to_sym]`, JSON-shaped Ruby hashes use symbol keys) and any
|
|
46
|
+
* other type to an Array lookup (`obj[index]`) — see
|
|
47
|
+
* `expr/operand.ts::isStringTypedOperand`.
|
|
48
|
+
*/
|
|
49
|
+
export declare function collectStringValueNames(ir: ComponentIR): Set<string>;
|
|
50
|
+
//# 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;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,EAAE,EAAE,WAAW,GAAG,GAAG,CAAC,MAAM,CAAC,CAMrE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,4BAA4B,CAAC,EAAE,EAAE,WAAW,GAAG,GAAG,CAAC,MAAM,CAAC,CAWzE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,uBAAuB,CAAC,EAAE,EAAE,WAAW,GAAG,GAAG,CAAC,MAAM,CAAC,CAWpE"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Object-literal / conditional-spread → Ruby Hash lowering for the ERB
|
|
3
|
+
* template adapter.
|
|
4
|
+
*
|
|
5
|
+
* Ported from the Mojolicious adapter's `spread/spread-codegen.ts` (issue
|
|
6
|
+
* #2018 track D lineage). Free functions taking an `ErbSpreadContext` (built
|
|
7
|
+
* by the adapter's `spreadCtx` getter) so the cluster depends on the narrow
|
|
8
|
+
* seam — the recursive expression entry plus per-compile bookkeeping —
|
|
9
|
+
* rather than the whole adapter class. Mirror of the Go adapter's
|
|
10
|
+
* `spread/spread-codegen.ts`.
|
|
11
|
+
*
|
|
12
|
+
* The conditional-spread / object-literal entries read the IR-carried
|
|
13
|
+
* structured `ParsedExpr` tree instead of re-parsing the source with
|
|
14
|
+
* `ts.createSourceFile`. The condition and scalar values are threaded
|
|
15
|
+
* straight into `ctx.convertExpressionToRuby` as its `preParsed` argument
|
|
16
|
+
* (cf. go-template's `convertExpressionToGo(jsExpr, out?, preParsed?)`), so
|
|
17
|
+
* no stringify→re-parse round-trip occurs. The `ts.factory` rebuild in
|
|
18
|
+
* `recordIndexAccessToRuby` only reconstructs the `IDENT[KEY]` node the
|
|
19
|
+
* shared `parseRecordIndexAccess` parser accepts; no source-text re-parse.
|
|
20
|
+
* `stringifyParsedExpr` is retained solely for the BF101 diagnostic message
|
|
21
|
+
* (display purposes).
|
|
22
|
+
*/
|
|
23
|
+
import type { ParsedExpr } from '@barefootjs/jsx';
|
|
24
|
+
import type { ErbSpreadContext } from '../emit-context.ts';
|
|
25
|
+
/**
|
|
26
|
+
* Lower a `cond ? {…} : {…}` conditional-spread expression — carried as the
|
|
27
|
+
* IR's structured `ParsedExpr` tree — to a Ruby ternary over two Hashes, or
|
|
28
|
+
* null when it isn't that shape. `parseExpression` already strips redundant
|
|
29
|
+
* parentheses, so the conditional / object-literal shapes surface directly.
|
|
30
|
+
*/
|
|
31
|
+
export declare function conditionalSpreadToRuby(ctx: ErbSpreadContext, expr: ParsedExpr | undefined): string | null;
|
|
32
|
+
/**
|
|
33
|
+
* Lower a bare object-literal expression (`{ align: 'start' }`), carried as
|
|
34
|
+
* the IR's structured `ParsedExpr` tree, to a Ruby Hash via
|
|
35
|
+
* `objectLiteralToRubyHash`, or null when it isn't a plain object literal.
|
|
36
|
+
* Used for inline object-literal child props (carousel `opts`).
|
|
37
|
+
*/
|
|
38
|
+
export declare function objectLiteralExprToRubyHash(ctx: ErbSpreadContext, expr: ParsedExpr | undefined): string | null;
|
|
39
|
+
/**
|
|
40
|
+
* Convert a static object literal into a Ruby Hash string for a conditional
|
|
41
|
+
* spread. Only static string/identifier keys are allowed; values resolve
|
|
42
|
+
* via `convertExpressionToRuby`. Returns null for any computed/spread/
|
|
43
|
+
* dynamic key. Empty object → `{}`.
|
|
44
|
+
*/
|
|
45
|
+
export declare function objectLiteralToRubyHash(ctx: ErbSpreadContext, obj: Extract<ParsedExpr, {
|
|
46
|
+
kind: 'object-literal';
|
|
47
|
+
}>): string | null;
|
|
48
|
+
/**
|
|
49
|
+
* Lower a spread-object VALUE of the form `IDENT[KEY]` where:
|
|
50
|
+
* - `IDENT` resolves via `localConstants` to a MODULE-scope object
|
|
51
|
+
* literal whose property values are all scalar (number/string)
|
|
52
|
+
* literals under static (string-literal or identifier) keys
|
|
53
|
+
* (a `Record<staticKeys, scalar>` map like `sizeMap`), AND
|
|
54
|
+
* - `KEY` is a bare identifier that is a prop.
|
|
55
|
+
* Emits an inline indexed Ruby Hash:
|
|
56
|
+
* `{ sm: 16, md: 20 }[v[:size].to_sym]`
|
|
57
|
+
*
|
|
58
|
+
* Returns the Ruby string when convertible, else `null` so the caller falls
|
|
59
|
+
* back to its normal value lowering (which records BF101 for an unsupported
|
|
60
|
+
* shape). Mirror of the Go adapter's `recordIndexAccessToGoMap`.
|
|
61
|
+
*/
|
|
62
|
+
export declare function recordIndexAccessToRuby(ctx: ErbSpreadContext, val: ParsedExpr): string | null;
|
|
63
|
+
//# 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;;;;;;;;;;;;;;;;;;;;;GAqBG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAG1D;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,GAAG,EAAE,gBAAgB,EACrB,IAAI,EAAE,UAAU,GAAG,SAAS,GAC3B,MAAM,GAAG,IAAI,CAiBf;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CACzC,GAAG,EAAE,gBAAgB,EACrB,IAAI,EAAE,UAAU,GAAG,SAAS,GAC3B,MAAM,GAAG,IAAI,CAGf;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,GAAG,EAAE,gBAAgB,EACrB,GAAG,EAAE,OAAO,CAAC,UAAU,EAAE;IAAE,IAAI,EAAE,gBAAgB,CAAA;CAAE,CAAC,GACnD,MAAM,GAAG,IAAI,CA0Cf;AAUD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,gBAAgB,EAAE,GAAG,EAAE,UAAU,GAAG,MAAM,GAAG,IAAI,CA4B7F"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* String-type value helpers for the ERB template adapter.
|
|
3
|
+
*
|
|
4
|
+
* Ported from the Mojolicious adapter's `value/parsed-literal.ts`
|
|
5
|
+
* (issue #2018 track D lineage). Pure functions over analyzer type info /
|
|
6
|
+
* const-initializer text — no adapter instance state.
|
|
7
|
+
*
|
|
8
|
+
* SHARED CANDIDATE: `isStringTypeInfo` and `isBareStringLiteral` are
|
|
9
|
+
* byte-identical to the Mojo/Xslate adapters' copies and adapter-agnostic.
|
|
10
|
+
*
|
|
11
|
+
* Module-scope pure-string-const inlining is owned by the shared
|
|
12
|
+
* `collectModuleStringConsts` in `@barefootjs/jsx` (consumed via
|
|
13
|
+
* `moduleStringConsts`), so no adapter-local source re-parse lives here.
|
|
14
|
+
*/
|
|
15
|
+
import type { TypeInfo } from '@barefootjs/jsx';
|
|
16
|
+
/** True when `type` is the `string` primitive. */
|
|
17
|
+
export declare function isStringTypeInfo(type: TypeInfo | undefined): boolean;
|
|
18
|
+
/** True when `initialValue` is a bare string-literal expression (`'x'` /
|
|
19
|
+
* `"x"`), used as a fallback for signals whose type wasn't inferred. */
|
|
20
|
+
export declare function isBareStringLiteral(initialValue: string | undefined): boolean;
|
|
21
|
+
//# 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;;;;;;;;;;;;;GAaG;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"}
|
package/dist/build.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { BuildOptions } from '@barefootjs/jsx';
|
|
2
|
+
import { ErbAdapter } from './adapter/index.ts';
|
|
3
|
+
import type { ErbAdapterOptions } from './adapter/index.ts';
|
|
4
|
+
export interface ErbBuildOptions extends BuildOptions {
|
|
5
|
+
/** Adapter-specific options passed to ErbAdapter */
|
|
6
|
+
adapterOptions?: ErbAdapterOptions;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Create a BarefootBuildConfig for ERB (Embedded Ruby) template projects.
|
|
10
|
+
*
|
|
11
|
+
* Uses structural typing — does not import BarefootBuildConfig to avoid a
|
|
12
|
+
* circular dependency between @barefootjs/erb and @barefootjs/cli.
|
|
13
|
+
*/
|
|
14
|
+
export declare function createConfig(options?: ErbBuildOptions): {
|
|
15
|
+
adapter: ErbAdapter;
|
|
16
|
+
paths: import("@barefootjs/jsx").BarefootPaths | undefined;
|
|
17
|
+
components: string[] | undefined;
|
|
18
|
+
outDir: string | undefined;
|
|
19
|
+
minify: boolean | undefined;
|
|
20
|
+
contentHash: boolean | undefined;
|
|
21
|
+
externals: Record<string, import("@barefootjs/jsx").ExternalSpec> | undefined;
|
|
22
|
+
externalsBasePath: string | undefined;
|
|
23
|
+
bundleEntries: import("@barefootjs/jsx").BundleEntry[] | undefined;
|
|
24
|
+
localImportPrefixes: string[] | undefined;
|
|
25
|
+
outputLayout: import("@barefootjs/jsx").OutputLayout;
|
|
26
|
+
postBuild: ((ctx: import("@barefootjs/jsx").PostBuildContext) => Promise<void> | void) | undefined;
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=build.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAC/C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAE3D,MAAM,WAAW,eAAgB,SAAQ,YAAY;IACnD,oDAAoD;IACpD,cAAc,CAAC,EAAE,iBAAiB,CAAA;CACnC;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,OAAO,GAAE,eAAoB;IAEtD,OAAO;IACP,KAAK;IACL,UAAU;IACV,MAAM;IACN,MAAM;IACN,WAAW;IACX,SAAS;IACT,iBAAiB;IACjB,aAAa;IACb,mBAAmB;IACnB,YAAY;IAKZ,SAAS;EAEZ"}
|