seroval 0.4.0-alpha.8 → 0.4.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 +81 -55
- package/dist/cjs/development/index.cjs +999 -831
- package/dist/cjs/development/index.cjs.map +4 -4
- package/dist/cjs/production/index.cjs +2 -2
- package/dist/esm/development/index.mjs +999 -831
- package/dist/esm/development/index.mjs.map +4 -4
- package/dist/esm/production/index.mjs +2 -2
- package/dist/types/compat.d.ts +10 -25
- package/dist/types/context.d.ts +17 -15
- package/dist/types/index.d.ts +2 -1
- package/dist/types/tree/primitives.d.ts +17 -0
- package/dist/types/tree/serialize.d.ts +1 -1
- package/dist/types/tree/shared.d.ts +4 -8
- package/dist/types/tree/types.d.ts +108 -59
- package/dist/types/types.d.ts +3 -2
- package/package.json +2 -2
- package/src/compat.ts +10 -246
- package/src/context.ts +37 -26
- package/src/index.ts +33 -41
- package/src/quote.ts +1 -1
- package/src/tree/async.ts +362 -163
- package/src/tree/primitives.ts +150 -0
- package/src/tree/serialize.ts +308 -282
- package/src/tree/shared.ts +43 -119
- package/src/tree/sync.ts +295 -146
- package/src/tree/types.ts +143 -65
- package/src/types.ts +4 -1
- package/dist/types/checks.d.ts +0 -5
- package/src/checks.ts +0 -40
package/dist/types/context.d.ts
CHANGED
|
@@ -1,40 +1,42 @@
|
|
|
1
1
|
interface IndexAssignment {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
t: 'index';
|
|
3
|
+
s: string;
|
|
4
|
+
k: undefined;
|
|
5
|
+
v: string;
|
|
5
6
|
}
|
|
6
7
|
interface MapAssignment {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
t: 'map';
|
|
9
|
+
s: string;
|
|
10
|
+
k: string;
|
|
11
|
+
v: string;
|
|
11
12
|
}
|
|
12
13
|
interface SetAssignment {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
t: 'set';
|
|
15
|
+
s: string;
|
|
16
|
+
k: undefined;
|
|
17
|
+
v: string;
|
|
16
18
|
}
|
|
17
19
|
export type Assignment = IndexAssignment | MapAssignment | SetAssignment;
|
|
18
20
|
export interface ParserContext {
|
|
19
21
|
refs: Map<unknown, number>;
|
|
20
|
-
markedRefs:
|
|
22
|
+
markedRefs: Set<number>;
|
|
21
23
|
features: number;
|
|
22
24
|
}
|
|
23
25
|
export interface SerializationContext {
|
|
24
26
|
stack: number[];
|
|
25
27
|
validRefs: number[];
|
|
26
28
|
refSize: number;
|
|
27
|
-
markedRefs:
|
|
29
|
+
markedRefs: Set<number>;
|
|
28
30
|
vars: string[];
|
|
29
31
|
assignments: Assignment[];
|
|
30
32
|
features: number;
|
|
31
33
|
}
|
|
32
34
|
export interface Options {
|
|
33
|
-
|
|
35
|
+
disabledFeatures: number;
|
|
34
36
|
}
|
|
35
37
|
export declare function createParserContext(options?: Partial<Options>): ParserContext;
|
|
36
38
|
export interface SerializationOptions {
|
|
37
|
-
markedRefs:
|
|
39
|
+
markedRefs: number[] | Set<number>;
|
|
38
40
|
features: number;
|
|
39
41
|
}
|
|
40
42
|
export declare function createSerializationContext(options: SerializationOptions): SerializationContext;
|
|
@@ -50,5 +52,5 @@ export declare function getRefParam(ctx: SerializationContext, index: number): s
|
|
|
50
52
|
/**
|
|
51
53
|
* Creates a reference ID from the given values
|
|
52
54
|
*/
|
|
53
|
-
export declare function createRef(ctx: ParserContext,
|
|
55
|
+
export declare function createRef(ctx: ParserContext, current: unknown, mark: boolean): number;
|
|
54
56
|
export {};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { Feature } from './compat';
|
|
1
2
|
import { Options } from './context';
|
|
2
3
|
import { AsyncServerValue, PrimitiveValue, ServerValue, CommonServerValue, SemiPrimitiveValue, ErrorValue } from './types';
|
|
3
|
-
export { AsyncServerValue, ServerValue, PrimitiveValue, CommonServerValue, SemiPrimitiveValue, ErrorValue, };
|
|
4
|
+
export { AsyncServerValue, ServerValue, PrimitiveValue, CommonServerValue, SemiPrimitiveValue, ErrorValue, Feature, };
|
|
4
5
|
export declare function serialize<T extends ServerValue>(source: T, options?: Partial<Options>): string;
|
|
5
6
|
export declare function serializeAsync<T extends AsyncServerValue>(source: T, options?: Partial<Options>): Promise<string>;
|
|
6
7
|
export declare function deserialize<T extends AsyncServerValue>(source: string): T;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ParserContext } from '../context';
|
|
2
|
+
import { BigIntTypedArrayValue, TypedArrayValue } from '../types';
|
|
3
|
+
import { SerovalBigIntNode, SerovalBigIntTypedArrayNode, SerovalDateNode, SerovalPrimitiveNode, SerovalReferenceNode, SerovalRegExpNode, SerovalTypedArrayNode } from './types';
|
|
4
|
+
export declare function createPrimitiveNode(value: string | number | null): SerovalPrimitiveNode;
|
|
5
|
+
export declare const TRUE_NODE: SerovalPrimitiveNode;
|
|
6
|
+
export declare const FALSE_NODE: SerovalPrimitiveNode;
|
|
7
|
+
export declare const UNDEFINED_NODE: SerovalPrimitiveNode;
|
|
8
|
+
export declare const NULL_NODE: SerovalPrimitiveNode;
|
|
9
|
+
export declare const NEG_ZERO_NODE: SerovalPrimitiveNode;
|
|
10
|
+
export declare const INFINITY_NODE: SerovalPrimitiveNode;
|
|
11
|
+
export declare const NEG_INFINITY_NODE: SerovalPrimitiveNode;
|
|
12
|
+
export declare function createBigIntNode(ctx: ParserContext, current: bigint): SerovalBigIntNode;
|
|
13
|
+
export declare function createReferenceNode(id: number): SerovalReferenceNode;
|
|
14
|
+
export declare function createDateNode(id: number, current: Date): SerovalDateNode;
|
|
15
|
+
export declare function createRegExpNode(id: number, current: RegExp): SerovalRegExpNode;
|
|
16
|
+
export declare function createTypedArrayNode(ctx: ParserContext, id: number, current: TypedArrayValue): SerovalTypedArrayNode;
|
|
17
|
+
export declare function createBigIntTypedArrayNode(ctx: ParserContext, id: number, current: BigIntTypedArrayValue): SerovalBigIntTypedArrayNode;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { SerializationContext } from '../context';
|
|
2
2
|
import { SerovalNode } from './types';
|
|
3
3
|
export declare function resolvePatches(ctx: SerializationContext): string | undefined;
|
|
4
|
-
export default function serializeTree(ctx: SerializationContext,
|
|
4
|
+
export default function serializeTree(ctx: SerializationContext, node: SerovalNode): string;
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { SerovalNode, SerovalReferenceNode } from './types';
|
|
1
|
+
import { ParserContext } from '../context';
|
|
2
|
+
import { AsyncServerValue, ErrorValue } from '../types';
|
|
4
3
|
export declare function getErrorConstructor(error: ErrorValue): "EvalError" | "RangeError" | "ReferenceError" | "SyntaxError" | "TypeError" | "URIError" | "Error";
|
|
5
|
-
export declare function getErrorOptions(error: Error): Record<string, any> | undefined;
|
|
4
|
+
export declare function getErrorOptions(ctx: ParserContext, error: Error): Record<string, any> | undefined;
|
|
6
5
|
export declare function getIterableOptions(obj: Iterable<any>): Record<string, unknown> | undefined;
|
|
7
|
-
export declare function
|
|
8
|
-
export declare function generateRef(ctx: ParserContext, current: unknown): number | SerovalReferenceNode;
|
|
9
|
-
export declare function generateSemiPrimitiveValue(ctx: ParserContext, current: unknown, id: number): SerovalNode | undefined;
|
|
10
|
-
export declare function serializePrimitive(value: PrimitiveValue): string | number | null;
|
|
6
|
+
export declare function isIterable(value: unknown): value is Iterable<AsyncServerValue>;
|
|
@@ -17,63 +17,112 @@ export declare const enum SerovalNodeType {
|
|
|
17
17
|
TypedArray = 14,
|
|
18
18
|
BigIntTypedArray = 15
|
|
19
19
|
}
|
|
20
|
-
export
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
] |
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
];
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
export
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
export type
|
|
42
|
-
export
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
export
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
20
|
+
export interface SerovalBaseNode {
|
|
21
|
+
t: SerovalNodeType;
|
|
22
|
+
s: PrimitiveValue | undefined;
|
|
23
|
+
i: number | undefined;
|
|
24
|
+
l: number | undefined;
|
|
25
|
+
c: string | undefined;
|
|
26
|
+
d: SerovalDictionaryNode | undefined;
|
|
27
|
+
m: string | undefined;
|
|
28
|
+
n: SerovalNode | undefined;
|
|
29
|
+
a: SerovalNode[] | undefined;
|
|
30
|
+
}
|
|
31
|
+
export interface SerovalObjectRecordNode {
|
|
32
|
+
k: string[];
|
|
33
|
+
v: SerovalNode[];
|
|
34
|
+
s: number;
|
|
35
|
+
}
|
|
36
|
+
export interface SerovalMapRecordNode {
|
|
37
|
+
k: SerovalNode[];
|
|
38
|
+
v: SerovalNode[];
|
|
39
|
+
s: number;
|
|
40
|
+
}
|
|
41
|
+
export type SerovalDictionaryNode = SerovalObjectRecordNode | SerovalMapRecordNode;
|
|
42
|
+
export interface SerovalPrimitiveNode extends SerovalBaseNode {
|
|
43
|
+
t: SerovalNodeType.Primitive;
|
|
44
|
+
}
|
|
45
|
+
export interface SerovalReferenceNode extends SerovalBaseNode {
|
|
46
|
+
t: SerovalNodeType.Reference;
|
|
47
|
+
i: number;
|
|
48
|
+
}
|
|
49
|
+
export interface SerovalBigIntNode extends SerovalBaseNode {
|
|
50
|
+
t: SerovalNodeType.BigInt;
|
|
51
|
+
s: string;
|
|
52
|
+
}
|
|
53
|
+
export interface SerovalDateNode extends SerovalBaseNode {
|
|
54
|
+
t: SerovalNodeType.Date;
|
|
55
|
+
i: number;
|
|
56
|
+
s: string;
|
|
57
|
+
}
|
|
58
|
+
export interface SerovalRegExpNode extends SerovalBaseNode {
|
|
59
|
+
t: SerovalNodeType.RegExp;
|
|
60
|
+
i: number;
|
|
61
|
+
s: string;
|
|
62
|
+
}
|
|
63
|
+
export interface SerovalTypedArrayNode extends SerovalBaseNode {
|
|
64
|
+
t: SerovalNodeType.TypedArray;
|
|
65
|
+
i: number;
|
|
66
|
+
s: string;
|
|
67
|
+
l: number;
|
|
68
|
+
c: string;
|
|
69
|
+
}
|
|
70
|
+
export interface SerovalBigIntTypedArrayNode extends SerovalBaseNode {
|
|
71
|
+
t: SerovalNodeType.BigIntTypedArray;
|
|
72
|
+
i: number;
|
|
73
|
+
s: string;
|
|
74
|
+
l: number;
|
|
75
|
+
c: string;
|
|
76
|
+
}
|
|
77
|
+
export type SerovalSemiPrimitiveNode = SerovalBigIntNode | SerovalDateNode | SerovalRegExpNode | SerovalTypedArrayNode | SerovalBigIntTypedArrayNode;
|
|
78
|
+
export interface SerovalSetNode extends SerovalBaseNode {
|
|
79
|
+
t: SerovalNodeType.Set;
|
|
80
|
+
a: SerovalNode[];
|
|
81
|
+
i: number;
|
|
82
|
+
}
|
|
83
|
+
export interface SerovalMapNode extends SerovalBaseNode {
|
|
84
|
+
t: SerovalNodeType.Map;
|
|
85
|
+
d: SerovalMapRecordNode;
|
|
86
|
+
i: number;
|
|
87
|
+
}
|
|
88
|
+
export interface SerovalArrayNode extends SerovalBaseNode {
|
|
89
|
+
t: SerovalNodeType.Array;
|
|
90
|
+
a: SerovalNode[];
|
|
91
|
+
i: number;
|
|
92
|
+
}
|
|
93
|
+
export interface SerovalObjectNode extends SerovalBaseNode {
|
|
94
|
+
t: SerovalNodeType.Object;
|
|
95
|
+
d: SerovalObjectRecordNode;
|
|
96
|
+
i: number;
|
|
97
|
+
}
|
|
98
|
+
export interface SerovalNullConstructorNode extends SerovalBaseNode {
|
|
99
|
+
t: SerovalNodeType.NullConstructor;
|
|
100
|
+
d: SerovalObjectRecordNode;
|
|
101
|
+
i: number;
|
|
102
|
+
}
|
|
103
|
+
export interface SerovalPromiseNode extends SerovalBaseNode {
|
|
104
|
+
t: SerovalNodeType.Promise;
|
|
105
|
+
n: SerovalNode;
|
|
106
|
+
i: number;
|
|
107
|
+
}
|
|
108
|
+
export interface SerovalErrorNode extends SerovalBaseNode {
|
|
109
|
+
t: SerovalNodeType.Error;
|
|
110
|
+
c: string;
|
|
111
|
+
m: string;
|
|
112
|
+
d: SerovalObjectRecordNode | undefined;
|
|
113
|
+
i: number;
|
|
114
|
+
}
|
|
115
|
+
export interface SerovalAggregateErrorNode extends SerovalBaseNode {
|
|
116
|
+
t: SerovalNodeType.AggregateError;
|
|
117
|
+
m: string;
|
|
118
|
+
d: SerovalObjectRecordNode | undefined;
|
|
119
|
+
n: SerovalNode;
|
|
120
|
+
i: number;
|
|
121
|
+
}
|
|
122
|
+
export interface SerovalIterableNode extends SerovalBaseNode {
|
|
123
|
+
t: SerovalNodeType.Iterable;
|
|
124
|
+
d: SerovalObjectRecordNode | undefined;
|
|
125
|
+
a: SerovalNode[];
|
|
126
|
+
i: number;
|
|
127
|
+
}
|
|
79
128
|
export type SerovalNode = SerovalPrimitiveNode | SerovalReferenceNode | SerovalSemiPrimitiveNode | SerovalSetNode | SerovalMapNode | SerovalArrayNode | SerovalObjectNode | SerovalNullConstructorNode | SerovalPromiseNode | SerovalErrorNode | SerovalAggregateErrorNode | SerovalIterableNode;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export type PrimitiveValue = boolean | string | number | undefined | null;
|
|
2
2
|
export type ErrorValue = Error | AggregateError | EvalError | RangeError | ReferenceError | TypeError | SyntaxError | URIError;
|
|
3
|
-
export type TypedArrayValue = Int8Array | Int16Array | Int32Array | Uint8Array | Uint16Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array
|
|
4
|
-
export type
|
|
3
|
+
export type TypedArrayValue = Int8Array | Int16Array | Int32Array | Uint8Array | Uint16Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array;
|
|
4
|
+
export type BigIntTypedArrayValue = BigInt64Array | BigUint64Array;
|
|
5
|
+
export type SemiPrimitiveValue = RegExp | Date | TypedArrayValue | BigIntTypedArrayValue | bigint;
|
|
5
6
|
export type CommonServerValue = PrimitiveValue | SemiPrimitiveValue | ErrorValue;
|
|
6
7
|
export type ServerValue = CommonServerValue | Array<ServerValue> | readonly ServerValue[] | Iterable<ServerValue> | {
|
|
7
8
|
[key: string | number]: ServerValue;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "seroval",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.4.0
|
|
4
|
+
"version": "0.4.0",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
7
7
|
"src"
|
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
"typesVersions": {
|
|
65
65
|
"*": {}
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "4767da3b4b6397d6830978b6f4d0f014d2115479"
|
|
68
68
|
}
|
package/src/compat.ts
CHANGED
|
@@ -3,258 +3,22 @@
|
|
|
3
3
|
* References
|
|
4
4
|
* - https://kangax.github.io/compat-table/es6/
|
|
5
5
|
* - MDN
|
|
6
|
-
* - ESBuild
|
|
7
6
|
*/
|
|
8
7
|
|
|
9
|
-
import assert from './assert';
|
|
10
|
-
|
|
11
|
-
export type Version = [major: number, minor: number, patch: number];
|
|
12
|
-
|
|
13
|
-
function compareVersion(left: Version, right: Version) {
|
|
14
|
-
let diff = left[0] - right[0];
|
|
15
|
-
if (diff === 0) {
|
|
16
|
-
diff = left[1] - right[1];
|
|
17
|
-
}
|
|
18
|
-
if (diff === 0) {
|
|
19
|
-
diff = left[2] - right[2];
|
|
20
|
-
}
|
|
21
|
-
return diff;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export interface PlatformVersion {
|
|
25
|
-
es: Version;
|
|
26
|
-
// desktop
|
|
27
|
-
chrome?: Version;
|
|
28
|
-
edge?: Version;
|
|
29
|
-
safari?: Version;
|
|
30
|
-
firefox?: Version;
|
|
31
|
-
opera?: Version;
|
|
32
|
-
// mobile
|
|
33
|
-
ios?: Version;
|
|
34
|
-
samsung?: Version;
|
|
35
|
-
// js runtimes
|
|
36
|
-
deno?: Version;
|
|
37
|
-
node?: Version;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export type Platform = keyof PlatformVersion;
|
|
41
|
-
|
|
42
8
|
export const enum Feature {
|
|
43
9
|
AggregateError = 0x01,
|
|
44
10
|
ArrayPrototypeValues = 0x02,
|
|
45
11
|
ArrowFunction = 0x04,
|
|
46
12
|
BigInt = 0x08,
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
13
|
+
ErrorPrototypeStack = 0x10,
|
|
14
|
+
Map = 0x20,
|
|
15
|
+
MethodShorthand = 0x40,
|
|
16
|
+
ObjectAssign = 0x80,
|
|
17
|
+
Promise = 0x100,
|
|
18
|
+
Set = 0x200,
|
|
19
|
+
SymbolIterator = 0x400,
|
|
20
|
+
TypedArray = 0x800,
|
|
21
|
+
BigIntTypedArray = 0x1000,
|
|
55
22
|
}
|
|
56
23
|
|
|
57
|
-
|
|
58
|
-
[key in Feature]: PlatformVersion;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const VERSION_TABLE: VersionTable = {
|
|
62
|
-
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AggregateError#browser_compatibility
|
|
63
|
-
[Feature.AggregateError]: {
|
|
64
|
-
es: [2021, 0, 0],
|
|
65
|
-
chrome: [85, 0, 0],
|
|
66
|
-
edge: [85, 0, 0],
|
|
67
|
-
firefox: [79, 0, 0],
|
|
68
|
-
opera: [71, 0, 0],
|
|
69
|
-
safari: [14, 0, 0],
|
|
70
|
-
ios: [14, 0, 0],
|
|
71
|
-
samsung: [14, 0, 0],
|
|
72
|
-
deno: [1, 2, 0],
|
|
73
|
-
node: [15, 0, 0],
|
|
74
|
-
},
|
|
75
|
-
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/values#browser_compatibility
|
|
76
|
-
[Feature.ArrayPrototypeValues]: {
|
|
77
|
-
es: [6, 0, 0],
|
|
78
|
-
chrome: [66, 0, 0],
|
|
79
|
-
edge: [14, 0, 0],
|
|
80
|
-
firefox: [60, 0, 0],
|
|
81
|
-
opera: [53, 0, 0],
|
|
82
|
-
safari: [9, 0, 0],
|
|
83
|
-
ios: [9, 0, 0],
|
|
84
|
-
samsung: [9, 0, 0],
|
|
85
|
-
deno: [1, 0, 0],
|
|
86
|
-
node: [10, 9, 0],
|
|
87
|
-
},
|
|
88
|
-
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions#browser_compatibility
|
|
89
|
-
[Feature.ArrowFunction]: {
|
|
90
|
-
es: [6, 0, 0],
|
|
91
|
-
chrome: [45, 0, 0],
|
|
92
|
-
edge: [12, 0, 0],
|
|
93
|
-
firefox: [24, 0, 0],
|
|
94
|
-
opera: [32, 0, 0],
|
|
95
|
-
safari: [10, 0, 0],
|
|
96
|
-
ios: [10, 0, 0],
|
|
97
|
-
samsung: [5, 0, 0],
|
|
98
|
-
deno: [1, 0, 0],
|
|
99
|
-
node: [4, 0, 0],
|
|
100
|
-
},
|
|
101
|
-
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt#browser_compatibility
|
|
102
|
-
[Feature.BigInt]: {
|
|
103
|
-
es: [2020, 0, 0],
|
|
104
|
-
chrome: [67, 0, 0],
|
|
105
|
-
edge: [79, 0, 0],
|
|
106
|
-
firefox: [68, 0, 0],
|
|
107
|
-
opera: [54, 0, 0],
|
|
108
|
-
safari: [14, 0, 0],
|
|
109
|
-
ios: [14, 0, 0],
|
|
110
|
-
samsung: [9, 0, 0],
|
|
111
|
-
deno: [1, 0, 0],
|
|
112
|
-
node: [10, 4, 0],
|
|
113
|
-
},
|
|
114
|
-
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#browser_compatibility
|
|
115
|
-
[Feature.Map]: {
|
|
116
|
-
es: [6, 0, 0],
|
|
117
|
-
chrome: [38, 0, 0],
|
|
118
|
-
edge: [12, 0, 0],
|
|
119
|
-
firefox: [13, 0, 0],
|
|
120
|
-
opera: [25, 0, 0],
|
|
121
|
-
safari: [8, 0, 0],
|
|
122
|
-
ios: [8, 0, 0],
|
|
123
|
-
samsung: [3, 0, 0],
|
|
124
|
-
deno: [1, 0, 0],
|
|
125
|
-
node: [0, 12, 0],
|
|
126
|
-
},
|
|
127
|
-
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Method_definitions#browser_compatibility
|
|
128
|
-
[Feature.MethodShorthand]: {
|
|
129
|
-
es: [6, 0, 0],
|
|
130
|
-
chrome: [39, 0, 0],
|
|
131
|
-
edge: [12, 0, 0],
|
|
132
|
-
firefox: [34, 0, 0],
|
|
133
|
-
opera: [26, 0, 0],
|
|
134
|
-
safari: [9, 0, 0],
|
|
135
|
-
ios: [9, 0, 0],
|
|
136
|
-
samsung: [4, 0, 0],
|
|
137
|
-
deno: [1, 0, 0],
|
|
138
|
-
node: [4, 0, 0],
|
|
139
|
-
},
|
|
140
|
-
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign#browser_compatibility
|
|
141
|
-
[Feature.ObjectAssign]: {
|
|
142
|
-
es: [6, 0, 0],
|
|
143
|
-
chrome: [45, 0, 0],
|
|
144
|
-
edge: [12, 0, 0],
|
|
145
|
-
firefox: [34, 0, 0],
|
|
146
|
-
opera: [32, 0, 0],
|
|
147
|
-
safari: [9, 0, 0],
|
|
148
|
-
ios: [9, 0, 0],
|
|
149
|
-
samsung: [5, 0, 0],
|
|
150
|
-
deno: [1, 0, 0],
|
|
151
|
-
node: [4, 0, 0],
|
|
152
|
-
},
|
|
153
|
-
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise#browser_compatibility
|
|
154
|
-
[Feature.Promise]: {
|
|
155
|
-
es: [6, 0, 0],
|
|
156
|
-
chrome: [32, 0, 0],
|
|
157
|
-
edge: [12, 0, 0],
|
|
158
|
-
firefox: [29, 0, 0],
|
|
159
|
-
opera: [19, 0, 0],
|
|
160
|
-
safari: [8, 0, 0],
|
|
161
|
-
ios: [8, 0, 0],
|
|
162
|
-
samsung: [2, 0, 0],
|
|
163
|
-
deno: [1, 0, 0],
|
|
164
|
-
node: [0, 12, 0],
|
|
165
|
-
},
|
|
166
|
-
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set#browser_compatibility
|
|
167
|
-
[Feature.Set]: {
|
|
168
|
-
es: [6, 0, 0],
|
|
169
|
-
chrome: [38, 0, 0],
|
|
170
|
-
edge: [12, 0, 0],
|
|
171
|
-
firefox: [13, 0, 0],
|
|
172
|
-
opera: [25, 0, 0],
|
|
173
|
-
safari: [8, 0, 0],
|
|
174
|
-
ios: [8, 0, 0],
|
|
175
|
-
samsung: [3, 0, 0],
|
|
176
|
-
deno: [1, 0, 0],
|
|
177
|
-
node: [0, 12, 0],
|
|
178
|
-
},
|
|
179
|
-
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/iterator#browser_compatibility
|
|
180
|
-
[Feature.SymbolIterator]: {
|
|
181
|
-
es: [6, 0, 0],
|
|
182
|
-
chrome: [43, 0, 0],
|
|
183
|
-
edge: [12, 0, 0],
|
|
184
|
-
firefox: [36, 0, 0],
|
|
185
|
-
opera: [30, 0, 0],
|
|
186
|
-
safari: [10, 0, 0],
|
|
187
|
-
ios: [10, 0, 0],
|
|
188
|
-
samsung: [4, 0, 0],
|
|
189
|
-
deno: [1, 0, 0],
|
|
190
|
-
node: [0, 12, 0],
|
|
191
|
-
},
|
|
192
|
-
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray#browser_compatibility
|
|
193
|
-
[Feature.TypedArray]: {
|
|
194
|
-
es: [6, 0, 0],
|
|
195
|
-
chrome: [7, 0, 0],
|
|
196
|
-
edge: [12, 0, 0],
|
|
197
|
-
firefox: [4, 0, 0],
|
|
198
|
-
opera: [11, 6, 0],
|
|
199
|
-
safari: [5, 1, 0],
|
|
200
|
-
ios: [4, 2, 0],
|
|
201
|
-
samsung: [1, 0, 0],
|
|
202
|
-
deno: [1, 0, 0],
|
|
203
|
-
node: [0, 10, 0],
|
|
204
|
-
},
|
|
205
|
-
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt64Array#browser_compatibility
|
|
206
|
-
[Feature.BigIntTypedArray]: {
|
|
207
|
-
es: [2020, 0, 0],
|
|
208
|
-
chrome: [67, 0, 0],
|
|
209
|
-
edge: [79, 0, 0],
|
|
210
|
-
firefox: [68, 0, 0],
|
|
211
|
-
opera: [54, 6, 0],
|
|
212
|
-
safari: [15, 1, 0],
|
|
213
|
-
ios: [15, 2, 0],
|
|
214
|
-
samsung: [9, 0, 0],
|
|
215
|
-
deno: [1, 0, 0],
|
|
216
|
-
node: [10, 4, 0],
|
|
217
|
-
},
|
|
218
|
-
};
|
|
219
|
-
|
|
220
|
-
const TARGET_REGEX = /^(es|chrome|edge|safari|firefox|opera|ios|samsung|deno|node)([0-9]+(\.[0-9]+(\.[0-9]+)?)?)$/i;
|
|
221
|
-
|
|
222
|
-
export type Target = [platform: Platform, version: Version];
|
|
223
|
-
|
|
224
|
-
function parseTarget(target: string): Target {
|
|
225
|
-
const result = TARGET_REGEX.exec(target);
|
|
226
|
-
assert(result, `Invalid target "${target}"`);
|
|
227
|
-
const [, platform, version] = result;
|
|
228
|
-
const [major, minor = '0', patch = '0'] = version.split('.');
|
|
229
|
-
return [platform as Platform, [Number(major), Number(minor), Number(patch)]];
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
function getTargetVersions(targets: string | string[]): Target[] {
|
|
233
|
-
if (Array.isArray(targets)) {
|
|
234
|
-
const versions: Target[] = [];
|
|
235
|
-
for (const target of targets) {
|
|
236
|
-
versions.push(parseTarget(target));
|
|
237
|
-
}
|
|
238
|
-
return versions;
|
|
239
|
-
}
|
|
240
|
-
return [parseTarget(targets)];
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
export function parseTargets(targets: string | string[]): number {
|
|
244
|
-
const parsed = getTargetVersions(targets);
|
|
245
|
-
let flags = 0;
|
|
246
|
-
|
|
247
|
-
for (const key in VERSION_TABLE) {
|
|
248
|
-
const base = VERSION_TABLE[key as unknown as Feature];
|
|
249
|
-
let flag = true;
|
|
250
|
-
for (const [platform, version] of parsed) {
|
|
251
|
-
const baseVersion = base[platform];
|
|
252
|
-
flag = flag && !!baseVersion && (compareVersion(baseVersion, version) <= 0);
|
|
253
|
-
}
|
|
254
|
-
if (flag) {
|
|
255
|
-
flags |= Number(key);
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
return flags;
|
|
260
|
-
}
|
|
24
|
+
export const ALL_ENABLED = 0x1FFF;
|