@barefootjs/jsx 0.40.1 → 0.41.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/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 +45 -5
- package/dist/adapters/callback-method.d.ts.map +1 -1
- package/dist/adapters/component-props.d.ts +3 -4
- package/dist/adapters/component-props.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 +24 -12
- 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 +59 -0
- package/dist/adapters/loop-row-type.d.ts.map +1 -0
- package/dist/adapters/nil-reading.d.ts +63 -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 +80 -12
- package/dist/adapters/parsed-expr-emitter.d.ts.map +1 -1
- package/dist/adapters/primitive-plan.d.ts +320 -0
- package/dist/adapters/primitive-plan.d.ts.map +1 -0
- package/dist/adapters/prop-classes.d.ts +5 -0
- package/dist/adapters/prop-classes.d.ts.map +1 -1
- 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 +20 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4903 -2311
- package/dist/ir-to-client-js/build-references.d.ts.map +1 -1
- package/dist/ir-to-client-js/child-props-object.d.ts +106 -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/phases/props-extraction.d.ts +3 -3
- package/dist/ir-to-client-js/plan/build-declaration-emit.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/prune-unused-prop-extractions.d.ts +3 -1
- package/dist/ir-to-client-js/prune-unused-prop-extractions.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 +51 -34
- 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-binding.d.ts +58 -13
- package/dist/props-binding.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/ssr-defaults.d.ts +39 -3
- package/dist/ssr-defaults.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 +9 -9
- package/src/__tests__/binding-scope.test.ts +89 -1
- package/src/__tests__/body-destructure-props-object-alias.test.ts +123 -0
- package/src/__tests__/body-destructured-prop-default-arrow.test.ts +2 -2
- package/src/__tests__/body-destructured-props-live.test.ts +5 -5
- 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__/client-js-generation.test.ts +3 -3
- package/src/__tests__/computed-const.test.ts +103 -0
- package/src/__tests__/destructure-default-reads-earlier-param.test.ts +7 -7
- package/src/__tests__/destructured-props-live.test.ts +1 -1
- 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__/issue-3861-object-spread-child.test.ts +102 -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__/memo-body-expr.test.ts +2 -2
- 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 +78 -0
- package/src/__tests__/nullable-signal-attr.test.ts +109 -48
- package/src/__tests__/primitive-plan.test.ts +494 -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__/prop-default-undefined-only.test.ts +115 -0
- package/src/__tests__/prop-references.test.ts +2 -2
- package/src/__tests__/props-destructuring.test.ts +17 -0
- package/src/__tests__/props-object-whole-read.test.ts +40 -0
- package/src/__tests__/prune-unused-prop-extractions.test.ts +3 -3
- package/src/__tests__/reactive-attrs-in-map.test.ts +1 -1
- package/src/__tests__/reactive-factory-inlining.test.ts +4 -1
- package/src/__tests__/renamed-body-destructure-template.test.ts +7 -7
- package/src/__tests__/rest-binding-gaps.test.ts +192 -0
- package/src/__tests__/rewrite-destructured-props.test.ts +1 -1
- package/src/__tests__/root-prop-alias.test.ts +53 -8
- package/src/__tests__/ssr-defaults.test.ts +113 -25
- 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/__tests__/written-binding-substitution.test.ts +8 -8
- package/src/adapters/boolean-result.ts +72 -66
- package/src/adapters/brace-delimiter-text.ts +25 -0
- package/src/adapters/callback-method.ts +159 -27
- package/src/adapters/component-props.ts +3 -4
- package/src/adapters/computed-const.ts +238 -4
- package/src/adapters/dsl-template-adapter.ts +62 -26
- package/src/adapters/loop-bound-names.ts +9 -1
- package/src/adapters/loop-plan.ts +1 -1
- package/src/adapters/loop-row-type.ts +149 -0
- package/src/adapters/nil-reading.ts +295 -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 +183 -19
- package/src/adapters/primitive-plan.ts +765 -0
- package/src/adapters/prop-classes.ts +16 -3
- package/src/analyzer-context.ts +6 -0
- package/src/analyzer.ts +532 -26
- 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 +35 -16
- package/src/ir-to-client-js/build-references.ts +69 -0
- package/src/ir-to-client-js/child-props-object.ts +240 -0
- package/src/ir-to-client-js/collect-elements.ts +31 -63
- package/src/ir-to-client-js/control-flow/plan/build-inner-loop.ts +8 -1
- package/src/ir-to-client-js/control-flow/plan/build-loop-child-arm.ts +31 -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 +43 -17
- package/src/ir-to-client-js/imports.ts +2 -2
- package/src/ir-to-client-js/index.ts +53 -11
- package/src/ir-to-client-js/phases/props-extraction.ts +11 -7
- package/src/ir-to-client-js/plan/build-declaration-emit.ts +40 -7
- 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/prune-unused-prop-extractions.ts +58 -5
- package/src/ir-to-client-js/rewrite-destructured-props.ts +31 -1
- package/src/ir-to-client-js/stringify/static-array-child-init.ts +26 -10
- package/src/jsx-to-ir.ts +459 -37
- package/src/nullable-signal-attr.ts +200 -110
- package/src/prop-rewrite.ts +30 -6
- package/src/props-binding.ts +84 -19
- 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/ssr-defaults.ts +100 -11
- package/src/strip-types.ts +31 -3
- package/src/template-position-walk.ts +57 -28
- package/src/types.ts +87 -0
- package/dist/adapters/ambiguous-nil-arithmetic.d.ts +0 -41
- package/dist/adapters/ambiguous-nil-arithmetic.d.ts.map +0 -1
- package/src/adapters/ambiguous-nil-arithmetic.ts +0 -94
|
@@ -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,EAA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AWG;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,44 @@ 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
|
+
* Where an evaluator body is read, for its nil-reading rewrite
|
|
70
|
+
* (`rewriteNilReadingsDeep`): the enclosing scope's operand typing.
|
|
71
|
+
*/
|
|
72
|
+
export interface NilReadingSite {
|
|
73
|
+
readonly typing: ScopedOperandTyping;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Serialize a callback body for the runtime evaluator, with the captures its
|
|
77
|
+
* env needs; `null` when the body is outside the evaluator surface. `bound`
|
|
78
|
+
* are the callback's own params. `propsObject` is the component's props
|
|
79
|
+
* object identifier (`BindingScope.propsObject` / `propsObjectIdentifier`):
|
|
80
|
+
* `props`, or the props parameter's own name (`function C(p)`).
|
|
81
|
+
*
|
|
82
|
+
* A template has no props object: the props are its top-level variables,
|
|
83
|
+
* and the adapters spell `props.X` as the variable `X`. So each `props.X` the
|
|
84
|
+
* body reads, where no param binds `props`, becomes a fresh env name bound to
|
|
85
|
+
* the read itself, which the adapter spells as it spells `props.X` anywhere
|
|
86
|
+
* else. Capturing `props` whole would bind it to an undefined template
|
|
87
|
+
* variable, and the predicate would read every `props.X` as `undefined`.
|
|
88
|
+
*/
|
|
89
|
+
export declare function evalBody(body: ParsedExpr, bound: ReadonlySet<string>, propsObject: string, site?: NilReadingSite): EvalBody | null;
|
|
53
90
|
/**
|
|
54
91
|
* A lowered `.sort` / `.toSorted` comparator: the evaluator call, the
|
|
55
92
|
* structured `{keys: …}` descriptor for a comparator the evaluator cannot
|
|
@@ -89,21 +126,24 @@ export interface CallbackLoweringOptions {
|
|
|
89
126
|
*/
|
|
90
127
|
nativePredicate?: boolean;
|
|
91
128
|
}
|
|
92
|
-
/**
|
|
93
|
-
|
|
129
|
+
/**
|
|
130
|
+
* Lower `<recv>.<method>(arrow, ...restArgs)`. `propsObject`: the
|
|
131
|
+
* component's props object identifier (see {@link evalBody}).
|
|
132
|
+
*/
|
|
133
|
+
export declare function lowerCallbackMethod(method: string, arrow: Arrow, restArgs: readonly ParsedExpr[], options: CallbackLoweringOptions, propsObject: string): CallbackPlan;
|
|
94
134
|
/**
|
|
95
135
|
* Lower a `.sort` / `.toSorted` comparator: the evaluator first, then the
|
|
96
136
|
* structured `{keys: …}` descriptor, otherwise BF101. A loop source's sort
|
|
97
137
|
* (`planLoop`) and `.sort(cmp)` at an expression position decide the same.
|
|
98
138
|
*/
|
|
99
|
-
export declare function lowerSortComparator(method: 'sort' | 'toSorted', arrow: Arrow, adapterName: string): SortPlan;
|
|
139
|
+
export declare function lowerSortComparator(method: 'sort' | 'toSorted', arrow: Arrow, adapterName: string, propsObject: string): SortPlan;
|
|
100
140
|
/**
|
|
101
141
|
* The evaluator plan for a sort comparator, or `null` when the body is
|
|
102
142
|
* outside the evaluator surface (a `localeCompare` comparator) or the arrow
|
|
103
143
|
* has fewer than the two params a comparator needs. The loop-source sort
|
|
104
144
|
* shares this with `.sort(cmp)` at an expression position.
|
|
105
145
|
*/
|
|
106
|
-
export declare function sortEvalPlan(body: ParsedExpr, params: readonly string[]): CallbackEvalPlan | null;
|
|
146
|
+
export declare function sortEvalPlan(body: ParsedExpr, params: readonly string[], propsObject: string): CallbackEvalPlan | null;
|
|
107
147
|
/** The BF101 for a comparator neither the evaluator nor the descriptor can model. */
|
|
108
148
|
export declare function sortRefusal(method: string, adapterName: string): {
|
|
109
149
|
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,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC,CAAA;AAEnD,mDAAmD;AACnD,MAAM,MAAM,eAAe,GACvB,QAAQ,GACR,OAAO,GACP,MAAM,GACN,MAAM,GACN,WAAW,GACX,UAAU,GACV,eAAe,CAAA;AAYnB,+DAA+D;AAC/D,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,IAAI,eAAe,CAE3E;AAED,oFAAoF;AACpF,MAAM,MAAM,kBAAkB,GAC1B,WAAW,GACX,aAAa,GACb,aAAa,GACb,YAAY,GACZ,WAAW,GACX,WAAW,GACX,iBAAiB,GACjB,eAAe,GACf,UAAU,CAAA;AAEd,uEAAuE;AACvE,MAAM,MAAM,mBAAmB,GAC3B;IAAE,IAAI,EAA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,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAKlH"}
|
|
@@ -110,10 +110,9 @@ export interface EarlierComponentProps {
|
|
|
110
110
|
* caller actually handed over, and every optional param is `'present'`:
|
|
111
111
|
* an `'entry'` would hand the child the key even when the caller left it
|
|
112
112
|
* out, and the child would then read it as passed (a nil overriding its
|
|
113
|
-
* own earlier prop in a further `{...props}`). Without `callerKeys
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
* `props-spread-explicit-null-override`).
|
|
113
|
+
* own earlier prop in a further `{...props}`). Without `callerKeys`,
|
|
114
|
+
* "passed" is "not nil"; Go answers it from its own `bf.Opt[T]` Input
|
|
115
|
+
* field (`Passed()`) instead.
|
|
117
116
|
*/
|
|
118
117
|
export declare function propsSpreadParam(param: ComponentPropsParam, earlier: EarlierComponentProps, callerKeys?: boolean): 'entry' | 'present';
|
|
119
118
|
/** The key an entry sets in the props hash. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-props.d.ts","sourceRoot":"","sources":["../../src/adapters/component-props.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAG7E,mCAAmC;AACnC,MAAM,MAAM,kBAAkB;AAC5B,gFAAgF;AAC9E;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,SAAS,CAAA;CAAE;AACnD,wFAAwF;GACtF;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE;AAC1D,8FAA8F;GAC5F;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,IAAI,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MAAM,EAAE,CAAA;CACxB;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,SAAS,oBAAoB,EAAE,GAAG,qBAAqB,EAAE,GAAG,IAAI,CAuBlH;AAED,qDAAqD;AACrD,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,SAAS,2BAA2B,EAAE,GAAG,OAAO,CAE/F;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,aAAa,EAAE,MAAM,EAAE,aAAa,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAM3G"}
|
|
@@ -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,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACtC,qFAAqF;IACrF,cAAc,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;IACnC;;;;;;OAMG;IACH,cAAc,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;IACnC,mGAAmG;IACnG,KAAK,EAAE;QAAE,MAAM,EAAE,SAAS,SAAS,EAAE,CAAC;QAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAA;IAClE,gFAAgF;IAChF,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAA;IACjC,2FAA2F;IAC3F,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAA;IACrC;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAA;CAChC;AAED,uFAAuF;AACvF,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,UAAU,EACpB,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,EACrC,cAAc,GAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAqB,GACtD,oBAAoB,CAetB;AA2BD;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,IAAI,CAAC,UAAU,EAAE,iBAAiB,GAAG,aAAa,GAAG,eAAe,GAAG,gBAAgB,GAAG,gBAAgB,GAAG,SAAS,GAAG,OAAO,CAAC,GAC1I,GAAG,CAAC,MAAM,CAAC,CAeb;AAgCD;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,oBAAoB,GAAG,IAAI,GAAG,UAAU,CASnG;AAoJD;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,cAAc,EAAE,GAAG,EAAE,oBAAoB,GAAG,IAAI,GAAG,cAAc,CAQ/G"}
|
|
@@ -8,6 +8,8 @@ import { type LoweringMatcher } from '../lowering-registry.ts';
|
|
|
8
8
|
import type { ParsedExpr } 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,24 +191,26 @@ 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
|
/**
|
|
187
208
|
* The coercion an arithmetic operand's emitter spells
|
|
188
|
-
* (`arithmeticOperandCoercion`)
|
|
189
|
-
*
|
|
190
|
-
* `isShadowed` is the adapter's scope test at the emission site.
|
|
209
|
+
* (`arithmeticOperandCoercion`). `isShadowed` is the adapter's scope test
|
|
210
|
+
* at the emission site.
|
|
191
211
|
*/
|
|
192
212
|
protected arithmeticCoercion(op: string, operand: ParsedExpr, other: ParsedExpr | undefined, isShadowed: (name: string) => boolean): ArithmeticCoercion;
|
|
193
|
-
|
|
194
|
-
* Refuse the ambiguous-nil arithmetic (#3700) in a whole expression the
|
|
195
|
-
* adapter lowers through its own renderer rather than per operator: a
|
|
196
|
-
* `.filter()` predicate, read in the current scope with the callback's
|
|
197
|
-
* own `params` (its parameter and block locals) entered as a callback
|
|
198
|
-
* frame.
|
|
199
|
-
*/
|
|
200
|
-
protected refuseAmbiguousNilArithmeticIn(expr: ParsedExpr, params: readonly string[]): void;
|
|
201
|
-
private ambiguousNilSink;
|
|
213
|
+
private errorSink;
|
|
202
214
|
/** {@link planLoop} against the current scope and the component's constants. */
|
|
203
215
|
protected loopPlanFor<Spelled>(loop: IRLoop, spelling: LoopPlanSpelling<Spelled>): LoopPlan<Spelled>;
|
|
204
216
|
/**
|
|
@@ -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,yBAA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,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,QAAQ,EAAE,mBAAmB,GAAG,IAAI,CA4B3G;IAED;;;;;;;;;;;OAWG;IACH,SAAS,CAAC,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,GAAG,OAAO,CAWxE;IAED,OAAO,CAAC,YAAY;IAUpB,uEAAuE;IACvE,SAAS,CAAC,QAAQ,CAAC,iBAAiB,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAAA;IACnE,yDAAyD;IACzD,SAAS,CAAC,QAAQ,CAAC,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;IAmCzB,OAAO,CAAC,oBAAoB;CAkB7B"}
|
|
@@ -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,59 @@
|
|
|
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 declared type of the value `expr` reads in `scope` (a prop, a member
|
|
44
|
+
* path below one, a loop row, a signal or memo getter), or null when the
|
|
45
|
+
* declarations do not say. An optional field below the root admits
|
|
46
|
+
* `undefined` (`loopValueTypeAt`).
|
|
47
|
+
*/
|
|
48
|
+
export declare function declaredValueType(types: DeclaredValueTypes, expr: ParsedExpr, scope: BindingScope): LoopValueType | null;
|
|
49
|
+
/**
|
|
50
|
+
* The type of `receiver.concat(...args)`: an array whose element type is the
|
|
51
|
+
* union of the receiver's element type and each argument's (an array
|
|
52
|
+
* argument's elements, or the argument itself). A field read on a row of it
|
|
53
|
+
* is then a definite string only when it is one in every member
|
|
54
|
+
* (`loopValueTypeAt`), so an `any[]` argument or a field one member lacks
|
|
55
|
+
* types nothing (#3762 review). An argument of unknown type leaves the
|
|
56
|
+
* result with no element type.
|
|
57
|
+
*/
|
|
58
|
+
export declare function concatType<T extends LoopValueType>(receiver: T | null, args: readonly (T | null)[]): T | null;
|
|
59
|
+
//# 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,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,WAAW,EAAE,SAAS;QAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;QACrB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAA;QACvB,QAAQ,CAAC,YAAY,CAAC,EAAE,QAAQ,CAAA;QAChC,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAA;KAC1B,EAAE,CAAA;IACH,QAAQ,CAAC,OAAO,EAAE,SAAS;QAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAA;KAAE,EAAE,CAAA;IACjF,QAAQ,CAAC,KAAK,EAAE,SAAS;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAA;KAAE,EAAE,CAAA;IAC7E,2GAA2G;IAC3G,QAAQ,CAAC,eAAe,EAAE,MAAM,GAAG,IAAI,CAAA;IACvC,QAAQ,CAAC,WAAW,EAAE,eAAe,CAAA;CACtC;AAED,iDAAiD;AACjD,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,WAAW,GAAG,kBAAkB,CAStE;AAED,sFAAsF;AACtF,wBAAgB,WAAW,CACzB,KAAK,EAAE,kBAAkB,EACzB,IAAI,EAAE;IAAE,QAAQ,CAAC,WAAW,CAAC,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,eAAe,CAAC,EAAE,OAAO,CAAA;CAAE,EACjH,KAAK,EAAE,YAAY,GAClB,aAAa,GAAG,IAAI,CAKtB;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,kBAAkB,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,YAAY,GAAG,aAAa,GAAG,IAAI,CAExH;AAkCD;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,aAAa,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC,GAAG,IAAI,CAO7G"}
|
|
@@ -0,0 +1,63 @@
|
|
|
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 carries JS `null` and `undefined` as two values
|
|
6
|
+
* (`spec/js-undefined-value.md`), and its primitive helpers (`to_number`,
|
|
7
|
+
* `to_string`, `plus`, the relational ones) read each exactly. Where
|
|
8
|
+
* Phase-1 types say which value a nil stands for, and the consumer's
|
|
9
|
+
* coercion is known statically, the operand is rewritten before planning so
|
|
10
|
+
* that it is never nil:
|
|
11
|
+
*
|
|
12
|
+
* | Consumer | nil reads as `null` | nil reads as `undefined` |
|
|
13
|
+
* | --- | --- | --- |
|
|
14
|
+
* | numeric (`- * / %`, unary `-` / `+`, relational, numeric `+`) | `x ?? 0` | `x ?? NaN` |
|
|
15
|
+
* | string (`+` concatenation, template-literal part) | `x ?? 'null'` | `x ?? 'undefined'` |
|
|
16
|
+
*
|
|
17
|
+
* After the rewrite the operand is non-nil, so the plan can name the native
|
|
18
|
+
* operator (`(n ?? NaN) * 2` stays native).
|
|
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, to the runtime's helpers, which read the
|
|
28
|
+
* value, `null` or `UNDEF`, exactly:
|
|
29
|
+
*
|
|
30
|
+
* - An operand whose nil may be either (`n?: number | null`,
|
|
31
|
+
* `c?: string | null`).
|
|
32
|
+
* - A `+` whose other operand is neither a proven number nor a proven
|
|
33
|
+
* string: numeric addition or concatenation is decided at run time
|
|
34
|
+
* (the runtime's `plus`).
|
|
35
|
+
* - A nil Phase 1 cannot type (an index read, an untyped value): a missing
|
|
36
|
+
* key or an out-of-range index is `UNDEF`, data `null` is `null`.
|
|
37
|
+
*/
|
|
38
|
+
import type { ParsedExpr } from '../expression-parser.ts';
|
|
39
|
+
import type { ScopedOperandTyping } from './operand-typing.ts';
|
|
40
|
+
/** The literal `NaN`, which every emitter spells through its runtime's `number('NaN')`. */
|
|
41
|
+
export declare const NAN_LITERAL: ParsedExpr;
|
|
42
|
+
/**
|
|
43
|
+
* Whether `l ?? r` was built by the rewrite (its right operand is the
|
|
44
|
+
* rewrite's fallback). A target whose host types an absent value as a
|
|
45
|
+
* concrete zero (Go) must give `l` a nillable representation, or refuse:
|
|
46
|
+
* the nil test would see a present `''` / `0` / `false` as absent.
|
|
47
|
+
*/
|
|
48
|
+
export declare function isNilReadingFallback(right: ParsedExpr): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* `expr` with the operands of its own coercion rewritten by their nil
|
|
51
|
+
* reading in `typing`'s scope; `expr` itself when nothing changes. Shallow:
|
|
52
|
+
* only `expr`'s direct operands are rewritten, as `emitParsedExpr` calls it
|
|
53
|
+
* at every node it dispatches. Idempotent: a rewritten operand is never nil.
|
|
54
|
+
*/
|
|
55
|
+
export declare function rewriteNilReadings(expr: ParsedExpr, typing: ScopedOperandTyping): ParsedExpr;
|
|
56
|
+
/**
|
|
57
|
+
* {@link rewriteNilReadings} at every node of `expr`, children first, for a
|
|
58
|
+
* tree a template adapter hands to the runtime evaluator or to its own
|
|
59
|
+
* walker instead of `emitParsedExpr` (a callback body, a memo body). An
|
|
60
|
+
* arrow's params shadow outer names within its body.
|
|
61
|
+
*/
|
|
62
|
+
export declare function rewriteNilReadingsDeep(expr: ParsedExpr, typing: ScopedOperandTyping): ParsedExpr;
|
|
63
|
+
//# 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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;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;AA8ED;;;;;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: it plans as the runtime'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"}
|