@jbrowse/mobx-state-tree 5.6.3 → 5.6.6

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 (126) hide show
  1. package/dist/core/action.d.ts +87 -0
  2. package/dist/core/action.js +228 -0
  3. package/dist/core/action.js.map +1 -0
  4. package/dist/core/actionContext.d.ts +27 -0
  5. package/dist/core/actionContext.js +42 -0
  6. package/dist/core/actionContext.js.map +1 -0
  7. package/dist/core/flow.d.ts +69 -0
  8. package/dist/core/flow.js +180 -0
  9. package/dist/core/flow.js.map +1 -0
  10. package/dist/core/json-patch.d.ts +46 -0
  11. package/dist/core/json-patch.js +133 -0
  12. package/dist/core/json-patch.js.map +1 -0
  13. package/dist/core/mst-operations.d.ts +459 -0
  14. package/dist/core/mst-operations.js +885 -0
  15. package/dist/core/mst-operations.js.map +1 -0
  16. package/dist/core/node/BaseNode.d.ts +62 -0
  17. package/dist/core/node/BaseNode.js +152 -0
  18. package/dist/core/node/BaseNode.js.map +1 -0
  19. package/dist/core/node/Hook.d.ts +17 -0
  20. package/dist/core/node/Hook.js +15 -0
  21. package/dist/core/node/Hook.js.map +1 -0
  22. package/dist/core/node/create-node.d.ts +16 -0
  23. package/dist/core/node/create-node.js +41 -0
  24. package/dist/core/node/create-node.js.map +1 -0
  25. package/dist/core/node/identifier-cache.d.ts +19 -0
  26. package/dist/core/node/identifier-cache.js +115 -0
  27. package/dist/core/node/identifier-cache.js.map +1 -0
  28. package/dist/core/node/livelinessChecking.d.ts +37 -0
  29. package/dist/core/node/livelinessChecking.js +38 -0
  30. package/dist/core/node/livelinessChecking.js.map +1 -0
  31. package/dist/core/node/node-utils.d.ts +83 -0
  32. package/dist/core/node/node-utils.js +165 -0
  33. package/dist/core/node/node-utils.js.map +1 -0
  34. package/dist/core/node/object-node.d.ts +99 -0
  35. package/dist/core/node/object-node.js +545 -0
  36. package/dist/core/node/object-node.js.map +1 -0
  37. package/dist/core/node/scalar-node.d.ts +19 -0
  38. package/dist/core/node/scalar-node.js +89 -0
  39. package/dist/core/node/scalar-node.js.map +1 -0
  40. package/dist/core/process.d.ts +50 -0
  41. package/dist/core/process.js +39 -0
  42. package/dist/core/process.js.map +1 -0
  43. package/dist/core/type/type-checker.d.ts +69 -0
  44. package/dist/core/type/type-checker.js +154 -0
  45. package/dist/core/type/type-checker.js.map +1 -0
  46. package/dist/core/type/type.d.ts +317 -0
  47. package/dist/core/type/type.js +251 -0
  48. package/dist/core/type/type.js.map +1 -0
  49. package/dist/index.d.ts +2 -0
  50. package/dist/index.js +85 -0
  51. package/dist/index.js.map +1 -0
  52. package/dist/internal.d.ts +39 -0
  53. package/dist/internal.js +60 -0
  54. package/dist/internal.js.map +1 -0
  55. package/dist/middlewares/create-action-tracking-middleware.d.ts +24 -0
  56. package/dist/middlewares/create-action-tracking-middleware.js +81 -0
  57. package/dist/middlewares/create-action-tracking-middleware.js.map +1 -0
  58. package/dist/middlewares/createActionTrackingMiddleware2.d.ts +34 -0
  59. package/dist/middlewares/createActionTrackingMiddleware2.js +133 -0
  60. package/dist/middlewares/createActionTrackingMiddleware2.js.map +1 -0
  61. package/dist/middlewares/on-action.d.ts +87 -0
  62. package/dist/middlewares/on-action.js +215 -0
  63. package/dist/middlewares/on-action.js.map +1 -0
  64. package/dist/mobx-state-tree.js +85 -0
  65. package/dist/mobx-state-tree.module.js +83 -0
  66. package/dist/types/complex-types/array.d.ts +80 -0
  67. package/dist/types/complex-types/array.js +352 -0
  68. package/dist/types/complex-types/array.js.map +1 -0
  69. package/dist/types/complex-types/map.d.ts +110 -0
  70. package/dist/types/complex-types/map.js +361 -0
  71. package/dist/types/complex-types/map.js.map +1 -0
  72. package/dist/types/complex-types/model.d.ts +192 -0
  73. package/dist/types/complex-types/model.js +477 -0
  74. package/dist/types/complex-types/model.js.map +1 -0
  75. package/dist/types/index.d.ts +33 -0
  76. package/dist/types/index.js +38 -0
  77. package/dist/types/index.js.map +1 -0
  78. package/dist/types/primitives.d.ts +124 -0
  79. package/dist/types/primitives.js +182 -0
  80. package/dist/types/primitives.js.map +1 -0
  81. package/dist/types/utility-types/custom.d.ts +74 -0
  82. package/dist/types/utility-types/custom.js +110 -0
  83. package/dist/types/utility-types/custom.js.map +1 -0
  84. package/dist/types/utility-types/enumeration.d.ts +5 -0
  85. package/dist/types/utility-types/enumeration.js +34 -0
  86. package/dist/types/utility-types/enumeration.js.map +1 -0
  87. package/dist/types/utility-types/frozen.d.ts +23 -0
  88. package/dist/types/utility-types/frozen.js +97 -0
  89. package/dist/types/utility-types/frozen.js.map +1 -0
  90. package/dist/types/utility-types/identifier.d.ts +86 -0
  91. package/dist/types/utility-types/identifier.js +129 -0
  92. package/dist/types/utility-types/identifier.js.map +1 -0
  93. package/dist/types/utility-types/late.d.ts +10 -0
  94. package/dist/types/utility-types/late.js +109 -0
  95. package/dist/types/utility-types/late.js.map +1 -0
  96. package/dist/types/utility-types/lazy.d.ts +22 -0
  97. package/dist/types/utility-types/lazy.js +76 -0
  98. package/dist/types/utility-types/lazy.js.map +1 -0
  99. package/dist/types/utility-types/literal.d.ts +37 -0
  100. package/dist/types/utility-types/literal.js +63 -0
  101. package/dist/types/utility-types/literal.js.map +1 -0
  102. package/dist/types/utility-types/maybe.d.ts +26 -0
  103. package/dist/types/utility-types/maybe.js +30 -0
  104. package/dist/types/utility-types/maybe.js.map +1 -0
  105. package/dist/types/utility-types/optional.d.ts +41 -0
  106. package/dist/types/utility-types/optional.js +140 -0
  107. package/dist/types/utility-types/optional.js.map +1 -0
  108. package/dist/types/utility-types/reference.d.ts +89 -0
  109. package/dist/types/utility-types/reference.js +392 -0
  110. package/dist/types/utility-types/reference.js.map +1 -0
  111. package/dist/types/utility-types/refinement.d.ts +10 -0
  112. package/dist/types/utility-types/refinement.js +85 -0
  113. package/dist/types/utility-types/refinement.js.map +1 -0
  114. package/dist/types/utility-types/resilient.d.ts +18 -0
  115. package/dist/types/utility-types/resilient.js +120 -0
  116. package/dist/types/utility-types/resilient.js.map +1 -0
  117. package/dist/types/utility-types/snapshotProcessor.d.ts +63 -0
  118. package/dist/types/utility-types/snapshotProcessor.js +161 -0
  119. package/dist/types/utility-types/snapshotProcessor.js.map +1 -0
  120. package/dist/types/utility-types/union.d.ts +77 -0
  121. package/dist/types/utility-types/union.js +245 -0
  122. package/dist/types/utility-types/union.js.map +1 -0
  123. package/dist/utils.d.ts +230 -0
  124. package/dist/utils.js +483 -0
  125. package/dist/utils.js.map +1 -0
  126. package/package.json +1 -1
