mobx-keystone 0.67.4 → 0.68.1-alpha

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 (394) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/_virtual/_tslib.mjs +12 -0
  3. package/dist/mobx-keystone.umd.js +5339 -5261
  4. package/dist/model/utils.d.ts +1 -1
  5. package/dist/node_modules/fast-deep-equal/es6/index.mjs +68 -0
  6. package/dist/node_modules/nanoid/non-secure/index.mjs +11 -0
  7. package/dist/snapshot/index.d.ts +0 -8
  8. package/dist/{dataModel/_BaseDataModel.d.ts → snapshot/registerDefaultReconcilers.d.ts} +0 -0
  9. package/dist/{model/_BaseModel.d.ts → snapshot/registerDefaultSnapshotters.d.ts} +0 -0
  10. package/dist/src/action/actionDecoratorUtils.mjs +25 -0
  11. package/dist/src/action/applyAction.mjs +54 -0
  12. package/dist/src/action/applyDelete.mjs +20 -0
  13. package/dist/src/action/applyMethodCall.mjs +19 -0
  14. package/dist/src/action/applySet.mjs +25 -0
  15. package/dist/src/action/builtInActions.mjs +15 -0
  16. package/dist/src/action/context.mjs +22 -0
  17. package/dist/src/action/hookActions.mjs +13 -0
  18. package/dist/src/action/isModelAction.mjs +6 -0
  19. package/dist/src/action/middleware.mjs +84 -0
  20. package/dist/src/action/modelAction.mjs +34 -0
  21. package/dist/src/action/modelFlow.mjs +251 -0
  22. package/dist/src/action/pendingActions.mjs +30 -0
  23. package/dist/src/action/protection.mjs +19 -0
  24. package/dist/src/action/runUnprotected.mjs +24 -0
  25. package/dist/src/action/wrapInAction.mjs +90 -0
  26. package/dist/src/actionMiddlewares/actionSerialization/actionSerialization.mjs +131 -0
  27. package/dist/src/actionMiddlewares/actionSerialization/applySerializedAction.mjs +110 -0
  28. package/dist/src/actionMiddlewares/actionSerialization/arraySerializer.mjs +15 -0
  29. package/dist/src/actionMiddlewares/actionSerialization/core.mjs +3 -0
  30. package/dist/src/actionMiddlewares/actionSerialization/dateSerializer.mjs +15 -0
  31. package/dist/src/actionMiddlewares/actionSerialization/mapSerializer.mjs +32 -0
  32. package/dist/src/actionMiddlewares/actionSerialization/objectPathSerializer.mjs +33 -0
  33. package/dist/src/actionMiddlewares/actionSerialization/objectSnapshotSerializer.mjs +18 -0
  34. package/dist/src/actionMiddlewares/actionSerialization/plainObjectSerializer.mjs +27 -0
  35. package/dist/src/actionMiddlewares/actionSerialization/primitiveSerializer.mjs +39 -0
  36. package/dist/src/actionMiddlewares/actionSerialization/setSerializer.mjs +29 -0
  37. package/dist/src/actionMiddlewares/actionTrackingMiddleware.mjs +239 -0
  38. package/dist/src/actionMiddlewares/onActionMiddleware.mjs +44 -0
  39. package/dist/src/actionMiddlewares/readonlyMiddleware.mjs +49 -0
  40. package/dist/src/actionMiddlewares/transactionMiddleware.mjs +69 -0
  41. package/dist/src/actionMiddlewares/undoMiddleware.mjs +472 -0
  42. package/dist/src/actionMiddlewares/utils.mjs +25 -0
  43. package/dist/src/computedTree/computedTree.mjs +63 -0
  44. package/dist/src/context/context.mjs +141 -0
  45. package/dist/src/dataModel/BaseDataModel.mjs +108 -0
  46. package/dist/src/dataModel/DataModel.mjs +32 -0
  47. package/dist/src/dataModel/actions.mjs +12 -0
  48. package/dist/src/dataModel/getDataModelMetadata.mjs +14 -0
  49. package/dist/src/dataModel/newDataModel.mjs +31 -0
  50. package/dist/src/dataModel/utils.mjs +29 -0
  51. package/dist/src/frozen/Frozen.mjs +68 -0
  52. package/dist/src/globalConfig/globalConfig.mjs +57 -0
  53. package/dist/src/index.mjs +97 -0
  54. package/dist/src/model/BaseModel.mjs +118 -0
  55. package/dist/src/model/Model.mjs +36 -0
  56. package/dist/src/model/getModelMetadata.mjs +19 -0
  57. package/dist/src/model/metadata.mjs +7 -0
  58. package/dist/src/model/newModel.mjs +95 -0
  59. package/dist/src/model/utils.mjs +33 -0
  60. package/dist/src/modelShared/BaseModelShared.mjs +9 -0
  61. package/dist/src/modelShared/Model.mjs +249 -0
  62. package/dist/src/modelShared/checkModelDecoratorArgs.mjs +21 -0
  63. package/dist/src/modelShared/modelClassInitializer.mjs +14 -0
  64. package/dist/src/modelShared/modelDecorator.mjs +117 -0
  65. package/dist/src/modelShared/modelInfo.mjs +7 -0
  66. package/dist/src/modelShared/modelPropsInfo.mjs +9 -0
  67. package/dist/src/modelShared/modelSymbols.mjs +5 -0
  68. package/dist/src/modelShared/newModel.mjs +13 -0
  69. package/dist/src/modelShared/prop.mjs +138 -0
  70. package/dist/src/modelShared/utils.mjs +10 -0
  71. package/dist/src/parent/core.mjs +34 -0
  72. package/dist/src/parent/coreObjectChildren.mjs +98 -0
  73. package/dist/src/parent/detach.mjs +32 -0
  74. package/dist/src/parent/findChildren.mjs +16 -0
  75. package/dist/src/parent/findParent.mjs +30 -0
  76. package/dist/src/parent/getChildrenObjects.mjs +12 -0
  77. package/dist/src/parent/onChildAttachedTo.mjs +101 -0
  78. package/dist/src/parent/path.mjs +149 -0
  79. package/dist/src/parent/path2.mjs +12 -0
  80. package/dist/src/parent/setParent.mjs +83 -0
  81. package/dist/src/parent/walkTree.mjs +104 -0
  82. package/dist/src/patch/applyPatches.mjs +118 -0
  83. package/dist/src/patch/emitPatch.mjs +100 -0
  84. package/dist/src/patch/jsonPatch.mjs +60 -0
  85. package/dist/src/patch/patchRecorder.mjs +75 -0
  86. package/dist/src/redux/connectReduxDevTools.mjs +153 -0
  87. package/dist/src/redux/redux.mjs +60 -0
  88. package/dist/src/ref/Ref.mjs +38 -0
  89. package/dist/src/ref/core.mjs +179 -0
  90. package/dist/src/ref/customRef.mjs +9 -0
  91. package/dist/src/ref/rootRef.mjs +34 -0
  92. package/dist/src/rootStore/attachDetach.mjs +53 -0
  93. package/dist/src/rootStore/rootStore.mjs +50 -0
  94. package/dist/src/snapshot/SnapshotterAndReconcilerPriority.mjs +9 -0
  95. package/dist/src/snapshot/applySnapshot.mjs +92 -0
  96. package/dist/src/snapshot/clone.mjs +29 -0
  97. package/dist/src/snapshot/fromArraySnapshot.mjs +23 -0
  98. package/dist/src/snapshot/fromFrozenSnapshot.mjs +13 -0
  99. package/dist/src/snapshot/fromModelSnapshot.mjs +38 -0
  100. package/dist/src/snapshot/fromPlainObjectSnapshot.mjs +26 -0
  101. package/dist/src/snapshot/fromSnapshot.mjs +91 -0
  102. package/dist/src/snapshot/getSnapshot.mjs +27 -0
  103. package/dist/src/snapshot/internal.mjs +97 -0
  104. package/dist/src/snapshot/onSnapshot.mjs +16 -0
  105. package/dist/src/snapshot/reconcileArraySnapshot.mjs +40 -0
  106. package/dist/src/snapshot/reconcileFrozenSnapshot.mjs +19 -0
  107. package/dist/src/snapshot/reconcileModelSnapshot.mjs +77 -0
  108. package/dist/src/snapshot/reconcilePlainObjectSnapshot.mjs +47 -0
  109. package/dist/src/snapshot/reconcileSnapshot.mjs +49 -0
  110. package/dist/src/snapshot/registerDefaultReconcilers.mjs +17 -0
  111. package/dist/src/snapshot/registerDefaultSnapshotters.mjs +17 -0
  112. package/dist/src/standardActions/actions.mjs +35 -0
  113. package/dist/src/standardActions/arrayActions.mjs +66 -0
  114. package/dist/src/standardActions/objectActions.mjs +36 -0
  115. package/dist/src/standardActions/standaloneActions.mjs +9 -0
  116. package/dist/src/transforms/ImmutableDate.mjs +51 -0
  117. package/dist/src/transforms/asMap.mjs +29 -0
  118. package/dist/src/transforms/asSet.mjs +12 -0
  119. package/dist/src/transforms/bigint.mjs +14 -0
  120. package/dist/src/transforms/date.mjs +27 -0
  121. package/dist/src/treeUtils/deepEquals.mjs +40 -0
  122. package/dist/src/treeUtils/draft.mjs +116 -0
  123. package/dist/src/treeUtils/sandbox.mjs +158 -0
  124. package/dist/src/tweaker/TweakerPriority.mjs +9 -0
  125. package/dist/src/tweaker/core.mjs +38 -0
  126. package/dist/src/tweaker/registerDefaultTweakers.mjs +17 -0
  127. package/dist/src/tweaker/tweak.mjs +109 -0
  128. package/dist/src/tweaker/tweakArray.mjs +272 -0
  129. package/dist/src/tweaker/tweakFrozen.mjs +28 -0
  130. package/dist/src/tweaker/tweakModel.mjs +26 -0
  131. package/dist/src/tweaker/tweakPlainObject.mjs +205 -0
  132. package/dist/src/tweaker/typeChecking.mjs +46 -0
  133. package/dist/src/tweaker/withoutTypeChecking.mjs +15 -0
  134. package/dist/src/types/TypeCheckError.mjs +31 -0
  135. package/dist/src/types/TypeChecker.mjs +165 -0
  136. package/dist/src/types/arrayBased/array.mjs +68 -0
  137. package/dist/src/types/arrayBased/tuple.mjs +71 -0
  138. package/dist/src/types/getTypeInfo.mjs +12 -0
  139. package/dist/src/types/objectBased/arraySet.mjs +83 -0
  140. package/dist/src/types/objectBased/dataModelData.mjs +95 -0
  141. package/dist/src/types/objectBased/model.mjs +133 -0
  142. package/dist/src/types/objectBased/object.mjs +119 -0
  143. package/dist/src/types/objectBased/objectMap.mjs +90 -0
  144. package/dist/src/types/objectBased/record.mjs +80 -0
  145. package/dist/src/types/objectBased/ref.mjs +62 -0
  146. package/dist/src/types/primitiveBased/enum.mjs +20 -0
  147. package/dist/src/types/primitiveBased/primitives.mjs +59 -0
  148. package/dist/src/types/primitiveBased/refinedPrimitives.mjs +6 -0
  149. package/dist/src/types/registerDefaultStandardTypeResolvers.mjs +13 -0
  150. package/dist/src/types/resolveTypeChecker.mjs +52 -0
  151. package/dist/src/types/tProp.mjs +53 -0
  152. package/dist/src/types/typeCheck.mjs +11 -0
  153. package/dist/src/types/types.mjs +69 -0
  154. package/dist/src/types/utility/maybe.mjs +10 -0
  155. package/dist/src/types/utility/or.mjs +99 -0
  156. package/dist/src/types/utility/refinement.mjs +52 -0
  157. package/dist/src/types/utility/unchecked.mjs +10 -0
  158. package/dist/src/utils/ModelPool.mjs +50 -0
  159. package/dist/src/utils/chainFns.mjs +15 -0
  160. package/dist/src/utils/index.mjs +228 -0
  161. package/dist/src/utils/mapUtils.mjs +10 -0
  162. package/dist/src/utils/tag.mjs +16 -0
  163. package/dist/src/wrappers/ArraySet.mjs +85 -0
  164. package/dist/src/wrappers/ObjectMap.mjs +96 -0
  165. package/dist/src/wrappers/asMap.mjs +181 -0
  166. package/dist/src/wrappers/asSet.mjs +97 -0
  167. package/dist/tweaker/index.d.ts +0 -4
  168. package/dist/tweaker/registerDefaultTweakers.d.ts +1 -0
  169. package/dist/types/registerDefaultStandardTypeResolvers.d.ts +1 -0
  170. package/package.json +12 -14
  171. package/src/actionMiddlewares/actionSerialization/actionSerialization.ts +24 -9
  172. package/src/dataModel/BaseDataModel.ts +0 -3
  173. package/src/dataModel/utils.ts +4 -4
  174. package/src/dist/action/actionDecoratorUtils.d.ts +5 -0
  175. package/src/dist/action/applyAction.d.ts +36 -0
  176. package/src/dist/action/applyDelete.d.ts +7 -0
  177. package/src/dist/action/applyMethodCall.d.ts +9 -0
  178. package/src/dist/action/applySet.d.ts +8 -0
  179. package/src/dist/action/builtInActions.d.ts +39 -0
  180. package/src/dist/action/context.d.ts +85 -0
  181. package/src/dist/action/hookActions.d.ts +32 -0
  182. package/src/dist/action/index.d.ts +12 -0
  183. package/src/dist/action/isModelAction.d.ts +7 -0
  184. package/src/dist/action/middleware.d.ts +34 -0
  185. package/src/dist/action/modelAction.d.ts +9 -0
  186. package/src/dist/action/modelFlow.d.ts +34 -0
  187. package/src/dist/action/pendingActions.d.ts +1 -0
  188. package/src/dist/action/protection.d.ts +1 -0
  189. package/src/dist/action/runUnprotected.d.ts +19 -0
  190. package/src/dist/action/wrapInAction.d.ts +1 -0
  191. package/src/dist/actionMiddlewares/actionSerialization/actionSerialization.d.ts +84 -0
  192. package/src/dist/actionMiddlewares/actionSerialization/applySerializedAction.d.ts +45 -0
  193. package/src/dist/actionMiddlewares/actionSerialization/arraySerializer.d.ts +3 -0
  194. package/src/dist/actionMiddlewares/actionSerialization/core.d.ts +28 -0
  195. package/src/dist/actionMiddlewares/actionSerialization/dateSerializer.d.ts +2 -0
  196. package/src/dist/actionMiddlewares/actionSerialization/index.d.ts +3 -0
  197. package/src/dist/actionMiddlewares/actionSerialization/mapSerializer.d.ts +6 -0
  198. package/src/dist/actionMiddlewares/actionSerialization/objectPathSerializer.d.ts +8 -0
  199. package/src/dist/actionMiddlewares/actionSerialization/objectSnapshotSerializer.d.ts +2 -0
  200. package/src/dist/actionMiddlewares/actionSerialization/plainObjectSerializer.d.ts +2 -0
  201. package/src/dist/actionMiddlewares/actionSerialization/primitiveSerializer.d.ts +2 -0
  202. package/src/dist/actionMiddlewares/actionSerialization/setSerializer.d.ts +3 -0
  203. package/src/dist/actionMiddlewares/actionTrackingMiddleware.d.ts +122 -0
  204. package/src/dist/actionMiddlewares/index.d.ts +6 -0
  205. package/src/dist/actionMiddlewares/onActionMiddleware.d.ts +26 -0
  206. package/src/dist/actionMiddlewares/readonlyMiddleware.d.ts +35 -0
  207. package/src/dist/actionMiddlewares/transactionMiddleware.d.ts +21 -0
  208. package/src/dist/actionMiddlewares/undoMiddleware.d.ts +283 -0
  209. package/src/dist/actionMiddlewares/utils.d.ts +1 -0
  210. package/src/dist/computedTree/computedTree.d.ts +16 -0
  211. package/src/dist/computedTree/index.d.ts +1 -0
  212. package/src/dist/context/context.d.ts +84 -0
  213. package/src/dist/context/index.d.ts +1 -0
  214. package/src/dist/dataModel/BaseDataModel.d.ts +52 -0
  215. package/src/dist/dataModel/DataModel.d.ts +47 -0
  216. package/src/dist/dataModel/DataModelConstructorOptions.d.ts +1 -0
  217. package/src/dist/dataModel/actions.d.ts +1 -0
  218. package/src/dist/dataModel/getDataModelMetadata.d.ts +19 -0
  219. package/src/dist/dataModel/index.d.ts +4 -0
  220. package/src/dist/dataModel/newDataModel.d.ts +1 -0
  221. package/src/dist/dataModel/utils.d.ts +8 -0
  222. package/src/dist/frozen/Frozen.d.ts +50 -0
  223. package/src/dist/frozen/index.d.ts +1 -0
  224. package/src/dist/globalConfig/globalConfig.d.ts +51 -0
  225. package/src/dist/globalConfig/index.d.ts +1 -0
  226. package/src/dist/index.d.ts +23 -0
  227. package/src/dist/mobx-keystone.umd.js +8201 -0
  228. package/src/dist/model/BaseModel.d.ts +125 -0
  229. package/src/dist/model/Model.d.ts +94 -0
  230. package/src/dist/model/ModelConstructorOptions.d.ts +1 -0
  231. package/src/dist/model/getModelMetadata.d.ts +27 -0
  232. package/src/dist/model/index.d.ts +5 -0
  233. package/src/dist/model/metadata.d.ts +8 -0
  234. package/src/dist/model/newModel.d.ts +1 -0
  235. package/src/dist/model/utils.d.ts +8 -0
  236. package/src/dist/modelShared/BaseModelShared.d.ts +76 -0
  237. package/src/dist/modelShared/Model.d.ts +15 -0
  238. package/src/dist/modelShared/checkModelDecoratorArgs.d.ts +1 -0
  239. package/src/dist/modelShared/index.d.ts +3 -0
  240. package/src/dist/modelShared/modelClassInitializer.d.ts +1 -0
  241. package/src/dist/modelShared/modelDecorator.d.ts +24 -0
  242. package/src/dist/modelShared/modelInfo.d.ts +1 -0
  243. package/src/dist/modelShared/modelPropsInfo.d.ts +1 -0
  244. package/src/dist/modelShared/modelSymbols.d.ts +3 -0
  245. package/src/dist/modelShared/newModel.d.ts +4 -0
  246. package/src/dist/modelShared/prop.d.ts +179 -0
  247. package/src/dist/modelShared/utils.d.ts +1 -0
  248. package/src/dist/parent/core.d.ts +1 -0
  249. package/src/dist/parent/coreObjectChildren.d.ts +1 -0
  250. package/src/dist/parent/detach.d.ts +9 -0
  251. package/src/dist/parent/findChildren.d.ts +13 -0
  252. package/src/dist/parent/findParent.d.ts +41 -0
  253. package/src/dist/parent/getChildrenObjects.d.ts +11 -0
  254. package/src/dist/parent/index.d.ts +9 -0
  255. package/src/dist/parent/onChildAttachedTo.d.ts +22 -0
  256. package/src/dist/parent/path.d.ts +107 -0
  257. package/src/dist/parent/path2.d.ts +16 -0
  258. package/src/dist/parent/pathTypes.d.ts +12 -0
  259. package/src/dist/parent/setParent.d.ts +1 -0
  260. package/src/dist/parent/walkTree.d.ts +25 -0
  261. package/src/dist/patch/Patch.d.ts +16 -0
  262. package/src/dist/patch/applyPatches.d.ts +9 -0
  263. package/src/dist/patch/emitPatch.d.ts +29 -0
  264. package/src/dist/patch/index.d.ts +5 -0
  265. package/src/dist/patch/jsonPatch.d.ts +45 -0
  266. package/src/dist/patch/patchRecorder.d.ts +70 -0
  267. package/src/dist/redux/connectReduxDevTools.d.ts +12 -0
  268. package/src/dist/redux/index.d.ts +2 -0
  269. package/src/dist/redux/redux.d.ts +47 -0
  270. package/src/dist/ref/Ref.d.ts +53 -0
  271. package/src/dist/ref/core.d.ts +46 -0
  272. package/src/dist/ref/customRef.d.ts +38 -0
  273. package/src/dist/ref/index.d.ts +4 -0
  274. package/src/dist/ref/rootRef.d.ts +33 -0
  275. package/src/dist/rootStore/attachDetach.d.ts +1 -0
  276. package/src/dist/rootStore/index.d.ts +1 -0
  277. package/src/dist/rootStore/rootStore.d.ts +33 -0
  278. package/src/dist/snapshot/SnapshotOf.d.ts +47 -0
  279. package/src/dist/snapshot/SnapshotterAndReconcilerPriority.d.ts +1 -0
  280. package/src/dist/snapshot/applySnapshot.d.ts +17 -0
  281. package/src/dist/snapshot/clone.d.ts +18 -0
  282. package/src/dist/snapshot/fromArraySnapshot.d.ts +1 -0
  283. package/src/dist/snapshot/fromFrozenSnapshot.d.ts +1 -0
  284. package/src/dist/snapshot/fromModelSnapshot.d.ts +1 -0
  285. package/src/dist/snapshot/fromPlainObjectSnapshot.d.ts +1 -0
  286. package/src/dist/snapshot/fromSnapshot.d.ts +36 -0
  287. package/src/dist/snapshot/getSnapshot.d.ts +22 -0
  288. package/src/dist/snapshot/index.d.ts +6 -0
  289. package/src/dist/snapshot/internal.d.ts +1 -0
  290. package/src/dist/snapshot/onSnapshot.d.ts +18 -0
  291. package/src/dist/snapshot/reconcileArraySnapshot.d.ts +1 -0
  292. package/src/dist/snapshot/reconcileFrozenSnapshot.d.ts +1 -0
  293. package/src/dist/snapshot/reconcileModelSnapshot.d.ts +1 -0
  294. package/src/dist/snapshot/reconcilePlainObjectSnapshot.d.ts +1 -0
  295. package/src/dist/snapshot/reconcileSnapshot.d.ts +1 -0
  296. package/src/dist/snapshot/registerDefaultReconcilers.d.ts +1 -0
  297. package/src/dist/snapshot/registerDefaultSnapshotters.d.ts +1 -0
  298. package/src/dist/standardActions/actions.d.ts +1 -0
  299. package/src/dist/standardActions/arrayActions.d.ts +18 -0
  300. package/src/dist/standardActions/index.d.ts +3 -0
  301. package/src/dist/standardActions/objectActions.d.ts +7 -0
  302. package/src/dist/standardActions/standaloneActions.d.ts +16 -0
  303. package/src/dist/transforms/ImmutableDate.d.ts +1 -0
  304. package/src/dist/transforms/asMap.d.ts +3 -0
  305. package/src/dist/transforms/asSet.d.ts +2 -0
  306. package/src/dist/transforms/bigint.d.ts +2 -0
  307. package/src/dist/transforms/date.d.ts +3 -0
  308. package/src/dist/transforms/index.d.ts +4 -0
  309. package/src/dist/treeUtils/deepEquals.d.ts +20 -0
  310. package/src/dist/treeUtils/draft.d.ts +70 -0
  311. package/src/dist/treeUtils/index.d.ts +3 -0
  312. package/src/dist/treeUtils/sandbox.d.ts +85 -0
  313. package/src/dist/tweaker/TweakerPriority.d.ts +1 -0
  314. package/src/dist/tweaker/core.d.ts +14 -0
  315. package/src/dist/tweaker/index.d.ts +2 -0
  316. package/src/dist/tweaker/registerDefaultTweakers.d.ts +1 -0
  317. package/src/dist/tweaker/tweak.d.ts +22 -0
  318. package/src/dist/tweaker/tweakArray.d.ts +1 -0
  319. package/src/dist/tweaker/tweakFrozen.d.ts +1 -0
  320. package/src/dist/tweaker/tweakModel.d.ts +1 -0
  321. package/src/dist/tweaker/tweakPlainObject.d.ts +1 -0
  322. package/src/dist/tweaker/typeChecking.d.ts +1 -0
  323. package/src/dist/tweaker/withoutTypeChecking.d.ts +2 -0
  324. package/src/dist/types/TypeCheckError.d.ts +22 -0
  325. package/src/dist/types/TypeChecker.d.ts +8 -0
  326. package/src/dist/types/arrayBased/array.d.ts +23 -0
  327. package/src/dist/types/arrayBased/tuple.d.ts +24 -0
  328. package/src/dist/types/getTypeInfo.d.ts +9 -0
  329. package/src/dist/types/index.d.ts +5 -0
  330. package/src/dist/types/objectBased/arraySet.d.ts +24 -0
  331. package/src/dist/types/objectBased/dataModelData.d.ts +44 -0
  332. package/src/dist/types/objectBased/model.d.ts +43 -0
  333. package/src/dist/types/objectBased/object.d.ts +63 -0
  334. package/src/dist/types/objectBased/objectMap.d.ts +24 -0
  335. package/src/dist/types/objectBased/record.d.ts +24 -0
  336. package/src/dist/types/objectBased/ref.d.ts +21 -0
  337. package/src/dist/types/primitiveBased/enum.d.ts +34 -0
  338. package/src/dist/types/primitiveBased/primitives.d.ts +81 -0
  339. package/src/dist/types/primitiveBased/refinedPrimitives.d.ts +18 -0
  340. package/src/dist/types/registerDefaultStandardTypeResolvers.d.ts +1 -0
  341. package/src/dist/types/resolveTypeChecker.d.ts +1 -0
  342. package/src/dist/types/schemas.d.ts +53 -0
  343. package/src/dist/types/tProp.d.ts +92 -0
  344. package/src/dist/types/typeCheck.d.ts +11 -0
  345. package/src/dist/types/types.d.ts +51 -0
  346. package/src/dist/types/utility/maybe.d.ts +29 -0
  347. package/src/dist/types/utility/or.d.ts +35 -0
  348. package/src/dist/types/utility/refinement.d.ts +45 -0
  349. package/src/dist/types/utility/unchecked.d.ts +22 -0
  350. package/src/dist/utils/ModelPool.d.ts +7 -0
  351. package/src/dist/utils/chainFns.d.ts +1 -0
  352. package/src/dist/utils/index.d.ts +6 -0
  353. package/src/dist/utils/mapUtils.d.ts +2 -0
  354. package/src/dist/utils/tag.d.ts +13 -0
  355. package/src/dist/utils/types.d.ts +39 -0
  356. package/src/dist/wrappers/ArraySet.d.ts +29 -0
  357. package/src/dist/wrappers/ObjectMap.d.ts +32 -0
  358. package/src/dist/wrappers/asMap.d.ts +29 -0
  359. package/src/dist/wrappers/asSet.d.ts +15 -0
  360. package/src/dist/wrappers/index.d.ts +4 -0
  361. package/src/model/BaseModel.ts +0 -3
  362. package/src/model/utils.ts +4 -5
  363. package/src/modelShared/checkModelDecoratorArgs.ts +6 -6
  364. package/src/parent/setParent.ts +2 -2
  365. package/src/rootStore/attachDetach.ts +2 -3
  366. package/src/snapshot/fromArraySnapshot.ts +11 -6
  367. package/src/snapshot/fromFrozenSnapshot.ts +11 -6
  368. package/src/snapshot/fromModelSnapshot.ts +11 -6
  369. package/src/snapshot/fromPlainObjectSnapshot.ts +11 -6
  370. package/src/snapshot/fromSnapshot.ts +3 -0
  371. package/src/snapshot/index.ts +0 -10
  372. package/src/snapshot/reconcileArraySnapshot.ts +11 -6
  373. package/src/snapshot/reconcileFrozenSnapshot.ts +11 -6
  374. package/src/snapshot/reconcileModelSnapshot.ts +11 -6
  375. package/src/snapshot/reconcilePlainObjectSnapshot.ts +11 -6
  376. package/src/snapshot/reconcileSnapshot.ts +3 -0
  377. package/src/snapshot/registerDefaultReconcilers.ts +21 -0
  378. package/src/snapshot/registerDefaultSnapshotters.ts +21 -0
  379. package/src/tweaker/index.ts +0 -6
  380. package/src/tweaker/registerDefaultTweakers.ts +21 -0
  381. package/src/tweaker/tweak.ts +3 -0
  382. package/src/tweaker/tweakArray.ts +406 -401
  383. package/src/tweaker/tweakFrozen.ts +11 -6
  384. package/src/tweaker/tweakModel.ts +11 -6
  385. package/src/tweaker/tweakPlainObject.ts +288 -283
  386. package/src/types/objectBased/model.ts +6 -1
  387. package/src/types/objectBased/ref.ts +1 -1
  388. package/src/types/primitiveBased/primitives.ts +177 -166
  389. package/src/types/registerDefaultStandardTypeResolvers.ts +17 -0
  390. package/src/types/resolveTypeChecker.ts +7 -1
  391. package/dist/mobx-keystone.es.js +0 -7856
  392. package/dist/mobx-keystone.es.mjs +0 -7856
  393. package/src/dataModel/_BaseDataModel.ts +0 -15
  394. package/src/model/_BaseModel.ts +0 -15
