@jxsuite/compiler 0.23.2 → 0.25.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/compiler.js +155 -155
- package/package.json +18 -16
- package/src/{cli.js → cli.ts} +2 -2
- package/src/{compile-cli.js → compile-cli.ts} +1 -1
- package/src/{compiler.js → compiler.ts} +10 -8
- package/src/{shared.js → shared.ts} +161 -123
- package/src/site/{content-loader.js → content-loader.ts} +57 -48
- package/src/site/{context-injection.js → context-injection.ts} +18 -12
- package/src/site/{head-merger.js → head-merger.ts} +17 -11
- package/src/site/{image-cache.js → image-cache.ts} +22 -22
- package/src/site/{image-optimizer.js → image-optimizer.ts} +35 -44
- package/src/site/{image-transform.js → image-transform.ts} +52 -22
- package/src/site/{layout-resolver.js → layout-resolver.ts} +31 -26
- package/src/site/{pages-discovery.js → pages-discovery.ts} +31 -30
- package/src/site/{prototype-resolver.js → prototype-resolver.ts} +16 -5
- package/src/site/{site-build.js → site-build.ts} +135 -135
- package/src/site/{site-loader.js → site-loader.ts} +2 -2
- package/src/targets/{compile-class.js → compile-class.ts} +20 -19
- package/src/targets/{compile-client.js → compile-client.ts} +84 -105
- package/src/targets/{compile-element.js → compile-element.ts} +82 -88
- package/src/targets/{compile-markdown.js → compile-markdown.ts} +95 -81
- package/src/targets/{compile-server.js → compile-server.ts} +23 -6
- package/src/targets/{compile-static.js → compile-static.ts} +35 -18
- package/src/types.ts +16 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jxsuite/compiler",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.0",
|
|
4
4
|
"description": "Jx static HTML compiler, island detector, and site builder",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"directory": "packages/compiler"
|
|
10
10
|
},
|
|
11
11
|
"bin": {
|
|
12
|
-
"jx": "./src/cli.
|
|
12
|
+
"jx": "./src/cli.ts"
|
|
13
13
|
},
|
|
14
14
|
"files": [
|
|
15
15
|
"src/",
|
|
@@ -17,29 +17,31 @@
|
|
|
17
17
|
],
|
|
18
18
|
"type": "module",
|
|
19
19
|
"exports": {
|
|
20
|
-
".": "./src/compiler.
|
|
21
|
-
"./content-loader": "./src/site/content-loader.
|
|
22
|
-
"./context-injection": "./src/site/context-injection.
|
|
23
|
-
"./head-merger": "./src/site/head-merger.
|
|
24
|
-
"./layout-resolver": "./src/site/layout-resolver.
|
|
25
|
-
"./pages-discovery": "./src/site/pages-discovery.
|
|
26
|
-
"./site": "./src/site/site-build.
|
|
27
|
-
"./site-loader": "./src/site/site-loader.
|
|
20
|
+
".": "./src/compiler.ts",
|
|
21
|
+
"./content-loader": "./src/site/content-loader.ts",
|
|
22
|
+
"./context-injection": "./src/site/context-injection.ts",
|
|
23
|
+
"./head-merger": "./src/site/head-merger.ts",
|
|
24
|
+
"./layout-resolver": "./src/site/layout-resolver.ts",
|
|
25
|
+
"./pages-discovery": "./src/site/pages-discovery.ts",
|
|
26
|
+
"./site": "./src/site/site-build.ts",
|
|
27
|
+
"./site-loader": "./src/site/site-loader.ts",
|
|
28
|
+
"./types": "./src/types.ts"
|
|
28
29
|
},
|
|
29
30
|
"publishConfig": {
|
|
30
31
|
"provenance": true
|
|
31
32
|
},
|
|
32
33
|
"scripts": {
|
|
33
|
-
"build": "bun build src/compiler.
|
|
34
|
-
"build:site": "bun src/cli.
|
|
35
|
-
"test": "bun test",
|
|
36
|
-
"test:coverage": "bun test --coverage",
|
|
34
|
+
"build": "bun build src/compiler.ts --outdir=dist --format=esm --minify",
|
|
35
|
+
"build:site": "bun src/cli.ts build",
|
|
36
|
+
"test": "bun test --isolate",
|
|
37
|
+
"test:coverage": "bun test --isolate --coverage",
|
|
37
38
|
"upgrade": "bunx npm-check-updates -u && bun install"
|
|
38
39
|
},
|
|
39
40
|
"dependencies": {
|
|
40
41
|
"@apidevtools/json-schema-ref-parser": "^15.3.5",
|
|
41
|
-
"@jxsuite/parser": "^0.
|
|
42
|
-
"@jxsuite/runtime": "^0.
|
|
42
|
+
"@jxsuite/parser": "^0.25.0",
|
|
43
|
+
"@jxsuite/runtime": "^0.25.0",
|
|
44
|
+
"@jxsuite/schema": "^0.23.2",
|
|
43
45
|
"remark-gfm": "^4.0.1",
|
|
44
46
|
"remark-stringify": "^11.0.0",
|
|
45
47
|
"sharp": "^0.34.5",
|
package/src/{cli.js → cli.ts}
RENAMED
|
@@ -36,7 +36,7 @@ if (command === "build") {
|
|
|
36
36
|
console.log(`Building site from ${projectRoot}...`);
|
|
37
37
|
|
|
38
38
|
try {
|
|
39
|
-
const { buildSite } = await import("./site/site-build.
|
|
39
|
+
const { buildSite } = await import("./site/site-build.ts");
|
|
40
40
|
const result = await buildSite(projectRoot, { verbose, clean });
|
|
41
41
|
|
|
42
42
|
if (result.errors.length > 0) {
|
|
@@ -49,7 +49,7 @@ if (command === "build") {
|
|
|
49
49
|
|
|
50
50
|
console.log(`\nDone: ${result.routes} routes → ${result.files} files`);
|
|
51
51
|
} catch (e) {
|
|
52
|
-
const err =
|
|
52
|
+
const err = e as Error;
|
|
53
53
|
console.error(`Build failed: ${err.message}`);
|
|
54
54
|
process.exit(1);
|
|
55
55
|
}
|
|
@@ -21,19 +21,21 @@ import {
|
|
|
21
21
|
tagNameToClassName,
|
|
22
22
|
DEFAULT_REACTIVITY_SRC,
|
|
23
23
|
DEFAULT_LIT_HTML_SRC,
|
|
24
|
-
} from "./shared.
|
|
24
|
+
} from "./shared.ts";
|
|
25
25
|
import {
|
|
26
26
|
compileServer,
|
|
27
27
|
compileSiteServer,
|
|
28
28
|
compilePagesFunctions,
|
|
29
|
-
} from "./targets/compile-server.
|
|
29
|
+
} from "./targets/compile-server.ts";
|
|
30
|
+
|
|
30
31
|
import {
|
|
31
32
|
compileElement,
|
|
32
33
|
compileElementPage,
|
|
33
34
|
emitElementModule,
|
|
34
|
-
} from "./targets/compile-element.
|
|
35
|
-
import { compileStaticPage } from "./targets/compile-static.
|
|
36
|
-
import { compileClient } from "./targets/compile-client.
|
|
35
|
+
} from "./targets/compile-element.ts";
|
|
36
|
+
import { compileStaticPage } from "./targets/compile-static.ts";
|
|
37
|
+
import { compileClient } from "./targets/compile-client.ts";
|
|
38
|
+
import type { JxMutableNode } from "@jxsuite/schema/types";
|
|
37
39
|
|
|
38
40
|
// Re-exports for consumers
|
|
39
41
|
export {
|
|
@@ -61,13 +63,13 @@ export {
|
|
|
61
63
|
* files: { path: string; content: string; tagName?: string }[];
|
|
62
64
|
* }>}
|
|
63
65
|
*/
|
|
64
|
-
export async function compile(sourcePath, opts = {}) {
|
|
66
|
+
export async function compile(sourcePath: string | any, opts: Record<string, unknown> = {}) {
|
|
65
67
|
const {
|
|
66
68
|
title = "Jx App",
|
|
67
69
|
reactivitySrc = DEFAULT_REACTIVITY_SRC,
|
|
68
70
|
litHtmlSrc = DEFAULT_LIT_HTML_SRC,
|
|
69
71
|
projectStyle = null,
|
|
70
|
-
} =
|
|
72
|
+
} = opts as JxMutableNode;
|
|
71
73
|
|
|
72
74
|
let raw;
|
|
73
75
|
if (typeof sourcePath === "string") {
|
|
@@ -141,7 +143,7 @@ export async function compile(sourcePath, opts = {}) {
|
|
|
141
143
|
* @param {string} src
|
|
142
144
|
* @param {string} [out]
|
|
143
145
|
*/
|
|
144
|
-
export async function runCli(src, out) {
|
|
146
|
+
export async function runCli(src: string, out?: string) {
|
|
145
147
|
const [result, server] = await Promise.all([compile(src), compileServer(src)]);
|
|
146
148
|
const { writeFileSync, mkdirSync } = await import("node:fs");
|
|
147
149
|
const { dirname, join } = await import("node:path");
|