@domql/state 2.5.35 → 2.5.45

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict'
2
2
 
3
3
  import { triggerEventOn } from '@domql/event'
4
- import { deepClone, exec, is, isArray, isFunction, isObject, isUndefined } from '@domql/utils'
4
+ import { deepCloneWithExtnd, exec, is, isArray, isFunction, isObject, isUndefined } from '@domql/utils'
5
5
  import { IGNORE_STATE_PARAMS } from './ignore'
6
6
  import { add, apply, clean, destroy, parentUpdate, parse, remove, rootUpdate, set, reset, toggle } from './methods'
7
7
  import { updateState } from './updateState'
@@ -15,7 +15,7 @@ export const createState = function (element, parent, options) {
15
15
  export const applyInitialState = function (element, parent, options) {
16
16
  const objectizeState = checkForTypes(element)
17
17
  if (objectizeState === false) return parent.state || {}
18
- else element.state = deepClone(objectizeState, IGNORE_STATE_PARAMS)
18
+ else element.state = deepCloneWithExtnd(objectizeState, IGNORE_STATE_PARAMS)
19
19
 
20
20
  const whatInitReturns = triggerEventOn('stateInit', element, options)
21
21
  if (whatInitReturns === false) return element.state
@@ -39,7 +39,7 @@ export const applyInitialState = function (element, parent, options) {
39
39
  const applyDependentState = (element, state) => {
40
40
  const { __ref: ref } = state
41
41
  if (!ref) return
42
- const dependentState = deepClone(ref, IGNORE_STATE_PARAMS)
42
+ const dependentState = deepCloneWithExtnd(ref, IGNORE_STATE_PARAMS)
43
43
  const newDepends = { [element.key]: dependentState }
44
44
  ref.__depends = isObject(ref.__depends)
45
45
  ? { ...ref.__depends, ...newDepends }
@@ -37,7 +37,7 @@ const applyInitialState = function(element, parent, options) {
37
37
  if (objectizeState === false)
38
38
  return parent.state || {};
39
39
  else
40
- element.state = (0, import_utils.deepClone)(objectizeState, import_ignore.IGNORE_STATE_PARAMS);
40
+ element.state = (0, import_utils.deepCloneWithExtnd)(objectizeState, import_ignore.IGNORE_STATE_PARAMS);
41
41
  const whatInitReturns = (0, import_event.triggerEventOn)("stateInit", element, options);
42
42
  if (whatInitReturns === false)
43
43
  return element.state;
@@ -56,7 +56,7 @@ const applyDependentState = (element, state) => {
56
56
  const { __ref: ref } = state;
57
57
  if (!ref)
58
58
  return;
59
- const dependentState = (0, import_utils.deepClone)(ref, import_ignore.IGNORE_STATE_PARAMS);
59
+ const dependentState = (0, import_utils.deepCloneWithExtnd)(ref, import_ignore.IGNORE_STATE_PARAMS);
60
60
  const newDepends = { [element.key]: dependentState };
61
61
  ref.__depends = (0, import_utils.isObject)(ref.__depends) ? { ...ref.__depends, ...newDepends } : newDepends;
62
62
  return dependentState;
@@ -82,7 +82,7 @@ const createInheritedState = (element, parent) => {
82
82
  if ((0, import_utils.isUndefined)(inheritedState))
83
83
  return element.state;
84
84
  if ((0, import_utils.is)(inheritedState)("object", "array")) {
85
- return (0, import_utils.deepClone)(inheritedState, import_ignore.IGNORE_STATE_PARAMS);
85
+ return (0, import_utils.deepCloneWithExtnd)(inheritedState, import_ignore.IGNORE_STATE_PARAMS);
86
86
  } else if ((0, import_utils.is)(inheritedState)("string", "number", "boolean")) {
87
87
  ref.__stateType = typeof inheritedState;
88
88
  return { value: inheritedState };
@@ -124,20 +124,21 @@ const toggle = function(key, options = {}) {
124
124
  };
125
125
  const remove = function(key, options = {}) {
126
126
  const state = this;
127
+ console.log(state);
127
128
  if ((0, import_utils.isArray)(state))
128
129
  (0, import_utils.removeFromArray)(state, key);
129
130
  if ((0, import_utils.isObject)(state))
130
131
  (0, import_utils.removeFromObject)(state, key);
131
- return state.update(state.parse(), { replace: true, ...options });
132
+ return state.set(state.parse(), { replace: true, ...options });
132
133
  };
133
134
  const set = function(val, options = {}) {
134
135
  const state = this;
135
- const value = (0, import_utils.deepClone)(val);
136
+ const value = (0, import_utils.deepCloneWithExtnd)(val);
136
137
  return state.clean({ preventStateUpdate: true, ...options }).update(value, { replace: true, ...options });
137
138
  };
138
139
  const reset = function(options = {}) {
139
140
  const state = this;
140
- const value = (0, import_utils.deepClone)(state.parse());
141
+ const value = (0, import_utils.deepCloneWithExtnd)(state.parse());
141
142
  return state.set(value, { replace: true, ...options });
142
143
  };
143
144
  const apply = function(func, options = {}) {
package/inherit.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- import { deepClone, is, isObjectLike, isUndefined } from '@domql/utils'
3
+ import { deepCloneWithExtnd, is, isObjectLike, isUndefined } from '@domql/utils'
4
4
  import { IGNORE_STATE_PARAMS } from './ignore'
5
5
 
6
6
  export const getParentStateInKey = (stateKey, parentState) => {
@@ -56,7 +56,7 @@ export const createInheritedState = (element, parent) => {
56
56
  if (isUndefined(inheritedState)) return element.state
57
57
 
58
58
  if (is(inheritedState)('object', 'array')) {
59
- return deepClone(inheritedState, IGNORE_STATE_PARAMS)
59
+ return deepCloneWithExtnd(inheritedState, IGNORE_STATE_PARAMS)
60
60
  } else if (is(inheritedState)('string', 'number', 'boolean')) {
61
61
  ref.__stateType = typeof inheritedState
62
62
  return { value: inheritedState }
package/methods.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- import { isArray, deepClone, isFunction, isObject, isString, removeFromArray, removeFromObject } from '@domql/utils'
3
+ import { isArray, deepCloneWithExtnd, isFunction, isObject, isString, removeFromArray, removeFromObject } from '@domql/utils'
4
4
 
5
5
  import { IGNORE_STATE_PARAMS } from './ignore'
6
6
 
@@ -102,21 +102,22 @@ export const toggle = function (key, options = {}) {
102
102
 
103
103
  export const remove = function (key, options = {}) {
104
104
  const state = this
105
+ console.log(state)
105
106
  if (isArray(state)) removeFromArray(state, key)
106
107
  if (isObject(state)) removeFromObject(state, key)
107
- return state.update(state.parse(), { replace: true, ...options })
108
+ return state.set(state.parse(), { replace: true, ...options })
108
109
  }
109
110
 
110
111
  export const set = function (val, options = {}) {
111
112
  const state = this
112
- const value = deepClone(val)
113
+ const value = deepCloneWithExtnd(val)
113
114
  return state.clean({ preventStateUpdate: true, ...options })
114
115
  .update(value, { replace: true, ...options })
115
116
  }
116
117
 
117
118
  export const reset = function (options = {}) {
118
119
  const state = this
119
- const value = deepClone(state.parse())
120
+ const value = deepCloneWithExtnd(state.parse())
120
121
  return state.set(value, { replace: true, ...options })
121
122
  }
122
123
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@domql/state",
3
- "version": "2.5.35",
3
+ "version": "2.5.45",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "dist/esm/index.js",
@@ -31,5 +31,5 @@
31
31
  "@domql/report": "latest",
32
32
  "@domql/utils": "latest"
33
33
  },
34
- "gitHead": "8d7684fd84f5c48fb5cf71e76a05eda071c118f7"
34
+ "gitHead": "d27f2c6a7f03bf170b68c5bfb2c45bddb8bf5e94"
35
35
  }