@@ -0,0 +1,51 @@
1
+ import { ArrayTypeInfo, typesArray } from "./arrayBased/array";
2
+ import { TupleTypeInfo, typesTuple } from "./arrayBased/tuple";
3
+ import { ArraySetTypeInfo, typesArraySet } from "./objectBased/arraySet";
4
+ import { typesDataModelData } from "./objectBased/dataModelData";
5
+ import { ModelTypeInfo, ModelTypeInfoProps, typesModel } from "./objectBased/model";
6
+ import { FrozenTypeInfo, ObjectTypeInfo, ObjectTypeInfoProps, typesFrozen, typesObject } from "./objectBased/object";
7
+ import { ObjectMapTypeInfo, typesObjectMap } from "./objectBased/objectMap";
8
+ import { RecordTypeInfo, typesRecord } from "./objectBased/record";
9
+ import { RefTypeInfo, typesRef } from "./objectBased/ref";
10
+ import { typesEnum } from "./primitiveBased/enum";
11
+ import { BooleanTypeInfo, LiteralTypeInfo, NumberTypeInfo, StringTypeInfo, typesLiteral } from "./primitiveBased/primitives";
12
+ import type { AnyType } from "./schemas";
13
+ import { typesMaybe, typesMaybeNull } from "./utility/maybe";
14
+ import { OrTypeInfo, typesOr } from "./utility/or";
15
+ import { RefinementTypeInfo, typesRefinement } from "./utility/refinement";
16
+ import { typesUnchecked, UncheckedTypeInfo } from "./utility/unchecked";
17
+ export { getTypeInfo } from "./getTypeInfo";
18
+ export { TypeInfo } from "./TypeChecker";
19
+ export type { ObjectTypeInfoProps, ModelTypeInfoProps };
20
+ export { BooleanTypeInfo, LiteralTypeInfo, NumberTypeInfo, StringTypeInfo, FrozenTypeInfo, ObjectMapTypeInfo, RefinementTypeInfo, RecordTypeInfo, RefTypeInfo, UncheckedTypeInfo, ObjectTypeInfo, ArraySetTypeInfo, ArrayTypeInfo, ModelTypeInfo, OrTypeInfo, TupleTypeInfo, };
21
+ export declare const types: {
22
+ literal: typeof typesLiteral;
23
+ undefined: import("./schemas").IdentityType<undefined>;
24
+ null: import("./schemas").IdentityType<null>;
25
+ boolean: import("./schemas").IdentityType<boolean>;
26
+ number: import("./schemas").IdentityType<number>;
27
+ string: import("./schemas").IdentityType<string>;
28
+ or: typeof typesOr;
29
+ maybe: typeof typesMaybe;
30
+ maybeNull: typeof typesMaybeNull;
31
+ array: typeof typesArray;
32
+ record: typeof typesRecord;
33
+ unchecked: typeof typesUnchecked;
34
+ model: typeof typesModel;
35
+ dataModelData: typeof typesDataModelData;
36
+ object: typeof typesObject;
37
+ ref: typeof typesRef;
38
+ frozen: typeof typesFrozen;
39
+ enum: typeof typesEnum;
40
+ refinement: typeof typesRefinement;
41
+ integer: import("./schemas").IdentityType<number>;
42
+ nonEmptyString: import("./schemas").IdentityType<string>;
43
+ objectMap: typeof typesObjectMap;
44
+ arraySet: typeof typesArraySet;
45
+ tuple: typeof typesTuple;
46
+ mapArray<T extends AnyType>(valueType: T): import("./schemas").ArrayType<import("./schemas").ArrayType<[import("./schemas").IdentityType<string>, T]>[]>;
47
+ setArray<T_1 extends AnyType>(valueType: T_1): import("./schemas").ArrayType<T_1[]>;
48
+ mapObject<T_2 extends AnyType>(valueType: T_2): import("./schemas").RecordType<T_2>;
49
+ dateString: import("./schemas").IdentityType<string>;
50
+ dateTimestamp: import("./schemas").IdentityType<number>;
51
+ };
@@ -0,0 +1,29 @@
1
+ import type { AnyType, IdentityType } from "../schemas";
2
+ /**
3
+ * A type that represents either a type or undefined.
4
+ * Syntactic sugar for `types.or(baseType, types.undefined)`
5
+ *
6
+ * Example:
7
+ * ```ts
8
+ * const numberOrUndefinedType = types.maybe(types.number)
9
+ * ```
10
+ *
11
+ * @typeparam T Type.
12
+ * @param baseType Type.
13
+ * @returns
14
+ */
15
+ export declare function typesMaybe<T extends AnyType>(baseType: T): T | IdentityType<undefined>;
16
+ /**
17
+ * A type that represents either a type or null.
18
+ * Syntactic sugar for `types.or(baseType, types.null)`
19
+ *
20
+ * * Example:
21
+ * ```ts
22
+ * const numberOrNullType = types.maybeNull(types.number)
23
+ * ```
24
+ *
25
+ * @typeparam T Type.
26
+ * @param type Type.
27
+ * @returns
28
+ */
29
+ export declare function typesMaybeNull<T extends AnyType>(type: T): T | IdentityType<null>;
@@ -0,0 +1,35 @@
1
+ import type { AnyStandardType, AnyType } from "../schemas";
2
+ import { TypeInfo } from "../TypeChecker";
3
+ /**
4
+ * A type that represents the union of several other types (a | b | c | ...).
5
+ * Accepts a dispatcher that, given a snapshot, returns the type
6
+ * that snapshot is.
7
+ *
8
+ * @typeparam T Type.
9
+ * @param dispatcher Function that given a snapshot returns the type.
10
+ * @param orTypes Possible types.
11
+ * @returns
12
+ */
13
+ export declare function typesOr<T extends AnyType[]>(dispatcher: (sn: any) => T[number], ...orTypes: T): T[number];
14
+ /**
15
+ * A type that represents the union of several other types (a | b | c | ...).
16
+ *
17
+ * Example:
18
+ * ```ts
19
+ * const booleanOrNumberType = types.or(types.boolean, types.number)
20
+ * ```
21
+ *
22
+ * @typeparam T Type.
23
+ * @param orTypes Possible types.
24
+ * @returns
25
+ */
26
+ export declare function typesOr<T extends AnyType[]>(...orTypes: T): T[number];
27
+ /**
28
+ * `types.or` type info.
29
+ */
30
+ export declare class OrTypeInfo extends TypeInfo {
31
+ readonly orTypes: ReadonlyArray<AnyStandardType>;
32
+ private _orTypeInfos;
33
+ get orTypeInfos(): ReadonlyArray<TypeInfo>;
34
+ constructor(thisType: AnyStandardType, orTypes: ReadonlyArray<AnyStandardType>);
35
+ }
@@ -0,0 +1,45 @@
1
+ import type { AnyStandardType, AnyType, TypeToData } from "../schemas";
2
+ import { TypeInfo } from "../TypeChecker";
3
+ import { TypeCheckError } from "../TypeCheckError";
4
+ /**
5
+ * A refinement over a given type. This allows you to do extra checks
6
+ * over models, ensure numbers are integers, etc.
7
+ *
8
+ * Example:
9
+ * ```ts
10
+ * const integerType = types.refinement(types.number, (n) => {
11
+ * return Number.isInteger(n)
12
+ * }, "integer")
13
+ *
14
+ * const sumModelType = types.refinement(types.model(Sum), (sum) => {
15
+ * // imagine that for some reason sum includes a number 'a', a number 'b'
16
+ * // and the result
17
+ *
18
+ * const rightResult = sum.a + sum.b === sum.result
19
+ *
20
+ * // simple mode that will just return that the whole model is incorrect
21
+ * return rightResult
22
+ *
23
+ * // this will return that the result field is wrong
24
+ * return rightResult ? null : new TypeCheckError(["result"], "a+b", sum.result)
25
+ * })
26
+ * ```
27
+ *
28
+ * @typeparam T Base type.
29
+ * @param baseType Base type.
30
+ * @param checkFn Function that will receive the data (if it passes the base type
31
+ * check) and return null or false if there were no errors or either a TypeCheckError instance or
32
+ * true if there were.
33
+ * @returns
34
+ */
35
+ export declare function typesRefinement<T extends AnyType>(baseType: T, checkFn: (data: TypeToData<T>) => TypeCheckError | null | boolean, typeName?: string): T;
36
+ /**
37
+ * `types.refinement` type info.
38
+ */
39
+ export declare class RefinementTypeInfo extends TypeInfo {
40
+ readonly baseType: AnyStandardType;
41
+ readonly checkFunction: (data: any) => TypeCheckError | null | boolean;
42
+ readonly typeName: string | undefined;
43
+ get baseTypeInfo(): TypeInfo;
44
+ constructor(thisType: AnyStandardType, baseType: AnyStandardType, checkFunction: (data: any) => TypeCheckError | null | boolean, typeName: string | undefined);
45
+ }
@@ -0,0 +1,22 @@
1
+ import type { IdentityType } from "../schemas";
2
+ import { TypeInfo } from "../TypeChecker";
3
+ /**
4
+ * A type that represents a given value that won't be type checked.
5
+ * This is basically a way to bail out of the runtime type checking system.
6
+ *
7
+ * Example:
8
+ * ```ts
9
+ * const uncheckedSomeModel = types.unchecked<SomeModel>()
10
+ * const anyType = types.unchecked<any>()
11
+ * const customUncheckedType = types.unchecked<(A & B) | C>()
12
+ * ```
13
+ *
14
+ * @typeparam T Type of the value, or unkown if not given.
15
+ * @returns
16
+ */
17
+ export declare function typesUnchecked<T = never>(): IdentityType<T>;
18
+ /**
19
+ * `types.unchecked` type info.
20
+ */
21
+ export declare class UncheckedTypeInfo extends TypeInfo {
22
+ }
@@ -0,0 +1,7 @@
1
+ import type { AnyModel } from "../model/BaseModel";
2
+ export declare class ModelPool {
3
+ private pool;
4
+ constructor(root: object);
5
+ findModelByTypeAndId(modelType: string, modelId: string | undefined): AnyModel | undefined;
6
+ findModelForSnapshot(sn: any): AnyModel | undefined;
7
+ }
@@ -0,0 +1 @@
1
+ export declare function chainFns<F extends Function>(...fns: (F | undefined)[]): F | undefined;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * A mobx-keystone error.
3
+ */
4
+ export declare class MobxKeystoneError extends Error {
5
+ constructor(msg: string);
6
+ }
@@ -0,0 +1,2 @@
1
+ export declare function getOrCreate<K, V, C = V>(map: Map<K, V>, key: K, create: () => C): V;
2
+ export declare function getOrCreate<K extends object, V, C = V>(map: WeakMap<K, V>, key: K, create: () => C): V;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Creates a tag data accessor for a target object of a certain type.
3
+ * Tag data will be lazy created on access and reused for the same target object.
4
+ *
5
+ * @typeparam Target Target type.
6
+ * @typeparam TagData Tag data type.
7
+ * @param tagDataConstructor Function that will be called the first time the tag
8
+ * for a given object is requested.
9
+ * @returns The tag data associated with the target object.
10
+ */
11
+ export declare function tag<Target extends object, TagData>(tagDataConstructor: (target: Target) => TagData): {
12
+ for(target: Target): TagData;
13
+ };
@@ -0,0 +1,39 @@
1
+ /**
2
+ * @ignore
3
+ *
4
+ * A primitive value.
5
+ */
6
+ export declare type PrimitiveValue = undefined | null | boolean | number | string | bigint;
7
+ /**
8
+ * @ignore
9
+ *
10
+ * A JSON-compatible primitive value.
11
+ */
12
+ export declare type JSONPrimitiveValue = null | boolean | number | string;
13
+ /**
14
+ * @ignore
15
+ *
16
+ * Checks if a value is optional (undefined or any).
17
+ *
18
+ * Examples:
19
+ * - string = false
20
+ * - undefined = true
21
+ * - string | undefined = true
22
+ * - string & undefined = false, but we don't care
23
+ * - any = true
24
+ * - unknown = false, but we don't care
25
+ * - null = false
26
+ * - string | null = false
27
+ * - string & null = false
28
+ */
29
+ export declare type IsOptionalValue<C, TV, FV> = IsNeverType<Extract<C, undefined>, FV, TV>;
30
+ /**
31
+ * @ignore
32
+ */
33
+ export declare type IsNeverType<T, IfNever, IfNotNever> = [T] extends [never] ? IfNever : IfNotNever;
34
+ /**
35
+ * @ignore
36
+ */
37
+ export declare type Flatten<T> = T extends Record<any, any> ? {
38
+ [P in keyof T]: T[P];
39
+ } : T;
@@ -0,0 +1,29 @@
1
+ declare const ArraySet_base: import("../model/Model")._Model<unknown, {
2
+ $modelId: import("../modelShared/prop").ModelIdProp;
3
+ items: import("../modelShared/prop").OptionalModelProp<any[]>;
4
+ }, never, never>;
5
+ /**
6
+ * A set that is backed by an array.
7
+ * Use `arraySet` to create it.
8
+ */
9
+ export declare class ArraySet<V> extends ArraySet_base implements Set<V> {
10
+ add(value: V): this;
11
+ clear(): void;
12
+ delete(value: V): boolean;
13
+ forEach(callbackfn: (value: V, value2: V, set: Set<V>) => void, thisArg?: any): void;
14
+ has(value: V): boolean;
15
+ get size(): number;
16
+ keys(): IterableIterator<V>;
17
+ values(): IterableIterator<V>;
18
+ entries(): IterableIterator<[V, V]>;
19
+ [Symbol.iterator](): IterableIterator<V>;
20
+ get [Symbol.toStringTag](): string;
21
+ }
22
+ /**
23
+ * Creates a new ArraySet model instance.
24
+ *
25
+ * @typeparam V Value type.
26
+ * @param [entries] Optional initial values.
27
+ */
28
+ export declare function arraySet<V>(values?: ReadonlyArray<V> | null): ArraySet<V>;
29
+ export {};
@@ -0,0 +1,32 @@
1
+ declare const ObjectMap_base: import("../model/Model")._Model<unknown, {
2
+ $modelId: import("../modelShared/prop").ModelIdProp;
3
+ items: import("../modelShared/prop").OptionalModelProp<{
4
+ [k: string]: any;
5
+ }>;
6
+ }, never, never>;
7
+ /**
8
+ * A map that is backed by an object-like map.
9
+ * Use `objectMap` to create it.
10
+ */
11
+ export declare class ObjectMap<V> extends ObjectMap_base implements Map<string, V> {
12
+ clear(): void;
13
+ delete(key: string): boolean;
14
+ forEach(callbackfn: (value: V, key: string, map: Map<string, V>) => void, thisArg?: any): void;
15
+ get(key: string): V | undefined;
16
+ has(key: string): boolean;
17
+ set(key: string, value: V): this;
18
+ get size(): number;
19
+ keys(): IterableIterator<string>;
20
+ values(): IterableIterator<V>;
21
+ entries(): IterableIterator<[string, V]>;
22
+ [Symbol.iterator](): IterableIterator<[string, V]>;
23
+ get [Symbol.toStringTag](): string;
24
+ }
25
+ /**
26
+ * Creates a new ObjectMap model instance.
27
+ *
28
+ * @typeparam V Value type.
29
+ * @param [entries] Optional initial values.
30
+ */
31
+ export declare function objectMap<V>(entries?: ReadonlyArray<readonly [string, V]> | null): ObjectMap<V>;
32
+ export {};
@@ -0,0 +1,29 @@
1
+ import { ObservableMap } from "mobx";
2
+ /**
3
+ * Wraps an observable object or a tuple array to offer a map like interface.
4
+ *
5
+ * @param array Array.
6
+ */
7
+ export declare function asMap<K, V>(array: Array<[K, V]>): ObservableMap<K, V> & {
8
+ dataObject: Array<[K, V]>;
9
+ };
10
+ /**
11
+ * Wraps an observable object or a tuple array to offer a map like interface.
12
+ *
13
+ * @param object Object.
14
+ */
15
+ export declare function asMap<T>(object: Record<string, T>): ObservableMap<string, T> & {
16
+ dataObject: Record<string, T>;
17
+ };
18
+ /**
19
+ * Converts a map to an object. If the map is a collection wrapper it will return the backed object.
20
+ *
21
+ * @param map
22
+ */
23
+ export declare function mapToObject<T>(map: Map<string, T>): Record<string, T>;
24
+ /**
25
+ * Converts a map to an array. If the map is a collection wrapper it will return the backed array.
26
+ *
27
+ * @param map
28
+ */
29
+ export declare function mapToArray<K, V>(map: Map<K, V>): Array<[K, V]>;
@@ -0,0 +1,15 @@
1
+ import { ObservableSet } from "mobx";
2
+ /**
3
+ * Wraps an observable array to offer a set like interface.
4
+ *
5
+ * @param array
6
+ */
7
+ export declare function asSet<T>(array: Array<T>): ObservableSet<T> & {
8
+ dataObject: typeof array;
9
+ };
10
+ /**
11
+ * Converts a set to an array. If the set is a collection wrapper it will return the backed array.
12
+ *
13
+ * @param set
14
+ */
15
+ export declare function setToArray<T>(set: Set<T>): Array<T>;
@@ -0,0 +1,4 @@
1
+ export * from "./ArraySet";
2
+ export * from "./asMap";
3
+ export * from "./asSet";
4
+ export * from "./ObjectMap";
@@ -22,7 +22,6 @@ import { modelIdKey, modelTypeKey } from "./metadata"
22
22
  import type { ModelConstructorOptions } from "./ModelConstructorOptions"
