@noma.to/qwik-mock 1.0.2 → 1.1.1

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 (53) hide show
  1. package/lib/lib/qwik-mock.cjs +24 -6
  2. package/lib/lib/qwik-mock.mjs +24 -6
  3. package/lib-types/index.d.ts +2 -1
  4. package/lib-types/lib/qwik-mock.d.ts +21 -19
  5. package/package.json +7 -6
  6. package/lib/node_modules/.pnpm/@jridgewell_sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.cjs +0 -83
  7. package/lib/node_modules/.pnpm/@jridgewell_sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs +0 -83
  8. package/lib/node_modules/.pnpm/@vitest_expect@4.0.18/node_modules/@vitest/expect/dist/index.cjs +0 -1785
  9. package/lib/node_modules/.pnpm/@vitest_expect@4.0.18/node_modules/@vitest/expect/dist/index.mjs +0 -1785
  10. package/lib/node_modules/.pnpm/@vitest_pretty-format@4.0.18/node_modules/@vitest/pretty-format/dist/index.cjs +0 -964
  11. package/lib/node_modules/.pnpm/@vitest_pretty-format@4.0.18/node_modules/@vitest/pretty-format/dist/index.mjs +0 -964
  12. package/lib/node_modules/.pnpm/@vitest_runner@4.0.18/node_modules/@vitest/runner/dist/chunk-tasks.cjs +0 -60
  13. package/lib/node_modules/.pnpm/@vitest_runner@4.0.18/node_modules/@vitest/runner/dist/chunk-tasks.mjs +0 -60
  14. package/lib/node_modules/.pnpm/@vitest_runner@4.0.18/node_modules/@vitest/runner/dist/index.cjs +0 -1102
  15. package/lib/node_modules/.pnpm/@vitest_runner@4.0.18/node_modules/@vitest/runner/dist/index.mjs +0 -1102
  16. package/lib/node_modules/.pnpm/@vitest_snapshot@4.0.18/node_modules/@vitest/snapshot/dist/index.cjs +0 -1289
  17. package/lib/node_modules/.pnpm/@vitest_snapshot@4.0.18/node_modules/@vitest/snapshot/dist/index.mjs +0 -1289
  18. package/lib/node_modules/.pnpm/@vitest_spy@4.0.18/node_modules/@vitest/spy/dist/index.cjs +0 -422
  19. package/lib/node_modules/.pnpm/@vitest_spy@4.0.18/node_modules/@vitest/spy/dist/index.mjs +0 -422
  20. package/lib/node_modules/.pnpm/@vitest_utils@4.0.18/node_modules/@vitest/utils/dist/chunk-_commonjsHelpers.cjs +0 -6
  21. package/lib/node_modules/.pnpm/@vitest_utils@4.0.18/node_modules/@vitest/utils/dist/chunk-_commonjsHelpers.mjs +0 -6
  22. package/lib/node_modules/.pnpm/@vitest_utils@4.0.18/node_modules/@vitest/utils/dist/chunk-pathe.M-eThtNZ.cjs +0 -98
  23. package/lib/node_modules/.pnpm/@vitest_utils@4.0.18/node_modules/@vitest/utils/dist/chunk-pathe.M-eThtNZ.mjs +0 -98
  24. package/lib/node_modules/.pnpm/@vitest_utils@4.0.18/node_modules/@vitest/utils/dist/diff.cjs +0 -1626
  25. package/lib/node_modules/.pnpm/@vitest_utils@4.0.18/node_modules/@vitest/utils/dist/diff.mjs +0 -1626
  26. package/lib/node_modules/.pnpm/@vitest_utils@4.0.18/node_modules/@vitest/utils/dist/display.cjs +0 -690
  27. package/lib/node_modules/.pnpm/@vitest_utils@4.0.18/node_modules/@vitest/utils/dist/display.mjs +0 -690
  28. package/lib/node_modules/.pnpm/@vitest_utils@4.0.18/node_modules/@vitest/utils/dist/error.cjs +0 -39
  29. package/lib/node_modules/.pnpm/@vitest_utils@4.0.18/node_modules/@vitest/utils/dist/error.mjs +0 -39
  30. package/lib/node_modules/.pnpm/@vitest_utils@4.0.18/node_modules/@vitest/utils/dist/helpers.cjs +0 -151
  31. package/lib/node_modules/.pnpm/@vitest_utils@4.0.18/node_modules/@vitest/utils/dist/helpers.mjs +0 -151
  32. package/lib/node_modules/.pnpm/@vitest_utils@4.0.18/node_modules/@vitest/utils/dist/serialize.cjs +0 -114
  33. package/lib/node_modules/.pnpm/@vitest_utils@4.0.18/node_modules/@vitest/utils/dist/serialize.mjs +0 -114
  34. package/lib/node_modules/.pnpm/@vitest_utils@4.0.18/node_modules/@vitest/utils/dist/source-map.cjs +0 -125
  35. package/lib/node_modules/.pnpm/@vitest_utils@4.0.18/node_modules/@vitest/utils/dist/source-map.mjs +0 -125
  36. package/lib/node_modules/.pnpm/@vitest_utils@4.0.18/node_modules/@vitest/utils/dist/timers.cjs +0 -22
  37. package/lib/node_modules/.pnpm/@vitest_utils@4.0.18/node_modules/@vitest/utils/dist/timers.mjs +0 -22
  38. package/lib/node_modules/.pnpm/chai@6.2.2/node_modules/chai/index.cjs +0 -4056
  39. package/lib/node_modules/.pnpm/chai@6.2.2/node_modules/chai/index.mjs +0 -4056
  40. package/lib/node_modules/.pnpm/magic-string@0.30.21/node_modules/magic-string/dist/magic-string.es.cjs +0 -994
  41. package/lib/node_modules/.pnpm/magic-string@0.30.21/node_modules/magic-string/dist/magic-string.es.mjs +0 -994
  42. package/lib/node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.cjs +0 -101
  43. package/lib/node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs +0 -101
  44. package/lib/node_modules/.pnpm/tinyrainbow@3.0.3/node_modules/tinyrainbow/dist/index.cjs +0 -84
  45. package/lib/node_modules/.pnpm/tinyrainbow@3.0.3/node_modules/tinyrainbow/dist/index.mjs +0 -84
  46. package/lib/node_modules/.pnpm/vitest@4.0.18_@types_node@25.1.0_@vitest_ui@4.0.18_happy-dom@20.0.11_jiti@2.4.2_jsdom@26.1.0__pd2l5poczrcnqygjcqiguyknnm/node_modules/vitest/dist/chunks/_commonjsHelpers.D26ty3Ew.cjs +0 -4
  47. package/lib/node_modules/.pnpm/vitest@4.0.18_@types_node@25.1.0_@vitest_ui@4.0.18_happy-dom@20.0.11_jiti@2.4.2_jsdom@26.1.0__pd2l5poczrcnqygjcqiguyknnm/node_modules/vitest/dist/chunks/_commonjsHelpers.D26ty3Ew.mjs +0 -4
  48. package/lib/node_modules/.pnpm/vitest@4.0.18_@types_node@25.1.0_@vitest_ui@4.0.18_happy-dom@20.0.11_jiti@2.4.2_jsdom@26.1.0__pd2l5poczrcnqygjcqiguyknnm/node_modules/vitest/dist/chunks/date.Bq6ZW5rf.cjs +0 -51
  49. package/lib/node_modules/.pnpm/vitest@4.0.18_@types_node@25.1.0_@vitest_ui@4.0.18_happy-dom@20.0.11_jiti@2.4.2_jsdom@26.1.0__pd2l5poczrcnqygjcqiguyknnm/node_modules/vitest/dist/chunks/date.Bq6ZW5rf.mjs +0 -51
  50. package/lib/node_modules/.pnpm/vitest@4.0.18_@types_node@25.1.0_@vitest_ui@4.0.18_happy-dom@20.0.11_jiti@2.4.2_jsdom@26.1.0__pd2l5poczrcnqygjcqiguyknnm/node_modules/vitest/dist/chunks/utils.DvEY5TfP.cjs +0 -45
  51. package/lib/node_modules/.pnpm/vitest@4.0.18_@types_node@25.1.0_@vitest_ui@4.0.18_happy-dom@20.0.11_jiti@2.4.2_jsdom@26.1.0__pd2l5poczrcnqygjcqiguyknnm/node_modules/vitest/dist/chunks/utils.DvEY5TfP.mjs +0 -45
  52. package/lib/node_modules/.pnpm/vitest@4.0.18_@types_node@25.1.0_@vitest_ui@4.0.18_happy-dom@20.0.11_jiti@2.4.2_jsdom@26.1.0__pd2l5poczrcnqygjcqiguyknnm/node_modules/vitest/dist/chunks/vi.2VT5v0um.cjs +0 -2609
  53. package/lib/node_modules/.pnpm/vitest@4.0.18_@types_node@25.1.0_@vitest_ui@4.0.18_happy-dom@20.0.11_jiti@2.4.2_jsdom@26.1.0__pd2l5poczrcnqygjcqiguyknnm/node_modules/vitest/dist/chunks/vi.2VT5v0um.mjs +0 -2609
