xanix 1.0.17 → 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 +20 -10
- 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 +142 -93
- 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 +67 -13
- package/dist/bin/cli/build.js +38 -10
- 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 -72
- 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/utils.d.ts +0 -0
- package/dist/bin/cli/start/utils.js +1 -0
- package/dist/bin/cli/start.js +18 -10
- 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/logger.d.ts +3 -6
- package/dist/bin/include/logger.js +4 -7
- 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/spinner.d.ts +9 -0
- package/dist/bin/include/spinner.js +27 -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 -0
- package/dist/server/runtime/createServer.js +13 -12
- 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 +60 -22
- package/dist/types/express.d.ts +8 -4
- package/dist/types/globals.d.ts +0 -8
- package/dist/types/xanix-virtual.d.ts +16 -22
- package/package.json +12 -24
- 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/dataLoader.d.ts +0 -11
- package/dist/dataLoader.js +0 -52
- package/dist/db/index.d.ts +0 -2
- package/dist/db/index.js +0 -1
- package/dist/db/test.d.ts +0 -2
- package/dist/db/test.js +0 -1
- package/dist/hooks/useData.d.ts +0 -14
- package/dist/hooks/useData.js +0 -67
- package/dist/hooks/useServer/context.d.ts +0 -7
- package/dist/hooks/useServer/context.js +0 -19
- 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/registerUseServer.d.ts +0 -3
- package/dist/hooks/useServer/registerUseServer.js +0 -5
- package/dist/hooks/useServer/registry.d.ts +0 -7
- package/dist/hooks/useServer/registry.js +0 -12
- 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/AppRoot.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import pages from "virtual:xanix-pages";
|
|
3
|
+
import Document from "virtual:xanix-document";
|
|
4
|
+
import { useState, useEffect } from "react";
|
|
5
|
+
import { DocumentProvider } from "./components/DocumentContext";
|
|
6
|
+
import xanix from "./server/index.js";
|
|
7
|
+
const AppRoot = ({ Component, doc }) => {
|
|
8
|
+
const [_document, setDocument] = useState(doc);
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
xanix.on("navigate:end", setDocument);
|
|
11
|
+
}, []);
|
|
12
|
+
const ComponentToRender = pages[_document.page.id] || Component;
|
|
13
|
+
return (_jsx(DocumentProvider, { value: _document, children: _jsx(Document, { children: _jsx(ComponentToRender, {}) }) }));
|
|
14
|
+
};
|
|
15
|
+
export default AppRoot;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function Caching(): Promise<void>;
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import { rolldown, watch } from "rolldown";
|
|
4
|
+
const root = process.cwd();
|
|
5
|
+
const appEntry = path.resolve(root, "src/index.ts");
|
|
6
|
+
const outDir = path.resolve(root, ".xanix");
|
|
7
|
+
const cacheDir = path.join(outDir, "cache");
|
|
8
|
+
function normalize(id) {
|
|
9
|
+
return id.replace(/\\/g, "/");
|
|
10
|
+
}
|
|
11
|
+
function isNodeModule(id) {
|
|
12
|
+
return normalize(id).includes("/node_modules/");
|
|
13
|
+
}
|
|
14
|
+
function getPackageName(id) {
|
|
15
|
+
const normalized = normalize(id);
|
|
16
|
+
const match = normalized.match(/\/node_modules\/((?:@[^/]+\/)?[^/]+)/);
|
|
17
|
+
if (!match) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
return match[1];
|
|
21
|
+
}
|
|
22
|
+
function getSafeEntryName(packageName) {
|
|
23
|
+
return packageName
|
|
24
|
+
.replace(/^@/, "")
|
|
25
|
+
.replace(/\//g, "-")
|
|
26
|
+
.replace(/[^a-zA-Z0-9._-]/g, "-");
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Finds the package root from a node_modules file.
|
|
30
|
+
*/
|
|
31
|
+
function getPackageRoot(id) {
|
|
32
|
+
const normalized = normalize(id);
|
|
33
|
+
const index = normalized.lastIndexOf("/node_modules/");
|
|
34
|
+
if (index === -1) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
const after = normalized.slice(index + "/node_modules/".length);
|
|
38
|
+
const parts = after.split("/");
|
|
39
|
+
if (parts[0].startsWith("@")) {
|
|
40
|
+
if (!parts[1]) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
return path.join(normalized.slice(0, index), "node_modules", parts[0], parts[1]);
|
|
44
|
+
}
|
|
45
|
+
return path.join(normalized.slice(0, index), "node_modules", parts[0]);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Plugin used only to discover node_modules dependencies.
|
|
49
|
+
*/
|
|
50
|
+
function discoverDependencies() {
|
|
51
|
+
const dependencies = new Map();
|
|
52
|
+
const plugin = {
|
|
53
|
+
name: "xanix-discover-dependencies",
|
|
54
|
+
resolveId(source, importer) {
|
|
55
|
+
if (!importer) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
return null;
|
|
59
|
+
},
|
|
60
|
+
load(id) {
|
|
61
|
+
if (!isNodeModule(id)) {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
const packageName = getPackageName(id);
|
|
65
|
+
if (!packageName) {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
if (!dependencies.has(packageName)) {
|
|
69
|
+
dependencies.set(packageName, id);
|
|
70
|
+
}
|
|
71
|
+
return null;
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
return {
|
|
75
|
+
plugin,
|
|
76
|
+
dependencies,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Build the input object dynamically.
|
|
81
|
+
*
|
|
82
|
+
* IMPORTANT:
|
|
83
|
+
*
|
|
84
|
+
* The dependencies need to become independent entries.
|
|
85
|
+
*/
|
|
86
|
+
async function createInputs() {
|
|
87
|
+
const discovered = new Map();
|
|
88
|
+
const plugin = {
|
|
89
|
+
name: "xanix-discover",
|
|
90
|
+
resolveId(source, importer) {
|
|
91
|
+
return null;
|
|
92
|
+
},
|
|
93
|
+
load(id) {
|
|
94
|
+
if (!isNodeModule(id)) {
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
const packageName = getPackageName(id);
|
|
98
|
+
if (packageName) {
|
|
99
|
+
discovered.set(packageName, id);
|
|
100
|
+
}
|
|
101
|
+
return null;
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
/*
|
|
105
|
+
* First build only to discover the dependency graph.
|
|
106
|
+
*/
|
|
107
|
+
const discoveryBundle = await rolldown({
|
|
108
|
+
input: appEntry,
|
|
109
|
+
plugins: [plugin],
|
|
110
|
+
});
|
|
111
|
+
await discoveryBundle.generate({
|
|
112
|
+
format: "esm",
|
|
113
|
+
});
|
|
114
|
+
/*
|
|
115
|
+
* Add the application entry.
|
|
116
|
+
*/
|
|
117
|
+
const inputs = {
|
|
118
|
+
app: appEntry,
|
|
119
|
+
};
|
|
120
|
+
/*
|
|
121
|
+
* Add each discovered npm package as an independent entry.
|
|
122
|
+
*/
|
|
123
|
+
for (const [packageName, id] of discovered) {
|
|
124
|
+
const entryName = getSafeEntryName(packageName);
|
|
125
|
+
inputs[`dep_${entryName}`] = id;
|
|
126
|
+
}
|
|
127
|
+
return inputs;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Cache plugin.
|
|
131
|
+
*
|
|
132
|
+
* This does NOT rebuild the dependencies separately.
|
|
133
|
+
*
|
|
134
|
+
* They are entries in the SAME Rolldown watch.
|
|
135
|
+
*/
|
|
136
|
+
function xanixCachePlugin() {
|
|
137
|
+
return {
|
|
138
|
+
name: "xanix-cache",
|
|
139
|
+
outputOptions(options) {
|
|
140
|
+
return {
|
|
141
|
+
...options,
|
|
142
|
+
entryFileNames(chunk) {
|
|
143
|
+
if (chunk.name.startsWith("dep_")) {
|
|
144
|
+
const name = chunk.name.slice("dep_".length);
|
|
145
|
+
return `cache/${name}.js`;
|
|
146
|
+
}
|
|
147
|
+
return "[name].js";
|
|
148
|
+
},
|
|
149
|
+
};
|
|
150
|
+
},
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
export async function Caching() {
|
|
154
|
+
fs.mkdirSync(cacheDir, {
|
|
155
|
+
recursive: true,
|
|
156
|
+
});
|
|
157
|
+
/*
|
|
158
|
+
* Discover dependencies once when creating the watch graph.
|
|
159
|
+
*/
|
|
160
|
+
const inputs = await createInputs();
|
|
161
|
+
console.log("Rolldown watch entries:");
|
|
162
|
+
for (const [name, value] of Object.entries(inputs)) {
|
|
163
|
+
console.log(` ${name} → ${value}`);
|
|
164
|
+
}
|
|
165
|
+
/*
|
|
166
|
+
* ONE Rolldown watch.
|
|
167
|
+
*
|
|
168
|
+
* No buildDependencyCache().
|
|
169
|
+
* No external dependency build.
|
|
170
|
+
*/
|
|
171
|
+
const watcher = await watch({
|
|
172
|
+
input: inputs,
|
|
173
|
+
plugins: [xanixCachePlugin()],
|
|
174
|
+
output: {
|
|
175
|
+
dir: outDir,
|
|
176
|
+
format: "esm",
|
|
177
|
+
entryFileNames: (chunk) => {
|
|
178
|
+
if (chunk.name.startsWith("dep_")) {
|
|
179
|
+
const name = chunk.name.slice("dep_".length);
|
|
180
|
+
return `cache/${name}.js`;
|
|
181
|
+
}
|
|
182
|
+
return "[name].js";
|
|
183
|
+
},
|
|
184
|
+
chunkFileNames: "chunks/[name]-[hash].js",
|
|
185
|
+
assetFileNames: "assets/[name]-[hash][extname]",
|
|
186
|
+
},
|
|
187
|
+
watch: {
|
|
188
|
+
include: ["src/**", "node_modules/**"],
|
|
189
|
+
},
|
|
190
|
+
});
|
|
191
|
+
watcher.on("event", (event) => {
|
|
192
|
+
switch (event.code) {
|
|
193
|
+
case "START":
|
|
194
|
+
console.log("watch started");
|
|
195
|
+
break;
|
|
196
|
+
case "BUNDLE_START":
|
|
197
|
+
console.log("building...");
|
|
198
|
+
break;
|
|
199
|
+
case "BUNDLE_END":
|
|
200
|
+
console.log(`built in ${event.duration}ms`);
|
|
201
|
+
break;
|
|
202
|
+
case "END":
|
|
203
|
+
console.log("waiting for changes...");
|
|
204
|
+
break;
|
|
205
|
+
case "ERROR":
|
|
206
|
+
console.error(event.error);
|
|
207
|
+
break;
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { rolldown } from "rolldown";
|
|
2
2
|
import fs from "node:fs";
|
|
3
3
|
import bundlerOutput from "./config/output.js";
|
|
4
4
|
import { getClientRuntimeFile, getClientRuntimeFileName, } from "../include/utils.js";
|
|
@@ -18,7 +18,7 @@ const buildClient = async (entries) => {
|
|
|
18
18
|
fs.mkdirSync(outdirs.client, {
|
|
19
19
|
recursive: true,
|
|
20
20
|
});
|
|
21
|
-
const build = await
|
|
21
|
+
const build = await rolldown({
|
|
22
22
|
input,
|
|
23
23
|
treeshake: true,
|
|
24
24
|
onwarn(warning, warn) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { rolldown } from "rolldown";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import bundlerOutput from "./config/output.js";
|
|
4
4
|
import fs from "node:fs";
|
|
@@ -18,7 +18,7 @@ const BuildServer = async ({ rootEntry, onBuildEnd }) => {
|
|
|
18
18
|
const input = {
|
|
19
19
|
index: path.resolve(root, rootEntry),
|
|
20
20
|
};
|
|
21
|
-
const build = await
|
|
21
|
+
const build = await rolldown({
|
|
22
22
|
input,
|
|
23
23
|
treeshake: true,
|
|
24
24
|
onwarn(warning, warn) {
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { rolldown } from "rolldown";
|
|
2
|
+
import loadEnv from "../../include/loadEnv.js";
|
|
3
|
+
import outdirs from "../../../outdirs.js";
|
|
4
|
+
const VIRTUAL_PREFIX = "\0xanix-cache:";
|
|
5
|
+
const buildCache = async (cached) => {
|
|
6
|
+
const input = {};
|
|
7
|
+
for (const [source, { name }] of cached) {
|
|
8
|
+
input[name] = `${VIRTUAL_PREFIX}${name}`;
|
|
9
|
+
}
|
|
10
|
+
const build = await rolldown({
|
|
11
|
+
input,
|
|
12
|
+
treeshake: true,
|
|
13
|
+
platform: "browser",
|
|
14
|
+
tsconfig: true,
|
|
15
|
+
checks: {
|
|
16
|
+
moduleLevelDirective: false,
|
|
17
|
+
},
|
|
18
|
+
resolve: {
|
|
19
|
+
extensions: [".mjs", ".js", ".jsx", ".json", ".ts", ".tsx"],
|
|
20
|
+
conditionNames: ["browser", "import", "module", "default"],
|
|
21
|
+
},
|
|
22
|
+
transform: {
|
|
23
|
+
target: "es2020",
|
|
24
|
+
jsx: {
|
|
25
|
+
runtime: "automatic",
|
|
26
|
+
},
|
|
27
|
+
define: await loadEnv({
|
|
28
|
+
mode: "development",
|
|
29
|
+
isClient: false,
|
|
30
|
+
}),
|
|
31
|
+
},
|
|
32
|
+
plugins: [
|
|
33
|
+
{
|
|
34
|
+
name: "CacheEntry",
|
|
35
|
+
resolveId(source) {
|
|
36
|
+
if (source.startsWith(VIRTUAL_PREFIX)) {
|
|
37
|
+
return source;
|
|
38
|
+
}
|
|
39
|
+
return null;
|
|
40
|
+
},
|
|
41
|
+
load(id) {
|
|
42
|
+
if (!id.startsWith(VIRTUAL_PREFIX)) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
const name = id.slice(VIRTUAL_PREFIX.length);
|
|
46
|
+
const cache = [...cached.values()].find((item) => item.name === name);
|
|
47
|
+
if (!cache) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
const resolved = cache.resolved || cache.module;
|
|
51
|
+
if (cache.default) {
|
|
52
|
+
return `
|
|
53
|
+
import * as __xanix_namespace from ${JSON.stringify(resolved)};
|
|
54
|
+
|
|
55
|
+
export default __xanix_namespace.default;
|
|
56
|
+
export { __xanix_namespace };
|
|
57
|
+
`;
|
|
58
|
+
}
|
|
59
|
+
return `
|
|
60
|
+
import * as __xanix_namespace from ${JSON.stringify(resolved)};
|
|
61
|
+
|
|
62
|
+
export default __xanix_namespace;
|
|
63
|
+
export { __xanix_namespace };
|
|
64
|
+
`;
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
});
|
|
69
|
+
await build.write({
|
|
70
|
+
dir: outdirs.module_cache,
|
|
71
|
+
format: "es",
|
|
72
|
+
entryFileNames: "[name].js",
|
|
73
|
+
});
|
|
74
|
+
await build.close();
|
|
75
|
+
};
|
|
76
|
+
export default buildCache;
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import { isPackageImport, makeFilename } from "./utils.js";
|
|
3
|
+
import buildCache from "./buildCache.js";
|
|
4
|
+
import { walk } from "oxc-walker";
|
|
5
|
+
import { builtinModules } from "node:module";
|
|
6
|
+
import { readManifest, writeManifest } from "./manifest.js";
|
|
7
|
+
import logger from "../../include/logger.js";
|
|
8
|
+
import pc from "picocolors";
|
|
9
|
+
const nodeBuiltins = new Set(builtinModules);
|
|
10
|
+
function isNodeBuiltin(id) {
|
|
11
|
+
const normalized = id.startsWith("node:") ? id.slice(5) : id;
|
|
12
|
+
return nodeBuiltins.has(normalized);
|
|
13
|
+
}
|
|
14
|
+
const require = createRequire(import.meta.url);
|
|
15
|
+
function getParserLanguage(id) {
|
|
16
|
+
const cleanId = id.split("?")[0];
|
|
17
|
+
if (cleanId.endsWith(".tsx"))
|
|
18
|
+
return "tsx";
|
|
19
|
+
if (cleanId.endsWith(".ts"))
|
|
20
|
+
return "ts";
|
|
21
|
+
if (cleanId.endsWith(".jsx"))
|
|
22
|
+
return "jsx";
|
|
23
|
+
return "js";
|
|
24
|
+
}
|
|
25
|
+
function makeImportName(name) {
|
|
26
|
+
return `require_${name.replace(/[^a-zA-Z0-9_$]/g, "_")}`;
|
|
27
|
+
}
|
|
28
|
+
const XanixCache = () => {
|
|
29
|
+
const cached = new Map();
|
|
30
|
+
let init = false;
|
|
31
|
+
return {
|
|
32
|
+
name: "__xmod",
|
|
33
|
+
buildStart() {
|
|
34
|
+
cached.clear();
|
|
35
|
+
},
|
|
36
|
+
watchChange() {
|
|
37
|
+
cached.clear();
|
|
38
|
+
},
|
|
39
|
+
async resolveId(source) {
|
|
40
|
+
if (source.startsWith("/__xmod")) {
|
|
41
|
+
return {
|
|
42
|
+
id: source,
|
|
43
|
+
external: true,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
return null;
|
|
47
|
+
},
|
|
48
|
+
async transform(code, id) {
|
|
49
|
+
if (id.includes("/node_modules/") || id.includes("/.xanix/")) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
if (!code.includes("import ") && !code.includes("import(")) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
const lang = getParserLanguage(id);
|
|
56
|
+
const ast = this.parse(code, { lang });
|
|
57
|
+
const packages = [];
|
|
58
|
+
let replacements = [];
|
|
59
|
+
walk(ast, {
|
|
60
|
+
enter(node) {
|
|
61
|
+
if (node.type !== "ImportDeclaration" || node.importKind === "type") {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const source = node.source.value;
|
|
65
|
+
if (typeof source !== "string" ||
|
|
66
|
+
!isPackageImport(source) ||
|
|
67
|
+
isNodeBuiltin(source)) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
/*
|
|
71
|
+
* Don't add the same package multiple times
|
|
72
|
+
* when the file imports it more than once.
|
|
73
|
+
*/
|
|
74
|
+
if (!packages.includes(source)) {
|
|
75
|
+
packages.push(source);
|
|
76
|
+
}
|
|
77
|
+
const name = makeFilename(source);
|
|
78
|
+
const importName = makeImportName(name);
|
|
79
|
+
const cachePath = `/__xmod/${name}.js`;
|
|
80
|
+
const lines = [];
|
|
81
|
+
const specifiers = (node.specifiers ?? []).filter((specifier) => specifier.importKind !== "type");
|
|
82
|
+
if (!specifiers.length) {
|
|
83
|
+
lines.push(`import "${cachePath}";`);
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
const defaultSpecifier = specifiers.find((specifier) => specifier.type === "ImportDefaultSpecifier");
|
|
87
|
+
const namespaceSpecifier = specifiers.find((specifier) => specifier.type === "ImportNamespaceSpecifier");
|
|
88
|
+
const namedSpecifiers = specifiers.filter((specifier) => specifier.type === "ImportSpecifier");
|
|
89
|
+
/*
|
|
90
|
+
* Only import default when the original import
|
|
91
|
+
* actually has a default import.
|
|
92
|
+
*/
|
|
93
|
+
if (defaultSpecifier) {
|
|
94
|
+
lines.push(`import ${importName} from "${cachePath}";`);
|
|
95
|
+
lines.push(`const ${defaultSpecifier.local.name} = ${importName};`);
|
|
96
|
+
}
|
|
97
|
+
/*
|
|
98
|
+
* Namespace and named imports use the Xanix
|
|
99
|
+
* namespace export.
|
|
100
|
+
*/
|
|
101
|
+
if (namespaceSpecifier || namedSpecifiers.length) {
|
|
102
|
+
const namespaceName = `${importName}_ns`;
|
|
103
|
+
lines.push(`import { __xanix_namespace as ${namespaceName} } from "${cachePath}";`);
|
|
104
|
+
if (namespaceSpecifier) {
|
|
105
|
+
lines.push(`const ${namespaceSpecifier.local.name} = ${namespaceName};`);
|
|
106
|
+
}
|
|
107
|
+
if (namedSpecifiers.length) {
|
|
108
|
+
const properties = namedSpecifiers
|
|
109
|
+
.map((specifier) => {
|
|
110
|
+
const imported = specifier.imported?.type === "Identifier"
|
|
111
|
+
? specifier.imported.name
|
|
112
|
+
: specifier.imported?.value;
|
|
113
|
+
const local = specifier.local?.name;
|
|
114
|
+
if (!imported || !local) {
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
if (imported !== local) {
|
|
118
|
+
if (typeof imported === "string" &&
|
|
119
|
+
!/^[$A-Z_a-z][$\w]*$/.test(imported)) {
|
|
120
|
+
return `${JSON.stringify(imported)}: ${local}`;
|
|
121
|
+
}
|
|
122
|
+
return `${imported}: ${local}`;
|
|
123
|
+
}
|
|
124
|
+
return imported;
|
|
125
|
+
})
|
|
126
|
+
.filter(Boolean)
|
|
127
|
+
.join(", ");
|
|
128
|
+
if (properties) {
|
|
129
|
+
lines.push(`const { ${properties} } = ${namespaceName};`);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
if (!cached.has(source)) {
|
|
135
|
+
cached.set(source, {
|
|
136
|
+
module: source,
|
|
137
|
+
name,
|
|
138
|
+
resolved: "",
|
|
139
|
+
exports: [],
|
|
140
|
+
default: false,
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
replacements.push({
|
|
144
|
+
source,
|
|
145
|
+
start: node.start,
|
|
146
|
+
end: node.end,
|
|
147
|
+
value: lines.join("\n"),
|
|
148
|
+
});
|
|
149
|
+
},
|
|
150
|
+
});
|
|
151
|
+
if (!replacements.length) {
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
/*
|
|
155
|
+
* Resolve ONLY newly discovered packages.
|
|
156
|
+
*
|
|
157
|
+
* Never loop through the entire cache here.
|
|
158
|
+
*/
|
|
159
|
+
for (const source of packages) {
|
|
160
|
+
const cache = cached.get(source);
|
|
161
|
+
if (!cache || cache.resolved)
|
|
162
|
+
continue;
|
|
163
|
+
try {
|
|
164
|
+
const resolved = await this.resolve(source, id);
|
|
165
|
+
if (!resolved?.id || !resolved.id.includes("node_modules")) {
|
|
166
|
+
throw new Error(`Resolved module ${resolved.id} is not in node_modules`);
|
|
167
|
+
}
|
|
168
|
+
cache.resolved = resolved.id;
|
|
169
|
+
const mod = require(resolved.id);
|
|
170
|
+
cache.exports = Object.keys(mod);
|
|
171
|
+
cache.default = Object.prototype.hasOwnProperty.call(mod, "default");
|
|
172
|
+
}
|
|
173
|
+
catch (error) {
|
|
174
|
+
cached.delete(source);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
for (let rep of replacements) {
|
|
178
|
+
const cache = cached.get(rep.source);
|
|
179
|
+
if (!cache ||
|
|
180
|
+
!cache.resolved ||
|
|
181
|
+
!cache.resolved.includes("node_modules")) {
|
|
182
|
+
replacements = replacements.filter((r) => r.source !== rep.source);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
/*
|
|
186
|
+
* Apply replacements only when this file actually
|
|
187
|
+
* contained cacheable imports.
|
|
188
|
+
*/
|
|
189
|
+
const sorted = replacements.sort((a, b) => b.start - a.start);
|
|
190
|
+
for (const { start, end, value } of sorted) {
|
|
191
|
+
code = code.slice(0, start) + value + code.slice(end);
|
|
192
|
+
}
|
|
193
|
+
return {
|
|
194
|
+
code,
|
|
195
|
+
map: null,
|
|
196
|
+
};
|
|
197
|
+
},
|
|
198
|
+
async generateBundle() {
|
|
199
|
+
// write manifest
|
|
200
|
+
const cachedManifest = await readManifest();
|
|
201
|
+
const pmodules = Array.from(cachedManifest.values()).map((m) => m.module);
|
|
202
|
+
const cmodule = Array.from(cached.values()).map((m) => m.module);
|
|
203
|
+
const hasChanges = pmodules.some((m) => !cmodule.includes(m)) ||
|
|
204
|
+
cmodule.some((m) => !pmodules.includes(m));
|
|
205
|
+
if (hasChanges) {
|
|
206
|
+
if (init) {
|
|
207
|
+
logger.info(`${pc.yellow("Optimizing dependencies")} `, "[optimize]");
|
|
208
|
+
}
|
|
209
|
+
init = true;
|
|
210
|
+
await buildCache(cached);
|
|
211
|
+
await writeManifest(cached);
|
|
212
|
+
}
|
|
213
|
+
},
|
|
214
|
+
};
|
|
215
|
+
};
|
|
216
|
+
export default XanixCache;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import fs from "fs/promises";
|
|
2
|
+
import outdirs from "../../../outdirs.js";
|
|
3
|
+
const manifestFile = `${outdirs.module_cache}/manifest.json`;
|
|
4
|
+
export const writeManifest = async (manifest) => {
|
|
5
|
+
const data = Array.from(manifest.values());
|
|
6
|
+
for (const item of data) {
|
|
7
|
+
delete item.exports;
|
|
8
|
+
delete item.default;
|
|
9
|
+
delete item.resolved;
|
|
10
|
+
delete item.name;
|
|
11
|
+
}
|
|
12
|
+
await fs.writeFile(manifestFile, JSON.stringify(data, null, 2), "utf-8");
|
|
13
|
+
};
|
|
14
|
+
export const readManifest = async () => {
|
|
15
|
+
try {
|
|
16
|
+
const content = await fs.readFile(manifestFile, "utf-8");
|
|
17
|
+
const parsed = JSON.parse(content);
|
|
18
|
+
let data = new Map();
|
|
19
|
+
for (let p of parsed) {
|
|
20
|
+
data.set(p.module, p);
|
|
21
|
+
}
|
|
22
|
+
return data;
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return new Map();
|
|
26
|
+
}
|
|
27
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { createRequire } from "module";
|
|
2
|
+
const require = createRequire(import.meta.url);
|
|
3
|
+
const exportsMap = new Map();
|
|
4
|
+
const CacheExportPlugin = () => {
|
|
5
|
+
return {
|
|
6
|
+
name: "cache-export",
|
|
7
|
+
load(id) {
|
|
8
|
+
if (!id.includes("node_modules")) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
try {
|
|
12
|
+
const mod = require(id);
|
|
13
|
+
const names = Object.keys(mod);
|
|
14
|
+
exportsMap.set(id, names);
|
|
15
|
+
console.log(id, names);
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
// ignore modules that cannot be require()'d
|
|
19
|
+
}
|
|
20
|
+
return null;
|
|
21
|
+
},
|
|
22
|
+
generateBundle(_options, bundle) {
|
|
23
|
+
for (const output of Object.values(bundle)) {
|
|
24
|
+
if (output.type !== "chunk" || !output.isEntry) {
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
const id = output.facadeModuleId;
|
|
28
|
+
if (!id) {
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
const names = exportsMap.get(id);
|
|
32
|
+
if (!names) {
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
console.log("Generating:", id);
|
|
36
|
+
console.log("Exports:", names);
|
|
37
|
+
// Here you generate your ESM exports.
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
export default CacheExportPlugin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function isPackageImport(source: string): boolean;
|
|
2
|
+
export declare const makeFilename: (id: string) => string;
|
|
3
|
+
export declare const writeCacheManifest: (cached: Map<string, string>) => Promise<void>;
|
|
4
|
+
export declare const readCacheManifest: () => Promise<Map<any, any>>;
|
|
5
|
+
export declare function isNodeBuiltin(id: string): boolean;
|