@barefootjs/jsx 0.40.1 → 0.40.2
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/adapters/ambiguous-nil-arithmetic.d.ts +4 -3
- package/dist/adapters/ambiguous-nil-arithmetic.d.ts.map +1 -1
- package/dist/adapters/boolean-result.d.ts +32 -10
- package/dist/adapters/boolean-result.d.ts.map +1 -1
- package/dist/adapters/brace-delimiter-text.d.ts +18 -0
- package/dist/adapters/brace-delimiter-text.d.ts.map +1 -0
- package/dist/adapters/callback-method.d.ts +38 -5
- package/dist/adapters/callback-method.d.ts.map +1 -1
- package/dist/adapters/computed-const.d.ts +11 -1
- package/dist/adapters/computed-const.d.ts.map +1 -1
- package/dist/adapters/dsl-template-adapter.d.ts +21 -0
- package/dist/adapters/dsl-template-adapter.d.ts.map +1 -1
- package/dist/adapters/loop-bound-names.d.ts +9 -1
- package/dist/adapters/loop-bound-names.d.ts.map +1 -1
- package/dist/adapters/loop-row-type.d.ts +52 -0
- package/dist/adapters/loop-row-type.d.ts.map +1 -0
- package/dist/adapters/nil-reading.d.ts +68 -0
- package/dist/adapters/nil-reading.d.ts.map +1 -0
- package/dist/adapters/non-primitive-equality.d.ts +33 -0
- package/dist/adapters/non-primitive-equality.d.ts.map +1 -0
- package/dist/adapters/number-value.d.ts +5 -3
- package/dist/adapters/number-value.d.ts.map +1 -1
- package/dist/adapters/operand-typing.d.ts +126 -0
- package/dist/adapters/operand-typing.d.ts.map +1 -0
- package/dist/adapters/parsed-expr-emitter.d.ts +70 -12
- package/dist/adapters/parsed-expr-emitter.d.ts.map +1 -1
- package/dist/adapters/primitive-plan.d.ts +291 -0
- package/dist/adapters/primitive-plan.d.ts.map +1 -0
- package/dist/analyzer-context.d.ts +4 -0
- package/dist/analyzer-context.d.ts.map +1 -1
- package/dist/analyzer.d.ts.map +1 -1
- package/dist/augment-inherited-props.d.ts +63 -8
- package/dist/augment-inherited-props.d.ts.map +1 -1
- package/dist/compiler.d.ts.map +1 -1
- package/dist/event-handler-name.d.ts +12 -0
- package/dist/event-handler-name.d.ts.map +1 -1
- package/dist/expression-parser.d.ts +8 -0
- package/dist/expression-parser.d.ts.map +1 -1
- package/dist/index.d.ts +19 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4628 -2198
- package/dist/ir-to-client-js/build-references.d.ts.map +1 -1
- package/dist/ir-to-client-js/child-props-object.d.ts +64 -0
- package/dist/ir-to-client-js/child-props-object.d.ts.map +1 -0
- package/dist/ir-to-client-js/collect-elements.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/plan/build-inner-loop.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/plan/build-loop-child-arm.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/shared.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/stringify/claim-plan.d.ts +4 -2
- package/dist/ir-to-client-js/control-flow/stringify/claim-plan.d.ts.map +1 -1
- package/dist/ir-to-client-js/html-template.d.ts.map +1 -1
- package/dist/ir-to-client-js/imports.d.ts +2 -2
- package/dist/ir-to-client-js/imports.d.ts.map +1 -1
- package/dist/ir-to-client-js/index.d.ts +2 -6
- package/dist/ir-to-client-js/index.d.ts.map +1 -1
- package/dist/ir-to-client-js/plan/build-static-array-child-init.d.ts.map +1 -1
- package/dist/ir-to-client-js/plan/static-array-child-init.d.ts +30 -18
- package/dist/ir-to-client-js/plan/static-array-child-init.d.ts.map +1 -1
- package/dist/ir-to-client-js/prop-handling.d.ts.map +1 -1
- package/dist/ir-to-client-js/stringify/static-array-child-init.d.ts +3 -2
- package/dist/ir-to-client-js/stringify/static-array-child-init.d.ts.map +1 -1
- package/dist/jsx-to-ir.d.ts +1 -0
- package/dist/jsx-to-ir.d.ts.map +1 -1
- package/dist/nullable-signal-attr.d.ts +68 -9
- package/dist/nullable-signal-attr.d.ts.map +1 -1
- package/dist/prop-rewrite.d.ts +7 -0
- package/dist/prop-rewrite.d.ts.map +1 -1
- package/dist/props-object-whole-read.d.ts +15 -0
- package/dist/props-object-whole-read.d.ts.map +1 -0
- package/dist/rich-type-refusal.d.ts.map +1 -1
- package/dist/scope/binding-scope.d.ts +85 -10
- package/dist/scope/binding-scope.d.ts.map +1 -1
- package/dist/scope/lexical-scope-walk.d.ts +3 -2
- package/dist/scope/lexical-scope-walk.d.ts.map +1 -1
- package/dist/scope/root-prop-alias.d.ts +10 -7
- package/dist/scope/root-prop-alias.d.ts.map +1 -1
- package/dist/strip-types.d.ts +13 -0
- package/dist/strip-types.d.ts.map +1 -1
- package/dist/template-position-walk.d.ts +21 -3
- package/dist/template-position-walk.d.ts.map +1 -1
- package/dist/types.d.ts +90 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/__snapshots__/doc-examples.test.ts.snap +3 -3
- package/src/__tests__/binding-scope.test.ts +89 -1
- package/src/__tests__/body-destructure-props-object-alias.test.ts +123 -0
- package/src/__tests__/boolean-result.test.ts +22 -5
- package/src/__tests__/brace-delimiter-text.test.ts +26 -0
- package/src/__tests__/callback-method.test.ts +62 -2
- package/src/__tests__/child-components-in-map.test.ts +1 -1
- package/src/__tests__/computed-const.test.ts +103 -0
- package/src/__tests__/emit-to-string-call.test.ts +2 -1
- package/src/__tests__/hydration-payload-analysis.test.ts +166 -0
- package/src/__tests__/issue-2724-prop-alias-loop-not-static.test.ts +7 -7
- package/src/__tests__/issue-2754-rest-spread-needs-slot.test.ts +5 -2
- package/src/__tests__/issue-2798-static-nested-loop-bindings.test.ts +1 -1
- package/src/__tests__/issue-2835-props-type-member-name-collision.test.ts +4 -4
- package/src/__tests__/issue-3044-nested-prop-object-array-not-static.test.ts +1 -1
- package/src/__tests__/issue-3688-props-spread-child-csr.test.ts +2 -1
- package/src/__tests__/issue-3713-props-spread-loop-row.test.ts +65 -0
- package/src/__tests__/lookup-literal-const.test.ts +9 -3
- package/src/__tests__/loop-index-reactivity.test.ts +2 -2
- package/src/__tests__/loop-param-accessor-key-member-safety.test.ts +1 -1
- package/src/__tests__/loop-plan.test.ts +1 -1
- package/src/__tests__/loop-row-const-initializer-shadow.test.ts +146 -0
- package/src/__tests__/loop-row-type.test.ts +64 -0
- package/src/__tests__/lowering-value-position.test.ts +4 -0
- package/src/__tests__/module-const-destructure-default.test.ts +156 -0
- package/src/__tests__/nested-loop-index-param.test.ts +1 -1
- package/src/__tests__/nested-loop-reactive-attrs.test.ts +2 -2
- package/src/__tests__/nested-row-shadowing.test.ts +2 -2
- package/src/__tests__/nil-reading.test.ts +77 -0
- package/src/__tests__/nullable-signal-attr.test.ts +134 -0
- package/src/__tests__/primitive-plan.test.ts +416 -0
- package/src/__tests__/profile-loop-binding-ids.test.ts +2 -2
- package/src/__tests__/profile-nested-binding-ids.test.ts +2 -2
- package/src/__tests__/props-object-whole-read.test.ts +40 -0
- package/src/__tests__/reactive-attrs-in-map.test.ts +1 -1
- package/src/__tests__/reactive-factory-inlining.test.ts +4 -1
- package/src/__tests__/rest-binding-gaps.test.ts +192 -0
- package/src/__tests__/root-prop-alias.test.ts +53 -8
- package/src/__tests__/static-loop-csr-materialize.test.ts +2 -2
- package/src/__tests__/static-record-literal-array.test.ts +171 -0
- package/src/__tests__/string-concat-identifier.test.ts +40 -1
- package/src/adapters/ambiguous-nil-arithmetic.ts +22 -13
- package/src/adapters/boolean-result.ts +72 -66
- package/src/adapters/brace-delimiter-text.ts +25 -0
- package/src/adapters/callback-method.ts +151 -27
- package/src/adapters/computed-const.ts +238 -4
- package/src/adapters/dsl-template-adapter.ts +40 -2
- package/src/adapters/loop-bound-names.ts +9 -1
- package/src/adapters/loop-plan.ts +1 -1
- package/src/adapters/loop-row-type.ts +139 -0
- package/src/adapters/nil-reading.ts +297 -0
- package/src/adapters/non-primitive-equality.ts +92 -0
- package/src/adapters/number-value.ts +17 -4
- package/src/adapters/operand-typing.ts +522 -0
- package/src/adapters/parsed-expr-emitter.ts +154 -19
- package/src/adapters/primitive-plan.ts +696 -0
- package/src/analyzer-context.ts +6 -0
- package/src/analyzer.ts +505 -19
- package/src/augment-inherited-props.ts +108 -10
- package/src/compiler.ts +17 -0
- package/src/event-handler-name.ts +15 -0
- package/src/expression-parser.ts +70 -1
- package/src/index.ts +33 -7
- package/src/ir-to-client-js/build-references.ts +69 -0
- package/src/ir-to-client-js/child-props-object.ts +106 -0
- package/src/ir-to-client-js/collect-elements.ts +30 -55
- package/src/ir-to-client-js/control-flow/plan/build-inner-loop.ts +6 -1
- package/src/ir-to-client-js/control-flow/plan/build-loop-child-arm.ts +29 -28
- package/src/ir-to-client-js/control-flow/shared.ts +20 -22
- package/src/ir-to-client-js/control-flow/stringify/claim-plan.ts +5 -3
- package/src/ir-to-client-js/control-flow/stringify/inner-loop.ts +2 -2
- package/src/ir-to-client-js/control-flow/stringify/lazy-row.ts +1 -1
- package/src/ir-to-client-js/control-flow/stringify/loop-child-arm.ts +2 -2
- package/src/ir-to-client-js/control-flow/stringify/loop.ts +1 -1
- package/src/ir-to-client-js/control-flow/stringify/reactive-effects.ts +3 -3
- package/src/ir-to-client-js/html-template.ts +25 -8
- package/src/ir-to-client-js/imports.ts +1 -1
- package/src/ir-to-client-js/index.ts +53 -11
- package/src/ir-to-client-js/plan/build-static-array-child-init.ts +31 -14
- package/src/ir-to-client-js/plan/static-array-child-init.ts +27 -18
- package/src/ir-to-client-js/prop-handling.ts +22 -3
- package/src/ir-to-client-js/stringify/static-array-child-init.ts +26 -10
- package/src/jsx-to-ir.ts +446 -37
- package/src/nullable-signal-attr.ts +246 -29
- package/src/prop-rewrite.ts +30 -6
- package/src/props-object-whole-read.ts +87 -0
- package/src/rich-type-refusal.ts +2 -1
- package/src/scope/binding-scope.ts +182 -18
- package/src/scope/lexical-scope-walk.ts +4 -3
- package/src/scope/root-prop-alias.ts +15 -8
- package/src/strip-types.ts +31 -3
- package/src/template-position-walk.ts +57 -28
- package/src/types.ts +87 -0
|
@@ -17,9 +17,10 @@ export interface AmbiguousNilArithmeticSink {
|
|
|
17
17
|
* optional and nullable (`n?: number | null`, `arithmeticOperandNilIsAmbiguous`).
|
|
18
18
|
* JS reads that prop as `undefined` when omitted (`NaN` in arithmetic) and
|
|
19
19
|
* as `0` when `null`; the engine holds both as one nil, so any spelling
|
|
20
|
-
* renders one of them wrong.
|
|
21
|
-
*
|
|
22
|
-
* operand
|
|
20
|
+
* renders one of them wrong. Under a comparison the same holds for a string
|
|
21
|
+
* or boolean prop declared `?: string | null` / `?: boolean | null` (#3824
|
|
22
|
+
* step 3). Asked at the emission site so the operand is classified in the
|
|
23
|
+
* scope it is read in (`isShadowed`). One error per operand text per compile.
|
|
23
24
|
*/
|
|
24
25
|
export declare function arithmeticCoercionOrRefuse(op: string, operand: ParsedExpr, other: ParsedExpr | undefined, ctx: NullishAttrContext, isShadowed: (name: string) => boolean, sink: AmbiguousNilArithmeticSink): ArithmeticCoercion;
|
|
25
26
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ambiguous-nil-arithmetic.d.ts","sourceRoot":"","sources":["../../src/adapters/ambiguous-nil-arithmetic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACvE,OAAO,
|
|
1
|
+
{"version":3,"file":"ambiguous-nil-arithmetic.d.ts","sourceRoot":"","sources":["../../src/adapters/ambiguous-nil-arithmetic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACvE,OAAO,EAKL,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACxB,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AACxD,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAE1D;;;GAGG;AACH,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,MAAM,EAAE,aAAa,EAAE,CAAA;IAChC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;CAC/B;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,0BAA0B,CACxC,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,UAAU,EACnB,KAAK,EAAE,UAAU,GAAG,SAAS,EAC7B,GAAG,EAAE,kBAAkB,EACvB,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,EACrC,IAAI,EAAE,0BAA0B,GAC/B,kBAAkB,CAIpB;AAED;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,UAAU,EAChB,GAAG,EAAE,kBAAkB,EACvB,KAAK,EAAE,YAAY,EACnB,IAAI,EAAE,0BAA0B,GAC/B,IAAI,CAIN;AAED;;;;;;GAMG;AACH,wBAAgB,gCAAgC,CAC9C,KAAK,EAAE,SAAS,QAAQ,EAAE,EAC1B,GAAG,EAAE,kBAAkB,EACvB,IAAI,EAAE,0BAA0B,GAC/B,IAAI,CAIN"}
|
|
@@ -39,6 +39,8 @@
|
|
|
39
39
|
*/
|
|
40
40
|
import { type ParsedExpr } from '../expression-parser.ts';
|
|
41
41
|
import type { IRMetadata } from '../types.ts';
|
|
42
|
+
import { type NativeSafeTable, type PrimitivePlan } from './primitive-plan.ts';
|
|
43
|
+
import { type ScopedOperandTyping } from './operand-typing.ts';
|
|
42
44
|
/**
|
|
43
45
|
* Whether `node` evaluates to a JS boolean: structurally, or, when the
|
|
44
46
|
* caller passes `isBooleanName`, through a leaf declared `boolean` — a
|
|
@@ -49,17 +51,29 @@ import type { IRMetadata } from '../types.ts';
|
|
|
49
51
|
*/
|
|
50
52
|
export declare function isBooleanResultParsed(node: ParsedExpr, isBooleanName?: (name: string, componentProperty?: boolean) => boolean): boolean;
|
|
51
53
|
/**
|
|
52
|
-
* Rewrites the boolean-result
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
* `
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
54
|
+
* Rewrites the boolean-result values a mixed expression can evaluate to, so
|
|
55
|
+
* a taken boolean carries JS `String(boolean)` instead of Perl's `0` / `''`
|
|
56
|
+
* / `1`. The whole value isn't boolean-shaped, so `bool_str` can't wrap it.
|
|
57
|
+
*
|
|
58
|
+
* - A ternary branch (`yes() ? false : s()`, #3349): a literal `true` /
|
|
59
|
+
* `false` becomes the string literal `'true'` / `'false'`, any other
|
|
60
|
+
* boolean-result branch `b` becomes `b ? 'true' : 'false'`.
|
|
61
|
+
* - An operand JS `&&` / `||` / `??` returns (`n > 0 && 'y'`): the left
|
|
62
|
+
* operand is returned only when it decides the result, so its rewritten
|
|
63
|
+
* form `l'` (the operand stringified, a nested chain or a ternary
|
|
64
|
+
* rewritten likewise) is what the expression yields then, while the
|
|
65
|
+
* original operand stays the test: `l && r` becomes `l ? r : l'` and
|
|
66
|
+
* `l || r` becomes `l ? l' : r`. `l ?? r` becomes `l' ?? r`, since the
|
|
67
|
+
* rewrite keeps nullishness. A boolean-result `l` gives `b ? r :
|
|
68
|
+
* 'false'` and `b ? 'true' : r`. The right operand is rewritten as a
|
|
69
|
+
* branch.
|
|
70
|
+
*
|
|
71
|
+
* The existing lowering then renders the rewritten tree unchanged. Nested
|
|
72
|
+
* values are rewritten recursively; a tree with nothing to rewrite is
|
|
73
|
+
* returned as is (the same object). Only an output position may take the
|
|
74
|
+
* rewrite: a `'false'` string is truthy.
|
|
61
75
|
*/
|
|
62
|
-
export declare function
|
|
76
|
+
export declare function stringifyBooleanBranches(node: ParsedExpr): ParsedExpr;
|
|
63
77
|
/**
|
|
64
78
|
* Names whose value is always a JS boolean, for {@link isBooleanResultParsed}'s
|
|
65
79
|
* `isBooleanName` (#3443):
|
|
@@ -89,6 +103,14 @@ export declare function collectBooleanValueNames(metadata: Pick<IRMetadata, 'sig
|
|
|
89
103
|
* unparseable expression is not boolean-result.
|
|
90
104
|
*/
|
|
91
105
|
export declare function isBooleanResultExpr(expr: string): boolean;
|
|
106
|
+
/**
|
|
107
|
+
* The ToBoolean plan (`planTest`, #3824) of a test whose `ParsedExpr` the IR
|
|
108
|
+
* does not carry: a template literal's ternary part, which holds only its
|
|
109
|
+
* condition text. It reads the same tree {@link isBooleanResultExpr} always
|
|
110
|
+
* parsed for such a test. A test the IR carries a tree for is planned with
|
|
111
|
+
* `planTest` on that tree.
|
|
112
|
+
*/
|
|
113
|
+
export declare function planTestOfSource(expr: string, typing: ScopedOperandTyping, target: NativeSafeTable): PrimitivePlan | null;
|
|
92
114
|
/**
|
|
93
115
|
* True when `expr`'s top-level shape is an explicit one-argument JS
|
|
94
116
|
* `String(x)` call (the `EVAL_BUILTIN_IDENTS` builtin the compiler
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boolean-result.d.ts","sourceRoot":"","sources":["../../src/adapters/boolean-result.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAEH,OAAO,EAAmB,KAAK,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAC1E,OAAO,KAAK,EAAE,UAAU,EAAY,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"boolean-result.d.ts","sourceRoot":"","sources":["../../src/adapters/boolean-result.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAEH,OAAO,EAAmB,KAAK,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAC1E,OAAO,KAAK,EAAE,UAAU,EAAY,MAAM,aAAa,CAAA;AACvD,OAAO,EAA0B,KAAK,eAAe,EAAE,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACtG,OAAO,EAAiC,KAAK,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAE7F;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,UAAU,EAChB,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,iBAAiB,CAAC,EAAE,OAAO,KAAK,OAAO,GACrE,OAAO,CAKT;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CAqBrE;AAaD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,IAAI,CAAC,UAAU,EAAE,SAAS,GAAG,OAAO,GAAG,aAAa,GAAG,gBAAgB,GAAG,iBAAiB,CAAC,GACrG;IAAE,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAAC,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;CAAE,CAqD5C;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAIzD;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,EAAE,eAAe,GAAG,aAAa,GAAG,IAAI,CAGzH;AAOD;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAS1D;AA0CD,2DAA2D;AAC3D,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEvD"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Static text in a template engine whose tags open with a brace — Jinja,
|
|
3
|
+
* MiniJinja, Twig and Pebble (`{{`, `{%`, `{#`), Go `html/template` (`{{`)
|
|
4
|
+
* — must never put a tag opener into the template: JSX text such as
|
|
5
|
+
* `{{ 1 }}` decodes to `{{ 1 }}`, which Hono prints as
|
|
6
|
+
* written but such an engine compiles as a tag, and so prints `1` or fails
|
|
7
|
+
* to parse.
|
|
8
|
+
*
|
|
9
|
+
* Every `{` that is followed by one of `followers` (the characters that turn
|
|
10
|
+
* a `{` into a tag opener on this engine) is emitted through `literal`
|
|
11
|
+
* instead — an output expression for the brace itself (`{{ '{' }}`,
|
|
12
|
+
* `{{"{"}}`). So is a `{` that ends the text: the text cannot know what the
|
|
13
|
+
* adapter writes after it, and a following output tag (`{{ x }}`) would turn
|
|
14
|
+
* that brace into part of a longer opener. The expression renders the same
|
|
15
|
+
* character either way.
|
|
16
|
+
*/
|
|
17
|
+
export declare function escapeBraceDelimiters(text: string, followers: string, literal: string): string;
|
|
18
|
+
//# sourceMappingURL=brace-delimiter-text.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brace-delimiter-text.d.ts","sourceRoot":"","sources":["../../src/adapters/brace-delimiter-text.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAQ9F"}
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
* support gate refuses it (`unboundCallbackParamRead`), because no DSL
|
|
16
16
|
* runtime binds those.
|
|
17
17
|
*/
|
|
18
|
+
import type { ScopedOperandTyping } from './operand-typing.ts';
|
|
18
19
|
import { type ParsedExpr, type SortComparator } from '../expression-parser.ts';
|
|
19
20
|
type Arrow = Extract<ParsedExpr, {
|
|
20
21
|
kind: 'arrow';
|
|
@@ -48,8 +49,37 @@ export interface CallbackEvalPlan {
|
|
|
48
49
|
kind: 'eval';
|
|
49
50
|
helper: CallbackEvalHelper;
|
|
50
51
|
operands: CallbackEvalOperand[];
|
|
51
|
-
captured:
|
|
52
|
+
captured: CallbackCapture[];
|
|
52
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* A free name of an evaluator body and the expression whose SSR value the
|
|
56
|
+
* env binds it to: the name itself, or, for a lifted `props.X` read (see
|
|
57
|
+
* {@link evalBody}), that read.
|
|
58
|
+
*/
|
|
59
|
+
export interface CallbackCapture {
|
|
60
|
+
name: string;
|
|
61
|
+
value: ParsedExpr;
|
|
62
|
+
}
|
|
63
|
+
/** A callback body the runtime evaluator can run: its JSON and its env. */
|
|
64
|
+
export interface EvalBody {
|
|
65
|
+
json: string;
|
|
66
|
+
captured: CallbackCapture[];
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Serialize a callback body for the runtime evaluator, with the captures its
|
|
70
|
+
* env needs; `null` when the body is outside the evaluator surface. `bound`
|
|
71
|
+
* are the callback's own params. `propsObject` is the component's props
|
|
72
|
+
* object identifier (`BindingScope.propsObject` / `propsObjectIdentifier`):
|
|
73
|
+
* `props`, or the props parameter's own name (`function C(p)`).
|
|
74
|
+
*
|
|
75
|
+
* A template has no props object: the props are its top-level variables,
|
|
76
|
+
* and the adapters spell `props.X` as the variable `X`. So each `props.X` the
|
|
77
|
+
* body reads, where no param binds `props`, becomes a fresh env name bound to
|
|
78
|
+
* the read itself, which the adapter spells as it spells `props.X` anywhere
|
|
79
|
+
* else. Capturing `props` whole would bind it to an undefined template
|
|
80
|
+
* variable, and the predicate would read every `props.X` as `undefined`.
|
|
81
|
+
*/
|
|
82
|
+
export declare function evalBody(body: ParsedExpr, bound: ReadonlySet<string>, propsObject: string, typing?: ScopedOperandTyping): EvalBody | null;
|
|
53
83
|
/**
|
|
54
84
|
* A lowered `.sort` / `.toSorted` comparator: the evaluator call, the
|
|
55
85
|
* structured `{keys: …}` descriptor for a comparator the evaluator cannot
|
|
@@ -89,21 +119,24 @@ export interface CallbackLoweringOptions {
|
|
|
89
119
|
*/
|
|
90
120
|
nativePredicate?: boolean;
|
|
91
121
|
}
|
|
92
|
-
/**
|
|
93
|
-
|
|
122
|
+
/**
|
|
123
|
+
* Lower `<recv>.<method>(arrow, ...restArgs)`. `propsObject`: the
|
|
124
|
+
* component's props object identifier (see {@link evalBody}).
|
|
125
|
+
*/
|
|
126
|
+
export declare function lowerCallbackMethod(method: string, arrow: Arrow, restArgs: readonly ParsedExpr[], options: CallbackLoweringOptions, propsObject: string): CallbackPlan;
|
|
94
127
|
/**
|
|
95
128
|
* Lower a `.sort` / `.toSorted` comparator: the evaluator first, then the
|
|
96
129
|
* structured `{keys: …}` descriptor, otherwise BF101. A loop source's sort
|
|
97
130
|
* (`planLoop`) and `.sort(cmp)` at an expression position decide the same.
|
|
98
131
|
*/
|
|
99
|
-
export declare function lowerSortComparator(method: 'sort' | 'toSorted', arrow: Arrow, adapterName: string): SortPlan;
|
|
132
|
+
export declare function lowerSortComparator(method: 'sort' | 'toSorted', arrow: Arrow, adapterName: string, propsObject: string): SortPlan;
|
|
100
133
|
/**
|
|
101
134
|
* The evaluator plan for a sort comparator, or `null` when the body is
|
|
102
135
|
* outside the evaluator surface (a `localeCompare` comparator) or the arrow
|
|
103
136
|
* has fewer than the two params a comparator needs. The loop-source sort
|
|
104
137
|
* shares this with `.sort(cmp)` at an expression position.
|
|
105
138
|
*/
|
|
106
|
-
export declare function sortEvalPlan(body: ParsedExpr, params: readonly string[]): CallbackEvalPlan | null;
|
|
139
|
+
export declare function sortEvalPlan(body: ParsedExpr, params: readonly string[], propsObject: string): CallbackEvalPlan | null;
|
|
107
140
|
/** The BF101 for a comparator neither the evaluator nor the descriptor can model. */
|
|
108
141
|
export declare function sortRefusal(method: string, adapterName: string): {
|
|
109
142
|
kind: 'refuse';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"callback-method.d.ts","sourceRoot":"","sources":["../../src/adapters/callback-method.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;
|
|
1
|
+
{"version":3,"file":"callback-method.d.ts","sourceRoot":"","sources":["../../src/adapters/callback-method.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAC9D,OAAO,EAOL,KAAK,UAAU,EACf,KAAK,cAAc,EACpB,MAAM,yBAAyB,CAAA;AAEhC,KAAK,KAAK,GAAG,OAAO,CAAC,UAAU,EAAE;IAAE,I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A;CAAE,CAQzC;AAED;;;;;;;GAOG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAKvH;AAED,4EAA4E;AAC5E,wBAAgB,6BAA6B,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAKvH;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAKlH"}
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* shadow the name are respected.
|
|
16
16
|
*/
|
|
17
17
|
import { type ParsedExpr } from '../expression-parser.ts';
|
|
18
|
-
import type { ExpressionAttr, IRMetadata } from '../types.ts';
|
|
18
|
+
import type { ExpressionAttr, IRMetadata, ParamInfo } from '../types.ts';
|
|
19
19
|
export interface ComputedConstContext {
|
|
20
20
|
constants: IRMetadata['localConstants'] | undefined;
|
|
21
21
|
/** Signal getters and memo names: the zero-arg calls a template reads as values. */
|
|
@@ -41,6 +41,11 @@ export interface ComputedConstContext {
|
|
|
41
41
|
* (`function C(props: { label: string })`) binds no name.
|
|
42
42
|
*/
|
|
43
43
|
componentNames: ReadonlySet<string>;
|
|
44
|
+
/** The component's props params and props object name, which type an index read (`keyedValue`). */
|
|
45
|
+
props: {
|
|
46
|
+
params: readonly ParamInfo[];
|
|
47
|
+
objectName: string | null;
|
|
48
|
+
};
|
|
44
49
|
/** Whether a loop row or callback binds `name` where the expression is read. */
|
|
45
50
|
isShadowed(name: string): boolean;
|
|
46
51
|
/** Whether the adapter binds the const `name` itself, so a read of it stays as written. */
|
|
@@ -54,6 +59,11 @@ export interface ComputedConstContext {
|
|
|
54
59
|
}
|
|
55
60
|
/** The {@link ComputedConstContext} fields that come from the component's metadata. */
|
|
56
61
|
export declare function computedConstContext(metadata: IRMetadata, isShadowed: (name: string) => boolean, isAdapterBound?: (name: string) => boolean): ComputedConstContext;
|
|
62
|
+
/**
|
|
63
|
+
* {@link ComputedConstContext.componentNames}. Not `componentBindings`, which
|
|
64
|
+
* also lists every typed prop of a props object as a `prop` binding.
|
|
65
|
+
*/
|
|
66
|
+
export declare function componentScopeNames(metadata: Pick<IRMetadata, 'propsObjectName' | 'propsParams' | 'restPropsName' | 'localConstants' | 'localFunctions' | 'signals' | 'memos'>): Set<string>;
|
|
57
67
|
/**
|
|
58
68
|
* `expr` with each read of a computed const replaced by its initializer,
|
|
59
69
|
* repeated so a const read inside an initializer is replaced too.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computed-const.d.ts","sourceRoot":"","sources":["../../src/adapters/computed-const.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,
|
|
1
|
+
{"version":3,"file":"computed-const.d.ts","sourceRoot":"","sources":["../../src/adapters/computed-const.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAuF,KAAK,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAC9I,OAAO,KAAK,EAAgB,cAAc,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAItF,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,UAAU,CAAC,gBAAgB,CAAC,GAAG,SAAS,CAAA;IACnD,oFAAoF;IACpF,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;IAC5B,oGAAoG;IACpG,gBAAgB,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;IACrC,iFAAiF;IACjF,aAAa,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;IAClC;;;;;OAKG;IACH,SAAS,EAAE,WAAW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r } from '../expression-parser.ts';
|
|
9
9
|
import { type ArithmeticCoercion, type NullishAttrContext } from '../nullable-signal-attr.ts';
|
|
10
10
|
import { BindingScope } from '../scope/binding-scope.ts';
|
|
11
|
+
import { type DeclaredValueTypes } from './loop-row-type.ts';
|
|
12
|
+
import { type OperandTyping, type ScopedOperandTyping } from './operand-typing.ts';
|
|
11
13
|
import type { CompilerError, ComponentIR, ConstantInfo, IRIfStatement, IRLoop, IRMetadata, PreambleValueDeclaration } from '../types.ts';
|
|
12
14
|
import { type ComputedConstContext } from './computed-const.ts';
|
|
13
15
|
import { BaseAdapter, type AdapterGenerateOptions, type AdapterOutput } from './interface.ts';
|
|
@@ -94,6 +96,14 @@ export declare abstract class DslTemplateAdapter extends BaseAdapter {
|
|
|
94
96
|
protected booleanTypedProps: Set<string>;
|
|
95
97
|
/** Names (signal getters + props) whose value is a string (`stringValueNamesFor`). */
|
|
96
98
|
protected stringValueNames: Set<string>;
|
|
99
|
+
/** The declared types a loop row's type is read from (`loopRowType`, #3762). */
|
|
100
|
+
protected declaredTypes: DeclaredValueTypes | null;
|
|
101
|
+
/**
|
|
102
|
+
* The component's operand typing (`collectOperandTyping`), which the
|
|
103
|
+
* emitters' primitive plans read through the scope at the emission site
|
|
104
|
+
* (`operandTypingAt`, #3824).
|
|
105
|
+
*/
|
|
106
|
+
protected operandTyping: OperandTyping;
|
|
97
107
|
/**
|
|
98
108
|
* Module-scope pure-string consts (`const x = 'literal'`), keyed by name →
|
|
99
109
|
* unescaped value. A className template literal that references such a
|
|
@@ -181,6 +191,17 @@ export declare abstract class DslTemplateAdapter extends BaseAdapter {
|
|
|
181
191
|
* above and before any diagnostic or rendering.
|
|
182
192
|
*/
|
|
183
193
|
protected resetAdapterState(_ir: ComponentIR): void;
|
|
194
|
+
/**
|
|
195
|
+
* Whether `name` (a signal getter, prop, local constant or loop binding)
|
|
196
|
+
* holds a string value at `scope`, which picks the template's string
|
|
197
|
+
* concatenation for a JS `+` (`isStringConcatBinary`). A loop row or
|
|
198
|
+
* callback binding of the same name shadows the outer typing; a row field
|
|
199
|
+
* read (`path`: `row.id`) takes the row type's declared field type.
|
|
200
|
+
* `componentProperty`: read as `props.<name>`.
|
|
201
|
+
*/
|
|
202
|
+
protected isStringValueNameAt(name: string, componentProperty?: boolean, path?: readonly string[], scope?: BindingScope): boolean;
|
|
203
|
+
/** The component's operand typing at `scope` (the emission site's, by default). */
|
|
204
|
+
protected operandTypingAt(scope?: BindingScope): ScopedOperandTyping;
|
|
184
205
|
/** `render()` under `scope`, the current scope restored afterwards. */
|
|
185
206
|
protected renderInScope<T>(scope: BindingScope, render: () => T): T;
|
|
186
207
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dsl-template-adapter.d.ts","sourceRoot":"","sources":["../../src/adapters/dsl-template-adapter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAA2B,KAAK,eAAe,EAAE,MAAM,yBAAyB,CAAA;AACvF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACzD,OAAO,EAGL,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACxB,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;
|
|
1
|
+
{"version":3,"file":"dsl-template-adapter.d.ts","sourceRoot":"","sources":["../../src/adapters/dsl-template-adapter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAA2B,KAAK,eAAe,EAAE,MAAM,yBAAyB,CAAA;AACvF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACzD,OAAO,EAGL,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACxB,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AACxD,OAAO,EAAmC,KAAK,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AAC7F,OAAO,EAA8C,K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C,2BAA2B,CAC5C,EAAE,EAAE,WAAW,EACf,cAAc,CAAC,EAAE,MAAM,EACvB,YAAY,CAAC,EAAE,MAAM,EAAE,EACvB,aAAa,CAAC,EAAE,MAAM,EAAE,GACvB,MAAM,CAAA;IACT;;;;OAIG;IACH,SAAS,CAAC,QAAQ,CAAC,mBAAmB,CAAC,EAAE,EAAE,WAAW,GAAG,MAAM,CAAA;IAC/D;;;;;OAKG;IACH,SAAS,CAAC,QAAQ,CAAC,eAAe,CAAC,EAAE,EAAE,WAAW,GAAG,MAAM,CAAA;IAE3D,QAAQ,CAAC,EAAE,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,sBAAsB,GAAG,aAAa,CA4BzE;IAED,OAAO,CAAC,iBAAiB;IAgCzB,OAAO,CAAC,oBAAoB;CAmB7B"}
|
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Every name a `.map()`/`.filter()` loop callback binds as its item or
|
|
3
3
|
* index parameter, anywhere in a component's IR tree (#2212 review
|
|
4
|
-
* finding).
|
|
4
|
+
* finding).
|
|
5
|
+
*
|
|
6
|
+
* The string-typing use described below is retired: every template adapter
|
|
7
|
+
* now resolves a name's string typing at the read through the shared
|
|
8
|
+
* `BindingScope` (#3762), and no longer subtracts this set. The remaining
|
|
9
|
+
* callers use it as a whole-component "may be shadowed somewhere" set
|
|
10
|
+
* (root prop aliases, Go's static loop sources, Xslate's memo seeds).
|
|
11
|
+
*
|
|
12
|
+
* Original rationale: `isStringTypedOperand`'s identifier arm resolves a bare
|
|
5
13
|
* identifier against `collectStringValueNames`'s flat, scope-BLIND
|
|
6
14
|
* `Set<string>` — so a loop callback whose param happens to reuse a
|
|
7
15
|
* string prop's name (`items.map((name) => ... 1 + name ...)`, where the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loop-bound-names.d.ts","sourceRoot":"","sources":["../../src/adapters/loop-bound-names.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"loop-bound-names.d.ts","sourceRoot":"","sources":["../../src/adapters/loop-bound-names.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAU,MAAM,aAAa,CAAA;AAEtD,wBAAgB,qBAAqB,CAAC,EAAE,EAAE,WAAW,GAAG,GAAG,CAAC,MAAM,CAAC,CAmElE"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The declared element type of the array a loop ranges over, read from the
|
|
3
|
+
* component's IR: a prop (`props.rows`, a destructured `rows`), a signal or
|
|
4
|
+
* memo getter (`items()`), a row field of an enclosing loop (`r.tags`), an
|
|
5
|
+
* index into one of those, and a `filter` / `slice` / `sort` chain over them.
|
|
6
|
+
* A template adapter enters a loop row with it as
|
|
7
|
+
* `LoopBindingSource.rowType`, so the row's bindings resolve their field types
|
|
8
|
+
* at the read (`row.id`, a destructured `id`) through the shared
|
|
9
|
+
* `BindingScope` (#3762). The IR's `itemType` carries scalar evidence only.
|
|
10
|
+
*/
|
|
11
|
+
import type { ParsedExpr } from '../expression-parser.ts';
|
|
12
|
+
import type { ComponentIR, TypeInfo } from '../types.ts';
|
|
13
|
+
import { type BindingScope, type LoopValueType, type NamedTypeFields } from '../scope/binding-scope.ts';
|
|
14
|
+
/** What a component declares about the types of the values it reads. */
|
|
15
|
+
export interface DeclaredValueTypes {
|
|
16
|
+
readonly propsParams: readonly {
|
|
17
|
+
readonly name: string;
|
|
18
|
+
readonly type: TypeInfo;
|
|
19
|
+
readonly declaredType?: TypeInfo;
|
|
20
|
+
readonly isRest?: boolean;
|
|
21
|
+
}[];
|
|
22
|
+
readonly signals: readonly {
|
|
23
|
+
readonly getter: string;
|
|
24
|
+
readonly type: TypeInfo;
|
|
25
|
+
}[];
|
|
26
|
+
readonly memos: readonly {
|
|
27
|
+
readonly name: string;
|
|
28
|
+
readonly type: TypeInfo;
|
|
29
|
+
}[];
|
|
30
|
+
/** The identifier the component reads its props object as (`props`); null for a destructured signature. */
|
|
31
|
+
readonly propsObjectName: string | null;
|
|
32
|
+
readonly namedFields: NamedTypeFields;
|
|
33
|
+
}
|
|
34
|
+
/** {@link DeclaredValueTypes} of a component. */
|
|
35
|
+
export declare function declaredValueTypes(ir: ComponentIR): DeclaredValueTypes;
|
|
36
|
+
/** The element type of the array `loop` ranges over; null when it is not declared. */
|
|
37
|
+
export declare function loopRowType(types: DeclaredValueTypes, loop: {
|
|
38
|
+
readonly arrayParsed?: ParsedExpr;
|
|
39
|
+
readonly iterationShape?: string;
|
|
40
|
+
readonly objectIteration?: unknown;
|
|
41
|
+
}, scope: BindingScope): LoopValueType | null;
|
|
42
|
+
/**
|
|
43
|
+
* The type of `receiver.concat(...args)`: an array whose element type is the
|
|
44
|
+
* union of the receiver's element type and each argument's (an array
|
|
45
|
+
* argument's elements, or the argument itself). A field read on a row of it
|
|
46
|
+
* is then a definite string only when it is one in every member
|
|
47
|
+
* (`loopValueTypeAt`), so an `any[]` argument or a field one member lacks
|
|
48
|
+
* types nothing (#3762 review). An argument of unknown type leaves the
|
|
49
|
+
* result with no element type.
|
|
50
|
+
*/
|
|
51
|
+
export declare function concatType<T extends LoopValueType>(receiver: T | null, args: readonly (T | null)[]): T | null;
|
|
52
|
+
//# sourceMappingURL=loop-row-type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loop-row-type.d.ts","sourceRoot":"","sources":["../../src/adapters/loop-row-type.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACxD,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,eAAe,EACrB,MAAM,2BAA2B,CAAA;AAUlC,wEAAwE;AACxE,MA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}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The nil-reading rewrite (`spec/js-primitive-semantics.md`, "Nil reading is
|
|
3
|
+
* a tree rewrite"; #3824 step 4a in `spec/js-undefined-value.md`).
|
|
4
|
+
*
|
|
5
|
+
* Every runtime holds JS `null` and `undefined` as one nil, and its
|
|
6
|
+
* primitive helpers (`to_number`, `to_string`, `plus`, the relational ones)
|
|
7
|
+
* read that nil as `null`. Where Phase-1 types say which value a nil stands
|
|
8
|
+
* for, and the consumer's coercion is known statically, the operand is
|
|
9
|
+
* rewritten before planning so that it is never nil:
|
|
10
|
+
*
|
|
11
|
+
* | Consumer | nil reads as `null` | nil reads as `undefined` |
|
|
12
|
+
* | --- | --- | --- |
|
|
13
|
+
* | numeric (`- * / %`, unary `-` / `+`, relational, numeric `+`) | `x ?? 0` | `x ?? NaN` |
|
|
14
|
+
* | string (`+` concatenation, template-literal part) | `x ?? 'null'` | `x ?? 'undefined'` |
|
|
15
|
+
*
|
|
16
|
+
* After the rewrite the operand is non-nil, so the plan can name the native
|
|
17
|
+
* operator (`(n ?? NaN) * 2` stays native) and the helpers never need to
|
|
18
|
+
* know about `undefined`.
|
|
19
|
+
*
|
|
20
|
+
* A `+` whose present branch concatenates and whose nil branch adds
|
|
21
|
+
* (`o.id + 1` with `id?: string`) is split on nil by the numeric row:
|
|
22
|
+
* `(o.id ?? NaN) + 1` is `NaN` for an omitted field and `'o1'` for a present
|
|
23
|
+
* one, because the operand is then a string or a number and the plan takes
|
|
24
|
+
* the runtime's `plus`, which decides per value. With a `null` reading the
|
|
25
|
+
* nil branch is `0 + 1`, as JS's `null + 1`.
|
|
26
|
+
*
|
|
27
|
+
* What the rewrite leaves alone (`spec/js-undefined-value.md` §7 (4)):
|
|
28
|
+
*
|
|
29
|
+
* - A numeric operand whose nil may be either (`n?: number | null`): the
|
|
30
|
+
* template adapters refuse it with BF101 (#3700) where the coercion is
|
|
31
|
+
* static, and keep today's output elsewhere.
|
|
32
|
+
* - A `+` whose other operand is neither a proven number nor a proven
|
|
33
|
+
* string: numeric addition or concatenation is decided at run time, and a
|
|
34
|
+
* nil reading as `undefined` cannot be told from `null` there. It keeps
|
|
35
|
+
* today's output (the runtime's `plus` reads the nil as `null`) until the
|
|
36
|
+
* runtimes carry `undefined` (#3848).
|
|
37
|
+
* - A string operand whose nil may be either (`c?: string | null`): it keeps
|
|
38
|
+
* today's display reading, the empty string, until the runtimes carry
|
|
39
|
+
* `undefined` (#3848).
|
|
40
|
+
* - A nil Phase 1 cannot type (an index read, an untyped value): the
|
|
41
|
+
* runtime's helpers read it as `null`.
|
|
42
|
+
*/
|
|
43
|
+
import type { ParsedExpr } from '../expression-parser.ts';
|
|
44
|
+
import type { ScopedOperandTyping } from './operand-typing.ts';
|
|
45
|
+
/** The literal `NaN`, which every emitter spells through its runtime's `number('NaN')`. */
|
|
46
|
+
export declare const NAN_LITERAL: ParsedExpr;
|
|
47
|
+
/**
|
|
48
|
+
* Whether `l ?? r` was built by the rewrite (its right operand is the
|
|
49
|
+
* rewrite's fallback). A target whose host types an absent value as a
|
|
50
|
+
* concrete zero (Go) must give `l` a nillable representation, or refuse:
|
|
51
|
+
* the nil test would see a present `''` / `0` / `false` as absent.
|
|
52
|
+
*/
|
|
53
|
+
export declare function isNilReadingFallback(right: ParsedExpr): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* `expr` with the operands of its own coercion rewritten by their nil
|
|
56
|
+
* reading in `typing`'s scope; `expr` itself when nothing changes. Shallow:
|
|
57
|
+
* only `expr`'s direct operands are rewritten, as `emitParsedExpr` calls it
|
|
58
|
+
* at every node it dispatches. Idempotent: a rewritten operand is never nil.
|
|
59
|
+
*/
|
|
60
|
+
export declare function rewriteNilReadings(expr: ParsedExpr, typing: ScopedOperandTyping): ParsedExpr;
|
|
61
|
+
/**
|
|
62
|
+
* {@link rewriteNilReadings} at every node of `expr`, children first, for a
|
|
63
|
+
* tree a template adapter hands to the runtime evaluator or to its own
|
|
64
|
+
* walker instead of `emitParsedExpr` (a callback body, a memo body). An
|
|
65
|
+
* arrow's params shadow outer names within its body.
|
|
66
|
+
*/
|
|
67
|
+
export declare function rewriteNilReadingsDeep(expr: ParsedExpr, typing: ScopedOperandTyping): ParsedExpr;
|
|
68
|
+
//# sourceMappingURL=nil-reading.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nil-reading.d.ts","sourceRoot":"","sources":["../../src/adapters/nil-reading.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAgB,MAAM,yBAAyB,CAAA;AAEvE,OAAO,KAAK,EAA4B,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAIxF,2FAA2F;AAC3F,eAAO,MAAM,WAAW,EAAE,UAAsF,CAAA;AAwBhH;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAE/D;AA2ED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,mBAAmB,GAAG,UAAU,CAc5F;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,mBAAmB,GAAG,UAAU,CAShG"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The refusal of `===` / `!==` over an operand that may be an object or an
|
|
3
|
+
* array (#3774; `spec/js-primitive-semantics.md`, "Decisions" (4), option
|
|
4
|
+
* (b)).
|
|
5
|
+
*
|
|
6
|
+
* JS compares objects and arrays by reference. A template runtime holds a
|
|
7
|
+
* decoded prop as a value (PHP copy-on-write arrays, Go structs, Ruby and
|
|
8
|
+
* Python containers compared by contents), so no runtime can tell two
|
|
9
|
+
* distinct structures with equal contents apart. Every template adapter
|
|
10
|
+
* therefore refuses the comparison with BF101, as the callback evaluator
|
|
11
|
+
* contract already does (`spec/compiler.md`, "ParsedExpr Evaluator
|
|
12
|
+
* Semantics"). A nullish test (`x === null`, `x === undefined`) is not a
|
|
13
|
+
* strict equality and keeps the target's nil test.
|
|
14
|
+
*
|
|
15
|
+
* The primitive plan names the refusal per node (`mode: 'refuse'`), and
|
|
16
|
+
* every emitter spells the runtime's `strict_eq` for it; the error itself
|
|
17
|
+
* is recorded here, once per component, over every template position, each
|
|
18
|
+
* read in its own scope, and over the memo bodies the adapters seed at SSR.
|
|
19
|
+
*/
|
|
20
|
+
import type { ComponentIR, CompilerError } from '../types.ts';
|
|
21
|
+
import type { OperandTyping } from './operand-typing.ts';
|
|
22
|
+
/** Where a template adapter records the refusal. */
|
|
23
|
+
export interface NonPrimitiveEqualitySink {
|
|
24
|
+
readonly errors: CompilerError[];
|
|
25
|
+
readonly componentName: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Record BF101 for every `===` / `!==` over an operand that may be an
|
|
29
|
+
* object in `ir`'s template positions and memo bodies. One error per
|
|
30
|
+
* comparison text per compile.
|
|
31
|
+
*/
|
|
32
|
+
export declare function refuseNonPrimitiveStrictEquality(ir: ComponentIR, typing: OperandTyping, sink: NonPrimitiveEqualitySink): void;
|
|
33
|
+
//# sourceMappingURL=non-primitive-equality.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"non-primitive-equality.d.ts","sourceRoot":"","sources":["../../src/adapters/non-primitive-equality.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAMH,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAkB,MAAM,aAAa,CAAA;AAC7E,OAAO,KAAK,EAAE,aAAa,EAAuB,MAAM,qBAAqB,CAAA;AAG7E,oDAAoD;AACpD,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,MAAM,EAAE,aAAa,EAAE,CAAA;IAChC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;CAC/B;AAoBD;;;;GAIG;AACH,wBAAgB,gCAAgC,CAAC,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE,wBAAwB,GAAG,IAAI,CAe7H"}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* need the operand's type.
|
|
6
6
|
*/
|
|
7
7
|
import type { ParsedExpr } from '../expression-parser.ts';
|
|
8
|
+
import type { StringNameTest } from './parsed-expr-emitter.ts';
|
|
8
9
|
import type { SsrSeedPlan } from '../ssr-seed-plan.ts';
|
|
9
10
|
import type { ComponentIR } from '../types.ts';
|
|
10
11
|
/**
|
|
@@ -24,14 +25,15 @@ export declare function collectNumberValueNames(ir: Pick<ComponentIR, 'metadata'
|
|
|
24
25
|
* Whether an expression yields a JS NUMBER: arithmetic
|
|
25
26
|
* ({@link isNumericArithmeticResult}), a read of a name `isNumberName`
|
|
26
27
|
* accepts — a zero-argument getter call, a `props.<key>` member, or a bare
|
|
27
|
-
* identifier —
|
|
28
|
+
* identifier — a number literal that is not a safe integer, or a ternary
|
|
29
|
+
* with such a branch. Backends whose own number
|
|
28
30
|
* stringification differs from JS (Perl spells the infinities `Inf` and
|
|
29
31
|
* prints `%.15g`) route such a value through their `Number::toString`
|
|
30
32
|
* helper wherever JS stringifies it: an output position, or an operand of
|
|
31
33
|
* string concatenation (#3711). Whether a binding shadows the name is
|
|
32
34
|
* `isNumberName`'s scope question.
|
|
33
35
|
*/
|
|
34
|
-
export declare function isNumberValuedExpr(expr: ParsedExpr | null | undefined, isStringName:
|
|
36
|
+
export declare function isNumberValuedExpr(expr: ParsedExpr | null | undefined, isStringName: StringNameTest, isNumberName: (n: string, componentProperty?: boolean) => boolean): boolean;
|
|
35
37
|
/**
|
|
36
38
|
* Signals and memos whose in-template seed (a `derived` step of the SSR seed
|
|
37
39
|
* plan) is a JS number by construction: arithmetic, or a read of a
|
|
@@ -39,5 +41,5 @@ export declare function isNumberValuedExpr(expr: ParsedExpr | null | undefined,
|
|
|
39
41
|
* declared type is often `unknown` (`createMemo(() => count() / 0)` infers
|
|
40
42
|
* none without a checker), so the seed's shape is the evidence (#3711).
|
|
41
43
|
*/
|
|
42
|
-
export declare function numberValuedSeedNames(plan: SsrSeedPlan, isStringName:
|
|
44
|
+
export declare function numberValuedSeedNames(plan: SsrSeedPlan, isStringName: StringNameTest, isNumberName: (n: string, componentProperty?: boolean) => boolean): Set<string>;
|
|
43
45
|
//# sourceMappingURL=number-value.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number-value.d.ts","sourceRoot":"","sources":["../../src/adapters/number-value.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,KAAK,EAAE,WAAW,EAAY,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"number-value.d.ts","sourceRoot":"","sources":["../../src/adapters/number-value.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,KAAK,EAAE,WAAW,EAAY,MAAM,aAAa,CAAA;AAIxD;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CAAC,EAAE,EAAE,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,GAAG;IAAE,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAAC,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;CAAE,CAsBrH;AAQD;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,UAAU,GAAG,IAAI,GAAG,SAAS,EACnC,YAAY,EAAE,cAAc,EAC5B,YAAY,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,iBAAiB,CAAC,EAAE,OAAO,KAAK,OAAO,GAChE,OAAO,CAgBT;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,WAAW,EACjB,YAAY,EAAE,cAAc,EAC5B,YAAY,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,iBAAiB,CAAC,EAAE,OAAO,KAAK,OAAO,GAChE,GAAG,CAAC,MAAM,CAAC,CASb"}
|