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,197 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import ts from "typescript";
|
|
4
|
-
const EXTENSIONS = [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"];
|
|
5
|
-
function getConfig() {
|
|
6
|
-
const root = process.cwd();
|
|
7
|
-
const tsconfigPath = path.resolve(root, "tsconfig.json");
|
|
8
|
-
if (!fs.existsSync(tsconfigPath)) {
|
|
9
|
-
return {
|
|
10
|
-
basePath: root,
|
|
11
|
-
aliases: [],
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
const result = ts.readConfigFile(tsconfigPath, ts.sys.readFile);
|
|
15
|
-
if (result.error) {
|
|
16
|
-
throw new Error(`[xanix] Failed to read tsconfig.json:\n${ts.flattenDiagnosticMessageText(result.error.messageText, "\n")}`);
|
|
17
|
-
}
|
|
18
|
-
const config = result.config;
|
|
19
|
-
const compilerOptions = config.compilerOptions ?? {};
|
|
20
|
-
const tsconfigDir = path.dirname(tsconfigPath);
|
|
21
|
-
const baseUrl = compilerOptions.baseUrl ?? ".";
|
|
22
|
-
const basePath = path.resolve(tsconfigDir, baseUrl);
|
|
23
|
-
const paths = compilerOptions.paths ?? {};
|
|
24
|
-
const aliases = [];
|
|
25
|
-
for (const [pattern, replacements] of Object.entries(paths)) {
|
|
26
|
-
const replacement = replacements?.[0];
|
|
27
|
-
if (!replacement) {
|
|
28
|
-
continue;
|
|
29
|
-
}
|
|
30
|
-
const wildcard = pattern.endsWith("/*");
|
|
31
|
-
aliases.push({
|
|
32
|
-
pattern: wildcard ? pattern.slice(0, -2) : pattern,
|
|
33
|
-
wildcard,
|
|
34
|
-
replacement: wildcard
|
|
35
|
-
? replacement.endsWith("/*")
|
|
36
|
-
? replacement.slice(0, -2)
|
|
37
|
-
: replacement
|
|
38
|
-
: replacement,
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
return {
|
|
42
|
-
basePath,
|
|
43
|
-
aliases,
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
const config = getConfig();
|
|
47
|
-
/**
|
|
48
|
-
* Check whether an import matches a tsconfig path alias.
|
|
49
|
-
*
|
|
50
|
-
* Examples:
|
|
51
|
-
*
|
|
52
|
-
* @db
|
|
53
|
-
* @db/index
|
|
54
|
-
* @db/user
|
|
55
|
-
*
|
|
56
|
-
* with:
|
|
57
|
-
*
|
|
58
|
-
* "@db/*": ["./src/db/*"]
|
|
59
|
-
*/
|
|
60
|
-
export function tsconfigPathsMatcher(id) {
|
|
61
|
-
for (const alias of config.aliases) {
|
|
62
|
-
if (!alias.wildcard) {
|
|
63
|
-
if (id === alias.pattern) {
|
|
64
|
-
return true;
|
|
65
|
-
}
|
|
66
|
-
continue;
|
|
67
|
-
}
|
|
68
|
-
if (id === alias.pattern || id.startsWith(`${alias.pattern}/`)) {
|
|
69
|
-
return true;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
return false;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Resolve a tsconfig path alias.
|
|
76
|
-
*/
|
|
77
|
-
function resolveTsconfigAlias(source) {
|
|
78
|
-
for (const alias of config.aliases) {
|
|
79
|
-
let target = null;
|
|
80
|
-
/*
|
|
81
|
-
* Exact alias
|
|
82
|
-
*
|
|
83
|
-
* "@db": ["./src/db"]
|
|
84
|
-
*/
|
|
85
|
-
if (!alias.wildcard) {
|
|
86
|
-
if (source !== alias.pattern) {
|
|
87
|
-
continue;
|
|
88
|
-
}
|
|
89
|
-
target = alias.replacement;
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
/*
|
|
93
|
-
* Wildcard alias
|
|
94
|
-
*
|
|
95
|
-
* "@db/*": ["./src/db/*"]
|
|
96
|
-
*
|
|
97
|
-
* @db/index
|
|
98
|
-
* ↓
|
|
99
|
-
* ./src/db/index
|
|
100
|
-
*/
|
|
101
|
-
if (source !== alias.pattern && !source.startsWith(`${alias.pattern}/`)) {
|
|
102
|
-
continue;
|
|
103
|
-
}
|
|
104
|
-
const subPath = source === alias.pattern ? "" : source.slice(alias.pattern.length + 1);
|
|
105
|
-
target = path.join(alias.replacement, subPath);
|
|
106
|
-
}
|
|
107
|
-
const absoluteTarget = path.resolve(config.basePath, target);
|
|
108
|
-
const resolved = resolvePath(absoluteTarget);
|
|
109
|
-
if (resolved) {
|
|
110
|
-
return resolved;
|
|
111
|
-
}
|
|
112
|
-
throw new Error(`[xanix] Cannot resolve "${source}"\n` + `Target: ${absoluteTarget}`);
|
|
113
|
-
}
|
|
114
|
-
return null;
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Resolve:
|
|
118
|
-
*
|
|
119
|
-
* file.ts
|
|
120
|
-
* file.tsx
|
|
121
|
-
* file.js
|
|
122
|
-
* directory/index.ts
|
|
123
|
-
* directory/index.tsx
|
|
124
|
-
* etc.
|
|
125
|
-
*/
|
|
126
|
-
function resolvePath(input) {
|
|
127
|
-
/*
|
|
128
|
-
* Exact file.
|
|
129
|
-
*/
|
|
130
|
-
if (isFile(input)) {
|
|
131
|
-
return input;
|
|
132
|
-
}
|
|
133
|
-
/*
|
|
134
|
-
* Extension resolution.
|
|
135
|
-
*
|
|
136
|
-
* ./db/index
|
|
137
|
-
*
|
|
138
|
-
* →
|
|
139
|
-
*
|
|
140
|
-
* ./db/index.ts
|
|
141
|
-
*/
|
|
142
|
-
for (const extension of EXTENSIONS) {
|
|
143
|
-
const candidate = `${input}${extension}`;
|
|
144
|
-
if (isFile(candidate)) {
|
|
145
|
-
return candidate;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
/*
|
|
149
|
-
* Directory resolution.
|
|
150
|
-
*
|
|
151
|
-
* ./db
|
|
152
|
-
*
|
|
153
|
-
* →
|
|
154
|
-
*
|
|
155
|
-
* ./db/index.ts
|
|
156
|
-
*/
|
|
157
|
-
if (isDirectory(input)) {
|
|
158
|
-
for (const extension of EXTENSIONS) {
|
|
159
|
-
const candidate = path.join(input, `index${extension}`);
|
|
160
|
-
if (isFile(candidate)) {
|
|
161
|
-
return candidate;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
return null;
|
|
166
|
-
}
|
|
167
|
-
function isFile(file) {
|
|
168
|
-
try {
|
|
169
|
-
return fs.statSync(file).isFile();
|
|
170
|
-
}
|
|
171
|
-
catch {
|
|
172
|
-
return false;
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
function isDirectory(directory) {
|
|
176
|
-
try {
|
|
177
|
-
return fs.statSync(directory).isDirectory();
|
|
178
|
-
}
|
|
179
|
-
catch {
|
|
180
|
-
return false;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* Rollup plugin.
|
|
185
|
-
*/
|
|
186
|
-
export default function xanixTsconfigAlias() {
|
|
187
|
-
return {
|
|
188
|
-
name: "xanix-tsconfig-alias",
|
|
189
|
-
resolveId(source) {
|
|
190
|
-
const resolved = resolveTsconfigAlias(source);
|
|
191
|
-
if (resolved) {
|
|
192
|
-
return resolved;
|
|
193
|
-
}
|
|
194
|
-
return null;
|
|
195
|
-
},
|
|
196
|
-
};
|
|
197
|
-
}
|
|
@@ -1,445 +0,0 @@
|
|
|
1
|
-
import crypto from "node:crypto";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
const XANIX_PACKAGE = "xanix";
|
|
4
|
-
/* ============================================================
|
|
5
|
-
Utils
|
|
6
|
-
============================================================ */
|
|
7
|
-
const normalizePath = (value) => value.replace(/\\/g, "/");
|
|
8
|
-
const createUID = (file, index) => crypto
|
|
9
|
-
.createHash("sha256")
|
|
10
|
-
.update(`${file}:${index}`)
|
|
11
|
-
.digest("hex")
|
|
12
|
-
.slice(0, 16);
|
|
13
|
-
const source = (code, node) => code.slice(node.start, node.end);
|
|
14
|
-
/* ============================================================
|
|
15
|
-
AST walker
|
|
16
|
-
============================================================ */
|
|
17
|
-
function walk(node, visitor, parent = null, ancestors = []) {
|
|
18
|
-
visitor(node, parent, ancestors);
|
|
19
|
-
const nextAncestors = [...ancestors, node];
|
|
20
|
-
for (const key of Object.keys(node)) {
|
|
21
|
-
if (key === "parent" ||
|
|
22
|
-
key === "loc" ||
|
|
23
|
-
key === "range" ||
|
|
24
|
-
key === "tokens" ||
|
|
25
|
-
key === "comments") {
|
|
26
|
-
continue;
|
|
27
|
-
}
|
|
28
|
-
const value = node[key];
|
|
29
|
-
if (Array.isArray(value)) {
|
|
30
|
-
for (const item of value) {
|
|
31
|
-
if (item && typeof item === "object" && typeof item.type === "string") {
|
|
32
|
-
walk(item, visitor, node, nextAncestors);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
continue;
|
|
36
|
-
}
|
|
37
|
-
if (value && typeof value === "object" && typeof value.type === "string") {
|
|
38
|
-
walk(value, visitor, node, nextAncestors);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
/* ============================================================
|
|
43
|
-
Find local useServer name
|
|
44
|
-
|
|
45
|
-
import { useServer } from "xanix";
|
|
46
|
-
|
|
47
|
-
import {
|
|
48
|
-
useServer as server
|
|
49
|
-
} from "xanix";
|
|
50
|
-
============================================================ */
|
|
51
|
-
function getUseServerName(ast) {
|
|
52
|
-
for (const statement of ast.body ?? []) {
|
|
53
|
-
if (statement.type !== "ImportDeclaration") {
|
|
54
|
-
continue;
|
|
55
|
-
}
|
|
56
|
-
if (statement.source?.value !== XANIX_PACKAGE) {
|
|
57
|
-
continue;
|
|
58
|
-
}
|
|
59
|
-
for (const specifier of statement.specifiers ?? []) {
|
|
60
|
-
if (specifier.type !== "ImportSpecifier") {
|
|
61
|
-
continue;
|
|
62
|
-
}
|
|
63
|
-
const imported = specifier.imported;
|
|
64
|
-
if (imported?.type === "Identifier" && imported.name === "useServer") {
|
|
65
|
-
return specifier.local.name;
|
|
66
|
-
}
|
|
67
|
-
if (imported?.type === "Literal" && imported.value === "useServer") {
|
|
68
|
-
return specifier.local.name;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
return null;
|
|
73
|
-
}
|
|
74
|
-
/* ============================================================
|
|
75
|
-
Detect:
|
|
76
|
-
|
|
77
|
-
useServer(...)
|
|
78
|
-
============================================================ */
|
|
79
|
-
function isUseServer(node, localName) {
|
|
80
|
-
return (node.type === "CallExpression" &&
|
|
81
|
-
node.callee?.type === "Identifier" &&
|
|
82
|
-
node.callee.name === localName);
|
|
83
|
-
}
|
|
84
|
-
/* ============================================================
|
|
85
|
-
Create:
|
|
86
|
-
|
|
87
|
-
{
|
|
88
|
-
uid: "abc",
|
|
89
|
-
args: {
|
|
90
|
-
id
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
OR:
|
|
95
|
-
|
|
96
|
-
{
|
|
97
|
-
uid: "abc",
|
|
98
|
-
args: {
|
|
99
|
-
...args
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
============================================================ */
|
|
103
|
-
function createServerRequest(code, props, uid) {
|
|
104
|
-
const args = props ? source(code, props) : "{}";
|
|
105
|
-
return ["{", `uid: ${JSON.stringify(uid)},`, `args: ${args},`, "}"].join("\n");
|
|
106
|
-
}
|
|
107
|
-
/* ============================================================
|
|
108
|
-
Find Xanix import
|
|
109
|
-
============================================================ */
|
|
110
|
-
function findXanixImport(ast) {
|
|
111
|
-
for (const statement of ast.body ?? []) {
|
|
112
|
-
if (statement.type === "ImportDeclaration" &&
|
|
113
|
-
statement.source?.value === XANIX_PACKAGE) {
|
|
114
|
-
return statement;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
return null;
|
|
118
|
-
}
|
|
119
|
-
/* ============================================================
|
|
120
|
-
Check registerUseServer import
|
|
121
|
-
============================================================ */
|
|
122
|
-
function hasRegisterUseServerImport(ast) {
|
|
123
|
-
const xanixImport = findXanixImport(ast);
|
|
124
|
-
if (!xanixImport) {
|
|
125
|
-
return false;
|
|
126
|
-
}
|
|
127
|
-
for (const specifier of xanixImport.specifiers ?? []) {
|
|
128
|
-
if (specifier.type !== "ImportSpecifier") {
|
|
129
|
-
continue;
|
|
130
|
-
}
|
|
131
|
-
const imported = specifier.imported;
|
|
132
|
-
if (imported?.type === "Identifier" &&
|
|
133
|
-
imported.name === "registerUseServer") {
|
|
134
|
-
return true;
|
|
135
|
-
}
|
|
136
|
-
if (imported?.type === "Literal" &&
|
|
137
|
-
imported.value === "registerUseServer") {
|
|
138
|
-
return true;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
return false;
|
|
142
|
-
}
|
|
143
|
-
/* ============================================================
|
|
144
|
-
Create import edit
|
|
145
|
-
|
|
146
|
-
Existing:
|
|
147
|
-
|
|
148
|
-
import { useServer } from "xanix";
|
|
149
|
-
|
|
150
|
-
becomes:
|
|
151
|
-
|
|
152
|
-
import {
|
|
153
|
-
useServer,
|
|
154
|
-
registerUseServer
|
|
155
|
-
} from "xanix";
|
|
156
|
-
============================================================ */
|
|
157
|
-
function createRegisterImportEdit(code, ast) {
|
|
158
|
-
if (hasRegisterUseServerImport(ast)) {
|
|
159
|
-
return null;
|
|
160
|
-
}
|
|
161
|
-
const xanixImport = findXanixImport(ast);
|
|
162
|
-
if (!xanixImport) {
|
|
163
|
-
return {
|
|
164
|
-
start: 0,
|
|
165
|
-
end: 0,
|
|
166
|
-
content: `import { registerUseServer } from "xanix";\n`,
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
const specifiers = xanixImport.specifiers ?? [];
|
|
170
|
-
/*
|
|
171
|
-
* import "xanix";
|
|
172
|
-
*/
|
|
173
|
-
if (!specifiers.length) {
|
|
174
|
-
return {
|
|
175
|
-
start: xanixImport.start,
|
|
176
|
-
end: xanixImport.end,
|
|
177
|
-
content: `import { registerUseServer } from "xanix";`,
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
/*
|
|
181
|
-
* Insert before the closing "}".
|
|
182
|
-
*
|
|
183
|
-
* We don't regenerate the import.
|
|
184
|
-
* We simply append a named specifier.
|
|
185
|
-
*/
|
|
186
|
-
const lastSpecifier = specifiers[specifiers.length - 1];
|
|
187
|
-
if (lastSpecifier?.end == null) {
|
|
188
|
-
return null;
|
|
189
|
-
}
|
|
190
|
-
return {
|
|
191
|
-
start: lastSpecifier.end,
|
|
192
|
-
end: lastSpecifier.end,
|
|
193
|
-
content: ", registerUseServer",
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
/* ============================================================
|
|
197
|
-
Insert registrations after imports
|
|
198
|
-
============================================================ */
|
|
199
|
-
function getImportInsertionPosition(ast) {
|
|
200
|
-
const body = ast.body ?? [];
|
|
201
|
-
let position = 0;
|
|
202
|
-
for (const statement of body) {
|
|
203
|
-
if (statement.type !== "ImportDeclaration") {
|
|
204
|
-
break;
|
|
205
|
-
}
|
|
206
|
-
if (statement.end != null) {
|
|
207
|
-
position = statement.end;
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
return position;
|
|
211
|
-
}
|
|
212
|
-
/* ============================================================
|
|
213
|
-
CLIENT
|
|
214
|
-
|
|
215
|
-
Source:
|
|
216
|
-
|
|
217
|
-
useServer(
|
|
218
|
-
async ({ id }) => getUser(id),
|
|
219
|
-
{ id }
|
|
220
|
-
)
|
|
221
|
-
|
|
222
|
-
becomes:
|
|
223
|
-
|
|
224
|
-
useServer({
|
|
225
|
-
uid: "abc123",
|
|
226
|
-
args: {
|
|
227
|
-
id
|
|
228
|
-
}
|
|
229
|
-
})
|
|
230
|
-
============================================================ */
|
|
231
|
-
function transformClient(code, ast, filePath, useServerName) {
|
|
232
|
-
let index = 0;
|
|
233
|
-
const edits = [];
|
|
234
|
-
walk(ast, (node) => {
|
|
235
|
-
if (!isUseServer(node, useServerName)) {
|
|
236
|
-
return;
|
|
237
|
-
}
|
|
238
|
-
const callback = node.arguments?.[0];
|
|
239
|
-
if (!callback ||
|
|
240
|
-
!(callback.type === "ArrowFunctionExpression" ||
|
|
241
|
-
callback.type === "FunctionExpression")) {
|
|
242
|
-
return;
|
|
243
|
-
}
|
|
244
|
-
const props = node.arguments?.[1];
|
|
245
|
-
const uid = createUID(filePath, index++);
|
|
246
|
-
const request = createServerRequest(code, props, uid);
|
|
247
|
-
edits.push({
|
|
248
|
-
start: node.start,
|
|
249
|
-
end: node.end,
|
|
250
|
-
content: `${useServerName}(${request})`,
|
|
251
|
-
});
|
|
252
|
-
});
|
|
253
|
-
if (!edits.length) {
|
|
254
|
-
return null;
|
|
255
|
-
}
|
|
256
|
-
return applyEdits(code, edits, filePath);
|
|
257
|
-
}
|
|
258
|
-
/* ============================================================
|
|
259
|
-
SERVER
|
|
260
|
-
|
|
261
|
-
Source:
|
|
262
|
-
|
|
263
|
-
useServer(
|
|
264
|
-
async ({ id }) => getUser(id),
|
|
265
|
-
{ id }
|
|
266
|
-
)
|
|
267
|
-
|
|
268
|
-
becomes:
|
|
269
|
-
|
|
270
|
-
registerUseServer(
|
|
271
|
-
"abc123",
|
|
272
|
-
async ({ id }) => getUser(id)
|
|
273
|
-
);
|
|
274
|
-
|
|
275
|
-
useServer({
|
|
276
|
-
uid: "abc123",
|
|
277
|
-
args: { id }
|
|
278
|
-
})
|
|
279
|
-
============================================================ */
|
|
280
|
-
function transformServer(code, ast, filePath, useServerName) {
|
|
281
|
-
let index = 0;
|
|
282
|
-
const edits = [];
|
|
283
|
-
const registrations = [];
|
|
284
|
-
walk(ast, (node) => {
|
|
285
|
-
if (!isUseServer(node, useServerName)) {
|
|
286
|
-
return;
|
|
287
|
-
}
|
|
288
|
-
const callback = node.arguments?.[0];
|
|
289
|
-
if (!callback ||
|
|
290
|
-
!(callback.type === "ArrowFunctionExpression" ||
|
|
291
|
-
callback.type === "FunctionExpression")) {
|
|
292
|
-
return;
|
|
293
|
-
}
|
|
294
|
-
const props = node.arguments?.[1];
|
|
295
|
-
const uid = createUID(filePath, index++);
|
|
296
|
-
/*
|
|
297
|
-
* registerUseServer(
|
|
298
|
-
* "abc123",
|
|
299
|
-
* async ({ id }) => getUser(id)
|
|
300
|
-
* );
|
|
301
|
-
*/
|
|
302
|
-
registrations.push([
|
|
303
|
-
"registerUseServer(",
|
|
304
|
-
`${JSON.stringify(uid)},`,
|
|
305
|
-
`${source(code, callback)}`,
|
|
306
|
-
");",
|
|
307
|
-
].join("\n"));
|
|
308
|
-
/*
|
|
309
|
-
* Replace:
|
|
310
|
-
*
|
|
311
|
-
* useServer(callback, props)
|
|
312
|
-
*
|
|
313
|
-
* with:
|
|
314
|
-
*
|
|
315
|
-
* useServer({
|
|
316
|
-
* uid,
|
|
317
|
-
* args
|
|
318
|
-
* })
|
|
319
|
-
*/
|
|
320
|
-
const request = createServerRequest(code, props, uid);
|
|
321
|
-
edits.push({
|
|
322
|
-
start: node.start,
|
|
323
|
-
end: node.end,
|
|
324
|
-
content: `${useServerName}(${request})`,
|
|
325
|
-
});
|
|
326
|
-
});
|
|
327
|
-
if (!edits.length) {
|
|
328
|
-
return null;
|
|
329
|
-
}
|
|
330
|
-
/*
|
|
331
|
-
* Add registerUseServer import.
|
|
332
|
-
*/
|
|
333
|
-
const importEdit = createRegisterImportEdit(code, ast);
|
|
334
|
-
if (importEdit) {
|
|
335
|
-
edits.push(importEdit);
|
|
336
|
-
}
|
|
337
|
-
/*
|
|
338
|
-
* Insert registrations after imports.
|
|
339
|
-
*/
|
|
340
|
-
const importPosition = getImportInsertionPosition(ast);
|
|
341
|
-
if (registrations.length) {
|
|
342
|
-
edits.push({
|
|
343
|
-
start: importPosition,
|
|
344
|
-
end: importPosition,
|
|
345
|
-
content: `\n\n${registrations.join("\n\n")}\n`,
|
|
346
|
-
});
|
|
347
|
-
}
|
|
348
|
-
return applyEdits(code, edits, filePath);
|
|
349
|
-
}
|
|
350
|
-
/* ============================================================
|
|
351
|
-
Apply edits
|
|
352
|
-
============================================================ */
|
|
353
|
-
function applyEdits(code, edits, filePath) {
|
|
354
|
-
/*
|
|
355
|
-
* Sort backwards so source offsets
|
|
356
|
-
* remain valid.
|
|
357
|
-
*/
|
|
358
|
-
edits.sort((a, b) => b.start - a.start);
|
|
359
|
-
let result = code;
|
|
360
|
-
let lastStart = Number.POSITIVE_INFINITY;
|
|
361
|
-
for (const edit of edits) {
|
|
362
|
-
/*
|
|
363
|
-
* Ignore overlapping edits.
|
|
364
|
-
*/
|
|
365
|
-
if (edit.end > lastStart) {
|
|
366
|
-
continue;
|
|
367
|
-
}
|
|
368
|
-
result =
|
|
369
|
-
result.slice(0, edit.start) + edit.content + result.slice(edit.end);
|
|
370
|
-
lastStart = edit.start;
|
|
371
|
-
}
|
|
372
|
-
/*
|
|
373
|
-
* We deliberately don't fabricate
|
|
374
|
-
* a sourcemap here.
|
|
375
|
-
*
|
|
376
|
-
* The plugin returns null below.
|
|
377
|
-
*/
|
|
378
|
-
return {
|
|
379
|
-
code: result,
|
|
380
|
-
map: null,
|
|
381
|
-
};
|
|
382
|
-
}
|
|
383
|
-
/* ============================================================
|
|
384
|
-
Plugin
|
|
385
|
-
============================================================ */
|
|
386
|
-
export default function XanixUseServer(options) {
|
|
387
|
-
const root = path.resolve(options.root ?? process.cwd());
|
|
388
|
-
return {
|
|
389
|
-
name: "xanix-use-server",
|
|
390
|
-
transform: {
|
|
391
|
-
filter: {
|
|
392
|
-
id: /^(?!.*(?:node_modules[\\/])).*\.[cm]?[jt]sx?$/,
|
|
393
|
-
},
|
|
394
|
-
handler(code, id) {
|
|
395
|
-
const filename = id.split("?")[0];
|
|
396
|
-
const relativePath = normalizePath(path.relative(root, filename));
|
|
397
|
-
let ast;
|
|
398
|
-
try {
|
|
399
|
-
/*
|
|
400
|
-
* Rolldown/Oxc parser.
|
|
401
|
-
*
|
|
402
|
-
* This parses the original
|
|
403
|
-
* TypeScript / TSX / JSX source.
|
|
404
|
-
*/
|
|
405
|
-
ast = this.parse(code, {
|
|
406
|
-
lang: getLanguage(filename),
|
|
407
|
-
});
|
|
408
|
-
}
|
|
409
|
-
catch {
|
|
410
|
-
return null;
|
|
411
|
-
}
|
|
412
|
-
const useServerName = getUseServerName(ast);
|
|
413
|
-
if (!useServerName) {
|
|
414
|
-
return null;
|
|
415
|
-
}
|
|
416
|
-
const result = options.isClient
|
|
417
|
-
? transformClient(code, ast, relativePath, useServerName)
|
|
418
|
-
: transformServer(code, ast, relativePath, useServerName);
|
|
419
|
-
if (!result) {
|
|
420
|
-
return null;
|
|
421
|
-
}
|
|
422
|
-
return {
|
|
423
|
-
code: result.code,
|
|
424
|
-
map: result.map,
|
|
425
|
-
};
|
|
426
|
-
},
|
|
427
|
-
},
|
|
428
|
-
};
|
|
429
|
-
}
|
|
430
|
-
/* ============================================================
|
|
431
|
-
Language
|
|
432
|
-
============================================================ */
|
|
433
|
-
function getLanguage(id) {
|
|
434
|
-
const file = id.split("?")[0];
|
|
435
|
-
if (file.endsWith(".tsx")) {
|
|
436
|
-
return "tsx";
|
|
437
|
-
}
|
|
438
|
-
if (file.endsWith(".ts")) {
|
|
439
|
-
return "ts";
|
|
440
|
-
}
|
|
441
|
-
if (file.endsWith(".jsx")) {
|
|
442
|
-
return "jsx";
|
|
443
|
-
}
|
|
444
|
-
return "js";
|
|
445
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { Plugin } from "rolldown";
|
|
2
|
-
export interface XanixRollupOptions {
|
|
3
|
-
target?: "client" | "server";
|
|
4
|
-
development?: boolean;
|
|
5
|
-
assetExternal?: boolean;
|
|
6
|
-
WebSocketPort?: number;
|
|
7
|
-
}
|
|
8
|
-
export declare function xanixDefaultPlugins(options: XanixRollupOptions): Plugin[];
|
|
9
|
-
export declare function xanixCachePlugins(): Plugin[];
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import XanixTsconfigAlias from "./XanixTsconfigAlias.js";
|
|
2
|
-
import XanixDocument from "./XanixDocument/index.js";
|
|
3
|
-
import xanixReactRefresh from "./XanixReactRefresh.js";
|
|
4
|
-
import XanixUseServer from "./XanixUseServer.js";
|
|
5
|
-
import XanixAssets from "./XanixAssets.js";
|
|
6
|
-
export function xanixDefaultPlugins(options) {
|
|
7
|
-
const target = options.target ?? "client";
|
|
8
|
-
const development = options.development ?? true;
|
|
9
|
-
const isClient = target === "client";
|
|
10
|
-
const isServer = target === "server";
|
|
11
|
-
let _plugins = [];
|
|
12
|
-
if (isServer) {
|
|
13
|
-
// _plugins.push(XanixPageTransform());
|
|
14
|
-
// _plugins.push(
|
|
15
|
-
// XanixServerTransform({ mode: development ? "watch" : "start" }),
|
|
16
|
-
// );
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
if (development) {
|
|
20
|
-
_plugins.push(xanixReactRefresh(options.WebSocketPort));
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
return [
|
|
24
|
-
XanixAssets({
|
|
25
|
-
emit: isServer,
|
|
26
|
-
}),
|
|
27
|
-
XanixTsconfigAlias(),
|
|
28
|
-
XanixDocument(),
|
|
29
|
-
XanixUseServer({ isClient }),
|
|
30
|
-
..._plugins,
|
|
31
|
-
];
|
|
32
|
-
}
|
|
33
|
-
export function xanixCachePlugins() {
|
|
34
|
-
const isClient = true;
|
|
35
|
-
const development = true;
|
|
36
|
-
return [XanixTsconfigAlias(), XanixDocument()];
|
|
37
|
-
}
|