@yiin/reactive-proxy-state 1.0.21 → 1.0.23

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.
@@ -0,0 +1,71 @@
1
+ import type { StateEvent } from "../types";
2
+ export type BridgeMessage = {
3
+ tx: string;
4
+ origin: string;
5
+ event: StateEvent;
6
+ };
7
+ type OnMessage = (cb: (msg: BridgeMessage, ctx?: any) => void) => () => void;
8
+ type Send = (msg: BridgeMessage, ctx?: any) => void;
9
+ type Forward = (msg: BridgeMessage, ctx?: any) => void;
10
+ /**
11
+ * Create a loop-safe bridge emitter for bi-directional sync.
12
+ * - Tags every message with tx + origin
13
+ * - Mutes emit while applying remote updates
14
+ * - Dedupe by tx using a small LRU
15
+ */
16
+ export declare function createBridgeEmitter(opts: {
17
+ id: string;
18
+ apply: (event: StateEvent) => void;
19
+ send: Send;
20
+ onMessage: OnMessage;
21
+ forward?: Forward;
22
+ seenLimit?: number;
23
+ }): {
24
+ emit: (event: StateEvent) => void;
25
+ stop: () => void;
26
+ mute: <T>(fn: () => T) => T;
27
+ };
28
+ /**
29
+ * Renderer-side bridge bound to Electron's ipcRenderer.
30
+ * Keep this generic by accepting a minimal ipcRenderer-like object.
31
+ */
32
+ export declare function createRendererBridgeEmitter(opts: {
33
+ id: string;
34
+ channel: string;
35
+ ipcRenderer: {
36
+ send: (channel: string, msg: any) => void;
37
+ on: (channel: string, handler: (event: any, msg: any) => void) => void;
38
+ off: (channel: string, handler: (event: any, msg: any) => void) => void;
39
+ };
40
+ apply: (event: StateEvent) => void;
41
+ seenLimit?: number;
42
+ }): {
43
+ emit: (event: StateEvent) => void;
44
+ stop: () => void;
45
+ mute: <T>(fn: () => T) => T;
46
+ };
47
+ /**
48
+ * Main-process bridge bound to Electron's ipcMain and BrowserWindows.
49
+ * Accepts a provider for windows to avoid importing Electron types.
50
+ */
51
+ export declare function createMainBridgeEmitter(opts: {
52
+ id?: string;
53
+ channel: string;
54
+ ipcMain: {
55
+ on: (channel: string, handler: (event: any, msg: any) => void) => void;
56
+ off: (channel: string, handler: (event: any, msg: any) => void) => void;
57
+ };
58
+ windows: () => {
59
+ webContents: {
60
+ id: number;
61
+ send: (channel: string, msg: any) => void;
62
+ };
63
+ }[];
64
+ apply: (event: StateEvent) => void;
65
+ seenLimit?: number;
66
+ }): {
67
+ emit: (event: StateEvent) => void;
68
+ stop: () => void;
69
+ mute: <T>(fn: () => T) => T;
70
+ };
71
+ export {};
@@ -0,0 +1,11 @@
1
+ import type { StateEvent } from "../types";
2
+ export type TrackVueReactiveEventsOptions = {
3
+ emitInitialReplace?: boolean;
4
+ };
5
+ /**
6
+ * Observe a Vue 3 reactive object and emit RPS-compatible StateEvents
7
+ * for each mutation performed through Vue reactivity.
8
+ *
9
+ * Returns a stop() function to tear down the watcher.
10
+ */
11
+ export declare function trackVueReactiveEvents<T extends object>(vueState: T, emit: (event: StateEvent) => void, options?: TrackVueReactiveEventsOptions): () => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yiin/reactive-proxy-state",
3
- "version": "1.0.21",
3
+ "version": "1.0.23",
4
4
  "author": "Yiin <stanislovas@yiin.lt>",
5
5
  "repository": {
6
6
  "type": "git",