xanix 1.0.9 → 1.0.10
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/bin/bundler/buildClient.js +4 -3
- package/dist/bin/bundler/buildServer.js +4 -3
- package/dist/bin/bundler/cacheNpmModules.js +2 -1
- package/dist/bin/bundler/config/output.d.ts +0 -4
- package/dist/bin/bundler/config/output.js +3 -7
- package/dist/bin/bundler/plugins/XanixEntryFinder/finder.js +2 -1
- package/dist/bin/bundler/plugins/XanixResolveCacheDeps/index.js +6 -2
- package/dist/bin/bundler/watchClient.js +4 -3
- package/dist/bin/bundler/watchServer.js +4 -3
- package/dist/bin/cli/dev.js +2 -2
- package/dist/bin/cli/start.js +2 -2
- package/dist/bin/include/manifest.js +2 -1
- package/dist/client-runtime.js +2 -1
- package/dist/components/Head.js +2 -1
- package/dist/dirs.d.ts +0 -0
- package/dist/dirs.js +1 -0
- package/dist/hooks/useData.js +2 -1
- package/dist/index.d.ts +1 -0
- package/dist/outdir.d.ts +8 -0
- package/dist/outdir.js +9 -0
- package/dist/outdirs.d.ts +8 -0
- package/dist/outdirs.js +9 -0
- package/dist/server/runtime/createServer.js +7 -6
- package/dist/server/runtime/readManifest.js +2 -1
- package/dist/types/globals.d.ts +0 -1
- package/package.json +1 -1
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { rollup } from "rollup";
|
|
2
2
|
import fs from "node:fs";
|
|
3
|
-
import bundlerOutput
|
|
3
|
+
import bundlerOutput from "./config/output.js";
|
|
4
4
|
import { getClientRuntimeFile, getClientRuntimeFileName, } from "../include/utils.js";
|
|
5
5
|
import { xanixDefaultPlugins } from "./plugins/plugins.js";
|
|
6
|
+
import outdirs from "../../outdirs.js";
|
|
6
7
|
const buildClient = async (entries) => {
|
|
7
8
|
const input = {};
|
|
8
9
|
for (const entry of entries) {
|
|
@@ -10,11 +11,11 @@ const buildClient = async (entries) => {
|
|
|
10
11
|
}
|
|
11
12
|
const runtimeFileName = getClientRuntimeFileName("production");
|
|
12
13
|
input[runtimeFileName] = getClientRuntimeFile();
|
|
13
|
-
fs.rmSync(
|
|
14
|
+
fs.rmSync(outdirs.client, {
|
|
14
15
|
recursive: true,
|
|
15
16
|
force: true,
|
|
16
17
|
});
|
|
17
|
-
fs.mkdirSync(
|
|
18
|
+
fs.mkdirSync(outdirs.client, {
|
|
18
19
|
recursive: true,
|
|
19
20
|
});
|
|
20
21
|
const build = await rollup({
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { rollup } from "rollup";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import bundlerOutput
|
|
3
|
+
import bundlerOutput from "./config/output.js";
|
|
4
4
|
import fs from "node:fs";
|
|
5
5
|
import { createManifest } from "../include/manifest.js";
|
|
6
6
|
import generateClientEntries from "./generateClientEntries.js";
|
|
7
7
|
import { xanixDefaultPlugins } from "./plugins/plugins.js";
|
|
8
|
+
import outdirs from "../../outdirs.js";
|
|
8
9
|
const root = process.cwd();
|
|
9
10
|
const BuildServer = async ({ rootEntry, onBuildEnd }) => {
|
|
10
|
-
fs.rmSync(
|
|
11
|
+
fs.rmSync(outdirs.server, {
|
|
11
12
|
recursive: true,
|
|
12
13
|
force: true,
|
|
13
14
|
});
|
|
14
|
-
fs.mkdirSync(
|
|
15
|
+
fs.mkdirSync(outdirs.server, {
|
|
15
16
|
recursive: true,
|
|
16
17
|
});
|
|
17
18
|
const entries = await generateClientEntries();
|
|
@@ -7,6 +7,7 @@ import { getClientRuntimeFile } from "../include/utils.js";
|
|
|
7
7
|
import esbuild from "rollup-plugin-esbuild";
|
|
8
8
|
import url from "@rollup/plugin-url";
|
|
9
9
|
import XanixDocument from "./plugins/XanixDocument/index.js";
|
|
10
|
+
import outdirs from "../../outdirs.js";
|
|
10
11
|
const require = createRequire(import.meta.url);
|
|
11
12
|
const GenerateGraph = async (entries) => {
|
|
12
13
|
const collector = new Map();
|
|
@@ -154,7 +155,7 @@ const BuildCache = async (entries) => {
|
|
|
154
155
|
file: `${entryName}.js`,
|
|
155
156
|
});
|
|
156
157
|
}
|
|
157
|
-
const cacheDir = path.resolve(
|
|
158
|
+
const cacheDir = path.resolve(outdirs.server, "cache");
|
|
158
159
|
await bundleDeps(input, cacheDir);
|
|
159
160
|
return metadata;
|
|
160
161
|
};
|
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import outdirs from "../../../outdirs.js";
|
|
2
2
|
const root = process.cwd();
|
|
3
|
-
export const outDir = {
|
|
4
|
-
server: path.resolve(root, ".xanix"),
|
|
5
|
-
client: path.resolve(root, ".xanix/client"),
|
|
6
|
-
};
|
|
7
3
|
const client = (entries, { isDev }) => {
|
|
8
4
|
const _entries = {};
|
|
9
5
|
for (const entry of entries) {
|
|
10
6
|
_entries[entry.name] = entry;
|
|
11
7
|
}
|
|
12
8
|
const opt = {
|
|
13
|
-
dir:
|
|
9
|
+
dir: outdirs.client,
|
|
14
10
|
format: "esm",
|
|
15
11
|
entryFileNames: (id) => {
|
|
16
12
|
const entry = _entries[id.name];
|
|
@@ -33,7 +29,7 @@ const client = (entries, { isDev }) => {
|
|
|
33
29
|
};
|
|
34
30
|
const server = (opt) => {
|
|
35
31
|
return {
|
|
36
|
-
dir:
|
|
32
|
+
dir: outdirs.server,
|
|
37
33
|
format: "esm",
|
|
38
34
|
sourcemap: opt.isDev ?? true,
|
|
39
35
|
entryFileNames: "[name].js",
|
|
@@ -4,6 +4,7 @@ import crypto from "node:crypto";
|
|
|
4
4
|
import { parse } from "@babel/parser";
|
|
5
5
|
import traverse from "@babel/traverse";
|
|
6
6
|
import * as t from "@babel/types";
|
|
7
|
+
import outdirs from "../../../../outdirs.js";
|
|
7
8
|
const SOURCE_EXTENSIONS = [".tsx", ".ts", ".jsx", ".js", ".mjs", ".cjs"];
|
|
8
9
|
function normalizeFilePath(file) {
|
|
9
10
|
return path.resolve(file).split(path.sep).join("/");
|
|
@@ -140,7 +141,7 @@ export function entryFinder(code, id) {
|
|
|
140
141
|
const root = process.cwd();
|
|
141
142
|
const relativeSource = path.relative(root, componentFile);
|
|
142
143
|
const parsed = path.parse(relativeSource);
|
|
143
|
-
const buildPath = normalizeFilePath(path.resolve(root,
|
|
144
|
+
const buildPath = normalizeFilePath(path.resolve(root, outdirs.root, parsed.dir, `${parsed.name}.js`));
|
|
144
145
|
const entry = {
|
|
145
146
|
id: clientId,
|
|
146
147
|
name: componentName,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import BuildCache from "../../cacheNpmModules.js";
|
|
3
|
+
import outdirs from "../../../../outdirs.js";
|
|
3
4
|
function XanixResolveCacheDeps(metadata, entries) {
|
|
4
5
|
if (!entries.length) {
|
|
5
6
|
return {
|
|
@@ -14,12 +15,15 @@ function XanixResolveCacheDeps(metadata, entries) {
|
|
|
14
15
|
}
|
|
15
16
|
const dependency = metadata.get(source);
|
|
16
17
|
if (dependency) {
|
|
17
|
-
return { id:
|
|
18
|
+
return { id: `/${outdirs.cache}/${dependency.file}`, external: true };
|
|
18
19
|
}
|
|
19
20
|
const buildCache = await BuildCache(entries);
|
|
20
21
|
const newDependency = buildCache.get(source);
|
|
21
22
|
if (newDependency) {
|
|
22
|
-
return {
|
|
23
|
+
return {
|
|
24
|
+
id: `/${outdirs.cache}/${newDependency.file}`,
|
|
25
|
+
external: true,
|
|
26
|
+
};
|
|
23
27
|
}
|
|
24
28
|
},
|
|
25
29
|
};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { watch } from "rollup";
|
|
2
|
-
import bundlerOutput
|
|
2
|
+
import bundlerOutput from "./config/output.js";
|
|
3
3
|
import fs from "node:fs";
|
|
4
4
|
import BuildCache from "./cacheNpmModules.js";
|
|
5
5
|
import XanixResolveCacheDeps from "./plugins/XanixResolveCacheDeps/index.js";
|
|
6
6
|
import { getClientRuntimeFile, getClientRuntimeFileName, } from "../include/utils.js";
|
|
7
7
|
import { xanixDefaultPlugins } from "./plugins/plugins.js";
|
|
8
|
+
import outdirs from "../../outdirs.js";
|
|
8
9
|
const WatchClient = async (entries, options) => {
|
|
9
10
|
const input = {};
|
|
10
11
|
for (const entry of entries) {
|
|
@@ -12,11 +13,11 @@ const WatchClient = async (entries, options) => {
|
|
|
12
13
|
}
|
|
13
14
|
const runtimeFileName = getClientRuntimeFileName("development");
|
|
14
15
|
input[runtimeFileName] = getClientRuntimeFile();
|
|
15
|
-
fs.rmSync(
|
|
16
|
+
fs.rmSync(outdirs.client, {
|
|
16
17
|
recursive: true,
|
|
17
18
|
force: true,
|
|
18
19
|
});
|
|
19
|
-
fs.mkdirSync(
|
|
20
|
+
fs.mkdirSync(outdirs.client, {
|
|
20
21
|
recursive: true,
|
|
21
22
|
});
|
|
22
23
|
let buildCache;
|
|
@@ -3,16 +3,17 @@ import path from "node:path";
|
|
|
3
3
|
import fs from "node:fs";
|
|
4
4
|
import { createManifest, readManifest } from "../include/manifest.js";
|
|
5
5
|
import generateClientEntries from "./generateClientEntries.js";
|
|
6
|
-
import bundlerOutput
|
|
6
|
+
import bundlerOutput from "./config/output.js";
|
|
7
7
|
import { entriesEqual } from "../include/entry.js";
|
|
8
8
|
import { xanixDefaultPlugins } from "./plugins/plugins.js";
|
|
9
|
+
import outdirs from "../../outdirs.js";
|
|
9
10
|
const root = process.cwd();
|
|
10
11
|
const watchServer = async ({ rootEntry, onChange, onBuildEnd, onServerChange, onClientEntryChange, }) => {
|
|
11
|
-
fs.rmSync(
|
|
12
|
+
fs.rmSync(outdirs.server, {
|
|
12
13
|
recursive: true,
|
|
13
14
|
force: true,
|
|
14
15
|
});
|
|
15
|
-
fs.mkdirSync(
|
|
16
|
+
fs.mkdirSync(outdirs.server, {
|
|
16
17
|
recursive: true,
|
|
17
18
|
});
|
|
18
19
|
const entries = await generateClientEntries();
|
package/dist/bin/cli/dev.js
CHANGED
|
@@ -5,14 +5,14 @@ import watchClient from "../bundler/watchClient.js";
|
|
|
5
5
|
import pc from "picocolors";
|
|
6
6
|
import logger from "../include/logger.js";
|
|
7
7
|
import { getEntries } from "../include/entry.js";
|
|
8
|
-
import { outDir } from "../bundler/config/output.js";
|
|
9
8
|
import { WebSocketServer } from "ws";
|
|
9
|
+
import outdirs from "../../outdirs.js";
|
|
10
10
|
const root = process.cwd();
|
|
11
11
|
let child;
|
|
12
12
|
function start() {
|
|
13
13
|
child?.kill();
|
|
14
14
|
return new Promise((resolve) => {
|
|
15
|
-
const filePath = path.join(
|
|
15
|
+
const filePath = path.join(outdirs.server, "index.js");
|
|
16
16
|
child = spawn(process.execPath, [filePath], {
|
|
17
17
|
stdio: !child ? "inherit" : "pipe",
|
|
18
18
|
});
|
package/dist/bin/cli/start.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { spawn } from "child_process";
|
|
3
|
-
import
|
|
3
|
+
import outdirs from "../../outdirs.js";
|
|
4
4
|
let child;
|
|
5
5
|
const start = async () => {
|
|
6
|
-
const filePath = path.join(
|
|
6
|
+
const filePath = path.join(outdirs.server, "index.js");
|
|
7
7
|
child = spawn(process.execPath, [filePath], {
|
|
8
8
|
stdio: "inherit",
|
|
9
9
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import fs from "node:fs";
|
|
3
|
+
import outdirs from "../../outdirs.js";
|
|
3
4
|
let readedManifest = null;
|
|
4
5
|
export const createManifest = async (entries) => {
|
|
5
6
|
const manifest = {
|
|
@@ -7,7 +8,7 @@ export const createManifest = async (entries) => {
|
|
|
7
8
|
entries: [...entries.values()],
|
|
8
9
|
};
|
|
9
10
|
readedManifest = manifest;
|
|
10
|
-
const outDir = path.resolve(process.cwd(),
|
|
11
|
+
const outDir = path.resolve(process.cwd(), outdirs.root);
|
|
11
12
|
fs.writeFileSync(path.resolve(outDir, "client-manifest.json"), JSON.stringify(manifest, null, 2));
|
|
12
13
|
};
|
|
13
14
|
export const readManifest = async () => readedManifest;
|
package/dist/client-runtime.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { createRoot } from "react-dom/client";
|
|
3
|
+
import outdirs from "./outdirs.js";
|
|
3
4
|
const pages = new Map();
|
|
4
5
|
const ROOT_KEY = "__xanix_root__";
|
|
5
6
|
export const getPath = () => {
|
|
6
7
|
const { pathname, search } = window.location;
|
|
7
8
|
return search ? `${pathname}${search}` : pathname;
|
|
8
9
|
};
|
|
9
|
-
export const getImportUrl = (pageId) =>
|
|
10
|
+
export const getImportUrl = (pageId) => `/${outdirs.client}/${pageId}.js`;
|
|
10
11
|
function getRoot() {
|
|
11
12
|
let ele = document.body;
|
|
12
13
|
if (!ele) {
|
package/dist/components/Head.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect } from "react";
|
|
3
3
|
import useDocument from "../hooks/useDocument.js";
|
|
4
|
+
import outdirs from "../outdirs.js";
|
|
4
5
|
const Head = ({ children }) => {
|
|
5
6
|
const { title, meta, pageId, props, params, pageData } = useDocument();
|
|
6
7
|
if (__XANIX_CLIENT__) {
|
|
@@ -39,7 +40,7 @@ const Head = ({ children }) => {
|
|
|
39
40
|
request: null,
|
|
40
41
|
})};
|
|
41
42
|
`,
|
|
42
|
-
} }), _jsx("script", { type: "module", src:
|
|
43
|
+
} }), _jsx("script", { type: "module", src: `/${outdirs.client}/${__XANIX_CLIENT_RUNTIME_FILE_NAME__}.js` })] }));
|
|
43
44
|
}
|
|
44
45
|
};
|
|
45
46
|
export default Head;
|
package/dist/dirs.d.ts
ADDED
|
File without changes
|
package/dist/dirs.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
package/dist/hooks/useData.js
CHANGED
|
@@ -2,6 +2,7 @@ import usePage from "./usePage.js";
|
|
|
2
2
|
import React, { useEffect, useRef } from "react";
|
|
3
3
|
import useDocument from "./useDocument.js";
|
|
4
4
|
import loader from "../dataLoader.js";
|
|
5
|
+
import outdirs from "../outdirs.js";
|
|
5
6
|
const useData = (_callback, _args) => {
|
|
6
7
|
return {};
|
|
7
8
|
};
|
|
@@ -31,7 +32,7 @@ useData.register = (xanixId, callback) => {
|
|
|
31
32
|
const init = useRef(false);
|
|
32
33
|
const reload = async () => {
|
|
33
34
|
setLoading(true);
|
|
34
|
-
const res = await fetch(
|
|
35
|
+
const res = await fetch(`/${outdirs.root}/__data__/${xanixId}`, {
|
|
35
36
|
method: "POST",
|
|
36
37
|
headers: {
|
|
37
38
|
"Content-Type": "application/json",
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference path="./types/globals.d.ts" />
|
|
2
2
|
/// <reference path="./types/express.d.ts" />
|
|
3
3
|
/// <reference path="./types/assets.d.ts" />
|
|
4
|
+
/// <reference path="./types/xanix-virtual.d.ts" />
|
|
4
5
|
|
|
5
6
|
import Link from "./components/Link.js";
|
|
6
7
|
import Document, { DocumentProps } from "./components/Document.js";
|
package/dist/outdir.d.ts
ADDED
package/dist/outdir.js
ADDED
package/dist/outdirs.js
ADDED
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
import express from "express";
|
|
2
2
|
import dataLoader from "../../dataLoader.js";
|
|
3
|
+
import outdirs from "../../outdirs.js";
|
|
3
4
|
function createXanixServer({ mode }) {
|
|
4
5
|
const app = express();
|
|
5
6
|
if (mode === "watch") {
|
|
6
|
-
app.use(
|
|
7
|
-
app.use(
|
|
8
|
-
app.use(
|
|
7
|
+
app.use(`/${outdirs.client}`, express.static(`${outdirs.client}`));
|
|
8
|
+
app.use(`/assets`, express.static(outdirs.assets));
|
|
9
|
+
app.use(`/${outdirs.cache}`, express.static(`${outdirs.cache}`));
|
|
9
10
|
}
|
|
10
11
|
else {
|
|
11
|
-
app.use(
|
|
12
|
+
app.use(`/${outdirs.client}`, express.static(`${outdirs.client}`, {
|
|
12
13
|
maxAge: "1y",
|
|
13
14
|
immutable: true,
|
|
14
15
|
etag: true,
|
|
15
16
|
}));
|
|
16
|
-
app.use(
|
|
17
|
+
app.use(`/assets`, express.static(outdirs.assets, {
|
|
17
18
|
maxAge: "1y",
|
|
18
19
|
immutable: true,
|
|
19
20
|
etag: true,
|
|
20
21
|
}));
|
|
21
22
|
}
|
|
22
|
-
app.post(
|
|
23
|
+
app.post(`/${outdirs.root}/__data__/:xanixId`, express.json(), async (req, res) => {
|
|
23
24
|
const { xanixId } = req.params;
|
|
24
25
|
const args = req.body;
|
|
25
26
|
const data = await dataLoader.result(xanixId, args);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import fs from "node:fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
|
+
import outdirs from "../../outdirs";
|
|
3
4
|
async function readManifest() {
|
|
4
|
-
const manifestPath = path.resolve(process.cwd(),
|
|
5
|
+
const manifestPath = path.resolve(process.cwd(), outdirs.root, "client-manifest.json");
|
|
5
6
|
const source = await fs.readFile(manifestPath, "utf8");
|
|
6
7
|
return JSON.parse(source);
|
|
7
8
|
}
|
package/dist/types/globals.d.ts
CHANGED