@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.
Files changed (101) hide show
  1. package/dist/browser/index.iife.js +2093 -0
  2. package/dist/browser/index.iife.js.map +7 -0
  3. package/dist/browser/index.mjs +3250 -0
  4. package/dist/browser/index.mjs.map +7 -0
  5. package/dist/node/index.cjs +2135 -0
  6. package/dist/node/index.cjs.map +7 -0
  7. package/dist/node/index.mjs +2028 -0
  8. package/dist/node/index.mjs.map +7 -0
  9. package/dist/types/browser/dom/dom.d.ts +6 -0
  10. package/dist/types/browser/dom/dom.d.ts.map +1 -0
  11. package/dist/types/browser/dom/index.d.ts +2 -0
  12. package/dist/types/browser/dom/index.d.ts.map +1 -0
  13. package/dist/types/browser/factory.d.ts +5 -0
  14. package/dist/types/browser/factory.d.ts.map +1 -0
  15. package/dist/types/browser/index.d.ts +3 -0
  16. package/dist/types/browser/index.d.ts.map +1 -0
  17. package/dist/types/index.browser.d.ts +20 -0
  18. package/dist/types/index.browser.d.ts.map +1 -0
  19. package/dist/types/index.d.ts +3 -0
  20. package/dist/types/index.d.ts.map +1 -0
  21. package/dist/types/index.node.d.ts +20 -0
  22. package/dist/types/index.node.d.ts.map +1 -0
  23. package/dist/types/node/factory.d.ts +6 -0
  24. package/dist/types/node/factory.d.ts.map +1 -0
  25. package/dist/types/node/index.d.ts +3 -0
  26. package/dist/types/node/index.d.ts.map +1 -0
  27. package/dist/types/node/modules/index.d.ts +2 -0
  28. package/dist/types/node/modules/index.d.ts.map +1 -0
  29. package/dist/types/node/modules/serve_static/index.d.ts +2 -0
  30. package/dist/types/node/modules/serve_static/index.d.ts.map +1 -0
  31. package/dist/types/node/modules/serve_static/serve.d.ts +9 -0
  32. package/dist/types/node/modules/serve_static/serve.d.ts.map +1 -0
  33. package/dist/types/shared/component.d.ts +11 -0
  34. package/dist/types/shared/component.d.ts.map +1 -0
  35. package/dist/types/shared/decorators.d.ts +18 -0
  36. package/dist/types/shared/decorators.d.ts.map +1 -0
  37. package/dist/types/shared/dom/index.d.ts +2 -0
  38. package/dist/types/shared/dom/index.d.ts.map +1 -0
  39. package/dist/types/shared/dom/osc.d.ts +23 -0
  40. package/dist/types/shared/dom/osc.d.ts.map +1 -0
  41. package/dist/types/shared/index.d.ts +15 -0
  42. package/dist/types/shared/index.d.ts.map +1 -0
  43. package/dist/types/shared/json.d.ts +3 -0
  44. package/dist/types/shared/json.d.ts.map +1 -0
  45. package/dist/types/shared/jsx/index.d.ts +4 -0
  46. package/dist/types/shared/jsx/index.d.ts.map +1 -0
  47. package/dist/types/shared/jsx/jsx-dev-runtime.d.ts +2 -0
  48. package/dist/types/shared/jsx/jsx-dev-runtime.d.ts.map +1 -0
  49. package/dist/types/shared/jsx/jsx-runtime.d.ts +9 -0
  50. package/dist/types/shared/jsx/jsx-runtime.d.ts.map +1 -0
  51. package/dist/types/shared/jsx/types.d.ts +193 -0
  52. package/dist/types/shared/jsx/types.d.ts.map +1 -0
  53. package/dist/types/shared/macros/index.d.ts +2 -0
  54. package/dist/types/shared/macros/index.d.ts.map +1 -0
  55. package/dist/types/shared/module/compiler.d.ts +24 -0
  56. package/dist/types/shared/module/compiler.d.ts.map +1 -0
  57. package/dist/types/shared/module/context.d.ts +4 -0
  58. package/dist/types/shared/module/context.d.ts.map +1 -0
  59. package/dist/types/shared/module/index.d.ts +5 -0
  60. package/dist/types/shared/module/index.d.ts.map +1 -0
  61. package/dist/types/shared/module/injector.d.ts +14 -0
  62. package/dist/types/shared/module/injector.d.ts.map +1 -0
  63. package/dist/types/shared/module/node.d.ts +22 -0
  64. package/dist/types/shared/module/node.d.ts.map +1 -0
  65. package/dist/types/shared/module_libs/http_client/index.d.ts +2 -0
  66. package/dist/types/shared/module_libs/http_client/index.d.ts.map +1 -0
  67. package/dist/types/shared/module_libs/http_client/module.d.ts +22 -0
  68. package/dist/types/shared/module_libs/http_client/module.d.ts.map +1 -0
  69. package/dist/types/shared/module_libs/index.d.ts +3 -0
  70. package/dist/types/shared/module_libs/index.d.ts.map +1 -0
  71. package/dist/types/shared/module_libs/router_module/index.d.ts +4 -0
  72. package/dist/types/shared/module_libs/router_module/index.d.ts.map +1 -0
  73. package/dist/types/shared/module_libs/router_module/module.d.ts +5 -0
  74. package/dist/types/shared/module_libs/router_module/module.d.ts.map +1 -0
  75. package/dist/types/shared/module_libs/router_module/navigate.d.ts +17 -0
  76. package/dist/types/shared/module_libs/router_module/navigate.d.ts.map +1 -0
  77. package/dist/types/shared/module_libs/router_module/outlet.d.ts +7 -0
  78. package/dist/types/shared/module_libs/router_module/outlet.d.ts.map +1 -0
  79. package/dist/types/shared/observable/index.d.ts +2 -0
  80. package/dist/types/shared/observable/index.d.ts.map +1 -0
  81. package/dist/types/shared/observable/observable.d.ts +31 -0
  82. package/dist/types/shared/observable/observable.d.ts.map +1 -0
  83. package/dist/types/shared/renderers/index.d.ts +4 -0
  84. package/dist/types/shared/renderers/index.d.ts.map +1 -0
  85. package/dist/types/shared/renderers/stream.d.ts +25 -0
  86. package/dist/types/shared/renderers/stream.d.ts.map +1 -0
  87. package/dist/types/shared/renderers/string.d.ts +9 -0
  88. package/dist/types/shared/renderers/string.d.ts.map +1 -0
  89. package/dist/types/shared/renderers/vnode.d.ts +15 -0
  90. package/dist/types/shared/renderers/vnode.d.ts.map +1 -0
  91. package/dist/types/shared/signal/index.d.ts +2 -0
  92. package/dist/types/shared/signal/index.d.ts.map +1 -0
  93. package/dist/types/shared/signal/signal.d.ts +6 -0
  94. package/dist/types/shared/signal/signal.d.ts.map +1 -0
  95. package/dist/types/shared/store.d.ts +9 -0
  96. package/dist/types/shared/store.d.ts.map +1 -0
  97. package/dist/types/shared/symbols.d.ts +27 -0
  98. package/dist/types/shared/symbols.d.ts.map +1 -0
  99. package/dist/types/shared/types.d.ts +67 -0
  100. package/dist/types/shared/types.d.ts.map +1 -0
  101. package/package.json +49 -0
