@kithinji/orca 1.0.0
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/browser/index.iife.js +2093 -0
- package/dist/browser/index.iife.js.map +7 -0
- package/dist/browser/index.mjs +3250 -0
- package/dist/browser/index.mjs.map +7 -0
- package/dist/node/index.cjs +2135 -0
- package/dist/node/index.cjs.map +7 -0
- package/dist/node/index.mjs +2028 -0
- package/dist/node/index.mjs.map +7 -0
- package/dist/types/browser/dom/dom.d.ts +6 -0
- package/dist/types/browser/dom/dom.d.ts.map +1 -0
- package/dist/types/browser/dom/index.d.ts +2 -0
- package/dist/types/browser/dom/index.d.ts.map +1 -0
- package/dist/types/browser/factory.d.ts +5 -0
- package/dist/types/browser/factory.d.ts.map +1 -0
- package/dist/types/browser/index.d.ts +3 -0
- package/dist/types/browser/index.d.ts.map +1 -0
- package/dist/types/index.browser.d.ts +20 -0
- package/dist/types/index.browser.d.ts.map +1 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.node.d.ts +20 -0
- package/dist/types/index.node.d.ts.map +1 -0
- package/dist/types/node/factory.d.ts +6 -0
- package/dist/types/node/factory.d.ts.map +1 -0
- package/dist/types/node/index.d.ts +3 -0
- package/dist/types/node/index.d.ts.map +1 -0
- package/dist/types/node/modules/index.d.ts +2 -0
- package/dist/types/node/modules/index.d.ts.map +1 -0
- package/dist/types/node/modules/serve_static/index.d.ts +2 -0
- package/dist/types/node/modules/serve_static/index.d.ts.map +1 -0
- package/dist/types/node/modules/serve_static/serve.d.ts +9 -0
- package/dist/types/node/modules/serve_static/serve.d.ts.map +1 -0
- package/dist/types/shared/component.d.ts +11 -0
- package/dist/types/shared/component.d.ts.map +1 -0
- package/dist/types/shared/decorators.d.ts +18 -0
- package/dist/types/shared/decorators.d.ts.map +1 -0
- package/dist/types/shared/dom/index.d.ts +2 -0
- package/dist/types/shared/dom/index.d.ts.map +1 -0
- package/dist/types/shared/dom/osc.d.ts +23 -0
- package/dist/types/shared/dom/osc.d.ts.map +1 -0
- package/dist/types/shared/index.d.ts +15 -0
- package/dist/types/shared/index.d.ts.map +1 -0
- package/dist/types/shared/json.d.ts +3 -0
- package/dist/types/shared/json.d.ts.map +1 -0
- package/dist/types/shared/jsx/index.d.ts +4 -0
- package/dist/types/shared/jsx/index.d.ts.map +1 -0
- package/dist/types/shared/jsx/jsx-dev-runtime.d.ts +2 -0
- package/dist/types/shared/jsx/jsx-dev-runtime.d.ts.map +1 -0
- package/dist/types/shared/jsx/jsx-runtime.d.ts +9 -0
- package/dist/types/shared/jsx/jsx-runtime.d.ts.map +1 -0
- package/dist/types/shared/jsx/types.d.ts +193 -0
- package/dist/types/shared/jsx/types.d.ts.map +1 -0
- package/dist/types/shared/macros/index.d.ts +2 -0
- package/dist/types/shared/macros/index.d.ts.map +1 -0
- package/dist/types/shared/module/compiler.d.ts +24 -0
- package/dist/types/shared/module/compiler.d.ts.map +1 -0
- package/dist/types/shared/module/context.d.ts +4 -0
- package/dist/types/shared/module/context.d.ts.map +1 -0
- package/dist/types/shared/module/index.d.ts +5 -0
- package/dist/types/shared/module/index.d.ts.map +1 -0
- package/dist/types/shared/module/injector.d.ts +14 -0
- package/dist/types/shared/module/injector.d.ts.map +1 -0
- package/dist/types/shared/module/node.d.ts +22 -0
- package/dist/types/shared/module/node.d.ts.map +1 -0
- package/dist/types/shared/module_libs/http_client/index.d.ts +2 -0
- package/dist/types/shared/module_libs/http_client/index.d.ts.map +1 -0
- package/dist/types/shared/module_libs/http_client/module.d.ts +22 -0
- package/dist/types/shared/module_libs/http_client/module.d.ts.map +1 -0
- package/dist/types/shared/module_libs/index.d.ts +3 -0
- package/dist/types/shared/module_libs/index.d.ts.map +1 -0
- package/dist/types/shared/module_libs/router_module/index.d.ts +4 -0
- package/dist/types/shared/module_libs/router_module/index.d.ts.map +1 -0
- package/dist/types/shared/module_libs/router_module/module.d.ts +5 -0
- package/dist/types/shared/module_libs/router_module/module.d.ts.map +1 -0
- package/dist/types/shared/module_libs/router_module/navigate.d.ts +17 -0
- package/dist/types/shared/module_libs/router_module/navigate.d.ts.map +1 -0
- package/dist/types/shared/module_libs/router_module/outlet.d.ts +7 -0
- package/dist/types/shared/module_libs/router_module/outlet.d.ts.map +1 -0
- package/dist/types/shared/observable/index.d.ts +2 -0
- package/dist/types/shared/observable/index.d.ts.map +1 -0
- package/dist/types/shared/observable/observable.d.ts +31 -0
- package/dist/types/shared/observable/observable.d.ts.map +1 -0
- package/dist/types/shared/renderers/index.d.ts +4 -0
- package/dist/types/shared/renderers/index.d.ts.map +1 -0
- package/dist/types/shared/renderers/stream.d.ts +25 -0
- package/dist/types/shared/renderers/stream.d.ts.map +1 -0
- package/dist/types/shared/renderers/string.d.ts +9 -0
- package/dist/types/shared/renderers/string.d.ts.map +1 -0
- package/dist/types/shared/renderers/vnode.d.ts +15 -0
- package/dist/types/shared/renderers/vnode.d.ts.map +1 -0
- package/dist/types/shared/signal/index.d.ts +2 -0
- package/dist/types/shared/signal/index.d.ts.map +1 -0
- package/dist/types/shared/signal/signal.d.ts +6 -0
- package/dist/types/shared/signal/signal.d.ts.map +1 -0
- package/dist/types/shared/store.d.ts +9 -0
- package/dist/types/shared/store.d.ts.map +1 -0
- package/dist/types/shared/symbols.d.ts +27 -0
- package/dist/types/shared/symbols.d.ts.map +1 -0
- package/dist/types/shared/types.d.ts +67 -0
- package/dist/types/shared/types.d.ts.map +1 -0
- package/package.json +49 -0
|
@@ -0,0 +1,2093 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var kithinjiorca = (() => {
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
8
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
9
|
+
}) : x)(function(x) {
|
|
10
|
+
if (typeof require !== "undefined")
|
|
11
|
+
return require.apply(this, arguments);
|
|
12
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
13
|
+
});
|
|
14
|
+
var __export = (target, all) => {
|
|
15
|
+
for (var name in all)
|
|
16
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from2, except, desc) => {
|
|
19
|
+
if (from2 && typeof from2 === "object" || typeof from2 === "function") {
|
|
20
|
+
for (let key of __getOwnPropNames(from2))
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
+
__defProp(to, key, { get: () => from2[key], enumerable: !(desc = __getOwnPropDesc(from2, key)) || desc.enumerable });
|
|
23
|
+
}
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
+
|
|
28
|
+
// src/index.browser.ts
|
|
29
|
+
var index_browser_exports = {};
|
|
30
|
+
__export(index_browser_exports, {
|
|
31
|
+
BOOTSTRAP: () => BOOTSTRAP,
|
|
32
|
+
BOOTSTRAP_VNODE: () => BOOTSTRAP_VNODE,
|
|
33
|
+
Body: () => Body,
|
|
34
|
+
BrowserFactory: () => BrowserFactory,
|
|
35
|
+
COMPONENT: () => COMPONENT,
|
|
36
|
+
COMPONENT_DEPS: () => COMPONENT_DEPS,
|
|
37
|
+
COMPONENT_PROVIDERS: () => COMPONENT_PROVIDERS,
|
|
38
|
+
CONTROLLER: () => CONTROLLER,
|
|
39
|
+
CONTROLLERS_KEY: () => CONTROLLERS_KEY,
|
|
40
|
+
CONTROLLER_PREFIX_KEY: () => CONTROLLER_PREFIX_KEY,
|
|
41
|
+
Compiler: () => Compiler,
|
|
42
|
+
Component: () => Component,
|
|
43
|
+
Controller: () => Controller,
|
|
44
|
+
DECLARATIONS_KEY: () => DECLARATIONS_KEY,
|
|
45
|
+
DESIGN_PARAMTYPES: () => DESIGN_PARAMTYPES,
|
|
46
|
+
ERROR_ELEMENT: () => ERROR_ELEMENT,
|
|
47
|
+
EXPORTS_KEY: () => EXPORTS_KEY,
|
|
48
|
+
EXPRESS_ADAPTER_HOST: () => EXPRESS_ADAPTER_HOST,
|
|
49
|
+
Fragment: () => Fragment,
|
|
50
|
+
Get: () => Get,
|
|
51
|
+
HTTP_METHOD_KEY: () => HTTP_METHOD_KEY,
|
|
52
|
+
HandlerParamType: () => HandlerParamType,
|
|
53
|
+
HttpClient: () => HttpClient,
|
|
54
|
+
HttpClientModule: () => HttpClientModule,
|
|
55
|
+
HttpMethod: () => HttpMethod,
|
|
56
|
+
IMPORTS_KEY: () => IMPORTS_KEY,
|
|
57
|
+
INJECTABLE: () => INJECTABLE,
|
|
58
|
+
INJECT_TOKENS_KEY: () => INJECT_TOKENS_KEY,
|
|
59
|
+
Inject: () => Inject,
|
|
60
|
+
Injectable: () => Injectable,
|
|
61
|
+
Injector: () => Injector,
|
|
62
|
+
Module: () => Module,
|
|
63
|
+
NODE: () => NODE,
|
|
64
|
+
Navigate: () => Navigate,
|
|
65
|
+
Node: () => Node2,
|
|
66
|
+
ORCA_CLIENT_COMPONENT: () => ORCA_CLIENT_COMPONENT,
|
|
67
|
+
ORCA_ELEMENT_TYPE: () => ORCA_ELEMENT_TYPE,
|
|
68
|
+
ORCA_FRAGMENT_TYPE: () => ORCA_FRAGMENT_TYPE,
|
|
69
|
+
OSC: () => OSC,
|
|
70
|
+
Observable: () => Observable,
|
|
71
|
+
OrcaComponent: () => OrcaComponent,
|
|
72
|
+
PARAMS_META_KEY: () => PARAMS_META_KEY,
|
|
73
|
+
PATH_KEY: () => PATH_KEY,
|
|
74
|
+
PENDING_REFERENCE_TYPE: () => PENDING_REFERENCE_TYPE,
|
|
75
|
+
PROVIDERS_KEY: () => PROVIDERS_KEY,
|
|
76
|
+
Param: () => Param,
|
|
77
|
+
Post: () => Post,
|
|
78
|
+
ProviderNormalizer: () => ProviderNormalizer,
|
|
79
|
+
RouterModule: () => RouterModule,
|
|
80
|
+
RouterOutlet: () => RouterOutlet,
|
|
81
|
+
SIGNATURE_METADATA_KEY: () => SIGNATURE_METADATA_KEY,
|
|
82
|
+
Signature: () => Signature,
|
|
83
|
+
assert$: () => assert$,
|
|
84
|
+
browser: () => browser_exports,
|
|
85
|
+
collectAllProvidersFromNode: () => collectAllProvidersFromNode,
|
|
86
|
+
computed: () => computed,
|
|
87
|
+
createComponent: () => createComponent,
|
|
88
|
+
effect: () => effect,
|
|
89
|
+
from: () => from,
|
|
90
|
+
getCurrentInjector: () => getCurrentInjector,
|
|
91
|
+
getSignatureMetadata: () => getSignatureMetadata,
|
|
92
|
+
hasSignature: () => hasSignature,
|
|
93
|
+
insert: () => insert,
|
|
94
|
+
interval: () => interval,
|
|
95
|
+
isClassComponent: () => isClassComponent,
|
|
96
|
+
isFragment: () => isFragment,
|
|
97
|
+
isIntrinsicElement: () => isIntrinsicElement,
|
|
98
|
+
isObservable: () => isObservable,
|
|
99
|
+
isSignal: () => isSignal,
|
|
100
|
+
jsx: () => jsx,
|
|
101
|
+
jsxs: () => jsxs,
|
|
102
|
+
observable: () => observable,
|
|
103
|
+
of: () => of,
|
|
104
|
+
parseSignatureSchemas: () => parseSignatureSchemas,
|
|
105
|
+
setCurrentInjector: () => setCurrentInjector,
|
|
106
|
+
shared: () => shared_exports,
|
|
107
|
+
signal: () => signal,
|
|
108
|
+
spread: () => spread,
|
|
109
|
+
style: () => style,
|
|
110
|
+
symbolValueReplacer: () => symbolValueReplacer,
|
|
111
|
+
symbolValueReviver: () => symbolValueReviver,
|
|
112
|
+
toSignal: () => toSignal
|
|
113
|
+
});
|
|
114
|
+
var import_reflect_metadata = __require("reflect-metadata");
|
|
115
|
+
|
|
116
|
+
// src/shared/index.ts
|
|
117
|
+
var shared_exports = {};
|
|
118
|
+
__export(shared_exports, {
|
|
119
|
+
BOOTSTRAP: () => BOOTSTRAP,
|
|
120
|
+
BOOTSTRAP_VNODE: () => BOOTSTRAP_VNODE,
|
|
121
|
+
Body: () => Body,
|
|
122
|
+
COMPONENT: () => COMPONENT,
|
|
123
|
+
COMPONENT_DEPS: () => COMPONENT_DEPS,
|
|
124
|
+
COMPONENT_PROVIDERS: () => COMPONENT_PROVIDERS,
|
|
125
|
+
CONTROLLER: () => CONTROLLER,
|
|
126
|
+
CONTROLLERS_KEY: () => CONTROLLERS_KEY,
|
|
127
|
+
CONTROLLER_PREFIX_KEY: () => CONTROLLER_PREFIX_KEY,
|
|
128
|
+
Compiler: () => Compiler,
|
|
129
|
+
Component: () => Component,
|
|
130
|
+
Controller: () => Controller,
|
|
131
|
+
DECLARATIONS_KEY: () => DECLARATIONS_KEY,
|
|
132
|
+
DESIGN_PARAMTYPES: () => DESIGN_PARAMTYPES,
|
|
133
|
+
ERROR_ELEMENT: () => ERROR_ELEMENT,
|
|
134
|
+
EXPORTS_KEY: () => EXPORTS_KEY,
|
|
135
|
+
EXPRESS_ADAPTER_HOST: () => EXPRESS_ADAPTER_HOST,
|
|
136
|
+
Fragment: () => Fragment,
|
|
137
|
+
Get: () => Get,
|
|
138
|
+
HTTP_METHOD_KEY: () => HTTP_METHOD_KEY,
|
|
139
|
+
HandlerParamType: () => HandlerParamType,
|
|
140
|
+
HttpClient: () => HttpClient,
|
|
141
|
+
HttpClientModule: () => HttpClientModule,
|
|
142
|
+
HttpMethod: () => HttpMethod,
|
|
143
|
+
IMPORTS_KEY: () => IMPORTS_KEY,
|
|
144
|
+
INJECTABLE: () => INJECTABLE,
|
|
145
|
+
INJECT_TOKENS_KEY: () => INJECT_TOKENS_KEY,
|
|
146
|
+
Inject: () => Inject,
|
|
147
|
+
Injectable: () => Injectable,
|
|
148
|
+
Injector: () => Injector,
|
|
149
|
+
Module: () => Module,
|
|
150
|
+
NODE: () => NODE,
|
|
151
|
+
Navigate: () => Navigate,
|
|
152
|
+
Node: () => Node2,
|
|
153
|
+
ORCA_CLIENT_COMPONENT: () => ORCA_CLIENT_COMPONENT,
|
|
154
|
+
ORCA_ELEMENT_TYPE: () => ORCA_ELEMENT_TYPE,
|
|
155
|
+
ORCA_FRAGMENT_TYPE: () => ORCA_FRAGMENT_TYPE,
|
|
156
|
+
OSC: () => OSC,
|
|
157
|
+
Observable: () => Observable,
|
|
158
|
+
OrcaComponent: () => OrcaComponent,
|
|
159
|
+
PARAMS_META_KEY: () => PARAMS_META_KEY,
|
|
160
|
+
PATH_KEY: () => PATH_KEY,
|
|
161
|
+
PENDING_REFERENCE_TYPE: () => PENDING_REFERENCE_TYPE,
|
|
162
|
+
PROVIDERS_KEY: () => PROVIDERS_KEY,
|
|
163
|
+
Param: () => Param,
|
|
164
|
+
Post: () => Post,
|
|
165
|
+
ProviderNormalizer: () => ProviderNormalizer,
|
|
166
|
+
RouterModule: () => RouterModule,
|
|
167
|
+
RouterOutlet: () => RouterOutlet,
|
|
168
|
+
SIGNATURE_METADATA_KEY: () => SIGNATURE_METADATA_KEY,
|
|
169
|
+
Signature: () => Signature,
|
|
170
|
+
StreamRenderer: () => StreamRenderer,
|
|
171
|
+
StringRenderer: () => StringRenderer,
|
|
172
|
+
VNode: () => VNode,
|
|
173
|
+
assert$: () => assert$,
|
|
174
|
+
collectAllProvidersFromNode: () => collectAllProvidersFromNode,
|
|
175
|
+
computed: () => computed,
|
|
176
|
+
effect: () => effect,
|
|
177
|
+
from: () => from,
|
|
178
|
+
getCurrentInjector: () => getCurrentInjector,
|
|
179
|
+
getSignatureMetadata: () => getSignatureMetadata,
|
|
180
|
+
hasSignature: () => hasSignature,
|
|
181
|
+
interval: () => interval,
|
|
182
|
+
isClassComponent: () => isClassComponent,
|
|
183
|
+
isFragment: () => isFragment,
|
|
184
|
+
isIntrinsicElement: () => isIntrinsicElement,
|
|
185
|
+
isObservable: () => isObservable,
|
|
186
|
+
isSignal: () => isSignal,
|
|
187
|
+
jsx: () => jsx,
|
|
188
|
+
jsxs: () => jsxs,
|
|
189
|
+
observable: () => observable,
|
|
190
|
+
of: () => of,
|
|
191
|
+
parseSignatureSchemas: () => parseSignatureSchemas,
|
|
192
|
+
setCurrentInjector: () => setCurrentInjector,
|
|
193
|
+
signal: () => signal,
|
|
194
|
+
store: () => store,
|
|
195
|
+
symbolValueReplacer: () => symbolValueReplacer,
|
|
196
|
+
symbolValueReviver: () => symbolValueReviver,
|
|
197
|
+
toSignal: () => toSignal
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
// src/shared/store.ts
|
|
201
|
+
var Store = class {
|
|
202
|
+
constructor() {
|
|
203
|
+
this.namespace = /* @__PURE__ */ new Map();
|
|
204
|
+
}
|
|
205
|
+
set(name, value) {
|
|
206
|
+
this.namespace.set(name, value);
|
|
207
|
+
}
|
|
208
|
+
get(name) {
|
|
209
|
+
return this.namespace.get(name);
|
|
210
|
+
}
|
|
211
|
+
update(name, updater) {
|
|
212
|
+
const current = this.get(name);
|
|
213
|
+
const next = updater(current);
|
|
214
|
+
this.set(name, next);
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
var store = new Store();
|
|
218
|
+
|
|
219
|
+
// src/shared/symbols.ts
|
|
220
|
+
var DECLARATIONS_KEY = Symbol("orca:declarations");
|
|
221
|
+
var PROVIDERS_KEY = Symbol("orca:providers");
|
|
222
|
+
var CONTROLLERS_KEY = Symbol("orca:controllers");
|
|
223
|
+
var BOOTSTRAP = Symbol("orca:bootstrap");
|
|
224
|
+
var BOOTSTRAP_VNODE = Symbol("orca:bootstrap:vnode");
|
|
225
|
+
var IMPORTS_KEY = Symbol("orca:imports");
|
|
226
|
+
var EXPORTS_KEY = Symbol("orca:exports");
|
|
227
|
+
var INJECTABLE = Symbol("orca:injectable");
|
|
228
|
+
var COMPONENT = Symbol("orca:component");
|
|
229
|
+
var COMPONENT_PROVIDERS = Symbol("orca:component:providers");
|
|
230
|
+
var COMPONENT_DEPS = Symbol("orca:component:deps");
|
|
231
|
+
var INJECT_TOKENS_KEY = Symbol("orca:injectTokens");
|
|
232
|
+
var NODE = Symbol("orca:node");
|
|
233
|
+
var DESIGN_PARAMTYPES = "design:paramtypes";
|
|
234
|
+
var CONTROLLER = Symbol("orca:controller");
|
|
235
|
+
var CONTROLLER_PREFIX_KEY = Symbol("orca:controllerPrefix");
|
|
236
|
+
var PARAMS_META_KEY = Symbol("orca:paramsMeta");
|
|
237
|
+
var HTTP_METHOD_KEY = Symbol("orca:method");
|
|
238
|
+
var PATH_KEY = Symbol("orca:path");
|
|
239
|
+
var EXPRESS_ADAPTER_HOST = Symbol("orca:express");
|
|
240
|
+
var SIGNATURE_METADATA_KEY = Symbol("orca:signature:schemas");
|
|
241
|
+
var ERROR_ELEMENT = Symbol.for("orca:error");
|
|
242
|
+
var ORCA_ELEMENT_TYPE = Symbol.for("orca:element");
|
|
243
|
+
var ORCA_FRAGMENT_TYPE = Symbol.for("orca:fragment");
|
|
244
|
+
var ORCA_CLIENT_COMPONENT = Symbol.for("orca.client.component");
|
|
245
|
+
var PENDING_REFERENCE_TYPE = Symbol.for("orca:pending_reference");
|
|
246
|
+
|
|
247
|
+
// src/shared/types.ts
|
|
248
|
+
var HandlerParamType = /* @__PURE__ */ ((HandlerParamType2) => {
|
|
249
|
+
HandlerParamType2["ROUTE_PARAM"] = "ROUTE_PARAM";
|
|
250
|
+
HandlerParamType2["BODY"] = "BODY";
|
|
251
|
+
return HandlerParamType2;
|
|
252
|
+
})(HandlerParamType || {});
|
|
253
|
+
var HttpMethod = /* @__PURE__ */ ((HttpMethod2) => {
|
|
254
|
+
HttpMethod2["GET"] = "get";
|
|
255
|
+
HttpMethod2["POST"] = "post";
|
|
256
|
+
return HttpMethod2;
|
|
257
|
+
})(HttpMethod || {});
|
|
258
|
+
|
|
259
|
+
// src/shared/decorators.ts
|
|
260
|
+
function Module(params = {}) {
|
|
261
|
+
return function(target) {
|
|
262
|
+
Reflect.defineMetadata(PROVIDERS_KEY, params.providers || [], target);
|
|
263
|
+
Reflect.defineMetadata(DECLARATIONS_KEY, params.declarations || [], target);
|
|
264
|
+
Reflect.defineMetadata(IMPORTS_KEY, params.imports || [], target);
|
|
265
|
+
Reflect.defineMetadata(EXPORTS_KEY, params.exports || [], target);
|
|
266
|
+
Reflect.defineMetadata(CONTROLLERS_KEY, params.controllers || [], target);
|
|
267
|
+
Reflect.defineMetadata(BOOTSTRAP, params.bootstrap || [], target);
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
function Injectable() {
|
|
271
|
+
return function(target) {
|
|
272
|
+
Reflect.defineMetadata(INJECTABLE, true, target);
|
|
273
|
+
return target;
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
function Component(params = {}) {
|
|
277
|
+
return function(target) {
|
|
278
|
+
store.update("components", (current) => {
|
|
279
|
+
const next = current ?? /* @__PURE__ */ new Map();
|
|
280
|
+
next.set(target.name, target);
|
|
281
|
+
return next;
|
|
282
|
+
});
|
|
283
|
+
Reflect.defineMetadata(COMPONENT, true, target);
|
|
284
|
+
Reflect.defineMetadata(COMPONENT_PROVIDERS, params.providers || [], target);
|
|
285
|
+
Reflect.defineMetadata(COMPONENT_DEPS, params.deps || [], target);
|
|
286
|
+
return target;
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
function Inject(token, params = {}) {
|
|
290
|
+
return function(target, _propertyKey, parameterIndex) {
|
|
291
|
+
const existingTokens = Reflect.getOwnMetadata(INJECT_TOKENS_KEY, target) || /* @__PURE__ */ new Map();
|
|
292
|
+
existingTokens.set(parameterIndex, {
|
|
293
|
+
token,
|
|
294
|
+
...params
|
|
295
|
+
});
|
|
296
|
+
Reflect.defineMetadata(INJECT_TOKENS_KEY, existingTokens, target);
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
function Controller(prefix, options = {}) {
|
|
300
|
+
return function(target) {
|
|
301
|
+
Injectable()(target);
|
|
302
|
+
if (options.providedIn == "root") {
|
|
303
|
+
store.update("root_controllers", (current) => {
|
|
304
|
+
const next = current ?? /* @__PURE__ */ new Set();
|
|
305
|
+
next.add(target);
|
|
306
|
+
return next;
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
Reflect.defineMetadata(CONTROLLER_PREFIX_KEY, prefix ?? "/", target);
|
|
310
|
+
Reflect.defineMetadata(CONTROLLER, true, target);
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
function getHandlerParamDecorator(type, key) {
|
|
314
|
+
return function(target, methodName, index) {
|
|
315
|
+
const paramsMeta = Reflect.getMetadata(PARAMS_META_KEY, target, methodName) ?? {};
|
|
316
|
+
paramsMeta[index] = { key, type };
|
|
317
|
+
Reflect.defineMetadata(PARAMS_META_KEY, paramsMeta, target, methodName);
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
function Param(key) {
|
|
321
|
+
return getHandlerParamDecorator("ROUTE_PARAM" /* ROUTE_PARAM */, key);
|
|
322
|
+
}
|
|
323
|
+
function Body(key) {
|
|
324
|
+
return getHandlerParamDecorator("BODY" /* BODY */, key);
|
|
325
|
+
}
|
|
326
|
+
function getRouteDecorator(httpMethod, path) {
|
|
327
|
+
return function(target, key, descriptor) {
|
|
328
|
+
Reflect.defineMetadata(HTTP_METHOD_KEY, httpMethod, target, key);
|
|
329
|
+
Reflect.defineMetadata(PATH_KEY, path, target, key);
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
function Get(path) {
|
|
333
|
+
return getRouteDecorator("get" /* GET */, path ?? "");
|
|
334
|
+
}
|
|
335
|
+
function Post(path) {
|
|
336
|
+
return getRouteDecorator("post" /* POST */, path ?? "");
|
|
337
|
+
}
|
|
338
|
+
function Signature(...schemas) {
|
|
339
|
+
return function(target, propertyKey, descriptor) {
|
|
340
|
+
Reflect.defineMetadata(SIGNATURE_METADATA_KEY, schemas, target, propertyKey);
|
|
341
|
+
const originalMethod = descriptor.value;
|
|
342
|
+
descriptor.value = async function(...args) {
|
|
343
|
+
return originalMethod.apply(this, args);
|
|
344
|
+
};
|
|
345
|
+
return descriptor;
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
function getSignatureMetadata(target, propertyKey) {
|
|
349
|
+
return Reflect.getMetadata(SIGNATURE_METADATA_KEY, target, propertyKey);
|
|
350
|
+
}
|
|
351
|
+
function hasSignature(target, propertyKey) {
|
|
352
|
+
return Reflect.hasMetadata(SIGNATURE_METADATA_KEY, target, propertyKey);
|
|
353
|
+
}
|
|
354
|
+
function parseSignatureSchemas(schemas, paramCount) {
|
|
355
|
+
if (schemas.length === 0) {
|
|
356
|
+
return { paramSchemas: [] };
|
|
357
|
+
}
|
|
358
|
+
if (schemas.length === 1) {
|
|
359
|
+
return {
|
|
360
|
+
paramSchemas: [],
|
|
361
|
+
returnSchema: schemas[0]
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
const paramSchemas = schemas.slice(0, -1);
|
|
365
|
+
const returnSchema = schemas[schemas.length - 1];
|
|
366
|
+
if (paramSchemas.length !== paramCount) {
|
|
367
|
+
throw new Error(`@Signature decorator has ${paramSchemas.length} parameter schemas but method has ${paramCount} parameters. They must match.`);
|
|
368
|
+
}
|
|
369
|
+
return { paramSchemas, returnSchema };
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
// src/shared/module/node.ts
|
|
373
|
+
var ProviderNormalizer = class {
|
|
374
|
+
static normalize(provider) {
|
|
375
|
+
if (typeof provider === "function") {
|
|
376
|
+
return { provide: provider, useClass: provider, scope: "singleton" };
|
|
377
|
+
}
|
|
378
|
+
return { scope: "singleton", ...provider };
|
|
379
|
+
}
|
|
380
|
+
};
|
|
381
|
+
var Node2 = class {
|
|
382
|
+
constructor(name) {
|
|
383
|
+
this.name = name;
|
|
384
|
+
this.children = [];
|
|
385
|
+
this.tokens = /* @__PURE__ */ new Map();
|
|
386
|
+
this.exports = /* @__PURE__ */ new Set();
|
|
387
|
+
this.providers = /* @__PURE__ */ new Map();
|
|
388
|
+
}
|
|
389
|
+
traverse(cb) {
|
|
390
|
+
cb(this);
|
|
391
|
+
this.children.forEach((child) => child.traverse(cb));
|
|
392
|
+
}
|
|
393
|
+
addProviders(providers) {
|
|
394
|
+
providers.forEach((p) => {
|
|
395
|
+
const normalized = ProviderNormalizer.normalize(p);
|
|
396
|
+
this.providers.set(normalized.provide, normalized);
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
getProviders() {
|
|
400
|
+
return this.providers;
|
|
401
|
+
}
|
|
402
|
+
setChildren(children) {
|
|
403
|
+
this.children = children;
|
|
404
|
+
}
|
|
405
|
+
addToken(token, dependencies) {
|
|
406
|
+
this.tokens.set(token, dependencies);
|
|
407
|
+
}
|
|
408
|
+
addExport(token) {
|
|
409
|
+
this.exports.add(token);
|
|
410
|
+
}
|
|
411
|
+
getTokens() {
|
|
412
|
+
return this.tokens;
|
|
413
|
+
}
|
|
414
|
+
getExports() {
|
|
415
|
+
return this.exports;
|
|
416
|
+
}
|
|
417
|
+
getChildren() {
|
|
418
|
+
return this.children;
|
|
419
|
+
}
|
|
420
|
+
};
|
|
421
|
+
|
|
422
|
+
// src/shared/module/compiler.ts
|
|
423
|
+
var Compiler = class {
|
|
424
|
+
constructor() {
|
|
425
|
+
this.nodes = /* @__PURE__ */ new Map();
|
|
426
|
+
}
|
|
427
|
+
compile(rootModule) {
|
|
428
|
+
return this.createNode(rootModule);
|
|
429
|
+
}
|
|
430
|
+
createNode(moduleOrDynamic) {
|
|
431
|
+
const target = this.isDynamicModule(moduleOrDynamic) ? moduleOrDynamic.module : moduleOrDynamic;
|
|
432
|
+
if (this.nodes.has(target.name))
|
|
433
|
+
return this.nodes.get(target.name);
|
|
434
|
+
const node = new Node2(target.name);
|
|
435
|
+
this.nodes.set(target.name, node);
|
|
436
|
+
const imports = this.getImports(moduleOrDynamic);
|
|
437
|
+
node.setChildren(imports.map((imp) => this.createNode(imp)));
|
|
438
|
+
const providers = this.getProviders(moduleOrDynamic);
|
|
439
|
+
const controllers = this.getControllers(moduleOrDynamic);
|
|
440
|
+
const declarations = this.getDeclarations(moduleOrDynamic);
|
|
441
|
+
[...providers, ...controllers].forEach((item) => {
|
|
442
|
+
const token = this.getProviderToken(item);
|
|
443
|
+
const deps = this.extractDependencies(item);
|
|
444
|
+
node.addToken(token, deps);
|
|
445
|
+
});
|
|
446
|
+
node.addProviders(providers);
|
|
447
|
+
declarations.forEach((dec) => {
|
|
448
|
+
node.addProviders([{ provide: dec, useClass: dec, scope: "transient" }]);
|
|
449
|
+
});
|
|
450
|
+
controllers.forEach((ctrl) => {
|
|
451
|
+
node.addProviders([
|
|
452
|
+
{ provide: ctrl, useClass: ctrl, scope: "singleton" }
|
|
453
|
+
]);
|
|
454
|
+
});
|
|
455
|
+
[...declarations, ...controllers].forEach((comp) => {
|
|
456
|
+
if (Reflect.getMetadata(COMPONENT, comp)) {
|
|
457
|
+
const constructorDeps = this.getConstructorDependencies(comp);
|
|
458
|
+
node.addToken(comp, constructorDeps);
|
|
459
|
+
const componentDeps = Reflect.getMetadata(COMPONENT_DEPS, comp) || [];
|
|
460
|
+
const allDeps = [...constructorDeps, ...componentDeps];
|
|
461
|
+
node.addToken(comp, allDeps);
|
|
462
|
+
const localProviders = Reflect.getMetadata(COMPONENT_PROVIDERS, comp) || [];
|
|
463
|
+
node.addProviders(localProviders);
|
|
464
|
+
localProviders.forEach((lp) => {
|
|
465
|
+
const token = this.getProviderToken(lp);
|
|
466
|
+
const deps = this.extractDependencies(lp);
|
|
467
|
+
node.addToken(token, deps);
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
});
|
|
471
|
+
this.getExports(moduleOrDynamic).forEach((exp) => node.addExport(exp));
|
|
472
|
+
return node;
|
|
473
|
+
}
|
|
474
|
+
validate(rootNode) {
|
|
475
|
+
const errors = [];
|
|
476
|
+
const allNodes = /* @__PURE__ */ new Map();
|
|
477
|
+
this.collectAllNodes(rootNode, allNodes);
|
|
478
|
+
const tokenName = (token) => typeof token === "function" ? token.name : String(token);
|
|
479
|
+
allNodes.forEach((node) => {
|
|
480
|
+
const moduleName = node.name;
|
|
481
|
+
const providedTokens = node.getTokens();
|
|
482
|
+
const exportedTokens = node.getExports();
|
|
483
|
+
for (const exp of exportedTokens) {
|
|
484
|
+
if (!providedTokens.has(exp)) {
|
|
485
|
+
errors.push(`\u274C EXPORT ERROR in module "${moduleName}":
|
|
486
|
+
Exports token "${tokenName(exp)}" but this module does not provide it.
|
|
487
|
+
\u2192 Add it to providers/controllers/declarations, or remove from exports.`);
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
const seen = /* @__PURE__ */ new Set();
|
|
491
|
+
for (const token of providedTokens.keys()) {
|
|
492
|
+
if (seen.has(token)) {
|
|
493
|
+
errors.push(`\u274C DUPLICATE PROVIDER in module "${moduleName}":
|
|
494
|
+
Token "${tokenName(token)}" is registered more than once.
|
|
495
|
+
\u2192 Remove duplicate entries.`);
|
|
496
|
+
}
|
|
497
|
+
seen.add(token);
|
|
498
|
+
}
|
|
499
|
+
for (const [token, deps] of providedTokens) {
|
|
500
|
+
for (const dep of deps) {
|
|
501
|
+
if (providedTokens.has(dep))
|
|
502
|
+
continue;
|
|
503
|
+
const providingModule = this.findProvidingModule(dep, node, allNodes, /* @__PURE__ */ new Set());
|
|
504
|
+
if (!providingModule) {
|
|
505
|
+
const consumer = tokenName(token);
|
|
506
|
+
const missing = tokenName(dep);
|
|
507
|
+
const possibleProviders = Array.from(allNodes.values()).filter((n) => n.getTokens().has(dep)).map((n) => n.name);
|
|
508
|
+
let suggestion = "";
|
|
509
|
+
if (possibleProviders.length > 0) {
|
|
510
|
+
suggestion = `
|
|
511
|
+
\u2192 "${missing}" IS provided in: ${possibleProviders.join(", ")}
|
|
512
|
+
\u2192 Ensure one of those modules exports it AND "${moduleName}" imports that module.`;
|
|
513
|
+
} else {
|
|
514
|
+
suggestion = `
|
|
515
|
+
\u2192 "${missing}" is not provided anywhere. Add a provider for it.`;
|
|
516
|
+
}
|
|
517
|
+
errors.push(`\u274C UNRESOLVED DEPENDENCY in module "${moduleName}":
|
|
518
|
+
"${consumer}" requires "${missing}"${suggestion}`);
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
providedTokens.forEach((deps, token) => {
|
|
523
|
+
if (typeof token === "function" && Reflect.getMetadata(COMPONENT, token)) {
|
|
524
|
+
const componentDeps = Reflect.getMetadata(COMPONENT_DEPS, token) || [];
|
|
525
|
+
componentDeps.forEach((depComp) => {
|
|
526
|
+
if (typeof depComp === "function" && !Reflect.getMetadata(COMPONENT, depComp)) {
|
|
527
|
+
errors.push(`\u274C COMPONENT DEPENDENCY ERROR in module "${moduleName}":
|
|
528
|
+
Component "${tokenName(token)}" lists "${tokenName(depComp)}" in deps
|
|
529
|
+
\u2192 "${tokenName(depComp)}" is not a component (missing @Component decorator)`);
|
|
530
|
+
}
|
|
531
|
+
if (!providedTokens.has(depComp)) {
|
|
532
|
+
const providingMod = this.findProvidingModule(depComp, node, allNodes, /* @__PURE__ */ new Set());
|
|
533
|
+
if (!providingMod) {
|
|
534
|
+
errors.push(`\u274C COMPONENT DEPENDENCY ERROR in module "${moduleName}":
|
|
535
|
+
Component "${tokenName(token)}" renders "${tokenName(depComp)}"
|
|
536
|
+
\u2192 "${tokenName(depComp)}" must be in declarations or imported`);
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
});
|
|
540
|
+
}
|
|
541
|
+
});
|
|
542
|
+
});
|
|
543
|
+
return { valid: errors.length === 0, errors };
|
|
544
|
+
}
|
|
545
|
+
collectAllNodes(node, collected, visited = /* @__PURE__ */ new Set()) {
|
|
546
|
+
if (visited.has(node.name))
|
|
547
|
+
return;
|
|
548
|
+
visited.add(node.name);
|
|
549
|
+
collected.set(node.name, node);
|
|
550
|
+
node.getChildren().forEach((child) => this.collectAllNodes(child, collected, visited));
|
|
551
|
+
}
|
|
552
|
+
findProvidingModule(token, fromNode, allNodes, visited = /* @__PURE__ */ new Set()) {
|
|
553
|
+
if (visited.has(fromNode.name))
|
|
554
|
+
return null;
|
|
555
|
+
visited.add(fromNode.name);
|
|
556
|
+
for (const child of fromNode.getChildren()) {
|
|
557
|
+
if (child.getTokens().has(token) && child.getExports().has(token)) {
|
|
558
|
+
return child.name;
|
|
559
|
+
}
|
|
560
|
+
const found = this.findProvidingModule(token, child, allNodes, visited);
|
|
561
|
+
if (found)
|
|
562
|
+
return found;
|
|
563
|
+
}
|
|
564
|
+
return null;
|
|
565
|
+
}
|
|
566
|
+
getProviderToken(provider) {
|
|
567
|
+
return typeof provider === "function" ? provider : provider.provide;
|
|
568
|
+
}
|
|
569
|
+
extractDependencies(item) {
|
|
570
|
+
if (typeof item === "object" && "deps" in item && item.deps)
|
|
571
|
+
return item.deps;
|
|
572
|
+
if (typeof item === "object" && item.useClass)
|
|
573
|
+
return this.getConstructorDependencies(item.useClass);
|
|
574
|
+
if (typeof item === "function")
|
|
575
|
+
return this.getConstructorDependencies(item);
|
|
576
|
+
return [];
|
|
577
|
+
}
|
|
578
|
+
getConstructorDependencies(constructor) {
|
|
579
|
+
const injectTokens = Reflect.getOwnMetadata(INJECT_TOKENS_KEY, constructor) || /* @__PURE__ */ new Map();
|
|
580
|
+
const paramTypes = Reflect.getMetadata(DESIGN_PARAMTYPES, constructor) || [];
|
|
581
|
+
return paramTypes.map((type, index) => {
|
|
582
|
+
const injected = injectTokens.get(index);
|
|
583
|
+
if (injected?.maybe) {
|
|
584
|
+
return null;
|
|
585
|
+
}
|
|
586
|
+
return injected?.token ?? type;
|
|
587
|
+
}).filter((token) => Boolean(token));
|
|
588
|
+
}
|
|
589
|
+
isDynamicModule(m) {
|
|
590
|
+
return typeof m === "object" && "module" in m;
|
|
591
|
+
}
|
|
592
|
+
getImports(m) {
|
|
593
|
+
if (this.isDynamicModule(m))
|
|
594
|
+
return m.imports || [];
|
|
595
|
+
return Reflect.getMetadata(IMPORTS_KEY, m) || [];
|
|
596
|
+
}
|
|
597
|
+
getProviders(m) {
|
|
598
|
+
if (this.isDynamicModule(m))
|
|
599
|
+
return m.providers || [];
|
|
600
|
+
return Reflect.getMetadata(PROVIDERS_KEY, m) || [];
|
|
601
|
+
}
|
|
602
|
+
getControllers(m) {
|
|
603
|
+
if (this.isDynamicModule(m))
|
|
604
|
+
return m.controllers || [];
|
|
605
|
+
return Reflect.getMetadata(CONTROLLERS_KEY, m) || [];
|
|
606
|
+
}
|
|
607
|
+
getDeclarations(m) {
|
|
608
|
+
if (this.isDynamicModule(m))
|
|
609
|
+
return m.declarations || [];
|
|
610
|
+
return Reflect.getMetadata(DECLARATIONS_KEY, m) || [];
|
|
611
|
+
}
|
|
612
|
+
getExports(m) {
|
|
613
|
+
if (this.isDynamicModule(m))
|
|
614
|
+
return m.exports || [];
|
|
615
|
+
return Reflect.getMetadata(EXPORTS_KEY, m) || [];
|
|
616
|
+
}
|
|
617
|
+
printDAG(node, indent = "", visited = /* @__PURE__ */ new Set()) {
|
|
618
|
+
if (visited.has(node.name)) {
|
|
619
|
+
console.log(`${indent}${node.name} (circular)`);
|
|
620
|
+
return;
|
|
621
|
+
}
|
|
622
|
+
visited.add(node.name);
|
|
623
|
+
console.log(`${indent}${node.name}`);
|
|
624
|
+
const tokens = node.getTokens();
|
|
625
|
+
if (tokens.size > 0) {
|
|
626
|
+
console.log(`${indent}\u251C\u2500 Tokens:`);
|
|
627
|
+
Array.from(tokens.entries()).forEach(([token, deps], i, arr) => {
|
|
628
|
+
const prefix = i === arr.length - 1 ? "\u2514\u2500" : "\u251C\u2500";
|
|
629
|
+
const tokenName = typeof token === "function" ? token.name : String(token);
|
|
630
|
+
const depStr = deps.length ? ` \u2192 [${deps.map((d) => typeof d === "function" ? d.name : String(d)).join(", ")}]` : "";
|
|
631
|
+
console.log(`${indent}\u2502 ${prefix} ${tokenName}${depStr}`);
|
|
632
|
+
});
|
|
633
|
+
}
|
|
634
|
+
const exports = node.getExports();
|
|
635
|
+
if (exports.size > 0) {
|
|
636
|
+
const names = Array.from(exports).map((t) => typeof t === "function" ? t.name : String(t));
|
|
637
|
+
console.log(`${indent}\u251C\u2500 Exports: [${names.join(", ")}]`);
|
|
638
|
+
}
|
|
639
|
+
const children = node.getChildren();
|
|
640
|
+
if (children.length > 0) {
|
|
641
|
+
console.log(`${indent}\u2514\u2500 Imports:`);
|
|
642
|
+
children.forEach((child, i) => {
|
|
643
|
+
const isLast = i === children.length - 1;
|
|
644
|
+
const childIndent = indent + (isLast ? " " : "\u2502 ");
|
|
645
|
+
this.printDAG(child, childIndent, new Set(visited));
|
|
646
|
+
});
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
};
|
|
650
|
+
|
|
651
|
+
// src/shared/module/injector.ts
|
|
652
|
+
var Injector = class {
|
|
653
|
+
constructor(providers, parent) {
|
|
654
|
+
this.instanceCache = /* @__PURE__ */ new Map();
|
|
655
|
+
this.providerMap = /* @__PURE__ */ new Map();
|
|
656
|
+
this.parent = parent;
|
|
657
|
+
providers.forEach((p) => {
|
|
658
|
+
const normalized = ProviderNormalizer.normalize(p);
|
|
659
|
+
this.providerMap.set(normalized.provide, normalized);
|
|
660
|
+
});
|
|
661
|
+
}
|
|
662
|
+
addProvider(provider) {
|
|
663
|
+
const normalized = ProviderNormalizer.normalize(provider);
|
|
664
|
+
this.providerMap.set(normalized.provide, normalized);
|
|
665
|
+
}
|
|
666
|
+
resolve(token) {
|
|
667
|
+
if (this.instanceCache.has(token)) {
|
|
668
|
+
return this.instanceCache.get(token);
|
|
669
|
+
}
|
|
670
|
+
const provider = this.providerMap.get(token);
|
|
671
|
+
if (!provider) {
|
|
672
|
+
if (this.parent) {
|
|
673
|
+
return this.parent.resolve(token);
|
|
674
|
+
}
|
|
675
|
+
throw new Error(
|
|
676
|
+
`No provider for token: ${typeof token === "function" ? token.name : String(token)}`
|
|
677
|
+
);
|
|
678
|
+
}
|
|
679
|
+
const instance = this.createInstance(provider);
|
|
680
|
+
if (provider.scope !== "transient") {
|
|
681
|
+
this.instanceCache.set(token, instance);
|
|
682
|
+
}
|
|
683
|
+
return instance;
|
|
684
|
+
}
|
|
685
|
+
createInstance(provider) {
|
|
686
|
+
if ("useValue" in provider && provider.useValue !== void 0)
|
|
687
|
+
return provider.useValue;
|
|
688
|
+
if (provider.useExisting)
|
|
689
|
+
return this.resolve(provider.useExisting);
|
|
690
|
+
if (provider.useFactory) {
|
|
691
|
+
const deps2 = (provider.deps || []).map((d) => this.resolve(d));
|
|
692
|
+
return provider.useFactory(...deps2);
|
|
693
|
+
}
|
|
694
|
+
const Ctor = provider.useClass || provider.provide;
|
|
695
|
+
const deps = provider.deps || this.getConstructorDeps(Ctor);
|
|
696
|
+
return new Ctor(...deps.map((d) => this.resolve(d)));
|
|
697
|
+
}
|
|
698
|
+
getConstructorDeps(ctor) {
|
|
699
|
+
const injectTokens = Reflect.getOwnMetadata(INJECT_TOKENS_KEY, ctor) || /* @__PURE__ */ new Map();
|
|
700
|
+
const paramTypes = Reflect.getMetadata(DESIGN_PARAMTYPES, ctor) || [];
|
|
701
|
+
return paramTypes.map((type, index) => {
|
|
702
|
+
const injected = injectTokens.get(index);
|
|
703
|
+
return injected?.token ?? type;
|
|
704
|
+
}).filter((token) => Boolean(token));
|
|
705
|
+
}
|
|
706
|
+
};
|
|
707
|
+
function collectAllProvidersFromNode(node, collected = /* @__PURE__ */ new Set()) {
|
|
708
|
+
node.getProviders().forEach((p) => collected.add(p));
|
|
709
|
+
node.getChildren().forEach((child) => collectAllProvidersFromNode(child, collected));
|
|
710
|
+
return Array.from(collected);
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
// src/shared/module/context.ts
|
|
714
|
+
var currentInjector = null;
|
|
715
|
+
function setCurrentInjector(injector) {
|
|
716
|
+
currentInjector = injector;
|
|
717
|
+
}
|
|
718
|
+
function getCurrentInjector() {
|
|
719
|
+
return currentInjector;
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
// src/shared/jsx/jsx-runtime.ts
|
|
723
|
+
var import_uuid = __require("uuid");
|
|
724
|
+
function jsx(type, config, maybeKey) {
|
|
725
|
+
const key = maybeKey !== void 0 ? maybeKey : config?.key ?? null;
|
|
726
|
+
const props = {};
|
|
727
|
+
if (config) {
|
|
728
|
+
for (const propName in config) {
|
|
729
|
+
if (propName === "key")
|
|
730
|
+
continue;
|
|
731
|
+
if (propName === "ref")
|
|
732
|
+
continue;
|
|
733
|
+
props[propName] = config[propName];
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
if (props.children !== void 0) {
|
|
737
|
+
props.children = normalizeChildren(props.children);
|
|
738
|
+
}
|
|
739
|
+
if (typeof type === "function" && type.defaultProps) {
|
|
740
|
+
for (const propName in type.defaultProps) {
|
|
741
|
+
if (props[propName] === void 0) {
|
|
742
|
+
props[propName] = type.defaultProps[propName];
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
return createVNode(type, props, key);
|
|
747
|
+
}
|
|
748
|
+
var jsxs = jsx;
|
|
749
|
+
function Fragment(props) {
|
|
750
|
+
return {
|
|
751
|
+
$$typeof: ORCA_ELEMENT_TYPE,
|
|
752
|
+
type: ORCA_FRAGMENT_TYPE,
|
|
753
|
+
id: "00000000-0000-0000-0000-000000000000",
|
|
754
|
+
props,
|
|
755
|
+
key: null
|
|
756
|
+
};
|
|
757
|
+
}
|
|
758
|
+
function createVNode(type, props, key) {
|
|
759
|
+
return {
|
|
760
|
+
$$typeof: ORCA_ELEMENT_TYPE,
|
|
761
|
+
id: (0, import_uuid.v4)(),
|
|
762
|
+
type,
|
|
763
|
+
props,
|
|
764
|
+
key
|
|
765
|
+
};
|
|
766
|
+
}
|
|
767
|
+
function normalizeChildren(children) {
|
|
768
|
+
if (children === null || children === void 0) {
|
|
769
|
+
return null;
|
|
770
|
+
}
|
|
771
|
+
if (!Array.isArray(children)) {
|
|
772
|
+
return normalizeChild(children);
|
|
773
|
+
}
|
|
774
|
+
const normalized = [];
|
|
775
|
+
for (let i = 0; i < children.length; i++) {
|
|
776
|
+
const child = normalizeChild(children[i]);
|
|
777
|
+
if (child === null)
|
|
778
|
+
continue;
|
|
779
|
+
if (Array.isArray(child)) {
|
|
780
|
+
normalized.push(...child);
|
|
781
|
+
} else {
|
|
782
|
+
normalized.push(child);
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
if (normalized.length === 0)
|
|
786
|
+
return null;
|
|
787
|
+
if (normalized.length === 1)
|
|
788
|
+
return normalized[0];
|
|
789
|
+
return normalized;
|
|
790
|
+
}
|
|
791
|
+
function normalizeChild(child) {
|
|
792
|
+
if (child === null || child === void 0 || typeof child === "boolean") {
|
|
793
|
+
return null;
|
|
794
|
+
}
|
|
795
|
+
if (typeof child === "number") {
|
|
796
|
+
return String(child);
|
|
797
|
+
}
|
|
798
|
+
if (typeof child === "string" || child.$$typeof === ORCA_ELEMENT_TYPE) {
|
|
799
|
+
return child;
|
|
800
|
+
}
|
|
801
|
+
if (Array.isArray(child)) {
|
|
802
|
+
return child.map(normalizeChild).filter((c) => c !== null);
|
|
803
|
+
}
|
|
804
|
+
return String(child);
|
|
805
|
+
}
|
|
806
|
+
function isClassComponent(jsx2) {
|
|
807
|
+
return typeof jsx2.type === "function" && jsx2.type.prototype && typeof jsx2.type.prototype.build === "function";
|
|
808
|
+
}
|
|
809
|
+
function isIntrinsicElement(jsx2) {
|
|
810
|
+
return typeof jsx2.type === "string";
|
|
811
|
+
}
|
|
812
|
+
function isFragment(jsx2) {
|
|
813
|
+
return typeof jsx2.type === "function" && jsx2.type()?.type == ORCA_FRAGMENT_TYPE;
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
// src/shared/renderers/string.ts
|
|
817
|
+
var StringRenderer = class {
|
|
818
|
+
constructor(rootInjector) {
|
|
819
|
+
this.rootInjector = rootInjector;
|
|
820
|
+
}
|
|
821
|
+
render(vnode, parentInjector = this.rootInjector) {
|
|
822
|
+
if (typeof vnode.type === "function") {
|
|
823
|
+
const ComponentClass = vnode.type;
|
|
824
|
+
const isComponent = Reflect.getMetadata(COMPONENT, ComponentClass);
|
|
825
|
+
let componentInjector = parentInjector;
|
|
826
|
+
if (isComponent) {
|
|
827
|
+
const localProviders = Reflect.getMetadata(COMPONENT_PROVIDERS, ComponentClass) || [];
|
|
828
|
+
if (localProviders.length > 0) {
|
|
829
|
+
componentInjector = new Injector(
|
|
830
|
+
localProviders.map((p) => ProviderNormalizer.normalize(p)),
|
|
831
|
+
parentInjector
|
|
832
|
+
);
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
const instance = componentInjector.resolve(ComponentClass);
|
|
836
|
+
instance.props = vnode.props || {};
|
|
837
|
+
const childVNode = instance.build();
|
|
838
|
+
return this.render(childVNode, componentInjector);
|
|
839
|
+
}
|
|
840
|
+
if (typeof vnode.type === "string") {
|
|
841
|
+
const { children, ...attrs } = vnode.props;
|
|
842
|
+
const attrsStr = Object.entries(attrs).map(([key, value]) => {
|
|
843
|
+
if (value === true)
|
|
844
|
+
return key;
|
|
845
|
+
if (value === false || value === null || value === void 0)
|
|
846
|
+
return "";
|
|
847
|
+
return `${key}="${this.escapeHtml(String(value))}"`;
|
|
848
|
+
}).filter(Boolean).join(" ");
|
|
849
|
+
const openTag = attrsStr ? `<${vnode.type} ${attrsStr}>` : `<${vnode.type}>`;
|
|
850
|
+
const selfClosing = ["img", "br", "hr", "input", "meta", "link"];
|
|
851
|
+
if (selfClosing.includes(vnode.type)) {
|
|
852
|
+
return attrsStr ? `<${vnode.type} ${attrsStr} />` : `<${vnode.type} />`;
|
|
853
|
+
}
|
|
854
|
+
let childrenHtml = "";
|
|
855
|
+
if (children !== void 0 && children !== null) {
|
|
856
|
+
if (Array.isArray(children)) {
|
|
857
|
+
childrenHtml = children.map((child) => {
|
|
858
|
+
if (typeof child === "string" || typeof child === "number") {
|
|
859
|
+
return this.escapeHtml(String(child));
|
|
860
|
+
}
|
|
861
|
+
return this.render(child, parentInjector);
|
|
862
|
+
}).join("");
|
|
863
|
+
} else if (typeof children === "object" && "type" in children) {
|
|
864
|
+
childrenHtml = this.render(children, parentInjector);
|
|
865
|
+
} else {
|
|
866
|
+
childrenHtml = this.escapeHtml(String(children));
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
return `${openTag}${childrenHtml}</${vnode.type}>`;
|
|
870
|
+
}
|
|
871
|
+
return "";
|
|
872
|
+
}
|
|
873
|
+
escapeHtml(text) {
|
|
874
|
+
const map = {
|
|
875
|
+
"&": "&",
|
|
876
|
+
"<": "<",
|
|
877
|
+
">": ">",
|
|
878
|
+
'"': """,
|
|
879
|
+
"'": "'"
|
|
880
|
+
};
|
|
881
|
+
return text.replace(/[&<>"']/g, (m) => map[m]);
|
|
882
|
+
}
|
|
883
|
+
};
|
|
884
|
+
|
|
885
|
+
// src/shared/renderers/stream.ts
|
|
886
|
+
var StreamRenderer = class {
|
|
887
|
+
constructor(rootInjector, options = {}) {
|
|
888
|
+
this.rootInjector = rootInjector;
|
|
889
|
+
this.pending = /* @__PURE__ */ new Map();
|
|
890
|
+
this.processedIds = /* @__PURE__ */ new Set();
|
|
891
|
+
this.queueResolvers = [];
|
|
892
|
+
this.pushQueue = (u) => this.queueResolvers.shift()?.(u);
|
|
893
|
+
this.options = {
|
|
894
|
+
timeout: options.timeout ?? 3e4
|
|
895
|
+
};
|
|
896
|
+
}
|
|
897
|
+
render(vnode, parentInjector = this.rootInjector) {
|
|
898
|
+
return this.stream(vnode, parentInjector);
|
|
899
|
+
}
|
|
900
|
+
async *stream(vnode, parentInjector) {
|
|
901
|
+
this.pending.clear();
|
|
902
|
+
this.queueResolvers = [];
|
|
903
|
+
this.renderingNodes = /* @__PURE__ */ new WeakSet();
|
|
904
|
+
this.processedIds.clear();
|
|
905
|
+
const nextUpdate = () => new Promise((resolve) => this.queueResolvers.push(resolve));
|
|
906
|
+
try {
|
|
907
|
+
const root = this.buildSyncTree(vnode, parentInjector);
|
|
908
|
+
yield { ...root, action: "insert" };
|
|
909
|
+
while (this.pending.size > 0) {
|
|
910
|
+
const update = await nextUpdate();
|
|
911
|
+
yield update;
|
|
912
|
+
}
|
|
913
|
+
} finally {
|
|
914
|
+
this.cleanup();
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
buildSyncTree(vnode, injector) {
|
|
918
|
+
if (vnode == null || typeof vnode !== "object")
|
|
919
|
+
return vnode;
|
|
920
|
+
if (vnode.$$typeof !== ORCA_ELEMENT_TYPE)
|
|
921
|
+
return vnode;
|
|
922
|
+
if (this.renderingNodes.has(vnode)) {
|
|
923
|
+
throw new Error(
|
|
924
|
+
`Circular reference detected while rendering component "${vnode.type?.name}".`
|
|
925
|
+
);
|
|
926
|
+
}
|
|
927
|
+
this.renderingNodes.add(vnode);
|
|
928
|
+
try {
|
|
929
|
+
if (isClassComponent(vnode)) {
|
|
930
|
+
return this.renderClassComponent(vnode, injector);
|
|
931
|
+
}
|
|
932
|
+
if (isIntrinsicElement(vnode)) {
|
|
933
|
+
return {
|
|
934
|
+
$$typeof: ORCA_ELEMENT_TYPE,
|
|
935
|
+
type: vnode.type,
|
|
936
|
+
id: vnode.id,
|
|
937
|
+
props: {
|
|
938
|
+
...vnode.props,
|
|
939
|
+
children: this.mapChildren(vnode.props?.children, injector)
|
|
940
|
+
},
|
|
941
|
+
key: vnode.key ?? null
|
|
942
|
+
};
|
|
943
|
+
}
|
|
944
|
+
if (isFragment(vnode)) {
|
|
945
|
+
return {
|
|
946
|
+
$$typeof: ORCA_ELEMENT_TYPE,
|
|
947
|
+
type: null,
|
|
948
|
+
id: vnode.id,
|
|
949
|
+
props: {
|
|
950
|
+
children: this.mapChildren(vnode.props?.children, injector)
|
|
951
|
+
},
|
|
952
|
+
key: null
|
|
953
|
+
};
|
|
954
|
+
}
|
|
955
|
+
return vnode;
|
|
956
|
+
} finally {
|
|
957
|
+
this.renderingNodes.delete(vnode);
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
renderClassComponent(vnode, injector) {
|
|
961
|
+
const ComponentClass = vnode.type;
|
|
962
|
+
const isComponent = Reflect.getMetadata(COMPONENT, ComponentClass);
|
|
963
|
+
let componentInjector = injector;
|
|
964
|
+
if (isComponent) {
|
|
965
|
+
const localProviders = Reflect.getMetadata(COMPONENT_PROVIDERS, ComponentClass) || [];
|
|
966
|
+
if (localProviders.length > 0) {
|
|
967
|
+
componentInjector = new Injector(
|
|
968
|
+
localProviders.map((p) => ProviderNormalizer.normalize(p)),
|
|
969
|
+
injector
|
|
970
|
+
);
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
const instance = componentInjector.resolve(ComponentClass);
|
|
974
|
+
instance.props = vnode.props || {};
|
|
975
|
+
const childVNode = instance.build();
|
|
976
|
+
if (childVNode instanceof Promise) {
|
|
977
|
+
return this.createPendingReference(vnode, childVNode, componentInjector);
|
|
978
|
+
}
|
|
979
|
+
return this.buildSyncTree(childVNode, componentInjector);
|
|
980
|
+
}
|
|
981
|
+
mapChildren(children, injector) {
|
|
982
|
+
if (children == null || typeof children === "string" || typeof children === "number") {
|
|
983
|
+
return children;
|
|
984
|
+
}
|
|
985
|
+
if (Array.isArray(children)) {
|
|
986
|
+
return children.map((c) => this.buildSyncTree(c, injector));
|
|
987
|
+
}
|
|
988
|
+
return this.buildSyncTree(children, injector);
|
|
989
|
+
}
|
|
990
|
+
createPendingReference(vnode, promise, injector) {
|
|
991
|
+
const id = vnode.id;
|
|
992
|
+
const abortController = new AbortController();
|
|
993
|
+
const timeoutPromise = new Promise((_, reject) => {
|
|
994
|
+
const timeoutId = setTimeout(() => {
|
|
995
|
+
abortController.abort();
|
|
996
|
+
reject(
|
|
997
|
+
new Error(
|
|
998
|
+
`Component ${vnode.type.name || "Unknown"} timed out after ${this.options.timeout}ms`
|
|
999
|
+
)
|
|
1000
|
+
);
|
|
1001
|
+
}, this.options.timeout);
|
|
1002
|
+
abortController.signal.addEventListener("abort", () => {
|
|
1003
|
+
clearTimeout(timeoutId);
|
|
1004
|
+
});
|
|
1005
|
+
});
|
|
1006
|
+
const raced = Promise.race([promise, timeoutPromise]).then((result) => {
|
|
1007
|
+
result.id = vnode.id;
|
|
1008
|
+
return this.buildSyncTree(result, injector);
|
|
1009
|
+
}).catch((err) => Promise.reject({ id, error: err }));
|
|
1010
|
+
this.pending.set(id, { abortController, promise: raced });
|
|
1011
|
+
raced.then((resolved) => {
|
|
1012
|
+
if (this.processedIds.has(id))
|
|
1013
|
+
return;
|
|
1014
|
+
this.processedIds.add(id);
|
|
1015
|
+
this.pushQueue({
|
|
1016
|
+
...resolved,
|
|
1017
|
+
action: "update"
|
|
1018
|
+
});
|
|
1019
|
+
this.pending.delete(id);
|
|
1020
|
+
}).catch((e) => {
|
|
1021
|
+
this.pushQueue({
|
|
1022
|
+
$$typeof: ERROR_ELEMENT,
|
|
1023
|
+
type: "error",
|
|
1024
|
+
action: "error",
|
|
1025
|
+
id,
|
|
1026
|
+
props: {
|
|
1027
|
+
message: String(e?.error) || String(e)
|
|
1028
|
+
},
|
|
1029
|
+
key: null
|
|
1030
|
+
});
|
|
1031
|
+
this.pending.delete(id);
|
|
1032
|
+
});
|
|
1033
|
+
return {
|
|
1034
|
+
$$typeof: PENDING_REFERENCE_TYPE,
|
|
1035
|
+
id,
|
|
1036
|
+
type: "ref",
|
|
1037
|
+
props: vnode.props,
|
|
1038
|
+
key: vnode.key ?? null
|
|
1039
|
+
};
|
|
1040
|
+
}
|
|
1041
|
+
cleanup() {
|
|
1042
|
+
for (const { abortController } of this.pending.values()) {
|
|
1043
|
+
abortController.abort();
|
|
1044
|
+
}
|
|
1045
|
+
this.pending.clear();
|
|
1046
|
+
this.processedIds.clear();
|
|
1047
|
+
this.queueResolvers.length = 0;
|
|
1048
|
+
}
|
|
1049
|
+
cancel() {
|
|
1050
|
+
this.cleanup();
|
|
1051
|
+
}
|
|
1052
|
+
async renderToCompletion(jsx2) {
|
|
1053
|
+
const out = [];
|
|
1054
|
+
for await (const upd of this.stream(jsx2, this.rootInjector)) {
|
|
1055
|
+
out.push(upd);
|
|
1056
|
+
}
|
|
1057
|
+
return out;
|
|
1058
|
+
}
|
|
1059
|
+
};
|
|
1060
|
+
|
|
1061
|
+
// src/shared/renderers/vnode.ts
|
|
1062
|
+
var VNode = class {
|
|
1063
|
+
constructor(dom, cb) {
|
|
1064
|
+
this.dom = dom;
|
|
1065
|
+
this.cb = cb;
|
|
1066
|
+
this.children = [];
|
|
1067
|
+
}
|
|
1068
|
+
setId(id) {
|
|
1069
|
+
this.id = id;
|
|
1070
|
+
}
|
|
1071
|
+
addChild(child) {
|
|
1072
|
+
child.parent = this;
|
|
1073
|
+
this.children.push(child);
|
|
1074
|
+
return child;
|
|
1075
|
+
}
|
|
1076
|
+
removeChild(child) {
|
|
1077
|
+
const index = this.children.indexOf(child);
|
|
1078
|
+
if (index > -1) {
|
|
1079
|
+
this.children.splice(index, 1);
|
|
1080
|
+
child.parent = void 0;
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1083
|
+
findById(id) {
|
|
1084
|
+
if (this.id === id)
|
|
1085
|
+
return this;
|
|
1086
|
+
for (const child of this.children) {
|
|
1087
|
+
const found = child.findById(id);
|
|
1088
|
+
if (found)
|
|
1089
|
+
return found;
|
|
1090
|
+
}
|
|
1091
|
+
return null;
|
|
1092
|
+
}
|
|
1093
|
+
attach(nw) {
|
|
1094
|
+
if (this.cb) {
|
|
1095
|
+
this.cb(this.dom, nw);
|
|
1096
|
+
} else {
|
|
1097
|
+
if (this.dom.parentNode) {
|
|
1098
|
+
this.dom.parentNode.replaceChild(nw, this.dom);
|
|
1099
|
+
}
|
|
1100
|
+
}
|
|
1101
|
+
this.dom = nw;
|
|
1102
|
+
}
|
|
1103
|
+
unmount() {
|
|
1104
|
+
for (const child of this.children) {
|
|
1105
|
+
child.unmount();
|
|
1106
|
+
}
|
|
1107
|
+
if (this.dom.parentNode) {
|
|
1108
|
+
this.dom.parentNode.removeChild(this.dom);
|
|
1109
|
+
}
|
|
1110
|
+
if (this.parent) {
|
|
1111
|
+
this.parent.removeChild(this);
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
1114
|
+
};
|
|
1115
|
+
|
|
1116
|
+
// src/shared/json.ts
|
|
1117
|
+
function symbolValueReplacer(key, value) {
|
|
1118
|
+
if (typeof value === "symbol") {
|
|
1119
|
+
return `@@Symbol:${value.description}`;
|
|
1120
|
+
}
|
|
1121
|
+
return value;
|
|
1122
|
+
}
|
|
1123
|
+
function symbolValueReviver(key, value) {
|
|
1124
|
+
if (typeof value === "string" && value.startsWith("@@Symbol:")) {
|
|
1125
|
+
return Symbol.for(value.slice(9));
|
|
1126
|
+
}
|
|
1127
|
+
return value;
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
// src/shared/signal/signal.ts
|
|
1131
|
+
var currentEffect = null;
|
|
1132
|
+
function signal(initialValue) {
|
|
1133
|
+
let value = initialValue;
|
|
1134
|
+
const subscribers = /* @__PURE__ */ new Set();
|
|
1135
|
+
const notify = () => {
|
|
1136
|
+
subscribers.forEach((sub) => sub());
|
|
1137
|
+
};
|
|
1138
|
+
return {
|
|
1139
|
+
_isSignal: true,
|
|
1140
|
+
_subscribers: subscribers,
|
|
1141
|
+
get value() {
|
|
1142
|
+
if (currentEffect) {
|
|
1143
|
+
subscribers.add(currentEffect);
|
|
1144
|
+
}
|
|
1145
|
+
return value;
|
|
1146
|
+
},
|
|
1147
|
+
set value(newValue) {
|
|
1148
|
+
if (value !== newValue) {
|
|
1149
|
+
value = newValue;
|
|
1150
|
+
notify();
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
};
|
|
1154
|
+
}
|
|
1155
|
+
function effect(fn) {
|
|
1156
|
+
const execute = () => {
|
|
1157
|
+
currentEffect = execute;
|
|
1158
|
+
try {
|
|
1159
|
+
fn();
|
|
1160
|
+
} finally {
|
|
1161
|
+
currentEffect = null;
|
|
1162
|
+
}
|
|
1163
|
+
};
|
|
1164
|
+
execute();
|
|
1165
|
+
return () => {
|
|
1166
|
+
currentEffect = null;
|
|
1167
|
+
};
|
|
1168
|
+
}
|
|
1169
|
+
function computed(fn) {
|
|
1170
|
+
const sig = signal(fn());
|
|
1171
|
+
effect(() => {
|
|
1172
|
+
sig.value = fn();
|
|
1173
|
+
});
|
|
1174
|
+
return sig;
|
|
1175
|
+
}
|
|
1176
|
+
function isSignal(value) {
|
|
1177
|
+
return value && value._isSignal === true;
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1180
|
+
// src/shared/observable/observable.ts
|
|
1181
|
+
var Observable = class {
|
|
1182
|
+
constructor(producer) {
|
|
1183
|
+
this.producer = producer;
|
|
1184
|
+
this.__isObservable = true;
|
|
1185
|
+
this.subscribers = /* @__PURE__ */ new Set();
|
|
1186
|
+
}
|
|
1187
|
+
get $value() {
|
|
1188
|
+
return this._value;
|
|
1189
|
+
}
|
|
1190
|
+
setValue(newValue) {
|
|
1191
|
+
this._value = newValue;
|
|
1192
|
+
}
|
|
1193
|
+
subscribe(observerOrNext, error, complete) {
|
|
1194
|
+
const observer = typeof observerOrNext === "function" ? { next: observerOrNext, error, complete } : observerOrNext;
|
|
1195
|
+
this.subscribers.add(observer);
|
|
1196
|
+
let cleanup;
|
|
1197
|
+
if (this.producer) {
|
|
1198
|
+
try {
|
|
1199
|
+
cleanup = this.producer(observer);
|
|
1200
|
+
} catch (err) {
|
|
1201
|
+
if (observer.error) {
|
|
1202
|
+
observer.error(err);
|
|
1203
|
+
}
|
|
1204
|
+
}
|
|
1205
|
+
}
|
|
1206
|
+
return {
|
|
1207
|
+
unsubscribe: () => {
|
|
1208
|
+
this.subscribers.delete(observer);
|
|
1209
|
+
if (cleanup)
|
|
1210
|
+
cleanup();
|
|
1211
|
+
}
|
|
1212
|
+
};
|
|
1213
|
+
}
|
|
1214
|
+
next(value) {
|
|
1215
|
+
this.setValue(value);
|
|
1216
|
+
this.subscribers.forEach((observer) => {
|
|
1217
|
+
try {
|
|
1218
|
+
observer.next(value);
|
|
1219
|
+
} catch (err) {
|
|
1220
|
+
console.error("Error in observer:", err);
|
|
1221
|
+
}
|
|
1222
|
+
});
|
|
1223
|
+
}
|
|
1224
|
+
error(err) {
|
|
1225
|
+
this.subscribers.forEach((observer) => {
|
|
1226
|
+
if (observer.error) {
|
|
1227
|
+
try {
|
|
1228
|
+
observer.error(err);
|
|
1229
|
+
} catch (e) {
|
|
1230
|
+
console.error("Error in error handler:", e);
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
});
|
|
1234
|
+
}
|
|
1235
|
+
complete() {
|
|
1236
|
+
this.subscribers.forEach((observer) => {
|
|
1237
|
+
if (observer.complete) {
|
|
1238
|
+
try {
|
|
1239
|
+
observer.complete();
|
|
1240
|
+
} catch (err) {
|
|
1241
|
+
console.error("Error in complete handler:", err);
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1244
|
+
});
|
|
1245
|
+
this.subscribers.clear();
|
|
1246
|
+
}
|
|
1247
|
+
pipe(...operations) {
|
|
1248
|
+
if (operations.length === 0) {
|
|
1249
|
+
return this;
|
|
1250
|
+
}
|
|
1251
|
+
return operations.reduce((prev, fn) => fn(prev), this);
|
|
1252
|
+
}
|
|
1253
|
+
};
|
|
1254
|
+
function from(iterable) {
|
|
1255
|
+
return new Observable((observer) => {
|
|
1256
|
+
for (const value of iterable) {
|
|
1257
|
+
observer.next(value);
|
|
1258
|
+
}
|
|
1259
|
+
observer.complete?.();
|
|
1260
|
+
});
|
|
1261
|
+
}
|
|
1262
|
+
function interval(ms) {
|
|
1263
|
+
return new Observable((observer) => {
|
|
1264
|
+
let count = 0;
|
|
1265
|
+
const id = setInterval(() => {
|
|
1266
|
+
observer.next(count++);
|
|
1267
|
+
}, ms);
|
|
1268
|
+
return () => clearInterval(id);
|
|
1269
|
+
});
|
|
1270
|
+
}
|
|
1271
|
+
function of(...values) {
|
|
1272
|
+
return new Observable((observer) => {
|
|
1273
|
+
values.forEach((value) => observer.next(value));
|
|
1274
|
+
observer.complete?.();
|
|
1275
|
+
});
|
|
1276
|
+
}
|
|
1277
|
+
function observable(producer) {
|
|
1278
|
+
return new Observable(producer);
|
|
1279
|
+
}
|
|
1280
|
+
function toSignal(obs, instance) {
|
|
1281
|
+
const sig = signal(void 0);
|
|
1282
|
+
const subst = obs.subscribe((val) => {
|
|
1283
|
+
sig.value = val;
|
|
1284
|
+
});
|
|
1285
|
+
instance.__drop = [...instance.__drop ?? [], () => subst.unsubscribe()];
|
|
1286
|
+
return sig;
|
|
1287
|
+
}
|
|
1288
|
+
function isObservable(value) {
|
|
1289
|
+
return value && value.__isObservable === true;
|
|
1290
|
+
}
|
|
1291
|
+
|
|
1292
|
+
// src/shared/component.ts
|
|
1293
|
+
var OrcaComponent = class {
|
|
1294
|
+
constructor() {
|
|
1295
|
+
this.__cleanup = [];
|
|
1296
|
+
}
|
|
1297
|
+
onDestory() {
|
|
1298
|
+
this.__cleanup.forEach((cb) => cb());
|
|
1299
|
+
}
|
|
1300
|
+
pushDrop(fn) {
|
|
1301
|
+
this.__cleanup.push(fn);
|
|
1302
|
+
}
|
|
1303
|
+
};
|
|
1304
|
+
|
|
1305
|
+
// src/shared/module_libs/router_module/navigate.ts
|
|
1306
|
+
var __decorate = function(decorators, target, key, desc) {
|
|
1307
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1308
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1309
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
1310
|
+
else
|
|
1311
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
1312
|
+
if (d = decorators[i])
|
|
1313
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1314
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1315
|
+
};
|
|
1316
|
+
var __metadata = function(k, v) {
|
|
1317
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
1318
|
+
return Reflect.metadata(k, v);
|
|
1319
|
+
};
|
|
1320
|
+
var __param = function(paramIndex, decorator) {
|
|
1321
|
+
return function(target, key) {
|
|
1322
|
+
decorator(target, key, paramIndex);
|
|
1323
|
+
};
|
|
1324
|
+
};
|
|
1325
|
+
var Navigate = class Navigate2 {
|
|
1326
|
+
constructor(oscUrl) {
|
|
1327
|
+
this.oscUrl = oscUrl;
|
|
1328
|
+
this.pages = from([]);
|
|
1329
|
+
this.cursor = 0;
|
|
1330
|
+
const initialState = history.state?.cursor ?? 0;
|
|
1331
|
+
this.cursor = initialState;
|
|
1332
|
+
if (!history.state) {
|
|
1333
|
+
history.replaceState({ cursor: 0 }, "");
|
|
1334
|
+
}
|
|
1335
|
+
window.addEventListener("popstate", (e) => {
|
|
1336
|
+
const newIndex = e.state?.cursor ?? 0;
|
|
1337
|
+
this.cursor = newIndex;
|
|
1338
|
+
this.pages.next([...this.pages.$value || []]);
|
|
1339
|
+
});
|
|
1340
|
+
}
|
|
1341
|
+
getHome() {
|
|
1342
|
+
const http = new HttpClient();
|
|
1343
|
+
return http.post(this.oscUrl, {
|
|
1344
|
+
stream: "ndjson",
|
|
1345
|
+
reviver: symbolValueReviver
|
|
1346
|
+
});
|
|
1347
|
+
}
|
|
1348
|
+
push(component) {
|
|
1349
|
+
const currentPages = this.pages.$value || [];
|
|
1350
|
+
const newPages = currentPages.slice(0, this.cursor + 1);
|
|
1351
|
+
this.cursor++;
|
|
1352
|
+
newPages.push(component);
|
|
1353
|
+
history.pushState({ cursor: this.cursor }, "");
|
|
1354
|
+
this.pages.next(newPages);
|
|
1355
|
+
}
|
|
1356
|
+
replace(component) {
|
|
1357
|
+
const currentPages = [...this.pages.$value || []];
|
|
1358
|
+
currentPages[this.cursor] = component;
|
|
1359
|
+
history.replaceState({ cursor: this.cursor }, "");
|
|
1360
|
+
this.pages.next(currentPages);
|
|
1361
|
+
}
|
|
1362
|
+
goBack() {
|
|
1363
|
+
if (this.cursor > 0) {
|
|
1364
|
+
history.back();
|
|
1365
|
+
}
|
|
1366
|
+
}
|
|
1367
|
+
goForward() {
|
|
1368
|
+
const currentPages = this.pages.$value || [];
|
|
1369
|
+
if (this.cursor < currentPages.length - 1) {
|
|
1370
|
+
history.forward();
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
canGoBack() {
|
|
1374
|
+
return this.cursor > 0;
|
|
1375
|
+
}
|
|
1376
|
+
canGoForward() {
|
|
1377
|
+
const currentPages = this.pages.$value || [];
|
|
1378
|
+
return this.cursor < currentPages.length - 1;
|
|
1379
|
+
}
|
|
1380
|
+
getCurrentPage() {
|
|
1381
|
+
const currentPages = this.pages.$value || [];
|
|
1382
|
+
return currentPages[this.cursor];
|
|
1383
|
+
}
|
|
1384
|
+
clear() {
|
|
1385
|
+
this.cursor = 0;
|
|
1386
|
+
this.pages.next([]);
|
|
1387
|
+
history.replaceState({ cursor: 0 }, "");
|
|
1388
|
+
}
|
|
1389
|
+
};
|
|
1390
|
+
Navigate = __decorate([
|
|
1391
|
+
__param(0, Inject("OSC_URL", { maybe: true })),
|
|
1392
|
+
__metadata("design:paramtypes", [String])
|
|
1393
|
+
], Navigate);
|
|
1394
|
+
|
|
1395
|
+
// src/shared/module_libs/router_module/outlet.ts
|
|
1396
|
+
var __decorate2 = function(decorators, target, key, desc) {
|
|
1397
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1398
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1399
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
1400
|
+
else
|
|
1401
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
1402
|
+
if (d = decorators[i])
|
|
1403
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1404
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1405
|
+
};
|
|
1406
|
+
var __metadata2 = function(k, v) {
|
|
1407
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
1408
|
+
return Reflect.metadata(k, v);
|
|
1409
|
+
};
|
|
1410
|
+
var _a;
|
|
1411
|
+
var RouterOutlet = class RouterOutlet2 extends OrcaComponent {
|
|
1412
|
+
constructor(navigate) {
|
|
1413
|
+
super();
|
|
1414
|
+
this.navigate = navigate;
|
|
1415
|
+
}
|
|
1416
|
+
build() {
|
|
1417
|
+
const anchor = document.createElement("div");
|
|
1418
|
+
const root = document.createElement("div");
|
|
1419
|
+
anchor.appendChild(root);
|
|
1420
|
+
const osc = new OSC(root);
|
|
1421
|
+
const stream = this.navigate.getHome();
|
|
1422
|
+
const streamSubscription = stream.subscribe((jsx2) => {
|
|
1423
|
+
const action = jsx2.action || "insert";
|
|
1424
|
+
if (action === "insert") {
|
|
1425
|
+
osc.handleInsert(jsx2);
|
|
1426
|
+
} else if (action === "update") {
|
|
1427
|
+
osc.handleUpdate(jsx2);
|
|
1428
|
+
} else {
|
|
1429
|
+
console.warn(`Unknown action: ${action}`);
|
|
1430
|
+
}
|
|
1431
|
+
}, () => {
|
|
1432
|
+
}, () => {
|
|
1433
|
+
this.navigate.pages.setValue([osc.tree.dom]);
|
|
1434
|
+
});
|
|
1435
|
+
const subscription = this.navigate.pages.subscribe((pages) => {
|
|
1436
|
+
const top = pages[this.navigate.cursor];
|
|
1437
|
+
anchor.replaceChildren(top);
|
|
1438
|
+
});
|
|
1439
|
+
this.pushDrop(() => subscription.unsubscribe());
|
|
1440
|
+
this.pushDrop(() => streamSubscription.unsubscribe());
|
|
1441
|
+
return anchor;
|
|
1442
|
+
}
|
|
1443
|
+
};
|
|
1444
|
+
RouterOutlet = __decorate2([
|
|
1445
|
+
Component(),
|
|
1446
|
+
__metadata2("design:paramtypes", [typeof (_a = typeof Navigate !== "undefined" && Navigate) === "function" ? _a : Object])
|
|
1447
|
+
], RouterOutlet);
|
|
1448
|
+
|
|
1449
|
+
// src/shared/module_libs/router_module/module.ts
|
|
1450
|
+
var RouterModule = class _RouterModule {
|
|
1451
|
+
static forRoot() {
|
|
1452
|
+
return {
|
|
1453
|
+
module: _RouterModule,
|
|
1454
|
+
declarations: [RouterOutlet],
|
|
1455
|
+
providers: [Navigate],
|
|
1456
|
+
exports: [Navigate, RouterOutlet]
|
|
1457
|
+
};
|
|
1458
|
+
}
|
|
1459
|
+
};
|
|
1460
|
+
|
|
1461
|
+
// src/shared/module_libs/http_client/module.ts
|
|
1462
|
+
var __decorate3 = function(decorators, target, key, desc) {
|
|
1463
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1464
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1465
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
1466
|
+
else
|
|
1467
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
1468
|
+
if (d = decorators[i])
|
|
1469
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1470
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1471
|
+
};
|
|
1472
|
+
var HttpClient = class HttpClient2 {
|
|
1473
|
+
get(url, { stream = "json", reviver, init } = {}) {
|
|
1474
|
+
return new Observable((subscriber) => {
|
|
1475
|
+
const controller = new AbortController();
|
|
1476
|
+
fetch(url, {
|
|
1477
|
+
method: "GET",
|
|
1478
|
+
...init,
|
|
1479
|
+
signal: controller.signal
|
|
1480
|
+
}).then(async (res) => {
|
|
1481
|
+
if (!res.ok) {
|
|
1482
|
+
throw new Error(`HTTP ${res.status}: ${res.statusText}`);
|
|
1483
|
+
}
|
|
1484
|
+
if (stream === "json") {
|
|
1485
|
+
const data = await res.json();
|
|
1486
|
+
subscriber.next(reviver ? JSON.parse(JSON.stringify(data), reviver) : data);
|
|
1487
|
+
subscriber.complete?.();
|
|
1488
|
+
return;
|
|
1489
|
+
}
|
|
1490
|
+
if (stream === "raw") {
|
|
1491
|
+
subscriber.next(res);
|
|
1492
|
+
subscriber.complete?.();
|
|
1493
|
+
return;
|
|
1494
|
+
}
|
|
1495
|
+
const reader = res.body?.getReader();
|
|
1496
|
+
if (!reader) {
|
|
1497
|
+
throw new Error("ReadableStream not supported");
|
|
1498
|
+
}
|
|
1499
|
+
const decoder = new TextDecoder();
|
|
1500
|
+
let buffer = "";
|
|
1501
|
+
while (true) {
|
|
1502
|
+
const { done, value } = await reader.read();
|
|
1503
|
+
if (done) {
|
|
1504
|
+
if (stream === "ndjson" && buffer.trim()) {
|
|
1505
|
+
try {
|
|
1506
|
+
subscriber.next(JSON.parse(buffer, reviver));
|
|
1507
|
+
} catch (err) {
|
|
1508
|
+
console.warn("Failed to parse remaining buffer:", err);
|
|
1509
|
+
}
|
|
1510
|
+
}
|
|
1511
|
+
break;
|
|
1512
|
+
}
|
|
1513
|
+
const chunk = decoder.decode(value, { stream: true });
|
|
1514
|
+
if (stream === "text") {
|
|
1515
|
+
subscriber.next(chunk);
|
|
1516
|
+
continue;
|
|
1517
|
+
}
|
|
1518
|
+
if (stream === "ndjson") {
|
|
1519
|
+
buffer += chunk;
|
|
1520
|
+
const lines = buffer.split("\n");
|
|
1521
|
+
buffer = lines.pop();
|
|
1522
|
+
for (const line of lines) {
|
|
1523
|
+
if (line.trim()) {
|
|
1524
|
+
try {
|
|
1525
|
+
subscriber.next(JSON.parse(line, reviver));
|
|
1526
|
+
} catch (err) {
|
|
1527
|
+
console.error("Failed to parse NDJSON line:", line, err);
|
|
1528
|
+
}
|
|
1529
|
+
}
|
|
1530
|
+
}
|
|
1531
|
+
}
|
|
1532
|
+
}
|
|
1533
|
+
subscriber.complete?.();
|
|
1534
|
+
}).catch((err) => {
|
|
1535
|
+
if (err.name === "AbortError") {
|
|
1536
|
+
console.log("Request aborted");
|
|
1537
|
+
}
|
|
1538
|
+
subscriber.error?.(err);
|
|
1539
|
+
});
|
|
1540
|
+
return () => {
|
|
1541
|
+
controller.abort();
|
|
1542
|
+
};
|
|
1543
|
+
});
|
|
1544
|
+
}
|
|
1545
|
+
post(url, { body, stream = "json", reviver, init } = {}) {
|
|
1546
|
+
const headers = new Headers(init?.headers);
|
|
1547
|
+
if (body && !headers.has("Content-Type")) {
|
|
1548
|
+
headers.set("Content-Type", "application/json");
|
|
1549
|
+
}
|
|
1550
|
+
const processedBody = body !== void 0 ? typeof body === "string" ? body : JSON.stringify(body) : void 0;
|
|
1551
|
+
return this.get(url, {
|
|
1552
|
+
stream,
|
|
1553
|
+
reviver,
|
|
1554
|
+
init: {
|
|
1555
|
+
...init,
|
|
1556
|
+
method: "POST",
|
|
1557
|
+
headers,
|
|
1558
|
+
body: processedBody
|
|
1559
|
+
}
|
|
1560
|
+
});
|
|
1561
|
+
}
|
|
1562
|
+
put(url, options) {
|
|
1563
|
+
return this.request(url, "PUT", options);
|
|
1564
|
+
}
|
|
1565
|
+
patch(url, options) {
|
|
1566
|
+
return this.request(url, "PATCH", options);
|
|
1567
|
+
}
|
|
1568
|
+
delete(url, options) {
|
|
1569
|
+
return this.get(url, {
|
|
1570
|
+
...options,
|
|
1571
|
+
init: {
|
|
1572
|
+
...options?.init,
|
|
1573
|
+
method: "DELETE"
|
|
1574
|
+
}
|
|
1575
|
+
});
|
|
1576
|
+
}
|
|
1577
|
+
request(url, method, { body, stream = "json", reviver, init } = {}) {
|
|
1578
|
+
const headers = new Headers(init?.headers);
|
|
1579
|
+
if (body && !headers.has("Content-Type")) {
|
|
1580
|
+
headers.set("Content-Type", "application/json");
|
|
1581
|
+
}
|
|
1582
|
+
const processedBody = body !== void 0 ? typeof body === "string" ? body : JSON.stringify(body) : void 0;
|
|
1583
|
+
return this.get(url, {
|
|
1584
|
+
stream,
|
|
1585
|
+
reviver,
|
|
1586
|
+
init: {
|
|
1587
|
+
...init,
|
|
1588
|
+
method,
|
|
1589
|
+
headers,
|
|
1590
|
+
body: processedBody
|
|
1591
|
+
}
|
|
1592
|
+
});
|
|
1593
|
+
}
|
|
1594
|
+
};
|
|
1595
|
+
HttpClient = __decorate3([
|
|
1596
|
+
Injectable()
|
|
1597
|
+
], HttpClient);
|
|
1598
|
+
var HttpClientModule = class HttpClientModule2 {
|
|
1599
|
+
};
|
|
1600
|
+
HttpClientModule = __decorate3([
|
|
1601
|
+
Module({
|
|
1602
|
+
providers: [HttpClient],
|
|
1603
|
+
exports: [HttpClient]
|
|
1604
|
+
})
|
|
1605
|
+
], HttpClientModule);
|
|
1606
|
+
|
|
1607
|
+
// src/shared/dom/osc.ts
|
|
1608
|
+
var OSC = class {
|
|
1609
|
+
constructor(root) {
|
|
1610
|
+
this.root = root;
|
|
1611
|
+
this.pendingRefs = /* @__PURE__ */ new Map();
|
|
1612
|
+
this.tree = new VNode(root, (old, nw) => {
|
|
1613
|
+
old.replaceChildren(nw);
|
|
1614
|
+
});
|
|
1615
|
+
}
|
|
1616
|
+
handleInsert(jsx2) {
|
|
1617
|
+
const { domNode, vnode } = this.buildDOM(jsx2, this.tree);
|
|
1618
|
+
if (jsx2.id && vnode) {
|
|
1619
|
+
vnode.setId(jsx2.id);
|
|
1620
|
+
}
|
|
1621
|
+
this.tree.attach(domNode);
|
|
1622
|
+
}
|
|
1623
|
+
handleUpdate(jsx2) {
|
|
1624
|
+
if (!jsx2.id) {
|
|
1625
|
+
console.warn("Update action requires an id");
|
|
1626
|
+
return;
|
|
1627
|
+
}
|
|
1628
|
+
const targetVNode = this.tree.findById(jsx2.id);
|
|
1629
|
+
if (targetVNode) {
|
|
1630
|
+
const oldChildren = [...targetVNode.children];
|
|
1631
|
+
targetVNode.children = [];
|
|
1632
|
+
const { domNode, vnode } = this.buildDOM(
|
|
1633
|
+
jsx2,
|
|
1634
|
+
targetVNode.parent || this.tree
|
|
1635
|
+
);
|
|
1636
|
+
targetVNode.attach(domNode);
|
|
1637
|
+
if (vnode) {
|
|
1638
|
+
targetVNode.children = vnode.children;
|
|
1639
|
+
}
|
|
1640
|
+
} else {
|
|
1641
|
+
console.warn(`Update target ${jsx2.id} not found, inserting instead`);
|
|
1642
|
+
this.handleInsert(jsx2);
|
|
1643
|
+
}
|
|
1644
|
+
}
|
|
1645
|
+
buildDOM(jsx2, vparent) {
|
|
1646
|
+
if (jsx2 == null) {
|
|
1647
|
+
return { domNode: document.createDocumentFragment() };
|
|
1648
|
+
}
|
|
1649
|
+
if (Array.isArray(jsx2)) {
|
|
1650
|
+
return this.buildArray(jsx2, vparent);
|
|
1651
|
+
}
|
|
1652
|
+
if (this.isPrimitive(jsx2)) {
|
|
1653
|
+
return this.buildTextNode(String(jsx2), vparent);
|
|
1654
|
+
}
|
|
1655
|
+
if (jsx2.$$typeof === PENDING_REFERENCE_TYPE) {
|
|
1656
|
+
return this.buildPendingReference(jsx2, vparent);
|
|
1657
|
+
}
|
|
1658
|
+
if (jsx2.$$typeof === ORCA_CLIENT_COMPONENT) {
|
|
1659
|
+
return this.buildClientComponent(jsx2, vparent);
|
|
1660
|
+
}
|
|
1661
|
+
if (isIntrinsicElement(jsx2)) {
|
|
1662
|
+
return this.buildIntrinsicElement(jsx2, vparent);
|
|
1663
|
+
}
|
|
1664
|
+
console.error("Unsupported node:", jsx2);
|
|
1665
|
+
throw new Error(
|
|
1666
|
+
`Unsupported node type: ${typeof jsx2}, $typeof: ${String(jsx2.$$typeof)}`
|
|
1667
|
+
);
|
|
1668
|
+
}
|
|
1669
|
+
buildClientComponent(jsx2, parent) {
|
|
1670
|
+
const componentInfo = jsx2.props.__clientComponent;
|
|
1671
|
+
const { id, path, name } = componentInfo;
|
|
1672
|
+
const container = document.createElement("div");
|
|
1673
|
+
container.dataset.clientComponent = id;
|
|
1674
|
+
const vnode = new VNode(container, (old, nw) => {
|
|
1675
|
+
if (old.parentNode) {
|
|
1676
|
+
old.parentNode.replaceChild(nw, old);
|
|
1677
|
+
}
|
|
1678
|
+
});
|
|
1679
|
+
if (jsx2.id) {
|
|
1680
|
+
vnode.setId(jsx2.id);
|
|
1681
|
+
}
|
|
1682
|
+
parent.addChild(vnode);
|
|
1683
|
+
this.loadClientComponent(path, name, jsx2.props, container, vnode);
|
|
1684
|
+
return { domNode: container, vnode };
|
|
1685
|
+
}
|
|
1686
|
+
buildPendingReference(jsx2, parent) {
|
|
1687
|
+
const refId = jsx2.id;
|
|
1688
|
+
const div = document.createElement("div");
|
|
1689
|
+
div.dataset.ref = refId;
|
|
1690
|
+
div.className = "loading";
|
|
1691
|
+
div.textContent = "Loading...";
|
|
1692
|
+
const vnode = new VNode(div, (old, nw) => {
|
|
1693
|
+
if (old.parentNode) {
|
|
1694
|
+
old.parentNode.replaceChild(nw, old);
|
|
1695
|
+
}
|
|
1696
|
+
});
|
|
1697
|
+
vnode.setId(refId);
|
|
1698
|
+
parent.addChild(vnode);
|
|
1699
|
+
const pendingContent = this.pendingRefs.get(refId);
|
|
1700
|
+
if (pendingContent) {
|
|
1701
|
+
setTimeout(() => this.resolvePendingReference(refId, pendingContent), 0);
|
|
1702
|
+
}
|
|
1703
|
+
return { domNode: div, vnode };
|
|
1704
|
+
}
|
|
1705
|
+
resolvePendingReference(refId, content) {
|
|
1706
|
+
const vnode = this.tree.findById(refId);
|
|
1707
|
+
if (!vnode) {
|
|
1708
|
+
console.warn(`Reference ${refId} not found`);
|
|
1709
|
+
this.pendingRefs.set(refId, content);
|
|
1710
|
+
return;
|
|
1711
|
+
}
|
|
1712
|
+
try {
|
|
1713
|
+
vnode.children = [];
|
|
1714
|
+
const { domNode, vnode: newVNode } = this.buildDOM(content, vnode);
|
|
1715
|
+
vnode.attach(domNode);
|
|
1716
|
+
if (newVNode) {
|
|
1717
|
+
vnode.children = newVNode.children;
|
|
1718
|
+
}
|
|
1719
|
+
this.pendingRefs.delete(refId);
|
|
1720
|
+
} catch (error) {
|
|
1721
|
+
console.error(`Error resolving reference ${refId}:`, error);
|
|
1722
|
+
}
|
|
1723
|
+
}
|
|
1724
|
+
buildTextNode(text, parent) {
|
|
1725
|
+
const textNode = document.createTextNode(text);
|
|
1726
|
+
const vnode = new VNode(textNode, (old, nw) => {
|
|
1727
|
+
if (old.parentNode) {
|
|
1728
|
+
old.parentNode.replaceChild(nw, old);
|
|
1729
|
+
}
|
|
1730
|
+
});
|
|
1731
|
+
parent.addChild(vnode);
|
|
1732
|
+
return { domNode: textNode, vnode };
|
|
1733
|
+
}
|
|
1734
|
+
isPrimitive(node) {
|
|
1735
|
+
return typeof node === "string" || typeof node === "number" || typeof node === "boolean";
|
|
1736
|
+
}
|
|
1737
|
+
buildArray(nodes, parent) {
|
|
1738
|
+
const fragment = document.createDocumentFragment();
|
|
1739
|
+
const vnodes = [];
|
|
1740
|
+
nodes.forEach((child) => {
|
|
1741
|
+
const { domNode, vnode } = this.buildDOM(child, parent);
|
|
1742
|
+
fragment.appendChild(domNode);
|
|
1743
|
+
if (vnode) {
|
|
1744
|
+
vnodes.push(vnode);
|
|
1745
|
+
}
|
|
1746
|
+
});
|
|
1747
|
+
return { domNode: fragment };
|
|
1748
|
+
}
|
|
1749
|
+
buildIntrinsicElement(jsx2, parent) {
|
|
1750
|
+
const tag = jsx2.type;
|
|
1751
|
+
const dom = document.createElement(tag);
|
|
1752
|
+
const vnode = new VNode(dom, (old, nw) => {
|
|
1753
|
+
if (old.parentNode) {
|
|
1754
|
+
old.parentNode.replaceChild(nw, old);
|
|
1755
|
+
}
|
|
1756
|
+
});
|
|
1757
|
+
parent.addChild(vnode);
|
|
1758
|
+
if (jsx2.id) {
|
|
1759
|
+
vnode.setId(jsx2.id);
|
|
1760
|
+
}
|
|
1761
|
+
if (jsx2.props) {
|
|
1762
|
+
this.buildAttributes(jsx2.props, dom, vnode);
|
|
1763
|
+
}
|
|
1764
|
+
if (jsx2.props?.children != null) {
|
|
1765
|
+
const { domNode: childDom } = this.buildDOM(jsx2.props.children, vnode);
|
|
1766
|
+
dom.appendChild(childDom);
|
|
1767
|
+
}
|
|
1768
|
+
return { domNode: dom, vnode };
|
|
1769
|
+
}
|
|
1770
|
+
buildAttributes(props, dom, vnode) {
|
|
1771
|
+
for (const [key, value] of Object.entries(props)) {
|
|
1772
|
+
if (key === "children" || value == null) {
|
|
1773
|
+
continue;
|
|
1774
|
+
}
|
|
1775
|
+
const attrKey = this.normalizeAttributeKey(key);
|
|
1776
|
+
if (attrKey === "style" && typeof value === "object") {
|
|
1777
|
+
this.applyStyles(value, dom);
|
|
1778
|
+
continue;
|
|
1779
|
+
}
|
|
1780
|
+
if (typeof value === "boolean") {
|
|
1781
|
+
this.setBooleanAttribute(attrKey, value, dom);
|
|
1782
|
+
continue;
|
|
1783
|
+
}
|
|
1784
|
+
dom.setAttribute(attrKey, String(value));
|
|
1785
|
+
}
|
|
1786
|
+
}
|
|
1787
|
+
normalizeAttributeKey(key) {
|
|
1788
|
+
if (key === "className")
|
|
1789
|
+
return "class";
|
|
1790
|
+
if (key === "htmlFor")
|
|
1791
|
+
return "for";
|
|
1792
|
+
return key;
|
|
1793
|
+
}
|
|
1794
|
+
applyStyles(styles, dom) {
|
|
1795
|
+
const styleString = Object.entries(styles).map(([k, v]) => {
|
|
1796
|
+
const kebabKey = k.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
|
|
1797
|
+
return `${kebabKey}:${v}`;
|
|
1798
|
+
}).join(";");
|
|
1799
|
+
dom.setAttribute("style", styleString);
|
|
1800
|
+
}
|
|
1801
|
+
setBooleanAttribute(key, value, dom) {
|
|
1802
|
+
if (value) {
|
|
1803
|
+
dom.setAttribute(key, "");
|
|
1804
|
+
} else {
|
|
1805
|
+
dom.removeAttribute(key);
|
|
1806
|
+
}
|
|
1807
|
+
}
|
|
1808
|
+
async loadClientComponent(path, name, props, container, vnode) {
|
|
1809
|
+
try {
|
|
1810
|
+
const module = await import(path);
|
|
1811
|
+
const ComponentClass = module[name];
|
|
1812
|
+
const params = Reflect.getMetadata(DESIGN_PARAMTYPES, ComponentClass) || [];
|
|
1813
|
+
const injector = getCurrentInjector();
|
|
1814
|
+
if (injector == null) {
|
|
1815
|
+
throw new Error(`Couldn't find an injector`);
|
|
1816
|
+
}
|
|
1817
|
+
if (!ComponentClass) {
|
|
1818
|
+
throw new Error(`Component ${name} not found in ${path}`);
|
|
1819
|
+
}
|
|
1820
|
+
[...params, ComponentClass].forEach((p) => injector.addProvider(p));
|
|
1821
|
+
const cleanProps = { ...props };
|
|
1822
|
+
delete cleanProps.__clientComponent;
|
|
1823
|
+
const componentInstance = injector.resolve(ComponentClass);
|
|
1824
|
+
componentInstance.__injector = injector;
|
|
1825
|
+
componentInstance.props = cleanProps;
|
|
1826
|
+
if (typeof componentInstance.build === "function") {
|
|
1827
|
+
const rendered = componentInstance.build();
|
|
1828
|
+
container.parentNode?.replaceChild(rendered, container);
|
|
1829
|
+
} else {
|
|
1830
|
+
throw new Error(`Component ${name} does not have a build method`);
|
|
1831
|
+
}
|
|
1832
|
+
} catch (error) {
|
|
1833
|
+
console.error(`Failed to load client component ${name}:`, error);
|
|
1834
|
+
container.textContent = `Error loading component: ${name}`;
|
|
1835
|
+
container.className = "client-component-error";
|
|
1836
|
+
}
|
|
1837
|
+
}
|
|
1838
|
+
};
|
|
1839
|
+
|
|
1840
|
+
// src/shared/macros/index.ts
|
|
1841
|
+
function assert$(context) {
|
|
1842
|
+
return context?.factory.createStringLiteral("assert");
|
|
1843
|
+
}
|
|
1844
|
+
|
|
1845
|
+
// src/browser/index.ts
|
|
1846
|
+
var browser_exports = {};
|
|
1847
|
+
__export(browser_exports, {
|
|
1848
|
+
BrowserFactory: () => BrowserFactory,
|
|
1849
|
+
createComponent: () => createComponent,
|
|
1850
|
+
insert: () => insert,
|
|
1851
|
+
spread: () => spread,
|
|
1852
|
+
style: () => style
|
|
1853
|
+
});
|
|
1854
|
+
|
|
1855
|
+
// src/browser/factory.ts
|
|
1856
|
+
var BrowserFactory = class {
|
|
1857
|
+
static create(rootModule, rootElement) {
|
|
1858
|
+
const compiler = new Compiler();
|
|
1859
|
+
const appNode = compiler.compile(rootModule);
|
|
1860
|
+
const validation = compiler.validate(appNode);
|
|
1861
|
+
if (!validation.valid) {
|
|
1862
|
+
throw new Error(
|
|
1863
|
+
"\u274C Validation failed:\n" + validation.errors.join("\n\n")
|
|
1864
|
+
);
|
|
1865
|
+
}
|
|
1866
|
+
const allProviders = collectAllProvidersFromNode(appNode);
|
|
1867
|
+
const rootInjector = new Injector([
|
|
1868
|
+
...allProviders,
|
|
1869
|
+
{
|
|
1870
|
+
provide: "OSC_URL",
|
|
1871
|
+
useValue: "/osc"
|
|
1872
|
+
}
|
|
1873
|
+
]);
|
|
1874
|
+
setCurrentInjector(rootInjector);
|
|
1875
|
+
appNode.traverse((node) => {
|
|
1876
|
+
const providers = [...node.getProviders().values()];
|
|
1877
|
+
providers.filter((provider) => provider.eager).forEach((p) => rootInjector.resolve(p.provide));
|
|
1878
|
+
});
|
|
1879
|
+
const bootstrap = Reflect.getMetadata(BOOTSTRAP, rootModule);
|
|
1880
|
+
const instance = rootInjector.resolve(bootstrap);
|
|
1881
|
+
instance.__injector = rootInjector;
|
|
1882
|
+
const childDom = instance.build();
|
|
1883
|
+
rootElement.appendChild(childDom);
|
|
1884
|
+
}
|
|
1885
|
+
};
|
|
1886
|
+
|
|
1887
|
+
// src/browser/dom/dom.ts
|
|
1888
|
+
var elementEffects = /* @__PURE__ */ new WeakMap();
|
|
1889
|
+
var cleanupObserver = new MutationObserver((mutations) => {
|
|
1890
|
+
mutations.forEach((mutation) => {
|
|
1891
|
+
mutation.removedNodes.forEach((node) => {
|
|
1892
|
+
cleanupElement(node);
|
|
1893
|
+
});
|
|
1894
|
+
});
|
|
1895
|
+
});
|
|
1896
|
+
if (typeof document !== "undefined" && document.body) {
|
|
1897
|
+
cleanupObserver.observe(document.body, {
|
|
1898
|
+
childList: true,
|
|
1899
|
+
subtree: true
|
|
1900
|
+
});
|
|
1901
|
+
} else if (typeof document !== "undefined") {
|
|
1902
|
+
document.addEventListener("DOMContentLoaded", () => {
|
|
1903
|
+
cleanupObserver.observe(document.body, {
|
|
1904
|
+
childList: true,
|
|
1905
|
+
subtree: true
|
|
1906
|
+
});
|
|
1907
|
+
});
|
|
1908
|
+
}
|
|
1909
|
+
function cleanupElement(node) {
|
|
1910
|
+
const cleanups = elementEffects.get(node);
|
|
1911
|
+
if (cleanups) {
|
|
1912
|
+
cleanups.forEach((cleanup, idx) => {
|
|
1913
|
+
cleanup();
|
|
1914
|
+
});
|
|
1915
|
+
elementEffects.delete(node);
|
|
1916
|
+
}
|
|
1917
|
+
if (node.childNodes && node.childNodes.length > 0) {
|
|
1918
|
+
node.childNodes.forEach((child) => cleanupElement(child));
|
|
1919
|
+
}
|
|
1920
|
+
}
|
|
1921
|
+
function registerEffect(el, cleanup) {
|
|
1922
|
+
if (!elementEffects.has(el)) {
|
|
1923
|
+
elementEffects.set(el, []);
|
|
1924
|
+
}
|
|
1925
|
+
elementEffects.get(el).push(cleanup);
|
|
1926
|
+
}
|
|
1927
|
+
function buildDOM(value) {
|
|
1928
|
+
if (value instanceof Node) {
|
|
1929
|
+
return value;
|
|
1930
|
+
}
|
|
1931
|
+
if (typeof value === "string" || typeof value === "number") {
|
|
1932
|
+
return document.createTextNode(String(value));
|
|
1933
|
+
}
|
|
1934
|
+
if (value == null || typeof value === "boolean") {
|
|
1935
|
+
return document.createTextNode("");
|
|
1936
|
+
}
|
|
1937
|
+
if (Array.isArray(value)) {
|
|
1938
|
+
const fragment = document.createDocumentFragment();
|
|
1939
|
+
for (const item of value) {
|
|
1940
|
+
const node = buildDOM(item);
|
|
1941
|
+
fragment.appendChild(node);
|
|
1942
|
+
}
|
|
1943
|
+
return fragment;
|
|
1944
|
+
}
|
|
1945
|
+
console.log("Unhandled value:", value);
|
|
1946
|
+
throw new Error(`Cannot build DOM from value: ${value}`);
|
|
1947
|
+
}
|
|
1948
|
+
function insert(parent, value) {
|
|
1949
|
+
if (value == null)
|
|
1950
|
+
return;
|
|
1951
|
+
let currentDOM;
|
|
1952
|
+
function attach(value2) {
|
|
1953
|
+
const newDOM = buildDOM(value2);
|
|
1954
|
+
if (currentDOM) {
|
|
1955
|
+
if (Array.isArray(currentDOM)) {
|
|
1956
|
+
currentDOM.forEach((node) => {
|
|
1957
|
+
if (node.parentNode) {
|
|
1958
|
+
node.parentNode.removeChild(node);
|
|
1959
|
+
}
|
|
1960
|
+
});
|
|
1961
|
+
} else {
|
|
1962
|
+
if (currentDOM.parentNode) {
|
|
1963
|
+
currentDOM.parentNode.removeChild(currentDOM);
|
|
1964
|
+
}
|
|
1965
|
+
}
|
|
1966
|
+
}
|
|
1967
|
+
if (newDOM instanceof DocumentFragment) {
|
|
1968
|
+
const nodes = Array.from(newDOM.childNodes);
|
|
1969
|
+
parent.appendChild(newDOM);
|
|
1970
|
+
currentDOM = nodes;
|
|
1971
|
+
} else {
|
|
1972
|
+
parent.appendChild(newDOM);
|
|
1973
|
+
currentDOM = newDOM;
|
|
1974
|
+
}
|
|
1975
|
+
}
|
|
1976
|
+
if (isSignal(value)) {
|
|
1977
|
+
const cleanup = effect(() => {
|
|
1978
|
+
attach(value.value);
|
|
1979
|
+
});
|
|
1980
|
+
registerEffect(parent, cleanup);
|
|
1981
|
+
} else if (isObservable(value)) {
|
|
1982
|
+
const obs = value;
|
|
1983
|
+
const subst = obs.subscribe((val) => {
|
|
1984
|
+
attach(val);
|
|
1985
|
+
});
|
|
1986
|
+
registerEffect(parent, () => subst.unsubscribe());
|
|
1987
|
+
} else if (typeof value == "function") {
|
|
1988
|
+
const cleanup = effect(() => {
|
|
1989
|
+
attach(value());
|
|
1990
|
+
});
|
|
1991
|
+
registerEffect(parent, cleanup);
|
|
1992
|
+
} else {
|
|
1993
|
+
const node = buildDOM(value);
|
|
1994
|
+
parent.appendChild(node);
|
|
1995
|
+
}
|
|
1996
|
+
}
|
|
1997
|
+
function autoCleanup(element, callback) {
|
|
1998
|
+
const observer = new MutationObserver(() => {
|
|
1999
|
+
if (!document.contains(element)) {
|
|
2000
|
+
callback();
|
|
2001
|
+
observer.disconnect();
|
|
2002
|
+
}
|
|
2003
|
+
});
|
|
2004
|
+
setTimeout(() => {
|
|
2005
|
+
if (element.parentNode) {
|
|
2006
|
+
observer.observe(document.body, { childList: true, subtree: true });
|
|
2007
|
+
}
|
|
2008
|
+
}, 0);
|
|
2009
|
+
}
|
|
2010
|
+
function createComponent(ComponentClass, props = {}, parentComponent) {
|
|
2011
|
+
let injector = parentComponent.__injector;
|
|
2012
|
+
if (!injector) {
|
|
2013
|
+
throw new Error(`Cannot create component ${ComponentClass.name} outside injection context. No injector available from current context or parent component.`);
|
|
2014
|
+
}
|
|
2015
|
+
const isComponent = Reflect.getMetadata(COMPONENT, ComponentClass);
|
|
2016
|
+
if (!isComponent) {
|
|
2017
|
+
throw new Error(`${ComponentClass.name} is not decorated with @Component()`);
|
|
2018
|
+
}
|
|
2019
|
+
let instance;
|
|
2020
|
+
try {
|
|
2021
|
+
instance = injector.resolve(ComponentClass);
|
|
2022
|
+
} catch (e) {
|
|
2023
|
+
injector.addProvider(ComponentClass);
|
|
2024
|
+
instance = injector.resolve(ComponentClass);
|
|
2025
|
+
}
|
|
2026
|
+
const localProviders = Reflect.getMetadata(COMPONENT_PROVIDERS, ComponentClass) || [];
|
|
2027
|
+
if (localProviders.length > 0) {
|
|
2028
|
+
injector = new Injector(localProviders.map((p) => ProviderNormalizer.normalize(p)), parentComponent.__injector);
|
|
2029
|
+
instance.__injector = injector;
|
|
2030
|
+
}
|
|
2031
|
+
instance.props = props;
|
|
2032
|
+
const root = instance.build();
|
|
2033
|
+
if (!(root instanceof Node)) {
|
|
2034
|
+
throw new Error("Root is not instance of node");
|
|
2035
|
+
}
|
|
2036
|
+
const cleanup = () => {
|
|
2037
|
+
instance.__cleanup?.forEach((cb) => cb());
|
|
2038
|
+
instance.onDestory?.();
|
|
2039
|
+
};
|
|
2040
|
+
if (root.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
|
|
2041
|
+
const firstChild = root.firstChild;
|
|
2042
|
+
if (firstChild) {
|
|
2043
|
+
autoCleanup(firstChild, cleanup);
|
|
2044
|
+
}
|
|
2045
|
+
} else {
|
|
2046
|
+
autoCleanup(root, cleanup);
|
|
2047
|
+
}
|
|
2048
|
+
return root;
|
|
2049
|
+
}
|
|
2050
|
+
function style(el, styleObj) {
|
|
2051
|
+
if (typeof styleObj === "function") {
|
|
2052
|
+
const cleanup = effect(() => {
|
|
2053
|
+
const styles = styleObj();
|
|
2054
|
+
if (!styles)
|
|
2055
|
+
return;
|
|
2056
|
+
for (const key in styles) {
|
|
2057
|
+
const value = styles[key];
|
|
2058
|
+
const actualValue = isSignal(value) ? value.value : value;
|
|
2059
|
+
const cssKey = key.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
|
|
2060
|
+
el.style.setProperty(cssKey, actualValue);
|
|
2061
|
+
}
|
|
2062
|
+
});
|
|
2063
|
+
registerEffect(el, cleanup);
|
|
2064
|
+
return;
|
|
2065
|
+
}
|
|
2066
|
+
if (!styleObj)
|
|
2067
|
+
return;
|
|
2068
|
+
for (const key in styleObj) {
|
|
2069
|
+
const cssKey = key.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
|
|
2070
|
+
el.style.setProperty(cssKey, styleObj[key]);
|
|
2071
|
+
}
|
|
2072
|
+
}
|
|
2073
|
+
function spread(el, attrs) {
|
|
2074
|
+
if (!attrs)
|
|
2075
|
+
return;
|
|
2076
|
+
for (const key in attrs) {
|
|
2077
|
+
const value = attrs[key];
|
|
2078
|
+
if (/^on[A-Z]/.test(key)) {
|
|
2079
|
+
const eventName = key.slice(2).toLowerCase();
|
|
2080
|
+
el.addEventListener(eventName, value);
|
|
2081
|
+
continue;
|
|
2082
|
+
}
|
|
2083
|
+
if (key === "style" && typeof value === "object") {
|
|
2084
|
+
style(el, value);
|
|
2085
|
+
continue;
|
|
2086
|
+
}
|
|
2087
|
+
const attrName = key === "className" ? "class" : key;
|
|
2088
|
+
el.setAttribute(attrName, value);
|
|
2089
|
+
}
|
|
2090
|
+
}
|
|
2091
|
+
return __toCommonJS(index_browser_exports);
|
|
2092
|
+
})();
|
|
2093
|
+
//# sourceMappingURL=index.iife.js.map
|