@hypen-space/core 0.4.37 → 0.4.39

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 (85) hide show
  1. package/README.md +13 -14
  2. package/dist/app.js +304 -227
  3. package/dist/app.js.map +5 -5
  4. package/dist/components/builtin.d.ts +17 -0
  5. package/dist/components/builtin.js +336 -256
  6. package/dist/components/builtin.js.map +6 -6
  7. package/dist/context.d.ts +11 -20
  8. package/dist/context.js +69 -101
  9. package/dist/context.js.map +3 -3
  10. package/dist/datasource.js +80 -0
  11. package/dist/datasource.js.map +10 -0
  12. package/dist/disposable.js +60 -63
  13. package/dist/disposable.js.map +2 -2
  14. package/dist/events.js +60 -63
  15. package/dist/events.js.map +2 -2
  16. package/dist/hypen.js +78 -0
  17. package/dist/hypen.js.map +10 -0
  18. package/dist/index.browser.d.ts +2 -1
  19. package/dist/index.browser.js +327 -281
  20. package/dist/index.browser.js.map +7 -8
  21. package/dist/index.d.ts +0 -3
  22. package/dist/index.js +547 -246
  23. package/dist/index.js.map +9 -9
  24. package/dist/logger.js +60 -64
  25. package/dist/logger.js.map +2 -2
  26. package/dist/remote/client.js +258 -158
  27. package/dist/remote/client.js.map +6 -6
  28. package/dist/remote/index.d.ts +6 -5
  29. package/dist/remote/index.js +255 -1985
  30. package/dist/remote/index.js.map +6 -13
  31. package/dist/remote/session.js +151 -0
  32. package/dist/remote/session.js.map +10 -0
  33. package/dist/renderer.js +60 -63
  34. package/dist/renderer.js.map +2 -2
  35. package/dist/result.js +235 -0
  36. package/dist/result.js.map +10 -0
  37. package/dist/retry.js +344 -0
  38. package/dist/retry.js.map +11 -0
  39. package/dist/router.js +62 -70
  40. package/dist/router.js.map +2 -2
  41. package/dist/state.js +3 -8
  42. package/dist/state.js.map +2 -2
  43. package/package.json +11 -56
  44. package/src/components/builtin.ts +78 -56
  45. package/src/context.ts +22 -65
  46. package/src/index.browser.ts +5 -4
  47. package/src/index.ts +10 -23
  48. package/src/remote/index.ts +9 -5
  49. package/src/result.ts +11 -0
  50. package/dist/discovery.d.ts +0 -90
  51. package/dist/discovery.js +0 -1334
  52. package/dist/discovery.js.map +0 -15
  53. package/dist/engine.browser.d.ts +0 -116
  54. package/dist/engine.browser.js +0 -479
  55. package/dist/engine.browser.js.map +0 -12
  56. package/dist/engine.d.ts +0 -107
  57. package/dist/engine.js +0 -543
  58. package/dist/engine.js.map +0 -12
  59. package/dist/loader.d.ts +0 -51
  60. package/dist/loader.js +0 -292
  61. package/dist/loader.js.map +0 -11
  62. package/dist/plugin.d.ts +0 -39
  63. package/dist/plugin.js +0 -685
  64. package/dist/plugin.js.map +0 -12
  65. package/dist/remote/server.d.ts +0 -188
  66. package/dist/remote/server.js +0 -2270
  67. package/dist/remote/server.js.map +0 -19
  68. package/src/discovery.ts +0 -527
  69. package/src/engine.browser.ts +0 -302
  70. package/src/engine.ts +0 -282
  71. package/src/loader.ts +0 -136
  72. package/src/plugin.ts +0 -220
  73. package/src/remote/server.ts +0 -879
  74. package/wasm-browser/README.md +0 -594
  75. package/wasm-browser/hypen_engine.d.ts +0 -389
  76. package/wasm-browser/hypen_engine.js +0 -1070
  77. package/wasm-browser/hypen_engine_bg.wasm +0 -0
  78. package/wasm-browser/hypen_engine_bg.wasm.d.ts +0 -37
  79. package/wasm-browser/package.json +0 -24
  80. package/wasm-node/README.md +0 -594
  81. package/wasm-node/hypen_engine.d.ts +0 -327
  82. package/wasm-node/hypen_engine.js +0 -979
  83. package/wasm-node/hypen_engine_bg.wasm +0 -0
  84. package/wasm-node/hypen_engine_bg.wasm.d.ts +0 -37
  85. package/wasm-node/package.json +0 -22
package/dist/index.js CHANGED
@@ -1,4 +1,3 @@
1
- import { createRequire } from "node:module";
2
1
  var __defProp = Object.defineProperty;
3
2
  var __returnValue = (v) => v;
4
3
  function __exportSetter(name, newValue) {
@@ -14,7 +13,353 @@ var __export = (target, all) => {
14
13
  });
15
14
  };
16
15
  var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
