@afterrealism/dendri-client 2.4.0 → 2.6.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.
Files changed (44) hide show
  1. package/README.md +35 -18
  2. package/dist/chunk-G3PMV62Z.js +33 -0
  3. package/dist/chunk-G3PMV62Z.js.map +1 -0
  4. package/dist/{chunk-MBMSG4EC.js → chunk-YLWDCKUW.js} +73 -44
  5. package/dist/chunk-YLWDCKUW.js.map +1 -0
  6. package/dist/dendri.browser.global.js +70 -13
  7. package/dist/dendri.browser.global.js.map +1 -1
  8. package/dist/dendri.cjs +70 -13
  9. package/dist/dendri.cjs.map +1 -1
  10. package/dist/dendri.d.cts +13 -4
  11. package/dist/dendri.d.ts +13 -4
  12. package/dist/dendri.js +3 -2
  13. package/dist/dendri.js.map +1 -1
  14. package/dist/dendri.min.global.js +7 -7
  15. package/dist/dendri.min.global.js.map +1 -1
  16. package/dist/react.cjs +16 -0
  17. package/dist/react.cjs.map +1 -0
  18. package/dist/react.d.cts +25 -0
  19. package/dist/react.d.ts +25 -0
  20. package/dist/react.js +14 -0
  21. package/dist/react.js.map +1 -0
  22. package/dist/serializer.msgpack.d.cts +14 -0
  23. package/dist/serializer.msgpack.d.ts +14 -0
  24. package/dist/{store-DVE0ih44.d.cts → store-C3Nwl62R.d.cts} +14 -0
  25. package/dist/{store-DVE0ih44.d.ts → store-C3Nwl62R.d.ts} +14 -0
  26. package/dist/store.cjs +70 -13
  27. package/dist/store.cjs.map +1 -1
  28. package/dist/store.d.cts +1 -1
  29. package/dist/store.d.ts +1 -1
  30. package/dist/store.js +2 -1
  31. package/dist/svelte.cjs +15 -0
  32. package/dist/svelte.cjs.map +1 -0
  33. package/dist/svelte.d.cts +29 -0
  34. package/dist/svelte.d.ts +29 -0
  35. package/dist/svelte.js +15 -0
  36. package/dist/svelte.js.map +1 -0
  37. package/dist/vue.cjs +19 -0
  38. package/dist/vue.cjs.map +1 -0
  39. package/dist/vue.d.cts +25 -0
  40. package/dist/vue.d.ts +25 -0
  41. package/dist/vue.js +17 -0
  42. package/dist/vue.js.map +1 -0
  43. package/package.json +49 -2
  44. package/dist/chunk-MBMSG4EC.js.map +0 -1
package/dist/store.d.cts CHANGED
@@ -1,2 +1,2 @@
1
- export { V as CreateDendriStoreInput, n as DendriStore, o as DendriStoreOptions, p as DendriStoreSnapshot, J as StoreListener, O as createDendriStore } from './store-DVE0ih44.cjs';
1
+ export { V as CreateDendriStoreInput, n as DendriStore, o as DendriStoreOptions, p as DendriStoreSnapshot, J as StoreListener, O as createDendriStore } from './store-C3Nwl62R.cjs';
2
2
  import 'eventemitter3';
package/dist/store.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { V as CreateDendriStoreInput, n as DendriStore, o as DendriStoreOptions, p as DendriStoreSnapshot, J as StoreListener, O as createDendriStore } from './store-DVE0ih44.js';
1
+ export { V as CreateDendriStoreInput, n as DendriStore, o as DendriStoreOptions, p as DendriStoreSnapshot, J as StoreListener, O as createDendriStore } from './store-C3Nwl62R.js';
2
2
  import 'eventemitter3';
package/dist/store.js CHANGED
@@ -1,3 +1,4 @@
1
- export { createDendriStore } from './chunk-MBMSG4EC.js';
1
+ export { createDendriStore } from './chunk-YLWDCKUW.js';
2
+ import './chunk-G3PMV62Z.js';
2
3
  //# sourceMappingURL=store.js.map