@@ -0,0 +1,3250 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __commonJS = (cb, mod) => function __require() {
8
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
+ };
10
+ var __export = (target, all) => {
11
+ for (var name in all)
12
+ __defProp(target, name, { get: all[name], enumerable: true });
13
+ };
14
+ var __copyProps = (to, from2, except, desc) => {
15
+ if (from2 && typeof from2 === "object" || typeof from2 === "function") {
16
+ for (let key of __getOwnPropNames(from2))
17
+ if (!__hasOwnProp.call(to, key) && key !== except)
18
+ __defProp(to, key, { get: () => from2[key], enumerable: !(desc = __getOwnPropDesc(from2, key)) || desc.enumerable });
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23
+ // If the importer is in node compatibility mode or this is not an ESM
24
+ // file that has been converted to a CommonJS file using a Babel-
25
+ // compatible transform (i.e. "__esModule" has not been set), then set
26
+ // "default" to the CommonJS "module.exports" for node compatibility.
27
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
28
+ mod
29
+ ));
30
+
31
+ // node_modules/reflect-metadata/Reflect.js
32
+ var require_Reflect = __commonJS({
33
+ "node_modules/reflect-metadata/Reflect.js"() {
34
+ var Reflect2;
35
+ (function(Reflect3) {
36
+ (function(factory) {
37
+ var root = typeof globalThis === "object" ? globalThis : typeof global === "object" ? global : typeof self === "object" ? self : typeof this === "object" ? this : sloppyModeThis();
38
+ var exporter = makeExporter(Reflect3);
39
+ if (typeof root.Reflect !== "undefined") {
40
+ exporter = makeExporter(root.Reflect, exporter);
41
+ }
42
+ factory(exporter, root);
43
+ if (typeof root.Reflect === "undefined") {
44
+ root.Reflect = Reflect3;
45
+ }
46
+ function makeExporter(target, previous) {
47
+ return function(key, value) {
48
+ Object.defineProperty(target, key, { configurable: true, writable: true, value });
49
+ if (previous)
50
+ previous(key, value);
51
+ };
52
+ }
53
+ function functionThis() {
54
+ try {
55
+ return Function("return this;")();
56
+ } catch (_) {
57
+ }
58
+ }
59
+ function indirectEvalThis() {
60
+ try {
61
+ return (void 0, eval)("(function() { return this; })()");
62
+ } catch (_) {
63
+ }
64
+ }
65
+ function sloppyModeThis() {
66
+ return functionThis() || indirectEvalThis();
67
+ }
68
+ })(function(exporter, root) {
69
+ var hasOwn = Object.prototype.hasOwnProperty;
70
+ var supportsSymbol = typeof Symbol === "function";
71
+ var toPrimitiveSymbol = supportsSymbol && typeof Symbol.toPrimitive !== "undefined" ? Symbol.toPrimitive : "@@toPrimitive";
72
+ var iteratorSymbol = supportsSymbol && typeof Symbol.iterator !== "undefined" ? Symbol.iterator : "@@iterator";
73
+ var supportsCreate = typeof Object.create === "function";
74
+ var supportsProto = { __proto__: [] } instanceof Array;
75
+ var downLevel = !supportsCreate && !supportsProto;
76
+ var HashMap = {
77
+ // create an object in dictionary mode (a.k.a. "slow" mode in v8)
78
+ create: supportsCreate ? function() {
79
+ return MakeDictionary(/* @__PURE__ */ Object.create(null));
80
+ } : supportsProto ? function() {
81
+ return MakeDictionary({ __proto__: null });
82
+ } : function() {
83
+ return MakeDictionary({});
84
+ },
85
+ has: downLevel ? function(map, key) {
86
+ return hasOwn.call(map, key);
87
+ } : function(map, key) {
88
+ return key in map;
89
+ },
90
+ get: downLevel ? function(map, key) {
91
+ return hasOwn.call(map, key) ? map[key] : void 0;
92
+ } : function(map, key) {
93
+ return map[key];
94
+ }
95
+ };
96
+ var functionPrototype = Object.getPrototypeOf(Function);
97
+ var _Map = typeof Map === "function" && typeof Map.prototype.entries === "function" ? Map : CreateMapPolyfill();
98
+ var _Set = typeof Set === "function" && typeof Set.prototype.entries === "function" ? Set : CreateSetPolyfill();
99
+ var _WeakMap = typeof WeakMap === "function" ? WeakMap : CreateWeakMapPolyfill();
100
+ var registrySymbol = supportsSymbol ? Symbol.for("@reflect-metadata:registry") : void 0;
101
+ var metadataRegistry = GetOrCreateMetadataRegistry();
102
+ var metadataProvider = CreateMetadataProvider(metadataRegistry);
103
+ function decorate(decorators, target, propertyKey, attributes) {
104
+ if (!IsUndefined(propertyKey)) {
105
+ if (!IsArray(decorators))
106
+ throw new TypeError();
107
+ if (!IsObject(target))
108
+ throw new TypeError();
109
+ if (!IsObject(attributes) && !IsUndefined(attributes) && !IsNull(attributes))
110
+ throw new TypeError();
111
+ if (IsNull(attributes))
112
+ attributes = void 0;
113
+ propertyKey = ToPropertyKey(propertyKey);
114
+ return DecorateProperty(decorators, target, propertyKey, attributes);
115
+ } else {
116
+ if (!IsArray(decorators))
117
+ throw new TypeError();
118
+ if (!IsConstructor(target))
119
+ throw new TypeError();
120
+ return DecorateConstructor(decorators, target);
121
+ }
122
+ }
123
+ exporter("decorate", decorate);
124
+ function metadata(metadataKey, metadataValue) {
125
+ function decorator(target, propertyKey) {
126
+ if (!IsObject(target))
127
+ throw new TypeError();
128
+ if (!IsUndefined(propertyKey) && !IsPropertyKey(propertyKey))
129
+ throw new TypeError();
130
+ OrdinaryDefineOwnMetadata(metadataKey, metadataValue, target, propertyKey);
131
+ }
132
+ return decorator;
133
+ }
134
+ exporter("metadata", metadata);
135
+ function defineMetadata(metadataKey, metadataValue, target, propertyKey) {
136
+ if (!IsObject(target))
137
+ throw new TypeError();
138
+ if (!IsUndefined(propertyKey))
139
+ propertyKey = ToPropertyKey(propertyKey);
140
+ return OrdinaryDefineOwnMetadata(metadataKey, metadataValue, target, propertyKey);
141
+ }
142
+ exporter("defineMetadata", defineMetadata);
143
+ function hasMetadata(metadataKey, target, propertyKey) {
144
+ if (!IsObject(target))
145
+ throw new TypeError();
146
+ if (!IsUndefined(propertyKey))
147
+ propertyKey = ToPropertyKey(propertyKey);
148
+ return OrdinaryHasMetadata(metadataKey, target, propertyKey);
149
+ }
150
+ exporter("hasMetadata", hasMetadata);
151
+ function hasOwnMetadata(metadataKey, target, propertyKey) {
152
+ if (!IsObject(target))
153
+ throw new TypeError();
154
+ if (!IsUndefined(propertyKey))
155
+ propertyKey = ToPropertyKey(propertyKey);
156
+ return OrdinaryHasOwnMetadata(metadataKey, target, propertyKey);
157
+ }
158
+ exporter("hasOwnMetadata", hasOwnMetadata);
159
+ function getMetadata(metadataKey, target, propertyKey) {
160
+ if (!IsObject(target))
161
+ throw new TypeError();
162
+ if (!IsUndefined(propertyKey))
163
+ propertyKey = ToPropertyKey(propertyKey);
164
+ return OrdinaryGetMetadata(metadataKey, target, propertyKey);
165
+ }
166
+ exporter("getMetadata", getMetadata);
167
+ function getOwnMetadata(metadataKey, target, propertyKey) {
168
+ if (!IsObject(target))
169
+ throw new TypeError();
170
+ if (!IsUndefined(propertyKey))
171
+ propertyKey = ToPropertyKey(propertyKey);
172
+ return OrdinaryGetOwnMetadata(metadataKey, target, propertyKey);
173
+ }
174
+ exporter("getOwnMetadata", getOwnMetadata);
175
+ function getMetadataKeys(target, propertyKey) {
176
+ if (!IsObject(target))
177
+ throw new TypeError();
178
+ if (!IsUndefined(propertyKey))
179
+ propertyKey = ToPropertyKey(propertyKey);
180
+ return OrdinaryMetadataKeys(target, propertyKey);
181
+ }
182
+ exporter("getMetadataKeys", getMetadataKeys);
183
+ function getOwnMetadataKeys(target, propertyKey) {
184
+ if (!IsObject(target))
185
+ throw new TypeError();
186
+ if (!IsUndefined(propertyKey))
187
+ propertyKey = ToPropertyKey(propertyKey);
188
+ return OrdinaryOwnMetadataKeys(target, propertyKey);
189
+ }
190
+ exporter("getOwnMetadataKeys", getOwnMetadataKeys);
191
+ function deleteMetadata(metadataKey, target, propertyKey) {
192
+ if (!IsObject(target))
193
+ throw new TypeError();
194
+ if (!IsUndefined(propertyKey))
195
+ propertyKey = ToPropertyKey(propertyKey);
196
+ if (!IsObject(target))
197
+ throw new TypeError();
198
+ if (!IsUndefined(propertyKey))
199
+ propertyKey = ToPropertyKey(propertyKey);
200
+ var provider = GetMetadataProvider(
201
+ target,
202
+ propertyKey,
203
+ /*Create*/
204
+ false
205
+ );
206
+ if (IsUndefined(provider))
207
+ return false;
208
+ return provider.OrdinaryDeleteMetadata(metadataKey, target, propertyKey);
209
+ }
210
+ exporter("deleteMetadata", deleteMetadata);
211
+ function DecorateConstructor(decorators, target) {
212
+ for (var i = decorators.length - 1; i >= 0; --i) {
213
+ var decorator = decorators[i];
214
+ var decorated = decorator(target);
215
+ if (!IsUndefined(decorated) && !IsNull(decorated)) {
216
+ if (!IsConstructor(decorated))
217
+ throw new TypeError();
218
+ target = decorated;
219
+ }
220
+ }
221
+ return target;
222
+ }
223
+ function DecorateProperty(decorators, target, propertyKey, descriptor) {
224
+ for (var i = decorators.length - 1; i >= 0; --i) {
225
+ var decorator = decorators[i];
226
+ var decorated = decorator(target, propertyKey, descriptor);
227
+ if (!IsUndefined(decorated) && !IsNull(decorated)) {
228
+ if (!IsObject(decorated))
229
+ throw new TypeError();
230
+ descriptor = decorated;
231
+ }
232
+ }
233
+ return descriptor;
234
+ }
235
+ function OrdinaryHasMetadata(MetadataKey, O, P) {
236
+ var hasOwn2 = OrdinaryHasOwnMetadata(MetadataKey, O, P);
237
+ if (hasOwn2)
238
+ return true;
239
+ var parent = OrdinaryGetPrototypeOf(O);
240
+ if (!IsNull(parent))
241
+ return OrdinaryHasMetadata(MetadataKey, parent, P);
242
+ return false;
243
+ }
244
+ function OrdinaryHasOwnMetadata(MetadataKey, O, P) {
245
+ var provider = GetMetadataProvider(
246
+ O,
247
+ P,
248
+ /*Create*/
249
+ false
250
+ );
251
+ if (IsUndefined(provider))
252
+ return false;
253
+ return ToBoolean(provider.OrdinaryHasOwnMetadata(MetadataKey, O, P));
254
+ }
255
+ function OrdinaryGetMetadata(MetadataKey, O, P) {
256
+ var hasOwn2 = OrdinaryHasOwnMetadata(MetadataKey, O, P);
257
+ if (hasOwn2)
258
+ return OrdinaryGetOwnMetadata(MetadataKey, O, P);
259
+ var parent = OrdinaryGetPrototypeOf(O);
260
+ if (!IsNull(parent))
261
+ return OrdinaryGetMetadata(MetadataKey, parent, P);
262
+ return void 0;
263
+ }
264
+ function OrdinaryGetOwnMetadata(MetadataKey, O, P) {
265
+ var provider = GetMetadataProvider(
266
+ O,
267
+ P,
268
+ /*Create*/
269
+ false
270
+ );
271
+ if (IsUndefined(provider))
272
+ return;
273
+ return provider.OrdinaryGetOwnMetadata(MetadataKey, O, P);
274
+ }
275
+ function OrdinaryDefineOwnMetadata(MetadataKey, MetadataValue, O, P) {
276
+ var provider = GetMetadataProvider(
277
+ O,
278
+ P,
279
+ /*Create*/
280
+ true
281
+ );
282
+ provider.OrdinaryDefineOwnMetadata(MetadataKey, MetadataValue, O, P);
283
+ }
284
+ function OrdinaryMetadataKeys(O, P) {
285
+ var ownKeys = OrdinaryOwnMetadataKeys(O, P);
286
+ var parent = OrdinaryGetPrototypeOf(O);
287
+ if (parent === null)
288
+ return ownKeys;
289
+ var parentKeys = OrdinaryMetadataKeys(parent, P);
290
+ if (parentKeys.length <= 0)
291
+ return ownKeys;
292
+ if (ownKeys.length <= 0)
293
+ return parentKeys;
294
+ var set = new _Set();
295
+ var keys = [];
296
+ for (var _i = 0, ownKeys_1 = ownKeys; _i < ownKeys_1.length; _i++) {
297
+ var key = ownKeys_1[_i];
298
+ var hasKey = set.has(key);
299
+ if (!hasKey) {
300
+ set.add(key);
301
+ keys.push(key);
302
+ }
303
+ }
304
+ for (var _a2 = 0, parentKeys_1 = parentKeys; _a2 < parentKeys_1.length; _a2++) {
305
+ var key = parentKeys_1[_a2];
306
+ var hasKey = set.has(key);
307
+ if (!hasKey) {
308
+ set.add(key);
309
+ keys.push(key);
310
+ }
311
+ }
312
+ return keys;
313
+ }
314
+ function OrdinaryOwnMetadataKeys(O, P) {
315
+ var provider = GetMetadataProvider(
316
+ O,
317
+ P,
318
+ /*create*/
319
+ false
320
+ );
321
+ if (!provider) {
322
+ return [];
323
+ }
324
+ return provider.OrdinaryOwnMetadataKeys(O, P);
325
+ }
326
+ function Type(x) {
327
+ if (x === null)
328
+ return 1;
329
+ switch (typeof x) {
330
+ case "undefined":
331
+ return 0;
332
+ case "boolean":
333
+ return 2;
334
+ case "string":
335
+ return 3;
336
+ case "symbol":
337
+ return 4;
338
+ case "number":
339
+ return 5;
340
+ case "object":
341
+ return x === null ? 1 : 6;
342
+ default:
343
+ return 6;
344
+ }
345
+ }
346
+ function IsUndefined(x) {
347
+ return x === void 0;
348
+ }
349
+ function IsNull(x) {
350
+ return x === null;
351
+ }
352
+ function IsSymbol(x) {
353
+ return typeof x === "symbol";
354
+ }
355
+ function IsObject(x) {
356
+ return typeof x === "object" ? x !== null : typeof x === "function";
357
+ }
358
+ function ToPrimitive(input, PreferredType) {
359
+ switch (Type(input)) {
360
+ case 0:
361
+ return input;
362
+ case 1:
363
+ return input;
364
+ case 2:
365
+ return input;
366
+ case 3:
367
+ return input;
368
+ case 4:
369
+ return input;
370
+ case 5:
371
+ return input;
372
+ }
373
+ var hint = PreferredType === 3 ? "string" : PreferredType === 5 ? "number" : "default";
374
+ var exoticToPrim = GetMethod(input, toPrimitiveSymbol);
375
+ if (exoticToPrim !== void 0) {
376
+ var result = exoticToPrim.call(input, hint);
377
+ if (IsObject(result))
378
+ throw new TypeError();
379
+ return result;
380
+ }
381
+ return OrdinaryToPrimitive(input, hint === "default" ? "number" : hint);
382
+ }
383
+ function OrdinaryToPrimitive(O, hint) {
384
+ if (hint === "string") {
385
+ var toString_1 = O.toString;
386
+ if (IsCallable(toString_1)) {
387
+ var result = toString_1.call(O);
388
+ if (!IsObject(result))
389
+ return result;
390
+ }
391
+ var valueOf = O.valueOf;
392
+ if (IsCallable(valueOf)) {
393
+ var result = valueOf.call(O);
394
+ if (!IsObject(result))
395
+ return result;
396
+ }
397
+ } else {
398
+ var valueOf = O.valueOf;
399
+ if (IsCallable(valueOf)) {
400
+ var result = valueOf.call(O);
401
+ if (!IsObject(result))
402
+ return result;
403
+ }
404
+ var toString_2 = O.toString;
405
+ if (IsCallable(toString_2)) {
406
+ var result = toString_2.call(O);
407
+ if (!IsObject(result))
408
+ return result;
409
+ }
410
+ }
411
+ throw new TypeError();
412
+ }
413
+ function ToBoolean(argument) {
414
+ return !!argument;
415
+ }
416
+ function ToString(argument) {
417
+ return "" + argument;
418
+ }
419
+ function ToPropertyKey(argument) {
420
+ var key = ToPrimitive(
421
+ argument,
422
+ 3
423
+ /* String */
424
+ );
425
+ if (IsSymbol(key))
426
+ return key;
427
+ return ToString(key);
428
+ }
429
+ function IsArray(argument) {
430
+ return Array.isArray ? Array.isArray(argument) : argument instanceof Object ? argument instanceof Array : Object.prototype.toString.call(argument) === "[object Array]";
431
+ }
432
+ function IsCallable(argument) {
433
+ return typeof argument === "function";
434
+ }
435
+ function IsConstructor(argument) {
436
+ return typeof argument === "function";
437
+ }
438
+ function IsPropertyKey(argument) {
439
+ switch (Type(argument)) {
440
+ case 3:
441
+ return true;
442
+ case 4:
443
+ return true;
444
+ default:
445
+ return false;
446
+ }
447
+ }
448
+ function SameValueZero(x, y) {
449
+ return x === y || x !== x && y !== y;
450
+ }
451
+ function GetMethod(V, P) {
452
+ var func = V[P];
453
+ if (func === void 0 || func === null)
454
+ return void 0;
455
+ if (!IsCallable(func))
456
+ throw new TypeError();
457
+ return func;
458
+ }
459
+ function GetIterator(obj) {
460
+ var method = GetMethod(obj, iteratorSymbol);
461
+ if (!IsCallable(method))
462
+ throw new TypeError();
463
+ var iterator = method.call(obj);
464
+ if (!IsObject(iterator))
465
+ throw new TypeError();
466
+ return iterator;
467
+ }
468
+ function IteratorValue(iterResult) {
469
+ return iterResult.value;
470
+ }
471
+ function IteratorStep(iterator) {
472
+ var result = iterator.next();
473
+ return result.done ? false : result;
474
+ }
475
+ function IteratorClose(iterator) {
476
+ var f = iterator["return"];
477
+ if (f)
478
+ f.call(iterator);
479
+ }
480
+ function OrdinaryGetPrototypeOf(O) {
481
+ var proto = Object.getPrototypeOf(O);
482
+ if (typeof O !== "function" || O === functionPrototype)
483
+ return proto;
484
+ if (proto !== functionPrototype)
485
+ return proto;
486
+ var prototype = O.prototype;
487
+ var prototypeProto = prototype && Object.getPrototypeOf(prototype);
488
+ if (prototypeProto == null || prototypeProto === Object.prototype)
489
+ return proto;
490
+ var constructor = prototypeProto.constructor;
491
+ if (typeof constructor !== "function")
492
+ return proto;
493
+ if (constructor === O)
494
+ return proto;
495
+ return constructor;
496
+ }
497
+ function CreateMetadataRegistry() {
498
+ var fallback;
499
+ if (!IsUndefined(registrySymbol) && typeof root.Reflect !== "undefined" && !(registrySymbol in root.Reflect) && typeof root.Reflect.defineMetadata === "function") {
500
+ fallback = CreateFallbackProvider(root.Reflect);
501
+ }
502
+ var first;
503
+ var second;
504
+ var rest;
505
+ var targetProviderMap = new _WeakMap();
506
+ var registry = {
507
+ registerProvider,
508
+ getProvider,
509
+ setProvider
510
+ };
511
+ return registry;
512
+ function registerProvider(provider) {
513
+ if (!Object.isExtensible(registry)) {
514
+ throw new Error("Cannot add provider to a frozen registry.");
515
+ }
516
+ switch (true) {
517
+ case fallback === provider:
518
+ break;
519
+ case IsUndefined(first):
520
+ first = provider;
521
+ break;
522
+ case first === provider:
523
+ break;
524
+ case IsUndefined(second):
525
+ second = provider;
526
+ break;
527
+ case second === provider:
528
+ break;
529
+ default:
530
+ if (rest === void 0)
531
+ rest = new _Set();
532
+ rest.add(provider);
533
+ break;
534
+ }
535
+ }
536
+ function getProviderNoCache(O, P) {
537
+ if (!IsUndefined(first)) {
538
+ if (first.isProviderFor(O, P))
539
+ return first;
540
+ if (!IsUndefined(second)) {
541
+ if (second.isProviderFor(O, P))
542
+ return first;
543
+ if (!IsUndefined(rest)) {
544
+ var iterator = GetIterator(rest);
545
+ while (true) {
546
+ var next = IteratorStep(iterator);
547
+ if (!next) {
548
+ return void 0;
549
+ }
550
+ var provider = IteratorValue(next);
551
+ if (provider.isProviderFor(O, P)) {
552
+ IteratorClose(iterator);
553
+ return provider;
554
+ }
555
+ }
556
+ }
557
+ }
558
+ }
559
+ if (!IsUndefined(fallback) && fallback.isProviderFor(O, P)) {
560
+ return fallback;
561
+ }
562
+ return void 0;
563
+ }
564
+ function getProvider(O, P) {
565
+ var providerMap = targetProviderMap.get(O);
566
+ var provider;
567
+ if (!IsUndefined(providerMap)) {
568
+ provider = providerMap.get(P);
569
+ }
570
+ if (!IsUndefined(provider)) {
571
+ return provider;
572
+ }
573
+ provider = getProviderNoCache(O, P);
574
+ if (!IsUndefined(provider)) {
575
+ if (IsUndefined(providerMap)) {
576
+ providerMap = new _Map();
577
+ targetProviderMap.set(O, providerMap);
578
+ }
579
+ providerMap.set(P, provider);
580
+ }
581
+ return provider;
582
+ }
583
+ function hasProvider(provider) {
584
+ if (IsUndefined(provider))
585
+ throw new TypeError();
586
+ return first === provider || second === provider || !IsUndefined(rest) && rest.has(provider);
587
+ }
588
+ function setProvider(O, P, provider) {
589
+ if (!hasProvider(provider)) {
590
+ throw new Error("Metadata provider not registered.");
591
+ }
592
+ var existingProvider = getProvider(O, P);
593
+ if (existingProvider !== provider) {
594
+ if (!IsUndefined(existingProvider)) {
595
+ return false;
596
+ }
597
+ var providerMap = targetProviderMap.get(O);
598
+ if (IsUndefined(providerMap)) {
599
+ providerMap = new _Map();
600
+ targetProviderMap.set(O, providerMap);
601
+ }
602
+ providerMap.set(P, provider);
603
+ }
604
+ return true;
605
+ }
606
+ }
607
+ function GetOrCreateMetadataRegistry() {
608
+ var metadataRegistry2;
609
+ if (!IsUndefined(registrySymbol) && IsObject(root.Reflect) && Object.isExtensible(root.Reflect)) {
610
+ metadataRegistry2 = root.Reflect[registrySymbol];
611
+ }
612
+ if (IsUndefined(metadataRegistry2)) {
613
+ metadataRegistry2 = CreateMetadataRegistry();
614
+ }
615
+ if (!IsUndefined(registrySymbol) && IsObject(root.Reflect) && Object.isExtensible(root.Reflect)) {
616
+ Object.defineProperty(root.Reflect, registrySymbol, {
617
+ enumerable: false,
618
+ configurable: false,
619
+ writable: false,
620
+ value: metadataRegistry2
621
+ });
622
+ }
623
+ return metadataRegistry2;
624
+ }
625
+ function CreateMetadataProvider(registry) {
626
+ var metadata2 = new _WeakMap();
627
+ var provider = {
628
+ isProviderFor: function(O, P) {
629
+ var targetMetadata = metadata2.get(O);
630
+ if (IsUndefined(targetMetadata))
631
+ return false;
632
+ return targetMetadata.has(P);
633
+ },
634
+ OrdinaryDefineOwnMetadata: OrdinaryDefineOwnMetadata2,
635
+ OrdinaryHasOwnMetadata: OrdinaryHasOwnMetadata2,
636
+ OrdinaryGetOwnMetadata: OrdinaryGetOwnMetadata2,
637
+ OrdinaryOwnMetadataKeys: OrdinaryOwnMetadataKeys2,
638
+ OrdinaryDeleteMetadata
639
+ };
640
+ metadataRegistry.registerProvider(provider);
641
+ return provider;
642
+ function GetOrCreateMetadataMap(O, P, Create) {
643
+ var targetMetadata = metadata2.get(O);
644
+ var createdTargetMetadata = false;
645
+ if (IsUndefined(targetMetadata)) {
646
+ if (!Create)
647
+ return void 0;
648
+ targetMetadata = new _Map();
649
+ metadata2.set(O, targetMetadata);
650
+ createdTargetMetadata = true;
651
+ }
652
+ var metadataMap = targetMetadata.get(P);
653
+ if (IsUndefined(metadataMap)) {
654
+ if (!Create)
655
+ return void 0;
656
+ metadataMap = new _Map();
657
+ targetMetadata.set(P, metadataMap);
658
+ if (!registry.setProvider(O, P, provider)) {
659
+ targetMetadata.delete(P);
660
+ if (createdTargetMetadata) {
661
+ metadata2.delete(O);
662
+ }
663
+ throw new Error("Wrong provider for target.");
664
+ }
665
+ }
666
+ return metadataMap;
667
+ }
668
+ function OrdinaryHasOwnMetadata2(MetadataKey, O, P) {
669
+ var metadataMap = GetOrCreateMetadataMap(
670
+ O,
671
+ P,
672
+ /*Create*/
673
+ false
674
+ );
675
+ if (IsUndefined(metadataMap))
676
+ return false;
677
+ return ToBoolean(metadataMap.has(MetadataKey));
678
+ }
679
+ function OrdinaryGetOwnMetadata2(MetadataKey, O, P) {
680
+ var metadataMap = GetOrCreateMetadataMap(
681
+ O,
682
+ P,
683
+ /*Create*/
684
+ false
685
+ );
686
+ if (IsUndefined(metadataMap))
687
+ return void 0;
688
+ return metadataMap.get(MetadataKey);
689
+ }
690
+ function OrdinaryDefineOwnMetadata2(MetadataKey, MetadataValue, O, P) {
691
+ var metadataMap = GetOrCreateMetadataMap(
692
+ O,
693
+ P,
694
+ /*Create*/
695
+ true
696
+ );
697
+ metadataMap.set(MetadataKey, MetadataValue);
698
+ }
699
+ function OrdinaryOwnMetadataKeys2(O, P) {
700
+ var keys = [];
701
+ var metadataMap = GetOrCreateMetadataMap(
702
+ O,
703
+ P,
704
+ /*Create*/
705
+ false
706
+ );
707
+ if (IsUndefined(metadataMap))
708
+ return keys;
709
+ var keysObj = metadataMap.keys();
710
+ var iterator = GetIterator(keysObj);
711
+ var k = 0;
712
+ while (true) {
713
+ var next = IteratorStep(iterator);
714
+ if (!next) {
715
+ keys.length = k;
716
+ return keys;
717
+ }
718
+ var nextValue = IteratorValue(next);
719
+ try {
720
+ keys[k] = nextValue;
721
+ } catch (e) {
722
+ try {
723
+ IteratorClose(iterator);
724
+ } finally {
725
+ throw e;
726
+ }
727
+ }
728
+ k++;
729
+ }
730
+ }
731
+ function OrdinaryDeleteMetadata(MetadataKey, O, P) {
732
+ var metadataMap = GetOrCreateMetadataMap(
733
+ O,
734
+ P,
735
+ /*Create*/
736
+ false
737
+ );
738
+ if (IsUndefined(metadataMap))
739
+ return false;
740
+ if (!metadataMap.delete(MetadataKey))
741
+ return false;
742
+ if (metadataMap.size === 0) {
743
+ var targetMetadata = metadata2.get(O);
744
+ if (!IsUndefined(targetMetadata)) {
745
+ targetMetadata.delete(P);
746
+ if (targetMetadata.size === 0) {
747
+ metadata2.delete(targetMetadata);
748
+ }
749
+ }
750
+ }
751
+ return true;
752
+ }
753
+ }
754
+ function CreateFallbackProvider(reflect) {
755
+ var defineMetadata2 = reflect.defineMetadata, hasOwnMetadata2 = reflect.hasOwnMetadata, getOwnMetadata2 = reflect.getOwnMetadata, getOwnMetadataKeys2 = reflect.getOwnMetadataKeys, deleteMetadata2 = reflect.deleteMetadata;
756
+ var metadataOwner = new _WeakMap();
757
+ var provider = {
758
+ isProviderFor: function(O, P) {
759
+ var metadataPropertySet = metadataOwner.get(O);
760
+ if (!IsUndefined(metadataPropertySet) && metadataPropertySet.has(P)) {
761
+ return true;
762
+ }
763
+ if (getOwnMetadataKeys2(O, P).length) {
764
+ if (IsUndefined(metadataPropertySet)) {
765
+ metadataPropertySet = new _Set();
766
+ metadataOwner.set(O, metadataPropertySet);
767
+ }
768
+ metadataPropertySet.add(P);
769
+ return true;
770
+ }
771
+ return false;
772
+ },
773
+ OrdinaryDefineOwnMetadata: defineMetadata2,
774
+ OrdinaryHasOwnMetadata: hasOwnMetadata2,
775
+ OrdinaryGetOwnMetadata: getOwnMetadata2,
776
+ OrdinaryOwnMetadataKeys: getOwnMetadataKeys2,
777
+ OrdinaryDeleteMetadata: deleteMetadata2
778
+ };
779
+ return provider;
780
+ }
781
+ function GetMetadataProvider(O, P, Create) {
782
+ var registeredProvider = metadataRegistry.getProvider(O, P);
783
+ if (!IsUndefined(registeredProvider)) {
784
+ return registeredProvider;
785
+ }
786
+ if (Create) {
787
+ if (metadataRegistry.setProvider(O, P, metadataProvider)) {
788
+ return metadataProvider;
789
+ }
790
+ throw new Error("Illegal state.");
791
+ }
792
+ return void 0;
793
+ }
794
+ function CreateMapPolyfill() {
795
+ var cacheSentinel = {};
796
+ var arraySentinel = [];
797
+ var MapIterator = (
798
+ /** @class */
799
+ function() {
800
+ function MapIterator2(keys, values, selector) {
801
+ this._index = 0;
802
+ this._keys = keys;
803
+ this._values = values;
804
+ this._selector = selector;
805
+ }
806
+ MapIterator2.prototype["@@iterator"] = function() {
807
+ return this;
808
+ };
809
+ MapIterator2.prototype[iteratorSymbol] = function() {
810
+ return this;
811
+ };
812
+ MapIterator2.prototype.next = function() {
813
+ var index = this._index;
814
+ if (index >= 0 && index < this._keys.length) {
815
+ var result = this._selector(this._keys[index], this._values[index]);
816
+ if (index + 1 >= this._keys.length) {
817
+ this._index = -1;
818
+ this._keys = arraySentinel;
819
+ this._values = arraySentinel;
820
+ } else {
821
+ this._index++;
822
+ }
823
+ return { value: result, done: false };
824
+ }
825
+ return { value: void 0, done: true };
826
+ };
827
+ MapIterator2.prototype.throw = function(error) {
828
+ if (this._index >= 0) {
829
+ this._index = -1;
830
+ this._keys = arraySentinel;
831
+ this._values = arraySentinel;
832
+ }
833
+ throw error;
834
+ };
835
+ MapIterator2.prototype.return = function(value) {
836
+ if (this._index >= 0) {
837
+ this._index = -1;
838
+ this._keys = arraySentinel;
839
+ this._values = arraySentinel;
840
+ }
841
+ return { value, done: true };
842
+ };
843
+ return MapIterator2;
844
+ }()
845
+ );
846
+ var Map2 = (
847
+ /** @class */
848
+ function() {
849
+ function Map3() {
850
+ this._keys = [];
851
+ this._values = [];
852
+ this._cacheKey = cacheSentinel;
853
+ this._cacheIndex = -2;
854
+ }
855
+ Object.defineProperty(Map3.prototype, "size", {
856
+ get: function() {
857
+ return this._keys.length;
858
+ },
859
+ enumerable: true,
860
+ configurable: true
861
+ });
862
+ Map3.prototype.has = function(key) {
863
+ return this._find(
864
+ key,
865
+ /*insert*/
866
+ false
867
+ ) >= 0;
868
+ };
869
+ Map3.prototype.get = function(key) {
870
+ var index = this._find(
871
+ key,
872
+ /*insert*/
873
+ false
874
+ );
875
+ return index >= 0 ? this._values[index] : void 0;
876
+ };
877
+ Map3.prototype.set = function(key, value) {
878
+ var index = this._find(
879
+ key,
880
+ /*insert*/
881
+ true
882
+ );
883
+ this._values[index] = value;
884
+ return this;
885
+ };
886
+ Map3.prototype.delete = function(key) {
887
+ var index = this._find(
888
+ key,
889
+ /*insert*/
890
+ false
891
+ );
892
+ if (index >= 0) {
893
+ var size = this._keys.length;
894
+ for (var i = index + 1; i < size; i++) {
895
+ this._keys[i - 1] = this._keys[i];
896
+ this._values[i - 1] = this._values[i];
897
+ }
898
+ this._keys.length--;
899
+ this._values.length--;
900
+ if (SameValueZero(key, this._cacheKey)) {
901
+ this._cacheKey = cacheSentinel;
902
+ this._cacheIndex = -2;
903
+ }
904
+ return true;
905
+ }
906
+ return false;
907
+ };
908
+ Map3.prototype.clear = function() {
909
+ this._keys.length = 0;
910
+ this._values.length = 0;
911
+ this._cacheKey = cacheSentinel;
912
+ this._cacheIndex = -2;
913
+ };
914
+ Map3.prototype.keys = function() {
915
+ return new MapIterator(this._keys, this._values, getKey);
916
+ };
917
+ Map3.prototype.values = function() {
918
+ return new MapIterator(this._keys, this._values, getValue);
919
+ };
920
+ Map3.prototype.entries = function() {
921
+ return new MapIterator(this._keys, this._values, getEntry);
922
+ };
923
+ Map3.prototype["@@iterator"] = function() {
924
+ return this.entries();
925
+ };
926
+ Map3.prototype[iteratorSymbol] = function() {
927
+ return this.entries();
928
+ };
929
+ Map3.prototype._find = function(key, insert2) {
930
+ if (!SameValueZero(this._cacheKey, key)) {
931
+ this._cacheIndex = -1;
932
+ for (var i = 0; i < this._keys.length; i++) {
933
+ if (SameValueZero(this._keys[i], key)) {
934
+ this._cacheIndex = i;
935
+ break;
936
+ }
937
+ }
938
+ }
939
+ if (this._cacheIndex < 0 && insert2) {
940
+ this._cacheIndex = this._keys.length;
941
+ this._keys.push(key);
942
+ this._values.push(void 0);
943
+ }
944
+ return this._cacheIndex;
945
+ };
946
+ return Map3;
947
+ }()
948
+ );
949
+ return Map2;
950
+ function getKey(key, _) {
951
+ return key;
952
+ }
953
+ function getValue(_, value) {
954
+ return value;
955
+ }
956
+ function getEntry(key, value) {
957
+ return [key, value];
958
+ }
959
+ }
960
+ function CreateSetPolyfill() {
961
+ var Set2 = (
962
+ /** @class */
963
+ function() {
964
+ function Set3() {
965
+ this._map = new _Map();
966
+ }
967
+ Object.defineProperty(Set3.prototype, "size", {
968
+ get: function() {
969
+ return this._map.size;
970
+ },
971
+ enumerable: true,
972
+ configurable: true
973
+ });
974
+ Set3.prototype.has = function(value) {
975
+ return this._map.has(value);
976
+ };
977
+ Set3.prototype.add = function(value) {
978
+ return this._map.set(value, value), this;
979
+ };
980
+ Set3.prototype.delete = function(value) {
981
+ return this._map.delete(value);
982
+ };
983
+ Set3.prototype.clear = function() {
984
+ this._map.clear();
985
+ };
986
+ Set3.prototype.keys = function() {
987
+ return this._map.keys();
988
+ };
989
+ Set3.prototype.values = function() {
990
+ return this._map.keys();
991
+ };
992
+ Set3.prototype.entries = function() {
993
+ return this._map.entries();
994
+ };
995
+ Set3.prototype["@@iterator"] = function() {
996
+ return this.keys();
997
+ };
998
+ Set3.prototype[iteratorSymbol] = function() {
999
+ return this.keys();
1000
+ };
1001
+ return Set3;
1002
+ }()
1003
+ );
1004
+ return Set2;
1005
+ }
1006
+ function CreateWeakMapPolyfill() {
1007
+ var UUID_SIZE = 16;
1008
+ var keys = HashMap.create();
1009
+ var rootKey = CreateUniqueKey();
1010
+ return (
1011
+ /** @class */
1012
+ function() {
1013
+ function WeakMap2() {
1014
+ this._key = CreateUniqueKey();
1015
+ }
1016
+ WeakMap2.prototype.has = function(target) {
1017
+ var table = GetOrCreateWeakMapTable(
1018
+ target,
1019
+ /*create*/
1020
+ false
1021
+ );
1022
+ return table !== void 0 ? HashMap.has(table, this._key) : false;
1023
+ };
1024
+ WeakMap2.prototype.get = function(target) {
1025
+ var table = GetOrCreateWeakMapTable(
1026
+ target,
1027
+ /*create*/
1028
+ false
1029
+ );
1030
+ return table !== void 0 ? HashMap.get(table, this._key) : void 0;
1031
+ };
1032
+ WeakMap2.prototype.set = function(target, value) {
1033
+ var table = GetOrCreateWeakMapTable(
1034
+ target,
1035
+ /*create*/
1036
+ true
1037
+ );
1038
+ table[this._key] = value;
1039
+ return this;
1040
+ };
1041
+ WeakMap2.prototype.delete = function(target) {
1042
+ var table = GetOrCreateWeakMapTable(
1043
+ target,
1044
+ /*create*/
1045
+ false
1046
+ );
1047
+ return table !== void 0 ? delete table[this._key] : false;
1048
+ };
1049
+ WeakMap2.prototype.clear = function() {
1050
+ this._key = CreateUniqueKey();
1051
+ };
1052
+ return WeakMap2;
1053
+ }()
1054
+ );
1055
+ function CreateUniqueKey() {
1056
+ var key;
1057
+ do
1058
+ key = "@@WeakMap@@" + CreateUUID();
1059
+ while (HashMap.has(keys, key));
1060
+ keys[key] = true;
1061
+ return key;
1062
+ }
1063
+ function GetOrCreateWeakMapTable(target, create) {
1064
+ if (!hasOwn.call(target, rootKey)) {
1065
+ if (!create)
1066
+ return void 0;
1067
+ Object.defineProperty(target, rootKey, { value: HashMap.create() });
1068
+ }
1069
+ return target[rootKey];
1070
+ }
1071
+ function FillRandomBytes(buffer, size) {
1072
+ for (var i = 0; i < size; ++i)
1073
+ buffer[i] = Math.random() * 255 | 0;
1074
+ return buffer;
1075
+ }
1076
+ function GenRandomBytes(size) {
1077
+ if (typeof Uint8Array === "function") {
1078
+ var array = new Uint8Array(size);
1079
+ if (typeof crypto !== "undefined") {
1080
+ crypto.getRandomValues(array);
1081
+ } else if (typeof msCrypto !== "undefined") {
1082
+ msCrypto.getRandomValues(array);
1083
+ } else {
1084
+ FillRandomBytes(array, size);
1085
+ }
1086
+ return array;
1087
+ }
1088
+ return FillRandomBytes(new Array(size), size);
1089
+ }
1090
+ function CreateUUID() {
1091
+ var data = GenRandomBytes(UUID_SIZE);
1092
+ data[6] = data[6] & 79 | 64;
1093
+ data[8] = data[8] & 191 | 128;
1094
+ var result = "";
1095
+ for (var offset = 0; offset < UUID_SIZE; ++offset) {
1096
+ var byte = data[offset];
1097
+ if (offset === 4 || offset === 6 || offset === 8)
1098
+ result += "-";
1099
+ if (byte < 16)
1100
+ result += "0";
1101
+ result += byte.toString(16).toLowerCase();
1102
+ }
1103
+ return result;
1104
+ }
1105
+ }
1106
+ function MakeDictionary(obj) {
1107
+ obj.__ = void 0;
1108
+ delete obj.__;
1109
+ return obj;
1110
+ }
1111
+ });
1112
+ })(Reflect2 || (Reflect2 = {}));
1113
+ }
1114
+ });
1115
+
1116
+ // src/index.browser.ts
1117
+ var import_reflect_metadata = __toESM(require_Reflect());
1118
+
1119
+ // src/shared/index.ts
1120
+ var shared_exports = {};
1121
+ __export(shared_exports, {
1122
+ BOOTSTRAP: () => BOOTSTRAP,
1123
+ BOOTSTRAP_VNODE: () => BOOTSTRAP_VNODE,
1124
+ Body: () => Body,
1125
+ COMPONENT: () => COMPONENT,
1126
+ COMPONENT_DEPS: () => COMPONENT_DEPS,
1127
+ COMPONENT_PROVIDERS: () => COMPONENT_PROVIDERS,
1128
+ CONTROLLER: () => CONTROLLER,
1129
+ CONTROLLERS_KEY: () => CONTROLLERS_KEY,
1130
+ CONTROLLER_PREFIX_KEY: () => CONTROLLER_PREFIX_KEY,
1131
+ Compiler: () => Compiler,
1132
+ Component: () => Component,
1133
+ Controller: () => Controller,
1134
+ DECLARATIONS_KEY: () => DECLARATIONS_KEY,
1135
+ DESIGN_PARAMTYPES: () => DESIGN_PARAMTYPES,
1136
+ ERROR_ELEMENT: () => ERROR_ELEMENT,
1137
+ EXPORTS_KEY: () => EXPORTS_KEY,
1138
+ EXPRESS_ADAPTER_HOST: () => EXPRESS_ADAPTER_HOST,
1139
+ Fragment: () => Fragment,
1140
+ Get: () => Get,
1141
+ HTTP_METHOD_KEY: () => HTTP_METHOD_KEY,
1142
+ HandlerParamType: () => HandlerParamType,
1143
+ HttpClient: () => HttpClient,
1144
+ HttpClientModule: () => HttpClientModule,
1145
+ HttpMethod: () => HttpMethod,
1146
+ IMPORTS_KEY: () => IMPORTS_KEY,
1147
+ INJECTABLE: () => INJECTABLE,
1148
+ INJECT_TOKENS_KEY: () => INJECT_TOKENS_KEY,
1149
+ Inject: () => Inject,
1150
+ Injectable: () => Injectable,
1151
+ Injector: () => Injector,
1152
+ Module: () => Module,
1153
+ NODE: () => NODE,
1154
+ Navigate: () => Navigate,
1155
+ Node: () => Node2,
1156
+ ORCA_CLIENT_COMPONENT: () => ORCA_CLIENT_COMPONENT,
1157
+ ORCA_ELEMENT_TYPE: () => ORCA_ELEMENT_TYPE,
1158
+ ORCA_FRAGMENT_TYPE: () => ORCA_FRAGMENT_TYPE,
1159
+ OSC: () => OSC,
1160
+ Observable: () => Observable,
1161
+ OrcaComponent: () => OrcaComponent,
1162
+ PARAMS_META_KEY: () => PARAMS_META_KEY,
1163
+ PATH_KEY: () => PATH_KEY,
1164
+ PENDING_REFERENCE_TYPE: () => PENDING_REFERENCE_TYPE,
1165
+ PROVIDERS_KEY: () => PROVIDERS_KEY,
1166
+ Param: () => Param,
1167
+ Post: () => Post,
1168
+ ProviderNormalizer: () => ProviderNormalizer,
1169
+ RouterModule: () => RouterModule,
1170
+ RouterOutlet: () => RouterOutlet,
1171
+ SIGNATURE_METADATA_KEY: () => SIGNATURE_METADATA_KEY,
1172
+ Signature: () => Signature,
1173
+ StreamRenderer: () => StreamRenderer,
1174
+ StringRenderer: () => StringRenderer,
1175
+ VNode: () => VNode,
1176
+ assert$: () => assert$,
1177
+ collectAllProvidersFromNode: () => collectAllProvidersFromNode,
1178
+ computed: () => computed,
1179
+ effect: () => effect,
1180
+ from: () => from,
1181
+ getCurrentInjector: () => getCurrentInjector,
1182
+ getSignatureMetadata: () => getSignatureMetadata,
1183
+ hasSignature: () => hasSignature,
1184
+ interval: () => interval,
1185
+ isClassComponent: () => isClassComponent,
1186
+ isFragment: () => isFragment,
1187
+ isIntrinsicElement: () => isIntrinsicElement,
1188
+ isObservable: () => isObservable,
1189
+ isSignal: () => isSignal,
1190
+ jsx: () => jsx,
1191
+ jsxs: () => jsxs,
1192
+ observable: () => observable,
1193
+ of: () => of,
1194
+ parseSignatureSchemas: () => parseSignatureSchemas,
1195
+ setCurrentInjector: () => setCurrentInjector,
1196
+ signal: () => signal,
1197
+ store: () => store,
1198
+ symbolValueReplacer: () => symbolValueReplacer,
1199
+ symbolValueReviver: () => symbolValueReviver,
1200
+ toSignal: () => toSignal
1201
+ });
1202
+
1203
+ // src/shared/store.ts
1204
+ var Store = class {
1205
+ constructor() {
1206
+ this.namespace = /* @__PURE__ */ new Map();
1207
+ }
1208
+ set(name, value) {
1209
+ this.namespace.set(name, value);
1210
+ }
1211
+ get(name) {
1212
+ return this.namespace.get(name);
1213
+ }
1214
+ update(name, updater) {
1215
+ const current = this.get(name);
1216
+ const next = updater(current);
1217
+ this.set(name, next);
1218
+ }
1219
+ };
1220
+ var store = new Store();
1221
+
1222
+ // src/shared/symbols.ts
1223
+ var DECLARATIONS_KEY = Symbol("orca:declarations");
1224
+ var PROVIDERS_KEY = Symbol("orca:providers");
1225
+ var CONTROLLERS_KEY = Symbol("orca:controllers");
1226
+ var BOOTSTRAP = Symbol("orca:bootstrap");
1227
+ var BOOTSTRAP_VNODE = Symbol("orca:bootstrap:vnode");
1228
+ var IMPORTS_KEY = Symbol("orca:imports");
1229
+ var EXPORTS_KEY = Symbol("orca:exports");
1230
+ var INJECTABLE = Symbol("orca:injectable");
1231
+ var COMPONENT = Symbol("orca:component");
1232
+ var COMPONENT_PROVIDERS = Symbol("orca:component:providers");
1233
+ var COMPONENT_DEPS = Symbol("orca:component:deps");
1234
+ var INJECT_TOKENS_KEY = Symbol("orca:injectTokens");
1235
+ var NODE = Symbol("orca:node");
1236
+ var DESIGN_PARAMTYPES = "design:paramtypes";
1237
+ var CONTROLLER = Symbol("orca:controller");
1238
+ var CONTROLLER_PREFIX_KEY = Symbol("orca:controllerPrefix");
1239
+ var PARAMS_META_KEY = Symbol("orca:paramsMeta");
1240
+ var HTTP_METHOD_KEY = Symbol("orca:method");
1241
+ var PATH_KEY = Symbol("orca:path");
1242
+ var EXPRESS_ADAPTER_HOST = Symbol("orca:express");
1243
+ var SIGNATURE_METADATA_KEY = Symbol("orca:signature:schemas");
1244
+ var ERROR_ELEMENT = Symbol.for("orca:error");
1245
+ var ORCA_ELEMENT_TYPE = Symbol.for("orca:element");
1246
+ var ORCA_FRAGMENT_TYPE = Symbol.for("orca:fragment");
1247
+ var ORCA_CLIENT_COMPONENT = Symbol.for("orca.client.component");
1248
+ var PENDING_REFERENCE_TYPE = Symbol.for("orca:pending_reference");
1249
+
1250
+ // src/shared/types.ts
1251
+ var HandlerParamType = /* @__PURE__ */ ((HandlerParamType2) => {
1252
+ HandlerParamType2["ROUTE_PARAM"] = "ROUTE_PARAM";
1253
+ HandlerParamType2["BODY"] = "BODY";
1254
+ return HandlerParamType2;
1255
+ })(HandlerParamType || {});
1256
+ var HttpMethod = /* @__PURE__ */ ((HttpMethod2) => {
1257
+ HttpMethod2["GET"] = "get";
1258
+ HttpMethod2["POST"] = "post";
1259
+ return HttpMethod2;
1260
+ })(HttpMethod || {});
1261
+
1262
+ // src/shared/decorators.ts
1263
+ function Module(params = {}) {
1264
+ return function(target) {
1265
+ Reflect.defineMetadata(PROVIDERS_KEY, params.providers || [], target);
1266
+ Reflect.defineMetadata(DECLARATIONS_KEY, params.declarations || [], target);
1267
+ Reflect.defineMetadata(IMPORTS_KEY, params.imports || [], target);
1268
+ Reflect.defineMetadata(EXPORTS_KEY, params.exports || [], target);
1269
+ Reflect.defineMetadata(CONTROLLERS_KEY, params.controllers || [], target);
1270
+ Reflect.defineMetadata(BOOTSTRAP, params.bootstrap || [], target);
1271
+ };
1272
+ }
1273
+ function Injectable() {
1274
+ return function(target) {
1275
+ Reflect.defineMetadata(INJECTABLE, true, target);
1276
+ return target;
1277
+ };
1278
+ }
1279
+ function Component(params = {}) {
1280
+ return function(target) {
1281
+ store.update("components", (current) => {
1282
+ const next = current ?? /* @__PURE__ */ new Map();
1283
+ next.set(target.name, target);
1284
+ return next;
1285
+ });
1286
+ Reflect.defineMetadata(COMPONENT, true, target);
1287
+ Reflect.defineMetadata(COMPONENT_PROVIDERS, params.providers || [], target);
1288
+ Reflect.defineMetadata(COMPONENT_DEPS, params.deps || [], target);
1289
+ return target;
1290
+ };
1291
+ }
1292
+ function Inject(token, params = {}) {
1293
+ return function(target, _propertyKey, parameterIndex) {
1294
+ const existingTokens = Reflect.getOwnMetadata(INJECT_TOKENS_KEY, target) || /* @__PURE__ */ new Map();
1295
+ existingTokens.set(parameterIndex, {
1296
+ token,
1297
+ ...params
1298
+ });
1299
+ Reflect.defineMetadata(INJECT_TOKENS_KEY, existingTokens, target);
1300
+ };
1301
+ }
1302
+ function Controller(prefix, options = {}) {
1303
+ return function(target) {
1304
+ Injectable()(target);
1305
+ if (options.providedIn == "root") {
1306
+ store.update("root_controllers", (current) => {
1307
+ const next = current ?? /* @__PURE__ */ new Set();
1308
+ next.add(target);
1309
+ return next;
1310
+ });
1311
+ }
1312
+ Reflect.defineMetadata(CONTROLLER_PREFIX_KEY, prefix ?? "/", target);
1313
+ Reflect.defineMetadata(CONTROLLER, true, target);
1314
+ };
1315
+ }
1316
+ function getHandlerParamDecorator(type, key) {
1317
+ return function(target, methodName, index) {
1318
+ const paramsMeta = Reflect.getMetadata(PARAMS_META_KEY, target, methodName) ?? {};
1319
+ paramsMeta[index] = { key, type };
1320
+ Reflect.defineMetadata(PARAMS_META_KEY, paramsMeta, target, methodName);
1321
+ };
1322
+ }
1323
+ function Param(key) {
1324
+ return getHandlerParamDecorator("ROUTE_PARAM" /* ROUTE_PARAM */, key);
1325
+ }
1326
+ function Body(key) {
1327
+ return getHandlerParamDecorator("BODY" /* BODY */, key);
1328
+ }
1329
+ function getRouteDecorator(httpMethod, path) {
1330
+ return function(target, key, descriptor) {
1331
+ Reflect.defineMetadata(HTTP_METHOD_KEY, httpMethod, target, key);
1332
+ Reflect.defineMetadata(PATH_KEY, path, target, key);
1333
+ };
1334
+ }
1335
+ function Get(path) {
1336
+ return getRouteDecorator("get" /* GET */, path ?? "");
1337
+ }
1338
+ function Post(path) {
1339
+ return getRouteDecorator("post" /* POST */, path ?? "");
1340
+ }
1341
+ function Signature(...schemas) {
1342
+ return function(target, propertyKey, descriptor) {
1343
+ Reflect.defineMetadata(SIGNATURE_METADATA_KEY, schemas, target, propertyKey);
1344
+ const originalMethod = descriptor.value;
1345
+ descriptor.value = async function(...args) {
1346
+ return originalMethod.apply(this, args);
1347
+ };
1348
+ return descriptor;
1349
+ };
1350
+ }
1351
+ function getSignatureMetadata(target, propertyKey) {
1352
+ return Reflect.getMetadata(SIGNATURE_METADATA_KEY, target, propertyKey);
1353
+ }
1354
+ function hasSignature(target, propertyKey) {
1355
+ return Reflect.hasMetadata(SIGNATURE_METADATA_KEY, target, propertyKey);
1356
+ }
1357
+ function parseSignatureSchemas(schemas, paramCount) {
1358
+ if (schemas.length === 0) {
1359
+ return { paramSchemas: [] };
1360
+ }
1361
+ if (schemas.length === 1) {
1362
+ return {
1363
+ paramSchemas: [],
1364
+ returnSchema: schemas[0]
1365
+ };
1366
+ }
1367
+ const paramSchemas = schemas.slice(0, -1);
1368
+ const returnSchema = schemas[schemas.length - 1];
1369
+ if (paramSchemas.length !== paramCount) {
1370
+ throw new Error(`@Signature decorator has ${paramSchemas.length} parameter schemas but method has ${paramCount} parameters. They must match.`);
1371
+ }
1372
+ return { paramSchemas, returnSchema };
1373
+ }
1374
+
1375
+ // src/shared/module/node.ts
1376
+ var ProviderNormalizer = class {
1377
+ static normalize(provider) {
1378
+ if (typeof provider === "function") {
1379
+ return { provide: provider, useClass: provider, scope: "singleton" };
1380
+ }
1381
+ return { scope: "singleton", ...provider };
1382
+ }
1383
+ };
1384
+ var Node2 = class {
1385
+ constructor(name) {
1386
+ this.name = name;
1387
+ this.children = [];
1388
+ this.tokens = /* @__PURE__ */ new Map();
1389
+ this.exports = /* @__PURE__ */ new Set();
1390
+ this.providers = /* @__PURE__ */ new Map();
1391
+ }
1392
+ traverse(cb) {
1393
+ cb(this);
1394
+ this.children.forEach((child) => child.traverse(cb));
1395
+ }
1396
+ addProviders(providers) {
1397
+ providers.forEach((p) => {
1398
+ const normalized = ProviderNormalizer.normalize(p);
1399
+ this.providers.set(normalized.provide, normalized);
1400
+ });
1401
+ }
1402
+ getProviders() {
1403
+ return this.providers;
1404
+ }
1405
+ setChildren(children) {
1406
+ this.children = children;
1407
+ }
1408
+ addToken(token, dependencies) {
1409
+ this.tokens.set(token, dependencies);
1410
+ }
1411
+ addExport(token) {
1412
+ this.exports.add(token);
1413
+ }
1414
+ getTokens() {
1415
+ return this.tokens;
1416
+ }
1417
+ getExports() {
1418
+ return this.exports;
1419
+ }
1420
+ getChildren() {
1421
+ return this.children;
1422
+ }
1423
+ };
1424
+
1425
+ // src/shared/module/compiler.ts
1426
+ var Compiler = class {
1427
+ constructor() {
1428
+ this.nodes = /* @__PURE__ */ new Map();
1429
+ }
1430
+ compile(rootModule) {
1431
+ return this.createNode(rootModule);
1432
+ }
1433
+ createNode(moduleOrDynamic) {
1434
+ const target = this.isDynamicModule(moduleOrDynamic) ? moduleOrDynamic.module : moduleOrDynamic;
1435
+ if (this.nodes.has(target.name))
1436
+ return this.nodes.get(target.name);
1437
+ const node = new Node2(target.name);
1438
+ this.nodes.set(target.name, node);
1439
+ const imports = this.getImports(moduleOrDynamic);
1440
+ node.setChildren(imports.map((imp) => this.createNode(imp)));
1441
+ const providers = this.getProviders(moduleOrDynamic);
1442
+ const controllers = this.getControllers(moduleOrDynamic);
1443
+ const declarations = this.getDeclarations(moduleOrDynamic);
1444
+ [...providers, ...controllers].forEach((item) => {
1445
+ const token = this.getProviderToken(item);
1446
+ const deps = this.extractDependencies(item);
1447
+ node.addToken(token, deps);
1448
+ });
1449
+ node.addProviders(providers);
1450
+ declarations.forEach((dec) => {
1451
+ node.addProviders([{ provide: dec, useClass: dec, scope: "transient" }]);
1452
+ });
1453
+ controllers.forEach((ctrl) => {
1454
+ node.addProviders([
1455
+ { provide: ctrl, useClass: ctrl, scope: "singleton" }
1456
+ ]);
1457
+ });
1458
+ [...declarations, ...controllers].forEach((comp) => {
1459
+ if (Reflect.getMetadata(COMPONENT, comp)) {
1460
+ const constructorDeps = this.getConstructorDependencies(comp);
1461
+ node.addToken(comp, constructorDeps);
1462
+ const componentDeps = Reflect.getMetadata(COMPONENT_DEPS, comp) || [];
1463
+ const allDeps = [...constructorDeps, ...componentDeps];
1464
+ node.addToken(comp, allDeps);
1465
+ const localProviders = Reflect.getMetadata(COMPONENT_PROVIDERS, comp) || [];
1466
+ node.addProviders(localProviders);
1467
+ localProviders.forEach((lp) => {
1468
+ const token = this.getProviderToken(lp);
1469
+ const deps = this.extractDependencies(lp);
1470
+ node.addToken(token, deps);
1471
+ });
1472
+ }
1473
+ });
1474
+ this.getExports(moduleOrDynamic).forEach((exp) => node.addExport(exp));
1475
+ return node;
1476
+ }
1477
+ validate(rootNode) {
1478
+ const errors = [];
1479
+ const allNodes = /* @__PURE__ */ new Map();
1480
+ this.collectAllNodes(rootNode, allNodes);
1481
+ const tokenName = (token) => typeof token === "function" ? token.name : String(token);
1482
+ allNodes.forEach((node) => {
1483
+ const moduleName = node.name;
1484
+ const providedTokens = node.getTokens();
1485
+ const exportedTokens = node.getExports();
1486
+ for (const exp of exportedTokens) {
1487
+ if (!providedTokens.has(exp)) {
1488
+ errors.push(`\u274C EXPORT ERROR in module "${moduleName}":
1489
+ Exports token "${tokenName(exp)}" but this module does not provide it.
1490
+ \u2192 Add it to providers/controllers/declarations, or remove from exports.`);
1491
+ }
1492
+ }
1493
+ const seen = /* @__PURE__ */ new Set();
1494
+ for (const token of providedTokens.keys()) {
1495
+ if (seen.has(token)) {
1496
+ errors.push(`\u274C DUPLICATE PROVIDER in module "${moduleName}":
1497
+ Token "${tokenName(token)}" is registered more than once.
1498
+ \u2192 Remove duplicate entries.`);
1499
+ }
1500
+ seen.add(token);
1501
+ }
1502
+ for (const [token, deps] of providedTokens) {
1503
+ for (const dep of deps) {
1504
+ if (providedTokens.has(dep))
1505
+ continue;
1506
+ const providingModule = this.findProvidingModule(dep, node, allNodes, /* @__PURE__ */ new Set());
1507
+ if (!providingModule) {
1508
+ const consumer = tokenName(token);
1509
+ const missing = tokenName(dep);
1510
+ const possibleProviders = Array.from(allNodes.values()).filter((n) => n.getTokens().has(dep)).map((n) => n.name);
1511
+ let suggestion = "";
1512
+ if (possibleProviders.length > 0) {
1513
+ suggestion = `
1514
+ \u2192 "${missing}" IS provided in: ${possibleProviders.join(", ")}
1515
+ \u2192 Ensure one of those modules exports it AND "${moduleName}" imports that module.`;
1516
+ } else {
1517
+ suggestion = `
1518
+ \u2192 "${missing}" is not provided anywhere. Add a provider for it.`;
1519
+ }
1520
+ errors.push(`\u274C UNRESOLVED DEPENDENCY in module "${moduleName}":
1521
+ "${consumer}" requires "${missing}"${suggestion}`);
1522
+ }
1523
+ }
1524
+ }
1525
+ providedTokens.forEach((deps, token) => {
1526
+ if (typeof token === "function" && Reflect.getMetadata(COMPONENT, token)) {
1527
+ const componentDeps = Reflect.getMetadata(COMPONENT_DEPS, token) || [];
1528
+ componentDeps.forEach((depComp) => {
1529
+ if (typeof depComp === "function" && !Reflect.getMetadata(COMPONENT, depComp)) {
1530
+ errors.push(`\u274C COMPONENT DEPENDENCY ERROR in module "${moduleName}":
1531
+ Component "${tokenName(token)}" lists "${tokenName(depComp)}" in deps
1532
+ \u2192 "${tokenName(depComp)}" is not a component (missing @Component decorator)`);
1533
+ }
1534
+ if (!providedTokens.has(depComp)) {
1535
+ const providingMod = this.findProvidingModule(depComp, node, allNodes, /* @__PURE__ */ new Set());
1536
+ if (!providingMod) {
1537
+ errors.push(`\u274C COMPONENT DEPENDENCY ERROR in module "${moduleName}":
1538
+ Component "${tokenName(token)}" renders "${tokenName(depComp)}"
1539
+ \u2192 "${tokenName(depComp)}" must be in declarations or imported`);
1540
+ }
1541
+ }
1542
+ });
1543
+ }
1544
+ });
1545
+ });
1546
+ return { valid: errors.length === 0, errors };
1547
+ }
1548
+ collectAllNodes(node, collected, visited = /* @__PURE__ */ new Set()) {
1549
+ if (visited.has(node.name))
1550
+ return;
1551
+ visited.add(node.name);
1552
+ collected.set(node.name, node);
1553
+ node.getChildren().forEach((child) => this.collectAllNodes(child, collected, visited));
1554
+ }
1555
+ findProvidingModule(token, fromNode, allNodes, visited = /* @__PURE__ */ new Set()) {
1556
+ if (visited.has(fromNode.name))
1557
+ return null;
1558
+ visited.add(fromNode.name);
1559
+ for (const child of fromNode.getChildren()) {
1560
+ if (child.getTokens().has(token) && child.getExports().has(token)) {
1561
+ return child.name;
1562
+ }
1563
+ const found = this.findProvidingModule(token, child, allNodes, visited);
1564
+ if (found)
1565
+ return found;
1566
+ }
1567
+ return null;
1568
+ }
1569
+ getProviderToken(provider) {
1570
+ return typeof provider === "function" ? provider : provider.provide;
1571
+ }
1572
+ extractDependencies(item) {
1573
+ if (typeof item === "object" && "deps" in item && item.deps)
1574
+ return item.deps;
1575
+ if (typeof item === "object" && item.useClass)
1576
+ return this.getConstructorDependencies(item.useClass);
1577
+ if (typeof item === "function")
1578
+ return this.getConstructorDependencies(item);
1579
+ return [];
1580
+ }
1581
+ getConstructorDependencies(constructor) {
1582
+ const injectTokens = Reflect.getOwnMetadata(INJECT_TOKENS_KEY, constructor) || /* @__PURE__ */ new Map();
1583
+ const paramTypes = Reflect.getMetadata(DESIGN_PARAMTYPES, constructor) || [];
1584
+ return paramTypes.map((type, index) => {
1585
+ const injected = injectTokens.get(index);
1586
+ if (injected?.maybe) {
1587
+ return null;
1588
+ }
1589
+ return injected?.token ?? type;
1590
+ }).filter((token) => Boolean(token));
1591
+ }
1592
+ isDynamicModule(m) {
1593
+ return typeof m === "object" && "module" in m;
1594
+ }
1595
+ getImports(m) {
1596
+ if (this.isDynamicModule(m))
1597
+ return m.imports || [];
1598
+ return Reflect.getMetadata(IMPORTS_KEY, m) || [];
1599
+ }
1600
+ getProviders(m) {
1601
+ if (this.isDynamicModule(m))
1602
+ return m.providers || [];
1603
+ return Reflect.getMetadata(PROVIDERS_KEY, m) || [];
1604
+ }
1605
+ getControllers(m) {
1606
+ if (this.isDynamicModule(m))
1607
+ return m.controllers || [];
1608
+ return Reflect.getMetadata(CONTROLLERS_KEY, m) || [];
1609
+ }
1610
+ getDeclarations(m) {
1611
+ if (this.isDynamicModule(m))
1612
+ return m.declarations || [];
1613
+ return Reflect.getMetadata(DECLARATIONS_KEY, m) || [];
1614
+ }
1615
+ getExports(m) {
1616
+ if (this.isDynamicModule(m))
1617
+ return m.exports || [];
1618
+ return Reflect.getMetadata(EXPORTS_KEY, m) || [];
1619
+ }
1620
+ printDAG(node, indent = "", visited = /* @__PURE__ */ new Set()) {
1621
+ if (visited.has(node.name)) {
1622
+ console.log(`${indent}${node.name} (circular)`);
1623
+ return;
1624
+ }
1625
+ visited.add(node.name);
1626
+ console.log(`${indent}${node.name}`);
1627
+ const tokens = node.getTokens();
1628
+ if (tokens.size > 0) {
1629
+ console.log(`${indent}\u251C\u2500 Tokens:`);
1630
+ Array.from(tokens.entries()).forEach(([token, deps], i, arr) => {
1631
+ const prefix = i === arr.length - 1 ? "\u2514\u2500" : "\u251C\u2500";
1632
+ const tokenName = typeof token === "function" ? token.name : String(token);
1633
+ const depStr = deps.length ? ` \u2192 [${deps.map((d) => typeof d === "function" ? d.name : String(d)).join(", ")}]` : "";
1634
+ console.log(`${indent}\u2502 ${prefix} ${tokenName}${depStr}`);
1635
+ });
1636
+ }
1637
+ const exports = node.getExports();
1638
+ if (exports.size > 0) {
1639
+ const names = Array.from(exports).map((t) => typeof t === "function" ? t.name : String(t));
1640
+ console.log(`${indent}\u251C\u2500 Exports: [${names.join(", ")}]`);
1641
+ }
1642
+ const children = node.getChildren();
1643
+ if (children.length > 0) {
1644
+ console.log(`${indent}\u2514\u2500 Imports:`);
1645
+ children.forEach((child, i) => {
1646
+ const isLast = i === children.length - 1;
1647
+ const childIndent = indent + (isLast ? " " : "\u2502 ");
1648
+ this.printDAG(child, childIndent, new Set(visited));
1649
+ });
1650
+ }
1651
+ }
1652
+ };
1653
+
1654
+ // src/shared/module/injector.ts
1655
+ var Injector = class {
1656
+ constructor(providers, parent) {
1657
+ this.instanceCache = /* @__PURE__ */ new Map();
1658
+ this.providerMap = /* @__PURE__ */ new Map();
1659
+ this.parent = parent;
1660
+ providers.forEach((p) => {
1661
+ const normalized = ProviderNormalizer.normalize(p);
1662
+ this.providerMap.set(normalized.provide, normalized);
1663
+ });
1664
+ }
1665
+ addProvider(provider) {
1666
+ const normalized = ProviderNormalizer.normalize(provider);
1667
+ this.providerMap.set(normalized.provide, normalized);
1668
+ }
1669
+ resolve(token) {
1670
+ if (this.instanceCache.has(token)) {
1671
+ return this.instanceCache.get(token);
1672
+ }
1673
+ const provider = this.providerMap.get(token);
1674
+ if (!provider) {
1675
+ if (this.parent) {
1676
+ return this.parent.resolve(token);
1677
+ }
1678
+ throw new Error(
1679
+ `No provider for token: ${typeof token === "function" ? token.name : String(token)}`
1680
+ );
1681
+ }
1682
+ const instance = this.createInstance(provider);
1683
+ if (provider.scope !== "transient") {
1684
+ this.instanceCache.set(token, instance);
1685
+ }
1686
+ return instance;
1687
+ }
1688
+ createInstance(provider) {
1689
+ if ("useValue" in provider && provider.useValue !== void 0)
1690
+ return provider.useValue;
1691
+ if (provider.useExisting)
1692
+ return this.resolve(provider.useExisting);
1693
+ if (provider.useFactory) {
1694
+ const deps2 = (provider.deps || []).map((d) => this.resolve(d));
1695
+ return provider.useFactory(...deps2);
1696
+ }
1697
+ const Ctor = provider.useClass || provider.provide;
1698
+ const deps = provider.deps || this.getConstructorDeps(Ctor);
1699
+ return new Ctor(...deps.map((d) => this.resolve(d)));
1700
+ }
1701
+ getConstructorDeps(ctor) {
1702
+ const injectTokens = Reflect.getOwnMetadata(INJECT_TOKENS_KEY, ctor) || /* @__PURE__ */ new Map();
1703
+ const paramTypes = Reflect.getMetadata(DESIGN_PARAMTYPES, ctor) || [];
1704
+ return paramTypes.map((type, index) => {
1705
+ const injected = injectTokens.get(index);
1706
+ return injected?.token ?? type;
1707
+ }).filter((token) => Boolean(token));
1708
+ }
1709
+ };
1710
+ function collectAllProvidersFromNode(node, collected = /* @__PURE__ */ new Set()) {
1711
+ node.getProviders().forEach((p) => collected.add(p));
1712
+ node.getChildren().forEach((child) => collectAllProvidersFromNode(child, collected));
1713
+ return Array.from(collected);
1714
+ }
1715
+
1716
+ // src/shared/module/context.ts
1717
+ var currentInjector = null;
1718
+ function setCurrentInjector(injector) {
1719
+ currentInjector = injector;
1720
+ }
1721
+ function getCurrentInjector() {
1722
+ return currentInjector;
1723
+ }
1724
+
1725
+ // node_modules/uuid/dist/stringify.js
1726
+ var byteToHex = [];
1727
+ for (let i = 0; i < 256; ++i) {
1728
+ byteToHex.push((i + 256).toString(16).slice(1));
1729
+ }
1730
+ function unsafeStringify(arr, offset = 0) {
1731
+ return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
1732
+ }
1733
+
1734
+ // node_modules/uuid/dist/rng.js
1735
+ var getRandomValues;
1736
+ var rnds8 = new Uint8Array(16);
1737
+ function rng() {
1738
+ if (!getRandomValues) {
1739
+ if (typeof crypto === "undefined" || !crypto.getRandomValues) {
1740
+ throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
1741
+ }
1742
+ getRandomValues = crypto.getRandomValues.bind(crypto);
1743
+ }
1744
+ return getRandomValues(rnds8);
1745
+ }
1746
+
1747
+ // node_modules/uuid/dist/native.js
1748
+ var randomUUID = typeof crypto !== "undefined" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
1749
+ var native_default = { randomUUID };
1750
+
1751
+ // node_modules/uuid/dist/v4.js
1752
+ function _v4(options, buf, offset) {
1753
+ options = options || {};
1754
+ const rnds = options.random ?? options.rng?.() ?? rng();
1755
+ if (rnds.length < 16) {
1756
+ throw new Error("Random bytes length must be >= 16");
1757
+ }
1758
+ rnds[6] = rnds[6] & 15 | 64;
1759
+ rnds[8] = rnds[8] & 63 | 128;
1760
+ if (buf) {
1761
+ offset = offset || 0;
1762
+ if (offset < 0 || offset + 16 > buf.length) {
1763
+ throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
1764
+ }
1765
+ for (let i = 0; i < 16; ++i) {
1766
+ buf[offset + i] = rnds[i];
1767
+ }
1768
+ return buf;
1769
+ }
1770
+ return unsafeStringify(rnds);
1771
+ }
1772
+ function v4(options, buf, offset) {
1773
+ if (native_default.randomUUID && !buf && !options) {
1774
+ return native_default.randomUUID();
1775
+ }
1776
+ return _v4(options, buf, offset);
1777
+ }
1778
+ var v4_default = v4;
1779
+
1780
+ // src/shared/jsx/jsx-runtime.ts
1781
+ function jsx(type, config, maybeKey) {
1782
+ const key = maybeKey !== void 0 ? maybeKey : config?.key ?? null;
1783
+ const props = {};
1784
+ if (config) {
1785
+ for (const propName in config) {
1786
+ if (propName === "key")
1787
+ continue;
1788
+ if (propName === "ref")
1789
+ continue;
1790
+ props[propName] = config[propName];
1791
+ }
1792
+ }
1793
+ if (props.children !== void 0) {
1794
+ props.children = normalizeChildren(props.children);
1795
+ }
1796
+ if (typeof type === "function" && type.defaultProps) {
1797
+ for (const propName in type.defaultProps) {
1798
+ if (props[propName] === void 0) {
1799
+ props[propName] = type.defaultProps[propName];
1800
+ }
1801
+ }
1802
+ }
1803
+ return createVNode(type, props, key);
1804
+ }
1805
+ var jsxs = jsx;
1806
+ function Fragment(props) {
1807
+ return {
1808
+ $$typeof: ORCA_ELEMENT_TYPE,
1809
+ type: ORCA_FRAGMENT_TYPE,
1810
+ id: "00000000-0000-0000-0000-000000000000",
1811
+ props,
1812
+ key: null
1813
+ };
1814
+ }
1815
+ function createVNode(type, props, key) {
1816
+ return {
1817
+ $$typeof: ORCA_ELEMENT_TYPE,
1818
+ id: v4_default(),
1819
+ type,
1820
+ props,
1821
+ key
1822
+ };
1823
+ }
1824
+ function normalizeChildren(children) {
1825
+ if (children === null || children === void 0) {
1826
+ return null;
1827
+ }
1828
+ if (!Array.isArray(children)) {
1829
+ return normalizeChild(children);
1830
+ }
1831
+ const normalized = [];
1832
+ for (let i = 0; i < children.length; i++) {
1833
+ const child = normalizeChild(children[i]);
1834
+ if (child === null)
1835
+ continue;
1836
+ if (Array.isArray(child)) {
1837
+ normalized.push(...child);
1838
+ } else {
1839
+ normalized.push(child);
1840
+ }
1841
+ }
1842
+ if (normalized.length === 0)
1843
+ return null;
1844
+ if (normalized.length === 1)
1845
+ return normalized[0];
1846
+ return normalized;
1847
+ }
1848
+ function normalizeChild(child) {
1849
+ if (child === null || child === void 0 || typeof child === "boolean") {
1850
+ return null;
1851
+ }
1852
+ if (typeof child === "number") {
1853
+ return String(child);
1854
+ }
1855
+ if (typeof child === "string" || child.$$typeof === ORCA_ELEMENT_TYPE) {
1856
+ return child;
1857
+ }
1858
+ if (Array.isArray(child)) {
1859
+ return child.map(normalizeChild).filter((c) => c !== null);
1860
+ }
1861
+ return String(child);
1862
+ }
1863
+ function isClassComponent(jsx2) {
1864
+ return typeof jsx2.type === "function" && jsx2.type.prototype && typeof jsx2.type.prototype.build === "function";
1865
+ }
1866
+ function isIntrinsicElement(jsx2) {
1867
+ return typeof jsx2.type === "string";
1868
+ }
1869
+ function isFragment(jsx2) {
1870
+ return typeof jsx2.type === "function" && jsx2.type()?.type == ORCA_FRAGMENT_TYPE;
1871
+ }
1872
+
1873
+ // src/shared/renderers/string.ts
1874
+ var StringRenderer = class {
1875
+ constructor(rootInjector) {
1876
+ this.rootInjector = rootInjector;
1877
+ }
1878
+ render(vnode, parentInjector = this.rootInjector) {
1879
+ if (typeof vnode.type === "function") {
1880
+ const ComponentClass = vnode.type;
1881
+ const isComponent = Reflect.getMetadata(COMPONENT, ComponentClass);
1882
+ let componentInjector = parentInjector;
1883
+ if (isComponent) {
1884
+ const localProviders = Reflect.getMetadata(COMPONENT_PROVIDERS, ComponentClass) || [];
1885
+ if (localProviders.length > 0) {
1886
+ componentInjector = new Injector(
1887
+ localProviders.map((p) => ProviderNormalizer.normalize(p)),
1888
+ parentInjector
1889
+ );
1890
+ }
1891
+ }
1892
+ const instance = componentInjector.resolve(ComponentClass);
1893
+ instance.props = vnode.props || {};
1894
+ const childVNode = instance.build();
1895
+ return this.render(childVNode, componentInjector);
1896
+ }
1897
+ if (typeof vnode.type === "string") {
1898
+ const { children, ...attrs } = vnode.props;
1899
+ const attrsStr = Object.entries(attrs).map(([key, value]) => {
1900
+ if (value === true)
1901
+ return key;
1902
+ if (value === false || value === null || value === void 0)
1903
+ return "";
1904
+ return `${key}="${this.escapeHtml(String(value))}"`;
1905
+ }).filter(Boolean).join(" ");
1906
+ const openTag = attrsStr ? `<${vnode.type} ${attrsStr}>` : `<${vnode.type}>`;
1907
+ const selfClosing = ["img", "br", "hr", "input", "meta", "link"];
1908
+ if (selfClosing.includes(vnode.type)) {
1909
+ return attrsStr ? `<${vnode.type} ${attrsStr} />` : `<${vnode.type} />`;
1910
+ }
1911
+ let childrenHtml = "";
1912
+ if (children !== void 0 && children !== null) {
1913
+ if (Array.isArray(children)) {
1914
+ childrenHtml = children.map((child) => {
1915
+ if (typeof child === "string" || typeof child === "number") {
1916
+ return this.escapeHtml(String(child));
1917
+ }
1918
+ return this.render(child, parentInjector);
1919
+ }).join("");
1920
+ } else if (typeof children === "object" && "type" in children) {
1921
+ childrenHtml = this.render(children, parentInjector);
1922
+ } else {
1923
+ childrenHtml = this.escapeHtml(String(children));
1924
+ }
1925
+ }
1926
+ return `${openTag}${childrenHtml}</${vnode.type}>`;
1927
+ }
1928
+ return "";
1929
+ }
1930
+ escapeHtml(text) {
1931
+ const map = {
1932
+ "&": "&amp;",
1933
+ "<": "&lt;",
1934
+ ">": "&gt;",
1935
+ '"': "&quot;",
1936
+ "'": "&#039;"
1937
+ };
1938
+ return text.replace(/[&<>"']/g, (m) => map[m]);
1939
+ }
1940
+ };
1941
+
1942
+ // src/shared/renderers/stream.ts
1943
+ var StreamRenderer = class {
1944
+ constructor(rootInjector, options = {}) {
1945
+ this.rootInjector = rootInjector;
1946
+ this.pending = /* @__PURE__ */ new Map();
1947
+ this.processedIds = /* @__PURE__ */ new Set();
1948
+ this.queueResolvers = [];
1949
+ this.pushQueue = (u) => this.queueResolvers.shift()?.(u);
1950
+ this.options = {
1951
+ timeout: options.timeout ?? 3e4
1952
+ };
1953
+ }
1954
+ render(vnode, parentInjector = this.rootInjector) {
1955
+ return this.stream(vnode, parentInjector);
1956
+ }
1957
+ async *stream(vnode, parentInjector) {
1958
+ this.pending.clear();
1959
+ this.queueResolvers = [];
1960
+ this.renderingNodes = /* @__PURE__ */ new WeakSet();
1961
+ this.processedIds.clear();
1962
+ const nextUpdate = () => new Promise((resolve) => this.queueResolvers.push(resolve));
1963
+ try {
1964
+ const root = this.buildSyncTree(vnode, parentInjector);
1965
+ yield { ...root, action: "insert" };
1966
+ while (this.pending.size > 0) {
1967
+ const update = await nextUpdate();
1968
+ yield update;
1969
+ }
1970
+ } finally {
1971
+ this.cleanup();
1972
+ }
1973
+ }
1974
+ buildSyncTree(vnode, injector) {
1975
+ if (vnode == null || typeof vnode !== "object")
1976
+ return vnode;
1977
+ if (vnode.$$typeof !== ORCA_ELEMENT_TYPE)
1978
+ return vnode;
1979
+ if (this.renderingNodes.has(vnode)) {
1980
+ throw new Error(
1981
+ `Circular reference detected while rendering component "${vnode.type?.name}".`
1982
+ );
1983
+ }
1984
+ this.renderingNodes.add(vnode);
1985
+ try {
1986
+ if (isClassComponent(vnode)) {
1987
+ return this.renderClassComponent(vnode, injector);
1988
+ }
1989
+ if (isIntrinsicElement(vnode)) {
1990
+ return {
1991
+ $$typeof: ORCA_ELEMENT_TYPE,
1992
+ type: vnode.type,
1993
+ id: vnode.id,
1994
+ props: {
1995
+ ...vnode.props,
1996
+ children: this.mapChildren(vnode.props?.children, injector)
1997
+ },
1998
+ key: vnode.key ?? null
1999
+ };
2000
+ }
2001
+ if (isFragment(vnode)) {
2002
+ return {
2003
+ $$typeof: ORCA_ELEMENT_TYPE,
2004
+ type: null,
2005
+ id: vnode.id,
2006
+ props: {
2007
+ children: this.mapChildren(vnode.props?.children, injector)
2008
+ },
2009
+ key: null
2010
+ };
2011
+ }
2012
+ return vnode;
2013
+ } finally {
2014
+ this.renderingNodes.delete(vnode);
2015
+ }
2016
+ }
2017
+ renderClassComponent(vnode, injector) {
2018
+ const ComponentClass = vnode.type;
2019
+ const isComponent = Reflect.getMetadata(COMPONENT, ComponentClass);
2020
+ let componentInjector = injector;
2021
+ if (isComponent) {
2022
+ const localProviders = Reflect.getMetadata(COMPONENT_PROVIDERS, ComponentClass) || [];
2023
+ if (localProviders.length > 0) {
2024
+ componentInjector = new Injector(
2025
+ localProviders.map((p) => ProviderNormalizer.normalize(p)),
2026
+ injector
2027
+ );
2028
+ }
2029
+ }
2030
+ const instance = componentInjector.resolve(ComponentClass);
2031
+ instance.props = vnode.props || {};
2032
+ const childVNode = instance.build();
2033
+ if (childVNode instanceof Promise) {
2034
+ return this.createPendingReference(vnode, childVNode, componentInjector);
2035
+ }
2036
+ return this.buildSyncTree(childVNode, componentInjector);
2037
+ }
2038
+ mapChildren(children, injector) {
2039
+ if (children == null || typeof children === "string" || typeof children === "number") {
2040
+ return children;
2041
+ }
2042
+ if (Array.isArray(children)) {
2043
+ return children.map((c) => this.buildSyncTree(c, injector));
2044
+ }
2045
+ return this.buildSyncTree(children, injector);
2046
+ }
2047
+ createPendingReference(vnode, promise, injector) {
2048
+ const id = vnode.id;
2049
+ const abortController = new AbortController();
2050
+ const timeoutPromise = new Promise((_, reject) => {
2051
+ const timeoutId = setTimeout(() => {
2052
+ abortController.abort();
2053
+ reject(
2054
+ new Error(
2055
+ `Component ${vnode.type.name || "Unknown"} timed out after ${this.options.timeout}ms`
2056
+ )
2057
+ );
2058
+ }, this.options.timeout);
2059
+ abortController.signal.addEventListener("abort", () => {
2060
+ clearTimeout(timeoutId);
2061
+ });
2062
+ });
2063
+ const raced = Promise.race([promise, timeoutPromise]).then((result) => {
2064
+ result.id = vnode.id;
2065
+ return this.buildSyncTree(result, injector);
2066
+ }).catch((err) => Promise.reject({ id, error: err }));
2067
+ this.pending.set(id, { abortController, promise: raced });
2068
+ raced.then((resolved) => {
2069
+ if (this.processedIds.has(id))
2070
+ return;
2071
+ this.processedIds.add(id);
2072
+ this.pushQueue({
2073
+ ...resolved,
2074
+ action: "update"
2075
+ });
2076
+ this.pending.delete(id);
2077
+ }).catch((e) => {
2078
+ this.pushQueue({
2079
+ $$typeof: ERROR_ELEMENT,
2080
+ type: "error",
2081
+ action: "error",
2082
+ id,
2083
+ props: {
2084
+ message: String(e?.error) || String(e)
2085
+ },
2086
+ key: null
2087
+ });
2088
+ this.pending.delete(id);
2089
+ });
2090
+ return {
2091
+ $$typeof: PENDING_REFERENCE_TYPE,
2092
+ id,
2093
+ type: "ref",
2094
+ props: vnode.props,
2095
+ key: vnode.key ?? null
2096
+ };
2097
+ }
2098
+ cleanup() {
2099
+ for (const { abortController } of this.pending.values()) {
2100
+ abortController.abort();
2101
+ }
2102
+ this.pending.clear();
2103
+ this.processedIds.clear();
2104
+ this.queueResolvers.length = 0;
2105
+ }
2106
+ cancel() {
2107
+ this.cleanup();
2108
+ }
2109
+ async renderToCompletion(jsx2) {
2110
+ const out = [];
2111
+ for await (const upd of this.stream(jsx2, this.rootInjector)) {
2112
+ out.push(upd);
2113
+ }
2114
+ return out;
2115
+ }
2116
+ };
2117
+
2118
+ // src/shared/renderers/vnode.ts
2119
+ var VNode = class {
2120
+ constructor(dom, cb) {
2121
+ this.dom = dom;
2122
+ this.cb = cb;
2123
+ this.children = [];
2124
+ }
2125
+ setId(id) {
2126
+ this.id = id;
2127
+ }
2128
+ addChild(child) {
2129
+ child.parent = this;
2130
+ this.children.push(child);
2131
+ return child;
2132
+ }
2133
+ removeChild(child) {
2134
+ const index = this.children.indexOf(child);
2135
+ if (index > -1) {
2136
+ this.children.splice(index, 1);
2137
+ child.parent = void 0;
2138
+ }
2139
+ }
2140
+ findById(id) {
2141
+ if (this.id === id)
2142
+ return this;
2143
+ for (const child of this.children) {
2144
+ const found = child.findById(id);
2145
+ if (found)
2146
+ return found;
2147
+ }
2148
+ return null;
2149
+ }
2150
+ attach(nw) {
2151
+ if (this.cb) {
2152
+ this.cb(this.dom, nw);
2153
+ } else {
2154
+ if (this.dom.parentNode) {
2155
+ this.dom.parentNode.replaceChild(nw, this.dom);
2156
+ }
2157
+ }
2158
+ this.dom = nw;
2159
+ }
2160
+ unmount() {
2161
+ for (const child of this.children) {
2162
+ child.unmount();
2163
+ }
2164
+ if (this.dom.parentNode) {
2165
+ this.dom.parentNode.removeChild(this.dom);
2166
+ }
2167
+ if (this.parent) {
2168
+ this.parent.removeChild(this);
2169
+ }
2170
+ }
2171
+ };
2172
+
2173
+ // src/shared/json.ts
2174
+ function symbolValueReplacer(key, value) {
2175
+ if (typeof value === "symbol") {
2176
+ return `@@Symbol:${value.description}`;
2177
+ }
2178
+ return value;
2179
+ }
2180
+ function symbolValueReviver(key, value) {
2181
+ if (typeof value === "string" && value.startsWith("@@Symbol:")) {
2182
+ return Symbol.for(value.slice(9));
2183
+ }
2184
+ return value;
2185
+ }
2186
+
2187
+ // src/shared/signal/signal.ts
2188
+ var currentEffect = null;
2189
+ function signal(initialValue) {
2190
+ let value = initialValue;
2191
+ const subscribers = /* @__PURE__ */ new Set();
2192
+ const notify = () => {
2193
+ subscribers.forEach((sub) => sub());
2194
+ };
2195
+ return {
2196
+ _isSignal: true,
2197
+ _subscribers: subscribers,
2198
+ get value() {
2199
+ if (currentEffect) {
2200
+ subscribers.add(currentEffect);
2201
+ }
2202
+ return value;
2203
+ },
2204
+ set value(newValue) {
2205
+ if (value !== newValue) {
2206
+ value = newValue;
2207
+ notify();
2208
+ }
2209
+ }
2210
+ };
2211
+ }
2212
+ function effect(fn) {
2213
+ const execute = () => {
2214
+ currentEffect = execute;
2215
+ try {
2216
+ fn();
2217
+ } finally {
2218
+ currentEffect = null;
2219
+ }
2220
+ };
2221
+ execute();
2222
+ return () => {
2223
+ currentEffect = null;
2224
+ };
2225
+ }
2226
+ function computed(fn) {
2227
+ const sig = signal(fn());
2228
+ effect(() => {
2229
+ sig.value = fn();
2230
+ });
2231
+ return sig;
2232
+ }
2233
+ function isSignal(value) {
2234
+ return value && value._isSignal === true;
2235
+ }
2236
+
2237
+ // src/shared/observable/observable.ts
2238
+ var Observable = class {
2239
+ constructor(producer) {
2240
+ this.producer = producer;
2241
+ this.__isObservable = true;
2242
+ this.subscribers = /* @__PURE__ */ new Set();
2243
+ }
2244
+ get $value() {
2245
+ return this._value;
2246
+ }
2247
+ setValue(newValue) {
2248
+ this._value = newValue;
2249
+ }
2250
+ subscribe(observerOrNext, error, complete) {
2251
+ const observer = typeof observerOrNext === "function" ? { next: observerOrNext, error, complete } : observerOrNext;
2252
+ this.subscribers.add(observer);
2253
+ let cleanup;
2254
+ if (this.producer) {
2255
+ try {
2256
+ cleanup = this.producer(observer);
2257
+ } catch (err) {
2258
+ if (observer.error) {
2259
+ observer.error(err);
2260
+ }
2261
+ }
2262
+ }
2263
+ return {
2264
+ unsubscribe: () => {
2265
+ this.subscribers.delete(observer);
2266
+ if (cleanup)
2267
+ cleanup();
2268
+ }
2269
+ };
2270
+ }
2271
+ next(value) {
2272
+ this.setValue(value);
2273
+ this.subscribers.forEach((observer) => {
2274
+ try {
2275
+ observer.next(value);
2276
+ } catch (err) {
2277
+ console.error("Error in observer:", err);
2278
+ }
2279
+ });
2280
+ }
2281
+ error(err) {
2282
+ this.subscribers.forEach((observer) => {
2283
+ if (observer.error) {
2284
+ try {
2285
+ observer.error(err);
2286
+ } catch (e) {
2287
+ console.error("Error in error handler:", e);
2288
+ }
2289
+ }
2290
+ });
2291
+ }
2292
+ complete() {
2293
+ this.subscribers.forEach((observer) => {
2294
+ if (observer.complete) {
2295
+ try {
2296
+ observer.complete();
2297
+ } catch (err) {
2298
+ console.error("Error in complete handler:", err);
2299
+ }
2300
+ }
2301
+ });
2302
+ this.subscribers.clear();
2303
+ }
2304
+ pipe(...operations) {
2305
+ if (operations.length === 0) {
2306
+ return this;
2307
+ }
2308
+ return operations.reduce((prev, fn) => fn(prev), this);
2309
+ }
2310
+ };
2311
+ function from(iterable) {
2312
+ return new Observable((observer) => {
2313
+ for (const value of iterable) {
2314
+ observer.next(value);
2315
+ }
2316
+ observer.complete?.();
2317
+ });
2318
+ }
2319
+ function interval(ms) {
2320
+ return new Observable((observer) => {
2321
+ let count = 0;
2322
+ const id = setInterval(() => {
2323
+ observer.next(count++);
2324
+ }, ms);
2325
+ return () => clearInterval(id);
2326
+ });
2327
+ }
2328
+ function of(...values) {
2329
+ return new Observable((observer) => {
2330
+ values.forEach((value) => observer.next(value));
2331
+ observer.complete?.();
2332
+ });
2333
+ }
2334
+ function observable(producer) {
2335
+ return new Observable(producer);
2336
+ }
2337
+ function toSignal(obs, instance) {
2338
+ const sig = signal(void 0);
2339
+ const subst = obs.subscribe((val) => {
2340
+ sig.value = val;
2341
+ });
2342
+ instance.__drop = [...instance.__drop ?? [], () => subst.unsubscribe()];
2343
+ return sig;
2344
+ }
2345
+ function isObservable(value) {
2346
+ return value && value.__isObservable === true;
2347
+ }
2348
+
2349
+ // src/shared/component.ts
2350
+ var OrcaComponent = class {
2351
+ constructor() {
2352
+ this.__cleanup = [];
2353
+ }
2354
+ onDestory() {
2355
+ this.__cleanup.forEach((cb) => cb());
2356
+ }
2357
+ pushDrop(fn) {
2358
+ this.__cleanup.push(fn);
2359
+ }
2360
+ };
2361
+
2362
+ // src/shared/module_libs/router_module/navigate.ts
2363
+ var __decorate = function(decorators, target, key, desc) {
2364
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2365
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2366
+ r = Reflect.decorate(decorators, target, key, desc);
2367
+ else
2368
+ for (var i = decorators.length - 1; i >= 0; i--)
2369
+ if (d = decorators[i])
2370
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2371
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
2372
+ };
2373
+ var __metadata = function(k, v) {
2374
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
2375
+ return Reflect.metadata(k, v);
2376
+ };
2377
+ var __param = function(paramIndex, decorator) {
2378
+ return function(target, key) {
2379
+ decorator(target, key, paramIndex);
2380
+ };
2381
+ };
2382
+ var Navigate = class Navigate2 {
2383
+ constructor(oscUrl) {
2384
+ this.oscUrl = oscUrl;
2385
+ this.pages = from([]);
2386
+ this.cursor = 0;
2387
+ const initialState = history.state?.cursor ?? 0;
2388
+ this.cursor = initialState;
2389
+ if (!history.state) {
2390
+ history.replaceState({ cursor: 0 }, "");
2391
+ }
2392
+ window.addEventListener("popstate", (e) => {
2393
+ const newIndex = e.state?.cursor ?? 0;
2394
+ this.cursor = newIndex;
2395
+ this.pages.next([...this.pages.$value || []]);
2396
+ });
2397
+ }
2398
+ getHome() {
2399
+ const http = new HttpClient();
2400
+ return http.post(this.oscUrl, {
2401
+ stream: "ndjson",
2402
+ reviver: symbolValueReviver
2403
+ });
2404
+ }
2405
+ push(component) {
2406
+ const currentPages = this.pages.$value || [];
2407
+ const newPages = currentPages.slice(0, this.cursor + 1);
2408
+ this.cursor++;
2409
+ newPages.push(component);
2410
+ history.pushState({ cursor: this.cursor }, "");
2411
+ this.pages.next(newPages);
2412
+ }
2413
+ replace(component) {
2414
+ const currentPages = [...this.pages.$value || []];
2415
+ currentPages[this.cursor] = component;
2416
+ history.replaceState({ cursor: this.cursor }, "");
2417
+ this.pages.next(currentPages);
2418
+ }
2419
+ goBack() {
2420
+ if (this.cursor > 0) {
2421
+ history.back();
2422
+ }
2423
+ }
2424
+ goForward() {
2425
+ const currentPages = this.pages.$value || [];
2426
+ if (this.cursor < currentPages.length - 1) {
2427
+ history.forward();
2428
+ }
2429
+ }
2430
+ canGoBack() {
2431
+ return this.cursor > 0;
2432
+ }
2433
+ canGoForward() {
2434
+ const currentPages = this.pages.$value || [];
2435
+ return this.cursor < currentPages.length - 1;
2436
+ }
2437
+ getCurrentPage() {
2438
+ const currentPages = this.pages.$value || [];
2439
+ return currentPages[this.cursor];
2440
+ }
2441
+ clear() {
2442
+ this.cursor = 0;
2443
+ this.pages.next([]);
2444
+ history.replaceState({ cursor: 0 }, "");
2445
+ }
2446
+ };
2447
+ Navigate = __decorate([
2448
+ __param(0, Inject("OSC_URL", { maybe: true })),
2449
+ __metadata("design:paramtypes", [String])
2450
+ ], Navigate);
2451
+
2452
+ // src/shared/module_libs/router_module/outlet.ts
2453
+ var __decorate2 = function(decorators, target, key, desc) {
2454
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2455
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2456
+ r = Reflect.decorate(decorators, target, key, desc);
2457
+ else
2458
+ for (var i = decorators.length - 1; i >= 0; i--)
2459
+ if (d = decorators[i])
2460
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2461
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
2462
+ };
2463
+ var __metadata2 = function(k, v) {
2464
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
2465
+ return Reflect.metadata(k, v);
2466
+ };
2467
+ var _a;
2468
+ var RouterOutlet = class RouterOutlet2 extends OrcaComponent {
2469
+ constructor(navigate) {
2470
+ super();
2471
+ this.navigate = navigate;
2472
+ }
2473
+ build() {
2474
+ const anchor = document.createElement("div");
2475
+ const root = document.createElement("div");
2476
+ anchor.appendChild(root);
2477
+ const osc = new OSC(root);
2478
+ const stream = this.navigate.getHome();
2479
+ const streamSubscription = stream.subscribe((jsx2) => {
2480
+ const action = jsx2.action || "insert";
2481
+ if (action === "insert") {
2482
+ osc.handleInsert(jsx2);
2483
+ } else if (action === "update") {
2484
+ osc.handleUpdate(jsx2);
2485
+ } else {
2486
+ console.warn(`Unknown action: ${action}`);
2487
+ }
2488
+ }, () => {
2489
+ }, () => {
2490
+ this.navigate.pages.setValue([osc.tree.dom]);
2491
+ });
2492
+ const subscription = this.navigate.pages.subscribe((pages) => {
2493
+ const top = pages[this.navigate.cursor];
2494
+ anchor.replaceChildren(top);
2495
+ });
2496
+ this.pushDrop(() => subscription.unsubscribe());
2497
+ this.pushDrop(() => streamSubscription.unsubscribe());
2498
+ return anchor;
2499
+ }
2500
+ };
2501
+ RouterOutlet = __decorate2([
2502
+ Component(),
2503
+ __metadata2("design:paramtypes", [typeof (_a = typeof Navigate !== "undefined" && Navigate) === "function" ? _a : Object])
2504
+ ], RouterOutlet);
2505
+
2506
+ // src/shared/module_libs/router_module/module.ts
2507
+ var RouterModule = class _RouterModule {
2508
+ static forRoot() {
2509
+ return {
2510
+ module: _RouterModule,
2511
+ declarations: [RouterOutlet],
2512
+ providers: [Navigate],
2513
+ exports: [Navigate, RouterOutlet]
2514
+ };
2515
+ }
2516
+ };
2517
+
2518
+ // src/shared/module_libs/http_client/module.ts
2519
+ var __decorate3 = function(decorators, target, key, desc) {
2520
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2521
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2522
+ r = Reflect.decorate(decorators, target, key, desc);
2523
+ else
2524
+ for (var i = decorators.length - 1; i >= 0; i--)
2525
+ if (d = decorators[i])
2526
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2527
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
2528
+ };
2529
+ var HttpClient = class HttpClient2 {
2530
+ get(url, { stream = "json", reviver, init } = {}) {
2531
+ return new Observable((subscriber) => {
2532
+ const controller = new AbortController();
2533
+ fetch(url, {
2534
+ method: "GET",
2535
+ ...init,
2536
+ signal: controller.signal
2537
+ }).then(async (res) => {
2538
+ if (!res.ok) {
2539
+ throw new Error(`HTTP ${res.status}: ${res.statusText}`);
2540
+ }
2541
+ if (stream === "json") {
2542
+ const data = await res.json();
2543
+ subscriber.next(reviver ? JSON.parse(JSON.stringify(data), reviver) : data);
2544
+ subscriber.complete?.();
2545
+ return;
2546
+ }
2547
+ if (stream === "raw") {
2548
+ subscriber.next(res);
2549
+ subscriber.complete?.();
2550
+ return;
2551
+ }
2552
+ const reader = res.body?.getReader();
2553
+ if (!reader) {
2554
+ throw new Error("ReadableStream not supported");
2555
+ }
2556
+ const decoder = new TextDecoder();
2557
+ let buffer = "";
2558
+ while (true) {
2559
+ const { done, value } = await reader.read();
2560
+ if (done) {
2561
+ if (stream === "ndjson" && buffer.trim()) {
2562
+ try {
2563
+ subscriber.next(JSON.parse(buffer, reviver));
2564
+ } catch (err) {
2565
+ console.warn("Failed to parse remaining buffer:", err);
2566
+ }
2567
+ }
2568
+ break;
2569
+ }
2570
+ const chunk = decoder.decode(value, { stream: true });
2571
+ if (stream === "text") {
2572
+ subscriber.next(chunk);
2573
+ continue;
2574
+ }
2575
+ if (stream === "ndjson") {
2576
+ buffer += chunk;
2577
+ const lines = buffer.split("\n");
2578
+ buffer = lines.pop();
2579
+ for (const line of lines) {
2580
+ if (line.trim()) {
2581
+ try {
2582
+ subscriber.next(JSON.parse(line, reviver));
2583
+ } catch (err) {
2584
+ console.error("Failed to parse NDJSON line:", line, err);
2585
+ }
2586
+ }
2587
+ }
2588
+ }
2589
+ }
2590
+ subscriber.complete?.();
2591
+ }).catch((err) => {
2592
+ if (err.name === "AbortError") {
2593
+ console.log("Request aborted");
2594
+ }
2595
+ subscriber.error?.(err);
2596
+ });
2597
+ return () => {
2598
+ controller.abort();
2599
+ };
2600
+ });
2601
+ }
2602
+ post(url, { body, stream = "json", reviver, init } = {}) {
2603
+ const headers = new Headers(init?.headers);
2604
+ if (body && !headers.has("Content-Type")) {
2605
+ headers.set("Content-Type", "application/json");
2606
+ }
2607
+ const processedBody = body !== void 0 ? typeof body === "string" ? body : JSON.stringify(body) : void 0;
2608
+ return this.get(url, {
2609
+ stream,
2610
+ reviver,
2611
+ init: {
2612
+ ...init,
2613
+ method: "POST",
2614
+ headers,
2615
+ body: processedBody
2616
+ }
2617
+ });
2618
+ }
2619
+ put(url, options) {
2620
+ return this.request(url, "PUT", options);
2621
+ }
2622
+ patch(url, options) {
2623
+ return this.request(url, "PATCH", options);
2624
+ }
2625
+ delete(url, options) {
2626
+ return this.get(url, {
2627
+ ...options,
2628
+ init: {
2629
+ ...options?.init,
2630
+ method: "DELETE"
2631
+ }
2632
+ });
2633
+ }
2634
+ request(url, method, { body, stream = "json", reviver, init } = {}) {
2635
+ const headers = new Headers(init?.headers);
2636
+ if (body && !headers.has("Content-Type")) {
2637
+ headers.set("Content-Type", "application/json");
2638
+ }
2639
+ const processedBody = body !== void 0 ? typeof body === "string" ? body : JSON.stringify(body) : void 0;
2640
+ return this.get(url, {
2641
+ stream,
2642
+ reviver,
2643
+ init: {
2644
+ ...init,
2645
+ method,
2646
+ headers,
2647
+ body: processedBody
2648
+ }
2649
+ });
2650
+ }
2651
+ };
2652
+ HttpClient = __decorate3([
2653
+ Injectable()
2654
+ ], HttpClient);
2655
+ var HttpClientModule = class HttpClientModule2 {
2656
+ };
2657
+ HttpClientModule = __decorate3([
2658
+ Module({
2659
+ providers: [HttpClient],
2660
+ exports: [HttpClient]
2661
+ })
2662
+ ], HttpClientModule);
2663
+
2664
+ // src/shared/dom/osc.ts
2665
+ var OSC = class {
2666
+ constructor(root) {
2667
+ this.root = root;
2668
+ this.pendingRefs = /* @__PURE__ */ new Map();
2669
+ this.tree = new VNode(root, (old, nw) => {
2670
+ old.replaceChildren(nw);
2671
+ });
2672
+ }
2673
+ handleInsert(jsx2) {
2674
+ const { domNode, vnode } = this.buildDOM(jsx2, this.tree);
2675
+ if (jsx2.id && vnode) {
2676
+ vnode.setId(jsx2.id);
2677
+ }
2678
+ this.tree.attach(domNode);
2679
+ }
2680
+ handleUpdate(jsx2) {
2681
+ if (!jsx2.id) {
2682
+ console.warn("Update action requires an id");
2683
+ return;
2684
+ }
2685
+ const targetVNode = this.tree.findById(jsx2.id);
2686
+ if (targetVNode) {
2687
+ const oldChildren = [...targetVNode.children];
2688
+ targetVNode.children = [];
2689
+ const { domNode, vnode } = this.buildDOM(
2690
+ jsx2,
2691
+ targetVNode.parent || this.tree
2692
+ );
2693
+ targetVNode.attach(domNode);
2694
+ if (vnode) {
2695
+ targetVNode.children = vnode.children;
2696
+ }
2697
+ } else {
2698
+ console.warn(`Update target ${jsx2.id} not found, inserting instead`);
2699
+ this.handleInsert(jsx2);
2700
+ }
2701
+ }
2702
+ buildDOM(jsx2, vparent) {
2703
+ if (jsx2 == null) {
2704
+ return { domNode: document.createDocumentFragment() };
2705
+ }
2706
+ if (Array.isArray(jsx2)) {
2707
+ return this.buildArray(jsx2, vparent);
2708
+ }
2709
+ if (this.isPrimitive(jsx2)) {
2710
+ return this.buildTextNode(String(jsx2), vparent);
2711
+ }
2712
+ if (jsx2.$$typeof === PENDING_REFERENCE_TYPE) {
2713
+ return this.buildPendingReference(jsx2, vparent);
2714
+ }
2715
+ if (jsx2.$$typeof === ORCA_CLIENT_COMPONENT) {
2716
+ return this.buildClientComponent(jsx2, vparent);
2717
+ }
2718
+ if (isIntrinsicElement(jsx2)) {
2719
+ return this.buildIntrinsicElement(jsx2, vparent);
2720
+ }
2721
+ console.error("Unsupported node:", jsx2);
2722
+ throw new Error(
2723
+ `Unsupported node type: ${typeof jsx2}, $typeof: ${String(jsx2.$$typeof)}`
2724
+ );
2725
+ }
2726
+ buildClientComponent(jsx2, parent) {
2727
+ const componentInfo = jsx2.props.__clientComponent;
2728
+ const { id, path, name } = componentInfo;
2729
+ const container = document.createElement("div");
2730
+ container.dataset.clientComponent = id;
2731
+ const vnode = new VNode(container, (old, nw) => {
2732
+ if (old.parentNode) {
2733
+ old.parentNode.replaceChild(nw, old);
2734
+ }
2735
+ });
2736
+ if (jsx2.id) {
2737
+ vnode.setId(jsx2.id);
2738
+ }
2739
+ parent.addChild(vnode);
2740
+ this.loadClientComponent(path, name, jsx2.props, container, vnode);
2741
+ return { domNode: container, vnode };
2742
+ }
2743
+ buildPendingReference(jsx2, parent) {
2744
+ const refId = jsx2.id;
2745
+ const div = document.createElement("div");
2746
+ div.dataset.ref = refId;
2747
+ div.className = "loading";
2748
+ div.textContent = "Loading...";
2749
+ const vnode = new VNode(div, (old, nw) => {
2750
+ if (old.parentNode) {
2751
+ old.parentNode.replaceChild(nw, old);
2752
+ }
2753
+ });
2754
+ vnode.setId(refId);
2755
+ parent.addChild(vnode);
2756
+ const pendingContent = this.pendingRefs.get(refId);
2757
+ if (pendingContent) {
2758
+ setTimeout(() => this.resolvePendingReference(refId, pendingContent), 0);
2759
+ }
2760
+ return { domNode: div, vnode };
2761
+ }
2762
+ resolvePendingReference(refId, content) {
2763
+ const vnode = this.tree.findById(refId);
2764
+ if (!vnode) {
2765
+ console.warn(`Reference ${refId} not found`);
2766
+ this.pendingRefs.set(refId, content);
2767
+ return;
2768
+ }
2769
+ try {
2770
+ vnode.children = [];
2771
+ const { domNode, vnode: newVNode } = this.buildDOM(content, vnode);
2772
+ vnode.attach(domNode);
2773
+ if (newVNode) {
2774
+ vnode.children = newVNode.children;
2775
+ }
2776
+ this.pendingRefs.delete(refId);
2777
+ } catch (error) {
2778
+ console.error(`Error resolving reference ${refId}:`, error);
2779
+ }
2780
+ }
2781
+ buildTextNode(text, parent) {
2782
+ const textNode = document.createTextNode(text);
2783
+ const vnode = new VNode(textNode, (old, nw) => {
2784
+ if (old.parentNode) {
2785
+ old.parentNode.replaceChild(nw, old);
2786
+ }
2787
+ });
2788
+ parent.addChild(vnode);
2789
+ return { domNode: textNode, vnode };
2790
+ }
2791
+ isPrimitive(node) {
2792
+ return typeof node === "string" || typeof node === "number" || typeof node === "boolean";
2793
+ }
2794
+ buildArray(nodes, parent) {
2795
+ const fragment = document.createDocumentFragment();
2796
+ const vnodes = [];
2797
+ nodes.forEach((child) => {
2798
+ const { domNode, vnode } = this.buildDOM(child, parent);
2799
+ fragment.appendChild(domNode);
2800
+ if (vnode) {
2801
+ vnodes.push(vnode);
2802
+ }
2803
+ });
2804
+ return { domNode: fragment };
2805
+ }
2806
+ buildIntrinsicElement(jsx2, parent) {
2807
+ const tag = jsx2.type;
2808
+ const dom = document.createElement(tag);
2809
+ const vnode = new VNode(dom, (old, nw) => {
2810
+ if (old.parentNode) {
2811
+ old.parentNode.replaceChild(nw, old);
2812
+ }
2813
+ });
2814
+ parent.addChild(vnode);
2815
+ if (jsx2.id) {
2816
+ vnode.setId(jsx2.id);
2817
+ }
2818
+ if (jsx2.props) {
2819
+ this.buildAttributes(jsx2.props, dom, vnode);
2820
+ }
2821
+ if (jsx2.props?.children != null) {
2822
+ const { domNode: childDom } = this.buildDOM(jsx2.props.children, vnode);
2823
+ dom.appendChild(childDom);
2824
+ }
2825
+ return { domNode: dom, vnode };
2826
+ }
2827
+ buildAttributes(props, dom, vnode) {
2828
+ for (const [key, value] of Object.entries(props)) {
2829
+ if (key === "children" || value == null) {
2830
+ continue;
2831
+ }
2832
+ const attrKey = this.normalizeAttributeKey(key);
2833
+ if (attrKey === "style" && typeof value === "object") {
2834
+ this.applyStyles(value, dom);
2835
+ continue;
2836
+ }
2837
+ if (typeof value === "boolean") {
2838
+ this.setBooleanAttribute(attrKey, value, dom);
2839
+ continue;
2840
+ }
2841
+ dom.setAttribute(attrKey, String(value));
2842
+ }
2843
+ }
2844
+ normalizeAttributeKey(key) {
2845
+ if (key === "className")
2846
+ return "class";
2847
+ if (key === "htmlFor")
2848
+ return "for";
2849
+ return key;
2850
+ }
2851
+ applyStyles(styles, dom) {
2852
+ const styleString = Object.entries(styles).map(([k, v]) => {
2853
+ const kebabKey = k.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
2854
+ return `${kebabKey}:${v}`;
2855
+ }).join(";");
2856
+ dom.setAttribute("style", styleString);
2857
+ }
2858
+ setBooleanAttribute(key, value, dom) {
2859
+ if (value) {
2860
+ dom.setAttribute(key, "");
2861
+ } else {
2862
+ dom.removeAttribute(key);
2863
+ }
2864
+ }
2865
+ async loadClientComponent(path, name, props, container, vnode) {
2866
+ try {
2867
+ const module = await import(path);
2868
+ const ComponentClass = module[name];
2869
+ const params = Reflect.getMetadata(DESIGN_PARAMTYPES, ComponentClass) || [];
2870
+ const injector = getCurrentInjector();
2871
+ if (injector == null) {
2872
+ throw new Error(`Couldn't find an injector`);
2873
+ }
2874
+ if (!ComponentClass) {
2875
+ throw new Error(`Component ${name} not found in ${path}`);
2876
+ }
2877
+ [...params, ComponentClass].forEach((p) => injector.addProvider(p));
2878
+ const cleanProps = { ...props };
2879
+ delete cleanProps.__clientComponent;
2880
+ const componentInstance = injector.resolve(ComponentClass);
2881
+ componentInstance.__injector = injector;
2882
+ componentInstance.props = cleanProps;
2883
+ if (typeof componentInstance.build === "function") {
2884
+ const rendered = componentInstance.build();
2885
+ container.parentNode?.replaceChild(rendered, container);
2886
+ } else {
2887
+ throw new Error(`Component ${name} does not have a build method`);
2888
+ }
2889
+ } catch (error) {
2890
+ console.error(`Failed to load client component ${name}:`, error);
2891
+ container.textContent = `Error loading component: ${name}`;
2892
+ container.className = "client-component-error";
2893
+ }
2894
+ }
2895
+ };
2896
+
2897
+ // src/shared/macros/index.ts
2898
+ function assert$(context) {
2899
+ return context?.factory.createStringLiteral("assert");
2900
+ }
2901
+
2902
+ // src/browser/index.ts
2903
+ var browser_exports = {};
2904
+ __export(browser_exports, {
2905
+ BrowserFactory: () => BrowserFactory,
2906
+ createComponent: () => createComponent,
2907
+ insert: () => insert,
2908
+ spread: () => spread,
2909
+ style: () => style
2910
+ });
2911
+
2912
+ // src/browser/factory.ts
2913
+ var BrowserFactory = class {
2914
+ static create(rootModule, rootElement) {
2915
+ const compiler = new Compiler();
2916
+ const appNode = compiler.compile(rootModule);
2917
+ const validation = compiler.validate(appNode);
2918
+ if (!validation.valid) {
2919
+ throw new Error(
2920
+ "\u274C Validation failed:\n" + validation.errors.join("\n\n")
2921
+ );
2922
+ }
2923
+ const allProviders = collectAllProvidersFromNode(appNode);
2924
+ const rootInjector = new Injector([
2925
+ ...allProviders,
2926
+ {
2927
+ provide: "OSC_URL",
2928
+ useValue: "/osc"
2929
+ }
2930
+ ]);
2931
+ setCurrentInjector(rootInjector);
2932
+ appNode.traverse((node) => {
2933
+ const providers = [...node.getProviders().values()];
2934
+ providers.filter((provider) => provider.eager).forEach((p) => rootInjector.resolve(p.provide));
2935
+ });
2936
+ const bootstrap = Reflect.getMetadata(BOOTSTRAP, rootModule);
2937
+ const instance = rootInjector.resolve(bootstrap);
2938
+ instance.__injector = rootInjector;
2939
+ const childDom = instance.build();
2940
+ rootElement.appendChild(childDom);
2941
+ }
2942
+ };
2943
+
2944
+ // src/browser/dom/dom.ts
2945
+ var elementEffects = /* @__PURE__ */ new WeakMap();
2946
+ var cleanupObserver = new MutationObserver((mutations) => {
2947
+ mutations.forEach((mutation) => {
2948
+ mutation.removedNodes.forEach((node) => {
2949
+ cleanupElement(node);
2950
+ });
2951
+ });
2952
+ });
2953
+ if (typeof document !== "undefined" && document.body) {
2954
+ cleanupObserver.observe(document.body, {
2955
+ childList: true,
2956
+ subtree: true
2957
+ });
2958
+ } else if (typeof document !== "undefined") {
2959
+ document.addEventListener("DOMContentLoaded", () => {
2960
+ cleanupObserver.observe(document.body, {
2961
+ childList: true,
2962
+ subtree: true
2963
+ });
2964
+ });
2965
+ }
2966
+ function cleanupElement(node) {
2967
+ const cleanups = elementEffects.get(node);
2968
+ if (cleanups) {
2969
+ cleanups.forEach((cleanup, idx) => {
2970
+ cleanup();
2971
+ });
2972
+ elementEffects.delete(node);
2973
+ }
2974
+ if (node.childNodes && node.childNodes.length > 0) {
2975
+ node.childNodes.forEach((child) => cleanupElement(child));
2976
+ }
2977
+ }
2978
+ function registerEffect(el, cleanup) {
2979
+ if (!elementEffects.has(el)) {
2980
+ elementEffects.set(el, []);
2981
+ }
2982
+ elementEffects.get(el).push(cleanup);
2983
+ }
2984
+ function buildDOM(value) {
2985
+ if (value instanceof Node) {
2986
+ return value;
2987
+ }
2988
+ if (typeof value === "string" || typeof value === "number") {
2989
+ return document.createTextNode(String(value));
2990
+ }
2991
+ if (value == null || typeof value === "boolean") {
2992
+ return document.createTextNode("");
2993
+ }
2994
+ if (Array.isArray(value)) {
2995
+ const fragment = document.createDocumentFragment();
2996
+ for (const item of value) {
2997
+ const node = buildDOM(item);
2998
+ fragment.appendChild(node);
2999
+ }
3000
+ return fragment;
3001
+ }
3002
+ console.log("Unhandled value:", value);
3003
+ throw new Error(`Cannot build DOM from value: ${value}`);
3004
+ }
3005
+ function insert(parent, value) {
3006
+ if (value == null)
3007
+ return;
3008
+ let currentDOM;
3009
+ function attach(value2) {
3010
+ const newDOM = buildDOM(value2);
3011
+ if (currentDOM) {
3012
+ if (Array.isArray(currentDOM)) {
3013
+ currentDOM.forEach((node) => {
3014
+ if (node.parentNode) {
3015
+ node.parentNode.removeChild(node);
3016
+ }
3017
+ });
3018
+ } else {
3019
+ if (currentDOM.parentNode) {
3020
+ currentDOM.parentNode.removeChild(currentDOM);
3021
+ }
3022
+ }
3023
+ }
3024
+ if (newDOM instanceof DocumentFragment) {
3025
+ const nodes = Array.from(newDOM.childNodes);
3026
+ parent.appendChild(newDOM);
3027
+ currentDOM = nodes;
3028
+ } else {
3029
+ parent.appendChild(newDOM);
3030
+ currentDOM = newDOM;
3031
+ }
3032
+ }
3033
+ if (isSignal(value)) {
3034
+ const cleanup = effect(() => {
3035
+ attach(value.value);
3036
+ });
3037
+ registerEffect(parent, cleanup);
3038
+ } else if (isObservable(value)) {
3039
+ const obs = value;
3040
+ const subst = obs.subscribe((val) => {
3041
+ attach(val);
3042
+ });
3043
+ registerEffect(parent, () => subst.unsubscribe());
3044
+ } else if (typeof value == "function") {
3045
+ const cleanup = effect(() => {
3046
+ attach(value());
3047
+ });
3048
+ registerEffect(parent, cleanup);
3049
+ } else {
3050
+ const node = buildDOM(value);
3051
+ parent.appendChild(node);
3052
+ }
3053
+ }
3054
+ function autoCleanup(element, callback) {
3055
+ const observer = new MutationObserver(() => {
3056
+ if (!document.contains(element)) {
3057
+ callback();
3058
+ observer.disconnect();
3059
+ }
3060
+ });
3061
+ setTimeout(() => {
3062
+ if (element.parentNode) {
3063
+ observer.observe(document.body, { childList: true, subtree: true });
3064
+ }
3065
+ }, 0);
3066
+ }
3067
+ function createComponent(ComponentClass, props = {}, parentComponent) {
3068
+ let injector = parentComponent.__injector;
3069
+ if (!injector) {
3070
+ throw new Error(`Cannot create component ${ComponentClass.name} outside injection context. No injector available from current context or parent component.`);
3071
+ }
3072
+ const isComponent = Reflect.getMetadata(COMPONENT, ComponentClass);
3073
+ if (!isComponent) {
3074
+ throw new Error(`${ComponentClass.name} is not decorated with @Component()`);
3075
+ }
3076
+ let instance;
3077
+ try {
3078
+ instance = injector.resolve(ComponentClass);
3079
+ } catch (e) {
3080
+ injector.addProvider(ComponentClass);
3081
+ instance = injector.resolve(ComponentClass);
3082
+ }
3083
+ const localProviders = Reflect.getMetadata(COMPONENT_PROVIDERS, ComponentClass) || [];
3084
+ if (localProviders.length > 0) {
3085
+ injector = new Injector(localProviders.map((p) => ProviderNormalizer.normalize(p)), parentComponent.__injector);
3086
+ instance.__injector = injector;
3087
+ }
3088
+ instance.props = props;
3089
+ const root = instance.build();
3090
+ if (!(root instanceof Node)) {
3091
+ throw new Error("Root is not instance of node");
3092
+ }
3093
+ const cleanup = () => {
3094
+ instance.__cleanup?.forEach((cb) => cb());
3095
+ instance.onDestory?.();
3096
+ };
3097
+ if (root.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
3098
+ const firstChild = root.firstChild;
3099
+ if (firstChild) {
3100
+ autoCleanup(firstChild, cleanup);
3101
+ }
3102
+ } else {
3103
+ autoCleanup(root, cleanup);
3104
+ }
3105
+ return root;
3106
+ }
3107
+ function style(el, styleObj) {
3108
+ if (typeof styleObj === "function") {
3109
+ const cleanup = effect(() => {
3110
+ const styles = styleObj();
3111
+ if (!styles)
3112
+ return;
3113
+ for (const key in styles) {
3114
+ const value = styles[key];
3115
+ const actualValue = isSignal(value) ? value.value : value;
3116
+ const cssKey = key.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
3117
+ el.style.setProperty(cssKey, actualValue);
3118
+ }
3119
+ });
3120
+ registerEffect(el, cleanup);
3121
+ return;
3122
+ }
3123
+ if (!styleObj)
3124
+ return;
3125
+ for (const key in styleObj) {
3126
+ const cssKey = key.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
3127
+ el.style.setProperty(cssKey, styleObj[key]);
3128
+ }
3129
+ }
3130
+ function spread(el, attrs) {
3131
+ if (!attrs)
3132
+ return;
3133
+ for (const key in attrs) {
3134
+ const value = attrs[key];
3135
+ if (/^on[A-Z]/.test(key)) {
3136
+ const eventName = key.slice(2).toLowerCase();
3137
+ el.addEventListener(eventName, value);
3138
+ continue;
3139
+ }
3140
+ if (key === "style" && typeof value === "object") {
3141
+ style(el, value);
3142
+ continue;
3143
+ }
3144
+ const attrName = key === "className" ? "class" : key;
3145
+ el.setAttribute(attrName, value);
3146
+ }
3147
+ }
3148
+ export {
3149
+ BOOTSTRAP,
3150
+ BOOTSTRAP_VNODE,
3151
+ Body,
3152
+ BrowserFactory,
3153
+ COMPONENT,
3154
+ COMPONENT_DEPS,
3155
+ COMPONENT_PROVIDERS,
3156
+ CONTROLLER,
3157
+ CONTROLLERS_KEY,
3158
+ CONTROLLER_PREFIX_KEY,
3159
+ Compiler,
3160
+ Component,
3161
+ Controller,
3162
+ DECLARATIONS_KEY,
3163
+ DESIGN_PARAMTYPES,
3164
+ ERROR_ELEMENT,
3165
+ EXPORTS_KEY,
3166
+ EXPRESS_ADAPTER_HOST,
3167
+ Fragment,
3168
+ Get,
3169
+ HTTP_METHOD_KEY,
3170
+ HandlerParamType,
3171
+ HttpClient,
3172
+ HttpClientModule,
3173
+ HttpMethod,
3174
+ IMPORTS_KEY,
3175
+ INJECTABLE,
3176
+ INJECT_TOKENS_KEY,
3177
+ Inject,
3178
+ Injectable,
3179
+ Injector,
3180
+ Module,
3181
+ NODE,
3182
+ Navigate,
3183
+ Node2 as Node,
3184
+ ORCA_CLIENT_COMPONENT,
3185
+ ORCA_ELEMENT_TYPE,
3186
+ ORCA_FRAGMENT_TYPE,
3187
+ OSC,
3188
+ Observable,
3189
+ OrcaComponent,
3190
+ PARAMS_META_KEY,
3191
+ PATH_KEY,
3192
+ PENDING_REFERENCE_TYPE,
3193
+ PROVIDERS_KEY,
3194
+ Param,
3195
+ Post,
3196
+ ProviderNormalizer,
3197
+ RouterModule,
3198
+ RouterOutlet,
3199
+ SIGNATURE_METADATA_KEY,
3200
+ Signature,
3201
+ assert$,
3202
+ browser_exports as browser,
3203
+ collectAllProvidersFromNode,
3204
+ computed,
3205
+ createComponent,
3206
+ effect,
3207
+ from,
3208
+ getCurrentInjector,
3209
+ getSignatureMetadata,
3210
+ hasSignature,
3211
+ insert,
3212
+ interval,
3213
+ isClassComponent,
3214
+ isFragment,
3215
+ isIntrinsicElement,
3216
+ isObservable,
3217
+ isSignal,
3218
+ jsx,
3219
+ jsxs,
3220
+ observable,
3221
+ of,
3222
+ parseSignatureSchemas,
3223
+ setCurrentInjector,
3224
+ shared_exports as shared,
3225
+ signal,
3226
+ spread,
3227
+ style,
3228
+ symbolValueReplacer,
3229
+ symbolValueReviver,
3230
+ toSignal
3231
+ };
3232
+ /*! Bundled license information:
3233
+
3234
+ reflect-metadata/Reflect.js:
3235
+ (*! *****************************************************************************
3236
+ Copyright (C) Microsoft. All rights reserved.
3237
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
3238
+ this file except in compliance with the License. You may obtain a copy of the
3239
+ License at http://www.apache.org/licenses/LICENSE-2.0
3240
+
3241
+ THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
3242
+ KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
3243
+ WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
3244
+ MERCHANTABLITY OR NON-INFRINGEMENT.
3245
+
3246
+ See the Apache Version 2.0 License for specific language governing permissions
3247
+ and limitations under the License.
3248
+ ***************************************************************************** *)
3249
+ */
3250
+ //# sourceMappingURL=index.mjs.map