17
- var __require = /* @__PURE__ */ createRequire(import.meta.url);
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
+ });
23
+
24
+ // node:path
25
+ var exports_path = {};
26
+ __export(exports_path, {
27
+ sep: () => sep,
28
+ resolve: () => resolve,
29
+ relative: () => relative,
30
+ posix: () => posix,
31
+ parse: () => parse,
32
+ normalize: () => normalize,
33
+ join: () => join,
34
+ isAbsolute: () => isAbsolute,
35
+ format: () => format,
36
+ extname: () => extname,
37
+ dirname: () => dirname,
38
+ delimiter: () => delimiter,
39
+ default: () => path_default,
40
+ basename: () => basename,
41
+ _makeLong: () => _makeLong
42
+ });
43
+ function assertPath(path) {
44
+ if (typeof path !== "string")
45
+ throw TypeError("Path must be a string. Received " + JSON.stringify(path));
46
+ }
47
+ function normalizeStringPosix(path, allowAboveRoot) {
48
+ var res = "", lastSegmentLength = 0, lastSlash = -1, dots = 0, code;
49
+ for (var i = 0;i <= path.length; ++i) {
50
+ if (i < path.length)
51
+ code = path.charCodeAt(i);
52
+ else if (code === 47)
53
+ break;
54
+ else
55
+ code = 47;
56
+ if (code === 47) {
57
+ if (lastSlash === i - 1 || dots === 1)
58
+ ;
59
+ else if (lastSlash !== i - 1 && dots === 2) {
60
+ if (res.length < 2 || lastSegmentLength !== 2 || res.charCodeAt(res.length - 1) !== 46 || res.charCodeAt(res.length - 2) !== 46) {
61
+ if (res.length > 2) {
62
+ var lastSlashIndex = res.lastIndexOf("/");
63
+ if (lastSlashIndex !== res.length - 1) {
64
+ if (lastSlashIndex === -1)
65
+ res = "", lastSegmentLength = 0;
66
+ else
67
+ res = res.slice(0, lastSlashIndex), lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
68
+ lastSlash = i, dots = 0;
69
+ continue;
70
+ }
71
+ } else if (res.length === 2 || res.length === 1) {
72
+ res = "", lastSegmentLength = 0, lastSlash = i, dots = 0;
73
+ continue;
74
+ }
75
+ }
76
+ if (allowAboveRoot) {
77
+ if (res.length > 0)
78
+ res += "/..";
79
+ else
80
+ res = "..";
81
+ lastSegmentLength = 2;
82
+ }
83
+ } else {
84
+ if (res.length > 0)
85
+ res += "/" + path.slice(lastSlash + 1, i);
86
+ else
87
+ res = path.slice(lastSlash + 1, i);
88
+ lastSegmentLength = i - lastSlash - 1;
89
+ }
90
+ lastSlash = i, dots = 0;
91
+ } else if (code === 46 && dots !== -1)
92
+ ++dots;
93
+ else
94
+ dots = -1;
95
+ }
96
+ return res;
97
+ }
98
+ function _format(sep, pathObject) {
99
+ var dir = pathObject.dir || pathObject.root, base = pathObject.base || (pathObject.name || "") + (pathObject.ext || "");
100
+ if (!dir)
101
+ return base;
102
+ if (dir === pathObject.root)
103
+ return dir + base;
104
+ return dir + sep + base;
105
+ }
106
+ function resolve() {
107
+ var resolvedPath = "", resolvedAbsolute = false, cwd;
108
+ for (var i = arguments.length - 1;i >= -1 && !resolvedAbsolute; i--) {
109
+ var path;
110
+ if (i >= 0)
111
+ path = arguments[i];
112
+ else {
113
+ if (cwd === undefined)
114
+ cwd = process.cwd();
115
+ path = cwd;
116
+ }
117
+ if (assertPath(path), path.length === 0)
118
+ continue;
119
+ resolvedPath = path + "/" + resolvedPath, resolvedAbsolute = path.charCodeAt(0) === 47;
120
+ }
121
+ if (resolvedPath = normalizeStringPosix(resolvedPath, !resolvedAbsolute), resolvedAbsolute)
122
+ if (resolvedPath.length > 0)
123
+ return "/" + resolvedPath;
124
+ else
125
+ return "/";
126
+ else if (resolvedPath.length > 0)
127
+ return resolvedPath;
128
+ else
129
+ return ".";
130
+ }
131
+ function normalize(path) {
132
+ if (assertPath(path), path.length === 0)
133
+ return ".";
134
+ var isAbsolute = path.charCodeAt(0) === 47, trailingSeparator = path.charCodeAt(path.length - 1) === 47;
135
+ if (path = normalizeStringPosix(path, !isAbsolute), path.length === 0 && !isAbsolute)
136
+ path = ".";
137
+ if (path.length > 0 && trailingSeparator)
138
+ path += "/";
139
+ if (isAbsolute)
140
+ return "/" + path;
141
+ return path;
142
+ }
143
+ function isAbsolute(path) {
144
+ return assertPath(path), path.length > 0 && path.charCodeAt(0) === 47;
145
+ }
146
+ function join() {
147
+ if (arguments.length === 0)
148
+ return ".";
149
+ var joined;
150
+ for (var i = 0;i < arguments.length; ++i) {
151
+ var arg = arguments[i];
152
+ if (assertPath(arg), arg.length > 0)
153
+ if (joined === undefined)
154
+ joined = arg;
155
+ else
156
+ joined += "/" + arg;
157
+ }
158
+ if (joined === undefined)
159
+ return ".";
160
+ return normalize(joined);
161
+ }
162
+ function relative(from, to) {
163
+ if (assertPath(from), assertPath(to), from === to)
164
+ return "";
165
+ if (from = resolve(from), to = resolve(to), from === to)
166
+ return "";
167
+ var fromStart = 1;
168
+ for (;fromStart < from.length; ++fromStart)
169
+ if (from.charCodeAt(fromStart) !== 47)
170
+ break;
171
+ var fromEnd = from.length, fromLen = fromEnd - fromStart, toStart = 1;
172
+ for (;toStart < to.length; ++toStart)
173
+ if (to.charCodeAt(toStart) !== 47)
174
+ break;
175
+ var toEnd = to.length, toLen = toEnd - toStart, length = fromLen < toLen ? fromLen : toLen, lastCommonSep = -1, i = 0;
176
+ for (;i <= length; ++i) {
177
+ if (i === length) {
178
+ if (toLen > length) {
179
+ if (to.charCodeAt(toStart + i) === 47)
180
+ return to.slice(toStart + i + 1);
181
+ else if (i === 0)
182
+ return to.slice(toStart + i);
183
+ } else if (fromLen > length) {
184
+ if (from.charCodeAt(fromStart + i) === 47)
185
+ lastCommonSep = i;
186
+ else if (i === 0)
187
+ lastCommonSep = 0;
188
+ }
189
+ break;
190
+ }
191
+ var fromCode = from.charCodeAt(fromStart + i), toCode = to.charCodeAt(toStart + i);
192
+ if (fromCode !== toCode)
193
+ break;
194
+ else if (fromCode === 47)
195
+ lastCommonSep = i;
196
+ }
197
+ var out = "";
198
+ for (i = fromStart + lastCommonSep + 1;i <= fromEnd; ++i)
199
+ if (i === fromEnd || from.charCodeAt(i) === 47)
200
+ if (out.length === 0)
201
+ out += "..";
202
+ else
203
+ out += "/..";
204
+ if (out.length > 0)
205
+ return out + to.slice(toStart + lastCommonSep);
206
+ else {
207
+ if (toStart += lastCommonSep, to.charCodeAt(toStart) === 47)
208
+ ++toStart;
209
+ return to.slice(toStart);
210
+ }
211
+ }
212
+ function _makeLong(path) {
213
+ return path;
214
+ }
215
+ function dirname(path) {
216
+ if (assertPath(path), path.length === 0)
217
+ return ".";
218
+ var code = path.charCodeAt(0), hasRoot = code === 47, end = -1, matchedSlash = true;
219
+ for (var i = path.length - 1;i >= 1; --i)
220
+ if (code = path.charCodeAt(i), code === 47) {
221
+ if (!matchedSlash) {
222
+ end = i;
223
+ break;
224
+ }
225
+ } else
226
+ matchedSlash = false;
227
+ if (end === -1)
228
+ return hasRoot ? "/" : ".";
229
+ if (hasRoot && end === 1)
230
+ return "//";
231
+ return path.slice(0, end);
232
+ }
233
+ function basename(path, ext) {
234
+ if (ext !== undefined && typeof ext !== "string")
235
+ throw TypeError('"ext" argument must be a string');
236
+ assertPath(path);
237
+ var start = 0, end = -1, matchedSlash = true, i;
238
+ if (ext !== undefined && ext.length > 0 && ext.length <= path.length) {
239
+ if (ext.length === path.length && ext === path)
240
+ return "";
241
+ var extIdx = ext.length - 1, firstNonSlashEnd = -1;
242
+ for (i = path.length - 1;i >= 0; --i) {
243
+ var code = path.charCodeAt(i);
244
+ if (code === 47) {
245
+ if (!matchedSlash) {
246
+ start = i + 1;
247
+ break;
248
+ }
249
+ } else {
250
+ if (firstNonSlashEnd === -1)
251
+ matchedSlash = false, firstNonSlashEnd = i + 1;
252
+ if (extIdx >= 0)
253
+ if (code === ext.charCodeAt(extIdx)) {
254
+ if (--extIdx === -1)
255
+ end = i;
256
+ } else
257
+ extIdx = -1, end = firstNonSlashEnd;
258
+ }
259
+ }
260
+ if (start === end)
261
+ end = firstNonSlashEnd;
262
+ else if (end === -1)
263
+ end = path.length;
264
+ return path.slice(start, end);
265
+ } else {
266
+ for (i = path.length - 1;i >= 0; --i)
267
+ if (path.charCodeAt(i) === 47) {
268
+ if (!matchedSlash) {
269
+ start = i + 1;
270
+ break;
271
+ }
272
+ } else if (end === -1)
273
+ matchedSlash = false, end = i + 1;
274
+ if (end === -1)
275
+ return "";
276
+ return path.slice(start, end);
277
+ }
278
+ }
279
+ function extname(path) {
280
+ assertPath(path);
281
+ var startDot = -1, startPart = 0, end = -1, matchedSlash = true, preDotState = 0;
282
+ for (var i = path.length - 1;i >= 0; --i) {
283
+ var code = path.charCodeAt(i);
284
+ if (code === 47) {
285
+ if (!matchedSlash) {
286
+ startPart = i + 1;
287
+ break;
288
+ }
289
+ continue;
290
+ }
291
+ if (end === -1)
292
+ matchedSlash = false, end = i + 1;
293
+ if (code === 46) {
294
+ if (startDot === -1)
295
+ startDot = i;
296
+ else if (preDotState !== 1)
297
+ preDotState = 1;
298
+ } else if (startDot !== -1)
299
+ preDotState = -1;
300
+ }
301
+ if (startDot === -1 || end === -1 || preDotState === 0 || preDotState === 1 && startDot === end - 1 && startDot === startPart + 1)
302
+ return "";
303
+ return path.slice(startDot, end);
304
+ }
305
+ function format(pathObject) {
306
+ if (pathObject === null || typeof pathObject !== "object")
307
+ throw TypeError('The "pathObject" argument must be of type Object. Received type ' + typeof pathObject);
308
+ return _format("/", pathObject);
309
+ }
310
+ function parse(path) {
311
+ assertPath(path);
312
+ var ret = { root: "", dir: "", base: "", ext: "", name: "" };
313
+ if (path.length === 0)
314
+ return ret;
315
+ var code = path.charCodeAt(0), isAbsolute2 = code === 47, start;
316
+ if (isAbsolute2)
317
+ ret.root = "/", start = 1;
318
+ else
319
+ start = 0;
320
+ var startDot = -1, startPart = 0, end = -1, matchedSlash = true, i = path.length - 1, preDotState = 0;
321
+ for (;i >= start; --i) {
322
+ if (code = path.charCodeAt(i), code === 47) {
323
+ if (!matchedSlash) {
324
+ startPart = i + 1;
325
+ break;
326
+ }
327
+ continue;
328
+ }
329
+ if (end === -1)
330
+ matchedSlash = false, end = i + 1;
331
+ if (code === 46) {
332
+ if (startDot === -1)
333
+ startDot = i;
334
+ else if (preDotState !== 1)
335
+ preDotState = 1;
336
+ } else if (startDot !== -1)
337
+ preDotState = -1;
338
+ }
339
+ if (startDot === -1 || end === -1 || preDotState === 0 || preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
340
+ if (end !== -1)
341
+ if (startPart === 0 && isAbsolute2)
342
+ ret.base = ret.name = path.slice(1, end);
343
+ else
344
+ ret.base = ret.name = path.slice(startPart, end);
345
+ } else {
346
+ if (startPart === 0 && isAbsolute2)
347
+ ret.name = path.slice(1, startDot), ret.base = path.slice(1, end);
348
+ else
349
+ ret.name = path.slice(startPart, startDot), ret.base = path.slice(startPart, end);
350
+ ret.ext = path.slice(startDot, end);
351
+ }
352
+ if (startPart > 0)
353
+ ret.dir = path.slice(0, startPart - 1);
354
+ else if (isAbsolute2)
355
+ ret.dir = "/";
356
+ return ret;
357
+ }
358
+ var sep = "/", delimiter = ":", posix, path_default;
359
+ var init_path = __esm(() => {
360
+ posix = ((p) => (p.posix = p, p))({ resolve, normalize, isAbsolute, join, relative, _makeLong, dirname, basename, extname, format, parse, sep, delimiter, win32: null, posix: null });
361
+ path_default = posix;
362
+ });
18
363
 
