@voidhash/mimic-react 0.0.2 → 0.0.4

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.
Files changed (61) hide show
  1. package/.turbo/turbo-build.log +60 -26
  2. package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/defineProperty.cjs +14 -0
  3. package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/defineProperty.mjs +14 -0
  4. package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/objectSpread2.cjs +27 -0
  5. package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/objectSpread2.mjs +27 -0
  6. package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/toPrimitive.cjs +16 -0
  7. package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/toPrimitive.mjs +16 -0
  8. package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/toPropertyKey.cjs +11 -0
  9. package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/toPropertyKey.mjs +11 -0
  10. package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/typeof.cjs +18 -0
  11. package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/typeof.mjs +12 -0
  12. package/dist/zustand/index.cjs +2 -94
  13. package/dist/zustand/index.d.cts +3 -115
  14. package/dist/zustand/index.d.mts +3 -115
  15. package/dist/zustand/index.mjs +2 -95
  16. package/dist/zustand/middleware.cjs +95 -0
  17. package/dist/zustand/middleware.d.cts +47 -0
  18. package/dist/zustand/middleware.d.cts.map +1 -0
  19. package/dist/zustand/middleware.d.mts +47 -0
  20. package/dist/zustand/middleware.d.mts.map +1 -0
  21. package/dist/zustand/middleware.mjs +96 -0
  22. package/dist/zustand/middleware.mjs.map +1 -0
  23. package/dist/zustand/types.d.cts +75 -0
  24. package/dist/zustand/types.d.cts.map +1 -0
  25. package/dist/zustand/types.d.mts +75 -0
  26. package/dist/zustand/types.d.mts.map +1 -0
  27. package/dist/zustand-commander/commander.cjs +187 -0
  28. package/dist/zustand-commander/commander.d.cts +52 -0
  29. package/dist/zustand-commander/commander.d.cts.map +1 -0
  30. package/dist/zustand-commander/commander.d.mts +52 -0
  31. package/dist/zustand-commander/commander.d.mts.map +1 -0
  32. package/dist/zustand-commander/commander.mjs +185 -0
  33. package/dist/zustand-commander/commander.mjs.map +1 -0
  34. package/dist/zustand-commander/hooks.cjs +145 -0
  35. package/dist/zustand-commander/hooks.d.cts +78 -0
  36. package/dist/zustand-commander/hooks.d.cts.map +1 -0
  37. package/dist/zustand-commander/hooks.d.mts +78 -0
  38. package/dist/zustand-commander/hooks.d.mts.map +1 -0
  39. package/dist/zustand-commander/hooks.mjs +144 -0
  40. package/dist/zustand-commander/hooks.mjs.map +1 -0
  41. package/dist/zustand-commander/index.cjs +15 -354
  42. package/dist/zustand-commander/index.d.cts +4 -313
  43. package/dist/zustand-commander/index.d.mts +4 -313
  44. package/dist/zustand-commander/index.mjs +4 -344
  45. package/dist/zustand-commander/types.cjs +28 -0
  46. package/dist/zustand-commander/types.d.cts +195 -0
  47. package/dist/zustand-commander/types.d.cts.map +1 -0
  48. package/dist/zustand-commander/types.d.mts +195 -0
  49. package/dist/zustand-commander/types.d.mts.map +1 -0
  50. package/dist/zustand-commander/types.mjs +25 -0
  51. package/dist/zustand-commander/types.mjs.map +1 -0
  52. package/package.json +3 -3
  53. package/tsdown.config.ts +1 -1
  54. package/dist/objectSpread2-CIP_6jda.cjs +0 -73
  55. package/dist/objectSpread2-CxTyNSYl.mjs +0 -67
  56. package/dist/zustand/index.d.cts.map +0 -1
  57. package/dist/zustand/index.d.mts.map +0 -1
  58. package/dist/zustand/index.mjs.map +0 -1
  59. package/dist/zustand-commander/index.d.cts.map +0 -1
  60. package/dist/zustand-commander/index.d.mts.map +0 -1
  61. package/dist/zustand-commander/index.mjs.map +0 -1
@@ -1,5 +1,5 @@
1
1
 
2
- > @voidhash/mimic-react@0.0.2 build /home/runner/work/mimic/mimic/packages/mimic-react
2
+ > @voidhash/mimic-react@0.0.4 build /home/runner/work/mimic/mimic/packages/mimic-react
3
3
  > tsdown
4
4
 
5
5
  ℹ tsdown v0.18.2 powered by rolldown v1.0.0-beta.55
@@ -8,28 +8,62 @@
8
8
  ℹ target: es2017
9
9
  ℹ tsconfig: tsconfig.json
10
10
  ℹ Build start
