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,290 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FragmentFetch = exports.FragmentHttpError = void 0;
4
+ class FragmentHttpError extends Error {
5
+ constructor(message, init) {
6
+ super(message);
7
+ this.name = "FragmentHttpError";
8
+ this.status = init.status;
9
+ this.statusText = init.statusText;
10
+ this.body = init.body;
11
+ this.request = init.request;
12
+ this.response = init.response;
13
+ }
14
+ }
15
+ exports.FragmentHttpError = FragmentHttpError;
16
+ const memoryTokenState = { token: null };
17
+ class FragmentFetchClient {
18
+ constructor() {
19
+ this.config = {
20
+ baseUrl: "",
21
+ timeout: 10000,
22
+ retries: 0,
23
+ retryDelay: 300,
24
+ headers: {},
25
+ tokenTransport: "cookie",
26
+ tokenKey: "fragment_token",
27
+ onUnauthorized: "throw",
28
+ onForbidden: "throw",
29
+ onError: undefined,
30
+ };
31
+ this.requestInterceptors = [];
32
+ this.responseInterceptors = [];
33
+ }
34
+ configure(config) {
35
+ this.config = {
36
+ ...this.config,
37
+ ...config,
38
+ headers: {
39
+ ...this.config.headers,
40
+ ...(config.headers || {}),
41
+ },
42
+ };
43
+ }
44
+ setToken(token) {
45
+ memoryTokenState.token = token;
46
+ if (this.config.tokenTransport === "localStorage" && typeof window !== "undefined") {
47
+ window.localStorage.setItem(this.config.tokenKey, token);
48
+ }
49
+ }
50
+ clearToken() {
51
+ memoryTokenState.token = null;
52
+ if (this.config.tokenTransport === "localStorage" && typeof window !== "undefined") {
53
+ window.localStorage.removeItem(this.config.tokenKey);
54
+ }
55
+ }
56
+ getToken() {
57
+ if (this.config.tokenTransport === "memory") {
58
+ return memoryTokenState.token;
59
+ }
60
+ if (this.config.tokenTransport === "localStorage" && typeof window !== "undefined") {
61
+ return window.localStorage.getItem(this.config.tokenKey);
62
+ }
63
+ return null;
64
+ }
65
+ addRequestInterceptor(fn) {
66
+ this.requestInterceptors.push(fn);
67
+ return () => {
68
+ this.requestInterceptors = this.requestInterceptors.filter((it) => it !== fn);
69
+ };
70
+ }
71
+ addResponseInterceptor(fn) {
72
+ this.responseInterceptors.push(fn);
73
+ return () => {
74
+ this.responseInterceptors = this.responseInterceptors.filter((it) => it !== fn);
75
+ };
76
+ }
77
+ get(path, options) {
78
+ return this.request(path, { method: "GET" }, options);
79
+ }
80
+ post(path, body, options) {
81
+ return this.request(path, { method: "POST", body: body ? JSON.stringify(body) : undefined }, options);
82
+ }
83
+ put(path, body, options) {
84
+ return this.request(path, { method: "PUT", body: body ? JSON.stringify(body) : undefined }, options);
85
+ }
86
+ patch(path, body, options) {
87
+ return this.request(path, { method: "PATCH", body: body ? JSON.stringify(body) : undefined }, options);
88
+ }
89
+ delete(path, options) {
90
+ return this.request(path, { method: "DELETE" }, options);
91
+ }
92
+ async request(path, init = {}, options = {}) {
93
+ const url = this.buildUrl(path, options.params);
94
+ const headers = {
95
+ "Content-Type": "application/json",
96
+ ...this.config.headers,
97
+ ...options.headers,
98
+ };
99
+ if (!options.skipAuth && this.config.tokenTransport !== "cookie") {
100
+ const token = this.getToken();
101
+ if (token) {
102
+ headers.Authorization = `Bearer ${token}`;
103
+ }
104
+ }
105
+ const controller = new AbortController();
106
+ const timeoutMs = options.timeout ?? this.config.timeout;
107
+ const timeout = setTimeout(() => controller.abort(), timeoutMs);
108
+ let request = new Request(url, {
109
+ ...init,
110
+ headers,
111
+ credentials: this.config.tokenTransport === "cookie" ? "include" : init.credentials,
112
+ signal: options.signal || controller.signal,
113
+ });
114
+ for (const interceptor of this.requestInterceptors) {
115
+ request = await interceptor(request);
116
+ }
117
+ const retries = options.retries ?? this.config.retries;
118
+ try {
119
+ return await this.executeWithRetry(request, retries, this.config.retryDelay);
120
+ }
121
+ catch (error) {
122
+ if (error instanceof FragmentHttpError) {
123
+ this.config.onError?.(error);
124
+ }
125
+ throw error;
126
+ }
127
+ finally {
128
+ clearTimeout(timeout);
129
+ }
130
+ }
131
+ async executeWithRetry(request, retries, retryDelay) {
132
+ let attempt = 0;
133
+ let lastError = null;
134
+ while (attempt <= retries) {
135
+ try {
136
+ const response = await fetch(request.clone());
137
+ for (const interceptor of this.responseInterceptors) {
138
+ await interceptor(response, { request });
139
+ }
140
+ if (!response.ok) {
141
+ const body = await this.parseBody(response);
142
+ const error = new FragmentHttpError(`HTTP ${response.status}`, {
143
+ status: response.status,
144
+ statusText: response.statusText,
145
+ body,
146
+ request,
147
+ response,
148
+ });
149
+ if (response.status === 401) {
150
+ const result = this.handleAuthMode(this.config.onUnauthorized);
151
+ if (result === "silent")
152
+ return null;
153
+ }
154
+ if (response.status === 403) {
155
+ const result = this.handleAuthMode(this.config.onForbidden);
156
+ if (result === "silent")
157
+ return null;
158
+ }
159
+ for (const interceptor of this.responseInterceptors) {
160
+ await interceptor(response, { request, error });
161
+ }
162
+ if (response.status >= 500 && attempt < retries) {
163
+ await this.delay(retryDelay);
164
+ attempt += 1;
165
+ continue;
166
+ }
167
+ throw error;
168
+ }
169
+ return (await this.parseBody(response));
170
+ }
171
+ catch (error) {
172
+ if (error instanceof FragmentHttpError) {
173
+ throw error;
174
+ }
175
+ if (error?.name === "AbortError") {
176
+ const syntheticResponse = new Response(null, { status: 408, statusText: "Request Timeout" });
177
+ throw new FragmentHttpError("Request timeout", {
178
+ status: 408,
179
+ statusText: "Request Timeout",
180
+ body: null,
181
+ request,
182
+ response: syntheticResponse,
183
+ });
184
+ }
185
+ lastError = error;
186
+ if (attempt >= retries) {
187
+ const syntheticResponse = new Response(null, { status: 503, statusText: "Service Unavailable" });
188
+ throw new FragmentHttpError(error?.message || "Network error", {
189
+ status: 503,
190
+ statusText: "Service Unavailable",
191
+ body: null,
192
+ request,
193
+ response: syntheticResponse,
194
+ });
195
+ }
196
+ await this.delay(retryDelay);
197
+ }
198
+ attempt += 1;
199
+ }
200
+ const syntheticResponse = new Response(null, { status: 503, statusText: "Service Unavailable" });
201
+ throw new FragmentHttpError("Request failed", {
202
+ status: 503,
203
+ statusText: "Service Unavailable",
204
+ body: lastError,
205
+ request,
206
+ response: syntheticResponse,
207
+ });
208
+ }
209
+ async parseBody(response) {
210
+ const contentType = response.headers.get("content-type") || "";
211
+ if (contentType.includes("application/json")) {
212
+ return response.json();
213
+ }
214
+ const text = await response.text();
215
+ return text.length ? text : null;
216
+ }
217
+ buildUrl(path, params) {
218
+ const normalizedBase = this.config.baseUrl.replace(/\/$/, "");
219
+ const normalizedPath = path.startsWith("/") ? path : `/${path}`;
220
+ const url = new URL(`${normalizedBase}${normalizedPath}`);
221
+ if (params) {
222
+ Object.entries(params).forEach(([key, value]) => {
223
+ if (Array.isArray(value)) {
224
+ value.forEach((v) => url.searchParams.append(key, String(v)));
225
+ return;
226
+ }
227
+ url.searchParams.append(key, String(value));
228
+ });
229
+ }
230
+ return url.toString();
231
+ }
232
+ handleAuthMode(mode) {
233
+ if (!mode || mode === "throw") {
234
+ return "throw";
235
+ }
236
+ if (mode === "silent") {
237
+ return "silent";
238
+ }
239
+ if (mode.startsWith("redirect:")) {
240
+ const to = mode.slice("redirect:".length);
241
+ if (typeof window !== "undefined") {
242
+ window.location.href = to;
243
+ }
244
+ }
245
+ return "throw";
246
+ }
247
+ async delay(ms) {
248
+ await new Promise((resolve) => setTimeout(resolve, ms));
249
+ }
250
+ }
251
+ const client = new FragmentFetchClient();
252
+ exports.FragmentFetch = {
253
+ configure(config) {
254
+ client.configure(config);
255
+ },
256
+ get(path, options) {
257
+ return client.get(path, options);
258
+ },
259
+ post(path, body, options) {
260
+ return client.post(path, body, options);
261
+ },
262
+ put(path, body, options) {
263
+ return client.put(path, body, options);
264
+ },
265
+ patch(path, body, options) {
266
+ return client.patch(path, body, options);
267
+ },
268
+ delete(path, options) {
269
+ return client.delete(path, options);
270
+ },
271
+ request(path, init, options) {
272
+ return client.request(path, init, options);
273
+ },
274
+ setToken(token) {
275
+ client.setToken(token);
276
+ },
277
+ clearToken() {
278
+ client.clearToken();
279
+ },
280
+ getToken() {
281
+ return client.getToken();
282
+ },
283
+ addRequestInterceptor(fn) {
284
+ return client.addRequestInterceptor(fn);
285
+ },
286
+ addResponseInterceptor(fn) {
287
+ return client.addResponseInterceptor(fn);
288
+ },
289
+ };
290
+ //# sourceMappingURL=fragment-fetch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fragment-fetch.js","sourceRoot":"","sources":["../../../../src/web/src/http/fragment-fetch.ts"],"names":[],"mappings":";;;AAsBA,MAAa,iBAAkB,SAAQ,KAAK;IAO1C,YAAY,OAAe,EAAE,IAM5B;QACC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC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IACD,OAAO,CAAI,IAAY,EAAE,IAAkB,EAAE,OAAwB;QACnE,OAAO,MAAM,CAAC,OAAO,CAAI,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAChD,CAAC;IACD,QAAQ,CAAC,KAAa;QACpB,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACzB,CAAC;IACD,UAAU;QACR,MAAM,CAAC,UAAU,EAAE,CAAC;IACtB,CAAC;IACD,QAAQ;QACN,OAAO,MAAM,CAAC,QAAQ,EAAE,CAAC;IAC3B,CAAC;IACD,qBAAqB,CAAC,EAAsB;QAC1C,OAAO,MAAM,CAAC,qBAAqB,CAAC,EAAE,CAAC,CAAC;IAC1C,CAAC;IACD,sBAAsB,CAAC,EAAuB;QAC5C,OAAO,MAAM,CAAC,sBAAsB,CAAC,EAAE,CAAC,CAAC;IAC3C,CAAC;CACF,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,7 @@
1
+ export { FragmentFetch, FragmentHttpError } from "./http/fragment-fetch";
2
+ export { FragmentWebApplication, FragmentWebUIApplication } from "./core/application";
3
+ export { Component, State, Computed, Effect, Watch, Store, Prop, Ref, Inject, FragmentService, Injectable, } from "./core/decorators/component";
4
+ export { Page, Layout, Guard, Param, Query, RedirectIfAuthenticated, } from "./core/decorators/page";
5
+ export { DIContainer } from "./core/di/container";
6
+ export type { FragmentWebConfig } from "./config/web-config";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/web/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AACzE,OAAO,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AACtF,OAAO,EACL,SAAS,EACT,KAAK,EACL,QAAQ,EACR,MAAM,EACN,KAAK,EACL,KAAK,EACL,IAAI,EACJ,GAAG,EACH,MAAM,EACN,eAAe,EACf,UAAU,GACX,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,IAAI,EACJ,MAAM,EACN,KAAK,EACL,KAAK,EACL,KAAK,EACL,uBAAuB,GACxB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,YAAY,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DIContainer = exports.RedirectIfAuthenticated = exports.Query = exports.Param = exports.Guard = exports.Layout = exports.Page = exports.Injectable = exports.FragmentService = exports.Inject = exports.Ref = exports.Prop = exports.Store = exports.Watch = exports.Effect = exports.Computed = exports.State = exports.Component = exports.FragmentWebUIApplication = exports.FragmentWebApplication = exports.FragmentHttpError = exports.FragmentFetch = void 0;
4
+ var fragment_fetch_1 = require("./http/fragment-fetch");
5
+ Object.defineProperty(exports, "FragmentFetch", { enumerable: true, get: function () { return fragment_fetch_1.FragmentFetch; } });
6
+ Object.defineProperty(exports, "FragmentHttpError", { enumerable: true, get: function () { return fragment_fetch_1.FragmentHttpError; } });
7
+ var application_1 = require("./core/application");
8
+ Object.defineProperty(exports, "FragmentWebApplication", { enumerable: true, get: function () { return application_1.FragmentWebApplication; } });
9
+ Object.defineProperty(exports, "FragmentWebUIApplication", { enumerable: true, get: function () { return application_1.FragmentWebUIApplication; } });
10
+ var component_1 = require("./core/decorators/component");
11
+ Object.defineProperty(exports, "Component", { enumerable: true, get: function () { return component_1.Component; } });
12
+ Object.defineProperty(exports, "State", { enumerable: true, get: function () { return component_1.State; } });
13
+ Object.defineProperty(exports, "Computed", { enumerable: true, get: function () { return component_1.Computed; } });
14
+ Object.defineProperty(exports, "Effect", { enumerable: true, get: function () { return component_1.Effect; } });
15
+ Object.defineProperty(exports, "Watch", { enumerable: true, get: function () { return component_1.Watch; } });
16
+ Object.defineProperty(exports, "Store", { enumerable: true, get: function () { return component_1.Store; } });
17
+ Object.defineProperty(exports, "Prop", { enumerable: true, get: function () { return component_1.Prop; } });
18
+ Object.defineProperty(exports, "Ref", { enumerable: true, get: function () { return component_1.Ref; } });
19
+ Object.defineProperty(exports, "Inject", { enumerable: true, get: function () { return component_1.Inject; } });
20
+ Object.defineProperty(exports, "FragmentService", { enumerable: true, get: function () { return component_1.FragmentService; } });
21
+ Object.defineProperty(exports, "Injectable", { enumerable: true, get: function () { return component_1.Injectable; } });
22
+ var page_1 = require("./core/decorators/page");
23
+ Object.defineProperty(exports, "Page", { enumerable: true, get: function () { return page_1.Page; } });
24
+ Object.defineProperty(exports, "Layout", { enumerable: true, get: function () { return page_1.Layout; } });
25
+ Object.defineProperty(exports, "Guard", { enumerable: true, get: function () { return page_1.Guard; } });
26
+ Object.defineProperty(exports, "Param", { enumerable: true, get: function () { return page_1.Param; } });
27
+ Object.defineProperty(exports, "Query", { enumerable: true, get: function () { return page_1.Query; } });
28
+ Object.defineProperty(exports, "RedirectIfAuthenticated", { enumerable: true, get: function () { return page_1.RedirectIfAuthenticated; } });
29
+ var container_1 = require("./core/di/container");
30
+ Object.defineProperty(exports, "DIContainer", { enumerable: true, get: function () { return container_1.DIContainer; } });
31
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/web/src/index.ts"],"names":[],"mappings":";;;AAAA,wDAAyE;AAAhE,+GAAA,aAAa,OAAA;AAAE,mHAAA,iBAAiB,OAAA;AACzC,kDAAsF;AAA7E,qHAAA,sBAAsB,OAAA;AAAE,uHAAA,wBAAwB,OAAA;AACzD,yDAYqC;AAXnC,sGAAA,SAAS,OAAA;AACT,kGAAA,KAAK,OAAA;AACL,qGAAA,QAAQ,OAAA;AACR,mGAAA,MAAM,OAAA;AACN,kGAAA,KAAK,OAAA;AACL,kGAAA,KAAK,OAAA;AACL,iGAAA,IAAI,OAAA;AACJ,gGAAA,GAAG,OAAA;AACH,mGAAA,MAAM,OAAA;AACN,4GAAA,eAAe,OAAA;AACf,uGAAA,UAAU,OAAA;AAEZ,+CAOgC;AAN9B,4FAAA,IAAI,OAAA;AACJ,8FAAA,MAAM,OAAA;AACN,6FAAA,KAAK,OAAA;AACL,6FAAA,KAAK,OAAA;AACL,6FAAA,KAAK,OAAA;AACL,+GAAA,uBAAuB,OAAA;AAEzB,iDAAkD;AAAzC,wGAAA,WAAW,OAAA"}