@zag-js/store 1.46.0 → 1.48.0
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/clone.d.mts +1 -3
- package/dist/clone.d.ts +1 -3
- package/dist/clone.js +37 -72
- package/dist/clone.mjs +33 -47
- package/dist/global.d.mts +2 -4
- package/dist/global.d.ts +2 -4
- package/dist/global.js +15 -39
- package/dist/global.mjs +10 -13
- package/dist/index.d.mts +5 -4
- package/dist/index.d.ts +5 -4
- package/dist/index.js +14 -44
- package/dist/index.mjs +1 -10
- package/dist/proxy-computed.d.mts +5 -10
- package/dist/proxy-computed.d.ts +5 -10
- package/dist/proxy-computed.js +17 -45
- package/dist/proxy-computed.mjs +13 -20
- package/dist/proxy.d.mts +9 -10
- package/dist/proxy.d.ts +9 -10
- package/dist/proxy.js +180 -241
- package/dist/proxy.mjs +171 -211
- package/dist/utils.d.mts +3 -5
- package/dist/utils.d.ts +3 -5
- package/dist/utils.js +15 -40
- package/dist/utils.mjs +9 -13
- package/package.json +3 -3
package/dist/proxy.mjs
CHANGED
|
@@ -1,225 +1,185 @@
|
|
|
1
|
-
// src/proxy.ts
|
|
2
|
-
import { getUntracked, markToTrack } from "proxy-compare";
|
|
3
1
|
import { globalRef, refSet } from "./global.mjs";
|
|
4
2
|
import { canProxy, isDev, isObject } from "./utils.mjs";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
Reflect.set(target, prop, nextValue, receiver);
|
|
136
|
-
notifyUpdate(["set", [prop], value, prevValue]);
|
|
137
|
-
return true;
|
|
138
|
-
}
|
|
139
|
-
};
|
|
140
|
-
const proxyObject = newProxy(baseObject, handler);
|
|
141
|
-
proxyCache.set(initialObject, proxyObject);
|
|
142
|
-
const proxyState = [baseObject, ensureVersion, createSnapshot, addListener];
|
|
143
|
-
proxyStateMap.set(proxyObject, proxyState);
|
|
144
|
-
Reflect.ownKeys(initialObject).forEach((key) => {
|
|
145
|
-
const desc = Object.getOwnPropertyDescriptor(initialObject, key);
|
|
146
|
-
if (desc.get || desc.set) {
|
|
147
|
-
Object.defineProperty(baseObject, key, desc);
|
|
148
|
-
} else {
|
|
149
|
-
proxyObject[key] = initialObject[key];
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
return proxyObject;
|
|
3
|
+
import { getUntracked, markToTrack } from "proxy-compare";
|
|
4
|
+
// src/proxy.ts
|
|
5
|
+
const proxyStateMap = globalRef("__zag__proxyStateMap", () => /* @__PURE__ */ new WeakMap());
|
|
6
|
+
const buildProxyFunction = (objectIs = Object.is, newProxy = (target, handler) => new Proxy(target, handler), snapCache = /* @__PURE__ */ new WeakMap(), createSnapshot = (target, version) => {
|
|
7
|
+
const cache = snapCache.get(target);
|
|
8
|
+
if (cache?.[0] === version) return cache[1];
|
|
9
|
+
const snap = Array.isArray(target) ? [] : Object.create(Object.getPrototypeOf(target));
|
|
10
|
+
markToTrack(snap, true);
|
|
11
|
+
snapCache.set(target, [version, snap]);
|
|
12
|
+
Reflect.ownKeys(target).forEach((key) => {
|
|
13
|
+
const value = Reflect.get(target, key);
|
|
14
|
+
if (refSet.has(value)) {
|
|
15
|
+
markToTrack(value, false);
|
|
16
|
+
snap[key] = value;
|
|
17
|
+
} else if (proxyStateMap.has(value)) snap[key] = snapshot(value);
|
|
18
|
+
else snap[key] = value;
|
|
19
|
+
});
|
|
20
|
+
return Object.freeze(snap);
|
|
21
|
+
}, proxyCache = /* @__PURE__ */ new WeakMap(), versionHolder = [1, 1], proxyFunction = (initialObject) => {
|
|
22
|
+
if (!isObject(initialObject)) throw new Error("object required");
|
|
23
|
+
const found = proxyCache.get(initialObject);
|
|
24
|
+
if (found) return found;
|
|
25
|
+
let version = versionHolder[0];
|
|
26
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
27
|
+
const notifyUpdate = (op, nextVersion = ++versionHolder[0]) => {
|
|
28
|
+
if (version !== nextVersion) {
|
|
29
|
+
version = nextVersion;
|
|
30
|
+
listeners.forEach((listener) => listener(op, nextVersion));
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
let checkVersion = versionHolder[1];
|
|
34
|
+
const ensureVersion = (nextCheckVersion = ++versionHolder[1]) => {
|
|
35
|
+
if (checkVersion !== nextCheckVersion && !listeners.size) {
|
|
36
|
+
checkVersion = nextCheckVersion;
|
|
37
|
+
propProxyStates.forEach(([propProxyState]) => {
|
|
38
|
+
const propVersion = propProxyState[1](nextCheckVersion);
|
|
39
|
+
if (propVersion > version) version = propVersion;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
return version;
|
|
43
|
+
};
|
|
44
|
+
const createPropListener = (prop) => (op, nextVersion) => {
|
|
45
|
+
const newOp = [...op];
|
|
46
|
+
newOp[1] = [prop, ...newOp[1]];
|
|
47
|
+
notifyUpdate(newOp, nextVersion);
|
|
48
|
+
};
|
|
49
|
+
const propProxyStates = /* @__PURE__ */ new Map();
|
|
50
|
+
const addPropListener = (prop, propProxyState) => {
|
|
51
|
+
if (isDev() && propProxyStates.has(prop)) throw new Error("prop listener already exists");
|
|
52
|
+
if (listeners.size) {
|
|
53
|
+
const remove = propProxyState[3](createPropListener(prop));
|
|
54
|
+
propProxyStates.set(prop, [propProxyState, remove]);
|
|
55
|
+
} else propProxyStates.set(prop, [propProxyState]);
|
|
56
|
+
};
|
|
57
|
+
const removePropListener = (prop) => {
|
|
58
|
+
const entry = propProxyStates.get(prop);
|
|
59
|
+
if (entry) {
|
|
60
|
+
propProxyStates.delete(prop);
|
|
61
|
+
entry[1]?.();
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
const addListener = (listener) => {
|
|
65
|
+
listeners.add(listener);
|
|
66
|
+
if (listeners.size === 1) propProxyStates.forEach(([propProxyState, prevRemove], prop) => {
|
|
67
|
+
if (isDev() && prevRemove) throw new Error("remove already exists");
|
|
68
|
+
const remove = propProxyState[3](createPropListener(prop));
|
|
69
|
+
propProxyStates.set(prop, [propProxyState, remove]);
|
|
70
|
+
});
|
|
71
|
+
const removeListener = () => {
|
|
72
|
+
listeners.delete(listener);
|
|
73
|
+
if (listeners.size === 0) propProxyStates.forEach(([propProxyState, remove], prop) => {
|
|
74
|
+
if (remove) {
|
|
75
|
+
remove();
|
|
76
|
+
propProxyStates.set(prop, [propProxyState]);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
return removeListener;
|
|
81
|
+
};
|
|
82
|
+
const baseObject = Array.isArray(initialObject) ? [] : Object.create(Object.getPrototypeOf(initialObject));
|
|
83
|
+
const proxyObject = newProxy(baseObject, {
|
|
84
|
+
deleteProperty(target, prop) {
|
|
85
|
+
const prevValue = Reflect.get(target, prop);
|
|
86
|
+
removePropListener(prop);
|
|
87
|
+
const deleted = Reflect.deleteProperty(target, prop);
|
|
88
|
+
if (deleted) notifyUpdate([
|
|
89
|
+
"delete",
|
|
90
|
+
[prop],
|
|
91
|
+
prevValue
|
|
92
|
+
]);
|
|
93
|
+
return deleted;
|
|
94
|
+
},
|
|
95
|
+
set(target, prop, value, receiver) {
|
|
96
|
+
const hasPrevValue = Reflect.has(target, prop);
|
|
97
|
+
const prevValue = Reflect.get(target, prop, receiver);
|
|
98
|
+
if (hasPrevValue && (objectIs(prevValue, value) || proxyCache.has(value) && objectIs(prevValue, proxyCache.get(value)))) return true;
|
|
99
|
+
removePropListener(prop);
|
|
100
|
+
if (isObject(value)) value = getUntracked(value) || value;
|
|
101
|
+
let nextValue = value;
|
|
102
|
+
if (Object.getOwnPropertyDescriptor(target, prop)?.set) {} else {
|
|
103
|
+
if (!proxyStateMap.has(value) && canProxy(value)) nextValue = proxy(value);
|
|
104
|
+
const childProxyState = !refSet.has(nextValue) && proxyStateMap.get(nextValue);
|
|
105
|
+
if (childProxyState) addPropListener(prop, childProxyState);
|
|
106
|
+
}
|
|
107
|
+
Reflect.set(target, prop, nextValue, receiver);
|
|
108
|
+
notifyUpdate([
|
|
109
|
+
"set",
|
|
110
|
+
[prop],
|
|
111
|
+
value,
|
|
112
|
+
prevValue
|
|
113
|
+
]);
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
proxyCache.set(initialObject, proxyObject);
|
|
118
|
+
const proxyState = [
|
|
119
|
+
baseObject,
|
|
120
|
+
ensureVersion,
|
|
121
|
+
createSnapshot,
|
|
122
|
+
addListener
|
|
123
|
+
];
|
|
124
|
+
proxyStateMap.set(proxyObject, proxyState);
|
|
125
|
+
Reflect.ownKeys(initialObject).forEach((key) => {
|
|
126
|
+
const desc = Object.getOwnPropertyDescriptor(initialObject, key);
|
|
127
|
+
if (desc.get || desc.set) Object.defineProperty(baseObject, key, desc);
|
|
128
|
+
else proxyObject[key] = initialObject[key];
|
|
129
|
+
});
|
|
130
|
+
return proxyObject;
|
|
153
131
|
}) => [
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
createSnapshot,
|
|
165
|
-
proxyCache,
|
|
166
|
-
versionHolder
|
|
132
|
+
proxyFunction,
|
|
133
|
+
proxyStateMap,
|
|
134
|
+
refSet,
|
|
135
|
+
objectIs,
|
|
136
|
+
newProxy,
|
|
137
|
+
canProxy,
|
|
138
|
+
snapCache,
|
|
139
|
+
createSnapshot,
|
|
140
|
+
proxyCache,
|
|
141
|
+
versionHolder
|
|
167
142
|
];
|
|
168
|
-
|
|
143
|
+
const [proxyFunction] = buildProxyFunction();
|
|
169
144
|
function proxy(initialObject = {}) {
|
|
170
|
-
|
|
145
|
+
return proxyFunction(initialObject);
|
|
171
146
|
}
|
|
172
147
|
function getVersion(proxyObject) {
|
|
173
|
-
|
|
174
|
-
return proxyState?.[1]();
|
|
148
|
+
return proxyStateMap.get(proxyObject)?.[1]();
|
|
175
149
|
}
|
|
176
150
|
function subscribe(proxyObject, callback, notifyInSync) {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
const removeListener = addListener(listener);
|
|
201
|
-
isListenerActive = true;
|
|
202
|
-
return () => {
|
|
203
|
-
isListenerActive = false;
|
|
204
|
-
removeListener();
|
|
205
|
-
};
|
|
151
|
+
const proxyState = proxyStateMap.get(proxyObject);
|
|
152
|
+
if (isDev() && !proxyState) console.warn("Please use proxy object");
|
|
153
|
+
let promise;
|
|
154
|
+
const ops = [];
|
|
155
|
+
const addListener = proxyState[3];
|
|
156
|
+
let isListenerActive = false;
|
|
157
|
+
const listener = (op) => {
|
|
158
|
+
ops.push(op);
|
|
159
|
+
if (notifyInSync) {
|
|
160
|
+
callback(ops.splice(0));
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
if (!promise) promise = Promise.resolve().then(() => {
|
|
164
|
+
promise = void 0;
|
|
165
|
+
if (isListenerActive) callback(ops.splice(0));
|
|
166
|
+
});
|
|
167
|
+
};
|
|
168
|
+
const removeListener = addListener(listener);
|
|
169
|
+
isListenerActive = true;
|
|
170
|
+
return () => {
|
|
171
|
+
isListenerActive = false;
|
|
172
|
+
removeListener();
|
|
173
|
+
};
|
|
206
174
|
}
|
|
207
175
|
function snapshot(proxyObject) {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
const [target, ensureVersion, createSnapshot] = proxyState;
|
|
213
|
-
return createSnapshot(target, ensureVersion());
|
|
176
|
+
const proxyState = proxyStateMap.get(proxyObject);
|
|
177
|
+
if (isDev() && !proxyState) console.warn("Please use proxy object");
|
|
178
|
+
const [target, ensureVersion, createSnapshot] = proxyState;
|
|
179
|
+
return createSnapshot(target, ensureVersion());
|
|
214
180
|
}
|
|
215
181
|
function ref(obj) {
|
|
216
|
-
|
|
217
|
-
|
|
182
|
+
refSet.add(obj);
|
|
183
|
+
return obj;
|
|
218
184
|
}
|
|
219
|
-
export {
|
|
220
|
-
getVersion,
|
|
221
|
-
proxy,
|
|
222
|
-
ref,
|
|
223
|
-
snapshot,
|
|
224
|
-
subscribe
|
|
225
|
-
};
|
|
185
|
+
export { getVersion, proxy, ref, snapshot, subscribe };
|
package/dist/utils.d.mts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
declare const isObject: (x: unknown) => x is object;
|
|
2
|
-
declare const canProxy: (x: unknown) => boolean;
|
|
3
|
-
declare const isDev: () => boolean;
|
|
4
|
-
|
|
5
|
-
export { canProxy, isDev, isObject };
|
|
1
|
+
export declare const isObject: (x: unknown) => x is object;
|
|
2
|
+
export declare const canProxy: (x: unknown) => boolean;
|
|
3
|
+
export declare const isDev: () => boolean;
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
declare const isObject: (x: unknown) => x is object;
|
|
2
|
-
declare const canProxy: (x: unknown) => boolean;
|
|
3
|
-
declare const isDev: () => boolean;
|
|
4
|
-
|
|
5
|
-
export { canProxy, isDev, isObject };
|
|
1
|
+
export declare const isObject: (x: unknown) => x is object;
|
|
2
|
+
export declare const canProxy: (x: unknown) => boolean;
|
|
3
|
+
export declare const isDev: () => boolean;
|
package/dist/utils.js
CHANGED
|
@@ -1,41 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/utils.ts
|
|
21
|
-
var utils_exports = {};
|
|
22
|
-
__export(utils_exports, {
|
|
23
|
-
canProxy: () => canProxy,
|
|
24
|
-
isDev: () => isDev,
|
|
25
|
-
isObject: () => isObject
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(utils_exports);
|
|
28
|
-
var import_global = require("./global.js");
|
|
29
|
-
var isReactElement = (x) => typeof x === "object" && x !== null && "$$typeof" in x && "props" in x;
|
|
30
|
-
var isVueElement = (x) => typeof x === "object" && x !== null && "__v_isVNode" in x;
|
|
31
|
-
var isDOMElement = (x) => typeof x === "object" && x !== null && "nodeType" in x && typeof x.nodeName === "string";
|
|
32
|
-
var isElement = (x) => isReactElement(x) || isVueElement(x) || isDOMElement(x);
|
|
33
|
-
var isObject = (x) => x !== null && typeof x === "object";
|
|
34
|
-
var canProxy = (x) => isObject(x) && !import_global.refSet.has(x) && (Array.isArray(x) || !(Symbol.iterator in x)) && !isElement(x) && !(x instanceof WeakMap) && !(x instanceof WeakSet) && !(x instanceof Error) && !(x instanceof Number) && !(x instanceof Date) && !(x instanceof String) && !(x instanceof RegExp) && !(x instanceof ArrayBuffer) && !(x instanceof Promise) && !(x instanceof File) && !(x instanceof Blob) && !(x instanceof AbortController);
|
|
35
|
-
var isDev = () => process.env.NODE_ENV !== "production";
|
|
36
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
37
|
-
0 && (module.exports = {
|
|
38
|
-
canProxy,
|
|
39
|
-
isDev,
|
|
40
|
-
isObject
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
41
4
|
});
|
|
5
|
+
const require_global = require("./global.js");
|
|
6
|
+
// src/utils.ts
|
|
7
|
+
const isReactElement = (x) => typeof x === "object" && x !== null && "$$typeof" in x && "props" in x;
|
|
8
|
+
const isVueElement = (x) => typeof x === "object" && x !== null && "__v_isVNode" in x;
|
|
9
|
+
const isDOMElement = (x) => typeof x === "object" && x !== null && "nodeType" in x && typeof x.nodeName === "string";
|
|
10
|
+
const isElement = (x) => isReactElement(x) || isVueElement(x) || isDOMElement(x);
|
|
11
|
+
const isObject = (x) => x !== null && typeof x === "object";
|
|
12
|
+
const canProxy = (x) => isObject(x) && !require_global.refSet.has(x) && (Array.isArray(x) || !(Symbol.iterator in x)) && !isElement(x) && !(x instanceof WeakMap) && !(x instanceof WeakSet) && !(x instanceof Error) && !(x instanceof Number) && !(x instanceof Date) && !(x instanceof String) && !(x instanceof RegExp) && !(x instanceof ArrayBuffer) && !(x instanceof Promise) && !(x instanceof File) && !(x instanceof Blob) && !(x instanceof AbortController);
|
|
13
|
+
const isDev = () => process.env.NODE_ENV !== "production";
|
|
14
|
+
exports.canProxy = canProxy;
|
|
15
|
+
exports.isDev = isDev;
|
|
16
|
+
exports.isObject = isObject;
|
package/dist/utils.mjs
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
// src/utils.ts
|
|
2
1
|
import { refSet } from "./global.mjs";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
isDev,
|
|
13
|
-
isObject
|
|
14
|
-
};
|
|
2
|
+
// src/utils.ts
|
|
3
|
+
const isReactElement = (x) => typeof x === "object" && x !== null && "$$typeof" in x && "props" in x;
|
|
4
|
+
const isVueElement = (x) => typeof x === "object" && x !== null && "__v_isVNode" in x;
|
|
5
|
+
const isDOMElement = (x) => typeof x === "object" && x !== null && "nodeType" in x && typeof x.nodeName === "string";
|
|
6
|
+
const isElement = (x) => isReactElement(x) || isVueElement(x) || isDOMElement(x);
|
|
7
|
+
const isObject = (x) => x !== null && typeof x === "object";
|
|
8
|
+
const canProxy = (x) => isObject(x) && !refSet.has(x) && (Array.isArray(x) || !(Symbol.iterator in x)) && !isElement(x) && !(x instanceof WeakMap) && !(x instanceof WeakSet) && !(x instanceof Error) && !(x instanceof Number) && !(x instanceof Date) && !(x instanceof String) && !(x instanceof RegExp) && !(x instanceof ArrayBuffer) && !(x instanceof Promise) && !(x instanceof File) && !(x instanceof Blob) && !(x instanceof AbortController);
|
|
9
|
+
const isDev = () => process.env.NODE_ENV !== "production";
|
|
10
|
+
export { canProxy, isDev, isObject };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zag-js/store",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.48.0",
|
|
4
4
|
"description": "The reactive store package for zag machines",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"js",
|
|
@@ -49,9 +49,9 @@
|
|
|
49
49
|
"./package.json": "./package.json"
|
|
50
50
|
},
|
|
51
51
|
"scripts": {
|
|
52
|
-
"build": "
|
|
52
|
+
"build": "tsdown",
|
|
53
53
|
"test": "vitest",
|
|
54
|
-
"lint": "
|
|
54
|
+
"lint": "oxlint src",
|
|
55
55
|
"test-ci": "pnpm test --ci --runInBand -u",
|
|
56
56
|
"test-watch": "pnpm test --watchAll"
|
|
57
57
|
}
|