@ahana-awesome-platform/ahana-electron-sdk 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 (111) hide show
  1. package/dist/cjs/controller/index.d.ts +12 -0
  2. package/dist/cjs/controller/index.d.ts.map +1 -0
  3. package/dist/cjs/controller/index.js +1 -0
  4. package/dist/cjs/ipc/IpcMain.d.ts +20 -0
  5. package/dist/cjs/ipc/IpcMain.d.ts.map +1 -0
  6. package/dist/cjs/ipc/IpcTypes.d.ts +24 -0
  7. package/dist/cjs/ipc/IpcTypes.d.ts.map +1 -0
  8. package/dist/cjs/ipc/index.d.ts +66 -0
  9. package/dist/cjs/ipc/index.d.ts.map +1 -0
  10. package/dist/cjs/ipc/index.js +1 -0
  11. package/dist/cjs/logger/String16.d.ts +11 -0
  12. package/dist/cjs/logger/String16.d.ts.map +1 -0
  13. package/dist/cjs/logger/index.d.ts +104 -0
  14. package/dist/cjs/logger/index.d.ts.map +1 -0
  15. package/dist/cjs/logger/index.js +1 -0
  16. package/dist/cjs/orm/common/logger.d.ts +4 -0
  17. package/dist/cjs/orm/common/logger.d.ts.map +1 -0
  18. package/dist/cjs/orm/index.d.ts +4 -0
  19. package/dist/cjs/orm/index.d.ts.map +1 -0
  20. package/dist/cjs/orm/index.js +1 -0
  21. package/dist/cjs/orm/orm/CheckHealth.d.ts +4 -0
  22. package/dist/cjs/orm/orm/CheckHealth.d.ts.map +1 -0
  23. package/dist/cjs/orm/orm/ExecuteInTransaction.d.ts +5 -0
  24. package/dist/cjs/orm/orm/ExecuteInTransaction.d.ts.map +1 -0
  25. package/dist/cjs/orm/orm/SafeAlterTable.d.ts +8 -0
  26. package/dist/cjs/orm/orm/SafeAlterTable.d.ts.map +1 -0
  27. package/dist/cjs/orm/orm/SqLiteConnection.d.ts +5 -0
  28. package/dist/cjs/orm/orm/SqLiteConnection.d.ts.map +1 -0
  29. package/dist/cjs/orm/sqlite/index.d.ts +10 -0
  30. package/dist/cjs/orm/sqlite/index.d.ts.map +1 -0
  31. package/dist/cjs/platform/index.d.ts +2 -0
  32. package/dist/cjs/platform/index.d.ts.map +1 -0
  33. package/dist/cjs/platform/index.js +1 -0
  34. package/dist/cjs/platform/platform/detector.d.ts +47 -0
  35. package/dist/cjs/platform/platform/detector.d.ts.map +1 -0
  36. package/dist/cjs/platform/platform/registry/index.d.ts +47 -0
  37. package/dist/cjs/platform/platform/registry/index.d.ts.map +1 -0
  38. package/dist/cjs/platform/platform/registry/kylin-registry.d.ts +31 -0
  39. package/dist/cjs/platform/platform/registry/kylin-registry.d.ts.map +1 -0
  40. package/dist/cjs/platform/platform/registry/registry.d.ts +89 -0
  41. package/dist/cjs/platform/platform/registry/registry.d.ts.map +1 -0
  42. package/dist/cjs/platform/platform/registry/windows-registry.d.ts +32 -0
  43. package/dist/cjs/platform/platform/registry/windows-registry.d.ts.map +1 -0
  44. package/dist/cjs/response-factory/factory/AppError.d.ts +8 -0
  45. package/dist/cjs/response-factory/factory/AppError.d.ts.map +1 -0
  46. package/dist/cjs/response-factory/factory/BusinessError.d.ts +70 -0
  47. package/dist/cjs/response-factory/factory/BusinessError.d.ts.map +1 -0
  48. package/dist/cjs/response-factory/index.d.ts +3 -0
  49. package/dist/cjs/response-factory/index.d.ts.map +1 -0
  50. package/dist/cjs/response-factory/index.js +1 -0
  51. package/dist/cjs/response-factory/response/Response.d.ts +15 -0
  52. package/dist/cjs/response-factory/response/Response.d.ts.map +1 -0
  53. package/dist/esm/_commonjsHelpers-Dm6U3U_N.js +35 -0
  54. package/dist/esm/controller/index.d.ts +12 -0
  55. package/dist/esm/controller/index.d.ts.map +1 -0
  56. package/dist/esm/controller/index.js +1128 -0
  57. package/dist/esm/events-CqhjgOaW.js +213 -0
  58. package/dist/esm/index-Dys2BW-7.js +256 -0
  59. package/dist/esm/index-xOyNRTcn.js +21640 -0
  60. package/dist/esm/ipc/IpcMain.d.ts +20 -0
  61. package/dist/esm/ipc/IpcMain.d.ts.map +1 -0
  62. package/dist/esm/ipc/IpcTypes.d.ts +24 -0
  63. package/dist/esm/ipc/IpcTypes.d.ts.map +1 -0
  64. package/dist/esm/ipc/index.d.ts +66 -0
  65. package/dist/esm/ipc/index.d.ts.map +1 -0
  66. package/dist/esm/ipc/index.js +137 -0
  67. package/dist/esm/kylin-registry-3nmgzi3s.js +249 -0
  68. package/dist/esm/logger/String16.d.ts +11 -0
  69. package/dist/esm/logger/String16.d.ts.map +1 -0
  70. package/dist/esm/logger/index.d.ts +104 -0
  71. package/dist/esm/logger/index.d.ts.map +1 -0
  72. package/dist/esm/logger/index.js +7 -0
  73. package/dist/esm/orm/common/logger.d.ts +4 -0
  74. package/dist/esm/orm/common/logger.d.ts.map +1 -0
  75. package/dist/esm/orm/index.d.ts +4 -0
  76. package/dist/esm/orm/index.d.ts.map +1 -0
  77. package/dist/esm/orm/index.js +50024 -0
  78. package/dist/esm/orm/orm/CheckHealth.d.ts +4 -0
  79. package/dist/esm/orm/orm/CheckHealth.d.ts.map +1 -0
  80. package/dist/esm/orm/orm/ExecuteInTransaction.d.ts +5 -0
  81. package/dist/esm/orm/orm/ExecuteInTransaction.d.ts.map +1 -0
  82. package/dist/esm/orm/orm/SafeAlterTable.d.ts +8 -0
  83. package/dist/esm/orm/orm/SafeAlterTable.d.ts.map +1 -0
  84. package/dist/esm/orm/orm/SqLiteConnection.d.ts +5 -0
  85. package/dist/esm/orm/orm/SqLiteConnection.d.ts.map +1 -0
  86. package/dist/esm/orm/sqlite/index.d.ts +10 -0
  87. package/dist/esm/orm/sqlite/index.d.ts.map +1 -0
  88. package/dist/esm/platform/index.d.ts +2 -0
  89. package/dist/esm/platform/index.d.ts.map +1 -0
  90. package/dist/esm/platform/index.js +8 -0
  91. package/dist/esm/platform/platform/detector.d.ts +47 -0
  92. package/dist/esm/platform/platform/detector.d.ts.map +1 -0
  93. package/dist/esm/platform/platform/registry/index.d.ts +47 -0
  94. package/dist/esm/platform/platform/registry/index.d.ts.map +1 -0
  95. package/dist/esm/platform/platform/registry/kylin-registry.d.ts +31 -0
  96. package/dist/esm/platform/platform/registry/kylin-registry.d.ts.map +1 -0
  97. package/dist/esm/platform/platform/registry/registry.d.ts +89 -0
  98. package/dist/esm/platform/platform/registry/registry.d.ts.map +1 -0
  99. package/dist/esm/platform/platform/registry/windows-registry.d.ts +32 -0
  100. package/dist/esm/platform/platform/registry/windows-registry.d.ts.map +1 -0
  101. package/dist/esm/response-factory/factory/AppError.d.ts +8 -0
  102. package/dist/esm/response-factory/factory/AppError.d.ts.map +1 -0
  103. package/dist/esm/response-factory/factory/BusinessError.d.ts +70 -0
  104. package/dist/esm/response-factory/factory/BusinessError.d.ts.map +1 -0
  105. package/dist/esm/response-factory/index.d.ts +3 -0
  106. package/dist/esm/response-factory/index.d.ts.map +1 -0
  107. package/dist/esm/response-factory/index.js +121 -0
  108. package/dist/esm/response-factory/response/Response.d.ts +15 -0
  109. package/dist/esm/response-factory/response/Response.d.ts.map +1 -0
  110. package/dist/esm/windows-registry-B92IgP1f.js +354 -0
  111. package/package.json +73 -0