11
- ℹ [CJS] dist/zustand-commander/index.cjs 10.02 kB │ gzip: 2.67 kB
12
- ℹ [CJS] dist/zustand/index.cjs  3.02 kB │ gzip: 1.09 kB
13
- ℹ [CJS] dist/index.cjs  0.00 kB │ gzip: 0.02 kB
14
- ℹ [CJS] dist/objectSpread2-CIP_6jda.cjs  2.23 kB │ gzip: 0.80 kB
15
- ℹ [CJS] 4 files, total: 15.27 kB
16
- ℹ [CJS] dist/zustand-commander/index.d.cts.map  5.29 kB │ gzip: 2.15 kB
17
- ℹ [CJS] dist/zustand/index.d.cts.map  1.86 kB │ gzip: 0.82 kB
18
- ℹ [CJS] dist/zustand-commander/index.d.cts 10.95 kB │ gzip: 3.00 kB
19
- ℹ [CJS] dist/zustand/index.d.cts  5.01 kB │ gzip: 1.46 kB
20
- ℹ [CJS] dist/index.d.cts  0.01 kB │ gzip: 0.03 kB
21
- ℹ [CJS] 5 files, total: 23.13 kB
22
- ✔ Build complete in 3864ms
23
- ℹ [ESM] dist/zustand-commander/index.mjs  9.40 kB │ gzip: 2.63 kB
24
- ℹ [ESM] dist/zustand/index.mjs  2.96 kB │ gzip: 1.11 kB
25
- ℹ [ESM] dist/index.mjs  0.01 kB │ gzip: 0.03 kB
26
- ℹ [ESM] dist/zustand-commander/index.mjs.map 30.61 kB │ gzip: 7.03 kB
27
- ℹ [ESM] dist/zustand/index.mjs.map  6.71 kB │ gzip: 2.09 kB
28
- ℹ [ESM] dist/zustand-commander/index.d.mts.map  5.29 kB │ gzip: 2.15 kB
29
- ℹ [ESM] dist/objectSpread2-CxTyNSYl.mjs  2.13 kB │ gzip: 0.77 kB
30
- ℹ [ESM] dist/zustand/index.d.mts.map  1.86 kB │ gzip: 0.82 kB
31
- ℹ [ESM] dist/zustand-commander/index.d.mts 10.95 kB │ gzip: 3.00 kB
32
- ℹ [ESM] dist/zustand/index.d.mts  5.01 kB │ gzip: 1.46 kB
33
- ℹ [ESM] dist/index.d.mts  0.01 kB │ gzip: 0.03 kB
34
- ℹ [ESM] 11 files, total: 74.95 kB
35
- ✔ Build complete in 3868ms
11
+ ℹ [CJS] dist/zustand-commander/index.cjs 0.78 kB │ gzip: 0.24 kB
12
+ ℹ [CJS] dist/zustand/index.cjs 0.10 kB │ gzip: 0.08 kB
13
+ ℹ [CJS] dist/index.cjs 0.00 kB │ gzip: 0.02 kB
14
+ ℹ [CJS] dist/zustand-commander/commander.cjs 5.39 kB │ gzip: 1.54 kB
15
+ ℹ [CJS] dist/zustand-commander/hooks.cjs 4.18 kB │ gzip: 1.46 kB
16
+ ℹ [CJS] dist/zustand/middleware.cjs 3.06 kB │ gzip: 1.12 kB
17
+ ℹ [CJS] dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/objectSpread2.cjs 0.95 kB │ gzip: 0.43 kB
18
+ ℹ [CJS] dist/zustand-commander/types.cjs 0.91 kB │ gzip: 0.34 kB
19
+ ℹ [CJS] dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/typeof.cjs 0.53 kB │ gzip: 0.29 kB
20
+ ℹ [CJS] dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/toPrimitive.cjs 0.52 kB │ gzip: 0.32 kB
21
+ ℹ [CJS] dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/defineProperty.cjs 0.40 kB │ gzip: 0.24 kB
22
+ ℹ [CJS] dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/toPropertyKey.cjs 0.37 kB │ gzip: 0.23 kB
23
+ ℹ [CJS] 12 files, total: 17.16 kB
24
+ ℹ [CJS] dist/zustand-commander/types.d.cts.map 2.75 kB │ gzip: 1.17 kB
25
+ ℹ [CJS] dist/zustand/types.d.cts.map 1.24 kB │ gzip: 0.59 kB
26
+ ℹ [CJS] dist/zustand-commander/hooks.d.cts.map 0.48 kB │ gzip: 0.30 kB
27
+ ℹ [CJS] dist/zustand/middleware.d.cts.map 0.38 kB │ gzip: 0.23 kB
28
+ ℹ [CJS] dist/zustand-commander/commander.d.cts.map 0.30 kB │ gzip: 0.20 kB
29
+ ℹ [CJS] dist/zustand-commander/index.d.cts 1.14 kB │ gzip: 0.36 kB
30
+ ℹ [CJS] dist/zustand/index.d.cts 0.24 kB │ gzip: 0.14 kB
31
+ ℹ [CJS] dist/index.d.cts 0.01 kB │ gzip: 0.03 kB
32
+ ℹ [CJS] dist/zustand-commander/types.d.cts 7.04 kB │ gzip: 2.06 kB
33
+ ℹ [CJS] dist/zustand/types.d.cts 3.15 kB │ gzip: 1.02 kB
34
+ ℹ [CJS] dist/zustand-commander/hooks.d.cts 2.52 kB │ gzip: 0.89 kB
35
+ ℹ [CJS] dist/zustand/middleware.d.cts 2.13 kB │ gzip: 0.85 kB
36
+ ℹ [CJS] dist/zustand-commander/commander.d.cts 1.63 kB │ gzip: 0.64 kB
37
+ ℹ [CJS] 13 files, total: 23.02 kB
38
+ ✔ Build complete in 3809ms
39
+ ℹ [ESM] dist/zustand-commander/index.mjs  0.47 kB │ gzip: 0.20 kB
40
+ ℹ [ESM] dist/zustand/index.mjs  0.06 kB │ gzip: 0.07 kB
41
+ ℹ [ESM] dist/index.mjs  0.01 kB │ gzip: 0.03 kB
42
+ ℹ [ESM] dist/zustand-commander/commander.mjs.map 11.46 kB │ gzip: 3.08 kB
43
+ ℹ [ESM] dist/zustand-commander/types.mjs.map 10.16 kB │ gzip: 2.60 kB
44
+ ℹ [ESM] dist/zustand-commander/hooks.mjs.map  9.15 kB │ gzip: 2.82 kB
45
+ ℹ [ESM] dist/zustand/middleware.mjs.map  6.72 kB │ gzip: 2.09 kB
46
+ ℹ [ESM] dist/zustand-commander/commander.mjs  5.05 kB │ gzip: 1.54 kB
47
+ ℹ [ESM] dist/zustand-commander/hooks.mjs  3.95 kB │ gzip: 1.46 kB
48
+ ℹ [ESM] dist/zustand/middleware.mjs  3.00 kB │ gzip: 1.13 kB
49
+ ℹ [ESM] dist/zustand-commander/types.d.mts.map  2.75 kB │ gzip: 1.17 kB
50
+ ℹ [ESM] dist/zustand/types.d.mts.map  1.24 kB │ gzip: 0.59 kB
51
+ ℹ [ESM] dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/objectSpread2.mjs  0.90 kB │ gzip: 0.42 kB
52
+ ℹ [ESM] dist/zustand-commander/types.mjs  0.84 kB │ gzip: 0.35 kB
53
+ ℹ [ESM] dist/zustand-commander/hooks.d.mts.map  0.48 kB │ gzip: 0.30 kB
54
+ ℹ [ESM] dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/toPrimitive.mjs  0.47 kB │ gzip: 0.30 kB
55
+ ℹ [ESM] dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/typeof.mjs  0.43 kB │ gzip: 0.24 kB
56
+ ℹ [ESM] dist/zustand/middleware.d.mts.map  0.38 kB │ gzip: 0.23 kB
57
+ ℹ [ESM] dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/defineProperty.mjs  0.35 kB │ gzip: 0.23 kB
58
+ ℹ [ESM] dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/toPropertyKey.mjs  0.30 kB │ gzip: 0.21 kB
59
+ ℹ [ESM] dist/zustand-commander/commander.d.mts.map  0.30 kB │ gzip: 0.20 kB
60
+ ℹ [ESM] dist/zustand-commander/index.d.mts  1.14 kB │ gzip: 0.36 kB
61
+ ℹ [ESM] dist/zustand/index.d.mts  0.24 kB │ gzip: 0.14 kB
62
+ ℹ [ESM] dist/index.d.mts  0.01 kB │ gzip: 0.03 kB
63
+ ℹ [ESM] dist/zustand-commander/types.d.mts  7.04 kB │ gzip: 2.06 kB
64
+ ℹ [ESM] dist/zustand/types.d.mts  3.15 kB │ gzip: 1.02 kB
65
+ ℹ [ESM] dist/zustand-commander/hooks.d.mts  2.52 kB │ gzip: 0.89 kB
66
+ ℹ [ESM] dist/zustand/middleware.d.mts  2.13 kB │ gzip: 0.85 kB
67
+ ℹ [ESM] dist/zustand-commander/commander.d.mts  1.63 kB │ gzip: 0.64 kB
68
+ ℹ [ESM] 29 files, total: 76.37 kB
69
+ ✔ Build complete in 3817ms
@@ -0,0 +1,14 @@
1
+ const require_toPropertyKey = require('./toPropertyKey.cjs');
2
+
3
+ //#region \0@oxc-project+runtime@0.103.0/helpers/defineProperty.js
4
+ function _defineProperty(e, r, t) {
5
+ return (r = require_toPropertyKey.toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
6
+ value: t,
7
+ enumerable: !0,
8
+ configurable: !0,
9
+ writable: !0
10
+ }) : e[r] = t, e;
11
+ }
12
+
13
+ //#endregion
14
+ exports._defineProperty = _defineProperty;
@@ -0,0 +1,14 @@
1
+ import { toPropertyKey } from "./toPropertyKey.mjs";
2
+
3
+ //#region \0@oxc-project+runtime@0.103.0/helpers/defineProperty.js
4
+ function _defineProperty(e, r, t) {
5
+ return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
6
+ value: t,
7
+ enumerable: !0,
8
+ configurable: !0,
9
+ writable: !0
10
+ }) : e[r] = t, e;
11
+ }
12
+
13
+ //#endregion
14
+ export { _defineProperty };
@@ -0,0 +1,27 @@
1
+ const require_defineProperty = require('./defineProperty.cjs');
2
+
3
+ //#region \0@oxc-project+runtime@0.103.0/helpers/objectSpread2.js
4
+ function ownKeys(e, r) {
5
+ var t = Object.keys(e);
6
+ if (Object.getOwnPropertySymbols) {
7
+ var o = Object.getOwnPropertySymbols(e);
8
+ r && (o = o.filter(function(r$1) {
9
+ return Object.getOwnPropertyDescriptor(e, r$1).enumerable;
10
+ })), t.push.apply(t, o);
11
+ }
12
+ return t;
13
+ }
14
+ function _objectSpread2(e) {
15
+ for (var r = 1; r < arguments.length; r++) {
16
+ var t = null != arguments[r] ? arguments[r] : {};
17
+ r % 2 ? ownKeys(Object(t), !0).forEach(function(r$1) {
18
+ require_defineProperty._defineProperty(e, r$1, t[r$1]);
19
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r$1) {
20
+ Object.defineProperty(e, r$1, Object.getOwnPropertyDescriptor(t, r$1));
21
+ });
22
+ }
23
+ return e;
24
+ }
25
+
26
+ //#endregion
27
+ exports._objectSpread2 = _objectSpread2;
@@ -0,0 +1,27 @@
1
+ import { _defineProperty } from "./defineProperty.mjs";
2
+
3
+ //#region \0@oxc-project+runtime@0.103.0/helpers/objectSpread2.js
4
+ function ownKeys(e, r) {
5
+ var t = Object.keys(e);
6
+ if (Object.getOwnPropertySymbols) {
7
+ var o = Object.getOwnPropertySymbols(e);
8
+ r && (o = o.filter(function(r$1) {
9
+ return Object.getOwnPropertyDescriptor(e, r$1).enumerable;
10
+ })), t.push.apply(t, o);
11
+ }
12
+ return t;
13
+ }
14
+ function _objectSpread2(e) {
15
+ for (var r = 1; r < arguments.length; r++) {
16
+ var t = null != arguments[r] ? arguments[r] : {};
17
+ r % 2 ? ownKeys(Object(t), !0).forEach(function(r$1) {
18
+ _defineProperty(e, r$1, t[r$1]);
19
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r$1) {
20
+ Object.defineProperty(e, r$1, Object.getOwnPropertyDescriptor(t, r$1));
21
+ });
22
+ }
23
+ return e;
24
+ }
25
+
26
+ //#endregion
27
+ export { _objectSpread2 };
@@ -0,0 +1,16 @@
1
+ const require_typeof = require('./typeof.cjs');
2
+
3
+ //#region \0@oxc-project+runtime@0.103.0/helpers/toPrimitive.js
4
+ function toPrimitive(t, r) {
5
+ if ("object" != require_typeof._typeof(t) || !t) return t;
6
+ var e = t[Symbol.toPrimitive];
7
+ if (void 0 !== e) {
8
+ var i = e.call(t, r || "default");
9
+ if ("object" != require_typeof._typeof(i)) return i;
10
+ throw new TypeError("@@toPrimitive must return a primitive value.");
11
+ }
12
+ return ("string" === r ? String : Number)(t);
13
+ }
14
+
15
+ //#endregion
16
+ exports.toPrimitive = toPrimitive;
@@ -0,0 +1,16 @@
1
+ import { _typeof } from "./typeof.mjs";
2
+
3
+ //#region \0@oxc-project+runtime@0.103.0/helpers/toPrimitive.js
4
+ function toPrimitive(t, r) {
5
+ if ("object" != _typeof(t) || !t) return t;
6
+ var e = t[Symbol.toPrimitive];
7
+ if (void 0 !== e) {
8
+ var i = e.call(t, r || "default");
9
+ if ("object" != _typeof(i)) return i;
10
+ throw new TypeError("@@toPrimitive must return a primitive value.");
11
+ }
12
+ return ("string" === r ? String : Number)(t);
13
+ }
14
+
15
+ //#endregion
16
+ export { toPrimitive };
@@ -0,0 +1,11 @@
1
+ const require_typeof = require('./typeof.cjs');
2
+ const require_toPrimitive = require('./toPrimitive.cjs');
3
+
4
+ //#region \0@oxc-project+runtime@0.103.0/helpers/toPropertyKey.js
5
+ function toPropertyKey(t) {
6
+ var i = require_toPrimitive.toPrimitive(t, "string");
7
+ return "symbol" == require_typeof._typeof(i) ? i : i + "";
8
+ }
9
+
10
+ //#endregion
11
+ exports.toPropertyKey = toPropertyKey;
@@ -0,0 +1,11 @@
1
+ import { _typeof } from "./typeof.mjs";
2
+ import { toPrimitive } from "./toPrimitive.mjs";
3
+
4
+ //#region \0@oxc-project+runtime@0.103.0/helpers/toPropertyKey.js
5
+ function toPropertyKey(t) {
6
+ var i = toPrimitive(t, "string");
7
+ return "symbol" == _typeof(i) ? i : i + "";
8
+ }
9
+
10
+ //#endregion
11
+ export { toPropertyKey };
@@ -0,0 +1,18 @@
1
+
2
+ //#region \0@oxc-project+runtime@0.103.0/helpers/typeof.js
3
+ function _typeof(o) {
4
+ "@babel/helpers - typeof";
5
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) {
6
+ return typeof o$1;
7
+ } : function(o$1) {
8
+ return o$1 && "function" == typeof Symbol && o$1.constructor === Symbol && o$1 !== Symbol.prototype ? "symbol" : typeof o$1;
9
+ }, _typeof(o);
10
+ }
11
+
12
+ //#endregion
13
+ Object.defineProperty(exports, '_typeof', {
14
+ enumerable: true,
15
+ get: function () {
16
+ return _typeof;
17
+ }
18
+ });
@@ -0,0 +1,12 @@
1
+ //#region \0@oxc-project+runtime@0.103.0/helpers/typeof.js
2
+ function _typeof(o) {
3
+ "@babel/helpers - typeof";
4
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) {
5
+ return typeof o$1;
6
+ } : function(o$1) {
7
+ return o$1 && "function" == typeof Symbol && o$1.constructor === Symbol && o$1 !== Symbol.prototype ? "symbol" : typeof o$1;
8
+ }, _typeof(o);
9
+ }
10
+
11
+ //#endregion
12
+ export { _typeof };
@@ -1,95 +1,3 @@
1
- const require_objectSpread2 = require('../objectSpread2-CIP_6jda.cjs');
1
+ const require_middleware = require('./middleware.cjs');
2
2
 
