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,414 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import crypto from "node:crypto";
|
|
4
|
+
import { parse } from "@babel/parser";
|
|
5
|
+
import traverse from "@babel/traverse";
|
|
6
|
+
import generate from "@babel/generator";
|
|
7
|
+
import * as t from "@babel/types";
|
|
8
|
+
const RUNTIME_IMPORT = "xanix/runtime";
|
|
9
|
+
const SOURCE_EXTENSIONS = [".tsx", ".ts", ".jsx", ".js", ".mjs", ".cjs"];
|
|
10
|
+
function normalizeFilePath(file) {
|
|
11
|
+
return path.resolve(file).split(path.sep).join("/");
|
|
12
|
+
}
|
|
13
|
+
export function resolveFile(file) {
|
|
14
|
+
const absolute = path.resolve(file);
|
|
15
|
+
if (fs.existsSync(absolute)) {
|
|
16
|
+
const stat = fs.statSync(absolute);
|
|
17
|
+
if (stat.isFile()) {
|
|
18
|
+
return absolute;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
for (const ext of SOURCE_EXTENSIONS) {
|
|
22
|
+
const candidate = `${absolute}${ext}`;
|
|
23
|
+
if (fs.existsSync(candidate) && fs.statSync(candidate).isFile()) {
|
|
24
|
+
return path.resolve(candidate);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (fs.existsSync(absolute) && fs.statSync(absolute).isDirectory()) {
|
|
28
|
+
for (const ext of SOURCE_EXTENSIONS) {
|
|
29
|
+
const candidate = path.join(absolute, `index${ext}`);
|
|
30
|
+
if (fs.existsSync(candidate) && fs.statSync(candidate).isFile()) {
|
|
31
|
+
return path.resolve(candidate);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return absolute;
|
|
36
|
+
}
|
|
37
|
+
export function resolveComponentFile(importer, importPath) {
|
|
38
|
+
if (!importPath.startsWith(".")) {
|
|
39
|
+
return importPath;
|
|
40
|
+
}
|
|
41
|
+
const base = path.resolve(path.dirname(importer), importPath);
|
|
42
|
+
return resolveFile(base);
|
|
43
|
+
}
|
|
44
|
+
export function createPageId(file) {
|
|
45
|
+
return `${crypto
|
|
46
|
+
.createHash("sha256")
|
|
47
|
+
.update(path.normalize(file))
|
|
48
|
+
.digest("hex")
|
|
49
|
+
.slice(0, 12)}`;
|
|
50
|
+
}
|
|
51
|
+
export function getJSXComponentName(node) {
|
|
52
|
+
const name = node.openingElement.name;
|
|
53
|
+
if (t.isJSXIdentifier(name)) {
|
|
54
|
+
return name.name;
|
|
55
|
+
}
|
|
56
|
+
if (t.isJSXMemberExpression(name)) {
|
|
57
|
+
if (t.isJSXIdentifier(name.object) && t.isJSXIdentifier(name.property)) {
|
|
58
|
+
return `${name.object.name}.${name.property.name}`;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
function findComponentImport(ast, componentName) {
|
|
64
|
+
for (const node of ast.program.body) {
|
|
65
|
+
if (!t.isImportDeclaration(node)) {
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
for (const specifier of node.specifiers) {
|
|
69
|
+
if (t.isImportDefaultSpecifier(specifier) &&
|
|
70
|
+
specifier.local.name === componentName) {
|
|
71
|
+
return {
|
|
72
|
+
file: node.source.value,
|
|
73
|
+
export: "default",
|
|
74
|
+
declaration: node,
|
|
75
|
+
specifier,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
if (t.isImportSpecifier(specifier) &&
|
|
79
|
+
specifier.local.name === componentName) {
|
|
80
|
+
const imported = specifier.imported;
|
|
81
|
+
return {
|
|
82
|
+
file: node.source.value,
|
|
83
|
+
export: t.isIdentifier(imported) ? imported.name : imported.value,
|
|
84
|
+
declaration: node,
|
|
85
|
+
specifier,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
function removeComponentImport(ast, componentImport) {
|
|
93
|
+
const { declaration, specifier } = componentImport;
|
|
94
|
+
const index = declaration.specifiers.indexOf(specifier);
|
|
95
|
+
if (index !== -1) {
|
|
96
|
+
declaration.specifiers.splice(index, 1);
|
|
97
|
+
}
|
|
98
|
+
if (declaration.specifiers.length === 0) {
|
|
99
|
+
const bodyIndex = ast.program.body.indexOf(declaration);
|
|
100
|
+
if (bodyIndex !== -1) {
|
|
101
|
+
ast.program.body.splice(bodyIndex, 1);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
function jsxNameToExpression(name) {
|
|
106
|
+
if (t.isJSXIdentifier(name)) {
|
|
107
|
+
return t.identifier(name.name);
|
|
108
|
+
}
|
|
109
|
+
if (t.isJSXMemberExpression(name)) {
|
|
110
|
+
const object = jsxNameToExpressionFromJSXName(name.object);
|
|
111
|
+
const property = jsxNameToExpressionFromJSXName(name.property);
|
|
112
|
+
if (!object || !property) {
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
return t.memberExpression(object, property);
|
|
116
|
+
}
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
function jsxNameToExpressionFromJSXName(name) {
|
|
120
|
+
if (t.isJSXIdentifier(name)) {
|
|
121
|
+
return t.identifier(name.name);
|
|
122
|
+
}
|
|
123
|
+
if (t.isJSXMemberExpression(name)) {
|
|
124
|
+
const object = jsxNameToExpressionFromJSXName(name.object);
|
|
125
|
+
const property = jsxNameToExpressionFromJSXName(name.property);
|
|
126
|
+
if (!object || !property) {
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
return t.memberExpression(object, property);
|
|
130
|
+
}
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
function jsxAttributesToProps(jsx) {
|
|
134
|
+
const properties = [];
|
|
135
|
+
for (const attribute of jsx.openingElement.attributes) {
|
|
136
|
+
if (t.isJSXSpreadAttribute(attribute)) {
|
|
137
|
+
properties.push(t.spreadElement(attribute.argument));
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
if (!t.isJSXAttribute(attribute)) {
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
function jsxAttributeNameToExpression(name) {
|
|
144
|
+
if (t.isJSXIdentifier(name)) {
|
|
145
|
+
return t.identifier(name.name);
|
|
146
|
+
}
|
|
147
|
+
return t.stringLiteral(`${name.namespace.name}:${name.name.name}`);
|
|
148
|
+
}
|
|
149
|
+
const key = jsxAttributeNameToExpression(attribute.name);
|
|
150
|
+
if (!attribute.value) {
|
|
151
|
+
properties.push(t.objectProperty(key, t.booleanLiteral(true)));
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
if (t.isStringLiteral(attribute.value)) {
|
|
155
|
+
properties.push(t.objectProperty(key, t.stringLiteral(attribute.value.value)));
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
if (t.isJSXExpressionContainer(attribute.value)) {
|
|
159
|
+
const expression = attribute.value.expression;
|
|
160
|
+
if (t.isJSXEmptyExpression(expression)) {
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
properties.push(t.objectProperty(key, expression));
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
if (t.isJSXElement(attribute.value)) {
|
|
167
|
+
properties.push(t.objectProperty(key, attribute.value));
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return t.objectExpression(properties);
|
|
171
|
+
}
|
|
172
|
+
function jsxToComponentAndProps(jsx) {
|
|
173
|
+
const component = jsxNameToExpression(jsx.openingElement.name);
|
|
174
|
+
if (!component) {
|
|
175
|
+
return null;
|
|
176
|
+
}
|
|
177
|
+
const props = jsxAttributesToProps(jsx);
|
|
178
|
+
return {
|
|
179
|
+
component,
|
|
180
|
+
props,
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
function createDynamicComponentProperty(importPath) {
|
|
184
|
+
const importCall = t.callExpression(t.import(), [
|
|
185
|
+
t.stringLiteral(importPath),
|
|
186
|
+
]);
|
|
187
|
+
const awaitedImport = t.awaitExpression(importCall);
|
|
188
|
+
const arrowFunction = t.arrowFunctionExpression([], awaitedImport);
|
|
189
|
+
arrowFunction.async = true;
|
|
190
|
+
return t.objectProperty(t.identifier("component"), arrowFunction);
|
|
191
|
+
}
|
|
192
|
+
function hasRuntimeImport(ast, name) {
|
|
193
|
+
for (const statement of ast.program.body) {
|
|
194
|
+
if (!t.isImportDeclaration(statement)) {
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
if (statement.source.value !== RUNTIME_IMPORT) {
|
|
198
|
+
continue;
|
|
199
|
+
}
|
|
200
|
+
for (const specifier of statement.specifiers) {
|
|
201
|
+
if (t.isImportSpecifier(specifier) &&
|
|
202
|
+
t.isIdentifier(specifier.imported) &&
|
|
203
|
+
specifier.imported.name === name) {
|
|
204
|
+
return true;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return false;
|
|
209
|
+
}
|
|
210
|
+
function injectRuntimeImport(ast, name) {
|
|
211
|
+
if (hasRuntimeImport(ast, name)) {
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
for (const statement of ast.program.body) {
|
|
215
|
+
if (!t.isImportDeclaration(statement)) {
|
|
216
|
+
continue;
|
|
217
|
+
}
|
|
218
|
+
if (statement.source.value !== RUNTIME_IMPORT) {
|
|
219
|
+
continue;
|
|
220
|
+
}
|
|
221
|
+
statement.specifiers.push(t.importSpecifier(t.identifier(name), t.identifier(name)));
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
ast.program.body.unshift(t.importDeclaration([t.importSpecifier(t.identifier(name), t.identifier(name))], t.stringLiteral(RUNTIME_IMPORT)));
|
|
225
|
+
}
|
|
226
|
+
export function transformer(code, id) {
|
|
227
|
+
const ast = parse(code, {
|
|
228
|
+
sourceType: "module",
|
|
229
|
+
plugins: ["typescript", "jsx"],
|
|
230
|
+
});
|
|
231
|
+
let changed = false;
|
|
232
|
+
const entries = [];
|
|
233
|
+
traverse(ast, {
|
|
234
|
+
CallExpression(callPath) {
|
|
235
|
+
const call = callPath.node;
|
|
236
|
+
/*
|
|
237
|
+
* Find:
|
|
238
|
+
*
|
|
239
|
+
* res.send(...)
|
|
240
|
+
*/
|
|
241
|
+
if (!t.isMemberExpression(call.callee)) {
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
if (!t.isIdentifier(call.callee.property, {
|
|
245
|
+
name: "send",
|
|
246
|
+
})) {
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
const argument = call.arguments[0];
|
|
250
|
+
/*
|
|
251
|
+
* Only transform:
|
|
252
|
+
*
|
|
253
|
+
* res.send(<HomePage />)
|
|
254
|
+
*/
|
|
255
|
+
if (!argument || !t.isJSXElement(argument)) {
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
/*
|
|
259
|
+
* Find:
|
|
260
|
+
*
|
|
261
|
+
* (req, res) => {}
|
|
262
|
+
*/
|
|
263
|
+
const functionPath = callPath.getFunctionParent();
|
|
264
|
+
if (!functionPath) {
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
const params = functionPath.node.params;
|
|
268
|
+
if (params.length < 2) {
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
const requestParam = params[0];
|
|
272
|
+
const responseParam = params[1];
|
|
273
|
+
if (!t.isIdentifier(requestParam) || !t.isIdentifier(responseParam)) {
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
/*
|
|
277
|
+
* Find component name:
|
|
278
|
+
*
|
|
279
|
+
* <HomePage />
|
|
280
|
+
*/
|
|
281
|
+
const componentName = getJSXComponentName(argument);
|
|
282
|
+
if (!componentName) {
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
/*
|
|
286
|
+
* Find:
|
|
287
|
+
*
|
|
288
|
+
* import HomePage from "../pages/Home";
|
|
289
|
+
*/
|
|
290
|
+
const componentImport = findComponentImport(ast, componentName);
|
|
291
|
+
if (!componentImport) {
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
const componentImportPath = componentImport.file;
|
|
295
|
+
/*
|
|
296
|
+
* Resolve:
|
|
297
|
+
*
|
|
298
|
+
* ../pages/Home
|
|
299
|
+
*
|
|
300
|
+
* ->
|
|
301
|
+
*
|
|
302
|
+
* C:/xampp/htdocs/xanix/app/pages/Home/index.tsx
|
|
303
|
+
*/
|
|
304
|
+
const componentFile = resolveComponentFile(id, componentImportPath);
|
|
305
|
+
if (!path.isAbsolute(componentFile)) {
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
/*
|
|
309
|
+
* Normalize absolute file path.
|
|
310
|
+
*/
|
|
311
|
+
const normalizedFile = normalizeFilePath(componentFile);
|
|
312
|
+
/*
|
|
313
|
+
* Stable page ID.
|
|
314
|
+
*/
|
|
315
|
+
const pageId = createPageId(normalizedFile);
|
|
316
|
+
/*
|
|
317
|
+
* JSX:
|
|
318
|
+
*
|
|
319
|
+
* <HomePage title="Hello" />
|
|
320
|
+
*
|
|
321
|
+
* ->
|
|
322
|
+
*
|
|
323
|
+
* {
|
|
324
|
+
* title: "Hello"
|
|
325
|
+
* }
|
|
326
|
+
*/
|
|
327
|
+
const componentAndProps = jsxToComponentAndProps(argument);
|
|
328
|
+
if (!componentAndProps) {
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
/*
|
|
332
|
+
* Create manifest entry.
|
|
333
|
+
*/
|
|
334
|
+
entries.push({
|
|
335
|
+
id: pageId,
|
|
336
|
+
name: componentName,
|
|
337
|
+
file: normalizedFile,
|
|
338
|
+
path: componentImportPath,
|
|
339
|
+
export: componentImport.export,
|
|
340
|
+
});
|
|
341
|
+
/*
|
|
342
|
+
* Remove static component import.
|
|
343
|
+
*/
|
|
344
|
+
removeComponentImport(ast, componentImport);
|
|
345
|
+
/*
|
|
346
|
+
* Create:
|
|
347
|
+
*
|
|
348
|
+
* component: async () =>
|
|
349
|
+
* await import("../pages/Home")
|
|
350
|
+
*/
|
|
351
|
+
const componentProperty = createDynamicComponentProperty(componentImportPath);
|
|
352
|
+
/*
|
|
353
|
+
* Make route handler async.
|
|
354
|
+
*/
|
|
355
|
+
if (t.isFunction(functionPath.node)) {
|
|
356
|
+
functionPath.node.async = true;
|
|
357
|
+
}
|
|
358
|
+
/*
|
|
359
|
+
* Create:
|
|
360
|
+
*
|
|
361
|
+
* await xanixPage({
|
|
362
|
+
* component: async () =>
|
|
363
|
+
* await import("../pages/Home"),
|
|
364
|
+
* pageId: "...",
|
|
365
|
+
* req,
|
|
366
|
+
* res,
|
|
367
|
+
* props: {}
|
|
368
|
+
* })
|
|
369
|
+
*/
|
|
370
|
+
const pageOptions = t.objectExpression([
|
|
371
|
+
componentProperty,
|
|
372
|
+
t.objectProperty(t.identifier("pageId"), t.stringLiteral(pageId)),
|
|
373
|
+
t.objectProperty(t.identifier("req"), t.identifier(requestParam.name)),
|
|
374
|
+
t.objectProperty(t.identifier("res"), t.identifier(responseParam.name)),
|
|
375
|
+
t.objectProperty(t.identifier("props"), componentAndProps.props),
|
|
376
|
+
]);
|
|
377
|
+
const pageCall = t.awaitExpression(t.callExpression(t.identifier("xanixPage"), [pageOptions]));
|
|
378
|
+
/*
|
|
379
|
+
* Replace:
|
|
380
|
+
*
|
|
381
|
+
* res.send(<HomePage />);
|
|
382
|
+
*
|
|
383
|
+
* with:
|
|
384
|
+
*
|
|
385
|
+
* res.send(
|
|
386
|
+
* await xanixPage({...})
|
|
387
|
+
* );
|
|
388
|
+
*/
|
|
389
|
+
call.arguments[0] = pageCall;
|
|
390
|
+
changed = true;
|
|
391
|
+
},
|
|
392
|
+
});
|
|
393
|
+
if (!changed) {
|
|
394
|
+
return null;
|
|
395
|
+
}
|
|
396
|
+
/*
|
|
397
|
+
* Add:
|
|
398
|
+
*
|
|
399
|
+
* import { xanixPage } from "xanix/runtime";
|
|
400
|
+
*/
|
|
401
|
+
injectRuntimeImport(ast, "xanixPage");
|
|
402
|
+
/*
|
|
403
|
+
* Generate final code + source map.
|
|
404
|
+
*/
|
|
405
|
+
const output = generate(ast, {
|
|
406
|
+
sourceMaps: true,
|
|
407
|
+
sourceFileName: id,
|
|
408
|
+
}, code);
|
|
409
|
+
return {
|
|
410
|
+
code: output.code,
|
|
411
|
+
map: output.map,
|
|
412
|
+
entries,
|
|
413
|
+
};
|
|
414
|
+
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as t from "@babel/types";
|
|
2
1
|
export interface XanixPageEntry {
|
|
3
2
|
id: string;
|
|
4
3
|
name: string;
|
|
@@ -8,11 +7,17 @@ export interface XanixPageEntry {
|
|
|
8
7
|
}
|
|
9
8
|
export interface XanixTransformResult {
|
|
10
9
|
code: string;
|
|
11
|
-
map: any;
|
|
12
10
|
entries: XanixPageEntry[];
|
|
13
11
|
}
|
|
12
|
+
type AstNode = {
|
|
13
|
+
type: string;
|
|
14
|
+
start?: number;
|
|
15
|
+
end?: number;
|
|
16
|
+
[key: string]: any;
|
|
17
|
+
};
|
|
18
|
+
export declare function normalizeFilePath(file: string): string;
|
|
14
19
|
export declare function resolveFile(file: string): string;
|
|
15
20
|
export declare function resolveComponentFile(importer: string, importPath: string): string;
|
|
16
21
|
export declare function createPageId(file: string): string;
|
|
17
|
-
export declare function
|
|
18
|
-
export
|
|
22
|
+
export declare function transformer(code: string, id: string, ast: AstNode): XanixTransformResult | null;
|
|
23
|
+
export {};
|