fragment-ts 2.0.2 → 2.0.4

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 (296) hide show
  1. package/API.md +1 -8
  2. package/DOCS.md +1 -5
  3. package/README.md +2 -11
  4. package/SETUP.md +4 -14
  5. package/USAGE.md +11 -4
  6. package/dist/core/decorators/middleware.decorator.d.ts +10 -1
  7. package/dist/core/decorators/middleware.decorator.d.ts.map +1 -1
  8. package/dist/core/decorators/middleware.decorator.js +35 -7
  9. package/dist/core/decorators/middleware.decorator.js.map +1 -1
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +3 -0
  12. package/dist/index.js.map +1 -1
  13. package/dist/platform/cli/commands/install/command.d.ts +14 -0
  14. package/dist/platform/cli/commands/install/command.d.ts.map +1 -0
  15. package/dist/platform/cli/commands/install/command.js +145 -0
  16. package/dist/platform/cli/commands/install/command.js.map +1 -0
  17. package/dist/platform/cli/commands/register.d.ts.map +1 -1
  18. package/dist/platform/cli/commands/register.js +39 -32
  19. package/dist/platform/cli/commands/register.js.map +1 -1
  20. package/dist/platform/cli/commands/serve/command.d.ts.map +1 -1
  21. package/dist/platform/cli/commands/serve/command.js +9 -3
  22. package/dist/platform/cli/commands/serve/command.js.map +1 -1
  23. package/dist/platform/cli/index.js +77 -10
  24. package/dist/platform/cli/index.js.map +1 -1
  25. package/dist/platform/cli/scaffold/generate/component-generator.js +1 -1
  26. package/dist/platform/cli/scaffold/init/init.scaffold.d.ts.map +1 -1
  27. package/dist/platform/cli/scaffold/init/init.scaffold.js +1 -8
  28. package/dist/platform/cli/scaffold/init/init.scaffold.js.map +1 -1
  29. package/dist/platform/cli/web/commands/create/feature.d.ts +11 -0
  30. package/dist/platform/cli/web/commands/create/feature.d.ts.map +1 -0
  31. package/dist/platform/cli/web/commands/create/feature.js +43 -0
  32. package/dist/platform/cli/web/commands/create/feature.js.map +1 -0
  33. package/dist/platform/cli/web/commands/create/module.d.ts +11 -0
  34. package/dist/platform/cli/web/commands/create/module.d.ts.map +1 -0
  35. package/dist/platform/cli/web/commands/create/module.js +44 -0
  36. package/dist/platform/cli/web/commands/create/module.js.map +1 -0
  37. package/dist/platform/cli/web/commands/create/mvvm.d.ts +11 -0
  38. package/dist/platform/cli/web/commands/create/mvvm.d.ts.map +1 -0
  39. package/dist/platform/cli/web/commands/create/mvvm.js +43 -0
  40. package/dist/platform/cli/web/commands/create/mvvm.js.map +1 -0
  41. package/dist/platform/cli/web/commands/init-fullstack.d.ts +12 -0
  42. package/dist/platform/cli/web/commands/init-fullstack.d.ts.map +1 -0
  43. package/dist/platform/cli/web/commands/init-fullstack.js +42 -0
  44. package/dist/platform/cli/web/commands/init-fullstack.js.map +1 -0
  45. package/dist/platform/cli/web/commands/init-web.d.ts +12 -0
  46. package/dist/platform/cli/web/commands/init-web.d.ts.map +1 -0
  47. package/dist/platform/cli/web/commands/init-web.js +70 -0
  48. package/dist/platform/cli/web/commands/init-web.js.map +1 -0
  49. package/dist/platform/cli/web/commands/install-api.d.ts +11 -0
  50. package/dist/platform/cli/web/commands/install-api.d.ts.map +1 -0
  51. package/dist/platform/cli/web/commands/install-api.js +92 -0
  52. package/dist/platform/cli/web/commands/install-api.js.map +1 -0
  53. package/dist/platform/cli/web/commands/install-web.d.ts +13 -0
  54. package/dist/platform/cli/web/commands/install-web.d.ts.map +1 -0
  55. package/dist/platform/cli/web/commands/install-web.js +102 -0
  56. package/dist/platform/cli/web/commands/install-web.js.map +1 -0
  57. package/dist/platform/cli/web/commands/install.d.ts +3 -0
  58. package/dist/platform/cli/web/commands/install.d.ts.map +1 -0
  59. package/dist/platform/cli/web/commands/install.js +23 -0
  60. package/dist/platform/cli/web/commands/install.js.map +1 -0
  61. package/dist/platform/cli/web/commands/make/component.d.ts +16 -0
  62. package/dist/platform/cli/web/commands/make/component.d.ts.map +1 -0
  63. package/dist/platform/cli/web/commands/make/component.js +73 -0
  64. package/dist/platform/cli/web/commands/make/component.js.map +1 -0
  65. package/dist/platform/cli/web/commands/make/guard.d.ts +13 -0
  66. package/dist/platform/cli/web/commands/make/guard.d.ts.map +1 -0
  67. package/dist/platform/cli/web/commands/make/guard.js +46 -0
  68. package/dist/platform/cli/web/commands/make/guard.js.map +1 -0
  69. package/dist/platform/cli/web/commands/make/layout.d.ts +12 -0
  70. package/dist/platform/cli/web/commands/make/layout.d.ts.map +1 -0
  71. package/dist/platform/cli/web/commands/make/layout.js +44 -0
  72. package/dist/platform/cli/web/commands/make/layout.js.map +1 -0
  73. package/dist/platform/cli/web/commands/make/page.d.ts +17 -0
  74. package/dist/platform/cli/web/commands/make/page.d.ts.map +1 -0
  75. package/dist/platform/cli/web/commands/make/page.js +66 -0
  76. package/dist/platform/cli/web/commands/make/page.js.map +1 -0
  77. package/dist/platform/cli/web/commands/make/resource.d.ts +17 -0
  78. package/dist/platform/cli/web/commands/make/resource.d.ts.map +1 -0
  79. package/dist/platform/cli/web/commands/make/resource.js +37 -0
  80. package/dist/platform/cli/web/commands/make/resource.js.map +1 -0
  81. package/dist/platform/cli/web/commands/make/service.d.ts +16 -0
  82. package/dist/platform/cli/web/commands/make/service.d.ts.map +1 -0
  83. package/dist/platform/cli/web/commands/make/service.js +137 -0
  84. package/dist/platform/cli/web/commands/make/service.js.map +1 -0
  85. package/dist/platform/cli/web/commands/make/store.d.ts +16 -0
  86. package/dist/platform/cli/web/commands/make/store.d.ts.map +1 -0
  87. package/dist/platform/cli/web/commands/make/store.js +72 -0
  88. package/dist/platform/cli/web/commands/make/store.js.map +1 -0
  89. package/dist/platform/cli/web/commands/web-sync.d.ts +10 -0
  90. package/dist/platform/cli/web/commands/web-sync.d.ts.map +1 -0
  91. package/dist/platform/cli/web/commands/web-sync.js +307 -0
  92. package/dist/platform/cli/web/commands/web-sync.js.map +1 -0
  93. package/dist/platform/cli/web/index.d.ts +3 -0
  94. package/dist/platform/cli/web/index.d.ts.map +1 -0
  95. package/dist/platform/cli/web/index.js +40 -0
  96. package/dist/platform/cli/web/index.js.map +1 -0
  97. package/dist/platform/cli/web/utils/config.d.ts +52 -0
  98. package/dist/platform/cli/web/utils/config.d.ts.map +1 -0
  99. package/dist/platform/cli/web/utils/config.js +89 -0
  100. package/dist/platform/cli/web/utils/config.js.map +1 -0
  101. package/dist/platform/cli/web/utils/format.d.ts +2 -0
  102. package/dist/platform/cli/web/utils/format.d.ts.map +1 -0
  103. package/dist/platform/cli/web/utils/format.js +28 -0
  104. package/dist/platform/cli/web/utils/format.js.map +1 -0
  105. package/dist/platform/cli/web/utils/header.d.ts +3 -0
  106. package/dist/platform/cli/web/utils/header.d.ts.map +1 -0
  107. package/dist/platform/cli/web/utils/header.js +11 -0
  108. package/dist/platform/cli/web/utils/header.js.map +1 -0
  109. package/dist/platform/cli/web/utils/logger.d.ts +10 -0
  110. package/dist/platform/cli/web/utils/logger.d.ts.map +1 -0
  111. package/dist/platform/cli/web/utils/logger.js +47 -0
  112. package/dist/platform/cli/web/utils/logger.js.map +1 -0
  113. package/dist/platform/cli/web/utils/names.d.ts +7 -0
  114. package/dist/platform/cli/web/utils/names.d.ts.map +1 -0
  115. package/dist/platform/cli/web/utils/names.js +43 -0
  116. package/dist/platform/cli/web/utils/names.js.map +1 -0
  117. package/dist/platform/cli/web/utils/resolve-paths.d.ts +10 -0
  118. package/dist/platform/cli/web/utils/resolve-paths.d.ts.map +1 -0
  119. package/dist/platform/cli/web/utils/resolve-paths.js +87 -0
  120. package/dist/platform/cli/web/utils/resolve-paths.js.map +1 -0
  121. package/dist/platform/cli/web/utils/write-file.d.ts +7 -0
  122. package/dist/platform/cli/web/utils/write-file.d.ts.map +1 -0
  123. package/dist/platform/cli/web/utils/write-file.js +31 -0
  124. package/dist/platform/cli/web/utils/write-file.js.map +1 -0
  125. package/dist/platform/web/application.d.ts.map +1 -1
  126. package/dist/platform/web/application.js +2 -0
  127. package/dist/platform/web/application.js.map +1 -1
  128. package/dist/platform/web/bootstrap/RouteRegistrar.d.ts +2 -0
  129. package/dist/platform/web/bootstrap/RouteRegistrar.d.ts.map +1 -1
  130. package/dist/platform/web/bootstrap/RouteRegistrar.js +33 -4
  131. package/dist/platform/web/bootstrap/RouteRegistrar.js.map +1 -1
  132. package/dist/shared/config.utils.d.ts +1 -0
  133. package/dist/shared/config.utils.d.ts.map +1 -1
  134. package/dist/shared/config.utils.js +36 -11
  135. package/dist/shared/config.utils.js.map +1 -1
  136. package/dist/shared/env.utils.d.ts +6 -1
  137. package/dist/shared/env.utils.d.ts.map +1 -1
  138. package/dist/shared/env.utils.js +92 -9
  139. package/dist/shared/env.utils.js.map +1 -1
  140. package/dist/shared/runtime.resolver.d.ts +1 -0
  141. package/dist/shared/runtime.resolver.d.ts.map +1 -1
  142. package/dist/shared/runtime.resolver.js +27 -6
  143. package/dist/shared/runtime.resolver.js.map +1 -1
  144. package/dist/web/cli/commands/create/feature.d.ts +11 -0
  145. package/dist/web/cli/commands/create/feature.d.ts.map +1 -0
  146. package/dist/web/cli/commands/create/feature.js +43 -0
  147. package/dist/web/cli/commands/create/feature.js.map +1 -0
  148. package/dist/web/cli/commands/create/module.d.ts +11 -0
  149. package/dist/web/cli/commands/create/module.d.ts.map +1 -0
  150. package/dist/web/cli/commands/create/module.js +44 -0
  151. package/dist/web/cli/commands/create/module.js.map +1 -0
  152. package/dist/web/cli/commands/create/mvvm.d.ts +11 -0
  153. package/dist/web/cli/commands/create/mvvm.d.ts.map +1 -0
  154. package/dist/web/cli/commands/create/mvvm.js +43 -0
  155. package/dist/web/cli/commands/create/mvvm.js.map +1 -0
  156. package/dist/web/cli/commands/init-fullstack.d.ts +12 -0
  157. package/dist/web/cli/commands/init-fullstack.d.ts.map +1 -0
  158. package/dist/web/cli/commands/init-fullstack.js +42 -0
  159. package/dist/web/cli/commands/init-fullstack.js.map +1 -0
  160. package/dist/web/cli/commands/init-web.d.ts +12 -0
  161. package/dist/web/cli/commands/init-web.d.ts.map +1 -0
  162. package/dist/web/cli/commands/init-web.js +70 -0
  163. package/dist/web/cli/commands/init-web.js.map +1 -0
  164. package/dist/web/cli/commands/install-api.d.ts +10 -0
  165. package/dist/web/cli/commands/install-api.d.ts.map +1 -0
  166. package/dist/web/cli/commands/install-api.js +91 -0
  167. package/dist/web/cli/commands/install-api.js.map +1 -0
  168. package/dist/web/cli/commands/install-web.d.ts +12 -0
  169. package/dist/web/cli/commands/install-web.d.ts.map +1 -0
  170. package/dist/web/cli/commands/install-web.js +101 -0
  171. package/dist/web/cli/commands/install-web.js.map +1 -0
  172. package/dist/web/cli/commands/make/component.d.ts +13 -0
  173. package/dist/web/cli/commands/make/component.d.ts.map +1 -0
  174. package/dist/web/cli/commands/make/component.js +40 -0
  175. package/dist/web/cli/commands/make/component.js.map +1 -0
  176. package/dist/web/cli/commands/make/guard.d.ts +11 -0
  177. package/dist/web/cli/commands/make/guard.d.ts.map +1 -0
  178. package/dist/web/cli/commands/make/guard.js +37 -0
  179. package/dist/web/cli/commands/make/guard.js.map +1 -0
  180. package/dist/web/cli/commands/make/layout.d.ts +11 -0
  181. package/dist/web/cli/commands/make/layout.d.ts.map +1 -0
  182. package/dist/web/cli/commands/make/layout.js +37 -0
  183. package/dist/web/cli/commands/make/layout.js.map +1 -0
  184. package/dist/web/cli/commands/make/page.d.ts +14 -0
  185. package/dist/web/cli/commands/make/page.d.ts.map +1 -0
  186. package/dist/web/cli/commands/make/page.js +42 -0
  187. package/dist/web/cli/commands/make/page.js.map +1 -0
  188. package/dist/web/cli/commands/make/resource.d.ts +13 -0
  189. package/dist/web/cli/commands/make/resource.d.ts.map +1 -0
  190. package/dist/web/cli/commands/make/resource.js +33 -0
  191. package/dist/web/cli/commands/make/resource.js.map +1 -0
  192. package/dist/web/cli/commands/make/service.d.ts +14 -0
  193. package/dist/web/cli/commands/make/service.d.ts.map +1 -0
  194. package/dist/web/cli/commands/make/service.js +56 -0
  195. package/dist/web/cli/commands/make/service.js.map +1 -0
  196. package/dist/web/cli/commands/make/store.d.ts +14 -0
  197. package/dist/web/cli/commands/make/store.d.ts.map +1 -0
  198. package/dist/web/cli/commands/make/store.js +47 -0
  199. package/dist/web/cli/commands/make/store.js.map +1 -0
  200. package/dist/web/cli/commands/web-sync.d.ts +10 -0
  201. package/dist/web/cli/commands/web-sync.d.ts.map +1 -0
  202. package/dist/web/cli/commands/web-sync.js +48 -0
  203. package/dist/web/cli/commands/web-sync.js.map +1 -0
  204. package/dist/web/cli/index.d.mts +5 -0
  205. package/dist/web/cli/index.d.ts +5 -0
  206. package/dist/web/cli/index.d.ts.map +1 -0
  207. package/dist/web/cli/index.js +36 -0
  208. package/dist/web/cli/index.js.map +1 -0
  209. package/dist/web/cli/index.mjs +984 -0
  210. package/dist/web/cli/utils/config.d.ts +52 -0
  211. package/dist/web/cli/utils/config.d.ts.map +1 -0
  212. package/dist/web/cli/utils/config.js +89 -0
  213. package/dist/web/cli/utils/config.js.map +1 -0
  214. package/dist/web/cli/utils/format.d.ts +2 -0
  215. package/dist/web/cli/utils/format.d.ts.map +1 -0
  216. package/dist/web/cli/utils/format.js +28 -0
  217. package/dist/web/cli/utils/format.js.map +1 -0
  218. package/dist/web/cli/utils/logger.d.ts +10 -0
  219. package/dist/web/cli/utils/logger.d.ts.map +1 -0
  220. package/dist/web/cli/utils/logger.js +34 -0
  221. package/dist/web/cli/utils/logger.js.map +1 -0
  222. package/dist/web/cli/utils/names.d.ts +7 -0
  223. package/dist/web/cli/utils/names.d.ts.map +1 -0
  224. package/dist/web/cli/utils/names.js +43 -0
  225. package/dist/web/cli/utils/names.js.map +1 -0
  226. package/dist/web/cli/utils/resolve-paths.d.ts +10 -0
  227. package/dist/web/cli/utils/resolve-paths.d.ts.map +1 -0
  228. package/dist/web/cli/utils/resolve-paths.js +87 -0
  229. package/dist/web/cli/utils/resolve-paths.js.map +1 -0
  230. package/dist/web/cli/utils/write-file.d.ts +7 -0
  231. package/dist/web/cli/utils/write-file.d.ts.map +1 -0
  232. package/dist/web/cli/utils/write-file.js +31 -0
  233. package/dist/web/cli/utils/write-file.js.map +1 -0
  234. package/dist/web/platform/cli/web/index.d.mts +5 -0
  235. package/dist/web/platform/cli/web/index.d.ts +5 -0
  236. package/dist/web/platform/cli/web/index.js +2035 -0
  237. package/dist/web/platform/cli/web/index.mjs +1998 -0
  238. package/dist/web/src/adapters/jotai.d.ts +2 -0
  239. package/dist/web/src/adapters/jotai.d.ts.map +1 -0
  240. package/dist/web/src/adapters/jotai.js +7 -0
  241. package/dist/web/src/adapters/jotai.js.map +1 -0
  242. package/dist/web/src/adapters/mobx.d.ts +2 -0
  243. package/dist/web/src/adapters/mobx.d.ts.map +1 -0
  244. package/dist/web/src/adapters/mobx.js +7 -0
  245. package/dist/web/src/adapters/mobx.js.map +1 -0
  246. package/dist/web/src/adapters/redux.d.ts +2 -0
  247. package/dist/web/src/adapters/redux.d.ts.map +1 -0
  248. package/dist/web/src/adapters/redux.js +7 -0
  249. package/dist/web/src/adapters/redux.js.map +1 -0
  250. package/dist/web/src/adapters/zustand.d.ts +2 -0
  251. package/dist/web/src/adapters/zustand.d.ts.map +1 -0
  252. package/dist/web/src/adapters/zustand.js +7 -0
  253. package/dist/web/src/adapters/zustand.js.map +1 -0
  254. package/dist/web/src/config/web-config.d.ts +34 -0
  255. package/dist/web/src/config/web-config.d.ts.map +1 -0
  256. package/dist/web/src/config/web-config.js +73 -0
  257. package/dist/web/src/config/web-config.js.map +1 -0
  258. package/dist/web/src/core/application.d.ts +8 -0
  259. package/dist/web/src/core/application.d.ts.map +1 -0
  260. package/dist/web/src/core/application.js +45 -0
  261. package/dist/web/src/core/application.js.map +1 -0
  262. package/dist/web/src/core/decorators/component.d.ts +20 -0
  263. package/dist/web/src/core/decorators/component.d.ts.map +1 -0
  264. package/dist/web/src/core/decorators/component.js +83 -0
  265. package/dist/web/src/core/decorators/component.js.map +1 -0
  266. package/dist/web/src/core/decorators/page.d.ts +27 -0
  267. package/dist/web/src/core/decorators/page.d.ts.map +1 -0
  268. package/dist/web/src/core/decorators/page.js +58 -0
  269. package/dist/web/src/core/decorators/page.js.map +1 -0
  270. package/dist/web/src/core/di/container.d.ts +8 -0
  271. package/dist/web/src/core/di/container.d.ts.map +1 -0
  272. package/dist/web/src/core/di/container.js +26 -0
  273. package/dist/web/src/core/di/container.js.map +1 -0
  274. package/dist/web/src/core/runtime.d.ts +3 -0
  275. package/dist/web/src/core/runtime.d.ts.map +1 -0
  276. package/dist/web/src/core/runtime.js +15 -0
  277. package/dist/web/src/core/runtime.js.map +1 -0
  278. package/dist/web/src/http/fragment-fetch.d.ts +55 -0
  279. package/dist/web/src/http/fragment-fetch.d.ts.map +1 -0
  280. package/dist/web/src/http/fragment-fetch.js +290 -0
  281. package/dist/web/src/http/fragment-fetch.js.map +1 -0
  282. package/dist/web/src/index.d.mts +137 -0
  283. package/dist/web/src/index.d.ts +7 -0
  284. package/dist/web/src/index.d.ts.map +1 -0
  285. package/dist/web/src/index.js +31 -0
  286. package/dist/web/src/index.js.map +1 -0
  287. package/dist/web/src/index.mjs +643 -0
  288. package/dist/web/src/router/fragment-router.d.ts +14 -0
  289. package/dist/web/src/router/fragment-router.d.ts.map +1 -0
  290. package/dist/web/src/router/fragment-router.js +94 -0
  291. package/dist/web/src/router/fragment-router.js.map +1 -0
  292. package/dist/web/web/src/index.d.mts +137 -0
  293. package/dist/web/web/src/index.d.ts +137 -0
  294. package/dist/web/web/src/index.js +702 -0
  295. package/dist/web/web/src/index.mjs +644 -0
  296. package/package.json +15 -3
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RouterInternals = void 0;
4
+ exports.FragmentRouter = FragmentRouter;
5
+ const jsx_runtime_1 = require("react/jsx-runtime");
6
+ const react_1 = require("react");
7
+ const react_router_dom_1 = require("react-router-dom");
8
+ const page_1 = require("../core/decorators/page");
9
+ const fragment_fetch_1 = require("../http/fragment-fetch");
10
+ const runtime_1 = require("../core/runtime");
11
+ function prefixMatch(route, pathname) {
12
+ if (route === "/")
13
+ return pathname === "/";
14
+ return pathname === route || pathname.startsWith(`${route}/`);
15
+ }
16
+ async function resolveSession(config) {
17
+ if (config.fetch.tokenTransport === "cookie") {
18
+ try {
19
+ await fragment_fetch_1.FragmentFetch.get("/auth/me", { skipAuth: true });
20
+ return true;
21
+ }
22
+ catch {
23
+ return false;
24
+ }
25
+ }
26
+ return Boolean(fragment_fetch_1.FragmentFetch.getToken());
27
+ }
28
+ function routeNeedsAuth(path, config) {
29
+ return config.authenticatedRoutes.some((route) => prefixMatch(route, path));
30
+ }
31
+ function routeIsPublic(path, config) {
32
+ return config.publicRoutes.some((route) => prefixMatch(route, path));
33
+ }
34
+ function extractRedirectPath(mode, fallback = "/login") {
35
+ if (!mode)
36
+ return fallback;
37
+ if (mode.startsWith("redirect:"))
38
+ return mode.slice("redirect:".length);
39
+ return fallback;
40
+ }
41
+ function PageRoute({ page, config }) {
42
+ const [checking, setChecking] = (0, react_1.useState)(true);
43
+ const [authenticated, setAuthenticated] = (0, react_1.useState)(false);
44
+ const [guardAllowed, setGuardAllowed] = (0, react_1.useState)(true);
45
+ (0, react_1.useEffect)(() => {
46
+ let cancelled = false;
47
+ (async () => {
48
+ const isAuthed = await resolveSession(config);
49
+ if (cancelled)
50
+ return;
51
+ setAuthenticated(isAuthed);
52
+ if (page.guard) {
53
+ const guard = new page.guard();
54
+ if (typeof guard.canActivate === "function") {
55
+ const result = await Promise.resolve(guard.canActivate());
56
+ if (!cancelled) {
57
+ setGuardAllowed(result !== false);
58
+ }
59
+ }
60
+ }
61
+ if (!cancelled) {
62
+ setChecking(false);
63
+ }
64
+ })();
65
+ return () => {
66
+ cancelled = true;
67
+ };
68
+ }, [config]);
69
+ if (checking) {
70
+ return (0, jsx_runtime_1.jsx)("div", { children: "Loading..." });
71
+ }
72
+ const needsAuth = routeNeedsAuth(page.path, config);
73
+ const isPublic = routeIsPublic(page.path, config) || !needsAuth;
74
+ if (needsAuth && !authenticated) {
75
+ return (0, jsx_runtime_1.jsx)(react_router_dom_1.Navigate, { to: extractRedirectPath(config.fetch.onUnauthorized, "/login"), replace: true });
76
+ }
77
+ if (isPublic && page.redirectIfAuthenticated && authenticated) {
78
+ return (0, jsx_runtime_1.jsx)(react_router_dom_1.Navigate, { to: page.redirectIfAuthenticated, replace: true });
79
+ }
80
+ if (!guardAllowed) {
81
+ return (0, jsx_runtime_1.jsx)(react_router_dom_1.Navigate, { to: extractRedirectPath(config.fetch.onForbidden, "/403"), replace: true });
82
+ }
83
+ return (0, runtime_1.renderPageInstance)(page.target);
84
+ }
85
+ function FragmentRouter({ config }) {
86
+ const pages = (0, react_1.useMemo)(() => (0, page_1.getPages)(), []);
87
+ return ((0, jsx_runtime_1.jsx)(react_router_dom_1.BrowserRouter, { basename: config.webRoot, children: (0, jsx_runtime_1.jsx)(react_router_dom_1.Routes, { children: pages.map((page) => ((0, jsx_runtime_1.jsx)(react_router_dom_1.Route, { path: page.path, element: (0, jsx_runtime_1.jsx)(PageRoute, { page: page, config: config }) }, page.path))) }) }));
88
+ }
89
+ exports.RouterInternals = {
90
+ prefixMatch,
91
+ routeNeedsAuth,
92
+ routeIsPublic,
93
+ };
94
+ //# sourceMappingURL=fragment-router.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fragment-router.js","sourceRoot":"","sources":["../../../../src/web/src/router/fragment-router.tsx"],"names":[],"mappings":";;;AA6FA,wCAgBC;;AA7GD,iCAA4D;AAC5D,uDAA0E;AAC1E,kDAAkE;AAClE,2DAAuD;AAEvD,6CAAqD;AAErD,SAAS,WAAW,CAAC,KAAa,EAAE,QAAgB;IAClD,IAAI,KAAK,KAAK,GAAG;QAAE,OAAO,QAAQ,KAAK,GAAG,CAAC;IAC3C,OAAO,QAAQ,KAAK,KAAK,IAAI,QAAQ,CAAC,UAAU,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC;AAChE,CAAC;AAED,KAAK,UAAU,cAAc,CAAC,MAAyB;IACrD,IAAI,MAAM,CAAC,KAAK,CAAC,cAAc,KAAK,QAAQ,EAAE,CAAC;QAC7C,IA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Q,CAAC,EAAE,OAAO,SAAG,CAAC;IAC9F,CAAC;IAED,IAAI,QAAQ,IAAI,IAAI,CAAC,uBAAuB,IAAI,aAAa,EAAE,CAAC;QAC9D,OAAO,uBAAC,2BAAQ,IAAC,EAAE,EAAE,IAAI,CAAC,uBAAuB,EAAE,OAAO,SAAG,CAAC;IAChE,CAAC;IAED,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,OAAO,uBAAC,2BAAQ,IAAC,EAAE,EAAE,mBAAmB,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,EAAE,MAAM,CAAC,EAAE,OAAO,SAAG,CAAC;IACzF,CAAC;IAED,OAAO,IAAA,4BAAkB,EAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AACzC,CAAC;AAED,SAAgB,cAAc,CAAC,EAAE,MAAM,EAAiC;IACtE,MAAM,KAAK,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE,CAAC,IAAA,eAAQ,GAAE,EAAE,EAAE,CAAC,CAAC;IAE5C,OAAO,CACL,uBAAC,gCAAa,IAAC,QAAQ,EAAE,MAAM,CAAC,OAAO,YACrC,uBAAC,yBAAM,cACJ,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CACnB,uBAAC,wBAAK,IAEJ,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,OAAO,EAAE,uBAAC,SAAS,IAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,GAAI,IAF7C,IAAI,CAAC,IAAI,CAGd,CACH,CAAC,GACK,GACK,CACjB,CAAC;AACJ,CAAC;AAEY,QAAA,eAAe,GAAG;IAC7B,WAAW;IACX,cAAc;IACd,aAAa;CACd,CAAC"}
@@ -0,0 +1,137 @@
1
+ interface FragmentFetchConfig {
2
+ baseUrl: string;
3
+ timeout?: number;
4
+ retries?: number;
5
+ retryDelay?: number;
6
+ headers?: Record<string, string>;
7
+ tokenTransport?: "cookie" | "localStorage" | "memory";
8
+ tokenKey?: string;
9
+ onUnauthorized?: "throw" | `redirect:${string}` | "silent";
10
+ onForbidden?: "throw" | `redirect:${string}` | "silent";
11
+ onError?: (err: FragmentHttpError) => void;
12
+ }
13
+ interface RequestOptions {
14
+ headers?: Record<string, string>;
15
+ params?: Record<string, string | number | boolean | Array<string | number | boolean>>;
16
+ timeout?: number;
17
+ retries?: number;
18
+ skipAuth?: boolean;
19
+ signal?: AbortSignal;
20
+ }
21
+ declare class FragmentHttpError extends Error {
22
+ status: number;
23
+ statusText: string;
24
+ body: unknown;
25
+ request: Request;
26
+ response: Response;
27
+ constructor(message: string, init: {
28
+ status: number;
29
+ statusText: string;
30
+ body: unknown;
31
+ request: Request;
32
+ response: Response;
33
+ });
34
+ }
35
+ type RequestInterceptor = (request: Request) => Promise<Request> | Request;
36
+ type ResponseInterceptor = (response: Response, context: {
37
+ request: Request;
38
+ error?: FragmentHttpError;
39
+ }) => Promise<Response> | Response;
40
+ declare const FragmentFetch: {
41
+ configure(config: FragmentFetchConfig): void;
42
+ get<T>(path: string, options?: RequestOptions): Promise<T>;
43
+ post<T>(path: string, body?: unknown, options?: RequestOptions): Promise<T>;
44
+ put<T>(path: string, body?: unknown, options?: RequestOptions): Promise<T>;
45
+ patch<T>(path: string, body?: unknown, options?: RequestOptions): Promise<T>;
46
+ delete<T>(path: string, options?: RequestOptions): Promise<T>;
47
+ request<T>(path: string, init?: RequestInit, options?: RequestOptions): Promise<T>;
48
+ setToken(token: string): void;
49
+ clearToken(): void;
50
+ getToken(): string | null;
51
+ addRequestInterceptor(fn: RequestInterceptor): () => void;
52
+ addResponseInterceptor(fn: ResponseInterceptor): () => void;
53
+ };
54
+
55
+ declare function FragmentWebApplication(options: {
56
+ rootElement: string;
57
+ strict?: boolean;
58
+ }): ClassDecorator;
59
+ declare class FragmentWebUIApplication {
60
+ bootstrap(applicationClass: new () => unknown): Promise<void>;
61
+ }
62
+
63
+ declare function Component(options?: {
64
+ tag?: string;
65
+ memo?: boolean;
66
+ displayName?: string;
67
+ }): ClassDecorator;
68
+ declare function State(initial: unknown): PropertyDecorator;
69
+ declare function Computed(deps?: string[]): MethodDecorator;
70
+ declare function Effect(options: {
71
+ on: "mount" | "update" | "unmount";
72
+ deps?: string[];
73
+ }): MethodDecorator;
74
+ declare function Watch(key: string): MethodDecorator;
75
+ declare function Store(store: unknown, selector?: (state: any) => unknown): PropertyDecorator;
76
+ declare function Prop(defaultValue?: unknown): PropertyDecorator;
77
+ declare function Ref(): PropertyDecorator;
78
+ declare function Inject(token: unknown): PropertyDecorator;
79
+ declare function FragmentService(): ClassDecorator;
80
+ declare function Injectable(_scope?: "singleton" | "transient"): ClassDecorator;
81
+
82
+ declare function Page(options: {
83
+ path: string;
84
+ title?: string;
85
+ layout?: string;
86
+ }): ClassDecorator;
87
+ declare function Layout(options: {
88
+ name: string;
89
+ }): ClassDecorator;
90
+ declare function Guard(guardClass: new (...args: any[]) => {
91
+ canActivate?: () => boolean | Promise<boolean>;
92
+ }): ClassDecorator;
93
+ declare function Param(_name: string): PropertyDecorator;
94
+ declare function Query(_name: string, _defaultValue?: string): PropertyDecorator;
95
+ declare function RedirectIfAuthenticated(to?: string): ClassDecorator;
96
+
97
+ type Token<T = unknown> = string | symbol | (new (...args: any[]) => T);
98
+ declare class DIContainer {
99
+ private static providers;
100
+ static register<T>(token: Token<T>, value: T): void;
101
+ static resolve<T>(token: Token<T>): T;
102
+ static clear(): void;
103
+ }
104
+
105
+ type StructureMode = "layered" | "module" | "feature" | "mvvm";
106
+ type StoreAdapter = "zustand" | "jotai" | "redux" | "mobx";
107
+ interface FragmentWebConfig {
108
+ webRoot: string;
109
+ serverRoot: string;
110
+ publicRoutes: string[];
111
+ authenticatedRoutes: string[];
112
+ app: {
113
+ name: string;
114
+ rootElement: string;
115
+ strict: boolean;
116
+ router: "react-router";
117
+ stateAdapter: StoreAdapter;
118
+ };
119
+ fetch: {
120
+ baseUrl: string;
121
+ timeout?: number;
122
+ retries?: number;
123
+ retryDelay?: number;
124
+ headers?: Record<string, string>;
125
+ tokenTransport?: "cookie" | "localStorage" | "memory";
126
+ tokenKey?: string;
127
+ onUnauthorized?: "throw" | `redirect:${string}` | "silent";
128
+ onForbidden?: "throw" | `redirect:${string}` | "silent";
129
+ };
130
+ structure: StructureMode;
131
+ di: {
132
+ autoScan: boolean;
133
+ scanPaths: string[];
134
+ };
135
+ }
136
+
137
+ export { Component, Computed, DIContainer, Effect, FragmentFetch, FragmentHttpError, FragmentService, FragmentWebApplication, type FragmentWebConfig, FragmentWebUIApplication, Guard, Inject, Injectable, Layout, Page, Param, Prop, Query, RedirectIfAuthenticated, Ref, State, Store, Watch };
@@ -0,0 +1,137 @@
1
+ interface FragmentFetchConfig {
2
+ baseUrl: string;
3
+ timeout?: number;
4
+ retries?: number;
5
+ retryDelay?: number;
6
+ headers?: Record<string, string>;
7
+ tokenTransport?: "cookie" | "localStorage" | "memory";
8
+ tokenKey?: string;
9
+ onUnauthorized?: "throw" | `redirect:${string}` | "silent";
10
+ onForbidden?: "throw" | `redirect:${string}` | "silent";
11
+ onError?: (err: FragmentHttpError) => void;
12
+ }
13
+ interface RequestOptions {
14
+ headers?: Record<string, string>;
15
+ params?: Record<string, string | number | boolean | Array<string | number | boolean>>;
16
+ timeout?: number;
17
+ retries?: number;
18
+ skipAuth?: boolean;
19
+ signal?: AbortSignal;
20
+ }
21
+ declare class FragmentHttpError extends Error {
22
+ status: number;
23
+ statusText: string;
24
+ body: unknown;
25
+ request: Request;
26
+ response: Response;
27
+ constructor(message: string, init: {
28
+ status: number;
29
+ statusText: string;
30
+ body: unknown;
31
+ request: Request;
32
+ response: Response;
33
+ });
34
+ }
35
+ type RequestInterceptor = (request: Request) => Promise<Request> | Request;
36
+ type ResponseInterceptor = (response: Response, context: {
37
+ request: Request;
38
+ error?: FragmentHttpError;
39
+ }) => Promise<Response> | Response;
40
+ declare const FragmentFetch: {
41
+ configure(config: FragmentFetchConfig): void;
42
+ get<T>(path: string, options?: RequestOptions): Promise<T>;
43
+ post<T>(path: string, body?: unknown, options?: RequestOptions): Promise<T>;
44
+ put<T>(path: string, body?: unknown, options?: RequestOptions): Promise<T>;
45
+ patch<T>(path: string, body?: unknown, options?: RequestOptions): Promise<T>;
46
+ delete<T>(path: string, options?: RequestOptions): Promise<T>;
47
+ request<T>(path: string, init?: RequestInit, options?: RequestOptions): Promise<T>;
48
+ setToken(token: string): void;
49
+ clearToken(): void;
50
+ getToken(): string | null;
51
+ addRequestInterceptor(fn: RequestInterceptor): () => void;
52
+ addResponseInterceptor(fn: ResponseInterceptor): () => void;
53
+ };
54
+
55
+ declare function FragmentWebApplication(options: {
56
+ rootElement: string;
57
+ strict?: boolean;
58
+ }): ClassDecorator;
59
+ declare class FragmentWebUIApplication {
60
+ bootstrap(applicationClass: new () => unknown): Promise<void>;
61
+ }
62
+
63
+ declare function Component(options?: {
64
+ tag?: string;
65
+ memo?: boolean;
66
+ displayName?: string;
67
+ }): ClassDecorator;
68
+ declare function State(initial: unknown): PropertyDecorator;
69
+ declare function Computed(deps?: string[]): MethodDecorator;
70
+ declare function Effect(options: {
71
+ on: "mount" | "update" | "unmount";
72
+ deps?: string[];
73
+ }): MethodDecorator;
74
+ declare function Watch(key: string): MethodDecorator;
75
+ declare function Store(store: unknown, selector?: (state: any) => unknown): PropertyDecorator;
76
+ declare function Prop(defaultValue?: unknown): PropertyDecorator;
77
+ declare function Ref(): PropertyDecorator;
78
+ declare function Inject(token: unknown): PropertyDecorator;
79
+ declare function FragmentService(): ClassDecorator;
80
+ declare function Injectable(_scope?: "singleton" | "transient"): ClassDecorator;
81
+
82
+ declare function Page(options: {
83
+ path: string;
84
+ title?: string;
85
+ layout?: string;
86
+ }): ClassDecorator;
87
+ declare function Layout(options: {
88
+ name: string;
89
+ }): ClassDecorator;
90
+ declare function Guard(guardClass: new (...args: any[]) => {
91
+ canActivate?: () => boolean | Promise<boolean>;
92
+ }): ClassDecorator;
93
+ declare function Param(_name: string): PropertyDecorator;
94
+ declare function Query(_name: string, _defaultValue?: string): PropertyDecorator;
95
+ declare function RedirectIfAuthenticated(to?: string): ClassDecorator;
96
+
97
+ type Token<T = unknown> = string | symbol | (new (...args: any[]) => T);
98
+ declare class DIContainer {
99
+ private static providers;
100
+ static register<T>(token: Token<T>, value: T): void;
101
+ static resolve<T>(token: Token<T>): T;
102
+ static clear(): void;
103
+ }
104
+
105
+ type StructureMode = "layered" | "module" | "feature" | "mvvm";
106
+ type StoreAdapter = "zustand" | "jotai" | "redux" | "mobx";
107
+ interface FragmentWebConfig {
108
+ webRoot: string;
109
+ serverRoot: string;
110
+ publicRoutes: string[];
111
+ authenticatedRoutes: string[];
112
+ app: {
113
+ name: string;
114
+ rootElement: string;
115
+ strict: boolean;
116
+ router: "react-router";
117
+ stateAdapter: StoreAdapter;
118
+ };
119
+ fetch: {
120
+ baseUrl: string;
121
+ timeout?: number;
122
+ retries?: number;
123
+ retryDelay?: number;
124
+ headers?: Record<string, string>;
125
+ tokenTransport?: "cookie" | "localStorage" | "memory";
126
+ tokenKey?: string;
127
+ onUnauthorized?: "throw" | `redirect:${string}` | "silent";
128
+ onForbidden?: "throw" | `redirect:${string}` | "silent";
129
+ };
130
+ structure: StructureMode;
131
+ di: {
132
+ autoScan: boolean;
133
+ scanPaths: string[];
134
+ };
135
+ }
136
+
137
+ export { Component, Computed, DIContainer, Effect, FragmentFetch, FragmentHttpError, FragmentService, FragmentWebApplication, type FragmentWebConfig, FragmentWebUIApplication, Guard, Inject, Injectable, Layout, Page, Param, Prop, Query, RedirectIfAuthenticated, Ref, State, Store, Watch };