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.
Files changed (43) hide show
  1. package/dist/cjs/IsolateSerializer.development.js +114 -26
  2. package/dist/cjs/IsolateSerializer.development.js.map +1 -1
  3. package/dist/cjs/IsolateSerializer.production.js +1 -1
  4. package/dist/cjs/IsolateSerializer.production.js.map +1 -1
  5. package/dist/cjs/test-utils.development.js +22 -6
  6. package/dist/cjs/test-utils.development.js.map +1 -1
  7. package/dist/cjs/test-utils.production.js +1 -1
  8. package/dist/cjs/test-utils.production.js.map +1 -1
  9. package/dist/cjs/vestjs-runtime.development.js +114 -27
  10. package/dist/cjs/vestjs-runtime.development.js.map +1 -1
  11. package/dist/cjs/vestjs-runtime.production.js +1 -1
  12. package/dist/cjs/vestjs-runtime.production.js.map +1 -1
  13. package/dist/es/IsolateSerializer.development.js +115 -28
  14. package/dist/es/IsolateSerializer.development.js.map +1 -1
  15. package/dist/es/IsolateSerializer.production.js +1 -1
  16. package/dist/es/IsolateSerializer.production.js.map +1 -1
  17. package/dist/es/test-utils.development.js +22 -6
  18. package/dist/es/test-utils.development.js.map +1 -1
  19. package/dist/es/test-utils.production.js +1 -1
  20. package/dist/es/test-utils.production.js.map +1 -1
  21. package/dist/es/vestjs-runtime.development.js +115 -28
  22. package/dist/es/vestjs-runtime.development.js.map +1 -1
  23. package/dist/es/vestjs-runtime.production.js +1 -1
  24. package/dist/es/vestjs-runtime.production.js.map +1 -1
  25. package/dist/umd/IsolateSerializer.development.js +117 -30
  26. package/dist/umd/IsolateSerializer.development.js.map +1 -1
  27. package/dist/umd/IsolateSerializer.production.js +1 -1
  28. package/dist/umd/IsolateSerializer.production.js.map +1 -1
  29. package/dist/umd/test-utils.development.js +24 -10
  30. package/dist/umd/test-utils.development.js.map +1 -1
  31. package/dist/umd/test-utils.production.js +1 -1
  32. package/dist/umd/test-utils.production.js.map +1 -1
  33. package/dist/umd/vestjs-runtime.development.js +117 -31
  34. package/dist/umd/vestjs-runtime.development.js.map +1 -1
  35. package/dist/umd/vestjs-runtime.production.js +1 -1
  36. package/dist/umd/vestjs-runtime.production.js.map +1 -1
  37. package/package.json +3 -3
  38. package/types/IsolateSerializer.d.ts +22 -7
  39. package/types/IsolateSerializer.d.ts.map +1 -1
  40. package/types/test-utils.d.ts +5 -1
  41. package/types/test-utils.d.ts.map +1 -1
  42. package/types/vestjs-runtime.d.ts +51 -21
  43. package/types/vestjs-runtime.d.ts.map +1 -1
