likec4 1.48.0 → 1.50.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/README.md +11 -1
  2. package/__app__/src/likec4.js +5941 -4496
  3. package/__app__/src/routes/index.js +3 -153
  4. package/__app__/src/routes/projects.js +21 -1087
  5. package/__app__/src/routes/single.js +1228 -16
  6. package/__app__/src/style.css +1 -1
  7. package/__app__/src/vendors.js +4649 -1897
  8. package/__app__/src/webcomponent.js +1 -1
  9. package/config/schema.json +169 -141
  10. package/dist/THIRD-PARTY-LICENSES.md +1769 -0
  11. package/dist/_chunks/LikeC4.mjs +1154 -202
  12. package/dist/_chunks/binary.mjs +72 -0
  13. package/dist/_chunks/index.d.mts +234 -140
  14. package/dist/_chunks/index2.d.mts +2043 -1828
  15. package/dist/_chunks/libs/@chevrotain/cst-dts-gen.mjs +30 -0
  16. package/dist/_chunks/libs/@chevrotain/regexp-to-ast.mjs +9 -785
  17. package/dist/_chunks/libs/@chevrotain/utils.mjs +1 -37
  18. package/dist/_chunks/libs/@hono/mcp.mjs +34 -0
  19. package/dist/_chunks/libs/@hono/node-server.mjs +1 -436
  20. package/dist/_chunks/libs/@logtape/logtape.d.mts +741 -0
  21. package/dist/_chunks/libs/@logtape/logtape.mjs +6 -1354
  22. package/dist/_chunks/libs/@lume/kiwi.mjs +1 -1355
  23. package/dist/_chunks/libs/@modelcontextprotocol/sdk.d.mts +114 -14
  24. package/dist/_chunks/libs/@modelcontextprotocol/sdk.mjs +12 -25105
  25. package/dist/_chunks/libs/@msgpack/msgpack.mjs +1 -1503
  26. package/dist/_chunks/libs/@nanostores/react.d.mts +61 -1
  27. package/dist/_chunks/libs/@nanostores/react.mjs +1 -30
  28. package/dist/_chunks/libs/@smithy/is-array-buffer.mjs +1 -10
  29. package/dist/_chunks/libs/@smithy/util-base64.mjs +1 -100
  30. package/dist/_chunks/libs/ajv.mjs +1 -777
  31. package/dist/_chunks/libs/atomically.mjs +1 -362
  32. package/dist/_chunks/libs/birpc.mjs +1 -201
  33. package/dist/_chunks/libs/chevrotain-allstar.mjs +2 -850
  34. package/dist/_chunks/libs/chevrotain.mjs +55 -6229
  35. package/dist/_chunks/libs/conf.mjs +1 -2258
  36. package/dist/_chunks/libs/defu.mjs +1 -42
  37. package/dist/_chunks/libs/esm-env.mjs +1 -5
  38. package/dist/_chunks/libs/eventemitter3.mjs +1 -243
  39. package/dist/_chunks/libs/fast-equals.mjs +1 -446
  40. package/dist/_chunks/libs/find-up-simple.mjs +1 -24
  41. package/dist/_chunks/libs/get-port.mjs +1 -107
  42. package/dist/_chunks/libs/is-docker.mjs +1 -26
  43. package/dist/_chunks/libs/is-error-instance.mjs +1 -26
  44. package/dist/_chunks/libs/is-inside-container.mjs +1 -20
  45. package/dist/_chunks/libs/is-plain-obj.mjs +1 -9
  46. package/dist/_chunks/libs/isexe.mjs +1 -127
  47. package/dist/_chunks/libs/json5.mjs +14 -959
  48. package/dist/_chunks/libs/khroma.mjs +1 -605
  49. package/dist/_chunks/libs/ky.mjs +2 -807
  50. package/dist/_chunks/libs/langium.d.mts +2913 -2876
  51. package/dist/_chunks/libs/langium.mjs +33 -20351
  52. package/dist/_chunks/libs/merge-error-cause.mjs +2 -746
  53. package/dist/_chunks/libs/p-limit.mjs +1 -120
  54. package/dist/_chunks/libs/p-queue.mjs +1 -449
  55. package/dist/_chunks/libs/package-manager-detector.mjs +1 -559
  56. package/dist/_chunks/libs/package-up.mjs +1 -10
  57. package/dist/_chunks/libs/pako.mjs +1 -0
  58. package/dist/_chunks/libs/parse-ms.mjs +1 -36
  59. package/dist/_chunks/libs/pathe.mjs +1 -0
  60. package/dist/_chunks/libs/picomatch.mjs +1 -1673
  61. package/dist/_chunks/libs/pretty-ms.mjs +1 -80
  62. package/dist/_chunks/libs/remeda.mjs +2 -690
  63. package/dist/_chunks/libs/safe-stringify.mjs +1 -21
  64. package/dist/_chunks/libs/strip-indent.mjs +1 -15
  65. package/dist/_chunks/libs/tinyrainbow.mjs +1 -88
  66. package/dist/_chunks/libs/ts-graphviz.mjs +4 -725
  67. package/dist/_chunks/libs/ufo.mjs +1 -240
  68. package/dist/_chunks/libs/which.mjs +1 -84
  69. package/dist/_chunks/libs/word-wrap.mjs +12 -43
  70. package/dist/_chunks/rolldown-runtime.mjs +1 -48
  71. package/dist/_chunks/sequence.mjs +1 -0
  72. package/dist/_chunks/src.mjs +15 -0
  73. package/dist/_chunks/src2.mjs +499 -0
  74. package/dist/cli/index.mjs +77 -1952
  75. package/dist/config/index.d.mts +2 -2
  76. package/dist/config/index.mjs +1 -6
  77. package/dist/index.d.mts +150 -7
  78. package/dist/index.mjs +1 -21
  79. package/dist/model/builder.mjs +1 -3
  80. package/dist/model/index.d.mts +57 -3
  81. package/dist/model/index.mjs +1 -5
  82. package/dist/vite-plugin/index.d.mts +7 -3
  83. package/dist/vite-plugin/index.mjs +1 -22
  84. package/dist/vite-plugin/internal.d.mts +6 -7
  85. package/dist/vite-plugin/internal.mjs +1 -68
  86. package/package.json +64 -45
  87. package/react/{index.d.ts → index.d.mts} +114 -72
  88. package/react/{index.js → index.mjs} +21320 -22041
  89. package/react/package.json +2 -5
  90. package/vite-plugin-modules.d.ts +10 -5
  91. package/dist/_chunks/LikeC4.d.mts +0 -121
  92. package/dist/_chunks/config-app.prod.d.mts +0 -18
  93. package/dist/_chunks/config-app.prod.mjs +0 -188
  94. package/dist/_chunks/config-webcomponent.prod.mjs +0 -71
  95. package/dist/_chunks/define-config.mjs +0 -409
  96. package/dist/_chunks/index3.d.mts +0 -60
  97. package/dist/_chunks/libs/@chevrotain/gast.mjs +0 -3969
  98. package/dist/_chunks/libs/hono.mjs +0 -1829
  99. package/dist/_chunks/libs/nanoid.mjs +0 -29
  100. package/dist/_chunks/libs/nanostores.d.mts +0 -63
  101. package/dist/_chunks/libs/nanostores.mjs +0 -198
  102. package/dist/_chunks/model.mjs +0 -12
  103. package/dist/_chunks/module.d.mts +0 -71
  104. package/dist/_chunks/module.mjs +0 -18657
  105. package/dist/_chunks/plugin.mjs +0 -996
  106. package/dist/_chunks/sequence-view.mjs +0 -575
  107. package/dist/_chunks/vite-build.mjs +0 -69
  108. package/dist/_chunks/vite-dev.mjs +0 -79
  109. package/dist/_chunks/vite-preview.mjs +0 -27
  110. package/dist/language/module.d.mts +0 -5
  111. package/dist/language/module.mjs +0 -20
  112. package/dist/vite/vite-build.d.mts +0 -26
  113. package/dist/vite/vite-build.mjs +0 -27
  114. package/dist/vite/vite-dev.d.mts +0 -34
  115. package/dist/vite/vite-dev.mjs +0 -29
  116. package/dist/vite/vite-preview.d.mts +0 -20
  117. package/dist/vite/vite-preview.mjs +0 -26
  118. /package/dist/_chunks/{index4.d.mts → libs/@chevrotain/types.d.mts} +0 -0
