@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/clone.d.mts
CHANGED
package/dist/clone.d.ts
CHANGED
package/dist/clone.js
CHANGED
|
@@ -1,77 +1,42 @@
|
|
|
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/clone.ts
|
|
21
|
-
var clone_exports = {};
|
|
22
|
-
__export(clone_exports, {
|
|
23
|
-
clone: () => clone
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
24
4
|
});
|
|
25
|
-
|
|
26
|
-
|
|
5
|
+
const require_utils = require("./utils.js");
|
|
6
|
+
// src/clone.ts
|
|
27
7
|
function set(obj, key, val) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
} else obj[key] = val.value;
|
|
8
|
+
if (typeof val.value === "object" && !require_utils.canProxy(val.value)) val.value = clone(val.value);
|
|
9
|
+
if (!val.enumerable || val.get || val.set || !val.configurable || !val.writable || key === "__proto__") Object.defineProperty(obj, key, val);
|
|
10
|
+
else obj[key] = val.value;
|
|
32
11
|
}
|
|
33
12
|
function clone(x) {
|
|
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
|
-
if (tmp) {
|
|
64
|
-
for (list = Object.getOwnPropertySymbols(x); i < list.length; i++) {
|
|
65
|
-
set(tmp, list[i], Object.getOwnPropertyDescriptor(x, list[i]));
|
|
66
|
-
}
|
|
67
|
-
for (i = 0, list = Object.getOwnPropertyNames(x); i < list.length; i++) {
|
|
68
|
-
if (Object.hasOwnProperty.call(tmp, k = list[i]) && tmp[k] === x[k]) continue;
|
|
69
|
-
set(tmp, k, Object.getOwnPropertyDescriptor(x, k));
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
return tmp || x;
|
|
13
|
+
if (typeof x !== "object") return x;
|
|
14
|
+
let i = 0, k, list, tmp, str = Object.prototype.toString.call(x);
|
|
15
|
+
if (str === "[object Object]") tmp = Object.create(Object.getPrototypeOf(x) || null);
|
|
16
|
+
else if (str === "[object Array]") tmp = Array(x.length);
|
|
17
|
+
else if (str === "[object Set]") {
|
|
18
|
+
tmp = /* @__PURE__ */ new Set();
|
|
19
|
+
x.forEach(function(val) {
|
|
20
|
+
tmp.add(clone(val));
|
|
21
|
+
});
|
|
22
|
+
} else if (str === "[object Map]") {
|
|
23
|
+
tmp = /* @__PURE__ */ new Map();
|
|
24
|
+
x.forEach(function(val, key) {
|
|
25
|
+
tmp.set(clone(key), clone(val));
|
|
26
|
+
});
|
|
27
|
+
} else if (str === "[object Date]") tmp = /* @__PURE__ */ new Date(+x);
|
|
28
|
+
else if (str === "[object RegExp]") tmp = new RegExp(x.source, x.flags);
|
|
29
|
+
else if (str === "[object DataView]") tmp = new x.constructor(clone(x.buffer));
|
|
30
|
+
else if (str === "[object ArrayBuffer]") tmp = x.slice(0);
|
|
31
|
+
else if (str === "[object Blob]") tmp = x.slice();
|
|
32
|
+
else if (str.slice(-6) === "Array]") tmp = new x.constructor(x);
|
|
33
|
+
if (tmp) {
|
|
34
|
+
for (list = Object.getOwnPropertySymbols(x); i < list.length; i++) set(tmp, list[i], Object.getOwnPropertyDescriptor(x, list[i]));
|
|
35
|
+
for (i = 0, list = Object.getOwnPropertyNames(x); i < list.length; i++) {
|
|
36
|
+
if (Object.hasOwnProperty.call(tmp, k = list[i]) && tmp[k] === x[k]) continue;
|
|
37
|
+
set(tmp, k, Object.getOwnPropertyDescriptor(x, k));
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return tmp || x;
|
|
73
41
|
}
|
|
74
|
-
|
|
75
|
-
0 && (module.exports = {
|
|
76
|
-
clone
|
|
77
|
-
});
|
|
42
|
+
exports.clone = clone;
|
package/dist/clone.mjs
CHANGED
|
@@ -1,52 +1,38 @@
|
|
|
1
|
-
// src/clone.ts
|
|
2
1
|
import { canProxy } from "./utils.mjs";
|
|
2
|
+
// src/clone.ts
|
|
3
3
|
function set(obj, key, val) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} else obj[key] = val.value;
|
|
4
|
+
if (typeof val.value === "object" && !canProxy(val.value)) val.value = clone(val.value);
|
|
5
|
+
if (!val.enumerable || val.get || val.set || !val.configurable || !val.writable || key === "__proto__") Object.defineProperty(obj, key, val);
|
|
6
|
+
else obj[key] = val.value;
|
|
8
7
|
}
|
|
9
8
|
function clone(x) {
|
|
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
|
-
if (tmp) {
|
|
40
|
-
for (list = Object.getOwnPropertySymbols(x); i < list.length; i++) {
|
|
41
|
-
set(tmp, list[i], Object.getOwnPropertyDescriptor(x, list[i]));
|
|
42
|
-
}
|
|
43
|
-
for (i = 0, list = Object.getOwnPropertyNames(x); i < list.length; i++) {
|
|
44
|
-
if (Object.hasOwnProperty.call(tmp, k = list[i]) && tmp[k] === x[k]) continue;
|
|
45
|
-
set(tmp, k, Object.getOwnPropertyDescriptor(x, k));
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
return tmp || x;
|
|
9
|
+
if (typeof x !== "object") return x;
|
|
10
|
+
let i = 0, k, list, tmp, str = Object.prototype.toString.call(x);
|
|
11
|
+
if (str === "[object Object]") tmp = Object.create(Object.getPrototypeOf(x) || null);
|
|
12
|
+
else if (str === "[object Array]") tmp = Array(x.length);
|
|
13
|
+
else if (str === "[object Set]") {
|
|
14
|
+
tmp = /* @__PURE__ */ new Set();
|
|
15
|
+
x.forEach(function(val) {
|
|
16
|
+
tmp.add(clone(val));
|
|
17
|
+
});
|
|
18
|
+
} else if (str === "[object Map]") {
|
|
19
|
+
tmp = /* @__PURE__ */ new Map();
|
|
20
|
+
x.forEach(function(val, key) {
|
|
21
|
+
tmp.set(clone(key), clone(val));
|
|
22
|
+
});
|
|
23
|
+
} else if (str === "[object Date]") tmp = /* @__PURE__ */ new Date(+x);
|
|
24
|
+
else if (str === "[object RegExp]") tmp = new RegExp(x.source, x.flags);
|
|
25
|
+
else if (str === "[object DataView]") tmp = new x.constructor(clone(x.buffer));
|
|
26
|
+
else if (str === "[object ArrayBuffer]") tmp = x.slice(0);
|
|
27
|
+
else if (str === "[object Blob]") tmp = x.slice();
|
|
28
|
+
else if (str.slice(-6) === "Array]") tmp = new x.constructor(x);
|
|
29
|
+
if (tmp) {
|
|
30
|
+
for (list = Object.getOwnPropertySymbols(x); i < list.length; i++) set(tmp, list[i], Object.getOwnPropertyDescriptor(x, list[i]));
|
|
31
|
+
for (i = 0, list = Object.getOwnPropertyNames(x); i < list.length; i++) {
|
|
32
|
+
if (Object.hasOwnProperty.call(tmp, k = list[i]) && tmp[k] === x[k]) continue;
|
|
33
|
+
set(tmp, k, Object.getOwnPropertyDescriptor(x, k));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return tmp || x;
|
|
49
37
|
}
|
|
50
|
-
export {
|
|
51
|
-
clone
|
|
52
|
-
};
|
|
38
|
+
export { clone };
|
package/dist/global.d.mts
CHANGED
package/dist/global.d.ts
CHANGED
package/dist/global.js
CHANGED
|
@@ -1,44 +1,20 @@
|
|
|
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/global.ts
|
|
21
|
-
var global_exports = {};
|
|
22
|
-
__export(global_exports, {
|
|
23
|
-
globalRef: () => globalRef,
|
|
24
|
-
refSet: () => refSet
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
25
4
|
});
|
|
26
|
-
|
|
5
|
+
// src/global.ts
|
|
27
6
|
function glob() {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
7
|
+
if (typeof globalThis !== "undefined") return globalThis;
|
|
8
|
+
if (typeof self !== "undefined") return self;
|
|
9
|
+
if (typeof window !== "undefined") return window;
|
|
10
|
+
if (typeof global !== "undefined") return global;
|
|
32
11
|
}
|
|
33
12
|
function globalRef(key, value) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
13
|
+
const g = glob();
|
|
14
|
+
if (!g) return value();
|
|
15
|
+
g[key] || (g[key] = value());
|
|
16
|
+
return g[key];
|
|
38
17
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
globalRef,
|
|
43
|
-
refSet
|
|
44
|
-
});
|
|
18
|
+
const refSet = globalRef("__zag__refSet", () => /* @__PURE__ */ new WeakSet());
|
|
19
|
+
exports.globalRef = globalRef;
|
|
20
|
+
exports.refSet = refSet;
|
package/dist/global.mjs
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
// src/global.ts
|
|
2
2
|
function glob() {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
if (typeof globalThis !== "undefined") return globalThis;
|
|
4
|
+
if (typeof self !== "undefined") return self;
|
|
5
|
+
if (typeof window !== "undefined") return window;
|
|
6
|
+
if (typeof global !== "undefined") return global;
|
|
7
7
|
}
|
|
8
8
|
function globalRef(key, value) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
const g = glob();
|
|
10
|
+
if (!g) return value();
|
|
11
|
+
g[key] || (g[key] = value());
|
|
12
|
+
return g[key];
|
|
13
13
|
}
|
|
14
|
-
|
|
15
|
-
export {
|
|
16
|
-
globalRef,
|
|
17
|
-
refSet
|
|
18
|
-
};
|
|
14
|
+
const refSet = globalRef("__zag__refSet", () => /* @__PURE__ */ new WeakSet());
|
|
15
|
+
export { globalRef, refSet };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { clone } from "./clone.mjs";
|
|
2
|
+
import { globalRef } from "./global.mjs";
|
|
3
|
+
import { Ref, Snapshot, proxy, ref, snapshot, subscribe } from "./proxy.mjs";
|
|
4
|
+
import { proxyWithComputed } from "./proxy-computed.mjs";
|
|
5
|
+
export { type Ref, type Snapshot, clone, globalRef, proxy, proxyWithComputed, ref, snapshot, subscribe };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { clone } from "./clone.js";
|
|
2
|
+
import { globalRef } from "./global.js";
|
|
3
|
+
import { Ref, Snapshot, proxy, ref, snapshot, subscribe } from "./proxy.js";
|
|
4
|
+
import { proxyWithComputed } from "./proxy-computed.js";
|
|
5
|
+
export { type Ref, type Snapshot, clone, globalRef, proxy, proxyWithComputed, ref, snapshot, subscribe };
|
package/dist/index.js
CHANGED
|
@@ -1,45 +1,15 @@
|
|
|
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/index.ts
|
|
21
|
-
var index_exports = {};
|
|
22
|
-
__export(index_exports, {
|
|
23
|
-
clone: () => import_clone.clone,
|
|
24
|
-
globalRef: () => import_global.globalRef,
|
|
25
|
-
proxy: () => import_proxy.proxy,
|
|
26
|
-
proxyWithComputed: () => import_proxy_computed.proxyWithComputed,
|
|
27
|
-
ref: () => import_proxy.ref,
|
|
28
|
-
snapshot: () => import_proxy.snapshot,
|
|
29
|
-
subscribe: () => import_proxy.subscribe
|
|
30
|
-
});
|
|
31
|
-
module.exports = __toCommonJS(index_exports);
|
|
32
|
-
var import_clone = require("./clone.js");
|
|
33
|
-
var import_global = require("./global.js");
|
|
34
|
-
var import_proxy = require("./proxy.js");
|
|
35
|
-
var import_proxy_computed = require("./proxy-computed.js");
|
|
36
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
37
|
-
0 && (module.exports = {
|
|
38
|
-
clone,
|
|
39
|
-
globalRef,
|
|
40
|
-
proxy,
|
|
41
|
-
proxyWithComputed,
|
|
42
|
-
ref,
|
|
43
|
-
snapshot,
|
|
44
|
-
subscribe
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
45
4
|
});
|
|
5
|
+
const require_clone = require("./clone.js");
|
|
6
|
+
const require_global = require("./global.js");
|
|
7
|
+
const require_proxy = require("./proxy.js");
|
|
8
|
+
const require_proxy_computed = require("./proxy-computed.js");
|
|
9
|
+
exports.clone = require_clone.clone;
|
|
10
|
+
exports.globalRef = require_global.globalRef;
|
|
11
|
+
exports.proxy = require_proxy.proxy;
|
|
12
|
+
exports.proxyWithComputed = require_proxy_computed.proxyWithComputed;
|
|
13
|
+
exports.ref = require_proxy.ref;
|
|
14
|
+
exports.snapshot = require_proxy.snapshot;
|
|
15
|
+
exports.subscribe = require_proxy.subscribe;
|
package/dist/index.mjs
CHANGED
|
@@ -1,14 +1,5 @@
|
|
|
1
|
-
// src/index.ts
|
|
2
1
|
import { clone } from "./clone.mjs";
|
|
3
2
|
import { globalRef } from "./global.mjs";
|
|
4
3
|
import { proxy, ref, snapshot, subscribe } from "./proxy.mjs";
|
|
5
4
|
import { proxyWithComputed } from "./proxy-computed.mjs";
|
|
6
|
-
export {
|
|
7
|
-
clone,
|
|
8
|
-
globalRef,
|
|
9
|
-
proxy,
|
|
10
|
-
proxyWithComputed,
|
|
11
|
-
ref,
|
|
12
|
-
snapshot,
|
|
13
|
-
subscribe
|
|
14
|
-
};
|
|
5
|
+
export { clone, globalRef, proxy, proxyWithComputed, ref, snapshot, subscribe };
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
import { Snapshot } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
set?: ((state: T, newValue: U[K]) => void) | undefined;
|
|
7
|
-
};
|
|
8
|
-
}): T & U;
|
|
9
|
-
|
|
10
|
-
export { proxyWithComputed };
|
|
1
|
+
import { Snapshot } from "./proxy.mjs";
|
|
2
|
+
export declare function proxyWithComputed<T extends object, U extends object>(initialObject: T, computedFns: { [K in keyof U]: ((snap: Snapshot<T>) => U[K]) | {
|
|
3
|
+
get: (snap: Snapshot<T>) => U[K];
|
|
4
|
+
set?: ((state: T, newValue: U[K]) => void) | undefined;
|
|
5
|
+
}; }): T & U;
|
package/dist/proxy-computed.d.ts
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
import { Snapshot } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
set?: ((state: T, newValue: U[K]) => void) | undefined;
|
|
7
|
-
};
|
|
8
|
-
}): T & U;
|
|
9
|
-
|
|
10
|
-
export { proxyWithComputed };
|
|
1
|
+
import { Snapshot } from "./proxy.js";
|
|
2
|
+
export declare function proxyWithComputed<T extends object, U extends object>(initialObject: T, computedFns: { [K in keyof U]: ((snap: Snapshot<T>) => U[K]) | {
|
|
3
|
+
get: (snap: Snapshot<T>) => U[K];
|
|
4
|
+
set?: ((state: T, newValue: U[K]) => void) | undefined;
|
|
5
|
+
}; }): T & U;
|
package/dist/proxy-computed.js
CHANGED
|
@@ -1,48 +1,20 @@
|
|
|
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/proxy-computed.ts
|
|
21
|
-
var proxy_computed_exports = {};
|
|
22
|
-
__export(proxy_computed_exports, {
|
|
23
|
-
proxyWithComputed: () => proxyWithComputed
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
24
4
|
});
|
|
25
|
-
|
|
26
|
-
|
|
5
|
+
const require_proxy = require("./proxy.js");
|
|
6
|
+
// src/proxy-computed.ts
|
|
27
7
|
function proxyWithComputed(initialObject, computedFns) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
Object.defineProperty(initialObject, key, desc);
|
|
41
|
-
});
|
|
42
|
-
const proxyObject = (0, import_proxy.proxy)(initialObject);
|
|
43
|
-
return proxyObject;
|
|
8
|
+
Object.keys(computedFns).forEach((key) => {
|
|
9
|
+
if (Object.getOwnPropertyDescriptor(initialObject, key)) throw new Error("object property already defined");
|
|
10
|
+
const computedFn = computedFns[key];
|
|
11
|
+
const { get, set } = typeof computedFn === "function" ? { get: computedFn } : computedFn;
|
|
12
|
+
const desc = {};
|
|
13
|
+
desc.get = () => get(require_proxy.snapshot(proxyObject));
|
|
14
|
+
if (set) desc.set = (newValue) => set(proxyObject, newValue);
|
|
15
|
+
Object.defineProperty(initialObject, key, desc);
|
|
16
|
+
});
|
|
17
|
+
const proxyObject = require_proxy.proxy(initialObject);
|
|
18
|
+
return proxyObject;
|
|
44
19
|
}
|
|
45
|
-
|
|
46
|
-
0 && (module.exports = {
|
|
47
|
-
proxyWithComputed
|
|
48
|
-
});
|
|
20
|
+
exports.proxyWithComputed = proxyWithComputed;
|
package/dist/proxy-computed.mjs
CHANGED
|
@@ -1,23 +1,16 @@
|
|
|
1
|
-
// src/proxy-computed.ts
|
|
2
1
|
import { proxy, snapshot } from "./proxy.mjs";
|
|
2
|
+
// src/proxy-computed.ts
|
|
3
3
|
function proxyWithComputed(initialObject, computedFns) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
Object.defineProperty(initialObject, key, desc);
|
|
17
|
-
});
|
|
18
|
-
const proxyObject = proxy(initialObject);
|
|
19
|
-
return proxyObject;
|
|
4
|
+
Object.keys(computedFns).forEach((key) => {
|
|
5
|
+
if (Object.getOwnPropertyDescriptor(initialObject, key)) throw new Error("object property already defined");
|
|
6
|
+
const computedFn = computedFns[key];
|
|
7
|
+
const { get, set } = typeof computedFn === "function" ? { get: computedFn } : computedFn;
|
|
8
|
+
const desc = {};
|
|
9
|
+
desc.get = () => get(snapshot(proxyObject));
|
|
10
|
+
if (set) desc.set = (newValue) => set(proxyObject, newValue);
|
|
11
|
+
Object.defineProperty(initialObject, key, desc);
|
|
12
|
+
});
|
|
13
|
+
const proxyObject = proxy(initialObject);
|
|
14
|
+
return proxyObject;
|
|
20
15
|
}
|
|
21
|
-
export {
|
|
22
|
-
proxyWithComputed
|
|
23
|
-
};
|
|
16
|
+
export { proxyWithComputed };
|
package/dist/proxy.d.mts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
type AsRef = {
|
|
2
|
-
|
|
2
|
+
$$valtioRef: true;
|
|
3
3
|
};
|
|
4
4
|
type Path = (string | symbol)[];
|
|
5
5
|
type Op = [op: "set", path: Path, value: unknown, prevValue: unknown] | [op: "delete", path: Path, prevValue: unknown];
|
|
6
|
-
type Snapshot<T> = T;
|
|
7
|
-
declare function proxy<T extends object>(initialObject?: T): T;
|
|
8
|
-
declare function getVersion(proxyObject: unknown): number | undefined;
|
|
9
|
-
declare function subscribe<T extends object>(proxyObject: T, callback: (ops: Op[]) => void, notifyInSync?: boolean): () => void;
|
|
10
|
-
declare function snapshot<T extends object>(proxyObject: T): T;
|
|
11
|
-
declare function ref<T extends object>(obj: T): Ref<T>;
|
|
12
|
-
type Ref<T> = T & AsRef;
|
|
13
|
-
|
|
14
|
-
export { type Ref, type Snapshot, getVersion, proxy, ref, snapshot, subscribe };
|
|
6
|
+
export type Snapshot<T> = T;
|
|
7
|
+
export declare function proxy<T extends object>(initialObject?: T): T;
|
|
8
|
+
export declare function getVersion(proxyObject: unknown): number | undefined;
|
|
9
|
+
export declare function subscribe<T extends object>(proxyObject: T, callback: (ops: Op[]) => void, notifyInSync?: boolean): () => void;
|
|
10
|
+
export declare function snapshot<T extends object>(proxyObject: T): T;
|
|
11
|
+
export declare function ref<T extends object>(obj: T): Ref<T>;
|
|
12
|
+
export type Ref<T> = T & AsRef;
|
|
13
|
+
export {};
|
package/dist/proxy.d.ts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
type AsRef = {
|
|
2
|
-
|
|
2
|
+
$$valtioRef: true;
|
|
3
3
|
};
|
|
4
4
|
type Path = (string | symbol)[];
|
|
5
5
|
type Op = [op: "set", path: Path, value: unknown, prevValue: unknown] | [op: "delete", path: Path, prevValue: unknown];
|
|
6
|
-
type Snapshot<T> = T;
|
|
7
|
-
declare function proxy<T extends object>(initialObject?: T): T;
|
|
8
|
-
declare function getVersion(proxyObject: unknown): number | undefined;
|
|
9
|
-
declare function subscribe<T extends object>(proxyObject: T, callback: (ops: Op[]) => void, notifyInSync?: boolean): () => void;
|
|
10
|
-
declare function snapshot<T extends object>(proxyObject: T): T;
|
|
11
|
-
declare function ref<T extends object>(obj: T): Ref<T>;
|
|
12
|
-
type Ref<T> = T & AsRef;
|
|
13
|
-
|
|
14
|
-
export { type Ref, type Snapshot, getVersion, proxy, ref, snapshot, subscribe };
|
|
6
|
+
export type Snapshot<T> = T;
|
|
7
|
+
export declare function proxy<T extends object>(initialObject?: T): T;
|
|
8
|
+
export declare function getVersion(proxyObject: unknown): number | undefined;
|
|
9
|
+
export declare function subscribe<T extends object>(proxyObject: T, callback: (ops: Op[]) => void, notifyInSync?: boolean): () => void;
|
|
10
|
+
export declare function snapshot<T extends object>(proxyObject: T): T;
|
|
11
|
+
export declare function ref<T extends object>(obj: T): Ref<T>;
|
|
12
|
+
export type Ref<T> = T & AsRef;
|
|
13
|
+
export {};
|