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
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { entryFinder } from "./finder.js";
|
|
2
|
-
export function XanixEntryFinder({ entries }) {
|
|
3
|
-
return {
|
|
4
|
-
name: "xanix-entry-finder",
|
|
5
|
-
async transform(code, id) {
|
|
6
|
-
if (id.includes("node_modules") || !/\.(tsx?|jsx?)$/.test(id)) {
|
|
7
|
-
return null;
|
|
8
|
-
}
|
|
9
|
-
const clientEntries = entryFinder(code, id);
|
|
10
|
-
if (!clientEntries) {
|
|
11
|
-
return null;
|
|
12
|
-
}
|
|
13
|
-
for (const entry of clientEntries) {
|
|
14
|
-
const resolved = await this.resolve(entry.file, id, {
|
|
15
|
-
skipSelf: true,
|
|
16
|
-
});
|
|
17
|
-
if (!resolved) {
|
|
18
|
-
this.error(`Could not resolve client component "${entry.file}" imported by "${id}"`);
|
|
19
|
-
}
|
|
20
|
-
entries.set(entry.id, entry);
|
|
21
|
-
}
|
|
22
|
-
return null;
|
|
23
|
-
},
|
|
24
|
-
// generateBundle() {
|
|
25
|
-
// const manifest = {
|
|
26
|
-
// version: 1,
|
|
27
|
-
// entries: [...entries.values()],
|
|
28
|
-
// };
|
|
29
|
-
// console.log(manifest);
|
|
30
|
-
// this.emitFile({
|
|
31
|
-
// type: "asset",
|
|
32
|
-
// fileName: "client-manifest.json",
|
|
33
|
-
// source: JSON.stringify(manifest, null, 2),
|
|
34
|
-
// });
|
|
35
|
-
// },
|
|
36
|
-
};
|
|
37
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import * as t from "@babel/types";
|
|
2
|
-
import { XanixClientEntry } from "../../../types";
|
|
3
|
-
export declare function resolveFile(file: string): string;
|
|
4
|
-
export declare function resolveComponentFile(importer: string, importPath: string): string;
|
|
5
|
-
export declare function createClientId(file: string): string;
|
|
6
|
-
export declare function getJSXComponentName(node: t.JSXElement): string | null;
|
|
7
|
-
export declare function findComponentImport(ast: t.File, componentName: string): {
|
|
8
|
-
file: string;
|
|
9
|
-
export: string;
|
|
10
|
-
} | null;
|
|
11
|
-
export declare function entryFinder(code: string, id: string): XanixClientEntry[];
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import fs from "node:fs";
|
|
3
|
-
import crypto from "node:crypto";
|
|
4
|
-
import { parse } from "@babel/parser";
|
|
5
|
-
import traverse from "@babel/traverse";
|
|
6
|
-
import * as t from "@babel/types";
|
|
7
|
-
import { normalizePath } from "../../../include/utils.js";
|
|
8
|
-
const SOURCE_EXTENSIONS = [".tsx", ".ts", ".jsx", ".js", ".mjs", ".cjs"];
|
|
9
|
-
export function resolveFile(file) {
|
|
10
|
-
const absolute = path.resolve(file);
|
|
11
|
-
if (fs.existsSync(absolute)) {
|
|
12
|
-
const stat = fs.statSync(absolute);
|
|
13
|
-
if (stat.isFile()) {
|
|
14
|
-
return absolute;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
for (const ext of SOURCE_EXTENSIONS) {
|
|
18
|
-
const candidate = `${absolute}${ext}`;
|
|
19
|
-
if (fs.existsSync(candidate) && fs.statSync(candidate).isFile()) {
|
|
20
|
-
return path.resolve(candidate);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
if (fs.existsSync(absolute) && fs.statSync(absolute).isDirectory()) {
|
|
24
|
-
for (const ext of SOURCE_EXTENSIONS) {
|
|
25
|
-
const candidate = path.join(absolute, `index${ext}`);
|
|
26
|
-
if (fs.existsSync(candidate) && fs.statSync(candidate).isFile()) {
|
|
27
|
-
return path.resolve(candidate);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return absolute;
|
|
32
|
-
}
|
|
33
|
-
export function resolveComponentFile(importer, importPath) {
|
|
34
|
-
if (!importPath.startsWith(".")) {
|
|
35
|
-
return importPath;
|
|
36
|
-
}
|
|
37
|
-
const base = path.resolve(path.dirname(importer), importPath);
|
|
38
|
-
return resolveFile(base);
|
|
39
|
-
}
|
|
40
|
-
export function createClientId(file) {
|
|
41
|
-
return `c_${crypto
|
|
42
|
-
.createHash("sha256")
|
|
43
|
-
.update(path.normalize(file))
|
|
44
|
-
.digest("hex")
|
|
45
|
-
.slice(0, 12)}`;
|
|
46
|
-
}
|
|
47
|
-
export function getJSXComponentName(node) {
|
|
48
|
-
const name = node.openingElement.name;
|
|
49
|
-
if (t.isJSXIdentifier(name)) {
|
|
50
|
-
return name.name;
|
|
51
|
-
}
|
|
52
|
-
if (t.isJSXMemberExpression(name)) {
|
|
53
|
-
if (t.isJSXIdentifier(name.object) && t.isJSXIdentifier(name.property)) {
|
|
54
|
-
return `${name.object.name}.${name.property.name}`;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
return null;
|
|
58
|
-
}
|
|
59
|
-
export function findComponentImport(ast, componentName) {
|
|
60
|
-
for (const node of ast.program.body) {
|
|
61
|
-
if (!t.isImportDeclaration(node)) {
|
|
62
|
-
continue;
|
|
63
|
-
}
|
|
64
|
-
for (const specifier of node.specifiers) {
|
|
65
|
-
if (t.isImportDefaultSpecifier(specifier) &&
|
|
66
|
-
specifier.local.name === componentName) {
|
|
67
|
-
return {
|
|
68
|
-
file: node.source.value,
|
|
69
|
-
export: "default",
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
if (t.isImportSpecifier(specifier) &&
|
|
73
|
-
specifier.local.name === componentName) {
|
|
74
|
-
const imported = specifier.imported;
|
|
75
|
-
return {
|
|
76
|
-
file: node.source.value,
|
|
77
|
-
export: t.isIdentifier(imported) ? imported.name : imported.value,
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
return null;
|
|
83
|
-
}
|
|
84
|
-
export function entryFinder(code, id) {
|
|
85
|
-
const ast = parse(code, {
|
|
86
|
-
sourceType: "module",
|
|
87
|
-
plugins: ["typescript", "jsx"],
|
|
88
|
-
});
|
|
89
|
-
const entries = new Map();
|
|
90
|
-
traverse(ast, {
|
|
91
|
-
CallExpression(callPath) {
|
|
92
|
-
const call = callPath.node;
|
|
93
|
-
/*
|
|
94
|
-
* Find:
|
|
95
|
-
*
|
|
96
|
-
* res.send(<Home />);
|
|
97
|
-
*/
|
|
98
|
-
if (!t.isMemberExpression(call.callee)) {
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
if (!t.isIdentifier(call.callee.property, {
|
|
102
|
-
name: "send",
|
|
103
|
-
})) {
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
const argument = call.arguments[0];
|
|
107
|
-
if (!argument || !t.isJSXElement(argument)) {
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
const functionPath = callPath.getFunctionParent();
|
|
111
|
-
if (!functionPath) {
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
const params = functionPath.node.params;
|
|
115
|
-
if (params.length < 2) {
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
const requestParam = params[0];
|
|
119
|
-
const responseParam = params[1];
|
|
120
|
-
if (!t.isIdentifier(requestParam) || !t.isIdentifier(responseParam)) {
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
const componentName = getJSXComponentName(argument);
|
|
124
|
-
if (!componentName) {
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
const componentImport = findComponentImport(ast, componentName);
|
|
128
|
-
if (!componentImport) {
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
const componentImportPath = componentImport.file;
|
|
132
|
-
const componentFile = resolveComponentFile(id, componentImportPath);
|
|
133
|
-
if (!path.isAbsolute(componentFile)) {
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
const normalizedFile = normalizePath(componentFile);
|
|
137
|
-
const clientId = createClientId(normalizedFile);
|
|
138
|
-
const entry = {
|
|
139
|
-
id: clientId,
|
|
140
|
-
name: componentName,
|
|
141
|
-
file: normalizedFile,
|
|
142
|
-
path: componentImportPath,
|
|
143
|
-
export: componentImport.export,
|
|
144
|
-
};
|
|
145
|
-
entries.set(clientId, entry);
|
|
146
|
-
},
|
|
147
|
-
});
|
|
148
|
-
return Array.from(entries.values());
|
|
149
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { entryFinder } from "./finder.js";
|
|
2
|
-
export function XanixEntryFinder({ entries }) {
|
|
3
|
-
return {
|
|
4
|
-
name: "xanix-entry-finder",
|
|
5
|
-
async transform(code, id) {
|
|
6
|
-
if (id.includes("node_modules") || !/\.(tsx?|jsx?)$/.test(id)) {
|
|
7
|
-
return null;
|
|
8
|
-
}
|
|
9
|
-
const clientEntries = entryFinder(code, id);
|
|
10
|
-
if (!clientEntries) {
|
|
11
|
-
return null;
|
|
12
|
-
}
|
|
13
|
-
for (const entry of clientEntries) {
|
|
14
|
-
const resolved = await this.resolve(entry.file, id, {
|
|
15
|
-
skipSelf: true,
|
|
16
|
-
});
|
|
17
|
-
if (!resolved) {
|
|
18
|
-
this.error(`Could not resolve client component "${entry.file}" imported by "${id}"`);
|
|
19
|
-
}
|
|
20
|
-
entries.set(entry.id, entry);
|
|
21
|
-
}
|
|
22
|
-
return null;
|
|
23
|
-
},
|
|
24
|
-
// generateBundle() {
|
|
25
|
-
// const manifest = {
|
|
26
|
-
// version: 1,
|
|
27
|
-
// entries: [...entries.values()],
|
|
28
|
-
// };
|
|
29
|
-
// console.log(manifest);
|
|
30
|
-
// this.emitFile({
|
|
31
|
-
// type: "asset",
|
|
32
|
-
// fileName: "client-manifest.json",
|
|
33
|
-
// source: JSON.stringify(manifest, null, 2),
|
|
34
|
-
// });
|
|
35
|
-
// },
|
|
36
|
-
};
|
|
37
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { Plugin } from "rollup";
|
|
2
|
-
export interface XanixEnvPluginOptions {
|
|
3
|
-
/**
|
|
4
|
-
* Build environment.
|
|
5
|
-
*
|
|
6
|
-
* development → .env + .env.dev
|
|
7
|
-
* production → .env + .env.prod
|
|
8
|
-
*/
|
|
9
|
-
mode?: "development" | "production";
|
|
10
|
-
/**
|
|
11
|
-
* Whether this is a client build.
|
|
12
|
-
*/
|
|
13
|
-
isClient?: boolean;
|
|
14
|
-
}
|
|
15
|
-
export default function XanixEnvPlugin(options?: XanixEnvPluginOptions): Plugin;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import dotenv from "dotenv";
|
|
4
|
-
import replace from "@rollup/plugin-replace";
|
|
5
|
-
import defines from "../config/defines.js";
|
|
6
|
-
export default function XanixEnvPlugin(options = {}) {
|
|
7
|
-
const root = process.cwd();
|
|
8
|
-
const mode = options.mode ?? "development";
|
|
9
|
-
const isClient = options.isClient ?? false;
|
|
10
|
-
const publicPrefix = "PUBLIC_";
|
|
11
|
-
const envFiles = [
|
|
12
|
-
path.resolve(root, ".env"),
|
|
13
|
-
path.resolve(root, mode === "development" ? ".env.dev" : ".env.prod"),
|
|
14
|
-
];
|
|
15
|
-
const env = {};
|
|
16
|
-
for (const file of envFiles) {
|
|
17
|
-
if (!fs.existsSync(file)) {
|
|
18
|
-
continue;
|
|
19
|
-
}
|
|
20
|
-
const result = dotenv.parse(fs.readFileSync(file));
|
|
21
|
-
Object.assign(env, result);
|
|
22
|
-
}
|
|
23
|
-
const clientEnv = {};
|
|
24
|
-
const serverEnv = {};
|
|
25
|
-
for (const [key, value] of Object.entries(env)) {
|
|
26
|
-
if (key.startsWith(publicPrefix)) {
|
|
27
|
-
clientEnv[`process.env.${key}`] = JSON.stringify(value);
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
serverEnv[`process.env.${key}`] = JSON.stringify(value);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
const envs = {
|
|
34
|
-
...(isClient ? clientEnv : serverEnv),
|
|
35
|
-
...defines({
|
|
36
|
-
mode,
|
|
37
|
-
isClient,
|
|
38
|
-
}),
|
|
39
|
-
};
|
|
40
|
-
return replace({
|
|
41
|
-
preventAssignment: true,
|
|
42
|
-
values: envs,
|
|
43
|
-
});
|
|
44
|
-
}
|
|
@@ -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,18 +0,0 @@
|
|
|
1
|
-
import * as t from "@babel/types";
|
|
2
|
-
export interface XanixPageEntry {
|
|
3
|
-
id: string;
|
|
4
|
-
name: string;
|
|
5
|
-
file: string;
|
|
6
|
-
path: string;
|
|
7
|
-
export: string;
|
|
8
|
-
}
|
|
9
|
-
export interface XanixTransformResult {
|
|
10
|
-
code: string;
|
|
11
|
-
map: any;
|
|
12
|
-
entries: XanixPageEntry[];
|
|
13
|
-
}
|
|
14
|
-
export declare function resolveFile(file: string): string;
|
|
15
|
-
export declare function resolveComponentFile(importer: string, importPath: string): string;
|
|
16
|
-
export declare function createPageId(file: string): string;
|
|
17
|
-
export declare function getJSXComponentName(node: t.JSXElement): string | null;
|
|
18
|
-
export declare function transformer(code: string, id: string): XanixTransformResult | null;
|