mobx-keystone 0.68.0 → 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.
- package/dist/_virtual/_tslib.mjs +12 -0
- package/dist/node_modules/fast-deep-equal/es6/index.mjs +68 -0
- package/dist/node_modules/nanoid/non-secure/index.mjs +11 -0
- package/dist/src/action/actionDecoratorUtils.mjs +25 -0
- package/dist/src/action/applyAction.mjs +54 -0
- package/dist/src/action/applyDelete.mjs +20 -0
- package/dist/src/action/applyMethodCall.mjs +19 -0
- package/dist/src/action/applySet.mjs +25 -0
- package/dist/src/action/builtInActions.mjs +15 -0
- package/dist/src/action/context.mjs +22 -0
- package/dist/src/action/hookActions.mjs +13 -0
- package/dist/src/action/isModelAction.mjs +6 -0
- package/dist/src/action/middleware.mjs +84 -0
- package/dist/src/action/modelAction.mjs +34 -0
- package/dist/src/action/modelFlow.mjs +251 -0
- package/dist/src/action/pendingActions.mjs +30 -0
- package/dist/src/action/protection.mjs +19 -0
- package/dist/src/action/runUnprotected.mjs +24 -0
- package/dist/src/action/wrapInAction.mjs +90 -0
- package/dist/src/actionMiddlewares/actionSerialization/actionSerialization.mjs +131 -0
- package/dist/src/actionMiddlewares/actionSerialization/applySerializedAction.mjs +110 -0
- package/dist/src/actionMiddlewares/actionSerialization/arraySerializer.mjs +15 -0
- package/dist/src/actionMiddlewares/actionSerialization/core.mjs +3 -0
- package/dist/src/actionMiddlewares/actionSerialization/dateSerializer.mjs +15 -0
- package/dist/src/actionMiddlewares/actionSerialization/mapSerializer.mjs +32 -0
- package/dist/src/actionMiddlewares/actionSerialization/objectPathSerializer.mjs +33 -0
- package/dist/src/actionMiddlewares/actionSerialization/objectSnapshotSerializer.mjs +18 -0
- package/dist/src/actionMiddlewares/actionSerialization/plainObjectSerializer.mjs +27 -0
- package/dist/src/actionMiddlewares/actionSerialization/primitiveSerializer.mjs +39 -0
- package/dist/src/actionMiddlewares/actionSerialization/setSerializer.mjs +29 -0
- package/dist/src/actionMiddlewares/actionTrackingMiddleware.mjs +239 -0
- package/dist/src/actionMiddlewares/onActionMiddleware.mjs +44 -0
- package/dist/src/actionMiddlewares/readonlyMiddleware.mjs +49 -0
- package/dist/src/actionMiddlewares/transactionMiddleware.mjs +69 -0
- package/dist/src/actionMiddlewares/undoMiddleware.mjs +472 -0
- package/dist/src/actionMiddlewares/utils.mjs +25 -0
- package/dist/src/computedTree/computedTree.mjs +63 -0
- package/dist/src/context/context.mjs +141 -0
- package/dist/src/dataModel/BaseDataModel.mjs +108 -0
- package/dist/src/dataModel/DataModel.mjs +32 -0
- package/dist/src/dataModel/actions.mjs +12 -0
- package/dist/src/dataModel/getDataModelMetadata.mjs +14 -0
- package/dist/src/dataModel/newDataModel.mjs +31 -0
- package/dist/src/dataModel/utils.mjs +29 -0
- package/dist/src/frozen/Frozen.mjs +68 -0
- package/dist/src/globalConfig/globalConfig.mjs +57 -0
- package/dist/src/index.mjs +97 -0
- package/dist/src/model/BaseModel.mjs +118 -0
- package/dist/src/model/Model.mjs +36 -0
- package/dist/src/model/getModelMetadata.mjs +19 -0
- package/dist/src/model/metadata.mjs +7 -0
- package/dist/src/model/newModel.mjs +95 -0
- package/dist/src/model/utils.mjs +33 -0
- package/dist/src/modelShared/BaseModelShared.mjs +9 -0
- package/dist/src/modelShared/Model.mjs +249 -0
- package/dist/src/modelShared/checkModelDecoratorArgs.mjs +21 -0
- package/dist/src/modelShared/modelClassInitializer.mjs +14 -0
- package/dist/src/modelShared/modelDecorator.mjs +117 -0
- package/dist/src/modelShared/modelInfo.mjs +7 -0
- package/dist/src/modelShared/modelPropsInfo.mjs +9 -0
- package/dist/src/modelShared/modelSymbols.mjs +5 -0
- package/dist/src/modelShared/newModel.mjs +13 -0
- package/dist/src/modelShared/prop.mjs +138 -0
- package/dist/src/modelShared/utils.mjs +10 -0
- package/dist/src/parent/core.mjs +34 -0
- package/dist/src/parent/coreObjectChildren.mjs +98 -0
- package/dist/src/parent/detach.mjs +32 -0
- package/dist/src/parent/findChildren.mjs +16 -0
- package/dist/src/parent/findParent.mjs +30 -0
- package/dist/src/parent/getChildrenObjects.mjs +12 -0
- package/dist/src/parent/onChildAttachedTo.mjs +101 -0
- package/dist/src/parent/path.mjs +149 -0
- package/dist/src/parent/path2.mjs +12 -0
- package/dist/src/parent/setParent.mjs +83 -0
- package/dist/src/parent/walkTree.mjs +104 -0
- package/dist/src/patch/applyPatches.mjs +118 -0
- package/dist/src/patch/emitPatch.mjs +100 -0
- package/dist/src/patch/jsonPatch.mjs +60 -0
- package/dist/src/patch/patchRecorder.mjs +75 -0
- package/dist/src/redux/connectReduxDevTools.mjs +153 -0
- package/dist/src/redux/redux.mjs +60 -0
- package/dist/src/ref/Ref.mjs +38 -0
- package/dist/src/ref/core.mjs +179 -0
- package/dist/src/ref/customRef.mjs +9 -0
- package/dist/src/ref/rootRef.mjs +34 -0
- package/dist/src/rootStore/attachDetach.mjs +53 -0
- package/dist/src/rootStore/rootStore.mjs +50 -0
- package/dist/src/snapshot/SnapshotterAndReconcilerPriority.mjs +9 -0
- package/dist/src/snapshot/applySnapshot.mjs +92 -0
- package/dist/src/snapshot/clone.mjs +29 -0
- package/dist/src/snapshot/fromArraySnapshot.mjs +23 -0
- package/dist/src/snapshot/fromFrozenSnapshot.mjs +13 -0
- package/dist/src/snapshot/fromModelSnapshot.mjs +38 -0
- package/dist/src/snapshot/fromPlainObjectSnapshot.mjs +26 -0
- package/dist/src/snapshot/fromSnapshot.mjs +91 -0
- package/dist/src/snapshot/getSnapshot.mjs +27 -0
- package/dist/src/snapshot/internal.mjs +97 -0
- package/dist/src/snapshot/onSnapshot.mjs +16 -0
- package/dist/src/snapshot/reconcileArraySnapshot.mjs +40 -0
- package/dist/src/snapshot/reconcileFrozenSnapshot.mjs +19 -0
- package/dist/src/snapshot/reconcileModelSnapshot.mjs +77 -0
- package/dist/src/snapshot/reconcilePlainObjectSnapshot.mjs +47 -0
- package/dist/src/snapshot/reconcileSnapshot.mjs +49 -0
- package/dist/src/snapshot/registerDefaultReconcilers.mjs +17 -0
- package/dist/src/snapshot/registerDefaultSnapshotters.mjs +17 -0
- package/dist/src/standardActions/actions.mjs +35 -0
- package/dist/src/standardActions/arrayActions.mjs +66 -0
- package/dist/src/standardActions/objectActions.mjs +36 -0
- package/dist/src/standardActions/standaloneActions.mjs +9 -0
- package/dist/src/transforms/ImmutableDate.mjs +51 -0
- package/dist/src/transforms/asMap.mjs +29 -0
- package/dist/src/transforms/asSet.mjs +12 -0
- package/dist/src/transforms/bigint.mjs +14 -0
- package/dist/src/transforms/date.mjs +27 -0
- package/dist/src/treeUtils/deepEquals.mjs +40 -0
- package/dist/src/treeUtils/draft.mjs +116 -0
- package/dist/src/treeUtils/sandbox.mjs +158 -0
- package/dist/src/tweaker/TweakerPriority.mjs +9 -0
- package/dist/src/tweaker/core.mjs +38 -0
- package/dist/src/tweaker/registerDefaultTweakers.mjs +17 -0
- package/dist/src/tweaker/tweak.mjs +109 -0
- package/dist/src/tweaker/tweakArray.mjs +272 -0
- package/dist/src/tweaker/tweakFrozen.mjs +28 -0
- package/dist/src/tweaker/tweakModel.mjs +26 -0
- package/dist/src/tweaker/tweakPlainObject.mjs +205 -0
- package/dist/src/tweaker/typeChecking.mjs +46 -0
- package/dist/src/tweaker/withoutTypeChecking.mjs +15 -0
- package/dist/src/types/TypeCheckError.mjs +31 -0
- package/dist/src/types/TypeChecker.mjs +165 -0
- package/dist/src/types/arrayBased/array.mjs +68 -0
- package/dist/src/types/arrayBased/tuple.mjs +71 -0
- package/dist/src/types/getTypeInfo.mjs +12 -0
- package/dist/src/types/objectBased/arraySet.mjs +83 -0
- package/dist/src/types/objectBased/dataModelData.mjs +95 -0
- package/dist/src/types/objectBased/model.mjs +133 -0
- package/dist/src/types/objectBased/object.mjs +119 -0
- package/dist/src/types/objectBased/objectMap.mjs +90 -0
- package/dist/src/types/objectBased/record.mjs +80 -0
- package/dist/src/types/objectBased/ref.mjs +62 -0
- package/dist/src/types/primitiveBased/enum.mjs +20 -0
- package/dist/src/types/primitiveBased/primitives.mjs +59 -0
- package/dist/src/types/primitiveBased/refinedPrimitives.mjs +6 -0
- package/dist/src/types/registerDefaultStandardTypeResolvers.mjs +13 -0
- package/dist/src/types/resolveTypeChecker.mjs +52 -0
- package/dist/src/types/tProp.mjs +53 -0
- package/dist/src/types/typeCheck.mjs +11 -0
- package/dist/src/types/types.mjs +69 -0
- package/dist/src/types/utility/maybe.mjs +10 -0
- package/dist/src/types/utility/or.mjs +99 -0
- package/dist/src/types/utility/refinement.mjs +52 -0
- package/dist/src/types/utility/unchecked.mjs +10 -0
- package/dist/src/utils/ModelPool.mjs +50 -0
- package/dist/src/utils/chainFns.mjs +15 -0
- package/dist/src/utils/index.mjs +228 -0
- package/dist/src/utils/mapUtils.mjs +10 -0
- package/dist/src/utils/tag.mjs +16 -0
- package/dist/src/wrappers/ArraySet.mjs +85 -0
- package/dist/src/wrappers/ObjectMap.mjs +96 -0
- package/dist/src/wrappers/asMap.mjs +181 -0
- package/dist/src/wrappers/asSet.mjs +97 -0
- package/package.json +8 -11
- package/src/dist/action/actionDecoratorUtils.d.ts +5 -0
- package/src/dist/action/applyAction.d.ts +36 -0
- package/src/dist/action/applyDelete.d.ts +7 -0
- package/src/dist/action/applyMethodCall.d.ts +9 -0
- package/src/dist/action/applySet.d.ts +8 -0
- package/src/dist/action/builtInActions.d.ts +39 -0
- package/src/dist/action/context.d.ts +85 -0
- package/src/dist/action/hookActions.d.ts +32 -0
- package/src/dist/action/index.d.ts +12 -0
- package/src/dist/action/isModelAction.d.ts +7 -0
- package/src/dist/action/middleware.d.ts +34 -0
- package/src/dist/action/modelAction.d.ts +9 -0
- package/src/dist/action/modelFlow.d.ts +34 -0
- package/src/dist/action/pendingActions.d.ts +1 -0
- package/src/dist/action/protection.d.ts +1 -0
- package/src/dist/action/runUnprotected.d.ts +19 -0
- package/src/dist/action/wrapInAction.d.ts +1 -0
- package/src/dist/actionMiddlewares/actionSerialization/actionSerialization.d.ts +84 -0
- package/src/dist/actionMiddlewares/actionSerialization/applySerializedAction.d.ts +45 -0
- package/src/dist/actionMiddlewares/actionSerialization/arraySerializer.d.ts +3 -0
- package/src/dist/actionMiddlewares/actionSerialization/core.d.ts +28 -0
- package/src/dist/actionMiddlewares/actionSerialization/dateSerializer.d.ts +2 -0
- package/src/dist/actionMiddlewares/actionSerialization/index.d.ts +3 -0
- package/src/dist/actionMiddlewares/actionSerialization/mapSerializer.d.ts +6 -0
- package/src/dist/actionMiddlewares/actionSerialization/objectPathSerializer.d.ts +8 -0
- package/src/dist/actionMiddlewares/actionSerialization/objectSnapshotSerializer.d.ts +2 -0
- package/src/dist/actionMiddlewares/actionSerialization/plainObjectSerializer.d.ts +2 -0
- package/src/dist/actionMiddlewares/actionSerialization/primitiveSerializer.d.ts +2 -0
- package/src/dist/actionMiddlewares/actionSerialization/setSerializer.d.ts +3 -0
- package/src/dist/actionMiddlewares/actionTrackingMiddleware.d.ts +122 -0
- package/src/dist/actionMiddlewares/index.d.ts +6 -0
- package/src/dist/actionMiddlewares/onActionMiddleware.d.ts +26 -0
- package/src/dist/actionMiddlewares/readonlyMiddleware.d.ts +35 -0
- package/src/dist/actionMiddlewares/transactionMiddleware.d.ts +21 -0
- package/src/dist/actionMiddlewares/undoMiddleware.d.ts +283 -0
- package/src/dist/actionMiddlewares/utils.d.ts +1 -0
- package/src/dist/computedTree/computedTree.d.ts +16 -0
- package/src/dist/computedTree/index.d.ts +1 -0
- package/src/dist/context/context.d.ts +84 -0
- package/src/dist/context/index.d.ts +1 -0
- package/src/dist/dataModel/BaseDataModel.d.ts +52 -0
- package/src/dist/dataModel/DataModel.d.ts +47 -0
- package/src/dist/dataModel/DataModelConstructorOptions.d.ts +1 -0
- package/src/dist/dataModel/actions.d.ts +1 -0
- package/src/dist/dataModel/getDataModelMetadata.d.ts +19 -0
- package/src/dist/dataModel/index.d.ts +4 -0
- package/src/dist/dataModel/newDataModel.d.ts +1 -0
- package/src/dist/dataModel/utils.d.ts +8 -0
- package/src/dist/frozen/Frozen.d.ts +50 -0
- package/src/dist/frozen/index.d.ts +1 -0
- package/src/dist/globalConfig/globalConfig.d.ts +51 -0
- package/src/dist/globalConfig/index.d.ts +1 -0
- package/src/dist/index.d.ts +23 -0
- package/src/dist/mobx-keystone.umd.js +8201 -0
- package/src/dist/model/BaseModel.d.ts +125 -0
- package/src/dist/model/Model.d.ts +94 -0
- package/src/dist/model/ModelConstructorOptions.d.ts +1 -0
- package/src/dist/model/getModelMetadata.d.ts +27 -0
- package/src/dist/model/index.d.ts +5 -0
- package/src/dist/model/metadata.d.ts +8 -0
- package/src/dist/model/newModel.d.ts +1 -0
- package/src/dist/model/utils.d.ts +8 -0
- package/src/dist/modelShared/BaseModelShared.d.ts +76 -0
- package/src/dist/modelShared/Model.d.ts +15 -0
- package/src/dist/modelShared/checkModelDecoratorArgs.d.ts +1 -0
- package/src/dist/modelShared/index.d.ts +3 -0
- package/src/dist/modelShared/modelClassInitializer.d.ts +1 -0
- package/src/dist/modelShared/modelDecorator.d.ts +24 -0
- package/src/dist/modelShared/modelInfo.d.ts +1 -0
- package/src/dist/modelShared/modelPropsInfo.d.ts +1 -0
- package/src/dist/modelShared/modelSymbols.d.ts +3 -0
- package/src/dist/modelShared/newModel.d.ts +4 -0
- package/src/dist/modelShared/prop.d.ts +179 -0
- package/src/dist/modelShared/utils.d.ts +1 -0
- package/src/dist/parent/core.d.ts +1 -0
- package/src/dist/parent/coreObjectChildren.d.ts +1 -0
- package/src/dist/parent/detach.d.ts +9 -0
- package/src/dist/parent/findChildren.d.ts +13 -0
- package/src/dist/parent/findParent.d.ts +41 -0
- package/src/dist/parent/getChildrenObjects.d.ts +11 -0
- package/src/dist/parent/index.d.ts +9 -0
- package/src/dist/parent/onChildAttachedTo.d.ts +22 -0
- package/src/dist/parent/path.d.ts +107 -0
- package/src/dist/parent/path2.d.ts +16 -0
- package/src/dist/parent/pathTypes.d.ts +12 -0
- package/src/dist/parent/setParent.d.ts +1 -0
- package/src/dist/parent/walkTree.d.ts +25 -0
- package/src/dist/patch/Patch.d.ts +16 -0
- package/src/dist/patch/applyPatches.d.ts +9 -0
- package/src/dist/patch/emitPatch.d.ts +29 -0
- package/src/dist/patch/index.d.ts +5 -0
- package/src/dist/patch/jsonPatch.d.ts +45 -0
- package/src/dist/patch/patchRecorder.d.ts +70 -0
- package/src/dist/redux/connectReduxDevTools.d.ts +12 -0
- package/src/dist/redux/index.d.ts +2 -0
- package/src/dist/redux/redux.d.ts +47 -0
- package/src/dist/ref/Ref.d.ts +53 -0
- package/src/dist/ref/core.d.ts +46 -0
- package/src/dist/ref/customRef.d.ts +38 -0
- package/src/dist/ref/index.d.ts +4 -0
- package/src/dist/ref/rootRef.d.ts +33 -0
- package/src/dist/rootStore/attachDetach.d.ts +1 -0
- package/src/dist/rootStore/index.d.ts +1 -0
- package/src/dist/rootStore/rootStore.d.ts +33 -0
- package/src/dist/snapshot/SnapshotOf.d.ts +47 -0
- package/src/dist/snapshot/SnapshotterAndReconcilerPriority.d.ts +1 -0
- package/src/dist/snapshot/applySnapshot.d.ts +17 -0
- package/src/dist/snapshot/clone.d.ts +18 -0
- package/src/dist/snapshot/fromArraySnapshot.d.ts +1 -0
- package/src/dist/snapshot/fromFrozenSnapshot.d.ts +1 -0
- package/src/dist/snapshot/fromModelSnapshot.d.ts +1 -0
- package/src/dist/snapshot/fromPlainObjectSnapshot.d.ts +1 -0
- package/src/dist/snapshot/fromSnapshot.d.ts +36 -0
- package/src/dist/snapshot/getSnapshot.d.ts +22 -0
- package/src/dist/snapshot/index.d.ts +6 -0
- package/src/dist/snapshot/internal.d.ts +1 -0
- package/src/dist/snapshot/onSnapshot.d.ts +18 -0
- package/src/dist/snapshot/reconcileArraySnapshot.d.ts +1 -0
- package/src/dist/snapshot/reconcileFrozenSnapshot.d.ts +1 -0
- package/src/dist/snapshot/reconcileModelSnapshot.d.ts +1 -0
- package/src/dist/snapshot/reconcilePlainObjectSnapshot.d.ts +1 -0
- package/src/dist/snapshot/reconcileSnapshot.d.ts +1 -0
- package/src/dist/snapshot/registerDefaultReconcilers.d.ts +1 -0
- package/src/dist/snapshot/registerDefaultSnapshotters.d.ts +1 -0
- package/src/dist/standardActions/actions.d.ts +1 -0
- package/src/dist/standardActions/arrayActions.d.ts +18 -0
- package/src/dist/standardActions/index.d.ts +3 -0
- package/src/dist/standardActions/objectActions.d.ts +7 -0
- package/src/dist/standardActions/standaloneActions.d.ts +16 -0
- package/src/dist/transforms/ImmutableDate.d.ts +1 -0
- package/src/dist/transforms/asMap.d.ts +3 -0
- package/src/dist/transforms/asSet.d.ts +2 -0
- package/src/dist/transforms/bigint.d.ts +2 -0
- package/src/dist/transforms/date.d.ts +3 -0
- package/src/dist/transforms/index.d.ts +4 -0
- package/src/dist/treeUtils/deepEquals.d.ts +20 -0
- package/src/dist/treeUtils/draft.d.ts +70 -0
- package/src/dist/treeUtils/index.d.ts +3 -0
- package/src/dist/treeUtils/sandbox.d.ts +85 -0
- package/src/dist/tweaker/TweakerPriority.d.ts +1 -0
- package/src/dist/tweaker/core.d.ts +14 -0
- package/src/dist/tweaker/index.d.ts +2 -0
- package/src/dist/tweaker/registerDefaultTweakers.d.ts +1 -0
- package/src/dist/tweaker/tweak.d.ts +22 -0
- package/src/dist/tweaker/tweakArray.d.ts +1 -0
- package/src/dist/tweaker/tweakFrozen.d.ts +1 -0
- package/src/dist/tweaker/tweakModel.d.ts +1 -0
- package/src/dist/tweaker/tweakPlainObject.d.ts +1 -0
- package/src/dist/tweaker/typeChecking.d.ts +1 -0
- package/src/dist/tweaker/withoutTypeChecking.d.ts +2 -0
- package/src/dist/types/TypeCheckError.d.ts +22 -0
- package/src/dist/types/TypeChecker.d.ts +8 -0
- package/src/dist/types/arrayBased/array.d.ts +23 -0
- package/src/dist/types/arrayBased/tuple.d.ts +24 -0
- package/src/dist/types/getTypeInfo.d.ts +9 -0
- package/src/dist/types/index.d.ts +5 -0
- package/src/dist/types/objectBased/arraySet.d.ts +24 -0
- package/src/dist/types/objectBased/dataModelData.d.ts +44 -0
- package/src/dist/types/objectBased/model.d.ts +43 -0
- package/src/dist/types/objectBased/object.d.ts +63 -0
- package/src/dist/types/objectBased/objectMap.d.ts +24 -0
- package/src/dist/types/objectBased/record.d.ts +24 -0
- package/src/dist/types/objectBased/ref.d.ts +21 -0
- package/src/dist/types/primitiveBased/enum.d.ts +34 -0
- package/src/dist/types/primitiveBased/primitives.d.ts +81 -0
- package/src/dist/types/primitiveBased/refinedPrimitives.d.ts +18 -0
- package/src/dist/types/registerDefaultStandardTypeResolvers.d.ts +1 -0
- package/src/dist/types/resolveTypeChecker.d.ts +1 -0
- package/src/dist/types/schemas.d.ts +53 -0
- package/src/dist/types/tProp.d.ts +92 -0
- package/src/dist/types/typeCheck.d.ts +11 -0
- package/src/dist/types/types.d.ts +51 -0
- package/src/dist/types/utility/maybe.d.ts +29 -0
- package/src/dist/types/utility/or.d.ts +35 -0
- package/src/dist/types/utility/refinement.d.ts +45 -0
- package/src/dist/types/utility/unchecked.d.ts +22 -0
- package/src/dist/utils/ModelPool.d.ts +7 -0
- package/src/dist/utils/chainFns.d.ts +1 -0
- package/src/dist/utils/index.d.ts +6 -0
- package/src/dist/utils/mapUtils.d.ts +2 -0
- package/src/dist/utils/tag.d.ts +13 -0
- package/src/dist/utils/types.d.ts +39 -0
- package/src/dist/wrappers/ArraySet.d.ts +29 -0
- package/src/dist/wrappers/ObjectMap.d.ts +32 -0
- package/src/dist/wrappers/asMap.d.ts +29 -0
- package/src/dist/wrappers/asSet.d.ts +15 -0
- package/src/dist/wrappers/index.d.ts +4 -0
- package/dist/mobx-keystone.es.js +0 -7934
- package/dist/mobx-keystone.es.mjs +0 -7934
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
import type { ActionMiddlewareDisposer } from "../action/middleware";
|
|
2
|
+
import type { Path } from "../parent/pathTypes";
|
|
3
|
+
import { Patch } from "../patch";
|
|
4
|
+
/**
|
|
5
|
+
* An undo/redo event without attached state.
|
|
6
|
+
*/
|
|
7
|
+
export declare type UndoEventWithoutAttachedState = UndoSingleEvent | UndoEventGroup;
|
|
8
|
+
/**
|
|
9
|
+
* An undo/redo event.
|
|
10
|
+
*/
|
|
11
|
+
export declare type UndoEvent = UndoEventWithoutAttachedState & {
|
|
12
|
+
/**
|
|
13
|
+
* The state saved before the event actions started / after the event actions finished.
|
|
14
|
+
*/
|
|
15
|
+
attachedState: {
|
|
16
|
+
/**
|
|
17
|
+
* The state saved before the event actions started.
|
|
18
|
+
*/
|
|
19
|
+
beforeEvent?: unknown;
|
|
20
|
+
/**
|
|
21
|
+
* The state saved after the event actions finished.
|
|
22
|
+
*/
|
|
23
|
+
afterEvent?: unknown;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Undo event type.
|
|
28
|
+
*/
|
|
29
|
+
export declare enum UndoEventType {
|
|
30
|
+
Single = "single",
|
|
31
|
+
Group = "group"
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* An undo/redo single event.
|
|
35
|
+
*/
|
|
36
|
+
export interface UndoSingleEvent {
|
|
37
|
+
/**
|
|
38
|
+
* Expresses this is a single event.
|
|
39
|
+
*/
|
|
40
|
+
readonly type: UndoEventType.Single;
|
|
41
|
+
/**
|
|
42
|
+
* Path to the object that invoked the action from its root.
|
|
43
|
+
*/
|
|
44
|
+
readonly targetPath: Path;
|
|
45
|
+
/**
|
|
46
|
+
* Name of the action that was invoked.
|
|
47
|
+
*/
|
|
48
|
+
readonly actionName: string;
|
|
49
|
+
/**
|
|
50
|
+
* Patches with changes done inside the action.
|
|
51
|
+
* Use `redo()` in the `UndoManager` to apply them.
|
|
52
|
+
*/
|
|
53
|
+
readonly patches: ReadonlyArray<Patch>;
|
|
54
|
+
/**
|
|
55
|
+
* Patches to undo the changes done inside the action.
|
|
56
|
+
* Use `undo()` in the `UndoManager` to apply them.
|
|
57
|
+
*/
|
|
58
|
+
readonly inversePatches: ReadonlyArray<Patch>;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* An undo/redo event group.
|
|
62
|
+
*/
|
|
63
|
+
export interface UndoEventGroup {
|
|
64
|
+
/**
|
|
65
|
+
* Expresses this is an event group.
|
|
66
|
+
*/
|
|
67
|
+
readonly type: UndoEventType.Group;
|
|
68
|
+
/**
|
|
69
|
+
* Name of the group (if any).
|
|
70
|
+
*/
|
|
71
|
+
readonly groupName?: string;
|
|
72
|
+
/**
|
|
73
|
+
* Events that conform this group (might be single events or other nested groups).
|
|
74
|
+
*/
|
|
75
|
+
readonly events: ReadonlyArray<UndoEventWithoutAttachedState>;
|
|
76
|
+
}
|
|
77
|
+
declare const UndoStore_base: import("../model/Model")._Model<unknown, {
|
|
78
|
+
undoEvents: import("..").OptionalModelProp<UndoEvent[]>;
|
|
79
|
+
redoEvents: import("..").OptionalModelProp<UndoEvent[]>;
|
|
80
|
+
}, never, never>;
|
|
81
|
+
/**
|
|
82
|
+
* Store model instance for undo/redo actions.
|
|
83
|
+
* Do not manipulate directly, other that creating it.
|
|
84
|
+
*/
|
|
85
|
+
export declare class UndoStore extends UndoStore_base {
|
|
86
|
+
/**
|
|
87
|
+
* @ignore
|
|
88
|
+
*/
|
|
89
|
+
_clearUndo(): void;
|
|
90
|
+
/**
|
|
91
|
+
* @ignore
|
|
92
|
+
*/
|
|
93
|
+
_clearRedo(): void;
|
|
94
|
+
/**
|
|
95
|
+
* @ignore
|
|
96
|
+
*/
|
|
97
|
+
_undo(): void;
|
|
98
|
+
/**
|
|
99
|
+
* @ignore
|
|
100
|
+
*/
|
|
101
|
+
_redo(): void;
|
|
102
|
+
/**
|
|
103
|
+
* @ignore
|
|
104
|
+
*/
|
|
105
|
+
_addUndo(event: UndoEvent): void;
|
|
106
|
+
private _groupStack;
|
|
107
|
+
/**
|
|
108
|
+
* @ignore
|
|
109
|
+
*/
|
|
110
|
+
_addUndoToParentGroup(parentGroup: UndoEventGroup, event: UndoEventWithoutAttachedState): void;
|
|
111
|
+
/**
|
|
112
|
+
* @ignore
|
|
113
|
+
*/
|
|
114
|
+
get _currentGroup(): UndoEventGroup | undefined;
|
|
115
|
+
/**
|
|
116
|
+
* @ignore
|
|
117
|
+
*/
|
|
118
|
+
_startGroup(groupName: string | undefined, startRunning: boolean, options: UndoMiddlewareOptions<unknown> | undefined): {
|
|
119
|
+
pause: () => void;
|
|
120
|
+
resume: () => void;
|
|
121
|
+
end: () => void;
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Manager class returned by `undoMiddleware` that allows you to perform undo/redo actions.
|
|
126
|
+
*/
|
|
127
|
+
export declare class UndoManager {
|
|
128
|
+
private readonly disposer;
|
|
129
|
+
private readonly subtreeRoot;
|
|
130
|
+
private readonly options;
|
|
131
|
+
/**
|
|
132
|
+
* The store currently being used to store undo/redo action events.
|
|
133
|
+
*/
|
|
134
|
+
readonly store: UndoStore;
|
|
135
|
+
/**
|
|
136
|
+
* The undo stack, where the first operation to undo will be the last of the array.
|
|
137
|
+
* Do not manipulate this array directly.
|
|
138
|
+
*/
|
|
139
|
+
get undoQueue(): ReadonlyArray<UndoEvent>;
|
|
140
|
+
/**
|
|
141
|
+
* The redo stack, where the first operation to redo will be the last of the array.
|
|
142
|
+
* Do not manipulate this array directly.
|
|
143
|
+
*/
|
|
144
|
+
get redoQueue(): ReadonlyArray<UndoEvent>;
|
|
145
|
+
/**
|
|
146
|
+
* The number of undo actions available.
|
|
147
|
+
*/
|
|
148
|
+
get undoLevels(): number;
|
|
149
|
+
/**
|
|
150
|
+
* If undo can be performed (if there is at least one undo action available).
|
|
151
|
+
*/
|
|
152
|
+
get canUndo(): boolean;
|
|
153
|
+
/**
|
|
154
|
+
* Clears the undo queue.
|
|
155
|
+
*/
|
|
156
|
+
clearUndo(): void;
|
|
157
|
+
/**
|
|
158
|
+
* The number of redo actions available.
|
|
159
|
+
*/
|
|
160
|
+
get redoLevels(): number;
|
|
161
|
+
/**
|
|
162
|
+
* If redo can be performed (if there is at least one redo action available)
|
|
163
|
+
*/
|
|
164
|
+
get canRedo(): boolean;
|
|
165
|
+
/**
|
|
166
|
+
* Clears the redo queue.
|
|
167
|
+
*/
|
|
168
|
+
clearRedo(): void;
|
|
169
|
+
/**
|
|
170
|
+
* Undoes the last action.
|
|
171
|
+
* Will throw if there is no action to undo.
|
|
172
|
+
*/
|
|
173
|
+
undo(): void;
|
|
174
|
+
/**
|
|
175
|
+
* Redoes the previous action.
|
|
176
|
+
* Will throw if there is no action to redo.
|
|
177
|
+
*/
|
|
178
|
+
redo(): void;
|
|
179
|
+
/**
|
|
180
|
+
* Disposes the undo middleware.
|
|
181
|
+
*/
|
|
182
|
+
dispose(): void;
|
|
183
|
+
private _isUndoRecordingDisabled;
|
|
184
|
+
/**
|
|
185
|
+
* Returns if undo recording is currently disabled or not for this particular `UndoManager`.
|
|
186
|
+
*/
|
|
187
|
+
get isUndoRecordingDisabled(): boolean;
|
|
188
|
+
/**
|
|
189
|
+
* Skips the undo recording mechanism for the code block that gets run synchronously inside.
|
|
190
|
+
*
|
|
191
|
+
* @typeparam T Code block return type.
|
|
192
|
+
* @param fn Code block to run.
|
|
193
|
+
* @returns The value returned by the code block.
|
|
194
|
+
*/
|
|
195
|
+
withoutUndo<T>(fn: () => T): T;
|
|
196
|
+
/**
|
|
197
|
+
* Creates a custom group that can be continued multiple times and then ended.
|
|
198
|
+
* @param groupName Optional group name.
|
|
199
|
+
* @returns An API to continue/end the group.
|
|
200
|
+
*/
|
|
201
|
+
createGroup(groupName?: string): {
|
|
202
|
+
continue<T>(fn: () => T): T;
|
|
203
|
+
end(): void;
|
|
204
|
+
};
|
|
205
|
+
/**
|
|
206
|
+
* Runs a synchronous code block as an undo group.
|
|
207
|
+
* Note that nested groups are allowed.
|
|
208
|
+
*
|
|
209
|
+
* @param groupName Group name.
|
|
210
|
+
* @param fn Code block.
|
|
211
|
+
* @returns Code block return value.
|
|
212
|
+
*/
|
|
213
|
+
withGroup<T>(groupName: string, fn: () => T): T;
|
|
214
|
+
/**
|
|
215
|
+
* Runs a synchronous code block as an undo group.
|
|
216
|
+
* Note that nested groups are allowed.
|
|
217
|
+
*
|
|
218
|
+
* @param fn Code block.
|
|
219
|
+
* @returns Code block return value.
|
|
220
|
+
*/
|
|
221
|
+
withGroup<T>(fn: () => T): T;
|
|
222
|
+
/**
|
|
223
|
+
* Runs an asynchronous code block as an undo group.
|
|
224
|
+
* Note that nested groups are allowed.
|
|
225
|
+
*
|
|
226
|
+
* @param groupName Group name.
|
|
227
|
+
* @param fn Flow function.
|
|
228
|
+
* @returns Flow function return value.
|
|
229
|
+
*/
|
|
230
|
+
withGroupFlow<R>(groupName: string, fn: () => Generator<any, R, any>): Promise<R>;
|
|
231
|
+
/**
|
|
232
|
+
* Runs an asynchronous code block as an undo group.
|
|
233
|
+
* Note that nested groups are allowed.
|
|
234
|
+
*
|
|
235
|
+
* @param fn Flow function.
|
|
236
|
+
* @returns Flow function return value.
|
|
237
|
+
*/
|
|
238
|
+
withGroupFlow<R>(fn: () => Generator<any, R, any>): Promise<R>;
|
|
239
|
+
/**
|
|
240
|
+
* Creates an instance of `UndoManager`.
|
|
241
|
+
* Do not use directly, use `undoMiddleware` instead.
|
|
242
|
+
*
|
|
243
|
+
* @param disposer
|
|
244
|
+
* @param subtreeRoot
|
|
245
|
+
* @param [store]
|
|
246
|
+
*/
|
|
247
|
+
constructor(disposer: ActionMiddlewareDisposer, subtreeRoot: object, store: UndoStore | undefined, options: UndoMiddlewareOptions<unknown> | undefined);
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Undo middleware options.
|
|
251
|
+
*/
|
|
252
|
+
export interface UndoMiddlewareOptions<S> {
|
|
253
|
+
attachedState?: {
|
|
254
|
+
save(): S;
|
|
255
|
+
restore(s: S): void;
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Creates an undo middleware.
|
|
260
|
+
*
|
|
261
|
+
* @param subtreeRoot Subtree root target object.
|
|
262
|
+
* @param store Optional `UndoStore` where to store the undo/redo queues. Use this if you want to
|
|
263
|
+
* store such queues somewhere in your models. If none is provided it will reside in memory.
|
|
264
|
+
* @param options Extra options, such as how to save / restore certain snapshot of the state to be restored when undoing/redoing.
|
|
265
|
+
* @returns An `UndoManager` which allows you to do the manage the undo/redo operations and dispose of the middleware.
|
|
266
|
+
*/
|
|
267
|
+
export declare function undoMiddleware<S>(subtreeRoot: object, store?: UndoStore, options?: UndoMiddlewareOptions<S>): UndoManager;
|
|
268
|
+
/**
|
|
269
|
+
* Returns if the undo recording mechanism is currently disabled.
|
|
270
|
+
*
|
|
271
|
+
* @returns `true` if it is currently disabled, `false` otherwise.
|
|
272
|
+
*/
|
|
273
|
+
export declare function isGlobalUndoRecordingDisabled(): boolean;
|
|
274
|
+
/**
|
|
275
|
+
* Globally skips the undo recording mechanism for the code block that gets run synchronously inside.
|
|
276
|
+
* Consider using the `withoutUndo` method of a particular `UndoManager` instead.
|
|
277
|
+
*
|
|
278
|
+
* @typeparam T Code block return type.
|
|
279
|
+
* @param fn Code block to run.
|
|
280
|
+
* @returns The value returned by the code block.
|
|
281
|
+
*/
|
|
282
|
+
export declare function withoutUndo<T>(fn: () => T): T;
|
|
283
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns if a given node is a computed tree node.
|
|
3
|
+
*
|
|
4
|
+
* @param node Node to check.
|
|
5
|
+
* @returns `true` if it is a computed tree node, `false` otherwise.
|
|
6
|
+
*/
|
|
7
|
+
export declare function isComputedTreeNode(node: object): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Decorator for turning a computed property into a computed tree which supports tree traversal
|
|
10
|
+
* functions, contexts, references, etc.
|
|
11
|
+
*
|
|
12
|
+
* @param target Prototype of the class.
|
|
13
|
+
* @param propertyKey Name of the member.
|
|
14
|
+
* @param descriptor Property descriptor for the member.
|
|
15
|
+
*/
|
|
16
|
+
export declare function computedTree(target: any, propertyKey: string, descriptor: PropertyDescriptor): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./computedTree";
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A context.
|
|
3
|
+
*/
|
|
4
|
+
export interface Context<T> {
|
|
5
|
+
/**
|
|
6
|
+
* Gets the context default value.
|
|
7
|
+
*
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
getDefault(): T;
|
|
11
|
+
/**
|
|
12
|
+
* Sets the context default value.
|
|
13
|
+
* @param value
|
|
14
|
+
*/
|
|
15
|
+
setDefault(value: T): void;
|
|
16
|
+
/**
|
|
17
|
+
* Sets the context default value resolver.
|
|
18
|
+
* @param valueFn
|
|
19
|
+
*/
|
|
20
|
+
setDefaultComputed(valueFn: () => T): void;
|
|
21
|
+
/**
|
|
22
|
+
* Gets the context value for a given node.
|
|
23
|
+
* @param node
|
|
24
|
+
*/
|
|
25
|
+
get(node: object): T;
|
|
26
|
+
/**
|
|
27
|
+
* Gets node that will provide the context value, or `undefined`
|
|
28
|
+
* if it comes from the default.
|
|
29
|
+
* @param node
|
|
30
|
+
*/
|
|
31
|
+
getProviderNode(node: object): object | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Sets the context value for a given node, effectively making it a provider.
|
|
34
|
+
* @param node
|
|
35
|
+
* @param value
|
|
36
|
+
*/
|
|
37
|
+
set(node: object, value: T): void;
|
|
38
|
+
/**
|
|
39
|
+
* Sets the context value resolver for a given node, effectively making it a provider.
|
|
40
|
+
* @param node
|
|
41
|
+
* @param valueFn
|
|
42
|
+
*/
|
|
43
|
+
setComputed(node: object, valueFn: () => T): void;
|
|
44
|
+
/**
|
|
45
|
+
* Unsets the context value for a given node, therefore it won't be a provider anymore.
|
|
46
|
+
* @param node
|
|
47
|
+
*/
|
|
48
|
+
unset(node: object): void;
|
|
49
|
+
/**
|
|
50
|
+
* Applies a value override while the given function is running and, if a node is returned,
|
|
51
|
+
* sets the node as a provider of the value.
|
|
52
|
+
*
|
|
53
|
+
* @typeparam R
|
|
54
|
+
* @param fn Function to run.
|
|
55
|
+
* @param value Value to apply.
|
|
56
|
+
* @returns The value returned from the function.
|
|
57
|
+
*/
|
|
58
|
+
apply<R>(fn: () => R, value: T): R;
|
|
59
|
+
/**
|
|
60
|
+
* Applies a computed value override while the given function is running and, if a node is returned,
|
|
61
|
+
* sets the node as a provider of the computed value.
|
|
62
|
+
*
|
|
63
|
+
* @typeparam R
|
|
64
|
+
* @param fn Function to run.
|
|
65
|
+
* @param value Value to apply.
|
|
66
|
+
* @returns The value returned from the function.
|
|
67
|
+
*/
|
|
68
|
+
applyComputed<R>(fn: () => R, valueFn: () => T): R;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Creates a new context with no default value, thus making its default value undefined.
|
|
72
|
+
*
|
|
73
|
+
* @typeparam T Context value type.
|
|
74
|
+
* @returns
|
|
75
|
+
*/
|
|
76
|
+
export declare function createContext<T>(): Context<T | undefined>;
|
|
77
|
+
/**
|
|
78
|
+
* Creates a new context with a default value.
|
|
79
|
+
*
|
|
80
|
+
* @typeparam T Context value type.
|
|
81
|
+
* @param defaultValue
|
|
82
|
+
* @returns
|
|
83
|
+
*/
|
|
84
|
+
export declare function createContext<T>(defaultValue: T): Context<T>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./context";
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { propsTypeSymbol } from "../modelShared/BaseModelShared";
|
|
2
|
+
import { ModelProps, ModelPropsToCreationData, ModelPropsToData, ModelPropsToTransformedCreationData } from "../modelShared/prop";
|
|
3
|
+
import type { TypeCheckError } from "../types/TypeCheckError";
|
|
4
|
+
/**
|
|
5
|
+
* Base abstract class for data models. Use `DataModel` instead when extending.
|
|
6
|
+
*
|
|
7
|
+
* Never override the constructor, use `onLazyInit` instead.
|
|
8
|
+
*
|
|
9
|
+
* @typeparam Data Props data type.
|
|
10
|
+
*/
|
|
11
|
+
export declare abstract class BaseDataModel<TProps extends ModelProps> {
|
|
12
|
+
[propsTypeSymbol]: TProps;
|
|
13
|
+
/**
|
|
14
|
+
* Called after the instance is created when there's the first call to `fn(M, data)`.
|
|
15
|
+
*/
|
|
16
|
+
protected onLazyInit?(): void;
|
|
17
|
+
/**
|
|
18
|
+
* Data part of the model, which is observable and will be serialized in snapshots.
|
|
19
|
+
* Use it if one of the data properties matches one of the model properties/functions.
|
|
20
|
+
* This also allows access to the backed values of transformed properties.
|
|
21
|
+
*/
|
|
22
|
+
readonly $: ModelPropsToData<TProps>;
|
|
23
|
+
/**
|
|
24
|
+
* Performs a type check over the model instance.
|
|
25
|
+
* For this to work a data type has to be declared as part of the model properties.
|
|
26
|
+
*
|
|
27
|
+
* @returns A `TypeCheckError` or `null` if there is no error.
|
|
28
|
+
*/
|
|
29
|
+
typeCheck(): TypeCheckError | null;
|
|
30
|
+
/**
|
|
31
|
+
* Creates an instance of a data model.
|
|
32
|
+
*/
|
|
33
|
+
constructor(data: ModelPropsToCreationData<TProps> | ModelPropsToTransformedCreationData<TProps>);
|
|
34
|
+
toString(options?: {
|
|
35
|
+
withData?: boolean;
|
|
36
|
+
}): string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* @ignore
|
|
40
|
+
*/
|
|
41
|
+
export declare type BaseDataModelKeys = keyof AnyDataModel | "onLazyInit";
|
|
42
|
+
/**
|
|
43
|
+
* Any kind of data model instance.
|
|
44
|
+
*/
|
|
45
|
+
export interface AnyDataModel extends BaseDataModel<any> {
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* A data model class declaration, made of a base model and the model interface.
|
|
49
|
+
*/
|
|
50
|
+
export declare type DataModelClassDeclaration<BaseModelClass, ModelInterface> = BaseModelClass & {
|
|
51
|
+
(...args: any[]): ModelInterface;
|
|
52
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { AbstractModelClass, ModelCreationData, ModelTransformedCreationData } from "../modelShared/BaseModelShared";
|
|
2
|
+
import type { ModelProps, ModelPropsToCreationData, ModelPropsToSetter, ModelPropsToTransformedCreationData, ModelPropsToTransformedData } from "../modelShared/prop";
|
|
3
|
+
import type { AnyDataModel, BaseDataModel, BaseDataModelKeys } from "./BaseDataModel";
|
|
4
|
+
export declare type _ComposedData<SuperModel, TProps extends ModelProps> = SuperModel extends AnyDataModel ? (ModelPropsToCreationData<TProps> & ModelCreationData<SuperModel>) | (ModelPropsToTransformedCreationData<TProps> & ModelTransformedCreationData<SuperModel>) : ModelPropsToCreationData<TProps> | ModelPropsToTransformedCreationData<TProps>;
|
|
5
|
+
export interface _DataModel<SuperModel, TProps extends ModelProps> {
|
|
6
|
+
new (data: _ComposedData<SuperModel, TProps>): SuperModel & BaseDataModel<TProps> & Omit<ModelPropsToTransformedData<TProps>, BaseDataModelKeys> & ModelPropsToSetter<TProps>;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Base abstract class for data models that extends another model.
|
|
10
|
+
*
|
|
11
|
+
* @typeparam TProps New model properties type.
|
|
12
|
+
* @typeparam TModel Model type.
|
|
13
|
+
* @param genFn Function that returns the base model and model properties.
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
export declare function ExtendedDataModel<TProps extends ModelProps, TModel extends AnyDataModel, A extends []>(genFn: (...args: A) => {
|
|
17
|
+
baseModel: AbstractModelClass<TModel>;
|
|
18
|
+
props: TProps;
|
|
19
|
+
}): _DataModel<TModel, TProps>;
|
|
20
|
+
/**
|
|
21
|
+
* Base abstract class for data models that extends another model.
|
|
22
|
+
*
|
|
23
|
+
* @typeparam TProps New model properties type.
|
|
24
|
+
* @typeparam TModel Model type.
|
|
25
|
+
* @param baseModel Base model type.
|
|
26
|
+
* @param modelProps Model properties.
|
|
27
|
+
* @returns
|
|
28
|
+
*/
|
|
29
|
+
export declare function ExtendedDataModel<TProps extends ModelProps, TModel extends AnyDataModel>(baseModel: AbstractModelClass<TModel>, modelProps: TProps): _DataModel<TModel, TProps>;
|
|
30
|
+
/**
|
|
31
|
+
* Base abstract class for data models.
|
|
32
|
+
*
|
|
33
|
+
* Never override the constructor, use `onLazyInit` or `onLazyAttachedToRootStore` instead.
|
|
34
|
+
*
|
|
35
|
+
* @typeparam TProps Model properties type.
|
|
36
|
+
* @param fnModelProps Function that generates model properties.
|
|
37
|
+
*/
|
|
38
|
+
export declare function DataModel<TProps extends ModelProps, A extends []>(fnModelProps: (...args: A) => TProps): _DataModel<unknown, TProps>;
|
|
39
|
+
/**
|
|
40
|
+
* Base abstract class for data models.
|
|
41
|
+
*
|
|
42
|
+
* Never override the constructor, use `onLazyInit` or `onLazyAttachedToRootStore` instead.
|
|
43
|
+
*
|
|
44
|
+
* @typeparam TProps Model properties type.
|
|
45
|
+
* @param modelProps Model properties.
|
|
46
|
+
*/
|
|
47
|
+
export declare function DataModel<TProps extends ModelProps>(modelProps: TProps): _DataModel<unknown, TProps>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ModelClass } from "../modelShared/BaseModelShared";
|
|
2
|
+
import type { AnyType } from "../types/schemas";
|
|
3
|
+
import type { AnyDataModel } from "./BaseDataModel";
|
|
4
|
+
/**
|
|
5
|
+
* Associated data model metadata.
|
|
6
|
+
*/
|
|
7
|
+
export interface DataModelMetadata {
|
|
8
|
+
/**
|
|
9
|
+
* Associated data type for runtime checking (if any).
|
|
10
|
+
*/
|
|
11
|
+
dataType?: AnyType;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Returns the associated metadata for a data model instance or class.
|
|
15
|
+
*
|
|
16
|
+
* @param modelClassOrInstance Data model class or instance.
|
|
17
|
+
* @returns The associated metadata.
|
|
18
|
+
*/
|
|
19
|
+
export declare function getDataModelMetadata(modelClassOrInstance: AnyDataModel | ModelClass<AnyDataModel>): DataModelMetadata;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Should freeze and plain json checks be done when creating the frozen object?
|
|
3
|
+
*/
|
|
4
|
+
export declare enum FrozenCheckMode {
|
|
5
|
+
/** Only when in dev mode */
|
|
6
|
+
DevModeOnly = "devModeOnly",
|
|
7
|
+
/** Always */
|
|
8
|
+
On = "on",
|
|
9
|
+
/** Never */
|
|
10
|
+
Off = "off"
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* @ignore
|
|
14
|
+
*/
|
|
15
|
+
export declare const frozenKey = "$frozen";
|
|
16
|
+
/**
|
|
17
|
+
* A class that contains frozen data.
|
|
18
|
+
* Use `frozen` to create an instance of this class.
|
|
19
|
+
*
|
|
20
|
+
* @typeparam T Data type.
|
|
21
|
+
*/
|
|
22
|
+
export declare class Frozen<T> {
|
|
23
|
+
/**
|
|
24
|
+
* Frozen data, deeply immutable.
|
|
25
|
+
*/
|
|
26
|
+
readonly data: T;
|
|
27
|
+
/**
|
|
28
|
+
* Creates an instance of Frozen.
|
|
29
|
+
* Do not use directly, use `frozen` instead.
|
|
30
|
+
*
|
|
31
|
+
* @param dataToFreeze
|
|
32
|
+
* @param checkMode
|
|
33
|
+
*/
|
|
34
|
+
constructor(dataToFreeze: T, checkMode?: FrozenCheckMode);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Marks some data as frozen. Frozen data becomes immutable (at least in dev mode), and is not enhanced
|
|
38
|
+
* with capabilities such as getting the parent of the objects (except for the root object), it is not
|
|
39
|
+
* made deeply observable (though the root object is observable by reference), etc.
|
|
40
|
+
* On the other hand, this means it will be much faster to create/access. Use this for big data pieces
|
|
41
|
+
* that are unlikely to change unless all of them change (for example lists of points for a polygon, etc).
|
|
42
|
+
*
|
|
43
|
+
* Note that data passed to frozen must be serializable to JSON, this is:
|
|
44
|
+
* - primitive, plain object, or array
|
|
45
|
+
* - without cycles
|
|
46
|
+
*
|
|
47
|
+
* @param data
|
|
48
|
+
* @param checkMode
|
|
49
|
+
*/
|
|
50
|
+
export declare function frozen<T>(data: T, checkMode?: FrozenCheckMode): Frozen<T>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Frozen";
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Model auto type-checking mode.
|
|
3
|
+
*/
|
|
4
|
+
export declare enum ModelAutoTypeCheckingMode {
|
|
5
|
+
/**
|
|
6
|
+
* Auto type check models only in dev mode
|
|
7
|
+
*/
|
|
8
|
+
DevModeOnly = "devModeOnly",
|
|
9
|
+
/**
|
|
10
|
+
* Auto type check models no matter the current environment
|
|
11
|
+
*/
|
|
12
|
+
AlwaysOn = "alwaysOn",
|
|
13
|
+
/**
|
|
14
|
+
* Do not auto type check models no matter the current environment
|
|
15
|
+
*/
|
|
16
|
+
AlwaysOff = "alwaysOff"
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Global config object.
|
|
20
|
+
*/
|
|
21
|
+
export interface GlobalConfig {
|
|
22
|
+
/**
|
|
23
|
+
* Model auto type-checking mode.
|
|
24
|
+
*/
|
|
25
|
+
modelAutoTypeChecking: ModelAutoTypeCheckingMode;
|
|
26
|
+
/**
|
|
27
|
+
* ID generator function for model ids.
|
|
28
|
+
*/
|
|
29
|
+
modelIdGenerator(): string;
|
|
30
|
+
/**
|
|
31
|
+
* Allow array elements to be `undefined`.
|
|
32
|
+
*/
|
|
33
|
+
allowUndefinedArrayElements: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Enables/disables warnings related to duplicated model names (defaults to `true`).
|
|
36
|
+
* Usually set to false in test environments (e.g. jest).
|
|
37
|
+
*/
|
|
38
|
+
showDuplicateModelNameWarnings: boolean;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Partially sets the current global config.
|
|
42
|
+
*
|
|
43
|
+
* @param config Partial object with the new configurations. Options not included in the object won't be changed.
|
|
44
|
+
*/
|
|
45
|
+
export declare function setGlobalConfig(config: Partial<GlobalConfig>): void;
|
|
46
|
+
/**
|
|
47
|
+
* Returns the current global config object.
|
|
48
|
+
*
|
|
49
|
+
* @returns
|
|
50
|
+
*/
|
|
51
|
+
export declare function getGlobalConfig(): Readonly<GlobalConfig>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./globalConfig";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export * from "./action";
|
|
2
|
+
export * from "./actionMiddlewares";
|
|
3
|
+
export * from "./computedTree";
|
|
4
|
+
export * from "./context";
|
|
5
|
+
export * from "./dataModel";
|
|
6
|
+
export * from "./frozen";
|
|
7
|
+
export * from "./globalConfig";
|
|
8
|
+
export * from "./model";
|
|
9
|
+
export * from "./modelShared";
|
|
10
|
+
export * from "./parent";
|
|
11
|
+
export * from "./patch";
|
|
12
|
+
export * from "./redux";
|
|
13
|
+
export * from "./ref";
|
|
14
|
+
export * from "./rootStore";
|
|
15
|
+
export * from "./snapshot";
|
|
16
|
+
export * from "./standardActions";
|
|
17
|
+
export * from "./transforms";
|
|
18
|
+
export * from "./treeUtils";
|
|
19
|
+
export * from "./tweaker";
|
|
20
|
+
export * from "./types";
|
|
21
|
+
export * from "./utils";
|
|
22
|
+
export * from "./utils/tag";
|
|
23
|
+
export * from "./wrappers";
|