mobx-keystone
Advanced tools
Comparing version 1.6.2 to 1.6.3
# Change Log | ||
## 1.6.3 | ||
- Fixed a bug where an object was sometimes being detached and then again retached when using applySnapshot. | ||
## 1.6.2 | ||
@@ -4,0 +8,0 @@ |
{ | ||
"name": "mobx-keystone", | ||
"version": "1.6.2", | ||
"version": "1.6.3", | ||
"description": "A MobX powered state management solution based on data trees with first class support for TypeScript, snapshots, patches and much more", | ||
@@ -69,6 +69,6 @@ "keywords": [ | ||
"devDependencies": { | ||
"@babel/core": "^7.22.5", | ||
"@babel/core": "^7.22.6", | ||
"@babel/plugin-proposal-class-properties": "^7.18.6", | ||
"@babel/plugin-proposal-decorators": "^7.22.5", | ||
"@babel/preset-env": "^7.22.5", | ||
"@babel/plugin-proposal-decorators": "^7.22.6", | ||
"@babel/preset-env": "^7.22.6", | ||
"@babel/preset-typescript": "^7.22.5", | ||
@@ -78,5 +78,5 @@ "@swc/core": "^1.3.67", | ||
"@types/jest": "^29.5.2", | ||
"@types/node": "^20.3.2", | ||
"babel-jest": "^29.5.0", | ||
"jest": "^29.5.0", | ||
"@types/node": "^20.3.3", | ||
"babel-jest": "^29.6.0", | ||
"jest": "^29.6.0", | ||
"mobx": "^6.9.0", | ||
@@ -83,0 +83,0 @@ "mobx-v4": "npm:mobx@^4.15.7", |
@@ -1,5 +0,6 @@ | ||
import { isObservable, set } from "mobx" | ||
import { isObservable } from "mobx" | ||
import { isModel } from "../model/utils" | ||
import { assertTweakedObject } from "../tweaker/core" | ||
import { lazy } from "../utils" | ||
import { setIfDifferent } from "../utils/setIfDifferent" | ||
import { BuiltInAction } from "./builtInActions" | ||
@@ -30,3 +31,3 @@ import { ActionContextActionType } from "./context" | ||
if (!isModel(this) && isObservable(this)) { | ||
set(this, fieldName, value) | ||
setIfDifferent(this, fieldName, value) | ||
} else { | ||
@@ -33,0 +34,0 @@ ;(this as any)[fieldName] = value |
@@ -13,5 +13,5 @@ import { action, set } from "mobx" | ||
import type { AnyModel } from "./BaseModel" | ||
import type { ModelConstructorOptions } from "./ModelConstructorOptions" | ||
import { getModelIdPropertyName, getModelMetadata } from "./getModelMetadata" | ||
import { modelTypeKey } from "./metadata" | ||
import type { ModelConstructorOptions } from "./ModelConstructorOptions" | ||
import { assertIsModelClass } from "./utils" | ||
@@ -114,2 +114,3 @@ | ||
if (changed) { | ||
// setIfDifferent not required | ||
set(initialData as any, k, newValue) | ||
@@ -120,2 +121,3 @@ } | ||
if (modelIdPropertyName) { | ||
// setIfDifferent not required | ||
set(initialData as any, modelIdPropertyName, id) | ||
@@ -122,0 +124,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { remove, set } from "mobx" | ||
import { remove } from "mobx" | ||
import { BuiltInAction } from "../action/builtInActions" | ||
@@ -12,2 +12,3 @@ import { ActionContextActionType } from "../action/context" | ||
import { ModelPool } from "../utils/ModelPool" | ||
import { setIfDifferent } from "../utils/setIfDifferent" | ||
@@ -110,3 +111,3 @@ /** | ||
const newValue = reconcileSnapshot(target[index], patch.value, modelPool, target) | ||
set(target, index as any, newValue) | ||
setIfDifferent(target, index as any, newValue) | ||
} | ||
@@ -124,3 +125,3 @@ break | ||
const newValue = reconcileSnapshot(undefined, patch.value, modelPool, target) | ||
set(target, prop, newValue) | ||
setIfDifferent(target, prop!, newValue) | ||
break | ||
@@ -139,3 +140,3 @@ } | ||
const newValue = reconcileSnapshot(target[prop!], patch.value, modelPool, target) | ||
set(target, prop, newValue) | ||
setIfDifferent(target, prop!, newValue) | ||
break | ||
@@ -142,0 +143,0 @@ } |
import { observable, set } from "mobx" | ||
import { tweakPlainObject } from "../tweaker/tweakPlainObject" | ||
import { isPlainObject } from "../utils" | ||
import { SnapshotInOfObject } from "./SnapshotOf" | ||
import { SnapshotterAndReconcilerPriority } from "./SnapshotterAndReconcilerPriority" | ||
import { | ||
@@ -10,4 +12,2 @@ FromSnapshotContext, | ||
} from "./fromSnapshot" | ||
import { SnapshotInOfObject } from "./SnapshotOf" | ||
import { SnapshotterAndReconcilerPriority } from "./SnapshotterAndReconcilerPriority" | ||
@@ -22,2 +22,3 @@ function fromPlainObjectSnapshot(sn: SnapshotInOfObject<any>, ctx: FromSnapshotContext): object { | ||
const v = sn[k] | ||
// setIfDifferent not required | ||
set(plainObj, k, internalFromSnapshot(v, ctx)) | ||
@@ -24,0 +25,0 @@ } |
@@ -7,8 +7,8 @@ import { action, observable, set } from "mobx" | ||
import type { ModelClass } from "../modelShared/BaseModelShared" | ||
import { TypeChecker, isLateTypeChecker } from "../types/TypeChecker" | ||
import { resolveTypeChecker } from "../types/resolveTypeChecker" | ||
import type { AnyStandardType, TypeToData } from "../types/schemas" | ||
import { isLateTypeChecker, TypeChecker } from "../types/TypeChecker" | ||
import { failure, isMap, isPrimitive, isSet } from "../utils" | ||
import type { SnapshotInOf, SnapshotInOfModel, SnapshotOutOf } from "./SnapshotOf" | ||
import { registerDefaultSnapshotters } from "./registerDefaultSnapshotters" | ||
import type { SnapshotInOf, SnapshotInOfModel, SnapshotOutOf } from "./SnapshotOf" | ||
@@ -157,2 +157,3 @@ /** | ||
const v = processedSn[k] | ||
// setIfDifferent not required | ||
set(initialData, k, internalFromSnapshot(v, ctx)) | ||
@@ -159,0 +160,0 @@ } |
@@ -1,2 +0,1 @@ | ||
import { set } from "mobx" | ||
import { runTypeCheckingAfterChange } from "../tweaker/typeChecking" | ||
@@ -6,7 +5,8 @@ import { withoutTypeChecking } from "../tweaker/withoutTypeChecking" | ||
import { ModelPool } from "../utils/ModelPool" | ||
import { setIfDifferent } from "../utils/setIfDifferent" | ||
import type { SnapshotInOfObject } from "./SnapshotOf" | ||
import { SnapshotterAndReconcilerPriority } from "./SnapshotterAndReconcilerPriority" | ||
import { fromSnapshot } from "./fromSnapshot" | ||
import { getSnapshot } from "./getSnapshot" | ||
import { detachIfNeeded, reconcileSnapshot, registerReconciler } from "./reconcileSnapshot" | ||
import type { SnapshotInOfObject } from "./SnapshotOf" | ||
import { SnapshotterAndReconcilerPriority } from "./SnapshotterAndReconcilerPriority" | ||
@@ -38,3 +38,3 @@ function reconcileArraySnapshot( | ||
set(value, i, newValue) | ||
setIfDifferent(value, i, newValue) | ||
} | ||
@@ -41,0 +41,0 @@ |
@@ -1,2 +0,2 @@ | ||
import { remove, set } from "mobx" | ||
import { remove } from "mobx" | ||
import type { AnyModel } from "../model/BaseModel" | ||
@@ -15,7 +15,8 @@ import { getModelIdPropertyName } from "../model/getModelMetadata" | ||
import type { ModelPool } from "../utils/ModelPool" | ||
import { setIfDifferent } from "../utils/setIfDifferent" | ||
import type { SnapshotInOfModel } from "./SnapshotOf" | ||
import { SnapshotterAndReconcilerPriority } from "./SnapshotterAndReconcilerPriority" | ||
import { fromSnapshot } from "./fromSnapshot" | ||
import { getSnapshot } from "./getSnapshot" | ||
import { detachIfNeeded, reconcileSnapshot, registerReconciler } from "./reconcileSnapshot" | ||
import type { SnapshotInOfModel } from "./SnapshotOf" | ||
import { SnapshotterAndReconcilerPriority } from "./SnapshotterAndReconcilerPriority" | ||
@@ -87,3 +88,3 @@ function reconcileModelSnapshot( | ||
} else { | ||
set(data, k, defaultValue) | ||
setIfDifferent(data, k, defaultValue) | ||
} | ||
@@ -115,3 +116,3 @@ } | ||
set(data, k, newValue) | ||
setIfDifferent(data, k, newValue) | ||
} | ||
@@ -118,0 +119,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { isObservableObject, remove, set } from "mobx" | ||
import { isObservableObject, remove } from "mobx" | ||
import { runTypeCheckingAfterChange } from "../tweaker/typeChecking" | ||
@@ -6,7 +6,8 @@ import { withoutTypeChecking } from "../tweaker/withoutTypeChecking" | ||
import type { ModelPool } from "../utils/ModelPool" | ||
import { setIfDifferent } from "../utils/setIfDifferent" | ||
import type { SnapshotInOfObject } from "./SnapshotOf" | ||
import { SnapshotterAndReconcilerPriority } from "./SnapshotterAndReconcilerPriority" | ||
import { fromSnapshot } from "./fromSnapshot" | ||
import { getSnapshot } from "./getSnapshot" | ||
import { detachIfNeeded, reconcileSnapshot, registerReconciler } from "./reconcileSnapshot" | ||
import type { SnapshotInOfObject } from "./SnapshotOf" | ||
import { SnapshotterAndReconcilerPriority } from "./SnapshotterAndReconcilerPriority" | ||
@@ -50,3 +51,3 @@ function reconcilePlainObjectSnapshot( | ||
set(plainObj, k, newValue) | ||
setIfDifferent(plainObj, k, newValue) | ||
} | ||
@@ -53,0 +54,0 @@ }) |
@@ -1,4 +0,5 @@ | ||
import { remove, set } from "mobx" | ||
import { remove } from "mobx" | ||
import { toTreeNode } from "../tweaker/tweak" | ||
import { namespace as ns } from "../utils" | ||
import { setIfDifferent } from "../utils/setIfDifferent" | ||
import { standaloneAction } from "./standaloneActions" | ||
@@ -16,3 +17,3 @@ | ||
set: standaloneAction(`${namespace}::set`, <T>(array: T[], index: number, value: any): void => { | ||
set(array, index, value) | ||
setIfDifferent(array, index, value) | ||
}), | ||
@@ -19,0 +20,0 @@ |
@@ -1,4 +0,5 @@ | ||
import { isObservable, remove, set } from "mobx" | ||
import { isObservable, remove } from "mobx" | ||
import { toTreeNode } from "../tweaker/tweak" | ||
import { assertIsObject, namespace as ns } from "../utils" | ||
import { setIfDifferent } from "../utils/setIfDifferent" | ||
import { standaloneAction } from "./standaloneActions" | ||
@@ -13,3 +14,3 @@ | ||
if (isObservable(target)) { | ||
set(target, key, value) | ||
setIfDifferent(target, key, value) | ||
} else { | ||
@@ -29,3 +30,4 @@ target[key] = value | ||
for (const key of keys) { | ||
set(target, key, (partialObject as any)[key]) | ||
const newValue = (partialObject as any)[key] | ||
setIfDifferent(target, key, newValue) | ||
} | ||
@@ -32,0 +34,0 @@ } else { |
@@ -9,3 +9,2 @@ import { | ||
observe, | ||
set, | ||
} from "mobx" | ||
@@ -25,2 +24,3 @@ import { assertCanWrite } from "../action/protection" | ||
import { failure, inDevMode, isArray, isPrimitive } from "../utils" | ||
import { setIfDifferent } from "../utils/setIfDifferent" | ||
import { runningWithoutSnapshotOrPatches, tweakedObjects } from "./core" | ||
@@ -75,3 +75,3 @@ import { registerTweaker, tweak } from "./tweak" | ||
if (!doNotTweakChildren) { | ||
set(tweakedArr, i, v) | ||
setIfDifferent(tweakedArr, i, v) | ||
} | ||
@@ -96,3 +96,3 @@ | ||
tweakedValue = tweak(v, path) | ||
set(tweakedArr, i, tweakedValue) | ||
setIfDifferent(tweakedArr, i, tweakedValue) | ||
} | ||
@@ -99,0 +99,0 @@ |
@@ -8,3 +8,2 @@ import { | ||
observe, | ||
set, | ||
} from "mobx" | ||
@@ -28,2 +27,3 @@ import { assertCanWrite } from "../action/protection" | ||
import { failure, isPlainObject, isPrimitive } from "../utils" | ||
import { setIfDifferent } from "../utils/setIfDifferent" | ||
import { runningWithoutSnapshotOrPatches, tweakedObjects } from "./core" | ||
@@ -78,3 +78,3 @@ import { registerTweaker, tweak } from "./tweak" | ||
if (!doNotTweakChildren) { | ||
set(tweakedObj, k, v) | ||
setIfDifferent(tweakedObj, k, v) | ||
} | ||
@@ -98,3 +98,3 @@ untransformedSn[k] = v | ||
tweakedValue = tweak(v, path) | ||
set(tweakedObj, k, tweakedValue) | ||
setIfDifferent(tweakedObj, k, tweakedValue) | ||
} | ||
@@ -101,0 +101,0 @@ |
@@ -13,3 +13,2 @@ import { | ||
remove, | ||
set, | ||
} from "mobx" | ||
@@ -25,2 +24,3 @@ import { | ||
} from "../utils" | ||
import { setIfDifferent } from "../utils/setIfDifferent" | ||
import { tag } from "../utils/tag" | ||
@@ -99,3 +99,3 @@ | ||
case "update": { | ||
set(obj, change.name, change.newValue) | ||
setIfDifferent(obj, change.name, change.newValue) | ||
break | ||
@@ -102,0 +102,0 @@ } |
@@ -1,5 +0,5 @@ | ||
import { entries, get, has, keys, remove, set, values } from "mobx" | ||
import { entries, get, has, keys, remove, values } from "mobx" | ||
import { modelAction } from "../action/modelAction" | ||
import { Model } from "../model/Model" | ||
import { modelIdKey } from "../model/metadata" | ||
import { Model } from "../model/Model" | ||
import { model } from "../modelShared/modelDecorator" | ||
@@ -11,2 +11,3 @@ import { idProp } from "../modelShared/prop" | ||
import { namespace } from "../utils" | ||
import { setIfDifferent } from "../utils/setIfDifferent" | ||
@@ -70,3 +71,3 @@ /** | ||
set(key: string, value: V): this { | ||
set(this.items, key, value) | ||
setIfDifferent(this.items, key, value) | ||
return this | ||
@@ -73,0 +74,0 @@ } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4245020
383
56295