vestjs-runtime 1.2.3 → 1.2.4
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/dist/cjs/IsolateSerializer.development.js +16 -156
- package/dist/cjs/IsolateSerializer.development.js.map +1 -1
- package/dist/cjs/IsolateSerializer.production.js +1 -1
- package/dist/cjs/IsolateSerializer.production.js.map +1 -1
- package/dist/cjs/test-utils.development.js +2 -40
- package/dist/cjs/test-utils.development.js.map +1 -1
- package/dist/cjs/test-utils.production.js +1 -1
- package/dist/cjs/test-utils.production.js.map +1 -1
- package/dist/cjs/vestjs-runtime.development.js +16 -155
- package/dist/cjs/vestjs-runtime.development.js.map +1 -1
- package/dist/cjs/vestjs-runtime.production.js +1 -1
- package/dist/cjs/vestjs-runtime.production.js.map +1 -1
- package/dist/es/IsolateSerializer.development.js +18 -157
- package/dist/es/IsolateSerializer.development.js.map +1 -1
- package/dist/es/IsolateSerializer.production.js +1 -1
- package/dist/es/IsolateSerializer.production.js.map +1 -1
- package/dist/es/test-utils.development.js +2 -40
- package/dist/es/test-utils.development.js.map +1 -1
- package/dist/es/test-utils.production.js +1 -1
- package/dist/es/test-utils.production.js.map +1 -1
- package/dist/es/vestjs-runtime.development.js +17 -156
- package/dist/es/vestjs-runtime.development.js.map +1 -1
- package/dist/es/vestjs-runtime.production.js +1 -1
- package/dist/es/vestjs-runtime.production.js.map +1 -1
- package/dist/umd/IsolateSerializer.development.js +19 -160
- package/dist/umd/IsolateSerializer.development.js.map +1 -1
- package/dist/umd/IsolateSerializer.production.js +1 -1
- package/dist/umd/IsolateSerializer.production.js.map +1 -1
- package/dist/umd/test-utils.development.js +6 -42
- package/dist/umd/test-utils.development.js.map +1 -1
- package/dist/umd/test-utils.production.js +1 -1
- package/dist/umd/test-utils.production.js.map +1 -1
- package/dist/umd/vestjs-runtime.development.js +19 -159
- package/dist/umd/vestjs-runtime.development.js.map +1 -1
- package/dist/umd/vestjs-runtime.production.js +1 -1
- package/dist/umd/vestjs-runtime.production.js.map +1 -1
- package/package.json +3 -3
- package/types/IsolateSerializer.d.ts +5 -17
- package/types/IsolateSerializer.d.ts.map +1 -1
- package/types/vestjs-runtime.d.ts +5 -84
- package/types/vestjs-runtime.d.ts.map +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var vestUtils = require('vest-utils');
|
|
4
|
+
var minifyObject = require('vest-utils/minifyObject');
|
|
4
5
|
|
|
5
6
|
var ErrorStrings;
|
|
6
7
|
(function (ErrorStrings) {
|
|
@@ -22,47 +23,11 @@ var IsolateKeys;
|
|
|
22
23
|
IsolateKeys["AbortController"] = "abortController";
|
|
23
24
|
IsolateKeys["Children"] = "children";
|
|
24
25
|
})(IsolateKeys || (IsolateKeys = {}));
|
|
25
|
-
|
|
26
|
-
(function (MinifiedKeys) {
|
|
27
|
-
MinifiedKeys["Type"] = "$";
|
|
28
|
-
MinifiedKeys["Keys"] = "Ks";
|
|
29
|
-
MinifiedKeys["Key"] = "ky";
|
|
30
|
-
MinifiedKeys["Parent"] = "P";
|
|
31
|
-
MinifiedKeys["Data"] = "D";
|
|
32
|
-
MinifiedKeys["AllowReorder"] = "AR";
|
|
33
|
-
MinifiedKeys["Status"] = "S";
|
|
34
|
-
MinifiedKeys["Children"] = "C";
|
|
35
|
-
})(MinifiedKeys || (MinifiedKeys = {}));
|
|
36
|
-
const KeyToMinified = {
|
|
37
|
-
[IsolateKeys.Type]: MinifiedKeys.Type,
|
|
38
|
-
[IsolateKeys.Keys]: MinifiedKeys.Keys,
|
|
39
|
-
[IsolateKeys.Parent]: MinifiedKeys.Parent,
|
|
40
|
-
[IsolateKeys.Data]: MinifiedKeys.Data,
|
|
41
|
-
[IsolateKeys.Key]: MinifiedKeys.Key,
|
|
42
|
-
[IsolateKeys.AllowReorder]: MinifiedKeys.AllowReorder,
|
|
43
|
-
[IsolateKeys.Status]: MinifiedKeys.Status,
|
|
44
|
-
[IsolateKeys.Children]: MinifiedKeys.Children,
|
|
45
|
-
};
|
|
46
|
-
// This const is an object that looks like this:
|
|
47
|
-
// {
|
|
48
|
-
// '$': '$type',
|
|
49
|
-
// 'K': 'keys',
|
|
50
|
-
// 'P': 'parent',
|
|
51
|
-
// ...
|
|
52
|
-
// }
|
|
53
|
-
const MinifiedToKey = invertKeyMap(KeyToMinified);
|
|
54
|
-
function invertKeyMap(miniMap = {}) {
|
|
55
|
-
return Object.entries(miniMap).reduce((acc, [key, minified]) => vestUtils.assign(acc, {
|
|
56
|
-
[minified]: key,
|
|
57
|
-
}), {});
|
|
58
|
-
}
|
|
59
|
-
const ExcludedFromDump = [
|
|
26
|
+
const ExcludedFromDump = new Set([
|
|
60
27
|
IsolateKeys.AbortController,
|
|
61
28
|
IsolateKeys.Parent,
|
|
62
29
|
IsolateKeys.Keys,
|
|
63
|
-
|
|
64
|
-
IsolateKeys.Data,
|
|
65
|
-
];
|
|
30
|
+
]);
|
|
66
31
|
|
|
67
32
|
class IsolateMutator {
|
|
68
33
|
static setParent(isolate, parent) {
|
|
@@ -114,50 +79,20 @@ class IsolateMutator {
|
|
|
114
79
|
|
|
115
80
|
class IsolateSerializer {
|
|
116
81
|
// eslint-disable-next-line max-statements, complexity, max-lines-per-function
|
|
117
|
-
static deserialize(node
|
|
118
|
-
var _a;
|
|
119
|
-
// the assumption is that the tree is built correctly,
|
|
120
|
-
// but the children are missing the parent property to
|
|
121
|
-
// avoid circular references during serialization.
|
|
122
|
-
// in the same way, the parents are missing the `keys` property
|
|
123
|
-
// to avoid circular references during serialization.
|
|
124
|
-
// we need to rebuild the tree and add back the parent property to the children
|
|
125
|
-
// and the keys property to the parents.
|
|
126
|
-
const inverseMinimap = deeplyInvertKeyMap(miniMaps);
|
|
82
|
+
static deserialize(node) {
|
|
127
83
|
// Validate the root object
|
|
128
|
-
const root = vestUtils.isStringValue(node)
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
const queue = [root];
|
|
84
|
+
const root = (vestUtils.isStringValue(node) ? JSON.parse(node) : Object.assign({}, node));
|
|
85
|
+
const expanded = minifyObject.expandObject(...root);
|
|
86
|
+
IsolateSerializer.validateIsolate(expanded);
|
|
87
|
+
const queue = [expanded];
|
|
133
88
|
// Iterate over the queue until it's empty
|
|
134
89
|
while (queue.length) {
|
|
135
90
|
// Get the next item from the queue
|
|
136
91
|
const current = queue.shift();
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
// Iterate over the minified keys
|
|
140
|
-
for (const key in MinifiedToKey) {
|
|
141
|
-
// Get the value for the current key
|
|
142
|
-
const value = current[key];
|
|
143
|
-
// If the value is not null or undefined
|
|
144
|
-
if (vestUtils.isNotNullish(value)) {
|
|
145
|
-
// Get the key to use
|
|
146
|
-
const keyToUse = MinifiedToKey[key];
|
|
147
|
-
// If the key is data, then we may need to transform the keys
|
|
148
|
-
// eslint-disable-next-line max-depth
|
|
149
|
-
if (keyToUse === IsolateKeys.Data) {
|
|
150
|
-
// Transform the keys
|
|
151
|
-
current[keyToUse] = transformKeys(value, (_a = inverseMinimap === null || inverseMinimap === void 0 ? void 0 : inverseMinimap.keys) === null || _a === void 0 ? void 0 : _a.data);
|
|
152
|
-
}
|
|
153
|
-
else {
|
|
154
|
-
// Otherwise, just set the key
|
|
155
|
-
current[keyToUse] = transformValueByKey(keyToUse, value, inverseMinimap);
|
|
156
|
-
}
|
|
157
|
-
// Remove the old key
|
|
158
|
-
delete current[key];
|
|
159
|
-
}
|
|
92
|
+
if (!current) {
|
|
93
|
+
continue;
|
|
160
94
|
}
|
|
95
|
+
const children = current.children;
|
|
161
96
|
// If there are no children, nothing to do.
|
|
162
97
|
if (!children) {
|
|
163
98
|
continue;
|
|
@@ -177,94 +112,19 @@ class IsolateSerializer {
|
|
|
177
112
|
return nextChild;
|
|
178
113
|
});
|
|
179
114
|
}
|
|
180
|
-
return
|
|
115
|
+
return expanded;
|
|
181
116
|
}
|
|
182
|
-
static serialize(isolate
|
|
117
|
+
static serialize(isolate) {
|
|
183
118
|
if (vestUtils.isNullish(isolate)) {
|
|
184
119
|
return '';
|
|
185
120
|
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
static expandChildren(node) {
|
|
189
|
-
return node[MinifiedKeys.Children]
|
|
190
|
-
? [...node[MinifiedKeys.Children]]
|
|
191
|
-
: null;
|
|
121
|
+
const minified = minifyObject.minifyObject(isolate, ExcludedFromDump);
|
|
122
|
+
return JSON.stringify(minified);
|
|
192
123
|
}
|
|
193
124
|
static validateIsolate(node) {
|
|
194
|
-
vestUtils.invariant(vestUtils.hasOwnProperty(node, IsolateKeys.Type)
|
|
195
|
-
vestUtils.hasOwnProperty(node, KeyToMinified[IsolateKeys.Type]), vestUtils.text(ErrorStrings.INVALID_ISOLATE_CANNOT_PARSE));
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
// eslint-disable-next-line max-statements, complexity
|
|
199
|
-
function transformIsolate(isolate, miniMaps) {
|
|
200
|
-
var _a;
|
|
201
|
-
const next = {};
|
|
202
|
-
if (isolate.children) {
|
|
203
|
-
next[MinifiedKeys.Children] = isolate.children.map(isolate => transformIsolate(isolate, miniMaps));
|
|
204
|
-
}
|
|
205
|
-
if (!vestUtils.isEmpty(isolate.data)) {
|
|
206
|
-
next[MinifiedKeys.Data] = transformKeys(isolate.data, (_a = miniMaps === null || miniMaps === void 0 ? void 0 : miniMaps.keys) === null || _a === void 0 ? void 0 : _a.data);
|
|
207
|
-
}
|
|
208
|
-
for (const key in isolate) {
|
|
209
|
-
// Skip keys that should be excluded from the dump.
|
|
210
|
-
// While we're excluding children from the dump, they'll actually remain there
|
|
211
|
-
// due to the fact that we've already transformed them recursively beforehand
|
|
212
|
-
// thus renaming them to the minified key.
|
|
213
|
-
if (isKeyExcluededFromDump(key)) {
|
|
214
|
-
continue;
|
|
215
|
-
}
|
|
216
|
-
const value = isolate[key];
|
|
217
|
-
if (vestUtils.isNullish(value)) {
|
|
218
|
-
continue;
|
|
219
|
-
}
|
|
220
|
-
const keyToUse = minifyKey(key);
|
|
221
|
-
next[keyToUse] = transformValueByKey(key, value, miniMaps);
|
|
222
|
-
}
|
|
223
|
-
return next;
|
|
224
|
-
}
|
|
225
|
-
function isKeyExcluededFromDump(key) {
|
|
226
|
-
return ExcludedFromDump.includes(key);
|
|
227
|
-
}
|
|
228
|
-
function minifyKey(key) {
|
|
229
|
-
var _a;
|
|
230
|
-
return (_a = KeyToMinified[key]) !== null && _a !== void 0 ? _a : key;
|
|
231
|
-
}
|
|
232
|
-
function transformValueByKey(key, value, miniMaps) {
|
|
233
|
-
var _a, _b;
|
|
234
|
-
if (vestUtils.isNullish(value)) {
|
|
235
|
-
return value;
|
|
125
|
+
vestUtils.invariant(vestUtils.hasOwnProperty(node, IsolateKeys.Type), vestUtils.text(ErrorStrings.INVALID_ISOLATE_CANNOT_PARSE));
|
|
236
126
|
}
|
|
237
|
-
const keyMap = (_a = miniMaps === null || miniMaps === void 0 ? void 0 : miniMaps.values) === null || _a === void 0 ? void 0 : _a[key];
|
|
238
|
-
return keyMap ? (_b = keyMap[value]) !== null && _b !== void 0 ? _b : value : value;
|
|
239
|
-
}
|
|
240
|
-
function transformKeys(data, keyMap) {
|
|
241
|
-
var _a;
|
|
242
|
-
const next = {};
|
|
243
|
-
// Loop over each key in the data.
|
|
244
|
-
for (const key in data) {
|
|
245
|
-
// Find the key to use for the next object.
|
|
246
|
-
// If there is no key map, use the original key.
|
|
247
|
-
// If there is a key map, use the key map entry for the current key.
|
|
248
|
-
const keyToUse = (_a = (keyMap ? keyMap[key] : key)) !== null && _a !== void 0 ? _a : key;
|
|
249
|
-
// Add the key and value to the next object.
|
|
250
|
-
next[keyToUse] = data[key];
|
|
251
|
-
}
|
|
252
|
-
// Return the next object.
|
|
253
|
-
return next;
|
|
254
|
-
}
|
|
255
|
-
function deeplyInvertKeyMap(miniMaps = {}) {
|
|
256
|
-
return Object.entries(miniMaps).reduce((acc, [key, value]) => {
|
|
257
|
-
if (typeof value === 'object') {
|
|
258
|
-
return vestUtils.assign(acc, {
|
|
259
|
-
[key]: deeplyInvertKeyMap(value),
|
|
260
|
-
});
|
|
261
|
-
}
|
|
262
|
-
return vestUtils.assign(acc, {
|
|
263
|
-
[value]: key,
|
|
264
|
-
});
|
|
265
|
-
}, {});
|
|
266
127
|
}
|
|
267
128
|
|
|
268
129
|
exports.IsolateSerializer = IsolateSerializer;
|
|
269
|
-
exports.deeplyInvertKeyMap = deeplyInvertKeyMap;
|
|
270
130
|
//# sourceMappingURL=IsolateSerializer.development.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IsolateSerializer.development.js","sources":["../../src/errors/ErrorStrings.ts","../../src/Isolate/IsolateKeys.ts","../../src/Isolate/IsolateMutator.ts","../../src/exports/IsolateSerializer.ts"],"sourcesContent":["export enum ErrorStrings {\n NO_ACTIVE_ISOLATE = 'Not within an active isolate',\n UNABLE_TO_PICK_NEXT_ISOLATE = 'Unable to pick next isolate. This is a bug, please report it to the Vest maintainers.',\n ENCOUNTERED_THE_SAME_KEY_TWICE = `Encountered the same key \"{key}\" twice. This may lead to inconsistent or overriding of results.`,\n INVALID_ISOLATE_CANNOT_PARSE = `Invalid isolate was passed to IsolateSerializer. Cannot proceed.`,\n}\n","import { assign } from 'vest-utils';\n\nexport enum IsolateKeys {\n Type = '$type',\n Keys = 'keys',\n Key = 'key',\n Parent = 'parent',\n Data = 'data',\n AllowReorder = 'allowReorder',\n Status = 'status',\n AbortController = 'abortController',\n Children = 'children',\n}\n\nexport enum MinifiedKeys {\n Type = '$',\n Keys = 'Ks',\n Key = 'ky',\n Parent = 'P',\n Data = 'D',\n AllowReorder = 'AR',\n Status = 'S',\n Children = 'C',\n}\n\nexport const KeyToMinified = {\n [IsolateKeys.Type]: MinifiedKeys.Type,\n [IsolateKeys.Keys]: MinifiedKeys.Keys,\n [IsolateKeys.Parent]: MinifiedKeys.Parent,\n [IsolateKeys.Data]: MinifiedKeys.Data,\n [IsolateKeys.Key]: MinifiedKeys.Key,\n [IsolateKeys.AllowReorder]: MinifiedKeys.AllowReorder,\n [IsolateKeys.Status]: MinifiedKeys.Status,\n [IsolateKeys.Children]: MinifiedKeys.Children,\n};\n\n// This const is an object that looks like this:\n// {\n// '$': '$type',\n// 'K': 'keys',\n// 'P': 'parent',\n// ...\n// }\nexport const MinifiedToKey = invertKeyMap(KeyToMinified);\n\nexport function invertKeyMap(miniMap: Record<string, string> = {}) {\n return Object.entries(miniMap).reduce(\n (acc, [key, minified]) =>\n assign(acc, {\n [minified]: key,\n }),\n {} as Record<string, string>\n );\n}\n\nexport const ExcludedFromDump = [\n IsolateKeys.AbortController,\n IsolateKeys.Parent,\n IsolateKeys.Keys,\n IsolateKeys.Children,\n IsolateKeys.Data,\n];\n","import { Nullable, invariant, isNullish } from 'vest-utils';\n\nimport { TIsolate } from 'Isolate';\n\nexport class IsolateMutator {\n static setParent(isolate: TIsolate, parent: Nullable<TIsolate>): TIsolate {\n isolate.parent = parent;\n return isolate;\n }\n\n static saveOutput(isolate: TIsolate, output: any): TIsolate {\n isolate.output = output;\n return isolate;\n }\n\n static setKey(isolate: TIsolate, key: Nullable<string>): TIsolate {\n isolate.key = key;\n return isolate;\n }\n\n static addChild(isolate: TIsolate, child: TIsolate): void {\n invariant(isolate);\n\n isolate.children = isolate.children ?? [];\n\n isolate.children.push(child);\n IsolateMutator.setParent(child, isolate);\n }\n\n static removeChild(isolate: TIsolate, node: TIsolate): void {\n isolate.children =\n isolate.children?.filter(child => child !== node) ?? null;\n }\n\n static addChildKey(isolate: TIsolate, key: string, node: TIsolate): void {\n invariant(isolate);\n\n isolate.keys = isolate.keys ?? {};\n\n isolate.keys[key] = node;\n }\n\n static slice(isolate: TIsolate, at: number): void {\n if (isNullish(isolate.children)) {\n return;\n }\n isolate.children.length = at;\n }\n\n static setData(isolate: TIsolate, data: any): void {\n isolate.data = data;\n }\n\n static abort(isolate: TIsolate, reason?: string): void {\n if (isNullish(isolate.abortController)) {\n return;\n }\n isolate.abortController.abort(reason);\n }\n}\n","import { ErrorStrings } from 'ErrorStrings';\nimport {\n Maybe,\n Nullable,\n assign,\n hasOwnProperty,\n invariant,\n isEmpty,\n isNotNullish,\n isNullish,\n isStringValue,\n text,\n} from 'vest-utils';\n\nimport { TIsolate } from 'Isolate';\nimport {\n ExcludedFromDump,\n IsolateKeys,\n KeyToMinified,\n MinifiedKeys,\n MinifiedToKey,\n} from 'IsolateKeys';\nimport { IsolateMutator } from 'IsolateMutator';\n\nexport class IsolateSerializer {\n // eslint-disable-next-line max-statements, complexity, max-lines-per-function\n static deserialize(\n node: Record<string, any> | TIsolate | string,\n miniMaps: Maybe<MiniMaps>\n ): TIsolate {\n // the assumption is that the tree is built correctly,\n // but the children are missing the parent property to\n // avoid circular references during serialization.\n // in the same way, the parents are missing the `keys` property\n // to avoid circular references during serialization.\n // we need to rebuild the tree and add back the parent property to the children\n // and the keys property to the parents.\n const inverseMinimap = deeplyInvertKeyMap(miniMaps);\n\n // Validate the root object\n const root = isStringValue(node)\n ? JSON.parse(node)\n : ({ ...node } as TIsolate);\n\n IsolateSerializer.validateIsolate(root);\n\n const queue = [root];\n\n // Iterate over the queue until it's empty\n while (queue.length) {\n // Get the next item from the queue\n const current = queue.shift();\n\n // Get the children of the current item\n const children = IsolateSerializer.expandChildren(current);\n\n // Iterate over the minified keys\n for (const key in MinifiedToKey) {\n // Get the value for the current key\n const value = current[key];\n\n // If the value is not null or undefined\n if (isNotNullish(value)) {\n // Get the key to use\n const keyToUse = MinifiedToKey[key];\n\n // If the key is data, then we may need to transform the keys\n // eslint-disable-next-line max-depth\n if (keyToUse === IsolateKeys.Data) {\n // Transform the keys\n current[keyToUse] = transformKeys(\n value,\n inverseMinimap?.keys?.data\n );\n } else {\n // Otherwise, just set the key\n current[keyToUse] = transformValueByKey(\n keyToUse,\n value,\n inverseMinimap\n );\n }\n\n // Remove the old key\n delete current[key];\n }\n }\n\n // If there are no children, nothing to do.\n if (!children) {\n continue;\n }\n\n // Copy the children and set their parent to the current node.\n current.children = children.map(child => {\n const nextChild = { ...child };\n\n IsolateMutator.setParent(nextChild, current);\n queue.push(nextChild);\n\n // If the child has a key, add it to the parent's keys.\n const key = nextChild.key;\n\n if (key) {\n current.keys = current.keys ?? {};\n current.keys[key] = nextChild;\n }\n\n return nextChild;\n });\n }\n\n return root as TIsolate;\n }\n\n static serialize(\n isolate: Nullable<TIsolate>,\n miniMaps: Maybe<MiniMaps>\n ): string {\n if (isNullish(isolate)) {\n return '';\n }\n\n return JSON.stringify(transformIsolate(isolate, miniMaps));\n }\n\n static expandChildren(node: Record<string, any>): Nullable<TIsolate[]> {\n return node[MinifiedKeys.Children]\n ? [...node[MinifiedKeys.Children]]\n : null;\n }\n\n static validateIsolate(node: Record<string, any> | TIsolate): void {\n invariant(\n hasOwnProperty(node, IsolateKeys.Type) ||\n hasOwnProperty(node, KeyToMinified[IsolateKeys.Type]),\n text(ErrorStrings.INVALID_ISOLATE_CANNOT_PARSE)\n );\n }\n}\n\n// eslint-disable-next-line max-statements, complexity\nfunction transformIsolate(\n isolate: TIsolate,\n miniMaps: Maybe<MiniMaps>\n): Record<string, any> {\n const next: Record<string, any> = {};\n\n if (isolate.children) {\n next[MinifiedKeys.Children] = isolate.children.map(isolate =>\n transformIsolate(isolate, miniMaps)\n );\n }\n\n if (!isEmpty(isolate.data)) {\n next[MinifiedKeys.Data] = transformKeys(isolate.data, miniMaps?.keys?.data);\n }\n\n for (const key in isolate) {\n // Skip keys that should be excluded from the dump.\n // While we're excluding children from the dump, they'll actually remain there\n // due to the fact that we've already transformed them recursively beforehand\n // thus renaming them to the minified key.\n if (isKeyExcluededFromDump(key)) {\n continue;\n }\n const value = isolate[key as keyof TIsolate];\n\n if (isNullish(value)) {\n continue;\n }\n\n const keyToUse = minifyKey(key);\n next[keyToUse] = transformValueByKey(key, value, miniMaps);\n }\n\n return next;\n}\n\nfunction isKeyExcluededFromDump(key: string): boolean {\n return ExcludedFromDump.includes(key as IsolateKeys);\n}\n\nfunction minifyKey(key: string): string {\n return KeyToMinified[key as keyof typeof KeyToMinified] ?? key;\n}\n\nfunction transformValueByKey(\n key: string,\n value: any,\n miniMaps: Maybe<MiniMaps>\n): any {\n if (isNullish(value)) {\n return value;\n }\n\n const keyMap = miniMaps?.values?.[key as keyof MiniMaps['values']];\n\n return keyMap ? keyMap[value] ?? value : value;\n}\n\nfunction transformKeys(\n data: Record<string, any>,\n keyMap: Maybe<MiniMap>\n): Record<string, any> {\n const next: Record<string, any> = {};\n\n // Loop over each key in the data.\n for (const key in data) {\n // Find the key to use for the next object.\n // If there is no key map, use the original key.\n // If there is a key map, use the key map entry for the current key.\n const keyToUse = (keyMap ? keyMap[key] : key) ?? key;\n\n // Add the key and value to the next object.\n next[keyToUse] = data[key];\n }\n\n // Return the next object.\n return next;\n}\n\ntype MiniMap = Record<string, string>;\n\ntype MiniMaps = Partial<{\n keys: Partial<{\n [IsolateKeys.Data]: MiniMap;\n }>;\n values: Partial<{\n [IsolateKeys.Status]: MiniMap;\n [IsolateKeys.Type]: MiniMap;\n }>;\n}>;\n\nexport function deeplyInvertKeyMap(miniMaps: Maybe<MiniMaps> = {}): MiniMaps {\n return Object.entries(miniMaps).reduce((acc, [key, value]) => {\n if (typeof value === 'object') {\n return assign(acc, {\n [key]: deeplyInvertKeyMap(value as MiniMaps),\n });\n }\n return assign(acc, {\n [value]: key,\n });\n }, {} as MiniMaps);\n}\n"],"names":["assign","invariant","isNullish","isStringValue","isNotNullish","hasOwnProperty","text","isEmpty"],"mappings":";;;;AAAA,IAAY,YAKX,CAAA;AALD,CAAA,UAAY,YAAY,EAAA;AACtB,IAAA,YAAA,CAAA,mBAAA,CAAA,GAAA,8BAAkD,CAAA;AAClD,IAAA,YAAA,CAAA,6BAAA,CAAA,GAAA,uFAAqH,CAAA;AACrH,IAAA,YAAA,CAAA,gCAAA,CAAA,GAAA,mGAAkI,CAAA;AAClI,IAAA,YAAA,CAAA,8BAAA,CAAA,GAAA,kEAAiG,CAAA;AACnG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OA,gBAAM,CAAC,GAAG,EAAE;YACjB,CAAC,KAAK,GAAG,GAAG;AACb,SAAA,CAAC,CAAC;KACJ,EAAE,EAAc,CAAC,CAAC;AACrB;;;;;"}
|
|
1
|
+
{"version":3,"file":"IsolateSerializer.development.js","sources":["../../src/errors/ErrorStrings.ts","../../src/Isolate/IsolateKeys.ts","../../src/Isolate/IsolateMutator.ts","../../src/exports/IsolateSerializer.ts"],"sourcesContent":["export enum ErrorStrings {\n NO_ACTIVE_ISOLATE = 'Not within an active isolate',\n UNABLE_TO_PICK_NEXT_ISOLATE = 'Unable to pick next isolate. This is a bug, please report it to the Vest maintainers.',\n ENCOUNTERED_THE_SAME_KEY_TWICE = `Encountered the same key \"{key}\" twice. This may lead to inconsistent or overriding of results.`,\n INVALID_ISOLATE_CANNOT_PARSE = `Invalid isolate was passed to IsolateSerializer. Cannot proceed.`,\n}\n","export enum IsolateKeys {\n Type = '$type',\n Keys = 'keys',\n Key = 'key',\n Parent = 'parent',\n Data = 'data',\n AllowReorder = 'allowReorder',\n Status = 'status',\n AbortController = 'abortController',\n Children = 'children',\n}\n\nexport const ExcludedFromDump = new Set([\n IsolateKeys.AbortController,\n IsolateKeys.Parent,\n IsolateKeys.Keys,\n]);\n","import { Nullable, invariant, isNullish } from 'vest-utils';\n\nimport { TIsolate } from 'Isolate';\n\nexport class IsolateMutator {\n static setParent(isolate: TIsolate, parent: Nullable<TIsolate>): TIsolate {\n isolate.parent = parent;\n return isolate;\n }\n\n static saveOutput(isolate: TIsolate, output: any): TIsolate {\n isolate.output = output;\n return isolate;\n }\n\n static setKey(isolate: TIsolate, key: Nullable<string>): TIsolate {\n isolate.key = key;\n return isolate;\n }\n\n static addChild(isolate: TIsolate, child: TIsolate): void {\n invariant(isolate);\n\n isolate.children = isolate.children ?? [];\n\n isolate.children.push(child);\n IsolateMutator.setParent(child, isolate);\n }\n\n static removeChild(isolate: TIsolate, node: TIsolate): void {\n isolate.children =\n isolate.children?.filter(child => child !== node) ?? null;\n }\n\n static addChildKey(isolate: TIsolate, key: string, node: TIsolate): void {\n invariant(isolate);\n\n isolate.keys = isolate.keys ?? {};\n\n isolate.keys[key] = node;\n }\n\n static slice(isolate: TIsolate, at: number): void {\n if (isNullish(isolate.children)) {\n return;\n }\n isolate.children.length = at;\n }\n\n static setData(isolate: TIsolate, data: any): void {\n isolate.data = data;\n }\n\n static abort(isolate: TIsolate, reason?: string): void {\n if (isNullish(isolate.abortController)) {\n return;\n }\n isolate.abortController.abort(reason);\n }\n}\n","import { ErrorStrings } from 'ErrorStrings';\nimport {\n Nullable,\n hasOwnProperty,\n invariant,\n isNullish,\n isStringValue,\n text,\n} from 'vest-utils';\nimport { expandObject, minifyObject } from 'vest-utils/minifyObject';\n\nimport { TIsolate } from 'Isolate';\nimport { ExcludedFromDump, IsolateKeys } from 'IsolateKeys';\nimport { IsolateMutator } from 'IsolateMutator';\n\nexport class IsolateSerializer {\n // eslint-disable-next-line max-statements, complexity, max-lines-per-function\n static deserialize(node: Record<string, any> | TIsolate | string): TIsolate {\n // Validate the root object\n const root = (\n isStringValue(node) ? JSON.parse(node) : ({ ...node } as TIsolate)\n ) as [any, any];\n\n const expanded = expandObject(...root);\n\n IsolateSerializer.validateIsolate(expanded);\n\n const queue = [expanded];\n\n // Iterate over the queue until it's empty\n while (queue.length) {\n // Get the next item from the queue\n const current = queue.shift();\n\n if (!current) {\n continue;\n }\n\n const children = current.children;\n\n // If there are no children, nothing to do.\n if (!children) {\n continue;\n }\n\n // Copy the children and set their parent to the current node.\n current.children = children.map(child => {\n const nextChild = { ...child };\n\n IsolateMutator.setParent(nextChild, current);\n queue.push(nextChild);\n\n // If the child has a key, add it to the parent's keys.\n const key = nextChild.key;\n\n if (key) {\n current.keys = current.keys ?? {};\n current.keys[key] = nextChild;\n }\n\n return nextChild;\n });\n }\n\n return expanded;\n }\n\n static serialize(isolate: Nullable<TIsolate>): string {\n if (isNullish(isolate)) {\n return '';\n }\n\n const minified = minifyObject(isolate, ExcludedFromDump);\n\n return JSON.stringify(minified);\n }\n\n static validateIsolate(\n node: Record<string, any> | TIsolate,\n ): asserts node is TIsolate {\n invariant(\n hasOwnProperty(node, IsolateKeys.Type),\n text(ErrorStrings.INVALID_ISOLATE_CANNOT_PARSE),\n );\n }\n}\n"],"names":["invariant","isNullish","isStringValue","expandObject","minifyObject","hasOwnProperty","text"],"mappings":";;;;;AAAA,IAAY,YAKX,CAAA;AALD,CAAA,UAAY,YAAY,EAAA;AACtB,IAAA,YAAA,CAAA,mBAAA,CAAA,GAAA,8BAAkD,CAAA;AAClD,IAAA,YAAA,CAAA,6BAAA,CAAA,GAAA,uFAAqH,CAAA;AACrH,IAAA,YAAA,CAAA,gCAAA,CAAA,GAAA,mGAAkI,CAAA;AAClI,IAAA,YAAA,CAAA,8BAAA,CAAA,GAAA,kEAAiG,CAAA;AACnG,CAAC,EALW,YAAY,KAAZ,YAAY,GAKvB,EAAA,CAAA,CAAA;;ACLD,IAAY,WAUX,CAAA;AAVD,CAAA,UAAY,WAAW,EAAA;AACrB,IAAA,WAAA,CAAA,MAAA,CAAA,GAAA,OAAc,CAAA;AACd,IAAA,WAAA,CAAA,MAAA,CAAA,GAAA,MAAa,CAAA;AACb,IAAA,WAAA,CAAA,KAAA,CAAA,GAAA,KAAW,CAAA;AACX,IAAA,WAAA,CAAA,QAAA,CAAA,GAAA,QAAiB,CAAA;AACjB,IAAA,WAAA,CAAA,MAAA,CAAA,GAAA,MAAa,CAAA;AACb,IAAA,WAAA,CAAA,cAAA,CAAA,GAAA,cAA6B,CAAA;AAC7B,IAAA,WAAA,CAAA,QAAA,CAAA,GAAA,QAAiB,CAAA;AACjB,IAAA,WAAA,CAAA,iBAAA,CAAA,GAAA,iBAAmC,CAAA;AACnC,IAAA,WAAA,CAAA,UAAA,CAAA,GAAA,UAAqB,CAAA;AACvB,CAAC,EAVW,WAAW,KAAX,WAAW,GAUtB,EAAA,CAAA,CAAA,CAAA;AAEM,MAAM,gBAAgB,GAAG,IAAI,GA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AgB,CAAC,CAAC;AAEzD,QAAA,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;KACjC;IAED,OAAO,eAAe,CACpB,IAAoC,EAAA;AAEpC,QAAAJ,mBAAS,CACPK,wBAAc,CAAC,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC,EACtCC,cAAI,CAAC,YAAY,CAAC,4BAA4B,CAAC,CAChD,CAAC;KACH;AACF;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var t,e,
|
|
1
|
+
"use strict";var t,e,i=require("vest-utils"),r=require("vest-utils/minifyObject");!function(t){t.NO_ACTIVE_ISOLATE="Not within an active isolate",t.UNABLE_TO_PICK_NEXT_ISOLATE="Unable to pick next isolate. This is a bug, please report it to the Vest maintainers.",t.ENCOUNTERED_THE_SAME_KEY_TWICE='Encountered the same key "{key}" twice. This may lead to inconsistent or overriding of results.',t.INVALID_ISOLATE_CANNOT_PARSE="Invalid isolate was passed to IsolateSerializer. Cannot proceed."}(t||(t={})),function(t){t.Type="$type",t.Keys="keys",t.Key="key",t.Parent="parent",t.Data="data",t.AllowReorder="allowReorder",t.Status="status",t.AbortController="abortController",t.Children="children"}(e||(e={}));const s=new Set([e.AbortController,e.Parent,e.Keys]);class a{static setParent(t,e){return t.parent=e,t}static saveOutput(t,e){return t.output=e,t}static setKey(t,e){return t.key=e,t}static addChild(t,e){var r;i.invariant(t),t.children=null!==(r=t.children)&&void 0!==r?r:[],t.children.push(e),a.setParent(e,t)}static removeChild(t,e){var i,r;t.children=null!==(r=null===(i=t.children)||void 0===i?void 0:i.filter((t=>t!==e)))&&void 0!==r?r:null}static addChildKey(t,e,r){var s;i.invariant(t),t.keys=null!==(s=t.keys)&&void 0!==s?s:{},t.keys[e]=r}static slice(t,e){i.isNullish(t.children)||(t.children.length=e)}static setData(t,e){t.data=e}static abort(t,e){i.isNullish(t.abortController)||t.abortController.abort(e)}}class n{static deserialize(t){const e=i.isStringValue(t)?JSON.parse(t):Object.assign({},t),s=r.expandObject(...e);n.validateIsolate(s);const l=[s];for(;l.length;){const t=l.shift();if(!t)continue;const e=t.children;e&&(t.children=e.map((e=>{var i;const r=Object.assign({},e);a.setParent(r,t),l.push(r);const s=r.key;return s&&(t.keys=null!==(i=t.keys)&&void 0!==i?i:{},t.keys[s]=r),r})))}return s}static serialize(t){if(i.isNullish(t))return"";const e=r.minifyObject(t,s);return JSON.stringify(e)}static validateIsolate(r){i.invariant(i.hasOwnProperty(r,e.Type),i.text(t.INVALID_ISOLATE_CANNOT_PARSE))}}exports.IsolateSerializer=n;
|
|
2
2
|
//# sourceMappingURL=IsolateSerializer.production.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IsolateSerializer.production.js","sources":["../../src/errors/ErrorStrings.ts","../../src/Isolate/IsolateKeys.ts","../../src/Isolate/IsolateMutator.ts","../../src/exports/IsolateSerializer.ts"],"sourcesContent":["export enum ErrorStrings {\n NO_ACTIVE_ISOLATE = 'Not within an active isolate',\n UNABLE_TO_PICK_NEXT_ISOLATE = 'Unable to pick next isolate. This is a bug, please report it to the Vest maintainers.',\n ENCOUNTERED_THE_SAME_KEY_TWICE = `Encountered the same key \"{key}\" twice. This may lead to inconsistent or overriding of results.`,\n INVALID_ISOLATE_CANNOT_PARSE = `Invalid isolate was passed to IsolateSerializer. Cannot proceed.`,\n}\n","import { assign } from 'vest-utils';\n\nexport enum IsolateKeys {\n Type = '$type',\n Keys = 'keys',\n Key = 'key',\n Parent = 'parent',\n Data = 'data',\n AllowReorder = 'allowReorder',\n Status = 'status',\n AbortController = 'abortController',\n Children = 'children',\n}\n\nexport enum MinifiedKeys {\n Type = '$',\n Keys = 'Ks',\n Key = 'ky',\n Parent = 'P',\n Data = 'D',\n AllowReorder = 'AR',\n Status = 'S',\n Children = 'C',\n}\n\nexport const KeyToMinified = {\n [IsolateKeys.Type]: MinifiedKeys.Type,\n [IsolateKeys.Keys]: MinifiedKeys.Keys,\n [IsolateKeys.Parent]: MinifiedKeys.Parent,\n [IsolateKeys.Data]: MinifiedKeys.Data,\n [IsolateKeys.Key]: MinifiedKeys.Key,\n [IsolateKeys.AllowReorder]: MinifiedKeys.AllowReorder,\n [IsolateKeys.Status]: MinifiedKeys.Status,\n [IsolateKeys.Children]: MinifiedKeys.Children,\n};\n\n// This const is an object that looks like this:\n// {\n// '$': '$type',\n// 'K': 'keys',\n// 'P': 'parent',\n// ...\n// }\nexport const MinifiedToKey = invertKeyMap(KeyToMinified);\n\nexport function invertKeyMap(miniMap: Record<string, string> = {}) {\n return Object.entries(miniMap).reduce(\n (acc, [key, minified]) =>\n assign(acc, {\n [minified]: key,\n }),\n {} as Record<string, string>\n );\n}\n\nexport const ExcludedFromDump = [\n IsolateKeys.AbortController,\n IsolateKeys.Parent,\n IsolateKeys.Keys,\n IsolateKeys.Children,\n IsolateKeys.Data,\n];\n","import { Nullable, invariant, isNullish } from 'vest-utils';\n\nimport { TIsolate } from 'Isolate';\n\nexport class IsolateMutator {\n static setParent(isolate: TIsolate, parent: Nullable<TIsolate>): TIsolate {\n isolate.parent = parent;\n return isolate;\n }\n\n static saveOutput(isolate: TIsolate, output: any): TIsolate {\n isolate.output = output;\n return isolate;\n }\n\n static setKey(isolate: TIsolate, key: Nullable<string>): TIsolate {\n isolate.key = key;\n return isolate;\n }\n\n static addChild(isolate: TIsolate, child: TIsolate): void {\n invariant(isolate);\n\n isolate.children = isolate.children ?? [];\n\n isolate.children.push(child);\n IsolateMutator.setParent(child, isolate);\n }\n\n static removeChild(isolate: TIsolate, node: TIsolate): void {\n isolate.children =\n isolate.children?.filter(child => child !== node) ?? null;\n }\n\n static addChildKey(isolate: TIsolate, key: string, node: TIsolate): void {\n invariant(isolate);\n\n isolate.keys = isolate.keys ?? {};\n\n isolate.keys[key] = node;\n }\n\n static slice(isolate: TIsolate, at: number): void {\n if (isNullish(isolate.children)) {\n return;\n }\n isolate.children.length = at;\n }\n\n static setData(isolate: TIsolate, data: any): void {\n isolate.data = data;\n }\n\n static abort(isolate: TIsolate, reason?: string): void {\n if (isNullish(isolate.abortController)) {\n return;\n }\n isolate.abortController.abort(reason);\n }\n}\n","import { ErrorStrings } from 'ErrorStrings';\nimport {\n Maybe,\n Nullable,\n assign,\n hasOwnProperty,\n invariant,\n isEmpty,\n isNotNullish,\n isNullish,\n isStringValue,\n text,\n} from 'vest-utils';\n\nimport { TIsolate } from 'Isolate';\nimport {\n ExcludedFromDump,\n IsolateKeys,\n KeyToMinified,\n MinifiedKeys,\n MinifiedToKey,\n} from 'IsolateKeys';\nimport { IsolateMutator } from 'IsolateMutator';\n\nexport class IsolateSerializer {\n // eslint-disable-next-line max-statements, complexity, max-lines-per-function\n static deserialize(\n node: Record<string, any> | TIsolate | string,\n miniMaps: Maybe<MiniMaps>\n ): TIsolate {\n // the assumption is that the tree is built correctly,\n // but the children are missing the parent property to\n // avoid circular references during serialization.\n // in the same way, the parents are missing the `keys` property\n // to avoid circular references during serialization.\n // we need to rebuild the tree and add back the parent property to the children\n // and the keys property to the parents.\n const inverseMinimap = deeplyInvertKeyMap(miniMaps);\n\n // Validate the root object\n const root = isStringValue(node)\n ? JSON.parse(node)\n : ({ ...node } as TIsolate);\n\n IsolateSerializer.validateIsolate(root);\n\n const queue = [root];\n\n // Iterate over the queue until it's empty\n while (queue.length) {\n // Get the next item from the queue\n const current = queue.shift();\n\n // Get the children of the current item\n const children = IsolateSerializer.expandChildren(current);\n\n // Iterate over the minified keys\n for (const key in MinifiedToKey) {\n // Get the value for the current key\n const value = current[key];\n\n // If the value is not null or undefined\n if (isNotNullish(value)) {\n // Get the key to use\n const keyToUse = MinifiedToKey[key];\n\n // If the key is data, then we may need to transform the keys\n // eslint-disable-next-line max-depth\n if (keyToUse === IsolateKeys.Data) {\n // Transform the keys\n current[keyToUse] = transformKeys(\n value,\n inverseMinimap?.keys?.data\n );\n } else {\n // Otherwise, just set the key\n current[keyToUse] = transformValueByKey(\n keyToUse,\n value,\n inverseMinimap\n );\n }\n\n // Remove the old key\n delete current[key];\n }\n }\n\n // If there are no children, nothing to do.\n if (!children) {\n continue;\n }\n\n // Copy the children and set their parent to the current node.\n current.children = children.map(child => {\n const nextChild = { ...child };\n\n IsolateMutator.setParent(nextChild, current);\n queue.push(nextChild);\n\n // If the child has a key, add it to the parent's keys.\n const key = nextChild.key;\n\n if (key) {\n current.keys = current.keys ?? {};\n current.keys[key] = nextChild;\n }\n\n return nextChild;\n });\n }\n\n return root as TIsolate;\n }\n\n static serialize(\n isolate: Nullable<TIsolate>,\n miniMaps: Maybe<MiniMaps>\n ): string {\n if (isNullish(isolate)) {\n return '';\n }\n\n return JSON.stringify(transformIsolate(isolate, miniMaps));\n }\n\n static expandChildren(node: Record<string, any>): Nullable<TIsolate[]> {\n return node[MinifiedKeys.Children]\n ? [...node[MinifiedKeys.Children]]\n : null;\n }\n\n static validateIsolate(node: Record<string, any> | TIsolate): void {\n invariant(\n hasOwnProperty(node, IsolateKeys.Type) ||\n hasOwnProperty(node, KeyToMinified[IsolateKeys.Type]),\n text(ErrorStrings.INVALID_ISOLATE_CANNOT_PARSE)\n );\n }\n}\n\n// eslint-disable-next-line max-statements, complexity\nfunction transformIsolate(\n isolate: TIsolate,\n miniMaps: Maybe<MiniMaps>\n): Record<string, any> {\n const next: Record<string, any> = {};\n\n if (isolate.children) {\n next[MinifiedKeys.Children] = isolate.children.map(isolate =>\n transformIsolate(isolate, miniMaps)\n );\n }\n\n if (!isEmpty(isolate.data)) {\n next[MinifiedKeys.Data] = transformKeys(isolate.data, miniMaps?.keys?.data);\n }\n\n for (const key in isolate) {\n // Skip keys that should be excluded from the dump.\n // While we're excluding children from the dump, they'll actually remain there\n // due to the fact that we've already transformed them recursively beforehand\n // thus renaming them to the minified key.\n if (isKeyExcluededFromDump(key)) {\n continue;\n }\n const value = isolate[key as keyof TIsolate];\n\n if (isNullish(value)) {\n continue;\n }\n\n const keyToUse = minifyKey(key);\n next[keyToUse] = transformValueByKey(key, value, miniMaps);\n }\n\n return next;\n}\n\nfunction isKeyExcluededFromDump(key: string): boolean {\n return ExcludedFromDump.includes(key as IsolateKeys);\n}\n\nfunction minifyKey(key: string): string {\n return KeyToMinified[key as keyof typeof KeyToMinified] ?? key;\n}\n\nfunction transformValueByKey(\n key: string,\n value: any,\n miniMaps: Maybe<MiniMaps>\n): any {\n if (isNullish(value)) {\n return value;\n }\n\n const keyMap = miniMaps?.values?.[key as keyof MiniMaps['values']];\n\n return keyMap ? keyMap[value] ?? value : value;\n}\n\nfunction transformKeys(\n data: Record<string, any>,\n keyMap: Maybe<MiniMap>\n): Record<string, any> {\n const next: Record<string, any> = {};\n\n // Loop over each key in the data.\n for (const key in data) {\n // Find the key to use for the next object.\n // If there is no key map, use the original key.\n // If there is a key map, use the key map entry for the current key.\n const keyToUse = (keyMap ? keyMap[key] : key) ?? key;\n\n // Add the key and value to the next object.\n next[keyToUse] = data[key];\n }\n\n // Return the next object.\n return next;\n}\n\ntype MiniMap = Record<string, string>;\n\ntype MiniMaps = Partial<{\n keys: Partial<{\n [IsolateKeys.Data]: MiniMap;\n }>;\n values: Partial<{\n [IsolateKeys.Status]: MiniMap;\n [IsolateKeys.Type]: MiniMap;\n }>;\n}>;\n\nexport function deeplyInvertKeyMap(miniMaps: Maybe<MiniMaps> = {}): MiniMaps {\n return Object.entries(miniMaps).reduce((acc, [key, value]) => {\n if (typeof value === 'object') {\n return assign(acc, {\n [key]: deeplyInvertKeyMap(value as MiniMaps),\n });\n }\n return assign(acc, {\n [value]: key,\n });\n }, {} as MiniMaps);\n}\n"],"names":["ErrorStrings","IsolateKeys","MinifiedKeys","KeyToMinified","Type","Keys","Parent","Data","Key","AllowReorder","Status","Children","MinifiedToKey","miniMap","Object","entries","reduce","acc","key","minified","assign","invertKeyMap","ExcludedFromDump","AbortController","IsolateMutator","static","isolate","parent","output","child","invariant","children","_a","push","setParent","node","_b","filter","keys","at","isNullish","length","data","reason","abortController","abort","IsolateSerializer","miniMaps","inverseMinimap","deeplyInvertKeyMap","root","isStringValue","JSON","parse","validateIsolate","queue","current","shift","expandChildren","value","isNotNullish","keyToUse","transformKeys","transformValueByKey","map","nextChild","stringify","transformIsolate","hasOwnProperty","text","INVALID_ISOLATE_CANNOT_PARSE","next","isEmpty","isKeyExcluededFromDump","minifyKey","includes","keyMap","values"],"mappings":"iBAAYA,ECEAC,EAYAC,2BDdZ,SAAYF,GACVA,EAAA,kBAAA,+BACAA,EAAA,4BAAA,wFACAA,EAAA,+BAAA,kGACAA,EAAA,6BAAA,kEACD,CALD,CAAYA,IAAAA,EAKX,CAAA,ICHD,SAAYC,GACVA,EAAA,KAAA,QACAA,EAAA,KAAA,OACAA,EAAA,IAAA,MACAA,EAAA,OAAA,SACAA,EAAA,KAAA,OACAA,EAAA,aAAA,eACAA,EAAA,OAAA,SACAA,EAAA,gBAAA,kBACAA,EAAA,SAAA,UACD,CAVD,CAAYA,IAAAA,EAUX,CAAA,IAED,SAAYC,GACVA,EAAA,KAAA,IACAA,EAAA,KAAA,KACAA,EAAA,IAAA,KACAA,EAAA,OAAA,IACAA,EAAA,KAAA,IACAA,EAAA,aAAA,KACAA,EAAA,OAAA,IACAA,EAAA,SAAA,GACD,CATD,CAAYA,IAAAA,EASX,CAAA,IAEM,MAAMC,EAAgB,CAC3B,CAACF,EAAYG,MAAOF,EAAaE,KACjC,CAACH,EAAYI,MAAOH,EAAaG,KACjC,CAACJ,EAAYK,QAASJ,EAAaI,OACnC,CAACL,EAAYM,MAAOL,EAAaK,KACjC,CAACN,EAAYO,KAAMN,EAAaM,IAChC,CAACP,EAAYQ,cAAeP,EAAaO,aACzC,CAACR,EAAYS,QAASR,EAAaQ,OACnC,CAACT,EAAYU,UAAWT,EAAaS,UAU1BC,EAEG,SAAaC,EAAkC,IAC7D,OAAOC,OAAOC,QAAQF,GAASG,QAC7B,CAACC,GAAMC,EAAKC,KACVC,EAAAA,OAAOH,EAAK,CACVE,CAACA,GAAWD,KAEhB,CAA4B,EAEhC,CAV6BG,CAAalB,GAYnC,MAAM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solateSerializer.production.js","sources":["../../src/errors/ErrorStrings.ts","../../src/Isolate/IsolateKeys.ts","../../src/Isolate/IsolateMutator.ts","../../src/exports/IsolateSerializer.ts"],"sourcesContent":["export enum ErrorStrings {\n NO_ACTIVE_ISOLATE = 'Not within an active isolate',\n UNABLE_TO_PICK_NEXT_ISOLATE = 'Unable to pick next isolate. This is a bug, please report it to the Vest maintainers.',\n ENCOUNTERED_THE_SAME_KEY_TWICE = `Encountered the same key \"{key}\" twice. This may lead to inconsistent or overriding of results.`,\n INVALID_ISOLATE_CANNOT_PARSE = `Invalid isolate was passed to IsolateSerializer. Cannot proceed.`,\n}\n","export enum IsolateKeys {\n Type = '$type',\n Keys = 'keys',\n Key = 'key',\n Parent = 'parent',\n Data = 'data',\n AllowReorder = 'allowReorder',\n Status = 'status',\n AbortController = 'abortController',\n Children = 'children',\n}\n\nexport const ExcludedFromDump = new Set([\n IsolateKeys.AbortController,\n IsolateKeys.Parent,\n IsolateKeys.Keys,\n]);\n","import { Nullable, invariant, isNullish } from 'vest-utils';\n\nimport { TIsolate } from 'Isolate';\n\nexport class IsolateMutator {\n static setParent(isolate: TIsolate, parent: Nullable<TIsolate>): TIsolate {\n isolate.parent = parent;\n return isolate;\n }\n\n static saveOutput(isolate: TIsolate, output: any): TIsolate {\n isolate.output = output;\n return isolate;\n }\n\n static setKey(isolate: TIsolate, key: Nullable<string>): TIsolate {\n isolate.key = key;\n return isolate;\n }\n\n static addChild(isolate: TIsolate, child: TIsolate): void {\n invariant(isolate);\n\n isolate.children = isolate.children ?? [];\n\n isolate.children.push(child);\n IsolateMutator.setParent(child, isolate);\n }\n\n static removeChild(isolate: TIsolate, node: TIsolate): void {\n isolate.children =\n isolate.children?.filter(child => child !== node) ?? null;\n }\n\n static addChildKey(isolate: TIsolate, key: string, node: TIsolate): void {\n invariant(isolate);\n\n isolate.keys = isolate.keys ?? {};\n\n isolate.keys[key] = node;\n }\n\n static slice(isolate: TIsolate, at: number): void {\n if (isNullish(isolate.children)) {\n return;\n }\n isolate.children.length = at;\n }\n\n static setData(isolate: TIsolate, data: any): void {\n isolate.data = data;\n }\n\n static abort(isolate: TIsolate, reason?: string): void {\n if (isNullish(isolate.abortController)) {\n return;\n }\n isolate.abortController.abort(reason);\n }\n}\n","import { ErrorStrings } from 'ErrorStrings';\nimport {\n Nullable,\n hasOwnProperty,\n invariant,\n isNullish,\n isStringValue,\n text,\n} from 'vest-utils';\nimport { expandObject, minifyObject } from 'vest-utils/minifyObject';\n\nimport { TIsolate } from 'Isolate';\nimport { ExcludedFromDump, IsolateKeys } from 'IsolateKeys';\nimport { IsolateMutator } from 'IsolateMutator';\n\nexport class IsolateSerializer {\n // eslint-disable-next-line max-statements, complexity, max-lines-per-function\n static deserialize(node: Record<string, any> | TIsolate | string): TIsolate {\n // Validate the root object\n const root = (\n isStringValue(node) ? JSON.parse(node) : ({ ...node } as TIsolate)\n ) as [any, any];\n\n const expanded = expandObject(...root);\n\n IsolateSerializer.validateIsolate(expanded);\n\n const queue = [expanded];\n\n // Iterate over the queue until it's empty\n while (queue.length) {\n // Get the next item from the queue\n const current = queue.shift();\n\n if (!current) {\n continue;\n }\n\n const children = current.children;\n\n // If there are no children, nothing to do.\n if (!children) {\n continue;\n }\n\n // Copy the children and set their parent to the current node.\n current.children = children.map(child => {\n const nextChild = { ...child };\n\n IsolateMutator.setParent(nextChild, current);\n queue.push(nextChild);\n\n // If the child has a key, add it to the parent's keys.\n const key = nextChild.key;\n\n if (key) {\n current.keys = current.keys ?? {};\n current.keys[key] = nextChild;\n }\n\n return nextChild;\n });\n }\n\n return expanded;\n }\n\n static serialize(isolate: Nullable<TIsolate>): string {\n if (isNullish(isolate)) {\n return '';\n }\n\n const minified = minifyObject(isolate, ExcludedFromDump);\n\n return JSON.stringify(minified);\n }\n\n static validateIsolate(\n node: Record<string, any> | TIsolate,\n ): asserts node is TIsolate {\n invariant(\n hasOwnProperty(node, IsolateKeys.Type),\n text(ErrorStrings.INVALID_ISOLATE_CANNOT_PARSE),\n );\n }\n}\n"],"names":["ErrorStrings","IsolateKeys","ExcludedFromDump","Set","AbortController","Parent","Keys","IsolateMutator","static","isolate","parent","output","key","child","invariant","children","_a","push","setParent","node","_b","filter","keys","at","isNullish","length","data","reason","abortController","abort","IsolateSerializer","root","isStringValue","JSON","parse","Object","assign","expanded","expandObject","validateIsolate","queue","current","shift","map","nextChild","minified","minifyObject","stringify","hasOwnProperty","Type","text","INVALID_ISOLATE_CANNOT_PARSE"],"mappings":"iBAAYA,ECAAC,gEDAZ,SAAYD,GACVA,EAAA,kBAAA,+BACAA,EAAA,4BAAA,wFACAA,EAAA,+BAAA,kGACAA,EAAA,6BAAA,kEACD,CALD,CAAYA,IAAAA,EAKX,CAAA,ICLD,SAAYC,GACVA,EAAA,KAAA,QACAA,EAAA,KAAA,OACAA,EAAA,IAAA,MACAA,EAAA,OAAA,SACAA,EAAA,KAAA,OACAA,EAAA,aAAA,eACAA,EAAA,OAAA,SACAA,EAAA,gBAAA,kBACAA,EAAA,SAAA,UACD,CAVD,CAAYA,IAAAA,EAUX,CAAA,IAEM,MAAMC,EAAmB,IAAIC,IAAI,CACtCF,EAAYG,gBACZH,EAAYI,OACZJ,EAAYK,aCXDC,EACXC,iBAAiBC,EAAmBC,GAElC,OADAD,EAAQC,OAASA,EACVD,CACR,CAEDD,kBAAkBC,EAAmBE,GAEnC,OADAF,EAAQE,OAASA,EACVF,CACR,CAEDD,cAAcC,EAAmBG,GAE/B,OADAH,EAAQG,IAAMA,EACPH,CACR,CAEDD,gBAAgBC,EAAmBI,SACjCC,EAASA,UAACL,GAEVA,EAAQM,SAA+B,QAApBC,EAAAP,EAAQM,gBAAY,IAAAC,EAAAA,EAAA,GAEvCP,EAAQM,SAASE,KAAKJ,GACtBN,EAAeW,UAAUL,EAAOJ,EACjC,CAEDD,mBAAmBC,EAAmBU,WACpCV,EAAQM,SAC2C,QAAjDK,EAAgB,UAAhBX,EAAQM,gBAAQ,IAAAC,OAAA,EAAAA,EAAEK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AKc,UAAUF,EACvB,CAEDrC,uBACEW,GAEAL,YACEkC,EAAAA,eAAe7B,EAAMlB,EAAYgD,MACjCC,OAAKlD,EAAamD,8BAErB"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var vestUtils = require('vest-utils');
|
|
4
|
-
|
|
5
3
|
/******************************************************************************
|
|
6
4
|
Copyright (c) Microsoft Corporation.
|
|
7
5
|
|
|
@@ -48,47 +46,11 @@ var IsolateKeys;
|
|
|
48
46
|
IsolateKeys["AbortController"] = "abortController";
|
|
49
47
|
IsolateKeys["Children"] = "children";
|
|
50
48
|
})(IsolateKeys || (IsolateKeys = {}));
|
|
51
|
-
|
|
52
|
-
(function (MinifiedKeys) {
|
|
53
|
-
MinifiedKeys["Type"] = "$";
|
|
54
|
-
MinifiedKeys["Keys"] = "Ks";
|
|
55
|
-
MinifiedKeys["Key"] = "ky";
|
|
56
|
-
MinifiedKeys["Parent"] = "P";
|
|
57
|
-
MinifiedKeys["Data"] = "D";
|
|
58
|
-
MinifiedKeys["AllowReorder"] = "AR";
|
|
59
|
-
MinifiedKeys["Status"] = "S";
|
|
60
|
-
MinifiedKeys["Children"] = "C";
|
|
61
|
-
})(MinifiedKeys || (MinifiedKeys = {}));
|
|
62
|
-
const KeyToMinified = {
|
|
63
|
-
[IsolateKeys.Type]: MinifiedKeys.Type,
|
|
64
|
-
[IsolateKeys.Keys]: MinifiedKeys.Keys,
|
|
65
|
-
[IsolateKeys.Parent]: MinifiedKeys.Parent,
|
|
66
|
-
[IsolateKeys.Data]: MinifiedKeys.Data,
|
|
67
|
-
[IsolateKeys.Key]: MinifiedKeys.Key,
|
|
68
|
-
[IsolateKeys.AllowReorder]: MinifiedKeys.AllowReorder,
|
|
69
|
-
[IsolateKeys.Status]: MinifiedKeys.Status,
|
|
70
|
-
[IsolateKeys.Children]: MinifiedKeys.Children,
|
|
71
|
-
};
|
|
72
|
-
// This const is an object that looks like this:
|
|
73
|
-
// {
|
|
74
|
-
// '$': '$type',
|
|
75
|
-
// 'K': 'keys',
|
|
76
|
-
// 'P': 'parent',
|
|
77
|
-
// ...
|
|
78
|
-
// }
|
|
79
|
-
invertKeyMap(KeyToMinified);
|
|
80
|
-
function invertKeyMap(miniMap = {}) {
|
|
81
|
-
return Object.entries(miniMap).reduce((acc, [key, minified]) => vestUtils.assign(acc, {
|
|
82
|
-
[minified]: key,
|
|
83
|
-
}), {});
|
|
84
|
-
}
|
|
85
|
-
[
|
|
49
|
+
new Set([
|
|
86
50
|
IsolateKeys.AbortController,
|
|
87
51
|
IsolateKeys.Parent,
|
|
88
52
|
IsolateKeys.Keys,
|
|
89
|
-
|
|
90
|
-
IsolateKeys.Data,
|
|
91
|
-
];
|
|
53
|
+
]);
|
|
92
54
|
|
|
93
55
|
function genTestIsolate(payload = {}) {
|
|
94
56
|
const { status } = payload, data = __rest(payload, ["status"]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-utils.development.js","sources":["../../src/Isolate/IsolateKeys.ts","../../src/exports/test-utils.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"test-utils.development.js","sources":["../../src/Isolate/IsolateKeys.ts","../../src/exports/test-utils.ts"],"sourcesContent":["export enum IsolateKeys {\n Type = '$type',\n Keys = 'keys',\n Key = 'key',\n Parent = 'parent',\n Data = 'data',\n AllowReorder = 'allowReorder',\n Status = 'status',\n AbortController = 'abortController',\n Children = 'children',\n}\n\nexport const ExcludedFromDump = new Set([\n IsolateKeys.AbortController,\n IsolateKeys.Parent,\n IsolateKeys.Keys,\n]);\n","import { TIsolate } from 'Isolate';\nimport { IsolateKeys } from 'IsolateKeys';\n\nexport function genTestIsolate(payload: Record<string, any> = {}): TIsolate {\n const { status, ...data } = payload;\n return {\n children: [],\n data,\n key: null,\n keys: {},\n output: null,\n parent: null,\n [IsolateKeys.Type]: 'UnitTest',\n ...(status && { status }),\n };\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;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1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var t;"function"==typeof SuppressedError&&SuppressedError,function(t){t.Type="$type",t.Keys="keys",t.Key="key",t.Parent="parent",t.Data="data",t.AllowReorder="allowReorder",t.Status="status",t.AbortController="abortController",t.Children="children"}(t||(t={})),new Set([t.AbortController,t.Parent,t.Keys]),exports.genTestIsolate=function(e={}){const{status:r}=e,n=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]])}return r}(e,["status"]);return Object.assign({children:[],data:n,key:null,keys:{},output:null,parent:null,[t.Type]:"UnitTest"},r&&{status:r})};
|
|
2
2
|
//# sourceMappingURL=test-utils.production.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-utils.production.js","sources":["../../src/Isolate/IsolateKeys.ts","../../src/exports/test-utils.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"test-utils.production.js","sources":["../../src/Isolate/IsolateKeys.ts","../../src/exports/test-utils.ts"],"sourcesContent":["export enum IsolateKeys {\n Type = '$type',\n Keys = 'keys',\n Key = 'key',\n Parent = 'parent',\n Data = 'data',\n AllowReorder = 'allowReorder',\n Status = 'status',\n AbortController = 'abortController',\n Children = 'children',\n}\n\nexport const ExcludedFromDump = new Set([\n IsolateKeys.AbortController,\n IsolateKeys.Parent,\n IsolateKeys.Keys,\n]);\n","import { TIsolate } from 'Isolate';\nimport { IsolateKeys } from 'IsolateKeys';\n\nexport function genTestIsolate(payload: Record<string, any> = {}): TIsolate {\n const { status, ...data } = payload;\n return {\n children: [],\n data,\n key: null,\n keys: {},\n output: null,\n parent: null,\n [IsolateKeys.Type]: 'UnitTest',\n ...(status && { status }),\n };\n}\n"],"names":["IsolateKeys","Set","AbortController","Parent","Keys","payload","status","data","__rest","Object","assign","children","key","keys","output","parent","Type"],"mappings":"aAAA,IAAYA,sDAAZ,SAAYA,GACVA,EAAA,KAAA,QACAA,EAAA,KAAA,OACAA,EAAA,IAAA,MACAA,EAAA,OAAA,SACAA,EAAA,KAAA,OACAA,EAAA,aAAA,eACAA,EAAA,OAAA,SACAA,EAAA,gBAAA,kBACAA,EAAA,SAAA,UACD,CAVD,CAAYA,IAAAA,EAUX,CAAA,IAE+B,IAAIC,IAAI,CACtCD,EAAYE,gBACZF,EAAYG,OACZH,EAAYI,8BCZE,SAAeC,EAA+B,IAC5D,MAAMC,OAAEA,GAAoBD,EAATE,2UAAIC,CAAKH,EAAtB,CAAmB,WACzB,OAAAI,OAAAC,OAAA,CACEC,SAAU,GACVJ,OACAK,IAAK,KACLC,KAAM,GACNC,OAAQ,KACRC,OAAQ,KACR,CAACf,EAAYgB,MAAO,YAChBV,GAAU,CAAEA,UAEpB"}
|