@barefootjs/go-template 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 +23 -0
- package/dist/adapter/analysis/component-tree.d.ts.map +1 -0
- package/dist/adapter/emit-context.d.ts +53 -0
- package/dist/adapter/emit-context.d.ts.map +1 -0
- package/dist/adapter/expr/helper-inline.d.ts +31 -0
- package/dist/adapter/expr/helper-inline.d.ts.map +1 -0
- package/dist/adapter/expr/url-builder.d.ts +23 -0
- package/dist/adapter/expr/url-builder.d.ts.map +1 -0
- package/dist/adapter/go-template-adapter.d.ts +291 -1070
- package/dist/adapter/go-template-adapter.d.ts.map +1 -1
- package/dist/adapter/index.js +2857 -2618
- package/dist/adapter/lib/compile-state.d.ts +116 -0
- package/dist/adapter/lib/compile-state.d.ts.map +1 -0
- package/dist/adapter/lib/constants.d.ts +11 -0
- package/dist/adapter/lib/constants.d.ts.map +1 -0
- package/dist/adapter/lib/go-emit.d.ts +117 -0
- package/dist/adapter/lib/go-emit.d.ts.map +1 -0
- package/dist/adapter/lib/go-naming.d.ts +39 -0
- package/dist/adapter/lib/go-naming.d.ts.map +1 -0
- package/dist/adapter/lib/ir-scope.d.ts +13 -0
- package/dist/adapter/lib/ir-scope.d.ts.map +1 -0
- package/dist/adapter/lib/types.d.ts +165 -0
- package/dist/adapter/lib/types.d.ts.map +1 -0
- package/dist/adapter/memo/ctor-lowering.d.ts +39 -0
- package/dist/adapter/memo/ctor-lowering.d.ts.map +1 -0
- package/dist/adapter/memo/memo-compute.d.ts +124 -0
- package/dist/adapter/memo/memo-compute.d.ts.map +1 -0
- package/dist/adapter/memo/memo-type.d.ts +38 -0
- package/dist/adapter/memo/memo-type.d.ts.map +1 -0
- package/dist/adapter/memo/memo-value.d.ts +64 -0
- package/dist/adapter/memo/memo-value.d.ts.map +1 -0
- package/dist/adapter/memo/template-interp.d.ts +43 -0
- package/dist/adapter/memo/template-interp.d.ts.map +1 -0
- package/dist/adapter/props/prop-types.d.ts +31 -0
- package/dist/adapter/props/prop-types.d.ts.map +1 -0
- package/dist/adapter/spread/spread-codegen.d.ts +40 -0
- package/dist/adapter/spread/spread-codegen.d.ts.map +1 -0
- package/dist/adapter/type/type-codegen.d.ts +25 -0
- package/dist/adapter/type/type-codegen.d.ts.map +1 -0
- package/dist/adapter/value/parsed-literal-to-go.d.ts +17 -0
- package/dist/adapter/value/parsed-literal-to-go.d.ts.map +1 -0
- package/dist/adapter/value/value-lowering.d.ts +46 -0
- package/dist/adapter/value/value-lowering.d.ts.map +1 -0
- package/dist/build.js +2856 -2617
- package/dist/index.js +2857 -2618
- package/dist/test-render.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/__tests__/derived-state-memo.test.ts +155 -84
- package/src/__tests__/go-template-adapter.test.ts +118 -54
- package/src/__tests__/lowering-plugin.test.ts +109 -0
- package/src/__tests__/query-href.test.ts +179 -0
- package/src/adapter/analysis/component-tree.ts +174 -0
- package/src/adapter/emit-context.ts +59 -0
- package/src/adapter/expr/helper-inline.ts +274 -0
- package/src/adapter/expr/url-builder.ts +123 -0
- package/src/adapter/go-template-adapter.ts +2099 -5325
- package/src/adapter/lib/compile-state.ts +150 -0
- package/src/adapter/lib/constants.ts +24 -0
- package/src/adapter/lib/go-emit.ts +289 -0
- package/src/adapter/lib/go-naming.ts +84 -0
- package/src/adapter/lib/ir-scope.ts +31 -0
- package/src/adapter/lib/types.ts +182 -0
- package/src/adapter/memo/ctor-lowering.ts +267 -0
- package/src/adapter/memo/memo-compute.ts +451 -0
- package/src/adapter/memo/memo-type.ts +74 -0
- package/src/adapter/memo/memo-value.ts +197 -0
- package/src/adapter/memo/template-interp.ts +246 -0
- package/src/adapter/props/prop-types.ts +84 -0
- package/src/adapter/spread/spread-codegen.ts +458 -0
- package/src/adapter/type/type-codegen.ts +95 -0
- package/src/adapter/value/parsed-literal-to-go.ts +94 -0
- package/src/adapter/value/value-lowering.ts +162 -0
- package/src/test-render.ts +2 -14
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Memo initial-value computation — lower a memo's computation to its SSR initial
|
|
3
|
+
* value as a Go expression.
|
|
4
|
+
*
|
|
5
|
+
* Free functions over a {@link GoEmitContext}. `computeMemoInitialValue` is the
|
|
6
|
+
* typed-field entry (zero-value defaulting); `computeMemoInitialValueOrNull` is
|
|
7
|
+
* the pattern-matching core dispatching over template-literal, parsed-body,
|
|
8
|
+
* comparison-ternary, block-body and object memo shapes.
|
|
9
|
+
*/
|
|
10
|
+
import type { ParsedExpr, ParsedStatement, TypeInfo } from '@barefootjs/jsx';
|
|
11
|
+
import type { GoEmitContext } from '../emit-context.ts';
|
|
12
|
+
import type { PropFallbackVar } from '../lib/types.ts';
|
|
13
|
+
/**
|
|
14
|
+
* Compute a memo's SSR initial value as a Go expression — e.g.
|
|
15
|
+
* `() => count() * 2` → `in.Initial * 2`, `() => props.value * 10` →
|
|
16
|
+
* `in.Value * 10`. Unresolved computations default to the memo's Go zero value.
|
|
17
|
+
*
|
|
18
|
+
* @param propFallbackVars when a hoisted fallback var exists for a referenced
|
|
19
|
+
* prop, it is substituted for `in.FieldName` so the memo inherits the
|
|
20
|
+
* signal-time `??` fallback
|
|
21
|
+
* @param goType Go type of the memo field, used to pick the zero-value fallback
|
|
22
|
+
*/
|
|
23
|
+
export declare function computeMemoInitialValue(ctx: GoEmitContext, memo: {
|
|
24
|
+
name: string;
|
|
25
|
+
computation: string;
|
|
26
|
+
deps: string[];
|
|
27
|
+
parsed?: ParsedExpr;
|
|
28
|
+
}, signals: {
|
|
29
|
+
getter: string;
|
|
30
|
+
initialValue: string;
|
|
31
|
+
}[], propsParams: {
|
|
32
|
+
name: string;
|
|
33
|
+
type?: TypeInfo;
|
|
34
|
+
defaultValue?: string;
|
|
35
|
+
}[], propFallbackVars?: ReadonlyMap<string, PropFallbackVar>, goType?: string): string;
|
|
36
|
+
/**
|
|
37
|
+
* Structural matcher for the common expression-bodied memo shapes, driven by
|
|
38
|
+
* the analyzer-attached `MemoInfo.parsed` (the memo arrow's body): `getter() ===
|
|
39
|
+
* 'lit'`, `props.X ?? false`, `cond() ? A : B`, `<getter()|props.X|var> <*+-/>
|
|
40
|
+
* <int>`, and bare `getter()` / `props.X` / `var`.
|
|
41
|
+
*
|
|
42
|
+
* @returns the Go SSR value, or null when the body is none of these (the caller
|
|
43
|
+
* then falls through to comparison-ternary / block-body / object-memo handling)
|
|
44
|
+
*/
|
|
45
|
+
export declare function memoInitialFromParsedBody(ctx: GoEmitContext, body: ParsedExpr, signals: {
|
|
46
|
+
getter: string;
|
|
47
|
+
initialValue: string;
|
|
48
|
+
}[], propsParams: {
|
|
49
|
+
name: string;
|
|
50
|
+
type?: TypeInfo;
|
|
51
|
+
defaultValue?: string;
|
|
52
|
+
}[], propFallbackVars: ReadonlyMap<string, PropFallbackVar>): string | null;
|
|
53
|
+
/**
|
|
54
|
+
* Pattern-matching core of `computeMemoInitialValue`.
|
|
55
|
+
*
|
|
56
|
+
* @returns the memo's SSR initial value as a Go expression, or `null` when no
|
|
57
|
+
* pattern applies. Callers with a typed field to fill use the
|
|
58
|
+
* zero-value-defaulting wrapper above; callers that can OMIT the field (a
|
|
59
|
+
* child-instance prop init, where Go's zero values then apply with the right
|
|
60
|
+
* type) use this directly.
|
|
61
|
+
*/
|
|
62
|
+
export declare function computeMemoInitialValueOrNull(ctx: GoEmitContext, memo: {
|
|
63
|
+
name: string;
|
|
64
|
+
computation: string;
|
|
65
|
+
deps: string[];
|
|
66
|
+
parsed?: ParsedExpr;
|
|
67
|
+
parsedBlock?: ParsedStatement[];
|
|
68
|
+
parsedBlockComplete?: boolean;
|
|
69
|
+
}, signals: {
|
|
70
|
+
getter: string;
|
|
71
|
+
initialValue: string;
|
|
72
|
+
}[], propsParams: {
|
|
73
|
+
name: string;
|
|
74
|
+
type?: TypeInfo;
|
|
75
|
+
defaultValue?: string;
|
|
76
|
+
}[], propFallbackVars?: ReadonlyMap<string, PropFallbackVar>): string | null;
|
|
77
|
+
/**
|
|
78
|
+
* Resolve a signal/memo getter NAME to a Go value expression, for use as the
|
|
79
|
+
* condition operand of another memo's ternary. Handles a plain signal, a
|
|
80
|
+
* prop-shadow memo `() => props.X ?? 'lit'` (→ a nil/empty-tolerant field
|
|
81
|
+
* read), else recurses.
|
|
82
|
+
*
|
|
83
|
+
* @returns the Go expression, or null when the shape isn't representable
|
|
84
|
+
*/
|
|
85
|
+
export declare function resolveGetterValueAsGo(ctx: GoEmitContext, name: string, signals: {
|
|
86
|
+
getter: string;
|
|
87
|
+
initialValue: string;
|
|
88
|
+
}[], propsParams: {
|
|
89
|
+
name: string;
|
|
90
|
+
type?: TypeInfo;
|
|
91
|
+
defaultValue?: string;
|
|
92
|
+
}[], propFallbackVars: ReadonlyMap<string, PropFallbackVar>): string | null;
|
|
93
|
+
/**
|
|
94
|
+
* Resolve a string-ternary memo whose condition is a literal comparison —
|
|
95
|
+
* `() => <operand> === 'lit' ? A : B` (or `!==`) — to a Go runtime conditional.
|
|
96
|
+
* Branches must be string literals/module-string-consts; the operand resolves
|
|
97
|
+
* via `resolveComparisonOperandGo`.
|
|
98
|
+
*
|
|
99
|
+
* @returns the Go conditional, or null when the shape isn't supported
|
|
100
|
+
*/
|
|
101
|
+
export declare function computeComparisonTernaryGo(ctx: GoEmitContext, parsed: ParsedExpr | undefined, signals: {
|
|
102
|
+
getter: string;
|
|
103
|
+
initialValue: string;
|
|
104
|
+
}[], propsParams: {
|
|
105
|
+
name: string;
|
|
106
|
+
type?: TypeInfo;
|
|
107
|
+
defaultValue?: string;
|
|
108
|
+
}[], propFallbackVars: ReadonlyMap<string, PropFallbackVar>): string | null;
|
|
109
|
+
/**
|
|
110
|
+
* Resolve the left operand of a string-ternary memo's comparison condition to a
|
|
111
|
+
* Go expression: a zero-arg getter call (a signal/prop-shadow memo), an inline
|
|
112
|
+
* `props.X ?? 'def'` (folds the default), or a bare `props.X`.
|
|
113
|
+
*
|
|
114
|
+
* @returns the Go expression, or null for anything else
|
|
115
|
+
*/
|
|
116
|
+
export declare function resolveComparisonOperandGo(ctx: GoEmitContext, node: ParsedExpr, signals: {
|
|
117
|
+
getter: string;
|
|
118
|
+
initialValue: string;
|
|
119
|
+
}[], propsParams: {
|
|
120
|
+
name: string;
|
|
121
|
+
type?: TypeInfo;
|
|
122
|
+
defaultValue?: string;
|
|
123
|
+
}[], propFallbackVars: ReadonlyMap<string, PropFallbackVar>): string | null;
|
|
124
|
+
//# sourceMappingURL=memo-compute.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memo-compute.d.ts","sourceRoot":"","sources":["../../../src/adapter/memo/memo-compute.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAE5E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAUtD;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CACrC,GAAG,EAAE,aAAa,EAClB,IAAI,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAC;IAAC,MAAM,CAAC,EAAE,UAAU,CAAA;CAAE,EAChF,OAAO,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,EAAE,EACnD,WAAW,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,QAAQ,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,EACvE,gBAAgB,GAAE,WAAW,CAAC,MAAM,EAAE,eAAe,CAA4B,EACjF,MAAM,CAAC,EAAE,MAAM,GACd,MAAM,CAqBR;AAED;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CACvC,GAAG,EAAE,aAAa,EAClB,IAAI,EAAE,UAAU,EAChB,OAAO,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,EAAE,EACnD,WAAW,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,QAAQ,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,EACvE,gBAAgB,EAAE,WAAW,CAAC,MAAM,EAAE,eAAe,CAAC,GACrD,MAAM,GAAG,IAAI,CAsKf;AAED;;;;;;;;GAQG;AACH,wBAAgB,6BAA6B,CAC3C,GAAG,EAAE,aAAa,EAClB,IAAI,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAC;IAAC,MAAM,CAAC,EAAE,UAAU,CAAC;IAAC,WAAW,CAAC,EAAE,eAAe,EAAE,CAAC;IAAC,mBAAmB,CAAC,EAAE,OAAO,CAAA;CAAE,EAChJ,OAAO,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,EAAE,EACnD,WAAW,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,QAAQ,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,EACvE,gBAAgB,GAAE,WAAW,CAAC,MAAM,EAAE,eAAe,CAA4B,GAChF,MAAM,GAAG,IAAI,CAsDf;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CACpC,GAAG,EAAE,aAAa,EAClB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,EAAE,EACnD,WAAW,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,QAAQ,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,EACvE,gBAAgB,EAAE,WAAW,CAAC,MAAM,EAAE,eAAe,CAAC,GACrD,MAAM,GAAG,IAAI,CAqBf;AAED;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CACxC,GAAG,EAAE,aAAa,EAClB,MAAM,EAAE,UAAU,GAAG,SAAS,EAC9B,OAAO,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,EAAE,EACnD,WAAW,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,QAAQ,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,EACvE,gBAAgB,EAAE,WAAW,CAAC,MAAM,EAAE,eAAe,CAAC,GACrD,MAAM,GAAG,IAAI,CAuCf;AAED;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CACxC,GAAG,EAAE,aAAa,EAClB,IAAI,EAAE,UAAU,EAChB,OAAO,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,EAAE,EACnD,WAAW,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,QAAQ,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,EACvE,gBAAgB,EAAE,WAAW,CAAC,MAAM,EAAE,eAAe,CAAC,GACrD,MAAM,GAAG,IAAI,CAiBf"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Memo type inference predicates.
|
|
3
|
+
*
|
|
4
|
+
* Pure free functions over a {@link GoEmitContext} that classify a memo's
|
|
5
|
+
* computation so `inferMemoType` can pick the right Go field type (and thus the
|
|
6
|
+
* right SSR zero value).
|
|
7
|
+
*/
|
|
8
|
+
import type { ParsedExpr, TypeInfo } from '@barefootjs/jsx';
|
|
9
|
+
import type { GoEmitContext } from '../emit-context.ts';
|
|
10
|
+
/**
|
|
11
|
+
* Heuristic: does this memo evaluate to a boolean? True when its computation is
|
|
12
|
+
* a comparison (`!==`/`===`/`!=`/`==`), a negation (`!x`), or a ternary whose
|
|
13
|
+
* branches are all boolean signals/props. Used to pick `bool` (zero value
|
|
14
|
+
* `false`) over the int `0` default for the SSR initial value.
|
|
15
|
+
*/
|
|
16
|
+
export declare function isBooleanMemo(ctx: GoEmitContext, memo: {
|
|
17
|
+
computation: string;
|
|
18
|
+
deps: string[];
|
|
19
|
+
parsed?: ParsedExpr;
|
|
20
|
+
}, signals: {
|
|
21
|
+
getter: string;
|
|
22
|
+
initialValue: string;
|
|
23
|
+
type: TypeInfo;
|
|
24
|
+
}[], propsParamMap: Map<string, {
|
|
25
|
+
name: string;
|
|
26
|
+
type: TypeInfo;
|
|
27
|
+
defaultValue?: string;
|
|
28
|
+
}>): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Does this memo's body resolve to a ternary whose BOTH branches are
|
|
31
|
+
* string-valued — e.g. `() => orientation() === 'vertical' ? 'flex-col' :
|
|
32
|
+
* 'flex'`? Such a memo is a string, not a bool, even though its condition
|
|
33
|
+
* contains `===`. Since #2040 a block-bodied memo can also carry `parsed` (a
|
|
34
|
+
* value `if` / early-return folds to a ternary), so this now applies to those
|
|
35
|
+
* too — the inferred field type follows the folded shape, not the syntax.
|
|
36
|
+
*/
|
|
37
|
+
export declare function isStringTernaryMemo(ctx: GoEmitContext, parsed: ParsedExpr | undefined): boolean;
|
|
38
|
+
//# sourceMappingURL=memo-type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memo-type.d.ts","sourceRoot":"","sources":["../../../src/adapter/memo/memo-type.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAE3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAGvD;;;;;GAKG;AACH,wBAAgB,aAAa,CAC3B,GAAG,EAAE,aAAa,EAClB,IAAI,EAAE;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAC;IAAC,MAAM,CAAC,EAAE,UAAU,CAAA;CAAE,EAClE,OAAO,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,QAAQ,CAAA;CAAE,EAAE,EACnE,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,GAClF,OAAO,CA8BT;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,aAAa,EAAE,MAAM,EAAE,UAAU,GAAG,SAAS,GAAG,OAAO,CAS/F"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Memo value computation for block-body / object-returning memos.
|
|
3
|
+
*
|
|
4
|
+
* Free functions over a {@link GoEmitContext}:
|
|
5
|
+
* - `resolveBlockBodyMemoModuleConst` recognises a guard-and-return-module-
|
|
6
|
+
* const memo and reports the constant, reading `state.localConstants`.
|
|
7
|
+
* - `computeObjectMemoInitialValue` lowers a `searchParams()`-derived
|
|
8
|
+
* object-returning memo to a Go `map[string]interface{}` literal, reading
|
|
9
|
+
* the analyzer-carried `parsedBlock` and `state.searchParamsLocals` and
|
|
10
|
+
* delegating value lowering to `lowerCtorExpr`.
|
|
11
|
+
*/
|
|
12
|
+
import type { ParsedExpr, ParsedStatement, TypeInfo } from '@barefootjs/jsx';
|
|
13
|
+
import type { GoEmitContext } from '../emit-context.ts';
|
|
14
|
+
type GuardConstResult = {
|
|
15
|
+
constName: string;
|
|
16
|
+
constValue: string | undefined;
|
|
17
|
+
constType: TypeInfo | undefined;
|
|
18
|
+
constParsed: ParsedExpr | undefined;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Recognise a block-body memo whose SSR path returns a module-const array when
|
|
22
|
+
* the guard signal starts falsy:
|
|
23
|
+
* `() => { const k = getter(); if (!k) return MODULE_CONST; … }`
|
|
24
|
+
*
|
|
25
|
+
* Primary path: the block is normalized to a single expression upstream (#2040,
|
|
26
|
+
* `foldBlockToExpr` in the analyzer), so this reads the folded `MemoInfo.parsed`
|
|
27
|
+
* conditional `!getter() ? MODULE_CONST : <derived>`. When the guard signal's
|
|
28
|
+
* initial value is falsy, `!guard` is `true`, so the `consequent` is the const
|
|
29
|
+
* rendered at SSR.
|
|
30
|
+
*
|
|
31
|
+
* Fallback path: a block the fold REFUSES (e.g. an impure local binding that
|
|
32
|
+
* isn't used exactly once per path sits alongside the guard) leaves
|
|
33
|
+
* `MemoInfo.parsed` unset, but the guard prefix is still present in the tolerant
|
|
34
|
+
* `MemoInfo.parsedBlock`. Scan that prefix so the SSR const bake matches `main`
|
|
35
|
+
* exactly — the bake depends only on the guard, not on the unfoldable tail.
|
|
36
|
+
*
|
|
37
|
+
* @returns the constant's name, value, inferred type and parsed tree, or null
|
|
38
|
+
*/
|
|
39
|
+
export declare function resolveBlockBodyMemoModuleConst(ctx: GoEmitContext, memo: {
|
|
40
|
+
parsed?: ParsedExpr;
|
|
41
|
+
parsedBlock?: ParsedStatement[];
|
|
42
|
+
}, signals: {
|
|
43
|
+
getter: string;
|
|
44
|
+
initialValue: string;
|
|
45
|
+
}[]): GuardConstResult | null;
|
|
46
|
+
/**
|
|
47
|
+
* Compute the SSR value of an object-returning block-body memo derived from
|
|
48
|
+
* `searchParams()`:
|
|
49
|
+
* () => { const sp = searchParams(); return { sort: asSortKey(sp.get('sort')),
|
|
50
|
+
* tag: sp.get('tag') ?? '' } }
|
|
51
|
+
* Emits a Go `map[string]interface{}{ "Sort": …, "Tag": … }` whose values are
|
|
52
|
+
* lowered from the request query (see `lowerCtorExpr`). Keys are capitalized to
|
|
53
|
+
* match the template's `.Params.<Field>` map access.
|
|
54
|
+
*
|
|
55
|
+
* @returns the Go map literal, or null for any shape the lowerer can't
|
|
56
|
+
* represent (→ nil-map fallback)
|
|
57
|
+
*/
|
|
58
|
+
export declare function computeObjectMemoInitialValue(ctx: GoEmitContext, memo: {
|
|
59
|
+
parsed?: ParsedExpr;
|
|
60
|
+
parsedBlock?: ParsedStatement[];
|
|
61
|
+
parsedBlockComplete?: boolean;
|
|
62
|
+
}): string | null;
|
|
63
|
+
export {};
|
|
64
|
+
//# sourceMappingURL=memo-value.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memo-value.d.ts","sourceRoot":"","sources":["../../../src/adapter/memo/memo-value.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAE5E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAKvD,KAAK,gBAAgB,GAAG;IACtB,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,EAAE,MAAM,GAAG,SAAS,CAAA;IAC9B,SAAS,EAAE,QAAQ,GAAG,SAAS,CAAA;IAC/B,WAAW,EAAE,UAAU,GAAG,SAAS,CAAA;CACpC,CAAA;AAkBD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,+BAA+B,CAC7C,GAAG,EAAE,aAAa,EAClB,IAAI,EAAE;IAAE,MAAM,CAAC,EAAE,UAAU,CAAC;IAAC,WAAW,CAAC,EAAE,eAAe,EAAE,CAAA;CAAE,EAC9D,OAAO,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,EAAE,GAClD,gBAAgB,GAAG,IAAI,CAKzB;AAsED;;;;;;;;;;;GAWG;AACH,wBAAgB,6BAA6B,CAC3C,GAAG,EAAE,aAAa,EAClB,IAAI,EAAE;IAAE,MAAM,CAAC,EAAE,UAAU,CAAC;IAAC,WAAW,CAAC,EAAE,eAAe,EAAE,CAAC;IAAC,mBAAmB,CAAC,EAAE,OAAO,CAAA;CAAE,GAC5F,MAAM,GAAG,IAAI,CAwCf"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Template-literal memo lowering.
|
|
3
|
+
*
|
|
4
|
+
* Free functions over a {@link GoEmitContext} that compute the SSR initial
|
|
5
|
+
* value of a template-literal memo (`() => `${a} ${props.x ?? ''} grid``) as a
|
|
6
|
+
* Go `string` expression. Each quasi becomes a Go string literal; each
|
|
7
|
+
* interpolation resolves to a module string const, a `Record`-index access, or
|
|
8
|
+
* a `props.<name>` field read. Sets `state.usesFmt` when a `Record`-index
|
|
9
|
+
* interpolation emits `fmt.Sprint`.
|
|
10
|
+
*/
|
|
11
|
+
import ts from 'typescript';
|
|
12
|
+
import type { ParsedExpr, ParsedStatement, TypeInfo } from '@barefootjs/jsx';
|
|
13
|
+
import type { GoEmitContext } from '../emit-context.ts';
|
|
14
|
+
/**
|
|
15
|
+
* Compute the SSR initial value of a template-literal memo as a Go `string`
|
|
16
|
+
* expression, e.g. `() => `${a} ${props.className ?? ''} grid``.
|
|
17
|
+
*
|
|
18
|
+
* Each quasi becomes a Go string literal; each interpolation is resolved:
|
|
19
|
+
* - an identifier naming a module string const → its inlined literal (covers
|
|
20
|
+
* pure-string and `[...].join(' ')` consts);
|
|
21
|
+
* - `props.<name> ?? '<fallback>'` or bare `props.<name>` → `in.<Field>` when
|
|
22
|
+
* `<name>` is a known string-typed prop param (the `?? ''` fallback maps to
|
|
23
|
+
* Go's zero value for an unset string field).
|
|
24
|
+
*
|
|
25
|
+
* @returns the `"a" + in.Field + " grid..."` concatenation, or null when the
|
|
26
|
+
* computation isn't a single template literal or any interpolation isn't
|
|
27
|
+
* representable
|
|
28
|
+
*/
|
|
29
|
+
export declare function computeTemplateLiteralMemoInitialValue(ctx: GoEmitContext, memo: {
|
|
30
|
+
parsed?: ParsedExpr;
|
|
31
|
+
parsedBlock?: ParsedStatement[];
|
|
32
|
+
parsedBlockComplete?: boolean;
|
|
33
|
+
}, propsParams: {
|
|
34
|
+
name: string;
|
|
35
|
+
type?: TypeInfo;
|
|
36
|
+
defaultValue?: string;
|
|
37
|
+
}[]): string | null;
|
|
38
|
+
/**
|
|
39
|
+
* If `node` is a `<propsObjectName>.<name>` access, return `<name>`, else
|
|
40
|
+
* null. Used to recognize props-object reads inside memo interpolations.
|
|
41
|
+
*/
|
|
42
|
+
export declare function propsAccessName(ctx: GoEmitContext, node: ts.Expression): string | null;
|
|
43
|
+
//# sourceMappingURL=template-interp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template-interp.d.ts","sourceRoot":"","sources":["../../../src/adapter/memo/template-interp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,MAAM,YAAY,CAAA;AAE3B,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAE5E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAIvD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,sCAAsC,CACpD,GAAG,EAAE,aAAa,EAClB,IAAI,EAAE;IAAE,MAAM,CAAC,EAAE,UAAU,CAAC;IAAC,WAAW,CAAC,EAAE,eAAe,EAAE,CAAC;IAAC,mBAAmB,CAAC,EAAE,OAAO,CAAA;CAAE,EAC7F,WAAW,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,QAAQ,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,GACtE,MAAM,GAAG,IAAI,CAsDf;AAgJD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,aAAa,EAAE,IAAI,EAAE,EAAE,CAAC,UAAU,GAAG,MAAM,GAAG,IAAI,CAKtF"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prop-type resolution: decide each prop's Go struct-field type.
|
|
3
|
+
*
|
|
4
|
+
* Free functions over a {@link GoEmitContext}, shared by the Input/Props struct
|
|
5
|
+
* generators and the nillable-field set so they can't drift.
|
|
6
|
+
*/
|
|
7
|
+
import type { ComponentIR, IRMetadata } from '@barefootjs/jsx';
|
|
8
|
+
import type { GoEmitContext } from '../emit-context.ts';
|
|
9
|
+
/**
|
|
10
|
+
* Build a map from prop name to a better Go type inferred from signals. When a
|
|
11
|
+
* signal is initialized from a prop (`createSignal(props.initial ?? 0)`), the
|
|
12
|
+
* signal's type annotation may be more specific than the prop's `TypeInfo`. Only
|
|
13
|
+
* generic prop types (containing `interface{}`) are overridden.
|
|
14
|
+
*/
|
|
15
|
+
export declare function buildPropTypeOverrides(ctx: GoEmitContext, ir: ComponentIR): Map<string, string>;
|
|
16
|
+
/**
|
|
17
|
+
* Resolve a prop param's Go struct-field type using the SAME logic
|
|
18
|
+
* `generatePropsStruct` / `generateInputStruct` use: a `propTypeOverrides` entry
|
|
19
|
+
* wins, otherwise `typeInfoToGo(param.type, param.defaultValue)`. Factored out so
|
|
20
|
+
* the nillable-field set (`collectNillablePropNames`) can't drift from the
|
|
21
|
+
* emitted field types.
|
|
22
|
+
*/
|
|
23
|
+
export declare function resolvePropGoType(ctx: GoEmitContext, param: IRMetadata['propsParams'][number], propTypeOverrides: Map<string, string>): string;
|
|
24
|
+
/**
|
|
25
|
+
* Build the set of prop NAMES whose resolved Go field type is exactly
|
|
26
|
+
* `interface{}` (nillable, for Hono-style attribute omission). Uses the same
|
|
27
|
+
* `propTypeOverrides` + `resolvePropGoType` pipeline as the struct generators.
|
|
28
|
+
* Concrete (`string`/`int`/`bool`/`[]T`/struct) types are excluded.
|
|
29
|
+
*/
|
|
30
|
+
export declare function collectNillablePropNames(ctx: GoEmitContext, ir: ComponentIR): Set<string>;
|
|
31
|
+
//# sourceMappingURL=prop-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prop-types.d.ts","sourceRoot":"","sources":["../../../src/adapter/props/prop-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAGvD;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,aAAa,EAAE,EAAE,EAAE,WAAW,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAoB/F;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,aAAa,EAClB,KAAK,EAAE,UAAU,CAAC,aAAa,CAAC,CAAC,MAAM,CAAC,EACxC,iBAAiB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GACrC,MAAM,CAeR;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,aAAa,EAAE,EAAE,EAAE,WAAW,GAAG,GAAG,CAAC,MAAM,CAAC,CASzF"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Spread-bag codegen: lower JSX `{...spread}` attributes to Go.
|
|
3
|
+
*
|
|
4
|
+
* Free functions over a {@link GoEmitContext}. Two entry points:
|
|
5
|
+
* - `collectSpreadSlots` walks the IR (stopping at loop bodies) to gather the
|
|
6
|
+
* `SpreadSlotInfo` entries plumbed onto the Input/Props structs.
|
|
7
|
+
* - `buildSpreadInitializer` builds the Go expression for a spread bag's
|
|
8
|
+
* initial value placed inside `NewXxxProps`: signal-getter object literals,
|
|
9
|
+
* destructured / SolidJS-style / rest props, and conditional inline-object
|
|
10
|
+
* spreads.
|
|
11
|
+
*/
|
|
12
|
+
import type { ComponentIR, IRNode, ParsedExpr } from '@barefootjs/jsx';
|
|
13
|
+
import type { GoEmitContext } from '../emit-context.ts';
|
|
14
|
+
import type { SpreadSlotInfo } from '../lib/types.ts';
|
|
15
|
+
/**
|
|
16
|
+
* Walk the IR (elements, fragments, conditionals, providers, async, components)
|
|
17
|
+
* but stop at loop bodies. Each `'spread'` attr value with a `slotId` becomes
|
|
18
|
+
* one `SpreadSlotInfo` entry.
|
|
19
|
+
*/
|
|
20
|
+
export declare function collectSpreadSlots(ctx: GoEmitContext, node: IRNode): SpreadSlotInfo[];
|
|
21
|
+
/**
|
|
22
|
+
* Build a Go expression for a JSX spread bag's initial value, placed inside
|
|
23
|
+
* `NewXxxProps`'s return literal.
|
|
24
|
+
*
|
|
25
|
+
* Supported shapes:
|
|
26
|
+
* - Signal-getter call (`attrs()`): emit the signal's object literal as a Go
|
|
27
|
+
* `map[string]any{...}`.
|
|
28
|
+
* - Bare identifier matching a destructured `propsParam`: emit `in.<Field>`.
|
|
29
|
+
* - Bare identifier matching `propsObjectName` (SolidJS-style `props`):
|
|
30
|
+
* enumerate `propsParams` into an inline `map[string]any{...}` (each Input
|
|
31
|
+
* field becomes a bag key).
|
|
32
|
+
* - Bare identifier matching `restPropsName` (destructured rest): emit
|
|
33
|
+
* `in.<Field>` against the `map[string]any` Input field added for
|
|
34
|
+
* `input-bag` slots; the caller populates the open-ended rest values.
|
|
35
|
+
*
|
|
36
|
+
* @returns `null` for unsupported shapes so the caller can raise a narrowed
|
|
37
|
+
* BF101 with the offending expression.
|
|
38
|
+
*/
|
|
39
|
+
export declare function buildSpreadInitializer(ctx: GoEmitContext, spreadExpr: string, ir: ComponentIR, parsed?: ParsedExpr): string | null;
|
|
40
|
+
//# 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;;;;;;;;;;GAUG;AAKH,OAAO,KAAK,EACV,WAAW,EACX,MAAM,EAQN,UAAU,EACX,MAAM,iBAAiB,CAAA;AAExB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAGrD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,GAAG,cAAc,EAAE,CAIrF;AAuID;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,sBAAsB,CACpC,GAAG,EAAE,aAAa,EAClB,UAAU,EAAE,MAAM,EAClB,EAAE,EAAE,WAAW,EACf,MAAM,CAAC,EAAE,UAAU,GAClB,MAAM,GAAG,IAAI,CA0Ef"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type codegen: render TypeScript types as Go type strings.
|
|
3
|
+
*
|
|
4
|
+
* Free functions over a {@link GoEmitContext}. They resolve a prop/signal/const's
|
|
5
|
+
* type (`TypeInfo`, a raw type string, or — as a last resort — an inferred shape
|
|
6
|
+
* from a literal value) into the Go type used for its struct field. They read
|
|
7
|
+
* only `state.localTypeNames`; `inferTypeFromValue` is fully pure.
|
|
8
|
+
*/
|
|
9
|
+
import type { TypeInfo } from '@barefootjs/jsx';
|
|
10
|
+
import type { GoEmitContext } from '../emit-context.ts';
|
|
11
|
+
/**
|
|
12
|
+
* Convert a `TypeInfo` to a Go type string.
|
|
13
|
+
*
|
|
14
|
+
* @param defaultValue used to infer the type when `typeInfo.kind` is `unknown`
|
|
15
|
+
* @returns the Go type, falling back to `interface{}` when unresolvable
|
|
16
|
+
*/
|
|
17
|
+
export declare function typeInfoToGo(ctx: GoEmitContext, typeInfo: TypeInfo, defaultValue?: string): string;
|
|
18
|
+
/**
|
|
19
|
+
* Convert a raw TypeScript type string to a Go type string. Handles primitives,
|
|
20
|
+
* `T[]` / `Array<T>` arrays, and known local types; else `interface{}`.
|
|
21
|
+
*/
|
|
22
|
+
export declare function tsTypeStringToGo(ctx: GoEmitContext, tsType: string): string;
|
|
23
|
+
/** Infer a Go type from a JS value literal; `interface{}` when unrecognized. */
|
|
24
|
+
export declare function inferTypeFromValue(value: string): string;
|
|
25
|
+
//# sourceMappingURL=type-codegen.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-codegen.d.ts","sourceRoot":"","sources":["../../../src/adapter/type/type-codegen.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAE/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAEvD;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,GAAG,EAAE,aAAa,EAClB,QAAQ,EAAE,QAAQ,EAClB,YAAY,CAAC,EAAE,MAAM,GACpB,MAAM,CAsCR;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAa3E;AAED,gFAAgF;AAChF,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAWxD"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lower a structured literal `ParsedExpr` (carried on the IR) to a Go literal,
|
|
3
|
+
* for baking a signal's inline initial value into the SSR data context.
|
|
4
|
+
*
|
|
5
|
+
* Covers scalar literals, a unary-minus number, arrays of those, and object
|
|
6
|
+
* literals baked against a concrete local struct.
|
|
7
|
+
*
|
|
8
|
+
* Contract is **null-means-defer**: returns null for anything not reproduced
|
|
9
|
+
* exactly — an object whose target type isn't a known struct, a key the struct
|
|
10
|
+
* doesn't declare, a nested object/array property value, an empty array, an
|
|
11
|
+
* identifier/call, or a numeric literal missing its `raw` token. The caller
|
|
12
|
+
* then keeps `nil`.
|
|
13
|
+
*/
|
|
14
|
+
import type { ParsedExpr, TypeInfo } from '@barefootjs/jsx';
|
|
15
|
+
import type { GoEmitContext } from '../emit-context.ts';
|
|
16
|
+
export declare function parsedLiteralToGo(ctx: GoEmitContext, expr: ParsedExpr, typeInfo?: TypeInfo): string | null;
|
|
17
|
+
//# sourceMappingURL=parsed-literal-to-go.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parsed-literal-to-go.d.ts","sourceRoot":"","sources":["../../../src/adapter/value/parsed-literal-to-go.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAE3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAGvD,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,aAAa,EAClB,IAAI,EAAE,UAAU,EAChB,QAAQ,CAAC,EAAE,QAAQ,GAClB,MAAM,GAAG,IAAI,CAsEf"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Value lowering: convert a JS signal/const initial value into a Go literal for
|
|
3
|
+
* the SSR data context — scalars, prop references, and fully-literal
|
|
4
|
+
* arrays/objects — falling back to `nil`/`0` for anything not reducible to a
|
|
5
|
+
* literal. Pure free functions over a {@link GoEmitContext}.
|
|
6
|
+
*/
|
|
7
|
+
import type { ParsedExpr, TypeInfo } from '@barefootjs/jsx';
|
|
8
|
+
import type { GoEmitContext } from '../emit-context.ts';
|
|
9
|
+
import type { PropFallbackVar } from '../lib/types.ts';
|
|
10
|
+
/**
|
|
11
|
+
* Lower a signal/const initial value to its Go SSR literal: a prop reference
|
|
12
|
+
* becomes `in.<Field>`, a non-literal falls back to the type's zero value.
|
|
13
|
+
*/
|
|
14
|
+
export declare function convertInitialValue(ctx: GoEmitContext, value: string, typeInfo: TypeInfo, propsParams?: {
|
|
15
|
+
name: string;
|
|
16
|
+
}[], preParsed?: ParsedExpr): string;
|
|
17
|
+
/**
|
|
18
|
+
* Lower a fully-literal value — from the analyzer's carried `ParsedExpr` tree —
|
|
19
|
+
* to a Go literal typed as `typeInfo`:
|
|
20
|
+
*
|
|
21
|
+
* `["x", "y"]` (string[]) → `[]string{"x", "y"}`
|
|
22
|
+
* `["x", "y"]` (unknown[]) → `[]interface{}{"x", "y"}`
|
|
23
|
+
* `[{ id: "a" }]` (Item[]) → `[]Item{Item{ID: "a"}}`
|
|
24
|
+
*
|
|
25
|
+
* Returns null (caller keeps `nil`) for a non-literal, or a shape that can't be
|
|
26
|
+
* expressed in the target type (e.g. an object in a `[]interface{}`, unreachable
|
|
27
|
+
* via the template's struct-field access).
|
|
28
|
+
*/
|
|
29
|
+
export declare function jsLiteralToGo(ctx: GoEmitContext, typeInfo: TypeInfo, preParsed?: ParsedExpr): string | null;
|
|
30
|
+
/**
|
|
31
|
+
* Bake a flat object literal (`{ align: 'start' }`) into a Go
|
|
32
|
+
* `map[string]interface{}` keyed by SOURCE property names, so it round-trips
|
|
33
|
+
* through `bf_json` like `JSON.stringify` (only the supplied keys, no zero-filled
|
|
34
|
+
* struct fields). Used for an inline object passed to a child's optional object
|
|
35
|
+
* prop. Returns null for a non-object / shorthand / nested / empty object.
|
|
36
|
+
*/
|
|
37
|
+
export declare function objectLiteralToGoMap(ctx: GoEmitContext, expr: ParsedExpr): string | null;
|
|
38
|
+
/**
|
|
39
|
+
* Get a signal's initial value as Go code — a literal, or a props reference
|
|
40
|
+
* (`in.<Field>`, or the hoisted fallback var when `props.X ?? N` has one).
|
|
41
|
+
* Unrecognized values default to `0`.
|
|
42
|
+
*/
|
|
43
|
+
export declare function getSignalInitialValueAsGo(ctx: GoEmitContext, initialValue: string, propsParams: {
|
|
44
|
+
name: string;
|
|
45
|
+
}[], propFallbackVars?: ReadonlyMap<string, PropFallbackVar>): string;
|
|
46
|
+
//# sourceMappingURL=value-lowering.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"value-lowering.d.ts","sourceRoot":"","sources":["../../../src/adapter/value/value-lowering.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAE3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAOtD;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,aAAa,EAClB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,QAAQ,EAClB,WAAW,CAAC,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,EAChC,SAAS,CAAC,EAAE,UAAU,GACrB,MAAM,CAgDR;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAC3B,GAAG,EAAE,aAAa,EAClB,QAAQ,EAAE,QAAQ,EAClB,SAAS,CAAC,EAAE,UAAU,GACrB,MAAM,GAAG,IAAI,CAMf;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,aAAa,EAAE,IAAI,EAAE,UAAU,GAAG,MAAM,GAAG,IAAI,CAWxF;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CACvC,GAAG,EAAE,aAAa,EAClB,YAAY,EAAE,MAAM,EACpB,WAAW,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,EAC/B,gBAAgB,GAAE,WAAW,CAAC,MAAM,EAAE,eAAe,CAA4B,GAChF,MAAM,CA8BR"}
|