vestjs-runtime 1.1.0 → 1.2.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.
- package/dist/cjs/IsolateSerializer.development.js +114 -26
- 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 +22 -6
- 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 +114 -27
- 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 +115 -28
- 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 +22 -6
- 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 +115 -28
- 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 +117 -30
- 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 +24 -10
- 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 +117 -31
- 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 +22 -7
- package/types/IsolateSerializer.d.ts.map +1 -1
- package/types/test-utils.d.ts +5 -1
- package/types/test-utils.d.ts.map +1 -1
- package/types/vestjs-runtime.d.ts +51 -21
- package/types/vestjs-runtime.d.ts.map +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vest-utils')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'vest-utils'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.IsolateSerializer = {}, global["vest-utils"]));
|
|
5
|
-
})(this, (function (exports, vestUtils) { 'use strict';
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vest-utils'), require('lodash')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'vest-utils', 'lodash'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.IsolateSerializer = {}, global["vest-utils"], global.lodash));
|
|
5
|
+
})(this, (function (exports, vestUtils, lodash) { 'use strict';
|
|
6
6
|
|
|
7
7
|
var ErrorStrings;
|
|
8
8
|
(function (ErrorStrings) {
|
|
@@ -21,16 +21,19 @@
|
|
|
21
21
|
IsolateKeys["Data"] = "data";
|
|
22
22
|
IsolateKeys["AllowReorder"] = "allowReorder";
|
|
23
23
|
IsolateKeys["Status"] = "status";
|
|
24
|
+
IsolateKeys["AbortController"] = "abortController";
|
|
25
|
+
IsolateKeys["Children"] = "children";
|
|
24
26
|
})(IsolateKeys || (IsolateKeys = {}));
|
|
25
27
|
var MinifiedKeys;
|
|
26
28
|
(function (MinifiedKeys) {
|
|
27
29
|
MinifiedKeys["Type"] = "$";
|
|
28
|
-
MinifiedKeys["Keys"] = "
|
|
29
|
-
MinifiedKeys["Key"] = "
|
|
30
|
+
MinifiedKeys["Keys"] = "Ks";
|
|
31
|
+
MinifiedKeys["Key"] = "ky";
|
|
30
32
|
MinifiedKeys["Parent"] = "P";
|
|
31
33
|
MinifiedKeys["Data"] = "D";
|
|
32
|
-
MinifiedKeys["AllowReorder"] = "
|
|
34
|
+
MinifiedKeys["AllowReorder"] = "AR";
|
|
33
35
|
MinifiedKeys["Status"] = "S";
|
|
36
|
+
MinifiedKeys["Children"] = "C";
|
|
34
37
|
})(MinifiedKeys || (MinifiedKeys = {}));
|
|
35
38
|
const KeyToMinified = {
|
|
36
39
|
[IsolateKeys.Type]: MinifiedKeys.Type,
|
|
@@ -40,6 +43,7 @@
|
|
|
40
43
|
[IsolateKeys.Key]: MinifiedKeys.Key,
|
|
41
44
|
[IsolateKeys.AllowReorder]: MinifiedKeys.AllowReorder,
|
|
42
45
|
[IsolateKeys.Status]: MinifiedKeys.Status,
|
|
46
|
+
[IsolateKeys.Children]: MinifiedKeys.Children,
|
|
43
47
|
};
|
|
44
48
|
// This const is an object that looks like this:
|
|
45
49
|
// {
|
|
@@ -48,9 +52,19 @@
|
|
|
48
52
|
// 'P': 'parent',
|
|
49
53
|
// ...
|
|
50
54
|
// }
|
|
51
|
-
const MinifiedToKey =
|
|
52
|
-
|
|
53
|
-
|
|
55
|
+
const MinifiedToKey = invertKeyMap(KeyToMinified);
|
|
56
|
+
function invertKeyMap(miniMap = {}) {
|
|
57
|
+
return Object.entries(miniMap).reduce((acc, [key, minified]) => lodash.assign(acc, {
|
|
58
|
+
[minified]: key,
|
|
59
|
+
}), {});
|
|
60
|
+
}
|
|
61
|
+
const ExcludedFromDump = [
|
|
62
|
+
IsolateKeys.AbortController,
|
|
63
|
+
IsolateKeys.Parent,
|
|
64
|
+
IsolateKeys.Keys,
|
|
65
|
+
IsolateKeys.Children,
|
|
66
|
+
IsolateKeys.Data,
|
|
67
|
+
];
|
|
54
68
|
|
|
55
69
|
class IsolateMutator {
|
|
56
70
|
static setParent(isolate, parent) {
|
|
@@ -92,11 +106,18 @@
|
|
|
92
106
|
static setData(isolate, data) {
|
|
93
107
|
isolate.data = data;
|
|
94
108
|
}
|
|
109
|
+
static abort(isolate, reason) {
|
|
110
|
+
if (vestUtils.isNullish(isolate.abortController)) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
isolate.abortController.abort(reason);
|
|
114
|
+
}
|
|
95
115
|
}
|
|
96
116
|
|
|
97
117
|
class IsolateSerializer {
|
|
98
|
-
// eslint-disable-next-line max-statements, complexity
|
|
99
|
-
static deserialize(node) {
|
|
118
|
+
// eslint-disable-next-line max-statements, complexity, max-lines-per-function
|
|
119
|
+
static deserialize(node, miniMaps) {
|
|
120
|
+
var _a;
|
|
100
121
|
// the assumption is that the tree is built correctly,
|
|
101
122
|
// but the children are missing the parent property to
|
|
102
123
|
// avoid circular references during serialization.
|
|
@@ -104,29 +125,52 @@
|
|
|
104
125
|
// to avoid circular references during serialization.
|
|
105
126
|
// we need to rebuild the tree and add back the parent property to the children
|
|
106
127
|
// and the keys property to the parents.
|
|
128
|
+
const inverseMinimap = deeplyInvertKeyMap(miniMaps);
|
|
129
|
+
// Validate the root object
|
|
107
130
|
const root = vestUtils.isStringValue(node)
|
|
108
131
|
? JSON.parse(node)
|
|
109
132
|
: Object.assign({}, node);
|
|
110
133
|
IsolateSerializer.validateIsolate(root);
|
|
111
134
|
const queue = [root];
|
|
135
|
+
// Iterate over the queue until it's empty
|
|
112
136
|
while (queue.length) {
|
|
137
|
+
// Get the next item from the queue
|
|
113
138
|
const current = queue.shift();
|
|
114
|
-
|
|
139
|
+
// Get the children of the current item
|
|
140
|
+
const children = IsolateSerializer.expandChildren(current);
|
|
141
|
+
// Iterate over the minified keys
|
|
115
142
|
for (const key in MinifiedToKey) {
|
|
143
|
+
// Get the value for the current key
|
|
116
144
|
const value = current[key];
|
|
145
|
+
// If the value is not null or undefined
|
|
117
146
|
if (vestUtils.isNotNullish(value)) {
|
|
118
|
-
|
|
147
|
+
// Get the key to use
|
|
148
|
+
const keyToUse = MinifiedToKey[key];
|
|
149
|
+
// If the key is data, then we may need to transform the keys
|
|
150
|
+
// eslint-disable-next-line max-depth
|
|
151
|
+
if (keyToUse === IsolateKeys.Data) {
|
|
152
|
+
// Transform the keys
|
|
153
|
+
current[keyToUse] = transformKeys(value, (_a = inverseMinimap === null || inverseMinimap === void 0 ? void 0 : inverseMinimap.keys) === null || _a === void 0 ? void 0 : _a.data);
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
// Otherwise, just set the key
|
|
157
|
+
current[keyToUse] = transformValueByKey(keyToUse, value, inverseMinimap);
|
|
158
|
+
}
|
|
159
|
+
// Remove the old key
|
|
119
160
|
delete current[key];
|
|
120
161
|
}
|
|
121
162
|
}
|
|
163
|
+
// If there are no children, nothing to do.
|
|
122
164
|
if (!children) {
|
|
123
165
|
continue;
|
|
124
166
|
}
|
|
167
|
+
// Copy the children and set their parent to the current node.
|
|
125
168
|
current.children = children.map(child => {
|
|
126
169
|
var _a;
|
|
127
170
|
const nextChild = Object.assign({}, child);
|
|
128
171
|
IsolateMutator.setParent(nextChild, current);
|
|
129
172
|
queue.push(nextChild);
|
|
173
|
+
// If the child has a key, add it to the parent's keys.
|
|
130
174
|
const key = nextChild.key;
|
|
131
175
|
if (key) {
|
|
132
176
|
current.keys = (_a = current.keys) !== null && _a !== void 0 ? _a : {};
|
|
@@ -137,14 +181,16 @@
|
|
|
137
181
|
}
|
|
138
182
|
return root;
|
|
139
183
|
}
|
|
140
|
-
static serialize(isolate) {
|
|
184
|
+
static serialize(isolate, miniMaps) {
|
|
141
185
|
if (vestUtils.isNullish(isolate)) {
|
|
142
186
|
return '';
|
|
143
187
|
}
|
|
144
|
-
return JSON.stringify(transformIsolate(isolate));
|
|
188
|
+
return JSON.stringify(transformIsolate(isolate, miniMaps));
|
|
145
189
|
}
|
|
146
|
-
static
|
|
147
|
-
return node
|
|
190
|
+
static expandChildren(node) {
|
|
191
|
+
return node[MinifiedKeys.Children]
|
|
192
|
+
? [...node[MinifiedKeys.Children]]
|
|
193
|
+
: null;
|
|
148
194
|
}
|
|
149
195
|
static validateIsolate(node) {
|
|
150
196
|
vestUtils.invariant(vestUtils.hasOwnProperty(node, IsolateKeys.Type) ||
|
|
@@ -152,15 +198,20 @@
|
|
|
152
198
|
}
|
|
153
199
|
}
|
|
154
200
|
// eslint-disable-next-line max-statements, complexity
|
|
155
|
-
function transformIsolate(isolate) {
|
|
201
|
+
function transformIsolate(isolate, miniMaps) {
|
|
202
|
+
var _a;
|
|
156
203
|
const next = {};
|
|
157
204
|
if (isolate.children) {
|
|
158
|
-
next.
|
|
205
|
+
next[MinifiedKeys.Children] = isolate.children.map(isolate => transformIsolate(isolate, miniMaps));
|
|
206
|
+
}
|
|
207
|
+
if (!vestUtils.isEmpty(isolate.data)) {
|
|
208
|
+
next[MinifiedKeys.Data] = transformKeys(isolate.data, (_a = miniMaps === null || miniMaps === void 0 ? void 0 : miniMaps.keys) === null || _a === void 0 ? void 0 : _a.data);
|
|
159
209
|
}
|
|
160
210
|
for (const key in isolate) {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
211
|
+
// Skip keys that should be excluded from the dump.
|
|
212
|
+
// While we're excluding children from the dump, they'll actually remain there
|
|
213
|
+
// due to the fact that we've already transformed them recursively beforehand
|
|
214
|
+
// thus renaming them to the minified key.
|
|
164
215
|
if (isKeyExcluededFromDump(key)) {
|
|
165
216
|
continue;
|
|
166
217
|
}
|
|
@@ -168,20 +219,56 @@
|
|
|
168
219
|
if (vestUtils.isNullish(value)) {
|
|
169
220
|
continue;
|
|
170
221
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
}
|
|
174
|
-
else {
|
|
175
|
-
next[key] = value;
|
|
176
|
-
}
|
|
222
|
+
const keyToUse = minifyKey(key);
|
|
223
|
+
next[keyToUse] = transformValueByKey(key, value, miniMaps);
|
|
177
224
|
}
|
|
178
225
|
return next;
|
|
179
226
|
}
|
|
180
227
|
function isKeyExcluededFromDump(key) {
|
|
181
|
-
return
|
|
228
|
+
return ExcludedFromDump.includes(key);
|
|
229
|
+
}
|
|
230
|
+
function minifyKey(key) {
|
|
231
|
+
var _a;
|
|
232
|
+
return (_a = KeyToMinified[key]) !== null && _a !== void 0 ? _a : key;
|
|
233
|
+
}
|
|
234
|
+
function transformValueByKey(key, value, miniMaps) {
|
|
235
|
+
var _a, _b;
|
|
236
|
+
if (vestUtils.isNullish(value)) {
|
|
237
|
+
return value;
|
|
238
|
+
}
|
|
239
|
+
const keyMap = (_a = miniMaps === null || miniMaps === void 0 ? void 0 : miniMaps.values) === null || _a === void 0 ? void 0 : _a[key];
|
|
240
|
+
return keyMap ? (_b = keyMap[value]) !== null && _b !== void 0 ? _b : value : value;
|
|
241
|
+
}
|
|
242
|
+
function transformKeys(data, keyMap) {
|
|
243
|
+
var _a;
|
|
244
|
+
const next = {};
|
|
245
|
+
// Loop over each key in the data.
|
|
246
|
+
for (const key in data) {
|
|
247
|
+
// Find the key to use for the next object.
|
|
248
|
+
// If there is no key map, use the original key.
|
|
249
|
+
// If there is a key map, use the key map entry for the current key.
|
|
250
|
+
const keyToUse = (_a = (keyMap ? keyMap[key] : key)) !== null && _a !== void 0 ? _a : key;
|
|
251
|
+
// Add the key and value to the next object.
|
|
252
|
+
next[keyToUse] = data[key];
|
|
253
|
+
}
|
|
254
|
+
// Return the next object.
|
|
255
|
+
return next;
|
|
256
|
+
}
|
|
257
|
+
function deeplyInvertKeyMap(miniMaps = {}) {
|
|
258
|
+
return Object.entries(miniMaps).reduce((acc, [key, value]) => {
|
|
259
|
+
if (typeof value === 'object') {
|
|
260
|
+
return vestUtils.assign(acc, {
|
|
261
|
+
[key]: deeplyInvertKeyMap(value),
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
return vestUtils.assign(acc, {
|
|
265
|
+
[value]: key,
|
|
266
|
+
});
|
|
267
|
+
}, {});
|
|
182
268
|
}
|
|
183
269
|
|
|
184
270
|
exports.IsolateSerializer = IsolateSerializer;
|
|
271
|
+
exports.deeplyInvertKeyMap = deeplyInvertKeyMap;
|
|
185
272
|
|
|
186
273
|
}));
|
|
187
274
|
//# 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","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}\n\nenum MinifiedKeys {\n Type = '$',\n Keys = 'K',\n Key = 'k',\n Parent = 'P',\n Data = 'D',\n AllowReorder = 'aR',\n Status = 'S',\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};\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 = Object.entries(KeyToMinified).reduce(\n (acc, [key, minified]) =>\n Object.assign(acc, {\n [minified]: key,\n }),\n {} as Record<string, IsolateKeys>\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","import { ErrorStrings } from 'ErrorStrings';\nimport {\n Nullable,\n hasOwnProperty,\n invariant,\n isNotNullish,\n isNullish,\n isStringValue,\n text,\n} from 'vest-utils';\n\nimport { TIsolate } from 'Isolate';\nimport { IsolateKeys, KeyToMinified, MinifiedToKey } from 'IsolateKeys';\nimport { IsolateMutator } from 'IsolateMutator';\n\nexport class IsolateSerializer {\n // eslint-disable-next-line max-statements, complexity\n static deserialize(node: Record<string, any> | TIsolate | string): 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\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 while (queue.length) {\n const current = queue.shift();\n\n const children = IsolateSerializer.getChildren(current);\n\n for (const key in MinifiedToKey) {\n const value = current[key];\n if (isNotNullish(value)) {\n current[MinifiedToKey[key]] = value;\n delete current[key];\n }\n }\n\n if (!children) {\n continue;\n }\n\n current.children = children.map(child => {\n const nextChild = { ...child };\n\n IsolateMutator.setParent(nextChild, current);\n queue.push(nextChild);\n\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(isolate: Nullable<TIsolate>): string {\n if (isNullish(isolate)) {\n return '';\n }\n\n return JSON.stringify(transformIsolate(isolate));\n }\n\n static getChildren(node: TIsolate): Nullable<TIsolate[]> {\n return node.children ? [...node.children] : 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(isolate: TIsolate): Record<string, any> {\n const next: Record<string, any> = {};\n\n if (isolate.children) {\n next.children = isolate.children.map(transformIsolate);\n }\n\n for (const key in isolate) {\n if (key === 'children') {\n continue;\n }\n\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 if (hasOwnProperty(KeyToMinified, key)) {\n next[KeyToMinified[key]] = value;\n } else {\n next[key] = value;\n }\n }\n\n return next;\n}\n\nfunction isKeyExcluededFromDump(key: string): boolean {\n return [IsolateKeys.Parent, IsolateKeys.Keys].includes(key as IsolateKeys);\n}\n"],"names":["invariant","isNullish","isStringValue","isNotNullish","hasOwnProperty","text"],"mappings":";;;;;;EAAA,IAAY,YAKX,CAAA;EALD,CAAA,UAAY,YAAY,EAAA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CAAC,QAAQ,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;EACxD,KAAA;EAED,IAAA,KAAK,MAAM,GAAG,IAAI,OAAO,EAAE;UACzB,IAAI,GAAG,KAAK,UAAU,EAAE;cACtB,SAAS;EACV,SAAA;EAED,QAAA,IAAI,sBAAsB,CAAC,GAAG,CAAC,EAAE;cAC/B,SAAS;EACV,SAAA;EACD,QAAA,MAAM,KAAK,GAAG,OAAO,CAAC,GAAqB,CAAC,CAAC;EAE7C,QAAA,IAAIJ,mBAAS,CAAC,KAAK,CAAC,EAAE;cACpB,SAAS;EACV,SAAA;EAED,QAAA,IAAIG,wBAAc,CAAC,aAAa,EAAE,GAAG,CAAC,EAAE;cACtC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC;EAClC,SAAA;EAAM,aAAA;EACL,YAAA,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;EACnB,SAAA;EACF,KAAA;EAED,IAAA,OAAO,IAAI,CAAC;EACd,CAAC;EAED,SAAS,sBAAsB,CAAC,GAAW,EAAA;EACzC,IAAA,OAAO,CAAC,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,GAAkB,CAAC,CAAC;EAC7E;;;;;;;;"}
|
|
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 'lodash';\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":";;;;;;EAAA,IAAY,YAKX,CAAA;EALD,CAAA,UAAY,YAAY,EAAA;EACtB,IAAA,YAAA,CAAA,mBAAA,CAAA,GAAA,8BAAkD,CAAA;EAClD,IAAA,YAAA,CAAA,6BAAA,CAAA,GAAA,uFAAqH,CAAA;EACrH,IAAA,YAAA,CAAA,gCAAA,CAAA,GAAA,mGAAkI,CAAA;EAClI,IAAA,YAAA,CAAA,8BAAA,CAAA,GAAA,kEAAiG,CAAA;EACnG,CAAC,EALW,YAAY,KAAZ,YAAY,GAKvB,EAAA,CAAA,CAAA;;ECHD,IAAY,WAUX,CAAA;EAVD,CAAA,UAAY,WAAW,EAAA;EACrB,IAAA,WAAA,CAAA,MAAA,CAAA,GAAA,OAAc,CAAA;EACd,IAAA,WAAA,CAAA,MAAA,CAAA,GAAA,MAAa,CAAA;EACb,IAAA,WAAA,CAAA,KAAA,CAAA,GAAA,KAAW,CAAA;EACX,IAAA,WAAA,CAAA,QAAA,CAAA,GAAA,QAAiB,CAAA;EACjB,IAAA,WAAA,CAAA,MAAA,CAAA,GAAA,MAAa,CAAA;EACb,IAAA,WAAA,CAAA,cAAA,CAAA,GAAA,cAA6B,CAAA;EAC7B,IAAA,WAAA,CAAA,QAAA,CAAA,GAAA,QAAiB,CAAA;EACjB,IAAA,WAAA,CAAA,iBAAA,CAAA,GAAA,iBAAmC,CAAA;EACnC,IAAA,WAAA,CAAA,UAAA,CAAA,GAAA,UAAqB,CAAA;EACvB,CAAC,EAVW,WAAW,KAAX,WAAW,GAUtB,EAAA,CAAA,CAAA,CAAA;EAED,IAAY,YASX,CAAA;EATD,CAAA,UAAY,YAAY,EAAA;EACtB,IAAA,YAAA,CAAA,MAAA,CAAA,GAAA,GAAU,CAA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IAAI,CAAC,GAAG,CAAC,CAAC;EAC5B,KAAA;;EAGD,IAAA,OAAO,IAAI,CAAC;EACd,CAAC;EAce,SAAA,kBAAkB,CAAC,QAAA,GAA4B,EAAE,EAAA;EAC/D,IAAA,OAAO,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,KAAI;EAC3D,QAAA,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;cAC7B,OAAOF,gBAAM,CAAC,GAAG,EAAE;EACjB,gBAAA,CAAC,GAAG,GAAG,kBAAkB,CAAC,KAAiB,CAAC;EAC7C,aAAA,CAAC,CAAC;EACJ,SAAA;UACD,OAAOA,gBAAM,CAAC,GAAG,EAAE;cACjB,CAAC,KAAK,GAAG,GAAG;EACb,SAAA,CAAC,CAAC;OACJ,EAAE,EAAc,CAAC,CAAC;EACrB;;;;;;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vest-utils")):"function"==typeof define&&define.amd?define(["exports","vest-utils"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).IsolateSerializer={},e["vest-utils"])}(this,(function(e,t){"use strict";var i,s
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vest-utils"),require("lodash")):"function"==typeof define&&define.amd?define(["exports","vest-utils","lodash"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).IsolateSerializer={},e["vest-utils"],e.lodash)}(this,(function(e,t,n){"use strict";var i,r,s;!function(e){e.NO_ACTIVE_ISOLATE="Not within an active isolate",e.UNABLE_TO_PICK_NEXT_ISOLATE="Unable to pick next isolate. This is a bug, please report it to the Vest maintainers.",e.ENCOUNTERED_THE_SAME_KEY_TWICE='Encountered the same key "{key}" twice. This may lead to inconsistent or overriding of results.',e.INVALID_ISOLATE_CANNOT_PARSE="Invalid isolate was passed to IsolateSerializer. Cannot proceed."}(i||(i={})),function(e){e.Type="$type",e.Keys="keys",e.Key="key",e.Parent="parent",e.Data="data",e.AllowReorder="allowReorder",e.Status="status",e.AbortController="abortController",e.Children="children"}(r||(r={})),function(e){e.Type="$",e.Keys="Ks",e.Key="ky",e.Parent="P",e.Data="D",e.AllowReorder="AR",e.Status="S",e.Children="C"}(s||(s={}));const a={[r.Type]:s.Type,[r.Keys]:s.Keys,[r.Parent]:s.Parent,[r.Data]:s.Data,[r.Key]:s.Key,[r.AllowReorder]:s.AllowReorder,[r.Status]:s.Status,[r.Children]:s.Children},l=function(e={}){return Object.entries(e).reduce(((e,[t,i])=>n.assign(e,{[i]:t})),{})}(a);const o=[r.AbortController,r.Parent,r.Keys,r.Children,r.Data];class d{static setParent(e,t){return e.parent=t,e}static saveOutput(e,t){return e.output=t,e}static setKey(e,t){return e.key=t,e}static addChild(e,n){var i;t.invariant(e),e.children=null!==(i=e.children)&&void 0!==i?i:[],e.children.push(n),d.setParent(n,e)}static removeChild(e,t){var n,i;e.children=null!==(i=null===(n=e.children)||void 0===n?void 0:n.filter((e=>e!==t)))&&void 0!==i?i:null}static addChildKey(e,n,i){var r;t.invariant(e),e.keys=null!==(r=e.keys)&&void 0!==r?r:{},e.keys[n]=i}static slice(e,n){t.isNullish(e.children)||(e.children.length=n)}static setData(e,t){e.data=t}static abort(e,n){t.isNullish(e.abortController)||e.abortController.abort(n)}}class u{static deserialize(e,n){var i;const s=p(n),a=t.isStringValue(e)?JSON.parse(e):Object.assign({},e);u.validateIsolate(a);const o=[a];for(;o.length;){const e=o.shift(),n=u.expandChildren(e);for(const n in l){const a=e[n];if(t.isNotNullish(a)){const t=l[n];t===r.Data?e[t]=f(a,null===(i=null==s?void 0:s.keys)||void 0===i?void 0:i.data):e[t]=v(t,a,s),delete e[n]}}n&&(e.children=n.map((t=>{var n;const i=Object.assign({},t);d.setParent(i,e),o.push(i);const r=i.key;return r&&(e.keys=null!==(n=e.keys)&&void 0!==n?n:{},e.keys[r]=i),i})))}return a}static serialize(e,n){return t.isNullish(e)?"":JSON.stringify(c(e,n))}static expandChildren(e){return e[s.Children]?[...e[s.Children]]:null}static validateIsolate(e){t.invariant(t.hasOwnProperty(e,r.Type)||t.hasOwnProperty(e,a[r.Type]),t.text(i.INVALID_ISOLATE_CANNOT_PARSE))}}function c(e,n){var i;const r={};e.children&&(r[s.Children]=e.children.map((e=>c(e,n)))),t.isEmpty(e.data)||(r[s.Data]=f(e.data,null===(i=null==n?void 0:n.keys)||void 0===i?void 0:i.data));for(const i in e){if(h(i))continue;const s=e[i];if(t.isNullish(s))continue;r[y(i)]=v(i,s,n)}return r}function h(e){return o.includes(e)}function y(e){var t;return null!==(t=a[e])&&void 0!==t?t:e}function v(e,n,i){var r,s;if(t.isNullish(n))return n;const a=null===(r=null==i?void 0:i.values)||void 0===r?void 0:r[e];return a&&null!==(s=a[n])&&void 0!==s?s:n}function f(e,t){var n;const i={};for(const r in e){i[null!==(n=t?t[r]:r)&&void 0!==n?n:r]=e[r]}return i}function p(e={}){return Object.entries(e).reduce(((e,[n,i])=>"object"==typeof i?t.assign(e,{[n]:p(i)}):t.assign(e,{[i]:n})),{})}e.IsolateSerializer=u,e.deeplyInvertKeyMap=p}));
|
|
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","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}\n\nenum MinifiedKeys {\n Type = '$',\n Keys = 'K',\n Key = 'k',\n Parent = 'P',\n Data = 'D',\n AllowReorder = 'aR',\n Status = 'S',\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};\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 = Object.entries(KeyToMinified).reduce(\n (acc, [key, minified]) =>\n Object.assign(acc, {\n [minified]: key,\n }),\n {} as Record<string, IsolateKeys>\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","import { ErrorStrings } from 'ErrorStrings';\nimport {\n Nullable,\n hasOwnProperty,\n invariant,\n isNotNullish,\n isNullish,\n isStringValue,\n text,\n} from 'vest-utils';\n\nimport { TIsolate } from 'Isolate';\nimport { IsolateKeys, KeyToMinified, MinifiedToKey } from 'IsolateKeys';\nimport { IsolateMutator } from 'IsolateMutator';\n\nexport class IsolateSerializer {\n // eslint-disable-next-line max-statements, complexity\n static deserialize(node: Record<string, any> | TIsolate | string): 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\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 while (queue.length) {\n const current = queue.shift();\n\n const children = IsolateSerializer.getChildren(current);\n\n for (const key in MinifiedToKey) {\n const value = current[key];\n if (isNotNullish(value)) {\n current[MinifiedToKey[key]] = value;\n delete current[key];\n }\n }\n\n if (!children) {\n continue;\n }\n\n current.children = children.map(child => {\n const nextChild = { ...child };\n\n IsolateMutator.setParent(nextChild, current);\n queue.push(nextChild);\n\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(isolate: Nullable<TIsolate>): string {\n if (isNullish(isolate)) {\n return '';\n }\n\n return JSON.stringify(transformIsolate(isolate));\n }\n\n static getChildren(node: TIsolate): Nullable<TIsolate[]> {\n return node.children ? [...node.children] : 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(isolate: TIsolate): Record<string, any> {\n const next: Record<string, any> = {};\n\n if (isolate.children) {\n next.children = isolate.children.map(transformIsolate);\n }\n\n for (const key in isolate) {\n if (key === 'children') {\n continue;\n }\n\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 if (hasOwnProperty(KeyToMinified, key)) {\n next[KeyToMinified[key]] = value;\n } else {\n next[key] = value;\n }\n }\n\n return next;\n}\n\nfunction isKeyExcluededFromDump(key: string): boolean {\n return [IsolateKeys.Parent, IsolateKeys.Keys].includes(key as IsolateKeys);\n}\n"],"names":["ErrorStrings","IsolateKeys","MinifiedKeys","KeyToMinified","Type","Keys","Parent","Data","Key","AllowReorder","Status","MinifiedToKey","Object","entries","reduce","acc","key","minified","assign","IsolateMutator","static","isolate","parent","output","child","invariant","children","_a","push","setParent","node","_b","filter","keys","at","isNullish","length","data","IsolateSerializer","root","isStringValue","JSON","parse","validateIsolate","queue","current","shift","getChildren","value","isNotNullish","map","nextChild","stringify","transformIsolate","hasOwnProperty","text","INVALID_ISOLATE_CANNOT_PARSE","next","isKeyExcluededFromDump","includes"],"mappings":"8SAAA,IAAYA,ECAAC,EAUPC,GDVL,SAAYF,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,QACD,CARD,CAAYA,IAAAA,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,EAIH,SAASH,EAAiBhC,GACxB,MAAMoC,EAA4B,CAAA,EAE9BpC,EAAQK,WACV+B,EAAK/B,SAAWL,EAAQK,SAASwB,IAAIG,IAGvC,IAAK,MAAMrC,KAAOK,EAAS,CACzB,GAAY,aAARL,EACF,SAGF,GAAI0C,EAAuB1C,GACzB,SAEF,MAAMgC,EAAQ3B,EAAQL,GAElBmB,EAAAA,UAAUa,KAIVM,EAAcA,eAACnD,EAAea,GAChCyC,EAAKtD,EAAca,IAAQgC,EAE3BS,EAAKzC,GAAOgC,EAEf,CAED,OAAOS,CACT,CAEA,SAASC,EAAuB1C,GAC9B,MAAO,CAACf,EAAYK,OAAQL,EAAYI,MAAMsD,SAAS3C,EACzD"}
|
|
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 'lodash';\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":"oVAAA,IAAYA,ECEAC,EAYAC,GDdZ,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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@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["test-utils"] = {}));
|
|
5
|
-
})(this, (function (exports) { 'use strict';
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('lodash')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'lodash'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["test-utils"] = {}, global.lodash));
|
|
5
|
+
})(this, (function (exports, lodash) { 'use strict';
|
|
6
6
|
|
|
7
7
|
/******************************************************************************
|
|
8
8
|
Copyright (c) Microsoft Corporation.
|
|
@@ -47,16 +47,19 @@
|
|
|
47
47
|
IsolateKeys["Data"] = "data";
|
|
48
48
|
IsolateKeys["AllowReorder"] = "allowReorder";
|
|
49
49
|
IsolateKeys["Status"] = "status";
|
|
50
|
+
IsolateKeys["AbortController"] = "abortController";
|
|
51
|
+
IsolateKeys["Children"] = "children";
|
|
50
52
|
})(IsolateKeys || (IsolateKeys = {}));
|
|
51
53
|
var MinifiedKeys;
|
|
52
54
|
(function (MinifiedKeys) {
|
|
53
55
|
MinifiedKeys["Type"] = "$";
|
|
54
|
-
MinifiedKeys["Keys"] = "
|
|
55
|
-
MinifiedKeys["Key"] = "
|
|
56
|
+
MinifiedKeys["Keys"] = "Ks";
|
|
57
|
+
MinifiedKeys["Key"] = "ky";
|
|
56
58
|
MinifiedKeys["Parent"] = "P";
|
|
57
59
|
MinifiedKeys["Data"] = "D";
|
|
58
|
-
MinifiedKeys["AllowReorder"] = "
|
|
60
|
+
MinifiedKeys["AllowReorder"] = "AR";
|
|
59
61
|
MinifiedKeys["Status"] = "S";
|
|
62
|
+
MinifiedKeys["Children"] = "C";
|
|
60
63
|
})(MinifiedKeys || (MinifiedKeys = {}));
|
|
61
64
|
const KeyToMinified = {
|
|
62
65
|
[IsolateKeys.Type]: MinifiedKeys.Type,
|
|
@@ -66,6 +69,7 @@
|
|
|
66
69
|
[IsolateKeys.Key]: MinifiedKeys.Key,
|
|
67
70
|
[IsolateKeys.AllowReorder]: MinifiedKeys.AllowReorder,
|
|
68
71
|
[IsolateKeys.Status]: MinifiedKeys.Status,
|
|
72
|
+
[IsolateKeys.Children]: MinifiedKeys.Children,
|
|
69
73
|
};
|
|
70
74
|
// This const is an object that looks like this:
|
|
71
75
|
// {
|
|
@@ -74,9 +78,19 @@
|
|
|
74
78
|
// 'P': 'parent',
|
|
75
79
|
// ...
|
|
76
80
|
// }
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
81
|
+
invertKeyMap(KeyToMinified);
|
|
82
|
+
function invertKeyMap(miniMap = {}) {
|
|
83
|
+
return Object.entries(miniMap).reduce((acc, [key, minified]) => lodash.assign(acc, {
|
|
84
|
+
[minified]: key,
|
|
85
|
+
}), {});
|
|
86
|
+
}
|
|
87
|
+
[
|
|
88
|
+
IsolateKeys.AbortController,
|
|
89
|
+
IsolateKeys.Parent,
|
|
90
|
+
IsolateKeys.Keys,
|
|
91
|
+
IsolateKeys.Children,
|
|
92
|
+
IsolateKeys.Data,
|
|
93
|
+
];
|
|
80
94
|
|
|
81
95
|
function genTestIsolate(payload = {}) {
|
|
82
96
|
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":["import { assign } from 'lodash';\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 { 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":["assign"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAEA,IAAY,WAUX,CAAA;IAVD,CAAA,UAAY,WAAW,EAAA;IACrB,IAAA,WAAA,CAAA,MAAA,CAAA,GAAA,OAAc,CAAA;IACd,IAAA,WAAA,CAAA,MAAA,CAAA,GA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M,EAAE,EACxB,CAAA;IACJ;;;;;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["test-utils"]={})}(this,(function(e){"use strict";var
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("lodash")):"function"==typeof define&&define.amd?define(["exports","lodash"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["test-utils"]={},e.lodash)}(this,(function(e,t){"use strict";var r,n;"function"==typeof SuppressedError&&SuppressedError,function(e){e.Type="$type",e.Keys="keys",e.Key="key",e.Parent="parent",e.Data="data",e.AllowReorder="allowReorder",e.Status="status",e.AbortController="abortController",e.Children="children"}(r||(r={})),function(e){e.Type="$",e.Keys="Ks",e.Key="ky",e.Parent="P",e.Data="D",e.AllowReorder="AR",e.Status="S",e.Children="C"}(n||(n={}));!function(e={}){Object.entries(e).reduce(((e,[r,n])=>t.assign(e,{[n]:r})),{})}({[r.Type]:n.Type,[r.Keys]:n.Keys,[r.Parent]:n.Parent,[r.Data]:n.Data,[r.Key]:n.Key,[r.AllowReorder]:n.AllowReorder,[r.Status]:n.Status,[r.Children]:n.Children}),r.AbortController,r.Parent,r.Keys,r.Children,r.Data,e.genTestIsolate=function(e={}){const{status:t}=e,n=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r}(e,["status"]);return Object.assign({children:[],data:n,key:null,keys:{},output:null,parent:null,[r.Type]:"UnitTest"},t&&{status:t})}}));
|
|
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":["import { assign } from 'lodash';\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 { 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","MinifiedKeys","miniMap","Object","entries","reduce","acc","key","minified","assign","invertKeyMap","Type","Keys","Parent","Data","Key","AllowReorder","Status","Children","AbortController","payload","status","data","__rest","children","keys","output","parent"],"mappings":"2RAEA,IAAYA,EAYAC,sDAZZ,SAAYD,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,KAsBe,SAAaC,EAAkC,IACtDC,OAAOC,QAAQF,GAASG,QAC7B,CAACC,GAAMC,EAAKC,KACVC,EAAAA,OAAOH,EAAK,CACVE,CAACA,GAAWD,KAEhB,CAA4B,EAEhC,CAV6BG,CAlBA,CAC3B,CAACV,EAAYW,MAAOV,EAAaU,KACjC,CAACX,EAAYY,MAAOX,EAAaW,KACjC,CAACZ,EAAYa,QAASZ,EAAaY,OACnC,CAACb,EAAYc,MAAOb,EAAaa,KACjC,CAACd,EAAYe,KAAMd,EAAac,IAChC,CAACf,EAAYgB,cAAef,EAAae,aACzC,CAAChB,EAAYiB,QAAShB,EAAagB,OACnC,CAACjB,EAAYkB,UAAWjB,EAAaiB,WAuBrClB,EAAYmB,gBACZnB,EAAYa,OACZb,EAAYY,KACZZ,EAAYkB,SACZlB,EAAYc,sBCzDE,SAAeM,EAA+B,IAC5D,MAAMC,OAAEA,GAAoBD,EAATE,2UAAIC,CAAKH,EAAtB,CAAmB,WACzB,OAAAjB,OAAAM,OAAA,CACEe,SAAU,GACVF,OACAf,IAAK,KACLkB,KAAM,GACNC,OAAQ,KACRC,OAAQ,KACR,CAAC3B,EAAYW,MAAO,YAChBU,GAAU,CAAEA,UAEpB"}
|