vestjs-runtime 1.0.5 → 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.
Files changed (43) hide show
  1. package/dist/cjs/IsolateSerializer.development.js +3 -0
  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 +40 -10
  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 +149 -141
  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 +3 -0
  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 +40 -10
  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 +150 -143
  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 +3 -0
  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 +81 -51
  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 +690 -682
  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 +4 -1
  39. package/types/IsolateSerializer.d.ts.map +1 -1
  40. package/types/test-utils.d.ts +5 -2
  41. package/types/test-utils.d.ts.map +1 -1
  42. package/types/vestjs-runtime.d.ts +30 -7
  43. package/types/vestjs-runtime.d.ts.map +1 -1
@@ -18,6 +18,7 @@ var IsolateKeys;
18
18
  IsolateKeys["Parent"] = "parent";
19
19
  IsolateKeys["Data"] = "data";
20
20
  IsolateKeys["AllowReorder"] = "allowReorder";
21
+ IsolateKeys["Status"] = "status";
21
22
  })(IsolateKeys || (IsolateKeys = {}));
22
23
  var MinifiedKeys;
23
24
  (function (MinifiedKeys) {
@@ -27,6 +28,7 @@ var MinifiedKeys;
27
28
  MinifiedKeys["Parent"] = "P";
28
29
  MinifiedKeys["Data"] = "D";
29
30
  MinifiedKeys["AllowReorder"] = "aR";
31
+ MinifiedKeys["Status"] = "S";
30
32
  })(MinifiedKeys || (MinifiedKeys = {}));
