ladrillosjs 2.0.0-rc.7 → 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.
Files changed (43) hide show
  1. package/README.md +171 -16
  2. package/dist/core/cache/expressionCache.d.ts +5 -70
  3. package/dist/core/component/loader.d.ts +1 -1
  4. package/dist/core/configure.d.ts +24 -0
  5. package/dist/core/diff/listDiff.d.ts +16 -0
  6. package/dist/core/html/controlTagEscape.d.ts +47 -0
  7. package/dist/core/js/moduleExecutor.d.ts +19 -0
  8. package/dist/core/js/scriptParser.d.ts +35 -1
  9. package/dist/core.d.ts +2 -2
  10. package/dist/core.dev.js +12 -0
  11. package/dist/core.dev.js.map +1 -0
  12. package/dist/core.js +1 -1
  13. package/dist/core.js.map +1 -1
  14. package/dist/events.dev.js +2 -0
  15. package/dist/events.js +1 -1
  16. package/dist/index.d.ts +2 -2
  17. package/dist/index.dev.js +22 -0
  18. package/dist/index.dev.js.map +1 -0
  19. package/dist/index.js +1 -1
  20. package/dist/index.js.map +1 -1
  21. package/dist/lazy.dev.js +2 -0
  22. package/dist/lazy.js +1 -1
  23. package/dist/shared-CMbR-Hhy.js +3 -0
  24. package/dist/shared-CMbR-Hhy.js.map +1 -0
  25. package/dist/shared-DqWGO1vN.js +2 -0
  26. package/dist/{shared-D-P0qKQY.js.map → shared-DqWGO1vN.js.map} +1 -1
  27. package/dist/shared-R1SSiaIW.dev.js +6785 -0
  28. package/dist/shared-R1SSiaIW.dev.js.map +1 -0
  29. package/dist/shared-Sk_U4mcq.dev.js +161 -0
  30. package/dist/shared-Sk_U4mcq.dev.js.map +1 -0
  31. package/dist/types/index.d.ts +6 -0
  32. package/dist/utils/devWarnings.d.ts +24 -3
  33. package/dist/utils/directives.d.ts +10 -0
  34. package/dist/utils/jsevents.d.ts +5 -0
  35. package/dist/utils/sandbox.d.ts +11 -0
  36. package/dist/utils/stateTransform.d.ts +58 -0
  37. package/package.json +22 -8
  38. package/dist/core/reactivity/dependencyTracker.d.ts +0 -120
  39. package/dist/shared-18P4lj9w.js +0 -2
  40. package/dist/shared-18P4lj9w.js.map +0 -1
  41. package/dist/shared-D-P0qKQY.js +0 -2
  42. package/dist/shared-mjNRZBte.js +0 -3
  43. package/dist/shared-mjNRZBte.js.map +0 -1
