@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/result.js
CHANGED
|
@@ -1,213 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
function Ok(value) {
|
|
26
|
-
return { ok: true, value };
|
|
27
|
-
}
|
|
28
|
-
function Err(error) {
|
|
29
|
-
return { ok: false, error };
|
|
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
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
ActionError,
|
|
3
|
+
ConnectionError,
|
|
4
|
+
Err,
|
|
5
|
+
HypenError,
|
|
6
|
+
Ok,
|
|
7
|
+
ParseError,
|
|
8
|
+
RenderError,
|
|
9
|
+
StateError,
|
|
10
|
+
all,
|
|
11
|
+
classifyEngineError,
|
|
12
|
+
flatMap,
|
|
13
|
+
fromPromise,
|
|
14
|
+
fromTry,
|
|
15
|
+
isErr,
|
|
16
|
+
isOk,
|
|
17
|
+
map,
|
|
18
|
+
mapErr,
|
|
19
|
+
match,
|
|
20
|
+
unwrap,
|
|
21
|
+
unwrapOr,
|
|
22
|
+
unwrapOrElse
|
|
23
|
+
} from "./chunk-7222131a.js";
|
|
24
|
+
import"./chunk-5gtx3pza.js";
|
|
211
25
|
export {
|
|
212
26
|
unwrapOrElse,
|
|
213
27
|
unwrapOr,
|
|
@@ -232,4 +46,4 @@ export {
|
|
|
232
46
|
ActionError
|
|
233
47
|
};
|
|
234
48
|
|
|
235
|
-
//# debugId=
|
|
49
|
+
//# debugId=45F27EF9437A7CD564756E2164756E21
|
package/dist/result.js.map
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": [
|
|
3
|
+
"sources": [],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"/**\n * Result Type for Error Handling\n *\n * A lightweight Result type for explicit error handling without exceptions.\n * Provides type-safe error propagation and composition.\n */\n\n/**\n * Represents either a successful value or an error\n */\nexport type Result<T, E = Error> =\n | { readonly ok: true; readonly value: T }\n | { readonly ok: false; readonly error: E };\n\n/**\n * Create a successful Result\n */\nexport function Ok<T>(value: T): Result<T, never> {\n return { ok: true, value };\n}\n\n/**\n * Create a failed Result\n */\nexport function Err<E>(error: E): Result<never, E> {\n return { ok: false, error };\n}\n\n/**\n * Check if a Result is Ok\n */\nexport function isOk<T, E>(result: Result<T, E>): result is { ok: true; value: T } {\n return result.ok;\n}\n\n/**\n * Check if a Result is Err\n */\nexport function isErr<T, E>(result: Result<T, E>): result is { ok: false; error: E } {\n return !result.ok;\n}\n\n/**\n * Wrap a Promise in a Result, catching any thrown errors\n */\nexport async function fromPromise<T, E = Error>(\n promise: Promise<T>,\n mapError?: (e: unknown) => E\n): Promise<Result<T, E>> {\n try {\n const value = await promise;\n return Ok(value);\n } catch (e) {\n if (mapError) {\n return Err(mapError(e));\n }\n return Err(e as E);\n }\n}\n\n/**\n * Wrap a synchronous function in a Result, catching any thrown errors\n */\nexport function fromTry<T, E = Error>(\n fn: () => T,\n mapError?: (e: unknown) => E\n): Result<T, E> {\n try {\n return Ok(fn());\n } catch (e) {\n if (mapError) {\n return Err(mapError(e));\n }\n return Err(e as E);\n }\n}\n\n/**\n * Map over a successful Result value\n */\nexport function map<T, U, E>(\n result: Result<T, E>,\n fn: (value: T) => U\n): Result<U, E> {\n if (result.ok) {\n return Ok(fn(result.value));\n }\n return result;\n}\n\n/**\n * Map over a failed Result error\n */\nexport function mapErr<T, E, F>(\n result: Result<T, E>,\n fn: (error: E) => F\n): Result<T, F> {\n if (!result.ok) {\n return Err(fn(result.error));\n }\n return result;\n}\n\n/**\n * Chain Results together (flatMap)\n */\nexport function flatMap<T, U, E>(\n result: Result<T, E>,\n fn: (value: T) => Result<U, E>\n): Result<U, E> {\n if (result.ok) {\n return fn(result.value);\n }\n return result;\n}\n\n/**\n * Unwrap a Result, throwing if it's an error\n */\nexport function unwrap<T, E>(result: Result<T, E>): T {\n if (result.ok) {\n return result.value;\n }\n throw result.error;\n}\n\n/**\n * Unwrap a Result with a default value\n */\nexport function unwrapOr<T, E>(result: Result<T, E>, defaultValue: T): T {\n if (result.ok) {\n return result.value;\n }\n return defaultValue;\n}\n\n/**\n * Unwrap a Result with a lazy default value\n */\nexport function unwrapOrElse<T, E>(result: Result<T, E>, fn: (error: E) => T): T {\n if (result.ok) {\n return result.value;\n }\n return fn(result.error);\n}\n\n/**\n * Match on a Result, providing handlers for both cases\n */\nexport function match<T, E, U>(\n result: Result<T, E>,\n handlers: {\n ok: (value: T) => U;\n err: (error: E) => U;\n }\n): U {\n if (result.ok) {\n return handlers.ok(result.value);\n }\n return handlers.err(result.error);\n}\n\n/**\n * Combine multiple Results into a single Result containing an array\n * Returns the first error encountered, or Ok with all values\n */\nexport function all<T, E>(results: Result<T, E>[]): Result<T[], E> {\n const values: T[] = [];\n for (const result of results) {\n if (!result.ok) {\n return result;\n }\n values.push(result.value);\n }\n return Ok(values);\n}\n\n/**\n * Base class for typed errors with context\n */\nexport class HypenError extends Error {\n readonly code: string;\n readonly context?: Record<string, unknown>;\n override readonly cause?: Error;\n\n constructor(\n code: string,\n message: string,\n options?: { context?: Record<string, unknown>; cause?: Error }\n ) {\n super(message);\n this.name = 'HypenError';\n this.code = code;\n this.context = options?.context;\n this.cause = options?.cause;\n\n // Maintain proper prototype chain\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/**\n * Error thrown when an action handler fails\n */\nexport class ActionError extends HypenError {\n readonly actionName: string;\n\n constructor(actionName: string, cause?: unknown) {\n super(\n 'ACTION_ERROR',\n `Action handler \"${actionName}\" failed: ${cause instanceof Error ? cause.message : String(cause)}`,\n {\n context: { actionName },\n cause: cause instanceof Error ? cause : undefined,\n }\n );\n this.name = 'ActionError';\n this.actionName = actionName;\n }\n}\n\n/**\n * Error thrown when a connection fails\n */\nexport class ConnectionError extends HypenError {\n readonly url: string;\n readonly attempt?: number;\n\n constructor(url: string, cause?: unknown, attempt?: number) {\n super(\n 'CONNECTION_ERROR',\n `Connection to \"${url}\" failed${attempt ? ` (attempt ${attempt})` : ''}: ${\n cause instanceof Error ? cause.message : String(cause)\n }`,\n {\n context: { url, attempt },\n cause: cause instanceof Error ? cause : undefined,\n }\n );\n this.name = 'ConnectionError';\n this.url = url;\n this.attempt = attempt;\n }\n}\n\n/**\n * Error thrown when state operations fail\n */\nexport class StateError extends HypenError {\n readonly path?: string;\n\n constructor(message: string, path?: string, cause?: unknown) {\n super('STATE_ERROR', message, {\n context: { path },\n cause: cause instanceof Error ? cause : undefined,\n });\n this.name = 'StateError';\n this.path = path;\n }\n}\n\n/**\n * Error thrown when parsing Hypen DSL source fails\n */\nexport class ParseError extends HypenError {\n readonly source?: string;\n\n constructor(message: string, source?: string, cause?: unknown) {\n super('PARSE_ERROR', message, {\n context: { source },\n cause: cause instanceof Error ? cause : undefined,\n });\n this.name = 'ParseError';\n this.source = source;\n }\n}\n\n/**\n * Error thrown when rendering fails\n */\nexport class RenderError extends HypenError {\n constructor(message: string, cause?: unknown) {\n super('RENDER_ERROR', message, {\n cause: cause instanceof Error ? cause : undefined,\n });\n this.name = 'RenderError';\n }\n}\n\n/**\n * Classify a WASM engine error string into the appropriate HypenError subclass.\n * The engine returns JsValue error strings with known prefixes.\n */\nexport function classifyEngineError(err: unknown): HypenError {\n // Handle structured WASM errors: { type: string, message: string }\n if (err && typeof err === 'object' && 'message' in err && 'type' in err) {\n const structured = err as { type: string; message: string };\n switch (structured.type) {\n case 'parseError': return new ParseError(structured.message);\n case 'stateError': return new StateError(structured.message);\n case 'renderError': return new RenderError(structured.message);\n case 'actionError': return new HypenError('ACTION_ERROR', structured.message);\n default: return new HypenError('UNKNOWN_ERROR', structured.message);\n }\n }\n const message = err instanceof Error ? err.message : String(err);\n\n if (message.startsWith('Parse error:')) {\n return new ParseError(message);\n }\n if (message.startsWith('Invalid state:') || message.startsWith('Invalid state patch:')) {\n return new StateError(message);\n }\n if (message.startsWith('Parent node not found:')) {\n return new RenderError(message);\n }\n\n return new RenderError(message);\n}\n"
|
|
6
5
|
],
|
|
7
|
-
"mappings": "
|
|
8
|
-
"debugId": "
|
|
6
|
+
"mappings": "",
|
|
7
|
+
"debugId": "45F27EF9437A7CD564756E2164756E21",
|
|
9
8
|
"names": []
|
|
10
9
|
}
|
package/dist/retry.js
CHANGED
|
@@ -1,338 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
});
|
|
23
|
-
|
|
24
|
-
// src/result.ts
|
|
25
|
-
function Ok(value) {
|
|
26
|
-
return { ok: true, value };
|
|
27
|
-
}
|
|
28
|
-
function Err(error) {
|
|
29
|
-
return { ok: false, error };
|
|
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/retry.ts
|
|
213
|
-
var DEFAULT_OPTIONS = {
|
|
214
|
-
maxAttempts: 3,
|
|
215
|
-
delayMs: 1000,
|
|
216
|
-
backoff: "exponential",
|
|
217
|
-
maxDelayMs: 30000,
|
|
218
|
-
jitter: 0.1
|
|
219
|
-
};
|
|
220
|
-
function calculateDelay(attempt, options) {
|
|
221
|
-
let delay;
|
|
222
|
-
switch (options.backoff) {
|
|
223
|
-
case "exponential":
|
|
224
|
-
delay = options.delayMs * Math.pow(2, attempt - 1);
|
|
225
|
-
break;
|
|
226
|
-
case "linear":
|
|
227
|
-
delay = options.delayMs * attempt;
|
|
228
|
-
break;
|
|
229
|
-
case "none":
|
|
230
|
-
delay = options.delayMs;
|
|
231
|
-
break;
|
|
232
|
-
}
|
|
233
|
-
if (options.jitter > 0) {
|
|
234
|
-
const jitterRange = delay * options.jitter;
|
|
235
|
-
delay += (Math.random() * 2 - 1) * jitterRange;
|
|
236
|
-
}
|
|
237
|
-
return Math.min(delay, options.maxDelayMs);
|
|
238
|
-
}
|
|
239
|
-
function sleep(ms, signal) {
|
|
240
|
-
return new Promise((resolve, reject) => {
|
|
241
|
-
if (signal?.aborted) {
|
|
242
|
-
reject(new Error("Retry aborted"));
|
|
243
|
-
return;
|
|
244
|
-
}
|
|
245
|
-
const timeoutId = setTimeout(resolve, ms);
|
|
246
|
-
signal?.addEventListener("abort", () => {
|
|
247
|
-
clearTimeout(timeoutId);
|
|
248
|
-
reject(new Error("Retry aborted"));
|
|
249
|
-
});
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
|
-
async function retry(fn, options = {}) {
|
|
253
|
-
const opts = { ...DEFAULT_OPTIONS, ...options };
|
|
254
|
-
let lastError = new Error("No attempts made");
|
|
255
|
-
for (let attempt = 1;attempt <= opts.maxAttempts; attempt++) {
|
|
256
|
-
try {
|
|
257
|
-
if (opts.signal?.aborted) {
|
|
258
|
-
throw new Error("Retry aborted");
|
|
259
|
-
}
|
|
260
|
-
return await fn();
|
|
261
|
-
} catch (e) {
|
|
262
|
-
lastError = e instanceof Error ? e : new Error(String(e));
|
|
263
|
-
if (opts.shouldRetry && !opts.shouldRetry(lastError)) {
|
|
264
|
-
throw lastError;
|
|
265
|
-
}
|
|
266
|
-
if (attempt === opts.maxAttempts) {
|
|
267
|
-
break;
|
|
268
|
-
}
|
|
269
|
-
const delayMs = calculateDelay(attempt, opts);
|
|
270
|
-
opts.onRetry?.(attempt, lastError, delayMs);
|
|
271
|
-
await sleep(delayMs, opts.signal);
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
throw lastError;
|
|
275
|
-
}
|
|
276
|
-
async function retryResult(fn, options = {}) {
|
|
277
|
-
try {
|
|
278
|
-
const value = await retry(fn, options);
|
|
279
|
-
return Ok(value);
|
|
280
|
-
} catch (e) {
|
|
281
|
-
return Err(e instanceof Error ? e : new Error(String(e)));
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
function withRetry(fn, options = {}) {
|
|
285
|
-
return (...args) => retry(() => fn(...args), options);
|
|
286
|
-
}
|
|
287
|
-
var RetryConditions = {
|
|
288
|
-
networkErrors: (error) => {
|
|
289
|
-
const message = error.message.toLowerCase();
|
|
290
|
-
return message.includes("network") || message.includes("fetch") || message.includes("timeout") || message.includes("econnrefused") || message.includes("econnreset") || message.includes("socket");
|
|
291
|
-
},
|
|
292
|
-
httpRetryable: (error) => {
|
|
293
|
-
const status = error.status;
|
|
294
|
-
if (!status)
|
|
295
|
-
return false;
|
|
296
|
-
return [408, 429, 500, 502, 503, 504].includes(status);
|
|
297
|
-
},
|
|
298
|
-
websocketErrors: (error) => {
|
|
299
|
-
const message = error.message.toLowerCase();
|
|
300
|
-
return message.includes("websocket") || message.includes("connection") || message.includes("close");
|
|
301
|
-
},
|
|
302
|
-
any: (...conditions) => (error) => conditions.some((c) => c(error)),
|
|
303
|
-
all: (...conditions) => (error) => conditions.every((c) => c(error))
|
|
304
|
-
};
|
|
305
|
-
var RetryPresets = {
|
|
306
|
-
aggressive: {
|
|
307
|
-
maxAttempts: 10,
|
|
308
|
-
delayMs: 500,
|
|
309
|
-
backoff: "exponential",
|
|
310
|
-
maxDelayMs: 60000,
|
|
311
|
-
jitter: 0.2
|
|
312
|
-
},
|
|
313
|
-
conservative: {
|
|
314
|
-
maxAttempts: 3,
|
|
315
|
-
delayMs: 2000,
|
|
316
|
-
backoff: "linear",
|
|
317
|
-
maxDelayMs: 1e4,
|
|
318
|
-
jitter: 0.1
|
|
319
|
-
},
|
|
320
|
-
fast: {
|
|
321
|
-
maxAttempts: 5,
|
|
322
|
-
delayMs: 100,
|
|
323
|
-
backoff: "exponential",
|
|
324
|
-
maxDelayMs: 2000,
|
|
325
|
-
jitter: 0
|
|
326
|
-
},
|
|
327
|
-
websocket: {
|
|
328
|
-
maxAttempts: 10,
|
|
329
|
-
delayMs: 1000,
|
|
330
|
-
backoff: "exponential",
|
|
331
|
-
maxDelayMs: 30000,
|
|
332
|
-
jitter: 0.1,
|
|
333
|
-
shouldRetry: RetryConditions.websocketErrors
|
|
334
|
-
}
|
|
335
|
-
};
|
|
1
|
+
import {
|
|
2
|
+
RetryConditions,
|
|
3
|
+
RetryPresets,
|
|
4
|
+
retry,
|
|
5
|
+
retryResult,
|
|
6
|
+
withRetry
|
|
7
|
+
} from "./chunk-g2gz9pgg.js";
|
|
8
|
+
import"./chunk-7222131a.js";
|
|
9
|
+
import"./chunk-5gtx3pza.js";
|
|
336
10
|
export {
|
|
337
11
|
withRetry,
|
|
338
12
|
retryResult,
|
|
@@ -341,4 +15,4 @@ export {
|
|
|
341
15
|
RetryConditions
|
|
342
16
|
};
|
|
343
17
|
|
|
344
|
-
//# debugId=
|
|
18
|
+
//# debugId=271C330395943DFE64756E2164756E21
|