@@ -1,746 +1,2 @@
1
- import { t as main_default$7 } from "./is-error-instance.mjs";
2
- import { t as isPlainObject } from "./is-plain-obj.mjs";
3
-
4
- //#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/descriptors.js
5
- const normalizeDescriptors = (error) => {
6
- CORE_ERROR_PROPS.forEach((propName) => {
7
- normalizeDescriptor$1(error, propName);
8
- });
9
- };
10
- const CORE_ERROR_PROPS = [
11
- "name",
12
- "message",
13
- "stack",
14
- "cause",
15
- "errors"
16
- ];
17
- const normalizeDescriptor$1 = (error, propName) => {
18
- const descriptor = getDescriptor(error, propName);
19
- if (descriptor === void 0) return;
20
- if (isReadonlyGetter(descriptor)) {
21
- setErrorProperty$1(error, propName, error[propName]);
22
- return;
23
- }
24
- if (isInvalidDescriptor(descriptor)) setErrorDescriptor(error, propName, descriptor);
25
- };
26
- const getDescriptor = (value, propName) => {
27
- const descriptor = Object.getOwnPropertyDescriptor(value, propName);
28
- if (descriptor !== void 0) return descriptor;
29
- const prototype = Object.getPrototypeOf(value);
30
- return prototype === null ? void 0 : getDescriptor(prototype, propName);
31
- };
32
- const isReadonlyGetter = ({ get, set }) => get !== void 0 && set === void 0;
33
- const isInvalidDescriptor = ({ enumerable, writable }) => enumerable || !writable;
34
- const setErrorProperty$1 = (error, propName, value) => {
35
- setErrorDescriptor(error, propName, { value });
36
- };
37
- const setErrorDescriptor = (error, propName, descriptor) => {
38
- Object.defineProperty(error, propName, {
39
- ...descriptor,
40
- ..."get" in descriptor || "set" in descriptor ? {} : { writable: true },
41
- enumerable: false,
42
- configurable: true
43
- });
44
- };
45
-
46
- //#endregion
47
- //#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/aggregate.js
48
- const normalizeAggregate = (error, recurse) => {
49
- if (Array.isArray(error.errors)) setErrorProperty$1(error, "errors", error.errors.filter(isDefined).map(recurse).filter(Boolean));
50
- else if (isAggregateError(error)) setErrorProperty$1(error, "errors", []);
51
- else if (error.errors !== void 0) deleteAggregateErrors(error);
52
- };
53
- const isDefined = (error) => error !== void 0;
54
- const isAggregateError = (error) => "AggregateError" in globalThis && (error.name === "AggregateError" || error instanceof AggregateError);
55
- const deleteAggregateErrors = (error) => {
56
- delete error.errors;
57
- if (error.errors !== void 0) setErrorProperty$1(error, "errors", []);
58
- };
59
-
60
- //#endregion
61
- //#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/cause.js
62
- const normalizeCause = (error, recurse) => {
63
- if (!("cause" in error)) return;
64
- const cause = error.cause === void 0 ? error.cause : recurse(error.cause);
65
- if (cause === void 0) delete error.cause;
66
- else setErrorProperty$1(error, "cause", cause);
67
- };
68
-
69
- //#endregion
70
- //#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/create/modifiable.js
71
- const isNonModifiableError = (error) => !Object.isExtensible(error) || CORE_ERROR_PROPS.some((propName) => isNonConfigurableProp(error, propName) || isThrowingProp(error, propName));
72
- const isNonConfigurableProp = (error, propName) => {
73
- const descriptor = Object.getOwnPropertyDescriptor(error, propName);
74
- return descriptor !== void 0 && !descriptor.configurable;
75
- };
76
- const isThrowingProp = (error, propName) => {
77
- try {
78
- error[propName];
79
- return false;
80
- } catch {
81
- return true;
82
- }
83
- };
84
-
85
- //#endregion
86
- //#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/stack.js
87
- const setStack = (error) => {
88
- setErrorProperty$1(error, "stack", getStack$3(error.message, error.name));
89
- };
90
- const getStack$3 = (message = "", name = "Error") => {
91
- const { stack } = new (getErrorClass(name))(message);
92
- return typeof stack === "string" && stack !== "" ? stack : `${name}: ${message}`;
93
- };
94
- const getErrorClass = (name) => {
95
- const descriptor = {
96
- value: name,
97
- enumerable: false,
98
- writable: true,
99
- configurable: true
100
- };
101
- const StackError = Object.defineProperty(class extends Error {}, "name", descriptor);
102
- Object.defineProperty(StackError.prototype, "name", descriptor);
103
- return StackError;
104
- };
105
-
106
- //#endregion
107
- //#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/create/copy.js
108
- const copyObject = (object) => {
109
- const objectCopy = {};
110
- for (const propName of getPropsToCopy(object)) try {
111
- const value = object[propName];
112
- const { enumerable, configurable, writable = true } = getDescriptor(object, propName);
113
- Object.defineProperty(objectCopy, propName, {
114
- value,
115
- enumerable,
116
- configurable,
117
- writable
118
- });
119
- } catch {}
120
- return objectCopy;
121
- };
122
- const getPropsToCopy = (object) => {
123
- const propNames = getOwnKeys(object);
124
- for (const propName of CORE_ERROR_PROPS) if (isInheritedProp(object, propName)) propNames.push(propName);
125
- return propNames;
126
- };
127
- const getOwnKeys = (object) => {
128
- try {
129
- return Reflect.ownKeys(object);
130
- } catch {
131
- return [];
132
- }
133
- };
134
- const isInheritedProp = (object, propName) => {
135
- try {
136
- return propName in object && !Object.hasOwn(object, propName);
137
- } catch {
138
- return false;
139
- }
140
- };
141
-
142
- //#endregion
143
- //#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/create/object.js
144
- const objectifyError = (object) => {
145
- const { name, message, stack, cause, errors, ...objectA } = copyObject(object);
146
- const messageA = getMessage$1(message, objectA);
147
- const error = newError(name, messageA);
148
- if (message === messageA) assignObjectProps(error, objectA);
149
- Object.entries({
150
- name,
151
- stack,
152
- cause,
153
- errors
154
- }).forEach(([propName, propValue]) => {
155
- setNewErrorProperty(error, propName, propValue);
156
- });
157
- if (stack === void 0) setStack(error);
158
- return error;
159
- };
160
- const getMessage$1 = (message, object) => typeof message === "string" && message !== "" ? message : truncateMessage(safeJsonStringify(object));
161
- const safeJsonStringify = (object) => {
162
- try {
163
- return JSON.stringify(object);
164
- } catch {
165
- return safeStringify(object);
166
- }
167
- };
168
- const safeStringify = (object) => {
169
- try {
170
- return String(object);
171
- } catch {
172
- return "Invalid error";
173
- }
174
- };
175
- const truncateMessage = (message) => message.length < MESSAGE_MAX_SIZE ? message : `${message.slice(0, MESSAGE_MAX_SIZE)}...`;
176
- const MESSAGE_MAX_SIZE = 1e3;
177
- const newError = (name, message) => {
178
- if (name === "AggregateError" && "AggregateError" in globalThis) return new AggregateError([], message);
179
- if (name in NATIVE_ERRORS) return new NATIVE_ERRORS[name](message);
180
- return new Error(message);
181
- };
182
- const NATIVE_ERRORS = {
183
- Error,
184
- ReferenceError,
185
- TypeError,
186
- SyntaxError,
187
- RangeError,
188
- URIError,
189
- EvalError
190
- };
191
- const assignObjectProps = (error, object) => {
192
- for (const propName in object) if (!(propName in error)) error[propName] = object[propName];
193
- };
194
- const setNewErrorProperty = (error, propName, propValue) => {
195
- if (propValue !== void 0) setErrorProperty$1(error, propName, propValue);
196
- };
197
-
198
- //#endregion
199
- //#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/create/string.js
200
- const stringifyError = (value) => {
201
- try {
202
- const error = new Error(String(value));
203
- setStack(error);
204
- return error;
205
- } catch (error_) {
206
- return error_;
207
- }
208
- };
209
-
210
- //#endregion
211
- //#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/create/main.js
212
- const { toString: objectToString } = Object.prototype;
213
- const createError = (value) => {
214
- if (isErrorPlainObj(value)) return objectifyError(value);
215
- if (!main_default$7(value)) return stringifyError(value);
216
- if (isInvalidError(value)) return objectifyError(value);
217
- return value;
218
- };
219
- const isErrorPlainObj = (value) => {
220
- try {
221
- return isPlainObject(value);
222
- } catch {
223
- return false;
224
- }
225
- };
226
- const isInvalidError = (value) => isProxy(value) || isNonModifiableError(value) || hasInvalidConstructor(value);
227
- const isProxy = (value) => {
228
- try {
229
- return objectToString.call(value) === "[object Object]";
230
- } catch {
231
- return true;
232
- }
233
- };
234
- const hasInvalidConstructor = (error) => typeof error.constructor !== "function" || typeof error.constructor.name !== "string" || error.constructor.name === "" || error.constructor.prototype !== Object.getPrototypeOf(error);
235
-
236
- //#endregion
237
- //#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/main.js
238
- const normalizeException = (error, { shallow = false } = {}) => recurseException(error, [], shallow);
239
- var main_default$6 = normalizeException;
240
- const recurseException = (error, parents, shallow) => {
241
- if (parents.includes(error)) return;
242
- const recurse = shallow ? identity : (innerError) => recurseException(innerError, [...parents, error], shallow);
243
- const errorA = createError(error);
244
- normalizeProps(errorA, recurse);
245
- return errorA;
246
- };
247
- const identity = (error) => error;
248
- const normalizeProps = (error, recurse) => {
249
- normalizeName(error);
250
- normalizeMessage(error);
251
- normalizeStack(error);
252
- normalizeCause(error, recurse);
253
- normalizeAggregate(error, recurse);
254
- normalizeDescriptors(error);
255
- };
256
- const normalizeName = (error) => {
257
- if (isDefinedString$1(error.name)) return;
258
- const prototypeName = Object.getPrototypeOf(error).name;
259
- setErrorProperty$1(error, "name", isDefinedString$1(prototypeName) ? prototypeName : error.constructor.name);
260
- };
261
- const normalizeMessage = (error) => {
262
- if (!isDefinedString$1(error.message)) setErrorProperty$1(error, "message", "");
263
- };
264
- const normalizeStack = (error) => {
265
- if (!isDefinedString$1(error.stack)) setStack(error);
266
- };
267
- const isDefinedString$1 = (value) => typeof value === "string" && value !== "";
268
-
269
- //#endregion
270
- //#region ../../node_modules/.pnpm/set-error-class@3.0.1/node_modules/set-error-class/build/src/args.js
271
- const normalizeArgs$1 = (error, ErrorClass, currentName = error.name) => {
272
- validateErrorClass(ErrorClass);
273
- if (typeof currentName !== "string") throw new TypeError(`currentName must be a string: ${currentName}`);
274
- return currentName;
275
- };
276
- const validateErrorClass = (ErrorClass) => {
277
- if (!isClass(ErrorClass)) throw new TypeError(`ErrorClass must be a class: ${ErrorClass}`);
278
- if (!isErrorClass(ErrorClass.prototype)) throw new TypeError(`ErrorClass must inherit from Error: ${ErrorClass}`);
279
- if (!hasConstructor(ErrorClass)) throw new TypeError(`ErrorClass must be have a valid constructor: ${ErrorClass}`);
280
- };
281
- const isClass = (ErrorClass) => typeof ErrorClass === "function" && typeof ErrorClass.prototype === "object" && ErrorClass.prototype !== null;
282
- const isErrorClass = (prototype) => prototype !== null && (prototype.name === "Error" || isErrorClass(Object.getPrototypeOf(prototype)));
283
- const hasConstructor = (ErrorClass) => typeof ErrorClass.prototype.constructor === "function";
284
-
285
- //#endregion
286
- //#region ../../node_modules/.pnpm/set-error-class@3.0.1/node_modules/set-error-class/build/src/enum.js
287
- const setNonEnumProp$1 = (error, propName, value) => {
288
- Object.defineProperty(error, propName, {
289
- value,
290
- enumerable: false,
291
- writable: true,
292
- configurable: true
293
- });
294
- };
295
-
296
- //#endregion
297
- //#region ../../node_modules/.pnpm/set-error-class@3.0.1/node_modules/set-error-class/build/src/prototype.js
298
- const updatePrototype = (error, ErrorClass) => {
299
- if (Object.getPrototypeOf(error) === ErrorClass.prototype) return;
300
- setPrototype(error, ErrorClass);
301
- deleteOwnProperty(error, "constructor");
302
- fixName(error, ErrorClass);
303
- };
304
- const setPrototype = (error, ErrorClass) => {
305
- Object.setPrototypeOf(error, ErrorClass.prototype);
306
- };
307
- const fixName = (error, ErrorClass) => {
308
- deleteOwnProperty(error, "name");
309
- const prototypeName = getClassName(ErrorClass.prototype);
310
- if (error.name !== prototypeName) setNonEnumProp$1(error, "name", prototypeName);
311
- };
312
- const getClassName = (prototype) => getPrototypeName(prototype) ?? getConstructorName(prototype) ?? getClassName(Object.getPrototypeOf(prototype));
313
- const getPrototypeName = (prototype) => Object.hasOwn(prototype, "name") && isDefinedString(prototype.name) ? prototype.name : void 0;
314
- const getConstructorName = (prototype) => typeof prototype.constructor === "function" && isDefinedString(prototype.constructor.name) ? prototype.constructor.name : void 0;
315
- const isDefinedString = (value) => typeof value === "string" && value !== "";
316
- const deleteOwnProperty = (error, propName) => {
317
- if (Object.hasOwn(error, propName)) delete error[propName];
318
- };
319
-
320
- //#endregion
321
- //#region ../../node_modules/.pnpm/set-error-class@3.0.1/node_modules/set-error-class/build/src/stack.js
322
- const updateStack$1 = (error, currentName) => {
323
- if (!shouldUpdateStack(error, currentName)) return;
324
- setNonEnumProp$1(error, "stack", getStack$2(error, currentName));
325
- };
326
- const shouldUpdateStack = (error, currentName) => currentName !== error.name && currentName !== "" && error.stack.includes(currentName) && stackIncludesName();
327
- const stackIncludesName = () => {
328
- class StackError extends Error {}
329
- const descriptor = {
330
- value: EXAMPLE_NAME,
331
- enumerable: false,
332
- writable: true,
333
- configurable: true
334
- };
335
- Object.defineProperty(StackError, "name", descriptor);
336
- Object.defineProperty(StackError.prototype, "name", descriptor);
337
- const { stack } = new StackError("");
338
- return typeof stack === "string" && stack.includes(EXAMPLE_NAME);
339
- };
340
- const EXAMPLE_NAME = "SetErrorClassError";
341
- const getStack$2 = ({ name, stack }, currentName) => {
342
- if (stack.startsWith(`${currentName}: `)) return stack.replace(currentName, name);
343
- const [fromA, to] = getReplacers$1(currentName, name).find(([from]) => stack.includes(from));
344
- return stack.replace(fromA, to);
345
- };
346
- const getReplacers$1 = (currentName, newName) => [
347
- [`\n${currentName}: `, `\n${newName}: `],
348
- [`${currentName}: `, `${newName}: `],
349
- [`${currentName} `, `${newName} `],
350
- [currentName, newName]
351
- ];
352
-
353
- //#endregion
354
- //#region ../../node_modules/.pnpm/set-error-class@3.0.1/node_modules/set-error-class/build/src/main.js
355
- const setErrorClass = (error, ErrorClass, currentName) => {
356
- const errorA = main_default$6(error);
357
- const currentNameA = normalizeArgs$1(errorA, ErrorClass, currentName);
358
- updatePrototype(errorA, ErrorClass);
359
- updateStack$1(errorA, currentNameA);
360
- return errorA;
361
- };
362
- var main_default$5 = setErrorClass;
363
-
364
- //#endregion
365
- //#region ../../node_modules/.pnpm/redefine-property@3.0.1/node_modules/redefine-property/build/src/merge.js
366
- const mergeDescriptors = (newDescriptor, currentDescriptor) => currentDescriptor.configurable === false ? mergeNonConfig(newDescriptor, currentDescriptor) : mergeConfig(newDescriptor, currentDescriptor);
367
- const mergeNonConfig = (newDescriptor, currentDescriptor) => ({
368
- ...currentDescriptor,
369
- ...getNonConfigWritable(newDescriptor, currentDescriptor),
370
- ...getNonConfigValue(newDescriptor, currentDescriptor)
371
- });
372
- const getNonConfigWritable = (newDescriptor, currentDescriptor) => currentDescriptor.writable === true && newDescriptor.writable === false ? { writable: false } : {};
373
- const getNonConfigValue = (newDescriptor, currentDescriptor) => newDescriptor.hasValue && "value" in currentDescriptor && currentDescriptor.writable === true ? { value: newDescriptor.value } : {};
374
- const mergeConfig = (newDescriptor, currentDescriptor) => {
375
- const enumerable = mergeDescriptor(newDescriptor.enumerable, currentDescriptor.enumerable, true);
376
- const writable = mergeDescriptor(newDescriptor.writable, currentDescriptor.writable, true);
377
- const configurable = mergeDescriptor(newDescriptor.configurable, currentDescriptor.configurable, true);
378
- return {
379
- ...mergeValue(newDescriptor, currentDescriptor, writable),
380
- enumerable,
381
- configurable
382
- };
383
- };
384
- const mergeValue = (newDescriptor, currentDescriptor, writable) => {
385
- if (newDescriptor.hasValue) return {
386
- value: newDescriptor.value,
387
- writable
388
- };
389
- if (!hasGetSet(newDescriptor) && !hasGetSet(currentDescriptor)) return {
390
- value: currentDescriptor.value,
391
- writable
392
- };
393
- return {
394
- get: mergeDescriptor(newDescriptor.get, currentDescriptor.get),
395
- set: mergeDescriptor(newDescriptor.set, currentDescriptor.set)
396
- };
397
- };
398
- const hasGetSet = ({ get, set }) => get !== void 0 || set !== void 0;
399
- const mergeDescriptor = (newValue, currentValue, defaultValue) => newValue ?? currentValue ?? defaultValue;
400
-
401
- //#endregion
402
- //#region ../../node_modules/.pnpm/redefine-property@3.0.1/node_modules/redefine-property/build/src/normalize.js
403
- const normalizeInput = (input, key, newDescriptor) => {
404
- if (!isAnyObj(input)) throw new TypeError(`Argument must be an object: ${input}`);
405
- if (!isValidKey(key)) throw new TypeError(`Property key must be a string, a symbol or an integer: ${key}`);
406
- return normalizeDescriptor(newDescriptor);
407
- };
408
- const isAnyObj = (value) => typeof value === "object" && value !== null;
409
- const isValidKey = (key) => {
410
- const type = typeof key;
411
- return type === "string" || type === "symbol" || type === "number";
412
- };
413
- const normalizeDescriptor = (newDescriptor) => {
414
- if (!isPlainObject(newDescriptor)) throw new TypeError(`Descriptor must be a plain object: ${newDescriptor}`);
415
- const { enumerable, writable, configurable, value, get, set, ...unknownProps } = newDescriptor;
416
- const hasValue = "value" in newDescriptor;
417
- validateDescriptor({
418
- enumerable,
419
- writable,
420
- configurable,
421
- get,
422
- set,
423
- unknownProps,
424
- hasValue
425
- });
426
- return {
427
- enumerable,
428
- writable,
429
- configurable,
430
- value,
431
- get,
432
- set,
433
- hasValue
434
- };
435
- };
436
- const validateDescriptor = ({ enumerable, writable, configurable, get, set, unknownProps, hasValue }) => {
437
- validateGetSet(hasValue, get, "get");
438
- validateGetSet(hasValue, set, "set");
439
- validateBoolean(enumerable, "enumerable");
440
- validateBoolean(writable, "writable");
441
- validateBoolean(configurable, "configurable");
442
- validateUnknownProps(unknownProps);
443
- };
444
- const validateGetSet = (hasValue, getSet, propName) => {
445
- validateFunction(getSet, propName);
446
- if (hasValue && getSet !== void 0) throw new TypeError(`Descriptor property "value" and "${propName}" must not both be defined: ${getSet}`);
447
- };
448
- const validateFunction = (propValue, propName) => {
449
- if (propValue !== void 0 && typeof propValue !== "function") throw new TypeError(`Descriptor property "${propName}" must be a function: ${propValue}`);
450
- };
451
- const validateBoolean = (propValue, propName) => {
452
- if (propValue !== void 0 && typeof propValue !== "boolean") throw new TypeError(`Descriptor property "${propName}" must be a boolean: ${propValue}`);
453
- };
454
- const validateUnknownProps = (unknownProps) => {
455
- const [unknownProp] = Object.keys(unknownProps);
456
- if (unknownProp !== void 0) throw new TypeError(`Unknown descriptor property "${unknownProp}": ${unknownProps[unknownProp]}`);
457
- };
458
-
459
- //#endregion
460
- //#region ../../node_modules/.pnpm/redefine-property@3.0.1/node_modules/redefine-property/build/src/main.js
461
- const redefineProperty = (input, key, newDescriptor) => {
462
- setProperty(input, key, mergeDescriptors(normalizeInput(input, key, newDescriptor), getCurrentDescriptor(input, key)));
463
- return input;
464
- };
465
- var main_default$4 = redefineProperty;
466
- const getCurrentDescriptor = (input, key) => {
467
- const descriptor = Object.getOwnPropertyDescriptor(input, key);
468
- if (descriptor !== void 0) return descriptor;
469
- const prototype = Object.getPrototypeOf(input);
470
- return prototype === null ? {} : getCurrentDescriptor(prototype, key);
471
- };
472
- const setProperty = (input, key, finalDescriptor) => {
473
- try {
474
- Object.defineProperty(input, key, finalDescriptor);
475
- } catch {}
476
- };
477
-
478
- //#endregion
479
- //#region ../../node_modules/.pnpm/set-error-props@6.0.1/node_modules/set-error-props/build/src/assign.js
480
- const assignProp = (error, propName, propValue) => {
481
- if (propValue !== void 0) return setProp(error, propName, propValue);
482
- try {
483
- delete error[propName];
484
- } catch {}
485
- if (error[propName] !== void 0) return setProp(error, propName);
486
- };
487
- const setProp = (error, propName, propValue) => {
488
- main_default$4(error, propName, {
489
- value: propValue,
490
- ...getNonEnum(propName)
491
- });
492
- };
493
- const getNonEnum = (propName) => typeof propName === "string" && propName.startsWith("_") ? { enumerable: false } : {};
494
-
495
- //#endregion
496
- //#region ../../node_modules/.pnpm/set-error-props@6.0.1/node_modules/set-error-props/build/src/options.js
497
- const normalizeOptions = (error, props, opts = {}) => {
498
- validateErrorOrObject(error, "First argument");
499
- validateErrorOrObject(props, "Second argument");
500
- if (!isPlainObject(opts)) throw new TypeError(`Options must be a plain object: ${opts}`);
501
- const { soft = false } = opts;
502
- if (typeof soft !== "boolean") throw new TypeError(`Option "soft" must be a boolean: ${soft}`);
503
- return { soft };
504
- };
505
- const validateErrorOrObject = (value, prefix) => {
506
- if (value === void 0) throw new TypeError(`${prefix} is required.`);
507
- if (!isErrorOrObject(value)) throw new TypeError(`${prefix} must be a plain object or an error: ${value}`);
508
- };
509
- const isErrorOrObject = (value) => isPlainObject(value) || main_default$7(value);
510
-
511
- //#endregion
512
- //#region ../../node_modules/.pnpm/set-error-props@6.0.1/node_modules/set-error-props/build/src/skip.js
513
- const shouldSkipProp = ({ error, props, propName, soft }) => isIgnoredPropName(propName) || !isEnum.call(props, propName) || soft && error[propName] !== void 0;
514
- const isIgnoredPropName = (propName) => propName in CHECK_ERROR || IGNORED_PROPS.has(propName);
515
- const CHECK_ERROR = /* @__PURE__ */ new Error("check");
516
- const IGNORED_PROPS = new Set([
517
- "prototype",
518
- "errors",
519
- "cause"
520
- ]);
521
- const { propertyIsEnumerable: isEnum } = Object.prototype;
522
-
523
- //#endregion
524
- //#region ../../node_modules/.pnpm/set-error-props@6.0.1/node_modules/set-error-props/build/src/main.js
525
- const setErrorProps = (error, props, opts) => {
526
- const { soft } = normalizeOptions(error, props, opts);
527
- for (const propName of Reflect.ownKeys(props)) setErrorProp({
528
- error,
529
- props,
530
- propName,
531
- soft
532
- });
533
- return error;
534
- };
535
- var main_default$3 = setErrorProps;
536
- const setErrorProp = ({ error, props, propName, soft }) => {
537
- if (!shouldSkipProp({
538
- error,
539
- props,
540
- propName,
541
- soft
542
- })) assignProp(error, propName, props[propName]);
543
- };
544
-
545
- //#endregion
546
- //#region ../../node_modules/.pnpm/merge-error-cause@5.0.2/node_modules/merge-error-cause/build/src/set.js
547
- const setErrorProperty = (error, propName, value) => {
548
- Object.defineProperty(error, propName, {
549
- value,
550
- writable: true,
551
- enumerable: false,
552
- configurable: true
553
- });
554
- };
555
-
556
- //#endregion
557
- //#region ../../node_modules/.pnpm/merge-error-cause@5.0.2/node_modules/merge-error-cause/build/src/aggregate.js
558
- const mergeAggregateCauses = (parent, recurse) => {
559
- if (parent.errors === void 0) return;
560
- setErrorProperty(parent, "errors", parent.errors.map((error) => recurse(error).error).filter(Boolean));
561
- };
562
- const mergeAggregateErrors = ({ target, source, parent, child }) => {
563
- if (!hasErrors(target)) {
564
- mergeSourceErrors(target, source);
565
- return;
566
- }
567
- if (hasErrors(source)) setErrorProperty(target, "errors", [...child.errors, ...parent.errors]);
568
- };
569
- const mergeSourceErrors = (target, source) => {
570
- if (source.errors !== void 0) setErrorProperty(target, "errors", source.errors);
571
- };
572
- const hasErrors = (targetOrSource) => targetOrSource.errors !== void 0 && targetOrSource.errors.length !== 0;
573
-
574
- //#endregion
575
- //#region ../../node_modules/.pnpm/set-error-message@3.0.1/node_modules/set-error-message/build/src/args.js
576
- const normalizeArgs = (error, newMessage, currentMessage = error.message) => {
577
- if (typeof newMessage !== "string") throw new TypeError(`newMessage must be a string: ${newMessage}`);
578
- if (typeof currentMessage !== "string") throw new TypeError(`currentMessage must be a string: ${currentMessage}`);
579
- return currentMessage;
580
- };
581
-
582
- //#endregion
583
- //#region ../../node_modules/.pnpm/set-error-message@3.0.1/node_modules/set-error-message/build/src/stack.js
584
- const getStack$1 = ({ name, stack }, newMessage, currentMessage) => currentMessage !== "" && stack.includes(currentMessage) ? replaceMessage({
585
- name,
586
- stack,
587
- newMessage,
588
- currentMessage
589
- }) : insertMessage(name, stack, newMessage);
590
- const replaceMessage = ({ name, stack, newMessage, currentMessage }) => {
591
- const [fromA, to] = getReplacers(name, newMessage, currentMessage).find(([from]) => stack.includes(from));
592
- return stack.replace(fromA, to);
593
- };
594
- const getReplacers = (name, newMessage, currentMessage) => [
595
- [`${name}: ${currentMessage}`, `${name}: ${newMessage}`],
596
- [`: ${currentMessage}`, `: ${newMessage}`],
597
- [`\n${currentMessage}`, `\n${newMessage}`],
598
- [` ${currentMessage}`, ` ${newMessage}`],
599
- [currentMessage, newMessage]
600
- ];
601
- const insertMessage = (name, stack, newMessage) => {
602
- const nameAndColon = `${name}: `;
603
- const newMessageA = newMessage.trimEnd();
604
- if (stack === name || stack.startsWith(`${name}\n`)) return stack.replace(name, `${nameAndColon}${newMessageA}`);
605
- return stack.startsWith(nameAndColon) ? stack.replace(nameAndColon, `${nameAndColon}${newMessageA}\n`) : `${nameAndColon}${newMessageA}\n${stack}`;
606
- };
607
-
608
- //#endregion
609
- //#region ../../node_modules/.pnpm/set-error-message@3.0.1/node_modules/set-error-message/build/src/main.js
610
- const setErrorMessage = (error, newMessage, currentMessage) => {
611
- const errorA = main_default$6(error);
612
- const currentMessageA = normalizeArgs(errorA, newMessage, currentMessage);
613
- setNonEnumProp(errorA, "message", newMessage);
614
- updateStack(errorA, newMessage, currentMessageA);
615
- return errorA;
616
- };
617
- var main_default$2 = setErrorMessage;
618
- const updateStack = (error, newMessage, currentMessage) => {
619
- if (newMessage === currentMessage || !stackIncludesMessage()) return;
620
- setNonEnumProp(error, "stack", getStack$1(error, newMessage, currentMessage));
621
- };
622
- const stackIncludesMessage = () => {
623
- const { stack } = new Error(EXAMPLE_MESSAGE);
624
- return typeof stack === "string" && stack.includes(EXAMPLE_MESSAGE);
625
- };
626
- const EXAMPLE_MESSAGE = "set-error-message test message";
627
- const setNonEnumProp = (error, propName, value) => {
628
- Object.defineProperty(error, propName, {
629
- value,
630
- enumerable: false,
631
- writable: true,
632
- configurable: true
633
- });
634
- };
635
-
636
- //#endregion
637
- //#region ../../node_modules/.pnpm/wrap-error-message@3.0.1/node_modules/wrap-error-message/build/src/main.js
638
- const wrapErrorMessage = (error, newMessage, oldMessage) => {
639
- if (typeof newMessage !== "string") throw new TypeError(`Second argument must be a message string: ${newMessage}`);
640
- const errorA = main_default$6(error);
641
- return main_default$2(errorA, getMessage(newMessage, errorA.message), oldMessage);
642
- };
643
- var main_default$1 = wrapErrorMessage;
644
- const getMessage = (rawNewMessage, rawCurrentMessage) => {
645
- const newMessage = rawNewMessage.trim();
646
- const currentMessage = rawCurrentMessage.trim();
647
- if (newMessage === "") return currentMessage;
648
- if (currentMessage === "") return newMessage;
649
- return concatMessages(newMessage, currentMessage, rawNewMessage);
650
- };
651
- const concatMessages = (newMessage, currentMessage, rawNewMessage) => {
652
- if (!newMessage.endsWith(PREPEND_CHAR)) return `${currentMessage}\n${newMessage}`;
653
- return rawNewMessage.endsWith(PREPEND_NEWLINE_CHAR) ? `${newMessage}\n${currentMessage}` : `${newMessage} ${currentMessage}`;
654
- };
655
- const PREPEND_CHAR = ":";
656
- const PREPEND_NEWLINE_CHAR = "\n";
657
-
658
- //#endregion
659
- //#region ../../node_modules/.pnpm/merge-error-cause@5.0.2/node_modules/merge-error-cause/build/src/message.js
660
- const mergeMessage = ({ parent, child, target, stackError }) => {
661
- const parentMessage = parent.message;
662
- const stackErrorMessage = stackError.message;
663
- target.message = child.message;
664
- return main_default$1(target, parentMessage, stackErrorMessage);
665
- };
666
-
667
- //#endregion
668
- //#region ../../node_modules/.pnpm/merge-error-cause@5.0.2/node_modules/merge-error-cause/build/src/stack.js
669
- const hasStack = (error, stack) => getStack(error) === stack;
670
- const getStack = (error) => typeof error === "object" && error !== null ? error.stack : void 0;
671
- const mergeStack = ({ wrap, target, source, childHasStack }) => {
672
- if (wrap === childHasStack) return target;
673
- setErrorProperty(target, "stack", source.stack);
674
- return source;
675
- };
676
-
677
- //#endregion
678
- //#region ../../node_modules/.pnpm/merge-error-cause@5.0.2/node_modules/merge-error-cause/build/src/wrap.js
679
- const getWrap = (parent) => {
680
- const { wrap, name } = parent;
681
- if (typeof wrap !== "boolean") return name === "Error";
682
- if (Object.hasOwn(parent, "wrap")) delete parent.wrap;
683
- return wrap;
684
- };
685
-
686
- //#endregion
687
- //#region ../../node_modules/.pnpm/merge-error-cause@5.0.2/node_modules/merge-error-cause/build/src/main.js
688
- const mergeErrorCause = (error) => mergeError(error, []).error;
689
- var main_default = mergeErrorCause;
690
- const mergeError = (error, parents) => {
691
- if (parents.includes(error)) return {};
692
- const recurse = (innerError) => mergeError(innerError, [...parents, error]);
693
- const stack = getStack(error);
694
- const errorA = main_default$6(error, { shallow: true });
695
- const parentHasStack = hasStack(errorA, stack);
696
- mergeAggregateCauses(errorA, recurse);
697
- const { parent: errorB, childHasStack } = mergeCause(errorA, recurse);
698
- return {
699
- error: errorB,
700
- errorHasStack: parentHasStack || childHasStack
701
- };
702
- };
703
- const mergeCause = (parent, recurse) => {
704
- const wrap = getWrap(parent);
705
- if (parent.cause === void 0) return {
706
- parent,
707
- childHasStack: false
708
- };
709
- const { error: child, errorHasStack: childHasStack } = recurse(parent.cause);
710
- delete parent.cause;
711
- return {
712
- parent: mergeChild({
713
- parent,
714
- child,
715
- childHasStack,
716
- wrap
717
- }),
718
- childHasStack
719
- };
720
- };
721
- const mergeChild = ({ parent, child, childHasStack, wrap }) => {
722
- if (child === void 0) return parent;
723
- const [target, source] = wrap ? [child, parent] : [parent, child];
724
- const stackError = mergeStack({
725
- wrap,
726
- target,
727
- source,
728
- childHasStack
729
- });
730
- const targetB = mergeMessage({
731
- parent,
732
- child,
733
- target: main_default$5(target, target.constructor, stackError.name),
734
- stackError
735
- });
736
- mergeAggregateErrors({
737
- target: targetB,
738
- source,
739
- parent,
740
- child
741
- });
742
- return main_default$3(targetB, source, { soft: !wrap });
743
- };
744
-
745
- //#endregion
746
- export { main_default$1 as n, main_default as t };
1
+ import{t as e}from"./is-error-instance.mjs";import{t}from"./is-plain-obj.mjs";const n=e=>{r.forEach(t=>{i(e,t)})},r=[`name`,`message`,`stack`,`cause`,`errors`],i=(e,t)=>{let n=a(e,t);if(n!==void 0){if(o(n)){c(e,t,e[t]);return}s(n)&&l(e,t,n)}},a=(e,t)=>{let n=Object.getOwnPropertyDescriptor(e,t);if(n!==void 0)return n;let r=Object.getPrototypeOf(e);return r===null?void 0:a(r,t)},o=({get:e,set:t})=>e!==void 0&&t===void 0,s=({enumerable:e,writable:t})=>e||!t,c=(e,t,n)=>{l(e,t,{value:n})},l=(e,t,n)=>{Object.defineProperty(e,t,{...n,...`get`in n||`set`in n?{}:{writable:!0},enumerable:!1,configurable:!0})},ee=(e,t)=>{Array.isArray(e.errors)?c(e,`errors`,e.errors.filter(te).map(t).filter(Boolean)):ne(e)?c(e,`errors`,[]):e.errors!==void 0&&re(e)},te=e=>e!==void 0,ne=e=>`AggregateError`in globalThis&&(e.name===`AggregateError`||e instanceof AggregateError),re=e=>{delete e.errors,e.errors!==void 0&&c(e,`errors`,[])},u=(e,t)=>{if(!(`cause`in e))return;let n=e.cause===void 0?e.cause:t(e.cause);n===void 0?delete e.cause:c(e,`cause`,n)},d=e=>!Object.isExtensible(e)||r.some(t=>f(e,t)||p(e,t)),f=(e,t)=>{let n=Object.getOwnPropertyDescriptor(e,t);return n!==void 0&&!n.configurable},p=(e,t)=>{try{return e[t],!1}catch{return!0}},m=e=>{c(e,`stack`,ie(e.message,e.name))},ie=(e=``,t=`Error`)=>{let{stack:n}=new(ae(t))(e);return typeof n==`string`&&n!==``?n:`${t}: ${e}`},ae=e=>{let t={value:e,enumerable:!1,writable:!0,configurable:!0},n=Object.defineProperty(class extends Error{},`name`,t);return Object.defineProperty(n.prototype,`name`,t),n},oe=e=>{let t={};for(let n of se(e))try{let r=e[n],{enumerable:i,configurable:o,writable:s=!0}=a(e,n);Object.defineProperty(t,n,{value:r,enumerable:i,configurable:o,writable:s})}catch{}return t},se=e=>{let t=ce(e);for(let n of r)le(e,n)&&t.push(n);return t},ce=e=>{try{return Reflect.ownKeys(e)}catch{return[]}},le=(e,t)=>{try{return t in e&&!Object.hasOwn(e,t)}catch{return!1}},h=e=>{let{name:t,message:n,stack:r,cause:i,errors:a,...o}=oe(e),s=ue(n,o),c=me(t,s);return n===s&&he(c,o),Object.entries({name:t,stack:r,cause:i,errors:a}).forEach(([e,t])=>{ge(c,e,t)}),r===void 0&&m(c),c},ue=(e,t)=>typeof e==`string`&&e!==``?e:pe(de(t)),de=e=>{try{return JSON.stringify(e)}catch{return fe(e)}},fe=e=>{try{return String(e)}catch{return`Invalid error`}},pe=e=>e.length<g?e:`${e.slice(0,g)}...`,g=1e3,me=(e,t)=>e===`AggregateError`&&`AggregateError`in globalThis?AggregateError([],t):e in _?new _[e](t):Error(t),_={Error,ReferenceError,TypeError,SyntaxError,RangeError,URIError,EvalError},he=(e,t)=>{for(let n in t)n in e||(e[n]=t[n])},ge=(e,t,n)=>{n!==void 0&&c(e,t,n)},_e=e=>{try{let t=Error(String(e));return m(t),t}catch(e){return e}},{toString:ve}=Object.prototype,ye=t=>be(t)?h(t):e(t)?v(t)?h(t):t:_e(t),be=e=>{try{return t(e)}catch{return!1}},v=e=>y(e)||d(e)||b(e),y=e=>{try{return ve.call(e)===`[object Object]`}catch{return!0}},b=e=>typeof e.constructor!=`function`||typeof e.constructor.name!=`string`||e.constructor.name===``||e.constructor.prototype!==Object.getPrototypeOf(e),x=(e,{shallow:t=!1}={})=>S(e,[],t),S=(e,t,n)=>{if(t.includes(e))return;let r=n?C:r=>S(r,[...t,e],n),i=ye(e);return w(i,r),i},C=e=>e,w=(e,t)=>{T(e),E(e),D(e),u(e,t),ee(e,t),n(e)},T=e=>{if(O(e.name))return;let t=Object.getPrototypeOf(e).name;c(e,`name`,O(t)?t:e.constructor.name)},E=e=>{O(e.message)||c(e,`message`,``)},D=e=>{O(e.stack)||m(e)},O=e=>typeof e==`string`&&e!==``,k=(e,t,n=e.name)=>{if(A(t),typeof n!=`string`)throw TypeError(`currentName must be a string: ${n}`);return n},A=e=>{if(!j(e))throw TypeError(`ErrorClass must be a class: ${e}`);if(!M(e.prototype))throw TypeError(`ErrorClass must inherit from Error: ${e}`);if(!N(e))throw TypeError(`ErrorClass must be have a valid constructor: ${e}`)},j=e=>typeof e==`function`&&typeof e.prototype==`object`&&e.prototype!==null,M=e=>e!==null&&(e.name===`Error`||M(Object.getPrototypeOf(e))),N=e=>typeof e.prototype.constructor==`function`,P=(e,t,n)=>{Object.defineProperty(e,t,{value:n,enumerable:!1,writable:!0,configurable:!0})},xe=(e,t)=>{Object.getPrototypeOf(e)!==t.prototype&&(Se(e,t),L(e,`constructor`),Ce(e,t))},Se=(e,t)=>{Object.setPrototypeOf(e,t.prototype)},Ce=(e,t)=>{L(e,`name`);let n=F(t.prototype);e.name!==n&&P(e,`name`,n)},F=e=>we(e)??Te(e)??F(Object.getPrototypeOf(e)),we=e=>Object.hasOwn(e,`name`)&&I(e.name)?e.name:void 0,Te=e=>typeof e.constructor==`function`&&I(e.constructor.name)?e.constructor.name:void 0,I=e=>typeof e==`string`&&e!==``,L=(e,t)=>{Object.hasOwn(e,t)&&delete e[t]},Ee=(e,t)=>{De(e,t)&&P(e,`stack`,ke(e,t))},De=(e,t)=>t!==e.name&&t!==``&&e.stack.includes(t)&&Oe(),Oe=()=>{class e extends Error{}let t={value:R,enumerable:!1,writable:!0,configurable:!0};Object.defineProperty(e,`name`,t),Object.defineProperty(e.prototype,`name`,t);let{stack:n}=new e(``);return typeof n==`string`&&n.includes(R)},R=`SetErrorClassError`,ke=({name:e,stack:t},n)=>{if(t.startsWith(`${n}: `))return t.replace(n,e);let[r,i]=Ae(n,e).find(([e])=>t.includes(e));return t.replace(r,i)},Ae=(e,t)=>[[`\n${e}: `,`\n${t}: `],[`${e}: `,`${t}: `],[`${e} `,`${t} `],[e,t]],je=(e,t,n)=>{let r=x(e),i=k(r,t,n);return xe(r,t),Ee(r,i),r},Me=(e,t)=>t.configurable===!1?Ne(e,t):Ie(e,t),Ne=(e,t)=>({...t,...Pe(e,t),...Fe(e,t)}),Pe=(e,t)=>t.writable===!0&&e.writable===!1?{writable:!1}:{},Fe=(e,t)=>e.hasValue&&`value`in t&&t.writable===!0?{value:e.value}:{},Ie=(e,t)=>{let n=B(e.enumerable,t.enumerable,!0),r=B(e.writable,t.writable,!0),i=B(e.configurable,t.configurable,!0);return{...Le(e,t,r),enumerable:n,configurable:i}},Le=(e,t,n)=>e.hasValue?{value:e.value,writable:n}:!z(e)&&!z(t)?{value:t.value,writable:n}:{get:B(e.get,t.get),set:B(e.set,t.set)},z=({get:e,set:t})=>e!==void 0||t!==void 0,B=(e,t,n)=>e??t??n,Re=(e,t,n)=>{if(!ze(e))throw TypeError(`Argument must be an object: ${e}`);if(!Be(t))throw TypeError(`Property key must be a string, a symbol or an integer: ${t}`);return Ve(n)},ze=e=>typeof e==`object`&&!!e,Be=e=>{let t=typeof e;return t===`string`||t===`symbol`||t===`number`},Ve=e=>{if(!t(e))throw TypeError(`Descriptor must be a plain object: ${e}`);let{enumerable:n,writable:r,configurable:i,value:a,get:o,set:s,...c}=e,l=`value`in e;return He({enumerable:n,writable:r,configurable:i,get:o,set:s,unknownProps:c,hasValue:l}),{enumerable:n,writable:r,configurable:i,value:a,get:o,set:s,hasValue:l}},He=({enumerable:e,writable:t,configurable:n,get:r,set:i,unknownProps:a,hasValue:o})=>{V(o,r,`get`),V(o,i,`set`),H(e,`enumerable`),H(t,`writable`),H(n,`configurable`),We(a)},V=(e,t,n)=>{if(Ue(t,n),e&&t!==void 0)throw TypeError(`Descriptor property "value" and "${n}" must not both be defined: ${t}`)},Ue=(e,t)=>{if(e!==void 0&&typeof e!=`function`)throw TypeError(`Descriptor property "${t}" must be a function: ${e}`)},H=(e,t)=>{if(e!==void 0&&typeof e!=`boolean`)throw TypeError(`Descriptor property "${t}" must be a boolean: ${e}`)},We=e=>{let[t]=Object.keys(e);if(t!==void 0)throw TypeError(`Unknown descriptor property "${t}": ${e[t]}`)},Ge=(e,t,n)=>(Ke(e,t,Me(Re(e,t,n),U(e,t))),e),U=(e,t)=>{let n=Object.getOwnPropertyDescriptor(e,t);if(n!==void 0)return n;let r=Object.getPrototypeOf(e);return r===null?{}:U(r,t)},Ke=(e,t,n)=>{try{Object.defineProperty(e,t,n)}catch{}},qe=(e,t,n)=>{if(n!==void 0)return W(e,t,n);try{delete e[t]}catch{}if(e[t]!==void 0)return W(e,t)},W=(e,t,n)=>{Ge(e,t,{value:n,...Je(t)})},Je=e=>typeof e==`string`&&e.startsWith(`_`)?{enumerable:!1}:{},Ye=(e,n,r={})=>{if(G(e,`First argument`),G(n,`Second argument`),!t(r))throw TypeError(`Options must be a plain object: ${r}`);let{soft:i=!1}=r;if(typeof i!=`boolean`)throw TypeError(`Option "soft" must be a boolean: ${i}`);return{soft:i}},G=(e,t)=>{if(e===void 0)throw TypeError(`${t} is required.`);if(!Xe(e))throw TypeError(`${t} must be a plain object or an error: ${e}`)},Xe=n=>t(n)||e(n),Ze=({error:e,props:t,propName:n,soft:r})=>Qe(n)||!tt.call(t,n)||r&&e[n]!==void 0,Qe=e=>e in $e||et.has(e),$e=Error(`check`),et=new Set([`prototype`,`errors`,`cause`]),{propertyIsEnumerable:tt}=Object.prototype,nt=(e,t,n)=>{let{soft:r}=Ye(e,t,n);for(let n of Reflect.ownKeys(t))rt({error:e,props:t,propName:n,soft:r});return e},rt=({error:e,props:t,propName:n,soft:r})=>{Ze({error:e,props:t,propName:n,soft:r})||qe(e,n,t[n])},K=(e,t,n)=>{Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!1,configurable:!0})},it=(e,t)=>{e.errors!==void 0&&K(e,`errors`,e.errors.map(e=>t(e).error).filter(Boolean))},at=({target:e,source:t,parent:n,child:r})=>{if(!q(e)){ot(e,t);return}q(t)&&K(e,`errors`,[...r.errors,...n.errors])},ot=(e,t)=>{t.errors!==void 0&&K(e,`errors`,t.errors)},q=e=>e.errors!==void 0&&e.errors.length!==0,st=(e,t,n=e.message)=>{if(typeof t!=`string`)throw TypeError(`newMessage must be a string: ${t}`);if(typeof n!=`string`)throw TypeError(`currentMessage must be a string: ${n}`);return n},ct=({name:e,stack:t},n,r)=>r!==``&&t.includes(r)?lt({name:e,stack:t,newMessage:n,currentMessage:r}):dt(e,t,n),lt=({name:e,stack:t,newMessage:n,currentMessage:r})=>{let[i,a]=ut(e,n,r).find(([e])=>t.includes(e));return t.replace(i,a)},ut=(e,t,n)=>[[`${e}: ${n}`,`${e}: ${t}`],[`: ${n}`,`: ${t}`],[`\n${n}`,`\n${t}`],[` ${n}`,` ${t}`],[n,t]],dt=(e,t,n)=>{let r=`${e}: `,i=n.trimEnd();return t===e||t.startsWith(`${e}\n`)?t.replace(e,`${r}${i}`):t.startsWith(r)?t.replace(r,`${r}${i}\n`):`${r}${i}\n${t}`},ft=(e,t,n)=>{let r=x(e),i=st(r,t,n);return Y(r,`message`,t),pt(r,t,i),r},pt=(e,t,n)=>{t===n||!mt()||Y(e,`stack`,ct(e,t,n))},mt=()=>{let{stack:e}=Error(J);return typeof e==`string`&&e.includes(J)},J=`set-error-message test message`,Y=(e,t,n)=>{Object.defineProperty(e,t,{value:n,enumerable:!1,writable:!0,configurable:!0})},X=(e,t,n)=>{if(typeof t!=`string`)throw TypeError(`Second argument must be a message string: ${t}`);let r=x(e);return ft(r,Z(t,r.message),n)},Z=(e,t)=>{let n=e.trim(),r=t.trim();return n===``?r:r===``?n:ht(n,r,e)},ht=(e,t,n)=>e.endsWith(gt)?n.endsWith(_t)?`${e}\n${t}`:`${e} ${t}`:`${t}\n${e}`,gt=`:`,_t=`
2
+ `,vt=({parent:e,child:t,target:n,stackError:r})=>{let i=e.message,a=r.message;return n.message=t.message,X(n,i,a)},yt=(e,t)=>Q(e)===t,Q=e=>typeof e==`object`&&e?e.stack:void 0,bt=({wrap:e,target:t,source:n,childHasStack:r})=>e===r?t:(K(t,`stack`,n.stack),n),xt=e=>{let{wrap:t,name:n}=e;return typeof t==`boolean`?(Object.hasOwn(e,`wrap`)&&delete e.wrap,t):n===`Error`},St=e=>$(e,[]).error,$=(e,t)=>{if(t.includes(e))return{};let n=n=>$(n,[...t,e]),r=Q(e),i=x(e,{shallow:!0}),a=yt(i,r);it(i,n);let{parent:o,childHasStack:s}=Ct(i,n);return{error:o,errorHasStack:a||s}},Ct=(e,t)=>{let n=xt(e);if(e.cause===void 0)return{parent:e,childHasStack:!1};let{error:r,errorHasStack:i}=t(e.cause);return delete e.cause,{parent:wt({parent:e,child:r,childHasStack:i,wrap:n}),childHasStack:i}},wt=({parent:e,child:t,childHasStack:n,wrap:r})=>{if(t===void 0)return e;let[i,a]=r?[t,e]:[e,t],o=bt({wrap:r,target:i,source:a,childHasStack:n}),s=vt({parent:e,child:t,target:je(i,i.constructor,o.name),stackError:o});return at({target:s,source:a,parent:e,child:t}),nt(s,a,{soft:!r})};export{X as n,St as t};