31
33
  const KeyToMinified = {
32
34
  [IsolateKeys.Type]: MinifiedKeys.Type,
@@ -35,6 +37,7 @@ const KeyToMinified = {
35
37
  [IsolateKeys.Data]: MinifiedKeys.Data,
36
38
  [IsolateKeys.Key]: MinifiedKeys.Key,
37
39
  [IsolateKeys.AllowReorder]: MinifiedKeys.AllowReorder,
40
+ [IsolateKeys.Status]: MinifiedKeys.Status,
38
41
  };
39
42
  // This const is an object that looks like this:
40
43
  // {
@@ -1 +1 @@
1
- {"version":3,"file":"IsolateSerializer.development.js","sources":["../../src/errors/ErrorStrings.ts","../../src/Isolate/IsolateKeys.ts","../../src/Isolate/IsolateMutator.ts","../../src/exports/IsolateSerializer.ts"],"sourcesContent":["export enum ErrorStrings {\n NO_ACTIVE_ISOLATE = 'Not within an active isolate',\n UNABLE_TO_PICK_NEXT_ISOLATE = 'Unable to pick next isolate. This is a bug, please report it to the Vest maintainers.',\n ENCOUNTERED_THE_SAME_KEY_TWICE = `Encountered the same key \"{key}\" twice. This may lead to inconsistent or overriding of results.`,\n INVALID_ISOLATE_CANNOT_PARSE = `Invalid isolate was passed to IsolateSerializer. Cannot proceed.`,\n}\n","export enum IsolateKeys {\n Type = '$type',\n Keys = 'keys',\n Key = 'key',\n Parent = 'parent',\n Data = 'data',\n AllowReorder = 'allowReorder',\n}\n\nenum MinifiedKeys {\n Type = '$',\n Keys = 'K',\n Key = 'k',\n Parent = 'P',\n Data = 'D',\n AllowReorder = 'aR',\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};\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;;ACLD,IAAY,WAOX,CAAA;AAPD,CAAA,UAAY,WAAW,EAAA;AACrB,IAAA,WAAA,CAAA,MAAA,CAAA,GAAA,OAAc,CAAA;AACd,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AAK,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","hasOwnPro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,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,2 +1,2 @@
1
- "use strict";var e,t,i,n=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"}(t||(t={})),function(e){e.Type="$",e.Keys="K",e.Key="k",e.Parent="P",e.Data="D",e.AllowReorder="aR"}(i||(i={}));const s={[t.Type]:i.Type,[t.Keys]:i.Keys,[t.Parent]:i.Parent,[t.Data]:i.Data,[t.Key]:i.Key,[t.AllowReorder]:i.AllowReorder},r=Object.entries(s).reduce(((e,[t,i])=>Object.assign(e,{[i]:t})),{});class a{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;n.invariant(e),e.children=null!==(i=e.children)&&void 0!==i?i:[],e.children.push(t),a.setParent(t,e)}static removeChild(e,t){var i,n;e.children=null!==(n=null===(i=e.children)||void 0===i?void 0:i.filter((e=>e!==t)))&&void 0!==n?n:null}static addChildKey(e,t,i){var s;n.invariant(e),e.keys=null!==(s=e.keys)&&void 0!==s?s:{},e.keys[t]=i}static slice(e,t){n.isNullish(e.children)||(e.children.length=t)}static setData(e,t){e.data=t}}class l{static deserialize(e){const t=n.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 r){const i=e[t];n.isNotNullish(i)&&(e[r[t]]=i,delete e[t])}t&&(e.children=t.map((t=>{var n;const s=Object.assign({},t);a.setParent(s,e),i.push(s);const r=s.key;return r&&(e.keys=null!==(n=e.keys)&&void 0!==n?n:{},e.keys[r]=s),s})))}return t}static serialize(e){return n.isNullish(e)?"":JSON.stringify(o(e))}static getChildren(e){return e.children?[...e.children]:null}static validateIsolate(i){n.invariant(n.hasOwnProperty(i,t.Type)||n.hasOwnProperty(i,s[t.Type]),n.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 r=e[i];n.isNullish(r)||(n.hasOwnProperty(s,i)?t[s[i]]=r:t[i]=r)}return t}function c(e){return[t.Parent,t.Keys].includes(e)}exports.IsolateSerializer=l;
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/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}\n\nenum MinifiedKeys {\n Type = '$',\n Keys = 'K',\n Key = 'k',\n Parent = 'P',\n Data = 'D',\n AllowReorder = 'aR',\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};\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","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,EASPC,2BDTL,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,cACD,CAPD,CAAYA,IAAAA,EAOX,CAAA,IAED,SAAKC,GACHA,EAAA,KAAA,IACAA,EAAA,KAAA,IACAA,EAAA,IAAA,IACAA,EAAA,OAAA,IACAA,EAAA,KAAA,IACAA,EAAA,aAAA,IACD,CAPD,CAAKA,IAAAA,EAOJ,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,cAU9BC,EAAgBC,OAAOC,QAAQT,GAAeU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ources":["../../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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jB,GAAOmC,GAGfA,CAAS,IAEnB,CAED,OAAOZ,CACR,CAEDnB,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";
@@ -8,6 +42,7 @@ var IsolateKeys;
8
42
  IsolateKeys["Parent"] = "parent";
9
43
  IsolateKeys["Data"] = "data";
10
44
  IsolateKeys["AllowReorder"] = "allowReorder";
45
+ IsolateKeys["Status"] = "status";
11
46
  })(IsolateKeys || (IsolateKeys = {}));
12
47
  var MinifiedKeys;
13
48
  (function (MinifiedKeys) {
@@ -17,6 +52,7 @@ var MinifiedKeys;
17
52
  MinifiedKeys["Parent"] = "P";
18
53
  MinifiedKeys["Data"] = "D";
19
54
  MinifiedKeys["AllowReorder"] = "aR";
55
+ MinifiedKeys["Status"] = "S";
20
56
  })(MinifiedKeys || (MinifiedKeys = {}));
21
57
  const KeyToMinified = {
22
58
  [IsolateKeys.Type]: MinifiedKeys.Type,
@@ -25,6 +61,7 @@ const KeyToMinified = {
25
61
  [IsolateKeys.Data]: MinifiedKeys.Data,
26
62
  [IsolateKeys.Key]: MinifiedKeys.Key,
27
63
  [IsolateKeys.AllowReorder]: MinifiedKeys.AllowReorder,
64
+ [IsolateKeys.Status]: MinifiedKeys.Status,
28
65
  };
29
66
  // This const is an object that looks like this:
30
67
  // {
@@ -37,16 +74,9 @@ Object.entries(KeyToMinified).reduce((acc, [key, minified]) => Object.assign(acc
37
74
  [minified]: key,
38
75
  }), {});
