yeow-api 0.2.34 → 0.2.35

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/event.ts +8 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yeow-api",
3
- "version": "0.2.34",
3
+ "version": "0.2.35",
4
4
  "description": "Yeow API �?TypeScript OOP wrappers over the task protocol",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
package/src/event.ts CHANGED
@@ -322,26 +322,26 @@ export function eventOn<K extends keyof EventMap>(
322
322
  $send('task', { type: 'event.complete', params: { callbackId: cbId, mods }, cb: '' });
323
323
  }, { persistent: true });
324
324
 
325
- if (!__yeowEventHandlers) (globalThis as any).__yeowEventHandlers = {};
326
- const handlers = __yeowEventHandlers!;
327
- if (!handlers[eventType]) handlers[eventType] = [];
328
- handlers[eventType].push({ cbId, handler, manualRelease });
325
+ const gh = globalThis as any;
326
+ if (!gh.__yeowEventHandlers) gh.__yeowEventHandlers = {};
327
+ if (!gh.__yeowEventHandlers[eventType]) gh.__yeowEventHandlers[eventType] = [];
328
+ gh.__yeowEventHandlers[eventType].push({ cbId, handler, manualRelease });
329
329
 
330
330
  call('event.subscribe', { pluginName, eventType, callbackId: String(cbId) });
331
331
  return () => eventOff(eventType, handler);
332
332
  }
333
333
 
334
334
  export function eventOff(eventType: string, handler: Function): void {
335
- if (!__yeowEventHandlers) return;
336
- const entries = __yeowEventHandlers[eventType];
335
+ const gh = globalThis as any;
336
+ const entries = gh.__yeowEventHandlers?.[eventType];
337
337
  if (!entries) return;
338
- const idx = entries.findIndex((e) => e.handler === handler);
338
+ const idx = entries.findIndex((e: any) => e.handler === handler);
339
339
  if (idx !== -1) {
340
340
  const removed = entries.splice(idx, 1)[0];
341
341
  if (removed.cbId) _unregisterCallback(removed.cbId);
342
342
  }
343
343
  if (entries.length === 0) {
344
- delete __yeowEventHandlers![eventType];
344
+ delete gh.__yeowEventHandlers[eventType];
345
345
  call('event.unsubscribe', {
346
346
  pluginName: __plugin?.name || 'unknown',
347
347
  eventType,