23
23
  import { internalNewModel } from "./newModel"
24
24
  import { assertIsModelClass } from "./utils"
25
- import { setBaseModel } from "./_BaseModel"
26
25
 
27
26
  /**
28
27
  * @ignore
@@ -162,8 +161,6 @@ export abstract class BaseModel<
162
161
  }
163
162
  }
164
163
 
165
- setBaseModel(BaseModel)
166
-
167
164
  /**
168
165
  * @ignore
169
166
  */
@@ -1,8 +1,7 @@
1
1
  import type { ModelClass } from "../modelShared/BaseModelShared"
2
2
  import { failure, isPlainObject } from "../utils"
3
- import type { AnyModel } from "./BaseModel"
3
+ import { AnyModel, BaseModel } from "./BaseModel"
4
4
  import { modelTypeKey } from "./metadata"
5
- import { _BaseModel } from "./_BaseModel"
6
5
 
7
6
  /**
8
7
  * Checks if an object is a model instance.
@@ -11,7 +10,7 @@ import { _BaseModel } from "./_BaseModel"
11
10
  * @returns
12
11
  */
13
12
  export function isModel(model: unknown): model is AnyModel {
14
- return model instanceof _BaseModel
13
+ return model instanceof BaseModel
15
14
  }
16
15
 
