@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,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The contract the extracted expression-emitter modules depend on instead of
|
|
3
|
+
* the concrete `ErbAdapter`.
|
|
4
|
+
*
|
|
5
|
+
* The ERB adapter's top-level expression lowering is mutually recursive with
|
|
6
|
+
* the adapter's own const/record resolution and its filter-predicate emitter,
|
|
7
|
+
* so the extracted `ErbTopLevelEmitter` still needs to call back into shared
|
|
8
|
+
* per-compile state and recursive entry points. `ErbEmitContext` is that
|
|
9
|
+
* seam: the emitter takes an `ErbEmitContext` built by the adapter's private
|
|
10
|
+
* `emitCtx` getter (the adapter does NOT `implements` this interface, so the
|
|
11
|
+
* wrapped members stay private and off its exported public type — matching
|
|
12
|
+
* the Mojo/Go adapters' `emitCtx`). The emitter depends on this narrow
|
|
13
|
+
* interface rather than the full adapter class, so the coupling is explicit
|
|
14
|
+
* and it's unit-testable against a stub.
|
|
15
|
+
*
|
|
16
|
+
* Keep this surface minimal: add a member only when an extracted module
|
|
17
|
+
* genuinely needs it, so the seam documents the real cross-module coupling
|
|
18
|
+
* rather than re-exposing the whole adapter.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import type { ParsedExpr, CompilerError, IRMetadata } from '@barefootjs/jsx'
|
|
22
|
+
|
|
23
|
+
export interface ErbEmitContext {
|
|
24
|
+
/**
|
|
25
|
+
* Local binding names the request-scoped `searchParams()` env signal
|
|
26
|
+
* is imported under. Non-empty enables the env-signal method-call lowering.
|
|
27
|
+
*/
|
|
28
|
+
readonly _searchParamsLocals: Set<string>
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Inline a module-scope pure string-literal const by name as the resolved
|
|
32
|
+
* literal value, or null when the name is not such a const.
|
|
33
|
+
*/
|
|
34
|
+
resolveModuleStringConst(name: string): string | null
|
|
35
|
+
|
|
36
|
+
/** Resolve a literal const (`const totalPages = 5`) to its Ruby value, or null. */
|
|
37
|
+
resolveLiteralConst(name: string): string | null
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Resolve a static property access on a module object-literal const
|
|
41
|
+
* (`variantClasses.ghost`) to its Ruby value at compile time, or null.
|
|
42
|
+
*/
|
|
43
|
+
resolveStaticRecordLiteral(objectName: string, key: string): string | null
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Whether `name` currently names a bare Ruby local bound by an enclosing
|
|
47
|
+
* loop/block (`todos().map(todo => ...)` → `|todo|`) — as opposed to a
|
|
48
|
+
* prop / signal / memo / module const, which always resolves through the
|
|
49
|
+
* `v[:name]` vars Hash. This is the ERB-specific branch point the Mojo/
|
|
50
|
+
* Kolon adapters don't need: Perl's `$name` sigil resolves a lexical
|
|
51
|
+
* loop var and a stash var identically, but ERB's two-locals variable
|
|
52
|
+
* model (`bf`, `v`) requires the identifier emitter to choose between a
|
|
53
|
+
* bare Ruby local and a `v[:name]` hash lookup.
|
|
54
|
+
*/
|
|
55
|
+
isLoopBoundName(name: string): boolean
|
|
56
|
+
|
|
57
|
+
/** Whether a getter/prop name resolves to a string-typed SSR value. */
|
|
58
|
+
_isStringValueName(name: string): boolean
|
|
59
|
+
|
|
60
|
+
/** Record a BF101 unsupported-expression diagnostic. */
|
|
61
|
+
_recordExprBF101(message: string, reason?: string): void
|
|
62
|
+
|
|
63
|
+
/** Lower a filter/predicate body to its Ruby form, bound to `param`. */
|
|
64
|
+
_renderRubyFilterExprPublic(expr: ParsedExpr, param: string): string
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* The contract the extracted object-literal / conditional-spread lowering
|
|
69
|
+
* (`spread/spread-codegen.ts`) depends on. The spread lowering recurses into
|
|
70
|
+
* the core expression lowering and records its own BF101 diagnostics, so it
|
|
71
|
+
* needs the recursive entry point plus the per-compile bookkeeping the
|
|
72
|
+
* adapter owns. Declared separately from `ErbEmitContext` so each extracted
|
|
73
|
+
* module's real coupling is documented precisely.
|
|
74
|
+
*/
|
|
75
|
+
export interface ErbSpreadContext {
|
|
76
|
+
/** Component name, for diagnostic source locations. */
|
|
77
|
+
readonly componentName: string
|
|
78
|
+
|
|
79
|
+
/** Per-compile diagnostic list the spread lowering appends to. */
|
|
80
|
+
readonly errors: CompilerError[]
|
|
81
|
+
|
|
82
|
+
/** Local-constant metadata, for resolving `Record[key]` spread values. */
|
|
83
|
+
readonly localConstants: IRMetadata['localConstants']
|
|
84
|
+
|
|
85
|
+
/** Prop params, for classifying a bare-identifier index as a prop. */
|
|
86
|
+
readonly propsParams: { name: string }[]
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Lower a JS expression to its Ruby form (the core recursive entry).
|
|
90
|
+
*
|
|
91
|
+
* When the IR already carries a structured `ParsedExpr` tree, pass it as
|
|
92
|
+
* `preParsed` so the converter threads it straight through instead of
|
|
93
|
+
* re-parsing `expr` — mirrors go-template's
|
|
94
|
+
* `convertExpressionToGo(jsExpr, out?, preParsed?)`. With `preParsed` set,
|
|
95
|
+
* `expr` is unused for parsing (the converter derives any diagnostic text
|
|
96
|
+
* from the tree), so callers may pass `''`.
|
|
97
|
+
*/
|
|
98
|
+
convertExpressionToRuby(expr: string, preParsed?: ParsedExpr): string
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* The contract the extracted in-template memo / context seeding
|
|
103
|
+
* (`memo/seed.ts`) depends on. The seed lowering recurses into the core
|
|
104
|
+
* expression lowering to compute a derived signal/memo value or a context
|
|
105
|
+
* default; that recursive entry is its only adapter coupling.
|
|
106
|
+
*/
|
|
107
|
+
export interface ErbMemoContext {
|
|
108
|
+
/**
|
|
109
|
+
* Lower a JS expression to its Ruby form (the core recursive entry).
|
|
110
|
+
*
|
|
111
|
+
* When the IR already carries a structured `ParsedExpr` tree, pass it as
|
|
112
|
+
* `preParsed` so the converter threads it straight through instead of
|
|
113
|
+
* re-parsing `expr` — mirrors go-template's
|
|
114
|
+
* `convertExpressionToGo(jsExpr, out?, preParsed?)`. With `preParsed` set,
|
|
115
|
+
* `expr` is unused for parsing (the converter derives any diagnostic text
|
|
116
|
+
* from the tree), so callers may pass `''`.
|
|
117
|
+
*/
|
|
118
|
+
convertExpressionToRuby(expr: string, preParsed?: ParsedExpr): string
|
|
119
|
+
}
|