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.
Files changed (350) hide show
  1. package/dist/AppRoot.d.ts +6 -0
  2. package/dist/AppRoot.js +15 -0
  3. package/dist/bin/bundler/Cache.d.ts +1 -0
  4. package/dist/bin/bundler/Cache.js +210 -0
  5. package/dist/bin/bundler/External.d.ts +3 -0
  6. package/dist/bin/bundler/External.js +6 -0
  7. package/dist/bin/bundler/buildClient.js +2 -2
  8. package/dist/bin/bundler/buildServer.js +2 -2
  9. package/dist/bin/bundler/cache/buildCache.d.ts +3 -0
  10. package/dist/bin/bundler/cache/buildCache.js +76 -0
  11. package/dist/bin/bundler/cache/index.d.ts +3 -0
  12. package/dist/bin/bundler/cache/index.js +216 -0
  13. package/dist/bin/bundler/cache/manifest.d.ts +3 -0
  14. package/dist/bin/bundler/cache/manifest.js +27 -0
  15. package/dist/bin/bundler/cache/plugin/Transformer.d.ts +3 -0
  16. package/dist/bin/bundler/cache/plugin/Transformer.js +42 -0
  17. package/dist/bin/bundler/cache/types.d.ts +8 -0
  18. package/dist/bin/bundler/cache/types.js +1 -0
  19. package/dist/bin/bundler/cache/utils.d.ts +5 -0
  20. package/dist/bin/bundler/cache/utils.js +56 -0
  21. package/dist/bin/bundler/client/build.d.ts +2 -0
  22. package/dist/bin/bundler/client/build.js +61 -0
  23. package/dist/bin/bundler/client/plugins/Transformer/TransformCache.d.ts +15 -0
  24. package/dist/bin/bundler/client/plugins/Transformer/TransformCache.js +39 -0
  25. package/dist/bin/bundler/client/plugins/Transformer/TransformCacheFunction.d.ts +3 -0
  26. package/dist/bin/bundler/client/plugins/Transformer/TransformCacheFunction.js +32 -0
  27. package/dist/bin/bundler/client/plugins/Transformer/TransformCreateSession.d.ts +3 -0
  28. package/dist/bin/bundler/client/plugins/Transformer/TransformCreateSession.js +29 -0
  29. package/dist/bin/bundler/client/plugins/Transformer/TransformExpress.d.ts +9 -0
  30. package/dist/bin/bundler/client/plugins/Transformer/TransformExpress.js +26 -0
  31. package/dist/bin/bundler/client/plugins/Transformer/TransformPage.d.ts +29 -0
  32. package/dist/bin/bundler/client/plugins/Transformer/TransformPage.js +77 -0
  33. package/dist/bin/bundler/client/plugins/Transformer/TransformReactContext.d.ts +17 -0
  34. package/dist/bin/bundler/client/plugins/Transformer/TransformReactContext.js +101 -0
  35. package/dist/bin/bundler/client/plugins/Transformer/TransformServerAction.d.ts +15 -0
  36. package/dist/bin/bundler/client/plugins/Transformer/TransformServerAction.js +42 -0
  37. package/dist/bin/bundler/client/plugins/Transformer/TransformServerFunction.d.ts +3 -0
  38. package/dist/bin/bundler/client/plugins/Transformer/TransformServerFunction.js +32 -0
  39. package/dist/bin/bundler/client/plugins/Transformer/TransformUseServer.d.ts +3 -0
  40. package/dist/bin/bundler/client/plugins/Transformer/TransformUseServer.js +31 -0
  41. package/dist/bin/bundler/client/plugins/Transformer/transformModuleCache.d.ts +15 -0
  42. package/dist/bin/bundler/client/plugins/Transformer/transformModuleCache.js +120 -0
  43. package/dist/bin/bundler/client/plugins/Transformer copy.d.ts +3 -0
  44. package/dist/bin/bundler/client/plugins/Transformer copy.js +70 -0
  45. package/dist/bin/bundler/client/plugins/Transformer.d.ts +3 -0
  46. package/dist/bin/bundler/client/plugins/Transformer.js +26 -0
  47. package/dist/bin/bundler/client/plugins/VirtualDev.d.ts +2 -0
  48. package/dist/bin/bundler/client/plugins/VirtualDev.js +34 -0
  49. package/dist/bin/bundler/client/plugins/XanixPages.d.ts +2 -0
  50. package/dist/bin/bundler/client/plugins/XanixPages.js +37 -0
  51. package/dist/bin/bundler/client/plugins/XanixReactRefresh.d.ts +2 -0
  52. package/dist/bin/bundler/client/plugins/XanixReactRefresh.js +22 -0
  53. package/dist/bin/bundler/client/plugins/replacer/cacheFunctionReplacer.d.ts +3 -0
  54. package/dist/bin/bundler/client/plugins/replacer/cacheFunctionReplacer.js +28 -0
  55. package/dist/bin/bundler/client/plugins/replacer/serverFunctionReplacer.d.ts +3 -0
  56. package/dist/bin/bundler/client/plugins/replacer/serverFunctionReplacer.js +28 -0
  57. package/dist/bin/bundler/client/plugins/replacer/useServerReplacer.d.ts +3 -0
  58. package/dist/bin/bundler/client/plugins/replacer/useServerReplacer.js +38 -0
  59. package/dist/bin/bundler/client/watch.config.d.ts +3 -0
  60. package/dist/bin/bundler/client/watch.config.js +39 -0
  61. package/dist/bin/bundler/client/watch.d.ts +13 -0
  62. package/dist/bin/bundler/client/watch.js +71 -0
  63. package/dist/bin/bundler/config/loadEnv.d.ts +20 -0
  64. package/dist/bin/bundler/config/loadEnv.js +48 -0
  65. package/dist/bin/bundler/config/output.d.ts +1 -1
  66. package/dist/bin/bundler/config/output.js +13 -12
  67. package/dist/bin/bundler/externalResolver-dep.d.ts +3 -0
  68. package/dist/bin/bundler/externalResolver-dep.js +203 -0
  69. package/dist/bin/bundler/externalResolver.d.ts +3 -0
  70. package/dist/bin/bundler/externalResolver.js +203 -0
  71. package/dist/bin/bundler/plugins/TransformServer/TransformExpress.d.ts +9 -0
  72. package/dist/bin/bundler/plugins/TransformServer/TransformExpress.js +26 -0
  73. package/dist/bin/bundler/plugins/TransformServer/TransformPage.d.ts +25 -0
  74. package/dist/bin/bundler/plugins/TransformServer/TransformPage.js +79 -0
  75. package/dist/bin/bundler/plugins/TransformServer/index.d.ts +3 -0
  76. package/dist/bin/bundler/plugins/TransformServer/index.js +103 -0
  77. package/dist/bin/bundler/plugins/XanixAssets.d.ts +5 -0
  78. package/dist/bin/bundler/plugins/XanixAssets.js +51 -0
  79. package/dist/bin/bundler/plugins/XanixCacheDeps-dep.d.ts +2 -0
  80. package/dist/bin/bundler/plugins/XanixCacheDeps-dep.js +150 -0
  81. package/dist/bin/bundler/plugins/XanixCacheDeps.d.ts +2 -0
  82. package/dist/bin/bundler/plugins/XanixCacheDeps.js +150 -0
  83. package/dist/bin/bundler/plugins/XanixDocument/index.d.ts +1 -1
  84. package/dist/bin/bundler/plugins/XanixDocument/index.js +24 -14
  85. package/dist/bin/bundler/plugins/XanixEntryFinder/finder.js +0 -6
  86. package/dist/bin/bundler/plugins/XanixEntryFinder-dep/finder.d.ts +11 -0
  87. package/dist/bin/bundler/plugins/XanixEntryFinder-dep/finder.js +149 -0
  88. package/dist/bin/bundler/plugins/XanixEntryFinder-dep/index.d.ts +6 -0
  89. package/dist/bin/bundler/plugins/XanixEntryFinder-dep/index.js +37 -0
  90. package/dist/bin/bundler/plugins/XanixPageTransform/index.d.ts +1 -1
  91. package/dist/bin/bundler/plugins/XanixPageTransform/index.js +48 -33
  92. package/dist/bin/bundler/plugins/XanixPageTransform/transformer copy.d.ts +18 -0
  93. package/dist/bin/bundler/plugins/XanixPageTransform/transformer copy.js +414 -0
  94. package/dist/bin/bundler/plugins/XanixPageTransform/transformer.d.ts +9 -4
  95. package/dist/bin/bundler/plugins/XanixPageTransform/transformer.js +477 -302
  96. package/dist/bin/bundler/plugins/XanixReactRefresh copy.d.ts +2 -0
  97. package/dist/bin/bundler/plugins/XanixReactRefresh copy.js +121 -0
  98. package/dist/bin/bundler/plugins/XanixReactRefresh.d.ts +2 -2
  99. package/dist/bin/bundler/plugins/XanixReactRefresh.js +150 -101
  100. package/dist/bin/bundler/plugins/XanixResolveCacheDeps/BuildClientCache.d.ts +11 -0
  101. package/dist/bin/bundler/plugins/XanixResolveCacheDeps/BuildClientCache.js +129 -0
  102. package/dist/bin/bundler/plugins/XanixResolveCacheDeps/index copy.d.ts +15 -0
  103. package/dist/bin/bundler/plugins/XanixResolveCacheDeps/index copy.js +228 -0
  104. package/dist/bin/bundler/plugins/XanixResolveCacheDeps/index.d.ts +7 -5
  105. package/dist/bin/bundler/plugins/XanixResolveCacheDeps/index.js +156 -21
  106. package/dist/bin/bundler/plugins/XanixResolveCacheDeps-dep/BuildClientCache.d.ts +11 -0
  107. package/dist/bin/bundler/{cacheNpmModules.js → plugins/XanixResolveCacheDeps-dep/BuildClientCache.js} +13 -9
  108. package/dist/bin/bundler/plugins/XanixResolveCacheDeps-dep/index.d.ts +5 -0
  109. package/dist/bin/bundler/plugins/XanixResolveCacheDeps-dep/index.js +26 -0
  110. package/dist/bin/bundler/plugins/XanixResolver.d.ts +11 -0
  111. package/dist/bin/bundler/plugins/XanixResolver.js +55 -0
  112. package/dist/bin/bundler/plugins/XanixServerTransform.d.ts +1 -1
  113. package/dist/bin/bundler/plugins/XanixServerTransform.js +193 -116
  114. package/dist/bin/bundler/plugins/XanixTransform.d.ts +3 -0
  115. package/dist/bin/bundler/plugins/XanixTransform.js +23 -0
  116. package/dist/bin/bundler/plugins/XanixTsconfigAlias.d.ts +1 -1
  117. package/dist/bin/bundler/plugins/XanixUseServer.d.ts +1 -1
  118. package/dist/bin/bundler/plugins/XanixUseServer.js +308 -245
  119. package/dist/bin/bundler/plugins/plugins.d.ts +1 -5
  120. package/dist/bin/bundler/plugins/plugins.js +9 -154
  121. package/dist/bin/bundler/requireCache.d.ts +3 -0
  122. package/dist/bin/bundler/requireCache.js +85 -0
  123. package/dist/bin/bundler/server/build.d.ts +6 -0
  124. package/dist/bin/bundler/server/build.js +92 -0
  125. package/dist/bin/bundler/server/plugins/ServerAction.d.ts +3 -0
  126. package/dist/bin/bundler/server/plugins/ServerAction.js +9 -0
  127. package/dist/bin/bundler/server/plugins/Transformer/ServerAction.d.ts +11 -0
  128. package/dist/bin/bundler/server/plugins/Transformer/ServerAction.js +28 -0
  129. package/dist/bin/bundler/server/plugins/Transformer/TransformCache.d.ts +15 -0
  130. package/dist/bin/bundler/server/plugins/Transformer/TransformCache.js +39 -0
  131. package/dist/bin/bundler/server/plugins/Transformer/TransformCacheFunction.d.ts +3 -0
  132. package/dist/bin/bundler/server/plugins/Transformer/TransformCacheFunction.js +32 -0
  133. package/dist/bin/bundler/server/plugins/Transformer/TransformCreateSession.d.ts +3 -0
  134. package/dist/bin/bundler/server/plugins/Transformer/TransformCreateSession.js +30 -0
  135. package/dist/bin/bundler/server/plugins/Transformer/TransformExpress copy.d.ts +11 -0
  136. package/dist/bin/bundler/server/plugins/Transformer/TransformExpress copy.js +22 -0
  137. package/dist/bin/bundler/server/plugins/Transformer/TransformExpress.d.ts +10 -0
  138. package/dist/bin/bundler/server/plugins/Transformer/TransformExpress.js +19 -0
  139. package/dist/bin/bundler/server/plugins/Transformer/TransformExpressFunction.d.ts +3 -0
  140. package/dist/bin/bundler/server/plugins/Transformer/TransformExpressFunction.js +24 -0
  141. package/dist/bin/bundler/server/plugins/Transformer/TransformPage.d.ts +4 -0
  142. package/dist/bin/bundler/server/plugins/Transformer/TransformPage.js +31 -0
  143. package/dist/bin/bundler/server/plugins/Transformer/TransformReactContext.d.ts +17 -0
  144. package/dist/bin/bundler/server/plugins/Transformer/TransformReactContext.js +101 -0
  145. package/dist/bin/bundler/server/plugins/Transformer/TransformServer.d.ts +10 -0
  146. package/dist/bin/bundler/server/plugins/Transformer/TransformServer.js +19 -0
  147. package/dist/bin/bundler/server/plugins/Transformer/TransformServerAction copy.d.ts +14 -0
  148. package/dist/bin/bundler/server/plugins/Transformer/TransformServerAction copy.js +38 -0
  149. package/dist/bin/bundler/server/plugins/Transformer/TransformServerAction.d.ts +15 -0
  150. package/dist/bin/bundler/server/plugins/Transformer/TransformServerAction.js +44 -0
  151. package/dist/bin/bundler/server/plugins/Transformer/TransformServerFunction.d.ts +3 -0
  152. package/dist/bin/bundler/server/plugins/Transformer/TransformServerFunction.js +32 -0
  153. package/dist/bin/bundler/server/plugins/Transformer/TransformUseServer.d.ts +3 -0
  154. package/dist/bin/bundler/server/plugins/Transformer/TransformUseServer.js +31 -0
  155. package/dist/bin/bundler/server/plugins/Transformer copy.d.ts +6 -0
  156. package/dist/bin/bundler/server/plugins/Transformer copy.js +99 -0
  157. package/dist/bin/bundler/server/plugins/Transformer.d.ts +7 -0
  158. package/dist/bin/bundler/server/plugins/Transformer.js +58 -0
  159. package/dist/bin/bundler/server/plugins/replacer/cacheFunctionReplacer.d.ts +3 -0
  160. package/dist/bin/bundler/server/plugins/replacer/cacheFunctionReplacer.js +28 -0
  161. package/dist/bin/bundler/server/plugins/replacer/expressFunctionReplace.d.ts +3 -0
  162. package/dist/bin/bundler/server/plugins/replacer/expressFunctionReplace.js +24 -0
  163. package/dist/bin/bundler/server/plugins/replacer/pageReplacer.d.ts +4 -0
  164. package/dist/bin/bundler/server/plugins/replacer/pageReplacer.js +31 -0
  165. package/dist/bin/bundler/server/plugins/replacer/serverFunctionReplacer.d.ts +3 -0
  166. package/dist/bin/bundler/server/plugins/replacer/serverFunctionReplacer.js +28 -0
  167. package/dist/bin/bundler/server/plugins/replacer/useServerReplacer.d.ts +3 -0
  168. package/dist/bin/bundler/server/plugins/replacer/useServerReplacer.js +38 -0
  169. package/dist/bin/bundler/server/types.d.ts +5 -0
  170. package/dist/bin/bundler/server/types.js +1 -0
  171. package/dist/bin/bundler/server/watch.config.d.ts +3 -0
  172. package/dist/bin/bundler/server/watch.config.js +71 -0
  173. package/dist/bin/bundler/server/watch.d.ts +9 -0
  174. package/dist/bin/bundler/server/watch.js +59 -0
  175. package/dist/bin/bundler/watchClient.d.ts +5 -3
  176. package/dist/bin/bundler/watchClient.js +31 -16
  177. package/dist/bin/bundler/watchServer.d.ts +2 -2
  178. package/dist/bin/bundler/watchServer.js +66 -12
  179. package/dist/bin/cli/build.js +29 -13
  180. package/dist/bin/cli/create.d.ts +2 -0
  181. package/dist/bin/cli/create.js +2 -0
  182. package/dist/bin/cli/dev/dev.d.ts +2 -0
  183. package/dist/bin/cli/dev/dev.js +178 -0
  184. package/dist/bin/cli/dev/index.d.ts +2 -0
  185. package/dist/bin/cli/dev/index.js +114 -0
  186. package/dist/bin/cli/dev/server.d.ts +1 -0
  187. package/dist/bin/cli/dev/server.js +95 -0
  188. package/dist/bin/cli/dev/ws.d.ts +2 -0
  189. package/dist/bin/cli/dev/ws.js +29 -0
  190. package/dist/bin/cli/dev.js +120 -76
  191. package/dist/bin/cli/logs.d.ts +2 -0
  192. package/dist/bin/cli/logs.js +224 -0
  193. package/dist/bin/cli/restart.d.ts +2 -0
  194. package/dist/bin/cli/restart.js +28 -0
  195. package/dist/bin/cli/resurrect.d.ts +2 -0
  196. package/dist/bin/cli/resurrect.js +79 -0
  197. package/dist/bin/cli/save.d.ts +2 -0
  198. package/dist/bin/cli/save.js +87 -0
  199. package/dist/bin/cli/start/external.d.ts +2 -0
  200. package/dist/bin/cli/start/external.js +22 -0
  201. package/dist/bin/cli/start/index.d.ts +2 -0
  202. package/dist/bin/cli/start/index.js +27 -0
  203. package/dist/bin/cli/start/start.d.ts +2 -0
  204. package/dist/bin/cli/start/start.js +27 -0
  205. package/dist/bin/cli/start.js +10 -17
  206. package/dist/bin/cli/startup.d.ts +2 -0
  207. package/dist/bin/cli/startup.js +170 -0
  208. package/dist/bin/cli/status.d.ts +2 -0
  209. package/dist/bin/cli/status.js +23 -0
  210. package/dist/bin/cli/stop.d.ts +4 -0
  211. package/dist/bin/cli/stop.js +83 -0
  212. package/dist/bin/include/callbackReplacer.d.ts +2 -0
  213. package/dist/bin/include/callbackReplacer.js +91 -0
  214. package/dist/bin/include/importFinder.d.ts +9 -0
  215. package/dist/bin/include/importFinder.js +69 -0
  216. package/dist/bin/include/loadEnv.d.ts +19 -0
  217. package/dist/bin/include/loadEnv.js +47 -0
  218. package/dist/bin/include/manifest.d.ts +2 -3
  219. package/dist/bin/include/manifest.js +7 -23
  220. package/dist/bin/include/path.d.ts +1 -0
  221. package/dist/bin/include/path.js +4 -0
  222. package/dist/bin/include/process.d.ts +12 -0
  223. package/dist/bin/include/process.js +39 -0
  224. package/dist/bin/include/sendFinder.d.ts +6 -0
  225. package/dist/bin/include/sendFinder.js +100 -0
  226. package/dist/bin/include/utils.d.ts +3 -4
  227. package/dist/bin/include/utils.js +10 -12
  228. package/dist/bin/index.js +1 -1
  229. package/dist/bin/modifier/callbackReplacer.d.ts +2 -0
  230. package/dist/bin/modifier/callbackReplacer.js +97 -0
  231. package/dist/bin/modifier/importFinder.d.ts +9 -0
  232. package/dist/bin/modifier/importFinder.js +69 -0
  233. package/dist/bin/modifier/pageFinder.d.ts +9 -0
  234. package/dist/bin/modifier/pageFinder.js +135 -0
  235. package/dist/bin/modifier/sriptCommnet.d.ts +2 -0
  236. package/dist/bin/modifier/sriptCommnet.js +8 -0
  237. package/dist/bin/plugins/XanixAssets.d.ts +6 -0
  238. package/dist/bin/plugins/XanixAssets.js +43 -0
  239. package/dist/bin/plugins/XanixCss.d.ts +5 -0
  240. package/dist/bin/plugins/XanixCss.js +57 -0
  241. package/dist/bin/plugins/XanixDocument/XanixDocument.d.ts +2 -0
  242. package/dist/bin/plugins/XanixDocument/XanixDocument.js +50 -0
  243. package/dist/bin/plugins/XanixDocument/index.d.ts +2 -0
  244. package/dist/bin/plugins/XanixDocument/index.js +50 -0
  245. package/dist/bin/plugins/XanixDocument.d.ts +2 -0
  246. package/dist/bin/plugins/XanixDocument.js +39 -0
  247. package/dist/bin/plugins/XanixPageTransform-dep/index.d.ts +2 -0
  248. package/dist/bin/plugins/XanixPageTransform-dep/index.js +62 -0
  249. package/dist/bin/plugins/XanixPageTransform-dep/transformer.d.ts +23 -0
  250. package/dist/bin/plugins/XanixPageTransform-dep/transformer.js +589 -0
  251. package/dist/bin/plugins/XanixServerTransform.d.ts +5 -0
  252. package/dist/bin/plugins/XanixServerTransform.js +207 -0
  253. package/dist/bin/plugins/XanixTsconfigAlias.d.ts +19 -0
  254. package/dist/bin/plugins/XanixTsconfigAlias.js +197 -0
  255. package/dist/bin/plugins/XanixUseServer.d.ts +7 -0
  256. package/dist/bin/plugins/XanixUseServer.js +445 -0
  257. package/dist/bin/plugins/plugins.d.ts +8 -0
  258. package/dist/bin/plugins/plugins.js +31 -0
  259. package/dist/bin/types.d.ts +2 -8
  260. package/dist/client-runtime.d.ts +0 -8
  261. package/dist/client-runtime.js +45 -103
  262. package/dist/components/BaseDocument.d.ts +1 -1
  263. package/dist/components/BaseDocument.js +2 -2
  264. package/dist/components/Body.d.ts +3 -4
  265. package/dist/components/Body.js +4 -3
  266. package/dist/components/Document.d.ts +3 -4
  267. package/dist/components/Document.js +3 -4
  268. package/dist/components/DocumentContext.d.ts +5 -3
  269. package/dist/components/Head.d.ts +3 -2
  270. package/dist/components/Head.js +17 -10
  271. package/dist/components/Link.d.ts +2 -2
  272. package/dist/components/Link.js +14 -26
  273. package/dist/dev.d.ts +1 -0
  274. package/dist/dev.js +25 -0
  275. package/dist/hooks/cache.d.ts +19 -0
  276. package/dist/hooks/cache.js +53 -0
  277. package/dist/hooks/encript.d.ts +2 -0
  278. package/dist/hooks/encript.js +30 -0
  279. package/dist/hooks/server.d.ts +11 -0
  280. package/dist/hooks/server.js +129 -0
  281. package/dist/hooks/session.d.ts +18 -0
  282. package/dist/hooks/session.js +145 -0
  283. package/dist/hooks/useCookies.d.ts +1 -0
  284. package/dist/hooks/useCookies.js +9 -40
  285. package/dist/hooks/usePage.d.ts +2 -2
  286. package/dist/hooks/usePage.js +2 -5
  287. package/dist/hooks/useSearchParams.js +30 -88
  288. package/dist/hooks/useServer.d.ts +20 -0
  289. package/dist/hooks/useServer.js +91 -0
  290. package/dist/hooks/useStore.d.ts +13 -0
  291. package/dist/hooks/useStore.js +45 -0
  292. package/dist/index.d.ts +19 -6
  293. package/dist/index.js +11 -7
  294. package/dist/navigate.d.ts +4 -6
  295. package/dist/navigate.js +109 -17
  296. package/dist/outdirs.d.ts +1 -1
  297. package/dist/outdirs.js +2 -2
  298. package/dist/react/createContext.d.ts +3 -0
  299. package/dist/react/createContext.js +11 -0
  300. package/dist/react/index.d.ts +12 -0
  301. package/dist/react/index.js +3 -0
  302. package/dist/server/express/Router.d.ts +2 -0
  303. package/dist/server/express/Router.js +115 -0
  304. package/dist/server/express/Ruter.d.ts +2 -0
  305. package/dist/server/express/Ruter.js +15 -0
  306. package/dist/server/express/index.d.ts +3 -0
  307. package/dist/server/express/index.js +90 -0
  308. package/dist/server/express/page.d.ts +10 -0
  309. package/dist/server/express/page.js +133 -0
  310. package/dist/server/index.d.ts +19 -0
  311. package/dist/server/index.js +44 -1
  312. package/dist/server/runtime/createServer.js +2 -0
  313. package/dist/server/runtime/readManifest.js +1 -1
  314. package/dist/server/runtime/xanixPage.js +9 -15
  315. package/dist/server/types.d.ts +52 -0
  316. package/dist/server/types.js +1 -0
  317. package/dist/types/assets.d.ts +72 -34
  318. package/dist/types/express.d.ts +11 -7
  319. package/dist/types/globals.d.ts +18 -26
  320. package/dist/types/xanix-virtual.d.ts +35 -41
  321. package/package.json +60 -72
  322. package/dist/bin/bundler/cacheNpmModules.d.ts +0 -11
  323. package/dist/bin/bundler/dep-generateClientEntries.d.ts +0 -5
  324. package/dist/bin/bundler/dep-generateClientEntries.js +0 -25
  325. package/dist/bin/bundler/generateClientEntries.d.ts +0 -5
  326. package/dist/bin/bundler/generateClientEntries.js +0 -25
  327. package/dist/bin/bundler/plugins/xanixUseDataId.d.ts +0 -4
  328. package/dist/bin/bundler/plugins/xanixUseDataId.js +0 -93
  329. package/dist/bin/cli/browser.d.ts +0 -1
  330. package/dist/bin/cli/browser.js +0 -97
  331. package/dist/dataLoader.d.ts +0 -11
  332. package/dist/dataLoader.js +0 -52
  333. package/dist/hooks/useData.d.ts +0 -14
  334. package/dist/hooks/useData.js +0 -68
  335. package/dist/hooks/useRequest copy.d.ts +0 -2
  336. package/dist/hooks/useRequest copy.js +0 -8
  337. package/dist/hooks/useServer/core.d.ts +0 -20
  338. package/dist/hooks/useServer/core.js +0 -72
  339. package/dist/hooks/useServer/index.d.ts +0 -20
  340. package/dist/hooks/useServer/index.js +0 -76
  341. package/dist/hooks/useServer/registry.d.ts +0 -0
  342. package/dist/hooks/useServer/registry.js +0 -1
  343. package/dist/hooks/useServer/resource.d.ts +0 -11
  344. package/dist/hooks/useServer/resource.js +0 -49
  345. package/dist/hooks/useServer/state.d.ts +0 -9
  346. package/dist/hooks/useServer/state.js +0 -33
  347. package/dist/theme.d.ts +0 -3
  348. package/dist/theme.js +0 -10
  349. /package/dist/bin/{browser.d.ts → cli/start/utils.d.ts} +0 -0
  350. /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 getJSXComponentName(node: t.JSXElement): string | null;
18
- export declare function transformer(code: string, id: string): XanixTransformResult | null;
22
+ export declare function transformer(code: string, id: string, ast: AstNode): XanixTransformResult | null;
23
+ export {};