19
364
  // src/result.ts
20
365
  function Ok(value) {
@@ -102,7 +447,95 @@ function all(results) {
102
447
  }
103
448
  return Ok(values);
104
449
  }
450
+
451
+ class HypenError extends Error {
452
+ code;
453
+ context;
454
+ cause;
455
+ constructor(code, message, options) {
456
+ super(message);
457
+ this.name = "HypenError";
458
+ this.code = code;
459
+ this.context = options?.context;
460
+ this.cause = options?.cause;
461
+ Object.setPrototypeOf(this, new.target.prototype);
462
+ }
463
+ }
464
+
465
+ class ActionError extends HypenError {
466
+ actionName;
467
+ constructor(actionName, cause) {
468
+ super("ACTION_ERROR", `Action handler "${actionName}" failed: ${cause instanceof Error ? cause.message : String(cause)}`, {
469
+ context: { actionName },
470
+ cause: cause instanceof Error ? cause : undefined
471
+ });
472
+ this.name = "ActionError";
473
+ this.actionName = actionName;
474
+ }
475
+ }
476
+
477
+ class ConnectionError extends HypenError {
478
+ url;
479
+ attempt;
480
+ constructor(url, cause, attempt) {
481
+ super("CONNECTION_ERROR", `Connection to "${url}" failed${attempt ? ` (attempt ${attempt})` : ""}: ${cause instanceof Error ? cause.message : String(cause)}`, {
482
+ context: { url, attempt },
483
+ cause: cause instanceof Error ? cause : undefined
484
+ });
485
+ this.name = "ConnectionError";
486
+ this.url = url;
487
+ this.attempt = attempt;
488
+ }
489
+ }
490
+
491
+ class StateError extends HypenError {
492
+ path;
493
+ constructor(message, path, cause) {
494
+ super("STATE_ERROR", message, {
495
+ context: { path },
496
+ cause: cause instanceof Error ? cause : undefined
497
+ });
498
+ this.name = "StateError";
499
+ this.path = path;
500
+ }
501
+ }
502
+
503
+ class ParseError extends HypenError {
504
+ source;
505
+ constructor(message, source, cause) {
506
+ super("PARSE_ERROR", message, {
507
+ context: { source },
508
+ cause: cause instanceof Error ? cause : undefined
509
+ });
510
+ this.name = "ParseError";
511
+ this.source = source;
512
+ }
513
+ }
514
+
515
+ class RenderError extends HypenError {
516
+ constructor(message, cause) {
517
+ super("RENDER_ERROR", message, {
518
+ cause: cause instanceof Error ? cause : undefined
519
+ });
520
+ this.name = "RenderError";
521
+ }
522
+ }
105
523
  function classifyEngineError(err) {
524
+ if (err && typeof err === "object" && "message" in err && "type" in err) {
525
+ const structured = err;
526
+ switch (structured.type) {
527
+ case "parseError":
528
+ return new ParseError(structured.message);
529
+ case "stateError":
530
+ return new StateError(structured.message);
531
+ case "renderError":
532
+ return new RenderError(structured.message);
533
+ case "actionError":
534
+ return new HypenError("ACTION_ERROR", structured.message);
535
+ default:
536
+ return new HypenError("UNKNOWN_ERROR", structured.message);
537
+ }
538
+ }
106
539
  const message = err instanceof Error ? err.message : String(err);
107
540
  if (message.startsWith("Parse error:")) {
108
541
  return new ParseError(message);
@@ -115,76 +548,6 @@ function classifyEngineError(err) {
115
548
  }
116
549
  return new RenderError(message);
117
550
  }
118
- var HypenError, ActionError, ConnectionError, StateError, ParseError, RenderError;
119
- var init_result = __esm(() => {
120
- HypenError = class HypenError extends Error {
121
- code;
122
- context;
123
- cause;
124
- constructor(code, message, options) {
125
- super(message);
126
- this.name = "HypenError";
127
- this.code = code;
128
- this.context = options?.context;
129
- this.cause = options?.cause;
130
- Object.setPrototypeOf(this, new.target.prototype);
131
- }
132
- };
133
- ActionError = class ActionError extends HypenError {
134
- actionName;
135
- constructor(actionName, cause) {
136
- super("ACTION_ERROR", `Action handler "${actionName}" failed: ${cause instanceof Error ? cause.message : String(cause)}`, {
137
- context: { actionName },
138
- cause: cause instanceof Error ? cause : undefined
139
- });
140
- this.name = "ActionError";
141
- this.actionName = actionName;
142
- }
143
- };
144
- ConnectionError = class ConnectionError extends HypenError {
145
- url;
146
- attempt;
147
- constructor(url, cause, attempt) {
148
- super("CONNECTION_ERROR", `Connection to "${url}" failed${attempt ? ` (attempt ${attempt})` : ""}: ${cause instanceof Error ? cause.message : String(cause)}`, {
149
- context: { url, attempt },
150
- cause: cause instanceof Error ? cause : undefined
151
- });
152
- this.name = "ConnectionError";
153
- this.url = url;
154
- this.attempt = attempt;
155
- }
156
- };
157
- StateError = class StateError extends HypenError {
158
- path;
159
- constructor(message, path, cause) {
160
- super("STATE_ERROR", message, {
161
- context: { path },
162
- cause: cause instanceof Error ? cause : undefined
163
- });
164
- this.name = "StateError";
165
- this.path = path;
166
- }
167
- };
168
- ParseError = class ParseError extends HypenError {
169
- source;
170
- constructor(message, source, cause) {
171
- super("PARSE_ERROR", message, {
172
- context: { source },
173
- cause: cause instanceof Error ? cause : undefined
174
- });
175
- this.name = "ParseError";
176
- this.source = source;
177
- }
178
- };
179
- RenderError = class RenderError extends HypenError {
180
- constructor(message, cause) {
181
- super("RENDER_ERROR", message, {
182
- cause: cause instanceof Error ? cause : undefined
183
- });
184
- this.name = "RenderError";
185
- }
186
- };
187
- });
188
551
 
189
552
  // src/datasource.ts
190
553
  class DataSourceManager {
@@ -240,6 +603,8 @@ class DataSourceManager {
240
603
  }
241
604
 
242
605
  // src/state.ts
606
+ var IS_PROXY = Symbol.for("hypen.isProxy");
607
+ var RAW_TARGET = Symbol.for("hypen.rawTarget");
243
608
  function deepClone(obj) {
244
609
  if (obj === null || typeof obj !== "object") {
245
610
  return obj;
@@ -484,19 +849,33 @@ function unwrapProxy(value) {
484
849
  }
485
850
  return value;
486
851
  }
487
- var IS_PROXY, RAW_TARGET;
488
- var init_state = __esm(() => {
489
- IS_PROXY = Symbol.for("hypen.isProxy");
490
- RAW_TARGET = Symbol.for("hypen.rawTarget");
491
- });
492
852
 
493
853
  // src/logger.ts
854
+ var LOG_LEVEL_ORDER = {
855
+ debug: 0,
856
+ info: 1,
857
+ warn: 2,
858
+ error: 3,
859
+ none: 4
860
+ };
861
+ var LOG_LEVEL_COLORS = {
862
+ debug: "\x1B[36m",
863
+ info: "\x1B[32m",
864
+ warn: "\x1B[33m",
865
+ error: "\x1B[31m"
866
+ };
867
+ var RESET_COLOR = "\x1B[0m";
494
868
  function isProduction() {
495
869
  if (typeof process !== "undefined" && process.env) {
496
870
  return false;
497
871
  }
498
872
  return false;
499
873
  }
874
+ var config = {
875
+ level: isProduction() ? "error" : "info",
876
+ colors: true,
877
+ timestamps: false
878
+ };
500
879
  function setLogLevel(level) {
501
880
  config.level = level;
502
881
  }
@@ -627,76 +1006,49 @@ class Logger {
627
1006
  function createLogger(tag) {
628
1007
  return new Logger(tag);
629
1008
  }
630
- var LOG_LEVEL_ORDER, LOG_LEVEL_COLORS, RESET_COLOR = "\x1B[0m", config, logger, log, frameworkLoggers;
631
- var init_logger = __esm(() => {
632
- LOG_LEVEL_ORDER = {
633
- debug: 0,
634
- info: 1,
635
- warn: 2,
636
- error: 3,
637
- none: 4
638
- };
639
- LOG_LEVEL_COLORS = {
640
- debug: "\x1B[36m",
641
- info: "\x1B[32m",
642
- warn: "\x1B[33m",
643
- error: "\x1B[31m"
644
- };
645
- config = {
646
- level: isProduction() ? "error" : "info",
647
- colors: true,
648
- timestamps: false
649
- };
650
- logger = createLogger("Hypen");
651
- log = {
652
- debug: (tag, ...args) => {
653
- if (!shouldLog("debug"))
654
- return;
655
- console.log(formatTag(tag, "debug"), ...args);
656
- },
657
- info: (tag, ...args) => {
658
- if (!shouldLog("info"))
659
- return;
660
- console.info(formatTag(tag, "info"), ...args);
661
- },
662
- warn: (tag, ...args) => {
663
- if (!shouldLog("warn"))
664
- return;
665
- console.warn(formatTag(tag, "warn"), ...args);
666
- },
667
- error: (tag, ...args) => {
668
- if (!shouldLog("error"))
669
- return;
670
- console.error(formatTag(tag, "error"), ...args);
671
- }
672
- };
673
- frameworkLoggers = {
674
- hypen: createLogger("Hypen"),
675
- engine: createLogger("Engine"),
676
- router: createLogger("Router"),
677
- state: createLogger("State"),
678
- events: createLogger("Events"),
679
- remote: createLogger("Remote"),
680
- renderer: createLogger("Renderer"),
681
- module: createLogger("Module"),
682
- lifecycle: createLogger("Lifecycle"),
683
- loader: createLogger("Loader"),
684
- context: createLogger("Context"),
685
- discovery: createLogger("Discovery"),
686
- plugin: createLogger("Plugin"),
687
- canvas: createLogger("Canvas"),
688
- debug: createLogger("Debug")
689
- };
690
- });
1009
+ var logger = createLogger("Hypen");
1010
+ var log = {
1011
+ debug: (tag, ...args) => {
1012
+ if (!shouldLog("debug"))
1013
+ return;
1014
+ console.log(formatTag(tag, "debug"), ...args);
1015
+ },
1016
+ info: (tag, ...args) => {
1017
+ if (!shouldLog("info"))
1018
+ return;
1019
+ console.info(formatTag(tag, "info"), ...args);
1020
+ },
1021
+ warn: (tag, ...args) => {
1022
+ if (!shouldLog("warn"))
1023
+ return;
1024
+ console.warn(formatTag(tag, "warn"), ...args);
1025
+ },
1026
+ error: (tag, ...args) => {
1027
+ if (!shouldLog("error"))
1028
+ return;
1029
+ console.error(formatTag(tag, "error"), ...args);
1030
+ }
1031
+ };
1032
+ var frameworkLoggers = {
1033
+ hypen: createLogger("Hypen"),
1034
+ engine: createLogger("Engine"),
1035
+ router: createLogger("Router"),
1036
+ state: createLogger("State"),
1037
+ events: createLogger("Events"),
1038
+ remote: createLogger("Remote"),
1039
+ renderer: createLogger("Renderer"),
1040
+ module: createLogger("Module"),
1041
+ lifecycle: createLogger("Lifecycle"),
1042
+ loader: createLogger("Loader"),
1043
+ context: createLogger("Context"),
1044
+ discovery: createLogger("Discovery"),
1045
+ plugin: createLogger("Plugin"),
1046
+ canvas: createLogger("Canvas"),
1047
+ debug: createLogger("Debug")
1048
+ };
691
1049
 
692
1050
  // src/app.ts
693
- var exports_app = {};
694
- __export(exports_app, {
695
- app: () => app,
696
- HypenModuleInstance: () => HypenModuleInstance,
697
- HypenAppBuilder: () => HypenAppBuilder,
698
- HypenApp: () => HypenApp
699
- });
1051
+ var log2 = createLogger("ModuleInstance");
700
1052
 
701
1053
  class HypenAppBuilder {
702
1054
  initialState;
@@ -753,7 +1105,7 @@ class HypenAppBuilder {
753
1105
  return this.build();
754
1106
  }
755
1107
  uiFile(path) {
756
- const fs = __require("fs");
1108
+ const fs = (() => ({}));
757
1109
  this.template = fs.readFileSync(path, "utf-8").trim();
758
1110
  return this.build();
759
1111
  }
@@ -820,6 +1172,7 @@ class HypenApp {
820
1172
  this._registry.clear();
821
1173
  }
822
1174
  }
1175
+ var app = new HypenApp;
823
1176
 
824
1177
  class HypenModuleInstance {
825
1178
  engine;
@@ -1023,17 +1376,6 @@ class HypenModuleInstance {
1023
1376
  Object.assign(this.state, patch);
1024
1377
  }
1025
1378
  }
1026
- var log2, app;
1027
- var init_app = __esm(() => {
1028
- init_result();
1029
- init_state();
1030
- init_logger();
1031
- log2 = createLogger("ModuleInstance");
1032
- app = new HypenApp;
1033
- });
1034
-
1035
- // src/index.ts
1036
- init_app();
1037
1379
 
1038
1380
  // src/hypen.ts
1039
1381
  function createBindingProxy(root) {
@@ -1083,11 +1425,7 @@ function hypen(strings, ...expressions) {
1083
1425
  return result.trim();
1084
1426
  }
1085
1427
 
1086
- // src/index.ts
1087
- init_state();
1088
-
1089
1428
  // src/renderer.ts
1090
- init_logger();
1091
1429
  var log3 = frameworkLoggers.renderer;
1092
1430
 
1093
1431
  class BaseRenderer {
@@ -1137,11 +1475,8 @@ class ConsoleRenderer {
1137
1475
  console.groupEnd();
1138
1476
  }
1139
1477
  }
1140
- // src/router.ts
1141
- init_state();
1142
1478
 
1143
1479
  // src/disposable.ts
1144
- init_logger();
1145
1480
  var log4 = frameworkLoggers.lifecycle;
1146
1481
  function isDisposable(obj) {
1147
1482
  return obj !== null && typeof obj === "object" && "dispose" in obj && typeof obj.dispose === "function";
@@ -1289,7 +1624,6 @@ function usingSync(resource, fn) {
1289
1624
  }
1290
1625
 
1291
1626
  // src/router.ts
1292
- init_logger();
1293
1627
  var log5 = frameworkLoggers.router;
1294
1628
 
1295
1629
  class HypenRouter {
@@ -1499,8 +1833,8 @@ class HypenRouter {
1499
1833
  this.dispose();
1500
1834
  }
1501
1835
  }
1836
+
1502
1837
  // src/events.ts
1503
- init_logger();
1504
1838
  var log6 = frameworkLoggers.events;
1505
1839
 
1506
1840
  class TypedEventEmitter {
@@ -1564,14 +1898,13 @@ class TypedEventEmitter {
1564
1898
  function createEventEmitter() {
1565
1899
  return new TypedEventEmitter;
1566
1900
  }
1901
+
1567
1902
  // src/context.ts
1568
- init_logger();
1569
1903
  var log7 = frameworkLoggers.context;
1570
1904
 
1571
1905
  class HypenGlobalContext {
1572
1906
  modules = new Map;
1573
1907
  typedEvents;
1574
- legacyEventBus = new Map;
1575
1908
  constructor() {
1576
1909
  this.typedEvents = new TypedEventEmitter;
1577
1910
  }
@@ -1614,66 +1947,36 @@ class HypenGlobalContext {
1614
1947
  return state2;
1615
1948
  }
1616
1949
  emit(event, payload) {
1617
- const handlers = this.legacyEventBus.get(event);
1618
- if (!handlers || handlers.size === 0) {
1950
+ if (this.typedEvents.listenerCount(event) === 0) {
1619
1951
  log7.debug(`Event "${event}" emitted but no listeners`);
1620
- } else {
1621
- log7.debug(`Emitting event: ${event}`, payload);
1622
- handlers.forEach((handler) => {
1623
- try {
1624
- handler(payload);
1625
- } catch (error) {
1626
- log7.error(`Error in event handler for "${event}":`, error);
1627
- }
1628
- });
1629
- }
1630
- if (this.typedEvents.listenerCount(event) > 0) {
1631
- this.typedEvents.emit(event, payload);
1952
+ return;
1632
1953
  }
1954
+ log7.debug(`Emitting event: ${event}`, payload);
1955
+ this.typedEvents.emit(event, payload);
1633
1956
  }
1634
1957
  on(event, handler) {
1635
- if (!this.legacyEventBus.has(event)) {
1636
- this.legacyEventBus.set(event, new Set);
1637
- }
1638
- const handlers = this.legacyEventBus.get(event);
1639
- handlers.add(handler);
1640
1958
  log7.debug(`Listening to event: ${event}`);
1641
- return () => {
1642
- handlers.delete(handler);
1643
- if (handlers.size === 0) {
1644
- this.legacyEventBus.delete(event);
1645
- }
1646
- };
1959
+ return this.typedEvents.on(event, handler);
1647
1960
  }
1648
1961
  off(event, handler) {
1649
- const handlers = this.legacyEventBus.get(event);
1650
- if (handlers) {
1651
- handlers.delete(handler);
1652
- if (handlers.size === 0) {
1653
- this.legacyEventBus.delete(event);
1654
- }
1655
- }
1962
+ this.typedEvents.off(event, handler);
1656
1963
  }
1657
1964
  clearEvent(event) {
1658
- this.legacyEventBus.delete(event);
1965
+ this.typedEvents.removeAllListeners(event);
1659
1966
  }
1660
1967
  clearAllEvents() {
1661
- this.legacyEventBus.clear();
1968
+ this.typedEvents.clearAll();
1662
1969
  }
1663
1970
  debug() {
1664
1971
  return {
1665
1972
  modules: this.getModuleIds(),
1666
- events: Array.from(this.legacyEventBus.keys()),
1667
- typedEvents: this.typedEvents.eventNames(),
1973
+ events: this.typedEvents.eventNames(),
1668
1974
  state: this.getGlobalState()
1669
1975
  };
1670
1976
  }
1671
1977
  }
1672
- // src/remote/client.ts
1673
- init_result();
1674
1978
 
1675
1979
  // src/retry.ts
1676
- init_result();
1677
1980
  var DEFAULT_OPTIONS = {
1678
1981
  maxAttempts: 3,
1679
1982
  delayMs: 1000,
@@ -1799,7 +2102,6 @@ var RetryPresets = {
1799
2102
  };
1800
2103
 
1801
2104
  // src/remote/client.ts
1802
- init_logger();
1803
2105
  var log8 = frameworkLoggers.remote;
1804
2106
 
1805
2107
  class RemoteEngine {
@@ -2065,6 +2367,7 @@ class RemoteEngine {
2065
2367
  }, this.options.reconnectInterval);
2066
2368
  }
2067
2369
  }
2370
+
2068
2371
  // src/remote/session.ts
2069
2372
  class SessionManager {
2070
2373
  activeSessions = new Map;
@@ -2188,6 +2491,7 @@ class SessionManager {
2188
2491
  this.sessionConnections.clear();
2189
2492
  }
2190
2493
  }
2494
+
2191
2495
  // src/resolver.ts
2192
2496
  class ComponentResolver {
2193
2497
  cache = new Map;
@@ -2235,9 +2539,9 @@ class ComponentResolver {
2235
2539
  return this.extractComponents(importStmt.clause, component);
2236
2540
  }
2237
2541
  async resolveLocal(path) {
2238
- const { resolve, join } = await import("path");
2542
+ const { resolve: resolve2, join: join2 } = await Promise.resolve().then(() => (init_path(), exports_path));
2239
2543
  const { readFile } = await import("fs/promises");
2240
- const basePath = resolve(this.options.baseDir, path);
2544
+ const basePath = resolve2(this.options.baseDir, path);
2241
2545
  const hypenPath = basePath.endsWith(".hypen") ? basePath : `${basePath}.hypen`;
2242
2546
  const template = await readFile(hypenPath, "utf-8");
2243
2547
  const modulePath = hypenPath.replace(/\.hypen$/, ".ts");
@@ -2308,10 +2612,38 @@ class ComponentResolver {
2308
2612
  return imports;
2309
2613
  }
2310
2614
  }
2615
+
2311
2616
  // src/components/builtin.ts
2312
- init_app();
2313
- init_logger();
2314
2617
  var log9 = frameworkLoggers.router;
2618
+ async function updateRouteVisibility(currentPath, engine, doc) {
2619
+ const targetDoc = doc ?? document;
2620
+ const routeElements = targetDoc.querySelectorAll('[data-hypen-type="route"]');
2621
+ let matchFound = false;
2622
+ for (let index2 = 0;index2 < routeElements.length; index2++) {
2623
+ const routeEl = routeElements[index2];
2624
+ const htmlEl = routeEl;
2625
+ const routePath = htmlEl.dataset.routePath || "/";
2626
+ const isMatch = routePath === currentPath;
2627
+ htmlEl.style.display = isMatch ? "flex" : "none";
2628
+ if (isMatch) {
2629
+ matchFound = true;
2630
+ const componentName = htmlEl.dataset.routeComponent;
2631
+ const isLazy = htmlEl.dataset.routeLazy === "true";
2632
+ const hasContent = htmlEl.children.length > 0;
2633
+ const shouldRender = componentName && engine && (isLazy || !hasContent);
2634
+ if (shouldRender) {
2635
+ try {
2636
+ await engine.renderLazyRoute(routePath, componentName, htmlEl);
2637
+ } catch (err) {
2638
+ log9.error(`Failed to render route ${routePath}:`, err);
2639
+ }
2640
+ }
2641
+ }
2642
+ }
2643
+ if (!matchFound) {
2644
+ log9.warn(`No route matched path: ${currentPath}. Available routes:`, Array.from(routeElements).map((el) => el.dataset.routePath));
2645
+ }
2646
+ }
2315
2647
  var Router = app.defineState({
2316
2648
  currentPath: "/",
2317
2649
  matchedRoute: null,
@@ -2327,40 +2659,13 @@ var Router = app.defineState({
2327
2659
  return;
2328
2660
  }
2329
2661
  const hypenEngine = context.__hypenEngine;
2330
- const updateRouteVisibility = async (currentPath) => {
2331
- const routeElements = document.querySelectorAll('[data-hypen-type="route"]');
2332
- let matchFound = false;
2333
- for (let index2 = 0;index2 < routeElements.length; index2++) {
2334
- const routeEl = routeElements[index2];
2335
- const htmlEl = routeEl;
2336
- const routePath = htmlEl.dataset.routePath || "/";
2337
- const isMatch = routePath === currentPath;
2338
- htmlEl.style.display = isMatch ? "flex" : "none";
2339
- if (isMatch) {
2340
- matchFound = true;
2341
- const componentName = htmlEl.dataset.routeComponent;
2342
- const isLazy = htmlEl.dataset.routeLazy === "true";
2343
- const hasContent = htmlEl.children.length > 0;
2344
- if (componentName && !hasContent && hypenEngine) {
2345
- try {
2346
- await hypenEngine.renderLazyRoute(routePath, componentName, htmlEl);
2347
- } catch (err) {
2348
- log9.error(`Failed to render route ${routePath}:`, err);
2349
- }
2350
- }
2351
- }
2352
- }
2353
- if (!matchFound) {
2354
- log9.warn(`No route matched path: ${currentPath}. Available routes:`, Array.from(routeElements).map((el) => el.dataset.routePath));
2355
- }
2356
- };
2357
2662
  setTimeout(() => {
2358
- updateRouteVisibility(state2.currentPath);
2663
+ updateRouteVisibility(state2.currentPath, hypenEngine);
2359
2664
  }, 100);
2360
2665
  router.onNavigate((routeState) => {
2361
2666
  state2.currentPath = routeState.currentPath;
2362
2667
  state2.routeParams = routeState.params;
2363
- updateRouteVisibility(routeState.currentPath);
2668
+ updateRouteVisibility(routeState.currentPath, hypenEngine);
2364
2669
  });
2365
2670
  }).build();
2366
2671
  var Route = app.defineState({}, { name: "__Route" }).build();
@@ -2385,10 +2690,6 @@ var Link = app.defineState({
2385
2690
  });
2386
2691
  }
2387
2692
  }).build();
2388
-
2389
- // src/index.ts
2390
- init_result();
2391
- init_logger();
2392
2693
  export {
2393
2694
  withRetry,
2394
2695
  usingSync,
@@ -2471,4 +2772,4 @@ export {
2471
2772
  ActionError
2472
2773
  };
2473
2774
 
2474
- //# debugId=D4B51C3A115B4AA664756E2164756E21
2775
+ //# debugId=9FB52584D73FE77364756E2164756E21