@@ -1,39 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const diff = require("./diff.cjs");
4
- const display = require("./display.cjs");
5
- const serialize = require("./serialize.cjs");
6
- require("../../../../../tinyrainbow@3.0.3/node_modules/tinyrainbow/dist/index.cjs");
7
- function processError(_err, diffOptions, seen = /* @__PURE__ */ new WeakSet()) {
8
- if (!_err || typeof _err !== "object") {
9
- return { message: String(_err) };
10
- }
11
- const err = _err;
12
- if (err.showDiff || err.showDiff === void 0 && err.expected !== void 0 && err.actual !== void 0) {
13
- err.diff = diff.printDiffOrStringify(err.actual, err.expected, {
14
- ...diffOptions,
15
- ...err.diffOptions
16
- });
17
- }
18
- if ("expected" in err && typeof err.expected !== "string") {
19
- err.expected = display.stringify(err.expected, 10);
20
- }
21
- if ("actual" in err && typeof err.actual !== "string") {
22
- err.actual = display.stringify(err.actual, 10);
23
- }
24
- try {
25
- if (!seen.has(err) && typeof err.cause === "object") {
26
- seen.add(err);
27
- err.cause = processError(err.cause, diffOptions, seen);
28
- }
29
- } catch {
30
- }
31
- try {
32
- return serialize.serializeValue(err);
33
- } catch (e) {
34
- return serialize.serializeValue(new Error(`Failed to fully serialize error: ${e === null || e === void 0 ? void 0 : e.message}
35
- Inner error message: ${err === null || err === void 0 ? void 0 : err.message}`));
36
- }
37
- }
38
- exports.serializeError = serialize.serializeValue;
39
- exports.processError = processError;
@@ -1,39 +0,0 @@
1
- import { printDiffOrStringify } from "./diff.mjs";
2
- import { stringify } from "./display.mjs";
3
- import { serializeValue } from "./serialize.mjs";
4
- import "../../../../../tinyrainbow@3.0.3/node_modules/tinyrainbow/dist/index.mjs";
5
- function processError(_err, diffOptions, seen = /* @__PURE__ */ new WeakSet()) {
6
- if (!_err || typeof _err !== "object") {
7
- return { message: String(_err) };
8
- }
9
- const err = _err;
10
- if (err.showDiff || err.showDiff === void 0 && err.expected !== void 0 && err.actual !== void 0) {
11
- err.diff = printDiffOrStringify(err.actual, err.expected, {
12
- ...diffOptions,
13
- ...err.diffOptions
14
- });
15
- }
16
- if ("expected" in err && typeof err.expected !== "string") {
17
- err.expected = stringify(err.expected, 10);
18
- }
19
- if ("actual" in err && typeof err.actual !== "string") {
20
- err.actual = stringify(err.actual, 10);
21
- }
22
- try {
23
- if (!seen.has(err) && typeof err.cause === "object") {
24
- seen.add(err);
25
- err.cause = processError(err.cause, diffOptions, seen);
26
- }
27
- } catch {
28
- }
29
- try {
30
- return serializeValue(err);
31
- } catch (e) {
32
- return serializeValue(new Error(`Failed to fully serialize error: ${e === null || e === void 0 ? void 0 : e.message}
33
- Inner error message: ${err === null || err === void 0 ? void 0 : err.message}`));
34
- }
35
- }
36
- export {
37
- processError,
38
- serializeValue as serializeError
39
- };
@@ -1,151 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- function createSimpleStackTrace(options) {
4
- const { message = "$$stack trace error", stackTraceLimit = 1 } = options || {};
5
- const limit = Error.stackTraceLimit;
6
- const prepareStackTrace = Error.prepareStackTrace;
7
- Error.stackTraceLimit = stackTraceLimit;
8
- Error.prepareStackTrace = (e) => e.stack;
9
- const err = new Error(message);
10
- const stackTrace = err.stack || "";
11
- Error.prepareStackTrace = prepareStackTrace;
12
- Error.stackTraceLimit = limit;
13
- return stackTrace;
14
- }
15
- function assertTypes(value, name, types) {
16
- const receivedType = typeof value;
17
- const pass = types.includes(receivedType);
18
- if (!pass) {
19
- throw new TypeError(`${name} value must be ${types.join(" or ")}, received "${receivedType}"`);
20
- }
21
- }
22
- function toArray(array) {
23
- if (array === null || array === void 0) {
24
- array = [];
25
- }
26
- if (Array.isArray(array)) {
27
- return array;
28
- }
29
- return [array];
30
- }
31
- function isObject(item) {
32
- return item != null && typeof item === "object" && !Array.isArray(item);
33
- }
34
- function isFinalObj(obj) {
35
- return obj === Object.prototype || obj === Function.prototype || obj === RegExp.prototype;
36
- }
37
- function getType(value) {
38
- return Object.prototype.toString.apply(value).slice(8, -1);
39
- }
40
- function collectOwnProperties(obj, collector) {
41
- const collect = typeof collector === "function" ? collector : (key) => collector.add(key);
42
- Object.getOwnPropertyNames(obj).forEach(collect);
43
- Object.getOwnPropertySymbols(obj).forEach(collect);
44
- }
45
- function getOwnProperties(obj) {
46
- const ownProps = /* @__PURE__ */ new Set();
47
- if (isFinalObj(obj)) {
48
- return [];
49
- }
50
- collectOwnProperties(obj, ownProps);
51
- return Array.from(ownProps);
52
- }
53
- const defaultCloneOptions = { forceWritable: false };
54
- function deepClone(val, options = defaultCloneOptions) {
55
- const seen = /* @__PURE__ */ new WeakMap();
56
- return clone(val, seen, options);
57
- }
58
- function clone(val, seen, options = defaultCloneOptions) {
59
- let k, out;
60
- if (seen.has(val)) {
61
- return seen.get(val);
62
- }
63
- if (Array.isArray(val)) {
64
- out = Array.from({ length: k = val.length });
65
- seen.set(val, out);
66
- while (k--) {
67
- out[k] = clone(val[k], seen, options);
68
- }
69
- return out;
70
- }
71
- if (Object.prototype.toString.call(val) === "[object Object]") {
72
- out = Object.create(Object.getPrototypeOf(val));
73
- seen.set(val, out);
74
- const props = getOwnProperties(val);
75
- for (const k2 of props) {
76
- const descriptor = Object.getOwnPropertyDescriptor(val, k2);
77
- if (!descriptor) {
78
- continue;
79
- }
80
- const cloned = clone(val[k2], seen, options);
81
- if (options.forceWritable) {
82
- Object.defineProperty(out, k2, {
83
- enumerable: descriptor.enumerable,
84
- configurable: true,
85
- writable: true,
86
- value: cloned
87
- });
88
- } else if ("get" in descriptor) {
89
- Object.defineProperty(out, k2, {
90
- ...descriptor,
91
- get() {
92
- return cloned;
93
- }
94
- });
95
- } else {
96
- Object.defineProperty(out, k2, {
97
- ...descriptor,
98
- value: cloned
99
- });
100
- }
101
- }
102
- return out;
103
- }
104
- return val;
105
- }
106
- function noop() {
107
- }
108
- function objectAttr(source, path, defaultValue = void 0) {
109
- const paths = path.replace(/\[(\d+)\]/g, ".$1").split(".");
110
- let result = source;
111
- for (const p of paths) {
112
- result = new Object(result)[p];
113
- if (result === void 0) {
114
- return defaultValue;
115
- }
116
- }
117
- return result;
118
- }
119
- function createDefer() {
120
- let resolve = null;
121
- let reject = null;
122
- const p = new Promise((_resolve, _reject) => {
123
- resolve = _resolve;
124
- reject = _reject;
125
- });
126
- p.resolve = resolve;
127
- p.reject = reject;
128
- return p;
129
- }
130
- function isNegativeNaN(val) {
131
- if (!Number.isNaN(val)) {
132
- return false;
133
- }
134
- const f64 = new Float64Array(1);
135
- f64[0] = val;
136
- const u32 = new Uint32Array(f64.buffer);
137
- const isNegative = u32[1] >>> 31 === 1;
138
- return isNegative;
139
- }
140
- exports.assertTypes = assertTypes;
141
- exports.clone = clone;
142
- exports.createDefer = createDefer;
143
- exports.createSimpleStackTrace = createSimpleStackTrace;
144
- exports.deepClone = deepClone;
145
- exports.getOwnProperties = getOwnProperties;
146
- exports.getType = getType;
147
- exports.isNegativeNaN = isNegativeNaN;
148
- exports.isObject = isObject;
149
- exports.noop = noop;
150
- exports.objectAttr = objectAttr;
151
- exports.toArray = toArray;
@@ -1,151 +0,0 @@
1
- function createSimpleStackTrace(options) {
2
- const { message = "$$stack trace error", stackTraceLimit = 1 } = options || {};
3
- const limit = Error.stackTraceLimit;
4
- const prepareStackTrace = Error.prepareStackTrace;
5
- Error.stackTraceLimit = stackTraceLimit;
6
- Error.prepareStackTrace = (e) => e.stack;
7
- const err = new Error(message);
8
- const stackTrace = err.stack || "";
9
- Error.prepareStackTrace = prepareStackTrace;
10
- Error.stackTraceLimit = limit;
11
- return stackTrace;
12
- }
13
- function assertTypes(value, name, types) {
14
- const receivedType = typeof value;
15
- const pass = types.includes(receivedType);
16
- if (!pass) {
17
- throw new TypeError(`${name} value must be ${types.join(" or ")}, received "${receivedType}"`);
18
- }
19
- }
20
- function toArray(array) {
21
- if (array === null || array === void 0) {
22
- array = [];
23
- }
24
- if (Array.isArray(array)) {
25
- return array;
26
- }
27
- return [array];
28
- }
29
- function isObject(item) {
30
- return item != null && typeof item === "object" && !Array.isArray(item);
31
- }
32
- function isFinalObj(obj) {
33
- return obj === Object.prototype || obj === Function.prototype || obj === RegExp.prototype;
34
- }
35
- function getType(value) {
36
- return Object.prototype.toString.apply(value).slice(8, -1);
37
- }
38
- function collectOwnProperties(obj, collector) {
39
- const collect = typeof collector === "function" ? collector : (key) => collector.add(key);
40
- Object.getOwnPropertyNames(obj).forEach(collect);
41
- Object.getOwnPropertySymbols(obj).forEach(collect);
42
- }
43
- function getOwnProperties(obj) {
44
- const ownProps = /* @__PURE__ */ new Set();
45
- if (isFinalObj(obj)) {
46
- return [];
47
- }
48
- collectOwnProperties(obj, ownProps);
49
- return Array.from(ownProps);
50
- }
51
- const defaultCloneOptions = { forceWritable: false };
52
- function deepClone(val, options = defaultCloneOptions) {
53
- const seen = /* @__PURE__ */ new WeakMap();
54
- return clone(val, seen, options);
55
- }
56
- function clone(val, seen, options = defaultCloneOptions) {
57
- let k, out;
58
- if (seen.has(val)) {
59
- return seen.get(val);
60
- }
61
- if (Array.isArray(val)) {
62
- out = Array.from({ length: k = val.length });
63
- seen.set(val, out);
64
- while (k--) {
65
- out[k] = clone(val[k], seen, options);
66
- }
67
- return out;
68
- }
69
- if (Object.prototype.toString.call(val) === "[object Object]") {
70
- out = Object.create(Object.getPrototypeOf(val));
71
- seen.set(val, out);
72
- const props = getOwnProperties(val);
73
- for (const k2 of props) {
74
- const descriptor = Object.getOwnPropertyDescriptor(val, k2);
75
- if (!descriptor) {
76
- continue;
77
- }
78
- const cloned = clone(val[k2], seen, options);
79
- if (options.forceWritable) {
80
- Object.defineProperty(out, k2, {
81
- enumerable: descriptor.enumerable,
82
- configurable: true,
83
- writable: true,
84
- value: cloned
85
- });
86
- } else if ("get" in descriptor) {
87
- Object.defineProperty(out, k2, {
88
- ...descriptor,
89
- get() {
90
- return cloned;
91
- }
92
- });
93
- } else {
94
- Object.defineProperty(out, k2, {
95
- ...descriptor,
96
- value: cloned
97
- });
98
- }
99
- }
100
- return out;
101
- }
102
- return val;
103
- }
104
- function noop() {
105
- }
106
- function objectAttr(source, path, defaultValue = void 0) {
107
- const paths = path.replace(/\[(\d+)\]/g, ".$1").split(".");
108
- let result = source;
109
- for (const p of paths) {
110
- result = new Object(result)[p];
111
- if (result === void 0) {
112
- return defaultValue;
113
- }
114
- }
115
- return result;
116
- }
117
- function createDefer() {
118
- let resolve = null;
119
- let reject = null;
120
- const p = new Promise((_resolve, _reject) => {
121
- resolve = _resolve;
122
- reject = _reject;
123
- });
124
- p.resolve = resolve;
125
- p.reject = reject;
126
- return p;
127
- }
128
- function isNegativeNaN(val) {
129
- if (!Number.isNaN(val)) {
130
- return false;
131
- }
132
- const f64 = new Float64Array(1);
133
- f64[0] = val;
134
- const u32 = new Uint32Array(f64.buffer);
135
- const isNegative = u32[1] >>> 31 === 1;
136
- return isNegative;
137
- }
138
- export {
139
- assertTypes,
140
- clone,
141
- createDefer,
142
- createSimpleStackTrace,
143
- deepClone,
144
- getOwnProperties,
145
- getType,
146
- isNegativeNaN,
147
- isObject,
148
- noop,
149
- objectAttr,
150
- toArray
151
- };
@@ -1,114 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const IS_RECORD_SYMBOL = "@@__IMMUTABLE_RECORD__@@";
4
- const IS_COLLECTION_SYMBOL = "@@__IMMUTABLE_ITERABLE__@@";
5
- function isImmutable(v) {
6
- return v && (v[IS_COLLECTION_SYMBOL] || v[IS_RECORD_SYMBOL]);
7
- }
8
- const OBJECT_PROTO = Object.getPrototypeOf({});
9
- function getUnserializableMessage(err) {
10
- if (err instanceof Error) {
11
- return `<unserializable>: ${err.message}`;
12
- }
13
- if (typeof err === "string") {
14
- return `<unserializable>: ${err}`;
15
- }
16
- return "<unserializable>";
17
- }
18
- function serializeValue(val, seen = /* @__PURE__ */ new WeakMap()) {
19
- if (!val || typeof val === "string") {
20
- return val;
21
- }
22
- if (val instanceof Error && "toJSON" in val && typeof val.toJSON === "function") {
23
- const jsonValue = val.toJSON();
24
- if (jsonValue && jsonValue !== val && typeof jsonValue === "object") {
25
- if (typeof val.message === "string") {
26
- safe(() => jsonValue.message ?? (jsonValue.message = normalizeErrorMessage(val.message)));
27
- }
28
- if (typeof val.stack === "string") {
29
- safe(() => jsonValue.stack ?? (jsonValue.stack = val.stack));
30
- }
31
- if (typeof val.name === "string") {
32
- safe(() => jsonValue.name ?? (jsonValue.name = val.name));
33
- }
34
- if (val.cause != null) {
35
- safe(() => jsonValue.cause ?? (jsonValue.cause = serializeValue(val.cause, seen)));
36
- }
37
- }
38
- return serializeValue(jsonValue, seen);
39
- }
40
- if (typeof val === "function") {
41
- return `Function<${val.name || "anonymous"}>`;
42
- }
43
- if (typeof val === "symbol") {
44
- return val.toString();
45
- }
46
- if (typeof val !== "object") {
47
- return val;
48
- }
49
- if (typeof Buffer !== "undefined" && val instanceof Buffer) {
50
- return `<Buffer(${val.length}) ...>`;
51
- }
52
- if (typeof Uint8Array !== "undefined" && val instanceof Uint8Array) {
53
- return `<Uint8Array(${val.length}) ...>`;
54
- }
55
- if (isImmutable(val)) {
56
- return serializeValue(val.toJSON(), seen);
57
- }
58
- if (val instanceof Promise || val.constructor && val.constructor.prototype === "AsyncFunction") {
59
- return "Promise";
60
- }
61
- if (typeof Element !== "undefined" && val instanceof Element) {
62
- return val.tagName;
63
- }
64
- if (typeof val.toJSON === "function") {
65
- return serializeValue(val.toJSON(), seen);
66
- }
67
- if (seen.has(val)) {
68
- return seen.get(val);
69
- }
70
- if (Array.isArray(val)) {
71
- const clone = new Array(val.length);
72
- seen.set(val, clone);
73
- val.forEach((e, i) => {
74
- try {
75
- clone[i] = serializeValue(e, seen);
76
- } catch (err) {
77
- clone[i] = getUnserializableMessage(err);
78
- }
79
- });
80
- return clone;
81
- } else {
82
- const clone = /* @__PURE__ */ Object.create(null);
83
- seen.set(val, clone);
84
- let obj = val;
85
- while (obj && obj !== OBJECT_PROTO) {
86
- Object.getOwnPropertyNames(obj).forEach((key) => {
87
- if (key in clone) {
88
- return;
89
- }
90
- try {
91
- clone[key] = serializeValue(val[key], seen);
92
- } catch (err) {
93
- delete clone[key];
94
- clone[key] = getUnserializableMessage(err);
95
- }
96
- });
97
- obj = Object.getPrototypeOf(obj);
98
- }
99
- if (val instanceof Error) {
100
- safe(() => val.message = normalizeErrorMessage(val.message));
101
- }
102
- return clone;
103
- }
104
- }
105
- function safe(fn) {
106
- try {
107
- return fn();
108
- } catch {
109
- }
110
- }
111
- function normalizeErrorMessage(message) {
112
- return message.replace(/__(vite_ssr_import|vi_import)_\d+__\./g, "");
113
- }
114
- exports.serializeValue = serializeValue;
@@ -1,114 +0,0 @@
1
- const IS_RECORD_SYMBOL = "@@__IMMUTABLE_RECORD__@@";
2
- const IS_COLLECTION_SYMBOL = "@@__IMMUTABLE_ITERABLE__@@";
3
- function isImmutable(v) {
4
- return v && (v[IS_COLLECTION_SYMBOL] || v[IS_RECORD_SYMBOL]);
5
- }
6
- const OBJECT_PROTO = Object.getPrototypeOf({});
7
- function getUnserializableMessage(err) {
8
- if (err instanceof Error) {
9
- return `<unserializable>: ${err.message}`;
10
- }
11
- if (typeof err === "string") {
12
- return `<unserializable>: ${err}`;
13
- }
14
- return "<unserializable>";
15
- }
16
- function serializeValue(val, seen = /* @__PURE__ */ new WeakMap()) {
17
- if (!val || typeof val === "string") {
18
- return val;
19
- }
20
- if (val instanceof Error && "toJSON" in val && typeof val.toJSON === "function") {
21
- const jsonValue = val.toJSON();
22
- if (jsonValue && jsonValue !== val && typeof jsonValue === "object") {
23
- if (typeof val.message === "string") {
24
- safe(() => jsonValue.message ?? (jsonValue.message = normalizeErrorMessage(val.message)));
25
- }
26
- if (typeof val.stack === "string") {
27
- safe(() => jsonValue.stack ?? (jsonValue.stack = val.stack));
28
- }
29
- if (typeof val.name === "string") {
30
- safe(() => jsonValue.name ?? (jsonValue.name = val.name));
31
- }
32
- if (val.cause != null) {
33
- safe(() => jsonValue.cause ?? (jsonValue.cause = serializeValue(val.cause, seen)));
34
- }
35
- }
36
- return serializeValue(jsonValue, seen);
37
- }
38
- if (typeof val === "function") {
39
- return `Function<${val.name || "anonymous"}>`;
40
- }
41
- if (typeof val === "symbol") {
42
- return val.toString();
43
- }
44
- if (typeof val !== "object") {
45
- return val;
46
- }
47
- if (typeof Buffer !== "undefined" && val instanceof Buffer) {
48
- return `<Buffer(${val.length}) ...>`;
49
- }
50
- if (typeof Uint8Array !== "undefined" && val instanceof Uint8Array) {
51
- return `<Uint8Array(${val.length}) ...>`;
52
- }
53
- if (isImmutable(val)) {
54
- return serializeValue(val.toJSON(), seen);
55
- }
56
- if (val instanceof Promise || val.constructor && val.constructor.prototype === "AsyncFunction") {
57
- return "Promise";
58
- }
59
- if (typeof Element !== "undefined" && val instanceof Element) {
60
- return val.tagName;
61
- }
62
- if (typeof val.toJSON === "function") {
63
- return serializeValue(val.toJSON(), seen);
64
- }
65
- if (seen.has(val)) {
66
- return seen.get(val);
67
- }
68
- if (Array.isArray(val)) {
69
- const clone = new Array(val.length);
70
- seen.set(val, clone);
71
- val.forEach((e, i) => {
72
- try {
73
- clone[i] = serializeValue(e, seen);
74
- } catch (err) {
75
- clone[i] = getUnserializableMessage(err);
76
- }
77
- });
78
- return clone;
79
- } else {
80
- const clone = /* @__PURE__ */ Object.create(null);
81
- seen.set(val, clone);
82
- let obj = val;
83
- while (obj && obj !== OBJECT_PROTO) {
84
- Object.getOwnPropertyNames(obj).forEach((key) => {
85
- if (key in clone) {
86
- return;
87
- }
88
- try {
89
- clone[key] = serializeValue(val[key], seen);
90
- } catch (err) {
91
- delete clone[key];
92
- clone[key] = getUnserializableMessage(err);
93
- }
94
- });
95
- obj = Object.getPrototypeOf(obj);
96
- }
97
- if (val instanceof Error) {
98
- safe(() => val.message = normalizeErrorMessage(val.message));
99
- }
100
- return clone;
101
- }
102
- }
103
- function safe(fn) {
104
- try {
105
- return fn();
106
- } catch {
107
- }
108
- }
109
- function normalizeErrorMessage(message) {
110
- return message.replace(/__(vite_ssr_import|vi_import)_\d+__\./g, "");
111
- }
112
- export {
113
- serializeValue
114
- };