3
4
  //# sourceMappingURL=store.js.map
@@ -0,0 +1,15 @@
1
+ 'use strict';
2
+
3
+ // src/adapters/svelte.ts
4
+ function toSvelteStore(store) {
5
+ return {
6
+ subscribe(run) {
7
+ run(store.getSnapshot());
8
+ return store.subscribe(() => run(store.getSnapshot()));
9
+ }
10
+ };
11
+ }
12
+
13
+ exports.toSvelteStore = toSvelteStore;
14
+ //# sourceMappingURL=svelte.cjs.map
15
+ //# sourceMappingURL=svelte.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/adapters/svelte.ts"],"names":[],"mappings":";;;AA0BO,SAAS,cAAc,KAAA,EAAyD;AACtF,EAAA,OAAO;AAAA,IACN,UAAU,GAAA,EAAK;AACd,MAAA,GAAA,CAAI,KAAA,CAAM,aAAa,CAAA;AACvB,MAAA,OAAO,MAAM,SAAA,CAAU,MAAM,IAAI,KAAA,CAAM,WAAA,EAAa,CAAC,CAAA;AAAA,IACtD;AAAA,GACD;AACD","file":"svelte.cjs","sourcesContent":["import type { DendriStore, DendriStoreSnapshot } from \"../store\";\n\n/** Svelte store contract (readable). Works with `$store` auto-subscription in Svelte 4 and 5. */\nexport interface SvelteReadable<T> {\n\tsubscribe(run: (value: T) => void): () => void;\n}\n\n/**\n * Wrap a Dendri store in Svelte's store contract.\n *\n * ```svelte\n * <script>\n * import { createDendriStore } from \"@afterrealism/dendri-client\";\n * import { toSvelteStore } from \"@afterrealism/dendri-client/svelte\";\n *\n * const store = createDendriStore({ url: \"wss://signal.example.com\" });\n * const snapshot = toSvelteStore(store);\n * </script>\n *\n * {$snapshot.connectionState} — {$snapshot.peers.length} peers\n * ```\n *\n * Plain store contract — no Svelte compiler or dependency involved, so it\n * also works from `.js`/`.ts` modules and with Svelte 5 runes code via\n * `fromStore()` if preferred.\n */\nexport function toSvelteStore(store: DendriStore): SvelteReadable<DendriStoreSnapshot> {\n\treturn {\n\t\tsubscribe(run) {\n\t\t\trun(store.getSnapshot());\n\t\t\treturn store.subscribe(() => run(store.getSnapshot()));\n\t\t},\n\t};\n}\n"]}
@@ -0,0 +1,29 @@
1
+ import { n as DendriStore, p as DendriStoreSnapshot } from './store-C3Nwl62R.cjs';
2
+ import 'eventemitter3';
3
+
4
+ /** Svelte store contract (readable). Works with `$store` auto-subscription in Svelte 4 and 5. */
5
+ interface SvelteReadable<T> {
6
+ subscribe(run: (value: T) => void): () => void;
7
+ }
8
+ /**
9
+ * Wrap a Dendri store in Svelte's store contract.
10
+ *
11
+ * ```svelte
12
+ * <script>
13
+ * import { createDendriStore } from "@afterrealism/dendri-client";
14
+ * import { toSvelteStore } from "@afterrealism/dendri-client/svelte";
15
+ *
16
+ * const store = createDendriStore({ url: "wss://signal.example.com" });
17
+ * const snapshot = toSvelteStore(store);
18
+ * </script>
19
+ *
20
+ * {$snapshot.connectionState} — {$snapshot.peers.length} peers
21
+ * ```
22
+ *
23
+ * Plain store contract — no Svelte compiler or dependency involved, so it
24
+ * also works from `.js`/`.ts` modules and with Svelte 5 runes code via
25
+ * `fromStore()` if preferred.
26
+ */
27
+ declare function toSvelteStore(store: DendriStore): SvelteReadable<DendriStoreSnapshot>;
28
+
29
+ export { type SvelteReadable, toSvelteStore };
@@ -0,0 +1,29 @@
1
+ import { n as DendriStore, p as DendriStoreSnapshot } from './store-C3Nwl62R.js';
2
+ import 'eventemitter3';
3
+
4
+ /** Svelte store contract (readable). Works with `$store` auto-subscription in Svelte 4 and 5. */
5
+ interface SvelteReadable<T> {
6
+ subscribe(run: (value: T) => void): () => void;
7
+ }
8
+ /**
9
+ * Wrap a Dendri store in Svelte's store contract.
10
+ *
11
+ * ```svelte
12
+ * <script>
13
+ * import { createDendriStore } from "@afterrealism/dendri-client";
14
+ * import { toSvelteStore } from "@afterrealism/dendri-client/svelte";
15
+ *
16
+ * const store = createDendriStore({ url: "wss://signal.example.com" });
17
+ * const snapshot = toSvelteStore(store);
18
+ * </script>
19
+ *
20
+ * {$snapshot.connectionState} — {$snapshot.peers.length} peers
21
+ * ```
22
+ *
23
+ * Plain store contract — no Svelte compiler or dependency involved, so it
24
+ * also works from `.js`/`.ts` modules and with Svelte 5 runes code via
25
+ * `fromStore()` if preferred.
26
+ */
27
+ declare function toSvelteStore(store: DendriStore): SvelteReadable<DendriStoreSnapshot>;
28
+
29
+ export { type SvelteReadable, toSvelteStore };
package/dist/svelte.js ADDED
@@ -0,0 +1,15 @@
1
+ import './chunk-G3PMV62Z.js';
2
+
3
+ // src/adapters/svelte.ts
4
+ function toSvelteStore(store) {
5
+ return {
6
+ subscribe(run) {
7
+ run(store.getSnapshot());
8
+ return store.subscribe(() => run(store.getSnapshot()));
9
+ }
10
+ };
11
+ }
12
+
13
+ export { toSvelteStore };
14
+ //# sourceMappingURL=svelte.js.map
15
+ //# sourceMappingURL=svelte.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/adapters/svelte.ts"],"names":[],"mappings":";;;AA0BO,SAAS,cAAc,KAAA,EAAyD;AACtF,EAAA,OAAO;AAAA,IACN,UAAU,GAAA,EAAK;AACd,MAAA,GAAA,CAAI,KAAA,CAAM,aAAa,CAAA;AACvB,MAAA,OAAO,MAAM,SAAA,CAAU,MAAM,IAAI,KAAA,CAAM,WAAA,EAAa,CAAC,CAAA;AAAA,IACtD;AAAA,GACD;AACD","file":"svelte.js","sourcesContent":["import type { DendriStore, DendriStoreSnapshot } from \"../store\";\n\n/** Svelte store contract (readable). Works with `$store` auto-subscription in Svelte 4 and 5. */\nexport interface SvelteReadable<T> {\n\tsubscribe(run: (value: T) => void): () => void;\n}\n\n/**\n * Wrap a Dendri store in Svelte's store contract.\n *\n * ```svelte\n * <script>\n * import { createDendriStore } from \"@afterrealism/dendri-client\";\n * import { toSvelteStore } from \"@afterrealism/dendri-client/svelte\";\n *\n * const store = createDendriStore({ url: \"wss://signal.example.com\" });\n * const snapshot = toSvelteStore(store);\n * </script>\n *\n * {$snapshot.connectionState} — {$snapshot.peers.length} peers\n * ```\n *\n * Plain store contract — no Svelte compiler or dependency involved, so it\n * also works from `.js`/`.ts` modules and with Svelte 5 runes code via\n * `fromStore()` if preferred.\n */\nexport function toSvelteStore(store: DendriStore): SvelteReadable<DendriStoreSnapshot> {\n\treturn {\n\t\tsubscribe(run) {\n\t\t\trun(store.getSnapshot());\n\t\t\treturn store.subscribe(() => run(store.getSnapshot()));\n\t\t},\n\t};\n}\n"]}
package/dist/vue.cjs ADDED
@@ -0,0 +1,19 @@
1
+ 'use strict';
2
+
3
+ var vue = require('vue');
4
+
5
+ // src/adapters/vue.ts
6
+ function useDendriStore(store) {
7
+ const snapshot = vue.shallowRef(store.getSnapshot());
8
+ const unsubscribe = store.subscribe(() => {
9
+ snapshot.value = store.getSnapshot();
10
+ });
11
+ if (vue.getCurrentScope()) {
12
+ vue.onScopeDispose(unsubscribe);
13
+ }
14
+ return snapshot;
15
+ }
16
+
17
+ exports.useDendriStore = useDendriStore;
18
+ //# sourceMappingURL=vue.cjs.map
19
+ //# sourceMappingURL=vue.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/adapters/vue.ts"],"names":["shallowRef","getCurrentScope","onScopeDispose"],"mappings":";;;;;AAqBO,SAAS,eAAe,KAAA,EAA+D;AAC7F,EAAA,MAAM,QAAA,GAAWA,cAAA,CAAW,KAAA,CAAM,WAAA,EAAa,CAAA;AAC/C,EAAA,MAAM,WAAA,GAAc,KAAA,CAAM,SAAA,CAAU,MAAM;AACzC,IAAA,QAAA,CAAS,KAAA,GAAQ,MAAM,WAAA,EAAY;AAAA,EACpC,CAAC,CAAA;AACD,EAAA,IAAIC,qBAAgB,EAAG;AACtB,IAAAC,kBAAA,CAAe,WAAW,CAAA;AAAA,EAC3B;AACA,EAAA,OAAO,QAAA;AACR","file":"vue.cjs","sourcesContent":["import { getCurrentScope, onScopeDispose, type ShallowRef, shallowRef } from \"vue\";\nimport type { DendriStore, DendriStoreSnapshot } from \"../store\";\n\n/**\n * Subscribe a Vue setup scope to a Dendri store.\n *\n * ```vue\n * <script setup>\n * import { createDendriStore } from \"@afterrealism/dendri-client\";\n * import { useDendriStore } from \"@afterrealism/dendri-client/vue\";\n *\n * const store = createDendriStore({ url: \"wss://signal.example.com\" });\n * const snapshot = useDendriStore(store);\n * </script>\n *\n * <template>{{ snapshot.connectionState }}</template>\n * ```\n *\n * The ref updates on every store change and unsubscribes automatically when\n * the component (effect scope) is torn down.\n */\nexport function useDendriStore(store: DendriStore): Readonly<ShallowRef<DendriStoreSnapshot>> {\n\tconst snapshot = shallowRef(store.getSnapshot());\n\tconst unsubscribe = store.subscribe(() => {\n\t\tsnapshot.value = store.getSnapshot();\n\t});\n\tif (getCurrentScope()) {\n\t\tonScopeDispose(unsubscribe);\n\t}\n\treturn snapshot;\n}\n"]}
package/dist/vue.d.cts ADDED
@@ -0,0 +1,25 @@
1
+ import { ShallowRef } from 'vue';
2
+ import { n as DendriStore, p as DendriStoreSnapshot } from './store-C3Nwl62R.cjs';
3
+ import 'eventemitter3';
4
+
5
+ /**
6
+ * Subscribe a Vue setup scope to a Dendri store.
7
+ *
8
+ * ```vue
9
+ * <script setup>
10
+ * import { createDendriStore } from "@afterrealism/dendri-client";
11
+ * import { useDendriStore } from "@afterrealism/dendri-client/vue";
12
+ *
13
+ * const store = createDendriStore({ url: "wss://signal.example.com" });
14
+ * const snapshot = useDendriStore(store);
15
+ * </script>
16
+ *
17
+ * <template>{{ snapshot.connectionState }}</template>
18
+ * ```
19
+ *
20
+ * The ref updates on every store change and unsubscribes automatically when
21
+ * the component (effect scope) is torn down.
22
+ */
23
+ declare function useDendriStore(store: DendriStore): Readonly<ShallowRef<DendriStoreSnapshot>>;
24
+
25
+ export { useDendriStore };
package/dist/vue.d.ts ADDED
@@ -0,0 +1,25 @@
1
+ import { ShallowRef } from 'vue';
2
+ import { n as DendriStore, p as DendriStoreSnapshot } from './store-C3Nwl62R.js';
3
+ import 'eventemitter3';
4
+
5
+ /**
6
+ * Subscribe a Vue setup scope to a Dendri store.
7
+ *
8
+ * ```vue
9
+ * <script setup>
10
+ * import { createDendriStore } from "@afterrealism/dendri-client";
11
+ * import { useDendriStore } from "@afterrealism/dendri-client/vue";
12
+ *
13
+ * const store = createDendriStore({ url: "wss://signal.example.com" });
14
+ * const snapshot = useDendriStore(store);
15
+ * </script>
16
+ *
17
+ * <template>{{ snapshot.connectionState }}</template>
18
+ * ```
19
+ *
20
+ * The ref updates on every store change and unsubscribes automatically when
21
+ * the component (effect scope) is torn down.
22
+ */
23
+ declare function useDendriStore(store: DendriStore): Readonly<ShallowRef<DendriStoreSnapshot>>;
24
+
25
+ export { useDendriStore };
package/dist/vue.js ADDED
@@ -0,0 +1,17 @@
1
+ import './chunk-G3PMV62Z.js';
2
+ import { shallowRef, getCurrentScope, onScopeDispose } from 'vue';
3
+
4
+ function useDendriStore(store) {
5
+ const snapshot = shallowRef(store.getSnapshot());
6
+ const unsubscribe = store.subscribe(() => {
7
+ snapshot.value = store.getSnapshot();
8
+ });
9
+ if (getCurrentScope()) {
10
+ onScopeDispose(unsubscribe);
11
+ }
12
+ return snapshot;
13
+ }
14
+
15
+ export { useDendriStore };
16
+ //# sourceMappingURL=vue.js.map
17
+ //# sourceMappingURL=vue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/adapters/vue.ts"],"names":[],"mappings":";;;AAqBO,SAAS,eAAe,KAAA,EAA+D;AAC7F,EAAA,MAAM,QAAA,GAAW,UAAA,CAAW,KAAA,CAAM,WAAA,EAAa,CAAA;AAC/C,EAAA,MAAM,WAAA,GAAc,KAAA,CAAM,SAAA,CAAU,MAAM;AACzC,IAAA,QAAA,CAAS,KAAA,GAAQ,MAAM,WAAA,EAAY;AAAA,EACpC,CAAC,CAAA;AACD,EAAA,IAAI,iBAAgB,EAAG;AACtB,IAAA,cAAA,CAAe,WAAW,CAAA;AAAA,EAC3B;AACA,EAAA,OAAO,QAAA;AACR","file":"vue.js","sourcesContent":["import { getCurrentScope, onScopeDispose, type ShallowRef, shallowRef } from \"vue\";\nimport type { DendriStore, DendriStoreSnapshot } from \"../store\";\n\n/**\n * Subscribe a Vue setup scope to a Dendri store.\n *\n * ```vue\n * <script setup>\n * import { createDendriStore } from \"@afterrealism/dendri-client\";\n * import { useDendriStore } from \"@afterrealism/dendri-client/vue\";\n *\n * const store = createDendriStore({ url: \"wss://signal.example.com\" });\n * const snapshot = useDendriStore(store);\n * </script>\n *\n * <template>{{ snapshot.connectionState }}</template>\n * ```\n *\n * The ref updates on every store change and unsubscribes automatically when\n * the component (effect scope) is torn down.\n */\nexport function useDendriStore(store: DendriStore): Readonly<ShallowRef<DendriStoreSnapshot>> {\n\tconst snapshot = shallowRef(store.getSnapshot());\n\tconst unsubscribe = store.subscribe(() => {\n\t\tsnapshot.value = store.getSnapshot();\n\t});\n\tif (getCurrentScope()) {\n\t\tonScopeDispose(unsubscribe);\n\t}\n\treturn snapshot;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@afterrealism/dendri-client",
3
- "version": "2.4.0",
3
+ "version": "2.6.0",
4
4
  "type": "module",
