fragment-ts 2.0.3 → 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.
- package/dist/platform/cli/commands/install/command.d.ts +14 -0
- package/dist/platform/cli/commands/install/command.d.ts.map +1 -0
- package/dist/platform/cli/commands/install/command.js +145 -0
- package/dist/platform/cli/commands/install/command.js.map +1 -0
- package/dist/platform/cli/commands/register.d.ts.map +1 -1
- package/dist/platform/cli/commands/register.js +37 -28
- package/dist/platform/cli/commands/register.js.map +1 -1
- package/dist/platform/cli/index.js +61 -1
- package/dist/platform/cli/index.js.map +1 -1
- package/dist/platform/cli/web/commands/create/feature.d.ts +11 -0
- package/dist/platform/cli/web/commands/create/feature.d.ts.map +1 -0
- package/dist/platform/cli/web/commands/create/feature.js +43 -0
- package/dist/platform/cli/web/commands/create/feature.js.map +1 -0
- package/dist/platform/cli/web/commands/create/module.d.ts +11 -0
- package/dist/platform/cli/web/commands/create/module.d.ts.map +1 -0
- package/dist/platform/cli/web/commands/create/module.js +44 -0
- package/dist/platform/cli/web/commands/create/module.js.map +1 -0
- package/dist/platform/cli/web/commands/create/mvvm.d.ts +11 -0
- package/dist/platform/cli/web/commands/create/mvvm.d.ts.map +1 -0
- package/dist/platform/cli/web/commands/create/mvvm.js +43 -0
- package/dist/platform/cli/web/commands/create/mvvm.js.map +1 -0
- package/dist/platform/cli/web/commands/init-fullstack.d.ts +12 -0
- package/dist/platform/cli/web/commands/init-fullstack.d.ts.map +1 -0
- package/dist/platform/cli/web/commands/init-fullstack.js +42 -0
- package/dist/platform/cli/web/commands/init-fullstack.js.map +1 -0
- package/dist/platform/cli/web/commands/init-web.d.ts +12 -0
- package/dist/platform/cli/web/commands/init-web.d.ts.map +1 -0
- package/dist/platform/cli/web/commands/init-web.js +70 -0
- package/dist/platform/cli/web/commands/init-web.js.map +1 -0
- package/dist/platform/cli/web/commands/install-api.d.ts +11 -0
- package/dist/platform/cli/web/commands/install-api.d.ts.map +1 -0
- package/dist/platform/cli/web/commands/install-api.js +92 -0
- package/dist/platform/cli/web/commands/install-api.js.map +1 -0
- package/dist/platform/cli/web/commands/install-web.d.ts +13 -0
- package/dist/platform/cli/web/commands/install-web.d.ts.map +1 -0
- package/dist/platform/cli/web/commands/install-web.js +102 -0
- package/dist/platform/cli/web/commands/install-web.js.map +1 -0
- package/dist/platform/cli/web/commands/install.d.ts +3 -0
- package/dist/platform/cli/web/commands/install.d.ts.map +1 -0
- package/dist/platform/cli/web/commands/install.js +23 -0
- package/dist/platform/cli/web/commands/install.js.map +1 -0
- package/dist/platform/cli/web/commands/make/component.d.ts +16 -0
- package/dist/platform/cli/web/commands/make/component.d.ts.map +1 -0
- package/dist/platform/cli/web/commands/make/component.js +73 -0
- package/dist/platform/cli/web/commands/make/component.js.map +1 -0
- package/dist/platform/cli/web/commands/make/guard.d.ts +13 -0
- package/dist/platform/cli/web/commands/make/guard.d.ts.map +1 -0
- package/dist/platform/cli/web/commands/make/guard.js +46 -0
- package/dist/platform/cli/web/commands/make/guard.js.map +1 -0
- package/dist/platform/cli/web/commands/make/layout.d.ts +12 -0
- package/dist/platform/cli/web/commands/make/layout.d.ts.map +1 -0
- package/dist/platform/cli/web/commands/make/layout.js +44 -0
- package/dist/platform/cli/web/commands/make/layout.js.map +1 -0
- package/dist/platform/cli/web/commands/make/page.d.ts +17 -0
- package/dist/platform/cli/web/commands/make/page.d.ts.map +1 -0
- package/dist/platform/cli/web/commands/make/page.js +66 -0
- package/dist/platform/cli/web/commands/make/page.js.map +1 -0
- package/dist/platform/cli/web/commands/make/resource.d.ts +17 -0
- package/dist/platform/cli/web/commands/make/resource.d.ts.map +1 -0
- package/dist/platform/cli/web/commands/make/resource.js +37 -0
- package/dist/platform/cli/web/commands/make/resource.js.map +1 -0
- package/dist/platform/cli/web/commands/make/service.d.ts +16 -0
- package/dist/platform/cli/web/commands/make/service.d.ts.map +1 -0
- package/dist/platform/cli/web/commands/make/service.js +137 -0
- package/dist/platform/cli/web/commands/make/service.js.map +1 -0
- package/dist/platform/cli/web/commands/make/store.d.ts +16 -0
- package/dist/platform/cli/web/commands/make/store.d.ts.map +1 -0
- package/dist/platform/cli/web/commands/make/store.js +72 -0
- package/dist/platform/cli/web/commands/make/store.js.map +1 -0
- package/dist/platform/cli/web/commands/web-sync.d.ts +10 -0
- package/dist/platform/cli/web/commands/web-sync.d.ts.map +1 -0
- package/dist/platform/cli/web/commands/web-sync.js +307 -0
- package/dist/platform/cli/web/commands/web-sync.js.map +1 -0
- package/dist/platform/cli/web/index.d.ts +3 -0
- package/dist/platform/cli/web/index.d.ts.map +1 -0
- package/dist/platform/cli/web/index.js +40 -0
- package/dist/platform/cli/web/index.js.map +1 -0
- package/dist/platform/cli/web/utils/config.d.ts +52 -0
- package/dist/platform/cli/web/utils/config.d.ts.map +1 -0
- package/dist/platform/cli/web/utils/config.js +89 -0
- package/dist/platform/cli/web/utils/config.js.map +1 -0
- package/dist/platform/cli/web/utils/format.d.ts +2 -0
- package/dist/platform/cli/web/utils/format.d.ts.map +1 -0
- package/dist/platform/cli/web/utils/format.js +28 -0
- package/dist/platform/cli/web/utils/format.js.map +1 -0
- package/dist/platform/cli/web/utils/header.d.ts +3 -0
- package/dist/platform/cli/web/utils/header.d.ts.map +1 -0
- package/dist/platform/cli/web/utils/header.js +11 -0
- package/dist/platform/cli/web/utils/header.js.map +1 -0
- package/dist/platform/cli/web/utils/logger.d.ts +10 -0
- package/dist/platform/cli/web/utils/logger.d.ts.map +1 -0
- package/dist/platform/cli/web/utils/logger.js +47 -0
- package/dist/platform/cli/web/utils/logger.js.map +1 -0
- package/dist/platform/cli/web/utils/names.d.ts +7 -0
- package/dist/platform/cli/web/utils/names.d.ts.map +1 -0
- package/dist/platform/cli/web/utils/names.js +43 -0
- package/dist/platform/cli/web/utils/names.js.map +1 -0
- package/dist/platform/cli/web/utils/resolve-paths.d.ts +10 -0
- package/dist/platform/cli/web/utils/resolve-paths.d.ts.map +1 -0
- package/dist/platform/cli/web/utils/resolve-paths.js +87 -0
- package/dist/platform/cli/web/utils/resolve-paths.js.map +1 -0
- package/dist/platform/cli/web/utils/write-file.d.ts +7 -0
- package/dist/platform/cli/web/utils/write-file.d.ts.map +1 -0
- package/dist/platform/cli/web/utils/write-file.js +31 -0
- package/dist/platform/cli/web/utils/write-file.js.map +1 -0
- package/dist/web/cli/commands/create/feature.d.ts +11 -0
- package/dist/web/cli/commands/create/feature.d.ts.map +1 -0
- package/dist/web/cli/commands/create/feature.js +43 -0
- package/dist/web/cli/commands/create/feature.js.map +1 -0
- package/dist/web/cli/commands/create/module.d.ts +11 -0
- package/dist/web/cli/commands/create/module.d.ts.map +1 -0
- package/dist/web/cli/commands/create/module.js +44 -0
- package/dist/web/cli/commands/create/module.js.map +1 -0
- package/dist/web/cli/commands/create/mvvm.d.ts +11 -0
- package/dist/web/cli/commands/create/mvvm.d.ts.map +1 -0
- package/dist/web/cli/commands/create/mvvm.js +43 -0
- package/dist/web/cli/commands/create/mvvm.js.map +1 -0
- package/dist/web/cli/commands/init-fullstack.d.ts +12 -0
- package/dist/web/cli/commands/init-fullstack.d.ts.map +1 -0
- package/dist/web/cli/commands/init-fullstack.js +42 -0
- package/dist/web/cli/commands/init-fullstack.js.map +1 -0
- package/dist/web/cli/commands/init-web.d.ts +12 -0
- package/dist/web/cli/commands/init-web.d.ts.map +1 -0
- package/dist/web/cli/commands/init-web.js +70 -0
- package/dist/web/cli/commands/init-web.js.map +1 -0
- package/dist/web/cli/commands/install-api.d.ts +10 -0
- package/dist/web/cli/commands/install-api.d.ts.map +1 -0
- package/dist/web/cli/commands/install-api.js +91 -0
- package/dist/web/cli/commands/install-api.js.map +1 -0
- package/dist/web/cli/commands/install-web.d.ts +12 -0
- package/dist/web/cli/commands/install-web.d.ts.map +1 -0
- package/dist/web/cli/commands/install-web.js +101 -0
- package/dist/web/cli/commands/install-web.js.map +1 -0
- package/dist/web/cli/commands/make/component.d.ts +13 -0
- package/dist/web/cli/commands/make/component.d.ts.map +1 -0
- package/dist/web/cli/commands/make/component.js +40 -0
- package/dist/web/cli/commands/make/component.js.map +1 -0
- package/dist/web/cli/commands/make/guard.d.ts +11 -0
- package/dist/web/cli/commands/make/guard.d.ts.map +1 -0
- package/dist/web/cli/commands/make/guard.js +37 -0
- package/dist/web/cli/commands/make/guard.js.map +1 -0
- package/dist/web/cli/commands/make/layout.d.ts +11 -0
- package/dist/web/cli/commands/make/layout.d.ts.map +1 -0
- package/dist/web/cli/commands/make/layout.js +37 -0
- package/dist/web/cli/commands/make/layout.js.map +1 -0
- package/dist/web/cli/commands/make/page.d.ts +14 -0
- package/dist/web/cli/commands/make/page.d.ts.map +1 -0
- package/dist/web/cli/commands/make/page.js +42 -0
- package/dist/web/cli/commands/make/page.js.map +1 -0
- package/dist/web/cli/commands/make/resource.d.ts +13 -0
- package/dist/web/cli/commands/make/resource.d.ts.map +1 -0
- package/dist/web/cli/commands/make/resource.js +33 -0
- package/dist/web/cli/commands/make/resource.js.map +1 -0
- package/dist/web/cli/commands/make/service.d.ts +14 -0
- package/dist/web/cli/commands/make/service.d.ts.map +1 -0
- package/dist/web/cli/commands/make/service.js +56 -0
- package/dist/web/cli/commands/make/service.js.map +1 -0
- package/dist/web/cli/commands/make/store.d.ts +14 -0
- package/dist/web/cli/commands/make/store.d.ts.map +1 -0
- package/dist/web/cli/commands/make/store.js +47 -0
- package/dist/web/cli/commands/make/store.js.map +1 -0
- package/dist/web/cli/commands/web-sync.d.ts +10 -0
- package/dist/web/cli/commands/web-sync.d.ts.map +1 -0
- package/dist/web/cli/commands/web-sync.js +48 -0
- package/dist/web/cli/commands/web-sync.js.map +1 -0
- package/dist/web/cli/index.d.mts +5 -0
- package/dist/web/cli/index.d.ts +5 -0
- package/dist/web/cli/index.d.ts.map +1 -0
- package/dist/web/cli/index.js +36 -0
- package/dist/web/cli/index.js.map +1 -0
- package/dist/web/cli/index.mjs +984 -0
- package/dist/web/cli/utils/config.d.ts +52 -0
- package/dist/web/cli/utils/config.d.ts.map +1 -0
- package/dist/web/cli/utils/config.js +89 -0
- package/dist/web/cli/utils/config.js.map +1 -0
- package/dist/web/cli/utils/format.d.ts +2 -0
- package/dist/web/cli/utils/format.d.ts.map +1 -0
- package/dist/web/cli/utils/format.js +28 -0
- package/dist/web/cli/utils/format.js.map +1 -0
- package/dist/web/cli/utils/logger.d.ts +10 -0
- package/dist/web/cli/utils/logger.d.ts.map +1 -0
- package/dist/web/cli/utils/logger.js +34 -0
- package/dist/web/cli/utils/logger.js.map +1 -0
- package/dist/web/cli/utils/names.d.ts +7 -0
- package/dist/web/cli/utils/names.d.ts.map +1 -0
- package/dist/web/cli/utils/names.js +43 -0
- package/dist/web/cli/utils/names.js.map +1 -0
- package/dist/web/cli/utils/resolve-paths.d.ts +10 -0
- package/dist/web/cli/utils/resolve-paths.d.ts.map +1 -0
- package/dist/web/cli/utils/resolve-paths.js +87 -0
- package/dist/web/cli/utils/resolve-paths.js.map +1 -0
- package/dist/web/cli/utils/write-file.d.ts +7 -0
- package/dist/web/cli/utils/write-file.d.ts.map +1 -0
- package/dist/web/cli/utils/write-file.js +31 -0
- package/dist/web/cli/utils/write-file.js.map +1 -0
- package/dist/web/platform/cli/web/index.d.mts +5 -0
- package/dist/web/platform/cli/web/index.d.ts +5 -0
- package/dist/web/platform/cli/web/index.js +2035 -0
- package/dist/web/platform/cli/web/index.mjs +1998 -0
- package/dist/web/src/adapters/jotai.d.ts +2 -0
- package/dist/web/src/adapters/jotai.d.ts.map +1 -0
- package/dist/web/src/adapters/jotai.js +7 -0
- package/dist/web/src/adapters/jotai.js.map +1 -0
- package/dist/web/src/adapters/mobx.d.ts +2 -0
- package/dist/web/src/adapters/mobx.d.ts.map +1 -0
- package/dist/web/src/adapters/mobx.js +7 -0
- package/dist/web/src/adapters/mobx.js.map +1 -0
- package/dist/web/src/adapters/redux.d.ts +2 -0
- package/dist/web/src/adapters/redux.d.ts.map +1 -0
- package/dist/web/src/adapters/redux.js +7 -0
- package/dist/web/src/adapters/redux.js.map +1 -0
- package/dist/web/src/adapters/zustand.d.ts +2 -0
- package/dist/web/src/adapters/zustand.d.ts.map +1 -0
- package/dist/web/src/adapters/zustand.js +7 -0
- package/dist/web/src/adapters/zustand.js.map +1 -0
- package/dist/web/src/config/web-config.d.ts +34 -0
- package/dist/web/src/config/web-config.d.ts.map +1 -0
- package/dist/web/src/config/web-config.js +73 -0
- package/dist/web/src/config/web-config.js.map +1 -0
- package/dist/web/src/core/application.d.ts +8 -0
- package/dist/web/src/core/application.d.ts.map +1 -0
- package/dist/web/src/core/application.js +45 -0
- package/dist/web/src/core/application.js.map +1 -0
- package/dist/web/src/core/decorators/component.d.ts +20 -0
- package/dist/web/src/core/decorators/component.d.ts.map +1 -0
- package/dist/web/src/core/decorators/component.js +83 -0
- package/dist/web/src/core/decorators/component.js.map +1 -0
- package/dist/web/src/core/decorators/page.d.ts +27 -0
- package/dist/web/src/core/decorators/page.d.ts.map +1 -0
- package/dist/web/src/core/decorators/page.js +58 -0
- package/dist/web/src/core/decorators/page.js.map +1 -0
- package/dist/web/src/core/di/container.d.ts +8 -0
- package/dist/web/src/core/di/container.d.ts.map +1 -0
- package/dist/web/src/core/di/container.js +26 -0
- package/dist/web/src/core/di/container.js.map +1 -0
- package/dist/web/src/core/runtime.d.ts +3 -0
- package/dist/web/src/core/runtime.d.ts.map +1 -0
- package/dist/web/src/core/runtime.js +15 -0
- package/dist/web/src/core/runtime.js.map +1 -0
- package/dist/web/src/http/fragment-fetch.d.ts +55 -0
- package/dist/web/src/http/fragment-fetch.d.ts.map +1 -0
- package/dist/web/src/http/fragment-fetch.js +290 -0
- package/dist/web/src/http/fragment-fetch.js.map +1 -0
- package/dist/web/src/index.d.mts +137 -0
- package/dist/web/src/index.d.ts +7 -0
- package/dist/web/src/index.d.ts.map +1 -0
- package/dist/web/src/index.js +31 -0
- package/dist/web/src/index.js.map +1 -0
- package/dist/web/src/index.mjs +643 -0
- package/dist/web/src/router/fragment-router.d.ts +14 -0
- package/dist/web/src/router/fragment-router.d.ts.map +1 -0
- package/dist/web/src/router/fragment-router.js +94 -0
- package/dist/web/src/router/fragment-router.js.map +1 -0
- package/dist/web/web/src/index.d.mts +137 -0
- package/dist/web/web/src/index.d.ts +137 -0
- package/dist/web/web/src/index.js +702 -0
- package/dist/web/web/src/index.mjs +644 -0
- package/package.json +15 -3
|
@@ -0,0 +1,643 @@
|
|
|
1
|
+
// src/web/src/http/fragment-fetch.ts
|
|
2
|
+
var FragmentHttpError = class extends Error {
|
|
3
|
+
constructor(message, init) {
|
|
4
|
+
super(message);
|
|
5
|
+
this.name = "FragmentHttpError";
|
|
6
|
+
this.status = init.status;
|
|
7
|
+
this.statusText = init.statusText;
|
|
8
|
+
this.body = init.body;
|
|
9
|
+
this.request = init.request;
|
|
10
|
+
this.response = init.response;
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
var memoryTokenState = { token: null };
|
|
14
|
+
var FragmentFetchClient = class {
|
|
15
|
+
constructor() {
|
|
16
|
+
this.config = {
|
|
17
|
+
baseUrl: "",
|
|
18
|
+
timeout: 1e4,
|
|
19
|
+
retries: 0,
|
|
20
|
+
retryDelay: 300,
|
|
21
|
+
headers: {},
|
|
22
|
+
tokenTransport: "cookie",
|
|
23
|
+
tokenKey: "fragment_token",
|
|
24
|
+
onUnauthorized: "throw",
|
|
25
|
+
onForbidden: "throw",
|
|
26
|
+
onError: void 0
|
|
27
|
+
};
|
|
28
|
+
this.requestInterceptors = [];
|
|
29
|
+
this.responseInterceptors = [];
|
|
30
|
+
}
|
|
31
|
+
configure(config) {
|
|
32
|
+
this.config = {
|
|
33
|
+
...this.config,
|
|
34
|
+
...config,
|
|
35
|
+
headers: {
|
|
36
|
+
...this.config.headers,
|
|
37
|
+
...config.headers || {}
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
setToken(token) {
|
|
42
|
+
memoryTokenState.token = token;
|
|
43
|
+
if (this.config.tokenTransport === "localStorage" && typeof window !== "undefined") {
|
|
44
|
+
window.localStorage.setItem(this.config.tokenKey, token);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
clearToken() {
|
|
48
|
+
memoryTokenState.token = null;
|
|
49
|
+
if (this.config.tokenTransport === "localStorage" && typeof window !== "undefined") {
|
|
50
|
+
window.localStorage.removeItem(this.config.tokenKey);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
getToken() {
|
|
54
|
+
if (this.config.tokenTransport === "memory") {
|
|
55
|
+
return memoryTokenState.token;
|
|
56
|
+
}
|
|
57
|
+
if (this.config.tokenTransport === "localStorage" && typeof window !== "undefined") {
|
|
58
|
+
return window.localStorage.getItem(this.config.tokenKey);
|
|
59
|
+
}
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
addRequestInterceptor(fn) {
|
|
63
|
+
this.requestInterceptors.push(fn);
|
|
64
|
+
return () => {
|
|
65
|
+
this.requestInterceptors = this.requestInterceptors.filter((it) => it !== fn);
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
addResponseInterceptor(fn) {
|
|
69
|
+
this.responseInterceptors.push(fn);
|
|
70
|
+
return () => {
|
|
71
|
+
this.responseInterceptors = this.responseInterceptors.filter((it) => it !== fn);
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
get(path, options) {
|
|
75
|
+
return this.request(path, { method: "GET" }, options);
|
|
76
|
+
}
|
|
77
|
+
post(path, body, options) {
|
|
78
|
+
return this.request(path, { method: "POST", body: body ? JSON.stringify(body) : void 0 }, options);
|
|
79
|
+
}
|
|
80
|
+
put(path, body, options) {
|
|
81
|
+
return this.request(path, { method: "PUT", body: body ? JSON.stringify(body) : void 0 }, options);
|
|
82
|
+
}
|
|
83
|
+
patch(path, body, options) {
|
|
84
|
+
return this.request(path, { method: "PATCH", body: body ? JSON.stringify(body) : void 0 }, options);
|
|
85
|
+
}
|
|
86
|
+
delete(path, options) {
|
|
87
|
+
return this.request(path, { method: "DELETE" }, options);
|
|
88
|
+
}
|
|
89
|
+
async request(path, init = {}, options = {}) {
|
|
90
|
+
const url = this.buildUrl(path, options.params);
|
|
91
|
+
const headers = {
|
|
92
|
+
"Content-Type": "application/json",
|
|
93
|
+
...this.config.headers,
|
|
94
|
+
...options.headers
|
|
95
|
+
};
|
|
96
|
+
if (!options.skipAuth && this.config.tokenTransport !== "cookie") {
|
|
97
|
+
const token = this.getToken();
|
|
98
|
+
if (token) {
|
|
99
|
+
headers.Authorization = `Bearer ${token}`;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
const controller = new AbortController();
|
|
103
|
+
const timeoutMs = options.timeout ?? this.config.timeout;
|
|
104
|
+
const timeout = setTimeout(() => controller.abort(), timeoutMs);
|
|
105
|
+
let request = new Request(url, {
|
|
106
|
+
...init,
|
|
107
|
+
headers,
|
|
108
|
+
credentials: this.config.tokenTransport === "cookie" ? "include" : init.credentials,
|
|
109
|
+
signal: options.signal || controller.signal
|
|
110
|
+
});
|
|
111
|
+
for (const interceptor of this.requestInterceptors) {
|
|
112
|
+
request = await interceptor(request);
|
|
113
|
+
}
|
|
114
|
+
const retries = options.retries ?? this.config.retries;
|
|
115
|
+
try {
|
|
116
|
+
return await this.executeWithRetry(request, retries, this.config.retryDelay);
|
|
117
|
+
} catch (error) {
|
|
118
|
+
if (error instanceof FragmentHttpError) {
|
|
119
|
+
this.config.onError?.(error);
|
|
120
|
+
}
|
|
121
|
+
throw error;
|
|
122
|
+
} finally {
|
|
123
|
+
clearTimeout(timeout);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
async executeWithRetry(request, retries, retryDelay) {
|
|
127
|
+
let attempt = 0;
|
|
128
|
+
let lastError = null;
|
|
129
|
+
while (attempt <= retries) {
|
|
130
|
+
try {
|
|
131
|
+
const response = await fetch(request.clone());
|
|
132
|
+
for (const interceptor of this.responseInterceptors) {
|
|
133
|
+
await interceptor(response, { request });
|
|
134
|
+
}
|
|
135
|
+
if (!response.ok) {
|
|
136
|
+
const body = await this.parseBody(response);
|
|
137
|
+
const error = new FragmentHttpError(`HTTP ${response.status}`, {
|
|
138
|
+
status: response.status,
|
|
139
|
+
statusText: response.statusText,
|
|
140
|
+
body,
|
|
141
|
+
request,
|
|
142
|
+
response
|
|
143
|
+
});
|
|
144
|
+
if (response.status === 401) {
|
|
145
|
+
const result = this.handleAuthMode(this.config.onUnauthorized);
|
|
146
|
+
if (result === "silent") return null;
|
|
147
|
+
}
|
|
148
|
+
if (response.status === 403) {
|
|
149
|
+
const result = this.handleAuthMode(this.config.onForbidden);
|
|
150
|
+
if (result === "silent") return null;
|
|
151
|
+
}
|
|
152
|
+
for (const interceptor of this.responseInterceptors) {
|
|
153
|
+
await interceptor(response, { request, error });
|
|
154
|
+
}
|
|
155
|
+
if (response.status >= 500 && attempt < retries) {
|
|
156
|
+
await this.delay(retryDelay);
|
|
157
|
+
attempt += 1;
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
throw error;
|
|
161
|
+
}
|
|
162
|
+
return await this.parseBody(response);
|
|
163
|
+
} catch (error) {
|
|
164
|
+
if (error instanceof FragmentHttpError) {
|
|
165
|
+
throw error;
|
|
166
|
+
}
|
|
167
|
+
if (error?.name === "AbortError") {
|
|
168
|
+
const syntheticResponse2 = new Response(null, { status: 408, statusText: "Request Timeout" });
|
|
169
|
+
throw new FragmentHttpError("Request timeout", {
|
|
170
|
+
status: 408,
|
|
171
|
+
statusText: "Request Timeout",
|
|
172
|
+
body: null,
|
|
173
|
+
request,
|
|
174
|
+
response: syntheticResponse2
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
lastError = error;
|
|
178
|
+
if (attempt >= retries) {
|
|
179
|
+
const syntheticResponse2 = new Response(null, { status: 503, statusText: "Service Unavailable" });
|
|
180
|
+
throw new FragmentHttpError(error?.message || "Network error", {
|
|
181
|
+
status: 503,
|
|
182
|
+
statusText: "Service Unavailable",
|
|
183
|
+
body: null,
|
|
184
|
+
request,
|
|
185
|
+
response: syntheticResponse2
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
await this.delay(retryDelay);
|
|
189
|
+
}
|
|
190
|
+
attempt += 1;
|
|
191
|
+
}
|
|
192
|
+
const syntheticResponse = new Response(null, { status: 503, statusText: "Service Unavailable" });
|
|
193
|
+
throw new FragmentHttpError("Request failed", {
|
|
194
|
+
status: 503,
|
|
195
|
+
statusText: "Service Unavailable",
|
|
196
|
+
body: lastError,
|
|
197
|
+
request,
|
|
198
|
+
response: syntheticResponse
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
async parseBody(response) {
|
|
202
|
+
const contentType = response.headers.get("content-type") || "";
|
|
203
|
+
if (contentType.includes("application/json")) {
|
|
204
|
+
return response.json();
|
|
205
|
+
}
|
|
206
|
+
const text = await response.text();
|
|
207
|
+
return text.length ? text : null;
|
|
208
|
+
}
|
|
209
|
+
buildUrl(path, params) {
|
|
210
|
+
const normalizedBase = this.config.baseUrl.replace(/\/$/, "");
|
|
211
|
+
const normalizedPath = path.startsWith("/") ? path : `/${path}`;
|
|
212
|
+
const url = new URL(`${normalizedBase}${normalizedPath}`);
|
|
213
|
+
if (params) {
|
|
214
|
+
Object.entries(params).forEach(([key, value]) => {
|
|
215
|
+
if (Array.isArray(value)) {
|
|
216
|
+
value.forEach((v) => url.searchParams.append(key, String(v)));
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
url.searchParams.append(key, String(value));
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
return url.toString();
|
|
223
|
+
}
|
|
224
|
+
handleAuthMode(mode) {
|
|
225
|
+
if (!mode || mode === "throw") {
|
|
226
|
+
return "throw";
|
|
227
|
+
}
|
|
228
|
+
if (mode === "silent") {
|
|
229
|
+
return "silent";
|
|
230
|
+
}
|
|
231
|
+
if (mode.startsWith("redirect:")) {
|
|
232
|
+
const to = mode.slice("redirect:".length);
|
|
233
|
+
if (typeof window !== "undefined") {
|
|
234
|
+
window.location.href = to;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
return "throw";
|
|
238
|
+
}
|
|
239
|
+
async delay(ms) {
|
|
240
|
+
await new Promise((resolve) => setTimeout(resolve, ms));
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
var client = new FragmentFetchClient();
|
|
244
|
+
var FragmentFetch = {
|
|
245
|
+
configure(config) {
|
|
246
|
+
client.configure(config);
|
|
247
|
+
},
|
|
248
|
+
get(path, options) {
|
|
249
|
+
return client.get(path, options);
|
|
250
|
+
},
|
|
251
|
+
post(path, body, options) {
|
|
252
|
+
return client.post(path, body, options);
|
|
253
|
+
},
|
|
254
|
+
put(path, body, options) {
|
|
255
|
+
return client.put(path, body, options);
|
|
256
|
+
},
|
|
257
|
+
patch(path, body, options) {
|
|
258
|
+
return client.patch(path, body, options);
|
|
259
|
+
},
|
|
260
|
+
delete(path, options) {
|
|
261
|
+
return client.delete(path, options);
|
|
262
|
+
},
|
|
263
|
+
request(path, init, options) {
|
|
264
|
+
return client.request(path, init, options);
|
|
265
|
+
},
|
|
266
|
+
setToken(token) {
|
|
267
|
+
client.setToken(token);
|
|
268
|
+
},
|
|
269
|
+
clearToken() {
|
|
270
|
+
client.clearToken();
|
|
271
|
+
},
|
|
272
|
+
getToken() {
|
|
273
|
+
return client.getToken();
|
|
274
|
+
},
|
|
275
|
+
addRequestInterceptor(fn) {
|
|
276
|
+
return client.addRequestInterceptor(fn);
|
|
277
|
+
},
|
|
278
|
+
addResponseInterceptor(fn) {
|
|
279
|
+
return client.addResponseInterceptor(fn);
|
|
280
|
+
}
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
// src/web/src/core/application.tsx
|
|
284
|
+
import { StrictMode } from "react";
|
|
285
|
+
import { createRoot } from "react-dom/client";
|
|
286
|
+
|
|
287
|
+
// src/web/src/router/fragment-router.tsx
|
|
288
|
+
import { useEffect, useMemo, useState } from "react";
|
|
289
|
+
import { BrowserRouter, Navigate, Route, Routes } from "react-router-dom";
|
|
290
|
+
|
|
291
|
+
// src/web/src/core/decorators/page.ts
|
|
292
|
+
var pageRegistry = [];
|
|
293
|
+
function Page(options) {
|
|
294
|
+
return (target) => {
|
|
295
|
+
pageRegistry.push({
|
|
296
|
+
target,
|
|
297
|
+
path: options.path,
|
|
298
|
+
title: options.title,
|
|
299
|
+
layout: options.layout
|
|
300
|
+
});
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
function Layout(options) {
|
|
304
|
+
return (target) => {
|
|
305
|
+
const found = pageRegistry.find((page) => page.target === target);
|
|
306
|
+
if (found) {
|
|
307
|
+
found.layout = options.name;
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
function Guard(guardClass) {
|
|
312
|
+
return (target) => {
|
|
313
|
+
const found = pageRegistry.find((page) => page.target === target);
|
|
314
|
+
if (found) {
|
|
315
|
+
found.guard = guardClass;
|
|
316
|
+
}
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
function Param(_name) {
|
|
320
|
+
return () => void 0;
|
|
321
|
+
}
|
|
322
|
+
function Query(_name, _defaultValue) {
|
|
323
|
+
return () => void 0;
|
|
324
|
+
}
|
|
325
|
+
function RedirectIfAuthenticated(to = "/") {
|
|
326
|
+
return (target) => {
|
|
327
|
+
const found = pageRegistry.find((page) => page.target === target);
|
|
328
|
+
if (found) {
|
|
329
|
+
found.redirectIfAuthenticated = to;
|
|
330
|
+
}
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
function getPages() {
|
|
334
|
+
return [...pageRegistry];
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
// src/web/src/core/runtime.tsx
|
|
338
|
+
import React from "react";
|
|
339
|
+
function renderPageInstance(PageClass) {
|
|
340
|
+
const instance = new PageClass();
|
|
341
|
+
if (typeof instance.render === "function") {
|
|
342
|
+
return instance.render();
|
|
343
|
+
}
|
|
344
|
+
return React.createElement("div", null, PageClass.name);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
// src/web/src/router/fragment-router.tsx
|
|
348
|
+
import { jsx } from "react/jsx-runtime";
|
|
349
|
+
function prefixMatch(route, pathname) {
|
|
350
|
+
if (route === "/") return pathname === "/";
|
|
351
|
+
return pathname === route || pathname.startsWith(`${route}/`);
|
|
352
|
+
}
|
|
353
|
+
async function resolveSession(config) {
|
|
354
|
+
if (config.fetch.tokenTransport === "cookie") {
|
|
355
|
+
try {
|
|
356
|
+
await FragmentFetch.get(`${config.serverRoot}/auth/me`, { skipAuth: true });
|
|
357
|
+
return true;
|
|
358
|
+
} catch {
|
|
359
|
+
return false;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
return Boolean(FragmentFetch.getToken());
|
|
363
|
+
}
|
|
364
|
+
function routeNeedsAuth(path, config) {
|
|
365
|
+
return config.authenticatedRoutes.some((route) => prefixMatch(route, path));
|
|
366
|
+
}
|
|
367
|
+
function routeIsPublic(path, config) {
|
|
368
|
+
return config.publicRoutes.some((route) => prefixMatch(route, path));
|
|
369
|
+
}
|
|
370
|
+
function extractRedirectPath(mode, fallback = "/login") {
|
|
371
|
+
if (!mode) return fallback;
|
|
372
|
+
if (mode.startsWith("redirect:")) return mode.slice("redirect:".length);
|
|
373
|
+
return fallback;
|
|
374
|
+
}
|
|
375
|
+
function withRoot(base, pagePath) {
|
|
376
|
+
const cleanBase = base === "/" ? "" : base.replace(/\/$/, "");
|
|
377
|
+
const cleanPath = pagePath.startsWith("/") ? pagePath : `/${pagePath}`;
|
|
378
|
+
return `${cleanBase}${cleanPath}` || "/";
|
|
379
|
+
}
|
|
380
|
+
function PageRoute({ page, config }) {
|
|
381
|
+
const [checking, setChecking] = useState(true);
|
|
382
|
+
const [authenticated, setAuthenticated] = useState(false);
|
|
383
|
+
useEffect(() => {
|
|
384
|
+
let cancelled = false;
|
|
385
|
+
resolveSession(config).then((isAuthed) => {
|
|
386
|
+
if (!cancelled) {
|
|
387
|
+
setAuthenticated(isAuthed);
|
|
388
|
+
setChecking(false);
|
|
389
|
+
}
|
|
390
|
+
});
|
|
391
|
+
return () => {
|
|
392
|
+
cancelled = true;
|
|
393
|
+
};
|
|
394
|
+
}, [config]);
|
|
395
|
+
if (checking) {
|
|
396
|
+
return /* @__PURE__ */ jsx("div", { children: "Loading..." });
|
|
397
|
+
}
|
|
398
|
+
const needsAuth = routeNeedsAuth(page.path, config);
|
|
399
|
+
const isPublic = routeIsPublic(page.path, config) || !needsAuth;
|
|
400
|
+
if (needsAuth && !authenticated) {
|
|
401
|
+
return /* @__PURE__ */ jsx(Navigate, { to: extractRedirectPath(config.fetch.onUnauthorized, "/login"), replace: true });
|
|
402
|
+
}
|
|
403
|
+
if (isPublic && page.redirectIfAuthenticated && authenticated) {
|
|
404
|
+
return /* @__PURE__ */ jsx(Navigate, { to: page.redirectIfAuthenticated, replace: true });
|
|
405
|
+
}
|
|
406
|
+
if (page.guard) {
|
|
407
|
+
const guard = new page.guard();
|
|
408
|
+
if (typeof guard.canActivate === "function") {
|
|
409
|
+
const result = guard.canActivate();
|
|
410
|
+
if (result === false) {
|
|
411
|
+
return /* @__PURE__ */ jsx(Navigate, { to: extractRedirectPath(config.fetch.onForbidden, "/403"), replace: true });
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
return renderPageInstance(page.target);
|
|
416
|
+
}
|
|
417
|
+
function FragmentRouter({ config }) {
|
|
418
|
+
const pages = useMemo(() => getPages(), []);
|
|
419
|
+
return /* @__PURE__ */ jsx(BrowserRouter, { basename: config.webRoot, children: /* @__PURE__ */ jsx(Routes, { children: pages.map((page) => /* @__PURE__ */ jsx(
|
|
420
|
+
Route,
|
|
421
|
+
{
|
|
422
|
+
path: withRoot(config.webRoot, page.path).replace(config.webRoot, "") || "/",
|
|
423
|
+
element: /* @__PURE__ */ jsx(PageRoute, { page, config })
|
|
424
|
+
},
|
|
425
|
+
page.path
|
|
426
|
+
)) }) });
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
// src/web/src/config/web-config.ts
|
|
430
|
+
function defaultWebConfig() {
|
|
431
|
+
return {
|
|
432
|
+
webRoot: "/",
|
|
433
|
+
serverRoot: "/api",
|
|
434
|
+
publicRoutes: ["/", "/login", "/register"],
|
|
435
|
+
authenticatedRoutes: ["/dashboard", "/profile", "/settings"],
|
|
436
|
+
app: {
|
|
437
|
+
name: "My App",
|
|
438
|
+
rootElement: "#root",
|
|
439
|
+
strict: true,
|
|
440
|
+
router: "react-router",
|
|
441
|
+
stateAdapter: "zustand"
|
|
442
|
+
},
|
|
443
|
+
fetch: {
|
|
444
|
+
baseUrl: "http://localhost:3000",
|
|
445
|
+
timeout: 1e4,
|
|
446
|
+
retries: 2,
|
|
447
|
+
retryDelay: 300,
|
|
448
|
+
tokenTransport: "cookie",
|
|
449
|
+
tokenKey: "fragment_token",
|
|
450
|
+
onUnauthorized: "redirect:/login",
|
|
451
|
+
onForbidden: "redirect:/403"
|
|
452
|
+
},
|
|
453
|
+
structure: "layered",
|
|
454
|
+
di: {
|
|
455
|
+
autoScan: true,
|
|
456
|
+
scanPaths: ["src/components", "src/pages", "src/services"]
|
|
457
|
+
}
|
|
458
|
+
};
|
|
459
|
+
}
|
|
460
|
+
function interpolateEnv(value) {
|
|
461
|
+
const match = value.match(/^\$\{([^:}]+):([^}]+)\}$/);
|
|
462
|
+
if (!match) return value;
|
|
463
|
+
const [, envName, fallback] = match;
|
|
464
|
+
const fromEnv = typeof process !== "undefined" ? process.env?.[envName] : void 0;
|
|
465
|
+
return fromEnv || fallback;
|
|
466
|
+
}
|
|
467
|
+
async function loadWebConfig() {
|
|
468
|
+
try {
|
|
469
|
+
if (typeof fetch === "function") {
|
|
470
|
+
const response = await fetch("/fragment.web.json");
|
|
471
|
+
if (!response.ok) {
|
|
472
|
+
throw new Error("fragment.web.json not found");
|
|
473
|
+
}
|
|
474
|
+
const raw = await response.json();
|
|
475
|
+
return {
|
|
476
|
+
...defaultWebConfig(),
|
|
477
|
+
...raw,
|
|
478
|
+
fetch: {
|
|
479
|
+
...defaultWebConfig().fetch,
|
|
480
|
+
...raw.fetch,
|
|
481
|
+
baseUrl: interpolateEnv(raw.fetch?.baseUrl || defaultWebConfig().fetch.baseUrl || "")
|
|
482
|
+
}
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
throw new Error("fetch unavailable");
|
|
486
|
+
} catch {
|
|
487
|
+
return {
|
|
488
|
+
...defaultWebConfig(),
|
|
489
|
+
fetch: {
|
|
490
|
+
...defaultWebConfig().fetch,
|
|
491
|
+
baseUrl: interpolateEnv(defaultWebConfig().fetch.baseUrl || "")
|
|
492
|
+
}
|
|
493
|
+
};
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
// src/web/src/core/application.tsx
|
|
498
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
499
|
+
var appMeta = /* @__PURE__ */ new WeakMap();
|
|
500
|
+
function FragmentWebApplication(options) {
|
|
501
|
+
return (target) => {
|
|
502
|
+
appMeta.set(target, {
|
|
503
|
+
rootElement: options.rootElement,
|
|
504
|
+
strict: options.strict ?? true
|
|
505
|
+
});
|
|
506
|
+
};
|
|
507
|
+
}
|
|
508
|
+
var FragmentWebUIApplication = class {
|
|
509
|
+
async bootstrap(applicationClass) {
|
|
510
|
+
const config = await loadWebConfig();
|
|
511
|
+
const meta = appMeta.get(applicationClass) || {
|
|
512
|
+
rootElement: config.app.rootElement,
|
|
513
|
+
strict: config.app.strict
|
|
514
|
+
};
|
|
515
|
+
FragmentFetch.configure({
|
|
516
|
+
...config.fetch,
|
|
517
|
+
baseUrl: `${config.fetch.baseUrl.replace(/\/$/, "")}${config.serverRoot}`
|
|
518
|
+
});
|
|
519
|
+
const rootElement = document.querySelector(meta.rootElement);
|
|
520
|
+
if (!rootElement) {
|
|
521
|
+
throw new Error(`Root element not found: ${meta.rootElement}`);
|
|
522
|
+
}
|
|
523
|
+
const root = createRoot(rootElement);
|
|
524
|
+
const app = /* @__PURE__ */ jsx2(FragmentRouter, { config });
|
|
525
|
+
if (meta.strict) {
|
|
526
|
+
root.render(/* @__PURE__ */ jsx2(StrictMode, { children: app }));
|
|
527
|
+
return;
|
|
528
|
+
}
|
|
529
|
+
root.render(app);
|
|
530
|
+
}
|
|
531
|
+
};
|
|
532
|
+
|
|
533
|
+
// src/web/src/core/di/container.ts
|
|
534
|
+
var DIContainer = class {
|
|
535
|
+
static register(token, value) {
|
|
536
|
+
this.providers.set(token, value);
|
|
537
|
+
}
|
|
538
|
+
static resolve(token) {
|
|
539
|
+
if (!this.providers.has(token)) {
|
|
540
|
+
if (typeof token === "function") {
|
|
541
|
+
const instance = new token();
|
|
542
|
+
this.providers.set(token, instance);
|
|
543
|
+
} else {
|
|
544
|
+
throw new Error(`Provider not found for token ${String(token)}`);
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
return this.providers.get(token);
|
|
548
|
+
}
|
|
549
|
+
static clear() {
|
|
550
|
+
this.providers.clear();
|
|
551
|
+
}
|
|
552
|
+
};
|
|
553
|
+
DIContainer.providers = /* @__PURE__ */ new Map();
|
|
554
|
+
|
|
555
|
+
// src/web/src/core/decorators/component.ts
|
|
556
|
+
var componentMeta = /* @__PURE__ */ new Map();
|
|
557
|
+
function Component(options = {}) {
|
|
558
|
+
return (target) => {
|
|
559
|
+
componentMeta.set(target, options);
|
|
560
|
+
};
|
|
561
|
+
}
|
|
562
|
+
function State(initial) {
|
|
563
|
+
return (target, propertyKey) => {
|
|
564
|
+
Reflect.defineMetadata(`fragment:state:${String(propertyKey)}`, initial, target);
|
|
565
|
+
};
|
|
566
|
+
}
|
|
567
|
+
function Computed(deps) {
|
|
568
|
+
return (target, propertyKey) => {
|
|
569
|
+
Reflect.defineMetadata(`fragment:computed:${String(propertyKey)}`, deps || [], target);
|
|
570
|
+
};
|
|
571
|
+
}
|
|
572
|
+
function Effect(options) {
|
|
573
|
+
return (target, propertyKey) => {
|
|
574
|
+
Reflect.defineMetadata(`fragment:effect:${String(propertyKey)}`, options, target);
|
|
575
|
+
};
|
|
576
|
+
}
|
|
577
|
+
function Watch(key) {
|
|
578
|
+
return (target, propertyKey) => {
|
|
579
|
+
Reflect.defineMetadata(`fragment:watch:${String(propertyKey)}`, key, target);
|
|
580
|
+
};
|
|
581
|
+
}
|
|
582
|
+
function Store(store, selector) {
|
|
583
|
+
return (target, propertyKey) => {
|
|
584
|
+
Reflect.defineMetadata(`fragment:store:${String(propertyKey)}`, { store, selector }, target);
|
|
585
|
+
};
|
|
586
|
+
}
|
|
587
|
+
function Prop(defaultValue) {
|
|
588
|
+
return (target, propertyKey) => {
|
|
589
|
+
Reflect.defineMetadata(`fragment:prop:${String(propertyKey)}`, defaultValue, target);
|
|
590
|
+
};
|
|
591
|
+
}
|
|
592
|
+
function Ref() {
|
|
593
|
+
return (target, propertyKey) => {
|
|
594
|
+
Reflect.defineMetadata(`fragment:ref:${String(propertyKey)}`, true, target);
|
|
595
|
+
};
|
|
596
|
+
}
|
|
597
|
+
function Inject(token) {
|
|
598
|
+
return (target, propertyKey) => {
|
|
599
|
+
Reflect.defineMetadata(`fragment:inject:${String(propertyKey)}`, token, target);
|
|
600
|
+
const key = propertyKey;
|
|
601
|
+
Object.defineProperty(target, key, {
|
|
602
|
+
configurable: true,
|
|
603
|
+
enumerable: true,
|
|
604
|
+
get() {
|
|
605
|
+
return DIContainer.resolve(token);
|
|
606
|
+
}
|
|
607
|
+
});
|
|
608
|
+
};
|
|
609
|
+
}
|
|
610
|
+
function FragmentService() {
|
|
611
|
+
return (target) => {
|
|
612
|
+
DIContainer.register(target, new target());
|
|
613
|
+
};
|
|
614
|
+
}
|
|
615
|
+
function Injectable(_scope = "singleton") {
|
|
616
|
+
return (target) => {
|
|
617
|
+
DIContainer.register(target, new target());
|
|
618
|
+
};
|
|
619
|
+
}
|
|
620
|
+
export {
|
|
621
|
+
Component,
|
|
622
|
+
Computed,
|
|
623
|
+
DIContainer,
|
|
624
|
+
Effect,
|
|
625
|
+
FragmentFetch,
|
|
626
|
+
FragmentHttpError,
|
|
627
|
+
FragmentService,
|
|
628
|
+
FragmentWebApplication,
|
|
629
|
+
FragmentWebUIApplication,
|
|
630
|
+
Guard,
|
|
631
|
+
Inject,
|
|
632
|
+
Injectable,
|
|
633
|
+
Layout,
|
|
634
|
+
Page,
|
|
635
|
+
Param,
|
|
636
|
+
Prop,
|
|
637
|
+
Query,
|
|
638
|
+
RedirectIfAuthenticated,
|
|
639
|
+
Ref,
|
|
640
|
+
State,
|
|
641
|
+
Store,
|
|
642
|
+
Watch
|
|
643
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { FragmentWebConfig } from "../config/web-config";
|
|
2
|
+
declare function prefixMatch(route: string, pathname: string): boolean;
|
|
3
|
+
declare function routeNeedsAuth(path: string, config: FragmentWebConfig): boolean;
|
|
4
|
+
declare function routeIsPublic(path: string, config: FragmentWebConfig): boolean;
|
|
5
|
+
export declare function FragmentRouter({ config }: {
|
|
6
|
+
config: FragmentWebConfig;
|
|
7
|
+
}): JSX.Element;
|
|
8
|
+
export declare const RouterInternals: {
|
|
9
|
+
prefixMatch: typeof prefixMatch;
|
|
10
|
+
routeNeedsAuth: typeof routeNeedsAuth;
|
|
11
|
+
routeIsPublic: typeof routeIsPublic;
|
|
12
|
+
};
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=fragment-router.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fragment-router.d.ts","sourceRoot":"","sources":["../../../../src/web/src/router/fragment-router.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAG9D,iBAAS,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAG7D;AAcD,iBAAS,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAExE;AAED,iBAAS,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAEvE;AA+DD,wBAAgB,cAAc,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE,iBAAiB,CAAA;CAAE,GAAG,GAAG,CAAC,OAAO,CAgBrF;AAED,eAAO,MAAM,eAAe;;;;CAI3B,CAAC"}
|