@yiin/reactive-proxy-state 2.0.0 → 3.0.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/README.md +2 -0
- package/dist/index.cjs +550 -2557
- package/dist/index.js +539 -2537
- package/dist/integrations/vue3.d.ts +14 -8
- package/package.json +10 -3
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { StateEvent } from "../types";
|
|
2
2
|
export type DiffErrorContext = {
|
|
3
|
+
/** The first key of `path`, or '' when the failure is in the root object itself. */
|
|
3
4
|
key: string;
|
|
5
|
+
/** Path of the event whose listener threw, or of the object whose scan failed. */
|
|
4
6
|
path: (string | number | symbol)[];
|
|
5
7
|
error: unknown;
|
|
6
8
|
};
|
|
@@ -9,22 +11,26 @@ export type TrackVueReactiveEventsOptions = {
|
|
|
9
11
|
onDiffError?: (ctx: DiffErrorContext) => void;
|
|
10
12
|
};
|
|
11
13
|
export type VueTrackingControl = {
|
|
12
|
-
/** Stop
|
|
14
|
+
/** Stop tracking for good. A stopped tracker cannot restart: pause() and resume() after stop() only warn. */
|
|
13
15
|
stop: () => void;
|
|
14
|
-
/** Stop
|
|
16
|
+
/** Stop sending events. Writes still keep the tracker's copy of the state in step, so resume() costs nothing. */
|
|
15
17
|
pause: () => void;
|
|
16
|
-
/**
|
|
18
|
+
/** Send events again. Writes made while paused are never sent. */
|
|
17
19
|
resume: () => void;
|
|
18
20
|
};
|
|
19
21
|
/**
|
|
20
22
|
* Observe a Vue 3 reactive object and emit RPS-compatible StateEvents
|
|
21
23
|
* for each mutation performed through Vue reactivity.
|
|
22
24
|
*
|
|
23
|
-
*
|
|
24
|
-
* only
|
|
25
|
-
*
|
|
25
|
+
* Every object and array in the state gets its own small Vue effect (a node)
|
|
26
|
+
* that reads only its own entries, so a write re-runs only the node it changed.
|
|
27
|
+
* Each node keeps a plain copy of its entries and diffs against it with the
|
|
28
|
+
* rules 2.0.0 used, so the events are the same: leaf-level sets, deletes,
|
|
29
|
+
* array grows as per-index sets, shrinks as one `length` set, a type change as
|
|
30
|
+
* one whole-value set. A Map or Set is one node that reads the whole collection
|
|
31
|
+
* and emits `map-set` / `set-add` with whole values.
|
|
26
32
|
*
|
|
27
|
-
* Returns a control object with stop/pause/resume. Use pause/resume
|
|
28
|
-
*
|
|
33
|
+
* Returns a control object with stop/pause/resume. Use pause/resume around
|
|
34
|
+
* writes that must not be sent back (e.g. server events).
|
|
29
35
|
*/
|
|
30
36
|
export declare function trackVueReactiveEvents<T extends object>(vueState: T, emit: (event: StateEvent) => void, options?: TrackVueReactiveEventsOptions): VueTrackingControl;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yiin/reactive-proxy-state",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"author": "Yiin <stanislovas@yiin.lt>",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -10,13 +10,20 @@
|
|
|
10
10
|
"module": "dist/index.js",
|
|
11
11
|
"type": "module",
|
|
12
12
|
"devDependencies": {
|
|
13
|
+
"@vue/reactivity": "^3.5.13",
|
|
13
14
|
"bun-types": "^1.2.8",
|
|
14
15
|
"typescript": "^5.0.4",
|
|
15
16
|
"vitepress": "^1.6.3",
|
|
16
17
|
"vue": "^3.5.13"
|
|
17
18
|
},
|
|
18
19
|
"peerDependencies": {
|
|
19
|
-
"vue": "
|
|
20
|
+
"@vue/reactivity": "^3.5.0",
|
|
21
|
+
"vue": "^3.5.0"
|
|
22
|
+
},
|
|
23
|
+
"peerDependenciesMeta": {
|
|
24
|
+
"@vue/reactivity": {
|
|
25
|
+
"optional": true
|
|
26
|
+
}
|
|
20
27
|
},
|
|
21
28
|
"exports": {
|
|
22
29
|
".": {
|
|
@@ -52,7 +59,7 @@
|
|
|
52
59
|
"access": "public"
|
|
53
60
|
},
|
|
54
61
|
"scripts": {
|
|
55
|
-
"build": "bun build src/index.ts --outdir dist --target node --format esm --external vue && bun build src/index.ts --outfile dist/index.cjs --target node --format cjs --external vue && tsc --emitDeclarationOnly --outDir dist",
|
|
62
|
+
"build": "bun build src/index.ts --outdir dist --target node --format esm --external vue --external @vue/reactivity && bun build src/index.ts --outfile dist/index.cjs --target node --format cjs --external vue --external @vue/reactivity && tsc --emitDeclarationOnly --outDir dist",
|
|
56
63
|
"test": "bun test",
|
|
57
64
|
"test:watch": "bun test --watch",
|
|
58
65
|
"test:bench": "bun --bun ./benchmarks/state-sync.bench.ts",
|