5
5
  "packageManager": "pnpm@10.30.1",
6
6
  "description": "Dendri client WebRTC P2P signaling library",
@@ -54,6 +54,36 @@
54
54
  "types": "./dist/serializer.msgpack.d.cts",
55
55
  "default": "./dist/serializer.msgpack.cjs"
56
56
  }
57
+ },
58
+ "./react": {
59
+ "import": {
60
+ "types": "./dist/react.d.ts",
61
+ "default": "./dist/react.js"
62
+ },
63
+ "require": {
64
+ "types": "./dist/react.d.cts",
65
+ "default": "./dist/react.cjs"
66
+ }
67
+ },
68
+ "./vue": {
69
+ "import": {
70
+ "types": "./dist/vue.d.ts",
71
+ "default": "./dist/vue.js"
72
+ },
73
+ "require": {
74
+ "types": "./dist/vue.d.cts",
75
+ "default": "./dist/vue.cjs"
76
+ }
77
+ },
78
+ "./svelte": {
79
+ "import": {
80
+ "types": "./dist/svelte.d.ts",
81
+ "default": "./dist/svelte.js"
82
+ },
83
+ "require": {
84
+ "types": "./dist/svelte.d.cts",
85
+ "default": "./dist/svelte.cjs"
86
+ }
57
87
  }
