@hypen-space/core 0.4.980 → 0.5.3
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/README.md +5 -8
- package/dist/a11y.d.ts +82 -0
- package/dist/app.js +13 -1168
- package/dist/app.js.map +3 -9
- package/dist/chunk-00zt3w6e.js +58 -0
- package/dist/chunk-00zt3w6e.js.map +10 -0
- package/dist/chunk-3zvyth50.js +87 -0
- package/dist/chunk-3zvyth50.js.map +10 -0
- package/dist/chunk-5gtx3pza.js +11 -0
- package/dist/chunk-5gtx3pza.js.map +9 -0
- package/dist/chunk-7222131a.js +191 -0
- package/dist/chunk-7222131a.js.map +10 -0
- package/dist/chunk-avchpwhf.js +200 -0
- package/dist/chunk-avchpwhf.js.map +10 -0
- package/dist/chunk-ec0tgy9a.js +154 -0
- package/dist/chunk-ec0tgy9a.js.map +10 -0
- package/dist/chunk-fnss4dm2.js +479 -0
- package/dist/chunk-fnss4dm2.js.map +10 -0
- package/dist/chunk-g2gz9pgg.js +133 -0
- package/dist/chunk-g2gz9pgg.js.map +10 -0
- package/dist/chunk-g72v6mmf.js +341 -0
- package/dist/chunk-g72v6mmf.js.map +10 -0
- package/dist/chunk-g7g3jxty.js +351 -0
- package/dist/chunk-g7g3jxty.js.map +10 -0
- package/dist/chunk-g830re2c.js +50 -0
- package/dist/chunk-g830re2c.js.map +10 -0
- package/dist/chunk-gtwh1sg7.js +127 -0
- package/dist/chunk-gtwh1sg7.js.map +10 -0
- package/dist/chunk-k12cwfst.js +72 -0
- package/dist/chunk-k12cwfst.js.map +10 -0
- package/dist/chunk-mbqqsz6r.js +128 -0
- package/dist/chunk-mbqqsz6r.js.map +10 -0
- package/dist/chunk-ne632swm.js +209 -0
- package/dist/chunk-ne632swm.js.map +10 -0
- package/dist/chunk-p3pj1bax.js +206 -0
- package/dist/chunk-p3pj1bax.js.map +10 -0
- package/dist/chunk-vshdk2pw.js +56 -0
- package/dist/chunk-vshdk2pw.js.map +10 -0
- package/dist/chunk-wp2ebn2m.js +51 -0
- package/dist/chunk-wp2ebn2m.js.map +10 -0
- package/dist/chunk-x4qv4jm9.js +88 -0
- package/dist/chunk-x4qv4jm9.js.map +10 -0
- package/dist/chunk-ycxp4drd.js +211 -0
- package/dist/chunk-ycxp4drd.js.map +10 -0
- package/dist/components/builtin.js +14 -1246
- package/dist/components/builtin.js.map +3 -10
- package/dist/context.js +7 -362
- package/dist/context.js.map +3 -6
- package/dist/datasource.js +5 -76
- package/dist/datasource.js.map +3 -4
- package/dist/disposable.js +20 -367
- package/dist/disposable.js.map +3 -5
- package/dist/engine-base.d.ts +38 -2
- package/dist/engine-base.js +45 -412
- package/dist/engine-base.js.map +4 -6
- package/dist/events.js +7 -285
- package/dist/events.js.map +3 -5
- package/dist/hypen.js +8 -71
- package/dist/hypen.js.map +3 -4
- package/dist/index.browser.js +58 -2152
- package/dist/index.browser.js.map +3 -16
- package/dist/index.d.ts +4 -0
- package/dist/index.js +175 -3057
- package/dist/index.js.map +5 -22
- package/dist/logger.js +16 -220
- package/dist/logger.js.map +3 -4
- package/dist/managed-router.js +12 -1367
- package/dist/managed-router.js.map +3 -10
- package/dist/portable.js +6 -70
- package/dist/portable.js.map +3 -4
- package/dist/remote/client.js +9 -1010
- package/dist/remote/client.js.map +3 -8
- package/dist/remote/index.d.ts +2 -0
- package/dist/remote/index.js +511 -1066
- package/dist/remote/index.js.map +4 -9
- package/dist/remote/remote-session.d.ts +245 -0
- package/dist/remote/session.js +5 -147
- package/dist/remote/session.js.map +3 -4
- package/dist/renderer.js +7 -271
- package/dist/renderer.js.map +3 -5
- package/dist/resolver.js +5 -484
- package/dist/resolver.js.map +3 -5
- package/dist/result.js +25 -211
- package/dist/result.js.map +3 -4
- package/dist/retry.js +10 -336
- package/dist/retry.js.map +3 -5
- package/dist/router.js +9 -807
- package/dist/router.js.map +3 -8
- package/dist/state.js +10 -274
- package/dist/state.js.map +3 -5
- package/dist/types.d.ts +129 -1
- package/dist/validate.d.ts +19 -0
- package/package.json +13 -1
- package/src/a11y.ts +127 -0
- package/src/engine-base.ts +87 -4
- package/src/index.ts +10 -0
- package/src/remote/index.ts +16 -0
- package/src/remote/remote-session.ts +998 -0
- package/src/types.ts +131 -1
- package/src/validate.ts +37 -0
package/dist/engine-base.js
CHANGED
|
@@ -1,417 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
__defProp(target, name, {
|
|
9
|
-
get: all[name],
|
|
10
|
-
enumerable: true,
|
|
11
|
-
configurable: true,
|
|
12
|
-
set: __exportSetter.bind(all, name)
|
|
13
|
-
});
|
|
14
|
-
};
|
|
15
|
-
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
16
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
17
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
18
|
-
}) : x)(function(x) {
|
|
19
|
-
if (typeof require !== "undefined")
|
|
20
|
-
return require.apply(this, arguments);
|
|
21
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
22
|
-
});
|
|
1
|
+
import {
|
|
2
|
+
classifyEngineError
|
|
3
|
+
} from "./chunk-7222131a.js";
|
|
4
|
+
import {
|
|
5
|
+
frameworkLoggers
|
|
6
|
+
} from "./chunk-avchpwhf.js";
|
|
7
|
+
import"./chunk-5gtx3pza.js";
|
|
23
8
|
|
|
24
|
-
// src/
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
function isOk(result) {
|
|
32
|
-
return result.ok;
|
|
33
|
-
}
|
|
34
|
-
function isErr(result) {
|
|
35
|
-
return !result.ok;
|
|
36
|
-
}
|
|
37
|
-
async function fromPromise(promise, mapError) {
|
|
38
|
-
try {
|
|
39
|
-
const value = await promise;
|
|
40
|
-
return Ok(value);
|
|
41
|
-
} catch (e) {
|
|
42
|
-
if (mapError) {
|
|
43
|
-
return Err(mapError(e));
|
|
44
|
-
}
|
|
45
|
-
return Err(e);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
function fromTry(fn, mapError) {
|
|
49
|
-
try {
|
|
50
|
-
return Ok(fn());
|
|
51
|
-
} catch (e) {
|
|
52
|
-
if (mapError) {
|
|
53
|
-
return Err(mapError(e));
|
|
54
|
-
}
|
|
55
|
-
return Err(e);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
function map(result, fn) {
|
|
59
|
-
if (result.ok) {
|
|
60
|
-
return Ok(fn(result.value));
|
|
61
|
-
}
|
|
62
|
-
return result;
|
|
63
|
-
}
|
|
64
|
-
function mapErr(result, fn) {
|
|
65
|
-
if (!result.ok) {
|
|
66
|
-
return Err(fn(result.error));
|
|
67
|
-
}
|
|
68
|
-
return result;
|
|
69
|
-
}
|
|
70
|
-
function flatMap(result, fn) {
|
|
71
|
-
if (result.ok) {
|
|
72
|
-
return fn(result.value);
|
|
73
|
-
}
|
|
74
|
-
return result;
|
|
75
|
-
}
|
|
76
|
-
function unwrap(result) {
|
|
77
|
-
if (result.ok) {
|
|
78
|
-
return result.value;
|
|
79
|
-
}
|
|
80
|
-
throw result.error;
|
|
81
|
-
}
|
|
82
|
-
function unwrapOr(result, defaultValue) {
|
|
83
|
-
if (result.ok) {
|
|
84
|
-
return result.value;
|
|
85
|
-
}
|
|
86
|
-
return defaultValue;
|
|
87
|
-
}
|
|
88
|
-
function unwrapOrElse(result, fn) {
|
|
89
|
-
if (result.ok) {
|
|
90
|
-
return result.value;
|
|
91
|
-
}
|
|
92
|
-
return fn(result.error);
|
|
93
|
-
}
|
|
94
|
-
function match(result, handlers) {
|
|
95
|
-
if (result.ok) {
|
|
96
|
-
return handlers.ok(result.value);
|
|
97
|
-
}
|
|
98
|
-
return handlers.err(result.error);
|
|
99
|
-
}
|
|
100
|
-
function all(results) {
|
|
101
|
-
const values = [];
|
|
102
|
-
for (const result of results) {
|
|
103
|
-
if (!result.ok) {
|
|
104
|
-
return result;
|
|
105
|
-
}
|
|
106
|
-
values.push(result.value);
|
|
107
|
-
}
|
|
108
|
-
return Ok(values);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
class HypenError extends Error {
|
|
112
|
-
code;
|
|
113
|
-
context;
|
|
114
|
-
cause;
|
|
115
|
-
constructor(code, message, options) {
|
|
116
|
-
super(message);
|
|
117
|
-
this.name = "HypenError";
|
|
118
|
-
this.code = code;
|
|
119
|
-
this.context = options?.context;
|
|
120
|
-
this.cause = options?.cause;
|
|
121
|
-
Object.setPrototypeOf(this, new.target.prototype);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
class ActionError extends HypenError {
|
|
126
|
-
actionName;
|
|
127
|
-
constructor(actionName, cause) {
|
|
128
|
-
super("ACTION_ERROR", `Action handler "${actionName}" failed: ${cause instanceof Error ? cause.message : String(cause)}`, {
|
|
129
|
-
context: { actionName },
|
|
130
|
-
cause: cause instanceof Error ? cause : undefined
|
|
131
|
-
});
|
|
132
|
-
this.name = "ActionError";
|
|
133
|
-
this.actionName = actionName;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
class ConnectionError extends HypenError {
|
|
138
|
-
url;
|
|
139
|
-
attempt;
|
|
140
|
-
constructor(url, cause, attempt) {
|
|
141
|
-
super("CONNECTION_ERROR", `Connection to "${url}" failed${attempt ? ` (attempt ${attempt})` : ""}: ${cause instanceof Error ? cause.message : String(cause)}`, {
|
|
142
|
-
context: { url, attempt },
|
|
143
|
-
cause: cause instanceof Error ? cause : undefined
|
|
144
|
-
});
|
|
145
|
-
this.name = "ConnectionError";
|
|
146
|
-
this.url = url;
|
|
147
|
-
this.attempt = attempt;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
class StateError extends HypenError {
|
|
152
|
-
path;
|
|
153
|
-
constructor(message, path, cause) {
|
|
154
|
-
super("STATE_ERROR", message, {
|
|
155
|
-
context: { path },
|
|
156
|
-
cause: cause instanceof Error ? cause : undefined
|
|
157
|
-
});
|
|
158
|
-
this.name = "StateError";
|
|
159
|
-
this.path = path;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
class ParseError extends HypenError {
|
|
164
|
-
source;
|
|
165
|
-
constructor(message, source, cause) {
|
|
166
|
-
super("PARSE_ERROR", message, {
|
|
167
|
-
context: { source },
|
|
168
|
-
cause: cause instanceof Error ? cause : undefined
|
|
169
|
-
});
|
|
170
|
-
this.name = "ParseError";
|
|
171
|
-
this.source = source;
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
class RenderError extends HypenError {
|
|
176
|
-
constructor(message, cause) {
|
|
177
|
-
super("RENDER_ERROR", message, {
|
|
178
|
-
cause: cause instanceof Error ? cause : undefined
|
|
179
|
-
});
|
|
180
|
-
this.name = "RenderError";
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
function classifyEngineError(err) {
|
|
184
|
-
if (err && typeof err === "object" && "message" in err && "type" in err) {
|
|
185
|
-
const structured = err;
|
|
186
|
-
switch (structured.type) {
|
|
187
|
-
case "parseError":
|
|
188
|
-
return new ParseError(structured.message);
|
|
189
|
-
case "stateError":
|
|
190
|
-
return new StateError(structured.message);
|
|
191
|
-
case "renderError":
|
|
192
|
-
return new RenderError(structured.message);
|
|
193
|
-
case "actionError":
|
|
194
|
-
return new HypenError("ACTION_ERROR", structured.message);
|
|
195
|
-
default:
|
|
196
|
-
return new HypenError("UNKNOWN_ERROR", structured.message);
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
200
|
-
if (message.startsWith("Parse error:")) {
|
|
201
|
-
return new ParseError(message);
|
|
202
|
-
}
|
|
203
|
-
if (message.startsWith("Invalid state:") || message.startsWith("Invalid state patch:")) {
|
|
204
|
-
return new StateError(message);
|
|
205
|
-
}
|
|
206
|
-
if (message.startsWith("Parent node not found:")) {
|
|
207
|
-
return new RenderError(message);
|
|
208
|
-
}
|
|
209
|
-
return new RenderError(message);
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
// src/logger.ts
|
|
213
|
-
var LOG_LEVEL_ORDER = {
|
|
214
|
-
debug: 0,
|
|
215
|
-
info: 1,
|
|
216
|
-
warn: 2,
|
|
217
|
-
error: 3,
|
|
218
|
-
none: 4
|
|
219
|
-
};
|
|
220
|
-
var LOG_LEVEL_COLORS = {
|
|
221
|
-
debug: "\x1B[36m",
|
|
222
|
-
info: "\x1B[32m",
|
|
223
|
-
warn: "\x1B[33m",
|
|
224
|
-
error: "\x1B[31m"
|
|
225
|
-
};
|
|
226
|
-
var RESET_COLOR = "\x1B[0m";
|
|
227
|
-
function isProduction() {
|
|
228
|
-
if (typeof process !== "undefined" && process.env) {
|
|
229
|
-
return false;
|
|
230
|
-
}
|
|
231
|
-
return false;
|
|
232
|
-
}
|
|
233
|
-
var config = {
|
|
234
|
-
level: isProduction() ? "error" : "info",
|
|
235
|
-
colors: true,
|
|
236
|
-
timestamps: false
|
|
237
|
-
};
|
|
238
|
-
function setLogLevel(level) {
|
|
239
|
-
config.level = level;
|
|
240
|
-
}
|
|
241
|
-
function getLogLevel() {
|
|
242
|
-
return config.level;
|
|
243
|
-
}
|
|
244
|
-
function configureLogger(options) {
|
|
245
|
-
config = { ...config, ...options };
|
|
246
|
-
}
|
|
247
|
-
function enableLogging() {
|
|
248
|
-
config.level = "debug";
|
|
249
|
-
}
|
|
250
|
-
function disableLogging() {
|
|
251
|
-
config.level = "none";
|
|
252
|
-
}
|
|
253
|
-
function setDebugMode(enabled) {
|
|
254
|
-
config.level = enabled ? "debug" : "error";
|
|
255
|
-
}
|
|
256
|
-
function isDebugMode() {
|
|
257
|
-
return config.level === "debug";
|
|
258
|
-
}
|
|
259
|
-
function shouldLog(level) {
|
|
260
|
-
return LOG_LEVEL_ORDER[level] >= LOG_LEVEL_ORDER[config.level];
|
|
261
|
-
}
|
|
262
|
-
function formatTag(tag, level) {
|
|
263
|
-
const timestamp = config.timestamps ? `${new Date().toISOString()} ` : "";
|
|
264
|
-
if (config.colors && level !== "none") {
|
|
265
|
-
const color = LOG_LEVEL_COLORS[level];
|
|
266
|
-
return `${timestamp}${color}[${tag}]${RESET_COLOR}`;
|
|
267
|
-
}
|
|
268
|
-
return `${timestamp}[${tag}]`;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
class Logger {
|
|
272
|
-
tag;
|
|
273
|
-
constructor(tag) {
|
|
274
|
-
this.tag = tag;
|
|
275
|
-
}
|
|
276
|
-
debug(...args) {
|
|
277
|
-
if (!shouldLog("debug"))
|
|
278
|
-
return;
|
|
279
|
-
if (config.handler) {
|
|
280
|
-
config.handler.debug(this.tag, ...args);
|
|
281
|
-
} else {
|
|
282
|
-
console.log(formatTag(this.tag, "debug"), ...args);
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
info(...args) {
|
|
286
|
-
if (!shouldLog("info"))
|
|
287
|
-
return;
|
|
288
|
-
if (config.handler) {
|
|
289
|
-
config.handler.info(this.tag, ...args);
|
|
290
|
-
} else {
|
|
291
|
-
console.info(formatTag(this.tag, "info"), ...args);
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
warn(...args) {
|
|
295
|
-
if (!shouldLog("warn"))
|
|
296
|
-
return;
|
|
297
|
-
if (config.handler) {
|
|
298
|
-
config.handler.warn(this.tag, ...args);
|
|
299
|
-
} else {
|
|
300
|
-
console.warn(formatTag(this.tag, "warn"), ...args);
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
error(...args) {
|
|
304
|
-
if (!shouldLog("error"))
|
|
305
|
-
return;
|
|
306
|
-
if (config.handler) {
|
|
307
|
-
config.handler.error(this.tag, ...args);
|
|
308
|
-
} else {
|
|
309
|
-
console.error(formatTag(this.tag, "error"), ...args);
|
|
9
|
+
// src/engine-base.ts
|
|
10
|
+
var log = frameworkLoggers.engine;
|
|
11
|
+
function mapToPlainObject(value) {
|
|
12
|
+
if (value instanceof Map) {
|
|
13
|
+
const obj = {};
|
|
14
|
+
for (const [key, val] of value.entries()) {
|
|
15
|
+
obj[key] = mapToPlainObject(val);
|
|
310
16
|
}
|
|
17
|
+
return obj;
|
|
311
18
|
}
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
return fn();
|
|
315
|
-
}
|
|
316
|
-
const start = performance.now();
|
|
317
|
-
try {
|
|
318
|
-
return fn();
|
|
319
|
-
} finally {
|
|
320
|
-
const duration = performance.now() - start;
|
|
321
|
-
this.debug(`${label}: ${duration.toFixed(2)}ms`);
|
|
322
|
-
}
|
|
19
|
+
if (Array.isArray(value)) {
|
|
20
|
+
return value.map(mapToPlainObject);
|
|
323
21
|
}
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
const start = performance.now();
|
|
329
|
-
try {
|
|
330
|
-
return await fn();
|
|
331
|
-
} finally {
|
|
332
|
-
const duration = performance.now() - start;
|
|
333
|
-
this.debug(`${label}: ${duration.toFixed(2)}ms`);
|
|
22
|
+
if (value && typeof value === "object" && value.constructor === Object) {
|
|
23
|
+
const obj = {};
|
|
24
|
+
for (const [key, val] of Object.entries(value)) {
|
|
25
|
+
obj[key] = mapToPlainObject(val);
|
|
334
26
|
}
|
|
27
|
+
return obj;
|
|
335
28
|
}
|
|
336
|
-
|
|
337
|
-
return new Logger(`${this.tag}:${subTag}`);
|
|
338
|
-
}
|
|
339
|
-
debugIf(condition, ...args) {
|
|
340
|
-
if (condition)
|
|
341
|
-
this.debug(...args);
|
|
342
|
-
}
|
|
343
|
-
warnIf(condition, ...args) {
|
|
344
|
-
if (condition)
|
|
345
|
-
this.warn(...args);
|
|
346
|
-
}
|
|
347
|
-
errorIf(condition, ...args) {
|
|
348
|
-
if (condition)
|
|
349
|
-
this.error(...args);
|
|
350
|
-
}
|
|
351
|
-
loggedOnce = new Set;
|
|
352
|
-
warnOnce(key, ...args) {
|
|
353
|
-
if (this.loggedOnce.has(key))
|
|
354
|
-
return;
|
|
355
|
-
this.loggedOnce.add(key);
|
|
356
|
-
this.warn(...args);
|
|
357
|
-
}
|
|
358
|
-
debugOnce(key, ...args) {
|
|
359
|
-
if (this.loggedOnce.has(key))
|
|
360
|
-
return;
|
|
361
|
-
this.loggedOnce.add(key);
|
|
362
|
-
this.debug(...args);
|
|
363
|
-
}
|
|
29
|
+
return value;
|
|
364
30
|
}
|
|
365
|
-
function createLogger(tag) {
|
|
366
|
-
return new Logger(tag);
|
|
367
|
-
}
|
|
368
|
-
var logger = createLogger("Hypen");
|
|
369
|
-
var log = {
|
|
370
|
-
debug: (tag, ...args) => {
|
|
371
|
-
if (!shouldLog("debug"))
|
|
372
|
-
return;
|
|
373
|
-
console.log(formatTag(tag, "debug"), ...args);
|
|
374
|
-
},
|
|
375
|
-
info: (tag, ...args) => {
|
|
376
|
-
if (!shouldLog("info"))
|
|
377
|
-
return;
|
|
378
|
-
console.info(formatTag(tag, "info"), ...args);
|
|
379
|
-
},
|
|
380
|
-
warn: (tag, ...args) => {
|
|
381
|
-
if (!shouldLog("warn"))
|
|
382
|
-
return;
|
|
383
|
-
console.warn(formatTag(tag, "warn"), ...args);
|
|
384
|
-
},
|
|
385
|
-
error: (tag, ...args) => {
|
|
386
|
-
if (!shouldLog("error"))
|
|
387
|
-
return;
|
|
388
|
-
console.error(formatTag(tag, "error"), ...args);
|
|
389
|
-
}
|
|
390
|
-
};
|
|
391
|
-
var frameworkLoggers = {
|
|
392
|
-
hypen: createLogger("Hypen"),
|
|
393
|
-
engine: createLogger("Engine"),
|
|
394
|
-
router: createLogger("Router"),
|
|
395
|
-
state: createLogger("State"),
|
|
396
|
-
events: createLogger("Events"),
|
|
397
|
-
remote: createLogger("Remote"),
|
|
398
|
-
renderer: createLogger("Renderer"),
|
|
399
|
-
module: createLogger("Module"),
|
|
400
|
-
lifecycle: createLogger("Lifecycle"),
|
|
401
|
-
loader: createLogger("Loader"),
|
|
402
|
-
context: createLogger("Context"),
|
|
403
|
-
discovery: createLogger("Discovery"),
|
|
404
|
-
plugin: createLogger("Plugin"),
|
|
405
|
-
canvas: createLogger("Canvas"),
|
|
406
|
-
debug: createLogger("Debug")
|
|
407
|
-
};
|
|
408
|
-
|
|
409
|
-
// src/engine-base.ts
|
|
410
|
-
var log2 = frameworkLoggers.engine;
|
|
411
31
|
|
|
412
32
|
class BaseEngine {
|
|
413
33
|
wasmEngine = null;
|
|
414
34
|
initialized = false;
|
|
35
|
+
unresolvedComponents = new Set;
|
|
415
36
|
ensureInitialized() {
|
|
416
37
|
if (!this.wasmEngine) {
|
|
417
38
|
throw new Error("Engine not initialized. Call init() first.");
|
|
@@ -427,9 +48,19 @@ class BaseEngine {
|
|
|
427
48
|
setComponentResolver(resolver) {
|
|
428
49
|
const engine = this.ensureInitialized();
|
|
429
50
|
engine.setComponentResolver((componentName, contextPath) => {
|
|
430
|
-
|
|
51
|
+
const resolved = resolver(componentName, contextPath);
|
|
52
|
+
if (resolved == null) {
|
|
53
|
+
if (!this.unresolvedComponents.has(componentName)) {
|
|
54
|
+
this.unresolvedComponents.add(componentName);
|
|
55
|
+
log.warn(`Component "${componentName}" did not resolve: it is not a ` + `registered primitive and the component resolver returned null. ` + `The engine will emit an opaque Create for it and the renderer ` + `will drop it. Did you forget to register/.module(...) the ` + `component, or is its name misspelled in the template?`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return resolved;
|
|
431
59
|
});
|
|
432
60
|
}
|
|
61
|
+
getUnresolvedComponents() {
|
|
62
|
+
return [...this.unresolvedComponents];
|
|
63
|
+
}
|
|
433
64
|
renderSource(source) {
|
|
434
65
|
const engine = this.ensureInitialized();
|
|
435
66
|
try {
|
|
@@ -460,7 +91,7 @@ class BaseEngine {
|
|
|
460
91
|
} catch (err) {
|
|
461
92
|
throw classifyEngineError(err);
|
|
462
93
|
}
|
|
463
|
-
|
|
94
|
+
log.debug("State changed (sparse):", { scope, paths });
|
|
464
95
|
}
|
|
465
96
|
updateState(scope, statePatch) {
|
|
466
97
|
const engine = this.ensureInitialized();
|
|
@@ -479,12 +110,14 @@ class BaseEngine {
|
|
|
479
110
|
engine.onAction(actionName, (action) => {
|
|
480
111
|
const normalized = this.normalizeAction(action);
|
|
481
112
|
Promise.resolve(handler(normalized)).catch((err) => {
|
|
482
|
-
|
|
113
|
+
log.error("Action handler error:", err);
|
|
483
114
|
});
|
|
484
115
|
});
|
|
485
116
|
}
|
|
486
117
|
normalizeAction(action) {
|
|
487
|
-
|
|
118
|
+
if (!action.payload)
|
|
119
|
+
return action;
|
|
120
|
+
return { ...action, payload: mapToPlainObject(action.payload) };
|
|
488
121
|
}
|
|
489
122
|
discoverRouters(source) {
|
|
490
123
|
const engine = this.ensureInitialized();
|
|
@@ -552,20 +185,20 @@ class BaseEngine {
|
|
|
552
185
|
} catch (err) {
|
|
553
186
|
throw classifyEngineError(err);
|
|
554
187
|
}
|
|
555
|
-
|
|
188
|
+
log.debug(`Data source "${name}" context set`);
|
|
556
189
|
}
|
|
557
190
|
removeContext(name) {
|
|
558
191
|
const engine = this.ensureInitialized();
|
|
559
192
|
engine.removeContext(name);
|
|
560
193
|
}
|
|
561
|
-
registerResources(
|
|
194
|
+
registerResources(map) {
|
|
562
195
|
const engine = this.ensureInitialized();
|
|
563
|
-
engine.registerResources(
|
|
564
|
-
|
|
196
|
+
engine.registerResources(map);
|
|
197
|
+
log.debug(`Resources registered (${Object.keys(map).length} entries)`);
|
|
565
198
|
}
|
|
566
199
|
}
|
|
567
200
|
export {
|
|
568
201
|
BaseEngine
|
|
569
202
|
};
|
|
570
203
|
|
|
571
|
-
//# debugId=
|
|
204
|
+
//# debugId=0B860F9754DCCD3064756E2164756E21
|