@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,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Array / string method lowering for the ERB template adapter.
|
|
3
|
+
*
|
|
4
|
+
* Ported from the Mojolicious adapter's `expr/array-method.ts` (issue #2018
|
|
5
|
+
* track D lineage). Pure free functions shared by both the filter-context
|
|
6
|
+
* emitter and the top-level emitter — they take an `emit` callback for
|
|
7
|
+
* receiver / argument recursion and read no adapter instance state.
|
|
8
|
+
*
|
|
9
|
+
* Every `bf.*` helper name below is kept 1:1 with the Perl (`BarefootJS.pm`)
|
|
10
|
+
* / Go runtime surface — the coordination contract between this TS emitter
|
|
11
|
+
* and the Ruby runtime (`lib/barefoot_js.rb`).
|
|
12
|
+
*/
|
|
13
|
+
import type { ParsedExpr, ArrayMethod, SortComparator, FlatDepth } from '@barefootjs/jsx';
|
|
14
|
+
/**
|
|
15
|
+
* Lower an `arr.<method>(...)` / `str.<method>(...)` value-builtin call to
|
|
16
|
+
* its Ruby form. The IR lifts these into the dedicated `array-method` kind at
|
|
17
|
+
* parse time (see the `arrayMethod` emitter arms), so this is the single
|
|
18
|
+
* place every adapter-supported array/string method is mapped. An unhandled
|
|
19
|
+
* `ArrayMethod` variant throws rather than emitting a silent no-op — the
|
|
20
|
+
* drift defence we already apply to `ParsedExpr.kind` extended to its
|
|
21
|
+
* sub-discriminator.
|
|
22
|
+
*/
|
|
23
|
+
export declare function renderArrayMethod(method: ArrayMethod, object: ParsedExpr, args: ParsedExpr[], emit: (e: ParsedExpr) => string): string;
|
|
24
|
+
/**
|
|
25
|
+
* Emit a `.sort(cmp)` / `.toSorted(cmp)` via the runtime evaluator: the
|
|
26
|
+
* comparator body travels as serialized-ParsedExpr JSON, evaluated per
|
|
27
|
+
* comparison against `{paramA, paramB, …captured}`. Returns null when the
|
|
28
|
+
* body can't be evaluated (e.g. a `localeCompare` comparator —
|
|
29
|
+
* `serializeParsedExpr` refuses it), so the caller falls back to the
|
|
30
|
+
* structured `bf.sort`. A `||`-chained multi-key comparator needs no
|
|
31
|
+
* special handling — JS `0 || next` is exactly the tie-break semantics.
|
|
32
|
+
*/
|
|
33
|
+
export declare function renderSortEval(recv: string, body: ParsedExpr, params: string[], emit: (e: ParsedExpr) => string): string | null;
|
|
34
|
+
/**
|
|
35
|
+
* Emit a `.reduce(fn, init)` / `.reduceRight(fn, init)` via the runtime
|
|
36
|
+
* evaluator: the reducer body travels as serialized-ParsedExpr JSON, folded
|
|
37
|
+
* over the receiver from `init` in `direction` order. Returns null when the
|
|
38
|
+
* body can't be evaluated (→ caller falls back to BF101). A numeric seed
|
|
39
|
+
* passes through as a bare Ruby number; a concat seed as a single-quoted
|
|
40
|
+
* string.
|
|
41
|
+
*/
|
|
42
|
+
export declare function renderReduceEval(recv: string, body: ParsedExpr, params: string[], init: ParsedExpr, direction: 'left' | 'right', emit: (e: ParsedExpr) => string): string | null;
|
|
43
|
+
/**
|
|
44
|
+
* Emit a higher-order predicate call via the runtime evaluator:
|
|
45
|
+
* `bf.filter_eval` / `bf.every_eval` / `bf.some_eval` / `bf.find_eval` /
|
|
46
|
+
* `bf.find_index_eval`, carrying the serialized predicate body + captured
|
|
47
|
+
* env Hash. Generalizes the inline predicate lowering to the same
|
|
48
|
+
* JS-faithful evaluator the Go adapter uses (cross-adapter isomorphism).
|
|
49
|
+
* Returns null when the predicate is outside the evaluator surface (e.g. a
|
|
50
|
+
* method-call predicate — `serializeParsedExpr` refuses it), so the caller
|
|
51
|
+
* falls back to the inline form. `forward` (find / findIndex family only)
|
|
52
|
+
* selects the search direction — `false` = findLast / findLastIndex.
|
|
53
|
+
*/
|
|
54
|
+
export declare function renderPredicateEval(funcName: string, recv: string, predicate: ParsedExpr, param: string, emit: (e: ParsedExpr) => string, forward?: boolean): string | null;
|
|
55
|
+
/**
|
|
56
|
+
* Emit a `.flatMap(proj)` via the runtime evaluator: the projection `body`
|
|
57
|
+
* serializes to JSON and `bf.flat_map_eval` projects + flattens one level.
|
|
58
|
+
* Returns null when the projection is outside the evaluator surface, and
|
|
59
|
+
* the caller records BF101.
|
|
60
|
+
*/
|
|
61
|
+
export declare function renderFlatMapEval(recv: string, body: ParsedExpr, param: string, emit: (e: ParsedExpr) => string): string | null;
|
|
62
|
+
/**
|
|
63
|
+
* Emit a value-producing `.map(cb)` via the runtime evaluator: the
|
|
64
|
+
* projection `body` serializes to JSON and `bf.map_eval` projects each
|
|
65
|
+
* element, one result per element (no flatten — the JS `.map` contract).
|
|
66
|
+
* Composes through the array-method chain (`.map(cb).join(' ')`). Returns
|
|
67
|
+
* null when the projection is outside the evaluator surface, and the caller
|
|
68
|
+
* records BF101. The JSX-returning `.map` is an IRLoop upstream and never
|
|
69
|
+
* reaches this emit.
|
|
70
|
+
*/
|
|
71
|
+
export declare function renderMapEval(recv: string, body: ParsedExpr, param: string, emit: (e: ParsedExpr) => string): string | null;
|
|
72
|
+
/**
|
|
73
|
+
* Shared ERB emit for `.sort(cmp)` / `.toSorted(cmp)`. Used by both the
|
|
74
|
+
* filter-context emitter and the top-level emitter, plus the loop-hoist path
|
|
75
|
+
* in `renderLoop` — same emit shape across all three so a regression in any
|
|
76
|
+
* one path surfaces consistently.
|
|
77
|
+
*
|
|
78
|
+
* The Ruby helper accepts an opts Hash whose `keys:` entry is an ordered
|
|
79
|
+
* list of per-key Hashes (room for a future `nulls` knob without arity
|
|
80
|
+
* churn), and returns a fresh Array so downstream composition
|
|
81
|
+
* (`bf.sort(...).join(...)`, etc.) stays straightforward.
|
|
82
|
+
*/
|
|
83
|
+
export declare function renderSortMethod(recv: string, c: SortComparator): string;
|
|
84
|
+
export declare function renderFlatMethod(recv: string, depth: FlatDepth | {
|
|
85
|
+
expr: ParsedExpr;
|
|
86
|
+
}, emit: (e: ParsedExpr) => string): string;
|
|
87
|
+
//# sourceMappingURL=array-method.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array-method.d.ts","sourceRoot":"","sources":["../../../src/adapter/expr/array-method.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAMH,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EACX,cAAc,EACd,SAAS,EACV,MAAM,iBAAiB,CAAA;AAGxB;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,WAAW,EACnB,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,UAAU,EAAE,EAClB,IAAI,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,MAAM,GAC9B,MAAM,CAuLR;AAuBD;;;;;;;;GAQG;AACH,wBAAgB,c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AE,MAAM,EACZ,KAAK,EAAE,SAAS,GAAG;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,EACvC,IAAI,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,MAAM,GAC9B,MAAM,CAqBR"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ParsedExpr → Ruby emitters for the ERB template adapter.
|
|
3
|
+
*
|
|
4
|
+
* Ported from the Mojolicious adapter's `expr/emitters.ts` (issue #2018
|
|
5
|
+
* track D lineage), retargeted at Ruby / ERB's two-locals variable model
|
|
6
|
+
* (`bf`, `v`). Two `ParsedExprEmitter` implementations:
|
|
7
|
+
*
|
|
8
|
+
* - `ErbFilterEmitter` — filter/predicate context (loop param + local
|
|
9
|
+
* aliases + `v[:name]` / loop-bound-local fallback for other
|
|
10
|
+
* identifiers); self-contained aside from a couple of adapter-supplied
|
|
11
|
+
* predicates, reads no other adapter state.
|
|
12
|
+
* - `ErbTopLevelEmitter` — top-level / vars-Hash context; depends on the
|
|
13
|
+
* adapter only through the narrow `ErbEmitContext` seam.
|
|
14
|
+
*
|
|
15
|
+
* Two structural simplifications fall out of Ruby's richer surface
|
|
16
|
+
* relative to Perl (documented at each site below, not scattered as
|
|
17
|
+
* special cases):
|
|
18
|
+
*
|
|
19
|
+
* 1. **Predicate callbacks compile to real Ruby blocks** (`.select { |x|
|
|
20
|
+
* ... }`) instead of Perl's regex `$param → $_` substitution into a
|
|
21
|
+
* `grep { ... }` block body — Ruby blocks take named parameters, so
|
|
22
|
+
* no textual substitution is needed.
|
|
23
|
+
* 2. **`.length` on a higher-order chain result needs no special form**
|
|
24
|
+
* (`arr.select { ... }.length` just works) — Perl's anonymous-arrayref
|
|
25
|
+
* `scalar(@{[grep ...]})` workaround has no ERB analog to port.
|
|
26
|
+
*
|
|
27
|
+
* The one thing EP does NOT need that ERB does: JS `&&` / `||` / `!` /
|
|
28
|
+
* ternary tests must be wrapped in `bf.truthy?(...)`. Perl's own falsy set
|
|
29
|
+
* (`undef`, `0`, `''`, `'0'`) already tracks JS's closely enough that Mojo's
|
|
30
|
+
* native `&&`/`||`/`!`/`?:` work unwrapped; Ruby's falsy set is only
|
|
31
|
+
* `nil`/`false`, so `0`, `''`, and `NaN` are Ruby-truthy but JS-falsy. Every
|
|
32
|
+
* JS truthiness test in this file goes through `bf.truthy?` for that reason.
|
|
33
|
+
*/
|
|
34
|
+
import { type ParsedExprEmitter, type ArrayMethod, type LiteralType, type ParsedExpr, type ObjectLiteralProperty, type FlatDepth, type TemplatePart } from '@barefootjs/jsx';
|
|
35
|
+
import type { ErbEmitContext } from '../emit-context.ts';
|
|
36
|
+
export declare class ErbFilterEmitter implements ParsedExprEmitter {
|
|
37
|
+
private readonly param;
|
|
38
|
+
private readonly localVarMap;
|
|
39
|
+
private readonly isLoopBoundOuter;
|
|
40
|
+
private readonly isStringName;
|
|
41
|
+
private readonly onUnsupported?;
|
|
42
|
+
constructor(param: string, localVarMap: Map<string, string>, isLoopBoundOuter?: (n: string) => boolean, isStringName?: (n: string) => boolean, onUnsupported?: ((message: string, reason?: string) => void) | undefined);
|
|
43
|
+
identifier(name: string): string;
|
|
44
|
+
literal(value: string | number | boolean | null, literalType: LiteralType): string;
|
|
45
|
+
member(object: ParsedExpr, property: string, _computed: boolean, emit: (e: ParsedExpr) => string): string;
|
|
46
|
+
indexAccess(object: ParsedExpr, index: ParsedExpr, emit: (e: ParsedExpr) => string): string;
|
|
47
|
+
call(callee: ParsedExpr, args: ParsedExpr[], emit: (e: ParsedExpr) => string): string;
|
|
48
|
+
unary(op: string, argument: ParsedExpr, emit: (e: ParsedExpr) => string): string;
|
|
49
|
+
binary(op: string, left: ParsedExpr, right: ParsedExpr, emit: (e: ParsedExpr) => string): string;
|
|
50
|
+
logical(op: '&&' | '||' | '??', left: ParsedExpr, right: ParsedExpr, emit: (e: ParsedExpr) => string): string;
|
|
51
|
+
callbackMethod(method: string, object: ParsedExpr, arrow: Extract<ParsedExpr, {
|
|
52
|
+
kind: 'arrow';
|
|
53
|
+
}>, _restArgs: ParsedExpr[], emit: (e: ParsedExpr) => string): string;
|
|
54
|
+
arrayLiteral(elements: ParsedExpr[], emit: (e: ParsedExpr) => string): string;
|
|
55
|
+
arrayMethod(method: ArrayMethod, object: ParsedExpr, args: ParsedExpr[], emit: (e: ParsedExpr) => string): string;
|
|
56
|
+
flatMethod(object: ParsedExpr, depth: FlatDepth | {
|
|
57
|
+
expr: ParsedExpr;
|
|
58
|
+
}, emit: (e: ParsedExpr) => string): string;
|
|
59
|
+
conditional(_test: ParsedExpr, _consequent: ParsedExpr, _alternate: ParsedExpr): string;
|
|
60
|
+
templateLiteral(_parts: TemplatePart[]): string;
|
|
61
|
+
arrow(_params: string[], _body: ParsedExpr, _emit: (e: ParsedExpr) => string): string;
|
|
62
|
+
regex(_raw: string): string;
|
|
63
|
+
unsupported(_raw: string, _reason: string): string;
|
|
64
|
+
objectLiteral(_properties: ObjectLiteralProperty[], _raw: string, _emit: (e: ParsedExpr) => string): string;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Lowering for top-level expressions whose identifiers resolve against the
|
|
68
|
+
* ERB template's vars Hash (`v`) — signals, props, module consts — or,
|
|
69
|
+
* inside a loop body, a bare Ruby local. Differs from the filter emitter
|
|
70
|
+
* mainly in:
|
|
71
|
+
* - `conditional` is supported (filter predicates can't return ternaries),
|
|
72
|
+
* - templatePrimitive / searchParams / eval-catalogue call dispatch,
|
|
73
|
+
* - the `unsupported` fallback returns the safe empty-string Ruby literal.
|
|
74
|
+
*/
|
|
75
|
+
export declare class ErbTopLevelEmitter implements ParsedExprEmitter {
|
|
76
|
+
private readonly ctx;
|
|
77
|
+
constructor(ctx: ErbEmitContext);
|
|
78
|
+
identifier(name: string): string;
|
|
79
|
+
literal(value: string | number | boolean | null, literalType: LiteralType): string;
|
|
80
|
+
member(object: ParsedExpr, property: string, _computed: boolean, emit: (e: ParsedExpr) => string): string;
|
|
81
|
+
indexAccess(object: ParsedExpr, index: ParsedExpr, emit: (e: ParsedExpr) => string): string;
|
|
82
|
+
call(callee: ParsedExpr, args: ParsedExpr[], emit: (e: ParsedExpr) => string): string;
|
|
83
|
+
unary(op: string, argument: ParsedExpr, emit: (e: ParsedExpr) => string): string;
|
|
84
|
+
binary(op: string, left: ParsedExpr, right: ParsedExpr, emit: (e: ParsedExpr) => string): string;
|
|
85
|
+
logical(op: '&&' | '||' | '??', left: ParsedExpr, right: ParsedExpr, emit: (e: ParsedExpr) => string): string;
|
|
86
|
+
callbackMethod(method: string, object: ParsedExpr, arrow: Extract<ParsedExpr, {
|
|
87
|
+
kind: 'arrow';
|
|
88
|
+
}>, restArgs: ParsedExpr[], emit: (e: ParsedExpr) => string): string;
|
|
89
|
+
private renderPredicate;
|
|
90
|
+
arrayLiteral(elements: ParsedExpr[], emit: (e: ParsedExpr) => string): string;
|
|
91
|
+
arrayMethod(method: ArrayMethod, object: ParsedExpr, args: ParsedExpr[], emit: (e: ParsedExpr) => string): string;
|
|
92
|
+
flatMethod(object: ParsedExpr, depth: FlatDepth | {
|
|
93
|
+
expr: ParsedExpr;
|
|
94
|
+
}, emit: (e: ParsedExpr) => string): string;
|
|
95
|
+
conditional(test: ParsedExpr, consequent: ParsedExpr, alternate: ParsedExpr, emit: (e: ParsedExpr) => string): string;
|
|
96
|
+
templateLiteral(parts: TemplatePart[], emit: (e: ParsedExpr) => string): string;
|
|
97
|
+
arrow(_params: string[], _body: ParsedExpr, _emit: (e: ParsedExpr) => string): string;
|
|
98
|
+
regex(_raw: string): string;
|
|
99
|
+
unsupported(_raw: string, _reason: string): string;
|
|
100
|
+
objectLiteral(properties: ObjectLiteralProperty[], _raw: string, _emit: (e: ParsedExpr) => string): string;
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=emitters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emitters.d.ts","sourceRoot":"","sources":["../../../src/adapter/expr/emitters.ts"],"names":[],"mappings":"AA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R,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,CAGR;IAED,eAAe,CAAC,KAAK,EAAE,YAAY,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,MAAM,GAAG,MAAM,CAiB9E;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,CAE1B;IAED,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAKjD;IAED,aAAa,CAAC,UAAU,EAAE,qBAAqB,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,MAAM,GAAG,MAAM,CAWzG;CACF"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Operand-type classification + index-access lowering for the ERB template
|
|
3
|
+
* adapter.
|
|
4
|
+
*
|
|
5
|
+
* Ported from the Mojolicious adapter's `expr/operand.ts` (issue #2018
|
|
6
|
+
* track D lineage). Pure functions over `ParsedExpr` — they take an
|
|
7
|
+
* `isStringName` predicate (supplied by the emitter from adapter state)
|
|
8
|
+
* rather than reading adapter instance state directly.
|
|
9
|
+
*
|
|
10
|
+
* `isStringTypedOperand` is byte-identical to the Mojo/Xslate adapters'
|
|
11
|
+
* copy. `emitIndexAccessRuby` is ERB-specific: Ruby's `[]` operator is
|
|
12
|
+
* syntactically the same for Array and Hash access (unlike Perl's
|
|
13
|
+
* `->[]`/`->{}` split), but this runtime's object values are JSON-shaped
|
|
14
|
+
* Ruby Hashes with SYMBOL keys — so a string-typed index still needs a
|
|
15
|
+
* `.to_sym` conversion to become a valid Hash key, while a non-string
|
|
16
|
+
* (numeric / loop-index) index passes straight through as an Array index.
|
|
17
|
+
*/
|
|
18
|
+
import type { ParsedExpr } from '@barefootjs/jsx';
|
|
19
|
+
/**
|
|
20
|
+
* Whether a comparison/index operand is string-typed. Covers a string
|
|
21
|
+
* literal, a string-signal getter call (`sel()`), and a string prop access
|
|
22
|
+
* (`props.x`). `isStringName` reports whether a getter/prop name is
|
|
23
|
+
* known-string. Loop-element fields (`t.id`) on untyped arrays have no known
|
|
24
|
+
* type and stay undetected — a separate, narrower gap.
|
|
25
|
+
*/
|
|
26
|
+
export declare function isStringTypedOperand(expr: ParsedExpr, isStringName: (n: string) => boolean): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Lower `arr[index]` to a Ruby `[]` access. A string-typed index reads a
|
|
29
|
+
* JSON-shaped Hash by symbol key (`.to_sym`); any other index (the common
|
|
30
|
+
* loop-index / arithmetic case, e.g. `selected()[index]`) reads an Array by
|
|
31
|
+
* its (already-numeric) value.
|
|
32
|
+
*/
|
|
33
|
+
export declare function emitIndexAccessRuby(object: ParsedExpr, index: ParsedExpr, emit: (e: ParsedExpr) => string, isStringName: (n: string) => boolean): string;
|
|
34
|
+
//# sourceMappingURL=operand.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operand.d.ts","sourceRoot":"","sources":["../../../src/adapter/expr/operand.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEjD;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,UAAU,EAAE,YAAY,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,OAAO,GAAG,OAAO,CASpG;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,UAAU,EAClB,KAAK,EAAE,UAAU,EACjB,IAAI,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,MAAM,EAC/B,YAAY,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,OAAO,GACnC,MAAM,CAKR"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/adapter/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AACzD,YAAY,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA"}
|