@jxsuite/compiler 1.4.0 → 2.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 +564 -230
- package/dist/compiler.js +334 -133
- package/package.json +11 -9
- package/src/compiler.ts +1 -1
- package/src/shadow.ts +65 -0
- package/src/shared.ts +461 -51
- package/src/site/bundler.ts +149 -18
- package/src/site/client-runtime.ts +374 -0
- package/src/site/context-injection.ts +45 -2
- package/src/site/csp.ts +224 -0
- package/src/site/head-merger.ts +57 -13
- package/src/site/headers-emitter.ts +232 -0
- package/src/site/i18n.ts +365 -0
- package/src/site/image-optimizer.ts +7 -0
- package/src/site/image-transform.ts +269 -118
- package/src/site/img-loading.ts +55 -0
- package/src/site/link-relations.ts +251 -0
- package/src/site/locale-negotiation.ts +258 -0
- package/src/site/pages-discovery.ts +149 -0
- package/src/site/preview-server.ts +9 -1
- package/src/site/schema-command.ts +138 -87
- package/src/site/service-worker.ts +294 -0
- package/src/site/site-build.ts +956 -109
- package/src/site/site-loader.ts +1 -0
- package/src/site/validate-command.ts +134 -38
- package/src/site/well-known.ts +221 -0
- package/src/targets/compile-client.ts +144 -81
- package/src/targets/compile-element.ts +620 -58
- package/src/targets/compile-server.ts +19 -2
- package/src/targets/compile-static.ts +12 -3
- package/src/types.ts +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jxsuite/compiler",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Jx static HTML compiler, island detector, and site builder",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -45,17 +45,19 @@
|
|
|
45
45
|
"upgrade": "bunx npm-check-updates -u && bun install"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@apidevtools/json-schema-ref-parser": "^
|
|
49
|
-
"@jxsuite/create": "^1.
|
|
50
|
-
"@jxsuite/runtime": "^
|
|
51
|
-
"@jxsuite/schema": "^1.
|
|
52
|
-
"
|
|
48
|
+
"@apidevtools/json-schema-ref-parser": "^16.0.0",
|
|
49
|
+
"@jxsuite/create": "^1.3.0",
|
|
50
|
+
"@jxsuite/runtime": "^2.0.0",
|
|
51
|
+
"@jxsuite/schema": "^1.6.0",
|
|
52
|
+
"@vue/reactivity": "3.5.41",
|
|
53
|
+
"esbuild": "^0.28.2",
|
|
54
|
+
"lit-html": "^3.3.3",
|
|
53
55
|
"sharp": "^0.35.3"
|
|
54
56
|
},
|
|
55
57
|
"devDependencies": {
|
|
56
|
-
"@happy-dom/global-registrator": "^20.11.
|
|
57
|
-
"@jxsuite/connector": "^0.
|
|
58
|
-
"@jxsuite/parser": "^1.
|
|
58
|
+
"@happy-dom/global-registrator": "^20.11.2",
|
|
59
|
+
"@jxsuite/connector": "^0.5.0",
|
|
60
|
+
"@jxsuite/parser": "^1.5.0",
|
|
59
61
|
"@types/mdast": "^4.0.4"
|
|
60
62
|
}
|
|
61
63
|
}
|
package/src/compiler.ts
CHANGED
|
@@ -130,7 +130,7 @@ export async function compile(sourcePath: string | JxDocument, opts: CompileOpti
|
|
|
130
130
|
path: `${tagName}.js`,
|
|
131
131
|
tagName,
|
|
132
132
|
};
|
|
133
|
-
const styleBlock = compileStyles(raw, raw.$media ?? {});
|
|
133
|
+
const styleBlock = compileStyles(raw, raw.$media ?? {}, projectStyle);
|
|
134
134
|
|
|
135
135
|
const html = `<!DOCTYPE html>
|
|
136
136
|
<html lang="en">
|
package/src/shadow.ts
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shadow DOM, opt-in.
|
|
3
|
+
*
|
|
4
|
+
* Light DOM is the default and stays the default. It is not a placeholder for shadow DOM: a Jx
|
|
5
|
+
* component's styles are reachable from the page, which is how a project restyles a component it
|
|
6
|
+
* did not write, and the `<slot>` emulation that makes light-DOM composition work has different
|
|
7
|
+
* distribution semantics from real slotting. Switching a component to a shadow root changes both,
|
|
8
|
+
* so it is a per-component decision an author makes deliberately.
|
|
9
|
+
*
|
|
10
|
+
* `$shadow` on a component document, `defaults.shadow` on the project, `false` if neither says
|
|
11
|
+
* otherwise. `"open"` and `"closed"` are the standard's two modes; the difference matters more here
|
|
12
|
+
* than usual, because a **closed** declarative shadow root is not reachable through
|
|
13
|
+
* `element.shadowRoot` and hydration has to find it another way (§16.6).
|
|
14
|
+
*
|
|
15
|
+
* @docs framework/concepts/components
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import type { JxDocument, JxElement, ProjectConfig } from "@jxsuite/schema/types";
|
|
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
|
+
function asSetting(value: unknown): ShadowSetting | undefined {
|
|
27
|
+
if (value === false || value === "open" || value === "closed") {
|
|
28
|
+
return value;
|
|
29
|
+
}
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The shadow mode a component renders in, or null for light DOM.
|
|
35
|
+
*
|
|
36
|
+
* A component's own `$shadow` wins over the project default in both directions — including
|
|
37
|
+
* `$shadow: false`, which is how one component opts _out_ of a project that opted in.
|
|
38
|
+
*
|
|
39
|
+
* @param {JxDocument | JxElement | null | undefined} doc - The component definition
|
|
40
|
+
* @param {ProjectConfig["defaults"] | undefined} defaults
|
|
41
|
+
* @returns {ShadowMode | null}
|
|
42
|
+
*/
|
|
43
|
+
export function resolveShadowMode(
|
|
44
|
+
doc: JxDocument | JxElement | null | undefined,
|
|
45
|
+
defaults?: ProjectConfig["defaults"],
|
|
46
|
+
): ShadowMode | null {
|
|
47
|
+
const own = asSetting((doc as { $shadow?: unknown } | null | undefined)?.$shadow);
|
|
48
|
+
const setting = own ?? asSetting(defaults?.shadow) ?? false;
|
|
49
|
+
return setting === false ? null : setting;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* The CSS scope prefix for a component's own rules.
|
|
54
|
+
*
|
|
55
|
+
* In light DOM the prefix is the tag name, which is what makes `sty-card .inner` reach only that
|
|
56
|
+
* component's descendants. Inside a shadow root the selector cannot see the host's tag name, and
|
|
57
|
+
* `:host` is the standard's way to address it.
|
|
58
|
+
*
|
|
59
|
+
* @param {string} tagName
|
|
60
|
+
* @param {ShadowMode | null} shadow
|
|
61
|
+
* @returns {string}
|
|
62
|
+
*/
|
|
63
|
+
export function styleScopePrefix(tagName: string, shadow: ShadowMode | null): string {
|
|
64
|
+
return shadow === null ? tagName : ":host";
|
|
65
|
+
}
|