17
16
  /**
@@ -40,7 +39,7 @@ export function isModelClass(modelClass: unknown): modelClass is ModelClass<AnyM
40
39
  return false
41
40
  }
42
41
 
43
- if (modelClass !== _BaseModel && !(modelClass.prototype instanceof _BaseModel)) {
42
+ if (modelClass !== BaseModel && !(modelClass.prototype instanceof BaseModel)) {
44
43
  return false
45
44
  }
46
45
 
@@ -58,7 +57,7 @@ export function assertIsModelClass(
58
57
  throw failure(`${argName} must be a class`)
59
58
  }
60
59
 
61
- if (modelClass !== _BaseModel && !(modelClass.prototype instanceof _BaseModel)) {
60
+ if (modelClass !== BaseModel && !(modelClass.prototype instanceof BaseModel)) {
62
61
  throw failure(`${argName} must extend Model`)
63
62
  }
64
63
  }
@@ -1,5 +1,5 @@
1
- import { _BaseDataModel } from "../dataModel/_BaseDataModel"
2
- import { _BaseModel } from "../model/_BaseModel"
1
+ import { BaseDataModel } from "../dataModel/BaseDataModel"
2
+ import { BaseModel } from "../model/BaseModel"
3
3
  import { failure } from "../utils"
4
4
 
5
5
  /**
@@ -18,13 +18,13 @@ export function checkModelDecoratorArgs(fnName: string, target: any, propertyKey
18
18
 
19
19
  // check target is a model object or extended class
20
20
  const isModel =
21
- target instanceof _BaseModel || target === _BaseModel || target.prototype instanceof _BaseModel
21
+ target instanceof BaseModel || target === BaseModel || target.prototype instanceof BaseModel
22
22
  if (isModel) return
23
23
 
24
24
  const isDataModel =
25
- target instanceof _BaseDataModel ||
26
- target === _BaseDataModel ||
27
- target.prototype instanceof _BaseDataModel
25
+ target instanceof BaseDataModel ||
26
+ target === BaseDataModel ||
27
+ target.prototype instanceof BaseDataModel
28
28
  if (isDataModel) return
29
29
 
30
30
  throw failure(errMessage)
@@ -1,8 +1,8 @@
1
1
  import { action } from "mobx"
2
2
  import { enqueuePendingAction } from "../action/pendingActions"
3
+ import { BaseModel } from "../model/BaseModel"
3
4
  import { getModelMetadata } from "../model/getModelMetadata"
4
5
  import { isModel } from "../model/utils"
5
- import { _BaseModel } from "../model/_BaseModel"
6
6
  import { attachToRootStore, detachFromRootStore } from "../rootStore/attachDetach"
7
7
  import { isRootStore } from "../rootStore/rootStore"
8
8
  import { clone } from "../snapshot/clone"
@@ -122,7 +122,7 @@ export const setParent = action(
122
122
  reportParentPathChanged(value)
123
123
  }
124
124
 
125
- if (value instanceof _BaseModel) {
125
+ if (value instanceof BaseModel) {
126
126
  const oldRoot = fastGetRoot(value)
127
127
  const oldRootStore = isRootStore(oldRoot) ? oldRoot : undefined
128
128
 
@@ -2,8 +2,7 @@ import { action } from "mobx"
2
2
  import { ActionContextActionType } from "../action/context"
3
3
  import { HookAction } from "../action/hookActions"
4
4
  import { wrapInAction, wrapModelMethodInActionIfNeeded } from "../action/wrapInAction"
5
- import type { AnyModel } from "../model/BaseModel"
6
- import { _BaseModel } from "../model/_BaseModel"
5
+ import { AnyModel, BaseModel } from "../model/BaseModel"
7
6
  import { walkTree, WalkTreeMode } from "../parent/walkTree"
8
7
 
9
8
  const onAttachedDisposers = new WeakMap<object, () => void>()
@@ -28,7 +27,7 @@ export const attachToRootStore = action(
28
27
  }
29
28
  attachedToRootStore.add(ch)
30
29
 
31
- if (ch instanceof _BaseModel && (ch as any).onAttachedToRootStore) {
30
+ if (ch instanceof BaseModel && (ch as any).onAttachedToRootStore) {
32
31
  wrapModelMethodInActionIfNeeded(
33
32
  ch as any,
34
33
  "onAttachedToRootStore",
@@ -19,9 +19,14 @@ function fromArraySnapshot(sn: SnapshotInOfObject<any>, ctx: FromSnapshotContext
19
19
  return tweakArray(arr, undefined, true)
20
20
  }
21
21
 
22
- registerSnapshotter(SnapshotterAndReconcilerPriority.Array, (sn, ctx) => {
23
- if (isArray(sn)) {
24
- return fromArraySnapshot(sn, ctx)
25
- }
26
- return undefined
27
- })
22
+ /**
23
+ * @internal
24
+ */
25
+ export function registerFromArraySnapshotter() {
26
+ registerSnapshotter(SnapshotterAndReconcilerPriority.Array, (sn, ctx) => {
27
+ if (isArray(sn)) {
28
+ return fromArraySnapshot(sn, ctx)
29
+ }
30
+ return undefined
31
+ })
32
+ }
@@ -2,9 +2,14 @@ import { frozen, isFrozenSnapshot } from "../frozen/Frozen"
2
2
  import { registerSnapshotter } from "./fromSnapshot"