@@ -0,0 +1,1128 @@
1
+ import { ipcMain } from "electron";
2
+ import { c as commonjsGlobal } from "../_commonjsHelpers-Dm6U3U_N.js";
3
+ /*! *****************************************************************************
4
+ Copyright (C) Microsoft. All rights reserved.
5
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
6
+ this file except in compliance with the License. You may obtain a copy of the
7
+ License at http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
10
+ KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
11
+ WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
12
+ MERCHANTABLITY OR NON-INFRINGEMENT.
13
+
14
+ See the Apache Version 2.0 License for specific language governing permissions
15
+ and limitations under the License.
16
+ ***************************************************************************** */
17
+ var Reflect$1;
18
+ (function(Reflect2) {
19
+ (function(factory) {
20
+ var root = typeof globalThis === "object" ? globalThis : typeof commonjsGlobal === "object" ? commonjsGlobal : typeof self === "object" ? self : typeof this === "object" ? this : sloppyModeThis();
21
+ var exporter = makeExporter(Reflect2);
22
+ if (typeof root.Reflect !== "undefined") {
23
+ exporter = makeExporter(root.Reflect, exporter);
24
+ }
25
+ factory(exporter, root);
26
+ if (typeof root.Reflect === "undefined") {
27
+ root.Reflect = Reflect2;
28
+ }
29
+ function makeExporter(target, previous) {
30
+ return function(key, value) {
31
+ Object.defineProperty(target, key, { configurable: true, writable: true, value });
32
+ if (previous)
33
+ previous(key, value);
34
+ };
35
+ }
36
+ function functionThis() {
37
+ try {
38
+ return Function("return this;")();
39
+ } catch (_) {
40
+ }
41
+ }
42
+ function indirectEvalThis() {
43
+ try {
44
+ return (void 0, eval)("(function() { return this; })()");
45
+ } catch (_) {
46
+ }
47
+ }
48
+ function sloppyModeThis() {
49
+ return functionThis() || indirectEvalThis();
50
+ }
51
+ })(function(exporter, root) {
52
+ var hasOwn = Object.prototype.hasOwnProperty;
53
+ var supportsSymbol = typeof Symbol === "function";
54
+ var toPrimitiveSymbol = supportsSymbol && typeof Symbol.toPrimitive !== "undefined" ? Symbol.toPrimitive : "@@toPrimitive";
55
+ var iteratorSymbol = supportsSymbol && typeof Symbol.iterator !== "undefined" ? Symbol.iterator : "@@iterator";
56
+ var supportsCreate = typeof Object.create === "function";
57
+ var supportsProto = { __proto__: [] } instanceof Array;
58
+ var downLevel = !supportsCreate && !supportsProto;
59
+ var HashMap = {
60
+ // create an object in dictionary mode (a.k.a. "slow" mode in v8)
61
+ create: supportsCreate ? function() {
62
+ return MakeDictionary(/* @__PURE__ */ Object.create(null));
63
+ } : supportsProto ? function() {
64
+ return MakeDictionary({ __proto__: null });
65
+ } : function() {
66
+ return MakeDictionary({});
67
+ },
68
+ has: downLevel ? function(map, key) {
69
+ return hasOwn.call(map, key);
70
+ } : function(map, key) {
71
+ return key in map;
72
+ },
73
+ get: downLevel ? function(map, key) {
74
+ return hasOwn.call(map, key) ? map[key] : void 0;
75
+ } : function(map, key) {
76
+ return map[key];
77
+ }
78
+ };
79
+ var functionPrototype = Object.getPrototypeOf(Function);
80
+ var _Map = typeof Map === "function" && typeof Map.prototype.entries === "function" ? Map : CreateMapPolyfill();
81
+ var _Set = typeof Set === "function" && typeof Set.prototype.entries === "function" ? Set : CreateSetPolyfill();
82
+ var _WeakMap = typeof WeakMap === "function" ? WeakMap : CreateWeakMapPolyfill();
83
+ var registrySymbol = supportsSymbol ? Symbol.for("@reflect-metadata:registry") : void 0;
84
+ var metadataRegistry = GetOrCreateMetadataRegistry();
85
+ var metadataProvider = CreateMetadataProvider(metadataRegistry);
86
+ function decorate(decorators, target, propertyKey, attributes) {
87
+ if (!IsUndefined(propertyKey)) {
88
+ if (!IsArray(decorators))
89
+ throw new TypeError();
90
+ if (!IsObject(target))
91
+ throw new TypeError();
92
+ if (!IsObject(attributes) && !IsUndefined(attributes) && !IsNull(attributes))
93
+ throw new TypeError();
94
+ if (IsNull(attributes))
95
+ attributes = void 0;
96
+ propertyKey = ToPropertyKey(propertyKey);
97
+ return DecorateProperty(decorators, target, propertyKey, attributes);
98
+ } else {
99
+ if (!IsArray(decorators))
100
+ throw new TypeError();
101
+ if (!IsConstructor(target))
102
+ throw new TypeError();
103
+ return DecorateConstructor(decorators, target);
104
+ }
105
+ }
106
+ exporter("decorate", decorate);
107
+ function metadata(metadataKey, metadataValue) {
108
+ function decorator(target, propertyKey) {
109
+ if (!IsObject(target))
110
+ throw new TypeError();
111
+ if (!IsUndefined(propertyKey) && !IsPropertyKey(propertyKey))
112
+ throw new TypeError();
113
+ OrdinaryDefineOwnMetadata(metadataKey, metadataValue, target, propertyKey);
114
+ }
115
+ return decorator;
116
+ }
117
+ exporter("metadata", metadata);
118
+ function defineMetadata(metadataKey, metadataValue, target, propertyKey) {
119
+ if (!IsObject(target))
120
+ throw new TypeError();
121
+ if (!IsUndefined(propertyKey))
122
+ propertyKey = ToPropertyKey(propertyKey);
123
+ return OrdinaryDefineOwnMetadata(metadataKey, metadataValue, target, propertyKey);
124
+ }
125
+ exporter("defineMetadata", defineMetadata);
126
+ function hasMetadata(metadataKey, target, propertyKey) {
127
+ if (!IsObject(target))
128
+ throw new TypeError();
129
+ if (!IsUndefined(propertyKey))
130
+ propertyKey = ToPropertyKey(propertyKey);
131
+ return OrdinaryHasMetadata(metadataKey, target, propertyKey);
132
+ }
133
+ exporter("hasMetadata", hasMetadata);
134
+ function hasOwnMetadata(metadataKey, target, propertyKey) {
135
+ if (!IsObject(target))
136
+ throw new TypeError();
137
+ if (!IsUndefined(propertyKey))
138
+ propertyKey = ToPropertyKey(propertyKey);
139
+ return OrdinaryHasOwnMetadata(metadataKey, target, propertyKey);
140
+ }
141
+ exporter("hasOwnMetadata", hasOwnMetadata);
142
+ function getMetadata(metadataKey, target, propertyKey) {
143
+ if (!IsObject(target))
144
+ throw new TypeError();
145
+ if (!IsUndefined(propertyKey))
146
+ propertyKey = ToPropertyKey(propertyKey);
147
+ return OrdinaryGetMetadata(metadataKey, target, propertyKey);
148
+ }
149
+ exporter("getMetadata", getMetadata);
150
+ function getOwnMetadata(metadataKey, target, propertyKey) {
151
+ if (!IsObject(target))
152
+ throw new TypeError();
153
+ if (!IsUndefined(propertyKey))
154
+ propertyKey = ToPropertyKey(propertyKey);
155
+ return OrdinaryGetOwnMetadata(metadataKey, target, propertyKey);
156
+ }
157
+ exporter("getOwnMetadata", getOwnMetadata);
158
+ function getMetadataKeys(target, propertyKey) {
159
+ if (!IsObject(target))
160
+ throw new TypeError();
161
+ if (!IsUndefined(propertyKey))
162
+ propertyKey = ToPropertyKey(propertyKey);
163
+ return OrdinaryMetadataKeys(target, propertyKey);
164
+ }
165
+ exporter("getMetadataKeys", getMetadataKeys);
166
+ function getOwnMetadataKeys(target, propertyKey) {
167
+ if (!IsObject(target))
168
+ throw new TypeError();
169
+ if (!IsUndefined(propertyKey))
170
+ propertyKey = ToPropertyKey(propertyKey);
171
+ return OrdinaryOwnMetadataKeys(target, propertyKey);
172
+ }
173
+ exporter("getOwnMetadataKeys", getOwnMetadataKeys);
174
+ function deleteMetadata(metadataKey, target, propertyKey) {
175
+ if (!IsObject(target))
176
+ throw new TypeError();
177
+ if (!IsUndefined(propertyKey))
178
+ propertyKey = ToPropertyKey(propertyKey);
179
+ if (!IsObject(target))
180
+ throw new TypeError();
181
+ if (!IsUndefined(propertyKey))
182
+ propertyKey = ToPropertyKey(propertyKey);
183
+ var provider = GetMetadataProvider(
184
+ target,
185
+ propertyKey,
186
+ /*Create*/
187
+ false
188
+ );
189
+ if (IsUndefined(provider))
190
+ return false;
191
+ return provider.OrdinaryDeleteMetadata(metadataKey, target, propertyKey);
192
+ }
193
+ exporter("deleteMetadata", deleteMetadata);
194
+ function DecorateConstructor(decorators, target) {
195
+ for (var i = decorators.length - 1; i >= 0; --i) {
196
+ var decorator = decorators[i];
197
+ var decorated = decorator(target);
198
+ if (!IsUndefined(decorated) && !IsNull(decorated)) {
199
+ if (!IsConstructor(decorated))
200
+ throw new TypeError();
201
+ target = decorated;
202
+ }
203
+ }
204
+ return target;
205
+ }
206
+ function DecorateProperty(decorators, target, propertyKey, descriptor) {
207
+ for (var i = decorators.length - 1; i >= 0; --i) {
208
+ var decorator = decorators[i];
209
+ var decorated = decorator(target, propertyKey, descriptor);
210
+ if (!IsUndefined(decorated) && !IsNull(decorated)) {
211
+ if (!IsObject(decorated))
212
+ throw new TypeError();
213
+ descriptor = decorated;
214
+ }
215
+ }
216
+ return descriptor;
217
+ }
218
+ function OrdinaryHasMetadata(MetadataKey, O, P) {
219
+ var hasOwn2 = OrdinaryHasOwnMetadata(MetadataKey, O, P);
220
+ if (hasOwn2)
221
+ return true;
222
+ var parent = OrdinaryGetPrototypeOf(O);
223
+ if (!IsNull(parent))
224
+ return OrdinaryHasMetadata(MetadataKey, parent, P);
225
+ return false;
226
+ }
227
+ function OrdinaryHasOwnMetadata(MetadataKey, O, P) {
228
+ var provider = GetMetadataProvider(
229
+ O,
230
+ P,
231
+ /*Create*/
232
+ false
233
+ );
234
+ if (IsUndefined(provider))
235
+ return false;
236
+ return ToBoolean(provider.OrdinaryHasOwnMetadata(MetadataKey, O, P));
237
+ }
238
+ function OrdinaryGetMetadata(MetadataKey, O, P) {
239
+ var hasOwn2 = OrdinaryHasOwnMetadata(MetadataKey, O, P);
240
+ if (hasOwn2)
241
+ return OrdinaryGetOwnMetadata(MetadataKey, O, P);
242
+ var parent = OrdinaryGetPrototypeOf(O);
243
+ if (!IsNull(parent))
244
+ return OrdinaryGetMetadata(MetadataKey, parent, P);
245
+ return void 0;
246
+ }
247
+ function OrdinaryGetOwnMetadata(MetadataKey, O, P) {
248
+ var provider = GetMetadataProvider(
249
+ O,
250
+ P,
251
+ /*Create*/
252
+ false
253
+ );
254
+ if (IsUndefined(provider))
255
+ return;
256
+ return provider.OrdinaryGetOwnMetadata(MetadataKey, O, P);
257
+ }
258
+ function OrdinaryDefineOwnMetadata(MetadataKey, MetadataValue, O, P) {
259
+ var provider = GetMetadataProvider(
260
+ O,
261
+ P,
262
+ /*Create*/
263
+ true
264
+ );
265
+ provider.OrdinaryDefineOwnMetadata(MetadataKey, MetadataValue, O, P);
266
+ }
267
+ function OrdinaryMetadataKeys(O, P) {
268
+ var ownKeys = OrdinaryOwnMetadataKeys(O, P);
269
+ var parent = OrdinaryGetPrototypeOf(O);
270
+ if (parent === null)
271
+ return ownKeys;
272
+ var parentKeys = OrdinaryMetadataKeys(parent, P);
273
+ if (parentKeys.length <= 0)
274
+ return ownKeys;
275
+ if (ownKeys.length <= 0)
276
+ return parentKeys;
277
+ var set = new _Set();
278
+ var keys = [];
279
+ for (var _i = 0, ownKeys_1 = ownKeys; _i < ownKeys_1.length; _i++) {
280
+ var key = ownKeys_1[_i];
281
+ var hasKey = set.has(key);
282
+ if (!hasKey) {
283
+ set.add(key);
284
+ keys.push(key);
285
+ }
286
+ }
287
+ for (var _a = 0, parentKeys_1 = parentKeys; _a < parentKeys_1.length; _a++) {
288
+ var key = parentKeys_1[_a];
289
+ var hasKey = set.has(key);
290
+ if (!hasKey) {
291
+ set.add(key);
292
+ keys.push(key);
293
+ }
294
+ }
295
+ return keys;
296
+ }
297
+ function OrdinaryOwnMetadataKeys(O, P) {
298
+ var provider = GetMetadataProvider(
299
+ O,
300
+ P,
301
+ /*create*/
302
+ false
303
+ );
304
+ if (!provider) {
305
+ return [];
306
+ }
307
+ return provider.OrdinaryOwnMetadataKeys(O, P);
308
+ }
309
+ function Type(x) {
310
+ if (x === null)
311
+ return 1;
312
+ switch (typeof x) {
313
+ case "undefined":
314
+ return 0;
315
+ case "boolean":
316
+ return 2;
317
+ case "string":
318
+ return 3;
319
+ case "symbol":
320
+ return 4;
321
+ case "number":
322
+ return 5;
323
+ case "object":
324
+ return x === null ? 1 : 6;
325
+ default:
326
+ return 6;
327
+ }
328
+ }
329
+ function IsUndefined(x) {
330
+ return x === void 0;
331
+ }
332
+ function IsNull(x) {
333
+ return x === null;
334
+ }
335
+ function IsSymbol(x) {
336
+ return typeof x === "symbol";
337
+ }
338
+ function IsObject(x) {
339
+ return typeof x === "object" ? x !== null : typeof x === "function";
340
+ }
341
+ function ToPrimitive(input, PreferredType) {
342
+ switch (Type(input)) {
343
+ case 0:
344
+ return input;
345
+ case 1:
346
+ return input;
347
+ case 2:
348
+ return input;
349
+ case 3:
350
+ return input;
351
+ case 4:
352
+ return input;
353
+ case 5:
354
+ return input;
355
+ }
356
+ var hint = "string";
357
+ var exoticToPrim = GetMethod(input, toPrimitiveSymbol);
358
+ if (exoticToPrim !== void 0) {
359
+ var result = exoticToPrim.call(input, hint);
360
+ if (IsObject(result))
361
+ throw new TypeError();
362
+ return result;
363
+ }
364
+ return OrdinaryToPrimitive(input);
365
+ }
366
+ function OrdinaryToPrimitive(O, hint) {
367
+ var valueOf, result, toString_2;
368
+ {
369
+ var toString_1 = O.toString;
370
+ if (IsCallable(toString_1)) {
371
+ var result = toString_1.call(O);
372
+ if (!IsObject(result))
373
+ return result;
374
+ }
375
+ var valueOf = O.valueOf;
376
+ if (IsCallable(valueOf)) {
377
+ var result = valueOf.call(O);
378
+ if (!IsObject(result))
379
+ return result;
380
+ }
381
+ }
382
+ throw new TypeError();
383
+ }
384
+ function ToBoolean(argument) {
385
+ return !!argument;
386
+ }
387
+ function ToString(argument) {
388
+ return "" + argument;
389
+ }
390
+ function ToPropertyKey(argument) {
391
+ var key = ToPrimitive(argument);
392
+ if (IsSymbol(key))
393
+ return key;
394
+ return ToString(key);
395
+ }
396
+ function IsArray(argument) {
397
+ return Array.isArray ? Array.isArray(argument) : argument instanceof Object ? argument instanceof Array : Object.prototype.toString.call(argument) === "[object Array]";
398
+ }
399
+ function IsCallable(argument) {
400
+ return typeof argument === "function";
401
+ }
402
+ function IsConstructor(argument) {
403
+ return typeof argument === "function";
404
+ }
405
+ function IsPropertyKey(argument) {
406
+ switch (Type(argument)) {
407
+ case 3:
408
+ return true;
409
+ case 4:
410
+ return true;
411
+ default:
412
+ return false;
413
+ }
414
+ }
415
+ function SameValueZero(x, y) {
416
+ return x === y || x !== x && y !== y;
417
+ }
418
+ function GetMethod(V, P) {
419
+ var func = V[P];
420
+ if (func === void 0 || func === null)
421
+ return void 0;
422
+ if (!IsCallable(func))
423
+ throw new TypeError();
424
+ return func;
425
+ }
426
+ function GetIterator(obj) {
427
+ var method = GetMethod(obj, iteratorSymbol);
428
+ if (!IsCallable(method))
429
+ throw new TypeError();
430
+ var iterator = method.call(obj);
431
+ if (!IsObject(iterator))
432
+ throw new TypeError();
433
+ return iterator;
434
+ }
435
+ function IteratorValue(iterResult) {
436
+ return iterResult.value;
437
+ }
438
+ function IteratorStep(iterator) {
439
+ var result = iterator.next();
440
+ return result.done ? false : result;
441
+ }
442
+ function IteratorClose(iterator) {
443
+ var f = iterator["return"];
444
+ if (f)
445
+ f.call(iterator);
446
+ }
447
+ function OrdinaryGetPrototypeOf(O) {
448
+ var proto = Object.getPrototypeOf(O);
449
+ if (typeof O !== "function" || O === functionPrototype)
450
+ return proto;
451
+ if (proto !== functionPrototype)
452
+ return proto;
453
+ var prototype = O.prototype;
454
+ var prototypeProto = prototype && Object.getPrototypeOf(prototype);
455
+ if (prototypeProto == null || prototypeProto === Object.prototype)
456
+ return proto;
457
+ var constructor = prototypeProto.constructor;
458
+ if (typeof constructor !== "function")
459
+ return proto;
460
+ if (constructor === O)
461
+ return proto;
462
+ return constructor;
463
+ }
464
+ function CreateMetadataRegistry() {
465
+ var fallback;
466
+ if (!IsUndefined(registrySymbol) && typeof root.Reflect !== "undefined" && !(registrySymbol in root.Reflect) && typeof root.Reflect.defineMetadata === "function") {
467
+ fallback = CreateFallbackProvider(root.Reflect);
468
+ }
469
+ var first;
470
+ var second;
471
+ var rest;
472
+ var targetProviderMap = new _WeakMap();
473
+ var registry = {
474
+ registerProvider,
475
+ getProvider,
476
+ setProvider
477
+ };
478
+ return registry;
479
+ function registerProvider(provider) {
480
+ if (!Object.isExtensible(registry)) {
481
+ throw new Error("Cannot add provider to a frozen registry.");
482
+ }
483
+ switch (true) {
484
+ case fallback === provider:
485
+ break;
486
+ case IsUndefined(first):
487
+ first = provider;
488
+ break;
489
+ case first === provider:
490
+ break;
491
+ case IsUndefined(second):
492
+ second = provider;
493
+ break;
494
+ case second === provider:
495
+ break;
496
+ default:
497
+ if (rest === void 0)
498
+ rest = new _Set();
499
+ rest.add(provider);
500
+ break;
501
+ }
502
+ }
503
+ function getProviderNoCache(O, P) {
504
+ if (!IsUndefined(first)) {
505
+ if (first.isProviderFor(O, P))
506
+ return first;
507
+ if (!IsUndefined(second)) {
508
+ if (second.isProviderFor(O, P))
509
+ return first;
510
+ if (!IsUndefined(rest)) {
511
+ var iterator = GetIterator(rest);
512
+ while (true) {
513
+ var next = IteratorStep(iterator);
514
+ if (!next) {
515
+ return void 0;
516
+ }
517
+ var provider = IteratorValue(next);
518
+ if (provider.isProviderFor(O, P)) {
519
+ IteratorClose(iterator);
520
+ return provider;
521
+ }
522
+ }
523
+ }
524
+ }
525
+ }
526
+ if (!IsUndefined(fallback) && fallback.isProviderFor(O, P)) {
527
+ return fallback;
528
+ }
529
+ return void 0;
530
+ }
531
+ function getProvider(O, P) {
532
+ var providerMap = targetProviderMap.get(O);
533
+ var provider;
534
+ if (!IsUndefined(providerMap)) {
535
+ provider = providerMap.get(P);
536
+ }
537
+ if (!IsUndefined(provider)) {
538
+ return provider;
539
+ }
540
+ provider = getProviderNoCache(O, P);
541
+ if (!IsUndefined(provider)) {
542
+ if (IsUndefined(providerMap)) {
543
+ providerMap = new _Map();
544
+ targetProviderMap.set(O, providerMap);
545
+ }
546
+ providerMap.set(P, provider);
547
+ }
548
+ return provider;
549
+ }
550
+ function hasProvider(provider) {
551
+ if (IsUndefined(provider))
552
+ throw new TypeError();
553
+ return first === provider || second === provider || !IsUndefined(rest) && rest.has(provider);
554
+ }
555
+ function setProvider(O, P, provider) {
556
+ if (!hasProvider(provider)) {
557
+ throw new Error("Metadata provider not registered.");
558
+ }
559
+ var existingProvider = getProvider(O, P);
560
+ if (existingProvider !== provider) {
561
+ if (!IsUndefined(existingProvider)) {
562
+ return false;
563
+ }
564
+ var providerMap = targetProviderMap.get(O);
565
+ if (IsUndefined(providerMap)) {
566
+ providerMap = new _Map();
567
+ targetProviderMap.set(O, providerMap);
568
+ }
569
+ providerMap.set(P, provider);
570
+ }
571
+ return true;
572
+ }
573
+ }
574
+ function GetOrCreateMetadataRegistry() {
575
+ var metadataRegistry2;
576
+ if (!IsUndefined(registrySymbol) && IsObject(root.Reflect) && Object.isExtensible(root.Reflect)) {
577
+ metadataRegistry2 = root.Reflect[registrySymbol];
578
+ }
579
+ if (IsUndefined(metadataRegistry2)) {
580
+ metadataRegistry2 = CreateMetadataRegistry();
581
+ }
582
+ if (!IsUndefined(registrySymbol) && IsObject(root.Reflect) && Object.isExtensible(root.Reflect)) {
583
+ Object.defineProperty(root.Reflect, registrySymbol, {
584
+ enumerable: false,
585
+ configurable: false,
586
+ writable: false,
587
+ value: metadataRegistry2
588
+ });
589
+ }
590
+ return metadataRegistry2;
591
+ }
592
+ function CreateMetadataProvider(registry) {
593
+ var metadata2 = new _WeakMap();
594
+ var provider = {
595
+ isProviderFor: function(O, P) {
596
+ var targetMetadata = metadata2.get(O);
597
+ if (IsUndefined(targetMetadata))
598
+ return false;
599
+ return targetMetadata.has(P);
600
+ },
601
+ OrdinaryDefineOwnMetadata: OrdinaryDefineOwnMetadata2,
602
+ OrdinaryHasOwnMetadata: OrdinaryHasOwnMetadata2,
603
+ OrdinaryGetOwnMetadata: OrdinaryGetOwnMetadata2,
604
+ OrdinaryOwnMetadataKeys: OrdinaryOwnMetadataKeys2,
605
+ OrdinaryDeleteMetadata
606
+ };
607
+ metadataRegistry.registerProvider(provider);
608
+ return provider;
609
+ function GetOrCreateMetadataMap(O, P, Create) {
610
+ var targetMetadata = metadata2.get(O);
611
+ var createdTargetMetadata = false;
612
+ if (IsUndefined(targetMetadata)) {
613
+ if (!Create)
614
+ return void 0;
615
+ targetMetadata = new _Map();
616
+ metadata2.set(O, targetMetadata);
617
+ createdTargetMetadata = true;
618
+ }
619
+ var metadataMap = targetMetadata.get(P);
620
+ if (IsUndefined(metadataMap)) {
621
+ if (!Create)
622
+ return void 0;
623
+ metadataMap = new _Map();
624
+ targetMetadata.set(P, metadataMap);
625
+ if (!registry.setProvider(O, P, provider)) {
626
+ targetMetadata.delete(P);
627
+ if (createdTargetMetadata) {
628
+ metadata2.delete(O);
629
+ }
630
+ throw new Error("Wrong provider for target.");
631
+ }
632
+ }
633
+ return metadataMap;
634
+ }
635
+ function OrdinaryHasOwnMetadata2(MetadataKey, O, P) {
636
+ var metadataMap = GetOrCreateMetadataMap(
637
+ O,
638
+ P,
639
+ /*Create*/
640
+ false
641
+ );
642
+ if (IsUndefined(metadataMap))
643
+ return false;
644
+ return ToBoolean(metadataMap.has(MetadataKey));
645
+ }
646
+ function OrdinaryGetOwnMetadata2(MetadataKey, O, P) {
647
+ var metadataMap = GetOrCreateMetadataMap(
648
+ O,
649
+ P,
650
+ /*Create*/
651
+ false
652
+ );
653
+ if (IsUndefined(metadataMap))
654
+ return void 0;
655
+ return metadataMap.get(MetadataKey);
656
+ }
657
+ function OrdinaryDefineOwnMetadata2(MetadataKey, MetadataValue, O, P) {
658
+ var metadataMap = GetOrCreateMetadataMap(
659
+ O,
660
+ P,
661
+ /*Create*/
662
+ true
663
+ );
664
+ metadataMap.set(MetadataKey, MetadataValue);
665
+ }
666
+ function OrdinaryOwnMetadataKeys2(O, P) {
667
+ var keys = [];
668
+ var metadataMap = GetOrCreateMetadataMap(
669
+ O,
670
+ P,
671
+ /*Create*/
672
+ false
673
+ );
674
+ if (IsUndefined(metadataMap))
675
+ return keys;
676
+ var keysObj = metadataMap.keys();
677
+ var iterator = GetIterator(keysObj);
678
+ var k = 0;
679
+ while (true) {
680
+ var next = IteratorStep(iterator);
681
+ if (!next) {
682
+ keys.length = k;
683
+ return keys;
684
+ }
685
+ var nextValue = IteratorValue(next);
686
+ try {
687
+ keys[k] = nextValue;
688
+ } catch (e) {
689
+ try {
690
+ IteratorClose(iterator);
691
+ } finally {
692
+ throw e;
693
+ }
694
+ }
695
+ k++;
696
+ }
697
+ }
698
+ function OrdinaryDeleteMetadata(MetadataKey, O, P) {
699
+ var metadataMap = GetOrCreateMetadataMap(
700
+ O,
701
+ P,
702
+ /*Create*/
703
+ false
704
+ );
705
+ if (IsUndefined(metadataMap))
706
+ return false;
707
+ if (!metadataMap.delete(MetadataKey))
708
+ return false;
709
+ if (metadataMap.size === 0) {
710
+ var targetMetadata = metadata2.get(O);
711
+ if (!IsUndefined(targetMetadata)) {
712
+ targetMetadata.delete(P);
713
+ if (targetMetadata.size === 0) {
714
+ metadata2.delete(targetMetadata);
715
+ }
716
+ }
717
+ }
718
+ return true;
719
+ }
720
+ }
721
+ function CreateFallbackProvider(reflect) {
722
+ var defineMetadata2 = reflect.defineMetadata, hasOwnMetadata2 = reflect.hasOwnMetadata, getOwnMetadata2 = reflect.getOwnMetadata, getOwnMetadataKeys2 = reflect.getOwnMetadataKeys, deleteMetadata2 = reflect.deleteMetadata;
723
+ var metadataOwner = new _WeakMap();
724
+ var provider = {
725
+ isProviderFor: function(O, P) {
726
+ var metadataPropertySet = metadataOwner.get(O);
727
+ if (!IsUndefined(metadataPropertySet) && metadataPropertySet.has(P)) {
728
+ return true;
729
+ }
730
+ if (getOwnMetadataKeys2(O, P).length) {
731
+ if (IsUndefined(metadataPropertySet)) {
732
+ metadataPropertySet = new _Set();
733
+ metadataOwner.set(O, metadataPropertySet);
734
+ }
735
+ metadataPropertySet.add(P);
736
+ return true;
737
+ }
738
+ return false;
739
+ },
740
+ OrdinaryDefineOwnMetadata: defineMetadata2,
741
+ OrdinaryHasOwnMetadata: hasOwnMetadata2,
742
+ OrdinaryGetOwnMetadata: getOwnMetadata2,
743
+ OrdinaryOwnMetadataKeys: getOwnMetadataKeys2,
744
+ OrdinaryDeleteMetadata: deleteMetadata2
745
+ };
746
+ return provider;
747
+ }
748
+ function GetMetadataProvider(O, P, Create) {
749
+ var registeredProvider = metadataRegistry.getProvider(O, P);
750
+ if (!IsUndefined(registeredProvider)) {
751
+ return registeredProvider;
752
+ }
753
+ if (Create) {
754
+ if (metadataRegistry.setProvider(O, P, metadataProvider)) {
755
+ return metadataProvider;
756
+ }
757
+ throw new Error("Illegal state.");
758
+ }
759
+ return void 0;
760
+ }
761
+ function CreateMapPolyfill() {
762
+ var cacheSentinel = {};
763
+ var arraySentinel = [];
764
+ var MapIterator = (
765
+ /** @class */
766
+ function() {
767
+ function MapIterator2(keys, values, selector) {
768
+ this._index = 0;
769
+ this._keys = keys;
770
+ this._values = values;
771
+ this._selector = selector;
772
+ }
773
+ MapIterator2.prototype["@@iterator"] = function() {
774
+ return this;
775
+ };
776
+ MapIterator2.prototype[iteratorSymbol] = function() {
777
+ return this;
778
+ };
779
+ MapIterator2.prototype.next = function() {
780
+ var index = this._index;
781
+ if (index >= 0 && index < this._keys.length) {
782
+ var result = this._selector(this._keys[index], this._values[index]);
783
+ if (index + 1 >= this._keys.length) {
784
+ this._index = -1;
785
+ this._keys = arraySentinel;
786
+ this._values = arraySentinel;
787
+ } else {
788
+ this._index++;
789
+ }
790
+ return { value: result, done: false };
791
+ }
792
+ return { value: void 0, done: true };
793
+ };
794
+ MapIterator2.prototype.throw = function(error) {
795
+ if (this._index >= 0) {
796
+ this._index = -1;
797
+ this._keys = arraySentinel;
798
+ this._values = arraySentinel;
799
+ }
800
+ throw error;
801
+ };
802
+ MapIterator2.prototype.return = function(value) {
803
+ if (this._index >= 0) {
804
+ this._index = -1;
805
+ this._keys = arraySentinel;
806
+ this._values = arraySentinel;
807
+ }
808
+ return { value, done: true };
809
+ };
810
+ return MapIterator2;
811
+ }()
812
+ );
813
+ var Map2 = (
814
+ /** @class */
815
+ function() {
816
+ function Map3() {
817
+ this._keys = [];
818
+ this._values = [];
819
+ this._cacheKey = cacheSentinel;
820
+ this._cacheIndex = -2;
821
+ }
822
+ Object.defineProperty(Map3.prototype, "size", {
823
+ get: function() {
824
+ return this._keys.length;
825
+ },
826
+ enumerable: true,
827
+ configurable: true
828
+ });
829
+ Map3.prototype.has = function(key) {
830
+ return this._find(
831
+ key,
832
+ /*insert*/
833
+ false
834
+ ) >= 0;
835
+ };
836
+ Map3.prototype.get = function(key) {
837
+ var index = this._find(
838
+ key,
839
+ /*insert*/
840
+ false
841
+ );
842
+ return index >= 0 ? this._values[index] : void 0;
843
+ };
844
+ Map3.prototype.set = function(key, value) {
845
+ var index = this._find(
846
+ key,
847
+ /*insert*/
848
+ true
849
+ );
850
+ this._values[index] = value;
851
+ return this;
852
+ };
853
+ Map3.prototype.delete = function(key) {
854
+ var index = this._find(
855
+ key,
856
+ /*insert*/
857
+ false
858
+ );
859
+ if (index >= 0) {
860
+ var size = this._keys.length;
861
+ for (var i = index + 1; i < size; i++) {
862
+ this._keys[i - 1] = this._keys[i];
863
+ this._values[i - 1] = this._values[i];
864
+ }
865
+ this._keys.length--;
866
+ this._values.length--;
867
+ if (SameValueZero(key, this._cacheKey)) {
868
+ this._cacheKey = cacheSentinel;
869
+ this._cacheIndex = -2;
870
+ }
871
+ return true;
872
+ }
873
+ return false;
874
+ };
875
+ Map3.prototype.clear = function() {
876
+ this._keys.length = 0;
877
+ this._values.length = 0;
878
+ this._cacheKey = cacheSentinel;
879
+ this._cacheIndex = -2;
880
+ };
881
+ Map3.prototype.keys = function() {
882
+ return new MapIterator(this._keys, this._values, getKey);
883
+ };
884
+ Map3.prototype.values = function() {
885
+ return new MapIterator(this._keys, this._values, getValue);
886
+ };
887
+ Map3.prototype.entries = function() {
888
+ return new MapIterator(this._keys, this._values, getEntry);
889
+ };
890
+ Map3.prototype["@@iterator"] = function() {
891
+ return this.entries();
892
+ };
893
+ Map3.prototype[iteratorSymbol] = function() {
894
+ return this.entries();
895
+ };
896
+ Map3.prototype._find = function(key, insert) {
897
+ if (!SameValueZero(this._cacheKey, key)) {
898
+ this._cacheIndex = -1;
899
+ for (var i = 0; i < this._keys.length; i++) {
900
+ if (SameValueZero(this._keys[i], key)) {
901
+ this._cacheIndex = i;
902
+ break;
903
+ }
904
+ }
905
+ }
906
+ if (this._cacheIndex < 0 && insert) {
907
+ this._cacheIndex = this._keys.length;
908
+ this._keys.push(key);
909
+ this._values.push(void 0);
910
+ }
911
+ return this._cacheIndex;
912
+ };
913
+ return Map3;
914
+ }()
915
+ );
916
+ return Map2;
917
+ function getKey(key, _) {
918
+ return key;
919
+ }
920
+ function getValue(_, value) {
921
+ return value;
922
+ }
923
+ function getEntry(key, value) {
924
+ return [key, value];
925
+ }
926
+ }
927
+ function CreateSetPolyfill() {
928
+ var Set2 = (
929
+ /** @class */
930
+ function() {
931
+ function Set3() {
932
+ this._map = new _Map();
933
+ }
934
+ Object.defineProperty(Set3.prototype, "size", {
935
+ get: function() {
936
+ return this._map.size;
937
+ },
938
+ enumerable: true,
939
+ configurable: true
940
+ });
941
+ Set3.prototype.has = function(value) {
942
+ return this._map.has(value);
943
+ };
944
+ Set3.prototype.add = function(value) {
945
+ return this._map.set(value, value), this;
946
+ };
947
+ Set3.prototype.delete = function(value) {
948
+ return this._map.delete(value);
949
+ };
950
+ Set3.prototype.clear = function() {
951
+ this._map.clear();
952
+ };
953
+ Set3.prototype.keys = function() {
954
+ return this._map.keys();
955
+ };
956
+ Set3.prototype.values = function() {
957
+ return this._map.keys();
958
+ };
959
+ Set3.prototype.entries = function() {
960
+ return this._map.entries();
961
+ };
962
+ Set3.prototype["@@iterator"] = function() {
963
+ return this.keys();
964
+ };
965
+ Set3.prototype[iteratorSymbol] = function() {
966
+ return this.keys();
967
+ };
968
+ return Set3;
969
+ }()
970
+ );
971
+ return Set2;
972
+ }
973
+ function CreateWeakMapPolyfill() {
974
+ var UUID_SIZE = 16;
975
+ var keys = HashMap.create();
976
+ var rootKey = CreateUniqueKey();
977
+ return (
978
+ /** @class */
979
+ function() {
980
+ function WeakMap2() {
981
+ this._key = CreateUniqueKey();
982
+ }
983
+ WeakMap2.prototype.has = function(target) {
984
+ var table = GetOrCreateWeakMapTable(
985
+ target,
986
+ /*create*/
987
+ false
988
+ );
989
+ return table !== void 0 ? HashMap.has(table, this._key) : false;
990
+ };
991
+ WeakMap2.prototype.get = function(target) {
992
+ var table = GetOrCreateWeakMapTable(
993
+ target,
994
+ /*create*/
995
+ false
996
+ );
997
+ return table !== void 0 ? HashMap.get(table, this._key) : void 0;
998
+ };
999
+ WeakMap2.prototype.set = function(target, value) {
1000
+ var table = GetOrCreateWeakMapTable(
1001
+ target,
1002
+ /*create*/
1003
+ true
1004
+ );
1005
+ table[this._key] = value;
1006
+ return this;
1007
+ };
1008
+ WeakMap2.prototype.delete = function(target) {
1009
+ var table = GetOrCreateWeakMapTable(
1010
+ target,
1011
+ /*create*/
1012
+ false
1013
+ );
1014
+ return table !== void 0 ? delete table[this._key] : false;
1015
+ };
1016
+ WeakMap2.prototype.clear = function() {
1017
+ this._key = CreateUniqueKey();
1018
+ };
1019
+ return WeakMap2;
1020
+ }()
1021
+ );
1022
+ function CreateUniqueKey() {
1023
+ var key;
1024
+ do
1025
+ key = "@@WeakMap@@" + CreateUUID();
1026
+ while (HashMap.has(keys, key));
1027
+ keys[key] = true;
1028
+ return key;
1029
+ }
1030
+ function GetOrCreateWeakMapTable(target, create) {
1031
+ if (!hasOwn.call(target, rootKey)) {
1032
+ if (!create)
1033
+ return void 0;
1034
+ Object.defineProperty(target, rootKey, { value: HashMap.create() });
1035
+ }
1036
+ return target[rootKey];
1037
+ }
1038
+ function FillRandomBytes(buffer, size) {
1039
+ for (var i = 0; i < size; ++i)
1040
+ buffer[i] = Math.random() * 255 | 0;
1041
+ return buffer;
1042
+ }
1043
+ function GenRandomBytes(size) {
1044
+ if (typeof Uint8Array === "function") {
1045
+ var array = new Uint8Array(size);
1046
+ if (typeof crypto !== "undefined") {
1047
+ crypto.getRandomValues(array);
1048
+ } else if (typeof msCrypto !== "undefined") {
1049
+ msCrypto.getRandomValues(array);
1050
+ } else {
1051
+ FillRandomBytes(array, size);
1052
+ }
1053
+ return array;
1054
+ }
1055
+ return FillRandomBytes(new Array(size), size);
1056
+ }
1057
+ function CreateUUID() {
1058
+ var data = GenRandomBytes(UUID_SIZE);
1059
+ data[6] = data[6] & 79 | 64;
1060
+ data[8] = data[8] & 191 | 128;
1061
+ var result = "";
1062
+ for (var offset = 0; offset < UUID_SIZE; ++offset) {
1063
+ var byte = data[offset];
1064
+ if (offset === 4 || offset === 6 || offset === 8)
1065
+ result += "-";
1066
+ if (byte < 16)
1067
+ result += "0";
1068
+ result += byte.toString(16).toLowerCase();
1069
+ }
1070
+ return result;
1071
+ }
1072
+ }
1073
+ function MakeDictionary(obj) {
1074
+ obj.__ = void 0;
1075
+ delete obj.__;
1076
+ return obj;
1077
+ }
1078
+ });
1079
+ })(Reflect$1 || (Reflect$1 = {}));
1080
+ const IPC_ROUTES_KEY = Symbol("ipc:routes");
1081
+ const PREFIX_KEY = Symbol("ipc:prefix");
1082
+ const getIpcRoutes = (target) => {
1083
+ const routes = Reflect.getMetadata(IPC_ROUTES_KEY, target);
1084
+ return routes || [];
1085
+ };
1086
+ const createBoundHandler = (handler, instance) => async (event, ...args) => {
1087
+ try {
1088
+ return await handler.call(instance, event, ...args);
1089
+ } catch (error) {
1090
+ const errorMessage = error instanceof Error ? error.message : String(error);
1091
+ throw errorMessage;
1092
+ }
1093
+ };
1094
+ const RestController = (prefix = "") => (target) => {
1095
+ const constructor = target;
1096
+ Reflect.defineMetadata(PREFIX_KEY, prefix, constructor);
1097
+ const routes = getIpcRoutes(constructor.prototype);
1098
+ if (routes.length === 0) {
1099
+ `控制器 ${constructor.name || "未知"} 没有IPC路由`;
1100
+ return;
1101
+ }
1102
+ const instance = new constructor();
1103
+ for (const route of routes) {
1104
+ const { channel, handler } = route;
1105
+ const fullChannel = prefix ? `${prefix}:${channel}` : channel;
1106
+ const boundHandler = createBoundHandler(handler, instance);
1107
+ ipcMain.handle(fullChannel, boundHandler);
1108
+ }
1109
+ Reflect.deleteMetadata(IPC_ROUTES_KEY, constructor.prototype);
1110
+ };
1111
+ const RequestMapping = (channel) => (target, propertyKey, descriptor) => {
1112
+ if (!descriptor || !descriptor.value) {
1113
+ throw new Error("缺少方法描述符");
1114
+ }
1115
+ if (typeof descriptor.value !== "function") {
1116
+ throw new Error("目标必须是函数");
1117
+ }
1118
+ const routes = getIpcRoutes(target);
1119
+ routes.push({
1120
+ channel,
1121
+ handler: descriptor.value
1122
+ });
1123
+ Reflect.defineMetadata(IPC_ROUTES_KEY, routes, target);
1124
+ };
1125
+ export {
1126
+ RequestMapping,
1127
+ RestController
1128
+ };