39
76
 
40
- function genTestIsolate(data = {}) {
41
- return {
42
- children: [],
43
- data,
44
- key: null,
45
- keys: {},
46
- output: null,
47
- parent: null,
48
- [IsolateKeys.Type]: 'UnitTest',
49
- };
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 }));
50
80
  }
51
81
 
52
82
  exports.genTestIsolate = genTestIsolate;
@@ -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}\n\nenum MinifiedKeys {\n Type = '$',\n Keys = 'K',\n Key = 'k',\n Parent = 'P',\n Data = 'D',\n AllowReorder = 'aR',\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};\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(data: Record<string, any> = {}): TIsolate {\n return {\n children: [],\n data,\n key: null,\n keys: {},\n output: null,\n parent: null,\n [IsolateKeys.Type]: 'UnitTest',\n };\n}\n"],"names":[],"mappings":";;AAAA,IAAY,WAOX,CAAA;AAPD,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;AAC/B,CAAC,EAPW,WAAW,KAAX,WAAW,GAOtB,EAAA,CAAA,CAAA,CAAA;AAED,IAAK,YAOJ,CAAA;AAPD,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;AACrB,CAAC,EAPI,YAAY,KAAZ,YAAY,GAOhB,EAAA,CAAA,CAAA,CAAA;AAEM,MAAM,aAAa,GAAG;AAC3B,IAAA,CAAC,WAAW,CAAC,IAAI,GAAG,YAAY,CAAC,IAAI;AACrC,IAAA,CAAC,WAAW,CAAC,IAAI,GAAG,YAAY,CAAC,IAAI;AACrC,IAAA,CAAC,WAAW,CAAC,MAAM,GAAG,YAAY,CAAC,MAAM;AACzC,IAAA,CAAC,WAAW,CAAC,IAAI,GAAG,YAAY,CAAC,IAAI;AACrC,IAAA,CAAC,WAAW,CAAC,GAAG,GAAG,YAAY,CAAC,GAAG;AACnC,IAAA,CAAC,WAAW,CAAC,YAAY,GAAG,YAAY,CAAC,YAAY;CACtD,CAAC;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;AAC6B,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,MAAM,CAC/D,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,QAAQ,CAAC,KACnB,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE;IACjB,CAAC,QAAQ,GAAG,GAAG;CAChB,CAAC,EACJ,EAAiC;;ACpCnB,SAAA,cAAc,CAAC,IAAA,GAA4B,EAAE,EAAA;IAC3D,OAAO;AACL,QAAA,QAAQ,EAAE,EAAE;QACZ,IAAI;AACJ,QAAA,GAAG,EAAE,IAAI;AACT,QAAA,IAAI,EAAE,EAAE;AACR,QAAA,MAAM,EAAE,IAAI;AACZ,QAAA,MAAM,EAAE,IAAI;AACZ,QAAA,CAAC,WAAW,CAAC,IAAI,GAAG,UAAU;KAC/B,CAAC;AACJ;;;;"}
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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,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
- "use strict";var e,t;!function(e){e.Type="$type",e.Keys="keys",e.Key="key",e.Parent="parent",e.Data="data",e.AllowReorder="allowReorder"}(e||(e={})),function(e){e.Type="$",e.Keys="K",e.Key="k",e.Parent="P",e.Data="D",e.AllowReorder="aR"}(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};Object.entries(r).reduce(((e,[t,r])=>Object.assign(e,{[r]:t})),{}),exports.genTestIsolate=function(t={}){return{children:[],data:t,key:null,keys:{},output:null,parent:null,[e.Type]:"UnitTest"}};
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/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}\n\nenum MinifiedKeys {\n Type = '$',\n Keys = 'K',\n Key = 'k',\n Parent = 'P',\n Data = 'D',\n AllowReorder = 'aR',\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};\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(data: Record<string, any> = {}): TIsolate {\n return {\n children: [],\n data,\n key: null,\n keys: {},\n output: null,\n parent: null,\n [IsolateKeys.Type]: 'UnitTest',\n };\n}\n"],"names":["IsolateKeys","MinifiedKeys","KeyToMinified","Type","Keys","Parent","Data","Key","AllowReorder","Object","entries","reduce","acc","key","minified","assign","data","children","keys","output","parent"],"mappings":"aAAA,IAAYA,EASPC,GATL,SAAYD,GACVA,EAAA,KAAA,QACAA,EAAA,KAAA,OACAA,EAAA,IAAA,MACAA,EAAA,OAAA,SACAA,EAAA,KAAA,OACAA,EAAA,aAAA,cACD,CAPD,CAAYA,IAAAA,EAOX,CAAA,IAED,SAAKC,GACHA,EAAA,KAAA,IACAA,EAAA,KAAA,IACAA,EAAA,IAAA,IACAA,EAAA,OAAA,IACAA,EAAA,KAAA,IACAA,EAAA,aAAA,IACD,CAPD,CAAKA,IAAAA,EAOJ,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,cAUdC,OAAOC,QAAQR,GAAeS,QACzD,CAACC,GAAMC,EAAKC,KACVL,OAAOM,OAAOH,EAAK,CACjBE,CAACA,GAAWD,KAEhB,CAAiC,0BCpCnB,SAAeG,EAA4B,IACzD,MAAO,CACLC,SAAU,GACVD,OACAH,IAAK,KACLK,KAAM,CAAE,EACRC,OAAQ,KACRC,OAAQ,KACR,CAACpB,EAAYG,MAAO,WAExB"}
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
 