3
3
  import { SnapshotterAndReconcilerPriority } from "./SnapshotterAndReconcilerPriority"
4
4
 
5
- registerSnapshotter(SnapshotterAndReconcilerPriority.Frozen, (sn) => {
6
- if (isFrozenSnapshot(sn)) {
7
- return frozen(sn.data)
8
- }
9
- return undefined
10
- })
5
+ /**
6
+ * @internal
7
+ */
8
+ export function registerFromFrozenSnapshotter() {
9
+ registerSnapshotter(SnapshotterAndReconcilerPriority.Frozen, (sn) => {
10
+ if (isFrozenSnapshot(sn)) {
11
+ return frozen(sn.data)
12
+ }
13
+ return undefined
14
+ })
15
+ }
@@ -38,9 +38,14 @@ function fromModelSnapshot(sn: SnapshotInOfModel<AnyModel>, ctx: FromSnapshotCon
38
38
  } as ModelConstructorOptions)
39
39
  }
40
40
 
41
- registerSnapshotter(SnapshotterAndReconcilerPriority.Model, (sn, ctx) => {
42
- if (isModelSnapshot(sn)) {
43
- return fromModelSnapshot(sn, ctx)
44
- }
45
- return undefined
46
- })
41
+ /**
42
+ * @internal
43
+ */
44
+ export function registerFromModelSnapshotter() {
45
+ registerSnapshotter(SnapshotterAndReconcilerPriority.Model, (sn, ctx) => {
46
+ if (isModelSnapshot(sn)) {
47
+ return fromModelSnapshot(sn, ctx)
48
+ }
49
+ return undefined
50
+ })
51
+ }
@@ -23,9 +23,14 @@ function fromPlainObjectSnapshot(sn: SnapshotInOfObject<any>, ctx: FromSnapshotC
23
23
  return tweakPlainObject(plainObj, undefined, undefined, true, false)
24
24
  }