3
- //#region src/zustand/middleware.ts
4
- /**
5
- * Creates a MimicObject from the current document state.
6
- */
7
- const createMimicObject = (document) => {
8
- const presence = document.presence ? {
9
- selfId: document.presence.selfId(),
10
- self: document.presence.self(),
11
- others: new Map(document.presence.others()),
12
- all: new Map(document.presence.all())
13
- } : void 0;
14
- return {
15
- document,
16
- snapshot: document.root.toSnapshot(),
17
- presence,
18
- isConnected: document.isConnected(),
19
- isReady: document.isReady(),
20
- pendingCount: document.getPendingCount(),
21
- hasPendingChanges: document.hasPendingChanges()
22
- };
23
- };
24
- /**
25
- * Implementation of the mimic middleware.
26
- */
27
- const mimicImpl = (document, config, options = {}) => {
28
- const { autoSubscribe = true, autoConnect = true } = options;
29
- return (set, get, api) => {
30
- const initialMimic = createMimicObject(document);
31
- const updateMimicState = () => {
32
- const newMimic = createMimicObject(document);
33
- set((state) => require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, state), {}, { mimic: newMimic }), false);
34
- };
35
- if (autoSubscribe) {
36
- var _document$presence;
37
- document.subscribe({
38
- onStateChange: () => {
39
- updateMimicState();
40
- },
41
- onConnectionChange: () => {
42
- updateMimicState();
43
- },
44
- onReady: () => {
45
- updateMimicState();
46
- }
47
- });
48
- (_document$presence = document.presence) === null || _document$presence === void 0 || _document$presence.subscribe({ onPresenceChange: () => {
49
- updateMimicState();
50
- } });
51
- }
52
- if (autoConnect) document.connect();
53
- return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, config(set, get, api)), {}, { mimic: initialMimic });
54
- };
55
- };
56
- /**
57
- * Zustand middleware that integrates a ClientDocument.
58
- *
59
- * Adds a `mimic` object to the store containing:
60
- * - `document`: The ClientDocument instance for performing transactions
61
- * - `snapshot`: Read-only snapshot of the document state (reactive)
62
- * - `presence`: Reactive presence snapshot (self + others). Undefined if presence is not enabled on the ClientDocument.
63
- * - `isConnected`: Connection status
64
- * - `isReady`: Ready status
65
- * - `pendingCount`: Number of pending transactions
66
- * - `hasPendingChanges`: Whether there are pending changes
67
- *
68
- * @example
69
- * ```ts
70
- * import { create } from 'zustand'
71
- * import { mimic } from '@voidhash/mimic-react/zustand'
72
- *
73
- * const useStore = create(
74
- * mimic(clientDocument, (set, get) => ({
75
- * // Your additional store state
76
- * }))
77
- * )
78
- *
79
- * // Read snapshot (reactive)
80
- * const snapshot = useStore(state => state.mimic.snapshot)
81
- *
82
- * // Read presence (reactive, if enabled)
83
- * const myPresence = useStore(state => state.mimic.presence?.self)
84
- * const othersPresence = useStore(state => state.mimic.presence?.others)
85
- *
86
- * // Write via document
87
- * store.getState().mimic.document.transaction(root => {
88
- * root.name.set("New Name")
89
- * })
90
- * ```
91
- */
92
- const mimic = mimicImpl;
93
-
94
- //#endregion
95
- exports.mimic = mimic;
3
+ exports.mimic = require_middleware.mimic;
@@ -1,115 +1,3 @@
1
- import { StateCreator, StoreMutatorIdentifier } from "zustand";
2
- import { ClientDocument } from "@voidhash/mimic/client";
3
- import { Presence, Primitive } from "@voidhash/mimic";
4
-
5
- //#region src/zustand/types.d.ts
6
-
7
- /**
8
- * Presence data exposed on the zustand store (reactive snapshot).
9
- */
10
- interface MimicPresence<TPresence extends Presence.AnyPresence> {
11
- /**
12
- * This client's connection ID (set after receiving presence snapshot).
13
- * Undefined before the snapshot is received.
14
- */
15
- readonly selfId: string | undefined;
16
- /**
17
- * This client's current presence data.
18
- * Undefined if not set.
19
- */
20
- readonly self: Presence.Infer<TPresence> | undefined;
21
- /**
22
- * Other clients' presence entries (connectionId -> entry).
23
- */
24
- readonly others: ReadonlyMap<string, Presence.PresenceEntry<Presence.Infer<TPresence>>>;
25
- /**
26
- * All presence entries including self (connectionId -> entry).
27
- */
28
- readonly all: ReadonlyMap<string, Presence.PresenceEntry<Presence.Infer<TPresence>>>;
29
- }
30
- /**
31
- * The mimic object containing the document and client state.
32
- * This is added to the zustand store by the middleware.
33
- */
34
- interface MimicObject<TSchema extends Primitive.AnyPrimitive, TPresence extends Presence.AnyPresence | undefined = undefined> {
35
- /** The ClientDocument instance for performing transactions */
36
- readonly document: ClientDocument.ClientDocument<TSchema, TPresence>;
37
- /** Read-only snapshot of the document state */
38
- readonly snapshot: Primitive.InferSnapshot<TSchema>;
39
- /**
40
- * Reactive presence snapshot (self + others).
41
- * Undefined when the ClientDocument was created without a presence schema.
42
- */
43
- readonly presence: TPresence extends Presence.AnyPresence ? MimicPresence<TPresence> : undefined;
44
- /** Whether the client is connected to the server */
45
- readonly isConnected: boolean;
46
- /** Whether the client is fully initialized and ready */
47
- readonly isReady: boolean;
48
- /** Number of pending transactions */
49
- readonly pendingCount: number;
50
- /** Whether there are pending changes */
51
- readonly hasPendingChanges: boolean;
52
- }
53
- /**
54
- * The state slice added by the mimic middleware.
55
- */
56
- interface MimicSlice<TSchema extends Primitive.AnyPrimitive, TPresence extends Presence.AnyPresence | undefined = undefined> {
57
- /** The mimic object containing document and state */
58
- readonly mimic: MimicObject<TSchema, TPresence>;
59
- }
60
- /**
61
- * Type for state creator with mimic slice merged.
62
- */
63
- type MimicStateCreator<TSchema extends Primitive.AnyPrimitive, TPresence extends Presence.AnyPresence | undefined, T, Mps extends [StoreMutatorIdentifier, unknown][] = [], Mcs extends [StoreMutatorIdentifier, unknown][] = []> = StateCreator<T & MimicSlice<TSchema, TPresence>, Mps, Mcs, T>;
64
- /**
65
- * Options for the mimic middleware.
66
- */
67
- interface MimicMiddlewareOptions {
68
- /** If true, automatically subscribe when store is created (default: true) */
69
- readonly autoSubscribe?: boolean;
70
- /** If true, automatically attempt to connect the document to the remote server */
71
- readonly autoConnect?: boolean;
72
- }
73
- //#endregion
74
- //#region src/zustand/middleware.d.ts
75
- type MimicMiddleware = <TSchema extends Primitive.AnyPrimitive, TPresence extends Presence.AnyPresence | undefined = undefined, T extends object = object, Mps extends [StoreMutatorIdentifier, unknown][] = [], Mcs extends [StoreMutatorIdentifier, unknown][] = []>(document: ClientDocument.ClientDocument<TSchema, TPresence>, config: StateCreator<T & MimicSlice<TSchema, TPresence>, Mps, Mcs, T>, options?: MimicMiddlewareOptions) => StateCreator<T & MimicSlice<TSchema, TPresence>, Mps, Mcs, T & MimicSlice<TSchema, TPresence>>;
76
- /**
77
- * Zustand middleware that integrates a ClientDocument.
78
- *
79
- * Adds a `mimic` object to the store containing:
80
- * - `document`: The ClientDocument instance for performing transactions
81
- * - `snapshot`: Read-only snapshot of the document state (reactive)
82
- * - `presence`: Reactive presence snapshot (self + others). Undefined if presence is not enabled on the ClientDocument.
83
- * - `isConnected`: Connection status
84
- * - `isReady`: Ready status
85
- * - `pendingCount`: Number of pending transactions
86
- * - `hasPendingChanges`: Whether there are pending changes
87
- *
88
- * @example
89
- * ```ts
90
- * import { create } from 'zustand'
91
- * import { mimic } from '@voidhash/mimic-react/zustand'
92
- *
93
- * const useStore = create(
94
- * mimic(clientDocument, (set, get) => ({
95
- * // Your additional store state
96
- * }))
97
- * )
98
- *
99
- * // Read snapshot (reactive)
100
- * const snapshot = useStore(state => state.mimic.snapshot)
101
- *
102
- * // Read presence (reactive, if enabled)
103
- * const myPresence = useStore(state => state.mimic.presence?.self)
104
- * const othersPresence = useStore(state => state.mimic.presence?.others)
105
- *
106
- * // Write via document
107
- * store.getState().mimic.document.transaction(root => {
108
- * root.name.set("New Name")
109
- * })
110
- * ```
111
- */
112
- declare const mimic: MimicMiddleware;
113
- //#endregion
114
- export { type MimicMiddlewareOptions, type MimicObject, type MimicSlice, type MimicStateCreator, mimic };
115
- //# sourceMappingURL=index.d.cts.map
1
+ import { MimicMiddlewareOptions, MimicObject, MimicSlice, MimicStateCreator } from "./types.cjs";
2
+ import { mimic } from "./middleware.cjs";
3
+ export { type MimicMiddlewareOptions, type MimicObject, type MimicSlice, type MimicStateCreator, mimic };
@@ -1,115 +1,3 @@
1
- import { StateCreator, StoreMutatorIdentifier } from "zustand";
2
- import { ClientDocument } from "@voidhash/mimic/client";
3
- import { Presence, Primitive } from "@voidhash/mimic";
4
-
5
- //#region src/zustand/types.d.ts
6
-
7
- /**
8
- * Presence data exposed on the zustand store (reactive snapshot).
9
- */
10
- interface MimicPresence<TPresence extends Presence.AnyPresence> {
11
- /**
12
- * This client's connection ID (set after receiving presence snapshot).
13
- * Undefined before the snapshot is received.
14
- */
15
- readonly selfId: string | undefined;
16
- /**
17
- * This client's current presence data.
18
- * Undefined if not set.
19
- */
20
- readonly self: Presence.Infer<TPresence> | undefined;
21
- /**
22
- * Other clients' presence entries (connectionId -> entry).
23
- */
24
- readonly others: ReadonlyMap<string, Presence.PresenceEntry<Presence.Infer<TPresence>>>;
25
- /**
26
- * All presence entries including self (connectionId -> entry).
27
- */
28
- readonly all: ReadonlyMap<string, Presence.PresenceEntry<Presence.Infer<TPresence>>>;
29
- }
30
- /**
31
- * The mimic object containing the document and client state.
32
- * This is added to the zustand store by the middleware.
33
- */
34
- interface MimicObject<TSchema extends Primitive.AnyPrimitive, TPresence extends Presence.AnyPresence | undefined = undefined> {
35
- /** The ClientDocument instance for performing transactions */
36
- readonly document: ClientDocument.ClientDocument<TSchema, TPresence>;
37
- /** Read-only snapshot of the document state */
38
- readonly snapshot: Primitive.InferSnapshot<TSchema>;
39
- /**
40
- * Reactive presence snapshot (self + others).
41
- * Undefined when the ClientDocument was created without a presence schema.
42
- */
43
- readonly presence: TPresence extends Presence.AnyPresence ? MimicPresence<TPresence> : undefined;
44
- /** Whether the client is connected to the server */
45
- readonly isConnected: boolean;
46
- /** Whether the client is fully initialized and ready */
47
- readonly isReady: boolean;
48
- /** Number of pending transactions */
49
- readonly pendingCount: number;
50
- /** Whether there are pending changes */
51
- readonly hasPendingChanges: boolean;
52
- }
53
- /**
54
- * The state slice added by the mimic middleware.
55
- */
56
- interface MimicSlice<TSchema extends Primitive.AnyPrimitive, TPresence extends Presence.AnyPresence | undefined = undefined> {
57
- /** The mimic object containing document and state */
58
- readonly mimic: MimicObject<TSchema, TPresence>;
59
- }
60
- /**
61
- * Type for state creator with mimic slice merged.
62
- */
63
- type MimicStateCreator<TSchema extends Primitive.AnyPrimitive, TPresence extends Presence.AnyPresence | undefined, T, Mps extends [StoreMutatorIdentifier, unknown][] = [], Mcs extends [StoreMutatorIdentifier, unknown][] = []> = StateCreator<T & MimicSlice<TSchema, TPresence>, Mps, Mcs, T>;
64
- /**
65
- * Options for the mimic middleware.
66
- */
67
- interface MimicMiddlewareOptions {
68
- /** If true, automatically subscribe when store is created (default: true) */
69
- readonly autoSubscribe?: boolean;
70
- /** If true, automatically attempt to connect the document to the remote server */
71
- readonly autoConnect?: boolean;
72
- }
73
- //#endregion
74
- //#region src/zustand/middleware.d.ts
75
- type MimicMiddleware = <TSchema extends Primitive.AnyPrimitive, TPresence extends Presence.AnyPresence | undefined = undefined, T extends object = object, Mps extends [StoreMutatorIdentifier, unknown][] = [], Mcs extends [StoreMutatorIdentifier, unknown][] = []>(document: ClientDocument.ClientDocument<TSchema, TPresence>, config: StateCreator<T & MimicSlice<TSchema, TPresence>, Mps, Mcs, T>, options?: MimicMiddlewareOptions) => StateCreator<T & MimicSlice<TSchema, TPresence>, Mps, Mcs, T & MimicSlice<TSchema, TPresence>>;
76
- /**
77
- * Zustand middleware that integrates a ClientDocument.
78
- *
79
- * Adds a `mimic` object to the store containing:
80
- * - `document`: The ClientDocument instance for performing transactions
81
- * - `snapshot`: Read-only snapshot of the document state (reactive)
82
- * - `presence`: Reactive presence snapshot (self + others). Undefined if presence is not enabled on the ClientDocument.
83
- * - `isConnected`: Connection status
84
- * - `isReady`: Ready status
85
- * - `pendingCount`: Number of pending transactions
86
- * - `hasPendingChanges`: Whether there are pending changes
87
- *
88
- * @example
89
- * ```ts
90
- * import { create } from 'zustand'
91
- * import { mimic } from '@voidhash/mimic-react/zustand'
92
- *
93
- * const useStore = create(
94
- * mimic(clientDocument, (set, get) => ({
95
- * // Your additional store state
96
- * }))
97
- * )
98
- *
99
- * // Read snapshot (reactive)
100
- * const snapshot = useStore(state => state.mimic.snapshot)
101
- *
102
- * // Read presence (reactive, if enabled)
103
- * const myPresence = useStore(state => state.mimic.presence?.self)
104
- * const othersPresence = useStore(state => state.mimic.presence?.others)
105
- *
106
- * // Write via document
107
- * store.getState().mimic.document.transaction(root => {
108
- * root.name.set("New Name")
109
- * })
110
- * ```
111
- */
112
- declare const mimic: MimicMiddleware;
113
- //#endregion
114
- export { type MimicMiddlewareOptions, type MimicObject, type MimicSlice, type MimicStateCreator, mimic };
115
- //# sourceMappingURL=index.d.mts.map
1
+ import { MimicMiddlewareOptions, MimicObject, MimicSlice, MimicStateCreator } from "./types.mjs";
2
+ import { mimic } from "./middleware.mjs";
3
+ export { type MimicMiddlewareOptions, type MimicObject, type MimicSlice, type MimicStateCreator, mimic };