seroval 0.11.6 → 0.12.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.
- package/README.md +29 -16
- package/dist/cjs/development/index.cjs +3072 -4875
- package/dist/cjs/development/index.cjs.map +4 -4
- package/dist/cjs/production/index.cjs +3 -3
- package/dist/esm/development/index.mjs +3069 -4874
- package/dist/esm/development/index.mjs.map +4 -4
- package/dist/esm/production/index.mjs +3 -3
- package/dist/types/core/Serializer.d.ts +2 -0
- package/dist/types/core/Serializer.d.ts.map +1 -0
- package/dist/types/core/UnsupportedTypeError.d.ts +1 -0
- package/dist/types/core/UnsupportedTypeError.d.ts.map +1 -0
- package/dist/types/core/assert.d.ts +1 -0
- package/dist/types/core/assert.d.ts.map +1 -0
- package/dist/types/core/base/async.d.ts +30 -0
- package/dist/types/core/base/async.d.ts.map +1 -0
- package/dist/types/core/base/stream.d.ts +40 -0
- package/dist/types/core/base/stream.d.ts.map +1 -0
- package/dist/types/core/base/sync.d.ts +32 -0
- package/dist/types/core/base/sync.d.ts.map +1 -0
- package/dist/types/core/base-primitives.d.ts +3 -1
- package/dist/types/core/base-primitives.d.ts.map +1 -0
- package/dist/types/core/compat.d.ts +1 -0
- package/dist/types/core/compat.d.ts.map +1 -0
- package/dist/types/core/constants.d.ts +19 -4
- package/dist/types/core/constants.d.ts.map +1 -0
- package/dist/types/core/constructors.d.ts +1 -0
- package/dist/types/core/constructors.d.ts.map +1 -0
- package/dist/types/core/cross/async.d.ts +8 -3
- package/dist/types/core/cross/async.d.ts.map +1 -0
- package/dist/types/core/cross/cross-parser.d.ts +8 -0
- package/dist/types/core/cross/cross-parser.d.ts.map +1 -0
- package/dist/types/core/cross/index.d.ts +12 -5
- package/dist/types/core/cross/index.d.ts.map +1 -0
- package/dist/types/core/cross/serialize.d.ts +23 -5
- package/dist/types/core/cross/serialize.d.ts.map +1 -0
- package/dist/types/core/cross/stream.d.ts +8 -3
- package/dist/types/core/cross/stream.d.ts.map +1 -0
- package/dist/types/core/cross/sync.d.ts +8 -3
- package/dist/types/core/cross/sync.d.ts.map +1 -0
- package/dist/types/core/get-identifier.d.ts +1 -0
- package/dist/types/core/get-identifier.d.ts.map +1 -0
- package/dist/types/core/keys.d.ts +1 -0
- package/dist/types/core/keys.d.ts.map +1 -0
- package/dist/types/core/literals.d.ts +1 -0
- package/dist/types/core/literals.d.ts.map +1 -0
- package/dist/types/core/parser-context.d.ts +23 -0
- package/dist/types/core/parser-context.d.ts.map +1 -0
- package/dist/types/core/plugin.d.ts +26 -0
- package/dist/types/core/plugin.d.ts.map +1 -0
- package/dist/types/core/promise-to-result.d.ts +1 -0
- package/dist/types/core/promise-to-result.d.ts.map +1 -0
- package/dist/types/core/reference.d.ts +1 -0
- package/dist/types/core/reference.d.ts.map +1 -0
- package/dist/types/core/serializer-context.old.d.ts +165 -0
- package/dist/types/core/serializer-context.old.d.ts.map +1 -0
- package/dist/types/core/shared.d.ts +4 -7
- package/dist/types/core/shared.d.ts.map +1 -0
- package/dist/types/core/string.d.ts +1 -0
- package/dist/types/core/string.d.ts.map +1 -0
- package/dist/types/core/tree/async.d.ts +8 -3
- package/dist/types/core/tree/async.d.ts.map +1 -0
- package/dist/types/core/tree/deserialize.d.ts +49 -2
- package/dist/types/core/tree/deserialize.d.ts.map +1 -0
- package/dist/types/core/tree/index.d.ts +10 -7
- package/dist/types/core/tree/index.d.ts.map +1 -0
- package/dist/types/core/tree/serialize.d.ts +37 -4
- package/dist/types/core/tree/serialize.d.ts.map +1 -0
- package/dist/types/core/tree/sync.d.ts +8 -3
- package/dist/types/core/tree/sync.d.ts.map +1 -0
- package/dist/types/core/types.d.ts +10 -3
- package/dist/types/core/types.d.ts.map +1 -0
- package/dist/types/core/web-api.d.ts +1 -0
- package/dist/types/core/web-api.d.ts.map +1 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/types.d.ts +1 -0
- package/dist/types/types.d.ts.map +1 -0
- package/package.json +2 -2
- package/src/core/Serializer.ts +2 -0
- package/src/core/base/async.ts +804 -0
- package/src/core/base/stream.ts +496 -0
- package/src/core/base/sync.ts +675 -0
- package/src/core/base-primitives.ts +22 -0
- package/src/core/constants.ts +61 -45
- package/src/core/cross/async.ts +6 -751
- package/src/core/cross/cross-parser.ts +9 -0
- package/src/core/cross/index.ts +62 -84
- package/src/core/cross/serialize.ts +71 -862
- package/src/core/cross/stream.ts +6 -873
- package/src/core/cross/sync.ts +6 -624
- package/src/core/is-serializable.new.ts +208 -0
- package/src/core/keys.ts +1 -1
- package/src/core/parser-context.ts +131 -0
- package/src/core/plugin.ts +55 -0
- package/src/core/serializer-context.new.ts +1168 -0
- package/src/core/serializer-context.old.ts +1126 -0
- package/src/core/shared.ts +46 -123
- package/src/core/tree/async.ts +6 -750
- package/src/core/tree/deserialize.ts +423 -420
- package/src/core/tree/index.ts +49 -91
- package/src/core/tree/parser.ts +45 -0
- package/src/core/tree/serialize.ts +122 -828
- package/src/core/tree/sync.ts +6 -624
- package/src/core/types.ts +13 -2
- package/src/example.ts +28 -0
- package/src/index.ts +3 -0
- package/dist/types/core/assignments.d.ts +0 -33
- package/dist/types/core/context.d.ts +0 -9
- package/dist/types/core/cross/context.d.ts +0 -37
- package/dist/types/core/cross/primitives.d.ts +0 -9
- package/dist/types/core/cross/web-api.d.ts +0 -4
- package/dist/types/core/tree/context.d.ts +0 -44
- package/dist/types/core/tree/primitives.d.ts +0 -9
- package/dist/types/core/tree/web-api.d.ts +0 -4
- package/src/core/assignments.ts +0 -159
- package/src/core/context.ts +0 -15
- package/src/core/cross/context.ts +0 -102
- package/src/core/cross/primitives.ts +0 -128
- package/src/core/cross/web-api.ts +0 -50
- package/src/core/tree/context.ts +0 -125
- package/src/core/tree/primitives.ts +0 -123
- package/src/core/tree/web-api.ts +0 -50
package/src/core/constants.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import type { SerovalConstantNode } from './types';
|
|
2
|
-
|
|
3
1
|
export const enum SerovalConstant {
|
|
4
2
|
Null = 0,
|
|
5
3
|
Undefined = 1,
|
|
@@ -52,6 +50,7 @@ export const enum SerovalNodeType {
|
|
|
52
50
|
Event = 37,
|
|
53
51
|
CustomEvent = 38,
|
|
54
52
|
DOMException = 39,
|
|
53
|
+
Plugin = 40,
|
|
55
54
|
}
|
|
56
55
|
|
|
57
56
|
export const enum SerovalObjectFlags {
|
|
@@ -127,48 +126,65 @@ export const SYMBOL_REF: Record<Symbols, WellKnownSymbols> = {
|
|
|
127
126
|
[Symbols.Unscopables]: Symbol.unscopables,
|
|
128
127
|
};
|
|
129
128
|
|
|
130
|
-
export
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
case SerovalConstant.NegativeZero:
|
|
141
|
-
return '-0';
|
|
142
|
-
case SerovalConstant.Infinity:
|
|
143
|
-
return '1/0';
|
|
144
|
-
case SerovalConstant.NegativeInfinity:
|
|
145
|
-
return '-1/0';
|
|
146
|
-
case SerovalConstant.NaN:
|
|
147
|
-
return 'NaN';
|
|
148
|
-
default:
|
|
149
|
-
throw new Error('invariant');
|
|
150
|
-
}
|
|
151
|
-
}
|
|
129
|
+
export const CONSTANT_STRING: Record<SerovalConstant, string> = {
|
|
130
|
+
[SerovalConstant.True]: '!0',
|
|
131
|
+
[SerovalConstant.False]: '!1',
|
|
132
|
+
[SerovalConstant.Undefined]: 'void 0',
|
|
133
|
+
[SerovalConstant.Null]: 'null',
|
|
134
|
+
[SerovalConstant.NegativeZero]: '-0',
|
|
135
|
+
[SerovalConstant.Infinity]: '1/0',
|
|
136
|
+
[SerovalConstant.NegativeInfinity]: '-1/0',
|
|
137
|
+
[SerovalConstant.NaN]: '0/0',
|
|
138
|
+
};
|
|
152
139
|
|
|
153
|
-
export
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
throw new Error('invariant');
|
|
173
|
-
}
|
|
140
|
+
export const CONSTANT_VAL: Record<SerovalConstant, unknown> = {
|
|
141
|
+
[SerovalConstant.True]: true,
|
|
142
|
+
[SerovalConstant.False]: false,
|
|
143
|
+
[SerovalConstant.Undefined]: undefined,
|
|
144
|
+
[SerovalConstant.Null]: null,
|
|
145
|
+
[SerovalConstant.NegativeZero]: -0,
|
|
146
|
+
[SerovalConstant.Infinity]: Infinity,
|
|
147
|
+
[SerovalConstant.NegativeInfinity]: -Infinity,
|
|
148
|
+
[SerovalConstant.NaN]: NaN,
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
export const enum ErrorConstructorTag {
|
|
152
|
+
Error = 0,
|
|
153
|
+
EvalError = 1,
|
|
154
|
+
RangeError = 2,
|
|
155
|
+
ReferenceError = 3,
|
|
156
|
+
SyntaxError = 4,
|
|
157
|
+
TypeError = 5,
|
|
158
|
+
URIError = 6,
|
|
174
159
|
}
|
|
160
|
+
|
|
161
|
+
export const ERROR_CONSTRUCTOR_STRING: Record<ErrorConstructorTag, string> = {
|
|
162
|
+
[ErrorConstructorTag.Error]: 'Error',
|
|
163
|
+
[ErrorConstructorTag.EvalError]: 'EvalError',
|
|
164
|
+
[ErrorConstructorTag.RangeError]: 'RangeError',
|
|
165
|
+
[ErrorConstructorTag.ReferenceError]: 'ReferenceError',
|
|
166
|
+
[ErrorConstructorTag.SyntaxError]: 'SyntaxError',
|
|
167
|
+
[ErrorConstructorTag.TypeError]: 'TypeError',
|
|
168
|
+
[ErrorConstructorTag.URIError]: 'URIError',
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
type ErrorConstructors =
|
|
172
|
+
| ErrorConstructor
|
|
173
|
+
| EvalErrorConstructor
|
|
174
|
+
| RangeErrorConstructor
|
|
175
|
+
| ReferenceErrorConstructor
|
|
176
|
+
| SyntaxErrorConstructor
|
|
177
|
+
| TypeErrorConstructor
|
|
178
|
+
| URIErrorConstructor;
|
|
179
|
+
|
|
180
|
+
export const ERROR_CONSTRUCTOR: Record<ErrorConstructorTag, ErrorConstructors> = {
|
|
181
|
+
[ErrorConstructorTag.Error]: Error,
|
|
182
|
+
[ErrorConstructorTag.EvalError]: EvalError,
|
|
183
|
+
[ErrorConstructorTag.RangeError]: RangeError,
|
|
184
|
+
[ErrorConstructorTag.ReferenceError]: ReferenceError,
|
|
185
|
+
[ErrorConstructorTag.SyntaxError]: SyntaxError,
|
|
186
|
+
[ErrorConstructorTag.TypeError]: TypeError,
|
|
187
|
+
[ErrorConstructorTag.URIError]: URIError,
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
export const UNIVERSAL_SENTINEL = Symbol('why');
|