@@ -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":"yHAAA,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,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,CA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EAAaD,KACfH,EAAQlC,EAAcK,IAAQgC,SACvBH,EAAQ7B,GAElB,CAEIU,IAILmB,EAAQnB,SAAWA,EAASwB,KAAI1B,UAC9B,MAAM2B,EAASvC,OAAAM,OAAA,CAAA,EAAQM,GAEvBL,EAAeU,UAAUsB,EAAWN,GACpCD,EAAMhB,KAAKuB,GAEX,MAAMnC,EAAMmC,EAAUnC,IAOtB,OALIA,IACF6B,EAAQZ,KAAuB,QAAhBN,EAAAkB,EAAQZ,YAAQ,IAAAN,EAAAA,EAAA,CAAA,EAC/BkB,EAAQZ,KAAKjB,GAAOmC,GAGfA,CAAS,IAEnB,CAED,OAAOZ,CACR,CAEDnB,iBAAiBC,GACf,OAAIc,EAAUd,GACL,GAGFoB,KAAKW,UAAUC,EAAiBhC,GACxC,CAEDD,mBAAmBU,GACjB,OAAOA,EAAKJ,SAAW,IAAII,EAAKJ,UAAY,IAC7C,CAEDN,uBAAuBU,GACrBL,EACE6B,EAAexB,EAAM7B,EAAYG,OAC/BkD,EAAexB,EAAM3B,EAAcF,EAAYG,OACjDmD,EAAKvD,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,EAAUa,KAIVM,EAAenD,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":"kLAAA,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,IAAA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AnB5C,EAAAe,aAAA,EAAAA,EAAU8B,cAAS,IAAA7C,OAAA,EAAAA,EAAAd,GAElC,OAAO0D,aAASA,EAAOjB,kBAAkBA,CAC3C,CAEA,SAASG,EACPpB,EACAkC,SAEA,MAAML,EAA4B,CAAA,EAGlC,IAAK,MAAMrD,KAAOwB,EAAM,CAOtB6B,EAH6C,QAA5BvC,EAAC4C,EAASA,EAAO1D,GAAOA,SAAI,IAAAc,EAAAA,EAAId,GAGhCwB,EAAKxB,EACvB,CAGD,OAAOqD,CACT,CAcgB,SAAAtB,EAAmBF,EAA4B,IAC7D,OAAOjC,OAAOC,QAAQgC,GAAU/B,QAAO,CAACC,GAAMC,EAAKyC,KAExCvC,EAAOH,EADK,iBAAV0C,EACU,CACjBzC,CAACA,GAAM+B,EAAmBU,IAGX,CACjBA,CAACA,GAAQzC,KAEV,CAAc,EACnB"}
@@ -1,3 +1,5 @@
1
+ import { assign } from 'lodash';
2
+
1
3
  /******************************************************************************
2
4
  Copyright (c) Microsoft Corporation.
3
5
 
@@ -41,16 +43,19 @@ var IsolateKeys;
41
43
  IsolateKeys["Data"] = "data";
42
44
  IsolateKeys["AllowReorder"] = "allowReorder";
43
45
  IsolateKeys["Status"] = "status";
46
+ IsolateKeys["AbortController"] = "abortController";
47
+ IsolateKeys["Children"] = "children";
44
48
  })(IsolateKeys || (IsolateKeys = {}));
45
49
  var MinifiedKeys;
46
50
  (function (MinifiedKeys) {
47
51
  MinifiedKeys["Type"] = "$";
48
- MinifiedKeys["Keys"] = "K";
49
- MinifiedKeys["Key"] = "k";
52
+ MinifiedKeys["Keys"] = "Ks";
53
+ MinifiedKeys["Key"] = "ky";
50
54
  MinifiedKeys["Parent"] = "P";
51
55
  MinifiedKeys["Data"] = "D";
52
- MinifiedKeys["AllowReorder"] = "aR";
56
+ MinifiedKeys["AllowReorder"] = "AR";
53
57
  MinifiedKeys["Status"] = "S";
58
+ MinifiedKeys["Children"] = "C";
54
59
  })(MinifiedKeys || (MinifiedKeys = {}));
55
60
  const KeyToMinified = {
56
61
  [IsolateKeys.Type]: MinifiedKeys.Type,
@@ -60,6 +65,7 @@ const KeyToMinified = {
60
65
  [IsolateKeys.Key]: MinifiedKeys.Key,
61
66
  [IsolateKeys.AllowReorder]: MinifiedKeys.AllowReorder,
62
67
  [IsolateKeys.Status]: MinifiedKeys.Status,
68
+ [IsolateKeys.Children]: MinifiedKeys.Children,
63
69
  };
64
70
  // This const is an object that looks like this:
65
71
  // {
@@ -68,9 +74,19 @@ const KeyToMinified = {
68
74
  // 'P': 'parent',
69
75
  // ...
70
76
  // }
71
- Object.entries(KeyToMinified).reduce((acc, [key, minified]) => Object.assign(acc, {
72
- [minified]: key,
73
- }), {});
77
+ invertKeyMap(KeyToMinified);
78
+ function invertKeyMap(miniMap = {}) {
79
+ return Object.entries(miniMap).reduce((acc, [key, minified]) => assign(acc, {
80
+ [minified]: key,
81
+ }), {});
82
+ }
83
+ [
84
+ IsolateKeys.AbortController,
85
+ IsolateKeys.Parent,
86
+ IsolateKeys.Keys,
87
+ IsolateKeys.Children,
88
+ IsolateKeys.Data,
89
+ ];
74
90
 
75
91
  function genTestIsolate(payload = {}) {
76
92
  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":["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,CAA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,EACE,QAAQ,EAAE,EAAE,EACZ,IAAI,EACJ,GAAG,EAAE,IAAI,EACT,IAAI,EAAE,EAAE,EACR,MAAM,EAAE,IAAI,EACZ,MAAM,EAAE,IAAI,EACZ,CAAC,WAAW,CAAC,IAAI,GAAG,UAAU,EAAA,GAC1B,MAAM,IAAI,EAAE,MAAM,EAAE,EACxB,CAAA;AACJ;;;;"}
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":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAY,WAUX,CAAA;AAVD,CAAA,UAAY,WAAW,EAAA;AACrB,IAAA,WAAA,CAAA,MAAA,CAAA,GAAA,OAAc,CAAA;AACd,IAAA,WAAA,CAAA,MAAA,CAAA,GAAA,MAAa,CAAA;AACb,IAAA,WAAA,CAAA,KAAA,CAAA,GAAA,KAAW,CAAA;AACX,IAAA,WAAA,CAAA,QAAA,CAAA,GAAA,QAAiB,CAAA;AACjB,IAAA,WAAA,CAAA,MAAA,CAAA,GAAA,MAAa,CAAA;AACb,IAAA,WAAA,CAAA,cAAA,CAAA,GAAA,cAA6B,CAAA;AAC7B,IAAA,WAAA,CAAA,QAAA,CAAA,GAAA,QAAiB,CAAA;AACjB,IAAA,WAAA,CAAA,iBAAA,CAAA,GAAA,iBAAmC,CAAA;AACnC,IAAA,WAAA,CAAA,UAAA,CAAA,GAAA,UAAqB,CAAA;AACvB,CAAC,EAVW,WAAW,KAAX,WAAW,GAUtB,EAAA,CAAA,CAAA,CAAA;AAED,IAAY,YASX,CAAA;AATD,CAAA,UAAY,YAAY,EAAA;AACtB,IAAA,YAAA,CAAA,MAAA,CAAA,GAAA,GAAU,CAAA;AACV,IAAA,YAAA,CAAA,MAAA,CAAA,GAAA,IAAW,CAAA;AACX,IAAA,YAAA,CAAA,KAAA,CAAA,GAAA,IAAU,CAAA;AACV,IAAA,YAAA,CAAA,QAAA,CAAA,GAAA,GAAY,CAAA;AACZ,IAAA,YAAA,CAAA,MAAA,CAAA,GAAA,GAAU,CAAA;AACV,IAAA,YAAA,C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IAAI;;;ACzDF,SAAA,cAAc,CAAC,OAAA,GAA+B,EAAE,EAAA;IAC9D,MAAM,EAAE,MAAM,EAAA,GAAc,OAAO,EAAhB,IAAI,GAAA,MAAA,CAAK,OAAO,EAA7B,CAAmB,QAAA,CAAA,CAAU,CAAC;AACpC,IAAA,OAAA,MAAA,CAAA,MAAA,CAAA,EACE,QAAQ,EAAE,EAAE,EACZ,IAAI,EACJ,GAAG,EAAE,IAAI,EACT,IAAI,EAAE,EAAE,EACR,MAAM,EAAE,IAAI,EACZ,MAAM,EAAE,IAAI,EACZ,CAAC,WAAW,CAAC,IAAI,GAAG,UAAU,EAAA,GAC1B,MAAM,IAAI,EAAE,MAAM,EAAE,EACxB,CAAA;AACJ;;;;"}
@@ -1,2 +1,2 @@
1
- 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};function n(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})}Object.entries(r).reduce(((e,[t,r])=>Object.assign(e,{[r]:t})),{});export{n as genTestIsolate};
1
+ import{assign as e}from"lodash";var t,r;"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"}(t||(t={})),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"}(r||(r={}));function n(e={}){const{status:r}=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,[t.Type]:"UnitTest"},r&&{status:r})}!function(t={}){Object.entries(t).reduce(((t,[r,n])=>e(t,{[n]:r})),{})}({[t.Type]:r.Type,[t.Keys]:r.Keys,[t.Parent]:r.Parent,[t.Data]:r.Data,[t.Key]:r.Key,[t.AllowReorder]:r.AllowReorder,[t.Status]:r.Status,[t.Children]:r.Children}),t.AbortController,t.Parent,t.Keys,t.Children,t.Data;export{n as genTestIsolate};
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":["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","genTestIsolate","payload","status","data","__rest","Object","assign","children","key","keys","output","parent","entries","reduce","acc","minified"],"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,QCxBrB,SAAAC,EAAeC,EAA+B,IAC5D,MAAMC,OAAEA,GAAoBD,EAATE,2UAAIC,CAAKH,EAAtB,CAAmB,WACzB,OAAAI,OAAAC,OAAA,CACEC,SAAU,GACVJ,OACAK,IAAK,KACLC,KAAM,GACNC,OAAQ,KACRC,OAAQ,KACR,CAACrB,EAAYG,MAAO,YAChBS,GAAU,CAAEA,UAEpB,CDsB6BG,OAAOO,QAAQpB,GAAeqB,QACzD,CAACC,GAAMN,EAAKO,KACVV,OAAOC,OAAOQ,EAAK,CACjBC,CAACA,GAAWP,KAEhB,CAAiC"}
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","genTestIsolate","payload","status","data","__rest","Object","assign","children","key","keys","output","parent","Type","miniMap","entries","reduce","acc","minified","invertKeyMap","Keys","Parent","Data","Key","AllowReorder","Status","Children","AbortController"],"mappings":"gCAEA,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,ICpBe,SAAAC,EAAeC,EAA+B,IAC5D,MAAMC,OAAEA,GAAoBD,EAATE,2UAAIC,CAAKH,EAAtB,CAAmB,WACzB,OAAAI,OAAAC,OAAA,CACEC,SAAU,GACVJ,OACAK,IAAK,KACLC,KAAM,GACNC,OAAQ,KACRC,OAAQ,KACR,CAACb,EAAYc,MAAO,YAChBV,GAAU,CAAEA,UAEpB,ED8BgB,SAAaW,EAAkC,IACtDR,OAAOS,QAAQD,GAASE,QAC7B,CAACC,GAAMR,EAAKS,KACVX,EAAOU,EAAK,CACVC,CAACA,GAAWT,KAEhB,CAA4B,EAEhC,CAV6BU,CAlBA,CAC3B,CAACpB,EAAYc,MAAOb,EAAaa,KACjC,CAACd,EAAYqB,MAAOpB,EAAaoB,KACjC,CAACrB,EAAYsB,QAASrB,EAAaqB,OACnC,CAACtB,EAAYuB,MAAOtB,EAAasB,KACjC,CAACvB,EAAYwB,KAAMvB,EAAauB,IAChC,CAACxB,EAAYyB,cAAexB,EAAawB,aACzC,CAACzB,EAAY0B,QAASzB,EAAayB,OACnC,CAAC1B,EAAY2B,UAAW1B,EAAa0B,WAuBrC3B,EAAY4B,gBACZ5B,EAAYsB,OACZtB,EAAYqB,KACZrB,EAAY2B,SACZ3B,EAAYuB"}
@@ -1,5 +1,6 @@
1
- import { isNullish, isNotNullish, invariant, assign, bus, optionalFunctionValue, tinyState, deferThrow, text, isPromise, isStringValue, hasOwnProperty } from 'vest-utils';
1
+ import { isNullish, isNotNullish, invariant, assign, bus, optionalFunctionValue, tinyState, deferThrow, text, isPromise, isStringValue, hasOwnProperty, isEmpty } from 'vest-utils';
2
2
  import { createCascade } from 'context';
3
+ import { assign as assign$1 } from 'lodash';
3
4
 
4
5
  const RuntimeEvents = {
5
6
  ISOLATE_ENTER: 'ISOLATE_ENTER',
@@ -128,6 +129,12 @@ class IsolateMutator {
128
129
  static setData(isolate, data) {
129
130
  isolate.data = data;
130
131
  }
132
+ static abort(isolate, reason) {
133
+ if (isNullish(isolate.abortController)) {
134
+ return;
135
+ }
136
+ isolate.abortController.abort(reason);
137
+ }
131
138
  }
132
139
 
133
140
  const PersistedContext = createCascade((stateRef, parentContext) => {
@@ -306,16 +313,19 @@ var IsolateKeys;
306
313
  IsolateKeys["Data"] = "data";
307
314
  IsolateKeys["AllowReorder"] = "allowReorder";
308
315
  IsolateKeys["Status"] = "status";
316
+ IsolateKeys["AbortController"] = "abortController";
317
+ IsolateKeys["Children"] = "children";
309
318
  })(IsolateKeys || (IsolateKeys = {}));
310
319
  var MinifiedKeys;
311
320
  (function (MinifiedKeys) {
312
321
  MinifiedKeys["Type"] = "$";
313
- MinifiedKeys["Keys"] = "K";
314
- MinifiedKeys["Key"] = "k";
322
+ MinifiedKeys["Keys"] = "Ks";
323
+ MinifiedKeys["Key"] = "ky";
315
324
  MinifiedKeys["Parent"] = "P";
316
325
  MinifiedKeys["Data"] = "D";
317
- MinifiedKeys["AllowReorder"] = "aR";
326
+ MinifiedKeys["AllowReorder"] = "AR";
318
327
  MinifiedKeys["Status"] = "S";
328
+ MinifiedKeys["Children"] = "C";
319
329
  })(MinifiedKeys || (MinifiedKeys = {}));
320
330
  const KeyToMinified = {
321
331
  [IsolateKeys.Type]: MinifiedKeys.Type,
@@ -325,6 +335,7 @@ const KeyToMinified = {
325
335
  [IsolateKeys.Key]: MinifiedKeys.Key,
326
336
  [IsolateKeys.AllowReorder]: MinifiedKeys.AllowReorder,
327
337
  [IsolateKeys.Status]: MinifiedKeys.Status,
338
+ [IsolateKeys.Children]: MinifiedKeys.Children,
328
339
  };
329
340
  // This const is an object that looks like this:
330
341
  // {
@@ -333,9 +344,19 @@ const KeyToMinified = {
333
344
  // 'P': 'parent',
334
345
  // ...
335
346
  // }
336
- const MinifiedToKey = Object.entries(KeyToMinified).reduce((acc, [key, minified]) => Object.assign(acc, {
337
- [minified]: key,
338
- }), {});
347
+ const MinifiedToKey = invertKeyMap(KeyToMinified);
348
+ function invertKeyMap(miniMap = {}) {
349
+ return Object.entries(miniMap).reduce((acc, [key, minified]) => assign$1(acc, {
350
+ [minified]: key,
351
+ }), {});
352
+ }
353
+ const ExcludedFromDump = [
354
+ IsolateKeys.AbortController,
355
+ IsolateKeys.Parent,
356
+ IsolateKeys.Keys,
357
+ IsolateKeys.Children,
358
+ IsolateKeys.Data,
359
+ ];
339
360
 
340
361
  function isIsolateType(node, type) {
341
362
  return (node === null || node === void 0 ? void 0 : node[IsolateKeys.Type]) === type;
@@ -477,7 +498,7 @@ function useRunAsNew(localHistoryNode, current, callback) {
477
498
  }
478
499
  function baseIsolate(type, payload = undefined, key = null) {
479
500
  const _a = payload !== null && payload !== void 0 ? payload : {}, { allowReorder, status } = _a, data = __rest(_a, ["allowReorder", "status"]);
480
- 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 });
501
+ return Object.assign(Object.assign({ [IsolateKeys.AllowReorder]: allowReorder, [IsolateKeys.AbortController]: new AbortController(), [IsolateKeys.Keys]: null, [IsolateKeys.Parent]: null, [IsolateKeys.Type]: type, [IsolateKeys.Data]: data }, (status && { [IsolateKeys.Status]: status })), { children: null, key, output: null });
481
502
  }
482
503
 
483
504
  // eslint-disable-next-line
@@ -612,8 +633,9 @@ var IsolateWalker = /*#__PURE__*/Object.freeze({
612
633
  });