58
88
  },
59
89
  "files": [
@@ -79,10 +109,23 @@
79
109
  "lint": "biome check src/ tests/",
80
110
  "lint:fix": "biome check --write src/ tests/",
81
111
  "format": "biome format --write src/ tests/",
112
+ "format:check": "biome format src/ tests/",
82
113
  "validate": "publint && attw --pack --profile node16",
83
114
  "prepublishOnly": "npm run build",
84
115
  "clean": "rm -rf dist"
85
116
  },
117
+ "peerDependencies": {
118
+ "react": ">=18",
119
+ "vue": ">=3.3"
120
+ },
121
+ "peerDependenciesMeta": {
122
+ "react": {
123
+ "optional": true
124
+ },
125
+ "vue": {
126
+ "optional": true
127
+ }
128
+ },
86
129
  "dependencies": {
87
130
  "@msgpack/msgpack": "^2.8.0",
88
131
  "eventemitter3": "^4.0.7",
@@ -93,13 +136,17 @@
93
136
  "devDependencies": {
94
137
  "@arethetypeswrong/cli": "^0.17.0",
95
138
  "@biomejs/biome": "^2.0.0",
139
+ "@types/react": "^19.2.17",
96
140
  "@vitest/coverage-v8": "^3.0.0",
97
141
  "fast-check": "^4.6.0",
98
142
  "jsdom": "^25.0.1",
99
143
  "mock-socket": "^9.0.0",
100
144
  "publint": "^0.3.0",
145
+ "react": "^19.2.7",
146
+ "react-dom": "^19.2.7",
101
147
  "tsup": "^8.0.0",
102
148
  "typescript": "^5.7.0",
103
- "vitest": "^3.0.0"
149
+ "vitest": "^3.0.0",
150
+ "vue": "^3.5.39"
104
151
  }
105
152
  }