@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,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;
|
package/dist/options.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ComponentResolverRule } from './resolve/component-resolver.js';
|
|
2
2
|
/**
|
|
3
|
-
* Public compiler options. This schema is the stable public API
|
|
3
|
+
* Public compiler options. This schema is the stable public API, it stays put
|
|
4
4
|
* as backends change. Switching DOM strategy is `backend`, not a rewrite.
|
|
5
5
|
*/
|
|
6
6
|
export interface CompilerOptions {
|
|
@@ -13,7 +13,7 @@ export interface CompilerOptions {
|
|
|
13
13
|
*/
|
|
14
14
|
templateClone?: boolean;
|
|
15
15
|
/**
|
|
16
|
-
* Also clone subtrees whose *structure* is static but which contain dynamic holes
|
|
16
|
+
* Also clone subtrees whose *structure* is static but which contain dynamic holes ,
|
|
17
17
|
* the common shape. Roughly halves the emitted code for such a subtree and replaces
|
|
18
18
|
* per-element construction with one clone.
|
|
19
19
|
*
|
package/dist/options.mjs
CHANGED
|
@@ -1 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
// src/options.ts
|
|
2
|
+
var defaultOptions = {
|
|
3
|
+
backend: "imperative",
|
|
4
|
+
moduleName: "@fluixi/dom",
|
|
5
|
+
delegateEvents: true,
|
|
6
|
+
hydratable: false,
|
|
7
|
+
sourceMaps: true,
|
|
8
|
+
dev: false
|
|
9
|
+
};
|
|
10
|
+
export {
|
|
11
|
+
defaultOptions
|
|
12
|
+
};
|
|
@@ -1 +1,73 @@
|
|
|
1
|
-
|
|
1
|
+
/*! @fluixi/compiler v1.0.0-alpha.85 | (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;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Two different things have always been bundled into one hardcoded `Set` per group:
|
|
5
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
|
|
6
|
+
* the first is interesting outside the compiler, and every tool needs it, the TS
|
|
7
7
|
* plugin, to resolve `<Show>` for hover and go-to-definition; the language server, to
|
|
8
8
|
* complete and validate tags inside `` html`…` ``; a codemod, to materialise imports.
|
|
9
9
|
* Having no published source, `@fluixi/ts-plugin` duplicated the list and pinned it
|
|
@@ -15,13 +15,13 @@
|
|
|
15
15
|
*
|
|
16
16
|
* The split matters: control-flow names cannot become ordinary rules. `Show`, `For`,
|
|
17
17
|
* `Index` and `Match` read a reactive *value* prop inside their own tracking scope, so
|
|
18
|
-
* the compiler emits that prop as a getter
|
|
18
|
+
* the compiler emits that prop as a getter: without it `each={items()}` snapshots once
|
|
19
19
|
* and never updates. They are also exempted from `createMemo` wrapping and may be
|
|
20
20
|
* replaced outright by `optimizeControlFlowComponent`. A rule only injects an import,
|
|
21
21
|
* so converting them would keep the import and silently drop the reactivity.
|
|
22
22
|
*
|
|
23
|
-
* Router components have no such behaviour
|
|
24
|
-
* import plumbing
|
|
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
25
|
*/
|
|
26
26
|
import type { ComponentMapRule } from './component-resolver.js';
|
|
27
27
|
/** Where the built-in groups come from when the host does not override the module. */
|
|
@@ -35,7 +35,7 @@ export interface BuiltinModules {
|
|
|
35
35
|
}
|
|
36
36
|
/** Control flow lowered against the DOM runtime. */
|
|
37
37
|
export declare const DOM_CONTROL_FLOW: readonly ["Show", "For", "Index", "Switch", "Match", "Portal", "Dynamic", "ErrorBoundary"];
|
|
38
|
-
/** Control flow that only `@fluixi/core` exports
|
|
38
|
+
/** Control flow that only `@fluixi/core` exports, importing it from dom resolves to nothing. */
|
|
39
39
|
export declare const CORE_CONTROL_FLOW: readonly ["Suspense", "SuspenseList", "Await"];
|
|
40
40
|
/**
|
|
41
41
|
* Router components.
|
|
@@ -49,7 +49,7 @@ export declare const BUILTIN_COMPONENTS: readonly string[];
|
|
|
49
49
|
/**
|
|
50
50
|
* Names whose meaning is fixed by the compiler and cannot be reassigned by a rule.
|
|
51
51
|
*
|
|
52
|
-
* A rule naming one of these is a silent no-op
|
|
52
|
+
* A rule naming one of these is a silent no-op: the compiler matches the built-in
|
|
53
53
|
* first and the tag renders control flow instead of the intended component, with no
|
|
54
54
|
* error. Rule authors should check against this set and report rather than emit.
|
|
55
55
|
*/
|
|
@@ -60,10 +60,10 @@ export declare function builtinComponentMap(modules?: BuiltinModules): Record<st
|
|
|
60
60
|
* The built-ins as a resolver rule, for tools that want one uniform lookup.
|
|
61
61
|
*
|
|
62
62
|
* Note this is the *naming* half only. Feeding it to the compiler would not make
|
|
63
|
-
* control flow work through resolution
|
|
63
|
+
* control flow work through resolution: the compiler still recognises those names
|
|
64
64
|
* itself, for the codegen reasons above.
|
|
65
65
|
*/
|
|
66
66
|
export declare function builtinComponents(modules?: BuiltinModules): ComponentMapRule;
|
|
67
|
-
/** Just the router group as a rule
|
|
67
|
+
/** Just the router group as a rule: the one group that is purely an import. */
|
|
68
68
|
export declare function routerComponents(routerModule?: string): ComponentMapRule;
|
|
69
69
|
//# sourceMappingURL=builtins.d.ts.map
|
|
@@ -1 +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,
|
|
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"}
|
package/dist/resolve/builtins.js
CHANGED
|
@@ -9,7 +9,7 @@ export const DOM_CONTROL_FLOW = [
|
|
|
9
9
|
'Dynamic',
|
|
10
10
|
'ErrorBoundary',
|
|
11
11
|
];
|
|
12
|
-
/** Control flow that only `@fluixi/core` exports
|
|
12
|
+
/** Control flow that only `@fluixi/core` exports, importing it from dom resolves to nothing. */
|
|
13
13
|
export const CORE_CONTROL_FLOW = ['Suspense', 'SuspenseList', 'Await'];
|
|
14
14
|
/**
|
|
15
15
|
* Router components.
|
|
@@ -27,7 +27,7 @@ export const BUILTIN_COMPONENTS = [
|
|
|
27
27
|
/**
|
|
28
28
|
* Names whose meaning is fixed by the compiler and cannot be reassigned by a rule.
|
|
29
29
|
*
|
|
30
|
-
* A rule naming one of these is a silent no-op
|
|
30
|
+
* A rule naming one of these is a silent no-op: the compiler matches the built-in
|
|
31
31
|
* first and the tag renders control flow instead of the intended component, with no
|
|
32
32
|
* error. Rule authors should check against this set and report rather than emit.
|
|
33
33
|
*/
|
|
@@ -51,13 +51,13 @@ export function builtinComponentMap(modules = {}) {
|
|
|
51
51
|
* The built-ins as a resolver rule, for tools that want one uniform lookup.
|
|
52
52
|
*
|
|
53
53
|
* Note this is the *naming* half only. Feeding it to the compiler would not make
|
|
54
|
-
* control flow work through resolution
|
|
54
|
+
* control flow work through resolution: the compiler still recognises those names
|
|
55
55
|
* itself, for the codegen reasons above.
|
|
56
56
|
*/
|
|
57
57
|
export function builtinComponents(modules = {}) {
|
|
58
58
|
return { components: builtinComponentMap(modules) };
|
|
59
59
|
}
|
|
60
|
-
/** Just the router group as a rule
|
|
60
|
+
/** Just the router group as a rule: the one group that is purely an import. */
|
|
61
61
|
export function routerComponents(routerModule) {
|
|
62
62
|
const module = routerModule ?? '@fluixi/core/router';
|
|
63
63
|
return { components: Object.fromEntries(ROUTER_COMPONENTS.map((n) => [n, module])) };
|
|
@@ -1 +1,53 @@
|
|
|
1
|
-
|
|
1
|
+
/*! @fluixi/compiler v1.0.0-alpha.85 | (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
|
+
};
|
|
@@ -1,22 +1,242 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
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/resolve/component-globals.ts
|
|
21
|
+
var component_globals_exports = {};
|
|
22
|
+
__export(component_globals_exports, {
|
|
23
|
+
componentGlobals: () => componentGlobals
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(component_globals_exports);
|
|
26
|
+
|
|
27
|
+
// src/resolve/component-resolver.ts
|
|
28
|
+
var isMapRule = (rule) => "components" in rule;
|
|
29
|
+
function substitute(template, match) {
|
|
30
|
+
return template.replace(/\$(\d+)/g, (whole, index) => {
|
|
31
|
+
const group = match[Number(index)];
|
|
32
|
+
return group ?? whole;
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
function normalise(name, entry) {
|
|
36
|
+
return typeof entry === "string" ? { module: entry, export: name } : entry;
|
|
37
|
+
}
|
|
38
|
+
function createComponentResolver(rules = []) {
|
|
39
|
+
const exact = /* @__PURE__ */ new Map();
|
|
40
|
+
const conflicts = [];
|
|
41
|
+
const patterns = [];
|
|
42
|
+
for (const rule of rules) {
|
|
43
|
+
if (!isMapRule(rule)) {
|
|
44
|
+
patterns.push(rule);
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
for (const [name, entry] of Object.entries(rule.components)) {
|
|
48
|
+
const resolved = normalise(name, entry);
|
|
49
|
+
const existing = exact.get(name);
|
|
50
|
+
if (existing && existing.module !== resolved.module) {
|
|
51
|
+
const conflict = conflicts.find((c) => c.name === name);
|
|
52
|
+
if (conflict) conflict.modules.push(resolved.module);
|
|
53
|
+
else conflicts.push({ name, modules: [existing.module, resolved.module] });
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
exact.set(name, resolved);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const cache = /* @__PURE__ */ new Map();
|
|
60
|
+
const resolve = (name) => {
|
|
61
|
+
if (cache.has(name)) return cache.get(name);
|
|
62
|
+
let result = exact.get(name);
|
|
63
|
+
if (!result) {
|
|
64
|
+
for (const rule of patterns) {
|
|
65
|
+
const match = name.match(new RegExp(rule.match.source, rule.match.flags.replace("g", "")));
|
|
66
|
+
if (!match) continue;
|
|
67
|
+
result = {
|
|
68
|
+
module: substitute(rule.module, match),
|
|
69
|
+
export: rule.export ? substitute(rule.export, match) : name
|
|
70
|
+
};
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
cache.set(name, result);
|
|
75
|
+
return result;
|
|
76
|
+
};
|
|
77
|
+
return {
|
|
78
|
+
resolve,
|
|
79
|
+
names: () => [...exact.keys()],
|
|
80
|
+
conflicts: () => conflicts
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// src/resolve/builtins.ts
|
|
85
|
+
var DOM_CONTROL_FLOW = [
|
|
86
|
+
"Show",
|
|
87
|
+
"For",
|
|
88
|
+
"Index",
|
|
89
|
+
"Switch",
|
|
90
|
+
"Match",
|
|
91
|
+
"Portal",
|
|
92
|
+
"Dynamic",
|
|
93
|
+
"ErrorBoundary"
|
|
94
|
+
];
|
|
95
|
+
var CORE_CONTROL_FLOW = ["Suspense", "SuspenseList", "Await"];
|
|
96
|
+
var ROUTER_COMPONENTS = ["Router", "Outlet", "Redirect", "Link"];
|
|
97
|
+
var BUILTIN_COMPONENTS = [
|
|
98
|
+
...DOM_CONTROL_FLOW,
|
|
99
|
+
...CORE_CONTROL_FLOW,
|
|
100
|
+
...ROUTER_COMPONENTS
|
|
101
|
+
];
|
|
102
|
+
var RESERVED_COMPONENTS = /* @__PURE__ */ new Set([
|
|
103
|
+
...DOM_CONTROL_FLOW,
|
|
104
|
+
...CORE_CONTROL_FLOW
|
|
105
|
+
]);
|
|
106
|
+
function builtinComponentMap(modules = {}) {
|
|
107
|
+
const {
|
|
108
|
+
controlFlowModule = "@fluixi/dom",
|
|
109
|
+
coreModule = "@fluixi/core",
|
|
110
|
+
routerModule = "@fluixi/core/router"
|
|
111
|
+
} = modules;
|
|
112
|
+
const map = {};
|
|
113
|
+
for (const name of DOM_CONTROL_FLOW) map[name] = controlFlowModule;
|
|
114
|
+
for (const name of CORE_CONTROL_FLOW) map[name] = coreModule;
|
|
115
|
+
for (const name of ROUTER_COMPONENTS) map[name] = routerModule;
|
|
116
|
+
return map;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// src/analyze/intrinsics.ts
|
|
120
|
+
var REACTIVE_MODULE = "@fluixi/reactive/signal";
|
|
121
|
+
var INTRINSICS = {
|
|
122
|
+
$signal: { export: "signal", module: REACTIVE_MODULE, returns: "signal-handle" },
|
|
123
|
+
$memo: { export: "memo", module: REACTIVE_MODULE, returns: "memo-handle" },
|
|
124
|
+
$effect: { export: "effect", module: REACTIVE_MODULE, returns: "effect" },
|
|
125
|
+
$store: { export: "store", module: "@fluixi/reactive/store", returns: "store-handle" },
|
|
126
|
+
$resource: { export: "resource", module: REACTIVE_MODULE, returns: "resource-handle" },
|
|
127
|
+
// No short runtime form for these yet, so the intrinsic stands for the `create*`
|
|
128
|
+
// name. Still worth having: no import to write, and when a shorter form is
|
|
129
|
+
// designed, the change is this line rather than a compiler pass.
|
|
130
|
+
$selector: { export: "createSelector", module: REACTIVE_MODULE, returns: "memo-accessor" },
|
|
131
|
+
$deferred: { export: "createDeferred", module: REACTIVE_MODULE, returns: "memo-accessor" },
|
|
132
|
+
// Not value constructors, but the compiler has to know them: they change what a read
|
|
133
|
+
// does. `untrack` suppresses dependency collection, which is exactly the kind of thing
|
|
134
|
+
// dependency analysis must not guess at.
|
|
135
|
+
$untrack: { export: "untrack", module: REACTIVE_MODULE, returns: "plain" },
|
|
136
|
+
$untrackStore: { export: "untrackStore", module: "@fluixi/reactive/store", returns: "plain" }
|
|
137
|
+
};
|
|
138
|
+
var INTRINSIC_CALL = new RegExp(`\\$(?:${Object.keys(INTRINSICS).map((n) => n.slice(1)).join("|")})\\s*\\(`);
|
|
139
|
+
|
|
140
|
+
// src/resolve/component-globals.ts
|
|
141
|
+
var DOM_GLOBALS = /* @__PURE__ */ new Set([
|
|
142
|
+
"Text",
|
|
143
|
+
"Image",
|
|
144
|
+
"Option",
|
|
145
|
+
"Audio",
|
|
146
|
+
"Comment",
|
|
147
|
+
"Range",
|
|
148
|
+
"Selection",
|
|
149
|
+
"Notification",
|
|
150
|
+
"Event",
|
|
151
|
+
"Document",
|
|
152
|
+
"Element",
|
|
153
|
+
"Node",
|
|
154
|
+
"Screen",
|
|
155
|
+
"Window",
|
|
156
|
+
"Location",
|
|
157
|
+
"History",
|
|
158
|
+
"Storage",
|
|
159
|
+
"Response",
|
|
160
|
+
"Request",
|
|
161
|
+
"Headers"
|
|
162
|
+
]);
|
|
163
|
+
function packageOf(specifier) {
|
|
164
|
+
if (specifier.startsWith(".") || specifier.startsWith("/")) return void 0;
|
|
165
|
+
if (/^[~@]\//.test(specifier)) return void 0;
|
|
166
|
+
const parts = specifier.split("/");
|
|
167
|
+
return specifier.startsWith("@") ? parts.slice(0, 2).join("/") : parts[0];
|
|
168
|
+
}
|
|
169
|
+
function namespaceAlias(module2) {
|
|
170
|
+
return `_${module2.replace(/[^A-Za-z0-9]/g, "_")}`;
|
|
171
|
+
}
|
|
172
|
+
function componentGlobals(rules, options = {}) {
|
|
173
|
+
const {
|
|
174
|
+
available: availableList,
|
|
175
|
+
builtins = true,
|
|
176
|
+
intrinsics = true,
|
|
177
|
+
generator = "@fluixi/compiler",
|
|
178
|
+
specifier = (module2) => module2
|
|
179
|
+
} = options;
|
|
180
|
+
const all = [...rules];
|
|
181
|
+
if (builtins) {
|
|
182
|
+
all.push({ components: builtinComponentMap() });
|
|
183
|
+
}
|
|
184
|
+
const resolver = createComponentResolver(all);
|
|
185
|
+
const available = availableList ? new Set(availableList) : void 0;
|
|
186
|
+
const declared = [];
|
|
187
|
+
const shadowedByDom = [];
|
|
188
|
+
const unavailable = [];
|
|
189
|
+
const resolved = /* @__PURE__ */ new Map();
|
|
190
|
+
for (const name of [...resolver.names()].sort()) {
|
|
191
|
+
const target = resolver.resolve(name);
|
|
192
|
+
if (!target) continue;
|
|
193
|
+
const pkg = packageOf(target.module);
|
|
194
|
+
if (DOM_GLOBALS.has(name)) shadowedByDom.push(name);
|
|
195
|
+
else if (available && pkg && !available.has(pkg)) unavailable.push(name);
|
|
196
|
+
else {
|
|
197
|
+
declared.push(name);
|
|
198
|
+
resolved.set(name, target);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
const intrinsicModules = intrinsics ? [...new Set(Object.values(INTRINSICS).map((i) => i.module))] : [];
|
|
202
|
+
const modules = [
|
|
203
|
+
.../* @__PURE__ */ new Set([...declared.map((name) => resolved.get(name).module), ...intrinsicModules])
|
|
204
|
+
].sort();
|
|
205
|
+
const imports = modules.map(
|
|
206
|
+
(m) => `import * as ${namespaceAlias(m)} from '${specifier(m)}';`
|
|
207
|
+
);
|
|
208
|
+
const lines = declared.map((name) => {
|
|
209
|
+
const target = resolved.get(name);
|
|
210
|
+
const ns = namespaceAlias(target.module);
|
|
211
|
+
return target.export === "default" ? ` const ${name}: typeof ${ns}.default;` : ` export import ${name} = ${ns}.${target.export};`;
|
|
212
|
+
});
|
|
213
|
+
const note = shadowedByDom.length > 0 ? `//
|
|
214
|
+
// Import these explicitly: lib.dom already declares the name, so an ambient
|
|
3
215
|
// declaration cannot win:
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
216
|
+
` + shadowedByDom.map((n) => {
|
|
217
|
+
const module2 = resolver.resolve(n)?.module;
|
|
218
|
+
return `// import { ${n} } from '${module2 ? specifier(module2) : ""}';
|
|
219
|
+
`;
|
|
220
|
+
}).join("") : "";
|
|
221
|
+
const intrinsicLines = intrinsics ? Object.entries(INTRINSICS).map(
|
|
222
|
+
([name, intrinsic]) => ` const ${name}: typeof ${namespaceAlias(intrinsic.module)}.${intrinsic.export};`
|
|
223
|
+
) : [];
|
|
224
|
+
const patternRules = rules.filter((rule) => "match" in rule).length;
|
|
225
|
+
const patternNote = patternRules > 0 ? `//
|
|
226
|
+
// ${patternRules} pattern rule${patternRules === 1 ? "" : "s"} cannot be declared:
|
|
7
227
|
// a pattern matches unboundedly many names, so there is no list to emit. Those
|
|
8
228
|
// tags still resolve at build time; declare them by hand if the editor needs them.
|
|
9
|
-
|
|
229
|
+
` : "";
|
|
230
|
+
const source = `// GENERATED by ${generator}, do not edit.
|
|
10
231
|
//
|
|
11
232
|
// The components \`resolve\` supplies without an import. This describes what the
|
|
12
233
|
// compiler already does; it does not enable it.
|
|
13
|
-
|
|
14
|
-
${
|
|
15
|
-
`)
|
|
16
|
-
`:`
|
|
17
|
-
`)+`
|
|
234
|
+
` + note + patternNote + (imports.length > 0 ? `
|
|
235
|
+
${imports.join("\n")}
|
|
236
|
+
` : "\n") + `
|
|
18
237
|
declare global {
|
|
19
|
-
${[...
|
|
20
|
-
|
|
238
|
+
${[...lines, ...intrinsicLines].join("\n")}
|
|
239
|
+
}
|
|
240
|
+
`;
|
|
241
|
+
return { source, declared, shadowedByDom, unavailable, patternRules };
|
|
21
242
|
}
|
|
22
|
-
`,declared:m,shadowedByDom:d,unavailable:R,patternRules:x}}
|