xanix 1.0.19 → 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,3 +1,3 @@
1
1
  import { ImportInfo } from "../../../../modifier/importFinder.js";
2
- declare const serverFunctionReplacer: (code: string, imports: ImportInfo[], uid: string) => string;
2
+ declare const serverFunctionReplacer: (code: string, imports: ImportInfo[], uid: string, source: string) => string;
3
3
  export default serverFunctionReplacer;
@@ -1,5 +1,6 @@
1
1
  import callbackReplacer from "../../../../modifier/callbackReplacer.js";
2
- const serverFunctionReplacer = (code, imports, uid) => {
2
+ import { framworkDir } from "../../../../include/path.js";
3
+ const serverFunctionReplacer = (code, imports, uid, source) => {
3
4
  let count = 0;
4
5
  const replacer = (code, cb) => {
5
6
  const replacedCode = callbackReplacer(code, cb, (args) => {
@@ -13,6 +14,9 @@ const serverFunctionReplacer = (code, imports, uid) => {
13
14
  code = replacedCode;
14
15
  return code;
15
16
  };
17
+ if (source.startsWith(framworkDir)) {
18
+ code = replacer(code, `server`);
19
+ }
16
20
  for (let _import of imports) {
17
21
  if (_import.namespace) {
18
22
  code = replacer(code, `${_import.namespace}.server`);
@@ -0,0 +1,3 @@
1
+ import { ImportInfo } from "../../../../modifier/importFinder";
2
+ declare const serverReplacer: (code: string, imports: ImportInfo[], uid: string) => string;
3
+ export default serverReplacer;
@@ -0,0 +1,26 @@
1
+ import callbackReplacer from "../../../../modifier/callbackReplacer.js";
2
+ const serverReplacer = (code, imports, uid) => {
3
+ let count = 0;
4
+ const replaceServer = (code, cb) => {
5
+ const replacedCode = callbackReplacer(code, cb, (args) => {
6
+ const id = uid + count++;
7
+ const fn = args[0];
8
+ const options = args[1] || "undefined";
9
+ return `${cb}(${fn}, ${options}, "${id}");`;
10
+ });
11
+ code = replacedCode;
12
+ return code;
13
+ };
14
+ for (let xanixImport of imports) {
15
+ if (xanixImport.namespace) {
16
+ code = replaceServer(code, `${xanixImport.namespace}.server`);
17
+ }
18
+ for (let sp of xanixImport.specifiers) {
19
+ if (sp.imported === "server") {
20
+ code = replaceServer(code, sp.local);
21
+ }
22
+ }
23
+ }
24
+ return code;
25
+ };
26
+ export default serverReplacer;
@@ -1,3 +1,3 @@
1
- import type { ImportInfo } from "../../../../modifier/importFinder";
2
- declare const useServerReplacer: (code: string, imports: ImportInfo[]) => string;
1
+ import type { ImportInfo } from "../../../../modifier/importFinder.js";
2
+ declare const useServerReplacer: (code: string, imports: ImportInfo[], source: string) => string;
3
3
  export default useServerReplacer;
@@ -1,8 +1,7 @@
1
+ import { framworkDir } from "../../../../include/path.js";
1
2
  import callbackReplacer from "../../../../modifier/callbackReplacer.js";
2
- const useServerReplacer = (code, imports) => {
3
- if (!imports.length)
4
- return code;
5
- const importName = `__xanix_server_${Math.random().toString(36).substring(2, 3)}`;
3
+ const useServerReplacer = (code, imports, source) => {
4
+ const importName = `__xanix_server_${Math.random().toString(36).substring(2, 4)}`;
6
5
  let codes = [`import { server as ${importName} } from "xanix"`];
7
6
  imports.push({
8
7
  specifiers: [
@@ -17,12 +16,17 @@ const useServerReplacer = (code, imports) => {
17
16
  const fn = args[0];
18
17
  const argString = args[1] ?? "undefined";
19
18
  const options = args[2] || "undefined";
20
- const varname = `_use_server_${Math.random().toString(36).substring(2, 9)}`;
19
+ const varname = `_use_server_${Math.random().toString(36).substring(2, 6)}`;
21
20
  const server_code = `const ${varname} = ${importName}(${fn}, ${options});`;
22
21
  codes.push(server_code);
23
22
  return `${cb}(${varname}, ${argString})`;
24
23
  });
25
24
  };
25
+ if (source.startsWith(framworkDir)) {
26
+ code = replacer(code, `useServer`);
27
+ }
28
+ if (!imports.length)
29
+ return code;
26
30
  for (let _import of imports) {
27
31
  if (_import.namespace) {
28
32
  code = replacer(code, `${_import.namespace}.useServer`);
@@ -10,69 +10,58 @@ import outdirs from "../../outdirs.js";
10
10
  import { readFile } from "node:fs/promises";
11
11
  import { fileURLToPath } from "node:url";
12
12
  import { normalizePath } from "../include/utils.js";
13
- const root = normalizePath(process.cwd());
14
13
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
15
14
  const packageJson = JSON.parse(await readFile(path.join(__dirname, "../../../package.json"), "utf8"));
16
15
  const serverInfo = {};
17
16
  let child;
18
17
  let firstStart = false;
19
- async function stopCurrentServer() {
20
- if (!child || child.exitCode !== null || child.signalCode !== null) {
21
- child = undefined;
22
- return;
23
- }
24
- const previous = child;
25
- await new Promise((resolve) => {
26
- previous.once("exit", () => resolve());
27
- previous.kill();
18
+ const root = normalizePath(process.cwd());
19
+ const curl = () => {
20
+ return new Promise((resolve, reject) => {
21
+ const child = spawn("curl", [serverInfo.url], {
22
+ stdio: "pipe",
23
+ });
24
+ child.on("error", reject);
25
+ child.on("close", () => resolve());
28
26
  });
29
- if (child === previous) {
30
- child = undefined;
31
- }
32
- }
33
- async function startServer() {
34
- await stopCurrentServer();
35
- const filePath = path.join(outdirs.server, "index.js");
36
- await new Promise((resolve, reject) => {
37
- const current = spawn(process.execPath, [filePath], {
27
+ };
28
+ function runServer() {
29
+ return new Promise((resolve, reject) => {
30
+ child?.kill();
31
+ const filePath = path.join(outdirs.server, "index.js");
32
+ child = spawn(process.execPath, [filePath], {
38
33
  stdio: ["inherit", "inherit", "inherit", "ipc"],
39
34
  });
40
- child = current;
41
- const cleanup = () => {
42
- current.off("message", onMessage);
43
- current.off("error", onError);
44
- current.off("exit", onExit);
45
- };
46
- const onMessage = (message) => {
47
- if (message?.type !== "xanix:ready")
48
- return;
49
- serverInfo.port = message.port;
50
- serverInfo.url = message.url;
51
- if (!firstStart) {
52
- firstStart = true;
53
- console.log("");
54
- console.log(` ${pc.blue("➜ Listening on:")} ${pc.yellow(serverInfo.url)}`);
55
- console.log("");
56
- }
57
- cleanup();
58
- resolve();
59
- };
60
- const onError = (error) => {
61
- cleanup();
62
- reject(error);
63
- };
64
- const onExit = (code, signal) => {
65
- cleanup();
66
- if (child === current) {
67
- child = undefined;
35
+ child.on("message", async (message) => {
36
+ if (message.type === "xanix:ready") {
37
+ serverInfo.port = message.port;
38
+ serverInfo.url = message.url;
39
+ if (!firstStart) {
40
+ firstStart = true;
41
+ console.log("");
42
+ console.log(` ${pc.blue("➜ Listening on:")} ${pc.yellow(serverInfo.url)}`);
43
+ console.log("");
44
+ }
45
+ resolve();
68
46
  }
69
- reject(new Error(`Xanix server exited before ready (code: ${code}, signal: ${signal})`));
70
- };
71
- current.on("message", onMessage);
72
- current.once("error", onError);
73
- current.once("exit", onExit);
47
+ });
48
+ child.on("error", reject);
74
49
  });
75
50
  }
51
+ let started = false;
52
+ let timer;
53
+ async function startServer() {
54
+ if (!started) {
55
+ await runServer();
56
+ started = true;
57
+ return;
58
+ }
59
+ clearTimeout(timer);
60
+ timer = setTimeout(async () => {
61
+ await runServer();
62
+ await curl();
63
+ }, 1000);
64
+ }
76
65
  const dev = async (rootEntry) => {
77
66
  // await stop();
78
67
  fs.rmSync(outdirs.root, {
@@ -99,31 +88,48 @@ const dev = async (rootEntry) => {
99
88
  ws.on("close", () => {
100
89
  sockets.delete(ws);
101
90
  });
102
- ws.on("message", (message) => {
103
- if (message.toString() === "reload") {
104
- startServer();
105
- }
106
- });
107
91
  });
108
- console.log("");
109
- console.log(pc.green(pc.bold(`Xanix`) + ` v${packageJson.version}`));
110
- let clientWatcher = null;
92
+ let _clientWatcher = null;
111
93
  let clientStarted = false;
112
94
  let buildDuration = 0;
113
- const startClientWatcher = async () => {
114
- clientWatcher?.close();
115
- clientWatcher = await watchClient({
95
+ let serverWatchReady = false;
96
+ const waitUntilReady = () => {
97
+ return new Promise((resolve) => {
98
+ if (serverWatchReady) {
99
+ resolve();
100
+ return;
101
+ }
102
+ const timer = setInterval(() => {
103
+ if (serverWatchReady) {
104
+ clearInterval(timer);
105
+ resolve();
106
+ }
107
+ }, 10);
108
+ });
109
+ };
110
+ const clientWatcher = async () => {
111
+ const isClientAlreadyReady = !!_clientWatcher;
112
+ _clientWatcher?.close();
113
+ _clientWatcher = await watchClient({
116
114
  onStart: async () => {
117
115
  clientStarted = true;
118
116
  },
119
117
  onReady: async (duration) => {
118
+ if (!isClientAlreadyReady) {
119
+ // spinner.stop(
120
+ // `${pc.green("✓")} Client compiled in ${pc.dim(buildDuration + duration + "ms")}`,
121
+ // );
122
+ }
120
123
  await startServer();
121
124
  buildDuration = 0;
122
125
  clientStarted = false;
126
+ serverWatchReady = false;
123
127
  },
124
128
  onChange: async (files, duration, entries) => {
129
+ await waitUntilReady();
125
130
  buildDuration += duration;
126
131
  clientStarted = false;
132
+ serverWatchReady = false;
127
133
  const _files = [];
128
134
  for (let file of files) {
129
135
  const entry = entries.find((entry) => entry.resolved === file);
@@ -140,38 +146,46 @@ const dev = async (rootEntry) => {
140
146
  logger.info(`${pc.yellow(files.join(", "))} ${pc.green(buildDuration + "ms")}`, "[update]");
141
147
  broadcast(JSON.stringify(_files));
142
148
  buildDuration = 0;
149
+ startServer();
143
150
  },
144
151
  });
145
152
  };
153
+ console.log("");
154
+ console.log(pc.green(pc.bold(`Xanix`) + ` v${packageJson.version}`));
155
+ // console.log("");
156
+ // spinner.start("Compiling Server...");
146
157
  const watch = await watchServer({
147
158
  rootEntry,
148
159
  onChangeManifest: async () => {
149
- await startClientWatcher();
160
+ // Handle manifest change
161
+ await clientWatcher();
150
162
  },
151
163
  onReady: async (duration) => {
152
164
  buildDuration += duration;
153
- await startClientWatcher();
165
+ serverWatchReady = true;
166
+ await clientWatcher();
154
167
  },
155
168
  onChange: async (files, duration) => {
156
169
  buildDuration += duration;
157
170
  if (!clientStarted) {
158
171
  files = files.map((file) => file.replace(root + "/", ""));
159
- logger.info(`${pc.yellow(files.join(", "))} ${pc.green(buildDuration + "ms")}`, "[update-server]");
172
+ logger.info(`${pc.yellow(files.join(", "))} ${pc.green(buildDuration + "ms")}`, "[update]");
160
173
  buildDuration = 0;
161
- await startServer();
174
+ startServer();
162
175
  }
176
+ serverWatchReady = true;
163
177
  },
164
178
  });
165
179
  process.on("SIGINT", () => {
166
- clientWatcher?.close();
167
- watch?.close();
168
180
  child?.kill();
181
+ _clientWatcher?.close();
182
+ watch?.close();
169
183
  process.exit(0);
170
184
  });
171
185
  process.on("SIGTERM", () => {
172
- clientWatcher?.close();
173
- watch?.close();
174
186
  child?.kill();
187
+ _clientWatcher?.close();
188
+ watch?.close();
175
189
  process.exit(0);
176
190
  });
177
191
  };
@@ -1,2 +1,5 @@
1
- declare const start: () => Promise<void>;
1
+ declare const start: (args: {
2
+ external?: boolean;
3
+ restart?: boolean;
4
+ }) => Promise<void>;
2
5
  export default start;
@@ -1,27 +1,78 @@
1
1
  import { spawn } from "child_process";
2
2
  import pc from "picocolors";
3
+ import { mkdir, open, writeFile } from "fs/promises";
3
4
  import path from "path";
4
5
  import outdirs from "../../../outdirs.js";
5
6
  import { getFrameworkPackageJson } from "../../include/utils.js";
6
- const start = async () => {
7
+ import { processFiles, getProcess, processProjectDir, } from "../../include/process.js";
8
+ import startExternal from "./external.js";
9
+ const start = async (args) => {
10
+ const isExternal = args.external ?? false;
7
11
  const packageJson = await getFrameworkPackageJson();
8
- console.log("");
9
- console.log(pc.cyan(pc.bold(`Xanix ${packageJson.version}`)));
10
- console.log("");
12
+ if (!args.restart) {
13
+ console.log("");
14
+ console.log(pc.cyan(pc.bold(`Xanix ${packageJson.version}`)));
15
+ console.log("");
16
+ }
17
+ if (isExternal) {
18
+ startExternal();
19
+ return;
20
+ }
21
+ await mkdir(processProjectDir, {
22
+ recursive: true,
23
+ });
11
24
  const filePath = path.join(outdirs.server, "index.js");
25
+ const files = processFiles;
26
+ const processFile = files.process;
27
+ const stdoutFile = files.logs.stdout;
28
+ const stderrFile = files.logs.stderr;
29
+ const oldProcess = await getProcess();
30
+ if (oldProcess) {
31
+ const oldPid = Number(oldProcess?.pid);
32
+ console.log(pc.yellow(`Xanix server is already running (${oldPid})`));
33
+ return;
34
+ }
35
+ // Create/open log files.
36
+ const stdout = await open(stdoutFile, "a");
37
+ const stderr = await open(stderrFile, "a");
12
38
  const child = spawn(process.execPath, [filePath], {
13
- stdio: ["inherit", "inherit", "inherit", "ipc"],
39
+ detached: true,
40
+ stdio: ["ignore", stdout.fd, stderr.fd, "ipc"],
41
+ env: {
42
+ ...process.env,
43
+ NODE_ENV: "production",
44
+ },
14
45
  });
46
+ // Keep file handles open for the child process to use.
47
+ if (!child.pid) {
48
+ console.error(pc.red("Failed to start Xanix server."));
49
+ return;
50
+ }
51
+ // clear pre logs
52
+ await writeFile(processFile, JSON.stringify({
53
+ pid: child.pid,
54
+ cwd: process.cwd(),
55
+ script: filePath,
56
+ startedAt: Date.now(),
57
+ }, null, 2));
15
58
  child.on("message", (message) => {
16
59
  if (message.type === "xanix:ready") {
17
- console.log(` ${pc.blue("➜ Local:")} ${pc.yellow(message.url ?? "")}`);
18
- console.log("");
19
- console.log(pc.gray("Press Ctrl+C to stop"));
20
- console.log("");
60
+ if (!args.restart) {
61
+ console.log(` ${pc.gray("➜ Local:")} ${pc.yellow(message.url ?? "")}`);
62
+ console.log(` ${pc.gray("➜ PID:")} ${child.pid}`);
63
+ console.log("");
64
+ console.log(pc.gray(`Run ${pc.cyan("xanix stop")} to stop the server.`));
65
+ console.log("");
66
+ }
67
+ child.disconnect();
68
+ child.unref();
21
69
  }
22
70
  });
23
71
  child.on("error", (error) => {
24
72
  console.error(pc.red("Failed to start Xanix server"), error);
73
+ // write error to stderr log
74
+ writeFile(stderrFile, String(error), { flag: "a" }).catch(() => { });
25
75
  });
76
+ child.unref();
26
77
  };
27
78
  export default start;
@@ -0,0 +1,2 @@
1
+ declare function callbackReplacer(code: string, name: string, replacer: (args: string[]) => string | void): string;
2
+ export default callbackReplacer;
@@ -0,0 +1,52 @@
1
+ import { TOKENS } from "./stripComments.js";
2
+ const mask = (code) => code.replace(TOKENS, (m) => /^["'`]/.test(m)
3
+ ? m[0] + m.slice(1, -1).replace(/[^\r\n]/g, " ") + m.at(-1)
4
+ : m.replace(/[^\r\n]/g, " "));
5
+ function callbackReplacer(code, name, replacer) {
6
+ const masked = mask(code);
7
+ const escaped = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
8
+ const re = new RegExp(`(?<![\\w$.])${escaped}\\s*\\(`, "g");
9
+ let result = "";
10
+ let last = 0;
11
+ let m;
12
+ while ((m = re.exec(masked))) {
13
+ const start = m.index;
14
+ const cs = re.lastIndex;
15
+ // find the matching ")"
16
+ let depth = 1;
17
+ let i = cs;
18
+ for (; i < masked.length && depth; i++) {
19
+ if (masked[i] === "(")
20
+ depth++;
21
+ else if (masked[i] === ")")
22
+ depth--;
23
+ }
24
+ if (depth)
25
+ break; // unbalanced: leave the rest untouched
26
+ const end = i - 1;
27
+ // split top-level args
28
+ const args = [];
29
+ let argStart = cs;
30
+ let d = 0;
31
+ for (let j = cs; j < end; j++) {
32
+ const c = masked[j];
33
+ if (c === "(" || c === "[" || c === "{")
34
+ d++;
35
+ else if (c === ")" || c === "]" || c === "}")
36
+ d--;
37
+ else if (c === "," && d === 0) {
38
+ args.push(code.slice(argStart, j).trim());
39
+ argStart = j + 1;
40
+ }
41
+ }
42
+ const tail = code.slice(argStart, end).trim();
43
+ if (tail)
44
+ args.push(tail);
45
+ result += code.slice(last, start);
46
+ const out = replacer(args);
47
+ result += out !== undefined ? out : code.slice(start, end + 1);
48
+ last = re.lastIndex = end + 1;
49
+ }
50
+ return result + code.slice(last);
51
+ }
52
+ export default callbackReplacer;
@@ -0,0 +1,9 @@
1
+ export type ImportInfo = {
2
+ specifiers: {
3
+ local: string;
4
+ imported: string;
5
+ }[];
6
+ namespace?: string;
7
+ };
8
+ declare function importFinder(code: string, module: string): ImportInfo[];
9
+ export default importFinder;
@@ -0,0 +1,50 @@
1
+ function importFinder(code, module) {
2
+ const esc = module.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
3
+ const from = `(?:"${esc}"|'${esc}')`;
4
+ const found = [];
5
+ // import a, { b as c }, * as ns from "module" (skips `import type ...`)
6
+ const importRe = new RegExp(`(?<![\\w$.])import(?![\\w$])(?!\\s+type\\s+[\\w$*{])\\s*([^;"']*?)\\s*from\\s*${from}`, "g");
7
+ for (const m of code.matchAll(importRe)) {
8
+ const clause = m[1];
9
+ const specifiers = [];
10
+ const namespace = /\*\s*as\s+([\w$]+)/.exec(clause)?.[1];
11
+ const named = /\{([^}]*)\}/.exec(clause)?.[1];
12
+ const def = clause
13
+ .replace(/\{[^}]*\}|\*\s*as\s+[\w$]+/g, "")
14
+ .replace(/,/g, "")
15
+ .trim();
16
+ if (/^[\w$]+$/.test(def))
17
+ specifiers.push({ local: def, imported: "default" });
18
+ for (const item of named?.split(",") ?? []) {
19
+ const s = item.trim();
20
+ if (!s || /^type\s+(?!as\s)/.test(s))
21
+ continue;
22
+ const [imported, local] = s.split(/\s+as\s+/).map((x) => x.trim());
23
+ specifiers.push({ local: local ?? imported, imported });
24
+ }
25
+ found.push({
26
+ index: m.index,
27
+ info: namespace ? { specifiers, namespace } : { specifiers },
28
+ });
29
+ }
30
+ // const a = require("module") / const { b, c: d } = require("module")
31
+ const requireRe = new RegExp(`(?<![\\w$.])(?:const|let|var)\\s+(?:([\\w$]+)|\\{([^}]*)\\})\\s*=\\s*require\\s*\\(\\s*${from}\\s*\\)(?![.(\\[])`, "g");
32
+ for (const m of code.matchAll(requireRe)) {
33
+ const specifiers = [];
34
+ if (m[1]) {
35
+ specifiers.push({ local: m[1], imported: "default" });
36
+ }
37
+ else {
38
+ for (const item of m[2].split(",")) {
39
+ const s = item.trim().replace(/\s*=[\s\S]*$/, ""); // drop defaults
40
+ if (!s || s.startsWith("..."))
41
+ continue;
42
+ const [imported, local] = s.split(/\s*:\s*/).map((x) => x.trim());
43
+ specifiers.push({ local: local ?? imported, imported });
44
+ }
45
+ }
46
+ found.push({ index: m.index, info: { specifiers } });
47
+ }
48
+ return found.sort((a, b) => a.index - b.index).map((f) => f.info);
49
+ }
50
+ export default importFinder;
@@ -0,0 +1,16 @@
1
+ export type ImportSpecifier = {
2
+ imported: string;
3
+ local: string;
4
+ typeOnly: boolean;
5
+ };
6
+ export type ImportRecord = {
7
+ source: string;
8
+ default?: string;
9
+ namespace?: string;
10
+ named: ImportSpecifier[];
11
+ typeOnly: boolean;
12
+ start: number;
13
+ end: number;
14
+ };
15
+ declare function findImports(code: string): ImportRecord[];
16
+ export default findImports;
@@ -0,0 +1,45 @@
1
+ import { TOKENS } from "./stripComments.js";
2
+ // Blank comments, regex literals and string/template contents (length preserved,
3
+ // quote characters kept) so imports inside them are never matched.
4
+ const mask = (code) => code.replace(TOKENS, (m) => /^["'`]/.test(m)
5
+ ? m[0] + m.slice(1, -1).replace(/[^\r\n]/g, " ") + m.at(-1)
6
+ : m.replace(/[^\r\n]/g, " "));
7
+ const IMPORT_RE = /(?<![\w$.])(?<head>import(?![\w$])\s*)(?<pre>(?:(?<type>type\s+(?!from\b)(?=[\w$*{]))?(?<clause>[^;"'`]*?)\s*from\s*)?)(?<q>["'])(?<src>[^"']+)\k<q>(?:\s*(?:with|assert)\s*\{[^}]*\})?;?/g;
8
+ function findImports(code) {
9
+ const records = [];
10
+ for (const m of mask(code).matchAll(IMPORT_RE)) {
11
+ const g = m.groups;
12
+ const srcStart = m.index + g.head.length + g.pre.length + 1;
13
+ const clause = g.clause ?? "";
14
+ const record = {
15
+ source: code.slice(srcStart, srcStart + g.src.length),
16
+ named: [],
17
+ typeOnly: !!g.type,
18
+ start: m.index,
19
+ end: m.index + m[0].length,
20
+ };
21
+ const namespace = /\*\s*as\s+([\w$]+)/.exec(clause)?.[1];
22
+ if (namespace)
23
+ record.namespace = namespace;
24
+ const named = /\{([^}]*)\}/.exec(clause)?.[1];
25
+ for (const item of named?.split(",") ?? []) {
26
+ let s = item.trim();
27
+ if (!s)
28
+ continue;
29
+ const typeOnly = /^type\s+(?!as\s)/.test(s);
30
+ if (typeOnly)
31
+ s = s.replace(/^type\s+/, "");
32
+ const [imported, local] = s.split(/\s+as\s+/).map((x) => x.trim());
33
+ record.named.push({ imported, local: local ?? imported, typeOnly });
34
+ }
35
+ const def = clause
36
+ .replace(/\{[^}]*\}|\*\s*as\s+[\w$]+/g, "")
37
+ .replace(/,/g, "")
38
+ .trim();
39
+ if (/^[\w$]+$/.test(def))
40
+ record.default = def;
41
+ records.push(record);
42
+ }
43
+ return records;
44
+ }
45
+ export default findImports;
@@ -0,0 +1,9 @@
1
+ export type SendFinderResult = {
2
+ source: string;
3
+ identifier: string;
4
+ args: string[];
5
+ start: number;
6
+ end: number;
7
+ };
8
+ declare function pageFinder(code: string): SendFinderResult[];
9
+ export default pageFinder;
@@ -0,0 +1,30 @@
1
+ import findImports from "./findImports.js";
2
+ const ID = "[A-Za-z_$][\\w$]*";
3
+ function pageFinder(code) {
4
+ // default imports only:
5
+ // import Home from "./Home";
6
+ // import Layout, { Header } from "./Layout";
7
+ // import Components, * as UI from "./components";
8
+ const defaultImports = new Map();
9
+ for (const imp of findImports(code)) {
10
+ if (imp.default && !imp.typeOnly)
11
+ defaultImports.set(imp.default, imp.source);
12
+ }
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)
19
+ continue;
20
+ results.push({
21
+ source,
22
+ identifier: m[1],
23
+ args: [m[2]],
24
+ start: m.index,
25
+ end: m.index + m[0].length,
26
+ });
27
+ }
28
+ return results;
29
+ }
30
+ export default pageFinder;
@@ -0,0 +1,9 @@
1
+ export type ImportInfo = {
2
+ specifiers: {
3
+ local: string;
4
+ imported: string;
5
+ }[];
6
+ namespace?: string;
7
+ };
8
+ declare function importFinder(code: string, module: string): ImportInfo[];
9
+ export default importFinder;