25
25
 
26
- registerSnapshotter(SnapshotterAndReconcilerPriority.PlainObject, (sn, ctx) => {
27
- if (isPlainObject(sn)) {
28
- return fromPlainObjectSnapshot(sn, ctx)
29
- }
30
- return undefined
31
- })
26
+ /**
27
+ * @internal
28
+ */
29
+ export function registerFromPlainObjectSnapshotter() {
30
+ registerSnapshotter(SnapshotterAndReconcilerPriority.PlainObject, (sn, ctx) => {
31
+ if (isPlainObject(sn)) {
32
+ return fromPlainObjectSnapshot(sn, ctx)
33
+ }
34
+ return undefined
35
+ })
36
+ }
@@ -8,6 +8,7 @@ import { resolveTypeChecker } from "../types/resolveTypeChecker"
8
8
  import type { AnyStandardType, TypeToData } from "../types/schemas"
9
9
  import { isLateTypeChecker, TypeChecker } from "../types/TypeChecker"
10
10
  import { failure, isMap, isPrimitive, isSet } from "../utils"
11
+ import { registerDefaultSnapshotters } from "./registerDefaultSnapshotters"
11
12
  import type { SnapshotInOf, SnapshotInOfModel, SnapshotOutOf } from "./SnapshotOf"
