@jxsuite/compiler 9.0.1 → 9.1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jxsuite/compiler",
3
- "version": "9.0.1",
3
+ "version": "9.1.0",
4
4
  "description": "Jx static HTML compiler, island detector, and site builder",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -54,31 +54,31 @@
54
54
  "upgrade": "bun update --latest && bun install"
55
55
  },
56
56
  "dependencies": {
57
- "@jxsuite/compiler-binding": "^0.2.1",
58
- "@jxsuite/create": "^1.8.2",
59
- "@jxsuite/erase": "^0.3.1",
60
- "@jxsuite/runtime": "^7.0.1",
61
- "@jxsuite/schema": "^6.0.1",
62
- "@jxsuite/site": "^2.7.1",
63
- "@vue/reactivity": "3.5.44",
57
+ "@jxsuite/compiler-binding": "^0.3.0",
58
+ "@jxsuite/create": "^1.8.3",
59
+ "@jxsuite/erase": "^0.3.2",
60
+ "@jxsuite/runtime": "^7.1.0",
61
+ "@jxsuite/schema": "^6.0.2",
62
+ "@jxsuite/site": "^2.8.0",
63
+ "@vue/reactivity": "3.5.45",
64
64
  "esbuild": "^0.28.2",
65
65
  "lit-html": "^3.3.3"
66
66
  },
67
67
  "devDependencies": {
68
68
  "@happy-dom/global-registrator": "^21.0.4",
69
- "@jxsuite/connector": "^0.8.10",
70
- "@jxsuite/parser": "^5.0.1",
69
+ "@jxsuite/connector": "^0.8.11",
70
+ "@jxsuite/parser": "^5.0.2",
71
71
  "@jxsuite/test-support": "^0.0.0",
72
72
  "@types/mdast": "^4.0.4"
73
73
  },
74
74
  "optionalDependencies": {
75
- "@jxsuite/compiler-binding-linux-x64-gnu": "0.2.1",
76
- "@jxsuite/compiler-binding-linux-x64-musl": "0.2.1",
77
- "@jxsuite/compiler-binding-linux-arm64-gnu": "0.2.1",
78
- "@jxsuite/compiler-binding-linux-arm64-musl": "0.2.1",
79
- "@jxsuite/compiler-binding-darwin-x64": "0.2.1",
80
- "@jxsuite/compiler-binding-darwin-arm64": "0.2.1",
81
- "@jxsuite/compiler-binding-win32-x64-msvc": "0.2.1",
82
- "@jxsuite/compiler-binding-win32-arm64-msvc": "0.2.1"
75
+ "@jxsuite/compiler-binding-linux-x64-gnu": "0.3.0",
76
+ "@jxsuite/compiler-binding-linux-x64-musl": "0.3.0",
77
+ "@jxsuite/compiler-binding-linux-arm64-gnu": "0.3.0",
78
+ "@jxsuite/compiler-binding-linux-arm64-musl": "0.3.0",
79
+ "@jxsuite/compiler-binding-darwin-x64": "0.3.0",
80
+ "@jxsuite/compiler-binding-darwin-arm64": "0.3.0",
81
+ "@jxsuite/compiler-binding-win32-x64-msvc": "0.3.0",
82
+ "@jxsuite/compiler-binding-win32-arm64-msvc": "0.3.0"
83
83
  }
84
84
  }
package/src/cli.ts CHANGED
@@ -2,8 +2,8 @@
2
2
  /**
3
3
  * Jx — Unified CLI for the Jx platform
4
4
  *
5
- * Commands: jx build [project-root] [--verbose] [--no-clean] [--include-held] jx schema
6
- * [project-root] jx validate [project-root]
5
+ * Commands: jx build [project-root] [--verbose] [--no-clean] [--include-held]
6
+ * [--no-optimize-images] jx schema [project-root] jx validate [project-root]
7
7
  *
8
8
  * @module jx-cli
9
9
  */
@@ -37,6 +37,8 @@ Options:
37
37
  --verbose Print detailed build progress
38
38
  --no-clean Don't clean outDir before building
39
39
  --include-held Keep entries a content type's hold rules match, for a preview
40
+ --no-optimize-images Publish images as they are, whatever images.optimize says (also
41
+ JX_IMAGES_OPTIMIZE=false in the environment)
40
42
  --port <n> dev/preview: port to listen on (default 3000 / 4173)
41
43
  --dry-run db push: print the statements without executing them
42
44
  --connection db push: restrict to one connection name
@@ -139,7 +141,15 @@ Options:
139
141
 
