@jxsuite/compiler 9.0.1 → 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 +269 -254
- package/dist/compiler.js +181 -162
- package/package.json +19 -18
- package/src/cli.ts +13 -3
- package/src/compiler.ts +38 -20
- package/src/shadow.ts +6 -33
- package/src/shared.ts +1850 -283
- package/src/site/base-path.ts +88 -2
- package/src/site/bundler-backend.bun.ts +36 -2
- package/src/site/bundler-backend.node.ts +42 -2
- package/src/site/bundler-backend.ts +12 -0
- package/src/site/bundler.ts +40 -4
- package/src/site/client-runtime.ts +13 -14
- package/src/site/external-class.ts +290 -0
- package/src/site/format-host.ts +49 -10
- package/src/site/headers-emitter.ts +6 -5
- package/src/site/image-cache.ts +34 -3
- package/src/site/image-optimizer.ts +51 -11
- package/src/site/image-transform.ts +219 -88
- package/src/site/pages-discovery.ts +8 -1
- package/src/site/prototype-resolver.ts +91 -195
- package/src/site/service-worker.ts +4 -3
- package/src/site/site-build.ts +425 -105
- package/src/site/site-loader.ts +9 -0
- package/src/targets/compile-class.ts +42 -3
- package/src/targets/compile-client.ts +319 -91
- package/src/targets/compile-element.ts +696 -94
- package/src/targets/compile-pack.ts +234 -0
- package/src/targets/compile-static.ts +33 -83
package/src/site/site-loader.ts
CHANGED
|
@@ -148,3 +148,12 @@ export function loadProjectConfig(projectRoot: string) {
|
|
|
148
148
|
projectRoot: resolve(projectRoot),
|
|
149
149
|
};
|
|
150
150
|
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Whether `JX_IMAGES_OPTIMIZE` turns image optimization off for this build. Only a plain "no" does:
|
|
154
|
+
* unset, empty or anything else leaves the project's own `images.optimize` in charge, so the
|
|
155
|
+
* variable can switch a build off and can never switch one on that the project switched off.
|
|
156
|
+
*/
|
|
157
|
+
export function imagesOptimizeOff(value: string | undefined): boolean {
|
|
158
|
+
return ["0", "false", "no", "off"].includes((value ?? "").trim().toLowerCase());
|
|
159
|
+
}
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* Compile-class.js — Compile .class.json schema-defined classes to JavaScript ES modules
|
|
3
3
|
*
|
|
4
4
|
* Generates proper ES modules with private fields, static members, accessors, etc. from a JSON
|
|
5
|
-
* Schema 2020-12 class definition.
|
|
5
|
+
* Schema 2020-12 class definition (compiler.md §5). A module imports nothing but a `$ref` base
|
|
6
|
+
* class, by the default export of the sibling module route 0 writes for that document.
|
|
6
7
|
*/
|
|
7
8
|
|
|
8
9
|
import { erasedClass } from "../erased.ts";
|
|
@@ -45,6 +46,12 @@ export function compileClassJson(authored: JxClassDef) {
|
|
|
45
46
|
}
|
|
46
47
|
lines.push("");
|
|
47
48
|
|
|
49
|
+
// A `$ref` base is another class document's module; a named base is a global the host supplies.
|
|
50
|
+
const baseImport = baseClassImport(classDef.extends);
|
|
51
|
+
if (baseImport !== null) {
|
|
52
|
+
lines.push(baseImport, "");
|
|
53
|
+
}
|
|
54
|
+
|
|
48
55
|
// Class declaration
|
|
49
56
|
const extendsClause = baseClass !== "Object" ? ` extends ${baseClass}` : "";
|
|
50
57
|
lines.push(`class ${className}${extendsClause} {`);
|
|
@@ -136,7 +143,8 @@ export function compileClassJson(authored: JxClassDef) {
|
|
|
136
143
|
}
|
|
137
144
|
// Setter
|
|
138
145
|
if (m.setter) {
|
|
139
|
-
|
|
146
|
+
// A setter takes exactly one parameter, so one that declares none is given a name.
|
|
147
|
+
const setterParams = resolveParams(m.setter.parameters ?? []) || "v";
|
|
140
148
|
lines.push(
|
|
141
149
|
` ${staticPrefix}set ${prefix}${name}(${setterParams}) {`,
|
|
142
150
|
` ${m.setter.body}`,
|
|
@@ -182,12 +190,43 @@ function resolveBaseClass(ext: JxClassDef["extends"]) {
|
|
|
182
190
|
return ext;
|
|
183
191
|
}
|
|
184
192
|
if (ext.$ref) {
|
|
185
|
-
const match = ext.$ref.match(
|
|
193
|
+
const match = ext.$ref.match(CLASS_DOCUMENT_REF);
|
|
186
194
|
return match ? match[1] : "Object";
|
|
187
195
|
}
|
|
188
196
|
return "Object";
|
|
189
197
|
}
|
|
190
198
|
|
|
199
|
+
/** A `$ref` to a class document: the file's base name is the local name the class extends. */
|
|
200
|
+
const CLASS_DOCUMENT_REF = /([A-Za-z0-9_]+)\.class\.json/;
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* The import a `$ref` base class needs, or `null` when `extends` names a global class, an
|
|
204
|
+
* unrecognised reference, or nothing.
|
|
205
|
+
*
|
|
206
|
+
* The specifier is the reference without its fragment, pointed at the module route 0 writes beside
|
|
207
|
+
* that document. The default export is what links the two, so a base whose `title` differs from its
|
|
208
|
+
* file name still resolves; a reference with no leading `./`, `../`, `/` or scheme is relative to
|
|
209
|
+
* the document, which a module specifier has to say.
|
|
210
|
+
*
|
|
211
|
+
* @param {JxClassDef["extends"]} ext
|
|
212
|
+
* @returns {string | null}
|
|
213
|
+
*/
|
|
214
|
+
function baseClassImport(ext: JxClassDef["extends"]): string | null {
|
|
215
|
+
if (!ext || isString(ext) || !ext.$ref) {
|
|
216
|
+
return null;
|
|
217
|
+
}
|
|
218
|
+
const match = ext.$ref.match(CLASS_DOCUMENT_REF);
|
|
219
|
+
if (!match) {
|
|
220
|
+
return null;
|
|
221
|
+
}
|
|
222
|
+
const [path = ""] = ext.$ref.split("#");
|
|
223
|
+
const modulePath = path.replace(/\.class\.json$/, ".js");
|
|
224
|
+
const specifier = /^(?:\.{0,2}\/|[a-z][a-z0-9+.-]*:)/i.test(modulePath)
|
|
225
|
+
? modulePath
|
|
226
|
+
: `./${modulePath}`;
|
|
227
|
+
return `import ${match[1]} from ${JSON.stringify(specifier)};`;
|
|
228
|
+
}
|
|
229
|
+
|
|
191
230
|
/**
|
|
192
231
|
* Resolve parameter names from $ref or inline definitions.
|
|
193
232
|
*
|