@oreefy/event 1.0.0 → 2.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 CHANGED
@@ -37,7 +37,7 @@ event.off("signedIn", listener);
37
37
  event.emit("signedIn", { success: true });
38
38
  ```
39
39
 
40
- Events are delivered to listeners in the same tab and automatically broadcast to other open tabs via `BroadcastChannel`.
40
+ Events emitted via `event.emit()` work exclusively across **other** open tabs. The **current** (emitting) tab **ignores** the event and will **not trigger** its own listeners.
41
41
 
42
42
  # API Reference
43
43
 
@@ -82,7 +82,7 @@ event.emit("theme", {
82
82
  });
83
83
  ```
84
84
 
85
- The event is immediately delivered to all listeners in the current tab and broadcast to other tabs using `BroadcastChannel`.
85
+ The event is broadcast to all other open tabs in the same origin using `BroadcastChannel`. It does not execute listeners in the originating tab.
86
86
 
87
87
  ## `idb.on()`
88
88
 
@@ -149,14 +149,14 @@ event.on("signedIn", (data) => {
149
149
  });
150
150
  ```
151
151
 
152
- The originating tab does not receive its own broadcast message, preventing duplicate delivery.
152
+ The originating tab (Tab A) does not fire its own `on()` listeners, guaranteeing zero self-triggering side effects.
153
153
 
154
154
  ## Same-Tab vs Cross-Tab Behavior
155
155
 
156
156
  When you call `event.emit()`
157
157
 
158
- 1. The event is delivered immediately to listeners in the current tab.
159
- 2. The event is broadcast to other tabs via `BroadcastChannel`.
158
+ 1. The event payload is broadcast directly to all other open tabs via `BroadcastChannel`.
159
+ 2. The current tab ignores the event locally, allowing your primary action handler to finish without interruption.
160
160
 
161
161
  ## Event Listener Errors
162
162
 
package/dist/index.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  type EventListener<T = any> = (data: T) => void;
2
2
  declare class Event {
3
3
  private static _instance;
4
- private static readonly TAB_ID;
5
4
  private listeners;
6
5
  private channel;
7
6
  private _triggerLocalListeners;
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- var r=class s{static _instance;static TAB_ID=crypto.randomUUID();listeners=new Map;channel=new BroadcastChannel("@oreefy/idb");_triggerLocalListeners(t,e){let n=this.listeners.get(t);if(n)for(let i of n)try{i(e);}catch{}}constructor(){this.channel.addEventListener("message",t=>{let{name:e,data:n,sourceTabId:i}=t.data||{};e&&i!==s.TAB_ID&&this._triggerLocalListeners(e,n);});}static _initInstance(){return s._instance||(s._instance=new s),s._instance}emit(t,e){this._triggerLocalListeners(t,e),this.channel.postMessage({name:t,data:e,sourceTabId:s.TAB_ID});}on(t,e){this.listeners.has(t)||this.listeners.set(t,new Set),this.listeners.get(t).add(e);}off(t,e){let n=this.listeners.get(t);n&&(n.delete(e),n.size===0&&this.listeners.delete(t));}},a=r._initInstance;export{a as eventInstance};
1
+ var i=class s{static _instance;listeners=new Map;channel=new BroadcastChannel("@oreefy/idb");_triggerLocalListeners(t,e){let n=this.listeners.get(t);if(n)for(let r of n)try{r(e);}catch{}}constructor(){this.channel.addEventListener("message",t=>{let{name:e,data:n}=t.data||{};e&&this._triggerLocalListeners(e,n);});}static _initInstance(){return s._instance||(s._instance=new s),s._instance}emit(t,e){this.channel.postMessage({name:t,data:e});}on(t,e){this.listeners.has(t)||this.listeners.set(t,new Set),this.listeners.get(t).add(e);}off(t,e){let n=this.listeners.get(t);n&&(n.delete(e),n.size===0&&this.listeners.delete(t));}},a=i._initInstance;export{a as eventInstance};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oreefy/event",
3
- "version": "1.0.0",
3
+ "version": "2.0.0",
4
4
  "type": "module",
5
5
  "types": "./dist/index.d.ts",
6
6
  "module": "./dist/index.js",