613
634
 
614
635
  class IsolateSerializer {
615
- // eslint-disable-next-line max-statements, complexity
616
- static deserialize(node) {
636
+ // eslint-disable-next-line max-statements, complexity, max-lines-per-function
637
+ static deserialize(node, miniMaps) {
638
+ var _a;
617
639
  // the assumption is that the tree is built correctly,
618
640
  // but the children are missing the parent property to
619
641
  // avoid circular references during serialization.
@@ -621,29 +643,52 @@ class IsolateSerializer {
621
643
  // to avoid circular references during serialization.
622
644
  // we need to rebuild the tree and add back the parent property to the children
623
645
  // and the keys property to the parents.
646
+ const inverseMinimap = deeplyInvertKeyMap(miniMaps);
647
+ // Validate the root object
624
648
  const root = isStringValue(node)
625
649
  ? JSON.parse(node)
626
650
  : Object.assign({}, node);
627
651
  IsolateSerializer.validateIsolate(root);
628
652
  const queue = [root];
653
+ // Iterate over the queue until it's empty
629
654
  while (queue.length) {
655
+ // Get the next item from the queue
630
656
  const current = queue.shift();
631
- const children = IsolateSerializer.getChildren(current);
657
+ // Get the children of the current item
658
+ const children = IsolateSerializer.expandChildren(current);
659
+ // Iterate over the minified keys
632
660
  for (const key in MinifiedToKey) {
661
+ // Get the value for the current key
633
662
  const value = current[key];
663
+ // If the value is not null or undefined
634
664
  if (isNotNullish(value)) {
635
- current[MinifiedToKey[key]] = value;
665
+ // Get the key to use
666
+ const keyToUse = MinifiedToKey[key];
667
+ // If the key is data, then we may need to transform the keys
668
+ // eslint-disable-next-line max-depth
669
+ if (keyToUse === IsolateKeys.Data) {
670
+ // Transform the keys
671
+ current[keyToUse] = transformKeys(value, (_a = inverseMinimap === null || inverseMinimap === void 0 ? void 0 : inverseMinimap.keys) === null || _a === void 0 ? void 0 : _a.data);
672
+ }
673
+ else {
674
+ // Otherwise, just set the key
675
+ current[keyToUse] = transformValueByKey(keyToUse, value, inverseMinimap);
676
+ }
677
+ // Remove the old key
636
678
  delete current[key];
637
679
  }
638
680
  }
681
+ // If there are no children, nothing to do.
639
682
  if (!children) {
640
683
  continue;
641
684
  }
685
+ // Copy the children and set their parent to the current node.
642
686
  current.children = children.map(child => {
643
687
  var _a;
644
688
  const nextChild = Object.assign({}, child);
645
689
  IsolateMutator.setParent(nextChild, current);
646
690
  queue.push(nextChild);
691
+ // If the child has a key, add it to the parent's keys.
647
692
  const key = nextChild.key;
648
693
  if (key) {
649
694
  current.keys = (_a = current.keys) !== null && _a !== void 0 ? _a : {};
@@ -654,14 +699,16 @@ class IsolateSerializer {
654
699
  }
655
700
  return root;
656
701
  }
657
- static serialize(isolate) {
702
+ static serialize(isolate, miniMaps) {
658
703
  if (isNullish(isolate)) {
659
704
  return '';
660
705
  }
661
- return JSON.stringify(transformIsolate(isolate));
706
+ return JSON.stringify(transformIsolate(isolate, miniMaps));
662
707
  }
663
- static getChildren(node) {
664
- return node.children ? [...node.children] : null;
708
+ static expandChildren(node) {
709
+ return node[MinifiedKeys.Children]
710
+ ? [...node[MinifiedKeys.Children]]
711
+ : null;
665
712
  }
666
713
  static validateIsolate(node) {
667
714
  invariant(hasOwnProperty(node, IsolateKeys.Type) ||
@@ -669,15 +716,20 @@ class IsolateSerializer {
669
716
  }
670
717
  }
671
718
  // eslint-disable-next-line max-statements, complexity
672
- function transformIsolate(isolate) {
719
+ function transformIsolate(isolate, miniMaps) {
720
+ var _a;
673
721
  const next = {};
674
722
  if (isolate.children) {
675
- next.children = isolate.children.map(transformIsolate);
723
+ next[MinifiedKeys.Children] = isolate.children.map(isolate => transformIsolate(isolate, miniMaps));
724
+ }
725
+ if (!isEmpty(isolate.data)) {
726
+ next[MinifiedKeys.Data] = transformKeys(isolate.data, (_a = miniMaps === null || miniMaps === void 0 ? void 0 : miniMaps.keys) === null || _a === void 0 ? void 0 : _a.data);
676
727
  }
677
728
  for (const key in isolate) {
678
- if (key === 'children') {
679
- continue;
680
- }
729
+ // Skip keys that should be excluded from the dump.
730
+ // While we're excluding children from the dump, they'll actually remain there
731
+ // due to the fact that we've already transformed them recursively beforehand
732
+ // thus renaming them to the minified key.
681
733
  if (isKeyExcluededFromDump(key)) {
682
734
  continue;
683
735
  }
@@ -685,17 +737,52 @@ function transformIsolate(isolate) {
685
737
  if (isNullish(value)) {
686
738
  continue;
687
739
  }
688
- if (hasOwnProperty(KeyToMinified, key)) {
689
- next[KeyToMinified[key]] = value;
690
- }
691
- else {
692
- next[key] = value;
693
- }
740
+ const keyToUse = minifyKey(key);
741
+ next[keyToUse] = transformValueByKey(key, value, miniMaps);
694
742
  }
695
743
  return next;
696
744
  }
697
745
  function isKeyExcluededFromDump(key) {
698
- return [IsolateKeys.Parent, IsolateKeys.Keys].includes(key);
746
+ return ExcludedFromDump.includes(key);
747
+ }
748
+ function minifyKey(key) {
749
+ var _a;
750
+ return (_a = KeyToMinified[key]) !== null && _a !== void 0 ? _a : key;
751
+ }
752
+ function transformValueByKey(key, value, miniMaps) {
753
+ var _a, _b;
754
+ if (isNullish(value)) {
755
+ return value;
756
+ }
757
+ const keyMap = (_a = miniMaps === null || miniMaps === void 0 ? void 0 : miniMaps.values) === null || _a === void 0 ? void 0 : _a[key];
758
+ return keyMap ? (_b = keyMap[value]) !== null && _b !== void 0 ? _b : value : value;
759
+ }
760
+ function transformKeys(data, keyMap) {
761
+ var _a;
762
+ const next = {};
763
+ // Loop over each key in the data.
764
+ for (const key in data) {
765
+ // Find the key to use for the next object.
766
+ // If there is no key map, use the original key.
767
+ // If there is a key map, use the key map entry for the current key.
768
+ const keyToUse = (_a = (keyMap ? keyMap[key] : key)) !== null && _a !== void 0 ? _a : key;
769
+ // Add the key and value to the next object.
770
+ next[keyToUse] = data[key];
771
+ }
772
+ // Return the next object.
773
+ return next;
774
+ }
775
+ function deeplyInvertKeyMap(miniMaps = {}) {
776
+ return Object.entries(miniMaps).reduce((acc, [key, value]) => {
777
+ if (typeof value === 'object') {
778
+ return assign(acc, {
779
+ [key]: deeplyInvertKeyMap(value),
780
+ });
781
+ }
782
+ return assign(acc, {
783
+ [value]: key,
784
+ });
785
+ }, {});
699
786
  }
700
787
 
701
788
  export { Bus, Isolate, IsolateInspector, IsolateMutator, IsolateSelectors, IsolateSerializer, Reconciler, RuntimeEvents, RuntimeApi as VestRuntime, IsolateWalker as Walker };