xanix 1.0.20 → 1.0.21

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 (275) hide show
  1. package/dist/bin/bundler/cache/buildCache.js +9 -11
  2. package/dist/bin/bundler/cache/index.js +70 -116
  3. package/dist/bin/bundler/cache/utils.d.ts +3 -2
  4. package/dist/bin/bundler/cache/utils.js +27 -24
  5. package/dist/bin/bundler/client/build.js +1 -1
  6. package/dist/bin/bundler/client/plugins/Transformer/TransformCacheFunction copy.d.ts +3 -0
  7. package/dist/bin/bundler/client/plugins/Transformer/TransformCacheFunction copy.js +32 -0
  8. package/dist/bin/bundler/client/plugins/Transformer/TransformCacheFunction.d.ts +1 -1
  9. package/dist/bin/bundler/client/plugins/Transformer/TransformCacheFunction.js +1 -1
  10. package/dist/bin/bundler/client/plugins/Transformer/TransformCreateSession.d.ts +1 -1
  11. package/dist/bin/bundler/client/plugins/Transformer/TransformCreateSession.js +1 -1
  12. package/dist/bin/bundler/client/plugins/Transformer/TransformDevModule.d.ts +13 -0
  13. package/dist/bin/bundler/client/plugins/Transformer/{transformModuleCache.js → TransformDevModule.js} +6 -18
  14. package/dist/bin/bundler/client/plugins/Transformer/TransformServerFunction.d.ts +1 -1
  15. package/dist/bin/bundler/client/plugins/Transformer/TransformServerFunction.js +1 -1
  16. package/dist/bin/bundler/client/plugins/Transformer/cacheFunctionReplacer.d.ts +3 -0
  17. package/dist/bin/bundler/client/plugins/Transformer/cacheFunctionReplacer.js +32 -0
  18. package/dist/bin/bundler/client/plugins/Transformer/cacheFunctionTransformer.d.ts +3 -0
  19. package/dist/bin/bundler/client/plugins/Transformer/cacheFunctionTransformer.js +32 -0
  20. package/dist/bin/bundler/client/plugins/Transformer/serverFunctionReplacer.d.ts +3 -0
  21. package/dist/bin/bundler/client/plugins/Transformer/serverFunctionReplacer.js +32 -0
  22. package/dist/bin/bundler/client/plugins/Transformer/useServerReplacer.d.ts +3 -0
  23. package/dist/bin/bundler/client/plugins/Transformer/useServerReplacer.js +42 -0
  24. package/dist/bin/bundler/client/plugins/Transformer.js +4 -2
  25. package/dist/bin/bundler/client/plugins/XanixAppRoot.d.ts +2 -0
  26. package/dist/bin/bundler/client/plugins/XanixAppRoot.js +46 -0
  27. package/dist/bin/bundler/client/plugins/XanixPage.js +30 -0
  28. package/dist/bin/bundler/client/plugins/XanixPages.js +8 -8
  29. package/dist/bin/bundler/client/plugins/replacer/cacheFunctionReplacer.d.ts +1 -1
  30. package/dist/bin/bundler/client/plugins/replacer/cacheFunctionReplacer.js +5 -1
  31. package/dist/bin/bundler/client/plugins/replacer/serverFunctionReplacer.d.ts +1 -1
  32. package/dist/bin/bundler/client/plugins/replacer/serverFunctionReplacer.js +5 -1
  33. package/dist/bin/bundler/client/plugins/replacer/useServerReplacer.d.ts +1 -1
  34. package/dist/bin/bundler/client/plugins/replacer/useServerReplacer.js +7 -3
  35. package/dist/bin/bundler/server/build.js +1 -1
  36. package/dist/bin/bundler/server/plugins/Transformer/TransformCacheFunction copy.d.ts +3 -0
  37. package/dist/bin/bundler/server/plugins/Transformer/TransformCacheFunction copy.js +32 -0
  38. package/dist/bin/bundler/server/plugins/Transformer/TransformCacheFunction.d.ts +1 -1
  39. package/dist/bin/bundler/server/plugins/Transformer/TransformCacheFunction.js +1 -1
  40. package/dist/bin/bundler/server/plugins/Transformer/TransformCreateSession.d.ts +1 -1
  41. package/dist/bin/bundler/server/plugins/Transformer/TransformCreateSession.js +1 -1
  42. package/dist/bin/bundler/server/plugins/Transformer/TransformExpressFunction.d.ts +1 -1
  43. package/dist/bin/bundler/server/plugins/Transformer/TransformExpressFunction.js +1 -1
  44. package/dist/bin/bundler/server/plugins/Transformer/TransformPage.js +1 -1
  45. package/dist/bin/bundler/server/plugins/Transformer/TransformServerFunction.d.ts +1 -1
  46. package/dist/bin/bundler/server/plugins/Transformer/TransformServerFunction.js +1 -1
  47. package/dist/bin/bundler/server/plugins/Transformer/cacheFunctionReplacer.d.ts +3 -0
  48. package/dist/bin/bundler/server/plugins/Transformer/cacheFunctionReplacer.js +32 -0
  49. package/dist/bin/bundler/server/plugins/Transformer/expressFunctionReplace.d.ts +3 -0
  50. package/dist/bin/bundler/server/plugins/Transformer/expressFunctionReplace.js +24 -0
  51. package/dist/bin/bundler/server/plugins/Transformer/pageReplacer.d.ts +4 -0
  52. package/dist/bin/bundler/server/plugins/Transformer/pageReplacer.js +31 -0
  53. package/dist/bin/bundler/server/plugins/Transformer/serverFunctionReplacer.d.ts +3 -0
  54. package/dist/bin/bundler/server/plugins/Transformer/serverFunctionReplacer.js +32 -0
  55. package/dist/bin/bundler/server/plugins/Transformer/useServerReplacer.d.ts +3 -0
  56. package/dist/bin/bundler/server/plugins/Transformer/useServerReplacer.js +42 -0
  57. package/dist/bin/bundler/server/plugins/Transformer copy.js +3 -3
  58. package/dist/bin/bundler/server/plugins/Transformer.js +2 -2
  59. package/dist/bin/bundler/server/plugins/replacer/cacheFunctionReplacer.d.ts +1 -1
  60. package/dist/bin/bundler/server/plugins/replacer/cacheFunctionReplacer.js +5 -1
  61. package/dist/bin/bundler/server/plugins/replacer/serverFunctionReplacer copy.d.ts +3 -0
  62. package/dist/bin/bundler/server/plugins/replacer/serverFunctionReplacer copy.js +26 -0
  63. package/dist/bin/bundler/server/plugins/replacer/serverFunctionReplacer.d.ts +1 -1
  64. package/dist/bin/bundler/server/plugins/replacer/serverFunctionReplacer.js +5 -1
  65. package/dist/bin/bundler/server/plugins/replacer/serverReplacer.d.ts +3 -0
  66. package/dist/bin/bundler/server/plugins/replacer/serverReplacer.js +26 -0
  67. package/dist/bin/bundler/server/plugins/replacer/useServerReplacer.d.ts +2 -2
  68. package/dist/bin/bundler/server/plugins/replacer/useServerReplacer.js +9 -5
  69. package/dist/bin/cli/dev.js +85 -71
  70. package/dist/bin/cli/start/index.d.ts +4 -1
  71. package/dist/bin/cli/start/index.js +60 -9
  72. package/dist/bin/finder/callbackReplacer.d.ts +2 -0
  73. package/dist/bin/finder/callbackReplacer.js +52 -0
  74. package/dist/bin/finder/findImport.d.ts +9 -0
  75. package/dist/bin/finder/findImport.js +50 -0
  76. package/dist/bin/finder/findImports.d.ts +16 -0
  77. package/dist/bin/finder/findImports.js +45 -0
  78. package/dist/bin/finder/findPage.d.ts +9 -0
  79. package/dist/bin/finder/findPage.js +30 -0
  80. package/dist/bin/finder/importFinder.d.ts +9 -0
  81. package/dist/bin/finder/importFinder.js +50 -0
  82. package/dist/bin/finder/pageFinder.d.ts +9 -0
  83. package/dist/bin/finder/pageFinder.js +30 -0
  84. package/dist/bin/finder/stripComments.d.ts +3 -0
  85. package/dist/bin/finder/stripComments.js +15 -0
  86. package/dist/bin/include/path.d.ts +5 -1
  87. package/dist/bin/include/path.js +15 -1
  88. package/dist/bin/include/sendFinder.d.ts +4 -1
  89. package/dist/bin/include/sendFinder.js +88 -53
  90. package/dist/bin/index.js +0 -0
  91. package/dist/bin/modifier/callbackReplacer.js +35 -80
  92. package/dist/bin/modifier/findImports.d.ts +16 -0
  93. package/dist/bin/modifier/findImports.js +45 -0
  94. package/dist/bin/modifier/importFinder.js +44 -63
  95. package/dist/bin/modifier/pageFinder.d.ts +1 -1
  96. package/dist/bin/modifier/pageFinder.js +19 -124
  97. package/dist/bin/modifier/sendFinder.d.ts +9 -0
  98. package/dist/bin/modifier/sendFinder.js +135 -0
  99. package/dist/bin/modifier/sriptCommnet.d.ts +1 -0
  100. package/dist/bin/modifier/sriptCommnet.js +12 -5
  101. package/dist/bin/modifier/stripComments.d.ts +3 -0
  102. package/dist/bin/modifier/stripComments.js +15 -0
  103. package/dist/bin/plugins/XanixAssets.js +2 -2
  104. package/dist/bin/plugins/XanixCss.js +13 -13
  105. package/dist/bin/plugins/XanixDocument.js +4 -4
  106. package/dist/components/Head.js +1 -1
  107. package/dist/hooks/encript.d.ts +2 -0
  108. package/dist/hooks/encript.js +13 -0
  109. package/dist/hooks/server.js +2 -2
  110. package/dist/hooks/session.js +2 -2
  111. package/dist/index.js +0 -0
  112. package/dist/libs/encoder.d.ts +2 -0
  113. package/dist/libs/encoder.js +13 -0
  114. package/dist/libs/encript.d.ts +2 -0
  115. package/dist/libs/encript.js +30 -0
  116. package/dist/navigate.js +1 -1
  117. package/dist/server/express/Router.js +4 -4
  118. package/dist/server/express/page.d.ts +1 -1
  119. package/dist/server/express/page.js +1 -1
  120. package/dist/types/assets.d.ts +72 -72
  121. package/dist/types/express.d.ts +11 -11
  122. package/dist/types/globals.d.ts +18 -18
  123. package/dist/types/xanix-virtual.d.ts +35 -35
  124. package/package.json +57 -60
  125. package/dist/bin/bundler/Cache.d.ts +0 -1
  126. package/dist/bin/bundler/Cache.js +0 -210
  127. package/dist/bin/bundler/External.d.ts +0 -3
  128. package/dist/bin/bundler/External.js +0 -6
  129. package/dist/bin/bundler/buildClient.d.ts +0 -3
  130. package/dist/bin/bundler/buildClient.js +0 -42
  131. package/dist/bin/bundler/buildServer.d.ts +0 -7
  132. package/dist/bin/bundler/buildServer.js +0 -50
  133. package/dist/bin/bundler/cache/plugin/Transformer.d.ts +0 -3
  134. package/dist/bin/bundler/cache/plugin/Transformer.js +0 -42
  135. package/dist/bin/bundler/client/plugins/Transformer/TransformExpress.d.ts +0 -9
  136. package/dist/bin/bundler/client/plugins/Transformer/TransformExpress.js +0 -26
  137. package/dist/bin/bundler/client/plugins/Transformer/TransformPage.d.ts +0 -29
  138. package/dist/bin/bundler/client/plugins/Transformer/TransformPage.js +0 -77
  139. package/dist/bin/bundler/client/plugins/Transformer/TransformReactContext.d.ts +0 -17
  140. package/dist/bin/bundler/client/plugins/Transformer/TransformReactContext.js +0 -101
  141. package/dist/bin/bundler/client/plugins/Transformer/transformModuleCache.d.ts +0 -15
  142. package/dist/bin/bundler/client/plugins/Transformer copy.d.ts +0 -3
  143. package/dist/bin/bundler/client/plugins/Transformer copy.js +0 -70
  144. package/dist/bin/bundler/client/plugins/VirtualDev.d.ts +0 -2
  145. package/dist/bin/bundler/client/plugins/VirtualDev.js +0 -34
  146. package/dist/bin/bundler/client/plugins/XanixReactRefresh.d.ts +0 -2
  147. package/dist/bin/bundler/client/plugins/XanixReactRefresh.js +0 -22
  148. package/dist/bin/bundler/config/defines.d.ts +0 -20
  149. package/dist/bin/bundler/config/defines.js +0 -21
  150. package/dist/bin/bundler/config/external.d.ts +0 -1
  151. package/dist/bin/bundler/config/external.js +0 -12
  152. package/dist/bin/bundler/config/loadEnv.d.ts +0 -20
  153. package/dist/bin/bundler/config/loadEnv.js +0 -48
  154. package/dist/bin/bundler/config/output.d.ts +0 -10
  155. package/dist/bin/bundler/config/output.js +0 -52
  156. package/dist/bin/bundler/externalResolver-dep.d.ts +0 -3
  157. package/dist/bin/bundler/externalResolver-dep.js +0 -203
  158. package/dist/bin/bundler/externalResolver.d.ts +0 -3
  159. package/dist/bin/bundler/externalResolver.js +0 -203
  160. package/dist/bin/bundler/plugins/TransformServer/TransformExpress.d.ts +0 -9
  161. package/dist/bin/bundler/plugins/TransformServer/TransformExpress.js +0 -26
  162. package/dist/bin/bundler/plugins/TransformServer/TransformPage.d.ts +0 -25
  163. package/dist/bin/bundler/plugins/TransformServer/TransformPage.js +0 -79
  164. package/dist/bin/bundler/plugins/TransformServer/index.d.ts +0 -3
  165. package/dist/bin/bundler/plugins/TransformServer/index.js +0 -103
  166. package/dist/bin/bundler/plugins/XanixAssets.d.ts +0 -5
  167. package/dist/bin/bundler/plugins/XanixAssets.js +0 -51
  168. package/dist/bin/bundler/plugins/XanixCacheDeps-dep.d.ts +0 -2
  169. package/dist/bin/bundler/plugins/XanixCacheDeps-dep.js +0 -150
  170. package/dist/bin/bundler/plugins/XanixCacheDeps.d.ts +0 -2
  171. package/dist/bin/bundler/plugins/XanixCacheDeps.js +0 -150
  172. package/dist/bin/bundler/plugins/XanixDocument/index.js +0 -53
  173. package/dist/bin/bundler/plugins/XanixEntryFinder/finder.d.ts +0 -11
  174. package/dist/bin/bundler/plugins/XanixEntryFinder/finder.js +0 -149
  175. package/dist/bin/bundler/plugins/XanixEntryFinder/index.d.ts +0 -6
  176. package/dist/bin/bundler/plugins/XanixEntryFinder/index.js +0 -37
  177. package/dist/bin/bundler/plugins/XanixEntryFinder-dep/finder.d.ts +0 -11
  178. package/dist/bin/bundler/plugins/XanixEntryFinder-dep/finder.js +0 -149
  179. package/dist/bin/bundler/plugins/XanixEntryFinder-dep/index.d.ts +0 -6
  180. package/dist/bin/bundler/plugins/XanixEntryFinder-dep/index.js +0 -37
  181. package/dist/bin/bundler/plugins/XanixEnv.d.ts +0 -15
  182. package/dist/bin/bundler/plugins/XanixEnv.js +0 -44
  183. package/dist/bin/bundler/plugins/XanixPageTransform/index.d.ts +0 -2
  184. package/dist/bin/bundler/plugins/XanixPageTransform/index.js +0 -62
  185. package/dist/bin/bundler/plugins/XanixPageTransform/transformer copy.d.ts +0 -18
  186. package/dist/bin/bundler/plugins/XanixPageTransform/transformer copy.js +0 -414
  187. package/dist/bin/bundler/plugins/XanixPageTransform/transformer.d.ts +0 -23
  188. package/dist/bin/bundler/plugins/XanixPageTransform/transformer.js +0 -589
  189. package/dist/bin/bundler/plugins/XanixReactRefresh copy.d.ts +0 -2
  190. package/dist/bin/bundler/plugins/XanixReactRefresh copy.js +0 -121
  191. package/dist/bin/bundler/plugins/XanixReactRefresh.d.ts +0 -2
  192. package/dist/bin/bundler/plugins/XanixReactRefresh.js +0 -170
  193. package/dist/bin/bundler/plugins/XanixResolveCacheDeps/BuildClientCache.d.ts +0 -11
  194. package/dist/bin/bundler/plugins/XanixResolveCacheDeps/BuildClientCache.js +0 -129
  195. package/dist/bin/bundler/plugins/XanixResolveCacheDeps/index copy.d.ts +0 -15
  196. package/dist/bin/bundler/plugins/XanixResolveCacheDeps/index copy.js +0 -228
  197. package/dist/bin/bundler/plugins/XanixResolveCacheDeps/index.d.ts +0 -7
  198. package/dist/bin/bundler/plugins/XanixResolveCacheDeps/index.js +0 -166
  199. package/dist/bin/bundler/plugins/XanixResolveCacheDeps-dep/BuildClientCache.d.ts +0 -11
  200. package/dist/bin/bundler/plugins/XanixResolveCacheDeps-dep/BuildClientCache.js +0 -129
  201. package/dist/bin/bundler/plugins/XanixResolveCacheDeps-dep/index.d.ts +0 -5
  202. package/dist/bin/bundler/plugins/XanixResolveCacheDeps-dep/index.js +0 -26
  203. package/dist/bin/bundler/plugins/XanixResolver.d.ts +0 -11
  204. package/dist/bin/bundler/plugins/XanixResolver.js +0 -55
  205. package/dist/bin/bundler/plugins/XanixServerTransform.d.ts +0 -5
  206. package/dist/bin/bundler/plugins/XanixServerTransform.js +0 -207
  207. package/dist/bin/bundler/plugins/XanixTransform.d.ts +0 -3
  208. package/dist/bin/bundler/plugins/XanixTransform.js +0 -23
  209. package/dist/bin/bundler/plugins/XanixTsconfigAlias.d.ts +0 -19
  210. package/dist/bin/bundler/plugins/XanixTsconfigAlias.js +0 -197
  211. package/dist/bin/bundler/plugins/XanixUseServer.d.ts +0 -7
  212. package/dist/bin/bundler/plugins/XanixUseServer.js +0 -445
  213. package/dist/bin/bundler/plugins/plugins.d.ts +0 -9
  214. package/dist/bin/bundler/plugins/plugins.js +0 -37
  215. package/dist/bin/bundler/requireCache.d.ts +0 -3
  216. package/dist/bin/bundler/requireCache.js +0 -85
  217. package/dist/bin/bundler/server/plugins/ServerAction.d.ts +0 -3
  218. package/dist/bin/bundler/server/plugins/ServerAction.js +0 -9
  219. package/dist/bin/bundler/server/plugins/Transformer/ServerAction.d.ts +0 -11
  220. package/dist/bin/bundler/server/plugins/Transformer/ServerAction.js +0 -28
  221. package/dist/bin/bundler/server/plugins/Transformer/TransformExpress copy.d.ts +0 -11
  222. package/dist/bin/bundler/server/plugins/Transformer/TransformExpress copy.js +0 -22
  223. package/dist/bin/bundler/server/plugins/Transformer/TransformExpress.d.ts +0 -10
  224. package/dist/bin/bundler/server/plugins/Transformer/TransformExpress.js +0 -19
  225. package/dist/bin/bundler/server/plugins/Transformer/TransformReactContext.d.ts +0 -17
  226. package/dist/bin/bundler/server/plugins/Transformer/TransformReactContext.js +0 -101
  227. package/dist/bin/bundler/server/plugins/Transformer/TransformServerAction copy.d.ts +0 -14
  228. package/dist/bin/bundler/server/plugins/Transformer/TransformServerAction copy.js +0 -38
  229. package/dist/bin/bundler/server/types.d.ts +0 -5
  230. package/dist/bin/bundler/server/types.js +0 -1
  231. package/dist/bin/bundler/watchClient.d.ts +0 -12
  232. package/dist/bin/bundler/watchClient.js +0 -104
  233. package/dist/bin/bundler/watchServer.d.ts +0 -10
  234. package/dist/bin/bundler/watchServer.js +0 -139
  235. package/dist/bin/cli/dev/dev.d.ts +0 -2
  236. package/dist/bin/cli/dev/dev.js +0 -178
  237. package/dist/bin/cli/start/start.d.ts +0 -2
  238. package/dist/bin/cli/start/start.js +0 -27
  239. package/dist/bin/include/entry.d.ts +0 -2
  240. package/dist/bin/include/entry.js +0 -21
  241. package/dist/bin/plugins/XanixDocument/XanixDocument.d.ts +0 -2
  242. package/dist/bin/plugins/XanixDocument/XanixDocument.js +0 -50
  243. package/dist/bin/plugins/XanixDocument/index.d.ts +0 -2
  244. package/dist/bin/plugins/XanixDocument/index.js +0 -50
  245. package/dist/bin/plugins/XanixPageTransform-dep/index.d.ts +0 -2
  246. package/dist/bin/plugins/XanixPageTransform-dep/index.js +0 -62
  247. package/dist/bin/plugins/XanixPageTransform-dep/transformer.d.ts +0 -23
  248. package/dist/bin/plugins/XanixPageTransform-dep/transformer.js +0 -589
  249. package/dist/bin/plugins/XanixServerTransform.d.ts +0 -5
  250. package/dist/bin/plugins/XanixServerTransform.js +0 -207
  251. package/dist/bin/plugins/XanixUseServer.d.ts +0 -7
  252. package/dist/bin/plugins/XanixUseServer.js +0 -445
  253. package/dist/bin/plugins/plugins.d.ts +0 -8
  254. package/dist/bin/plugins/plugins.js +0 -31
  255. package/dist/components/Script.d.ts +0 -3
  256. package/dist/components/Script.js +0 -5
  257. package/dist/dev.d.ts +0 -1
  258. package/dist/dev.js +0 -25
  259. package/dist/react/createContext.d.ts +0 -3
  260. package/dist/react/createContext.js +0 -11
  261. package/dist/react/index.d.ts +0 -12
  262. package/dist/react/index.js +0 -3
  263. package/dist/server/express/Ruter.d.ts +0 -2
  264. package/dist/server/express/Ruter.js +0 -15
  265. package/dist/server/runtime/createServer.d.ts +0 -12
  266. package/dist/server/runtime/createServer.js +0 -62
  267. package/dist/server/runtime/index.d.ts +0 -3
  268. package/dist/server/runtime/index.js +0 -3
  269. package/dist/server/runtime/readManifest.d.ts +0 -14
  270. package/dist/server/runtime/readManifest.js +0 -9
  271. package/dist/server/runtime/xanixPage.d.ts +0 -11
  272. package/dist/server/runtime/xanixPage.js +0 -92
  273. /package/dist/bin/bundler/{plugins/XanixDocument/index.d.ts → client/plugins/XanixPage.d.ts} +0 -0
  274. /package/dist/bin/{cli/start/utils.d.ts → bundler/server/plugins/replacer/useServer.d.ts} +0 -0
  275. /package/dist/bin/{cli/start/utils.js → bundler/server/plugins/replacer/useServer.js} +0 -0
