@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,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Babel front-end for the Fluixi compiler.
|
|
3
|
+
* @module @fluixi/babel-plugin-jsx
|
|
4
|
+
*
|
|
5
|
+
* This is a host adapter, not the compiler. It parses with babel and, for each
|
|
6
|
+
* JSX element/fragment and each `` html`...` `` template, hands the node to the
|
|
7
|
+
* shared pipeline: build IR, run the imperative backend, then splices the
|
|
8
|
+
* emitted code back into the program. Everything that decides *what* the output
|
|
9
|
+
* means (directives, control flow, component resolution, load strategies,
|
|
10
|
+
* reactivity, templates) lives in ../../{ir,resolve,optimize,codegen}, which
|
|
11
|
+
* import no babel at all.
|
|
12
|
+
*
|
|
13
|
+
* What stays here is genuinely host work: dispatching the visitors, collecting
|
|
14
|
+
* the runtime symbols the backend reported so the imports can be injected, and
|
|
15
|
+
* hoisting static templates to module scope.
|
|
16
|
+
*/
|
|
17
|
+
import { type ComponentResolverRule } from '../../resolve/component-resolver.cjs';
|
|
18
|
+
import { type PluginObj } from '@babel/core';
|
|
19
|
+
export interface PluginOptions {
|
|
20
|
+
/**
|
|
21
|
+
* Import source for the JSX types and for whatever JSX this plugin does not
|
|
22
|
+
* consume: esbuild's automatic runtime and TypeScript's `jsxImportSource`
|
|
23
|
+
* both point at it. The compiler itself never emits `jsx()` calls.
|
|
24
|
+
* @default '@fluixi/jsx'
|
|
25
|
+
*/
|
|
26
|
+
importSource?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Enable development mode with additional checks
|
|
29
|
+
* @default false
|
|
30
|
+
*/
|
|
31
|
+
development?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Enable event delegation
|
|
34
|
+
* @default true
|
|
35
|
+
*/
|
|
36
|
+
delegateEvents?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Generate source maps
|
|
39
|
+
* @default true
|
|
40
|
+
*/
|
|
41
|
+
sourceMaps?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Module name for signal directive
|
|
44
|
+
* @default '@fluixi/dom'
|
|
45
|
+
*/
|
|
46
|
+
signalModule?: string;
|
|
47
|
+
/**
|
|
48
|
+
* Module name for control flow
|
|
49
|
+
* @default '@fluixi/dom'
|
|
50
|
+
*/
|
|
51
|
+
controlFlowModule?: string;
|
|
52
|
+
/**
|
|
53
|
+
* Module the router components (Router/Outlet/…) are auto-imported from.
|
|
54
|
+
* @default '@fluixi/core/router'
|
|
55
|
+
*/
|
|
56
|
+
routerModule?: string;
|
|
57
|
+
/** Clone static subtrees from a template. Client-only, see CompilerOptions. */
|
|
58
|
+
templateClone?: boolean;
|
|
59
|
+
/** Also clone structure-static subtrees with holes. See CompilerOptions. */
|
|
60
|
+
partialTemplates?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Rules that resolve an unbound capitalised tag to a module, so a component can be
|
|
63
|
+
* used without an import: the configurable form of the built-in
|
|
64
|
+
* Suspense/Portal/Router auto-import.
|
|
65
|
+
*
|
|
66
|
+
* A lexical binding always wins, so an explicit import or a local variable is never
|
|
67
|
+
* overridden. With no rules, behaviour is exactly as before.
|
|
68
|
+
*/
|
|
69
|
+
resolve?: readonly ComponentResolverRule[];
|
|
70
|
+
/**
|
|
71
|
+
* Where reactive primitives (createMemo) are imported from, the signal core,
|
|
72
|
+
* not the dom runtime.
|
|
73
|
+
* @default '@fluixi/reactive/signal'
|
|
74
|
+
*/
|
|
75
|
+
reactiveModule?: string;
|
|
76
|
+
/**
|
|
77
|
+
* Which authoring syntaxes to compile:
|
|
78
|
+
* - 'jsx': only JSX elements/fragments.
|
|
79
|
+
* - 'lit': only `` html`...` `` / `` svg`...` `` tagged templates.
|
|
80
|
+
* - 'both' (default): JSX and `html``` templates in the same file.
|
|
81
|
+
*
|
|
82
|
+
* Both syntaxes lower to the same IR and the same imperative backend, so the
|
|
83
|
+
* choice is about which source forms the plugin touches, not about output.
|
|
84
|
+
* @default 'both'
|
|
85
|
+
*/
|
|
86
|
+
format?: 'jsx' | 'lit' | 'both';
|
|
87
|
+
/**
|
|
88
|
+
* Tag name that marks a lit template for compilation (when `format` includes
|
|
89
|
+
* lit). Other tagged templates are left untouched.
|
|
90
|
+
* @default 'html'
|
|
91
|
+
*/
|
|
92
|
+
litTag?: string;
|
|
93
|
+
}
|
|
94
|
+
declare const _default: (api: object, options: PluginOptions | null | undefined, dirname: string) => PluginObj<import("@babel/core").PluginPass>;
|
|
95
|
+
export default _default;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* This is a host adapter, not the compiler. It parses with babel and, for each
|
|
6
6
|
* JSX element/fragment and each `` html`...` `` template, hands the node to the
|
|
7
|
-
* shared pipeline
|
|
7
|
+
* shared pipeline: build IR, run the imperative backend, then splices the
|
|
8
8
|
* emitted code back into the program. Everything that decides *what* the output
|
|
9
9
|
* means (directives, control flow, component resolution, load strategies,
|
|
10
10
|
* reactivity, templates) lives in ../../{ir,resolve,optimize,codegen}, which
|
|
@@ -19,7 +19,7 @@ import { type PluginObj } from '@babel/core';
|
|
|
19
19
|
export interface PluginOptions {
|
|
20
20
|
/**
|
|
21
21
|
* Import source for the JSX types and for whatever JSX this plugin does not
|
|
22
|
-
* consume
|
|
22
|
+
* consume: esbuild's automatic runtime and TypeScript's `jsxImportSource`
|
|
23
23
|
* both point at it. The compiler itself never emits `jsx()` calls.
|
|
24
24
|
* @default '@fluixi/jsx'
|
|
25
25
|
*/
|
|
@@ -54,13 +54,13 @@ export interface PluginOptions {
|
|
|
54
54
|
* @default '@fluixi/core/router'
|
|
55
55
|
*/
|
|
56
56
|
routerModule?: string;
|
|
57
|
-
/** Clone static subtrees from a template. Client-only
|
|
57
|
+
/** Clone static subtrees from a template. Client-only, see CompilerOptions. */
|
|
58
58
|
templateClone?: boolean;
|
|
59
59
|
/** Also clone structure-static subtrees with holes. See CompilerOptions. */
|
|
60
60
|
partialTemplates?: boolean;
|
|
61
61
|
/**
|
|
62
62
|
* Rules that resolve an unbound capitalised tag to a module, so a component can be
|
|
63
|
-
* used without an import
|
|
63
|
+
* used without an import: the configurable form of the built-in
|
|
64
64
|
* Suspense/Portal/Router auto-import.
|
|
65
65
|
*
|
|
66
66
|
* A lexical binding always wins, so an explicit import or a local variable is never
|
|
@@ -68,7 +68,7 @@ export interface PluginOptions {
|
|
|
68
68
|
*/
|
|
69
69
|
resolve?: readonly ComponentResolverRule[];
|
|
70
70
|
/**
|
|
71
|
-
* Where reactive primitives (createMemo) are imported from
|
|
71
|
+
* Where reactive primitives (createMemo) are imported from, the signal core,
|
|
72
72
|
* not the dom runtime.
|
|
73
73
|
* @default '@fluixi/reactive/signal'
|
|
74
74
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../src/frontend/babel/plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAEL,KAAK,qBAAqB,EAG3B,MAAM,qCAAqC,CAAC;AAQ7C,OAAO,EAAwB,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAUnE,MAAM,WAAW,aAAa;IAC5B;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../src/frontend/babel/plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAEL,KAAK,qBAAqB,EAG3B,MAAM,qCAAqC,CAAC;AAQ7C,OAAO,EAAwB,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAUnE,MAAM,WAAW,aAAa;IAC5B;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,+EAA+E;IAC/E,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,4EAA4E;IAC5E,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,SAAS,qBAAqB,EAAE,CAAC;IAE3C;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;;;;;;;;OASG;IACH,MAAM,CAAC,EAAE,KAAK,GAAG,KAAK,GAAG,MAAM,CAAC;IAEhC;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;;AAkDD,wBAgVG"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* This is a host adapter, not the compiler. It parses with babel and, for each
|
|
6
6
|
* JSX element/fragment and each `` html`...` `` template, hands the node to the
|
|
7
|
-
* shared pipeline
|
|
7
|
+
* shared pipeline: build IR, run the imperative backend, then splices the
|
|
8
8
|
* emitted code back into the program. Everything that decides *what* the output
|
|
9
9
|
* means (directives, control flow, component resolution, load strategies,
|
|
10
10
|
* reactivity, templates) lives in ../../{ir,resolve,optimize,codegen}, which
|
|
@@ -27,7 +27,7 @@ import { imperativeBackend } from '../../codegen/backends/imperative.js';
|
|
|
27
27
|
// ============================================================================
|
|
28
28
|
// Constants
|
|
29
29
|
// ============================================================================
|
|
30
|
-
// Control-flow components that live in fluixi, NOT @fluixi/dom
|
|
30
|
+
// Control-flow components that live in fluixi, NOT @fluixi/dom, they must
|
|
31
31
|
// be auto-imported from core (dom doesn't export them).
|
|
32
32
|
const CORE_ONLY_CONTROL_FLOW = new Set(CORE_CONTROL_FLOW);
|
|
33
33
|
// Router components auto-imported (from routerModule) the same way control flow is:
|
|
@@ -168,7 +168,7 @@ export default declare((api, options = {}) => {
|
|
|
168
168
|
// enabling resolution can never change what an existing file means.
|
|
169
169
|
//
|
|
170
170
|
// Grouped by module so several components from one package share a single
|
|
171
|
-
// declaration, and emitted with the local name equal to the tag
|
|
171
|
+
// declaration, and emitted with the local name equal to the tag, the
|
|
172
172
|
// generated code refers to the tag, not to the export.
|
|
173
173
|
// Deferred components become value bindings, not imports: a literal
|
|
174
174
|
// `import()` is what lets the bundler split, hash and tree-shake the chunk
|
|
@@ -232,7 +232,7 @@ export default declare((api, options = {}) => {
|
|
|
232
232
|
t.variableDeclarator(t.identifier(name),
|
|
233
233
|
// Just the HTML. Parsing is deferred to `templateNode`, which
|
|
234
234
|
// knows whether this is a server render, a hydration or a fresh
|
|
235
|
-
// client render
|
|
235
|
+
// client render: a module-scope `createTemplate` would touch
|
|
236
236
|
// `document` at import time and break SSR outright.
|
|
237
237
|
t.stringLiteral(html)),
|
|
238
238
|
]));
|
|
@@ -242,7 +242,7 @@ export default declare((api, options = {}) => {
|
|
|
242
242
|
}
|
|
243
243
|
// Add all imports at the top, deduped. When a file mixes inline JSX
|
|
244
244
|
// and html`` (format 'both'), the two injection paths can each emit an
|
|
245
|
-
// import for the same module/name
|
|
245
|
+
// import for the same module/name: merge per-module and drop repeated
|
|
246
246
|
// specifiers so we never redeclare a binding.
|
|
247
247
|
if (imports.length > 0) {
|
|
248
248
|
path.node.body.unshift(...dedupeImports(imports));
|
|
@@ -262,7 +262,7 @@ export default declare((api, options = {}) => {
|
|
|
262
262
|
},
|
|
263
263
|
TaggedTemplateExpression(path, state) {
|
|
264
264
|
// `html`...`` and `svg`...`` lower through the same IR and the same
|
|
265
|
-
// backend as JSX
|
|
265
|
+
// backend as JSX: one pipeline, two authoring syntaxes.
|
|
266
266
|
if (compileLit &&
|
|
267
267
|
t.isIdentifier(path.node.tag) &&
|
|
268
268
|
(path.node.tag.name === litTag || path.node.tag.name === 'svg')) {
|
|
@@ -278,14 +278,14 @@ export default declare((api, options = {}) => {
|
|
|
278
278
|
/**
|
|
279
279
|
* Two usages of one component in the same file share a binding, so their strategies
|
|
280
280
|
* have to agree. The earlier-loading one wins: the module is in whichever chunk loads
|
|
281
|
-
* first regardless, so deferring the other buys nothing
|
|
281
|
+
* first regardless, so deferring the other buys nothing, the same reasoning as the
|
|
282
282
|
* collapse pass, applied within a file.
|
|
283
283
|
*/
|
|
284
284
|
/**
|
|
285
285
|
* What to do with JSX or a template found inside an expression: resolve its
|
|
286
286
|
* component references and record what the module needs, exactly as the
|
|
287
287
|
* top-level node gets. The IR itself is emitted and dropped by the walk, so
|
|
288
|
-
* anything not taken off it here is lost
|
|
288
|
+
* anything not taken off it here is lost: which is how `{(b) => <Input/>}`
|
|
289
289
|
* came out referring to a component nothing imported.
|
|
290
290
|
*/
|
|
291
291
|
function nestedHook(state) {
|
|
@@ -338,7 +338,7 @@ function adoptTemplates(code, templates, state) {
|
|
|
338
338
|
}
|
|
339
339
|
// One pass, not one replacement per id. The backend's local ids and the hoisted names
|
|
340
340
|
// share the `_tmpl$N` namespace, so replacing them in sequence can rewrite a name that
|
|
341
|
-
// an earlier replacement just produced
|
|
341
|
+
// an earlier replacement just produced: which silently points a template at another
|
|
342
342
|
// template's HTML.
|
|
343
343
|
return code.replace(/_tmpl\$\d+/g, (id) => rename.get(id) ?? id);
|
|
344
344
|
}
|
|
@@ -348,7 +348,7 @@ function emitViaIR(node, state) {
|
|
|
348
348
|
const used = new Set();
|
|
349
349
|
const ir = buildIR(node, used, nestedHook(state));
|
|
350
350
|
// The same passes the lit path runs. Without them `codegen: 'ir'` silently skipped
|
|
351
|
-
// resolution entirely
|
|
351
|
+
// resolution entirely: a resolved tag compiled to a reference with no import.
|
|
352
352
|
resolveComponentSources(ir, {
|
|
353
353
|
resolver: state.componentResolver,
|
|
354
354
|
modules: {
|
|
@@ -402,7 +402,7 @@ function dedupeImports(imports) {
|
|
|
402
402
|
}
|
|
403
403
|
/**
|
|
404
404
|
* Lit-pipeline path: build IR from a `` html`...` `` template, emit through the
|
|
405
|
-
* imperative backend, reparse. Mirrors emitViaIR
|
|
405
|
+
* imperative backend, reparse. Mirrors emitViaIR, the whole point is that lit
|
|
406
406
|
* and JSX share one IR + one backend. Collects runtime imports and the delegated
|
|
407
407
|
* events used so Program.exit wires them.
|
|
408
408
|
*/
|
|
@@ -411,7 +411,7 @@ function emitLitViaIR(node, state) {
|
|
|
411
411
|
const svg = t.isIdentifier(node.tag) && node.tag.name === 'svg';
|
|
412
412
|
const ir = buildIRFromLit(node, used, { svg, onNested: nestedHook(state) });
|
|
413
413
|
// Resolve pass: annotate each component reference with where it comes from, before
|
|
414
|
-
// codegen. Bindings are not checked here
|
|
414
|
+
// codegen. Bindings are not checked here: Program.exit knows the whole file's scope
|
|
415
415
|
// and drops any injected import whose name turns out to be bound.
|
|
416
416
|
resolveComponentSources(ir, {
|
|
417
417
|
resolver: state.componentResolver,
|
|
@@ -434,7 +434,7 @@ function emitLitViaIR(node, state) {
|
|
|
434
434
|
collectRuntimeNeeds(ir, state);
|
|
435
435
|
state.hasLitIR = true;
|
|
436
436
|
// The IR is emitted as a string and reparsed, so the resulting nodes carry no
|
|
437
|
-
// position
|
|
437
|
+
// position: which is why compiled html`` had no source map at all. Give every
|
|
438
438
|
// generated node the template's own location so a breakpoint or stack frame
|
|
439
439
|
// lands on the template instead of nowhere.
|
|
440
440
|
const expression = template.expression(adoptTemplates(code, templates, state), {
|
|
@@ -487,7 +487,7 @@ function collectRuntimeNeeds(node, state) {
|
|
|
487
487
|
if (node.kind === 'component' && node.source) {
|
|
488
488
|
// Provenance was decided by the resolve pass and recorded on the node; this only
|
|
489
489
|
// translates it into the two things Program.exit wires. Reading it here rather
|
|
490
|
-
// than re-resolving is the point
|
|
490
|
+
// than re-resolving is the point: one decision, so import injection and every
|
|
491
491
|
// later pass cannot disagree.
|
|
492
492
|
if (node.source.origin === 'builtin') {
|
|
493
493
|
state.controlFlowComponents.add(node.name);
|