@hypen-space/core 0.3.11 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app.js +24 -3
- package/dist/app.js.map +3 -3
- package/dist/components/builtin.js +24 -3
- package/dist/components/builtin.js.map +3 -3
- package/dist/context.js +18 -1
- package/dist/context.js.map +2 -2
- package/dist/discovery.js +25 -7
- package/dist/discovery.js.map +4 -4
- package/dist/disposable.js +18 -1
- package/dist/disposable.js.map +2 -2
- package/dist/engine.browser.js +18 -1
- package/dist/engine.browser.js.map +3 -3
- package/dist/engine.js +18 -1
- package/dist/engine.js.map +3 -3
- package/dist/events.js +18 -1
- package/dist/events.js.map +2 -2
- package/dist/index.browser.js +259 -371
- package/dist/index.browser.js.map +8 -9
- package/dist/index.js +558 -647
- package/dist/index.js.map +12 -13
- package/dist/loader.js +18 -1
- package/dist/loader.js.map +2 -2
- package/dist/plugin.js +18 -1
- package/dist/plugin.js.map +2 -2
- package/dist/remote/client.js +18 -1
- package/dist/remote/client.js.map +3 -3
- package/dist/remote/index.js +353 -332
- package/dist/remote/index.js.map +8 -8
- package/dist/remote/server.js +234 -213
- package/dist/remote/server.js.map +7 -7
- package/dist/renderer.js +18 -1
- package/dist/renderer.js.map +3 -3
- package/dist/resolver.js +48 -4
- package/dist/resolver.js.map +3 -3
- package/dist/router.js +18 -1
- package/dist/router.js.map +2 -2
- package/dist/state.js +18 -1
- package/dist/state.js.map +2 -2
- package/package.json +7 -1
- package/src/app.ts +14 -2
- package/src/discovery.ts +3 -1
- package/src/engine.browser.ts +4 -32
- package/src/engine.ts +4 -32
- package/src/index.browser.ts +6 -4
- package/src/index.ts +6 -6
- package/src/managed-router.ts +195 -0
- package/src/module-registry.ts +76 -0
- package/src/remote/client.ts +1 -1
- package/src/remote/index.ts +2 -2
- package/src/remote/server.ts +1 -1
- package/src/remote/types.ts +1 -1
- package/src/renderer.ts +1 -1
- package/src/resolver.ts +56 -9
- package/src/types.ts +38 -0
- package/wasm-browser/README.md +7 -1
- package/wasm-browser/hypen_engine.d.ts +1 -0
- package/wasm-browser/hypen_engine.js +1 -0
- package/wasm-browser/hypen_engine_bg.wasm +0 -0
- package/wasm-browser/package.json +1 -1
- package/wasm-node/README.md +7 -1
- package/wasm-node/hypen_engine.d.ts +1 -0
- package/wasm-node/hypen_engine.js +1 -0
- package/wasm-node/hypen_engine_bg.wasm +0 -0
- package/wasm-node/package.json +1 -1
package/dist/remote/server.js
CHANGED
|
@@ -1,4 +1,20 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
1
4
|
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __toESM = (mod, isNodeMode, target) => {
|
|
8
|
+
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
9
|
+
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
10
|
+
for (let key of __getOwnPropNames(mod))
|
|
11
|
+
if (!__hasOwnProp.call(to, key))
|
|
12
|
+
__defProp(to, key, {
|
|
13
|
+
get: () => mod[key],
|
|
14
|
+
enumerable: true
|
|
15
|
+
});
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
2
18
|
var __export = (target, all) => {
|
|
3
19
|
for (var name in all)
|
|
4
20
|
__defProp(target, name, {
|
|
@@ -9,205 +25,7 @@ var __export = (target, all) => {
|
|
|
9
25
|
});
|
|
10
26
|
};
|
|
11
27
|
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
12
|
-
|
|
13
|
-
// src/logger.ts
|
|
14
|
-
function isProduction() {
|
|
15
|
-
if (typeof process !== "undefined" && process.env) {
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
function setLogLevel(level) {
|
|
21
|
-
config.level = level;
|
|
22
|
-
}
|
|
23
|
-
function getLogLevel() {
|
|
24
|
-
return config.level;
|
|
25
|
-
}
|
|
26
|
-
function configureLogger(options) {
|
|
27
|
-
config = { ...config, ...options };
|
|
28
|
-
}
|
|
29
|
-
function enableLogging() {
|
|
30
|
-
config.level = "debug";
|
|
31
|
-
}
|
|
32
|
-
function disableLogging() {
|
|
33
|
-
config.level = "none";
|
|
34
|
-
}
|
|
35
|
-
function setDebugMode(enabled) {
|
|
36
|
-
config.level = enabled ? "debug" : "error";
|
|
37
|
-
}
|
|
38
|
-
function isDebugMode() {
|
|
39
|
-
return config.level === "debug";
|
|
40
|
-
}
|
|
41
|
-
function shouldLog(level) {
|
|
42
|
-
return LOG_LEVEL_ORDER[level] >= LOG_LEVEL_ORDER[config.level];
|
|
43
|
-
}
|
|
44
|
-
function formatTag(tag, level) {
|
|
45
|
-
const timestamp = config.timestamps ? `${new Date().toISOString()} ` : "";
|
|
46
|
-
if (config.colors && level !== "none") {
|
|
47
|
-
const color = LOG_LEVEL_COLORS[level];
|
|
48
|
-
return `${timestamp}${color}[${tag}]${RESET_COLOR}`;
|
|
49
|
-
}
|
|
50
|
-
return `${timestamp}[${tag}]`;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
class Logger {
|
|
54
|
-
tag;
|
|
55
|
-
constructor(tag) {
|
|
56
|
-
this.tag = tag;
|
|
57
|
-
}
|
|
58
|
-
debug(...args) {
|
|
59
|
-
if (!shouldLog("debug"))
|
|
60
|
-
return;
|
|
61
|
-
if (config.handler) {
|
|
62
|
-
config.handler.debug(this.tag, ...args);
|
|
63
|
-
} else {
|
|
64
|
-
console.log(formatTag(this.tag, "debug"), ...args);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
info(...args) {
|
|
68
|
-
if (!shouldLog("info"))
|
|
69
|
-
return;
|
|
70
|
-
if (config.handler) {
|
|
71
|
-
config.handler.info(this.tag, ...args);
|
|
72
|
-
} else {
|
|
73
|
-
console.info(formatTag(this.tag, "info"), ...args);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
warn(...args) {
|
|
77
|
-
if (!shouldLog("warn"))
|
|
78
|
-
return;
|
|
79
|
-
if (config.handler) {
|
|
80
|
-
config.handler.warn(this.tag, ...args);
|
|
81
|
-
} else {
|
|
82
|
-
console.warn(formatTag(this.tag, "warn"), ...args);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
error(...args) {
|
|
86
|
-
if (!shouldLog("error"))
|
|
87
|
-
return;
|
|
88
|
-
if (config.handler) {
|
|
89
|
-
config.handler.error(this.tag, ...args);
|
|
90
|
-
} else {
|
|
91
|
-
console.error(formatTag(this.tag, "error"), ...args);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
time(label, fn) {
|
|
95
|
-
if (!shouldLog("debug")) {
|
|
96
|
-
return fn();
|
|
97
|
-
}
|
|
98
|
-
const start = performance.now();
|
|
99
|
-
try {
|
|
100
|
-
return fn();
|
|
101
|
-
} finally {
|
|
102
|
-
const duration = performance.now() - start;
|
|
103
|
-
this.debug(`${label}: ${duration.toFixed(2)}ms`);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
async timeAsync(label, fn) {
|
|
107
|
-
if (!shouldLog("debug")) {
|
|
108
|
-
return fn();
|
|
109
|
-
}
|
|
110
|
-
const start = performance.now();
|
|
111
|
-
try {
|
|
112
|
-
return await fn();
|
|
113
|
-
} finally {
|
|
114
|
-
const duration = performance.now() - start;
|
|
115
|
-
this.debug(`${label}: ${duration.toFixed(2)}ms`);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
child(subTag) {
|
|
119
|
-
return new Logger(`${this.tag}:${subTag}`);
|
|
120
|
-
}
|
|
121
|
-
debugIf(condition, ...args) {
|
|
122
|
-
if (condition)
|
|
123
|
-
this.debug(...args);
|
|
124
|
-
}
|
|
125
|
-
warnIf(condition, ...args) {
|
|
126
|
-
if (condition)
|
|
127
|
-
this.warn(...args);
|
|
128
|
-
}
|
|
129
|
-
errorIf(condition, ...args) {
|
|
130
|
-
if (condition)
|
|
131
|
-
this.error(...args);
|
|
132
|
-
}
|
|
133
|
-
loggedOnce = new Set;
|
|
134
|
-
warnOnce(key, ...args) {
|
|
135
|
-
if (this.loggedOnce.has(key))
|
|
136
|
-
return;
|
|
137
|
-
this.loggedOnce.add(key);
|
|
138
|
-
this.warn(...args);
|
|
139
|
-
}
|
|
140
|
-
debugOnce(key, ...args) {
|
|
141
|
-
if (this.loggedOnce.has(key))
|
|
142
|
-
return;
|
|
143
|
-
this.loggedOnce.add(key);
|
|
144
|
-
this.debug(...args);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
function createLogger(tag) {
|
|
148
|
-
return new Logger(tag);
|
|
149
|
-
}
|
|
150
|
-
var LOG_LEVEL_ORDER, LOG_LEVEL_COLORS, RESET_COLOR = "\x1B[0m", config, logger, log, frameworkLoggers;
|
|
151
|
-
var init_logger = __esm(() => {
|
|
152
|
-
LOG_LEVEL_ORDER = {
|
|
153
|
-
debug: 0,
|
|
154
|
-
info: 1,
|
|
155
|
-
warn: 2,
|
|
156
|
-
error: 3,
|
|
157
|
-
none: 4
|
|
158
|
-
};
|
|
159
|
-
LOG_LEVEL_COLORS = {
|
|
160
|
-
debug: "\x1B[36m",
|
|
161
|
-
info: "\x1B[32m",
|
|
162
|
-
warn: "\x1B[33m",
|
|
163
|
-
error: "\x1B[31m"
|
|
164
|
-
};
|
|
165
|
-
config = {
|
|
166
|
-
level: isProduction() ? "error" : "debug",
|
|
167
|
-
colors: true,
|
|
168
|
-
timestamps: false
|
|
169
|
-
};
|
|
170
|
-
logger = createLogger("Hypen");
|
|
171
|
-
log = {
|
|
172
|
-
debug: (tag, ...args) => {
|
|
173
|
-
if (!shouldLog("debug"))
|
|
174
|
-
return;
|
|
175
|
-
console.log(formatTag(tag, "debug"), ...args);
|
|
176
|
-
},
|
|
177
|
-
info: (tag, ...args) => {
|
|
178
|
-
if (!shouldLog("info"))
|
|
179
|
-
return;
|
|
180
|
-
console.info(formatTag(tag, "info"), ...args);
|
|
181
|
-
},
|
|
182
|
-
warn: (tag, ...args) => {
|
|
183
|
-
if (!shouldLog("warn"))
|
|
184
|
-
return;
|
|
185
|
-
console.warn(formatTag(tag, "warn"), ...args);
|
|
186
|
-
},
|
|
187
|
-
error: (tag, ...args) => {
|
|
188
|
-
if (!shouldLog("error"))
|
|
189
|
-
return;
|
|
190
|
-
console.error(formatTag(tag, "error"), ...args);
|
|
191
|
-
}
|
|
192
|
-
};
|
|
193
|
-
frameworkLoggers = {
|
|
194
|
-
hypen: createLogger("Hypen"),
|
|
195
|
-
engine: createLogger("Engine"),
|
|
196
|
-
router: createLogger("Router"),
|
|
197
|
-
state: createLogger("State"),
|
|
198
|
-
events: createLogger("Events"),
|
|
199
|
-
remote: createLogger("Remote"),
|
|
200
|
-
renderer: createLogger("Renderer"),
|
|
201
|
-
module: createLogger("Module"),
|
|
202
|
-
lifecycle: createLogger("Lifecycle"),
|
|
203
|
-
loader: createLogger("Loader"),
|
|
204
|
-
context: createLogger("Context"),
|
|
205
|
-
discovery: createLogger("Discovery"),
|
|
206
|
-
plugin: createLogger("Plugin"),
|
|
207
|
-
canvas: createLogger("Canvas"),
|
|
208
|
-
debug: createLogger("Debug")
|
|
209
|
-
};
|
|
210
|
-
});
|
|
28
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
211
29
|
|
|
212
30
|
// src/state.ts
|
|
213
31
|
function deepClone(obj) {
|
|
@@ -595,6 +413,205 @@ var init_result = __esm(() => {
|
|
|
595
413
|
};
|
|
596
414
|
});
|
|
597
415
|
|
|
416
|
+
// src/logger.ts
|
|
417
|
+
function isProduction() {
|
|
418
|
+
if (typeof process !== "undefined" && process.env) {
|
|
419
|
+
return false;
|
|
420
|
+
}
|
|
421
|
+
return false;
|
|
422
|
+
}
|
|
423
|
+
function setLogLevel(level) {
|
|
424
|
+
config.level = level;
|
|
425
|
+
}
|
|
426
|
+
function getLogLevel() {
|
|
427
|
+
return config.level;
|
|
428
|
+
}
|
|
429
|
+
function configureLogger(options) {
|
|
430
|
+
config = { ...config, ...options };
|
|
431
|
+
}
|
|
432
|
+
function enableLogging() {
|
|
433
|
+
config.level = "debug";
|
|
434
|
+
}
|
|
435
|
+
function disableLogging() {
|
|
436
|
+
config.level = "none";
|
|
437
|
+
}
|
|
438
|
+
function setDebugMode(enabled) {
|
|
439
|
+
config.level = enabled ? "debug" : "error";
|
|
440
|
+
}
|
|
441
|
+
function isDebugMode() {
|
|
442
|
+
return config.level === "debug";
|
|
443
|
+
}
|
|
444
|
+
function shouldLog(level) {
|
|
445
|
+
return LOG_LEVEL_ORDER[level] >= LOG_LEVEL_ORDER[config.level];
|
|
446
|
+
}
|
|
447
|
+
function formatTag(tag, level) {
|
|
448
|
+
const timestamp = config.timestamps ? `${new Date().toISOString()} ` : "";
|
|
449
|
+
if (config.colors && level !== "none") {
|
|
450
|
+
const color = LOG_LEVEL_COLORS[level];
|
|
451
|
+
return `${timestamp}${color}[${tag}]${RESET_COLOR}`;
|
|
452
|
+
}
|
|
453
|
+
return `${timestamp}[${tag}]`;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
class Logger {
|
|
457
|
+
tag;
|
|
458
|
+
constructor(tag) {
|
|
459
|
+
this.tag = tag;
|
|
460
|
+
}
|
|
461
|
+
debug(...args) {
|
|
462
|
+
if (!shouldLog("debug"))
|
|
463
|
+
return;
|
|
464
|
+
if (config.handler) {
|
|
465
|
+
config.handler.debug(this.tag, ...args);
|
|
466
|
+
} else {
|
|
467
|
+
console.log(formatTag(this.tag, "debug"), ...args);
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
info(...args) {
|
|
471
|
+
if (!shouldLog("info"))
|
|
472
|
+
return;
|
|
473
|
+
if (config.handler) {
|
|
474
|
+
config.handler.info(this.tag, ...args);
|
|
475
|
+
} else {
|
|
476
|
+
console.info(formatTag(this.tag, "info"), ...args);
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
warn(...args) {
|
|
480
|
+
if (!shouldLog("warn"))
|
|
481
|
+
return;
|
|
482
|
+
if (config.handler) {
|
|
483
|
+
config.handler.warn(this.tag, ...args);
|
|
484
|
+
} else {
|
|
485
|
+
console.warn(formatTag(this.tag, "warn"), ...args);
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
error(...args) {
|
|
489
|
+
if (!shouldLog("error"))
|
|
490
|
+
return;
|
|
491
|
+
if (config.handler) {
|
|
492
|
+
config.handler.error(this.tag, ...args);
|
|
493
|
+
} else {
|
|
494
|
+
console.error(formatTag(this.tag, "error"), ...args);
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
time(label, fn) {
|
|
498
|
+
if (!shouldLog("debug")) {
|
|
499
|
+
return fn();
|
|
500
|
+
}
|
|
501
|
+
const start = performance.now();
|
|
502
|
+
try {
|
|
503
|
+
return fn();
|
|
504
|
+
} finally {
|
|
505
|
+
const duration = performance.now() - start;
|
|
506
|
+
this.debug(`${label}: ${duration.toFixed(2)}ms`);
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
async timeAsync(label, fn) {
|
|
510
|
+
if (!shouldLog("debug")) {
|
|
511
|
+
return fn();
|
|
512
|
+
}
|
|
513
|
+
const start = performance.now();
|
|
514
|
+
try {
|
|
515
|
+
return await fn();
|
|
516
|
+
} finally {
|
|
517
|
+
const duration = performance.now() - start;
|
|
518
|
+
this.debug(`${label}: ${duration.toFixed(2)}ms`);
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
child(subTag) {
|
|
522
|
+
return new Logger(`${this.tag}:${subTag}`);
|
|
523
|
+
}
|
|
524
|
+
debugIf(condition, ...args) {
|
|
525
|
+
if (condition)
|
|
526
|
+
this.debug(...args);
|
|
527
|
+
}
|
|
528
|
+
warnIf(condition, ...args) {
|
|
529
|
+
if (condition)
|
|
530
|
+
this.warn(...args);
|
|
531
|
+
}
|
|
532
|
+
errorIf(condition, ...args) {
|
|
533
|
+
if (condition)
|
|
534
|
+
this.error(...args);
|
|
535
|
+
}
|
|
536
|
+
loggedOnce = new Set;
|
|
537
|
+
warnOnce(key, ...args) {
|
|
538
|
+
if (this.loggedOnce.has(key))
|
|
539
|
+
return;
|
|
540
|
+
this.loggedOnce.add(key);
|
|
541
|
+
this.warn(...args);
|
|
542
|
+
}
|
|
543
|
+
debugOnce(key, ...args) {
|
|
544
|
+
if (this.loggedOnce.has(key))
|
|
545
|
+
return;
|
|
546
|
+
this.loggedOnce.add(key);
|
|
547
|
+
this.debug(...args);
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
function createLogger(tag) {
|
|
551
|
+
return new Logger(tag);
|
|
552
|
+
}
|
|
553
|
+
var LOG_LEVEL_ORDER, LOG_LEVEL_COLORS, RESET_COLOR = "\x1B[0m", config, logger, log, frameworkLoggers;
|
|
554
|
+
var init_logger = __esm(() => {
|
|
555
|
+
LOG_LEVEL_ORDER = {
|
|
556
|
+
debug: 0,
|
|
557
|
+
info: 1,
|
|
558
|
+
warn: 2,
|
|
559
|
+
error: 3,
|
|
560
|
+
none: 4
|
|
561
|
+
};
|
|
562
|
+
LOG_LEVEL_COLORS = {
|
|
563
|
+
debug: "\x1B[36m",
|
|
564
|
+
info: "\x1B[32m",
|
|
565
|
+
warn: "\x1B[33m",
|
|
566
|
+
error: "\x1B[31m"
|
|
567
|
+
};
|
|
568
|
+
config = {
|
|
569
|
+
level: isProduction() ? "error" : "debug",
|
|
570
|
+
colors: true,
|
|
571
|
+
timestamps: false
|
|
572
|
+
};
|
|
573
|
+
logger = createLogger("Hypen");
|
|
574
|
+
log = {
|
|
575
|
+
debug: (tag, ...args) => {
|
|
576
|
+
if (!shouldLog("debug"))
|
|
577
|
+
return;
|
|
578
|
+
console.log(formatTag(tag, "debug"), ...args);
|
|
579
|
+
},
|
|
580
|
+
info: (tag, ...args) => {
|
|
581
|
+
if (!shouldLog("info"))
|
|
582
|
+
return;
|
|
583
|
+
console.info(formatTag(tag, "info"), ...args);
|
|
584
|
+
},
|
|
585
|
+
warn: (tag, ...args) => {
|
|
586
|
+
if (!shouldLog("warn"))
|
|
587
|
+
return;
|
|
588
|
+
console.warn(formatTag(tag, "warn"), ...args);
|
|
589
|
+
},
|
|
590
|
+
error: (tag, ...args) => {
|
|
591
|
+
if (!shouldLog("error"))
|
|
592
|
+
return;
|
|
593
|
+
console.error(formatTag(tag, "error"), ...args);
|
|
594
|
+
}
|
|
595
|
+
};
|
|
596
|
+
frameworkLoggers = {
|
|
597
|
+
hypen: createLogger("Hypen"),
|
|
598
|
+
engine: createLogger("Engine"),
|
|
599
|
+
router: createLogger("Router"),
|
|
600
|
+
state: createLogger("State"),
|
|
601
|
+
events: createLogger("Events"),
|
|
602
|
+
remote: createLogger("Remote"),
|
|
603
|
+
renderer: createLogger("Renderer"),
|
|
604
|
+
module: createLogger("Module"),
|
|
605
|
+
lifecycle: createLogger("Lifecycle"),
|
|
606
|
+
loader: createLogger("Loader"),
|
|
607
|
+
context: createLogger("Context"),
|
|
608
|
+
discovery: createLogger("Discovery"),
|
|
609
|
+
plugin: createLogger("Plugin"),
|
|
610
|
+
canvas: createLogger("Canvas"),
|
|
611
|
+
debug: createLogger("Debug")
|
|
612
|
+
};
|
|
613
|
+
});
|
|
614
|
+
|
|
598
615
|
// src/app.ts
|
|
599
616
|
var exports_app = {};
|
|
600
617
|
__export(exports_app, {
|
|
@@ -693,17 +710,21 @@ class HypenModuleInstance {
|
|
|
693
710
|
this.definition = definition;
|
|
694
711
|
this.routerContext = routerContext;
|
|
695
712
|
this.globalContext = globalContext;
|
|
713
|
+
const statePrefix = (definition.name || "").toLowerCase();
|
|
696
714
|
this.state = createObservableState(definition.initialState, {
|
|
697
715
|
onChange: (change) => {
|
|
698
716
|
this.engine.notifyStateChange(change.paths, change.newValues);
|
|
699
717
|
this.stateChangeCallbacks.forEach((cb) => cb());
|
|
700
|
-
}
|
|
718
|
+
},
|
|
719
|
+
pathPrefix: statePrefix || undefined
|
|
701
720
|
});
|
|
702
|
-
|
|
721
|
+
const snapshot = getStateSnapshot(this.state);
|
|
722
|
+
const prefixedState = statePrefix ? { [statePrefix]: snapshot } : snapshot;
|
|
723
|
+
this.engine.setModule(definition.name || "AnonymousModule", definition.actions, definition.stateKeys, prefixedState);
|
|
703
724
|
for (const [actionName, handler] of definition.handlers.onAction) {
|
|
704
|
-
|
|
725
|
+
log2.debug(`Registering action handler: ${actionName} for module ${definition.name}`);
|
|
705
726
|
this.engine.onAction(actionName, async (action) => {
|
|
706
|
-
|
|
727
|
+
log2.debug(`Action handler fired: ${actionName}`, action);
|
|
707
728
|
const actionCtx = {
|
|
708
729
|
name: action.name,
|
|
709
730
|
payload: action.payload,
|
|
@@ -725,7 +746,7 @@ class HypenModuleInstance {
|
|
|
725
746
|
throw result.error;
|
|
726
747
|
}
|
|
727
748
|
} else {
|
|
728
|
-
|
|
749
|
+
log2.debug(`Action handler completed: ${actionName}`);
|
|
729
750
|
}
|
|
730
751
|
});
|
|
731
752
|
}
|
|
@@ -780,7 +801,7 @@ class HypenModuleInstance {
|
|
|
780
801
|
}
|
|
781
802
|
}
|
|
782
803
|
} catch (handlerError) {
|
|
783
|
-
|
|
804
|
+
log2.error("Error in onError handler:", handlerError);
|
|
784
805
|
}
|
|
785
806
|
}
|
|
786
807
|
if (this.globalContext) {
|
|
@@ -791,7 +812,7 @@ class HypenModuleInstance {
|
|
|
791
812
|
context: eventContext
|
|
792
813
|
});
|
|
793
814
|
}
|
|
794
|
-
|
|
815
|
+
log2.error(`${context.actionName ? `Action "${context.actionName}"` : `Lifecycle "${context.lifecycle}"`} error:`, error);
|
|
795
816
|
return false;
|
|
796
817
|
}
|
|
797
818
|
async callCreatedHandler() {
|
|
@@ -821,19 +842,19 @@ class HypenModuleInstance {
|
|
|
821
842
|
Object.assign(this.state, patch);
|
|
822
843
|
}
|
|
823
844
|
}
|
|
824
|
-
var
|
|
845
|
+
var log2, app;
|
|
825
846
|
var init_app = __esm(() => {
|
|
826
847
|
init_result();
|
|
827
848
|
init_state();
|
|
828
849
|
init_logger();
|
|
829
|
-
|
|
850
|
+
log2 = createLogger("ModuleInstance");
|
|
830
851
|
app = new HypenApp;
|
|
831
852
|
});
|
|
832
853
|
|
|
833
854
|
// src/engine.ts
|
|
834
855
|
init_logger();
|
|
835
856
|
import { WasmEngine } from "../wasm-node/hypen_engine.js";
|
|
836
|
-
var
|
|
857
|
+
var log3 = frameworkLoggers.engine;
|
|
837
858
|
function unwrapForWasm(value) {
|
|
838
859
|
if (value === null || typeof value !== "object") {
|
|
839
860
|
return value;
|
|
@@ -894,13 +915,13 @@ class Engine {
|
|
|
894
915
|
return;
|
|
895
916
|
}
|
|
896
917
|
engine.updateStateSparse(paths, unwrapForWasm(values));
|
|
897
|
-
|
|
918
|
+
log3.debug("State changed (sparse):", paths);
|
|
898
919
|
}
|
|
899
920
|
notifyStateChangeFull(paths, currentState) {
|
|
900
921
|
const engine = this.ensureInitialized();
|
|
901
922
|
engine.updateState(unwrapForWasm(currentState));
|
|
902
923
|
if (paths.length > 0) {
|
|
903
|
-
|
|
924
|
+
log3.debug("State changed (full):", paths);
|
|
904
925
|
}
|
|
905
926
|
}
|
|
906
927
|
updateState(statePatch) {
|
|
@@ -914,7 +935,7 @@ class Engine {
|
|
|
914
935
|
onAction(actionName, handler) {
|
|
915
936
|
const engine = this.ensureInitialized();
|
|
916
937
|
engine.onAction(actionName, (action) => {
|
|
917
|
-
Promise.resolve(handler(action)).catch((err) =>
|
|
938
|
+
Promise.resolve(handler(action)).catch((err) => log3.error("Action handler error:", err));
|
|
918
939
|
});
|
|
919
940
|
}
|
|
920
941
|
setModule(name, actions, stateKeys, initialState) {
|
|
@@ -1439,4 +1460,4 @@ export {
|
|
|
1439
1460
|
RemoteServer
|
|
1440
1461
|
};
|
|
1441
1462
|
|
|
1442
|
-
//# debugId=
|
|
1463
|
+
//# debugId=1E9F674E53CBE95764756E2164756E21
|