@domql/state 2.31.35 → 2.31.37
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/cjs/methods.js +8 -1
- package/dist/cjs/updateState.js +1 -1
- package/dist/esm/methods.js +10 -2
- package/dist/esm/updateState.js +1 -1
- package/methods.js +12 -2
- package/package.json +5 -5
- package/updateState.js +1 -1
package/dist/cjs/methods.js
CHANGED
|
@@ -143,7 +143,7 @@ const set = async function(val, options = {}) {
|
|
|
143
143
|
const state = this;
|
|
144
144
|
const value = (0, import_utils.deepClone)(val);
|
|
145
145
|
await state.clean({ preventStateUpdate: true, ...options });
|
|
146
|
-
await state.
|
|
146
|
+
await state.replace(value, options);
|
|
147
147
|
return state;
|
|
148
148
|
};
|
|
149
149
|
const setByPath = async function(path, val, options = {}) {
|
|
@@ -166,6 +166,13 @@ const setPathCollection = async function(changes, options = {}) {
|
|
|
166
166
|
return (0, import_utils.overwriteDeep)(acc, result);
|
|
167
167
|
} else if (change[0] === "delete") {
|
|
168
168
|
await removeByPath.call(state, change[1], options);
|
|
169
|
+
const removedFromPath = change[1].slice(0, -1);
|
|
170
|
+
const removedFromValue = (0, import_utils.getInObjectByPath)(state, removedFromPath);
|
|
171
|
+
const result = (0, import_utils.createNestedObject)(
|
|
172
|
+
removedFromPath,
|
|
173
|
+
(0, import_utils.isObject)(removedFromValue) ? {} : []
|
|
174
|
+
);
|
|
175
|
+
return (0, import_utils.deepMerge)(acc, result);
|
|
169
176
|
}
|
|
170
177
|
return acc;
|
|
171
178
|
}, {});
|
package/dist/cjs/updateState.js
CHANGED
|
@@ -109,7 +109,7 @@ const updateDependentState = async (state, obj, options) => {
|
|
|
109
109
|
if (!state.__depends) return;
|
|
110
110
|
for (const el in state.__depends) {
|
|
111
111
|
const dependentState = state.__depends[el];
|
|
112
|
-
await dependentState.
|
|
112
|
+
await dependentState.set(state.parse(), options);
|
|
113
113
|
}
|
|
114
114
|
};
|
|
115
115
|
const applyElementUpdate = async (state, obj, options) => {
|
package/dist/esm/methods.js
CHANGED
|
@@ -29,7 +29,8 @@ import {
|
|
|
29
29
|
createNestedObject,
|
|
30
30
|
getInObjectByPath,
|
|
31
31
|
removeNestedKeyByPath,
|
|
32
|
-
setInObjectByPath
|
|
32
|
+
setInObjectByPath,
|
|
33
|
+
deepMerge
|
|
33
34
|
} from "@domql/utils";
|
|
34
35
|
import { IGNORE_STATE_PARAMS } from "./ignore.js";
|
|
35
36
|
const parse = function() {
|
|
@@ -130,7 +131,7 @@ const set = async function(val, options = {}) {
|
|
|
130
131
|
const state = this;
|
|
131
132
|
const value = deepClone(val);
|
|
132
133
|
await state.clean(__spreadValues({ preventStateUpdate: true }, options));
|
|
133
|
-
await state.
|
|
134
|
+
await state.replace(value, options);
|
|
134
135
|
return state;
|
|
135
136
|
};
|
|
136
137
|
const setByPath = async function(path, val, options = {}) {
|
|
@@ -152,6 +153,13 @@ const setPathCollection = async function(changes, options = {}) {
|
|
|
152
153
|
return overwriteDeep(acc, result);
|
|
153
154
|
} else if (change[0] === "delete") {
|
|
154
155
|
await removeByPath.call(state, change[1], options);
|
|
156
|
+
const removedFromPath = change[1].slice(0, -1);
|
|
157
|
+
const removedFromValue = getInObjectByPath(state, removedFromPath);
|
|
158
|
+
const result = createNestedObject(
|
|
159
|
+
removedFromPath,
|
|
160
|
+
isObject(removedFromValue) ? {} : []
|
|
161
|
+
);
|
|
162
|
+
return deepMerge(acc, result);
|
|
155
163
|
}
|
|
156
164
|
return acc;
|
|
157
165
|
}, {});
|
package/dist/esm/updateState.js
CHANGED
|
@@ -110,7 +110,7 @@ const updateDependentState = async (state, obj, options) => {
|
|
|
110
110
|
if (!state.__depends) return;
|
|
111
111
|
for (const el in state.__depends) {
|
|
112
112
|
const dependentState = state.__depends[el];
|
|
113
|
-
await dependentState.
|
|
113
|
+
await dependentState.set(state.parse(), options);
|
|
114
114
|
}
|
|
115
115
|
};
|
|
116
116
|
const applyElementUpdate = async (state, obj, options) => {
|
package/methods.js
CHANGED
|
@@ -12,7 +12,8 @@ import {
|
|
|
12
12
|
createNestedObject,
|
|
13
13
|
getInObjectByPath,
|
|
14
14
|
removeNestedKeyByPath,
|
|
15
|
-
setInObjectByPath
|
|
15
|
+
setInObjectByPath,
|
|
16
|
+
deepMerge
|
|
16
17
|
} from '@domql/utils'
|
|
17
18
|
|
|
18
19
|
import { IGNORE_STATE_PARAMS } from './ignore.js'
|
|
@@ -128,7 +129,7 @@ export const set = async function (val, options = {}) {
|
|
|
128
129
|
const state = this
|
|
129
130
|
const value = deepClone(val)
|
|
130
131
|
await state.clean({ preventStateUpdate: true, ...options })
|
|
131
|
-
await state.
|
|
132
|
+
await state.replace(value, options)
|
|
132
133
|
return state
|
|
133
134
|
}
|
|
134
135
|
|
|
@@ -153,6 +154,15 @@ export const setPathCollection = async function (changes, options = {}) {
|
|
|
153
154
|
return overwriteDeep(acc, result)
|
|
154
155
|
} else if (change[0] === 'delete') {
|
|
155
156
|
await removeByPath.call(state, change[1], options)
|
|
157
|
+
// we are doing this to create empty nested
|
|
158
|
+
// by removed path to show as changed property
|
|
159
|
+
const removedFromPath = change[1].slice(0, -1)
|
|
160
|
+
const removedFromValue = getInObjectByPath(state, removedFromPath)
|
|
161
|
+
const result = createNestedObject(
|
|
162
|
+
removedFromPath,
|
|
163
|
+
isObject(removedFromValue) ? {} : []
|
|
164
|
+
)
|
|
165
|
+
return deepMerge(acc, result)
|
|
156
166
|
}
|
|
157
167
|
return acc
|
|
158
168
|
}, {})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domql/state",
|
|
3
|
-
"version": "2.31.
|
|
3
|
+
"version": "2.31.37",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "index.js",
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
"prepublish": "npx rimraf -I dist && npm run build && npm run copy:package:cjs"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@domql/event": "^2.31.
|
|
32
|
-
"@domql/report": "^2.31.
|
|
33
|
-
"@domql/utils": "^2.31.
|
|
31
|
+
"@domql/event": "^2.31.37",
|
|
32
|
+
"@domql/report": "^2.31.37",
|
|
33
|
+
"@domql/utils": "^2.31.37"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "4a0a9c683f742b8d81fe3c8c4022939b93058971"
|
|
36
36
|
}
|
package/updateState.js
CHANGED
|
@@ -121,7 +121,7 @@ const updateDependentState = async (state, obj, options) => {
|
|
|
121
121
|
if (!state.__depends) return
|
|
122
122
|
for (const el in state.__depends) {
|
|
123
123
|
const dependentState = state.__depends[el]
|
|
124
|
-
await dependentState.
|
|
124
|
+
await dependentState.set(state.parse(), options)
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
|