@@ -1,135 +1,30 @@
1
+ import findImports from "./findImports.js";
2
+ const ID = "[A-Za-z_$][\\w$]*";
1
3
  function pageFinder(code) {
2
- const results = [];
3
- // Only store DEFAULT imports.
4
- //
5
- // import Home from "./Home";
6
- // import Layout, { Header } from "./Layout";
7
- // import Components, * as UI from "./components";
8
- //
9
- // Does NOT store:
10
- // import { Layout } from "./Layout";
11
- // import * as Pages from "./pages";
4
+ // default imports only:
5
+ // import Home from "./Home";
6
+ // import Layout, { Header } from "./Layout";
7
+ // import Components, * as UI from "./components";
12
8
  const defaultImports = new Map();
13
- const defaultImportRegex = /import\s+([A-Za-z_$][\w$]*)\s*(?:,\s*(?:\{[^}]*\}|\*\s+as\s+[A-Za-z_$][\w$]*))?\s+from\s*["']([^"']+)["']/g;
14
- for (const match of code.matchAll(defaultImportRegex)) {
15
- const local = match[1];
16
- const file = match[2];
17
- defaultImports.set(local, file);
9
+ for (const imp of findImports(code)) {
10
+ if (imp.default && !imp.typeOnly)
11
+ defaultImports.set(imp.default, imp.source);
18
12
  }
19
- const sendRegex = /([A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*)\.send\s*\(/g;
20
- let match;
21
- while ((match = sendRegex.exec(code))) {
22
- const identifier = `${match[1]}`;
23
- const start = match.index;
24
- const argsStart = sendRegex.lastIndex;
25
- let depth = 1;
26
- let i = argsStart;
27
- let quote = null;
28
- for (; i < code.length; i++) {
29
- const char = code[i];
30
- if (quote) {
31
- if (char === "\\") {
32
- i++;
33
- }
34
- else if (char === quote) {
35
- quote = null;
36
- }
37
- continue;
38
- }
39
- if (char === "'" || char === '"' || char === "`") {
40
- quote = char;
41
- continue;
42
- }
43
- if (char === "(") {
44
- depth++;
45
- }
46
- else if (char === ")") {
47
- depth--;
48
- if (depth === 0) {
49
- break;
50
- }
51
- }
52
- }
53
- if (depth !== 0) {
54
- break;
55
- }
56
- const end = i + 1;
57
- const content = code.slice(argsStart, i);
58
- const args = splitArguments(content);
59
- const firstArg = args[0]?.trim();
60
- if (!firstArg?.startsWith("<")) {
61
- continue;
62
- }
63
- // <Home />
64
- // <Home>
65
- const jsxMatch = firstArg.match(/^<([A-Z_$][\w$]*)/);
66
- if (!jsxMatch) {
67
- continue;
68
- }
69
- const component = jsxMatch[1];
70
- const source = defaultImports.get(component);
71
- if (!source) {
13
+ // only: <identifier>.send(<Component />)
14
+ const sendRe = new RegExp(`(${ID}(?:\\??\\.${ID})*)\\??\\.send\\s*\\(\\s*(<([A-Z_$][\\w$]*)\\s*/>)\\s*\\)`, "g");
15
+ const results = [];
16
+ for (const m of code.matchAll(sendRe)) {
17
+ const source = defaultImports.get(m[3]);
18
+ if (!source)
72
19
  continue;
73
- }
74
20
  results.push({
75
21
  source,
76
- identifier,
77
- args,
78
- start,
79
- end,
22
+ identifier: m[1],
23
+ args: [m[2]],
24
+ start: m.index,
25
+ end: m.index + m[0].length,
80
26
  });
81
27
  }
82
28
  return results;
83
29
  }
84
- function splitArguments(code) {
85
- const args = [];
86
- let start = 0;
87
- let paren = 0;
88
- let brace = 0;
89
- let bracket = 0;
90
- let quote = null;
91
- for (let i = 0; i < code.length; i++) {
92
- const char = code[i];
93
- if (quote) {
94
- if (char === "\\") {
95
- i++;
96
- }
97
- else if (char === quote) {
98
- quote = null;
99
- }
100
- continue;
101
- }
102
- if (char === "'" || char === '"' || char === "`") {
103
- quote = char;
104
- continue;
105
- }
106
- if (char === "(") {
107
- paren++;
108
- }
109
- else if (char === ")") {
110
- paren--;
111
- }
112
- else if (char === "{") {
113
- brace++;
114
- }
115
- else if (char === "}") {
116
- brace--;
117
- }
118
- else if (char === "[") {
119
- bracket++;
120
- }
121
- else if (char === "]") {
122
- bracket--;
123
- }
124
- else if (char === "," && paren === 0 && brace === 0 && bracket === 0) {
125
- args.push(code.slice(start, i).trim());
126
- start = i + 1;
127
- }
128
- }
129
- const last = code.slice(start).trim();
130
- if (last) {
131
- args.push(last);
132
- }
133
- return args;
134
- }
135
30
  export default pageFinder;
@@ -0,0 +1,9 @@
1
+ type SendFinderResult = {
2
+ file: string;
3
+ identifier: string;
4
+ args: string[];
5
+ start: number;
6
+ end: number;
7
+ };
8
+ export declare function sendFinder(code: string): SendFinderResult[];
9
+ export default sendFinder;
@@ -0,0 +1,135 @@
1
+ export function sendFinder(code) {
2
+ const results = [];
3
+ // Only store DEFAULT imports.
4
+ //
5
+ // import Home from "./Home";
6
+ // import Layout, { Header } from "./Layout";
7
+ // import Components, * as UI from "./components";
8
+ //
9
+ // Does NOT store:
10
+ // import { Layout } from "./Layout";
11
+ // import * as Pages from "./pages";
12
+ const defaultImports = new Map();
13
+ const defaultImportRegex = /import\s+([A-Za-z_$][\w$]*)\s*(?:,\s*(?:\{[^}]*\}|\*\s+as\s+[A-Za-z_$][\w$]*))?\s+from\s*["']([^"']+)["']/g;
14
+ for (const match of code.matchAll(defaultImportRegex)) {
15
+ const local = match[1];
16
+ const file = match[2];
17
+ defaultImports.set(local, file);
18
+ }
19
+ const sendRegex = /([A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*)\.send\s*\(/g;
20
+ let match;
21
+ while ((match = sendRegex.exec(code))) {
22
+ const identifier = `${match[1]}`;
23
+ const start = match.index;
24
+ const argsStart = sendRegex.lastIndex;
25
+ let depth = 1;
26
+ let i = argsStart;
27
+ let quote = null;
28
+ for (; i < code.length; i++) {
29
+ const char = code[i];
30
+ if (quote) {
31
+ if (char === "\\") {
32
+ i++;
33
+ }
34
+ else if (char === quote) {
35
+ quote = null;
36
+ }
37
+ continue;
38
+ }
39
+ if (char === "'" || char === '"' || char === "`") {
40
+ quote = char;
41
+ continue;
42
+ }
43
+ if (char === "(") {
44
+ depth++;
45
+ }
46
+ else if (char === ")") {
47
+ depth--;
48
+ if (depth === 0) {
49
+ break;
50
+ }
51
+ }
52
+ }
53
+ if (depth !== 0) {
54
+ break;
55
+ }
56
+ const end = i + 1;
57
+ const content = code.slice(argsStart, i);
58
+ const args = splitArguments(content);
59
+ const firstArg = args[0]?.trim();
60
+ if (!firstArg?.startsWith("<")) {
61
+ continue;
62
+ }
63
+ // <Home />
64
+ // <Home>
65
+ const jsxMatch = firstArg.match(/^<([A-Z_$][\w$]*)/);
66
+ if (!jsxMatch) {
67
+ continue;
68
+ }
69
+ const component = jsxMatch[1];
70
+ const file = defaultImports.get(component);
71
+ if (!file) {
72
+ continue;
73
+ }
74
+ results.push({
75
+ file,
76
+ identifier,
77
+ args,
78
+ start,
79
+ end,
80
+ });
81
+ }
82
+ return results;
83
+ }
84
+ function splitArguments(code) {
85
+ const args = [];
86
+ let start = 0;
87
+ let paren = 0;
88
+ let brace = 0;
89
+ let bracket = 0;
90
+ let quote = null;
91
+ for (let i = 0; i < code.length; i++) {
92
+ const char = code[i];
93
+ if (quote) {
94
+ if (char === "\\") {
95
+ i++;
96
+ }
97
+ else if (char === quote) {
98
+ quote = null;
99
+ }
100
+ continue;
101
+ }
102
+ if (char === "'" || char === '"' || char === "`") {
103
+ quote = char;
104
+ continue;
105
+ }
106
+ if (char === "(") {
107
+ paren++;
108
+ }
109
+ else if (char === ")") {
110
+ paren--;
111
+ }
112
+ else if (char === "{") {
113
+ brace++;
114
+ }
115
+ else if (char === "}") {
116
+ brace--;
117
+ }
118
+ else if (char === "[") {
119
+ bracket++;
120
+ }
121
+ else if (char === "]") {
122
+ bracket--;
123
+ }
124
+ else if (char === "," && paren === 0 && brace === 0 && bracket === 0) {
125
+ args.push(code.slice(start, i).trim());
126
+ start = i + 1;
127
+ }
128
+ }
129
+ const last = code.slice(start).trim();
130
+ if (last) {
131
+ args.push(last);
132
+ }
133
+ return args;
134
+ }
135
+ export default sendFinder;
@@ -1,2 +1,3 @@
1
+ export declare const TOKENS: RegExp;
1
2
  declare function stripComments(code: string): string;
2
3
  export default stripComments;
@@ -1,8 +1,15 @@
1
+ const STRING = /"(?:\\[\s\S]|[^"\\])*"|'(?:\\[\s\S]|[^'\\])*'/;
2
+ // template literal: allows `${ ... }` with strings/templates inside (no nested braces),
3
+ // falls back to a plain backtick string
4
+ const TEMPLATE = /`(?:\\[\s\S]|\$\{(?:[^{}`]|`(?:\\[\s\S]|[^`\\])*`)*\}|[^`\\$]|\$(?!\{))*`|`(?:\\[\s\S]|[^`\\])*`/;
5
+ // regex literal: only where a regex can legally start (after an operator,
6
+ // opening bracket, keyword or start of file), and `/` allowed inside [...]
7
+ const REGEX = /(?<=(?:^|[(,=:[!&|?{};<>~^%*]|\b(?:return|typeof|case|void|delete|throw|yield|await|in|of))\s*)\/(?![/*])(?:\\.|\[(?:\\.|[^\]\\\r\n])*\]|[^/\\\r\n[])+\/[dgimsuvy]*/;
8
+ const COMMENT = /\/\*[\s\S]*?\*\/|\/\/[^\r\n]*/;
9
+ export const TOKENS = new RegExp([STRING, TEMPLATE, REGEX, COMMENT].map((r) => r.source).join("|"), "g");
1
10
  function stripComments(code) {
2
- return code.replace(/("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|`(?:\\.|[^`\\])*`)|(\/\/[^\r\n]*|\/\*[\s\S]*?\*\/)/g, (match, stringLiteral) => {
3
- if (stringLiteral)
4
- return match;
5
- return match.replace(/[^\r\n]/g, " ");
6
- });
11
+ return code.replace(TOKENS, (m) => m[0] === "/" && (m[1] === "/" || m[1] === "*")
12
+ ? m.replace(/[^\r\n]/g, " ")
13
+ : m);
7
14
  }
8
15
  export default stripComments;
@@ -0,0 +1,3 @@
1
+ export declare const TOKENS: RegExp;
2
+ declare function stripComments(code: string): string;
3
+ export default stripComments;
@@ -0,0 +1,15 @@
1
+ const STRING = /"(?:\\[\s\S]|[^"\\])*"|'(?:\\[\s\S]|[^'\\])*'/;
2
+ // template literal: allows `${ ... }` with strings/templates inside (no nested braces),
3
+ // falls back to a plain backtick string
4
+ const TEMPLATE = /`(?:\\[\s\S]|\$\{(?:[^{}`]|`(?:\\[\s\S]|[^`\\])*`)*\}|[^`\\$]|\$(?!\{))*`|`(?:\\[\s\S]|[^`\\])*`/;
5
+ // regex literal: only where a regex can legally start (after an operator,
6
+ // opening bracket, keyword or start of file), and `/` allowed inside [...]
7
+ const REGEX = /(?<=(?:^|[(,=:[!&|?{};<>~^%*]|\b(?:return|typeof|case|void|delete|throw|yield|await|in|of))\s*)\/(?![/*])(?:\\.|\[(?:\\.|[^\]\\\r\n])*\]|[^/\\\r\n[])+\/[dgimsuvy]*/;
8
+ const COMMENT = /\/\*[\s\S]*?\*\/|\/\/[^\r\n]*/;
9
+ export const TOKENS = new RegExp([STRING, TEMPLATE, REGEX, COMMENT].map((r) => r.source).join("|"), "g");
10
+ function stripComments(code) {
11
+ return code.replace(TOKENS, (m) => m[0] === "/" && (m[1] === "/" || m[1] === "*")
12
+ ? m.replace(/[^\r\n]/g, " ")
13
+ : m);
14
+ }
15
+ export default stripComments;
@@ -32,8 +32,8 @@ export default function xanixAssets(assets) {
32
32
  };
33
33
  assets?.set(fileName, { ...asset, name: fileName });
34
34
  return {
35
- code: `import {xanix} from "xanix"
36
- const assetData = xanix.asset(${JSON.stringify(asset)});
35
+ code: `import {xanix} from "xanix"
36
+ const assetData = xanix.asset(${JSON.stringify(asset)});
37
37
  export default assetData;`,
38
38
  moduleSideEffects: true,
39
39
  moduleType: "js",
@@ -34,20 +34,20 @@ export default function xanixCSS(options = {}) {
34
34
  return null;
35
35
  }
36
36
  this.addWatchFile(file);
37
- const css = fs.readFileSync(file);
38
- const basename = path.basename(file, ".css");
39
- const fileName = `${basename}-${uuid(file, 8)}.css`;
40
- if (emit) {
41
- this.emitFile({
42
- type: "asset",
43
- name: fileName,
44
- source: css,
45
- });
46
- }
37
+ // this.emitFile({
38
+ // type: "asset",
39
+ // name: fileName,
40
+ // source: css,
41
+ // });
42
+ const asset = {
43
+ type: "css",
44
+ path: file,
45
+ name: `${uuid(file, 20)}.css`,
46
+ };
47
47
  return {
48
- code: `
49
- import {xanix} from "xanix"
50
- xanix.css(\`${file}\`, \`${fileName}\`);
48
+ code: `
49
+ import {xanix} from "xanix"
50
+ export default xanix.asset(${JSON.stringify(asset)});
51
51
  `,
52
52
  moduleType: "js",
53
53
  moduleSideEffects: true,
@@ -27,10 +27,10 @@ export default function xanixDocument() {
27
27
  const hasMetadata = /\bexport\s+(?:const|let|var|function)\s+metadata\b/.test(source) ||
28
28
  /\bexport\s*\{[^}]*\bmetadata\b[^}]*\}/.test(source);
29
29
  return {
30
- code: `
31
- import Document, * as DocumentModule from ${JSON.stringify(documentFile)};
32
- export default Document;
33
- export const metadata = ${hasMetadata ? "DocumentModule.metadata" : "async () => ({})"};
30
+ code: `
31
+ import Document, * as DocumentModule from ${JSON.stringify(documentFile)};
32
+ export default Document;
33
+ export const metadata = ${hasMetadata ? "DocumentModule.metadata" : "async () => ({})"};
34
34
  `,
35
35
  map: null,
36
36
  };
@@ -33,7 +33,7 @@ const Head = ({ children, ...props }) => {
33
33
  path,
34
34
  metadata,
35
35
  pagedata,
36
- })};
36
+ })};
37
37
  `,
38
38
  } })] }));
39
39
  }
@@ -1,2 +1,4 @@
1
1
  export declare function encrypt(text: string, secret: string): string;
2
2
  export declare function decrypt(data: string, secret: string): string;
3
+ export declare function encode(value: unknown): Uint8Array;
4
+ export declare function decode(bytes: Uint8Array): any;
@@ -28,3 +28,16 @@ export function decrypt(data, secret) {
28
28
  ]);
29
29
  return decrypted.toString("utf8");
30
30
  }
31
+ export function encode(value) {
32
+ const bytes = new TextEncoder().encode(JSON.stringify(value));
33
+ for (let i = 0; i < bytes.length; i++) {
34
+ bytes[i] ^= 0xa7;
35
+ }
36
+ return bytes;
37
+ }
38
+ export function decode(bytes) {
39
+ for (let i = 0; i < bytes.length; i++) {
40
+ bytes[i] ^= 0xa7;
41
+ }
42
+ return JSON.parse(new TextDecoder().decode(bytes));
43
+ }
@@ -1,6 +1,6 @@
1
- import { encode, decode } from "@msgpack/msgpack";
2
1
  import cache from "./cache.js";
3
2
  import xanix from "../server/index.js";
3
+ import { decode, encode } from "../libs/encoder.js";
4
4
  export const register = new Map();
5
5
  export const CHUNK_SIZE = 256 * 1024; // 256 KB
6
6
  async function uploadFile(file) {
@@ -81,7 +81,7 @@ const server = (callback, options, id) => {
81
81
  const res = await fetch(`/__xanix__/server/${id}`, {
82
82
  method: "POST",
83
83
  headers: {
84
- "Content-Type": "application/xanix",
84
+ "Content-Type": "application/octet-stream",
85
85
  },
86
86
  body: binary,
87
87
  });
@@ -12,7 +12,7 @@ const login = server(async ({ id, info }, ctx) => {
12
12
  try {
13
13
  await session.verify(info);
14
14
  const user = await session.getUser(info);
15
- const encryptModule = await import("./encript.js");
15
+ const encryptModule = await import("../libs/encript.js");
16
16
  const cookieData = {
17
17
  info,
18
18
  expires: new Date(Date.now() + 1000 * 60 * 60 * 24), // 1 day expiration
@@ -60,7 +60,7 @@ const getUser = server(async ({ id, token }, ctx) => {
60
60
  if (!token) {
61
61
  return null;
62
62
  }
63
- const encryptModule = await import("./encript.js");
63
+ const encryptModule = await import("../libs/encript.js");
64
64
  const data = encryptModule.decrypt(token, session.secret);
65
65
  const parsed = JSON.parse(data);
66
66
  if (!parsed.info || new Date(parsed.expires) < new Date()) {
package/dist/index.js CHANGED
File without changes
@@ -0,0 +1,2 @@
1
+ export declare function encode(value: unknown): Uint8Array;
2
+ export declare function decode(bytes: Uint8Array): any;
@@ -0,0 +1,13 @@
1
+ export function encode(value) {
2
+ const bytes = new TextEncoder().encode(JSON.stringify(value));
3
+ for (let i = 0; i < bytes.length; i++) {
4
+ bytes[i] ^= 0xa7;
5
+ }
6
+ return bytes;
7
+ }
8
+ export function decode(bytes) {
9
+ for (let i = 0; i < bytes.length; i++) {
10
+ bytes[i] ^= 0xa7;
11
+ }
12
+ return JSON.parse(new TextDecoder().decode(bytes));
13
+ }
@@ -0,0 +1,2 @@
1
+ export declare function encrypt(text: string, secret: string): string;
2
+ export declare function decrypt(data: string, secret: string): string;
@@ -0,0 +1,30 @@
1
+ import { createCipheriv, createDecipheriv, randomBytes, scryptSync, } from "node:crypto";
2
+ const ALGORITHM = "aes-256-gcm";
3
+ function getKey(secret) {
4
+ return scryptSync(secret, "xanix-session", 32);
5
+ }
6
+ export function encrypt(text, secret) {
7
+ const key = getKey(secret);
8
+ const iv = randomBytes(12);
9
+ const cipher = createCipheriv(ALGORITHM, key, iv);
10
+ const encrypted = Buffer.concat([
11
+ cipher.update(text, "utf8"),
12
+ cipher.final(),
13
+ ]);
14
+ const authTag = cipher.getAuthTag();
15
+ return Buffer.concat([iv, authTag, encrypted]).toString("base64");
16
+ }
17
+ export function decrypt(data, secret) {
18
+ const key = getKey(secret);
19
+ const buffer = Buffer.from(data, "base64");
20
+ const iv = buffer.subarray(0, 12);
21
+ const authTag = buffer.subarray(12, 28);
22
+ const encrypted = buffer.subarray(28);
23
+ const decipher = createDecipheriv(ALGORITHM, key, iv);
24
+ decipher.setAuthTag(authTag);
25
+ const decrypted = Buffer.concat([
26
+ decipher.update(encrypted),
27
+ decipher.final(),
28
+ ]);
29
+ return decrypted.toString("utf8");
30
+ }
package/dist/navigate.js CHANGED
@@ -5,7 +5,7 @@ import { DocumentProvider, } from "./components/DocumentContext.js";
5
5
  import { createRoot } from "react-dom/client";
6
6
  import Document from "virtual:xanix-document";
7
7
  import { UseServerResult } from "./hooks/useServer.js";
8
- import { decode } from "@msgpack/msgpack";
8
+ import { decode } from "./libs/encoder.js";
9
9
  const getPath = () => {
10
10
  const { pathname, search } = window.location;
11
11
  return search ? `${pathname}${search}` : pathname;
@@ -1,9 +1,9 @@
1
- import { decode, encode } from "@msgpack/msgpack";
2
1
  import express, { Router } from "express";
3
2
  import fs from "fs";
4
3
  import path from "path";
5
4
  import { register, CHUNK_SIZE } from "../../hooks/server.js";
6
5
  import xanix from "../index.js";
6
+ import { decode, encode } from "../../libs/encoder.js";
7
7
  const router = Router();
8
8
  const TMP_DIR = path.resolve(".xanix/tmp");
9
9
  const readFile = async (uploadId, filename, fileType) => {
@@ -14,7 +14,7 @@ const readFile = async (uploadId, filename, fileType) => {
14
14
  const buffer = await fs.promises.readFile(filePath);
15
15
  return new File([buffer], filename, { type: fileType });
16
16
  };
17
- router.post("/server/:id", express.raw({ type: "application/xanix" }), async (req, res) => {
17
+ router.post("/server/:id", express.raw({ type: "application/octet-stream" }), async (req, res) => {
18
18
  const callback = register.get(req.params.id);
19
19
  if (!callback) {
20
20
  xanix.emit("action:error", {
@@ -36,7 +36,7 @@ router.post("/server/:id", express.raw({ type: "application/xanix" }), async (re
36
36
  request: req,
37
37
  response: res,
38
38
  });
39
- const args = req.body?.length ? decode(new Uint8Array(req.body)) : {};
39
+ const args = req.body?.length ? decode(req.body) : {};
40
40
  let fileIds = [];
41
41
  for (const key in args) {
42
42
  const value = args[key];
@@ -73,7 +73,7 @@ router.post("/server/:id", express.raw({ type: "application/xanix" }), async (re
73
73
  request: req,
74
74
  response: res,
75
75
  });
76
- res.set("Content-Type", "application/xanix");
76
+ res.set("Content-Type", "application/octet-stream");
77
77
  res.send(Buffer.from(encode(data)));
78
78
  });
79
79
  router.post("/upload/:uploadId", async (req, res) => {
@@ -6,5 +6,5 @@ interface XPageProps {
6
6
  props: Record<string, any>;
7
7
  pageId: string;
8
8
  }
9
- declare const __xpage: ({ component, req, res, pageId }: XPageProps, isNavigation: boolean) => Promise<string | Uint8Array<ArrayBuffer> | undefined>;
9
+ declare const __xpage: ({ component, req, res, pageId }: XPageProps, isNavigation: boolean) => Promise<string | Uint8Array<ArrayBufferLike> | undefined>;
10
10
  export default __xpage;
@@ -6,7 +6,7 @@ import { DocumentProvider } from "../../components/DocumentContext";
6
6
  import { UseServerResource, UseServerResult } from "../../hooks/useServer";
7
7
  import XanixRedirect from "../../classes/XanixRedirect";
8
8
  import xanix from "..";
9
- import { encode } from "@msgpack/msgpack";
9
+ import { encode } from "../../libs/encoder.js";
10
10
  function renderPage(element) {
11
11
  return new Promise((resolve, reject) => {
12
12
  let html = "";