@fluixi/compiler 1.0.0-alpha.100
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/LICENSE +21 -0
- package/README.md +131 -0
- package/dist/analyze/expr-shape.cjs +62 -0
- package/dist/analyze/expr-shape.d.cts +14 -0
- package/dist/analyze/expr-shape.d.ts +15 -0
- package/dist/analyze/expr-shape.d.ts.map +1 -0
- package/dist/analyze/expr-shape.js +37 -0
- package/dist/analyze/expr-shape.mjs +41 -0
- package/dist/analyze/intrinsics.cjs +112 -0
- package/dist/analyze/intrinsics.d.cts +80 -0
- package/dist/analyze/intrinsics.d.ts +81 -0
- package/dist/analyze/intrinsics.d.ts.map +1 -0
- package/dist/analyze/intrinsics.js +126 -0
- package/dist/analyze/intrinsics.mjs +91 -0
- 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 -0
- package/dist/analyze/props-destructure.d.cts +83 -0
- package/dist/analyze/props-destructure.d.ts +84 -0
- package/dist/analyze/props-destructure.d.ts.map +1 -0
- package/dist/analyze/props-destructure.js +272 -0
- package/dist/analyze/props-destructure.mjs +205 -0
- package/dist/analyze/reactive-bindings.cjs +210 -0
- package/dist/analyze/reactive-bindings.d.cts +42 -0
- package/dist/analyze/reactive-bindings.d.ts +43 -0
- package/dist/analyze/reactive-bindings.d.ts.map +1 -0
- package/dist/analyze/reactive-bindings.js +191 -0
- package/dist/analyze/reactive-bindings.mjs +187 -0
- package/dist/analyze/reactive-expr.cjs +38 -0
- package/dist/analyze/reactive-expr.d.cts +38 -0
- package/dist/analyze/reactive-expr.d.ts +39 -0
- package/dist/analyze/reactive-expr.d.ts.map +1 -0
- package/dist/analyze/reactive-expr.js +31 -0
- package/dist/analyze/reactive-expr.mjs +17 -0
- package/dist/analyze/static-graph.cjs +831 -0
- package/dist/analyze/static-graph.d.cts +102 -0
- package/dist/analyze/static-graph.d.ts +103 -0
- package/dist/analyze/static-graph.d.ts.map +1 -0
- package/dist/analyze/static-graph.js +871 -0
- package/dist/analyze/static-graph.mjs +813 -0
- package/dist/babel-I6BUWUCU.mjs +636 -0
- package/dist/chunk-3AICWNF7.mjs +92 -0
- package/dist/chunk-6CWJWGE2.mjs +2170 -0
- package/dist/chunk-C3XPDB4Y.mjs +16 -0
- package/dist/chunk-GX5XV6Z7.mjs +190 -0
- package/dist/chunk-HXEXPWJ2.mjs +999 -0
- package/dist/chunk-NU3W67UZ.mjs +584 -0
- package/dist/chunk-SKAVY75W.mjs +11 -0
- package/dist/codegen/backend.cjs +18 -0
- package/dist/codegen/backend.d.cts +35 -0
- package/dist/codegen/backend.d.ts +36 -0
- package/dist/codegen/backend.d.ts.map +1 -0
- package/dist/codegen/backend.js +1 -0
- package/dist/codegen/backend.mjs +0 -0
- package/dist/codegen/backends/imperative.cjs +577 -0
- package/dist/codegen/backends/imperative.d.cts +11 -0
- package/dist/codegen/backends/imperative.d.ts +12 -0
- package/dist/codegen/backends/imperative.d.ts.map +1 -0
- package/dist/codegen/backends/imperative.js +362 -0
- package/dist/codegen/backends/imperative.mjs +554 -0
- package/dist/codegen/contract.cjs +52 -0
- package/dist/codegen/contract.d.cts +24 -0
- package/dist/codegen/contract.d.ts +25 -0
- package/dist/codegen/contract.d.ts.map +1 -0
- package/dist/codegen/contract.js +30 -0
- package/dist/codegen/contract.mjs +31 -0
- package/dist/codegen/partial-template.cjs +176 -0
- package/dist/codegen/partial-template.d.cts +61 -0
- package/dist/codegen/partial-template.d.ts +62 -0
- package/dist/codegen/partial-template.d.ts.map +1 -0
- package/dist/codegen/partial-template.js +0 -0
- package/dist/codegen/partial-template.mjs +153 -0
- package/dist/codegen/serialize-static.cjs +125 -0
- package/dist/codegen/serialize-static.d.cts +38 -0
- package/dist/codegen/serialize-static.d.ts +39 -0
- package/dist/codegen/serialize-static.d.ts.map +1 -0
- package/dist/codegen/serialize-static.js +165 -0
- package/dist/codegen/serialize-static.mjs +104 -0
- package/dist/frontend/babel/build-ir-lit.cjs +1933 -0
- package/dist/frontend/babel/build-ir-lit.d.cts +26 -0
- package/dist/frontend/babel/build-ir-lit.d.ts +27 -0
- package/dist/frontend/babel/build-ir-lit.d.ts.map +1 -0
- package/dist/frontend/babel/build-ir-lit.js +13 -0
- package/dist/frontend/babel/build-ir-lit.mjs +1902 -0
- package/dist/frontend/babel/build-ir.cjs +1948 -0
- package/dist/frontend/babel/build-ir.d.cts +35 -0
- package/dist/frontend/babel/build-ir.d.ts +36 -0
- package/dist/frontend/babel/build-ir.d.ts.map +1 -0
- package/dist/frontend/babel/build-ir.js +124 -0
- package/dist/frontend/babel/build-ir.mjs +1919 -0
- package/dist/frontend/babel/index.cjs +2610 -0
- package/dist/frontend/babel/index.d.cts +33 -0
- package/dist/frontend/babel/index.d.ts +34 -0
- package/dist/frontend/babel/index.d.ts.map +1 -0
- package/dist/frontend/babel/index.js +65 -0
- package/dist/frontend/babel/index.mjs +2580 -0
- package/dist/frontend/babel/lower-template.cjs +1931 -0
- package/dist/frontend/babel/lower-template.d.cts +23 -0
- package/dist/frontend/babel/lower-template.d.ts +24 -0
- package/dist/frontend/babel/lower-template.d.ts.map +1 -0
- package/dist/frontend/babel/lower-template.js +64 -0
- package/dist/frontend/babel/lower-template.mjs +1902 -0
- package/dist/frontend/babel/plugin.cjs +2556 -0
- package/dist/frontend/babel/plugin.d.cts +95 -0
- package/dist/frontend/babel/plugin.d.ts +96 -0
- package/dist/frontend/babel/plugin.d.ts.map +1 -0
- package/dist/frontend/babel/plugin.js +523 -0
- package/dist/frontend/babel/plugin.mjs +2527 -0
- package/dist/frontend/babel/server-functions.cjs +110 -0
- package/dist/frontend/babel/server-functions.d.cts +10 -0
- package/dist/frontend/babel/server-functions.d.ts +11 -0
- package/dist/frontend/babel/server-functions.d.ts.map +1 -0
- package/dist/frontend/babel/server-functions.js +81 -0
- package/dist/frontend/babel/server-functions.mjs +89 -0
- package/dist/frontend/babel/types.cjs +18 -0
- package/dist/frontend/babel/types.d.cts +33 -0
- package/dist/frontend/babel/types.d.ts +34 -0
- package/dist/frontend/babel/types.d.ts.map +1 -0
- package/dist/frontend/babel/types.js +1 -0
- package/dist/frontend/babel/types.mjs +0 -0
- package/dist/frontend/types.cjs +18 -0
- package/dist/frontend/types.d.cts +25 -0
- package/dist/frontend/types.d.ts +26 -0
- package/dist/frontend/types.d.ts.map +1 -0
- package/dist/frontend/types.js +1 -0
- package/dist/frontend/types.mjs +0 -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 +1957 -0
- package/dist/index.d.cts +27 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +38 -0
- package/dist/index.mjs +1949 -0
- package/dist/integrations.cjs +5705 -0
- package/dist/integrations.d.cts +215 -0
- package/dist/integrations.d.ts +216 -0
- package/dist/integrations.d.ts.map +1 -0
- package/dist/integrations.js +566 -0
- package/dist/integrations.mjs +810 -0
- package/dist/ir/nodes.cjs +18 -0
- package/dist/ir/nodes.d.cts +168 -0
- package/dist/ir/nodes.d.ts +169 -0
- package/dist/ir/nodes.d.ts.map +1 -0
- package/dist/ir/nodes.js +1 -0
- package/dist/ir/nodes.mjs +0 -0
- package/dist/lower/compile-template.cjs +1670 -0
- package/dist/lower/compile-template.d.cts +82 -0
- package/dist/lower/compile-template.d.ts +83 -0
- package/dist/lower/compile-template.d.ts.map +1 -0
- package/dist/lower/compile-template.js +79 -0
- package/dist/lower/compile-template.mjs +1662 -0
- package/dist/lower/entities.cjs +288 -0
- package/dist/lower/entities.d.cts +1 -0
- package/dist/lower/entities.d.ts +2 -0
- package/dist/lower/entities.d.ts.map +1 -0
- package/dist/lower/entities.js +54 -0
- package/dist/lower/entities.mjs +267 -0
- package/dist/lower/jsx.cjs +1101 -0
- package/dist/lower/jsx.d.cts +33 -0
- package/dist/lower/jsx.d.ts +34 -0
- package/dist/lower/jsx.d.ts.map +1 -0
- package/dist/lower/jsx.js +414 -0
- package/dist/lower/jsx.mjs +1078 -0
- package/dist/lower/template.cjs +1354 -0
- package/dist/lower/template.d.cts +53 -0
- package/dist/lower/template.d.ts +54 -0
- package/dist/lower/template.d.ts.map +1 -0
- package/dist/lower/template.js +542 -0
- package/dist/lower/template.mjs +1335 -0
- package/dist/lower/text.cjs +42 -0
- package/dist/lower/text.d.cts +10 -0
- package/dist/lower/text.d.ts +11 -0
- package/dist/lower/text.d.ts.map +1 -0
- package/dist/lower/text.js +31 -0
- package/dist/lower/text.mjs +21 -0
- package/dist/optimize/analyze-static.cjs +112 -0
- package/dist/optimize/analyze-static.d.cts +39 -0
- package/dist/optimize/analyze-static.d.ts +40 -0
- package/dist/optimize/analyze-static.d.ts.map +1 -0
- package/dist/optimize/analyze-static.js +131 -0
- package/dist/optimize/analyze-static.mjs +91 -0
- package/dist/optimize/collapse-strategies.cjs +90 -0
- package/dist/optimize/collapse-strategies.d.cts +30 -0
- package/dist/optimize/collapse-strategies.d.ts +31 -0
- package/dist/optimize/collapse-strategies.d.ts.map +1 -0
- package/dist/optimize/collapse-strategies.js +33 -0
- package/dist/optimize/collapse-strategies.mjs +67 -0
- package/dist/options.cjs +33 -0
- package/dist/options.d.cts +39 -0
- package/dist/options.d.ts +40 -0
- package/dist/options.d.ts.map +1 -0
- package/dist/options.js +8 -0
- package/dist/options.mjs +12 -0
- package/dist/resolve/builtins.cjs +73 -0
- package/dist/resolve/builtins.d.cts +68 -0
- package/dist/resolve/builtins.d.ts +69 -0
- package/dist/resolve/builtins.d.ts.map +1 -0
- package/dist/resolve/builtins.js +64 -0
- package/dist/resolve/builtins.mjs +53 -0
- package/dist/resolve/component-globals.cjs +272 -0
- package/dist/resolve/component-globals.d.cts +88 -0
- package/dist/resolve/component-globals.d.ts +89 -0
- package/dist/resolve/component-globals.d.ts.map +1 -0
- package/dist/resolve/component-globals.js +160 -0
- package/dist/resolve/component-globals.mjs +249 -0
- package/dist/resolve/component-resolver.cjs +80 -0
- package/dist/resolve/component-resolver.d.cts +68 -0
- package/dist/resolve/component-resolver.d.ts +69 -0
- package/dist/resolve/component-resolver.d.ts.map +1 -0
- package/dist/resolve/component-resolver.js +95 -0
- package/dist/resolve/component-resolver.mjs +59 -0
- package/dist/resolve/load-directive.cjs +93 -0
- package/dist/resolve/load-directive.d.cts +53 -0
- package/dist/resolve/load-directive.d.ts +54 -0
- package/dist/resolve/load-directive.d.ts.map +1 -0
- package/dist/resolve/load-directive.js +93 -0
- package/dist/resolve/load-directive.mjs +72 -0
- package/dist/resolve/resolve-ir.cjs +108 -0
- package/dist/resolve/resolve-ir.d.cts +53 -0
- package/dist/resolve/resolve-ir.d.ts +54 -0
- package/dist/resolve/resolve-ir.d.ts.map +1 -0
- package/dist/resolve/resolve-ir.js +58 -0
- package/dist/resolve/resolve-ir.mjs +85 -0
- package/dist/resolve/write-globals.cjs +383 -0
- package/dist/resolve/write-globals.d.cts +36 -0
- package/dist/resolve/write-globals.d.ts +37 -0
- package/dist/resolve/write-globals.d.ts.map +1 -0
- package/dist/resolve/write-globals.js +169 -0
- package/dist/resolve/write-globals.mjs +362 -0
- package/dist/server-fns-VZLHMQTC.mjs +79 -0
- package/dist/server-functions-UAZKOLZW.mjs +82 -0
- package/dist/transform/bindings.cjs +71 -0
- package/dist/transform/bindings.d.cts +16 -0
- package/dist/transform/bindings.d.ts +17 -0
- package/dist/transform/bindings.d.ts.map +1 -0
- package/dist/transform/bindings.js +69 -0
- package/dist/transform/bindings.mjs +50 -0
- package/dist/transform/index.cjs +3837 -0
- package/dist/transform/index.d.cts +15 -0
- package/dist/transform/index.d.ts +16 -0
- package/dist/transform/index.d.ts.map +1 -0
- package/dist/transform/index.js +12 -0
- package/dist/transform/index.mjs +4882 -0
- package/dist/transform/intrinsics.cjs +261 -0
- package/dist/transform/intrinsics.d.cts +33 -0
- package/dist/transform/intrinsics.d.ts +34 -0
- package/dist/transform/intrinsics.d.ts.map +1 -0
- package/dist/transform/intrinsics.js +120 -0
- package/dist/transform/intrinsics.mjs +238 -0
- package/dist/transform/props.cjs +441 -0
- package/dist/transform/props.d.cts +45 -0
- package/dist/transform/props.d.ts +46 -0
- package/dist/transform/props.d.ts.map +1 -0
- package/dist/transform/props.js +221 -0
- package/dist/transform/props.mjs +1487 -0
- package/dist/transform/server-fn-id.cjs +35 -0
- package/dist/transform/server-fn-id.d.cts +9 -0
- package/dist/transform/server-fn-id.d.ts +10 -0
- package/dist/transform/server-fn-id.d.ts.map +1 -0
- package/dist/transform/server-fn-id.js +18 -0
- package/dist/transform/server-fn-id.mjs +14 -0
- package/dist/transform/server-fns.cjs +114 -0
- package/dist/transform/server-fns.d.cts +12 -0
- package/dist/transform/server-fns.d.ts +13 -0
- package/dist/transform/server-fns.d.ts.map +1 -0
- package/dist/transform/server-fns.js +94 -0
- package/dist/transform/server-fns.mjs +1160 -0
- package/dist/transform/source-locations.cjs +393 -0
- package/dist/transform/source-locations.d.cts +48 -0
- package/dist/transform/source-locations.d.ts +49 -0
- package/dist/transform/source-locations.d.ts.map +1 -0
- package/dist/transform/source-locations.js +303 -0
- package/dist/transform/source-locations.mjs +370 -0
- package/dist/transform/styles.cjs +606 -0
- package/dist/transform/styles.d.cts +237 -0
- package/dist/transform/styles.d.ts +238 -0
- package/dist/transform/styles.d.ts.map +1 -0
- package/dist/transform/styles.js +743 -0
- package/dist/transform/styles.mjs +671 -0
- package/dist/transform/templates.cjs +3806 -0
- package/dist/transform/templates.d.cts +82 -0
- package/dist/transform/templates.d.ts +83 -0
- package/dist/transform/templates.d.ts.map +1 -0
- package/dist/transform/templates.js +613 -0
- package/dist/transform/templates.mjs +4852 -0
- package/dist/transform-3W45L3EA.mjs +951 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -0
- package/dist/vite-styles.cjs +223 -0
- package/dist/vite-styles.d.cts +68 -0
- package/dist/vite-styles.d.ts +69 -0
- package/dist/vite-styles.d.ts.map +1 -0
- package/dist/vite-styles.js +241 -0
- package/dist/vite-styles.mjs +214 -0
- package/package.json +141 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Strategy collapsing: demote a deferred reference whose module is already present.
|
|
3
|
+
*
|
|
4
|
+
* This is not a nice-to-have. Without it the naive feature is a regression: if a module
|
|
5
|
+
* is referenced eagerly anywhere in the compilation unit, it is in the parent chunk
|
|
6
|
+
* already, so a `load:visible` boundary elsewhere adds a wrapper, a promise and a
|
|
7
|
+
* re-render in order to fetch nothing. The bytes are paid twice, once in the chunk,
|
|
8
|
+
* once in the deferral machinery: and the component renders later than it needs to.
|
|
9
|
+
*
|
|
10
|
+
* Collapsing runs per module, not per component name, because a chunk is a module:
|
|
11
|
+
* `<Button>` eager and `<ButtonGroup load:visible>` from the same package means the
|
|
12
|
+
* package is already loaded, so deferring the second buys nothing.
|
|
13
|
+
*
|
|
14
|
+
* `never` is not collapsed. It means "no client code at all", which is a statement about
|
|
15
|
+
* what should exist rather than about when to fetch it; an eager sibling does not make a
|
|
16
|
+
* server-only component suddenly belong in the client bundle. That combination is
|
|
17
|
+
* contradictory and reported instead.
|
|
18
|
+
*/
|
|
19
|
+
import type { IRNode } from '../ir/nodes.js';
|
|
20
|
+
export interface CollapseReport {
|
|
21
|
+
/** Modules demoted to eager, with the reference count that was demoted. */
|
|
22
|
+
collapsed: Map<string, number>;
|
|
23
|
+
/**
|
|
24
|
+
* Modules referenced both as `load:never` and in a way that needs client code.
|
|
25
|
+
* Contradictory rather than optimisable, so it is reported and left alone.
|
|
26
|
+
*/
|
|
27
|
+
conflicted: string[];
|
|
28
|
+
}
|
|
29
|
+
/** Demote deferred references to modules that are already in the chunk. */
|
|
30
|
+
export declare function collapseStrategies(root: IRNode | IRNode[]): CollapseReport;
|
|
31
|
+
//# sourceMappingURL=collapse-strategies.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collapse-strategies.d.ts","sourceRoot":"","sources":["../../src/optimize/collapse-strategies.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,KAAK,EAAE,MAAM,EAAe,MAAM,gBAAgB,CAAC;AAI1D,MAAM,WAAW,cAAc;IAC7B,2EAA2E;IAC3E,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B;;;OAGG;IACH,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB;AAED,2EAA2E;AAC3E,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,cAAc,CA2B1E"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { isDeferred } from '../resolve/load-directive.js';
|
|
2
|
+
import { walk } from '../resolve/resolve-ir.js';
|
|
3
|
+
/** Demote deferred references to modules that are already in the chunk. */
|
|
4
|
+
export function collapseStrategies(root) {
|
|
5
|
+
const components = [];
|
|
6
|
+
walk(root, (node) => {
|
|
7
|
+
if (node.kind === 'component' && node.source)
|
|
8
|
+
components.push(node);
|
|
9
|
+
});
|
|
10
|
+
const eager = new Set();
|
|
11
|
+
const never = new Set();
|
|
12
|
+
for (const node of components) {
|
|
13
|
+
const { module, loading } = node.source;
|
|
14
|
+
if (loading.kind === 'eager')
|
|
15
|
+
eager.add(module);
|
|
16
|
+
if (loading.kind === 'never')
|
|
17
|
+
never.add(module);
|
|
18
|
+
}
|
|
19
|
+
const collapsed = new Map();
|
|
20
|
+
for (const node of components) {
|
|
21
|
+
const source = node.source;
|
|
22
|
+
if (!isDeferred(source.loading))
|
|
23
|
+
continue;
|
|
24
|
+
if (!eager.has(source.module))
|
|
25
|
+
continue;
|
|
26
|
+
source.loading = { kind: 'eager' };
|
|
27
|
+
collapsed.set(source.module, (collapsed.get(source.module) ?? 0) + 1);
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
collapsed,
|
|
31
|
+
conflicted: [...never].filter((m) => eager.has(m)),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// src/resolve/load-directive.ts
|
|
2
|
+
function isDeferred(strategy) {
|
|
3
|
+
return strategy.kind !== "eager" && strategy.kind !== "never";
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
// src/resolve/builtins.ts
|
|
7
|
+
var DOM_CONTROL_FLOW = [
|
|
8
|
+
"Show",
|
|
9
|
+
"For",
|
|
10
|
+
"Index",
|
|
11
|
+
"Switch",
|
|
12
|
+
"Match",
|
|
13
|
+
"Portal",
|
|
14
|
+
"Dynamic",
|
|
15
|
+
"ErrorBoundary"
|
|
16
|
+
];
|
|
17
|
+
var CORE_CONTROL_FLOW = ["Suspense", "SuspenseList", "Await"];
|
|
18
|
+
var ROUTER_COMPONENTS = ["Router", "Outlet", "Redirect", "Link"];
|
|
19
|
+
var BUILTIN_COMPONENTS = [
|
|
20
|
+
...DOM_CONTROL_FLOW,
|
|
21
|
+
...CORE_CONTROL_FLOW,
|
|
22
|
+
...ROUTER_COMPONENTS
|
|
23
|
+
];
|
|
24
|
+
var RESERVED_COMPONENTS = /* @__PURE__ */ new Set([
|
|
25
|
+
...DOM_CONTROL_FLOW,
|
|
26
|
+
...CORE_CONTROL_FLOW
|
|
27
|
+
]);
|
|
28
|
+
|
|
29
|
+
// src/resolve/resolve-ir.ts
|
|
30
|
+
function walk(root, visit) {
|
|
31
|
+
const nodes = Array.isArray(root) ? root : [root];
|
|
32
|
+
for (const node of nodes) {
|
|
33
|
+
visit(node);
|
|
34
|
+
const children = node.children;
|
|
35
|
+
if (children) walk(children, visit);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// src/optimize/collapse-strategies.ts
|
|
40
|
+
function collapseStrategies(root) {
|
|
41
|
+
const components = [];
|
|
42
|
+
walk(root, (node) => {
|
|
43
|
+
if (node.kind === "component" && node.source) components.push(node);
|
|
44
|
+
});
|
|
45
|
+
const eager = /* @__PURE__ */ new Set();
|
|
46
|
+
const never = /* @__PURE__ */ new Set();
|
|
47
|
+
for (const node of components) {
|
|
48
|
+
const { module, loading } = node.source;
|
|
49
|
+
if (loading.kind === "eager") eager.add(module);
|
|
50
|
+
if (loading.kind === "never") never.add(module);
|
|
51
|
+
}
|
|
52
|
+
const collapsed = /* @__PURE__ */ new Map();
|
|
53
|
+
for (const node of components) {
|
|
54
|
+
const source = node.source;
|
|
55
|
+
if (!isDeferred(source.loading)) continue;
|
|
56
|
+
if (!eager.has(source.module)) continue;
|
|
57
|
+
source.loading = { kind: "eager" };
|
|
58
|
+
collapsed.set(source.module, (collapsed.get(source.module) ?? 0) + 1);
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
collapsed,
|
|
62
|
+
conflicted: [...never].filter((m) => eager.has(m))
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
export {
|
|
66
|
+
collapseStrategies
|
|
67
|
+
};
|
package/dist/options.cjs
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/options.ts
|
|
21
|
+
var options_exports = {};
|
|
22
|
+
__export(options_exports, {
|
|
23
|
+
defaultOptions: () => defaultOptions
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(options_exports);
|
|
26
|
+
var defaultOptions = {
|
|
27
|
+
backend: "imperative",
|
|
28
|
+
moduleName: "@fluixi/dom",
|
|
29
|
+
delegateEvents: true,
|
|
30
|
+
hydratable: false,
|
|
31
|
+
sourceMaps: true,
|
|
32
|
+
dev: false
|
|
33
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { ComponentResolverRule } from './resolve/component-resolver.cjs';
|
|
2
|
+
/**
|
|
3
|
+
* Public compiler options. This schema is the stable public API, it stays put
|
|
4
|
+
* as backends change. Switching DOM strategy is `backend`, not a rewrite.
|
|
5
|
+
*/
|
|
6
|
+
export interface CompilerOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Clone static subtrees from a `<template>` instead of building them element by
|
|
9
|
+
* element. Roughly 2x faster to instantiate, but **client-only**: `createTemplate`
|
|
10
|
+
* produces real DOM nodes, which the SSR renderer's ServerElement tree rejects, and a
|
|
11
|
+
* clone creates a fresh node where hydration must adopt the existing one. Opt in for
|
|
12
|
+
* a client-rendered app; leave off wherever SSR or hydration is involved.
|
|
13
|
+
*/
|
|
14
|
+
templateClone?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Also clone subtrees whose *structure* is static but which contain dynamic holes ,
|
|
17
|
+
* the common shape. Roughly halves the emitted code for such a subtree and replaces
|
|
18
|
+
* per-element construction with one clone.
|
|
19
|
+
*
|
|
20
|
+
* Works under SSR and hydration: each hole is bracketed by `<!--fx-->` markers, so its
|
|
21
|
+
* content is exactly the nodes between them and the server's markup has the same shape
|
|
22
|
+
* as the client's template. Hydration adopts those nodes rather than rebuilding them.
|
|
23
|
+
*/
|
|
24
|
+
partialTemplates?: boolean;
|
|
25
|
+
/** which codegen backend to use */
|
|
26
|
+
backend?: 'imperative' | 'template-clone';
|
|
27
|
+
/** runtime module emitted symbols are imported from */
|
|
28
|
+
moduleName?: string;
|
|
29
|
+
delegateEvents?: boolean;
|
|
30
|
+
hydratable?: boolean;
|
|
31
|
+
sourceMaps?: boolean;
|
|
32
|
+
dev?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Rules that resolve an unbound capitalised tag to a module, so a component can be
|
|
35
|
+
* used in a template without an import. See `createComponentResolver`.
|
|
36
|
+
*/
|
|
37
|
+
resolve?: readonly ComponentResolverRule[];
|
|
38
|
+
}
|
|
39
|
+
export declare const defaultOptions: CompilerOptions;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ComponentResolverRule } from './resolve/component-resolver.js';
|
|
2
|
+
/**
|
|
3
|
+
* Public compiler options. This schema is the stable public API, it stays put
|
|
4
|
+
* as backends change. Switching DOM strategy is `backend`, not a rewrite.
|
|
5
|
+
*/
|
|
6
|
+
export interface CompilerOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Clone static subtrees from a `<template>` instead of building them element by
|
|
9
|
+
* element. Roughly 2x faster to instantiate, but **client-only**: `createTemplate`
|
|
10
|
+
* produces real DOM nodes, which the SSR renderer's ServerElement tree rejects, and a
|
|
11
|
+
* clone creates a fresh node where hydration must adopt the existing one. Opt in for
|
|
12
|
+
* a client-rendered app; leave off wherever SSR or hydration is involved.
|
|
13
|
+
*/
|
|
14
|
+
templateClone?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Also clone subtrees whose *structure* is static but which contain dynamic holes ,
|
|
17
|
+
* the common shape. Roughly halves the emitted code for such a subtree and replaces
|
|
18
|
+
* per-element construction with one clone.
|
|
19
|
+
*
|
|
20
|
+
* Works under SSR and hydration: each hole is bracketed by `<!--fx-->` markers, so its
|
|
21
|
+
* content is exactly the nodes between them and the server's markup has the same shape
|
|
22
|
+
* as the client's template. Hydration adopts those nodes rather than rebuilding them.
|
|
23
|
+
*/
|
|
24
|
+
partialTemplates?: boolean;
|
|
25
|
+
/** which codegen backend to use */
|
|
26
|
+
backend?: 'imperative' | 'template-clone';
|
|
27
|
+
/** runtime module emitted symbols are imported from */
|
|
28
|
+
moduleName?: string;
|
|
29
|
+
delegateEvents?: boolean;
|
|
30
|
+
hydratable?: boolean;
|
|
31
|
+
sourceMaps?: boolean;
|
|
32
|
+
dev?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Rules that resolve an unbound capitalised tag to a module, so a component can be
|
|
35
|
+
* used in a template without an import. See `createComponentResolver`.
|
|
36
|
+
*/
|
|
37
|
+
resolve?: readonly ComponentResolverRule[];
|
|
38
|
+
}
|
|
39
|
+
export declare const defaultOptions: CompilerOptions;
|
|
40
|
+
//# sourceMappingURL=options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAE7E;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;;;OAMG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;;;;;;OAQG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B,mCAAmC;IACnC,OAAO,CAAC,EAAE,YAAY,GAAG,gBAAgB,CAAC;IAC1C,uDAAuD;IACvD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd;;;OAGG;IACH,OAAO,CAAC,EAAE,SAAS,qBAAqB,EAAE,CAAC;CAC5C;AAED,eAAO,MAAM,cAAc,EAAE,eAO5B,CAAC"}
|
package/dist/options.js
ADDED
package/dist/options.mjs
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/*! @fluixi/compiler v1.0.0-alpha.100 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
|
|
2
|
+
"use strict";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/resolve/builtins.ts
|
|
22
|
+
var builtins_exports = {};
|
|
23
|
+
__export(builtins_exports, {
|
|
24
|
+
BUILTIN_COMPONENTS: () => BUILTIN_COMPONENTS,
|
|
25
|
+
CORE_CONTROL_FLOW: () => CORE_CONTROL_FLOW,
|
|
26
|
+
DOM_CONTROL_FLOW: () => DOM_CONTROL_FLOW,
|
|
27
|
+
RESERVED_COMPONENTS: () => RESERVED_COMPONENTS,
|
|
28
|
+
ROUTER_COMPONENTS: () => ROUTER_COMPONENTS,
|
|
29
|
+
builtinComponentMap: () => builtinComponentMap,
|
|
30
|
+
builtinComponents: () => builtinComponents,
|
|
31
|
+
routerComponents: () => routerComponents
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(builtins_exports);
|
|
34
|
+
var DOM_CONTROL_FLOW = [
|
|
35
|
+
"Show",
|
|
36
|
+
"For",
|
|
37
|
+
"Index",
|
|
38
|
+
"Switch",
|
|
39
|
+
"Match",
|
|
40
|
+
"Portal",
|
|
41
|
+
"Dynamic",
|
|
42
|
+
"ErrorBoundary"
|
|
43
|
+
];
|
|
44
|
+
var CORE_CONTROL_FLOW = ["Suspense", "SuspenseList", "Await"];
|
|
45
|
+
var ROUTER_COMPONENTS = ["Router", "Outlet", "Redirect", "Link"];
|
|
46
|
+
var BUILTIN_COMPONENTS = [
|
|
47
|
+
...DOM_CONTROL_FLOW,
|
|
48
|
+
...CORE_CONTROL_FLOW,
|
|
49
|
+
...ROUTER_COMPONENTS
|
|
50
|
+
];
|
|
51
|
+
var RESERVED_COMPONENTS = /* @__PURE__ */ new Set([
|
|
52
|
+
...DOM_CONTROL_FLOW,
|
|
53
|
+
...CORE_CONTROL_FLOW
|
|
54
|
+
]);
|
|
55
|
+
function builtinComponentMap(modules = {}) {
|
|
56
|
+
const {
|
|
57
|
+
controlFlowModule = "@fluixi/dom",
|
|
58
|
+
coreModule = "@fluixi/core",
|
|
59
|
+
routerModule = "@fluixi/core/router"
|
|
60
|
+
} = modules;
|
|
61
|
+
const map = {};
|
|
62
|
+
for (const name of DOM_CONTROL_FLOW) map[name] = controlFlowModule;
|
|
63
|
+
for (const name of CORE_CONTROL_FLOW) map[name] = coreModule;
|
|
64
|
+
for (const name of ROUTER_COMPONENTS) map[name] = routerModule;
|
|
65
|
+
return map;
|
|
66
|
+
}
|
|
67
|
+
function builtinComponents(modules = {}) {
|
|
68
|
+
return { components: builtinComponentMap(modules) };
|
|
69
|
+
}
|
|
70
|
+
function routerComponents(routerModule) {
|
|
71
|
+
const module2 = routerModule ?? "@fluixi/core/router";
|
|
72
|
+
return { components: Object.fromEntries(ROUTER_COMPONENTS.map((n) => [n, module2])) };
|
|
73
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The components the compiler supplies without an import, as data.
|
|
3
|
+
*
|
|
4
|
+
* Two different things have always been bundled into one hardcoded `Set` per group:
|
|
5
|
+
* *which module a name comes from*, and *whether the name has special lowering*. Only
|
|
6
|
+
* the first is interesting outside the compiler, and every tool needs it, the TS
|
|
7
|
+
* plugin, to resolve `<Show>` for hover and go-to-definition; the language server, to
|
|
8
|
+
* complete and validate tags inside `` html`…` ``; a codemod, to materialise imports.
|
|
9
|
+
* Having no published source, `@fluixi/ts-plugin` duplicated the list and pinned it
|
|
10
|
+
* with a test that fails when the two drift.
|
|
11
|
+
*
|
|
12
|
+
* So the names live here, shaped as {@link ComponentMapRule} so they compose with
|
|
13
|
+
* user-configured `resolve` rules, and the compiler keeps its own sets for the parts
|
|
14
|
+
* that are genuinely about codegen.
|
|
15
|
+
*
|
|
16
|
+
* The split matters: control-flow names cannot become ordinary rules. `Show`, `For`,
|
|
17
|
+
* `Index` and `Match` read a reactive *value* prop inside their own tracking scope, so
|
|
18
|
+
* the compiler emits that prop as a getter: without it `each={items()}` snapshots once
|
|
19
|
+
* and never updates. They are also exempted from `createMemo` wrapping and may be
|
|
20
|
+
* replaced outright by `optimizeControlFlowComponent`. A rule only injects an import,
|
|
21
|
+
* so converting them would keep the import and silently drop the reactivity.
|
|
22
|
+
*
|
|
23
|
+
* Router components have no such behaviour: every reference to them in the plugin is
|
|
24
|
+
* import plumbing: so they are a plain rule.
|
|
25
|
+
*/
|
|
26
|
+
import type { ComponentMapRule } from './component-resolver.cjs';
|
|
27
|
+
/** Where the built-in groups come from when the host does not override the module. */
|
|
28
|
+
export interface BuiltinModules {
|
|
29
|
+
/** Control flow that lives in the DOM package. Default `@fluixi/dom`. */
|
|
30
|
+
controlFlowModule?: string;
|
|
31
|
+
/** Control flow that only exists in core. Default `@fluixi/core`. */
|
|
32
|
+
coreModule?: string;
|
|
33
|
+
/** Router components. Default `@fluixi/core/router`. */
|
|
34
|
+
routerModule?: string;
|
|
35
|
+
}
|
|
36
|
+
/** Control flow lowered against the DOM runtime. */
|
|
37
|
+
export declare const DOM_CONTROL_FLOW: readonly ["Show", "For", "Index", "Switch", "Match", "Portal", "Dynamic", "ErrorBoundary"];
|
|
38
|
+
/** Control flow that only `@fluixi/core` exports, importing it from dom resolves to nothing. */
|
|
39
|
+
export declare const CORE_CONTROL_FLOW: readonly ["Suspense", "SuspenseList", "Await"];
|
|
40
|
+
/**
|
|
41
|
+
* Router components.
|
|
42
|
+
*
|
|
43
|
+
* `Routes` is not a component (routing is `<Router routes={…}>`) and `lazy` is a call
|
|
44
|
+
* rather than a tag, so neither can be supplied this way.
|
|
45
|
+
*/
|
|
46
|
+
export declare const ROUTER_COMPONENTS: readonly ["Router", "Outlet", "Redirect", "Link"];
|
|
47
|
+
/** Every name the compiler supplies without an import. */
|
|
48
|
+
export declare const BUILTIN_COMPONENTS: readonly string[];
|
|
49
|
+
/**
|
|
50
|
+
* Names whose meaning is fixed by the compiler and cannot be reassigned by a rule.
|
|
51
|
+
*
|
|
52
|
+
* A rule naming one of these is a silent no-op: the compiler matches the built-in
|
|
53
|
+
* first and the tag renders control flow instead of the intended component, with no
|
|
54
|
+
* error. Rule authors should check against this set and report rather than emit.
|
|
55
|
+
*/
|
|
56
|
+
export declare const RESERVED_COMPONENTS: ReadonlySet<string>;
|
|
57
|
+
/** Name → module for every built-in, honouring host module overrides. */
|
|
58
|
+
export declare function builtinComponentMap(modules?: BuiltinModules): Record<string, string>;
|
|
59
|
+
/**
|
|
60
|
+
* The built-ins as a resolver rule, for tools that want one uniform lookup.
|
|
61
|
+
*
|
|
62
|
+
* Note this is the *naming* half only. Feeding it to the compiler would not make
|
|
63
|
+
* control flow work through resolution: the compiler still recognises those names
|
|
64
|
+
* itself, for the codegen reasons above.
|
|
65
|
+
*/
|
|
66
|
+
export declare function builtinComponents(modules?: BuiltinModules): ComponentMapRule;
|
|
67
|
+
/** Just the router group as a rule: the one group that is purely an import. */
|
|
68
|
+
export declare function routerComponents(routerModule?: string): ComponentMapRule;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The components the compiler supplies without an import, as data.
|
|
3
|
+
*
|
|
4
|
+
* Two different things have always been bundled into one hardcoded `Set` per group:
|
|
5
|
+
* *which module a name comes from*, and *whether the name has special lowering*. Only
|
|
6
|
+
* the first is interesting outside the compiler, and every tool needs it, the TS
|
|
7
|
+
* plugin, to resolve `<Show>` for hover and go-to-definition; the language server, to
|
|
8
|
+
* complete and validate tags inside `` html`…` ``; a codemod, to materialise imports.
|
|
9
|
+
* Having no published source, `@fluixi/ts-plugin` duplicated the list and pinned it
|
|
10
|
+
* with a test that fails when the two drift.
|
|
11
|
+
*
|
|
12
|
+
* So the names live here, shaped as {@link ComponentMapRule} so they compose with
|
|
13
|
+
* user-configured `resolve` rules, and the compiler keeps its own sets for the parts
|
|
14
|
+
* that are genuinely about codegen.
|
|
15
|
+
*
|
|
16
|
+
* The split matters: control-flow names cannot become ordinary rules. `Show`, `For`,
|
|
17
|
+
* `Index` and `Match` read a reactive *value* prop inside their own tracking scope, so
|
|
18
|
+
* the compiler emits that prop as a getter: without it `each={items()}` snapshots once
|
|
19
|
+
* and never updates. They are also exempted from `createMemo` wrapping and may be
|
|
20
|
+
* replaced outright by `optimizeControlFlowComponent`. A rule only injects an import,
|
|
21
|
+
* so converting them would keep the import and silently drop the reactivity.
|
|
22
|
+
*
|
|
23
|
+
* Router components have no such behaviour: every reference to them in the plugin is
|
|
24
|
+
* import plumbing: so they are a plain rule.
|
|
25
|
+
*/
|
|
26
|
+
import type { ComponentMapRule } from './component-resolver.js';
|
|
27
|
+
/** Where the built-in groups come from when the host does not override the module. */
|
|
28
|
+
export interface BuiltinModules {
|
|
29
|
+
/** Control flow that lives in the DOM package. Default `@fluixi/dom`. */
|
|
30
|
+
controlFlowModule?: string;
|
|
31
|
+
/** Control flow that only exists in core. Default `@fluixi/core`. */
|
|
32
|
+
coreModule?: string;
|
|
33
|
+
/** Router components. Default `@fluixi/core/router`. */
|
|
34
|
+
routerModule?: string;
|
|
35
|
+
}
|
|
36
|
+
/** Control flow lowered against the DOM runtime. */
|
|
37
|
+
export declare const DOM_CONTROL_FLOW: readonly ["Show", "For", "Index", "Switch", "Match", "Portal", "Dynamic", "ErrorBoundary"];
|
|
38
|
+
/** Control flow that only `@fluixi/core` exports, importing it from dom resolves to nothing. */
|
|
39
|
+
export declare const CORE_CONTROL_FLOW: readonly ["Suspense", "SuspenseList", "Await"];
|
|
40
|
+
/**
|
|
41
|
+
* Router components.
|
|
42
|
+
*
|
|
43
|
+
* `Routes` is not a component (routing is `<Router routes={…}>`) and `lazy` is a call
|
|
44
|
+
* rather than a tag, so neither can be supplied this way.
|
|
45
|
+
*/
|
|
46
|
+
export declare const ROUTER_COMPONENTS: readonly ["Router", "Outlet", "Redirect", "Link"];
|
|
47
|
+
/** Every name the compiler supplies without an import. */
|
|
48
|
+
export declare const BUILTIN_COMPONENTS: readonly string[];
|
|
49
|
+
/**
|
|
50
|
+
* Names whose meaning is fixed by the compiler and cannot be reassigned by a rule.
|
|
51
|
+
*
|
|
52
|
+
* A rule naming one of these is a silent no-op: the compiler matches the built-in
|
|
53
|
+
* first and the tag renders control flow instead of the intended component, with no
|
|
54
|
+
* error. Rule authors should check against this set and report rather than emit.
|
|
55
|
+
*/
|
|
56
|
+
export declare const RESERVED_COMPONENTS: ReadonlySet<string>;
|
|
57
|
+
/** Name → module for every built-in, honouring host module overrides. */
|
|
58
|
+
export declare function builtinComponentMap(modules?: BuiltinModules): Record<string, string>;
|
|
59
|
+
/**
|
|
60
|
+
* The built-ins as a resolver rule, for tools that want one uniform lookup.
|
|
61
|
+
*
|
|
62
|
+
* Note this is the *naming* half only. Feeding it to the compiler would not make
|
|
63
|
+
* control flow work through resolution: the compiler still recognises those names
|
|
64
|
+
* itself, for the codegen reasons above.
|
|
65
|
+
*/
|
|
66
|
+
export declare function builtinComponents(modules?: BuiltinModules): ComponentMapRule;
|
|
67
|
+
/** Just the router group as a rule: the one group that is purely an import. */
|
|
68
|
+
export declare function routerComponents(routerModule?: string): ComponentMapRule;
|
|
69
|
+
//# sourceMappingURL=builtins.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builtins.d.ts","sourceRoot":"","sources":["../../src/resolve/builtins.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,sFAAsF;AACtF,MAAM,WAAW,cAAc;IAC7B,yEAAyE;IACzE,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,qEAAqE;IACrE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,wDAAwD;IACxD,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,oDAAoD;AACpD,eAAO,MAAM,gBAAgB,4FASnB,CAAC;AAEX,gGAAgG;AAChG,eAAO,MAAM,iBAAiB,gDAAiD,CAAC;AAEhF;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,mDAAoD,CAAC;AAEnF,0DAA0D;AAC1D,eAAO,MAAM,kBAAkB,EAAE,SAAS,MAAM,EAI/C,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,EAAE,WAAW,CAAC,MAAM,CAGlD,CAAC;AAEH,yEAAyE;AACzE,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,cAAmB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAYxF;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,GAAE,cAAmB,GAAG,gBAAgB,CAEhF;AAED,+EAA+E;AAC/E,wBAAgB,gBAAgB,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,gBAAgB,CAGxE"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/** Control flow lowered against the DOM runtime. */
|
|
2
|
+
export const DOM_CONTROL_FLOW = [
|
|
3
|
+
'Show',
|
|
4
|
+
'For',
|
|
5
|
+
'Index',
|
|
6
|
+
'Switch',
|
|
7
|
+
'Match',
|
|
8
|
+
'Portal',
|
|
9
|
+
'Dynamic',
|
|
10
|
+
'ErrorBoundary',
|
|
11
|
+
];
|
|
12
|
+
/** Control flow that only `@fluixi/core` exports, importing it from dom resolves to nothing. */
|
|
13
|
+
export const CORE_CONTROL_FLOW = ['Suspense', 'SuspenseList', 'Await'];
|
|
14
|
+
/**
|
|
15
|
+
* Router components.
|
|
16
|
+
*
|
|
17
|
+
* `Routes` is not a component (routing is `<Router routes={…}>`) and `lazy` is a call
|
|
18
|
+
* rather than a tag, so neither can be supplied this way.
|
|
19
|
+
*/
|
|
20
|
+
export const ROUTER_COMPONENTS = ['Router', 'Outlet', 'Redirect', 'Link'];
|
|
21
|
+
/** Every name the compiler supplies without an import. */
|
|
22
|
+
export const BUILTIN_COMPONENTS = [
|
|
23
|
+
...DOM_CONTROL_FLOW,
|
|
24
|
+
...CORE_CONTROL_FLOW,
|
|
25
|
+
...ROUTER_COMPONENTS,
|
|
26
|
+
];
|
|
27
|
+
/**
|
|
28
|
+
* Names whose meaning is fixed by the compiler and cannot be reassigned by a rule.
|
|
29
|
+
*
|
|
30
|
+
* A rule naming one of these is a silent no-op: the compiler matches the built-in
|
|
31
|
+
* first and the tag renders control flow instead of the intended component, with no
|
|
32
|
+
* error. Rule authors should check against this set and report rather than emit.
|
|
33
|
+
*/
|
|
34
|
+
export const RESERVED_COMPONENTS = new Set([
|
|
35
|
+
...DOM_CONTROL_FLOW,
|
|
36
|
+
...CORE_CONTROL_FLOW,
|
|
37
|
+
]);
|
|
38
|
+
/** Name → module for every built-in, honouring host module overrides. */
|
|
39
|
+
export function builtinComponentMap(modules = {}) {
|
|
40
|
+
const { controlFlowModule = '@fluixi/dom', coreModule = '@fluixi/core', routerModule = '@fluixi/core/router', } = modules;
|
|
41
|
+
const map = {};
|
|
42
|
+
for (const name of DOM_CONTROL_FLOW)
|
|
43
|
+
map[name] = controlFlowModule;
|
|
44
|
+
for (const name of CORE_CONTROL_FLOW)
|
|
45
|
+
map[name] = coreModule;
|
|
46
|
+
for (const name of ROUTER_COMPONENTS)
|
|
47
|
+
map[name] = routerModule;
|
|
48
|
+
return map;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* The built-ins as a resolver rule, for tools that want one uniform lookup.
|
|
52
|
+
*
|
|
53
|
+
* Note this is the *naming* half only. Feeding it to the compiler would not make
|
|
54
|
+
* control flow work through resolution: the compiler still recognises those names
|
|
55
|
+
* itself, for the codegen reasons above.
|
|
56
|
+
*/
|
|
57
|
+
export function builtinComponents(modules = {}) {
|
|
58
|
+
return { components: builtinComponentMap(modules) };
|
|
59
|
+
}
|
|
60
|
+
/** Just the router group as a rule: the one group that is purely an import. */
|
|
61
|
+
export function routerComponents(routerModule) {
|
|
62
|
+
const module = routerModule ?? '@fluixi/core/router';
|
|
63
|
+
return { components: Object.fromEntries(ROUTER_COMPONENTS.map((n) => [n, module])) };
|
|
64
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/*! @fluixi/compiler v1.0.0-alpha.100 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
|
|
2
|
+
|
|
3
|
+
// src/resolve/builtins.ts
|
|
4
|
+
var DOM_CONTROL_FLOW = [
|
|
5
|
+
"Show",
|
|
6
|
+
"For",
|
|
7
|
+
"Index",
|
|
8
|
+
"Switch",
|
|
9
|
+
"Match",
|
|
10
|
+
"Portal",
|
|
11
|
+
"Dynamic",
|
|
12
|
+
"ErrorBoundary"
|
|
13
|
+
];
|
|
14
|
+
var CORE_CONTROL_FLOW = ["Suspense", "SuspenseList", "Await"];
|
|
15
|
+
var ROUTER_COMPONENTS = ["Router", "Outlet", "Redirect", "Link"];
|
|
16
|
+
var BUILTIN_COMPONENTS = [
|
|
17
|
+
...DOM_CONTROL_FLOW,
|
|
18
|
+
...CORE_CONTROL_FLOW,
|
|
19
|
+
...ROUTER_COMPONENTS
|
|
20
|
+
];
|
|
21
|
+
var RESERVED_COMPONENTS = /* @__PURE__ */ new Set([
|
|
22
|
+
...DOM_CONTROL_FLOW,
|
|
23
|
+
...CORE_CONTROL_FLOW
|
|
24
|
+
]);
|
|
25
|
+
function builtinComponentMap(modules = {}) {
|
|
26
|
+
const {
|
|
27
|
+
controlFlowModule = "@fluixi/dom",
|
|
28
|
+
coreModule = "@fluixi/core",
|
|
29
|
+
routerModule = "@fluixi/core/router"
|
|
30
|
+
} = modules;
|
|
31
|
+
const map = {};
|
|
32
|
+
for (const name of DOM_CONTROL_FLOW) map[name] = controlFlowModule;
|
|
33
|
+
for (const name of CORE_CONTROL_FLOW) map[name] = coreModule;
|
|
34
|
+
for (const name of ROUTER_COMPONENTS) map[name] = routerModule;
|
|
35
|
+
return map;
|
|
36
|
+
}
|
|
37
|
+
function builtinComponents(modules = {}) {
|
|
38
|
+
return { components: builtinComponentMap(modules) };
|
|
39
|
+
}
|
|
40
|
+
function routerComponents(routerModule) {
|
|
41
|
+
const module = routerModule ?? "@fluixi/core/router";
|
|
42
|
+
return { components: Object.fromEntries(ROUTER_COMPONENTS.map((n) => [n, module])) };
|
|
43
|
+
}
|
|
44
|
+
export {
|
|
45
|
+
BUILTIN_COMPONENTS,
|
|
46
|
+
CORE_CONTROL_FLOW,
|
|
47
|
+
DOM_CONTROL_FLOW,
|
|
48
|
+
RESERVED_COMPONENTS,
|
|
49
|
+
ROUTER_COMPONENTS,
|
|
50
|
+
builtinComponentMap,
|
|
51
|
+
builtinComponents,
|
|
52
|
+
routerComponents
|
|
53
|
+
};
|