xanix 1.0.19 → 1.0.21
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/cache/buildCache.js +9 -11
- package/dist/bin/bundler/cache/index.js +70 -116
- package/dist/bin/bundler/cache/utils.d.ts +3 -2
- package/dist/bin/bundler/cache/utils.js +27 -24
- package/dist/bin/bundler/client/build.js +1 -1
- package/dist/bin/bundler/client/plugins/Transformer/TransformCacheFunction copy.d.ts +3 -0
- package/dist/bin/bundler/client/plugins/Transformer/TransformCacheFunction copy.js +32 -0
- package/dist/bin/bundler/client/plugins/Transformer/TransformCacheFunction.d.ts +1 -1
- package/dist/bin/bundler/client/plugins/Transformer/TransformCacheFunction.js +1 -1
- package/dist/bin/bundler/client/plugins/Transformer/TransformCreateSession.d.ts +1 -1
- package/dist/bin/bundler/client/plugins/Transformer/TransformCreateSession.js +1 -1
- package/dist/bin/bundler/client/plugins/Transformer/TransformDevModule.d.ts +13 -0
- package/dist/bin/bundler/client/plugins/Transformer/{transformModuleCache.js → TransformDevModule.js} +6 -18
- package/dist/bin/bundler/client/plugins/Transformer/TransformServerFunction.d.ts +1 -1
- package/dist/bin/bundler/client/plugins/Transformer/TransformServerFunction.js +1 -1
- package/dist/bin/bundler/client/plugins/Transformer/cacheFunctionReplacer.d.ts +3 -0
- package/dist/bin/bundler/client/plugins/Transformer/cacheFunctionReplacer.js +32 -0
- package/dist/bin/bundler/client/plugins/Transformer/cacheFunctionTransformer.d.ts +3 -0
- package/dist/bin/bundler/client/plugins/Transformer/cacheFunctionTransformer.js +32 -0
- package/dist/bin/bundler/client/plugins/Transformer/serverFunctionReplacer.d.ts +3 -0
- package/dist/bin/bundler/client/plugins/Transformer/serverFunctionReplacer.js +32 -0
- package/dist/bin/bundler/client/plugins/Transformer/useServerReplacer.d.ts +3 -0
- package/dist/bin/bundler/client/plugins/Transformer/useServerReplacer.js +42 -0
- package/dist/bin/bundler/client/plugins/Transformer.js +4 -2
- package/dist/bin/bundler/client/plugins/XanixAppRoot.d.ts +2 -0
- package/dist/bin/bundler/client/plugins/XanixAppRoot.js +46 -0
- package/dist/bin/bundler/client/plugins/XanixPage.js +30 -0
- package/dist/bin/bundler/client/plugins/XanixPages.js +8 -8
- package/dist/bin/bundler/client/plugins/replacer/cacheFunctionReplacer.d.ts +1 -1
- package/dist/bin/bundler/client/plugins/replacer/cacheFunctionReplacer.js +5 -1
- package/dist/bin/bundler/client/plugins/replacer/serverFunctionReplacer.d.ts +1 -1
- package/dist/bin/bundler/client/plugins/replacer/serverFunctionReplacer.js +5 -1
- package/dist/bin/bundler/client/plugins/replacer/useServerReplacer.d.ts +1 -1
- package/dist/bin/bundler/client/plugins/replacer/useServerReplacer.js +7 -3
- package/dist/bin/bundler/server/build.js +1 -1
- package/dist/bin/bundler/server/plugins/Transformer/TransformCacheFunction copy.d.ts +3 -0
- package/dist/bin/bundler/server/plugins/Transformer/TransformCacheFunction copy.js +32 -0
- package/dist/bin/bundler/server/plugins/Transformer/TransformCacheFunction.d.ts +1 -1
- package/dist/bin/bundler/server/plugins/Transformer/TransformCacheFunction.js +1 -1
- package/dist/bin/bundler/server/plugins/Transformer/TransformCreateSession.d.ts +1 -1
- package/dist/bin/bundler/server/plugins/Transformer/TransformCreateSession.js +1 -1
- package/dist/bin/bundler/server/plugins/Transformer/TransformExpressFunction.d.ts +1 -1
- package/dist/bin/bundler/server/plugins/Transformer/TransformExpressFunction.js +1 -1
- package/dist/bin/bundler/server/plugins/Transformer/TransformPage.js +1 -1
- package/dist/bin/bundler/server/plugins/Transformer/TransformServerFunction.d.ts +1 -1
- package/dist/bin/bundler/server/plugins/Transformer/TransformServerFunction.js +1 -1
- package/dist/bin/bundler/server/plugins/Transformer/cacheFunctionReplacer.d.ts +3 -0
- package/dist/bin/bundler/server/plugins/Transformer/cacheFunctionReplacer.js +32 -0
- package/dist/bin/bundler/server/plugins/Transformer/expressFunctionReplace.d.ts +3 -0
- package/dist/bin/bundler/server/plugins/Transformer/expressFunctionReplace.js +24 -0
- package/dist/bin/bundler/server/plugins/Transformer/pageReplacer.d.ts +4 -0
- package/dist/bin/bundler/server/plugins/Transformer/pageReplacer.js +31 -0
- package/dist/bin/bundler/server/plugins/Transformer/serverFunctionReplacer.d.ts +3 -0
- package/dist/bin/bundler/server/plugins/Transformer/serverFunctionReplacer.js +32 -0
- package/dist/bin/bundler/server/plugins/Transformer/useServerReplacer.d.ts +3 -0
- package/dist/bin/bundler/server/plugins/Transformer/useServerReplacer.js +42 -0
- package/dist/bin/bundler/server/plugins/Transformer copy.js +3 -3
- package/dist/bin/bundler/server/plugins/Transformer.js +2 -2
- package/dist/bin/bundler/server/plugins/replacer/cacheFunctionReplacer.d.ts +1 -1
- package/dist/bin/bundler/server/plugins/replacer/cacheFunctionReplacer.js +5 -1
- package/dist/bin/bundler/server/plugins/replacer/serverFunctionReplacer copy.d.ts +3 -0
- package/dist/bin/bundler/server/plugins/replacer/serverFunctionReplacer copy.js +26 -0
- package/dist/bin/bundler/server/plugins/replacer/serverFunctionReplacer.d.ts +1 -1
- package/dist/bin/bundler/server/plugins/replacer/serverFunctionReplacer.js +5 -1
- package/dist/bin/bundler/server/plugins/replacer/serverReplacer.d.ts +3 -0
- package/dist/bin/bundler/server/plugins/replacer/serverReplacer.js +26 -0
- package/dist/bin/bundler/server/plugins/replacer/useServerReplacer.d.ts +2 -2
- package/dist/bin/bundler/server/plugins/replacer/useServerReplacer.js +9 -5
- package/dist/bin/cli/dev.js +85 -71
- package/dist/bin/cli/start/index.d.ts +4 -1
- package/dist/bin/cli/start/index.js +60 -9
- package/dist/bin/finder/callbackReplacer.d.ts +2 -0
- package/dist/bin/finder/callbackReplacer.js +52 -0
- package/dist/bin/finder/findImport.d.ts +9 -0
- package/dist/bin/finder/findImport.js +50 -0
- package/dist/bin/finder/findImports.d.ts +16 -0
- package/dist/bin/finder/findImports.js +45 -0
- package/dist/bin/finder/findPage.d.ts +9 -0
- package/dist/bin/finder/findPage.js +30 -0
- package/dist/bin/finder/importFinder.d.ts +9 -0
- package/dist/bin/finder/importFinder.js +50 -0
- package/dist/bin/finder/pageFinder.d.ts +9 -0
- package/dist/bin/finder/pageFinder.js +30 -0
- package/dist/bin/finder/stripComments.d.ts +3 -0
- package/dist/bin/finder/stripComments.js +15 -0
- package/dist/bin/include/path.d.ts +5 -1
- package/dist/bin/include/path.js +15 -1
- package/dist/bin/include/sendFinder.d.ts +4 -1
- package/dist/bin/include/sendFinder.js +88 -53
- package/dist/bin/index.js +0 -0
- package/dist/bin/modifier/callbackReplacer.js +35 -80
- package/dist/bin/modifier/findImports.d.ts +16 -0
- package/dist/bin/modifier/findImports.js +45 -0
- package/dist/bin/modifier/importFinder.js +44 -63
- package/dist/bin/modifier/pageFinder.d.ts +1 -1
- package/dist/bin/modifier/pageFinder.js +19 -124
- package/dist/bin/modifier/sendFinder.d.ts +9 -0
- package/dist/bin/modifier/sendFinder.js +135 -0
- package/dist/bin/modifier/sriptCommnet.d.ts +1 -0
- package/dist/bin/modifier/sriptCommnet.js +12 -5
- package/dist/bin/modifier/stripComments.d.ts +3 -0
- package/dist/bin/modifier/stripComments.js +15 -0
- package/dist/bin/plugins/XanixAssets.js +2 -2
- package/dist/bin/plugins/XanixCss.js +13 -13
- package/dist/bin/plugins/XanixDocument.js +4 -4
- package/dist/components/Head.js +1 -1
- package/dist/hooks/encript.d.ts +2 -0
- package/dist/hooks/encript.js +13 -0
- package/dist/hooks/server.js +2 -2
- package/dist/hooks/session.js +2 -2
- package/dist/index.js +0 -0
- package/dist/libs/encoder.d.ts +2 -0
- package/dist/libs/encoder.js +13 -0
- package/dist/libs/encript.d.ts +2 -0
- package/dist/libs/encript.js +30 -0
- package/dist/navigate.js +1 -1
- package/dist/server/express/Router.js +4 -4
- package/dist/server/express/page.d.ts +1 -1
- package/dist/server/express/page.js +1 -1
- package/dist/types/assets.d.ts +72 -72
- package/dist/types/express.d.ts +11 -11
- package/dist/types/globals.d.ts +18 -18
- package/dist/types/xanix-virtual.d.ts +35 -35
- package/package.json +57 -60
- package/dist/bin/bundler/Cache.d.ts +0 -1
- package/dist/bin/bundler/Cache.js +0 -210
- package/dist/bin/bundler/External.d.ts +0 -3
- package/dist/bin/bundler/External.js +0 -6
- package/dist/bin/bundler/buildClient.d.ts +0 -3
- package/dist/bin/bundler/buildClient.js +0 -42
- package/dist/bin/bundler/buildServer.d.ts +0 -7
- package/dist/bin/bundler/buildServer.js +0 -50
- package/dist/bin/bundler/cache/plugin/Transformer.d.ts +0 -3
- package/dist/bin/bundler/cache/plugin/Transformer.js +0 -42
- package/dist/bin/bundler/client/plugins/Transformer/TransformExpress.d.ts +0 -9
- package/dist/bin/bundler/client/plugins/Transformer/TransformExpress.js +0 -26
- package/dist/bin/bundler/client/plugins/Transformer/TransformPage.d.ts +0 -29
- package/dist/bin/bundler/client/plugins/Transformer/TransformPage.js +0 -77
- package/dist/bin/bundler/client/plugins/Transformer/TransformReactContext.d.ts +0 -17
- package/dist/bin/bundler/client/plugins/Transformer/TransformReactContext.js +0 -101
- package/dist/bin/bundler/client/plugins/Transformer/transformModuleCache.d.ts +0 -15
- package/dist/bin/bundler/client/plugins/Transformer copy.d.ts +0 -3
- package/dist/bin/bundler/client/plugins/Transformer copy.js +0 -70
- package/dist/bin/bundler/client/plugins/VirtualDev.d.ts +0 -2
- package/dist/bin/bundler/client/plugins/VirtualDev.js +0 -34
- package/dist/bin/bundler/client/plugins/XanixReactRefresh.d.ts +0 -2
- package/dist/bin/bundler/client/plugins/XanixReactRefresh.js +0 -22
- package/dist/bin/bundler/config/defines.d.ts +0 -20
- package/dist/bin/bundler/config/defines.js +0 -21
- package/dist/bin/bundler/config/external.d.ts +0 -1
- package/dist/bin/bundler/config/external.js +0 -12
- package/dist/bin/bundler/config/loadEnv.d.ts +0 -20
- package/dist/bin/bundler/config/loadEnv.js +0 -48
- package/dist/bin/bundler/config/output.d.ts +0 -10
- package/dist/bin/bundler/config/output.js +0 -52
- package/dist/bin/bundler/externalResolver-dep.d.ts +0 -3
- package/dist/bin/bundler/externalResolver-dep.js +0 -203
- package/dist/bin/bundler/externalResolver.d.ts +0 -3
- package/dist/bin/bundler/externalResolver.js +0 -203
- package/dist/bin/bundler/plugins/TransformServer/TransformExpress.d.ts +0 -9
- package/dist/bin/bundler/plugins/TransformServer/TransformExpress.js +0 -26
- package/dist/bin/bundler/plugins/TransformServer/TransformPage.d.ts +0 -25
- package/dist/bin/bundler/plugins/TransformServer/TransformPage.js +0 -79
- package/dist/bin/bundler/plugins/TransformServer/index.d.ts +0 -3
- package/dist/bin/bundler/plugins/TransformServer/index.js +0 -103
- package/dist/bin/bundler/plugins/XanixAssets.d.ts +0 -5
- package/dist/bin/bundler/plugins/XanixAssets.js +0 -51
- package/dist/bin/bundler/plugins/XanixCacheDeps-dep.d.ts +0 -2
- package/dist/bin/bundler/plugins/XanixCacheDeps-dep.js +0 -150
- package/dist/bin/bundler/plugins/XanixCacheDeps.d.ts +0 -2
- package/dist/bin/bundler/plugins/XanixCacheDeps.js +0 -150
- package/dist/bin/bundler/plugins/XanixDocument/index.js +0 -53
- package/dist/bin/bundler/plugins/XanixEntryFinder/finder.d.ts +0 -11
- package/dist/bin/bundler/plugins/XanixEntryFinder/finder.js +0 -149
- package/dist/bin/bundler/plugins/XanixEntryFinder/index.d.ts +0 -6
- package/dist/bin/bundler/plugins/XanixEntryFinder/index.js +0 -37
- package/dist/bin/bundler/plugins/XanixEntryFinder-dep/finder.d.ts +0 -11
- package/dist/bin/bundler/plugins/XanixEntryFinder-dep/finder.js +0 -149
- package/dist/bin/bundler/plugins/XanixEntryFinder-dep/index.d.ts +0 -6
- package/dist/bin/bundler/plugins/XanixEntryFinder-dep/index.js +0 -37
- package/dist/bin/bundler/plugins/XanixEnv.d.ts +0 -15
- package/dist/bin/bundler/plugins/XanixEnv.js +0 -44
- package/dist/bin/bundler/plugins/XanixPageTransform/index.d.ts +0 -2
- package/dist/bin/bundler/plugins/XanixPageTransform/index.js +0 -62
- package/dist/bin/bundler/plugins/XanixPageTransform/transformer copy.d.ts +0 -18
- package/dist/bin/bundler/plugins/XanixPageTransform/transformer copy.js +0 -414
- package/dist/bin/bundler/plugins/XanixPageTransform/transformer.d.ts +0 -23
- package/dist/bin/bundler/plugins/XanixPageTransform/transformer.js +0 -589
- package/dist/bin/bundler/plugins/XanixReactRefresh copy.d.ts +0 -2
- package/dist/bin/bundler/plugins/XanixReactRefresh copy.js +0 -121
- package/dist/bin/bundler/plugins/XanixReactRefresh.d.ts +0 -2
- package/dist/bin/bundler/plugins/XanixReactRefresh.js +0 -170
- package/dist/bin/bundler/plugins/XanixResolveCacheDeps/BuildClientCache.d.ts +0 -11
- package/dist/bin/bundler/plugins/XanixResolveCacheDeps/BuildClientCache.js +0 -129
- package/dist/bin/bundler/plugins/XanixResolveCacheDeps/index copy.d.ts +0 -15
- package/dist/bin/bundler/plugins/XanixResolveCacheDeps/index copy.js +0 -228
- package/dist/bin/bundler/plugins/XanixResolveCacheDeps/index.d.ts +0 -7
- package/dist/bin/bundler/plugins/XanixResolveCacheDeps/index.js +0 -166
- package/dist/bin/bundler/plugins/XanixResolveCacheDeps-dep/BuildClientCache.d.ts +0 -11
- package/dist/bin/bundler/plugins/XanixResolveCacheDeps-dep/BuildClientCache.js +0 -129
- package/dist/bin/bundler/plugins/XanixResolveCacheDeps-dep/index.d.ts +0 -5
- package/dist/bin/bundler/plugins/XanixResolveCacheDeps-dep/index.js +0 -26
- package/dist/bin/bundler/plugins/XanixResolver.d.ts +0 -11
- package/dist/bin/bundler/plugins/XanixResolver.js +0 -55
- package/dist/bin/bundler/plugins/XanixServerTransform.d.ts +0 -5
- package/dist/bin/bundler/plugins/XanixServerTransform.js +0 -207
- package/dist/bin/bundler/plugins/XanixTransform.d.ts +0 -3
- package/dist/bin/bundler/plugins/XanixTransform.js +0 -23
- package/dist/bin/bundler/plugins/XanixTsconfigAlias.d.ts +0 -19
- package/dist/bin/bundler/plugins/XanixTsconfigAlias.js +0 -197
- package/dist/bin/bundler/plugins/XanixUseServer.d.ts +0 -7
- package/dist/bin/bundler/plugins/XanixUseServer.js +0 -445
- package/dist/bin/bundler/plugins/plugins.d.ts +0 -9
- package/dist/bin/bundler/plugins/plugins.js +0 -37
- package/dist/bin/bundler/requireCache.d.ts +0 -3
- package/dist/bin/bundler/requireCache.js +0 -85
- package/dist/bin/bundler/server/plugins/ServerAction.d.ts +0 -3
- package/dist/bin/bundler/server/plugins/ServerAction.js +0 -9
- package/dist/bin/bundler/server/plugins/Transformer/ServerAction.d.ts +0 -11
- package/dist/bin/bundler/server/plugins/Transformer/ServerAction.js +0 -28
- package/dist/bin/bundler/server/plugins/Transformer/TransformExpress copy.d.ts +0 -11
- package/dist/bin/bundler/server/plugins/Transformer/TransformExpress copy.js +0 -22
- package/dist/bin/bundler/server/plugins/Transformer/TransformExpress.d.ts +0 -10
- package/dist/bin/bundler/server/plugins/Transformer/TransformExpress.js +0 -19
- package/dist/bin/bundler/server/plugins/Transformer/TransformReactContext.d.ts +0 -17
- package/dist/bin/bundler/server/plugins/Transformer/TransformReactContext.js +0 -101
- package/dist/bin/bundler/server/plugins/Transformer/TransformServerAction copy.d.ts +0 -14
- package/dist/bin/bundler/server/plugins/Transformer/TransformServerAction copy.js +0 -38
- package/dist/bin/bundler/server/types.d.ts +0 -5
- package/dist/bin/bundler/server/types.js +0 -1
- package/dist/bin/bundler/watchClient.d.ts +0 -12
- package/dist/bin/bundler/watchClient.js +0 -104
- package/dist/bin/bundler/watchServer.d.ts +0 -10
- package/dist/bin/bundler/watchServer.js +0 -139
- package/dist/bin/cli/dev/dev.d.ts +0 -2
- package/dist/bin/cli/dev/dev.js +0 -178
- package/dist/bin/cli/start/start.d.ts +0 -2
- package/dist/bin/cli/start/start.js +0 -27
- package/dist/bin/include/entry.d.ts +0 -2
- package/dist/bin/include/entry.js +0 -21
- package/dist/bin/plugins/XanixDocument/XanixDocument.d.ts +0 -2
- package/dist/bin/plugins/XanixDocument/XanixDocument.js +0 -50
- package/dist/bin/plugins/XanixDocument/index.d.ts +0 -2
- package/dist/bin/plugins/XanixDocument/index.js +0 -50
- package/dist/bin/plugins/XanixPageTransform-dep/index.d.ts +0 -2
- package/dist/bin/plugins/XanixPageTransform-dep/index.js +0 -62
- package/dist/bin/plugins/XanixPageTransform-dep/transformer.d.ts +0 -23
- package/dist/bin/plugins/XanixPageTransform-dep/transformer.js +0 -589
- package/dist/bin/plugins/XanixServerTransform.d.ts +0 -5
- package/dist/bin/plugins/XanixServerTransform.js +0 -207
- package/dist/bin/plugins/XanixUseServer.d.ts +0 -7
- package/dist/bin/plugins/XanixUseServer.js +0 -445
- package/dist/bin/plugins/plugins.d.ts +0 -8
- package/dist/bin/plugins/plugins.js +0 -31
- package/dist/components/Script.d.ts +0 -3
- package/dist/components/Script.js +0 -5
- package/dist/dev.d.ts +0 -1
- package/dist/dev.js +0 -25
- package/dist/react/createContext.d.ts +0 -3
- package/dist/react/createContext.js +0 -11
- package/dist/react/index.d.ts +0 -12
- package/dist/react/index.js +0 -3
- package/dist/server/express/Ruter.d.ts +0 -2
- package/dist/server/express/Ruter.js +0 -15
- package/dist/server/runtime/createServer.d.ts +0 -12
- package/dist/server/runtime/createServer.js +0 -62
- package/dist/server/runtime/index.d.ts +0 -3
- package/dist/server/runtime/index.js +0 -3
- package/dist/server/runtime/readManifest.d.ts +0 -14
- package/dist/server/runtime/readManifest.js +0 -9
- package/dist/server/runtime/xanixPage.d.ts +0 -11
- package/dist/server/runtime/xanixPage.js +0 -92
- /package/dist/bin/bundler/{plugins/XanixDocument/index.d.ts → client/plugins/XanixPage.d.ts} +0 -0
- /package/dist/bin/{cli/start/utils.d.ts → bundler/server/plugins/replacer/useServer.d.ts} +0 -0
- /package/dist/bin/{cli/start/utils.js → bundler/server/plugins/replacer/useServer.js} +0 -0
package/dist/bin/cli/dev/dev.js
DELETED
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import fs from "node:fs";
|
|
3
|
-
import { spawn } from "node:child_process";
|
|
4
|
-
import watchServer from "../../bundler/server/watch.js";
|
|
5
|
-
import watchClient from "../../bundler/client/watch.js";
|
|
6
|
-
import pc from "picocolors";
|
|
7
|
-
import logger from "../../include/logger.js";
|
|
8
|
-
import { WebSocketServer } from "ws";
|
|
9
|
-
import outdirs from "../../../outdirs.js";
|
|
10
|
-
import { readFile } from "node:fs/promises";
|
|
11
|
-
import { fileURLToPath } from "node:url";
|
|
12
|
-
import { normalizePath } from "../../include/utils.js";
|
|
13
|
-
const root = normalizePath(process.cwd());
|
|
14
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
15
|
-
const packageJson = JSON.parse(await readFile(path.join(__dirname, "../../../package.json"), "utf8"));
|
|
16
|
-
const serverInfo = {};
|
|
17
|
-
let child;
|
|
18
|
-
let firstStart = false;
|
|
19
|
-
async function stopCurrentServer() {
|
|
20
|
-
if (!child || child.exitCode !== null || child.signalCode !== null) {
|
|
21
|
-
child = undefined;
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
const previous = child;
|
|
25
|
-
await new Promise((resolve) => {
|
|
26
|
-
previous.once("exit", () => resolve());
|
|
27
|
-
previous.kill();
|
|
28
|
-
});
|
|
29
|
-
if (child === previous) {
|
|
30
|
-
child = undefined;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
async function startServer() {
|
|
34
|
-
await stopCurrentServer();
|
|
35
|
-
const filePath = path.join(outdirs.server, "index.js");
|
|
36
|
-
await new Promise((resolve, reject) => {
|
|
37
|
-
const current = spawn(process.execPath, [filePath], {
|
|
38
|
-
stdio: ["inherit", "inherit", "inherit", "ipc"],
|
|
39
|
-
});
|
|
40
|
-
child = current;
|
|
41
|
-
const cleanup = () => {
|
|
42
|
-
current.off("message", onMessage);
|
|
43
|
-
current.off("error", onError);
|
|
44
|
-
current.off("exit", onExit);
|
|
45
|
-
};
|
|
46
|
-
const onMessage = (message) => {
|
|
47
|
-
if (message?.type !== "xanix:ready")
|
|
48
|
-
return;
|
|
49
|
-
serverInfo.port = message.port;
|
|
50
|
-
serverInfo.url = message.url;
|
|
51
|
-
if (!firstStart) {
|
|
52
|
-
firstStart = true;
|
|
53
|
-
console.log("");
|
|
54
|
-
console.log(` ${pc.blue("➜ Listening on:")} ${pc.yellow(serverInfo.url)}`);
|
|
55
|
-
console.log("");
|
|
56
|
-
}
|
|
57
|
-
cleanup();
|
|
58
|
-
resolve();
|
|
59
|
-
};
|
|
60
|
-
const onError = (error) => {
|
|
61
|
-
cleanup();
|
|
62
|
-
reject(error);
|
|
63
|
-
};
|
|
64
|
-
const onExit = (code, signal) => {
|
|
65
|
-
cleanup();
|
|
66
|
-
if (child === current) {
|
|
67
|
-
child = undefined;
|
|
68
|
-
}
|
|
69
|
-
reject(new Error(`Xanix server exited before ready (code: ${code}, signal: ${signal})`));
|
|
70
|
-
};
|
|
71
|
-
current.on("message", onMessage);
|
|
72
|
-
current.once("error", onError);
|
|
73
|
-
current.once("exit", onExit);
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
const dev = async (rootEntry) => {
|
|
77
|
-
// await stop();
|
|
78
|
-
fs.rmSync(outdirs.root, {
|
|
79
|
-
recursive: true,
|
|
80
|
-
force: true,
|
|
81
|
-
});
|
|
82
|
-
fs.mkdirSync(outdirs.root, {
|
|
83
|
-
recursive: true,
|
|
84
|
-
});
|
|
85
|
-
const WebSocketPort = 49152;
|
|
86
|
-
const wss = new WebSocketServer({
|
|
87
|
-
port: WebSocketPort,
|
|
88
|
-
});
|
|
89
|
-
let sockets = new Set();
|
|
90
|
-
const broadcast = (message) => {
|
|
91
|
-
sockets.forEach((socket) => {
|
|
92
|
-
if (socket.readyState === 1) {
|
|
93
|
-
socket.send(message);
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
};
|
|
97
|
-
wss.on("connection", (ws) => {
|
|
98
|
-
sockets.add(ws);
|
|
99
|
-
ws.on("close", () => {
|
|
100
|
-
sockets.delete(ws);
|
|
101
|
-
});
|
|
102
|
-
ws.on("message", (message) => {
|
|
103
|
-
if (message.toString() === "reload") {
|
|
104
|
-
startServer();
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
console.log("");
|
|
109
|
-
console.log(pc.green(pc.bold(`Xanix`) + ` v${packageJson.version}`));
|
|
110
|
-
let clientWatcher = null;
|
|
111
|
-
let clientStarted = false;
|
|
112
|
-
let buildDuration = 0;
|
|
113
|
-
const startClientWatcher = async () => {
|
|
114
|
-
clientWatcher?.close();
|
|
115
|
-
clientWatcher = await watchClient({
|
|
116
|
-
onStart: async () => {
|
|
117
|
-
clientStarted = true;
|
|
118
|
-
},
|
|
119
|
-
onReady: async (duration) => {
|
|
120
|
-
await startServer();
|
|
121
|
-
buildDuration = 0;
|
|
122
|
-
clientStarted = false;
|
|
123
|
-
},
|
|
124
|
-
onChange: async (files, duration, entries) => {
|
|
125
|
-
buildDuration += duration;
|
|
126
|
-
clientStarted = false;
|
|
127
|
-
const _files = [];
|
|
128
|
-
for (let file of files) {
|
|
129
|
-
const entry = entries.find((entry) => entry.resolved === file);
|
|
130
|
-
if (entry) {
|
|
131
|
-
_files.push(`${entry.id}.js`);
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
file = file.replace(root + "/", "");
|
|
135
|
-
file = file.replace(path.extname(file), ".js");
|
|
136
|
-
_files.push(file);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
files = files.map((file) => file.replace(root + "/", ""));
|
|
140
|
-
logger.info(`${pc.yellow(files.join(", "))} ${pc.green(buildDuration + "ms")}`, "[update]");
|
|
141
|
-
broadcast(JSON.stringify(_files));
|
|
142
|
-
buildDuration = 0;
|
|
143
|
-
},
|
|
144
|
-
});
|
|
145
|
-
};
|
|
146
|
-
const watch = await watchServer({
|
|
147
|
-
rootEntry,
|
|
148
|
-
onChangeManifest: async () => {
|
|
149
|
-
await startClientWatcher();
|
|
150
|
-
},
|
|
151
|
-
onReady: async (duration) => {
|
|
152
|
-
buildDuration += duration;
|
|
153
|
-
await startClientWatcher();
|
|
154
|
-
},
|
|
155
|
-
onChange: async (files, duration) => {
|
|
156
|
-
buildDuration += duration;
|
|
157
|
-
if (!clientStarted) {
|
|
158
|
-
files = files.map((file) => file.replace(root + "/", ""));
|
|
159
|
-
logger.info(`${pc.yellow(files.join(", "))} ${pc.green(buildDuration + "ms")}`, "[update-server]");
|
|
160
|
-
buildDuration = 0;
|
|
161
|
-
await startServer();
|
|
162
|
-
}
|
|
163
|
-
},
|
|
164
|
-
});
|
|
165
|
-
process.on("SIGINT", () => {
|
|
166
|
-
clientWatcher?.close();
|
|
167
|
-
watch?.close();
|
|
168
|
-
child?.kill();
|
|
169
|
-
process.exit(0);
|
|
170
|
-
});
|
|
171
|
-
process.on("SIGTERM", () => {
|
|
172
|
-
clientWatcher?.close();
|
|
173
|
-
watch?.close();
|
|
174
|
-
child?.kill();
|
|
175
|
-
process.exit(0);
|
|
176
|
-
});
|
|
177
|
-
};
|
|
178
|
-
export default dev;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { spawn } from "child_process";
|
|
2
|
-
import pc from "picocolors";
|
|
3
|
-
import path from "path";
|
|
4
|
-
import outdirs from "../../../outdirs.js";
|
|
5
|
-
import { getFrameworkPackageJson } from "../../include/utils.js";
|
|
6
|
-
const start = async () => {
|
|
7
|
-
const packageJson = await getFrameworkPackageJson();
|
|
8
|
-
console.log("");
|
|
9
|
-
console.log(pc.cyan(pc.bold(`Xanix ${packageJson.version}`)));
|
|
10
|
-
console.log("");
|
|
11
|
-
const filePath = path.join(outdirs.server, "index.js");
|
|
12
|
-
const child = spawn(process.execPath, [filePath], {
|
|
13
|
-
stdio: ["inherit", "inherit", "inherit", "ipc"],
|
|
14
|
-
});
|
|
15
|
-
child.on("message", (message) => {
|
|
16
|
-
if (message.type === "xanix:ready") {
|
|
17
|
-
console.log(` ${pc.blue("➜ Local:")} ${pc.yellow(message.url ?? "")}`);
|
|
18
|
-
console.log("");
|
|
19
|
-
console.log(pc.gray("Press Ctrl+C to stop"));
|
|
20
|
-
console.log("");
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
child.on("error", (error) => {
|
|
24
|
-
console.error(pc.red("Failed to start Xanix server"), error);
|
|
25
|
-
});
|
|
26
|
-
};
|
|
27
|
-
export default start;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { readManifest } from "./manifest.js";
|
|
2
|
-
export const entriesEqual = async (entries) => {
|
|
3
|
-
const manifest = await readManifest();
|
|
4
|
-
if (!manifest) {
|
|
5
|
-
return false;
|
|
6
|
-
}
|
|
7
|
-
if (manifest.entries.length !== entries.length) {
|
|
8
|
-
return false;
|
|
9
|
-
}
|
|
10
|
-
for (const entry of manifest.entries) {
|
|
11
|
-
const existingEntry = entries.find((e) => e.id === entry.id);
|
|
12
|
-
if (!existingEntry) {
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
if (existingEntry.name !== entry.name ||
|
|
16
|
-
existingEntry.file !== entry.file) {
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return true;
|
|
21
|
-
};
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { createRequire } from "node:module";
|
|
4
|
-
const require = createRequire(import.meta.url);
|
|
5
|
-
const VIRTUAL_ID = "virtual:xanix-document";
|
|
6
|
-
const RESOLVED_ID = "\0virtual:xanix-document";
|
|
7
|
-
export default function xanixDocument() {
|
|
8
|
-
const root = process.cwd();
|
|
9
|
-
const userDocument = path.resolve(root, "document.tsx");
|
|
10
|
-
const baseDocument = require.resolve("../../../../dist/components/BaseDocument.js");
|
|
11
|
-
return {
|
|
12
|
-
name: "xanix-document",
|
|
13
|
-
resolveId(id) {
|
|
14
|
-
if (id === VIRTUAL_ID) {
|
|
15
|
-
return RESOLVED_ID;
|
|
16
|
-
}
|
|
17
|
-
return null;
|
|
18
|
-
},
|
|
19
|
-
load(id) {
|
|
20
|
-
if (id !== RESOLVED_ID) {
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
const documentFile = fs.existsSync(userDocument)
|
|
24
|
-
? userDocument
|
|
25
|
-
: baseDocument;
|
|
26
|
-
const source = fs.readFileSync(documentFile, "utf8");
|
|
27
|
-
const hasMetadata = /\bexport\s+(?:const|let|var|function)\s+metadata\b/.test(source) ||
|
|
28
|
-
/\bexport\s*\{[^}]*\bmetadata\b[^}]*\}/.test(source);
|
|
29
|
-
const importPath = path.resolve(documentFile).replaceAll("\\", "/");
|
|
30
|
-
if (hasMetadata) {
|
|
31
|
-
return {
|
|
32
|
-
code: `
|
|
33
|
-
import Document, * as DocumentModule from ${JSON.stringify(importPath)};
|
|
34
|
-
export const metadata = DocumentModule.metadata;
|
|
35
|
-
export default Document;
|
|
36
|
-
`,
|
|
37
|
-
map: null,
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
return {
|
|
41
|
-
code: `
|
|
42
|
-
import Document from ${JSON.stringify(importPath)};
|
|
43
|
-
export const metadata = async () => ({});
|
|
44
|
-
export default Document;
|
|
45
|
-
`,
|
|
46
|
-
map: null,
|
|
47
|
-
};
|
|
48
|
-
},
|
|
49
|
-
};
|
|
50
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { createRequire } from "node:module";
|
|
4
|
-
const require = createRequire(import.meta.url);
|
|
5
|
-
const VIRTUAL_ID = "virtual:xanix-document";
|
|
6
|
-
const RESOLVED_ID = "\0virtual:xanix-document";
|
|
7
|
-
export default function xanixDocument() {
|
|
8
|
-
const root = process.cwd();
|
|
9
|
-
const userDocument = path.resolve(root, "document.tsx");
|
|
10
|
-
const baseDocument = require.resolve("../../../../dist/components/BaseDocument.js");
|
|
11
|
-
return {
|
|
12
|
-
name: "xanix-document",
|
|
13
|
-
resolveId(id) {
|
|
14
|
-
if (id === VIRTUAL_ID) {
|
|
15
|
-
return RESOLVED_ID;
|
|
16
|
-
}
|
|
17
|
-
return null;
|
|
18
|
-
},
|
|
19
|
-
load(id) {
|
|
20
|
-
if (id !== RESOLVED_ID) {
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
const documentFile = fs.existsSync(userDocument)
|
|
24
|
-
? userDocument
|
|
25
|
-
: baseDocument;
|
|
26
|
-
const source = fs.readFileSync(documentFile, "utf8");
|
|
27
|
-
const hasMetadata = /\bexport\s+(?:const|let|var|function)\s+metadata\b/.test(source) ||
|
|
28
|
-
/\bexport\s*\{[^}]*\bmetadata\b[^}]*\}/.test(source);
|
|
29
|
-
const importPath = path.resolve(documentFile).replaceAll("\\", "/");
|
|
30
|
-
if (hasMetadata) {
|
|
31
|
-
return {
|
|
32
|
-
code: `
|
|
33
|
-
import Document, * as DocumentModule from ${JSON.stringify(importPath)};
|
|
34
|
-
export const metadata = DocumentModule.metadata;
|
|
35
|
-
export default Document;
|
|
36
|
-
`,
|
|
37
|
-
map: null,
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
return {
|
|
41
|
-
code: `
|
|
42
|
-
import Document from ${JSON.stringify(importPath)};
|
|
43
|
-
export const metadata = async () => ({});
|
|
44
|
-
export default Document;
|
|
45
|
-
`,
|
|
46
|
-
map: null,
|
|
47
|
-
};
|
|
48
|
-
},
|
|
49
|
-
};
|
|
50
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { transformer } from "./transformer.js";
|
|
2
|
-
export default function XanixPageTransform() {
|
|
3
|
-
const entries = new Map();
|
|
4
|
-
return {
|
|
5
|
-
name: "xanix-page-transform",
|
|
6
|
-
transform: {
|
|
7
|
-
filter: {
|
|
8
|
-
id: /^(?!.*(?:node_modules[\\/])).*\.[cm]?[jt]sx?$/,
|
|
9
|
-
},
|
|
10
|
-
handler(code, id) {
|
|
11
|
-
const lang = getParserLanguage(id);
|
|
12
|
-
const ast = this.parse(code, {
|
|
13
|
-
lang,
|
|
14
|
-
});
|
|
15
|
-
const result = transformer(code, id, ast);
|
|
16
|
-
if (!result) {
|
|
17
|
-
return null;
|
|
18
|
-
}
|
|
19
|
-
for (const entry of result.entries) {
|
|
20
|
-
entries.set(entry.id, entry);
|
|
21
|
-
}
|
|
22
|
-
return {
|
|
23
|
-
code: result.code,
|
|
24
|
-
map: null,
|
|
25
|
-
};
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
buildStart() {
|
|
29
|
-
entries.clear();
|
|
30
|
-
},
|
|
31
|
-
watchChange() {
|
|
32
|
-
entries.clear();
|
|
33
|
-
},
|
|
34
|
-
generateBundle() {
|
|
35
|
-
if (!entries.size) {
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
const manifest = {
|
|
39
|
-
id: "id_",
|
|
40
|
-
entries: [...entries.values()],
|
|
41
|
-
};
|
|
42
|
-
this.emitFile({
|
|
43
|
-
type: "asset",
|
|
44
|
-
fileName: "client-manifest.json",
|
|
45
|
-
source: JSON.stringify(manifest, null, 2),
|
|
46
|
-
});
|
|
47
|
-
},
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
function getParserLanguage(id) {
|
|
51
|
-
const cleanId = id.split("?")[0];
|
|
52
|
-
if (cleanId.endsWith(".tsx")) {
|
|
53
|
-
return "tsx";
|
|
54
|
-
}
|
|
55
|
-
if (cleanId.endsWith(".ts")) {
|
|
56
|
-
return "ts";
|
|
57
|
-
}
|
|
58
|
-
if (cleanId.endsWith(".jsx")) {
|
|
59
|
-
return "jsx";
|
|
60
|
-
}
|
|
61
|
-
return "js";
|
|
62
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
export interface XanixPageEntry {
|
|
2
|
-
id: string;
|
|
3
|
-
name: string;
|
|
4
|
-
file: string;
|
|
5
|
-
path: string;
|
|
6
|
-
export: string;
|
|
7
|
-
}
|
|
8
|
-
export interface XanixTransformResult {
|
|
9
|
-
code: string;
|
|
10
|
-
entries: XanixPageEntry[];
|
|
11
|
-
}
|
|
12
|
-
type AstNode = {
|
|
13
|
-
type: string;
|
|
14
|
-
start?: number;
|
|
15
|
-
end?: number;
|
|
16
|
-
[key: string]: any;
|
|
17
|
-
};
|
|
18
|
-
export declare function normalizeFilePath(file: string): string;
|
|
19
|
-
export declare function resolveFile(file: string): string;
|
|
20
|
-
export declare function resolveComponentFile(importer: string, importPath: string): string;
|
|
21
|
-
export declare function createPageId(file: string): string;
|
|
22
|
-
export declare function transformer(code: string, id: string, ast: AstNode): XanixTransformResult | null;
|
|
23
|
-
export {};
|