12
13
 
13
14
  /**
@@ -118,6 +119,8 @@ export function internalFromSnapshot<T>(
118
119
  return sn as any
119
120
  }
120
121
 
122
+ registerDefaultSnapshotters()
123
+
121
124
  const snapshotterLen = snapshotters.length
122
125
  for (let i = 0; i < snapshotterLen; i++) {
123
126
  const { snapshotter } = snapshotters[i]
@@ -1,13 +1,3 @@
1
- // make sure snapshotters/reconcilers are imported
2
- import "./fromArraySnapshot"
3
- import "./fromFrozenSnapshot"
4
- import "./fromModelSnapshot"
5
- import "./fromPlainObjectSnapshot"
6
- import "./reconcileArraySnapshot"
7
- import "./reconcileFrozenSnapshot"
8
- import "./reconcileModelSnapshot"
9
- import "./reconcilePlainObjectSnapshot"
10
-
11
1
  export * from "./applySnapshot"
12
2
  export * from "./clone"
13
3
  export * from "./fromSnapshot"
@@ -48,9 +48,14 @@ function reconcileArraySnapshot(
48
48
  return value
49
49
  }
50
50
 
51
- registerReconciler(SnapshotterAndReconcilerPriority.Array, (value, sn, modelPool) => {
52
- if (isArray(sn)) {
53
- return reconcileArraySnapshot(value, sn, modelPool)
54
- }
55
- return undefined
56
- })
51
+ /**
52
+ * @internal
53
+ */
54
+ export function registerArraySnapshotReconciler() {
55
+ registerReconciler(SnapshotterAndReconcilerPriority.Array, (value, sn, modelPool) => {
56
+ if (isArray(sn)) {
57
+ return reconcileArraySnapshot(value, sn, modelPool)
58
+ }
59
+ return undefined
60
+ })
61
+ }