140
142
  try {
141
143
  const { buildSite } = await import("./site/site-build.ts");
142
- const result = await buildSite(projectRoot, { clean, includeHeld, verbose });
144
+ const { imagesOptimizeOff } = await import("./site/site-loader.ts");
145
+ const optimizeImages =
146
+ !flags.has("--no-optimize-images") && !imagesOptimizeOff(process.env.JX_IMAGES_OPTIMIZE);
147
+ const result = await buildSite(projectRoot, {
148
+ clean,
149
+ includeHeld,
150
+ optimizeImages,
151
+ verbose,
152
+ });
143
153
 
144
154
  if (result.errors.length > 0) {
145
155
  console.error(`\nBuild completed with ${result.errors.length} error(s):`);
package/src/compiler.ts CHANGED
@@ -3,6 +3,7 @@
3
3
  *
4
4
  * Routes Jx documents to the appropriate compilation target:
5
5
  *
6
+ * - `$prototype: "Class"` → compile-class.js (ES class module, compiler.md §5.6)
6
7
  * - Fully static → compile-static.js (plain HTML/CSS, zero JS)
7
8
  * - Custom element (-) → compile-element.js (lit-html web component)
8
9
  * - Dynamic (standard) → compile-client.js (pre-rendered HTML + reactive bindings)
@@ -29,7 +30,7 @@ import { compileStaticPage } from "./targets/compile-static.ts";
29
30
  import { compileClient } from "./targets/compile-client.ts";
30
31
  import { isClassDef, isString } from "@jxsuite/schema/guards";
31
32
  import { isNativeDocumentPath, parseNativeDocument } from "@jxsuite/schema/jxn";
32
- import type { JxDocument, JxStyle } from "@jxsuite/schema/types";
33
+ import type { JxDocument, JxPrototypeDef, JxStyle } from "@jxsuite/schema/types";
33
34
  import type { FormatRegistry } from "@jxsuite/schema/format-registry";
34
35
 
35
36
  // Re-exports for consumers
@@ -48,6 +49,11 @@ export interface CompileOptions {
48
49
  formats?: FormatRegistry;
49
50
  /** Rewrite Function-def `$src` specifiers to served URLs (see CompileElementOptions). */
50
51
  rewriteSrc?: (specifier: string) => string;
52
+ /**
53
+ * The URL a `timing: "client"` external class's module is served at (compiler.md §3, §12). A site
54
+ * build supplies it; without it such an entry is a compile error.
55
+ */
56
+ resolveClass?: (def: JxPrototypeDef) => string;
51
57
  /**
52
58
  * The route prefix a `timing: "server"` entry posts to, deployment base included
53
59
  * (`serverRoutePrefix`). Default `"/_jx/server"`, for a site served from its origin root.
@@ -74,8 +80,10 @@ interface PageTargetOverrides {
74
80
  /**
75
81
  * Compile a Jx document to HTML (+ optional JS module files).
76
82
  *
77
- * Routing: 1. Not dynamic → static HTML/CSS, zero JS 2. tagName contains hyphen → custom element
78
- * (lit-html) 3. Otherwise → pre-rendered HTML with reactive bindings
83
+ * Routing, first match wins: 0. Root `$prototype` is `"Class"` → ES class module (compiler.md §5.6)
84
+ *
85
+ * 1. Not dynamic → static HTML/CSS, zero JS 2. tagName contains hyphen → custom element (lit-html) 3.
86
+ * Otherwise → pre-rendered HTML with reactive bindings
79
87
  *
80
88
  * @param {string | JxDocument} sourcePath - Path to .json file, URL, or raw document object
81
89
  * @param {CompileOptions} [opts]
@@ -113,25 +121,25 @@ export async function compile(sourcePath: string | JxDocument, opts: CompileOpti
113
121
  // Function bodies as JavaScript before anything analyses them (spec.md §23.1).
114
122
  raw = erasedDocument(raw, isString(sourcePath) ? sourcePath : "the document");
115
123
 
116
- // Route 0: .class.json schema-defined class → JS class module
124
+ // Route 0: a class document (`$prototype: "Class"`, whatever the file is called) → JS class module
117
125
  if (isClassDef(raw)) {
118
126
  const { compileClassJson } = await import("./targets/compile-class.js");
119
127
  const jsContent = compileClassJson(raw);
128
+ // Beside the source and never over it: the extension, and a `.class` before it, become `.js`.
120
129
  const outputPath = isString(sourcePath)
121
- ? sourcePath.replace(/\.class\.json$/, ".js")
130
+ ? sourcePath.replace(/(\.class)?\.[^./\\]+$/, ".js")
122
131
  : `${raw.title}.js`;
123
132
  return { files: [{ content: jsContent, path: outputPath }], html: "" };
124
133
  }
125
134
 
126
135
  // Route 1: Fully static → plain HTML/CSS
127
136
  if (!isDynamic(raw)) {
128
- return compileStaticPage(raw, {
129
- litHtmlSrc,
130
- projectStyle,
131
- reactivitySrc,
132
- ...pageTargetOverrides(opts),
133
- title,
134
- });
137
+ // The static target emits no module, so it takes no runtime source and no `$src` rewriter.
138
+ const staticOptions: Parameters<typeof compileStaticPage>[1] = { projectStyle, title };
139
+ if (opts.prePaintScheme === false) {
140
+ staticOptions.prePaintScheme = false;
141
+ }
142
+ return compileStaticPage(raw, staticOptions);
135
143
  }
136
144
 
137
145
  // Route 2: Custom element tagName (contains hyphen) → lit-html web component
@@ -145,6 +153,8 @@ export async function compile(sourcePath: string | JxDocument, opts: CompileOpti
145
153
  opts.rewriteSrc,
146
154
  null,
147
155
  opts.serverBaseUrl,
156
+ [],
157
+ opts.resolveClass,
148
158
  );
149
159
  const moduleFile = {
150
160
  content: moduleContent,
@@ -189,6 +199,9 @@ export async function compile(sourcePath: string | JxDocument, opts: CompileOpti
189
199
  if (opts.serverBaseUrl !== undefined) {
190
200
  clientOptions.serverBaseUrl = opts.serverBaseUrl;
191
201
  }
202
+ if (opts.resolveClass !== undefined) {
203
+ clientOptions.resolveClass = opts.resolveClass;
204
+ }
192
205
  return compileClient(raw, clientOptions);
193
206
  }
194
207