@domql/state 3.2.3 → 3.2.8
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 +3 -3
- package/dist/cjs/create.js +3 -4
- package/dist/cjs/methods.js +11 -13
- package/dist/cjs/updateState.js +5 -6
- package/dist/esm/create.js +3 -3
- package/dist/esm/methods.js +28 -48
- package/dist/esm/updateState.js +14 -30
- package/dist/iife/index.js +1051 -0
- package/methods.js +10 -11
- package/package.json +26 -14
- package/updateState.js +2 -2
- package/dist/cjs/package.json +0 -4
package/methods.js
CHANGED
|
@@ -25,13 +25,13 @@ export const parse = function () {
|
|
|
25
25
|
if (isObject(state)) {
|
|
26
26
|
const obj = {}
|
|
27
27
|
for (const param in state) {
|
|
28
|
-
if (!STATE_METHODS.
|
|
28
|
+
if (!STATE_METHODS.has(param)) {
|
|
29
29
|
obj[param] = state[param]
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
return obj
|
|
33
33
|
} else if (isArray(state)) {
|
|
34
|
-
return state.filter(item => !STATE_METHODS.
|
|
34
|
+
return state.filter(item => !STATE_METHODS.has(item))
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
|
|
@@ -39,8 +39,8 @@ export const clean = function (options = {}) {
|
|
|
39
39
|
const state = this
|
|
40
40
|
for (const param in state) {
|
|
41
41
|
if (
|
|
42
|
-
!STATE_METHODS.
|
|
43
|
-
Object.hasOwnProperty.call(state, param)
|
|
42
|
+
!STATE_METHODS.has(param) &&
|
|
43
|
+
Object.prototype.hasOwnProperty.call(state, param)
|
|
44
44
|
) {
|
|
45
45
|
delete state[param]
|
|
46
46
|
}
|
|
@@ -122,7 +122,7 @@ export const toggle = function (key, options = {}) {
|
|
|
122
122
|
export const remove = function (key, options = {}) {
|
|
123
123
|
const state = this
|
|
124
124
|
if (isArray(state)) removeFromArray(state, key)
|
|
125
|
-
if (isObject(state)) removeFromObject(state, key)
|
|
125
|
+
else if (isObject(state)) removeFromObject(state, key)
|
|
126
126
|
if (options.applyReset) {
|
|
127
127
|
return state.set(state.parse(), { replace: true, ...options })
|
|
128
128
|
}
|
|
@@ -147,8 +147,7 @@ export const setByPath = function (path, val, options = {}) {
|
|
|
147
147
|
|
|
148
148
|
export const setPathCollection = function (changes, options = {}) {
|
|
149
149
|
const state = this
|
|
150
|
-
const update = changes.reduce((
|
|
151
|
-
const acc = promise
|
|
150
|
+
const update = changes.reduce((acc, change) => {
|
|
152
151
|
if (change[0] === 'update') {
|
|
153
152
|
const result = setByPath.call(state, change[1], change[2], {
|
|
154
153
|
preventStateUpdate: true
|
|
@@ -161,7 +160,7 @@ export const setPathCollection = function (changes, options = {}) {
|
|
|
161
160
|
})
|
|
162
161
|
}
|
|
163
162
|
return acc
|
|
164
|
-
},
|
|
163
|
+
}, {})
|
|
165
164
|
|
|
166
165
|
return state.update(update, options)
|
|
167
166
|
}
|
|
@@ -175,9 +174,9 @@ export const removeByPath = function (path, options = {}) {
|
|
|
175
174
|
|
|
176
175
|
export const removePathCollection = function (changes, options = {}) {
|
|
177
176
|
const state = this
|
|
178
|
-
changes.
|
|
179
|
-
removeByPath(
|
|
180
|
-
}
|
|
177
|
+
for (let i = 0; i < changes.length; i++) {
|
|
178
|
+
removeByPath(changes[i], { preventUpdate: true })
|
|
179
|
+
}
|
|
181
180
|
return state.update({}, options)
|
|
182
181
|
}
|
|
183
182
|
|
package/package.json
CHANGED
|
@@ -1,36 +1,48 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domql/state",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.8",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"module": "index.js",
|
|
7
|
-
"main": "index.js",
|
|
8
|
-
"unpkg": "dist/iife/index.js",
|
|
9
|
-
"jsdelivr": "dist/iife/index.js",
|
|
6
|
+
"module": "./dist/esm/index.js",
|
|
7
|
+
"main": "./dist/cjs/index.js",
|
|
8
|
+
"unpkg": "./dist/iife/index.js",
|
|
9
|
+
"jsdelivr": "./dist/iife/index.js",
|
|
10
10
|
"exports": {
|
|
11
11
|
".": {
|
|
12
12
|
"import": "./dist/esm/index.js",
|
|
13
13
|
"require": "./dist/cjs/index.js",
|
|
14
|
+
"browser": "./dist/iife/index.js",
|
|
14
15
|
"default": "./dist/esm/index.js"
|
|
16
|
+
},
|
|
17
|
+
"./*.js": {
|
|
18
|
+
"import": "./dist/esm/*.js",
|
|
19
|
+
"require": "./dist/cjs/*.js",
|
|
20
|
+
"default": "./dist/esm/*.js"
|
|
21
|
+
},
|
|
22
|
+
"./*": {
|
|
23
|
+
"import": "./dist/esm/*.js",
|
|
24
|
+
"require": "./dist/cjs/*.js",
|
|
25
|
+
"default": "./dist/esm/*.js"
|
|
15
26
|
}
|
|
16
27
|
},
|
|
17
28
|
"source": "index.js",
|
|
18
29
|
"files": [
|
|
19
|
-
"
|
|
20
|
-
"
|
|
30
|
+
"dist",
|
|
31
|
+
"*.js"
|
|
21
32
|
],
|
|
22
33
|
"scripts": {
|
|
23
34
|
"copy:package:cjs": "cp ../../build/package-cjs.json dist/cjs/package.json",
|
|
24
|
-
"build:esm": "
|
|
25
|
-
"build:cjs": "
|
|
26
|
-
"build:iife": "
|
|
27
|
-
"build": "
|
|
28
|
-
"prepublish": "
|
|
35
|
+
"build:esm": "cross-env NODE_ENV=$NODE_ENV esbuild *.js --target=es2020 --format=esm --outdir=dist/esm --define:process.env.NODE_ENV=process.env.NODE_ENV",
|
|
36
|
+
"build:cjs": "cross-env NODE_ENV=$NODE_ENV esbuild *.js --target=node18 --format=cjs --outdir=dist/cjs --define:process.env.NODE_ENV=process.env.NODE_ENV",
|
|
37
|
+
"build:iife": "cross-env NODE_ENV=$NODE_ENV esbuild index.js --bundle --target=es2020 --format=iife --global-name=DomqlState --outfile=dist/iife/index.js --define:process.env.NODE_ENV=process.env.NODE_ENV",
|
|
38
|
+
"build": "node ../../build/build.js",
|
|
39
|
+
"prepublish": "npm run build && npm run copy:package:cjs"
|
|
29
40
|
},
|
|
30
41
|
"dependencies": {
|
|
31
|
-
"@domql/event": "^3.2.3",
|
|
32
42
|
"@domql/report": "^3.2.3",
|
|
33
43
|
"@domql/utils": "^3.2.3"
|
|
34
44
|
},
|
|
35
|
-
"gitHead": "9fc1b79b41cdc725ca6b24aec64920a599634681"
|
|
45
|
+
"gitHead": "9fc1b79b41cdc725ca6b24aec64920a599634681",
|
|
46
|
+
"browser": "./dist/iife/index.js",
|
|
47
|
+
"sideEffects": false
|
|
36
48
|
}
|
package/updateState.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
import { report } from '@domql/report'
|
|
4
|
-
import { triggerEventOnUpdate } from '@domql/event'
|
|
5
4
|
import {
|
|
6
5
|
checkIfInherits,
|
|
7
6
|
createNestedObjectByKeyPath,
|
|
@@ -10,7 +9,8 @@ import {
|
|
|
10
9
|
getRootStateInKey,
|
|
11
10
|
merge,
|
|
12
11
|
overwriteDeep,
|
|
13
|
-
overwriteState
|
|
12
|
+
overwriteState,
|
|
13
|
+
triggerEventOnUpdate
|
|
14
14
|
} from '@domql/utils'
|
|
15
15
|
|
|
16
16
|
const STATE_UPDATE_OPTIONS = {
|
package/dist/cjs/package.json
DELETED