@domql/state 2.5.200 → 2.5.206
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/create.js +2 -2
- package/dist/cjs/create.js +2 -2
- package/dist/cjs/updateState.js +11 -11
- package/dist/esm/create.js +2 -2
- package/dist/esm/updateState.js +11 -11
- package/package.json +7 -7
- package/updateState.js +11 -11
package/create.js
CHANGED
|
@@ -41,7 +41,7 @@ export const applyInitialState = async function (element, parent, options) {
|
|
|
41
41
|
if (objectizeState === false) return parent.state || {}
|
|
42
42
|
else element.state = objectizeState
|
|
43
43
|
|
|
44
|
-
const whatInitReturns = triggerEventOn('stateInit', element, options)
|
|
44
|
+
const whatInitReturns = await triggerEventOn('stateInit', element, options)
|
|
45
45
|
if (whatInitReturns === false) return element.state
|
|
46
46
|
|
|
47
47
|
if (checkIfInherits(element)) {
|
|
@@ -55,7 +55,7 @@ export const applyInitialState = async function (element, parent, options) {
|
|
|
55
55
|
applyMethods(element)
|
|
56
56
|
|
|
57
57
|
// trigger `on.stateCreated`
|
|
58
|
-
triggerEventOn('stateCreated', element)
|
|
58
|
+
await triggerEventOn('stateCreated', element)
|
|
59
59
|
|
|
60
60
|
return element.state
|
|
61
61
|
}
|
package/dist/cjs/create.js
CHANGED
|
@@ -36,7 +36,7 @@ const applyInitialState = async function(element, parent, options) {
|
|
|
36
36
|
const objectizeState = await checkForTypes(element);
|
|
37
37
|
if (objectizeState === false) return parent.state || {};
|
|
38
38
|
else element.state = objectizeState;
|
|
39
|
-
const whatInitReturns = (0, import_event.triggerEventOn)("stateInit", element, options);
|
|
39
|
+
const whatInitReturns = await (0, import_event.triggerEventOn)("stateInit", element, options);
|
|
40
40
|
if (whatInitReturns === false) return element.state;
|
|
41
41
|
if ((0, import_inherit.checkIfInherits)(element)) {
|
|
42
42
|
const inheritedState = (0, import_inherit.createInheritedState)(element, parent);
|
|
@@ -45,7 +45,7 @@ const applyInitialState = async function(element, parent, options) {
|
|
|
45
45
|
const dependentState = applyDependentState(element, element.state || parent.state || {});
|
|
46
46
|
if (dependentState) element.state = dependentState;
|
|
47
47
|
applyMethods(element);
|
|
48
|
-
(0, import_event.triggerEventOn)("stateCreated", element);
|
|
48
|
+
await (0, import_event.triggerEventOn)("stateCreated", element);
|
|
49
49
|
return element.state;
|
|
50
50
|
};
|
|
51
51
|
const applyDependentState = (element, state) => {
|
package/dist/cjs/updateState.js
CHANGED
|
@@ -47,10 +47,10 @@ const updateState = async function(obj, options = STATE_UPDATE_OPTIONS) {
|
|
|
47
47
|
if (beforeStateUpdateReturns === false) return element;
|
|
48
48
|
}
|
|
49
49
|
applyOverwrite(state, obj, options);
|
|
50
|
-
const updateIsHoisted = hoistStateUpdate(state, obj, options);
|
|
50
|
+
const updateIsHoisted = await hoistStateUpdate(state, obj, options);
|
|
51
51
|
if (updateIsHoisted) return state;
|
|
52
|
-
updateDependentState(state, obj, options);
|
|
53
|
-
applyElementUpdate(state, obj, options);
|
|
52
|
+
await updateDependentState(state, obj, options);
|
|
53
|
+
await applyElementUpdate(state, obj, options);
|
|
54
54
|
if (!options.preventStateUpdateListener) {
|
|
55
55
|
await (0, import_event.triggerEventOnUpdate)("stateUpdate", obj, element, options);
|
|
56
56
|
}
|
|
@@ -69,7 +69,7 @@ const applyOverwrite = (state, obj, options) => {
|
|
|
69
69
|
if (options.overwrite === "shallow-once") options.overwrite = true;
|
|
70
70
|
overwriteFunc(state, obj, import_ignore.IGNORE_STATE_PARAMS);
|
|
71
71
|
};
|
|
72
|
-
const hoistStateUpdate = (state, obj, options) => {
|
|
72
|
+
const hoistStateUpdate = async (state, obj, options) => {
|
|
73
73
|
const element = state.__element;
|
|
74
74
|
const { parent, __ref: ref } = element;
|
|
75
75
|
const stateKey = ref == null ? void 0 : ref.__state;
|
|
@@ -87,7 +87,7 @@ const hoistStateUpdate = (state, obj, options) => {
|
|
|
87
87
|
const changesValue = (0, import_inherit.createNestedObjectByKeyPath)(stateKey, passedValue);
|
|
88
88
|
const targetParent = findRootState || findGrandParentState || parent.state;
|
|
89
89
|
if (options.replace) (0, import_utils.overwriteDeep)(targetParent, changesValue || value);
|
|
90
|
-
targetParent.update(changesValue, {
|
|
90
|
+
await targetParent.update(changesValue, {
|
|
91
91
|
execStateFunction: false,
|
|
92
92
|
isHoisted: true,
|
|
93
93
|
preventUpdate: options.preventHoistElementUpdate,
|
|
@@ -96,26 +96,26 @@ const hoistStateUpdate = (state, obj, options) => {
|
|
|
96
96
|
});
|
|
97
97
|
const hasNotUpdated = options.preventUpdate !== true || !options.preventHoistElementUpdate;
|
|
98
98
|
if (!options.preventStateUpdateListener && hasNotUpdated) {
|
|
99
|
-
(0, import_event.triggerEventOnUpdate)("stateUpdate", obj, element, options);
|
|
99
|
+
await (0, import_event.triggerEventOnUpdate)("stateUpdate", obj, element, options);
|
|
100
100
|
}
|
|
101
101
|
return true;
|
|
102
102
|
};
|
|
103
|
-
const updateDependentState = (state, obj, options) => {
|
|
103
|
+
const updateDependentState = async (state, obj, options) => {
|
|
104
104
|
if (!state.__depends) return;
|
|
105
105
|
for (const el in state.__depends) {
|
|
106
106
|
const dependentState = state.__depends[el];
|
|
107
|
-
dependentState.clean().update(state.parse(), options);
|
|
107
|
+
await dependentState.clean().update(state.parse(), options);
|
|
108
108
|
}
|
|
109
109
|
};
|
|
110
|
-
const applyElementUpdate = (state, obj, options) => {
|
|
110
|
+
const applyElementUpdate = async (state, obj, options) => {
|
|
111
111
|
const element = state.__element;
|
|
112
112
|
if (options.preventUpdate !== true) {
|
|
113
|
-
element.update({}, {
|
|
113
|
+
await element.update({}, {
|
|
114
114
|
...options,
|
|
115
115
|
updateByState: true
|
|
116
116
|
});
|
|
117
117
|
} else if (options.preventUpdate === "recursive") {
|
|
118
|
-
element.update({}, {
|
|
118
|
+
await element.update({}, {
|
|
119
119
|
...options,
|
|
120
120
|
isHoisted: false,
|
|
121
121
|
updateByState: true,
|
package/dist/esm/create.js
CHANGED
|
@@ -55,7 +55,7 @@ const applyInitialState = async function(element, parent, options) {
|
|
|
55
55
|
const objectizeState = await checkForTypes(element);
|
|
56
56
|
if (objectizeState === false) return parent.state || {};
|
|
57
57
|
else element.state = objectizeState;
|
|
58
|
-
const whatInitReturns = triggerEventOn("stateInit", element, options);
|
|
58
|
+
const whatInitReturns = await triggerEventOn("stateInit", element, options);
|
|
59
59
|
if (whatInitReturns === false) return element.state;
|
|
60
60
|
if (checkIfInherits(element)) {
|
|
61
61
|
const inheritedState = createInheritedState(element, parent);
|
|
@@ -64,7 +64,7 @@ const applyInitialState = async function(element, parent, options) {
|
|
|
64
64
|
const dependentState = applyDependentState(element, element.state || parent.state || {});
|
|
65
65
|
if (dependentState) element.state = dependentState;
|
|
66
66
|
applyMethods(element);
|
|
67
|
-
triggerEventOn("stateCreated", element);
|
|
67
|
+
await triggerEventOn("stateCreated", element);
|
|
68
68
|
return element.state;
|
|
69
69
|
};
|
|
70
70
|
const applyDependentState = (element, state) => {
|
package/dist/esm/updateState.js
CHANGED
|
@@ -43,10 +43,10 @@ const updateState = async function(obj, options = STATE_UPDATE_OPTIONS) {
|
|
|
43
43
|
if (beforeStateUpdateReturns === false) return element;
|
|
44
44
|
}
|
|
45
45
|
applyOverwrite(state, obj, options);
|
|
46
|
-
const updateIsHoisted = hoistStateUpdate(state, obj, options);
|
|
46
|
+
const updateIsHoisted = await hoistStateUpdate(state, obj, options);
|
|
47
47
|
if (updateIsHoisted) return state;
|
|
48
|
-
updateDependentState(state, obj, options);
|
|
49
|
-
applyElementUpdate(state, obj, options);
|
|
48
|
+
await updateDependentState(state, obj, options);
|
|
49
|
+
await applyElementUpdate(state, obj, options);
|
|
50
50
|
if (!options.preventStateUpdateListener) {
|
|
51
51
|
await triggerEventOnUpdate("stateUpdate", obj, element, options);
|
|
52
52
|
}
|
|
@@ -65,7 +65,7 @@ const applyOverwrite = (state, obj, options) => {
|
|
|
65
65
|
if (options.overwrite === "shallow-once") options.overwrite = true;
|
|
66
66
|
overwriteFunc(state, obj, IGNORE_STATE_PARAMS);
|
|
67
67
|
};
|
|
68
|
-
const hoistStateUpdate = (state, obj, options) => {
|
|
68
|
+
const hoistStateUpdate = async (state, obj, options) => {
|
|
69
69
|
const element = state.__element;
|
|
70
70
|
const { parent, __ref: ref } = element;
|
|
71
71
|
const stateKey = ref == null ? void 0 : ref.__state;
|
|
@@ -83,7 +83,7 @@ const hoistStateUpdate = (state, obj, options) => {
|
|
|
83
83
|
const changesValue = createNestedObjectByKeyPath(stateKey, passedValue);
|
|
84
84
|
const targetParent = findRootState || findGrandParentState || parent.state;
|
|
85
85
|
if (options.replace) overwriteDeep(targetParent, changesValue || value);
|
|
86
|
-
targetParent.update(changesValue, __spreadValues({
|
|
86
|
+
await targetParent.update(changesValue, __spreadValues({
|
|
87
87
|
execStateFunction: false,
|
|
88
88
|
isHoisted: true,
|
|
89
89
|
preventUpdate: options.preventHoistElementUpdate,
|
|
@@ -91,25 +91,25 @@ const hoistStateUpdate = (state, obj, options) => {
|
|
|
91
91
|
}, options));
|
|
92
92
|
const hasNotUpdated = options.preventUpdate !== true || !options.preventHoistElementUpdate;
|
|
93
93
|
if (!options.preventStateUpdateListener && hasNotUpdated) {
|
|
94
|
-
triggerEventOnUpdate("stateUpdate", obj, element, options);
|
|
94
|
+
await triggerEventOnUpdate("stateUpdate", obj, element, options);
|
|
95
95
|
}
|
|
96
96
|
return true;
|
|
97
97
|
};
|
|
98
|
-
const updateDependentState = (state, obj, options) => {
|
|
98
|
+
const updateDependentState = async (state, obj, options) => {
|
|
99
99
|
if (!state.__depends) return;
|
|
100
100
|
for (const el in state.__depends) {
|
|
101
101
|
const dependentState = state.__depends[el];
|
|
102
|
-
dependentState.clean().update(state.parse(), options);
|
|
102
|
+
await dependentState.clean().update(state.parse(), options);
|
|
103
103
|
}
|
|
104
104
|
};
|
|
105
|
-
const applyElementUpdate = (state, obj, options) => {
|
|
105
|
+
const applyElementUpdate = async (state, obj, options) => {
|
|
106
106
|
const element = state.__element;
|
|
107
107
|
if (options.preventUpdate !== true) {
|
|
108
|
-
element.update({}, __spreadProps(__spreadValues({}, options), {
|
|
108
|
+
await element.update({}, __spreadProps(__spreadValues({}, options), {
|
|
109
109
|
updateByState: true
|
|
110
110
|
}));
|
|
111
111
|
} else if (options.preventUpdate === "recursive") {
|
|
112
|
-
element.update({}, __spreadProps(__spreadValues({}, options), {
|
|
112
|
+
await element.update({}, __spreadProps(__spreadValues({}, options), {
|
|
113
113
|
isHoisted: false,
|
|
114
114
|
updateByState: true,
|
|
115
115
|
preventUpdate: true
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domql/state",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.206",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "index.js",
|
|
@@ -24,13 +24,13 @@
|
|
|
24
24
|
"build:esm": "npx esbuild *.js --target=es2017 --format=esm --outdir=dist/esm",
|
|
25
25
|
"build:cjs": "npx esbuild *.js --target=node16 --format=cjs --outdir=dist/cjs",
|
|
26
26
|
"build:iife": "npx esbuild *.js --target=node16 --format=iife --outdir=dist/iife",
|
|
27
|
-
"build": "rimraf -I dist; npm run build:cjs; npm run build:esm",
|
|
28
|
-
"prepublish": "rimraf -I dist && npm run build && npm run copy:package:cjs"
|
|
27
|
+
"build": "npx rimraf -I dist; npm run build:cjs; npm run build:esm",
|
|
28
|
+
"prepublish": "npx rimraf -I dist && npm run build && npm run copy:package:cjs"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@domql/event": "^2.5.
|
|
32
|
-
"@domql/report": "^2.5.
|
|
33
|
-
"@domql/utils": "^2.5.
|
|
31
|
+
"@domql/event": "^2.5.203",
|
|
32
|
+
"@domql/report": "^2.5.203",
|
|
33
|
+
"@domql/utils": "^2.5.203"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "8d50915b5d72df7c8bdf35096b0a9cf50dc4d22e"
|
|
36
36
|
}
|
package/updateState.js
CHANGED
|
@@ -33,12 +33,12 @@ export const updateState = async function (obj, options = STATE_UPDATE_OPTIONS)
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
applyOverwrite(state, obj, options)
|
|
36
|
-
const updateIsHoisted = hoistStateUpdate(state, obj, options)
|
|
36
|
+
const updateIsHoisted = await hoistStateUpdate(state, obj, options)
|
|
37
37
|
if (updateIsHoisted) return state
|
|
38
38
|
|
|
39
|
-
updateDependentState(state, obj, options)
|
|
39
|
+
await updateDependentState(state, obj, options)
|
|
40
40
|
|
|
41
|
-
applyElementUpdate(state, obj, options)
|
|
41
|
+
await applyElementUpdate(state, obj, options)
|
|
42
42
|
|
|
43
43
|
if (!options.preventStateUpdateListener) {
|
|
44
44
|
await triggerEventOnUpdate('stateUpdate', obj, element, options)
|
|
@@ -64,7 +64,7 @@ const applyOverwrite = (state, obj, options) => {
|
|
|
64
64
|
overwriteFunc(state, obj, IGNORE_STATE_PARAMS)
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
const hoistStateUpdate = (state, obj, options) => {
|
|
67
|
+
const hoistStateUpdate = async (state, obj, options) => {
|
|
68
68
|
const element = state.__element
|
|
69
69
|
const { parent, __ref: ref } = element
|
|
70
70
|
|
|
@@ -86,7 +86,7 @@ const hoistStateUpdate = (state, obj, options) => {
|
|
|
86
86
|
const changesValue = createNestedObjectByKeyPath(stateKey, passedValue)
|
|
87
87
|
const targetParent = findRootState || findGrandParentState || parent.state
|
|
88
88
|
if (options.replace) overwriteDeep(targetParent, changesValue || value) // check with createNestedObjectByKeyPath
|
|
89
|
-
targetParent.update(changesValue, {
|
|
89
|
+
await targetParent.update(changesValue, {
|
|
90
90
|
execStateFunction: false,
|
|
91
91
|
isHoisted: true,
|
|
92
92
|
preventUpdate: options.preventHoistElementUpdate,
|
|
@@ -95,28 +95,28 @@ const hoistStateUpdate = (state, obj, options) => {
|
|
|
95
95
|
})
|
|
96
96
|
const hasNotUpdated = options.preventUpdate !== true || !options.preventHoistElementUpdate
|
|
97
97
|
if (!options.preventStateUpdateListener && hasNotUpdated) {
|
|
98
|
-
triggerEventOnUpdate('stateUpdate', obj, element, options)
|
|
98
|
+
await triggerEventOnUpdate('stateUpdate', obj, element, options)
|
|
99
99
|
}
|
|
100
100
|
return true
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
const updateDependentState = (state, obj, options) => {
|
|
103
|
+
const updateDependentState = async (state, obj, options) => {
|
|
104
104
|
if (!state.__depends) return
|
|
105
105
|
for (const el in state.__depends) {
|
|
106
106
|
const dependentState = state.__depends[el]
|
|
107
|
-
dependentState.clean().update(state.parse(), options)
|
|
107
|
+
await dependentState.clean().update(state.parse(), options)
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
const applyElementUpdate = (state, obj, options) => {
|
|
111
|
+
const applyElementUpdate = async (state, obj, options) => {
|
|
112
112
|
const element = state.__element
|
|
113
113
|
if (options.preventUpdate !== true) {
|
|
114
|
-
element.update({}, {
|
|
114
|
+
await element.update({}, {
|
|
115
115
|
...options,
|
|
116
116
|
updateByState: true
|
|
117
117
|
})
|
|
118
118
|
} else if (options.preventUpdate === 'recursive') {
|
|
119
|
-
element.update({}, {
|
|
119
|
+
await element.update({}, {
|
|
120
120
|
...options,
|
|
121
121
|
isHoisted: false,
|
|
122
122
|
updateByState: true,
|