@fluixi/compiler 1.0.0-alpha.83 → 1.0.0-alpha.85
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/analyze/expr-shape.cjs +62 -1
- package/dist/analyze/expr-shape.d.cts +14 -0
- package/dist/analyze/expr-shape.d.ts +2 -2
- package/dist/analyze/expr-shape.js +1 -1
- package/dist/analyze/expr-shape.mjs +41 -1
- package/dist/analyze/intrinsics.cjs +80 -1
- package/dist/analyze/intrinsics.d.cts +66 -0
- package/dist/analyze/intrinsics.d.ts +7 -7
- package/dist/analyze/intrinsics.d.ts.map +1 -1
- package/dist/analyze/intrinsics.js +3 -3
- package/dist/analyze/intrinsics.mjs +59 -1
- package/dist/analyze/paren.cjs +134 -0
- package/dist/analyze/paren.d.cts +23 -0
- package/dist/analyze/paren.d.ts +24 -0
- package/dist/analyze/paren.d.ts.map +1 -0
- package/dist/analyze/paren.js +168 -0
- package/dist/analyze/paren.mjs +113 -0
- package/dist/analyze/props-destructure.cjs +226 -1
- package/dist/analyze/props-destructure.d.cts +83 -0
- package/dist/analyze/props-destructure.d.ts +3 -3
- package/dist/analyze/props-destructure.d.ts.map +1 -1
- package/dist/analyze/props-destructure.js +4 -4
- package/dist/analyze/props-destructure.mjs +205 -1
- package/dist/analyze/reactive-bindings.cjs +190 -1
- package/dist/analyze/reactive-bindings.d.cts +42 -0
- package/dist/analyze/reactive-bindings.d.ts +1 -1
- package/dist/analyze/reactive-bindings.js +2 -2
- package/dist/analyze/reactive-bindings.mjs +167 -1
- package/dist/analyze/reactive-expr.cjs +38 -1
- package/dist/analyze/reactive-expr.d.cts +38 -0
- package/dist/analyze/reactive-expr.d.ts +4 -4
- package/dist/analyze/reactive-expr.d.ts.map +1 -1
- package/dist/analyze/reactive-expr.js +2 -2
- package/dist/analyze/reactive-expr.mjs +17 -1
- package/dist/analyze/static-graph.cjs +811 -1
- package/dist/analyze/static-graph.d.cts +102 -0
- package/dist/analyze/static-graph.d.ts +1 -1
- package/dist/analyze/static-graph.d.ts.map +1 -1
- package/dist/analyze/static-graph.js +11 -11
- package/dist/analyze/static-graph.mjs +793 -1
- package/dist/babel-TGY76XJ7.mjs +636 -0
- package/dist/chunk-4PLHS2FP.mjs +158 -0
- package/dist/chunk-6DB5FXS4.mjs +1718 -0
- package/dist/chunk-F74GFKSL.mjs +16 -0
- package/dist/chunk-G6QC2WRJ.mjs +11 -0
- package/dist/chunk-RUDJDZAA.mjs +1078 -0
- package/dist/codegen/backend.cjs +18 -1
- package/dist/codegen/backend.d.cts +35 -0
- package/dist/codegen/backends/imperative.cjs +542 -1
- package/dist/codegen/backends/imperative.d.cts +11 -0
- package/dist/codegen/backends/imperative.d.ts +1 -1
- package/dist/codegen/backends/imperative.d.ts.map +1 -1
- package/dist/codegen/backends/imperative.js +24 -20
- package/dist/codegen/backends/imperative.mjs +519 -1
- package/dist/codegen/contract.cjs +52 -1
- package/dist/codegen/contract.d.cts +24 -0
- package/dist/codegen/contract.d.ts +2 -2
- package/dist/codegen/contract.js +2 -2
- package/dist/codegen/contract.mjs +31 -1
- package/dist/codegen/partial-template.cjs +176 -1
- package/dist/codegen/partial-template.d.cts +61 -0
- package/dist/codegen/partial-template.d.ts +4 -4
- package/dist/codegen/partial-template.js +0 -0
- package/dist/codegen/partial-template.mjs +153 -1
- package/dist/codegen/serialize-static.cjs +125 -1
- package/dist/codegen/serialize-static.d.cts +38 -0
- package/dist/codegen/serialize-static.d.ts +3 -3
- package/dist/codegen/serialize-static.js +6 -6
- package/dist/codegen/serialize-static.mjs +104 -1
- package/dist/frontend/babel/build-ir-lit.cjs +1509 -1
- package/dist/frontend/babel/build-ir-lit.d.cts +26 -0
- package/dist/frontend/babel/build-ir-lit.d.ts +2 -2
- package/dist/frontend/babel/build-ir-lit.mjs +1478 -1
- package/dist/frontend/babel/build-ir.cjs +1524 -1
- package/dist/frontend/babel/build-ir.d.cts +35 -0
- package/dist/frontend/babel/build-ir.d.ts +2 -2
- package/dist/frontend/babel/build-ir.js +2 -2
- package/dist/frontend/babel/build-ir.mjs +1495 -1
- package/dist/frontend/babel/index.cjs +2186 -1
- package/dist/frontend/babel/index.d.cts +33 -0
- package/dist/frontend/babel/index.d.ts +1 -1
- package/dist/frontend/babel/index.js +1 -1
- package/dist/frontend/babel/index.mjs +2156 -1
- package/dist/frontend/babel/lower-template.cjs +1507 -1
- package/dist/frontend/babel/lower-template.d.cts +23 -0
- package/dist/frontend/babel/lower-template.d.ts +1 -1
- package/dist/frontend/babel/lower-template.js +2 -2
- package/dist/frontend/babel/lower-template.mjs +1478 -1
- package/dist/frontend/babel/plugin.cjs +2132 -1
- package/dist/frontend/babel/plugin.d.cts +95 -0
- package/dist/frontend/babel/plugin.d.ts +5 -5
- package/dist/frontend/babel/plugin.d.ts.map +1 -1
- package/dist/frontend/babel/plugin.js +14 -14
- package/dist/frontend/babel/plugin.mjs +2103 -1
- package/dist/frontend/babel/server-functions.cjs +110 -1
- package/dist/frontend/babel/server-functions.d.cts +10 -0
- package/dist/frontend/babel/server-functions.mjs +89 -1
- package/dist/frontend/babel/types.cjs +18 -1
- package/dist/frontend/babel/types.d.cts +33 -0
- package/dist/frontend/types.cjs +18 -1
- package/dist/frontend/types.d.cts +25 -0
- package/dist/frontend/vocabulary.cjs +98 -0
- package/dist/frontend/vocabulary.d.cts +79 -0
- package/dist/frontend/vocabulary.d.ts +80 -0
- package/dist/frontend/vocabulary.d.ts.map +1 -0
- package/dist/frontend/vocabulary.js +124 -0
- package/dist/frontend/vocabulary.mjs +77 -0
- package/dist/index.cjs +1595 -14
- package/dist/index.d.cts +27 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -4
- package/dist/index.mjs +1575 -14
- package/dist/integrations.cjs +4312 -26
- package/dist/integrations.d.cts +215 -0
- package/dist/integrations.d.ts +9 -9
- package/dist/integrations.d.ts.map +1 -1
- package/dist/integrations.js +29 -8
- package/dist/integrations.mjs +536 -18
- package/dist/ir/nodes.cjs +18 -1
- package/dist/ir/nodes.d.cts +168 -0
- package/dist/ir/nodes.d.ts +6 -6
- package/dist/lower/compile-template.cjs +1356 -1
- package/dist/lower/compile-template.d.cts +69 -0
- package/dist/lower/compile-template.d.ts +3 -3
- package/dist/lower/compile-template.js +1 -1
- package/dist/lower/compile-template.mjs +1336 -1
- package/dist/lower/jsx.cjs +529 -1
- package/dist/lower/jsx.d.cts +25 -0
- package/dist/lower/jsx.d.ts +1 -1
- package/dist/lower/jsx.d.ts.map +1 -1
- package/dist/lower/jsx.js +6 -5
- package/dist/lower/jsx.mjs +506 -1
- package/dist/lower/template.cjs +1061 -1
- package/dist/lower/template.d.cts +53 -0
- package/dist/lower/template.d.ts +3 -3
- package/dist/lower/template.d.ts.map +1 -1
- package/dist/lower/template.js +12 -11
- package/dist/lower/template.mjs +1042 -1
- package/dist/lower/text.cjs +42 -1
- package/dist/lower/text.d.cts +10 -0
- package/dist/lower/text.d.ts +2 -2
- package/dist/lower/text.d.ts.map +1 -1
- package/dist/lower/text.js +2 -2
- package/dist/lower/text.mjs +21 -1
- package/dist/optimize/analyze-static.cjs +112 -1
- package/dist/optimize/analyze-static.d.cts +39 -0
- package/dist/optimize/analyze-static.d.ts +2 -2
- package/dist/optimize/analyze-static.js +2 -2
- package/dist/optimize/analyze-static.mjs +91 -1
- package/dist/optimize/collapse-strategies.cjs +90 -1
- package/dist/optimize/collapse-strategies.d.cts +30 -0
- package/dist/optimize/collapse-strategies.d.ts +3 -3
- package/dist/optimize/collapse-strategies.mjs +67 -1
- package/dist/options.cjs +33 -1
- package/dist/options.d.cts +39 -0
- package/dist/options.d.ts +2 -2
- package/dist/options.mjs +12 -1
- package/dist/resolve/builtins.cjs +73 -1
- package/dist/resolve/builtins.d.cts +68 -0
- package/dist/resolve/builtins.d.ts +8 -8
- package/dist/resolve/builtins.d.ts.map +1 -1
- package/dist/resolve/builtins.js +4 -4
- package/dist/resolve/builtins.mjs +53 -1
- package/dist/resolve/component-globals.cjs +234 -14
- package/dist/resolve/component-globals.d.cts +80 -0
- package/dist/resolve/component-globals.d.ts +5 -5
- package/dist/resolve/component-globals.js +10 -10
- package/dist/resolve/component-globals.mjs +211 -14
- package/dist/resolve/component-resolver.cjs +80 -1
- package/dist/resolve/component-resolver.d.cts +68 -0
- package/dist/resolve/component-resolver.d.ts +3 -3
- package/dist/resolve/component-resolver.d.ts.map +1 -1
- package/dist/resolve/component-resolver.js +3 -3
- package/dist/resolve/component-resolver.mjs +59 -1
- package/dist/resolve/load-directive.cjs +93 -1
- package/dist/resolve/load-directive.d.cts +53 -0
- package/dist/resolve/load-directive.d.ts +5 -5
- package/dist/resolve/load-directive.js +6 -6
- package/dist/resolve/load-directive.mjs +72 -1
- package/dist/resolve/resolve-ir.cjs +108 -1
- package/dist/resolve/resolve-ir.d.cts +53 -0
- package/dist/resolve/resolve-ir.d.ts +6 -6
- package/dist/resolve/resolve-ir.d.ts.map +1 -1
- package/dist/resolve/resolve-ir.js +1 -1
- package/dist/resolve/resolve-ir.mjs +85 -1
- package/dist/resolve/write-globals.cjs +319 -14
- package/dist/resolve/write-globals.d.cts +30 -0
- package/dist/resolve/write-globals.js +2 -2
- package/dist/resolve/write-globals.mjs +298 -14
- package/dist/server-fns-ZYWQTSZU.mjs +78 -0
- package/dist/server-functions-PCERFA7A.mjs +82 -0
- package/dist/transform/bindings.cjs +71 -1
- package/dist/transform/bindings.d.cts +16 -0
- package/dist/transform/bindings.d.ts +1 -1
- package/dist/transform/bindings.js +1 -1
- package/dist/transform/bindings.mjs +50 -1
- package/dist/transform/index.cjs +2732 -8
- package/dist/transform/index.d.cts +15 -0
- package/dist/transform/index.mjs +3773 -17
- package/dist/transform/intrinsics.cjs +216 -3
- package/dist/transform/intrinsics.d.cts +21 -0
- package/dist/transform/intrinsics.js +1 -1
- package/dist/transform/intrinsics.mjs +193 -3
- package/dist/transform/props.cjs +441 -3
- package/dist/transform/props.d.cts +45 -0
- package/dist/transform/props.d.ts +1 -1
- package/dist/transform/props.d.ts.map +1 -1
- package/dist/transform/props.js +4 -4
- package/dist/transform/props.mjs +1482 -12
- package/dist/transform/server-fn-id.cjs +35 -1
- package/dist/transform/server-fn-id.d.cts +9 -0
- package/dist/transform/server-fn-id.d.ts +1 -1
- package/dist/transform/server-fn-id.js +2 -2
- package/dist/transform/server-fn-id.mjs +14 -1
- package/dist/transform/server-fns.cjs +114 -2
- package/dist/transform/server-fns.d.cts +12 -0
- package/dist/transform/server-fns.js +3 -3
- package/dist/transform/server-fns.mjs +1155 -11
- package/dist/transform/source-locations.cjs +330 -1
- package/dist/transform/source-locations.d.cts +43 -0
- package/dist/transform/source-locations.d.ts +1 -1
- package/dist/transform/source-locations.js +5 -5
- package/dist/transform/source-locations.mjs +307 -1
- package/dist/transform/templates.cjs +2701 -7
- package/dist/transform/templates.d.cts +69 -0
- package/dist/transform/templates.d.ts +2 -2
- package/dist/transform/templates.d.ts.map +1 -1
- package/dist/transform/templates.js +7 -7
- package/dist/transform/templates.mjs +3743 -16
- package/dist/transform-RWDTQUF5.mjs +893 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/package.json +6 -5
- package/dist/babel-VXKH6MRQ.mjs +0 -1
- package/dist/chunk-3SAEGOMQ.mjs +0 -1
- package/dist/chunk-5KMMN5QP.mjs +0 -1
- package/dist/chunk-IBRM4W7I.mjs +0 -10
- package/dist/chunk-OHHZCYIQ.mjs +0 -1
- package/dist/chunk-YKZ54NVE.mjs +0 -1
- package/dist/server-fns-6QM243HC.mjs +0 -2
- package/dist/server-functions-E3LKCZ4R.mjs +0 -1
- package/dist/transform-C4ZXRVGP.mjs +0 -8
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lower a parsed Template AST (`@fluixi/template-parser`) into the host-agnostic IR.
|
|
3
|
+
*
|
|
4
|
+
* No parser in here: the `${…}` holes arrive already described as `TemplateHole`,
|
|
5
|
+
* since reading them means reading JavaScript and that belongs to a front-end.
|
|
6
|
+
*
|
|
7
|
+
* Pipeline: pieces → parseTemplate → Template AST → lowerTemplate → IRNode
|
|
8
|
+
*/
|
|
9
|
+
import { type Piece } from '@fluixi/template-parser';
|
|
10
|
+
import type { HolePosition, IRNode } from '../ir/nodes.cjs';
|
|
11
|
+
/**
|
|
12
|
+
* One `${…}` slot, as the front-end describes it. Conclusions about the
|
|
13
|
+
* expression only: never a syntax tree, or the parser dependency creeps back.
|
|
14
|
+
*/
|
|
15
|
+
export interface TemplateHole {
|
|
16
|
+
/** The expression source, verbatim. Anything nested inside it is already compiled. */
|
|
17
|
+
code: string;
|
|
18
|
+
/** Whether it must be wired reactively (see analyze/reactive-expr.ts). */
|
|
19
|
+
reactive: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Set when the hole is a single-expression arrow, `${item => …}`. `each` turns
|
|
22
|
+
* that into `For`'s render function, so it needs the parameters and the body
|
|
23
|
+
* separately rather than the arrow as written.
|
|
24
|
+
*/
|
|
25
|
+
arrow?: {
|
|
26
|
+
params: string[];
|
|
27
|
+
body: string;
|
|
28
|
+
bodyReactive: boolean;
|
|
29
|
+
};
|
|
30
|
+
/** Whether the hole is an object literal: `class=${{…}}` lowers to classList. */
|
|
31
|
+
object?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Where the `${…}` was written. Only kept when the host asked for source locations.
|
|
34
|
+
*
|
|
35
|
+
* A template is emitted as one overwrite, so every hole in it traces back through the
|
|
36
|
+
* source map to the line the template opens at. Without this, every node a template makes
|
|
37
|
+
* reports that one position.
|
|
38
|
+
*/
|
|
39
|
+
at?: HolePosition;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Lower a parsed template to IR. `pieces` are the static runs and hole slots as
|
|
43
|
+
* the parser wants them; `holes` describes each `${…}` in the same order. `used`
|
|
44
|
+
* collects the runtime symbols the emitted code imports.
|
|
45
|
+
*/
|
|
46
|
+
export declare function lowerTemplate(pieces: Piece[], holes: TemplateHole[], used: Set<string>, opts?: {
|
|
47
|
+
svg?: boolean;
|
|
48
|
+
sourceFile?: string;
|
|
49
|
+
positionAt?: (offset: number) => {
|
|
50
|
+
line: number;
|
|
51
|
+
column: number;
|
|
52
|
+
};
|
|
53
|
+
}): IRNode;
|
package/dist/lower/template.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ import { type Piece } from '@fluixi/template-parser';
|
|
|
10
10
|
import type { HolePosition, IRNode } from '../ir/nodes.js';
|
|
11
11
|
/**
|
|
12
12
|
* One `${…}` slot, as the front-end describes it. Conclusions about the
|
|
13
|
-
* expression only
|
|
13
|
+
* expression only: never a syntax tree, or the parser dependency creeps back.
|
|
14
14
|
*/
|
|
15
15
|
export interface TemplateHole {
|
|
16
16
|
/** The expression source, verbatim. Anything nested inside it is already compiled. */
|
|
@@ -18,7 +18,7 @@ export interface TemplateHole {
|
|
|
18
18
|
/** Whether it must be wired reactively (see analyze/reactive-expr.ts). */
|
|
19
19
|
reactive: boolean;
|
|
20
20
|
/**
|
|
21
|
-
* Set when the hole is a single-expression arrow
|
|
21
|
+
* Set when the hole is a single-expression arrow, `${item => …}`. `each` turns
|
|
22
22
|
* that into `For`'s render function, so it needs the parameters and the body
|
|
23
23
|
* separately rather than the arrow as written.
|
|
24
24
|
*/
|
|
@@ -27,7 +27,7 @@ export interface TemplateHole {
|
|
|
27
27
|
body: string;
|
|
28
28
|
bodyReactive: boolean;
|
|
29
29
|
};
|
|
30
|
-
/** Whether the hole is an object literal
|
|
30
|
+
/** Whether the hole is an object literal: `class=${{…}}` lowers to classList. */
|
|
31
31
|
object?: boolean;
|
|
32
32
|
/**
|
|
33
33
|
* Where the `${…}` was written. Only kept when the host asked for source locations.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template.d.ts","sourceRoot":"","sources":["../../src/lower/template.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAML,KAAK,KAAK,EAGX,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,EAAsB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"template.d.ts","sourceRoot":"","sources":["../../src/lower/template.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAML,KAAK,KAAK,EAGX,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,EAAsB,MAAM,gBAAgB,CAAC;AAM/E;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,sFAAsF;IACtF,IAAI,EAAE,MAAM,CAAC;IACb,0EAA0E;IAC1E,QAAQ,EAAE,OAAO,CAAC;IAClB;;;;OAIG;IACH,KAAK,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,EAAE,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,OAAO,CAAA;KAAE,CAAC;IAClE,iFAAiF;IACjF,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;;;;OAMG;IACH,EAAE,CAAC,EAAE,YAAY,CAAC;CACnB;AAmhBD;;;;GAIG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,KAAK,EAAE,EACf,KAAK,EAAE,YAAY,EAAE,EACrB,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,EACjB,IAAI,GAAE;IAAE,GAAG,CAAC,EAAE,OAAO,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAA;CAAO,GACnH,MAAM,CAGR"}
|
package/dist/lower/template.js
CHANGED
|
@@ -10,6 +10,7 @@ import { parseTemplate, } from '@fluixi/template-parser';
|
|
|
10
10
|
import { parseLoadDirective } from '../resolve/load-directive.js';
|
|
11
11
|
import { imperativeBackend, inlineTemplates } from '../codegen/backends/imperative.js';
|
|
12
12
|
import { cleanTemplateText } from './text.js';
|
|
13
|
+
import { paren } from '../analyze/paren.js';
|
|
13
14
|
const DELEGATED = new Set([
|
|
14
15
|
'click', 'dblclick', 'input', 'change', 'submit', 'focus', 'blur',
|
|
15
16
|
'keydown', 'keyup', 'keypress', 'mousedown', 'mouseup',
|
|
@@ -133,7 +134,7 @@ class Lowerer {
|
|
|
133
134
|
if (el.tag === 'component' && isAttr && isAttr.value && isAttr.value.kind === 'hole') {
|
|
134
135
|
const rest = el.attributes.filter((a) => a !== isAttr);
|
|
135
136
|
const node = this.lowerComponent({ ...el, kind: 'Component', tag: 'Dynamic', tagHole: null, attributes: rest });
|
|
136
|
-
node.props.unshift({ name: 'component', kind: 'attr', expr: `() =>
|
|
137
|
+
node.props.unshift({ name: 'component', kind: 'attr', expr: `() => ${paren(this.hole(isAttr.value.hole).code, 'arrowBody')}` });
|
|
137
138
|
return node;
|
|
138
139
|
}
|
|
139
140
|
const at = this.tagAt(el);
|
|
@@ -148,13 +149,13 @@ class Lowerer {
|
|
|
148
149
|
};
|
|
149
150
|
}
|
|
150
151
|
lowerComponent(el) {
|
|
151
|
-
// `<${Comp} />`: the tag is an interpolated expression
|
|
152
|
+
// `<${Comp} />`: the tag is an interpolated expression, use the hole's code
|
|
152
153
|
// as the component identity, so `createComponent(<expr>, …)` is emitted.
|
|
153
154
|
const name = el.tagHole != null ? this.hole(el.tagHole).code : el.tag;
|
|
154
155
|
const props = this.lowerAttributes(el.attributes);
|
|
155
156
|
// Named slots: a child with `slot="header"` becomes `props.header` (a lazy
|
|
156
157
|
// getter, like `children`); the rest stay the default `children`. This is the
|
|
157
|
-
// Solid convention
|
|
158
|
+
// Solid convention: the component reads `props.header` / `props.children`.
|
|
158
159
|
const { slots, rest } = this.partitionSlots(el.children);
|
|
159
160
|
for (const [slotName, nodes] of slots) {
|
|
160
161
|
const ir = nodes.length === 1 ? nodes[0] : { kind: 'fragment', children: nodes };
|
|
@@ -165,7 +166,7 @@ class Lowerer {
|
|
|
165
166
|
jsxElement: true,
|
|
166
167
|
};
|
|
167
168
|
// A slot replaces a same-named attribute rather than joining it. `<Card header>`
|
|
168
|
-
// alongside `<span slot="header">` otherwise emits the key twice
|
|
169
|
+
// alongside `<span slot="header">` otherwise emits the key twice, valid JS where
|
|
169
170
|
// the last wins, but the first is dead code and esbuild warns on it. Content is
|
|
170
171
|
// the more specific intent, so the slot is what survives.
|
|
171
172
|
const clash = props.findIndex((p) => p.name === slotName);
|
|
@@ -182,7 +183,7 @@ class Lowerer {
|
|
|
182
183
|
: undefined;
|
|
183
184
|
// The parser's positions are relative to the template string, not the file, so the
|
|
184
185
|
// tag itself has none to give. The first hole is the closest thing that does, and for
|
|
185
|
-
// the control-flow components
|
|
186
|
+
// the control-flow components: `<Show when=${…}>`, `<For each=${…}>`, it is the
|
|
186
187
|
// expression driving the subtree anyway.
|
|
187
188
|
// A reactive one: a literal carries a position too now, and it drives nothing.
|
|
188
189
|
const bindAt = props.find((p) => p.at && p.reactive)?.at;
|
|
@@ -253,11 +254,11 @@ class Lowerer {
|
|
|
253
254
|
if (arrow) {
|
|
254
255
|
const bodyIR = { kind: 'expr', code: arrow.body, reactive: arrow.bodyReactive };
|
|
255
256
|
const repeated = this.rebuildWithChildren(el, [bodyIR]);
|
|
256
|
-
childrenCode = `(${arrow.params.join(', ')}) =>
|
|
257
|
+
childrenCode = `(${arrow.params.join(', ')}) => ${paren(this.emit(repeated), 'arrowBody')}`;
|
|
257
258
|
}
|
|
258
259
|
else {
|
|
259
260
|
const repeated = this.stripAndLower(el, (a) => a.kind === 'EachDirective');
|
|
260
|
-
childrenCode = `() =>
|
|
261
|
+
childrenCode = `() => ${paren(this.emit(repeated), 'arrowBody')}`;
|
|
261
262
|
}
|
|
262
263
|
const children = [{ kind: 'expr', code: childrenCode, reactive: false }];
|
|
263
264
|
const at = this.tagAt(el);
|
|
@@ -360,7 +361,7 @@ class Lowerer {
|
|
|
360
361
|
if (!dir)
|
|
361
362
|
break;
|
|
362
363
|
// parens so an object literal opts isn't read as a block body
|
|
363
|
-
usePairs.push(a.name != null && a.hole != null ? `[${dir}, () =>
|
|
364
|
+
usePairs.push(a.name != null && a.hole != null ? `[${dir}, () => ${paren(this.hole(a.hole).code, 'arrowBody')}]` : `[${dir}]`);
|
|
364
365
|
break;
|
|
365
366
|
}
|
|
366
367
|
}
|
|
@@ -368,7 +369,7 @@ class Lowerer {
|
|
|
368
369
|
// Merge all class:/style: directives into one classList/style prop so they
|
|
369
370
|
// don't collide as duplicate keys in the emitted props object.
|
|
370
371
|
// One prop covers every directive of its kind, so it carries the first hole's
|
|
371
|
-
// position
|
|
372
|
+
// position: a real source line beats the stack fallback, which lands in the
|
|
372
373
|
// compiled file.
|
|
373
374
|
if (classEntries.length > 0) {
|
|
374
375
|
props.push({
|
|
@@ -470,11 +471,11 @@ class Lowerer {
|
|
|
470
471
|
},
|
|
471
472
|
];
|
|
472
473
|
}
|
|
473
|
-
/** A plain attribute (incl. lit `?bool`, mixed values)
|
|
474
|
+
/** A plain attribute (incl. lit `?bool`, mixed values), old `mkProp` behavior. */
|
|
474
475
|
plainAttr(a) {
|
|
475
476
|
const v = a.value;
|
|
476
477
|
// `class=${{...}}` (object literal) -> classList (Solid convention), so it
|
|
477
|
-
// doesn't collide with a static `class="box"` (which stays className)
|
|
478
|
+
// doesn't collide with a static `class="box"` (which stays className), both
|
|
478
479
|
// apply. `class` -> className; `style=${{...}}` stays `style` (runtime merges).
|
|
479
480
|
// `html=${x}` is the raw-HTML escape hatch -> innerHTML.
|
|
480
481
|
let name = a.name;
|