vestjs-runtime 1.0.6 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/IsolateSerializer.development.js +0 -13
- 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 +37 -18
- 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 +31 -51
- 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 +0 -13
- 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 +37 -18
- 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 +31 -52
- 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 +0 -13
- 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 +80 -61
- 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 +690 -710
- 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 +2 -6
- package/types/IsolateSerializer.d.ts.map +1 -1
- package/types/test-utils.d.ts +3 -7
- package/types/test-utils.d.ts.map +1 -1
- package/types/vestjs-runtime.d.ts +16 -21
- package/types/vestjs-runtime.d.ts.map +1 -1
|
@@ -50,13 +50,6 @@ const MinifiedToKey = Object.entries(KeyToMinified).reduce((acc, [key, minified]
|
|
|
50
50
|
[minified]: key,
|
|
51
51
|
}), {});
|
|
52
52
|
|
|
53
|
-
var IsolateStatus;
|
|
54
|
-
(function (IsolateStatus) {
|
|
55
|
-
IsolateStatus["PENDING"] = "PENDING";
|
|
56
|
-
IsolateStatus["DONE"] = "DONE";
|
|
57
|
-
IsolateStatus["INITIAL"] = "INITIAL";
|
|
58
|
-
})(IsolateStatus || (IsolateStatus = {}));
|
|
59
|
-
|
|
60
53
|
class IsolateMutator {
|
|
61
54
|
static setParent(isolate, parent) {
|
|
62
55
|
isolate.parent = parent;
|
|
@@ -97,12 +90,6 @@ class IsolateMutator {
|
|
|
97
90
|
static setData(isolate, data) {
|
|
98
91
|
isolate.data = data;
|
|
99
92
|
}
|
|
100
|
-
static setPending(isolate) {
|
|
101
|
-
isolate.status = IsolateStatus.PENDING;
|
|
102
|
-
}
|
|
103
|
-
static setDone(isolate) {
|
|
104
|
-
isolate.status = IsolateStatus.DONE;
|
|
105
|
-
}
|
|
106
93
|
}
|
|
107
94
|
|
|
108
95
|
class IsolateSerializer {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IsolateSerializer.development.js","sources":["../../src/errors/ErrorStrings.ts","../../src/Isolate/IsolateKeys.ts","../../src/Isolate/IsolateStatus.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","export enum IsolateStatus {\n PENDING = 'PENDING',\n DONE = 'DONE',\n INITIAL = 'INITIAL',\n}\n","import { Nullable, invariant, isNullish } from 'vest-utils';\n\nimport { TIsolate } from 'Isolate';\nimport { IsolateStatus } from 'IsolateStatus';\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 setPending(isolate: TIsolate): void {\n isolate.status = IsolateStatus.PENDING;\n }\n\n static setDone(isolate: TIsolate): void {\n isolate.status = IsolateStatus.DONE;\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":";;;;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,CAA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,CAAC,IAAI,EAAE,aAAa,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,EACvDC,cAAI,CAAC,YAAY,CAAC,4BAA4B,CAAC,CAChD,CAAC;KACH;AACF,CAAA;AAED;AACA,SAAS,gBAAgB,CAAC,OAAiB,EAAA;IACzC,MAAM,IAAI,GAAwB,EAAE,CAAC;IAErC,IAAI,OAAO,CAAC,QAAQ,EAAE;QACpB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;AACxD,KAAA;AAED,IAAA,KAAK,MAAM,GAAG,IAAI,OAAO,EAAE;QACzB,IAAI,GAAG,KAAK,UAAU,EAAE;YACtB,SAAS;AACV,SAAA;AAED,QAAA,IAAI,sBAAsB,CAAC,GAAG,CAAC,EAAE;YAC/B,SAAS;AACV,SAAA;AACD,QAAA,MAAM,KAAK,GAAG,OAAO,CAAC,GAAqB,CAAC,CAAC;AAE7C,QAAA,IAAIJ,mBAAS,CAAC,KAAK,CAAC,EAAE;YACpB,SAAS;AACV,SAAA;AAED,QAAA,IAAIG,wBAAc,CAAC,aAAa,EAAE,GAAG,CAAC,EAAE;YACtC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC;AAClC,SAAA;AAAM,aAAA;AACL,YAAA,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AACnB,SAAA;AACF,KAAA;AAED,IAAA,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,sBAAsB,CAAC,GAAW,EAAA;AACzC,IAAA,OAAO,CAAC,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,GAAkB,CAAC,CAAC;AAC7E;;;;"}
|
|
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":";;;;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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AAC,CAAC;AAE7C,QAAA,IAAIJ,mBAAS,CAAC,KAAK,CAAC,EAAE;YACpB,SAAS;AACV,SAAA;AAED,QAAA,IAAIG,wBAAc,CAAC,aAAa,EAAE,GAAG,CAAC,EAAE;YACtC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC;AAClC,SAAA;AAAM,aAAA;AACL,YAAA,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AACnB,SAAA;AACF,KAAA;AAED,IAAA,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,sBAAsB,CAAC,GAAW,EAAA;AACzC,IAAA,OAAO,CAAC,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,GAAkB,CAAC,CAAC;AAC7E;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e,t,s
|
|
1
|
+
"use strict";var e,t,i,s=require("vest-utils");!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."}(e||(e={})),function(e){e.Type="$type",e.Keys="keys",e.Key="key",e.Parent="parent",e.Data="data",e.AllowReorder="allowReorder",e.Status="status"}(t||(t={})),function(e){e.Type="$",e.Keys="K",e.Key="k",e.Parent="P",e.Data="D",e.AllowReorder="aR",e.Status="S"}(i||(i={}));const n={[t.Type]:i.Type,[t.Keys]:i.Keys,[t.Parent]:i.Parent,[t.Data]:i.Data,[t.Key]:i.Key,[t.AllowReorder]:i.AllowReorder,[t.Status]:i.Status},a=Object.entries(n).reduce(((e,[t,i])=>Object.assign(e,{[i]:t})),{});class r{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,t){var i;s.invariant(e),e.children=null!==(i=e.children)&&void 0!==i?i:[],e.children.push(t),r.setParent(t,e)}static removeChild(e,t){var i,s;e.children=null!==(s=null===(i=e.children)||void 0===i?void 0:i.filter((e=>e!==t)))&&void 0!==s?s:null}static addChildKey(e,t,i){var n;s.invariant(e),e.keys=null!==(n=e.keys)&&void 0!==n?n:{},e.keys[t]=i}static slice(e,t){s.isNullish(e.children)||(e.children.length=t)}static setData(e,t){e.data=t}}class l{static deserialize(e){const t=s.isStringValue(e)?JSON.parse(e):Object.assign({},e);l.validateIsolate(t);const i=[t];for(;i.length;){const e=i.shift(),t=l.getChildren(e);for(const t in a){const i=e[t];s.isNotNullish(i)&&(e[a[t]]=i,delete e[t])}t&&(e.children=t.map((t=>{var s;const n=Object.assign({},t);r.setParent(n,e),i.push(n);const a=n.key;return a&&(e.keys=null!==(s=e.keys)&&void 0!==s?s:{},e.keys[a]=n),n})))}return t}static serialize(e){return s.isNullish(e)?"":JSON.stringify(o(e))}static getChildren(e){return e.children?[...e.children]:null}static validateIsolate(i){s.invariant(s.hasOwnProperty(i,t.Type)||s.hasOwnProperty(i,n[t.Type]),s.text(e.INVALID_ISOLATE_CANNOT_PARSE))}}function o(e){const t={};e.children&&(t.children=e.children.map(o));for(const i in e){if("children"===i)continue;if(c(i))continue;const a=e[i];s.isNullish(a)||(s.hasOwnProperty(n,i)?t[n[i]]=a:t[i]=a)}return t}function c(e){return[t.Parent,t.Keys].includes(e)}exports.IsolateSerializer=l;
|
|
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/IsolateStatus.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","export enum IsolateStatus {\n PENDING = 'PENDING',\n DONE = 'DONE',\n INITIAL = 'INITIAL',\n}\n","import { Nullable, invariant, isNullish } from 'vest-utils';\n\nimport { TIsolate } from 'Isolate';\nimport { IsolateStatus } from 'IsolateStatus';\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 setPending(isolate: TIsolate): void {\n isolate.status = IsolateStatus.PENDING;\n }\n\n static setDone(isolate: TIsolate): void {\n isolate.status = IsolateStatus.DONE;\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","IsolateStatus","IsolateMutator","static","isolate","parent","output","child","invariant","children","_a","push","setParent","node","_b","filter","keys","at","isNullish","length","data","status","PENDING","DONE","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":"iBAAYA,ECAAC,EAUPC,2BDVL,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,EAQX,CAAA,IAED,SAAKC,GACHA,EAAA,KAAA,IACAA,EAAA,KAAA,IACAA,EAAA,IAAA,IACAA,EAAA,OAAA,IACAA,EAAA,KAAA,IACAA,EAAA,aAAA,KACAA,EAAA,OAAA,GACD,CARD,CAAKA,IAAAA,EAQJ,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,QAUxBC,EAAgBC,OAAOC,QAAQV,GAAeW,QACzD,CAACC,GAAMC,EAAKC,KACVL,OAAOM,OAAOH,EAAK,CACjBE,CAACA,GAAWD,KAEhB,CAAA,GC1CF,IAAYG,GAAZ,SAAYA,GACVA,EAAA,QAAA,UACAA,EAAA,KAAA,OACAA,EAAA,QAAA,SACD,CAJD,CAAYA,IAAAA,EAIX,CAAA,UCCYC,EACXC,iBAAiBC,EAAmBC,GAElC,OADAD,EAAQC,OAASA,EACVD,CACR,CAEDD,kBAAkB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AAQoC,SACvBH,EAAQjC,GAElB,CAEIW,IAILsB,EAAQtB,SAAWA,EAAS2B,KAAI7B,UAC9B,MAAM8B,EAAS3C,OAAAM,OAAA,CAAA,EAAQO,GAEvBL,EAAeU,UAAUyB,EAAWN,GACpCD,EAAMnB,KAAK0B,GAEX,MAAMvC,EAAMuC,EAAUvC,IAOtB,OALIA,IACFiC,EAAQf,KAAuB,QAAhBN,EAAAqB,EAAQf,YAAQ,IAAAN,EAAAA,EAAA,CAAA,EAC/BqB,EAAQf,KAAKlB,GAAOuC,GAGfA,CAAS,IAEnB,CAED,OAAOZ,CACR,CAEDtB,iBAAiBC,GACf,OAAIc,EAAAA,UAAUd,GACL,GAGFuB,KAAKW,UAAUC,EAAiBnC,GACxC,CAEDD,mBAAmBU,GACjB,OAAOA,EAAKJ,SAAW,IAAII,EAAKJ,UAAY,IAC7C,CAEDN,uBAAuBU,GACrBL,EAAAA,UACEgC,EAAcA,eAAC3B,EAAM9B,EAAYG,OAC/BsD,iBAAe3B,EAAM5B,EAAcF,EAAYG,OACjDuD,OAAK3D,EAAa4D,8BAErB,EAIH,SAASH,EAAiBnC,GACxB,MAAMuC,EAA4B,CAAA,EAE9BvC,EAAQK,WACVkC,EAAKlC,SAAWL,EAAQK,SAAS2B,IAAIG,IAGvC,IAAK,MAAMzC,KAAOM,EAAS,CACzB,GAAY,aAARN,EACF,SAGF,GAAI8C,EAAuB9C,GACzB,SAEF,MAAMoC,EAAQ9B,EAAQN,GAElBoB,EAAAA,UAAUgB,KAIVM,EAAcA,eAACvD,EAAea,GAChC6C,EAAK1D,EAAca,IAAQoC,EAE3BS,EAAK7C,GAAOoC,EAEf,CAED,OAAOS,CACT,CAEA,SAASC,EAAuB9C,GAC9B,MAAO,CAACf,EAAYK,OAAQL,EAAYI,MAAM0D,SAAS/C,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","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":"iBAAYA,ECAAC,EAUPC,2BDV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iBAAiBC,GACf,OAAIc,EAAAA,UAAUd,GACL,GAGFoB,KAAKW,UAAUC,EAAiBhC,GACxC,CAEDD,mBAAmBU,GACjB,OAAOA,EAAKJ,SAAW,IAAII,EAAKJ,UAAY,IAC7C,CAEDN,uBAAuBU,GACrBL,EAAAA,UACE6B,EAAcA,eAACxB,EAAM7B,EAAYG,OAC/BkD,iBAAexB,EAAM3B,EAAcF,EAAYG,OACjDmD,OAAKvD,EAAawD,8BAErB,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,5 +1,39 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
/******************************************************************************
|
|
4
|
+
Copyright (c) Microsoft Corporation.
|
|
5
|
+
|
|
6
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
7
|
+
purpose with or without fee is hereby granted.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
10
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
11
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
12
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
13
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
14
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
15
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
16
|
+
***************************************************************************** */
|
|
17
|
+
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
function __rest(s, e) {
|
|
21
|
+
var t = {};
|
|
22
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
23
|
+
t[p] = s[p];
|
|
24
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
25
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
26
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
27
|
+
t[p[i]] = s[p[i]];
|
|
28
|
+
}
|
|
29
|
+
return t;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
33
|
+
var e = new Error(message);
|
|
34
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
35
|
+
};
|
|
36
|
+
|
|
3
37
|
var IsolateKeys;
|
|
4
38
|
(function (IsolateKeys) {
|
|
5
39
|
IsolateKeys["Type"] = "$type";
|
|
@@ -40,24 +74,9 @@ Object.entries(KeyToMinified).reduce((acc, [key, minified]) => Object.assign(acc
|
|
|
40
74
|
[minified]: key,
|
|
41
75
|
}), {});
|
|
42
76
|
|
|
43
|
-
|
|
44
|
-
(
|
|
45
|
-
|
|
46
|
-
IsolateStatus["DONE"] = "DONE";
|
|
47
|
-
IsolateStatus["INITIAL"] = "INITIAL";
|
|
48
|
-
})(IsolateStatus || (IsolateStatus = {}));
|
|
49
|
-
|
|
50
|
-
function genTestIsolate(data = {}) {
|
|
51
|
-
return {
|
|
52
|
-
children: [],
|
|
53
|
-
data,
|
|
54
|
-
key: null,
|
|
55
|
-
keys: {},
|
|
56
|
-
output: null,
|
|
57
|
-
parent: null,
|
|
58
|
-
status: IsolateStatus.INITIAL,
|
|
59
|
-
[IsolateKeys.Type]: 'UnitTest',
|
|
60
|
-
};
|
|
77
|
+
function genTestIsolate(payload = {}) {
|
|
78
|
+
const { status } = payload, data = __rest(payload, ["status"]);
|
|
79
|
+
return Object.assign({ children: [], data, key: null, keys: {}, output: null, parent: null, [IsolateKeys.Type]: 'UnitTest' }, (status && { status }));
|
|
61
80
|
}
|
|
62
81
|
|
|
63
82
|
exports.genTestIsolate = genTestIsolate;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-utils.development.js","sources":["../../src/Isolate/IsolateKeys.ts","../../src/
|
|
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}\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 { 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAY,WAQX,CAAA;AARD,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;AACnB,CAAC,EARW,WAAW,KAAX,WAAW,GAQtB,EAAA,CAAA,CAAA,CAAA;AAED,IAAK,YAQJ,CAAA;AARD,CAAA,UAAK,YAAY,EAAA;AACf,IAAA,YAAA,CAAA,MAAA,CAAA,GAAA,GAAU,CAAA;AACV,IAAA,YAAA,CAAA,MAAA,CAAA,GAAA,GAAU,CAAA;AACV,IAAA,YAAA,CAAA,KAAA,CAAA,GAAA,GAAS,CAAA;AACT,IAAA,YAAA,CAAA,QAAA,CAAA,GAAA,GAAY,CAAA;AACZ,IAAA,YAAA,CAAA,MAAA,CAAA,GAAA,GAAU,CAAA;AACV,IAAA,YAAA,CAAA,cAAA,CAAA,GAAA,IAAmB,CAAA;AACnB,IAAA,YAA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,EAAE,EACxB,CAAA;AACJ;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e,t
|
|
1
|
+
"use strict";var e,t;"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||(e={})),function(e){e.Type="$",e.Keys="K",e.Key="k",e.Parent="P",e.Data="D",e.AllowReorder="aR",e.Status="S"}(t||(t={}));const r={[e.Type]:t.Type,[e.Keys]:t.Keys,[e.Parent]:t.Parent,[e.Data]:t.Data,[e.Key]:t.Key,[e.AllowReorder]:t.AllowReorder,[e.Status]:t.Status};Object.entries(r).reduce(((e,[t,r])=>Object.assign(e,{[r]:t})),{}),exports.genTestIsolate=function(t={}){const{status:r}=t,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 a=0;for(n=Object.getOwnPropertySymbols(e);a<n.length;a++)t.indexOf(n[a])<0&&Object.prototype.propertyIsEnumerable.call(e,n[a])&&(r[n[a]]=e[n[a]])}return r}(t,["status"]);return Object.assign({children:[],data:n,key:null,keys:{},output:null,parent:null,[e.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/
|
|
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}\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 { 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","KeyToMinified","Type","Keys","Parent","Data","Key","AllowReorder","Status","Object","entries","reduce","acc","key","minified","assign","payload","status","data","__rest","children","keys","output","parent"],"mappings":"aAAA,IAAYA,EAUPC,sDAVL,SAAYD,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,EAQX,CAAA,IAED,SAAKC,GACHA,EAAA,KAAA,IACAA,EAAA,KAAA,IACAA,EAAA,IAAA,IACAA,EAAA,OAAA,IACAA,EAAA,KAAA,IACAA,EAAA,aAAA,KACAA,EAAA,OAAA,GACD,CARD,CAAKA,IAAAA,EAQJ,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,QAURC,OAAOC,QAAQT,GAAeU,QACzD,CAACC,GAAMC,EAAKC,KACVL,OAAOM,OAAOH,EAAK,CACjBE,CAACA,GAAWD,KAEhB,CAAiC,0BCvCnB,SAAeG,EAA+B,IAC5D,MAAMC,OAAEA,GAAoBD,EAATE,2UAAIC,CAAKH,EAAtB,CAAmB,WACzB,OAAAP,OAAAM,OAAA,CACEK,SAAU,GACVF,OACAL,IAAK,KACLQ,KAAM,GACNC,OAAQ,KACRC,OAAQ,KACR,CAACxB,EAAYG,MAAO,YAChBe,GAAU,CAAEA,UAEpB"}
|
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
var vestUtils = require('vest-utils');
|
|
4
4
|
var context = require('context');
|
|
5
5
|
|
|
6
|
+
const RuntimeEvents = {
|
|
7
|
+
ISOLATE_ENTER: 'ISOLATE_ENTER',
|
|
8
|
+
ISOLATE_PENDING: 'ISOLATE_PENDING',
|
|
9
|
+
ISOLATE_DONE: 'ISOLATE_DONE',
|
|
10
|
+
};
|
|
11
|
+
|
|
6
12
|
/******************************************************************************
|
|
7
13
|
Copyright (c) Microsoft Corporation.
|
|
8
14
|
|
|
@@ -84,13 +90,6 @@ class IsolateInspector {
|
|
|
84
90
|
}
|
|
85
91
|
}
|
|
86
92
|
|
|
87
|
-
exports.IsolateStatus = void 0;
|
|
88
|
-
(function (IsolateStatus) {
|
|
89
|
-
IsolateStatus["PENDING"] = "PENDING";
|
|
90
|
-
IsolateStatus["DONE"] = "DONE";
|
|
91
|
-
IsolateStatus["INITIAL"] = "INITIAL";
|
|
92
|
-
})(exports.IsolateStatus || (exports.IsolateStatus = {}));
|
|
93
|
-
|
|
94
93
|
class IsolateMutator {
|
|
95
94
|
static setParent(isolate, parent) {
|
|
96
95
|
isolate.parent = parent;
|
|
@@ -131,12 +130,6 @@ class IsolateMutator {
|
|
|
131
130
|
static setData(isolate, data) {
|
|
132
131
|
isolate.data = data;
|
|
133
132
|
}
|
|
134
|
-
static setPending(isolate) {
|
|
135
|
-
isolate.status = exports.IsolateStatus.PENDING;
|
|
136
|
-
}
|
|
137
|
-
static setDone(isolate) {
|
|
138
|
-
isolate.status = exports.IsolateStatus.DONE;
|
|
139
|
-
}
|
|
140
133
|
}
|
|
141
134
|
|
|
142
135
|
const PersistedContext = context.createCascade((stateRef, parentContext) => {
|
|
@@ -300,10 +293,10 @@ function usePrepareEmitter(event) {
|
|
|
300
293
|
}
|
|
301
294
|
|
|
302
295
|
var Bus = /*#__PURE__*/Object.freeze({
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
296
|
+
__proto__: null,
|
|
297
|
+
useBus: useBus,
|
|
298
|
+
useEmit: useEmit,
|
|
299
|
+
usePrepareEmitter: usePrepareEmitter
|
|
307
300
|
});
|
|
308
301
|
|
|
309
302
|
var IsolateKeys;
|
|
@@ -357,10 +350,10 @@ function isSameIsolateIdentity(a, b) {
|
|
|
357
350
|
}
|
|
358
351
|
|
|
359
352
|
var IsolateSelectors = /*#__PURE__*/Object.freeze({
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
353
|
+
__proto__: null,
|
|
354
|
+
isIsolateType: isIsolateType,
|
|
355
|
+
isSameIsolateIdentity: isSameIsolateIdentity,
|
|
356
|
+
isSameIsolateType: isSameIsolateType
|
|
364
357
|
});
|
|
365
358
|
|
|
366
359
|
function BaseReconciler(currentNode, historyNode) {
|
|
@@ -433,10 +426,6 @@ function removeAllNextNodesInIsolate() {
|
|
|
433
426
|
IsolateMutator.slice(historyNode, IsolateInspector.cursor(currentNode));
|
|
434
427
|
}
|
|
435
428
|
|
|
436
|
-
const RuntimeEvents = {
|
|
437
|
-
ASYNC_ISOLATE_DONE: 'ASYNC_ISOLATE_DONE',
|
|
438
|
-
};
|
|
439
|
-
|
|
440
429
|
class Isolate {
|
|
441
430
|
static create(type, callback, payload = undefined, key) {
|
|
442
431
|
const parent = useIsolate();
|
|
@@ -469,19 +458,19 @@ function useRunAsNew(localHistoryNode, current, callback) {
|
|
|
469
458
|
// We're creating a new child isolate context where the local history node
|
|
470
459
|
// is the current history node, thus advancing the history cursor.
|
|
471
460
|
const output = Run(Object.assign({ historyNode: localHistoryNode, runtimeNode: current }, (!runtimeRoot && { runtimeRoot: current })), () => {
|
|
461
|
+
emit(RuntimeEvents.ISOLATE_ENTER, current);
|
|
472
462
|
const output = callback(current);
|
|
473
463
|
if (vestUtils.isPromise(output)) {
|
|
474
|
-
|
|
464
|
+
emit(RuntimeEvents.ISOLATE_PENDING, current);
|
|
475
465
|
output.then(iso => {
|
|
476
466
|
if (Isolate.isIsolate(iso)) {
|
|
477
467
|
IsolateMutator.addChild(current, iso);
|
|
478
468
|
}
|
|
479
|
-
|
|
480
|
-
emit(RuntimeEvents.ASYNC_ISOLATE_DONE, current);
|
|
469
|
+
emit(RuntimeEvents.ISOLATE_DONE, current);
|
|
481
470
|
});
|
|
482
471
|
}
|
|
483
472
|
else {
|
|
484
|
-
|
|
473
|
+
emit(RuntimeEvents.ISOLATE_DONE, current);
|
|
485
474
|
}
|
|
486
475
|
return output;
|
|
487
476
|
});
|
|
@@ -489,18 +478,8 @@ function useRunAsNew(localHistoryNode, current, callback) {
|
|
|
489
478
|
return output;
|
|
490
479
|
}
|
|
491
480
|
function baseIsolate(type, payload = undefined, key = null) {
|
|
492
|
-
const _a = payload !== null && payload !== void 0 ? payload : {}, { allowReorder } = _a, data = __rest(_a, ["allowReorder"]);
|
|
493
|
-
return {
|
|
494
|
-
[IsolateKeys.AllowReorder]: allowReorder,
|
|
495
|
-
[IsolateKeys.Keys]: null,
|
|
496
|
-
[IsolateKeys.Parent]: null,
|
|
497
|
-
[IsolateKeys.Type]: type,
|
|
498
|
-
[IsolateKeys.Data]: data,
|
|
499
|
-
[IsolateKeys.Status]: exports.IsolateStatus.INITIAL,
|
|
500
|
-
children: null,
|
|
501
|
-
key,
|
|
502
|
-
output: null,
|
|
503
|
-
};
|
|
481
|
+
const _a = payload !== null && payload !== void 0 ? payload : {}, { allowReorder, status } = _a, data = __rest(_a, ["allowReorder", "status"]);
|
|
482
|
+
return Object.assign(Object.assign({ [IsolateKeys.AllowReorder]: allowReorder, [IsolateKeys.Keys]: null, [IsolateKeys.Parent]: null, [IsolateKeys.Type]: type, [IsolateKeys.Data]: data }, (status && { [IsolateKeys.Status]: status })), { children: null, key, output: null });
|
|
504
483
|
}
|
|
505
484
|
|
|
506
485
|
// eslint-disable-next-line
|
|
@@ -622,16 +601,16 @@ function closestExists(startNode, predicate) {
|
|
|
622
601
|
}
|
|
623
602
|
|
|
624
603
|
var IsolateWalker = /*#__PURE__*/Object.freeze({
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
604
|
+
__proto__: null,
|
|
605
|
+
closest: closest,
|
|
606
|
+
closestExists: closestExists,
|
|
607
|
+
every: every,
|
|
608
|
+
find: find,
|
|
609
|
+
findClosest: findClosest,
|
|
610
|
+
has: has,
|
|
611
|
+
pluck: pluck,
|
|
612
|
+
some: some,
|
|
613
|
+
walk: walk
|
|
635
614
|
});
|
|
636
615
|
|
|
637
616
|
class IsolateSerializer {
|
|
@@ -728,6 +707,7 @@ exports.IsolateMutator = IsolateMutator;
|
|
|
728
707
|
exports.IsolateSelectors = IsolateSelectors;
|
|
729
708
|
exports.IsolateSerializer = IsolateSerializer;
|
|
730
709
|
exports.Reconciler = Reconciler;
|
|
710
|
+
exports.RuntimeEvents = RuntimeEvents;
|
|
731
711
|
exports.VestRuntime = RuntimeApi;
|
|
732
712
|
exports.Walker = IsolateWalker;
|
|
733
713
|
//# sourceMappingURL=vestjs-runtime.development.js.map
|