package/dist/index.js ADDED
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isRefinementType = exports.isReferenceType = exports.isProtected = exports.isPrimitiveType = exports.isOptionalType = exports.isModelType = exports.isMapType = exports.isLiteralType = exports.isLateType = exports.isIdentifierType = exports.isFrozenType = exports.isArrayType = exports.isAlive = exports.isActionContextThisOrChildOf = exports.isActionContextChildOf = exports.hasParentOfType = exports.hasParent = exports.getType = exports.getSnapshot = exports.getRunningActionContext = exports.getRoot = exports.getRelativePath = exports.getPropertyMembers = exports.getPathParts = exports.getPath = exports.getParentOfType = exports.getParent = exports.getNodeId = exports.getMembers = exports.getLivelinessChecking = exports.getIdentifier = exports.getEnv = exports.getChildType = exports.flow = exports.escapeJsonPath = exports.detach = exports.destroy = exports.decorate = exports.createActionTrackingMiddleware = exports.createActionTrackingMiddleware2 = exports.clone = exports.castToSnapshot = exports.castToReferenceSnapshot = exports.castFlowReturn = exports.cast = exports.applySnapshot = exports.applyPatch = exports.applyAction = exports.addMiddleware = exports.addDisposer = void 0;
4
+ exports.setDevMode = exports.walk = exports.unprotect = exports.unescapeJsonPath = exports.t = exports.types = exports.typecheck = exports.tryResolve = exports.tryReference = exports.toGeneratorFunction = exports.toGenerator = exports.splitJsonPath = exports.setLivelynessChecking = exports.setLivelinessChecking = exports.resolvePath = exports.resolveIdentifier = exports.recordPatches = exports.recordActions = exports.protect = exports.process = exports.onSnapshot = exports.onPatch = exports.onAction = exports.joinJsonPath = exports.isValidReference = exports.isUnionType = exports.isType = exports.isStateTreeNode = exports.isRoot = void 0;
5
+ var internal_ts_1 = require("./internal.js");
6
+ Object.defineProperty(exports, "addDisposer", { enumerable: true, get: function () { return internal_ts_1.addDisposer; } });
7
+ Object.defineProperty(exports, "addMiddleware", { enumerable: true, get: function () { return internal_ts_1.addMiddleware; } });
8
+ Object.defineProperty(exports, "applyAction", { enumerable: true, get: function () { return internal_ts_1.applyAction; } });
9
+ Object.defineProperty(exports, "applyPatch", { enumerable: true, get: function () { return internal_ts_1.applyPatch; } });
10
+ Object.defineProperty(exports, "applySnapshot", { enumerable: true, get: function () { return internal_ts_1.applySnapshot; } });
11
+ Object.defineProperty(exports, "cast", { enumerable: true, get: function () { return internal_ts_1.cast; } });
12
+ Object.defineProperty(exports, "castFlowReturn", { enumerable: true, get: function () { return internal_ts_1.castFlowReturn; } });
13
+ Object.defineProperty(exports, "castToReferenceSnapshot", { enumerable: true, get: function () { return internal_ts_1.castToReferenceSnapshot; } });
14
+ Object.defineProperty(exports, "castToSnapshot", { enumerable: true, get: function () { return internal_ts_1.castToSnapshot; } });
15
+ Object.defineProperty(exports, "clone", { enumerable: true, get: function () { return internal_ts_1.clone; } });
16
+ Object.defineProperty(exports, "createActionTrackingMiddleware2", { enumerable: true, get: function () { return internal_ts_1.createActionTrackingMiddleware2; } });
17
+ Object.defineProperty(exports, "createActionTrackingMiddleware", { enumerable: true, get: function () { return internal_ts_1.createActionTrackingMiddleware; } });
18
+ Object.defineProperty(exports, "decorate", { enumerable: true, get: function () { return internal_ts_1.decorate; } });
19
+ Object.defineProperty(exports, "destroy", { enumerable: true, get: function () { return internal_ts_1.destroy; } });
20
+ Object.defineProperty(exports, "detach", { enumerable: true, get: function () { return internal_ts_1.detach; } });
21
+ Object.defineProperty(exports, "escapeJsonPath", { enumerable: true, get: function () { return internal_ts_1.escapeJsonPath; } });
22
+ Object.defineProperty(exports, "flow", { enumerable: true, get: function () { return internal_ts_1.flow; } });
23
+ Object.defineProperty(exports, "getChildType", { enumerable: true, get: function () { return internal_ts_1.getChildType; } });
24
+ Object.defineProperty(exports, "getEnv", { enumerable: true, get: function () { return internal_ts_1.getEnv; } });
25
+ Object.defineProperty(exports, "getIdentifier", { enumerable: true, get: function () { return internal_ts_1.getIdentifier; } });
26
+ Object.defineProperty(exports, "getLivelinessChecking", { enumerable: true, get: function () { return internal_ts_1.getLivelinessChecking; } });
27
+ Object.defineProperty(exports, "getMembers", { enumerable: true, get: function () { return internal_ts_1.getMembers; } });
28
+ Object.defineProperty(exports, "getNodeId", { enumerable: true, get: function () { return internal_ts_1.getNodeId; } });
29
+ Object.defineProperty(exports, "getParent", { enumerable: true, get: function () { return internal_ts_1.getParent; } });
30
+ Object.defineProperty(exports, "getParentOfType", { enumerable: true, get: function () { return internal_ts_1.getParentOfType; } });
31
+ Object.defineProperty(exports, "getPath", { enumerable: true, get: function () { return internal_ts_1.getPath; } });
32
+ Object.defineProperty(exports, "getPathParts", { enumerable: true, get: function () { return internal_ts_1.getPathParts; } });
33
+ Object.defineProperty(exports, "getPropertyMembers", { enumerable: true, get: function () { return internal_ts_1.getPropertyMembers; } });
34
+ Object.defineProperty(exports, "getRelativePath", { enumerable: true, get: function () { return internal_ts_1.getRelativePath; } });
35
+ Object.defineProperty(exports, "getRoot", { enumerable: true, get: function () { return internal_ts_1.getRoot; } });
36
+ Object.defineProperty(exports, "getRunningActionContext", { enumerable: true, get: function () { return internal_ts_1.getRunningActionContext; } });
37
+ Object.defineProperty(exports, "getSnapshot", { enumerable: true, get: function () { return internal_ts_1.getSnapshot; } });
38
+ Object.defineProperty(exports, "getType", { enumerable: true, get: function () { return internal_ts_1.getType; } });
39
+ Object.defineProperty(exports, "hasParent", { enumerable: true, get: function () { return internal_ts_1.hasParent; } });
40
+ Object.defineProperty(exports, "hasParentOfType", { enumerable: true, get: function () { return internal_ts_1.hasParentOfType; } });
41
+ Object.defineProperty(exports, "isActionContextChildOf", { enumerable: true, get: function () { return internal_ts_1.isActionContextChildOf; } });
42
+ Object.defineProperty(exports, "isActionContextThisOrChildOf", { enumerable: true, get: function () { return internal_ts_1.isActionContextThisOrChildOf; } });
43
+ Object.defineProperty(exports, "isAlive", { enumerable: true, get: function () { return internal_ts_1.isAlive; } });
44
+ Object.defineProperty(exports, "isArrayType", { enumerable: true, get: function () { return internal_ts_1.isArrayType; } });
45
+ Object.defineProperty(exports, "isFrozenType", { enumerable: true, get: function () { return internal_ts_1.isFrozenType; } });
46
+ Object.defineProperty(exports, "isIdentifierType", { enumerable: true, get: function () { return internal_ts_1.isIdentifierType; } });
47
+ Object.defineProperty(exports, "isLateType", { enumerable: true, get: function () { return internal_ts_1.isLateType; } });
48
+ Object.defineProperty(exports, "isLiteralType", { enumerable: true, get: function () { return internal_ts_1.isLiteralType; } });
49
+ Object.defineProperty(exports, "isMapType", { enumerable: true, get: function () { return internal_ts_1.isMapType; } });
50
+ Object.defineProperty(exports, "isModelType", { enumerable: true, get: function () { return internal_ts_1.isModelType; } });
51
+ Object.defineProperty(exports, "isOptionalType", { enumerable: true, get: function () { return internal_ts_1.isOptionalType; } });
52
+ Object.defineProperty(exports, "isPrimitiveType", { enumerable: true, get: function () { return internal_ts_1.isPrimitiveType; } });
53
+ Object.defineProperty(exports, "isProtected", { enumerable: true, get: function () { return internal_ts_1.isProtected; } });
54
+ Object.defineProperty(exports, "isReferenceType", { enumerable: true, get: function () { return internal_ts_1.isReferenceType; } });
55
+ Object.defineProperty(exports, "isRefinementType", { enumerable: true, get: function () { return internal_ts_1.isRefinementType; } });
56
+ Object.defineProperty(exports, "isRoot", { enumerable: true, get: function () { return internal_ts_1.isRoot; } });
57
+ Object.defineProperty(exports, "isStateTreeNode", { enumerable: true, get: function () { return internal_ts_1.isStateTreeNode; } });
58
+ Object.defineProperty(exports, "isType", { enumerable: true, get: function () { return internal_ts_1.isType; } });
59
+ Object.defineProperty(exports, "isUnionType", { enumerable: true, get: function () { return internal_ts_1.isUnionType; } });
60
+ Object.defineProperty(exports, "isValidReference", { enumerable: true, get: function () { return internal_ts_1.isValidReference; } });
61
+ Object.defineProperty(exports, "joinJsonPath", { enumerable: true, get: function () { return internal_ts_1.joinJsonPath; } });
62
+ Object.defineProperty(exports, "onAction", { enumerable: true, get: function () { return internal_ts_1.onAction; } });
63
+ Object.defineProperty(exports, "onPatch", { enumerable: true, get: function () { return internal_ts_1.onPatch; } });
64
+ Object.defineProperty(exports, "onSnapshot", { enumerable: true, get: function () { return internal_ts_1.onSnapshot; } });
65
+ Object.defineProperty(exports, "process", { enumerable: true, get: function () { return internal_ts_1.process; } });
66
+ Object.defineProperty(exports, "protect", { enumerable: true, get: function () { return internal_ts_1.protect; } });
67
+ Object.defineProperty(exports, "recordActions", { enumerable: true, get: function () { return internal_ts_1.recordActions; } });
68
+ Object.defineProperty(exports, "recordPatches", { enumerable: true, get: function () { return internal_ts_1.recordPatches; } });
69
+ Object.defineProperty(exports, "resolveIdentifier", { enumerable: true, get: function () { return internal_ts_1.resolveIdentifier; } });
70
+ Object.defineProperty(exports, "resolvePath", { enumerable: true, get: function () { return internal_ts_1.resolvePath; } });
71
+ Object.defineProperty(exports, "setLivelinessChecking", { enumerable: true, get: function () { return internal_ts_1.setLivelinessChecking; } });
72
+ Object.defineProperty(exports, "setLivelynessChecking", { enumerable: true, get: function () { return internal_ts_1.setLivelynessChecking; } });
73
+ Object.defineProperty(exports, "splitJsonPath", { enumerable: true, get: function () { return internal_ts_1.splitJsonPath; } });
74
+ Object.defineProperty(exports, "toGenerator", { enumerable: true, get: function () { return internal_ts_1.toGenerator; } });
75
+ Object.defineProperty(exports, "toGeneratorFunction", { enumerable: true, get: function () { return internal_ts_1.toGeneratorFunction; } });
76
+ Object.defineProperty(exports, "tryReference", { enumerable: true, get: function () { return internal_ts_1.tryReference; } });
77
+ Object.defineProperty(exports, "tryResolve", { enumerable: true, get: function () { return internal_ts_1.tryResolve; } });
78
+ Object.defineProperty(exports, "typecheck", { enumerable: true, get: function () { return internal_ts_1.typecheck; } });
79
+ Object.defineProperty(exports, "types", { enumerable: true, get: function () { return internal_ts_1.types; } });
80
+ Object.defineProperty(exports, "t", { enumerable: true, get: function () { return internal_ts_1.types; } });
81
+ Object.defineProperty(exports, "unescapeJsonPath", { enumerable: true, get: function () { return internal_ts_1.unescapeJsonPath; } });
82
+ Object.defineProperty(exports, "unprotect", { enumerable: true, get: function () { return internal_ts_1.unprotect; } });
83
+ Object.defineProperty(exports, "walk", { enumerable: true, get: function () { return internal_ts_1.walk; } });
84
+ Object.defineProperty(exports, "setDevMode", { enumerable: true, get: function () { return internal_ts_1.setDevMode; } });
85
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AA2EA,6CAgFsB;AA/EpB,0GAAA,WAAW,OAAA;AACX,4GAAA,aAAa,OAAA;AACb,0GAAA,WAAW,OAAA;AACX,yGAAA,UAAU,OAAA;AACV,4GAAA,aAAa,OAAA;AACb,mGAAA,IAAI,OAAA;AACJ,6GAAA,cAAc,OAAA;AACd,sHAAA,uBAAuB,OAAA;AACvB,6GAAA,cAAc,OAAA;AACd,oGAAA,KAAK,OAAA;AACL,8HAAA,+BAA+B,OAAA;AAC/B,6HAAA,8BAA8B,OAAA;AAC9B,uGAAA,QAAQ,OAAA;AACR,sGAAA,OAAO,OAAA;AACP,qGAAA,MAAM,OAAA;AACN,6GAAA,cAAc,OAAA;AACd,mGAAA,IAAI,OAAA;AACJ,2GAAA,YAAY,OAAA;AACZ,qGAAA,MAAM,OAAA;AACN,4GAAA,aAAa,OAAA;AACb,oHAAA,qBAAqB,OAAA;AACrB,yGAAA,UAAU,OAAA;AACV,wGAAA,SAAS,OAAA;AACT,wGAAA,SAAS,OAAA;AACT,8GAAA,eAAe,OAAA;AACf,sGAAA,OAAO,OAAA;AACP,2GAAA,YAAY,OAAA;AACZ,iHAAA,kBAAkB,OAAA;AAClB,8GAAA,eAAe,OAA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,yGAAA,UAAU,OAAA"}
@@ -0,0 +1,39 @@
1
+ export * from "./core/node/livelinessChecking.ts";
2
+ export * from "./core/node/Hook.ts";
3
+ export * from "./core/mst-operations.ts";
4
+ export * from "./core/node/BaseNode.ts";
5
+ export * from "./core/node/scalar-node.ts";
6
+ export * from "./core/node/object-node.ts";
7
+ export * from "./core/type/type.ts";
8
+ export * from "./middlewares/create-action-tracking-middleware.ts";
9
+ export * from "./middlewares/createActionTrackingMiddleware2.ts";
10
+ export * from "./middlewares/on-action.ts";
11
+ export * from "./core/action.ts";
12
+ export * from "./core/actionContext.ts";
13
+ export * from "./core/type/type-checker.ts";
14
+ export * from "./core/node/identifier-cache.ts";
15
+ export * from "./core/node/create-node.ts";
16
+ export * from "./core/node/node-utils.ts";
17
+ export * from "./core/process.ts";
18
+ export * from "./core/flow.ts";
19
+ export * from "./core/json-patch.ts";
20
+ export * from "./utils.ts";
21
+ export * from "./types/utility-types/snapshotProcessor.ts";
22
+ export * from "./types/complex-types/map.ts";
23
+ export * from "./types/complex-types/array.ts";
24
+ export * from "./types/complex-types/model.ts";
25
+ export * from "./types/primitives.ts";
26
+ export * from "./types/utility-types/literal.ts";
27
+ export * from "./types/utility-types/refinement.ts";
28
+ export * from "./types/utility-types/enumeration.ts";
29
+ export * from "./types/utility-types/union.ts";
30
+ export * from "./types/utility-types/optional.ts";
31
+ export * from "./types/utility-types/maybe.ts";
32
+ export * from "./types/utility-types/late.ts";
33
+ export * from "./types/utility-types/lazy.ts";
34
+ export * from "./types/utility-types/frozen.ts";
35
+ export * from "./types/utility-types/reference.ts";
36
+ export * from "./types/utility-types/identifier.ts";
37
+ export * from "./types/utility-types/custom.ts";
38
+ export * from "./types/utility-types/resilient.ts";
39
+ export * from "./types/index.ts";
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ /*
3
+ * All imports / exports should be proxied through this file.
4
+ * Why? It gives us full control over the module load order, preventing circular dependency isses
5
+ */
6
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
+ if (k2 === undefined) k2 = k;
8
+ var desc = Object.getOwnPropertyDescriptor(m, k);
9
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10
+ desc = { enumerable: true, get: function() { return m[k]; } };
11
+ }
12
+ Object.defineProperty(o, k2, desc);
13
+ }) : (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ o[k2] = m[k];
16
+ }));
17
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
18
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
19
+ };
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ __exportStar(require("./core/node/livelinessChecking.js"), exports);
22
+ __exportStar(require("./core/node/Hook.js"), exports);
23
+ __exportStar(require("./core/mst-operations.js"), exports);
24
+ __exportStar(require("./core/node/BaseNode.js"), exports);
25
+ __exportStar(require("./core/node/scalar-node.js"), exports);
26
+ __exportStar(require("./core/node/object-node.js"), exports);
27
+ __exportStar(require("./core/type/type.js"), exports);
28
+ __exportStar(require("./middlewares/create-action-tracking-middleware.js"), exports);
29
+ __exportStar(require("./middlewares/createActionTrackingMiddleware2.js"), exports);
30
+ __exportStar(require("./middlewares/on-action.js"), exports);
31
+ __exportStar(require("./core/action.js"), exports);
32
+ __exportStar(require("./core/actionContext.js"), exports);
33
+ __exportStar(require("./core/type/type-checker.js"), exports);
34
+ __exportStar(require("./core/node/identifier-cache.js"), exports);
35
+ __exportStar(require("./core/node/create-node.js"), exports);
36
+ __exportStar(require("./core/node/node-utils.js"), exports);
37
+ __exportStar(require("./core/process.js"), exports);
38
+ __exportStar(require("./core/flow.js"), exports);
39
+ __exportStar(require("./core/json-patch.js"), exports);
40
+ __exportStar(require("./utils.js"), exports);
41
+ __exportStar(require("./types/utility-types/snapshotProcessor.js"), exports);
42
+ __exportStar(require("./types/complex-types/map.js"), exports);
43
+ __exportStar(require("./types/complex-types/array.js"), exports);
44
+ __exportStar(require("./types/complex-types/model.js"), exports);
45
+ __exportStar(require("./types/primitives.js"), exports);
46
+ __exportStar(require("./types/utility-types/literal.js"), exports);
47
+ __exportStar(require("./types/utility-types/refinement.js"), exports);
48
+ __exportStar(require("./types/utility-types/enumeration.js"), exports);
49
+ __exportStar(require("./types/utility-types/union.js"), exports);
50
+ __exportStar(require("./types/utility-types/optional.js"), exports);
51
+ __exportStar(require("./types/utility-types/maybe.js"), exports);
52
+ __exportStar(require("./types/utility-types/late.js"), exports);
53
+ __exportStar(require("./types/utility-types/lazy.js"), exports);
54
+ __exportStar(require("./types/utility-types/frozen.js"), exports);
55
+ __exportStar(require("./types/utility-types/reference.js"), exports);
56
+ __exportStar(require("./types/utility-types/identifier.js"), exports);
57
+ __exportStar(require("./types/utility-types/custom.js"), exports);
58
+ __exportStar(require("./types/utility-types/resilient.js"), exports);
59
+ __exportStar(require("./types/index.js"), exports);
60
+ //# sourceMappingURL=internal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal.js","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;AAEH,oEAAiD;AACjD,sDAAmC;AACnC,2DAAwC;AACxC,0DAAuC;AACvC,6DAA0C;AAC1C,6DAA0C;AAC1C,sDAAmC;AACnC,qFAAkE;AAClE,mFAAgE;AAChE,6DAA0C;AAC1C,mDAAgC;AAChC,0DAAuC;AACvC,8DAA2C;AAC3C,kEAA+C;AAC/C,6DAA0C;AAC1C,4DAAyC;AACzC,oDAAiC;AACjC,iDAA8B;AAC9B,uDAAoC;AACpC,6CAA0B;AAC1B,6EAA0D;AAC1D,+DAA4C;AAC5C,iEAA8C;AAC9C,iEAA8C;AAC9C,wDAAqC;AACrC,mEAAgD;AAChD,sEAAmD;AACnD,uEAAoD;AACpD,iEAA8C;AAC9C,oEAAiD;AACjD,iEAA8C;AAC9C,gEAA6C;AAC7C,gEAA6C;AAC7C,kEAA+C;AAC/C,qEAAkD;AAClD,sEAAmD;AACnD,kEAA+C;AAC/C,qEAAkD;AAClD,mDAAgC"}
@@ -0,0 +1,24 @@
1
+ import { type IMiddlewareEvent, type IMiddlewareHandler } from "../internal.ts";
2
+ export interface IActionTrackingMiddlewareHooks<T> {
3
+ filter?: (call: IMiddlewareEvent) => boolean;
4
+ onStart: (call: IMiddlewareEvent) => T;
5
+ onResume: (call: IMiddlewareEvent, context: T) => void;
6
+ onSuspend: (call: IMiddlewareEvent, context: T) => void;
7
+ onSuccess: (call: IMiddlewareEvent, context: T, result: any) => void;
8
+ onFail: (call: IMiddlewareEvent, context: T, error: any) => void;
9
+ }
10
+ /**
11
+ * Note: Consider migrating to `createActionTrackingMiddleware2`, it is easier to use.
12
+ *
13
+ * Convenience utility to create action based middleware that supports async processes more easily.
14
+ * All hooks are called for both synchronous and asynchronous actions. Except that either `onSuccess` or `onFail` is called
15
+ *
16
+ * The create middleware tracks the process of an action (assuming it passes the `filter`).
17
+ * `onResume` can return any value, which will be passed as second argument to any other hook. This makes it possible to keep state during a process.
18
+ *
19
+ * See the `atomic` middleware for an example
20
+ *
21
+ * @param hooks
22
+ * @returns
23
+ */
24
+ export declare function createActionTrackingMiddleware<T = any>(hooks: IActionTrackingMiddlewareHooks<T>): IMiddlewareHandler;
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createActionTrackingMiddleware = createActionTrackingMiddleware;
4
+ const runningActions = new Map();
5
+ /**
6
+ * Note: Consider migrating to `createActionTrackingMiddleware2`, it is easier to use.
7
+ *
8
+ * Convenience utility to create action based middleware that supports async processes more easily.
9
+ * All hooks are called for both synchronous and asynchronous actions. Except that either `onSuccess` or `onFail` is called
10
+ *
11
+ * The create middleware tracks the process of an action (assuming it passes the `filter`).
12
+ * `onResume` can return any value, which will be passed as second argument to any other hook. This makes it possible to keep state during a process.
13
+ *
14
+ * See the `atomic` middleware for an example
15
+ *
16
+ * @param hooks
17
+ * @returns
18
+ */
19
+ function createActionTrackingMiddleware(hooks) {
20
+ return function actionTrackingMiddleware(call, next, _abort) {
21
+ switch (call.type) {
22
+ case "action": {
23
+ if (!hooks.filter || hooks.filter(call) === true) {
24
+ const context = hooks.onStart(call);
25
+ hooks.onResume(call, context);
26
+ runningActions.set(call.id, {
27
+ call,
28
+ context,
29
+ async: false
30
+ });
31
+ try {
32
+ const res = next(call);
33
+ hooks.onSuspend(call, context);
34
+ if (runningActions.get(call.id).async === false) {
35
+ runningActions.delete(call.id);
36
+ hooks.onSuccess(call, context, res);
37
+ }
38
+ return res;
39
+ }
40
+ catch (e) {
41
+ runningActions.delete(call.id);
42
+ hooks.onFail(call, context, e);
43
+ throw e;
44
+ }
45
+ }
46
+ else {
47
+ return next(call);
48
+ }
49
+ }
50
+ case "flow_spawn": {
51
+ const root = runningActions.get(call.rootId);
52
+ root.async = true;
53
+ return next(call);
54
+ }
55
+ case "flow_resume":
56
+ case "flow_resume_error": {
57
+ const root = runningActions.get(call.rootId);
58
+ hooks.onResume(call, root.context);
59
+ try {
60
+ return next(call);
61
+ }
62
+ finally {
63
+ hooks.onSuspend(call, root.context);
64
+ }
65
+ }
66
+ case "flow_throw": {
67
+ const root = runningActions.get(call.rootId);
68
+ runningActions.delete(call.rootId);
69
+ hooks.onFail(call, root.context, call.args[0]);
70
+ return next(call);
71
+ }
72
+ case "flow_return": {
73
+ const root = runningActions.get(call.rootId);
74
+ runningActions.delete(call.rootId);
75
+ hooks.onSuccess(call, root.context, call.args[0]);
76
+ return next(call);
77
+ }
78
+ }
79
+ };
80
+ }
81
+ //# sourceMappingURL=create-action-tracking-middleware.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-action-tracking-middleware.js","sourceRoot":"","sources":["../../src/middlewares/create-action-tracking-middleware.ts"],"names":[],"mappings":";;AA8BA,wEAgEC;AA5FD,MAAM,cAAc,GAAG,IAAI,GAAG,EAG3B,CAAA;AAWH;;;;;;;;;;;;;GAaG;AACH,SAAgB,8B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AAI,CAAC,CAAC,CAAC,CAAC,CAAA;gBACjD,OAAO,IAAI,CAAC,IAAI,CAAC,CAAA;YACnB,CAAC;QACH,CAAC;IACH,CAAC,CAAA;AACH,CAAC"}
@@ -0,0 +1,34 @@
1
+ import { type IActionContext, type IMiddlewareHandler } from "../internal.ts";
2
+ export interface IActionTrackingMiddleware2Call<TEnv> extends Readonly<IActionContext> {
3
+ env: TEnv | undefined;
4
+ readonly parentCall?: IActionTrackingMiddleware2Call<TEnv>;
5
+ }
6
+ export interface IActionTrackingMiddleware2Hooks<TEnv> {
7
+ filter?: (call: IActionTrackingMiddleware2Call<TEnv>) => boolean;
8
+ onStart: (call: IActionTrackingMiddleware2Call<TEnv>) => void;
9
+ onFinish: (call: IActionTrackingMiddleware2Call<TEnv>, error?: any) => void;
10
+ }
11
+ /**
12
+ * Convenience utility to create action based middleware that supports async processes more easily.
13
+ * The flow is like this:
14
+ * - for each action: if filter passes -> `onStart` -> (inner actions recursively) -> `onFinish`
15
+ *
16
+ * Example: if we had an action `a` that called inside an action `b1`, then `b2` the flow would be:
17
+ * - `filter(a)`
18
+ * - `onStart(a)`
19
+ * - `filter(b1)`
20
+ * - `onStart(b1)`
21
+ * - `onFinish(b1)`
22
+ * - `filter(b2)`
23
+ * - `onStart(b2)`
24
+ * - `onFinish(b2)`
25
+ * - `onFinish(a)`
26
+ *
27
+ * The flow is the same no matter if the actions are sync or async.
28
+ *
29
+ * See the `atomic` middleware for an example
30
+ *
31
+ * @param hooks
32
+ * @returns
33
+ */
34
+ export declare function createActionTrackingMiddleware2<TEnv = any>(middlewareHooks: IActionTrackingMiddleware2Hooks<TEnv>): IMiddlewareHandler;
@@ -0,0 +1,133 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createActionTrackingMiddleware2 = createActionTrackingMiddleware2;
4
+ class RunningAction {
5
+ hooks;
6
+ call;
7
+ flowsPending = 0;
8
+ running = true;
9
+ constructor(hooks, call) {
10
+ this.hooks = hooks;
11
+ this.call = call;
12
+ if (hooks) {
13
+ hooks.onStart(call);
14
+ }
15
+ }
16
+ finish(error) {
17
+ if (this.running) {
18
+ this.running = false;
19
+ if (this.hooks) {
20
+ this.hooks.onFinish(this.call, error);
21
+ }
22
+ }
23
+ }
24
+ incFlowsPending() {
25
+ this.flowsPending++;
26
+ }
27
+ decFlowsPending() {
28
+ this.flowsPending--;
29
+ }
30
+ get hasFlowsPending() {
31
+ return this.flowsPending > 0;
32
+ }
33
+ }
34
+ /**
35
+ * Convenience utility to create action based middleware that supports async processes more easily.
36
+ * The flow is like this:
37
+ * - for each action: if filter passes -> `onStart` -> (inner actions recursively) -> `onFinish`
38
+ *
39
+ * Example: if we had an action `a` that called inside an action `b1`, then `b2` the flow would be:
40
+ * - `filter(a)`
41
+ * - `onStart(a)`
42
+ * - `filter(b1)`
43
+ * - `onStart(b1)`
44
+ * - `onFinish(b1)`
45
+ * - `filter(b2)`
46
+ * - `onStart(b2)`
47
+ * - `onFinish(b2)`
48
+ * - `onFinish(a)`
49
+ *
50
+ * The flow is the same no matter if the actions are sync or async.
51
+ *
52
+ * See the `atomic` middleware for an example
53
+ *
54
+ * @param hooks
55
+ * @returns
56
+ */
57
+ function createActionTrackingMiddleware2(middlewareHooks) {
58
+ const runningActions = new Map();
59
+ return function actionTrackingMiddleware(call, next) {
60
+ // find parentRunningAction
61
+ const parentRunningAction = call.parentActionEvent
62
+ ? runningActions.get(call.parentActionEvent.id)
63
+ : undefined;
64
+ if (call.type === "action") {
65
+ const newCall = {
66
+ ...call,
67
+ // make a shallow copy of the parent action env
68
+ env: parentRunningAction && parentRunningAction.call.env,
69
+ parentCall: parentRunningAction && parentRunningAction.call
70
+ };
71
+ const passesFilter = !middlewareHooks.filter || middlewareHooks.filter(newCall);
72
+ const hooks = passesFilter ? middlewareHooks : undefined;
73
+ const runningAction = new RunningAction(hooks, newCall);
74
+ runningActions.set(call.id, runningAction);
75
+ let res;
76
+ try {
77
+ res = next(call);
78
+ }
79
+ catch (e) {
80
+ runningActions.delete(call.id);
81
+ runningAction.finish(e);
82
+ throw e;
83
+ }
84
+ // sync action finished
85
+ if (!runningAction.hasFlowsPending) {
86
+ runningActions.delete(call.id);
87
+ runningAction.finish();
88
+ }
89
+ return res;
90
+ }
91
+ else {
92
+ if (!parentRunningAction) {
93
+ return next(call);
94
+ }
95
+ switch (call.type) {
96
+ case "flow_spawn": {
97
+ parentRunningAction.incFlowsPending();
98
+ return next(call);
99
+ }
100
+ case "flow_resume":
101
+ case "flow_resume_error": {
102
+ return next(call);
103
+ }
104
+ case "flow_throw": {
105
+ const error = call.args[0];
106
+ try {
107
+ return next(call);
108
+ }
109
+ finally {
110
+ parentRunningAction.decFlowsPending();
111
+ if (!parentRunningAction.hasFlowsPending) {
112
+ runningActions.delete(call.parentActionEvent.id);
113
+ parentRunningAction.finish(error);
114
+ }
115
+ }
116
+ }
117
+ case "flow_return": {
118
+ try {
119
+ return next(call);
120
+ }
121
+ finally {
122
+ parentRunningAction.decFlowsPending();
123
+ if (!parentRunningAction.hasFlowsPending) {
124
+ runningActions.delete(call.parentActionEvent.id);
125
+ parentRunningAction.finish();
126
+ }
127
+ }
128
+ }
129
+ }
130
+ }
131
+ };
132
+ }
133
+ //# sourceMappingURL=createActionTrackingMiddleware2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createActionTrackingMiddleware2.js","sourceRoot":"","sources":["../../src/middlewares/createActionTrackingMiddleware2.ts"],"names":[],"mappings":";;AA6EA,0EAmFC;AA7ID,MAAM,aAAa;IAKC;IACP;IALH,YAAY,GAAG,CAAC,CAAA;IAChB,OAAO,GAAG,IAAI,CAAA;IAEtB,YACkB,KAAuD,EAC9D,IAAyC;QADlC,UAAK,GAAL,KAAK,CAAkD;QAC9D,SAAI,GAAJ,IAAI,CAAqC;QAElD,IAAI,KAAK,EAAE,CAAC;YACV,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;QACrB,CAAC;IACH,CAAC;IAED,MAAM,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wBACT,mBAAmB,CAAC,eAAe,EAAE,CAAA;wBACrC,IAAI,CAAC,mBAAmB,CAAC,eAAe,EAAE,CAAC;4BACzC,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,iBAAkB,CAAC,EAAE,CAAC,CAAA;4BACjD,mBAAmB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;wBACnC,CAAC;oBACH,CAAC;gBACH,CAAC;gBACD,KAAK,aAAa,CAAC,CAAC,CAAC;oBACnB,IAAI,CAAC;wBACH,OAAO,IAAI,CAAC,IAAI,CAAC,CAAA;oBACnB,CAAC;4BAAS,CAAC;wBACT,mBAAmB,CAAC,eAAe,EAAE,CAAA;wBACrC,IAAI,CAAC,mBAAmB,CAAC,eAAe,EAAE,CAAC;4BACzC,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,iBAAkB,CAAC,EAAE,CAAC,CAAA;4BACjD,mBAAmB,CAAC,MAAM,EAAE,CAAA;wBAC9B,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC,CAAA;AACH,CAAC"}
@@ -0,0 +1,87 @@
1
+ import { type IActionContext, type IAnyStateTreeNode, type IDisposer } from "../internal.ts";
2
+ export interface ISerializedActionCall {
3
+ name: string;
4
+ path?: string;
5
+ args?: any[];
6
+ }
7
+ export interface IActionRecorder {
8
+ actions: ReadonlyArray<ISerializedActionCall>;
9
+ readonly recording: boolean;
10
+ stop(): void;
11
+ resume(): void;
12
+ replay(target: IAnyStateTreeNode): void;
13
+ }
14
+ /**
15
+ * Applies an action or a series of actions in a single MobX transaction.
16
+ * Does not return any value
17
+ * Takes an action description as produced by the `onAction` middleware.
18
+ *
19
+ * @param target
20
+ * @param actions
21
+ */
22
+ export declare function applyAction(target: IAnyStateTreeNode, actions: ISerializedActionCall | ISerializedActionCall[]): void;
23
+ /**
24
+ * Small abstraction around `onAction` and `applyAction`, attaches an action listener to a tree and records all the actions emitted.
25
+ * Returns an recorder object with the following signature:
26
+ *
27
+ * Example:
28
+ * ```ts
29
+ * export interface IActionRecorder {
30
+ * // the recorded actions
31
+ * actions: ISerializedActionCall[]
32
+ * // true if currently recording
33
+ * recording: boolean
34
+ * // stop recording actions
35
+ * stop(): void
36
+ * // resume recording actions
37
+ * resume(): void
38
+ * // apply all the recorded actions on the given object
39
+ * replay(target: IAnyStateTreeNode): void
40
+ * }
41
+ * ```
42
+ *
43
+ * The optional filter function allows to skip recording certain actions.
44
+ *
45
+ * @param subject
46
+ * @returns
47
+ */
48
+ export declare function recordActions(subject: IAnyStateTreeNode, filter?: (action: ISerializedActionCall, actionContext: IActionContext | undefined) => boolean): IActionRecorder;
49
+ /**
50
+ * Registers a function that will be invoked for each action that is called on the provided model instance, or to any of its children.
51
+ * See [actions](https://github.com/mobxjs/mobx-state-tree#actions) for more details. onAction events are emitted only for the outermost called action in the stack.
52
+ * Action can also be intercepted by middleware using addMiddleware to change the function call before it will be run.
53
+ *
54
+ * Not all action arguments might be serializable. For unserializable arguments, a struct like `{ $MST_UNSERIALIZABLE: true, type: "someType" }` will be generated.
55
+ * MST Nodes are considered non-serializable as well (they could be serialized as there snapshot, but it is uncertain whether an replaying party will be able to handle such a non-instantiated snapshot).
56
+ * Rather, when using `onAction` middleware, one should consider in passing arguments which are 1: an id, 2: a (relative) path, or 3: a snapshot. Instead of a real MST node.
57
+ *
58
+ * Example:
59
+ * ```ts
60
+ * const Todo = types.model({
61
+ * task: types.string
62
+ * })
63
+ *
64
+ * const TodoStore = types.model({
65
+ * todos: types.array(Todo)
66
+ * }).actions(self => ({
67
+ * add(todo) {
68
+ * self.todos.push(todo);
69
+ * }
70
+ * }))
71
+ *
72
+ * const s = TodoStore.create({ todos: [] })
73
+ *
74
+ * let disposer = onAction(s, (call) => {
75
+ * console.log(call);
76
+ * })
77
+ *
78
+ * s.add({ task: "Grab a coffee" })
79
+ * // Logs: { name: "add", path: "", args: [{ task: "Grab a coffee" }] }
80
+ * ```
81
+ *
82
+ * @param target
83
+ * @param listener
84
+ * @param attachAfter (default false) fires the listener *after* the action has executed instead of before.
85
+ * @returns
86
+ */
87
+ export declare function onAction(target: IAnyStateTreeNode, listener: (call: ISerializedActionCall) => void, attachAfter?: boolean): IDisposer;