@jxsuite/compiler 9.1.0 → 10.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +258 -242
- package/dist/compiler.js +181 -158
- package/package.json +9 -8
- package/src/compiler.ts +13 -8
- package/src/shadow.ts +6 -33
- package/src/shared.ts +1301 -176
- package/src/site/base-path.ts +88 -2
- package/src/site/client-runtime.ts +13 -14
- package/src/site/image-transform.ts +122 -29
- package/src/site/site-build.ts +248 -93
- package/src/targets/compile-client.ts +143 -37
- package/src/targets/compile-element.ts +388 -48
- package/src/targets/compile-pack.ts +234 -0
- package/src/targets/compile-static.ts +15 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jxsuite/compiler",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "10.0.0",
|
|
4
4
|
"description": "Jx static HTML compiler, island detector, and site builder",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
"./types": "./src/types.ts",
|
|
39
39
|
"./db-push": "./src/site/db-push.ts",
|
|
40
40
|
"./document-scripts": "./src/site/document-scripts.ts",
|
|
41
|
+
"./pack": "./src/targets/compile-pack.ts",
|
|
41
42
|
"./bundler": "./src/site/bundler.ts",
|
|
42
43
|
"./bun-plugin": "./src/site/bun-plugin.ts"
|
|
43
44
|
},
|
|
@@ -55,19 +56,19 @@
|
|
|
55
56
|
},
|
|
56
57
|
"dependencies": {
|
|
57
58
|
"@jxsuite/compiler-binding": "^0.3.0",
|
|
58
|
-
"@jxsuite/create": "^1.8.
|
|
59
|
-
"@jxsuite/erase": "^0.3.
|
|
60
|
-
"@jxsuite/runtime": "^
|
|
61
|
-
"@jxsuite/schema": "^
|
|
62
|
-
"@jxsuite/site": "^
|
|
59
|
+
"@jxsuite/create": "^1.8.4",
|
|
60
|
+
"@jxsuite/erase": "^0.3.3",
|
|
61
|
+
"@jxsuite/runtime": "^8.0.0",
|
|
62
|
+
"@jxsuite/schema": "^7.0.0",
|
|
63
|
+
"@jxsuite/site": "^3.0.0",
|
|
63
64
|
"@vue/reactivity": "3.5.45",
|
|
64
65
|
"esbuild": "^0.28.2",
|
|
65
66
|
"lit-html": "^3.3.3"
|
|
66
67
|
},
|
|
67
68
|
"devDependencies": {
|
|
68
69
|
"@happy-dom/global-registrator": "^21.0.4",
|
|
69
|
-
"@jxsuite/connector": "^0.8.
|
|
70
|
-
"@jxsuite/parser": "^5.0
|
|
70
|
+
"@jxsuite/connector": "^0.8.12",
|
|
71
|
+
"@jxsuite/parser": "^5.1.0",
|
|
71
72
|
"@jxsuite/test-support": "^0.0.0",
|
|
72
73
|
"@types/mdast": "^4.0.4"
|
|
73
74
|
},
|
package/src/compiler.ts
CHANGED
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
compileStyles,
|
|
23
23
|
escapeHtml,
|
|
24
24
|
isDynamic,
|
|
25
|
+
pageImportMap,
|
|
25
26
|
tagNameToClassName,
|
|
26
27
|
} from "./shared.ts";
|
|
27
28
|
|
|
@@ -37,6 +38,8 @@ import type { FormatRegistry } from "@jxsuite/schema/format-registry";
|
|
|
37
38
|
export { isDynamic } from "./shared.ts";
|
|
38
39
|
export { compileSiteServer } from "./targets/compile-server.ts";
|
|
39
40
|
export { compileElement, compileElementPage } from "./targets/compile-element.ts";
|
|
41
|
+
export { compileElementPack, writeElementPack } from "./targets/compile-pack.ts";
|
|
42
|
+
export type { ElementPack, ElementPackOptions } from "./targets/compile-pack.ts";
|
|
40
43
|
export { compileClient } from "./targets/compile-client.ts";
|
|
41
44
|
|
|
42
45
|
// ─── Entry ────────────────────────────────────────────────────────────────────
|
|
@@ -45,6 +48,12 @@ export interface CompileOptions {
|
|
|
45
48
|
title?: string;
|
|
46
49
|
reactivitySrc?: string;
|
|
47
50
|
litHtmlSrc?: string;
|
|
51
|
+
/**
|
|
52
|
+
* The build's whole import map, prefix keys included. A page that writes its own map writes this
|
|
53
|
+
* one, so a compiled module's package subpath (`lit-html/directives/repeat.js`) resolves there
|
|
54
|
+
* (compiler.md §12). Without it the page maps the two sources above.
|
|
55
|
+
*/
|
|
56
|
+
runtimeImports?: Record<string, string>;
|
|
48
57
|
projectStyle?: JxStyle | null;
|
|
49
58
|
formats?: FormatRegistry;
|
|
50
59
|
/** Rewrite Function-def `$src` specifiers to served URLs (see CompileElementOptions). */
|
|
@@ -169,14 +178,7 @@ export async function compile(sourcePath: string | JxDocument, opts: CompileOpti
|
|
|
169
178
|
<meta charset="utf-8">
|
|
170
179
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
171
180
|
<title>${escapeHtml(title)}</title>
|
|
172
|
-
|
|
173
|
-
{
|
|
174
|
-
"imports": {
|
|
175
|
-
"@vue/reactivity": "${reactivitySrc}",
|
|
176
|
-
"lit-html": "${litHtmlSrc}"
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
</script>
|
|
181
|
+
${pageImportMap({ litHtmlSrc, reactivitySrc, runtimeImports: opts.runtimeImports })}
|
|
180
182
|
${styleBlock}
|
|
181
183
|
</head>
|
|
182
184
|
<body>
|
|
@@ -202,6 +204,9 @@ export async function compile(sourcePath: string | JxDocument, opts: CompileOpti
|
|
|
202
204
|
if (opts.resolveClass !== undefined) {
|
|
203
205
|
clientOptions.resolveClass = opts.resolveClass;
|
|
204
206
|
}
|
|
207
|
+
if (opts.runtimeImports !== undefined) {
|
|
208
|
+
clientOptions.runtimeImports = opts.runtimeImports;
|
|
209
|
+
}
|
|
205
210
|
return compileClient(raw, clientOptions);
|
|
206
211
|
}
|
|
207
212
|
|
package/src/shadow.ts
CHANGED
|
@@ -12,43 +12,16 @@
|
|
|
12
12
|
* than usual, because a **closed** declarative shadow root is not reachable through
|
|
13
13
|
* `element.shadowRoot` and hydration has to find it another way (§16.6).
|
|
14
14
|
*
|
|
15
|
+
* The verdict itself is the runtime's (`resolveShadowMode` in `@jxsuite/runtime/css`), re-exported
|
|
16
|
+
* here for the compiler's callers; the CSS scope a component sheet is written under is the
|
|
17
|
+
* compiler's own.
|
|
18
|
+
*
|
|
15
19
|
* @docs framework/concepts/components
|
|
16
20
|
*/
|
|
17
21
|
|
|
18
|
-
import type {
|
|
19
|
-
|
|
20
|
-
/** The two modes the standard defines, or null for light DOM. */
|
|
21
|
-
export type ShadowMode = "open" | "closed";
|
|
22
|
-
|
|
23
|
-
/** A value `$shadow` or `defaults.shadow` may carry. */
|
|
24
|
-
export type ShadowSetting = ShadowMode | false;
|
|
25
|
-
|
|
26
|
-
/** Whether a document value is one of the settings `$shadow` / `defaults.shadow` may carry. */
|
|
27
|
-
function isShadowSetting(value: unknown): value is ShadowSetting {
|
|
28
|
-
return value === false || value === "open" || value === "closed";
|
|
29
|
-
}
|
|
22
|
+
import type { ShadowMode } from "@jxsuite/runtime/css";
|
|
30
23
|
|
|
31
|
-
|
|
32
|
-
* The shadow mode a component renders in, or null for light DOM.
|
|
33
|
-
*
|
|
34
|
-
* A component's own `$shadow` wins over the project default in both directions — including
|
|
35
|
-
* `$shadow: false`, which is how one component opts _out_ of a project that opted in.
|
|
36
|
-
*
|
|
37
|
-
* @param {JxDocument | JxElement | null | undefined} doc - The component definition
|
|
38
|
-
* @param {ProjectConfig["defaults"] | undefined} defaults
|
|
39
|
-
* @returns {ShadowMode | null}
|
|
40
|
-
*/
|
|
41
|
-
export function resolveShadowMode(
|
|
42
|
-
doc: JxDocument | JxElement | null | undefined,
|
|
43
|
-
defaults?: ProjectConfig["defaults"],
|
|
44
|
-
): ShadowMode | null {
|
|
45
|
-
const own = doc?.$shadow;
|
|
46
|
-
if (isShadowSetting(own)) {
|
|
47
|
-
return own === false ? null : own;
|
|
48
|
-
}
|
|
49
|
-
const projectDefault = defaults?.shadow;
|
|
50
|
-
return isShadowSetting(projectDefault) && projectDefault !== false ? projectDefault : null;
|
|
51
|
-
}
|
|
24
|
+
export { resolveShadowMode, type ShadowMode, type ShadowSetting } from "@jxsuite/runtime/css";
|
|
52
25
|
|
|
53
26
|
/**
|
|
54
27
|
* The CSS scope prefix for a component's own rules.
|