xanix 1.0.18 → 1.0.19
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/AppRoot.d.ts +6 -0
- package/dist/AppRoot.js +15 -0
- package/dist/bin/bundler/Cache.d.ts +1 -0
- package/dist/bin/bundler/Cache.js +210 -0
- package/dist/bin/bundler/External.d.ts +3 -0
- package/dist/bin/bundler/External.js +6 -0
- package/dist/bin/bundler/buildClient.js +2 -2
- package/dist/bin/bundler/buildServer.js +2 -2
- package/dist/bin/bundler/cache/buildCache.d.ts +3 -0
- package/dist/bin/bundler/cache/buildCache.js +76 -0
- package/dist/bin/bundler/cache/index.d.ts +3 -0
- package/dist/bin/bundler/cache/index.js +216 -0
- package/dist/bin/bundler/cache/manifest.d.ts +3 -0
- package/dist/bin/bundler/cache/manifest.js +27 -0
- package/dist/bin/bundler/cache/plugin/Transformer.d.ts +3 -0
- package/dist/bin/bundler/cache/plugin/Transformer.js +42 -0
- package/dist/bin/bundler/cache/types.d.ts +8 -0
- package/dist/bin/bundler/cache/types.js +1 -0
- package/dist/bin/bundler/cache/utils.d.ts +5 -0
- package/dist/bin/bundler/cache/utils.js +56 -0
- package/dist/bin/bundler/client/build.d.ts +2 -0
- package/dist/bin/bundler/client/build.js +61 -0
- package/dist/bin/bundler/client/plugins/Transformer/TransformCache.d.ts +15 -0
- package/dist/bin/bundler/client/plugins/Transformer/TransformCache.js +39 -0
- package/dist/bin/bundler/client/plugins/Transformer/TransformCacheFunction.d.ts +3 -0
- package/dist/bin/bundler/client/plugins/Transformer/TransformCacheFunction.js +32 -0
- package/dist/bin/bundler/client/plugins/Transformer/TransformCreateSession.d.ts +3 -0
- package/dist/bin/bundler/client/plugins/Transformer/TransformCreateSession.js +29 -0
- package/dist/bin/bundler/client/plugins/Transformer/TransformExpress.d.ts +9 -0
- package/dist/bin/bundler/client/plugins/Transformer/TransformExpress.js +26 -0
- package/dist/bin/bundler/client/plugins/Transformer/TransformPage.d.ts +29 -0
- package/dist/bin/bundler/client/plugins/Transformer/TransformPage.js +77 -0
- package/dist/bin/bundler/client/plugins/Transformer/TransformReactContext.d.ts +17 -0
- package/dist/bin/bundler/client/plugins/Transformer/TransformReactContext.js +101 -0
- package/dist/bin/bundler/client/plugins/Transformer/TransformServerAction.d.ts +15 -0
- package/dist/bin/bundler/client/plugins/Transformer/TransformServerAction.js +42 -0
- package/dist/bin/bundler/client/plugins/Transformer/TransformServerFunction.d.ts +3 -0
- package/dist/bin/bundler/client/plugins/Transformer/TransformServerFunction.js +32 -0
- package/dist/bin/bundler/client/plugins/Transformer/TransformUseServer.d.ts +3 -0
- package/dist/bin/bundler/client/plugins/Transformer/TransformUseServer.js +31 -0
- package/dist/bin/bundler/client/plugins/Transformer/transformModuleCache.d.ts +15 -0
- package/dist/bin/bundler/client/plugins/Transformer/transformModuleCache.js +120 -0
- package/dist/bin/bundler/client/plugins/Transformer copy.d.ts +3 -0
- package/dist/bin/bundler/client/plugins/Transformer copy.js +70 -0
- package/dist/bin/bundler/client/plugins/Transformer.d.ts +3 -0
- package/dist/bin/bundler/client/plugins/Transformer.js +26 -0
- package/dist/bin/bundler/client/plugins/VirtualDev.d.ts +2 -0
- package/dist/bin/bundler/client/plugins/VirtualDev.js +34 -0
- package/dist/bin/bundler/client/plugins/XanixPages.d.ts +2 -0
- package/dist/bin/bundler/client/plugins/XanixPages.js +37 -0
- package/dist/bin/bundler/client/plugins/XanixReactRefresh.d.ts +2 -0
- package/dist/bin/bundler/client/plugins/XanixReactRefresh.js +22 -0
- package/dist/bin/bundler/client/plugins/replacer/cacheFunctionReplacer.d.ts +3 -0
- package/dist/bin/bundler/client/plugins/replacer/cacheFunctionReplacer.js +28 -0
- package/dist/bin/bundler/client/plugins/replacer/serverFunctionReplacer.d.ts +3 -0
- package/dist/bin/bundler/client/plugins/replacer/serverFunctionReplacer.js +28 -0
- package/dist/bin/bundler/client/plugins/replacer/useServerReplacer.d.ts +3 -0
- package/dist/bin/bundler/client/plugins/replacer/useServerReplacer.js +38 -0
- package/dist/bin/bundler/client/watch.config.d.ts +3 -0
- package/dist/bin/bundler/client/watch.config.js +39 -0
- package/dist/bin/bundler/client/watch.d.ts +13 -0
- package/dist/bin/bundler/client/watch.js +71 -0
- package/dist/bin/bundler/config/loadEnv.d.ts +20 -0
- package/dist/bin/bundler/config/loadEnv.js +48 -0
- package/dist/bin/bundler/config/output.d.ts +1 -1
- package/dist/bin/bundler/config/output.js +13 -12
- package/dist/bin/bundler/externalResolver-dep.d.ts +3 -0
- package/dist/bin/bundler/externalResolver-dep.js +203 -0
- package/dist/bin/bundler/externalResolver.d.ts +3 -0
- package/dist/bin/bundler/externalResolver.js +203 -0
- package/dist/bin/bundler/plugins/TransformServer/TransformExpress.d.ts +9 -0
- package/dist/bin/bundler/plugins/TransformServer/TransformExpress.js +26 -0
- package/dist/bin/bundler/plugins/TransformServer/TransformPage.d.ts +25 -0
- package/dist/bin/bundler/plugins/TransformServer/TransformPage.js +79 -0
- package/dist/bin/bundler/plugins/TransformServer/index.d.ts +3 -0
- package/dist/bin/bundler/plugins/TransformServer/index.js +103 -0
- package/dist/bin/bundler/plugins/XanixAssets.d.ts +5 -0
- package/dist/bin/bundler/plugins/XanixAssets.js +51 -0
- package/dist/bin/bundler/plugins/XanixCacheDeps-dep.d.ts +2 -0
- package/dist/bin/bundler/plugins/XanixCacheDeps-dep.js +150 -0
- package/dist/bin/bundler/plugins/XanixCacheDeps.d.ts +2 -0
- package/dist/bin/bundler/plugins/XanixCacheDeps.js +150 -0
- package/dist/bin/bundler/plugins/XanixDocument/index.d.ts +1 -1
- package/dist/bin/bundler/plugins/XanixDocument/index.js +24 -14
- package/dist/bin/bundler/plugins/XanixEntryFinder/finder.js +0 -6
- package/dist/bin/bundler/plugins/XanixEntryFinder-dep/finder.d.ts +11 -0
- package/dist/bin/bundler/plugins/XanixEntryFinder-dep/finder.js +149 -0
- package/dist/bin/bundler/plugins/XanixEntryFinder-dep/index.d.ts +6 -0
- package/dist/bin/bundler/plugins/XanixEntryFinder-dep/index.js +37 -0
- package/dist/bin/bundler/plugins/XanixPageTransform/index.d.ts +1 -1
- package/dist/bin/bundler/plugins/XanixPageTransform/index.js +48 -33
- package/dist/bin/bundler/plugins/XanixPageTransform/transformer copy.d.ts +18 -0
- package/dist/bin/bundler/plugins/XanixPageTransform/transformer copy.js +414 -0
- package/dist/bin/bundler/plugins/XanixPageTransform/transformer.d.ts +9 -4
- package/dist/bin/bundler/plugins/XanixPageTransform/transformer.js +477 -302
- package/dist/bin/bundler/plugins/XanixReactRefresh copy.d.ts +2 -0
- package/dist/bin/bundler/plugins/XanixReactRefresh copy.js +121 -0
- package/dist/bin/bundler/plugins/XanixReactRefresh.d.ts +2 -2
- package/dist/bin/bundler/plugins/XanixReactRefresh.js +150 -101
- package/dist/bin/bundler/plugins/XanixResolveCacheDeps/BuildClientCache.d.ts +11 -0
- package/dist/bin/bundler/plugins/XanixResolveCacheDeps/BuildClientCache.js +129 -0
- package/dist/bin/bundler/plugins/XanixResolveCacheDeps/index copy.d.ts +15 -0
- package/dist/bin/bundler/plugins/XanixResolveCacheDeps/index copy.js +228 -0
- package/dist/bin/bundler/plugins/XanixResolveCacheDeps/index.d.ts +7 -5
- package/dist/bin/bundler/plugins/XanixResolveCacheDeps/index.js +156 -21
- package/dist/bin/bundler/plugins/XanixResolveCacheDeps-dep/BuildClientCache.d.ts +11 -0
- package/dist/bin/bundler/{cacheNpmModules.js → plugins/XanixResolveCacheDeps-dep/BuildClientCache.js} +13 -9
- package/dist/bin/bundler/plugins/XanixResolveCacheDeps-dep/index.d.ts +5 -0
- package/dist/bin/bundler/plugins/XanixResolveCacheDeps-dep/index.js +26 -0
- package/dist/bin/bundler/plugins/XanixResolver.d.ts +11 -0
- package/dist/bin/bundler/plugins/XanixResolver.js +55 -0
- package/dist/bin/bundler/plugins/XanixServerTransform.d.ts +1 -1
- package/dist/bin/bundler/plugins/XanixServerTransform.js +193 -116
- package/dist/bin/bundler/plugins/XanixTransform.d.ts +3 -0
- package/dist/bin/bundler/plugins/XanixTransform.js +23 -0
- package/dist/bin/bundler/plugins/XanixTsconfigAlias.d.ts +1 -1
- package/dist/bin/bundler/plugins/XanixUseServer.d.ts +1 -1
- package/dist/bin/bundler/plugins/XanixUseServer.js +308 -245
- package/dist/bin/bundler/plugins/plugins.d.ts +1 -5
- package/dist/bin/bundler/plugins/plugins.js +9 -154
- package/dist/bin/bundler/requireCache.d.ts +3 -0
- package/dist/bin/bundler/requireCache.js +85 -0
- package/dist/bin/bundler/server/build.d.ts +6 -0
- package/dist/bin/bundler/server/build.js +92 -0
- package/dist/bin/bundler/server/plugins/ServerAction.d.ts +3 -0
- package/dist/bin/bundler/server/plugins/ServerAction.js +9 -0
- package/dist/bin/bundler/server/plugins/Transformer/ServerAction.d.ts +11 -0
- package/dist/bin/bundler/server/plugins/Transformer/ServerAction.js +28 -0
- package/dist/bin/bundler/server/plugins/Transformer/TransformCache.d.ts +15 -0
- package/dist/bin/bundler/server/plugins/Transformer/TransformCache.js +39 -0
- package/dist/bin/bundler/server/plugins/Transformer/TransformCacheFunction.d.ts +3 -0
- package/dist/bin/bundler/server/plugins/Transformer/TransformCacheFunction.js +32 -0
- package/dist/bin/bundler/server/plugins/Transformer/TransformCreateSession.d.ts +3 -0
- package/dist/bin/bundler/server/plugins/Transformer/TransformCreateSession.js +30 -0
- package/dist/bin/bundler/server/plugins/Transformer/TransformExpress copy.d.ts +11 -0
- package/dist/bin/bundler/server/plugins/Transformer/TransformExpress copy.js +22 -0
- package/dist/bin/bundler/server/plugins/Transformer/TransformExpress.d.ts +10 -0
- package/dist/bin/bundler/server/plugins/Transformer/TransformExpress.js +19 -0
- package/dist/bin/bundler/server/plugins/Transformer/TransformExpressFunction.d.ts +3 -0
- package/dist/bin/bundler/server/plugins/Transformer/TransformExpressFunction.js +24 -0
- package/dist/bin/bundler/server/plugins/Transformer/TransformPage.d.ts +4 -0
- package/dist/bin/bundler/server/plugins/Transformer/TransformPage.js +31 -0
- package/dist/bin/bundler/server/plugins/Transformer/TransformReactContext.d.ts +17 -0
- package/dist/bin/bundler/server/plugins/Transformer/TransformReactContext.js +101 -0
- package/dist/bin/bundler/server/plugins/Transformer/TransformServer.d.ts +10 -0
- package/dist/bin/bundler/server/plugins/Transformer/TransformServer.js +19 -0
- package/dist/bin/bundler/server/plugins/Transformer/TransformServerAction copy.d.ts +14 -0
- package/dist/bin/bundler/server/plugins/Transformer/TransformServerAction copy.js +38 -0
- package/dist/bin/bundler/server/plugins/Transformer/TransformServerAction.d.ts +15 -0
- package/dist/bin/bundler/server/plugins/Transformer/TransformServerAction.js +44 -0
- package/dist/bin/bundler/server/plugins/Transformer/TransformServerFunction.d.ts +3 -0
- package/dist/bin/bundler/server/plugins/Transformer/TransformServerFunction.js +32 -0
- package/dist/bin/bundler/server/plugins/Transformer/TransformUseServer.d.ts +3 -0
- package/dist/bin/bundler/server/plugins/Transformer/TransformUseServer.js +31 -0
- package/dist/bin/bundler/server/plugins/Transformer copy.d.ts +6 -0
- package/dist/bin/bundler/server/plugins/Transformer copy.js +99 -0
- package/dist/bin/bundler/server/plugins/Transformer.d.ts +7 -0
- package/dist/bin/bundler/server/plugins/Transformer.js +58 -0
- package/dist/bin/bundler/server/plugins/replacer/cacheFunctionReplacer.d.ts +3 -0
- package/dist/bin/bundler/server/plugins/replacer/cacheFunctionReplacer.js +28 -0
- package/dist/bin/bundler/server/plugins/replacer/expressFunctionReplace.d.ts +3 -0
- package/dist/bin/bundler/server/plugins/replacer/expressFunctionReplace.js +24 -0
- package/dist/bin/bundler/server/plugins/replacer/pageReplacer.d.ts +4 -0
- package/dist/bin/bundler/server/plugins/replacer/pageReplacer.js +31 -0
- package/dist/bin/bundler/server/plugins/replacer/serverFunctionReplacer.d.ts +3 -0
- package/dist/bin/bundler/server/plugins/replacer/serverFunctionReplacer.js +28 -0
- package/dist/bin/bundler/server/plugins/replacer/useServerReplacer.d.ts +3 -0
- package/dist/bin/bundler/server/plugins/replacer/useServerReplacer.js +38 -0
- package/dist/bin/bundler/server/types.d.ts +5 -0
- package/dist/bin/bundler/server/types.js +1 -0
- package/dist/bin/bundler/server/watch.config.d.ts +3 -0
- package/dist/bin/bundler/server/watch.config.js +71 -0
- package/dist/bin/bundler/server/watch.d.ts +9 -0
- package/dist/bin/bundler/server/watch.js +59 -0
- package/dist/bin/bundler/watchClient.d.ts +5 -3
- package/dist/bin/bundler/watchClient.js +31 -16
- package/dist/bin/bundler/watchServer.d.ts +2 -2
- package/dist/bin/bundler/watchServer.js +66 -12
- package/dist/bin/cli/build.js +29 -13
- package/dist/bin/cli/create.d.ts +2 -0
- package/dist/bin/cli/create.js +2 -0
- package/dist/bin/cli/dev/dev.d.ts +2 -0
- package/dist/bin/cli/dev/dev.js +178 -0
- package/dist/bin/cli/dev/index.d.ts +2 -0
- package/dist/bin/cli/dev/index.js +114 -0
- package/dist/bin/cli/dev/server.d.ts +1 -0
- package/dist/bin/cli/dev/server.js +95 -0
- package/dist/bin/cli/dev/ws.d.ts +2 -0
- package/dist/bin/cli/dev/ws.js +29 -0
- package/dist/bin/cli/dev.js +120 -76
- package/dist/bin/cli/logs.d.ts +2 -0
- package/dist/bin/cli/logs.js +224 -0
- package/dist/bin/cli/restart.d.ts +2 -0
- package/dist/bin/cli/restart.js +28 -0
- package/dist/bin/cli/resurrect.d.ts +2 -0
- package/dist/bin/cli/resurrect.js +79 -0
- package/dist/bin/cli/save.d.ts +2 -0
- package/dist/bin/cli/save.js +87 -0
- package/dist/bin/cli/start/external.d.ts +2 -0
- package/dist/bin/cli/start/external.js +22 -0
- package/dist/bin/cli/start/index.d.ts +2 -0
- package/dist/bin/cli/start/index.js +27 -0
- package/dist/bin/cli/start/start.d.ts +2 -0
- package/dist/bin/cli/start/start.js +27 -0
- package/dist/bin/cli/start.js +10 -17
- package/dist/bin/cli/startup.d.ts +2 -0
- package/dist/bin/cli/startup.js +170 -0
- package/dist/bin/cli/status.d.ts +2 -0
- package/dist/bin/cli/status.js +23 -0
- package/dist/bin/cli/stop.d.ts +4 -0
- package/dist/bin/cli/stop.js +83 -0
- package/dist/bin/include/callbackReplacer.d.ts +2 -0
- package/dist/bin/include/callbackReplacer.js +91 -0
- package/dist/bin/include/importFinder.d.ts +9 -0
- package/dist/bin/include/importFinder.js +69 -0
- package/dist/bin/include/loadEnv.d.ts +19 -0
- package/dist/bin/include/loadEnv.js +47 -0
- package/dist/bin/include/manifest.d.ts +2 -3
- package/dist/bin/include/manifest.js +7 -23
- package/dist/bin/include/path.d.ts +1 -0
- package/dist/bin/include/path.js +4 -0
- package/dist/bin/include/process.d.ts +12 -0
- package/dist/bin/include/process.js +39 -0
- package/dist/bin/include/sendFinder.d.ts +6 -0
- package/dist/bin/include/sendFinder.js +100 -0
- package/dist/bin/include/utils.d.ts +3 -4
- package/dist/bin/include/utils.js +10 -12
- package/dist/bin/index.js +1 -1
- package/dist/bin/modifier/callbackReplacer.d.ts +2 -0
- package/dist/bin/modifier/callbackReplacer.js +97 -0
- package/dist/bin/modifier/importFinder.d.ts +9 -0
- package/dist/bin/modifier/importFinder.js +69 -0
- package/dist/bin/modifier/pageFinder.d.ts +9 -0
- package/dist/bin/modifier/pageFinder.js +135 -0
- package/dist/bin/modifier/sriptCommnet.d.ts +2 -0
- package/dist/bin/modifier/sriptCommnet.js +8 -0
- package/dist/bin/plugins/XanixAssets.d.ts +6 -0
- package/dist/bin/plugins/XanixAssets.js +43 -0
- package/dist/bin/plugins/XanixCss.d.ts +5 -0
- package/dist/bin/plugins/XanixCss.js +57 -0
- package/dist/bin/plugins/XanixDocument/XanixDocument.d.ts +2 -0
- package/dist/bin/plugins/XanixDocument/XanixDocument.js +50 -0
- package/dist/bin/plugins/XanixDocument/index.d.ts +2 -0
- package/dist/bin/plugins/XanixDocument/index.js +50 -0
- package/dist/bin/plugins/XanixDocument.d.ts +2 -0
- package/dist/bin/plugins/XanixDocument.js +39 -0
- package/dist/bin/plugins/XanixPageTransform-dep/index.d.ts +2 -0
- package/dist/bin/plugins/XanixPageTransform-dep/index.js +62 -0
- package/dist/bin/plugins/XanixPageTransform-dep/transformer.d.ts +23 -0
- package/dist/bin/plugins/XanixPageTransform-dep/transformer.js +589 -0
- package/dist/bin/plugins/XanixServerTransform.d.ts +5 -0
- package/dist/bin/plugins/XanixServerTransform.js +207 -0
- package/dist/bin/plugins/XanixTsconfigAlias.d.ts +19 -0
- package/dist/bin/plugins/XanixTsconfigAlias.js +197 -0
- package/dist/bin/plugins/XanixUseServer.d.ts +7 -0
- package/dist/bin/plugins/XanixUseServer.js +445 -0
- package/dist/bin/plugins/plugins.d.ts +8 -0
- package/dist/bin/plugins/plugins.js +31 -0
- package/dist/bin/types.d.ts +2 -8
- package/dist/client-runtime.d.ts +0 -8
- package/dist/client-runtime.js +45 -103
- package/dist/components/BaseDocument.d.ts +1 -1
- package/dist/components/BaseDocument.js +2 -2
- package/dist/components/Body.d.ts +3 -4
- package/dist/components/Body.js +4 -3
- package/dist/components/Document.d.ts +3 -4
- package/dist/components/Document.js +3 -4
- package/dist/components/DocumentContext.d.ts +5 -3
- package/dist/components/Head.d.ts +3 -2
- package/dist/components/Head.js +17 -10
- package/dist/components/Link.d.ts +2 -2
- package/dist/components/Link.js +14 -26
- package/dist/dev.d.ts +1 -0
- package/dist/dev.js +25 -0
- package/dist/hooks/cache.d.ts +19 -0
- package/dist/hooks/cache.js +53 -0
- package/dist/hooks/encript.d.ts +2 -0
- package/dist/hooks/encript.js +30 -0
- package/dist/hooks/server.d.ts +11 -0
- package/dist/hooks/server.js +129 -0
- package/dist/hooks/session.d.ts +18 -0
- package/dist/hooks/session.js +145 -0
- package/dist/hooks/useCookies.d.ts +1 -0
- package/dist/hooks/useCookies.js +9 -40
- package/dist/hooks/usePage.d.ts +2 -2
- package/dist/hooks/usePage.js +2 -5
- package/dist/hooks/useSearchParams.js +30 -88
- package/dist/hooks/useServer.d.ts +20 -0
- package/dist/hooks/useServer.js +91 -0
- package/dist/hooks/useStore.d.ts +13 -0
- package/dist/hooks/useStore.js +45 -0
- package/dist/index.d.ts +19 -6
- package/dist/index.js +11 -7
- package/dist/navigate.d.ts +4 -6
- package/dist/navigate.js +109 -17
- package/dist/outdirs.d.ts +1 -1
- package/dist/outdirs.js +2 -2
- package/dist/react/createContext.d.ts +3 -0
- package/dist/react/createContext.js +11 -0
- package/dist/react/index.d.ts +12 -0
- package/dist/react/index.js +3 -0
- package/dist/server/express/Router.d.ts +2 -0
- package/dist/server/express/Router.js +115 -0
- package/dist/server/express/Ruter.d.ts +2 -0
- package/dist/server/express/Ruter.js +15 -0
- package/dist/server/express/index.d.ts +3 -0
- package/dist/server/express/index.js +90 -0
- package/dist/server/express/page.d.ts +10 -0
- package/dist/server/express/page.js +133 -0
- package/dist/server/index.d.ts +19 -0
- package/dist/server/index.js +44 -1
- package/dist/server/runtime/createServer.js +2 -0
- package/dist/server/runtime/readManifest.js +1 -1
- package/dist/server/runtime/xanixPage.js +9 -15
- package/dist/server/types.d.ts +52 -0
- package/dist/server/types.js +1 -0
- package/dist/types/assets.d.ts +72 -34
- package/dist/types/express.d.ts +11 -7
- package/dist/types/globals.d.ts +18 -26
- package/dist/types/xanix-virtual.d.ts +35 -41
- package/package.json +60 -72
- package/dist/bin/bundler/cacheNpmModules.d.ts +0 -11
- package/dist/bin/bundler/dep-generateClientEntries.d.ts +0 -5
- package/dist/bin/bundler/dep-generateClientEntries.js +0 -25
- package/dist/bin/bundler/generateClientEntries.d.ts +0 -5
- package/dist/bin/bundler/generateClientEntries.js +0 -25
- package/dist/bin/bundler/plugins/xanixUseDataId.d.ts +0 -4
- package/dist/bin/bundler/plugins/xanixUseDataId.js +0 -93
- package/dist/bin/cli/browser.d.ts +0 -1
- package/dist/bin/cli/browser.js +0 -97
- package/dist/dataLoader.d.ts +0 -11
- package/dist/dataLoader.js +0 -52
- package/dist/hooks/useData.d.ts +0 -14
- package/dist/hooks/useData.js +0 -68
- package/dist/hooks/useRequest copy.d.ts +0 -2
- package/dist/hooks/useRequest copy.js +0 -8
- package/dist/hooks/useServer/core.d.ts +0 -20
- package/dist/hooks/useServer/core.js +0 -72
- package/dist/hooks/useServer/index.d.ts +0 -20
- package/dist/hooks/useServer/index.js +0 -76
- package/dist/hooks/useServer/registry.d.ts +0 -0
- package/dist/hooks/useServer/registry.js +0 -1
- package/dist/hooks/useServer/resource.d.ts +0 -11
- package/dist/hooks/useServer/resource.js +0 -49
- package/dist/hooks/useServer/state.d.ts +0 -9
- package/dist/hooks/useServer/state.js +0 -33
- package/dist/theme.d.ts +0 -3
- package/dist/theme.js +0 -10
- /package/dist/bin/{browser.d.ts → cli/start/utils.d.ts} +0 -0
- /package/dist/bin/{browser.js → cli/start/utils.js} +0 -0
|
@@ -22,27 +22,28 @@ const client = (entries, { isDev }) => {
|
|
|
22
22
|
}
|
|
23
23
|
else {
|
|
24
24
|
opt.chunkFileNames = "chunks/[hash].js";
|
|
25
|
-
opt.assetFileNames = "assets/[name]
|
|
25
|
+
opt.assetFileNames = "assets/[name][extname]";
|
|
26
26
|
}
|
|
27
27
|
return opt;
|
|
28
28
|
};
|
|
29
29
|
const server = (opt) => {
|
|
30
|
-
|
|
30
|
+
const options = {
|
|
31
31
|
dir: outdirs.server,
|
|
32
32
|
format: "esm",
|
|
33
|
-
sourcemap: opt.isDev ?? true,
|
|
34
33
|
entryFileNames: "[name].js",
|
|
35
34
|
chunkFileNames: "chunks/[name].js",
|
|
36
|
-
assetFileNames: "assets/[
|
|
37
|
-
// manualChunks(id) {
|
|
38
|
-
// const filename = path.basename(id);
|
|
39
|
-
// return filename.split(".")[0];
|
|
40
|
-
// return "vendor";
|
|
41
|
-
// if (id.includes("virtual:xanix-document")) {
|
|
42
|
-
// return "vendor";
|
|
43
|
-
// }
|
|
44
|
-
// },
|
|
35
|
+
assetFileNames: "assets/[name][extname]",
|
|
45
36
|
};
|
|
37
|
+
if (opt.isDev) {
|
|
38
|
+
options.sourcemap = true;
|
|
39
|
+
// options.preserveModules = true;
|
|
40
|
+
// options.preserveModulesRoot = process.cwd();
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
options.chunkFileNames = "chunks/[hash].js";
|
|
44
|
+
options.assetFileNames = "assets/[name][extname]";
|
|
45
|
+
}
|
|
46
|
+
return options;
|
|
46
47
|
};
|
|
47
48
|
const bundlerOutput = {
|
|
48
49
|
client,
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import { rolldown } from "rolldown";
|
|
4
|
+
import loadEnv from "../include/loadEnv.js";
|
|
5
|
+
import { tsconfigPathsMatcher } from "../plugins/XanixTsconfigAlias.js";
|
|
6
|
+
import { builtinModules } from "module";
|
|
7
|
+
const nodeBuiltins = new Set(builtinModules);
|
|
8
|
+
function isNodeBuiltin(id) {
|
|
9
|
+
const normalized = id.startsWith("node:") ? id.slice(5) : id;
|
|
10
|
+
return nodeBuiltins.has(normalized);
|
|
11
|
+
}
|
|
12
|
+
const makeFilename = (id) => {
|
|
13
|
+
let root = process.cwd().replace(/\\/g, "/").replace(/\/+/g, "/");
|
|
14
|
+
id = id
|
|
15
|
+
.trim()
|
|
16
|
+
.replace(/\\/g, "/")
|
|
17
|
+
.replace(/\/+/g, "-")
|
|
18
|
+
.replace(`${root}/`, "")
|
|
19
|
+
.replace("node_modules/", "")
|
|
20
|
+
.toLowerCase()
|
|
21
|
+
.split("?")[0];
|
|
22
|
+
return id;
|
|
23
|
+
};
|
|
24
|
+
function isPackageImport(source) {
|
|
25
|
+
// Relative import
|
|
26
|
+
if (source.startsWith("./") || source.startsWith("../")) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
// Absolute filesystem path
|
|
30
|
+
if (source.startsWith("/") || /^[A-Za-z]:[\\/]/.test(source)) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
// URL / virtual module
|
|
34
|
+
if (source.startsWith("node:") ||
|
|
35
|
+
source.includes(":") ||
|
|
36
|
+
source.startsWith("\0")) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
// Everything else is a bare package specifier
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
const writeManifest = async (cached) => {
|
|
43
|
+
const file = path.resolve("node_modules/xanix-cache/manifest.json");
|
|
44
|
+
let manifest = {};
|
|
45
|
+
for (const [key, value] of cached.entries()) {
|
|
46
|
+
manifest[key] = value;
|
|
47
|
+
}
|
|
48
|
+
await fs.promises.writeFile(file, JSON.stringify(manifest, null, 2));
|
|
49
|
+
};
|
|
50
|
+
const readManifest = async () => {
|
|
51
|
+
const file = path.resolve("node_modules/xanix-cache/manifest.json");
|
|
52
|
+
if (!fs.existsSync(file)) {
|
|
53
|
+
return new Map();
|
|
54
|
+
}
|
|
55
|
+
const content = await fs.promises.readFile(file, "utf-8");
|
|
56
|
+
const parsed = JSON.parse(content);
|
|
57
|
+
const map = new Map(Object.entries(parsed));
|
|
58
|
+
return map;
|
|
59
|
+
};
|
|
60
|
+
const externalResolver = () => {
|
|
61
|
+
let initialBuild = false;
|
|
62
|
+
const cache = new Map();
|
|
63
|
+
return {
|
|
64
|
+
name: "externalResolver",
|
|
65
|
+
async buildStart() {
|
|
66
|
+
if (initialBuild) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
initialBuild = true;
|
|
70
|
+
const cacheDir = path.resolve("node_modules/xanix-cache");
|
|
71
|
+
// delete cache directory if it exists
|
|
72
|
+
if (fs.existsSync(cacheDir)) {
|
|
73
|
+
fs.rmSync(cacheDir, { recursive: true, force: true });
|
|
74
|
+
}
|
|
75
|
+
if (!fs.existsSync(cacheDir)) {
|
|
76
|
+
fs.mkdirSync(cacheDir, { recursive: true });
|
|
77
|
+
fs.writeFileSync(path.join(cacheDir, "package.json"), JSON.stringify({ type: "module" }));
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
async resolveId(source, importer) {
|
|
81
|
+
if (!importer) {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
if (source.startsWith("/xanix-cache")) {
|
|
85
|
+
return {
|
|
86
|
+
id: source,
|
|
87
|
+
external: true,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
return null;
|
|
91
|
+
// if (importer.includes("node_modules")) {
|
|
92
|
+
// return null;
|
|
93
|
+
// }
|
|
94
|
+
// if (source.startsWith("xanix")) {
|
|
95
|
+
// return null;
|
|
96
|
+
// }
|
|
97
|
+
// if (!isPackageImport(source)) {
|
|
98
|
+
// return null;
|
|
99
|
+
// }
|
|
100
|
+
// const name = makeFilename(source);
|
|
101
|
+
// cache.set(source, name);
|
|
102
|
+
// return {
|
|
103
|
+
// id: `xanix-cache/${name}.js`,
|
|
104
|
+
// external: true,
|
|
105
|
+
// };
|
|
106
|
+
},
|
|
107
|
+
transform(code) {
|
|
108
|
+
let changed = false;
|
|
109
|
+
const transformed = code.replace(/import\s*\{([^}]+)\}\s*from\s*(['"])([^'"]+)\2\s*;?/g, (match, imports, quote, source) => {
|
|
110
|
+
if (source.startsWith("xanix")) {
|
|
111
|
+
return match;
|
|
112
|
+
}
|
|
113
|
+
if (!isPackageImport(source)) {
|
|
114
|
+
return match;
|
|
115
|
+
}
|
|
116
|
+
const cleanSource = source.split("?")[0];
|
|
117
|
+
const name = makeFilename(cleanSource);
|
|
118
|
+
cache.set(cleanSource, name);
|
|
119
|
+
changed = true;
|
|
120
|
+
const localName = `_${name.replace(/[^a-zA-Z0-9_$]/g, "_")}`;
|
|
121
|
+
const declarations = imports
|
|
122
|
+
.split(",")
|
|
123
|
+
.map((item) => {
|
|
124
|
+
const [imported, local] = item
|
|
125
|
+
.trim()
|
|
126
|
+
.split(/\s+as\s+/)
|
|
127
|
+
.map((x) => x.trim());
|
|
128
|
+
return local ? `${imported}: ${local}` : imported;
|
|
129
|
+
})
|
|
130
|
+
.join(", ");
|
|
131
|
+
return [
|
|
132
|
+
`import ${localName} from ${quote}/xanix-cache/${name}.js${quote};`,
|
|
133
|
+
`const { ${declarations} } = ${localName};`,
|
|
134
|
+
].join("\n");
|
|
135
|
+
});
|
|
136
|
+
if (!changed) {
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
return {
|
|
140
|
+
code: transformed,
|
|
141
|
+
map: null,
|
|
142
|
+
};
|
|
143
|
+
},
|
|
144
|
+
async generateBundle() {
|
|
145
|
+
let manifest = await readManifest();
|
|
146
|
+
let changed = false;
|
|
147
|
+
const input = {};
|
|
148
|
+
for (const [source, name] of cache.entries()) {
|
|
149
|
+
input[name] = source;
|
|
150
|
+
if (!manifest.has(source)) {
|
|
151
|
+
manifest.set(source, name);
|
|
152
|
+
changed = true;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
if (!changed) {
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
const build = await rolldown({
|
|
159
|
+
input,
|
|
160
|
+
treeshake: true,
|
|
161
|
+
platform: "node",
|
|
162
|
+
tsconfig: true,
|
|
163
|
+
checks: {
|
|
164
|
+
moduleLevelDirective: false,
|
|
165
|
+
},
|
|
166
|
+
resolve: {
|
|
167
|
+
extensions: [".mjs", ".js", ".jsx", ".json", ".ts", ".tsx"],
|
|
168
|
+
conditionNames: ["node", "import", "module", "default"],
|
|
169
|
+
},
|
|
170
|
+
transform: {
|
|
171
|
+
target: "node20",
|
|
172
|
+
jsx: {
|
|
173
|
+
runtime: "automatic",
|
|
174
|
+
},
|
|
175
|
+
define: await loadEnv({
|
|
176
|
+
mode: "development",
|
|
177
|
+
isClient: false,
|
|
178
|
+
}),
|
|
179
|
+
},
|
|
180
|
+
external(id) {
|
|
181
|
+
if (isNodeBuiltin(id)) {
|
|
182
|
+
return true;
|
|
183
|
+
}
|
|
184
|
+
if (id === "is-promise") {
|
|
185
|
+
return true;
|
|
186
|
+
}
|
|
187
|
+
if (id === "virtual:xanix-document" || tsconfigPathsMatcher(id)) {
|
|
188
|
+
return false;
|
|
189
|
+
}
|
|
190
|
+
return false;
|
|
191
|
+
},
|
|
192
|
+
});
|
|
193
|
+
await build.write({
|
|
194
|
+
dir: "node_modules/xanix-cache",
|
|
195
|
+
format: "es",
|
|
196
|
+
entryFileNames: "[name].js",
|
|
197
|
+
});
|
|
198
|
+
await build.close();
|
|
199
|
+
await writeManifest(manifest);
|
|
200
|
+
},
|
|
201
|
+
};
|
|
202
|
+
};
|
|
203
|
+
export default externalResolver;
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import { rolldown } from "rolldown";
|
|
4
|
+
import loadEnv from "./config/loadEnv.js";
|
|
5
|
+
import { tsconfigPathsMatcher } from "./plugins/XanixTsconfigAlias.js";
|
|
6
|
+
import { builtinModules } from "module";
|
|
7
|
+
const nodeBuiltins = new Set(builtinModules);
|
|
8
|
+
function isNodeBuiltin(id) {
|
|
9
|
+
const normalized = id.startsWith("node:") ? id.slice(5) : id;
|
|
10
|
+
return nodeBuiltins.has(normalized);
|
|
11
|
+
}
|
|
12
|
+
const makeFilename = (id) => {
|
|
13
|
+
let root = process.cwd().replace(/\\/g, "/").replace(/\/+/g, "/");
|
|
14
|
+
id = id
|
|
15
|
+
.trim()
|
|
16
|
+
.replace(/\\/g, "/")
|
|
17
|
+
.replace(/\/+/g, "-")
|
|
18
|
+
.replace(`${root}/`, "")
|
|
19
|
+
.replace("node_modules/", "")
|
|
20
|
+
.toLowerCase()
|
|
21
|
+
.split("?")[0];
|
|
22
|
+
return id;
|
|
23
|
+
};
|
|
24
|
+
function isPackageImport(source) {
|
|
25
|
+
// Relative import
|
|
26
|
+
if (source.startsWith("./") || source.startsWith("../")) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
// Absolute filesystem path
|
|
30
|
+
if (source.startsWith("/") || /^[A-Za-z]:[\\/]/.test(source)) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
// URL / virtual module
|
|
34
|
+
if (source.startsWith("node:") ||
|
|
35
|
+
source.includes(":") ||
|
|
36
|
+
source.startsWith("\0")) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
// Everything else is a bare package specifier
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
const writeManifest = async (cached) => {
|
|
43
|
+
const file = path.resolve("node_modules/xanix-cache/manifest.json");
|
|
44
|
+
let manifest = {};
|
|
45
|
+
for (const [key, value] of cached.entries()) {
|
|
46
|
+
manifest[key] = value;
|
|
47
|
+
}
|
|
48
|
+
await fs.promises.writeFile(file, JSON.stringify(manifest, null, 2));
|
|
49
|
+
};
|
|
50
|
+
const readManifest = async () => {
|
|
51
|
+
const file = path.resolve("node_modules/xanix-cache/manifest.json");
|
|
52
|
+
if (!fs.existsSync(file)) {
|
|
53
|
+
return new Map();
|
|
54
|
+
}
|
|
55
|
+
const content = await fs.promises.readFile(file, "utf-8");
|
|
56
|
+
const parsed = JSON.parse(content);
|
|
57
|
+
const map = new Map(Object.entries(parsed));
|
|
58
|
+
return map;
|
|
59
|
+
};
|
|
60
|
+
const externalResolver = () => {
|
|
61
|
+
let initialBuild = false;
|
|
62
|
+
const cache = new Map();
|
|
63
|
+
return {
|
|
64
|
+
name: "externalResolver",
|
|
65
|
+
async buildStart() {
|
|
66
|
+
if (initialBuild) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
initialBuild = true;
|
|
70
|
+
const cacheDir = path.resolve("node_modules/xanix-cache");
|
|
71
|
+
// delete cache directory if it exists
|
|
72
|
+
if (fs.existsSync(cacheDir)) {
|
|
73
|
+
fs.rmSync(cacheDir, { recursive: true, force: true });
|
|
74
|
+
}
|
|
75
|
+
if (!fs.existsSync(cacheDir)) {
|
|
76
|
+
fs.mkdirSync(cacheDir, { recursive: true });
|
|
77
|
+
fs.writeFileSync(path.join(cacheDir, "package.json"), JSON.stringify({ type: "module" }));
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
async resolveId(source, importer) {
|
|
81
|
+
if (!importer) {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
if (source.startsWith("/xanix-cache")) {
|
|
85
|
+
return {
|
|
86
|
+
id: source,
|
|
87
|
+
external: true,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
return null;
|
|
91
|
+
// if (importer.includes("node_modules")) {
|
|
92
|
+
// return null;
|
|
93
|
+
// }
|
|
94
|
+
// if (source.startsWith("xanix")) {
|
|
95
|
+
// return null;
|
|
96
|
+
// }
|
|
97
|
+
// if (!isPackageImport(source)) {
|
|
98
|
+
// return null;
|
|
99
|
+
// }
|
|
100
|
+
// const name = makeFilename(source);
|
|
101
|
+
// cache.set(source, name);
|
|
102
|
+
// return {
|
|
103
|
+
// id: `xanix-cache/${name}.js`,
|
|
104
|
+
// external: true,
|
|
105
|
+
// };
|
|
106
|
+
},
|
|
107
|
+
transform(code) {
|
|
108
|
+
let changed = false;
|
|
109
|
+
const transformed = code.replace(/import\s*\{([^}]+)\}\s*from\s*(['"])([^'"]+)\2\s*;?/g, (match, imports, quote, source) => {
|
|
110
|
+
if (source.startsWith("xanix")) {
|
|
111
|
+
return match;
|
|
112
|
+
}
|
|
113
|
+
if (!isPackageImport(source)) {
|
|
114
|
+
return match;
|
|
115
|
+
}
|
|
116
|
+
const cleanSource = source.split("?")[0];
|
|
117
|
+
const name = makeFilename(cleanSource);
|
|
118
|
+
cache.set(cleanSource, name);
|
|
119
|
+
changed = true;
|
|
120
|
+
const localName = `_${name.replace(/[^a-zA-Z0-9_$]/g, "_")}`;
|
|
121
|
+
const declarations = imports
|
|
122
|
+
.split(",")
|
|
123
|
+
.map((item) => {
|
|
124
|
+
const [imported, local] = item
|
|
125
|
+
.trim()
|
|
126
|
+
.split(/\s+as\s+/)
|
|
127
|
+
.map((x) => x.trim());
|
|
128
|
+
return local ? `${imported}: ${local}` : imported;
|
|
129
|
+
})
|
|
130
|
+
.join(", ");
|
|
131
|
+
return [
|
|
132
|
+
`import ${localName} from ${quote}/xanix-cache/${name}.js${quote};`,
|
|
133
|
+
`const { ${declarations} } = ${localName};`,
|
|
134
|
+
].join("\n");
|
|
135
|
+
});
|
|
136
|
+
if (!changed) {
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
return {
|
|
140
|
+
code: transformed,
|
|
141
|
+
map: null,
|
|
142
|
+
};
|
|
143
|
+
},
|
|
144
|
+
async generateBundle() {
|
|
145
|
+
let manifest = await readManifest();
|
|
146
|
+
let changed = false;
|
|
147
|
+
const input = {};
|
|
148
|
+
for (const [source, name] of cache.entries()) {
|
|
149
|
+
input[name] = source;
|
|
150
|
+
if (!manifest.has(source)) {
|
|
151
|
+
manifest.set(source, name);
|
|
152
|
+
changed = true;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
if (!changed) {
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
const build = await rolldown({
|
|
159
|
+
input,
|
|
160
|
+
treeshake: true,
|
|
161
|
+
platform: "node",
|
|
162
|
+
tsconfig: true,
|
|
163
|
+
checks: {
|
|
164
|
+
moduleLevelDirective: false,
|
|
165
|
+
},
|
|
166
|
+
resolve: {
|
|
167
|
+
extensions: [".mjs", ".js", ".jsx", ".json", ".ts", ".tsx"],
|
|
168
|
+
conditionNames: ["node", "import", "module", "default"],
|
|
169
|
+
},
|
|
170
|
+
transform: {
|
|
171
|
+
target: "node20",
|
|
172
|
+
jsx: {
|
|
173
|
+
runtime: "automatic",
|
|
174
|
+
},
|
|
175
|
+
define: await loadEnv({
|
|
176
|
+
mode: "development",
|
|
177
|
+
isClient: false,
|
|
178
|
+
}),
|
|
179
|
+
},
|
|
180
|
+
external(id) {
|
|
181
|
+
if (isNodeBuiltin(id)) {
|
|
182
|
+
return true;
|
|
183
|
+
}
|
|
184
|
+
if (id === "is-promise") {
|
|
185
|
+
return true;
|
|
186
|
+
}
|
|
187
|
+
if (id === "virtual:xanix-document" || tsconfigPathsMatcher(id)) {
|
|
188
|
+
return false;
|
|
189
|
+
}
|
|
190
|
+
return false;
|
|
191
|
+
},
|
|
192
|
+
});
|
|
193
|
+
await build.write({
|
|
194
|
+
dir: "node_modules/xanix-cache",
|
|
195
|
+
format: "es",
|
|
196
|
+
entryFileNames: "[name].js",
|
|
197
|
+
});
|
|
198
|
+
await build.close();
|
|
199
|
+
await writeManifest(manifest);
|
|
200
|
+
},
|
|
201
|
+
};
|
|
202
|
+
};
|
|
203
|
+
export default externalResolver;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
class TransformExpress {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.replacements = [];
|
|
4
|
+
}
|
|
5
|
+
transform(node) {
|
|
6
|
+
if (node.type === "ImportDeclaration" && node.source.value === "express") {
|
|
7
|
+
this.replacements.push({
|
|
8
|
+
start: node.source.start + 1,
|
|
9
|
+
end: node.source.end - 1,
|
|
10
|
+
value: "xanix/express",
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
// check require express
|
|
14
|
+
if (node.type === "CallExpression" &&
|
|
15
|
+
node.callee.name === "require" &&
|
|
16
|
+
node.arguments.length === 1 &&
|
|
17
|
+
node.arguments[0].value === "express") {
|
|
18
|
+
this.replacements.push({
|
|
19
|
+
start: node.arguments[0].start + 1,
|
|
20
|
+
end: node.arguments[0].end - 1,
|
|
21
|
+
value: "xanix/express",
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export default TransformExpress;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
type Name = string;
|
|
2
|
+
type Entry = {
|
|
3
|
+
name: string;
|
|
4
|
+
id: string;
|
|
5
|
+
source: string;
|
|
6
|
+
resolved: string;
|
|
7
|
+
};
|
|
8
|
+
declare class TransformPage {
|
|
9
|
+
_replacements: {
|
|
10
|
+
start: number;
|
|
11
|
+
end: number;
|
|
12
|
+
value: string;
|
|
13
|
+
}[];
|
|
14
|
+
imports: Map<Name, string>;
|
|
15
|
+
entries: Entry[];
|
|
16
|
+
private identifiers;
|
|
17
|
+
get replacements(): {
|
|
18
|
+
start: number;
|
|
19
|
+
end: number;
|
|
20
|
+
value: string;
|
|
21
|
+
}[];
|
|
22
|
+
uid(source: string): string;
|
|
23
|
+
transform(node: any): void;
|
|
24
|
+
}
|
|
25
|
+
export default TransformPage;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import crypto from "node:crypto";
|
|
2
|
+
class TransformPage {
|
|
3
|
+
constructor() {
|
|
4
|
+
this._replacements = [];
|
|
5
|
+
this.imports = new Map();
|
|
6
|
+
this.entries = [];
|
|
7
|
+
this.identifiers = [];
|
|
8
|
+
}
|
|
9
|
+
get replacements() {
|
|
10
|
+
for (const identifier of this.identifiers) {
|
|
11
|
+
const source = this.imports.get(identifier.name);
|
|
12
|
+
if (source) {
|
|
13
|
+
const id = this.uid(source);
|
|
14
|
+
this.entries.push({
|
|
15
|
+
name: identifier.name,
|
|
16
|
+
id,
|
|
17
|
+
source,
|
|
18
|
+
resolved: "",
|
|
19
|
+
});
|
|
20
|
+
this._replacements.push({
|
|
21
|
+
start: identifier.placement,
|
|
22
|
+
end: identifier.placement,
|
|
23
|
+
value: ` __xpage={{ id: "${id}", name: "${identifier.name}" }} `,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return this._replacements;
|
|
28
|
+
}
|
|
29
|
+
uid(source) {
|
|
30
|
+
return crypto
|
|
31
|
+
.createHash("sha256")
|
|
32
|
+
.update(source)
|
|
33
|
+
.digest("hex")
|
|
34
|
+
.slice(0, 12);
|
|
35
|
+
}
|
|
36
|
+
transform(node) {
|
|
37
|
+
/*
|
|
38
|
+
res.send(<Home />) to
|
|
39
|
+
res.send(__xpage({
|
|
40
|
+
id: uid,
|
|
41
|
+
component: Home,
|
|
42
|
+
props: {},
|
|
43
|
+
request: req,
|
|
44
|
+
response: res,
|
|
45
|
+
}))
|
|
46
|
+
*/
|
|
47
|
+
if (node.type === "CallExpression" &&
|
|
48
|
+
node.callee.property?.name === "send" &&
|
|
49
|
+
node.arguments.length === 1 &&
|
|
50
|
+
node.arguments[0].type === "JSXElement") {
|
|
51
|
+
const element = node.arguments[0].openingElement;
|
|
52
|
+
const ComponentName = element.name.name;
|
|
53
|
+
const attrs = element.attributes;
|
|
54
|
+
let end = attrs.length > 0 ? attrs[attrs.length - 1].end : element.name.end;
|
|
55
|
+
this.identifiers.push({
|
|
56
|
+
placement: end,
|
|
57
|
+
name: ComponentName,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
// find static imports and add them to this.imports array
|
|
61
|
+
if (node.type === "ImportDeclaration" &&
|
|
62
|
+
node.specifiers.length > 0 &&
|
|
63
|
+
node.specifiers[0].type === "ImportDefaultSpecifier") {
|
|
64
|
+
const source = node.source.value;
|
|
65
|
+
const specifier = node.specifiers[0].local.name;
|
|
66
|
+
this.imports.set(specifier, source);
|
|
67
|
+
}
|
|
68
|
+
// find rfom require
|
|
69
|
+
if (node.type === "VariableDeclaration" &&
|
|
70
|
+
node.declarations.length === 1 &&
|
|
71
|
+
node.declarations[0].init?.type === "CallExpression" &&
|
|
72
|
+
node.declarations[0].init.callee.name === "require") {
|
|
73
|
+
const source = node.declarations[0].init.arguments[0].value;
|
|
74
|
+
const specifier = node.declarations[0].id.name;
|
|
75
|
+
this.imports.set(specifier, source);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
export default TransformPage;
|