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
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { builtinModules } from "node:module";
|
|
2
|
+
import { isPackageImport, makeFilename } from "../../../cache/utils.js";
|
|
3
|
+
const nodeBuiltins = new Set(builtinModules);
|
|
4
|
+
function isNodeBuiltin(id) {
|
|
5
|
+
const normalized = id.startsWith("node:") ? id.slice(5) : id;
|
|
6
|
+
return nodeBuiltins.has(normalized);
|
|
7
|
+
}
|
|
8
|
+
function makeImportName(name) {
|
|
9
|
+
return `require_${name.replace(/[^a-zA-Z0-9_$]/g, "_")}`;
|
|
10
|
+
}
|
|
11
|
+
function getCachePath(moduleName) {
|
|
12
|
+
const safeName = moduleName
|
|
13
|
+
.replace(/^@/, "")
|
|
14
|
+
.replace(/[\/\\]/g, "_")
|
|
15
|
+
.replace(/[^a-zA-Z0-9_$.-]/g, "_");
|
|
16
|
+
return `/cache/${safeName}.js`;
|
|
17
|
+
}
|
|
18
|
+
class TransformModuleCache {
|
|
19
|
+
constructor(cached) {
|
|
20
|
+
this.packages = [];
|
|
21
|
+
this.replacements = [];
|
|
22
|
+
this.cacheChanged = false;
|
|
23
|
+
this.cached = cached;
|
|
24
|
+
}
|
|
25
|
+
transform(node) {
|
|
26
|
+
if (node.type !== "ImportDeclaration" || node.importKind === "type") {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const source = node.source.value;
|
|
30
|
+
if (typeof source !== "string" ||
|
|
31
|
+
!isPackageImport(source) ||
|
|
32
|
+
source === "xanix" ||
|
|
33
|
+
isNodeBuiltin(source)) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
/*
|
|
37
|
+
* Don't add the same package multiple times
|
|
38
|
+
* when the file imports it more than once.
|
|
39
|
+
*/
|
|
40
|
+
if (!this.packages.includes(source)) {
|
|
41
|
+
this.packages.push(source);
|
|
42
|
+
}
|
|
43
|
+
const name = makeFilename(source);
|
|
44
|
+
const importName = makeImportName(name);
|
|
45
|
+
const cachePath = `/xanix-cache/${name}.js`;
|
|
46
|
+
const lines = [];
|
|
47
|
+
const specifiers = (node.specifiers ?? []).filter((specifier) => specifier.importKind !== "type");
|
|
48
|
+
if (!specifiers.length) {
|
|
49
|
+
lines.push(`import "${cachePath}";`);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
const defaultSpecifier = specifiers.find((specifier) => specifier.type === "ImportDefaultSpecifier");
|
|
53
|
+
const namespaceSpecifier = specifiers.find((specifier) => specifier.type === "ImportNamespaceSpecifier");
|
|
54
|
+
const namedSpecifiers = specifiers.filter((specifier) => specifier.type === "ImportSpecifier");
|
|
55
|
+
/*
|
|
56
|
+
* Only import default when the original import
|
|
57
|
+
* actually has a default import.
|
|
58
|
+
*/
|
|
59
|
+
if (defaultSpecifier) {
|
|
60
|
+
lines.push(`import ${importName} from "${cachePath}";`);
|
|
61
|
+
lines.push(`const ${defaultSpecifier.local.name} = ${importName};`);
|
|
62
|
+
}
|
|
63
|
+
/*
|
|
64
|
+
* Namespace and named imports use the Xanix
|
|
65
|
+
* namespace export.
|
|
66
|
+
*/
|
|
67
|
+
if (namespaceSpecifier || namedSpecifiers.length) {
|
|
68
|
+
const namespaceName = `${importName}_ns`;
|
|
69
|
+
lines.push(`import { __xanix_namespace as ${namespaceName} } from "${cachePath}";`);
|
|
70
|
+
if (namespaceSpecifier) {
|
|
71
|
+
lines.push(`const ${namespaceSpecifier.local.name} = ${namespaceName};`);
|
|
72
|
+
}
|
|
73
|
+
if (namedSpecifiers.length) {
|
|
74
|
+
const properties = namedSpecifiers
|
|
75
|
+
.map((specifier) => {
|
|
76
|
+
const imported = specifier.imported?.type === "Identifier"
|
|
77
|
+
? specifier.imported.name
|
|
78
|
+
: specifier.imported?.value;
|
|
79
|
+
const local = specifier.local?.name;
|
|
80
|
+
if (!imported || !local) {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
if (imported !== local) {
|
|
84
|
+
if (typeof imported === "string" &&
|
|
85
|
+
!/^[$A-Z_a-z][$\w]*$/.test(imported)) {
|
|
86
|
+
return `${JSON.stringify(imported)}: ${local}`;
|
|
87
|
+
}
|
|
88
|
+
return `${imported}: ${local}`;
|
|
89
|
+
}
|
|
90
|
+
return imported;
|
|
91
|
+
})
|
|
92
|
+
.filter(Boolean)
|
|
93
|
+
.join(", ");
|
|
94
|
+
if (properties) {
|
|
95
|
+
lines.push(`const { ${properties} } = ${namespaceName};`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/*
|
|
101
|
+
* Add the package only once.
|
|
102
|
+
*/
|
|
103
|
+
if (!this.cached.has(source)) {
|
|
104
|
+
this.cacheChanged = true;
|
|
105
|
+
this.cached.set(source, {
|
|
106
|
+
module: source,
|
|
107
|
+
name,
|
|
108
|
+
resolved: "",
|
|
109
|
+
exports: [],
|
|
110
|
+
default: false,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
this.replacements.push({
|
|
114
|
+
start: node.start,
|
|
115
|
+
end: node.end,
|
|
116
|
+
value: lines.join("\n"),
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
export default TransformModuleCache;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { walk } from "oxc-walker";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import TransformServerAction from "./Transformer/TransformServerAction.js";
|
|
4
|
+
import TransformUseServer from "./Transformer/TransformUseServer.js";
|
|
5
|
+
import TransformCache from "./Transformer/TransformCache.js";
|
|
6
|
+
import crypto from "node:crypto";
|
|
7
|
+
function getParserLanguage(id) {
|
|
8
|
+
const cleanId = id.split("?")[0];
|
|
9
|
+
if (cleanId.endsWith(".tsx"))
|
|
10
|
+
return "tsx";
|
|
11
|
+
if (cleanId.endsWith(".ts"))
|
|
12
|
+
return "ts";
|
|
13
|
+
if (cleanId.endsWith(".jsx"))
|
|
14
|
+
return "jsx";
|
|
15
|
+
return "js";
|
|
16
|
+
}
|
|
17
|
+
const XanixTransformer = () => {
|
|
18
|
+
return {
|
|
19
|
+
name: "xanix-transform",
|
|
20
|
+
async transform(code, id) {
|
|
21
|
+
if (id.includes("node_modules")) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
const ext = path.extname(id);
|
|
25
|
+
if (ext !== ".tsx" && ext !== ".jsx") {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
const uid = crypto
|
|
29
|
+
.createHash("sha256")
|
|
30
|
+
.update(id)
|
|
31
|
+
.digest("hex")
|
|
32
|
+
.slice(0, 12);
|
|
33
|
+
const lang = getParserLanguage(id);
|
|
34
|
+
const ast = this.parse(code, { lang });
|
|
35
|
+
const transformServerAction = new TransformServerAction(code, id, uid);
|
|
36
|
+
const transformUseServer = new TransformUseServer(code, id, uid);
|
|
37
|
+
const transformCache = new TransformCache(code, id, uid);
|
|
38
|
+
// const transformModuleCache = new TransformModuleCache();
|
|
39
|
+
walk(ast, {
|
|
40
|
+
enter(node) {
|
|
41
|
+
transformServerAction.transform(node);
|
|
42
|
+
transformUseServer.transform(node);
|
|
43
|
+
transformCache.transform(node);
|
|
44
|
+
// transformModuleCache.transform(node);
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
let replacements = [...transformUseServer.replacements];
|
|
48
|
+
if (transformServerAction.serverImported) {
|
|
49
|
+
replacements = [...replacements, ...transformServerAction.replacements];
|
|
50
|
+
}
|
|
51
|
+
if (transformCache.cacheImported) {
|
|
52
|
+
replacements = [...replacements, ...transformCache.replacements];
|
|
53
|
+
}
|
|
54
|
+
const sorted = replacements.sort((a, b) => b.start - a.start);
|
|
55
|
+
for (const { start, end, value } of sorted) {
|
|
56
|
+
code = code.slice(0, start) + value + code.slice(end);
|
|
57
|
+
}
|
|
58
|
+
let needImport = !transformUseServer.serverImported;
|
|
59
|
+
const useServerCode = `
|
|
60
|
+
${needImport ? 'import * as __xanix from "xanix";' : ""}
|
|
61
|
+
${transformUseServer.serverCodes.join("\n")}
|
|
62
|
+
`;
|
|
63
|
+
return {
|
|
64
|
+
code: useServerCode + "\n" + code,
|
|
65
|
+
map: null,
|
|
66
|
+
};
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
export default XanixTransformer;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import stripComments from "../../../modifier/sriptCommnet.js";
|
|
2
|
+
import TransformCacheFunction from "./transformer/TransformCacheFunction.js";
|
|
3
|
+
import TransformCreateSession from "./transformer/TransformCreateSession.js";
|
|
4
|
+
import importFinder from "../../../modifier/importFinder.js";
|
|
5
|
+
import TransformServerFunction from "./transformer/TransformServerFunction.js";
|
|
6
|
+
import { uuid, frameworkDir } from "../../../include/utils.js";
|
|
7
|
+
const XanixTransformer = () => {
|
|
8
|
+
return {
|
|
9
|
+
name: "xanix-transform",
|
|
10
|
+
async transform(code, id) {
|
|
11
|
+
const xanixImports = importFinder(code, "xanix");
|
|
12
|
+
if (xanixImports.length || id.startsWith(frameworkDir)) {
|
|
13
|
+
const uid = uuid(id, 12);
|
|
14
|
+
code = stripComments(code);
|
|
15
|
+
code = TransformServerFunction(code, xanixImports, uid, id);
|
|
16
|
+
code = TransformCacheFunction(code, xanixImports, uid, id);
|
|
17
|
+
code = TransformCreateSession(code, xanixImports, uid, id);
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
code,
|
|
21
|
+
map: null,
|
|
22
|
+
};
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
export default XanixTransformer;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
const VIRTUAL_ID = "virtual:xanix-dev";
|
|
5
|
+
const RESOLVED_ID = "\0virtual:xanix-dev";
|
|
6
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
7
|
+
const filepath = path.resolve(path.resolve(__dirname, "../../../../dev.js"));
|
|
8
|
+
export default function VirtualDev(dev) {
|
|
9
|
+
return {
|
|
10
|
+
name: "xanix-dev",
|
|
11
|
+
resolveId(id) {
|
|
12
|
+
if (id === VIRTUAL_ID) {
|
|
13
|
+
return RESOLVED_ID;
|
|
14
|
+
}
|
|
15
|
+
return null;
|
|
16
|
+
},
|
|
17
|
+
async load(id) {
|
|
18
|
+
if (id !== RESOLVED_ID) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
if (!dev) {
|
|
22
|
+
return {
|
|
23
|
+
code: "",
|
|
24
|
+
map: null,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
const source = await fs.promises.readFile(filepath, "utf8");
|
|
28
|
+
return {
|
|
29
|
+
code: source,
|
|
30
|
+
map: null,
|
|
31
|
+
};
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { getManifest } from "../../../include/manifest.js";
|
|
2
|
+
const VIRTUAL_ID = "virtual:xanix-pages";
|
|
3
|
+
const RESOLVED_ID = "\0virtual:xanix-pages";
|
|
4
|
+
export default function XanixAppRoot() {
|
|
5
|
+
return {
|
|
6
|
+
name: "xanix-pages",
|
|
7
|
+
resolveId(id) {
|
|
8
|
+
if (id === VIRTUAL_ID) {
|
|
9
|
+
return RESOLVED_ID;
|
|
10
|
+
}
|
|
11
|
+
return null;
|
|
12
|
+
},
|
|
13
|
+
async load(id) {
|
|
14
|
+
if (id !== RESOLVED_ID) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
const clients = await getManifest();
|
|
18
|
+
const pages = [];
|
|
19
|
+
for (const client of clients) {
|
|
20
|
+
pages.push(`
|
|
21
|
+
pages[${JSON.stringify(client.id)}] = () =>
|
|
22
|
+
import(${JSON.stringify(client.resolved)});
|
|
23
|
+
`);
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
code: `
|
|
27
|
+
import React from "react";
|
|
28
|
+
const pages = {};
|
|
29
|
+
${pages.join("\n")}
|
|
30
|
+
export default pages;
|
|
31
|
+
`,
|
|
32
|
+
map: null,
|
|
33
|
+
moduleType: "js",
|
|
34
|
+
};
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import { getClientRuntimeFile } from "../../../include/utils.js";
|
|
4
|
+
export default function xanixReactRefresh() {
|
|
5
|
+
return {
|
|
6
|
+
name: "xanix-react-refresh",
|
|
7
|
+
load(id) {
|
|
8
|
+
if (path.resolve(id) !== getClientRuntimeFile()) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
const code = fs.readFileSync(id, "utf8");
|
|
12
|
+
const refreshCode = `
|
|
13
|
+
|
|
14
|
+
${code}
|
|
15
|
+
`;
|
|
16
|
+
return {
|
|
17
|
+
code: refreshCode,
|
|
18
|
+
map: null,
|
|
19
|
+
};
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import callbackReplacer from "../../../../modifier/callbackReplacer.js";
|
|
2
|
+
const cacheFunctionReplacer = (code, imports, uid) => {
|
|
3
|
+
let count = 0;
|
|
4
|
+
const replacer = (code, cb) => {
|
|
5
|
+
const replacedCode = callbackReplacer(code, cb, (args) => {
|
|
6
|
+
if (args[2])
|
|
7
|
+
return;
|
|
8
|
+
const id = uid + count++;
|
|
9
|
+
const fn = args[0];
|
|
10
|
+
const options = args[1] || "undefined";
|
|
11
|
+
return `${cb}(${fn}, ${options}, "${id}");`;
|
|
12
|
+
});
|
|
13
|
+
code = replacedCode;
|
|
14
|
+
return code;
|
|
15
|
+
};
|
|
16
|
+
for (let _import of imports) {
|
|
17
|
+
if (_import.namespace) {
|
|
18
|
+
code = replacer(code, `${_import.namespace}.cache`);
|
|
19
|
+
}
|
|
20
|
+
for (let sp of _import.specifiers) {
|
|
21
|
+
if (sp.imported === "cache") {
|
|
22
|
+
code = replacer(code, sp.local);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return code;
|
|
27
|
+
};
|
|
28
|
+
export default cacheFunctionReplacer;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import callbackReplacer from "../../../../modifier/callbackReplacer.js";
|
|
2
|
+
const serverFunctionReplacer = (code, imports, uid) => {
|
|
3
|
+
let count = 0;
|
|
4
|
+
const replacer = (code, cb) => {
|
|
5
|
+
const replacedCode = callbackReplacer(code, cb, (args) => {
|
|
6
|
+
if (args[2])
|
|
7
|
+
return;
|
|
8
|
+
const id = uid + count++;
|
|
9
|
+
const fn = args[0];
|
|
10
|
+
const options = args[1] || "undefined";
|
|
11
|
+
return `${cb}(undefined, ${options}, "${id}");`;
|
|
12
|
+
});
|
|
13
|
+
code = replacedCode;
|
|
14
|
+
return code;
|
|
15
|
+
};
|
|
16
|
+
for (let _import of imports) {
|
|
17
|
+
if (_import.namespace) {
|
|
18
|
+
code = replacer(code, `${_import.namespace}.server`);
|
|
19
|
+
}
|
|
20
|
+
for (let sp of _import.specifiers) {
|
|
21
|
+
if (sp.imported === "server") {
|
|
22
|
+
code = replacer(code, sp.local);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return code;
|
|
27
|
+
};
|
|
28
|
+
export default serverFunctionReplacer;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import callbackReplacer from "../../../../modifier/callbackReplacer.js";
|
|
2
|
+
const useServerReplacer = (code, imports) => {
|
|
3
|
+
if (!imports.length)
|
|
4
|
+
return code;
|
|
5
|
+
const importName = `__xanix_server_${Math.random().toString(36).substring(2, 3)}`;
|
|
6
|
+
let codes = [`import { server as ${importName} } from "xanix"`];
|
|
7
|
+
imports.push({
|
|
8
|
+
specifiers: [
|
|
9
|
+
{
|
|
10
|
+
imported: "server",
|
|
11
|
+
local: importName,
|
|
12
|
+
},
|
|
13
|
+
],
|
|
14
|
+
});
|
|
15
|
+
const replacer = (code, cb) => {
|
|
16
|
+
return callbackReplacer(code, cb, (args) => {
|
|
17
|
+
const fn = args[0];
|
|
18
|
+
const argString = args[1] ?? "undefined";
|
|
19
|
+
const options = args[2] || "undefined";
|
|
20
|
+
const varname = `_xserver_${Math.random().toString(36).substring(2, 7)}`;
|
|
21
|
+
const server_code = `const ${varname} = ${importName}(${fn}, ${options});`;
|
|
22
|
+
codes.push(server_code);
|
|
23
|
+
return `${cb}(${varname}, ${argString})`;
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
for (let _import of imports) {
|
|
27
|
+
if (_import.namespace) {
|
|
28
|
+
code = replacer(code, `${_import.namespace}.useServer`);
|
|
29
|
+
}
|
|
30
|
+
for (let sp of _import.specifiers) {
|
|
31
|
+
if (sp.imported === "useServer") {
|
|
32
|
+
code = replacer(code, sp.local);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return codes.join("\n") + "\n" + code;
|
|
37
|
+
};
|
|
38
|
+
export default useServerReplacer;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import loadEnv from "../../include/loadEnv.js";
|
|
2
|
+
import outdirs from "../../../outdirs.js";
|
|
3
|
+
const ClientWatchConfig = async (isDev = false) => {
|
|
4
|
+
return {
|
|
5
|
+
output: {
|
|
6
|
+
dir: outdirs.client,
|
|
7
|
+
format: "esm",
|
|
8
|
+
sourcemap: isDev,
|
|
9
|
+
preserveModules: false,
|
|
10
|
+
chunkFileNames: isDev ? "chunks/[name].js" : "chunks/[hash]c.js",
|
|
11
|
+
assetFileNames: "assets/[name][extname]",
|
|
12
|
+
entryFileNames: "runtime.js",
|
|
13
|
+
},
|
|
14
|
+
treeshake: true,
|
|
15
|
+
tsconfig: true,
|
|
16
|
+
checks: {
|
|
17
|
+
moduleLevelDirective: false,
|
|
18
|
+
},
|
|
19
|
+
resolve: {
|
|
20
|
+
extensions: [".mjs", ".js", ".jsx", ".json", ".ts", ".tsx"],
|
|
21
|
+
conditionNames: ["browser", "import", "module", "default"],
|
|
22
|
+
},
|
|
23
|
+
transform: {
|
|
24
|
+
target: "es2022",
|
|
25
|
+
jsx: {
|
|
26
|
+
runtime: "automatic",
|
|
27
|
+
refresh: true,
|
|
28
|
+
},
|
|
29
|
+
define: await loadEnv({
|
|
30
|
+
mode: isDev ? "development" : "production",
|
|
31
|
+
isClient: true,
|
|
32
|
+
}),
|
|
33
|
+
},
|
|
34
|
+
watch: {
|
|
35
|
+
clearScreen: false,
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
export default ClientWatchConfig;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type RolldownWatcher } from "rolldown";
|
|
2
|
+
import { XanixClientEntry } from "../../types.js";
|
|
3
|
+
type Option = {
|
|
4
|
+
onStart?: () => Promise<void>;
|
|
5
|
+
onChange?: (files: string[], duration: number, moduleToChunk: Map<string, string>, assets: Map<string, {
|
|
6
|
+
type: string;
|
|
7
|
+
path: string;
|
|
8
|
+
name: string;
|
|
9
|
+
}>) => Promise<void>;
|
|
10
|
+
onReady?: (duration: number, entries: XanixClientEntry[]) => Promise<void>;
|
|
11
|
+
};
|
|
12
|
+
declare const WatchClient: (options: Option) => Promise<RolldownWatcher>;
|
|
13
|
+
export default WatchClient;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { watch } from "rolldown";
|
|
2
|
+
import ClientWatchConfig from "./watch.config.js";
|
|
3
|
+
import { getManifest } from "../../include/manifest.js";
|
|
4
|
+
import { frameworkDir, normalizePath } from "../../include/utils.js";
|
|
5
|
+
import XanixCache from "../cache/index.js";
|
|
6
|
+
import xanixAssets from "../../plugins/XanixAssets.js";
|
|
7
|
+
import xanixTsconfigAlias from "../../plugins/XanixTsconfigAlias.js";
|
|
8
|
+
import xanixDocument from "../../plugins/XanixDocument.js";
|
|
9
|
+
import XanixTransformer from "./plugins/Transformer.js";
|
|
10
|
+
import XanixPages from "./plugins/XanixPages.js";
|
|
11
|
+
import path from "node:path";
|
|
12
|
+
const WatchClient = async (options) => {
|
|
13
|
+
const entries = await getManifest();
|
|
14
|
+
const config = await ClientWatchConfig(true);
|
|
15
|
+
const changedFiles = new Set();
|
|
16
|
+
const moduleToChunk = new Map();
|
|
17
|
+
const assets = new Map();
|
|
18
|
+
let isReady = false;
|
|
19
|
+
let start = 0;
|
|
20
|
+
const watcher = watch({
|
|
21
|
+
...config,
|
|
22
|
+
input: path.join(frameworkDir, "dist/client-runtime.js"),
|
|
23
|
+
plugins: [
|
|
24
|
+
XanixCache(),
|
|
25
|
+
XanixTransformer(),
|
|
26
|
+
xanixAssets(assets),
|
|
27
|
+
xanixTsconfigAlias(),
|
|
28
|
+
xanixDocument(),
|
|
29
|
+
XanixPages(),
|
|
30
|
+
{
|
|
31
|
+
name: "xanix-client",
|
|
32
|
+
async watchChange(id) {
|
|
33
|
+
changedFiles.add(normalizePath(id));
|
|
34
|
+
},
|
|
35
|
+
async buildStart() {
|
|
36
|
+
await options.onStart?.();
|
|
37
|
+
start = performance.now();
|
|
38
|
+
},
|
|
39
|
+
async generateBundle(_options, bundle) {
|
|
40
|
+
moduleToChunk.clear();
|
|
41
|
+
for (const output of Object.values(bundle)) {
|
|
42
|
+
if (output.type !== "chunk")
|
|
43
|
+
continue;
|
|
44
|
+
for (const id of Object.keys(output.modules)) {
|
|
45
|
+
moduleToChunk.set(normalizePath(id), output.fileName);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const duration = parseInt((performance.now() - start).toFixed(2));
|
|
49
|
+
if (!isReady) {
|
|
50
|
+
await options.onReady?.(duration, entries);
|
|
51
|
+
isReady = true;
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
await options.onChange?.(Array.from(changedFiles), duration, moduleToChunk, assets);
|
|
55
|
+
}
|
|
56
|
+
changedFiles.clear();
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
});
|
|
61
|
+
watcher.on("event", (event) => {
|
|
62
|
+
if (event.code === "ERROR") {
|
|
63
|
+
console.error("Build error:", event.error);
|
|
64
|
+
}
|
|
65
|
+
// if (event.code === "BUNDLE_END") {
|
|
66
|
+
// console.log(event.duration);
|
|
67
|
+
// }
|
|
68
|
+
});
|
|
69
|
+
return watcher;
|
|
70
|
+
};
|
|
71
|
+
export default WatchClient;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
declare const loadEnv: ({ mode, isClient, }: {
|
|
2
|
+
mode: "development" | "production";
|
|
3
|
+
isClient: boolean;
|
|
4
|
+
}) => Promise<{
|
|
5
|
+
"process.env.NODE_ENV": string;
|
|
6
|
+
__XANIX_PAGE_NAVIGATION_HEADER_VALUE__: string;
|
|
7
|
+
__XANIX_CLIENT_RUNTIME_FILE_NAME__: string;
|
|
8
|
+
__XANIX_CLIENT__: string;
|
|
9
|
+
__XANIX_SERVER__: string;
|
|
10
|
+
__XANIX_DEV__: string;
|
|
11
|
+
__XANIX_PROD__: string;
|
|
12
|
+
XANIX_NAVIGATE: string;
|
|
13
|
+
XANIX_NAVIGATE_START: string;
|
|
14
|
+
XANIX_NAVIGATE_END: string;
|
|
15
|
+
XANIX_NAVIGATE_RELOAD: string;
|
|
16
|
+
XANIX_PRELOAD: string;
|
|
17
|
+
XANIX_PRELOAD_START: string;
|
|
18
|
+
XANIX_PRELOAD_END: string;
|
|
19
|
+
}>;
|
|
20
|
+
export default loadEnv;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import dotenv from "dotenv";
|
|
4
|
+
import { getClientRuntimeFileName, uid } from "../../include/utils.js";
|
|
5
|
+
const HEARDER_VALUE = uid(Math.random().toString(36), 32);
|
|
6
|
+
const loadEnv = async ({ mode, isClient, }) => {
|
|
7
|
+
const root = process.cwd();
|
|
8
|
+
const publicPrefix = "PUBLIC_";
|
|
9
|
+
const envFiles = [
|
|
10
|
+
path.resolve(root, ".env"),
|
|
11
|
+
path.resolve(root, mode === "development" ? ".env.dev" : ".env.prod"),
|
|
12
|
+
];
|
|
13
|
+
const env = {};
|
|
14
|
+
for (const file of envFiles) {
|
|
15
|
+
if (!fs.existsSync(file)) {
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
18
|
+
const result = dotenv.parse(fs.readFileSync(file));
|
|
19
|
+
Object.assign(env, result);
|
|
20
|
+
}
|
|
21
|
+
const clientEnv = {};
|
|
22
|
+
const serverEnv = {};
|
|
23
|
+
for (const [key, value] of Object.entries(env)) {
|
|
24
|
+
if (key.startsWith(publicPrefix)) {
|
|
25
|
+
clientEnv[`process.env.${key}`] = JSON.stringify(value);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
serverEnv[`process.env.${key}`] = JSON.stringify(value);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
"process.env.NODE_ENV": JSON.stringify(mode),
|
|
33
|
+
__XANIX_PAGE_NAVIGATION_HEADER_VALUE__: JSON.stringify(HEARDER_VALUE),
|
|
34
|
+
__XANIX_CLIENT_RUNTIME_FILE_NAME__: JSON.stringify(getClientRuntimeFileName(mode)),
|
|
35
|
+
__XANIX_CLIENT__: isClient ? "true" : "false",
|
|
36
|
+
__XANIX_SERVER__: isClient ? "false" : "true",
|
|
37
|
+
__XANIX_DEV__: mode === "development" ? "true" : "false",
|
|
38
|
+
__XANIX_PROD__: mode === "production" ? "true" : "false",
|
|
39
|
+
XANIX_NAVIGATE: JSON.stringify("xanix:navigate"),
|
|
40
|
+
XANIX_NAVIGATE_START: JSON.stringify("xanix:navigate:start"),
|
|
41
|
+
XANIX_NAVIGATE_END: JSON.stringify("xanix:navigate:end"),
|
|
42
|
+
XANIX_NAVIGATE_RELOAD: JSON.stringify("xanix:navigate:reload"),
|
|
43
|
+
XANIX_PRELOAD: JSON.stringify("xanix:preload"),
|
|
44
|
+
XANIX_PRELOAD_START: JSON.stringify("xanix:preload:start"),
|
|
45
|
+
XANIX_PRELOAD_END: JSON.stringify("xanix:preload:end"),
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
export default loadEnv;
|