@@ -0,0 +1,2 @@
1
+ function e(){return globalThis.__ladrillosEventBus||(globalThis.__ladrillosEventBus={listeners:/* @__PURE__ */new Map,componentListeners:/* @__PURE__ */new Map}),globalThis.__ladrillosEventBus}function t(){return e().listeners}function n(){return e().componentListeners}function o(e,n){const o=t().get(e);if(o&&0!==o.size)for(const t of o)try{t.callback(n)}catch(s){console.error(`[LadrillosJS] Error in event listener for "${e}":`,s)}}function s(e,o,s){const i=t(),r=n();let l=i.get(e);l||(l=/* @__PURE__ */new Set,i.set(e,l));const c={callback:o,componentId:s};if(l.add(c),s){let t=r.get(s);t||(t=/* @__PURE__ */new Set,r.set(s,t)),t.add({event:e,registration:c})}return()=>{const o=t(),i=n();if(l?.delete(c),0===l?.size&&o.delete(e),s){const e=i.get(s);if(e){for(const t of e)if(t.registration===c){e.delete(t);break}0===e.size&&i.delete(s)}}}}function i(e){const o=t(),s=n(),i=s.get(e);if(i){for(const{event:e,registration:t}of i){const n=o.get(e);n&&(n.delete(t),0===n.size&&o.delete(e))}s.delete(e)}}function r(e){return{$emit:function(e,t){o(e,t)},$listen:function(t,n){return s(t,n,e)}}}var l=["$emit","$listen"];export{l as a,r as i,s as n,i as r,o as t};
2
+ //# sourceMappingURL=shared-DqWGO1vN.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"shared-D-P0qKQY.js","names":[],"sources":["../src/core/events/eventBus.ts"],"sourcesContent":["/**\r\n * LadrillosJS Global Event Bus\r\n *\r\n * Provides cross-component communication without prop drilling.\r\n *\r\n * Usage:\r\n * - $emit(\"event-name\", data) - Emit an event to all listeners\r\n * - $listen(\"event-name\", callback) - Listen for events from any component\r\n *\r\n * @example\r\n * ```html\r\n * <!-- Component A: Emitting events -->\r\n * <script>\r\n * const login = () => {\r\n * $emit(\"user-logged-in\", { userId: 123, username: \"john\" });\r\n * };\r\n * </script>\r\n *\r\n * <!-- Component B: Listening for events -->\r\n * <script>\r\n * let isLoggedIn = false;\r\n * let username = \"\";\r\n *\r\n * $listen(\"user-logged-in\", (user) => {\r\n * isLoggedIn = true;\r\n * username = user.username;\r\n * });\r\n * </script>\r\n * ```\r\n */\r\n\r\n// ============================================================================\r\n// Types\r\n// ============================================================================\r\n\r\n/**\r\n * Event listener callback function type\r\n */\r\nexport type EventListener<T = unknown> = (data: T) => void;\r\n\r\n/**\r\n * Public alias for EventListener (for external API)\r\n */\r\nexport type EventCallback<T = unknown> = EventListener<T>;\r\n\r\n/**\r\n * Internal listener registration with metadata for cleanup\r\n */\r\ninterface ListenerRegistration {\r\n callback: EventListener;\r\n componentId?: string; // Track which component registered this listener\r\n}\r\n\r\n/**\r\n * Unsubscribe function returned by $listen\r\n */\r\nexport type Unsubscribe = () => void;\r\n\r\n// ============================================================================\r\n// Global Event Bus (Singleton)\r\n// ============================================================================\r\n\r\n/**\r\n * Global event bus interface for type safety\r\n */\r\ninterface GlobalEventBus {\r\n listeners: Map<string, Set<ListenerRegistration>>;\r\n componentListeners: Map<\r\n string,\r\n Set<{ event: string; registration: ListenerRegistration }>\r\n >;\r\n}\r\n\r\n/**\r\n * Extend globalThis to include our event bus\r\n */\r\ndeclare global {\r\n var __ladrillosEventBus: GlobalEventBus | undefined;\r\n}\r\n\r\n/**\r\n * Initialize or get the global event bus.\r\n * This is shared with external module scripts that inject their own $emit/$listen.\r\n */\r\nfunction getEventBus(): GlobalEventBus {\r\n if (!globalThis.__ladrillosEventBus) {\r\n globalThis.__ladrillosEventBus = {\r\n listeners: new Map(),\r\n componentListeners: new Map(),\r\n };\r\n }\r\n return globalThis.__ladrillosEventBus;\r\n}\r\n\r\n/**\r\n * Get the listeners map (uses global storage)\r\n */\r\nfunction getEventListeners(): Map<string, Set<ListenerRegistration>> {\r\n return getEventBus().listeners;\r\n}\r\n\r\n/**\r\n * Get the component listeners map (uses global storage)\r\n */\r\nfunction getComponentListeners(): Map<\r\n string,\r\n Set<{ event: string; registration: ListenerRegistration }>\r\n> {\r\n return getEventBus().componentListeners;\r\n}\r\n\r\n/**\r\n * Emit an event to all registered listeners.\r\n *\r\n * @param eventName - The name of the event to emit\r\n * @param data - Optional data to pass to listeners\r\n *\r\n * @example\r\n * ```js\r\n * $emit(\"user-logged-in\", { userId: 123, username: \"john\" });\r\n * $emit(\"show-modal\");\r\n * $emit(\"item-added\", { id: 1, name: \"Product\" });\r\n * ```\r\n */\r\nexport function $emit<T = unknown>(eventName: string, data?: T): void {\r\n const eventListeners = getEventListeners();\r\n const listeners = eventListeners.get(eventName);\r\n if (!listeners || listeners.size === 0) {\r\n // No listeners for this event - that's fine, just return\r\n return;\r\n }\r\n\r\n // Call all listeners with the data\r\n for (const registration of listeners) {\r\n try {\r\n registration.callback(data as T);\r\n } catch (error) {\r\n console.error(\r\n `[LadrillosJS] Error in event listener for \"${eventName}\":`,\r\n error\r\n );\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Listen for events from any component.\r\n *\r\n * @param eventName - The name of the event to listen for\r\n * @param callback - Function to call when the event is emitted\r\n * @param componentId - Optional component ID for automatic cleanup\r\n * @returns Unsubscribe function to remove the listener\r\n *\r\n * @example\r\n * ```js\r\n * // Basic usage\r\n * $listen(\"user-logged-in\", (user) => {\r\n * console.log(`Welcome, ${user.username}!`);\r\n * isLoggedIn = true;\r\n * });\r\n *\r\n * // With unsubscribe\r\n * const unsubscribe = $listen(\"notifications\", handleNotification);\r\n * // Later: unsubscribe();\r\n * ```\r\n */\r\nexport function $listen<T = unknown>(\r\n eventName: string,\r\n callback: EventListener<T>,\r\n componentId?: string\r\n): Unsubscribe {\r\n const eventListeners = getEventListeners();\r\n const componentListeners = getComponentListeners();\r\n\r\n // Get or create the listener set for this event\r\n let listeners = eventListeners.get(eventName);\r\n if (!listeners) {\r\n listeners = new Set();\r\n eventListeners.set(eventName, listeners);\r\n }\r\n\r\n // Create registration object\r\n const registration: ListenerRegistration = {\r\n callback: callback as EventListener,\r\n componentId,\r\n };\r\n\r\n // Add to event listeners\r\n listeners.add(registration);\r\n\r\n // Track by component ID for cleanup\r\n if (componentId) {\r\n let componentRegs = componentListeners.get(componentId);\r\n if (!componentRegs) {\r\n componentRegs = new Set();\r\n componentListeners.set(componentId, componentRegs);\r\n }\r\n componentRegs.add({ event: eventName, registration });\r\n }\r\n\r\n // Return unsubscribe function\r\n return () => {\r\n const eventListeners = getEventListeners();\r\n const componentListeners = getComponentListeners();\r\n\r\n listeners?.delete(registration);\r\n\r\n // Clean up empty listener sets\r\n if (listeners?.size === 0) {\r\n eventListeners.delete(eventName);\r\n }\r\n\r\n // Remove from component tracking\r\n if (componentId) {\r\n const componentRegs = componentListeners.get(componentId);\r\n if (componentRegs) {\r\n for (const reg of componentRegs) {\r\n if (reg.registration === registration) {\r\n componentRegs.delete(reg);\r\n break;\r\n }\r\n }\r\n if (componentRegs.size === 0) {\r\n componentListeners.delete(componentId);\r\n }\r\n }\r\n }\r\n };\r\n}\r\n\r\n/**\r\n * Remove all listeners registered by a specific component.\r\n * Called automatically when a component is disconnected from the DOM.\r\n *\r\n * @param componentId - The component's unique ID\r\n */\r\nexport function cleanupComponentListeners(componentId: string): void {\r\n const eventListeners = getEventListeners();\r\n const componentListeners = getComponentListeners();\r\n\r\n const componentRegs = componentListeners.get(componentId);\r\n if (!componentRegs) return;\r\n\r\n for (const { event, registration } of componentRegs) {\r\n const listeners = eventListeners.get(event);\r\n if (listeners) {\r\n listeners.delete(registration);\r\n if (listeners.size === 0) {\r\n eventListeners.delete(event);\r\n }\r\n }\r\n }\r\n\r\n componentListeners.delete(componentId);\r\n}\r\n\r\n/**\r\n * Remove all event listeners (useful for testing)\r\n */\r\nexport function clearAllListeners(): void {\r\n getEventListeners().clear();\r\n getComponentListeners().clear();\r\n}\r\n\r\n/**\r\n * Get the count of listeners for an event (useful for debugging)\r\n */\r\nexport function getListenerCount(eventName: string): number {\r\n return getEventListeners().get(eventName)?.size ?? 0;\r\n}\r\n\r\n/**\r\n * Check if an event has any listeners\r\n */\r\nexport function hasListeners(eventName: string): boolean {\r\n return (getEventListeners().get(eventName)?.size ?? 0) > 0;\r\n}\r\n\r\n// ============================================================================\r\n// Factory for Component-Bound Helpers\r\n// ============================================================================\r\n\r\n/**\r\n * Creates event bus helpers bound to a specific component.\r\n * This enables automatic cleanup when the component is disconnected.\r\n *\r\n * @param componentId - The unique ID of the component\r\n * @returns Object containing bound $emit and $listen functions\r\n */\r\nexport function createEventBusHelpers(componentId: string) {\r\n /**\r\n * Emit an event (same as global $emit)\r\n */\r\n function boundEmit<T = unknown>(eventName: string, data?: T): void {\r\n $emit(eventName, data);\r\n }\r\n\r\n /**\r\n * Listen for an event with automatic component tracking\r\n */\r\n function boundListen<T = unknown>(\r\n eventName: string,\r\n callback: EventListener<T>\r\n ): Unsubscribe {\r\n return $listen(eventName, callback, componentId);\r\n }\r\n\r\n return {\r\n $emit: boundEmit,\r\n $listen: boundListen,\r\n };\r\n}\r\n\r\n/**\r\n * Names of event bus helpers (for Function parameter lists)\r\n */\r\nexport const eventBusHelperNames = [\"$emit\", \"$listen\"];\r\n"],"mappings":"AAoFA,SAAS,IAOP,OANK,WAAW,sBACd,WAAW,oBAAsB,CAC/B,yBAAW,IAAI,IACf,kCAAoB,IAAI,MAGrB,WAAW,mBACpB,CAKA,SAAS,IACP,OAAO,IAAc,SACvB,CAKA,SAAS,IAIP,OAAO,IAAc,kBACvB,CAeA,SAAgB,EAAmB,EAAmB,GAEpD,MAAM,EADiB,IACU,IAAI,GACrC,GAAK,GAAgC,IAAnB,EAAU,KAM5B,IAAK,MAAM,KAAgB,EACzB,IACE,EAAa,SAAS,EACxB,CAAA,MAAS,GAKT,CAEJ,CAuBA,SAAgB,EACd,EACA,EACA,GAEA,MAAM,EAAiB,IACjB,EAAqB,IAG3B,IAAI,EAAY,EAAe,IAAI,GAC9B,IACH,iBAAY,IAAI,IAChB,EAAe,IAAI,EAAW,IAIhC,MAAM,EAAqC,CAC/B,WACV,eAOF,GAHA,EAAU,IAAI,GAGV,EAAa,CACf,IAAI,EAAgB,EAAmB,IAAI,GACtC,IACH,iBAAgB,IAAI,IACpB,EAAmB,IAAI,EAAa,IAEtC,EAAc,IAAI,CAAE,MAAO,EAAW,gBACxC,CAGA,MAAA,KACE,MAAM,EAAiB,IACjB,EAAqB,IAU3B,GARA,GAAW,OAAO,GAGM,IAApB,GAAW,MACb,EAAe,OAAO,GAIpB,EAAa,CACf,MAAM,EAAgB,EAAmB,IAAI,GAC7C,GAAI,EAAe,CACjB,IAAK,MAAM,KAAO,EAChB,GAAI,EAAI,eAAiB,EAAc,CACrC,EAAc,OAAO,GACrB,KACF,CAEyB,IAAvB,EAAc,MAChB,EAAmB,OAAO,EAE9B,CACF,EAEJ,CAQA,SAAgB,EAA0B,GACxC,MAAM,EAAiB,IACjB,EAAqB,IAErB,EAAgB,EAAmB,IAAI,GAC7C,GAAK,EAAL,CAEA,IAAK,MAAM,MAAE,EAAA,aAAO,KAAkB,EAAe,CACnD,MAAM,EAAY,EAAe,IAAI,GACjC,IACF,EAAU,OAAO,GACM,IAAnB,EAAU,MACZ,EAAe,OAAO,GAG5B,CAEA,EAAmB,OAAO,EAZN,CAatB,CAmCA,SAAgB,EAAsB,GAkBpC,MAAO,CACL,MAfF,SAAgC,EAAmB,GACjD,EAAM,EAAW,EACnB,EAcE,QATF,SACE,EACA,GAEA,OAAO,EAAQ,EAAW,EAAU,EACtC,EAMF,CAKA,IAAa,EAAsB,CAAC,QAAS"}
1
+ {"version":3,"file":"shared-DqWGO1vN.js","names":[],"sources":["../src/core/events/eventBus.ts"],"sourcesContent":["/**\r\n * LadrillosJS Global Event Bus\r\n *\r\n * Provides cross-component communication without prop drilling.\r\n *\r\n * Usage:\r\n * - $emit(\"event-name\", data) - Emit an event to all listeners\r\n * - $listen(\"event-name\", callback) - Listen for events from any component\r\n *\r\n * @example\r\n * ```html\r\n * <!-- Component A: Emitting events -->\r\n * <script>\r\n * const login = () => {\r\n * $emit(\"user-logged-in\", { userId: 123, username: \"john\" });\r\n * };\r\n * </script>\r\n *\r\n * <!-- Component B: Listening for events -->\r\n * <script>\r\n * let isLoggedIn = false;\r\n * let username = \"\";\r\n *\r\n * $listen(\"user-logged-in\", (user) => {\r\n * isLoggedIn = true;\r\n * username = user.username;\r\n * });\r\n * </script>\r\n * ```\r\n */\r\n\r\n// ============================================================================\r\n// Types\r\n// ============================================================================\r\n\r\n/**\r\n * Event listener callback function type\r\n */\r\nexport type EventListener<T = unknown> = (data: T) => void;\r\n\r\n/**\r\n * Public alias for EventListener (for external API)\r\n */\r\nexport type EventCallback<T = unknown> = EventListener<T>;\r\n\r\n/**\r\n * Internal listener registration with metadata for cleanup\r\n */\r\ninterface ListenerRegistration {\r\n callback: EventListener;\r\n componentId?: string; // Track which component registered this listener\r\n}\r\n\r\n/**\r\n * Unsubscribe function returned by $listen\r\n */\r\nexport type Unsubscribe = () => void;\r\n\r\n// ============================================================================\r\n// Global Event Bus (Singleton)\r\n// ============================================================================\r\n\r\n/**\r\n * Global event bus interface for type safety\r\n */\r\ninterface GlobalEventBus {\r\n listeners: Map<string, Set<ListenerRegistration>>;\r\n componentListeners: Map<\r\n string,\r\n Set<{ event: string; registration: ListenerRegistration }>\r\n >;\r\n}\r\n\r\n/**\r\n * Extend globalThis to include our event bus\r\n */\r\ndeclare global {\r\n var __ladrillosEventBus: GlobalEventBus | undefined;\r\n}\r\n\r\n/**\r\n * Initialize or get the global event bus.\r\n * This is shared with external module scripts that inject their own $emit/$listen.\r\n */\r\nfunction getEventBus(): GlobalEventBus {\r\n if (!globalThis.__ladrillosEventBus) {\r\n globalThis.__ladrillosEventBus = {\r\n listeners: new Map(),\r\n componentListeners: new Map(),\r\n };\r\n }\r\n return globalThis.__ladrillosEventBus;\r\n}\r\n\r\n/**\r\n * Get the listeners map (uses global storage)\r\n */\r\nfunction getEventListeners(): Map<string, Set<ListenerRegistration>> {\r\n return getEventBus().listeners;\r\n}\r\n\r\n/**\r\n * Get the component listeners map (uses global storage)\r\n */\r\nfunction getComponentListeners(): Map<\r\n string,\r\n Set<{ event: string; registration: ListenerRegistration }>\r\n> {\r\n return getEventBus().componentListeners;\r\n}\r\n\r\n/**\r\n * Emit an event to all registered listeners.\r\n *\r\n * @param eventName - The name of the event to emit\r\n * @param data - Optional data to pass to listeners\r\n *\r\n * @example\r\n * ```js\r\n * $emit(\"user-logged-in\", { userId: 123, username: \"john\" });\r\n * $emit(\"show-modal\");\r\n * $emit(\"item-added\", { id: 1, name: \"Product\" });\r\n * ```\r\n */\r\nexport function $emit<T = unknown>(eventName: string, data?: T): void {\r\n const eventListeners = getEventListeners();\r\n const listeners = eventListeners.get(eventName);\r\n if (!listeners || listeners.size === 0) {\r\n // No listeners for this event - that's fine, just return\r\n return;\r\n }\r\n\r\n // Call all listeners with the data\r\n for (const registration of listeners) {\r\n try {\r\n registration.callback(data as T);\r\n } catch (error) {\r\n console.error(\r\n `[LadrillosJS] Error in event listener for \"${eventName}\":`,\r\n error\r\n );\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Listen for events from any component.\r\n *\r\n * @param eventName - The name of the event to listen for\r\n * @param callback - Function to call when the event is emitted\r\n * @param componentId - Optional component ID for automatic cleanup\r\n * @returns Unsubscribe function to remove the listener\r\n *\r\n * @example\r\n * ```js\r\n * // Basic usage\r\n * $listen(\"user-logged-in\", (user) => {\r\n * console.log(`Welcome, ${user.username}!`);\r\n * isLoggedIn = true;\r\n * });\r\n *\r\n * // With unsubscribe\r\n * const unsubscribe = $listen(\"notifications\", handleNotification);\r\n * // Later: unsubscribe();\r\n * ```\r\n */\r\nexport function $listen<T = unknown>(\r\n eventName: string,\r\n callback: EventListener<T>,\r\n componentId?: string\r\n): Unsubscribe {\r\n const eventListeners = getEventListeners();\r\n const componentListeners = getComponentListeners();\r\n\r\n // Get or create the listener set for this event\r\n let listeners = eventListeners.get(eventName);\r\n if (!listeners) {\r\n listeners = new Set();\r\n eventListeners.set(eventName, listeners);\r\n }\r\n\r\n // Create registration object\r\n const registration: ListenerRegistration = {\r\n callback: callback as EventListener,\r\n componentId,\r\n };\r\n\r\n // Add to event listeners\r\n listeners.add(registration);\r\n\r\n // Track by component ID for cleanup\r\n if (componentId) {\r\n let componentRegs = componentListeners.get(componentId);\r\n if (!componentRegs) {\r\n componentRegs = new Set();\r\n componentListeners.set(componentId, componentRegs);\r\n }\r\n componentRegs.add({ event: eventName, registration });\r\n }\r\n\r\n // Return unsubscribe function\r\n return () => {\r\n const eventListeners = getEventListeners();\r\n const componentListeners = getComponentListeners();\r\n\r\n listeners?.delete(registration);\r\n\r\n // Clean up empty listener sets\r\n if (listeners?.size === 0) {\r\n eventListeners.delete(eventName);\r\n }\r\n\r\n // Remove from component tracking\r\n if (componentId) {\r\n const componentRegs = componentListeners.get(componentId);\r\n if (componentRegs) {\r\n for (const reg of componentRegs) {\r\n if (reg.registration === registration) {\r\n componentRegs.delete(reg);\r\n break;\r\n }\r\n }\r\n if (componentRegs.size === 0) {\r\n componentListeners.delete(componentId);\r\n }\r\n }\r\n }\r\n };\r\n}\r\n\r\n/**\r\n * Remove all listeners registered by a specific component.\r\n * Called automatically when a component is disconnected from the DOM.\r\n *\r\n * @param componentId - The component's unique ID\r\n */\r\nexport function cleanupComponentListeners(componentId: string): void {\r\n const eventListeners = getEventListeners();\r\n const componentListeners = getComponentListeners();\r\n\r\n const componentRegs = componentListeners.get(componentId);\r\n if (!componentRegs) return;\r\n\r\n for (const { event, registration } of componentRegs) {\r\n const listeners = eventListeners.get(event);\r\n if (listeners) {\r\n listeners.delete(registration);\r\n if (listeners.size === 0) {\r\n eventListeners.delete(event);\r\n }\r\n }\r\n }\r\n\r\n componentListeners.delete(componentId);\r\n}\r\n\r\n/**\r\n * Remove all event listeners (useful for testing)\r\n */\r\nexport function clearAllListeners(): void {\r\n getEventListeners().clear();\r\n getComponentListeners().clear();\r\n}\r\n\r\n/**\r\n * Get the count of listeners for an event (useful for debugging)\r\n */\r\nexport function getListenerCount(eventName: string): number {\r\n return getEventListeners().get(eventName)?.size ?? 0;\r\n}\r\n\r\n/**\r\n * Check if an event has any listeners\r\n */\r\nexport function hasListeners(eventName: string): boolean {\r\n return (getEventListeners().get(eventName)?.size ?? 0) > 0;\r\n}\r\n\r\n// ============================================================================\r\n// Factory for Component-Bound Helpers\r\n// ============================================================================\r\n\r\n/**\r\n * Creates event bus helpers bound to a specific component.\r\n * This enables automatic cleanup when the component is disconnected.\r\n *\r\n * @param componentId - The unique ID of the component\r\n * @returns Object containing bound $emit and $listen functions\r\n */\r\nexport function createEventBusHelpers(componentId: string) {\r\n /**\r\n * Emit an event (same as global $emit)\r\n */\r\n function boundEmit<T = unknown>(eventName: string, data?: T): void {\r\n $emit(eventName, data);\r\n }\r\n\r\n /**\r\n * Listen for an event with automatic component tracking\r\n */\r\n function boundListen<T = unknown>(\r\n eventName: string,\r\n callback: EventListener<T>\r\n ): Unsubscribe {\r\n return $listen(eventName, callback, componentId);\r\n }\r\n\r\n return {\r\n $emit: boundEmit,\r\n $listen: boundListen,\r\n };\r\n}\r\n\r\n/**\r\n * Names of event bus helpers (for Function parameter lists)\r\n */\r\nexport const eventBusHelperNames = [\"$emit\", \"$listen\"];\r\n"],"mappings":"AAoFA,SAAS,IAOP,OANK,WAAW,sBACd,WAAW,oBAAsB,CAC/B,yBAAW,IAAI,IACf,kCAAoB,IAAI,MAGrB,WAAW,mBACpB,CAKA,SAAS,IACP,OAAO,IAAc,SACvB,CAKA,SAAS,IAIP,OAAO,IAAc,kBACvB,CAeA,SAAgB,EAAmB,EAAmB,GAEpD,MAAM,EADiB,IACU,IAAI,GACrC,GAAK,GAAgC,IAAnB,EAAU,KAM5B,IAAK,MAAM,KAAgB,EACzB,IACE,EAAa,SAAS,EACxB,CAAA,MAAS,GACP,QAAQ,MACN,8CAA8C,MAC9C,EAEJ,CAEJ,CAuBA,SAAgB,EACd,EACA,EACA,GAEA,MAAM,EAAiB,IACjB,EAAqB,IAG3B,IAAI,EAAY,EAAe,IAAI,GAC9B,IACH,iBAAY,IAAI,IAChB,EAAe,IAAI,EAAW,IAIhC,MAAM,EAAqC,CAC/B,WACV,eAOF,GAHA,EAAU,IAAI,GAGV,EAAa,CACf,IAAI,EAAgB,EAAmB,IAAI,GACtC,IACH,iBAAgB,IAAI,IACpB,EAAmB,IAAI,EAAa,IAEtC,EAAc,IAAI,CAAE,MAAO,EAAW,gBACxC,CAGA,MAAA,KACE,MAAM,EAAiB,IACjB,EAAqB,IAU3B,GARA,GAAW,OAAO,GAGM,IAApB,GAAW,MACb,EAAe,OAAO,GAIpB,EAAa,CACf,MAAM,EAAgB,EAAmB,IAAI,GAC7C,GAAI,EAAe,CACjB,IAAK,MAAM,KAAO,EAChB,GAAI,EAAI,eAAiB,EAAc,CACrC,EAAc,OAAO,GACrB,KACF,CAEyB,IAAvB,EAAc,MAChB,EAAmB,OAAO,EAE9B,CACF,EAEJ,CAQA,SAAgB,EAA0B,GACxC,MAAM,EAAiB,IACjB,EAAqB,IAErB,EAAgB,EAAmB,IAAI,GAC7C,GAAK,EAAL,CAEA,IAAK,MAAM,MAAE,EAAA,aAAO,KAAkB,EAAe,CACnD,MAAM,EAAY,EAAe,IAAI,GACjC,IACF,EAAU,OAAO,GACM,IAAnB,EAAU,MACZ,EAAe,OAAO,GAG5B,CAEA,EAAmB,OAAO,EAZN,CAatB,CAmCA,SAAgB,EAAsB,GAkBpC,MAAO,CACL,MAfF,SAAgC,EAAmB,GACjD,EAAM,EAAW,EACnB,EAcE,QATF,SACE,EACA,GAEA,OAAO,EAAQ,EAAW,EAAU,EACtC,EAMF,CAKA,IAAa,EAAsB,CAAC,QAAS"}