@@ -37,85 +43,6 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
37
43
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
38
44
  };
39
45
 
40
- var IsolateKeys;
41
- (function (IsolateKeys) {
42
- IsolateKeys["Type"] = "$type";
43
- IsolateKeys["Keys"] = "keys";
44
- IsolateKeys["Key"] = "key";
45
- IsolateKeys["Parent"] = "parent";
46
- IsolateKeys["Data"] = "data";
47
- IsolateKeys["AllowReorder"] = "allowReorder";
48
- })(IsolateKeys || (IsolateKeys = {}));
49
- var MinifiedKeys;
50
- (function (MinifiedKeys) {
51
- MinifiedKeys["Type"] = "$";
52
- MinifiedKeys["Keys"] = "K";
53
- MinifiedKeys["Key"] = "k";
54
- MinifiedKeys["Parent"] = "P";
55
- MinifiedKeys["Data"] = "D";
56
- MinifiedKeys["AllowReorder"] = "aR";
57
- })(MinifiedKeys || (MinifiedKeys = {}));
58
- const KeyToMinified = {
59
- [IsolateKeys.Type]: MinifiedKeys.Type,
60
- [IsolateKeys.Keys]: MinifiedKeys.Keys,
61
- [IsolateKeys.Parent]: MinifiedKeys.Parent,
62
- [IsolateKeys.Data]: MinifiedKeys.Data,
63
- [IsolateKeys.Key]: MinifiedKeys.Key,
64
- [IsolateKeys.AllowReorder]: MinifiedKeys.AllowReorder,
65
- };
66
- // This const is an object that looks like this:
67
- // {
68
- // '$': '$type',
69
- // 'K': 'keys',
70
- // 'P': 'parent',
71
- // ...
72
- // }
73
- const MinifiedToKey = Object.entries(KeyToMinified).reduce((acc, [key, minified]) => Object.assign(acc, {
74
- [minified]: key,
75
- }), {});
76
-
77
- class IsolateMutator {
78
- static setParent(isolate, parent) {
79
- isolate.parent = parent;
80
- return isolate;
81
- }
82
- static saveOutput(isolate, output) {
83
- isolate.output = output;
84
- return isolate;
85
- }
86
- static setKey(isolate, key) {
87
- isolate.key = key;
88
- return isolate;
89
- }
90
- static addChild(isolate, child) {
91
- var _a;
92
- vestUtils.invariant(isolate);
93
- isolate.children = (_a = isolate.children) !== null && _a !== void 0 ? _a : [];
94
- isolate.children.push(child);
95
- IsolateMutator.setParent(child, isolate);
96
- }
97
- static removeChild(isolate, node) {
98
- var _a, _b;
99
- isolate.children =
100
- (_b = (_a = isolate.children) === null || _a === void 0 ? void 0 : _a.filter(child => child !== node)) !== null && _b !== void 0 ? _b : null;
101
- }
102
- static addChildKey(isolate, key, node) {
103
- var _a;
104
- vestUtils.invariant(isolate);
105
- isolate.keys = (_a = isolate.keys) !== null && _a !== void 0 ? _a : {};
106
- isolate.keys[key] = node;
107
- }
108
- static slice(isolate, at) {
109
- if (vestUtils.isNullish(isolate.children)) {
110
- return;
111
- }
112
- isolate.children.length = at;
113
- }
114
- static setData(isolate, data) {
115
- isolate.data = data;
116
- }
117
- }
118
-
119
46
  var ErrorStrings;
