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