120
47
  (function (ErrorStrings) {
121
48
  ErrorStrings["NO_ACTIVE_ISOLATE"] = "Not within an active isolate";
@@ -163,23 +90,48 @@ class IsolateInspector {
163
90
  }
164
91
  }
165
92
 
166
- function isIsolateType(node, type) {
167
- return (node === null || node === void 0 ? void 0 : node[IsolateKeys.Type]) === type;
168
- }
169
- function isSameIsolateType(a, b) {
170
- return isIsolateType(a, b[IsolateKeys.Type]);
171
- }
172
- function isSameIsolateIdentity(a, b) {
173
- return Object.is(a, b) || (isSameIsolateType(a, b) && a.key === b.key);
93
+ class IsolateMutator {
94
+ static setParent(isolate, parent) {
95
+ isolate.parent = parent;
96
+ return isolate;
97
+ }
98
+ static saveOutput(isolate, output) {
99
+ isolate.output = output;
100
+ return isolate;
101
+ }
102
+ static setKey(isolate, key) {
103
+ isolate.key = key;
104
+ return isolate;
105
+ }
106
+ static addChild(isolate, child) {
107
+ var _a;
108
+ vestUtils.invariant(isolate);
109
+ isolate.children = (_a = isolate.children) !== null && _a !== void 0 ? _a : [];
110
+ isolate.children.push(child);
111
+ IsolateMutator.setParent(child, isolate);
112
+ }
113
+ static removeChild(isolate, node) {
114
+ var _a, _b;
115
+ isolate.children =
116
+ (_b = (_a = isolate.children) === null || _a === void 0 ? void 0 : _a.filter(child => child !== node)) !== null && _b !== void 0 ? _b : null;
117
+ }
118
+ static addChildKey(isolate, key, node) {
119
+ var _a;
120
+ vestUtils.invariant(isolate);
121
+ isolate.keys = (_a = isolate.keys) !== null && _a !== void 0 ? _a : {};
122
+ isolate.keys[key] = node;
123
+ }
124
+ static slice(isolate, at) {
125
+ if (vestUtils.isNullish(isolate.children)) {
126
+ return;
127
+ }
128
+ isolate.children.length = at;
129
+ }
130
+ static setData(isolate, data) {
131
+ isolate.data = data;
132
+ }
174
133
  }
175
134
 
176
- var IsolateSelectors = /*#__PURE__*/Object.freeze({
177
- __proto__: null,
178
- isIsolateType: isIsolateType,
179
- isSameIsolateIdentity: isSameIsolateIdentity,
180
- isSameIsolateType: isSameIsolateType
181
- });
182
-
183
135
  const PersistedContext = context.createCascade((stateRef, parentContext) => {
184
136
  if (parentContext) {
185
137
  return null;
@@ -321,6 +273,89 @@ function useLoadRootNode(root) {
321
273
  useSetHistory(root);
322
274
  }
323
275
 
276
+ function useBus() {
277
+ return useX().stateRef.Bus;
278
+ }
279
+ /*
280
+ Returns an emitter, but it also has a shortcut for emitting an event immediately
281
+ by passing an event name.
282
+ */
283
+ function useEmit(event, data) {
284
+ const emit = useBus().emit;
285
+ if (!vestUtils.isNullish(event)) {
286
+ emit(event, data);
287
+ }
288
+ return persist(emit);
289
+ }
290
+ function usePrepareEmitter(event) {
291
+ const emit = useEmit();
292
+ return (arg) => emit(event, arg);
293
+ }
294
+
295
+ var Bus = /*#__PURE__*/Object.freeze({
296
+ __proto__: null,
297
+ useBus: useBus,
298
+ useEmit: useEmit,
299
+ usePrepareEmitter: usePrepareEmitter
300
+ });
301
+
302
+ var IsolateKeys;
303
+ (function (IsolateKeys) {
304
+ IsolateKeys["Type"] = "$type";
305
+ IsolateKeys["Keys"] = "keys";
306
+ IsolateKeys["Key"] = "key";
307
+ IsolateKeys["Parent"] = "parent";
308
+ IsolateKeys["Data"] = "data";
309
+ IsolateKeys["AllowReorder"] = "allowReorder";
310
+ IsolateKeys["Status"] = "status";
311
+ })(IsolateKeys || (IsolateKeys = {}));
312
+ var MinifiedKeys;
313
+ (function (MinifiedKeys) {
314
+ MinifiedKeys["Type"] = "$";
315
+ MinifiedKeys["Keys"] = "K";
316
+ MinifiedKeys["Key"] = "k";
317
+ MinifiedKeys["Parent"] = "P";
318
+ MinifiedKeys["Data"] = "D";
319
+ MinifiedKeys["AllowReorder"] = "aR";
320
+ MinifiedKeys["Status"] = "S";
321
+ })(MinifiedKeys || (MinifiedKeys = {}));
322
+ const KeyToMinified = {
323
+ [IsolateKeys.Type]: MinifiedKeys.Type,
324
+ [IsolateKeys.Keys]: MinifiedKeys.Keys,
325
+ [IsolateKeys.Parent]: MinifiedKeys.Parent,
326
+ [IsolateKeys.Data]: MinifiedKeys.Data,
327
+ [IsolateKeys.Key]: MinifiedKeys.Key,
328
+ [IsolateKeys.AllowReorder]: MinifiedKeys.AllowReorder,
329
+ [IsolateKeys.Status]: MinifiedKeys.Status,
330
+ };
331
+ // This const is an object that looks like this:
332
+ // {
333
+ // '$': '$type',
334
+ // 'K': 'keys',
335
+ // 'P': 'parent',
336
+ // ...
337
+ // }
338
+ const MinifiedToKey = Object.entries(KeyToMinified).reduce((acc, [key, minified]) => Object.assign(acc, {
339
+ [minified]: key,
340
+ }), {});
341
+
342
+ function isIsolateType(node, type) {
343
+ return (node === null || node === void 0 ? void 0 : node[IsolateKeys.Type]) === type;
344
+ }
345
+ function isSameIsolateType(a, b) {
346
+ return isIsolateType(a, b[IsolateKeys.Type]);
347
+ }
348
+ function isSameIsolateIdentity(a, b) {
349
+ return Object.is(a, b) || (isSameIsolateType(a, b) && a.key === b.key);
350
+ }
351
+
352
+ var IsolateSelectors = /*#__PURE__*/Object.freeze({
353
+ __proto__: null,
354
+ isIsolateType: isIsolateType,
355
+ isSameIsolateIdentity: isSameIsolateIdentity,
356
+ isSameIsolateType: isSameIsolateType
357
+ });
358
+
324
359
  function BaseReconciler(currentNode, historyNode) {
325
360
  if (vestUtils.isNullish(historyNode)) {
326
361
  return currentNode;
@@ -419,34 +454,32 @@ class Isolate {
419
454
  */
420
455
  function useRunAsNew(localHistoryNode, current, callback) {
421
456
  const runtimeRoot = useRuntimeRoot();
457
+ const emit = useEmit();
422
458
  // We're creating a new child isolate context where the local history node
423
459
  // is the current history node, thus advancing the history cursor.
424
460
  const output = Run(Object.assign({ historyNode: localHistoryNode, runtimeNode: current }, (!runtimeRoot && { runtimeRoot: current })), () => {
461
+ emit(RuntimeEvents.ISOLATE_ENTER, current);
425
462
  const output = callback(current);
426
463
  if (vestUtils.isPromise(output)) {
464
+ emit(RuntimeEvents.ISOLATE_PENDING, current);
427
465
  output.then(iso => {
428
466
  if (Isolate.isIsolate(iso)) {
429
467
  IsolateMutator.addChild(current, iso);
430
468
  }
469
+ emit(RuntimeEvents.ISOLATE_DONE, current);
431
470
  });
432
471
  }
472
+ else {
473
+ emit(RuntimeEvents.ISOLATE_DONE, current);
474
+ }
433
475
  return output;
434
476
  });
435
477
  current.output = output;
436
478
  return output;
437
479
  }
438
480
  function baseIsolate(type, payload = undefined, key = null) {
439
- const _a = payload !== null && payload !== void 0 ? payload : {}, { allowReorder } = _a, data = __rest(_a, ["allowReorder"]);
440
- return {
441
- [IsolateKeys.AllowReorder]: allowReorder,
442
- [IsolateKeys.Keys]: null,
443
- [IsolateKeys.Parent]: null,
444
- [IsolateKeys.Type]: type,
445
- [IsolateKeys.Data]: data,
446
- children: null,
447
- key,
448
- output: null,
449
- };
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 });
450
483
  }
451
484
 
452
485
  // eslint-disable-next-line
@@ -568,42 +601,16 @@ function closestExists(startNode, predicate) {
568
601
  }
569
602
 
570
603
  var IsolateWalker = /*#__PURE__*/Object.freeze({
571
- __proto__: null,
572
- closest: closest,
573
- closestExists: closestExists,
574
- every: every,
575
- find: find,
576
- findClosest: findClosest,
577
- has: has,
578
- pluck: pluck,
579
- some: some,
580
- walk: walk
581
- });
582
-
583
- function useBus() {
584
- return useX().stateRef.Bus;
585
- }
586
- /*
587
- Returns an emitter, but it also has a shortcut for emitting an event immediately
588
- by passing an event name.
589
- */
590
- function useEmit(event, data) {
591
- const emit = useBus().emit;
592
- if (!vestUtils.isNullish(event)) {
593
- emit(event, data);
594
- }
595
- return persist(emit);
596
- }
597
- function usePrepareEmitter(event) {
598
- const emit = useEmit();
599
- return (arg) => emit(event, arg);
600
- }
601
-
602
- var Bus = /*#__PURE__*/Object.freeze({
603
- __proto__: null,
604
- useBus: useBus,
605
- useEmit: useEmit,
606
- usePrepareEmitter: usePrepareEmitter
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
607
614
  });
608
615
 
609
616
  class IsolateSerializer {
@@ -700,6 +707,7 @@ exports.IsolateMutator = IsolateMutator;
700
707
  exports.IsolateSelectors = IsolateSelectors;
701
708
  exports.IsolateSerializer = IsolateSerializer;
702
709
  exports.Reconciler = Reconciler;
710
+ exports.RuntimeEvents = RuntimeEvents;
703
711
  exports.VestRuntime = RuntimeApi;
704
712
  exports.Walker = IsolateWalker;
705
713
  //# sourceMappingURL=vestjs-runtime.development.js.map