@aegisjsproject/callback-registry 1.0.3 → 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/CHANGELOG.md CHANGED
@@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [v2.0.0] - 2026-03-01
11
+
12
+ ## Added
13
+ - Add support for `DisposableStack` and `AsyncDisposableStack` disposal of keys
14
+
15
+ ### Changed
16
+ - Creating and registering callbacks now returns an object with `[Symbol.dispose]` extending `String`
17
+
10
18
  ## [v1.0.3] - 2025-09-29
11
19
 
12
20
  ### Added
@@ -653,6 +653,9 @@ const FUNCS = {
653
653
  },
654
654
  };
655
655
 
656
+ /**
657
+ * @type {Map<string, function>}
658
+ */
656
659
  const registry = new Map([
657
660
  [FUNCS.debug.log, console.log],
658
661
  [FUNCS.debug.warn, console.warn],
@@ -765,6 +768,12 @@ const registry = new Map([
765
768
  [FUNCS.ui.exitFullsceen, () => document.exitFullscreen()],
766
769
  ]);
767
770
 
771
+ class CallbackRegistryKey extends String {
772
+ [Symbol.dispose]() {
773
+ registry.delete(this.toString());
774
+ }
775
+ }
776
+
768
777
  /**
769
778
  * Check if callback registry is open
770
779
  *
@@ -789,26 +798,26 @@ const listCallbacks = () => Object.freeze(Array.from(registry.keys()));
789
798
  /**
790
799
  * Check if a callback is registered
791
800
  *
792
- * @param {string} name The name/key to check for in callback registry
801
+ * @param {CallbackRegistryKey|string} name The name/key to check for in callback registry
793
802
  * @returns {boolean} Whether or not a callback is registered
794
803
  */
795
- const hasCallback = name => registry.has(name);
804
+ const hasCallback = name => registry.has(name?.toString());
796
805
 
797
806
  /**
798
807
  * Get a callback from the registry by name/key
799
808
  *
800
- * @param {string} name The name/key of the callback to get
809
+ * @param {CallbackRegistryKey|string} name The name/key of the callback to get
801
810
  * @returns {Function|undefined} The corresponding function registered under that name/key
802
811
  */
803
- const getCallback = name => registry.get(name);
812
+ const getCallback = name => registry.get(name?.toString());
804
813
 
805
814
  /**
806
815
  * Remove a callback from the registry
807
816
  *
808
- * @param {string} name The name/key of the callback to get
817
+ * @param {CallbackRegistryKey|string} name The name/key of the callback to get
809
818
  * @returns {boolean} Whether or not the callback was successfully unregisterd
810
819
  */
811
- const unregisterCallback = name => _isRegistrationOpen && registry.delete(name);
820
+ const unregisterCallback = name => _isRegistrationOpen && registry.delete(name?.toString());
812
821
 
813
822
  /**
814
823
  * Remove all callbacks from the registry
@@ -821,21 +830,23 @@ const clearRegistry = () => registry.clear();
821
830
  * Create a registered callback with a randomly generated name
822
831
  *
823
832
  * @param {Function} callback Callback function to register
833
+ * @param {object} [config]
834
+ * @param {DisposableStack|AsyncDisposableStack} [config.stack] Optional `DisposableStack` to handle disposal and unregistering.
824
835
  * @returns {string} The automatically generated key/name of the registered callback
825
836
  */
826
- const createCallback = (callback) => registerCallback('aegis:callback:' + crypto.randomUUID(), callback);
837
+ const createCallback = (callback, { stack } = {}) => registerCallback('aegis:callback:' + crypto.randomUUID(), callback, { stack });
827
838
 
828
839
  /**
829
840
  * Call a callback fromt the registry by name/key
830
841
  *
831
- * @param {string} name The name/key of the registered function
842
+ * @param {CallbackRegistryKey|string} name The name/key of the registered function
832
843
  * @param {...any} args Any arguments to pass along to the function
833
844
  * @returns {any} Whatever the return value of the function is
834
845
  * @throws {Error} Throws if callback is not found or any error resulting from calling the function
835
846
  */
836
847
  function callCallback(name, ...args) {
837
- if (registry.has(name)) {
838
- return registry.get(name).apply(this || globalThis, args);
848
+ if (registry.has(name?.toString())) {
849
+ return registry.get(name?.toString()).apply(this || globalThis, args);
839
850
  } else {
840
851
  throw new Error(`No ${name} function registered.`);
841
852
  }
@@ -844,22 +855,33 @@ function callCallback(name, ...args) {
844
855
  /**
845
856
  * Register a named callback in registry
846
857
  *
847
- * @param {string} name The name/key to register the callback under
858
+ * @param {CallbackRegistryKey|string} name The name/key to register the callback under
848
859
  * @param {Function} callback The callback value to register
860
+ * @param {object} config
861
+ * @param {DisposableStack|AsyncDisposableStack} [config.stack] Optional `DisposableStack` to handle disposal and unregistering.
849
862
  * @returns {string} The registered name/key
850
863
  */
851
- function registerCallback(name, callback) {
852
- if (typeof name !== 'string' || name.length === 0) {
853
- throw new TypeError('Callback name must be a string.');
864
+ function registerCallback(name, callback, { stack } = {}) {
865
+ if (typeof name === 'string') {
866
+ return registerCallback(new CallbackRegistryKey(name), callback, { stack });
867
+ }else if (! (name instanceof CallbackRegistryKey)) {
868
+ throw new TypeError('Callback name must be a disposable string/CallbackRegistryKey.');
854
869
  } if (! (callback instanceof Function)) {
855
870
  throw new TypeError('Callback must be a function.');
856
871
  } else if (! _isRegistrationOpen) {
857
872
  throw new TypeError('Cannot register new callbacks because registry is closed.');
858
- } else if (registry.has(name)) {
873
+ } else if (registry.has(name?.toString())) {
859
874
  throw new Error(`Handler "${name}" is already registered.`);
875
+ } else if (stack instanceof DisposableStack || stack instanceof AsyncDisposableStack) {
876
+ const key = stack.use(new CallbackRegistryKey(name));
877
+ registry.set(key.toString(), callback);
878
+
879
+ return key;
860
880
  } else {
861
- registry.set(name, callback);
862
- return name;
881
+ const key = new CallbackRegistryKey(name);
882
+ registry.set(key.toString(), callback);
883
+
884
+ return key;
863
885
  }
864
886
  }
865
887
 
@@ -883,10 +905,10 @@ function getHost(target) {
883
905
  }
884
906
  }
885
907
 
886
- function on(event, callback, { capture: capture$1 = false, passive: passive$1 = false, once: once$1 = false, signal: signal$1 } = {}) {
908
+ function on(event, callback, { capture: capture$1 = false, passive: passive$1 = false, once: once$1 = false, signal: signal$1, stack } = {}) {
887
909
  if (callback instanceof Function) {
888
- return on(event, createCallback(callback), { capture: capture$1, passive: passive$1, once: once$1, signal: signal$1 });
889
- } else if (typeof callback !== 'string' || callback.length === 0) {
910
+ return on(event, createCallback(callback, { stack }), { capture: capture$1, passive: passive$1, once: once$1, signal: signal$1 });
911
+ } else if (! (callback instanceof String || typeof callback === 'string') || callback.length === 0) {
890
912
  throw new TypeError('Callback must be a function or a registered callback string.');
891
913
  } else if (typeof event !== 'string' || event.length === 0) {
892
914
  throw new TypeError('Event must be a non-empty string.');
@@ -919,6 +941,7 @@ function on(event, callback, { capture: capture$1 = false, passive: passive$1 =
919
941
  }
920
942
  }
921
943
 
944
+ exports.CallbackRegistryKey = CallbackRegistryKey;
922
945
  exports.EVENTS = EVENTS;
923
946
  exports.FUNCS = FUNCS;
924
947
  exports.abortController = abortController;
@@ -1,2 +1,2 @@
1
- const e="data-aegis-event-",t=e+"on-",n="aegisEventOn",o=Symbol("aegis:signal"),r=Symbol("aegis:controller"),a=new Map,i=new Map,s=e+"once",l=e+"passive",c=e+"capture",u=e+"signal",g=e+"controller",d=t+"abort",p=t+"blur",b=t+"focus",m=t+"cancel",h=t+"auxclick",f=t+"beforeinput",v=t+"beforetoggle",y=t+"canplay",w=t+"canplaythrough",T=t+"change",E=t+"click",S=t+"close",k=t+"command",A=t+"contextmenu",P=t+"copy",C=t+"cuechange",F=t+"cut",M=t+"dblclick",L=t+"drag",D=t+"dragend",O=t+"dragenter",q=t+"dragexit",I=t+"dragleave",x=t+"dragover",N=t+"dragstart",U=t+"drop",R=t+"durationchange",j=t+"emptied",$=t+"ended",z=t+"formdata",W=t+"input",H=t+"invalid",V=t+"keydown",B=t+"keypress",K=t+"keyup",G=t+"load",_=t+"loadeddata",J=t+"loadedmetadata",Q=t+"loadstart",X=t+"mousedown",Y=t+"mouseenter",Z=t+"mouseleave",ee=t+"mousemove",te=t+"mouseout",ne=t+"mouseover",oe=t+"mouseup",re=t+"wheel",ae=t+"paste",ie=t+"pause",se=t+"play",le=t+"playing",ce=t+"progress",ue=t+"ratechange",ge=t+"reset",de=t+"resize",pe=t+"scroll",be=t+"scrollend",me=t+"securitypolicyviolation",he=t+"seeked",fe=t+"seeking",ve=t+"select",ye=t+"slotchange",we=t+"stalled",Te=t+"submit",Ee=t+"suspend",Se=t+"timeupdate",ke=t+"volumechange",Ae=t+"waiting",Pe=t+"selectstart",Ce=t+"selectionchange",Fe=t+"toggle",Me=t+"pointercancel",Le=t+"pointerdown",De=t+"pointerup",Oe=t+"pointermove",qe=t+"pointerout",Ie=t+"pointerover",xe=t+"pointerenter",Ne=t+"pointerleave",Ue=t+"gotpointercapture",Re=t+"lostpointercapture",je=t+"mozfullscreenchange",$e=t+"mozfullscreenerror",ze=t+"animationcancel",We=t+"animationend",He=t+"animationiteration",Ve=t+"animationstart",Be=t+"transitioncancel",Ke=t+"transitionend",Ge=t+"transitionrun",_e=t+"transitionstart",Je=t+"webkitanimationend",Qe=t+"webkitanimationiteration",Xe=t+"webkitanimationstart",Ye=t+"webkittransitionend",Ze=t+"error",et=[d,p,b,m,h,f,v,y,w,T,E,S,k,A,P,C,F,M,L,D,O,q,I,x,N,U,R,j,$,z,W,H,V,B,K,G,_,J,Q,X,Y,Z,ee,te,ne,oe,re,ae,ie,se,le,ce,ue,ge,de,pe,be,me,he,fe,ve,ye,we,Te,Ee,Se,ke,Ae,Pe,Ce,Fe,Me,Le,De,Oe,qe,Ie,xe,Ne,Ue,Re,je,$e,ze,We,He,Ve,Be,Ke,Ge,_e,Je,Qe,Xe,Ye,Ze];let tt=et.map((e=>`[${CSS.escape(e)}]`)).join(", ");const nt=e=>t+e,ot=e=>et.includes(t+e),rt=([e])=>e.startsWith(n);function at(e,{signal:t,attrFilter:n=st}={}){const o=e.dataset;for(const[r,a]of Object.entries(o).filter(rt))try{const i="on"+r.substring(12);n.hasOwnProperty(i)&&Dt(a)&&e.addEventListener(i.substring(2).toLowerCase(),Ot(a),{passive:o.hasOwnProperty("aegisEventPassive"),capture:o.hasOwnProperty("aegisEventCapture"),once:o.hasOwnProperty("aegisEventOnce"),signal:o.hasOwnProperty("aegisEventSignal")?mt(o.aegisEventSignal):t})}catch(e){reportError(e)}}const it=new MutationObserver((e=>{e.forEach((e=>{switch(e.type){case"childList":[...e.addedNodes].filter((e=>e.nodeType===Node.ELEMENT_NODE)).forEach((e=>ft(e)));break;case"attributes":"string"==typeof e.oldValue&&Dt(e.oldValue)&&e.target.removeEventListener(e.attributeName.substring(20),Ot(e.oldValue),{once:e.target.hasAttribute(s),capture:e.target.hasAttribute(c),passive:e.target.hasAttribute(l)}),e.target.hasAttribute(e.attributeName)&&Dt(e.target.getAttribute(e.attributeName))&&e.target.addEventListener(e.attributeName.substring(20),Ot(e.target.getAttribute(e.attributeName)),{once:e.target.hasAttribute(s),capture:e.target.hasAttribute(c),passive:e.target.hasAttribute(l),signal:e.target.hasAttribute(u)?mt(e.target.getAttribute(u)):void 0})}}))})),st={onAbort:d,onBlur:p,onFocus:b,onCancel:m,onAuxclick:h,onBeforeinput:f,onBeforetoggle:v,onCanplay:y,onCanplaythrough:w,onChange:T,onClick:E,onClose:S,onCommand:k,onContextmenu:A,onCopy:P,onCuechange:C,onCut:F,onDblclick:M,onDrag:L,onDragend:D,onDragenter:O,onDragexit:q,onDragleave:I,onDragover:x,onDragstart:N,onDrop:U,onDurationchange:R,onEmptied:j,onEnded:$,onFormdata:z,onInput:W,onInvalid:H,onKeydown:V,onKeypress:B,onKeyup:K,onLoad:G,onLoadeddata:_,onLoadedmetadata:J,onLoadstart:Q,onMousedown:X,onMouseenter:Y,onMouseleave:Z,onMousemove:ee,onMouseout:te,onMouseover:ne,onMouseup:oe,onWheel:re,onPaste:ae,onPause:ie,onPlay:se,onPlaying:le,onProgress:ce,onRatechange:ue,onReset:ge,onResize:de,onScroll:pe,onScrollend:be,onSecuritypolicyviolation:me,onSeeked:he,onSeeking:fe,onSelect:ve,onSlotchange:ye,onStalled:we,onSubmit:Te,onSuspend:Ee,onTimeupdate:Se,onVolumechange:ke,onWaiting:Ae,onSelectstart:Pe,onSelectionchange:Ce,onToggle:Fe,onPointercancel:Me,onPointerdown:Le,onPointerup:De,onPointermove:Oe,onPointerout:qe,onPointerover:Ie,onPointerenter:xe,onPointerleave:Ne,onGotpointercapture:Ue,onLostpointercapture:Re,onMozfullscreenchange:je,onMozfullscreenerror:$e,onAnimationcancel:ze,onAnimationend:We,onAnimationiteration:He,onAnimationstart:Ve,onTransitioncancel:Be,onTransitionend:Ke,onTransitionrun:Ge,onTransitionstart:_e,onWebkitanimationend:Je,onWebkitanimationiteration:Qe,onWebkitanimationstart:Xe,onWebkittransitionend:Ye,onError:Ze,once:s,passive:l,capture:c};function lt(e,{addListeners:n=!1,base:o=document.body,signal:r}={}){const a=t+e.toLowerCase();if(!et.includes(a)){const e=`[${CSS.escape(a)}]`,t=(e=>`on${e[20].toUpperCase()}${e.substring(21)}`)(a);et.push(a),st[t]=a,tt+=`, ${e}`,n&&requestAnimationFrame((()=>{const n={attrFilter:{[t]:e},signal:r};[o,...o.querySelectorAll(e)].forEach((e=>at(e,n)))}))}return a}function ct(e){if(e instanceof AbortController){if(e.signal.aborted)throw e.signal.reason;if("string"==typeof e.signal[r])return e.signal[r];{const t="aegis:event:controller:"+crypto.randomUUID();return Object.defineProperty(e.signal,r,{value:t,writable:!1,enumerable:!1}),i.set(t,e),e.signal.addEventListener("abort",ut,{once:!0}),t}}throw new TypeError("Controller is not an `AbortSignal.")}function ut(e){return e instanceof AbortController?i.delete(e.signal[r]):e instanceof AbortSignal?i.delete(e[r]):i.delete(e)}function gt({signal:e}={}){const t=new AbortController;return e instanceof AbortSignal&&e.addEventListener("abort",(({target:e})=>t.abort(e.reason)),{signal:t.signal}),ct(t)}const dt=e=>i.get(e);function pt(e,t){const n=dt(e);return n instanceof AbortController&&("string"==typeof t?(n.abort(new Error(t)),!0):(n.abort(t),!0))}function bt(e){if(e instanceof AbortSignal){if("string"==typeof e[o])return e[o];{const t="aegis:event:signal:"+crypto.randomUUID();return Object.defineProperty(e,o,{value:t,writable:!1,enumerable:!1}),a.set(t,e),e.addEventListener("abort",(({target:e})=>ht(e[o])),{once:!0}),t}}throw new TypeError("Signal must be an `AbortSignal`.")}const mt=e=>a.get(e);function ht(e){if(e instanceof AbortSignal)return a.delete(e[o]);if("string"==typeof e)return a.delete(e);throw new TypeError("Signal must be an `AbortSignal` or registered key/attribute.")}function ft(e,{signal:t}={}){return(e instanceof Element&&e.matches(tt)?[e,...e.querySelectorAll(tt)]:e.querySelectorAll(tt)).forEach((e=>at(e,{signal:t}))),e}function vt(e=document){ft(e),it.observe(e,{subtree:!0,childList:!0,attributes:!0,attributeOldValue:!0,attributeFilter:et})}const yt=()=>it.disconnect();function wt(e,{capture:t,once:n,passive:o,signal:r}={}){if(!(e instanceof Function))throw new TypeError("Callback is not a function.");globalThis.addEventListener("error",e,{capture:t,once:n,passive:o,signal:r})}let Tt=!0;const Et=(e,t=document)=>t.querySelectorAll(e),St=(e,t=document)=>t.querySelector(e),kt={attr:"data-request-fullscreen-selector",data:"requestFullscreenSelector"},At={attr:"data-toggle-fullscreen-selector",data:"toggleFullscreenSelector"},Pt={debug:{log:"aegis:debug:log",info:"aegis:debug:info",warn:"aegis:debug:warn",error:"aegis:debug:error"},navigate:{back:"aegis:navigate:back",forward:"aegis:navigate:forward",reload:"aegis:navigate:reload",close:"aegis:navigate:close",link:"aegis:navigate:go",popup:"aegis:navigate:popup"},ui:{command:"aegis:ui:command",print:"aegis:ui:print",remove:"aegis:ui:remove",hide:"aegis:ui:hide",unhide:"aegis:ui:unhide",showModal:"aegis:ui:showModal",closeModal:"aegis:ui:closeModal",showPopover:"aegis:ui:showPopover",hidePopover:"aegis:ui:hidePopover",togglePopover:"aegis:ui:togglePopover",enable:"aegis:ui:enable",disable:"aegis:ui:disable",scrollTo:"aegis:ui:scrollTo",prevent:"aegis:ui:prevent",revokeObjectURL:"aegis:ui:revokeObjectURL",cancelAnimationFrame:"aegis:ui:cancelAnimationFrame",requestFullscreen:"aegis:ui:requestFullscreen",toggleFullscreen:"aegis:ui:toggleFullsceen",exitFullsceen:"aegis:ui:exitFullscreen",open:"aegis:ui:open",close:"aegis:ui:close",abortController:"aegis:ui:controller:abort"}},Ct=new Map([[Pt.debug.log,console.log],[Pt.debug.warn,console.warn],[Pt.debug.error,console.error],[Pt.debug.info,console.info],[Pt.navigate.back,()=>history.back()],[Pt.navigate.forward,()=>history.forward()],[Pt.navigate.reload,()=>history.go(0)],[Pt.navigate.close,()=>globalThis.close()],[Pt.navigate.link,e=>{e.isTrusted&&(e.preventDefault(),location.href=e.currentTarget.dataset.url)}],[Pt.navigate.popup,e=>{e.isTrusted&&(e.preventDefault(),globalThis.open(e.currentTarget.dataset.url))}],[Pt.ui.hide,({currentTarget:e})=>{Et(e.dataset.hideSelector).forEach((e=>e.hidden=!0))}],[Pt.ui.unhide,({currentTarget:e})=>{Et(e.dataset.unhideSelector).forEach((e=>e.hidden=!1))}],[Pt.ui.disable,({currentTarget:e})=>{Et(e.dataset.disableSelector).forEach((e=>e.disabled=!0))}],[Pt.ui.enable,({currentTarget:e})=>{Et(e.dataset.enableSelector).forEach((e=>e.disabled=!1))}],[Pt.ui.remove,({currentTarget:e})=>{Et(e.dataset.removeSelector).forEach((e=>e.remove()))}],[Pt.ui.scrollTo,({currentTarget:e})=>{const t=St(e.dataset.scrollToSelector);t instanceof Element&&t.scrollIntoView({behavior:matchMedia("(prefers-reduced-motion: reduce)").matches?"instant":"smooth"})}],[Pt.ui.revokeObjectURL,({currentTarget:e})=>URL.revokeObjectURL(e.src)],[Pt.ui.cancelAnimationFrame,({currentTarget:e})=>cancelAnimationFrame(parseInt(e.dataset.animationFrame))],[Pt.ui.clearInterval,({currentTarget:e})=>clearInterval(parseInt(e.dataset.clearInterval))],[Pt.ui.clearTimeout,({currentTarget:e})=>clearTimeout(parseInt(e.dataset.timeout))],[Pt.ui.abortController,({currentTarget:e})=>pt(e.dataset.aegisEventController,e.dataset.aegisControllerReason)],[Pt.ui.open,({currentTarget:e})=>document.querySelector(e.dataset.openSelector).open=!0],[Pt.ui.close,({currentTarget:e})=>document.querySelector(e.dataset.closeSelector).open=!1],[Pt.ui.showModal,({currentTarget:e})=>{const t=St(e.dataset.showModalSelector);t instanceof HTMLDialogElement&&t.showModal()}],[Pt.ui.closeModal,({currentTarget:e})=>{const t=St(e.dataset.closeModalSelector);t instanceof HTMLDialogElement&&t.close()}],[Pt.ui.showPopover,({currentTarget:e})=>{const t=St(e.dataset.showPopoverSelector);t instanceof HTMLElement&&t.showPopover()}],[Pt.ui.hidePopover,({currentTarget:e})=>{const t=St(e.dataset.hidePopoverSelector);t instanceof HTMLElement&&t.hidePopover()}],[Pt.ui.togglePopover,({currentTarget:e})=>{const t=St(e.dataset.togglePopoverSelector);t instanceof HTMLElement&&t.togglePopover()}],[Pt.ui.print,()=>globalThis.print()],[Pt.ui.prevent,e=>e.preventDefault()],[Pt.ui.requestFullscreen,({currentTarget:e})=>{e.dataset.hasOwnProperty(kt.data)?document.getElementById(e.dataset[kt.data]).requestFullscreen():e.requestFullscreen()}],[Pt.ui.toggleFullscreen,({currentTarget:e})=>{const t=e.dataset.hasOwnProperty(At.data)?document.getElementById(e.dataset[At.data]):e;t.isSameNode(document.fullscreenElement)?document.exitFullscreen():t.requestFullscreen()}],[Pt.ui.exitFullsceen,()=>document.exitFullscreen()]]),Ft=()=>Tt,Mt=()=>Tt=!1,Lt=()=>Object.freeze(Array.from(Ct.keys())),Dt=e=>Ct.has(e),Ot=e=>Ct.get(e),qt=e=>Tt&&Ct.delete(e),It=()=>Ct.clear(),xt=e=>Ut("aegis:callback:"+crypto.randomUUID(),e);function Nt(e,...t){if(Ct.has(e))return Ct.get(e).apply(this||globalThis,t);throw new Error(`No ${e} function registered.`)}function Ut(e,t){if("string"!=typeof e||0===e.length)throw new TypeError("Callback name must be a string.");if(t instanceof Function){if(Tt){if(Ct.has(e))throw new Error(`Handler "${e}" is already registered.`);return Ct.set(e,t),e}throw new TypeError("Cannot register new callbacks because registry is closed.")}throw new TypeError("Callback must be a function.")}function Rt(e){return e instanceof Event?Rt(e.currentTarget):e instanceof Document?e:e instanceof Element?Rt(e.getRootNode()):e instanceof ShadowRoot?e.host:null}function jt(e,t,{capture:n=!1,passive:o=!1,once:r=!1,signal:a}={}){if(t instanceof Function)return jt(e,xt(t),{capture:n,passive:o,once:r,signal:a});if("string"!=typeof t||0===t.length)throw new TypeError("Callback must be a function or a registered callback string.");if("string"!=typeof e||0===e.length)throw new TypeError("Event must be a non-empty string.");{ot(e)||lt(e);const i=[[nt(e),t]];return n&&i.push([c,""]),o&&i.push([l,""]),r&&i.push([s,""]),a instanceof AbortSignal?i.push([u,bt(a)]):"string"==typeof a&&i.push([u,a]),i.map((([e,t])=>`${e}="${t}"`)).join(" ")}}export{st as EVENTS,Pt as FUNCS,pt as abortController,ft as attachListeners,Nt as callCallback,c as capture,It as clearRegistry,Mt as closeRegistration,g as controller,xt as createCallback,gt as createController,yt as disconnectEventsObserver,et as eventAttrs,nt as eventToProp,Ot as getCallback,dt as getController,Rt as getHost,mt as getSignal,Dt as hasCallback,ot as hasEventAttribute,Ft as isRegistrationOpen,Lt as listCallbacks,vt as observeEvents,jt as on,d as onAbort,ze as onAnimationcancel,We as onAnimationend,He as onAnimationiteration,Ve as onAnimationstart,h as onAuxclick,f as onBeforeinput,v as onBeforetoggle,p as onBlur,m as onCancel,y as onCanplay,w as onCanplaythrough,T as onChange,E as onClick,S as onClose,k as onCommand,A as onContextmenu,P as onCopy,C as onCuechange,F as onCut,M as onDblclick,L as onDrag,D as onDragend,O as onDragenter,q as onDragexit,I as onDragleave,x as onDragover,N as onDragstart,U as onDrop,R as onDurationchange,j as onEmptied,$ as onEnded,Ze as onError,b as onFocus,z as onFormdata,Ue as onGotpointercapture,W as onInput,H as onInvalid,V as onKeydown,B as onKeypress,K as onKeyup,G as onLoad,_ as onLoadeddata,J as onLoadedmetadata,Q as onLoadstart,Re as onLostpointercapture,X as onMousedown,Y as onMouseenter,Z as onMouseleave,ee as onMousemove,te as onMouseout,ne as onMouseover,oe as onMouseup,je as onMozfullscreenchange,$e as onMozfullscreenerror,ae as onPaste,ie as onPause,se as onPlay,le as onPlaying,Me as onPointercancel,Le as onPointerdown,xe as onPointerenter,Ne as onPointerleave,Oe as onPointermove,qe as onPointerout,Ie as onPointerover,De as onPointerup,ce as onProgress,ue as onRatechange,ge as onReset,de as onResize,pe as onScroll,be as onScrollend,me as onSecuritypolicyviolation,he as onSeeked,fe as onSeeking,ve as onSelect,Ce as onSelectionchange,Pe as onSelectstart,ye as onSlotchange,we as onStalled,Te as onSubmit,Ee as onSuspend,Se as onTimeupdate,Fe as onToggle,Be as onTransitioncancel,Ke as onTransitionend,Ge as onTransitionrun,_e as onTransitionstart,ke as onVolumechange,Ae as onWaiting,Je as onWebkitanimationend,Qe as onWebkitanimationiteration,Xe as onWebkitanimationstart,Ye as onWebkittransitionend,re as onWheel,s as once,l as passive,Ut as registerCallback,ct as registerController,lt as registerEventAttribute,bt as registerSignal,kt as requestFullscreen,wt as setGlobalErrorHandler,u as signal,At as toggleFullsceen,qt as unregisterCallback,ut as unregisterController,ht as unregisterSignal};
1
+ const e="data-aegis-event-",t=e+"on-",n="aegisEventOn",o=Symbol("aegis:signal"),r=Symbol("aegis:controller"),a=new Map,i=new Map,s=e+"once",l=e+"passive",c=e+"capture",u=e+"signal",g=e+"controller",d=t+"abort",p=t+"blur",b=t+"focus",m=t+"cancel",h=t+"auxclick",f=t+"beforeinput",v=t+"beforetoggle",y=t+"canplay",w=t+"canplaythrough",S=t+"change",T=t+"click",E=t+"close",k=t+"command",A=t+"contextmenu",P=t+"copy",C=t+"cuechange",F=t+"cut",M=t+"dblclick",L=t+"drag",D=t+"dragend",O=t+"dragenter",q=t+"dragexit",I=t+"dragleave",x=t+"dragover",N=t+"dragstart",R=t+"drop",U=t+"durationchange",j=t+"emptied",$=t+"ended",z=t+"formdata",W=t+"input",H=t+"invalid",V=t+"keydown",B=t+"keypress",K=t+"keyup",G=t+"load",_=t+"loadeddata",J=t+"loadedmetadata",Q=t+"loadstart",X=t+"mousedown",Y=t+"mouseenter",Z=t+"mouseleave",ee=t+"mousemove",te=t+"mouseout",ne=t+"mouseover",oe=t+"mouseup",re=t+"wheel",ae=t+"paste",ie=t+"pause",se=t+"play",le=t+"playing",ce=t+"progress",ue=t+"ratechange",ge=t+"reset",de=t+"resize",pe=t+"scroll",be=t+"scrollend",me=t+"securitypolicyviolation",he=t+"seeked",fe=t+"seeking",ve=t+"select",ye=t+"slotchange",we=t+"stalled",Se=t+"submit",Te=t+"suspend",Ee=t+"timeupdate",ke=t+"volumechange",Ae=t+"waiting",Pe=t+"selectstart",Ce=t+"selectionchange",Fe=t+"toggle",Me=t+"pointercancel",Le=t+"pointerdown",De=t+"pointerup",Oe=t+"pointermove",qe=t+"pointerout",Ie=t+"pointerover",xe=t+"pointerenter",Ne=t+"pointerleave",Re=t+"gotpointercapture",Ue=t+"lostpointercapture",je=t+"mozfullscreenchange",$e=t+"mozfullscreenerror",ze=t+"animationcancel",We=t+"animationend",He=t+"animationiteration",Ve=t+"animationstart",Be=t+"transitioncancel",Ke=t+"transitionend",Ge=t+"transitionrun",_e=t+"transitionstart",Je=t+"webkitanimationend",Qe=t+"webkitanimationiteration",Xe=t+"webkitanimationstart",Ye=t+"webkittransitionend",Ze=t+"error",et=[d,p,b,m,h,f,v,y,w,S,T,E,k,A,P,C,F,M,L,D,O,q,I,x,N,R,U,j,$,z,W,H,V,B,K,G,_,J,Q,X,Y,Z,ee,te,ne,oe,re,ae,ie,se,le,ce,ue,ge,de,pe,be,me,he,fe,ve,ye,we,Se,Te,Ee,ke,Ae,Pe,Ce,Fe,Me,Le,De,Oe,qe,Ie,xe,Ne,Re,Ue,je,$e,ze,We,He,Ve,Be,Ke,Ge,_e,Je,Qe,Xe,Ye,Ze];let tt=et.map(e=>`[${CSS.escape(e)}]`).join(", ");const nt=e=>t+e,ot=e=>et.includes(t+e),rt=([e])=>e.startsWith(n);function at(e,{signal:t,attrFilter:n=st}={}){const o=e.dataset;for(const[r,a]of Object.entries(o).filter(rt))try{const i="on"+r.substring(12);n.hasOwnProperty(i)&&Ot(a)&&e.addEventListener(i.substring(2).toLowerCase(),qt(a),{passive:o.hasOwnProperty("aegisEventPassive"),capture:o.hasOwnProperty("aegisEventCapture"),once:o.hasOwnProperty("aegisEventOnce"),signal:o.hasOwnProperty("aegisEventSignal")?mt(o.aegisEventSignal):t})}catch(e){reportError(e)}}const it=new MutationObserver(e=>{e.forEach(e=>{switch(e.type){case"childList":[...e.addedNodes].filter(e=>e.nodeType===Node.ELEMENT_NODE).forEach(e=>ft(e));break;case"attributes":"string"==typeof e.oldValue&&Ot(e.oldValue)&&e.target.removeEventListener(e.attributeName.substring(20),qt(e.oldValue),{once:e.target.hasAttribute(s),capture:e.target.hasAttribute(c),passive:e.target.hasAttribute(l)}),e.target.hasAttribute(e.attributeName)&&Ot(e.target.getAttribute(e.attributeName))&&e.target.addEventListener(e.attributeName.substring(20),qt(e.target.getAttribute(e.attributeName)),{once:e.target.hasAttribute(s),capture:e.target.hasAttribute(c),passive:e.target.hasAttribute(l),signal:e.target.hasAttribute(u)?mt(e.target.getAttribute(u)):void 0})}})}),st={onAbort:d,onBlur:p,onFocus:b,onCancel:m,onAuxclick:h,onBeforeinput:f,onBeforetoggle:v,onCanplay:y,onCanplaythrough:w,onChange:S,onClick:T,onClose:E,onCommand:k,onContextmenu:A,onCopy:P,onCuechange:C,onCut:F,onDblclick:M,onDrag:L,onDragend:D,onDragenter:O,onDragexit:q,onDragleave:I,onDragover:x,onDragstart:N,onDrop:R,onDurationchange:U,onEmptied:j,onEnded:$,onFormdata:z,onInput:W,onInvalid:H,onKeydown:V,onKeypress:B,onKeyup:K,onLoad:G,onLoadeddata:_,onLoadedmetadata:J,onLoadstart:Q,onMousedown:X,onMouseenter:Y,onMouseleave:Z,onMousemove:ee,onMouseout:te,onMouseover:ne,onMouseup:oe,onWheel:re,onPaste:ae,onPause:ie,onPlay:se,onPlaying:le,onProgress:ce,onRatechange:ue,onReset:ge,onResize:de,onScroll:pe,onScrollend:be,onSecuritypolicyviolation:me,onSeeked:he,onSeeking:fe,onSelect:ve,onSlotchange:ye,onStalled:we,onSubmit:Se,onSuspend:Te,onTimeupdate:Ee,onVolumechange:ke,onWaiting:Ae,onSelectstart:Pe,onSelectionchange:Ce,onToggle:Fe,onPointercancel:Me,onPointerdown:Le,onPointerup:De,onPointermove:Oe,onPointerout:qe,onPointerover:Ie,onPointerenter:xe,onPointerleave:Ne,onGotpointercapture:Re,onLostpointercapture:Ue,onMozfullscreenchange:je,onMozfullscreenerror:$e,onAnimationcancel:ze,onAnimationend:We,onAnimationiteration:He,onAnimationstart:Ve,onTransitioncancel:Be,onTransitionend:Ke,onTransitionrun:Ge,onTransitionstart:_e,onWebkitanimationend:Je,onWebkitanimationiteration:Qe,onWebkitanimationstart:Xe,onWebkittransitionend:Ye,onError:Ze,once:s,passive:l,capture:c};function lt(e,{addListeners:n=!1,base:o=document.body,signal:r}={}){const a=t+e.toLowerCase();if(!et.includes(a)){const e=`[${CSS.escape(a)}]`,t=(e=>`on${e[20].toUpperCase()}${e.substring(21)}`)(a);et.push(a),st[t]=a,tt+=`, ${e}`,n&&requestAnimationFrame(()=>{const n={attrFilter:{[t]:e},signal:r};[o,...o.querySelectorAll(e)].forEach(e=>at(e,n))})}return a}function ct(e){if(e instanceof AbortController){if(e.signal.aborted)throw e.signal.reason;if("string"==typeof e.signal[r])return e.signal[r];{const t="aegis:event:controller:"+crypto.randomUUID();return Object.defineProperty(e.signal,r,{value:t,writable:!1,enumerable:!1}),i.set(t,e),e.signal.addEventListener("abort",ut,{once:!0}),t}}throw new TypeError("Controller is not an `AbortSignal.")}function ut(e){return e instanceof AbortController?i.delete(e.signal[r]):e instanceof AbortSignal?i.delete(e[r]):i.delete(e)}function gt({signal:e}={}){const t=new AbortController;return e instanceof AbortSignal&&e.addEventListener("abort",({target:e})=>t.abort(e.reason),{signal:t.signal}),ct(t)}const dt=e=>i.get(e);function pt(e,t){const n=dt(e);return n instanceof AbortController&&("string"==typeof t?(n.abort(new Error(t)),!0):(n.abort(t),!0))}function bt(e){if(e instanceof AbortSignal){if("string"==typeof e[o])return e[o];{const t="aegis:event:signal:"+crypto.randomUUID();return Object.defineProperty(e,o,{value:t,writable:!1,enumerable:!1}),a.set(t,e),e.addEventListener("abort",({target:e})=>ht(e[o]),{once:!0}),t}}throw new TypeError("Signal must be an `AbortSignal`.")}const mt=e=>a.get(e);function ht(e){if(e instanceof AbortSignal)return a.delete(e[o]);if("string"==typeof e)return a.delete(e);throw new TypeError("Signal must be an `AbortSignal` or registered key/attribute.")}function ft(e,{signal:t}={}){return(e instanceof Element&&e.matches(tt)?[e,...e.querySelectorAll(tt)]:e.querySelectorAll(tt)).forEach(e=>at(e,{signal:t})),e}function vt(e=document){ft(e),it.observe(e,{subtree:!0,childList:!0,attributes:!0,attributeOldValue:!0,attributeFilter:et})}const yt=()=>it.disconnect();function wt(e,{capture:t,once:n,passive:o,signal:r}={}){if(!(e instanceof Function))throw new TypeError("Callback is not a function.");globalThis.addEventListener("error",e,{capture:t,once:n,passive:o,signal:r})}let St=!0;const Tt=(e,t=document)=>t.querySelectorAll(e),Et=(e,t=document)=>t.querySelector(e),kt={attr:"data-request-fullscreen-selector",data:"requestFullscreenSelector"},At={attr:"data-toggle-fullscreen-selector",data:"toggleFullscreenSelector"},Pt={debug:{log:"aegis:debug:log",info:"aegis:debug:info",warn:"aegis:debug:warn",error:"aegis:debug:error"},navigate:{back:"aegis:navigate:back",forward:"aegis:navigate:forward",reload:"aegis:navigate:reload",close:"aegis:navigate:close",link:"aegis:navigate:go",popup:"aegis:navigate:popup"},ui:{command:"aegis:ui:command",print:"aegis:ui:print",remove:"aegis:ui:remove",hide:"aegis:ui:hide",unhide:"aegis:ui:unhide",showModal:"aegis:ui:showModal",closeModal:"aegis:ui:closeModal",showPopover:"aegis:ui:showPopover",hidePopover:"aegis:ui:hidePopover",togglePopover:"aegis:ui:togglePopover",enable:"aegis:ui:enable",disable:"aegis:ui:disable",scrollTo:"aegis:ui:scrollTo",prevent:"aegis:ui:prevent",revokeObjectURL:"aegis:ui:revokeObjectURL",cancelAnimationFrame:"aegis:ui:cancelAnimationFrame",requestFullscreen:"aegis:ui:requestFullscreen",toggleFullscreen:"aegis:ui:toggleFullsceen",exitFullsceen:"aegis:ui:exitFullscreen",open:"aegis:ui:open",close:"aegis:ui:close",abortController:"aegis:ui:controller:abort"}},Ct=new Map([[Pt.debug.log,console.log],[Pt.debug.warn,console.warn],[Pt.debug.error,console.error],[Pt.debug.info,console.info],[Pt.navigate.back,()=>history.back()],[Pt.navigate.forward,()=>history.forward()],[Pt.navigate.reload,()=>history.go(0)],[Pt.navigate.close,()=>globalThis.close()],[Pt.navigate.link,e=>{e.isTrusted&&(e.preventDefault(),location.href=e.currentTarget.dataset.url)}],[Pt.navigate.popup,e=>{e.isTrusted&&(e.preventDefault(),globalThis.open(e.currentTarget.dataset.url))}],[Pt.ui.hide,({currentTarget:e})=>{Tt(e.dataset.hideSelector).forEach(e=>e.hidden=!0)}],[Pt.ui.unhide,({currentTarget:e})=>{Tt(e.dataset.unhideSelector).forEach(e=>e.hidden=!1)}],[Pt.ui.disable,({currentTarget:e})=>{Tt(e.dataset.disableSelector).forEach(e=>e.disabled=!0)}],[Pt.ui.enable,({currentTarget:e})=>{Tt(e.dataset.enableSelector).forEach(e=>e.disabled=!1)}],[Pt.ui.remove,({currentTarget:e})=>{Tt(e.dataset.removeSelector).forEach(e=>e.remove())}],[Pt.ui.scrollTo,({currentTarget:e})=>{const t=Et(e.dataset.scrollToSelector);t instanceof Element&&t.scrollIntoView({behavior:matchMedia("(prefers-reduced-motion: reduce)").matches?"instant":"smooth"})}],[Pt.ui.revokeObjectURL,({currentTarget:e})=>URL.revokeObjectURL(e.src)],[Pt.ui.cancelAnimationFrame,({currentTarget:e})=>cancelAnimationFrame(parseInt(e.dataset.animationFrame))],[Pt.ui.clearInterval,({currentTarget:e})=>clearInterval(parseInt(e.dataset.clearInterval))],[Pt.ui.clearTimeout,({currentTarget:e})=>clearTimeout(parseInt(e.dataset.timeout))],[Pt.ui.abortController,({currentTarget:e})=>pt(e.dataset.aegisEventController,e.dataset.aegisControllerReason)],[Pt.ui.open,({currentTarget:e})=>document.querySelector(e.dataset.openSelector).open=!0],[Pt.ui.close,({currentTarget:e})=>document.querySelector(e.dataset.closeSelector).open=!1],[Pt.ui.showModal,({currentTarget:e})=>{const t=Et(e.dataset.showModalSelector);t instanceof HTMLDialogElement&&t.showModal()}],[Pt.ui.closeModal,({currentTarget:e})=>{const t=Et(e.dataset.closeModalSelector);t instanceof HTMLDialogElement&&t.close()}],[Pt.ui.showPopover,({currentTarget:e})=>{const t=Et(e.dataset.showPopoverSelector);t instanceof HTMLElement&&t.showPopover()}],[Pt.ui.hidePopover,({currentTarget:e})=>{const t=Et(e.dataset.hidePopoverSelector);t instanceof HTMLElement&&t.hidePopover()}],[Pt.ui.togglePopover,({currentTarget:e})=>{const t=Et(e.dataset.togglePopoverSelector);t instanceof HTMLElement&&t.togglePopover()}],[Pt.ui.print,()=>globalThis.print()],[Pt.ui.prevent,e=>e.preventDefault()],[Pt.ui.requestFullscreen,({currentTarget:e})=>{e.dataset.hasOwnProperty(kt.data)?document.getElementById(e.dataset[kt.data]).requestFullscreen():e.requestFullscreen()}],[Pt.ui.toggleFullscreen,({currentTarget:e})=>{const t=e.dataset.hasOwnProperty(At.data)?document.getElementById(e.dataset[At.data]):e;t.isSameNode(document.fullscreenElement)?document.exitFullscreen():t.requestFullscreen()}],[Pt.ui.exitFullsceen,()=>document.exitFullscreen()]]);class Ft extends String{[Symbol.dispose](){Ct.delete(this.toString())}}const Mt=()=>St,Lt=()=>St=!1,Dt=()=>Object.freeze(Array.from(Ct.keys())),Ot=e=>Ct.has(e?.toString()),qt=e=>Ct.get(e?.toString()),It=e=>St&&Ct.delete(e?.toString()),xt=()=>Ct.clear(),Nt=(e,{stack:t}={})=>Ut("aegis:callback:"+crypto.randomUUID(),e,{stack:t});function Rt(e,...t){if(Ct.has(e?.toString()))return Ct.get(e?.toString()).apply(this||globalThis,t);throw new Error(`No ${e} function registered.`)}function Ut(e,t,{stack:n}={}){if("string"==typeof e)return Ut(new Ft(e),t,{stack:n});if(!(e instanceof Ft))throw new TypeError("Callback name must be a disposable string/CallbackRegistryKey.");if(t instanceof Function){if(St){if(Ct.has(e?.toString()))throw new Error(`Handler "${e}" is already registered.`);if(n instanceof DisposableStack||n instanceof AsyncDisposableStack){const o=n.use(new Ft(e));return Ct.set(o.toString(),t),o}{const n=new Ft(e);return Ct.set(n.toString(),t),n}}throw new TypeError("Cannot register new callbacks because registry is closed.")}throw new TypeError("Callback must be a function.")}function jt(e){return e instanceof Event?jt(e.currentTarget):e instanceof Document?e:e instanceof Element?jt(e.getRootNode()):e instanceof ShadowRoot?e.host:null}function $t(e,t,{capture:n=!1,passive:o=!1,once:r=!1,signal:a,stack:i}={}){if(t instanceof Function)return $t(e,Nt(t,{stack:i}),{capture:n,passive:o,once:r,signal:a});if((t instanceof String||"string"==typeof t)&&0!==t.length){if("string"!=typeof e||0===e.length)throw new TypeError("Event must be a non-empty string.");{ot(e)||lt(e);const i=[[nt(e),t]];return n&&i.push([c,""]),o&&i.push([l,""]),r&&i.push([s,""]),a instanceof AbortSignal?i.push([u,bt(a)]):"string"==typeof a&&i.push([u,a]),i.map(([e,t])=>`${e}="${t}"`).join(" ")}}throw new TypeError("Callback must be a function or a registered callback string.")}export{Ft as CallbackRegistryKey,st as EVENTS,Pt as FUNCS,pt as abortController,ft as attachListeners,Rt as callCallback,c as capture,xt as clearRegistry,Lt as closeRegistration,g as controller,Nt as createCallback,gt as createController,yt as disconnectEventsObserver,et as eventAttrs,nt as eventToProp,qt as getCallback,dt as getController,jt as getHost,mt as getSignal,Ot as hasCallback,ot as hasEventAttribute,Mt as isRegistrationOpen,Dt as listCallbacks,vt as observeEvents,$t as on,d as onAbort,ze as onAnimationcancel,We as onAnimationend,He as onAnimationiteration,Ve as onAnimationstart,h as onAuxclick,f as onBeforeinput,v as onBeforetoggle,p as onBlur,m as onCancel,y as onCanplay,w as onCanplaythrough,S as onChange,T as onClick,E as onClose,k as onCommand,A as onContextmenu,P as onCopy,C as onCuechange,F as onCut,M as onDblclick,L as onDrag,D as onDragend,O as onDragenter,q as onDragexit,I as onDragleave,x as onDragover,N as onDragstart,R as onDrop,U as onDurationchange,j as onEmptied,$ as onEnded,Ze as onError,b as onFocus,z as onFormdata,Re as onGotpointercapture,W as onInput,H as onInvalid,V as onKeydown,B as onKeypress,K as onKeyup,G as onLoad,_ as onLoadeddata,J as onLoadedmetadata,Q as onLoadstart,Ue as onLostpointercapture,X as onMousedown,Y as onMouseenter,Z as onMouseleave,ee as onMousemove,te as onMouseout,ne as onMouseover,oe as onMouseup,je as onMozfullscreenchange,$e as onMozfullscreenerror,ae as onPaste,ie as onPause,se as onPlay,le as onPlaying,Me as onPointercancel,Le as onPointerdown,xe as onPointerenter,Ne as onPointerleave,Oe as onPointermove,qe as onPointerout,Ie as onPointerover,De as onPointerup,ce as onProgress,ue as onRatechange,ge as onReset,de as onResize,pe as onScroll,be as onScrollend,me as onSecuritypolicyviolation,he as onSeeked,fe as onSeeking,ve as onSelect,Ce as onSelectionchange,Pe as onSelectstart,ye as onSlotchange,we as onStalled,Se as onSubmit,Te as onSuspend,Ee as onTimeupdate,Fe as onToggle,Be as onTransitioncancel,Ke as onTransitionend,Ge as onTransitionrun,_e as onTransitionstart,ke as onVolumechange,Ae as onWaiting,Je as onWebkitanimationend,Qe as onWebkitanimationiteration,Xe as onWebkitanimationstart,Ye as onWebkittransitionend,re as onWheel,s as once,l as passive,Ut as registerCallback,ct as registerController,lt as registerEventAttribute,bt as registerSignal,kt as requestFullscreen,wt as setGlobalErrorHandler,u as signal,At as toggleFullsceen,It as unregisterCallback,ut as unregisterController,ht as unregisterSignal};
2
2
  //# sourceMappingURL=callbackRegistry.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"callbackRegistry.mjs","sources":["events.js","callbacks.js"],"sourcesContent":["import { hasCallback, getCallback } from './callbacks.js';\n\nconst PREFIX = 'data-aegis-event-';\nconst EVENT_PREFIX = PREFIX + 'on-';\nconst EVENT_PREFIX_LENGTH = EVENT_PREFIX.length;\nconst DATA_PREFIX = 'aegisEventOn';\nconst DATA_PREFIX_LENGTH = DATA_PREFIX.length;\nconst signalSymbol = Symbol('aegis:signal');\nconst controllerSymbol = Symbol('aegis:controller');\nconst signalRegistry = new Map();\nconst controllerRegistry = new Map();\n\nexport const once = PREFIX + 'once';\nexport const passive = PREFIX + 'passive';\nexport const capture = PREFIX + 'capture';\nexport const signal = PREFIX + 'signal';\nexport const controller = PREFIX + 'controller';\nexport const onAbort = EVENT_PREFIX + 'abort';\nexport const onBlur = EVENT_PREFIX + 'blur';\nexport const onFocus = EVENT_PREFIX + 'focus';\nexport const onCancel = EVENT_PREFIX + 'cancel';\nexport const onAuxclick = EVENT_PREFIX + 'auxclick';\nexport const onBeforeinput = EVENT_PREFIX + 'beforeinput';\nexport const onBeforetoggle = EVENT_PREFIX + 'beforetoggle';\nexport const onCanplay = EVENT_PREFIX + 'canplay';\nexport const onCanplaythrough = EVENT_PREFIX + 'canplaythrough';\nexport const onChange = EVENT_PREFIX + 'change';\nexport const onClick = EVENT_PREFIX + 'click';\nexport const onClose = EVENT_PREFIX + 'close';\nexport const onCommand = EVENT_PREFIX + 'command';\nexport const onContextmenu = EVENT_PREFIX + 'contextmenu';\nexport const onCopy = EVENT_PREFIX + 'copy';\nexport const onCuechange = EVENT_PREFIX + 'cuechange';\nexport const onCut = EVENT_PREFIX + 'cut';\nexport const onDblclick = EVENT_PREFIX + 'dblclick';\nexport const onDrag = EVENT_PREFIX + 'drag';\nexport const onDragend = EVENT_PREFIX + 'dragend';\nexport const onDragenter = EVENT_PREFIX + 'dragenter';\nexport const onDragexit = EVENT_PREFIX + 'dragexit';\nexport const onDragleave = EVENT_PREFIX + 'dragleave';\nexport const onDragover = EVENT_PREFIX + 'dragover';\nexport const onDragstart = EVENT_PREFIX + 'dragstart';\nexport const onDrop = EVENT_PREFIX + 'drop';\nexport const onDurationchange = EVENT_PREFIX + 'durationchange';\nexport const onEmptied = EVENT_PREFIX + 'emptied';\nexport const onEnded = EVENT_PREFIX + 'ended';\nexport const onFormdata = EVENT_PREFIX + 'formdata';\nexport const onInput = EVENT_PREFIX + 'input';\nexport const onInvalid = EVENT_PREFIX + 'invalid';\nexport const onKeydown = EVENT_PREFIX + 'keydown';\nexport const onKeypress = EVENT_PREFIX + 'keypress';\nexport const onKeyup = EVENT_PREFIX + 'keyup';\nexport const onLoad = EVENT_PREFIX + 'load';\nexport const onLoadeddata = EVENT_PREFIX + 'loadeddata';\nexport const onLoadedmetadata = EVENT_PREFIX + 'loadedmetadata';\nexport const onLoadstart = EVENT_PREFIX + 'loadstart';\nexport const onMousedown = EVENT_PREFIX + 'mousedown';\nexport const onMouseenter = EVENT_PREFIX + 'mouseenter';\nexport const onMouseleave = EVENT_PREFIX + 'mouseleave';\nexport const onMousemove = EVENT_PREFIX + 'mousemove';\nexport const onMouseout = EVENT_PREFIX + 'mouseout';\nexport const onMouseover = EVENT_PREFIX + 'mouseover';\nexport const onMouseup = EVENT_PREFIX + 'mouseup';\nexport const onWheel = EVENT_PREFIX + 'wheel';\nexport const onPaste = EVENT_PREFIX + 'paste';\nexport const onPause = EVENT_PREFIX + 'pause';\nexport const onPlay = EVENT_PREFIX + 'play';\nexport const onPlaying = EVENT_PREFIX + 'playing';\nexport const onProgress = EVENT_PREFIX + 'progress';\nexport const onRatechange = EVENT_PREFIX + 'ratechange';\nexport const onReset = EVENT_PREFIX + 'reset';\nexport const onResize = EVENT_PREFIX + 'resize';\nexport const onScroll = EVENT_PREFIX + 'scroll';\nexport const onScrollend = EVENT_PREFIX + 'scrollend';\nexport const onSecuritypolicyviolation = EVENT_PREFIX + 'securitypolicyviolation';\nexport const onSeeked = EVENT_PREFIX + 'seeked';\nexport const onSeeking = EVENT_PREFIX + 'seeking';\nexport const onSelect = EVENT_PREFIX + 'select';\nexport const onSlotchange = EVENT_PREFIX + 'slotchange';\nexport const onStalled = EVENT_PREFIX + 'stalled';\nexport const onSubmit = EVENT_PREFIX + 'submit';\nexport const onSuspend = EVENT_PREFIX + 'suspend';\nexport const onTimeupdate = EVENT_PREFIX + 'timeupdate';\nexport const onVolumechange = EVENT_PREFIX + 'volumechange';\nexport const onWaiting = EVENT_PREFIX + 'waiting';\nexport const onSelectstart = EVENT_PREFIX + 'selectstart';\nexport const onSelectionchange = EVENT_PREFIX + 'selectionchange';\nexport const onToggle = EVENT_PREFIX + 'toggle';\nexport const onPointercancel = EVENT_PREFIX + 'pointercancel';\nexport const onPointerdown = EVENT_PREFIX + 'pointerdown';\nexport const onPointerup = EVENT_PREFIX + 'pointerup';\nexport const onPointermove = EVENT_PREFIX + 'pointermove';\nexport const onPointerout = EVENT_PREFIX + 'pointerout';\nexport const onPointerover = EVENT_PREFIX + 'pointerover';\nexport const onPointerenter = EVENT_PREFIX + 'pointerenter';\nexport const onPointerleave = EVENT_PREFIX + 'pointerleave';\nexport const onGotpointercapture = EVENT_PREFIX + 'gotpointercapture';\nexport const onLostpointercapture = EVENT_PREFIX + 'lostpointercapture';\nexport const onMozfullscreenchange = EVENT_PREFIX + 'mozfullscreenchange';\nexport const onMozfullscreenerror = EVENT_PREFIX + 'mozfullscreenerror';\nexport const onAnimationcancel = EVENT_PREFIX + 'animationcancel';\nexport const onAnimationend = EVENT_PREFIX + 'animationend';\nexport const onAnimationiteration = EVENT_PREFIX + 'animationiteration';\nexport const onAnimationstart = EVENT_PREFIX + 'animationstart';\nexport const onTransitioncancel = EVENT_PREFIX + 'transitioncancel';\nexport const onTransitionend = EVENT_PREFIX + 'transitionend';\nexport const onTransitionrun = EVENT_PREFIX + 'transitionrun';\nexport const onTransitionstart = EVENT_PREFIX + 'transitionstart';\nexport const onWebkitanimationend = EVENT_PREFIX + 'webkitanimationend';\nexport const onWebkitanimationiteration = EVENT_PREFIX + 'webkitanimationiteration';\nexport const onWebkitanimationstart = EVENT_PREFIX + 'webkitanimationstart';\nexport const onWebkittransitionend = EVENT_PREFIX + 'webkittransitionend';\nexport const onError = EVENT_PREFIX + 'error';\n\nexport const eventAttrs = [\n\tonAbort,\n\tonBlur,\n\tonFocus,\n\tonCancel,\n\tonAuxclick,\n\tonBeforeinput,\n\tonBeforetoggle,\n\tonCanplay,\n\tonCanplaythrough,\n\tonChange,\n\tonClick,\n\tonClose,\n\tonCommand,\n\tonContextmenu,\n\tonCopy,\n\tonCuechange,\n\tonCut,\n\tonDblclick,\n\tonDrag,\n\tonDragend,\n\tonDragenter,\n\tonDragexit,\n\tonDragleave,\n\tonDragover,\n\tonDragstart,\n\tonDrop,\n\tonDurationchange,\n\tonEmptied,\n\tonEnded,\n\tonFormdata,\n\tonInput,\n\tonInvalid,\n\tonKeydown,\n\tonKeypress,\n\tonKeyup,\n\tonLoad,\n\tonLoadeddata,\n\tonLoadedmetadata,\n\tonLoadstart,\n\tonMousedown,\n\tonMouseenter,\n\tonMouseleave,\n\tonMousemove,\n\tonMouseout,\n\tonMouseover,\n\tonMouseup,\n\tonWheel,\n\tonPaste,\n\tonPause,\n\tonPlay,\n\tonPlaying,\n\tonProgress,\n\tonRatechange,\n\tonReset,\n\tonResize,\n\tonScroll,\n\tonScrollend,\n\tonSecuritypolicyviolation,\n\tonSeeked,\n\tonSeeking,\n\tonSelect,\n\tonSlotchange,\n\tonStalled,\n\tonSubmit,\n\tonSuspend,\n\tonTimeupdate,\n\tonVolumechange,\n\tonWaiting,\n\tonSelectstart,\n\tonSelectionchange,\n\tonToggle,\n\tonPointercancel,\n\tonPointerdown,\n\tonPointerup,\n\tonPointermove,\n\tonPointerout,\n\tonPointerover,\n\tonPointerenter,\n\tonPointerleave,\n\tonGotpointercapture,\n\tonLostpointercapture,\n\tonMozfullscreenchange,\n\tonMozfullscreenerror,\n\tonAnimationcancel,\n\tonAnimationend,\n\tonAnimationiteration,\n\tonAnimationstart,\n\tonTransitioncancel,\n\tonTransitionend,\n\tonTransitionrun,\n\tonTransitionstart,\n\tonWebkitanimationend,\n\tonWebkitanimationiteration,\n\tonWebkitanimationstart,\n\tonWebkittransitionend,\n\tonError,\n];\n\nlet selector = eventAttrs.map(attr => `[${CSS.escape(attr)}]`).join(', ');\n\nconst attrToProp = attr => `on${attr[EVENT_PREFIX_LENGTH].toUpperCase()}${attr.substring(EVENT_PREFIX_LENGTH + 1)}`;\n\nexport const eventToProp = event => EVENT_PREFIX + event;\n\nexport const hasEventAttribute = event => eventAttrs.includes(EVENT_PREFIX + event);\n\nconst isEventDataAttr = ([name]) => name.startsWith(DATA_PREFIX);\n\nfunction _addListeners(el, { signal, attrFilter = EVENTS } = {}) {\n\tconst dataset = el.dataset;\n\n\tfor (const [attr, val] of Object.entries(dataset).filter(isEventDataAttr)) {\n\t\ttry {\n\t\t\tconst event = 'on' + attr.substring(DATA_PREFIX_LENGTH);\n\n\t\t\tif (attrFilter.hasOwnProperty(event) && hasCallback(val)) {\n\t\t\t\tel.addEventListener(event.substring(2).toLowerCase(), getCallback(val), {\n\t\t\t\t\tpassive: dataset.hasOwnProperty('aegisEventPassive'),\n\t\t\t\t\tcapture: dataset.hasOwnProperty('aegisEventCapture'),\n\t\t\t\t\tonce: dataset.hasOwnProperty('aegisEventOnce'),\n\t\t\t\t\tsignal: dataset.hasOwnProperty('aegisEventSignal') ? getSignal(dataset.aegisEventSignal) : signal,\n\t\t\t\t});\n\t\t\t}\n\t\t} catch(err) {\n\t\t\treportError(err);\n\t\t}\n\t}\n}\n\nconst observer = new MutationObserver(records => {\n\trecords.forEach(record => {\n\t\tswitch(record.type) {\n\t\t\tcase 'childList':\n\t\t\t\t[...record.addedNodes]\n\t\t\t\t\t.filter(node => node.nodeType === Node.ELEMENT_NODE)\n\t\t\t\t\t.forEach(node => attachListeners(node));\n\t\t\t\tbreak;\n\n\t\t\tcase 'attributes':\n\t\t\t\tif (typeof record.oldValue === 'string' && hasCallback(record.oldValue)) {\n\t\t\t\t\trecord.target.removeEventListener(\n\t\t\t\t\t\trecord.attributeName.substring(EVENT_PREFIX_LENGTH),\n\t\t\t\t\t\tgetCallback(record.oldValue), {\n\t\t\t\t\t\t\tonce: record.target.hasAttribute(once),\n\t\t\t\t\t\t\tcapture: record.target.hasAttribute(capture),\n\t\t\t\t\t\t\tpassive: record.target.hasAttribute(passive),\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\trecord.target.hasAttribute(record.attributeName)\n\t\t\t\t\t&& hasCallback(record.target.getAttribute(record.attributeName))\n\t\t\t\t) {\n\t\t\t\t\trecord.target.addEventListener(\n\t\t\t\t\t\trecord.attributeName.substring(EVENT_PREFIX_LENGTH),\n\t\t\t\t\t\tgetCallback(record.target.getAttribute(record.attributeName)), {\n\t\t\t\t\t\t\tonce: record.target.hasAttribute(once),\n\t\t\t\t\t\t\tcapture: record.target.hasAttribute(capture),\n\t\t\t\t\t\t\tpassive: record.target.hasAttribute(passive),\n\t\t\t\t\t\t\tsignal: record.target.hasAttribute(signal) ? getSignal(record.target.getAttribute(signal)) : undefined,\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t}\n\t});\n});\n\nexport const EVENTS = {\n\tonAbort,\n\tonBlur,\n\tonFocus,\n\tonCancel,\n\tonAuxclick,\n\tonBeforeinput,\n\tonBeforetoggle,\n\tonCanplay,\n\tonCanplaythrough,\n\tonChange,\n\tonClick,\n\tonClose,\n\tonCommand,\n\tonContextmenu,\n\tonCopy,\n\tonCuechange,\n\tonCut,\n\tonDblclick,\n\tonDrag,\n\tonDragend,\n\tonDragenter,\n\tonDragexit,\n\tonDragleave,\n\tonDragover,\n\tonDragstart,\n\tonDrop,\n\tonDurationchange,\n\tonEmptied,\n\tonEnded,\n\tonFormdata,\n\tonInput,\n\tonInvalid,\n\tonKeydown,\n\tonKeypress,\n\tonKeyup,\n\tonLoad,\n\tonLoadeddata,\n\tonLoadedmetadata,\n\tonLoadstart,\n\tonMousedown,\n\tonMouseenter,\n\tonMouseleave,\n\tonMousemove,\n\tonMouseout,\n\tonMouseover,\n\tonMouseup,\n\tonWheel,\n\tonPaste,\n\tonPause,\n\tonPlay,\n\tonPlaying,\n\tonProgress,\n\tonRatechange,\n\tonReset,\n\tonResize,\n\tonScroll,\n\tonScrollend,\n\tonSecuritypolicyviolation,\n\tonSeeked,\n\tonSeeking,\n\tonSelect,\n\tonSlotchange,\n\tonStalled,\n\tonSubmit,\n\tonSuspend,\n\tonTimeupdate,\n\tonVolumechange,\n\tonWaiting,\n\tonSelectstart,\n\tonSelectionchange,\n\tonToggle,\n\tonPointercancel,\n\tonPointerdown,\n\tonPointerup,\n\tonPointermove,\n\tonPointerout,\n\tonPointerover,\n\tonPointerenter,\n\tonPointerleave,\n\tonGotpointercapture,\n\tonLostpointercapture,\n\tonMozfullscreenchange,\n\tonMozfullscreenerror,\n\tonAnimationcancel,\n\tonAnimationend,\n\tonAnimationiteration,\n\tonAnimationstart,\n\tonTransitioncancel,\n\tonTransitionend,\n\tonTransitionrun,\n\tonTransitionstart,\n\tonWebkitanimationend,\n\tonWebkitanimationiteration,\n\tonWebkitanimationstart,\n\tonWebkittransitionend,\n\tonError,\n\tonce,\n\tpassive,\n\tcapture,\n};\n\n/**\n * Register an attribute to observe for adding/removing event listeners\n *\n * @param {string} attr Name of the attribute to observe\n * @param {object} options\n * @param {boolean} [options.addListeners=false] Whether or not to automatically add listeners\n * @param {Document|Element} [options.base=document.body] Root node to observe\n * @param {AbortSignal} [options.signal] An abort signal to remove any listeners when aborted\n * @returns {string} The resulting `data-*` attribute name\n */\nexport function registerEventAttribute(attr, {\n\taddListeners = false,\n\tbase = document.body,\n\tsignal,\n} = {}) {\n\tconst fullAttr = EVENT_PREFIX + attr.toLowerCase();\n\n\tif (! eventAttrs.includes(fullAttr)) {\n\t\tconst sel = `[${CSS.escape(fullAttr)}]`;\n\t\tconst prop = attrToProp(fullAttr);\n\t\teventAttrs.push(fullAttr);\n\t\tEVENTS[prop] = fullAttr;\n\t\tselector += `, ${sel}`;\n\n\t\tif (addListeners) {\n\t\t\trequestAnimationFrame(() => {\n\t\t\t\tconst config = { attrFilter: { [prop]: sel }, signal };\n\t\t\t\t[base, ...base.querySelectorAll(sel)].forEach(el => _addListeners(el, config));\n\t\t\t});\n\t\t}\n\t}\n\n\treturn fullAttr;\n}\n\n/**\n * Registers an `AbortController` in the controller registry and returns the key for it\n *\n * @param {AbortController} controller\n * @returns {string} The randomly generated key with which the controller is registered\n * @throws {TypeError} If controller is not an `AbortController`\n * @throws {Error} Any `reason` if controller is already aborted\n */\nexport function registerController(controller) {\n\tif (! (controller instanceof AbortController)) {\n\t\tthrow new TypeError('Controller is not an `AbortSignal.');\n\t} else if (controller.signal.aborted) {\n\t\tthrow controller.signal.reason;\n\t} else if (typeof controller.signal[controllerSymbol] === 'string') {\n\t\treturn controller.signal[controllerSymbol];\n\t} else {\n\t\tconst key = 'aegis:event:controller:' + crypto.randomUUID();\n\t\tObject.defineProperty(controller.signal, controllerSymbol, { value: key, writable: false, enumerable: false });\n\t\tcontrollerRegistry.set(key, controller);\n\n\t\tcontroller.signal.addEventListener('abort', unregisterController, { once: true });\n\n\t\treturn key;\n\t}\n}\n\n/**\n * Removes a controller from the registry\n *\n * @param {AbortController|AbortSignal|string} key The registed key or the controller or signal it corresponds to\n * @returns {boolean} Whether or not the controller was successfully unregistered\n */\nexport function unregisterController(key) {\n\tif (key instanceof AbortController) {\n\t\treturn controllerRegistry.delete(key.signal[controllerSymbol]);\n\t} else if (key instanceof AbortSignal) {\n\t\treturn controllerRegistry.delete(key[controllerSymbol]);\n\t} else {\n\t\treturn controllerRegistry.delete(key);\n\t}\n}\n\n/**\n * Creates and registers an `AbortController` in the controller registry and returns the key for it\n *\n * @param {object} options\n * @param {AbortSignal} [options.signal] An optional `AbortSignal` to externally abort the controller with\n * @returns {string} The randomly generated key with which the controller is registered\n */\nexport function createController({ signal } = {}) {\n\tconst controller = new AbortController();\n\n\tif (signal instanceof AbortSignal) {\n\t\tsignal.addEventListener('abort', ({ target }) => controller.abort(target.reason), { signal: controller.signal});\n\t}\n\n\treturn registerController(controller);\n}\n\n/**\n * Get a registetd controller from the registry\n *\n * @param {string} key Generated key with which the controller was registered\n * @returns {AbortController|void} Any registered controller, if any\n */\nexport const getController = key => controllerRegistry.get(key);\n\nexport function abortController(key, reason) {\n\tconst controller = getController(key);\n\n\tif (! (controller instanceof AbortController)) {\n\t\treturn false;\n\t} else if (typeof reason === 'string') {\n\t\tcontroller.abort(new Error(reason));\n\t\treturn true;\n\t} else {\n\t\tcontroller.abort(reason);\n\t\treturn true;\n\t}\n}\n\n/**\n * Register an `AbortSignal` to be used in declarative HTML as a value for `data-aegis-event-signal`\n *\n * @param {AbortSignal} signal The signal to register\n * @returns {string} The registered key\n * @throws {TypeError} Thrown if not an `AbortSignal`\n */\nexport function registerSignal(signal) {\n\tif (! (signal instanceof AbortSignal)) {\n\t\tthrow new TypeError('Signal must be an `AbortSignal`.');\n\t} else if (typeof signal[signalSymbol] === 'string') {\n\t\treturn signal[signalSymbol];\n\t} else {\n\t\tconst key = 'aegis:event:signal:' + crypto.randomUUID();\n\t\tObject.defineProperty(signal, signalSymbol, { value: key, writable: false, enumerable: false });\n\t\tsignalRegistry.set(key, signal);\n\t\tsignal.addEventListener('abort', ({ target }) => unregisterSignal(target[signalSymbol]), { once: true });\n\n\t\treturn key;\n\t}\n}\n\n/**\n * Gets and `AbortSignal` from the registry\n *\n * @param {string} key The registered key for the signal\n * @returns {AbortSignal|void} The corresponding `AbortSignal`, if any\n */\nexport const getSignal = key => signalRegistry.get(key);\n\n/**\n * Removes an `AbortSignal` from the registry\n *\n * @param {AbortSignal|string} signal An `AbortSignal` or the registered key for one\n * @returns {boolean} Whether or not the signal was sucessfully unregistered\n * @throws {TypeError} Throws if `signal` is not an `AbortSignal` or the key for a registered signal\n */\nexport function unregisterSignal(signal) {\n\tif (signal instanceof AbortSignal) {\n\t\treturn signalRegistry.delete(signal[signalSymbol]);\n\t} else if (typeof signal === 'string') {\n\t\treturn signalRegistry.delete(signal);\n\t} else {\n\t\tthrow new TypeError('Signal must be an `AbortSignal` or registered key/attribute.');\n\t}\n}\n\n/**\n * Add listeners to an element and its children, matching a generated query based on registered attributes\n *\n * @param {Element|Document} target Root node to add listeners from\n * @param {object} options\n * @param {AbortSignal} [options.signal] Optional signal to remove event listeners\n * @returns {Element|Document} Returns the passed target node\n */\nexport function attachListeners(target, { signal } = {}) {\n\tconst nodes = target instanceof Element && target.matches(selector)\n\t\t? [target, ...target.querySelectorAll(selector)]\n\t\t: target.querySelectorAll(selector);\n\n\tnodes.forEach(el => _addListeners(el, { signal }));\n\n\treturn target;\n}\n\n/**\n * Add a node to the `MutationObserver` to observe attributes and add/remove event listeners\n *\n * @param {Document|Element} root Element to observe attributes on\n */\nexport function observeEvents(root = document) {\n\tattachListeners(root);\n\n\tobserver.observe(root, {\n\t\tsubtree: true,\n\t\tchildList:true,\n\t\tattributes: true,\n\t\tattributeOldValue: true,\n\t\tattributeFilter: eventAttrs,\n\t});\n}\n\n/**\n * Disconnects the `MutationObserver`, disabling observing of all attribute changes\n *\n * @returns {void}\n */\nexport const disconnectEventsObserver = () => observer.disconnect();\n\n/**\n * Register a global error handler callback\n *\n * @param {Function} callback Callback to register as a global error handler\n * @param {EventInit} config Typical event listener config object\n */\nexport function setGlobalErrorHandler(callback, { capture, once, passive, signal } = {}) {\n\tif (callback instanceof Function) {\n\t\tglobalThis.addEventListener('error', callback, { capture, once, passive, signal });\n\t} else {\n\t\tthrow new TypeError('Callback is not a function.');\n\t}\n}\n","import {\n\teventToProp, capture as captureAttr, once as onceAttr, passive as passiveAttr, signal as signalAttr,\n\tregisterEventAttribute, hasEventAttribute, registerSignal, abortController,\n} from './events.js';\n\nlet _isRegistrationOpen = true;\n\nconst $$ = (selector, base = document) => base.querySelectorAll(selector);\n\nconst $ = (selector, base = document) => base.querySelector(selector);\n\nexport const requestFullscreen = { attr: 'data-request-fullscreen-selector', data: 'requestFullscreenSelector' };\nexport const toggleFullsceen = { attr: 'data-toggle-fullscreen-selector', data: 'toggleFullscreenSelector' };\n\nexport const FUNCS = {\n\tdebug: {\n\t\tlog: 'aegis:debug:log',\n\t\tinfo: 'aegis:debug:info',\n\t\twarn: 'aegis:debug:warn',\n\t\terror: 'aegis:debug:error',\n\t},\n\tnavigate: {\n\t\tback: 'aegis:navigate:back',\n\t\tforward: 'aegis:navigate:forward',\n\t\treload: 'aegis:navigate:reload',\n\t\tclose: 'aegis:navigate:close',\n\t\tlink: 'aegis:navigate:go',\n\t\tpopup: 'aegis:navigate:popup',\n\t},\n\tui: {\n\t\tcommand: 'aegis:ui:command',\n\t\tprint: 'aegis:ui:print',\n\t\tremove: 'aegis:ui:remove',\n\t\thide: 'aegis:ui:hide',\n\t\tunhide: 'aegis:ui:unhide',\n\t\tshowModal: 'aegis:ui:showModal',\n\t\tcloseModal: 'aegis:ui:closeModal',\n\t\tshowPopover: 'aegis:ui:showPopover',\n\t\thidePopover: 'aegis:ui:hidePopover',\n\t\ttogglePopover: 'aegis:ui:togglePopover',\n\t\tenable: 'aegis:ui:enable',\n\t\tdisable: 'aegis:ui:disable',\n\t\tscrollTo: 'aegis:ui:scrollTo',\n\t\tprevent: 'aegis:ui:prevent',\n\t\trevokeObjectURL: 'aegis:ui:revokeObjectURL',\n\t\tcancelAnimationFrame: 'aegis:ui:cancelAnimationFrame',\n\t\trequestFullscreen: 'aegis:ui:requestFullscreen',\n\t\ttoggleFullscreen: 'aegis:ui:toggleFullsceen',\n\t\texitFullsceen: 'aegis:ui:exitFullscreen',\n\t\topen: 'aegis:ui:open',\n\t\tclose: 'aegis:ui:close',\n\t\tabortController: 'aegis:ui:controller:abort',\n\t},\n};\n\nconst registry = new Map([\n\t[FUNCS.debug.log, console.log],\n\t[FUNCS.debug.warn, console.warn],\n\t[FUNCS.debug.error, console.error],\n\t[FUNCS.debug.info, console.info],\n\t[FUNCS.navigate.back, () => history.back()],\n\t[FUNCS.navigate.forward, () => history.forward()],\n\t[FUNCS.navigate.reload, () => history.go(0)],\n\t[FUNCS.navigate.close, () => globalThis.close()],\n\t[FUNCS.navigate.link, event => {\n\t\tif (event.isTrusted) {\n\t\t\tevent.preventDefault();\n\t\t\tlocation.href = event.currentTarget.dataset.url;\n\t\t}\n\t}],\n\t[FUNCS.navigate.popup, event => {\n\t\tif (event.isTrusted) {\n\t\t\tevent.preventDefault();\n\t\t\tglobalThis.open(event.currentTarget.dataset.url);\n\t\t}\n\t}],\n\t[FUNCS.ui.hide, ({ currentTarget }) => {\n\t\t$$(currentTarget.dataset.hideSelector).forEach(el => el.hidden = true);\n\t}],\n\t[FUNCS.ui.unhide, ({ currentTarget }) => {\n\t\t$$(currentTarget.dataset.unhideSelector).forEach(el => el.hidden = false);\n\t}],\n\t[FUNCS.ui.disable, ({ currentTarget }) => {\n\t\t$$(currentTarget.dataset.disableSelector).forEach(el => el.disabled = true);\n\t}],\n\t[FUNCS.ui.enable, ({ currentTarget }) => {\n\t\t$$(currentTarget.dataset.enableSelector).forEach(el => el.disabled = false);\n\t}],\n\t[FUNCS.ui.remove, ({ currentTarget }) => {\n\t\t$$(currentTarget.dataset.removeSelector).forEach(el => el.remove());\n\t}],\n\t[FUNCS.ui.scrollTo, ({ currentTarget }) => {\n\t\tconst target = $(currentTarget.dataset.scrollToSelector);\n\n\t\tif (target instanceof Element) {\n\t\t\ttarget.scrollIntoView({\n\t\t\t\tbehavior: matchMedia('(prefers-reduced-motion: reduce)').matches\n\t\t\t\t\t? 'instant'\n\t\t\t\t\t: 'smooth',\n\t\t\t});\n\t\t}\n\t}],\n\t[FUNCS.ui.revokeObjectURL, ({ currentTarget }) => URL.revokeObjectURL(currentTarget.src)],\n\t[FUNCS.ui.cancelAnimationFrame, ({ currentTarget }) => cancelAnimationFrame(parseInt(currentTarget.dataset.animationFrame))],\n\t[FUNCS.ui.clearInterval, ({ currentTarget }) => clearInterval(parseInt(currentTarget.dataset.clearInterval))],\n\t[FUNCS.ui.clearTimeout, ({ currentTarget }) => clearTimeout(parseInt(currentTarget.dataset.timeout))],\n\t[FUNCS.ui.abortController, ({ currentTarget }) => abortController(currentTarget.dataset.aegisEventController, currentTarget.dataset.aegisControllerReason)],\n\t[FUNCS.ui.open, ({ currentTarget }) => document.querySelector(currentTarget.dataset.openSelector).open = true],\n\t[FUNCS.ui.close, ({ currentTarget }) => document.querySelector(currentTarget.dataset.closeSelector).open = false],\n\t[FUNCS.ui.showModal, ({ currentTarget }) => {\n\t\tconst target = $(currentTarget.dataset.showModalSelector);\n\n\t\tif (target instanceof HTMLDialogElement) {\n\t\t\ttarget.showModal();\n\t\t}\n\t}],\n\t[FUNCS.ui.closeModal, ({ currentTarget }) => {\n\t\tconst target = $(currentTarget.dataset.closeModalSelector);\n\n\t\tif (target instanceof HTMLDialogElement) {\n\t\t\ttarget.close();\n\t\t}\n\t}],\n\t[FUNCS.ui.showPopover, ({ currentTarget }) => {\n\t\tconst target = $(currentTarget.dataset.showPopoverSelector);\n\n\t\tif (target instanceof HTMLElement) {\n\t\t\ttarget.showPopover();\n\t\t}\n\t}],\n\t[FUNCS.ui.hidePopover, ({ currentTarget }) => {\n\t\tconst target = $(currentTarget.dataset.hidePopoverSelector);\n\n\t\tif (target instanceof HTMLElement) {\n\t\t\ttarget.hidePopover();\n\t\t}\n\t}],\n\t[FUNCS.ui.togglePopover, ({ currentTarget }) => {\n\t\tconst target = $(currentTarget.dataset.togglePopoverSelector);\n\n\t\tif (target instanceof HTMLElement) {\n\t\t\ttarget.togglePopover();\n\t\t}\n\t}],\n\t[FUNCS.ui.print, () => globalThis.print()],\n\t[FUNCS.ui.prevent, event => event.preventDefault()],\n\t[FUNCS.ui.requestFullscreen, ({ currentTarget}) => {\n\t\tif (currentTarget.dataset.hasOwnProperty(requestFullscreen.data)) {\n\t\t\tdocument.getElementById(currentTarget.dataset[requestFullscreen.data]).requestFullscreen();\n\t\t} else {\n\t\t\tcurrentTarget.requestFullscreen();\n\t\t}\n\t}],\n\t[FUNCS.ui.toggleFullscreen, ({ currentTarget }) => {\n\t\tconst target = currentTarget.dataset.hasOwnProperty(toggleFullsceen.data)\n\t\t\t? document.getElementById(currentTarget.dataset[toggleFullsceen.data])\n\t\t\t: currentTarget;\n\n\t\tif (target.isSameNode(document.fullscreenElement)) {\n\t\t\tdocument.exitFullscreen();\n\t\t} else {\n\t\t\ttarget.requestFullscreen();\n\t\t}\n\t}],\n\t[FUNCS.ui.exitFullsceen, () => document.exitFullscreen()],\n]);\n\n/**\n * Check if callback registry is open\n *\n * @returns {boolean} Whether or not callback registry is open\n */\nexport const isRegistrationOpen = () => _isRegistrationOpen;\n\n/**\n * Close callback registry\n *\n * @returns {boolean} Whether or not the callback was succesfully removed\n */\nexport const closeRegistration = () => _isRegistrationOpen = false;\n\n/**\n * Get an array of registered callbacks\n *\n * @returns {Array} A frozen array listing keys to all registered callbacks\n */\nexport const listCallbacks = () => Object.freeze(Array.from(registry.keys()));\n\n/**\n * Check if a callback is registered\n *\n * @param {string} name The name/key to check for in callback registry\n * @returns {boolean} Whether or not a callback is registered\n */\nexport const hasCallback = name => registry.has(name);\n\n/**\n * Get a callback from the registry by name/key\n *\n * @param {string} name The name/key of the callback to get\n * @returns {Function|undefined} The corresponding function registered under that name/key\n */\nexport const getCallback = name => registry.get(name);\n\n/**\n *\t Remove a callback from the registry\n *\n * @param {string} name The name/key of the callback to get\n * @returns {boolean} Whether or not the callback was successfully unregisterd\n */\nexport const unregisterCallback = name => _isRegistrationOpen && registry.delete(name);\n\n/**\n * Remove all callbacks from the registry\n *\n * @returns {void}\n */\nexport const clearRegistry = () => registry.clear();\n\n/**\n * Create a registered callback with a randomly generated name\n *\n * @param {Function} callback Callback function to register\n * @returns {string} The automatically generated key/name of the registered callback\n */\nexport const createCallback = (callback) => registerCallback('aegis:callback:' + crypto.randomUUID(), callback);\n\n/**\n * Call a callback fromt the registry by name/key\n *\n * @param {string} name The name/key of the registered function\n * @param {...any} args Any arguments to pass along to the function\n * @returns {any} Whatever the return value of the function is\n * @throws {Error} Throws if callback is not found or any error resulting from calling the function\n */\nexport function callCallback(name, ...args) {\n\tif (registry.has(name)) {\n\t\treturn registry.get(name).apply(this || globalThis, args);\n\t} else {\n\t\tthrow new Error(`No ${name} function registered.`);\n\t}\n}\n\n/**\n * Register a named callback in registry\n *\n * @param {string} name The name/key to register the callback under\n * @param {Function} callback The callback value to register\n * @returns {string} The registered name/key\n */\nexport function registerCallback(name, callback) {\n\tif (typeof name !== 'string' || name.length === 0) {\n\t\tthrow new TypeError('Callback name must be a string.');\n\t} if (! (callback instanceof Function)) {\n\t\tthrow new TypeError('Callback must be a function.');\n\t} else if (! _isRegistrationOpen) {\n\t\tthrow new TypeError('Cannot register new callbacks because registry is closed.');\n\t} else if (registry.has(name)) {\n\t\tthrow new Error(`Handler \"${name}\" is already registered.`);\n\t} else {\n\t\tregistry.set(name, callback);\n\t\treturn name;\n\t}\n}\n\n/**\n * Get the host/root node of a given thing.\n *\n * @param {Event|Document|Element|ShadowRoot} target Source thing to search for host of\n * @returns {Document|Element|null} The host/root node, or null\n */\nexport function getHost(target) {\n\tif (target instanceof Event) {\n\t\treturn getHost(target.currentTarget);\n\t} else if (target instanceof Document) {\n\t\treturn target;\n\t} else if (target instanceof Element) {\n\t\treturn getHost(target.getRootNode());\n\t} else if (target instanceof ShadowRoot) {\n\t\treturn target.host;\n\t} else {\n\t\treturn null;\n\t}\n}\n\nexport function on(event, callback, { capture = false, passive = false, once = false, signal } = {}) {\n\tif (callback instanceof Function) {\n\t\treturn on(event, createCallback(callback), { capture, passive, once, signal });\n\t} else if (typeof callback !== 'string' || callback.length === 0) {\n\t\tthrow new TypeError('Callback must be a function or a registered callback string.');\n\t} else if (typeof event !== 'string' || event.length === 0) {\n\t\tthrow new TypeError('Event must be a non-empty string.');\n\t} else {\n\t\tif (! hasEventAttribute(event)) {\n\t\t\tregisterEventAttribute(event);\n\t\t}\n\n\t\tconst parts = [[eventToProp(event), callback]];\n\n\t\tif (capture) {\n\t\t\tparts.push([captureAttr, '']);\n\t\t}\n\n\t\tif (passive) {\n\t\t\tparts.push([passiveAttr, '']);\n\t\t}\n\n\t\tif (once) {\n\t\t\tparts.push([onceAttr, '']);\n\t\t}\n\n\t\tif (signal instanceof AbortSignal) {\n\t\t\tparts.push([signalAttr, registerSignal(signal)]);\n\t\t} else if (typeof signal === 'string') {\n\t\t\tparts.push([signalAttr, signal]);\n\t\t}\n\n\t\treturn parts.map(([prop, val]) => `${prop}=\"${val}\"`).join(' ');\n\t}\n}\n"],"names":["PREFIX","EVENT_PREFIX","DATA_PREFIX","signalSymbol","Symbol","controllerSymbol","signalRegistry","Map","controllerRegistry","once","passive","capture","signal","controller","onAbort","onBlur","onFocus","onCancel","onAuxclick","onBeforeinput","onBeforetoggle","onCanplay","onCanplaythrough","onChange","onClick","onClose","onCommand","onContextmenu","onCopy","onCuechange","onCut","onDblclick","onDrag","onDragend","onDragenter","onDragexit","onDragleave","onDragover","onDragstart","onDrop","onDurationchange","onEmptied","onEnded","onFormdata","onInput","onInvalid","onKeydown","onKeypress","onKeyup","onLoad","onLoadeddata","onLoadedmetadata","onLoadstart","onMousedown","onMouseenter","onMouseleave","onMousemove","onMouseout","onMouseover","onMouseup","onWheel","onPaste","onPause","onPlay","onPlaying","onProgress","onRatechange","onReset","onResize","onScroll","onScrollend","onSecuritypolicyviolation","onSeeked","onSeeking","onSelect","onSlotchange","onStalled","onSubmit","onSuspend","onTimeupdate","onVolumechange","onWaiting","onSelectstart","onSelectionchange","onToggle","onPointercancel","onPointerdown","onPointerup","onPointermove","onPointerout","onPointerover","onPointerenter","onPointerleave","onGotpointercapture","onLostpointercapture","onMozfullscreenchange","onMozfullscreenerror","onAnimationcancel","onAnimationend","onAnimationiteration","onAnimationstart","onTransitioncancel","onTransitionend","onTransitionrun","onTransitionstart","onWebkitanimationend","onWebkitanimationiteration","onWebkitanimationstart","onWebkittransitionend","onError","eventAttrs","selector","map","attr","CSS","escape","join","eventToProp","event","hasEventAttribute","includes","isEventDataAttr","name","startsWith","_addListeners","el","attrFilter","EVENTS","dataset","val","Object","entries","filter","substring","hasOwnProperty","hasCallback","addEventListener","toLowerCase","getCallback","getSignal","aegisEventSignal","err","reportError","observer","MutationObserver","records","forEach","record","type","addedNodes","node","nodeType","Node","ELEMENT_NODE","attachListeners","oldValue","target","removeEventListener","attributeName","hasAttribute","getAttribute","undefined","registerEventAttribute","addListeners","base","document","body","fullAttr","sel","prop","toUpperCase","EVENT_PREFIX_LENGTH","attrToProp","push","requestAnimationFrame","config","querySelectorAll","registerController","AbortController","aborted","reason","key","crypto","randomUUID","defineProperty","value","writable","enumerable","set","unregisterController","TypeError","delete","AbortSignal","createController","abort","getController","get","abortController","Error","registerSignal","unregisterSignal","Element","matches","observeEvents","root","observe","subtree","childList","attributes","attributeOldValue","attributeFilter","disconnectEventsObserver","disconnect","setGlobalErrorHandler","callback","Function","globalThis","_isRegistrationOpen","$$","$","querySelector","requestFullscreen","data","toggleFullsceen","FUNCS","debug","log","info","warn","error","navigate","back","forward","reload","close","link","popup","ui","command","print","remove","hide","unhide","showModal","closeModal","showPopover","hidePopover","togglePopover","enable","disable","scrollTo","prevent","revokeObjectURL","cancelAnimationFrame","toggleFullscreen","exitFullsceen","open","registry","console","history","go","isTrusted","preventDefault","location","href","currentTarget","url","hideSelector","hidden","unhideSelector","disableSelector","disabled","enableSelector","removeSelector","scrollToSelector","scrollIntoView","behavior","matchMedia","URL","src","parseInt","animationFrame","clearInterval","clearTimeout","timeout","aegisEventController","aegisControllerReason","openSelector","closeSelector","showModalSelector","HTMLDialogElement","closeModalSelector","showPopoverSelector","HTMLElement","hidePopoverSelector","togglePopoverSelector","getElementById","isSameNode","fullscreenElement","exitFullscreen","isRegistrationOpen","closeRegistration","listCallbacks","freeze","Array","from","keys","has","unregisterCallback","clearRegistry","clear","createCallback","registerCallback","callCallback","args","apply","this","length","getHost","Event","Document","getRootNode","ShadowRoot","host","on","parts","captureAttr","passiveAttr","onceAttr","signalAttr"],"mappings":"AAEA,MAAMA,EAAS,oBACTC,EAAeD,EAAS,MAExBE,EAAc,eAEdC,EAAeC,OAAO,gBACtBC,EAAmBD,OAAO,oBAC1BE,EAAiB,IAAIC,IACrBC,EAAqB,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AAVxE,GAAuC,IAAjBA,EAAMuM,OAC7C,MAAM,IAAI/H,UAAU,qCACd,CACAvE,GAAkBD,IACvB4C,GAAuB5C,GAGxB,MAAM+M,EAAQ,CAAC,CAAChN,GAAYC,GAAQgG,IAoBpC,OAlBI3M,GACH0T,EAAMxJ,KAAK,CAACyJ,EAAa,KAGtB5T,GACH2T,EAAMxJ,KAAK,CAAC0J,EAAa,KAGtB9T,GACH4T,EAAMxJ,KAAK,CAAC2J,EAAU,KAGnB5T,aAAkBoL,YACrBqI,EAAMxJ,KAAK,CAAC4J,EAAYlI,GAAe3L,KACX,iBAAXA,GACjByT,EAAMxJ,KAAK,CAAC4J,EAAY7T,IAGlByT,EAAMrN,KAAI,EAAEyD,EAAMxC,KAAS,GAAGwC,MAASxC,OAAQb,KAAK,IAC5D,CACD"}
1
+ {"version":3,"file":"callbackRegistry.mjs","sources":["events.js","callbacks.js"],"sourcesContent":["import { hasCallback, getCallback } from './callbacks.js';\n\nconst PREFIX = 'data-aegis-event-';\nconst EVENT_PREFIX = PREFIX + 'on-';\nconst EVENT_PREFIX_LENGTH = EVENT_PREFIX.length;\nconst DATA_PREFIX = 'aegisEventOn';\nconst DATA_PREFIX_LENGTH = DATA_PREFIX.length;\nconst signalSymbol = Symbol('aegis:signal');\nconst controllerSymbol = Symbol('aegis:controller');\nconst signalRegistry = new Map();\nconst controllerRegistry = new Map();\n\nexport const once = PREFIX + 'once';\nexport const passive = PREFIX + 'passive';\nexport const capture = PREFIX + 'capture';\nexport const signal = PREFIX + 'signal';\nexport const controller = PREFIX + 'controller';\nexport const onAbort = EVENT_PREFIX + 'abort';\nexport const onBlur = EVENT_PREFIX + 'blur';\nexport const onFocus = EVENT_PREFIX + 'focus';\nexport const onCancel = EVENT_PREFIX + 'cancel';\nexport const onAuxclick = EVENT_PREFIX + 'auxclick';\nexport const onBeforeinput = EVENT_PREFIX + 'beforeinput';\nexport const onBeforetoggle = EVENT_PREFIX + 'beforetoggle';\nexport const onCanplay = EVENT_PREFIX + 'canplay';\nexport const onCanplaythrough = EVENT_PREFIX + 'canplaythrough';\nexport const onChange = EVENT_PREFIX + 'change';\nexport const onClick = EVENT_PREFIX + 'click';\nexport const onClose = EVENT_PREFIX + 'close';\nexport const onCommand = EVENT_PREFIX + 'command';\nexport const onContextmenu = EVENT_PREFIX + 'contextmenu';\nexport const onCopy = EVENT_PREFIX + 'copy';\nexport const onCuechange = EVENT_PREFIX + 'cuechange';\nexport const onCut = EVENT_PREFIX + 'cut';\nexport const onDblclick = EVENT_PREFIX + 'dblclick';\nexport const onDrag = EVENT_PREFIX + 'drag';\nexport const onDragend = EVENT_PREFIX + 'dragend';\nexport const onDragenter = EVENT_PREFIX + 'dragenter';\nexport const onDragexit = EVENT_PREFIX + 'dragexit';\nexport const onDragleave = EVENT_PREFIX + 'dragleave';\nexport const onDragover = EVENT_PREFIX + 'dragover';\nexport const onDragstart = EVENT_PREFIX + 'dragstart';\nexport const onDrop = EVENT_PREFIX + 'drop';\nexport const onDurationchange = EVENT_PREFIX + 'durationchange';\nexport const onEmptied = EVENT_PREFIX + 'emptied';\nexport const onEnded = EVENT_PREFIX + 'ended';\nexport const onFormdata = EVENT_PREFIX + 'formdata';\nexport const onInput = EVENT_PREFIX + 'input';\nexport const onInvalid = EVENT_PREFIX + 'invalid';\nexport const onKeydown = EVENT_PREFIX + 'keydown';\nexport const onKeypress = EVENT_PREFIX + 'keypress';\nexport const onKeyup = EVENT_PREFIX + 'keyup';\nexport const onLoad = EVENT_PREFIX + 'load';\nexport const onLoadeddata = EVENT_PREFIX + 'loadeddata';\nexport const onLoadedmetadata = EVENT_PREFIX + 'loadedmetadata';\nexport const onLoadstart = EVENT_PREFIX + 'loadstart';\nexport const onMousedown = EVENT_PREFIX + 'mousedown';\nexport const onMouseenter = EVENT_PREFIX + 'mouseenter';\nexport const onMouseleave = EVENT_PREFIX + 'mouseleave';\nexport const onMousemove = EVENT_PREFIX + 'mousemove';\nexport const onMouseout = EVENT_PREFIX + 'mouseout';\nexport const onMouseover = EVENT_PREFIX + 'mouseover';\nexport const onMouseup = EVENT_PREFIX + 'mouseup';\nexport const onWheel = EVENT_PREFIX + 'wheel';\nexport const onPaste = EVENT_PREFIX + 'paste';\nexport const onPause = EVENT_PREFIX + 'pause';\nexport const onPlay = EVENT_PREFIX + 'play';\nexport const onPlaying = EVENT_PREFIX + 'playing';\nexport const onProgress = EVENT_PREFIX + 'progress';\nexport const onRatechange = EVENT_PREFIX + 'ratechange';\nexport const onReset = EVENT_PREFIX + 'reset';\nexport const onResize = EVENT_PREFIX + 'resize';\nexport const onScroll = EVENT_PREFIX + 'scroll';\nexport const onScrollend = EVENT_PREFIX + 'scrollend';\nexport const onSecuritypolicyviolation = EVENT_PREFIX + 'securitypolicyviolation';\nexport const onSeeked = EVENT_PREFIX + 'seeked';\nexport const onSeeking = EVENT_PREFIX + 'seeking';\nexport const onSelect = EVENT_PREFIX + 'select';\nexport const onSlotchange = EVENT_PREFIX + 'slotchange';\nexport const onStalled = EVENT_PREFIX + 'stalled';\nexport const onSubmit = EVENT_PREFIX + 'submit';\nexport const onSuspend = EVENT_PREFIX + 'suspend';\nexport const onTimeupdate = EVENT_PREFIX + 'timeupdate';\nexport const onVolumechange = EVENT_PREFIX + 'volumechange';\nexport const onWaiting = EVENT_PREFIX + 'waiting';\nexport const onSelectstart = EVENT_PREFIX + 'selectstart';\nexport const onSelectionchange = EVENT_PREFIX + 'selectionchange';\nexport const onToggle = EVENT_PREFIX + 'toggle';\nexport const onPointercancel = EVENT_PREFIX + 'pointercancel';\nexport const onPointerdown = EVENT_PREFIX + 'pointerdown';\nexport const onPointerup = EVENT_PREFIX + 'pointerup';\nexport const onPointermove = EVENT_PREFIX + 'pointermove';\nexport const onPointerout = EVENT_PREFIX + 'pointerout';\nexport const onPointerover = EVENT_PREFIX + 'pointerover';\nexport const onPointerenter = EVENT_PREFIX + 'pointerenter';\nexport const onPointerleave = EVENT_PREFIX + 'pointerleave';\nexport const onGotpointercapture = EVENT_PREFIX + 'gotpointercapture';\nexport const onLostpointercapture = EVENT_PREFIX + 'lostpointercapture';\nexport const onMozfullscreenchange = EVENT_PREFIX + 'mozfullscreenchange';\nexport const onMozfullscreenerror = EVENT_PREFIX + 'mozfullscreenerror';\nexport const onAnimationcancel = EVENT_PREFIX + 'animationcancel';\nexport const onAnimationend = EVENT_PREFIX + 'animationend';\nexport const onAnimationiteration = EVENT_PREFIX + 'animationiteration';\nexport const onAnimationstart = EVENT_PREFIX + 'animationstart';\nexport const onTransitioncancel = EVENT_PREFIX + 'transitioncancel';\nexport const onTransitionend = EVENT_PREFIX + 'transitionend';\nexport const onTransitionrun = EVENT_PREFIX + 'transitionrun';\nexport const onTransitionstart = EVENT_PREFIX + 'transitionstart';\nexport const onWebkitanimationend = EVENT_PREFIX + 'webkitanimationend';\nexport const onWebkitanimationiteration = EVENT_PREFIX + 'webkitanimationiteration';\nexport const onWebkitanimationstart = EVENT_PREFIX + 'webkitanimationstart';\nexport const onWebkittransitionend = EVENT_PREFIX + 'webkittransitionend';\nexport const onError = EVENT_PREFIX + 'error';\n\nexport const eventAttrs = [\n\tonAbort,\n\tonBlur,\n\tonFocus,\n\tonCancel,\n\tonAuxclick,\n\tonBeforeinput,\n\tonBeforetoggle,\n\tonCanplay,\n\tonCanplaythrough,\n\tonChange,\n\tonClick,\n\tonClose,\n\tonCommand,\n\tonContextmenu,\n\tonCopy,\n\tonCuechange,\n\tonCut,\n\tonDblclick,\n\tonDrag,\n\tonDragend,\n\tonDragenter,\n\tonDragexit,\n\tonDragleave,\n\tonDragover,\n\tonDragstart,\n\tonDrop,\n\tonDurationchange,\n\tonEmptied,\n\tonEnded,\n\tonFormdata,\n\tonInput,\n\tonInvalid,\n\tonKeydown,\n\tonKeypress,\n\tonKeyup,\n\tonLoad,\n\tonLoadeddata,\n\tonLoadedmetadata,\n\tonLoadstart,\n\tonMousedown,\n\tonMouseenter,\n\tonMouseleave,\n\tonMousemove,\n\tonMouseout,\n\tonMouseover,\n\tonMouseup,\n\tonWheel,\n\tonPaste,\n\tonPause,\n\tonPlay,\n\tonPlaying,\n\tonProgress,\n\tonRatechange,\n\tonReset,\n\tonResize,\n\tonScroll,\n\tonScrollend,\n\tonSecuritypolicyviolation,\n\tonSeeked,\n\tonSeeking,\n\tonSelect,\n\tonSlotchange,\n\tonStalled,\n\tonSubmit,\n\tonSuspend,\n\tonTimeupdate,\n\tonVolumechange,\n\tonWaiting,\n\tonSelectstart,\n\tonSelectionchange,\n\tonToggle,\n\tonPointercancel,\n\tonPointerdown,\n\tonPointerup,\n\tonPointermove,\n\tonPointerout,\n\tonPointerover,\n\tonPointerenter,\n\tonPointerleave,\n\tonGotpointercapture,\n\tonLostpointercapture,\n\tonMozfullscreenchange,\n\tonMozfullscreenerror,\n\tonAnimationcancel,\n\tonAnimationend,\n\tonAnimationiteration,\n\tonAnimationstart,\n\tonTransitioncancel,\n\tonTransitionend,\n\tonTransitionrun,\n\tonTransitionstart,\n\tonWebkitanimationend,\n\tonWebkitanimationiteration,\n\tonWebkitanimationstart,\n\tonWebkittransitionend,\n\tonError,\n];\n\nlet selector = eventAttrs.map(attr => `[${CSS.escape(attr)}]`).join(', ');\n\nconst attrToProp = attr => `on${attr[EVENT_PREFIX_LENGTH].toUpperCase()}${attr.substring(EVENT_PREFIX_LENGTH + 1)}`;\n\nexport const eventToProp = event => EVENT_PREFIX + event;\n\nexport const hasEventAttribute = event => eventAttrs.includes(EVENT_PREFIX + event);\n\nconst isEventDataAttr = ([name]) => name.startsWith(DATA_PREFIX);\n\nfunction _addListeners(el, { signal, attrFilter = EVENTS } = {}) {\n\tconst dataset = el.dataset;\n\n\tfor (const [attr, val] of Object.entries(dataset).filter(isEventDataAttr)) {\n\t\ttry {\n\t\t\tconst event = 'on' + attr.substring(DATA_PREFIX_LENGTH);\n\n\t\t\tif (attrFilter.hasOwnProperty(event) && hasCallback(val)) {\n\t\t\t\tel.addEventListener(event.substring(2).toLowerCase(), getCallback(val), {\n\t\t\t\t\tpassive: dataset.hasOwnProperty('aegisEventPassive'),\n\t\t\t\t\tcapture: dataset.hasOwnProperty('aegisEventCapture'),\n\t\t\t\t\tonce: dataset.hasOwnProperty('aegisEventOnce'),\n\t\t\t\t\tsignal: dataset.hasOwnProperty('aegisEventSignal') ? getSignal(dataset.aegisEventSignal) : signal,\n\t\t\t\t});\n\t\t\t}\n\t\t} catch(err) {\n\t\t\treportError(err);\n\t\t}\n\t}\n}\n\nconst observer = new MutationObserver(records => {\n\trecords.forEach(record => {\n\t\tswitch(record.type) {\n\t\t\tcase 'childList':\n\t\t\t\t[...record.addedNodes]\n\t\t\t\t\t.filter(node => node.nodeType === Node.ELEMENT_NODE)\n\t\t\t\t\t.forEach(node => attachListeners(node));\n\t\t\t\tbreak;\n\n\t\t\tcase 'attributes':\n\t\t\t\tif (typeof record.oldValue === 'string' && hasCallback(record.oldValue)) {\n\t\t\t\t\trecord.target.removeEventListener(\n\t\t\t\t\t\trecord.attributeName.substring(EVENT_PREFIX_LENGTH),\n\t\t\t\t\t\tgetCallback(record.oldValue), {\n\t\t\t\t\t\t\tonce: record.target.hasAttribute(once),\n\t\t\t\t\t\t\tcapture: record.target.hasAttribute(capture),\n\t\t\t\t\t\t\tpassive: record.target.hasAttribute(passive),\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\trecord.target.hasAttribute(record.attributeName)\n\t\t\t\t\t&& hasCallback(record.target.getAttribute(record.attributeName))\n\t\t\t\t) {\n\t\t\t\t\trecord.target.addEventListener(\n\t\t\t\t\t\trecord.attributeName.substring(EVENT_PREFIX_LENGTH),\n\t\t\t\t\t\tgetCallback(record.target.getAttribute(record.attributeName)), {\n\t\t\t\t\t\t\tonce: record.target.hasAttribute(once),\n\t\t\t\t\t\t\tcapture: record.target.hasAttribute(capture),\n\t\t\t\t\t\t\tpassive: record.target.hasAttribute(passive),\n\t\t\t\t\t\t\tsignal: record.target.hasAttribute(signal) ? getSignal(record.target.getAttribute(signal)) : undefined,\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t}\n\t});\n});\n\nexport const EVENTS = {\n\tonAbort,\n\tonBlur,\n\tonFocus,\n\tonCancel,\n\tonAuxclick,\n\tonBeforeinput,\n\tonBeforetoggle,\n\tonCanplay,\n\tonCanplaythrough,\n\tonChange,\n\tonClick,\n\tonClose,\n\tonCommand,\n\tonContextmenu,\n\tonCopy,\n\tonCuechange,\n\tonCut,\n\tonDblclick,\n\tonDrag,\n\tonDragend,\n\tonDragenter,\n\tonDragexit,\n\tonDragleave,\n\tonDragover,\n\tonDragstart,\n\tonDrop,\n\tonDurationchange,\n\tonEmptied,\n\tonEnded,\n\tonFormdata,\n\tonInput,\n\tonInvalid,\n\tonKeydown,\n\tonKeypress,\n\tonKeyup,\n\tonLoad,\n\tonLoadeddata,\n\tonLoadedmetadata,\n\tonLoadstart,\n\tonMousedown,\n\tonMouseenter,\n\tonMouseleave,\n\tonMousemove,\n\tonMouseout,\n\tonMouseover,\n\tonMouseup,\n\tonWheel,\n\tonPaste,\n\tonPause,\n\tonPlay,\n\tonPlaying,\n\tonProgress,\n\tonRatechange,\n\tonReset,\n\tonResize,\n\tonScroll,\n\tonScrollend,\n\tonSecuritypolicyviolation,\n\tonSeeked,\n\tonSeeking,\n\tonSelect,\n\tonSlotchange,\n\tonStalled,\n\tonSubmit,\n\tonSuspend,\n\tonTimeupdate,\n\tonVolumechange,\n\tonWaiting,\n\tonSelectstart,\n\tonSelectionchange,\n\tonToggle,\n\tonPointercancel,\n\tonPointerdown,\n\tonPointerup,\n\tonPointermove,\n\tonPointerout,\n\tonPointerover,\n\tonPointerenter,\n\tonPointerleave,\n\tonGotpointercapture,\n\tonLostpointercapture,\n\tonMozfullscreenchange,\n\tonMozfullscreenerror,\n\tonAnimationcancel,\n\tonAnimationend,\n\tonAnimationiteration,\n\tonAnimationstart,\n\tonTransitioncancel,\n\tonTransitionend,\n\tonTransitionrun,\n\tonTransitionstart,\n\tonWebkitanimationend,\n\tonWebkitanimationiteration,\n\tonWebkitanimationstart,\n\tonWebkittransitionend,\n\tonError,\n\tonce,\n\tpassive,\n\tcapture,\n};\n\n/**\n * Register an attribute to observe for adding/removing event listeners\n *\n * @param {string} attr Name of the attribute to observe\n * @param {object} options\n * @param {boolean} [options.addListeners=false] Whether or not to automatically add listeners\n * @param {Document|Element} [options.base=document.body] Root node to observe\n * @param {AbortSignal} [options.signal] An abort signal to remove any listeners when aborted\n * @returns {string} The resulting `data-*` attribute name\n */\nexport function registerEventAttribute(attr, {\n\taddListeners = false,\n\tbase = document.body,\n\tsignal,\n} = {}) {\n\tconst fullAttr = EVENT_PREFIX + attr.toLowerCase();\n\n\tif (! eventAttrs.includes(fullAttr)) {\n\t\tconst sel = `[${CSS.escape(fullAttr)}]`;\n\t\tconst prop = attrToProp(fullAttr);\n\t\teventAttrs.push(fullAttr);\n\t\tEVENTS[prop] = fullAttr;\n\t\tselector += `, ${sel}`;\n\n\t\tif (addListeners) {\n\t\t\trequestAnimationFrame(() => {\n\t\t\t\tconst config = { attrFilter: { [prop]: sel }, signal };\n\t\t\t\t[base, ...base.querySelectorAll(sel)].forEach(el => _addListeners(el, config));\n\t\t\t});\n\t\t}\n\t}\n\n\treturn fullAttr;\n}\n\n/**\n * Registers an `AbortController` in the controller registry and returns the key for it\n *\n * @param {AbortController} controller\n * @returns {string} The randomly generated key with which the controller is registered\n * @throws {TypeError} If controller is not an `AbortController`\n * @throws {Error} Any `reason` if controller is already aborted\n */\nexport function registerController(controller) {\n\tif (! (controller instanceof AbortController)) {\n\t\tthrow new TypeError('Controller is not an `AbortSignal.');\n\t} else if (controller.signal.aborted) {\n\t\tthrow controller.signal.reason;\n\t} else if (typeof controller.signal[controllerSymbol] === 'string') {\n\t\treturn controller.signal[controllerSymbol];\n\t} else {\n\t\tconst key = 'aegis:event:controller:' + crypto.randomUUID();\n\t\tObject.defineProperty(controller.signal, controllerSymbol, { value: key, writable: false, enumerable: false });\n\t\tcontrollerRegistry.set(key, controller);\n\n\t\tcontroller.signal.addEventListener('abort', unregisterController, { once: true });\n\n\t\treturn key;\n\t}\n}\n\n/**\n * Removes a controller from the registry\n *\n * @param {AbortController|AbortSignal|string} key The registed key or the controller or signal it corresponds to\n * @returns {boolean} Whether or not the controller was successfully unregistered\n */\nexport function unregisterController(key) {\n\tif (key instanceof AbortController) {\n\t\treturn controllerRegistry.delete(key.signal[controllerSymbol]);\n\t} else if (key instanceof AbortSignal) {\n\t\treturn controllerRegistry.delete(key[controllerSymbol]);\n\t} else {\n\t\treturn controllerRegistry.delete(key);\n\t}\n}\n\n/**\n * Creates and registers an `AbortController` in the controller registry and returns the key for it\n *\n * @param {object} options\n * @param {AbortSignal} [options.signal] An optional `AbortSignal` to externally abort the controller with\n * @returns {string} The randomly generated key with which the controller is registered\n */\nexport function createController({ signal } = {}) {\n\tconst controller = new AbortController();\n\n\tif (signal instanceof AbortSignal) {\n\t\tsignal.addEventListener('abort', ({ target }) => controller.abort(target.reason), { signal: controller.signal});\n\t}\n\n\treturn registerController(controller);\n}\n\n/**\n * Get a registetd controller from the registry\n *\n * @param {string} key Generated key with which the controller was registered\n * @returns {AbortController|void} Any registered controller, if any\n */\nexport const getController = key => controllerRegistry.get(key);\n\nexport function abortController(key, reason) {\n\tconst controller = getController(key);\n\n\tif (! (controller instanceof AbortController)) {\n\t\treturn false;\n\t} else if (typeof reason === 'string') {\n\t\tcontroller.abort(new Error(reason));\n\t\treturn true;\n\t} else {\n\t\tcontroller.abort(reason);\n\t\treturn true;\n\t}\n}\n\n/**\n * Register an `AbortSignal` to be used in declarative HTML as a value for `data-aegis-event-signal`\n *\n * @param {AbortSignal} signal The signal to register\n * @returns {string} The registered key\n * @throws {TypeError} Thrown if not an `AbortSignal`\n */\nexport function registerSignal(signal) {\n\tif (! (signal instanceof AbortSignal)) {\n\t\tthrow new TypeError('Signal must be an `AbortSignal`.');\n\t} else if (typeof signal[signalSymbol] === 'string') {\n\t\treturn signal[signalSymbol];\n\t} else {\n\t\tconst key = 'aegis:event:signal:' + crypto.randomUUID();\n\t\tObject.defineProperty(signal, signalSymbol, { value: key, writable: false, enumerable: false });\n\t\tsignalRegistry.set(key, signal);\n\t\tsignal.addEventListener('abort', ({ target }) => unregisterSignal(target[signalSymbol]), { once: true });\n\n\t\treturn key;\n\t}\n}\n\n/**\n * Gets and `AbortSignal` from the registry\n *\n * @param {string} key The registered key for the signal\n * @returns {AbortSignal|void} The corresponding `AbortSignal`, if any\n */\nexport const getSignal = key => signalRegistry.get(key);\n\n/**\n * Removes an `AbortSignal` from the registry\n *\n * @param {AbortSignal|string} signal An `AbortSignal` or the registered key for one\n * @returns {boolean} Whether or not the signal was sucessfully unregistered\n * @throws {TypeError} Throws if `signal` is not an `AbortSignal` or the key for a registered signal\n */\nexport function unregisterSignal(signal) {\n\tif (signal instanceof AbortSignal) {\n\t\treturn signalRegistry.delete(signal[signalSymbol]);\n\t} else if (typeof signal === 'string') {\n\t\treturn signalRegistry.delete(signal);\n\t} else {\n\t\tthrow new TypeError('Signal must be an `AbortSignal` or registered key/attribute.');\n\t}\n}\n\n/**\n * Add listeners to an element and its children, matching a generated query based on registered attributes\n *\n * @param {Element|Document} target Root node to add listeners from\n * @param {object} options\n * @param {AbortSignal} [options.signal] Optional signal to remove event listeners\n * @returns {Element|Document} Returns the passed target node\n */\nexport function attachListeners(target, { signal } = {}) {\n\tconst nodes = target instanceof Element && target.matches(selector)\n\t\t? [target, ...target.querySelectorAll(selector)]\n\t\t: target.querySelectorAll(selector);\n\n\tnodes.forEach(el => _addListeners(el, { signal }));\n\n\treturn target;\n}\n\n/**\n * Add a node to the `MutationObserver` to observe attributes and add/remove event listeners\n *\n * @param {Document|Element} root Element to observe attributes on\n */\nexport function observeEvents(root = document) {\n\tattachListeners(root);\n\n\tobserver.observe(root, {\n\t\tsubtree: true,\n\t\tchildList:true,\n\t\tattributes: true,\n\t\tattributeOldValue: true,\n\t\tattributeFilter: eventAttrs,\n\t});\n}\n\n/**\n * Disconnects the `MutationObserver`, disabling observing of all attribute changes\n *\n * @returns {void}\n */\nexport const disconnectEventsObserver = () => observer.disconnect();\n\n/**\n * Register a global error handler callback\n *\n * @param {Function} callback Callback to register as a global error handler\n * @param {EventInit} config Typical event listener config object\n */\nexport function setGlobalErrorHandler(callback, { capture, once, passive, signal } = {}) {\n\tif (callback instanceof Function) {\n\t\tglobalThis.addEventListener('error', callback, { capture, once, passive, signal });\n\t} else {\n\t\tthrow new TypeError('Callback is not a function.');\n\t}\n}\n","import {\n\teventToProp, capture as captureAttr, once as onceAttr, passive as passiveAttr, signal as signalAttr,\n\tregisterEventAttribute, hasEventAttribute, registerSignal, abortController,\n} from './events.js';\n\nlet _isRegistrationOpen = true;\n\nconst $$ = (selector, base = document) => base.querySelectorAll(selector);\n\nconst $ = (selector, base = document) => base.querySelector(selector);\n\nexport const requestFullscreen = { attr: 'data-request-fullscreen-selector', data: 'requestFullscreenSelector' };\nexport const toggleFullsceen = { attr: 'data-toggle-fullscreen-selector', data: 'toggleFullscreenSelector' };\n\nexport const FUNCS = {\n\tdebug: {\n\t\tlog: 'aegis:debug:log',\n\t\tinfo: 'aegis:debug:info',\n\t\twarn: 'aegis:debug:warn',\n\t\terror: 'aegis:debug:error',\n\t},\n\tnavigate: {\n\t\tback: 'aegis:navigate:back',\n\t\tforward: 'aegis:navigate:forward',\n\t\treload: 'aegis:navigate:reload',\n\t\tclose: 'aegis:navigate:close',\n\t\tlink: 'aegis:navigate:go',\n\t\tpopup: 'aegis:navigate:popup',\n\t},\n\tui: {\n\t\tcommand: 'aegis:ui:command',\n\t\tprint: 'aegis:ui:print',\n\t\tremove: 'aegis:ui:remove',\n\t\thide: 'aegis:ui:hide',\n\t\tunhide: 'aegis:ui:unhide',\n\t\tshowModal: 'aegis:ui:showModal',\n\t\tcloseModal: 'aegis:ui:closeModal',\n\t\tshowPopover: 'aegis:ui:showPopover',\n\t\thidePopover: 'aegis:ui:hidePopover',\n\t\ttogglePopover: 'aegis:ui:togglePopover',\n\t\tenable: 'aegis:ui:enable',\n\t\tdisable: 'aegis:ui:disable',\n\t\tscrollTo: 'aegis:ui:scrollTo',\n\t\tprevent: 'aegis:ui:prevent',\n\t\trevokeObjectURL: 'aegis:ui:revokeObjectURL',\n\t\tcancelAnimationFrame: 'aegis:ui:cancelAnimationFrame',\n\t\trequestFullscreen: 'aegis:ui:requestFullscreen',\n\t\ttoggleFullscreen: 'aegis:ui:toggleFullsceen',\n\t\texitFullsceen: 'aegis:ui:exitFullscreen',\n\t\topen: 'aegis:ui:open',\n\t\tclose: 'aegis:ui:close',\n\t\tabortController: 'aegis:ui:controller:abort',\n\t},\n};\n\n/**\n * @type {Map<string, function>}\n */\nconst registry = new Map([\n\t[FUNCS.debug.log, console.log],\n\t[FUNCS.debug.warn, console.warn],\n\t[FUNCS.debug.error, console.error],\n\t[FUNCS.debug.info, console.info],\n\t[FUNCS.navigate.back, () => history.back()],\n\t[FUNCS.navigate.forward, () => history.forward()],\n\t[FUNCS.navigate.reload, () => history.go(0)],\n\t[FUNCS.navigate.close, () => globalThis.close()],\n\t[FUNCS.navigate.link, event => {\n\t\tif (event.isTrusted) {\n\t\t\tevent.preventDefault();\n\t\t\tlocation.href = event.currentTarget.dataset.url;\n\t\t}\n\t}],\n\t[FUNCS.navigate.popup, event => {\n\t\tif (event.isTrusted) {\n\t\t\tevent.preventDefault();\n\t\t\tglobalThis.open(event.currentTarget.dataset.url);\n\t\t}\n\t}],\n\t[FUNCS.ui.hide, ({ currentTarget }) => {\n\t\t$$(currentTarget.dataset.hideSelector).forEach(el => el.hidden = true);\n\t}],\n\t[FUNCS.ui.unhide, ({ currentTarget }) => {\n\t\t$$(currentTarget.dataset.unhideSelector).forEach(el => el.hidden = false);\n\t}],\n\t[FUNCS.ui.disable, ({ currentTarget }) => {\n\t\t$$(currentTarget.dataset.disableSelector).forEach(el => el.disabled = true);\n\t}],\n\t[FUNCS.ui.enable, ({ currentTarget }) => {\n\t\t$$(currentTarget.dataset.enableSelector).forEach(el => el.disabled = false);\n\t}],\n\t[FUNCS.ui.remove, ({ currentTarget }) => {\n\t\t$$(currentTarget.dataset.removeSelector).forEach(el => el.remove());\n\t}],\n\t[FUNCS.ui.scrollTo, ({ currentTarget }) => {\n\t\tconst target = $(currentTarget.dataset.scrollToSelector);\n\n\t\tif (target instanceof Element) {\n\t\t\ttarget.scrollIntoView({\n\t\t\t\tbehavior: matchMedia('(prefers-reduced-motion: reduce)').matches\n\t\t\t\t\t? 'instant'\n\t\t\t\t\t: 'smooth',\n\t\t\t});\n\t\t}\n\t}],\n\t[FUNCS.ui.revokeObjectURL, ({ currentTarget }) => URL.revokeObjectURL(currentTarget.src)],\n\t[FUNCS.ui.cancelAnimationFrame, ({ currentTarget }) => cancelAnimationFrame(parseInt(currentTarget.dataset.animationFrame))],\n\t[FUNCS.ui.clearInterval, ({ currentTarget }) => clearInterval(parseInt(currentTarget.dataset.clearInterval))],\n\t[FUNCS.ui.clearTimeout, ({ currentTarget }) => clearTimeout(parseInt(currentTarget.dataset.timeout))],\n\t[FUNCS.ui.abortController, ({ currentTarget }) => abortController(currentTarget.dataset.aegisEventController, currentTarget.dataset.aegisControllerReason)],\n\t[FUNCS.ui.open, ({ currentTarget }) => document.querySelector(currentTarget.dataset.openSelector).open = true],\n\t[FUNCS.ui.close, ({ currentTarget }) => document.querySelector(currentTarget.dataset.closeSelector).open = false],\n\t[FUNCS.ui.showModal, ({ currentTarget }) => {\n\t\tconst target = $(currentTarget.dataset.showModalSelector);\n\n\t\tif (target instanceof HTMLDialogElement) {\n\t\t\ttarget.showModal();\n\t\t}\n\t}],\n\t[FUNCS.ui.closeModal, ({ currentTarget }) => {\n\t\tconst target = $(currentTarget.dataset.closeModalSelector);\n\n\t\tif (target instanceof HTMLDialogElement) {\n\t\t\ttarget.close();\n\t\t}\n\t}],\n\t[FUNCS.ui.showPopover, ({ currentTarget }) => {\n\t\tconst target = $(currentTarget.dataset.showPopoverSelector);\n\n\t\tif (target instanceof HTMLElement) {\n\t\t\ttarget.showPopover();\n\t\t}\n\t}],\n\t[FUNCS.ui.hidePopover, ({ currentTarget }) => {\n\t\tconst target = $(currentTarget.dataset.hidePopoverSelector);\n\n\t\tif (target instanceof HTMLElement) {\n\t\t\ttarget.hidePopover();\n\t\t}\n\t}],\n\t[FUNCS.ui.togglePopover, ({ currentTarget }) => {\n\t\tconst target = $(currentTarget.dataset.togglePopoverSelector);\n\n\t\tif (target instanceof HTMLElement) {\n\t\t\ttarget.togglePopover();\n\t\t}\n\t}],\n\t[FUNCS.ui.print, () => globalThis.print()],\n\t[FUNCS.ui.prevent, event => event.preventDefault()],\n\t[FUNCS.ui.requestFullscreen, ({ currentTarget}) => {\n\t\tif (currentTarget.dataset.hasOwnProperty(requestFullscreen.data)) {\n\t\t\tdocument.getElementById(currentTarget.dataset[requestFullscreen.data]).requestFullscreen();\n\t\t} else {\n\t\t\tcurrentTarget.requestFullscreen();\n\t\t}\n\t}],\n\t[FUNCS.ui.toggleFullscreen, ({ currentTarget }) => {\n\t\tconst target = currentTarget.dataset.hasOwnProperty(toggleFullsceen.data)\n\t\t\t? document.getElementById(currentTarget.dataset[toggleFullsceen.data])\n\t\t\t: currentTarget;\n\n\t\tif (target.isSameNode(document.fullscreenElement)) {\n\t\t\tdocument.exitFullscreen();\n\t\t} else {\n\t\t\ttarget.requestFullscreen();\n\t\t}\n\t}],\n\t[FUNCS.ui.exitFullsceen, () => document.exitFullscreen()],\n]);\n\nexport class CallbackRegistryKey extends String {\n\t[Symbol.dispose]() {\n\t\tregistry.delete(this.toString());\n\t}\n}\n\n/**\n * Check if callback registry is open\n *\n * @returns {boolean} Whether or not callback registry is open\n */\nexport const isRegistrationOpen = () => _isRegistrationOpen;\n\n/**\n * Close callback registry\n *\n * @returns {boolean} Whether or not the callback was succesfully removed\n */\nexport const closeRegistration = () => _isRegistrationOpen = false;\n\n/**\n * Get an array of registered callbacks\n *\n * @returns {Array} A frozen array listing keys to all registered callbacks\n */\nexport const listCallbacks = () => Object.freeze(Array.from(registry.keys()));\n\n/**\n * Check if a callback is registered\n *\n * @param {CallbackRegistryKey|string} name The name/key to check for in callback registry\n * @returns {boolean} Whether or not a callback is registered\n */\nexport const hasCallback = name => registry.has(name?.toString());\n\n/**\n * Get a callback from the registry by name/key\n *\n * @param {CallbackRegistryKey|string} name The name/key of the callback to get\n * @returns {Function|undefined} The corresponding function registered under that name/key\n */\nexport const getCallback = name => registry.get(name?.toString());\n\n/**\n *\t Remove a callback from the registry\n *\n * @param {CallbackRegistryKey|string} name The name/key of the callback to get\n * @returns {boolean} Whether or not the callback was successfully unregisterd\n */\nexport const unregisterCallback = name => _isRegistrationOpen && registry.delete(name?.toString());\n\n/**\n * Remove all callbacks from the registry\n *\n * @returns {void}\n */\nexport const clearRegistry = () => registry.clear();\n\n/**\n * Create a registered callback with a randomly generated name\n *\n * @param {Function} callback Callback function to register\n * @param {object} [config]\n * @param {DisposableStack|AsyncDisposableStack} [config.stack] Optional `DisposableStack` to handle disposal and unregistering.\n * @returns {string} The automatically generated key/name of the registered callback\n */\nexport const createCallback = (callback, { stack } = {}) => registerCallback('aegis:callback:' + crypto.randomUUID(), callback, { stack });\n\n/**\n * Call a callback fromt the registry by name/key\n *\n * @param {CallbackRegistryKey|string} name The name/key of the registered function\n * @param {...any} args Any arguments to pass along to the function\n * @returns {any} Whatever the return value of the function is\n * @throws {Error} Throws if callback is not found or any error resulting from calling the function\n */\nexport function callCallback(name, ...args) {\n\tif (registry.has(name?.toString())) {\n\t\treturn registry.get(name?.toString()).apply(this || globalThis, args);\n\t} else {\n\t\tthrow new Error(`No ${name} function registered.`);\n\t}\n}\n\n/**\n * Register a named callback in registry\n *\n * @param {CallbackRegistryKey|string} name The name/key to register the callback under\n * @param {Function} callback The callback value to register\n * @param {object} config\n * @param {DisposableStack|AsyncDisposableStack} [config.stack] Optional `DisposableStack` to handle disposal and unregistering.\n * @returns {string} The registered name/key\n */\nexport function registerCallback(name, callback, { stack } = {}) {\n\tif (typeof name === 'string') {\n\t\treturn registerCallback(new CallbackRegistryKey(name), callback, { stack });\n\t}else if (! (name instanceof CallbackRegistryKey)) {\n\t\tthrow new TypeError('Callback name must be a disposable string/CallbackRegistryKey.');\n\t} if (! (callback instanceof Function)) {\n\t\tthrow new TypeError('Callback must be a function.');\n\t} else if (! _isRegistrationOpen) {\n\t\tthrow new TypeError('Cannot register new callbacks because registry is closed.');\n\t} else if (registry.has(name?.toString())) {\n\t\tthrow new Error(`Handler \"${name}\" is already registered.`);\n\t} else if (stack instanceof DisposableStack || stack instanceof AsyncDisposableStack) {\n\t\tconst key = stack.use(new CallbackRegistryKey(name));\n\t\tregistry.set(key.toString(), callback);\n\n\t\treturn key;\n\t} else {\n\t\tconst key = new CallbackRegistryKey(name);\n\t\tregistry.set(key.toString(), callback);\n\n\t\treturn key;\n\t}\n}\n\n/**\n * Get the host/root node of a given thing.\n *\n * @param {Event|Document|Element|ShadowRoot} target Source thing to search for host of\n * @returns {Document|Element|null} The host/root node, or null\n */\nexport function getHost(target) {\n\tif (target instanceof Event) {\n\t\treturn getHost(target.currentTarget);\n\t} else if (target instanceof Document) {\n\t\treturn target;\n\t} else if (target instanceof Element) {\n\t\treturn getHost(target.getRootNode());\n\t} else if (target instanceof ShadowRoot) {\n\t\treturn target.host;\n\t} else {\n\t\treturn null;\n\t}\n}\n\nexport function on(event, callback, { capture = false, passive = false, once = false, signal, stack } = {}) {\n\tif (callback instanceof Function) {\n\t\treturn on(event, createCallback(callback, { stack }), { capture, passive, once, signal });\n\t} else if (! (callback instanceof String || typeof callback === 'string') || callback.length === 0) {\n\t\tthrow new TypeError('Callback must be a function or a registered callback string.');\n\t} else if (typeof event !== 'string' || event.length === 0) {\n\t\tthrow new TypeError('Event must be a non-empty string.');\n\t} else {\n\t\tif (! hasEventAttribute(event)) {\n\t\t\tregisterEventAttribute(event);\n\t\t}\n\n\t\tconst parts = [[eventToProp(event), callback]];\n\n\t\tif (capture) {\n\t\t\tparts.push([captureAttr, '']);\n\t\t}\n\n\t\tif (passive) {\n\t\t\tparts.push([passiveAttr, '']);\n\t\t}\n\n\t\tif (once) {\n\t\t\tparts.push([onceAttr, '']);\n\t\t}\n\n\t\tif (signal instanceof AbortSignal) {\n\t\t\tparts.push([signalAttr, registerSignal(signal)]);\n\t\t} else if (typeof signal === 'string') {\n\t\t\tparts.push([signalAttr, signal]);\n\t\t}\n\n\t\treturn parts.map(([prop, val]) => `${prop}=\"${val}\"`).join(' ');\n\t}\n}\n"],"names":["PREFIX","EVENT_PREFIX","DATA_PREFIX","signalSymbol","Symbol","controllerSymbol","signalRegistry","Map","controllerRegistry","once","passive","capture","signal","controller","onAbort","onBlur","onFocus","onCancel","onAuxclick","onBeforeinput","onBeforetoggle","onCanplay","onCanplaythrough","onChange","onClick","onClose","onCommand","onContextmenu","onCopy","onCuechange","onCut","onDblclick","onDrag","onDragend","onDragenter","onDragexit","onDragleave","onDragover","onDragstart","onDrop","onDurationchange","onEmptied","onEnded","onFormdata","onInput","onInvalid","onKeydown","onKeypress","onKeyup","onLoad","onLoadeddata","onLoadedmetadata","onLoadstart","onMousedown","onMouseenter","onMouseleave","onMousemove","onMouseout","onMouseover","onMouseup","onWheel","onPaste","onPause","onPlay","onPlaying","onProgress","onRatechange","onReset","onResize","onScroll","onScrollend","onSecuritypolicyviolation","onSeeked","onSeeking","onSelect","onSlotchange","onStalled","onSubmit","onSuspend","onTimeupdate","onVolumechange","onWaiting","onSelectstart","onSelectionchange","onToggle","onPointercancel","onPointerdown","onPointerup","onPointermove","onPointerout","onPointerover","onPointerenter","onPointerleave","onGotpointercapture","onLostpointercapture","onMozfullscreenchange","onMozfullscreenerror","onAnimationcancel","onAnimationend","onAnimationiteration","onAnimationstart","onTransitioncancel","onTransitionend","onTransitionrun","onTransitionstart","onWebkitanimationend","onWebkitanimationiteration","onWebkitanimationstart","onWebkittransitionend","onError","eventAttrs","selector","map","attr","CSS","escape","join","eventToProp","event","hasEventAttribute","includes","isEventDataAttr","name","startsWith","_addListeners","el","attrFilter","EVENTS","dataset","val","Object","entries","filter","substring","hasOwnProperty","hasCallback","addEventListener","toLowerCase","getCallback","getSignal","aegisEventSignal","err","reportError","observer","MutationObserver","records","forEach","record","type","addedNodes","node","nodeType","Node","ELEMENT_NODE","attachListeners","oldValue","target","removeEventListener","attributeName","hasAttribute","getAttribute","undefined","registerEventAttribute","addListeners","base","document","body","fullAttr","sel","prop","toUpperCase","EVENT_PREFIX_LENGTH","attrToProp","push","requestAnimationFrame","config","querySelectorAll","registerController","AbortController","aborted","reason","key","crypto","randomUUID","defineProperty","value","writable","enumerable","set","unregisterController","TypeError","delete","AbortSignal","createController","abort","getController","get","abortController","Error","registerSignal","unregisterSignal","Element","matches","observeEvents","root","observe","subtree","childList","attributes","attributeOldValue","attributeFilter","disconnectEventsObserver","disconnect","setGlobalErrorHandler","callback","Function","globalThis","_isRegistrationOpen","$$","$","querySelector","requestFullscreen","data","toggleFullsceen","FUNCS","debug","log","info","warn","error","navigate","back","forward","reload","close","link","popup","ui","command","print","remove","hide","unhide","showModal","closeModal","showPopover","hidePopover","togglePopover","enable","disable","scrollTo","prevent","revokeObjectURL","cancelAnimationFrame","toggleFullscreen","exitFullsceen","open","registry","console","history","go","isTrusted","preventDefault","location","href","currentTarget","url","hideSelector","hidden","unhideSelector","disableSelector","disabled","enableSelector","removeSelector","scrollToSelector","scrollIntoView","behavior","matchMedia","URL","src","parseInt","animationFrame","clearInterval","clearTimeout","timeout","aegisEventController","aegisControllerReason","openSelector","closeSelector","showModalSelector","HTMLDialogElement","closeModalSelector","showPopoverSelector","HTMLElement","hidePopoverSelector","togglePopoverSelector","getElementById","isSameNode","fullscreenElement","exitFullscreen","CallbackRegistryKey","String","dispose","this","toString","isRegistrationOpen","closeRegistration","listCallbacks","freeze","Array","from","keys","has","unregisterCallback","clearRegistry","clear","createCallback","stack","registerCallback","callCallback","args","apply","DisposableStack","AsyncDisposableStack","use","getHost","Event","Document","getRootNode","ShadowRo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kBACnCwG,GAAuBxG,EAAe,qBACtCyG,GAA6BzG,EAAe,2BAC5C0G,GAAyB1G,EAAe,uBACxC2G,GAAwB3G,EAAe,sBACvC4G,GAAU5G,EAAe,QAEzB6G,GAAa,CACzBhG,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,IAGD,IAAIE,GAAWD,GAAWE,IAAIC,GAAQ,IAAIC,IAAIC,OAAOF,OAAUG,KAAK,MAEpE,MAEaC,GAAcC,GAASrH,EAAeqH,EAEtCC,GAAoBD,GAASR,GAAWU,SAASvH,EAAeqH,GAEvEG,GAAkB,EAAEC,KAAUA,EAAKC,WAAWzH,GAEpD,SAAS0H,GAAcC,GAAIjH,OAAEA,EAAMkH,WAAEA,EAAaC,IAAW,IAC5D,MAAMC,EAAUH,EAAGG,QAEnB,IAAK,MAAOf,EAAMgB,KAAQC,OAAOC,QAAQH,GAASI,OAAOX,IACxD,IACC,MAAMH,EAAQ,KAAOL,EAAKoB,UA9NFnI,IAgOpB4H,EAAWQ,eAAehB,IAAUiB,GAAYN,IACnDJ,EAAGW,iBAAiBlB,EAAMe,UAAU,GAAGI,cAAe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* @type {Map<string, function>}
559
+ */
557
560
  const registry = new Map([
558
561
  [FUNCS.debug.log, console.log],
559
562
  [FUNCS.debug.warn, console.warn],
@@ -666,6 +669,12 @@ const registry = new Map([
666
669
  [FUNCS.ui.exitFullsceen, () => document.exitFullscreen()],
667
670
  ]);
668
671
 
672
+ class CallbackRegistryKey extends String {
673
+ [Symbol.dispose]() {
674
+ registry.delete(this.toString());
675
+ }
676
+ }
677
+
669
678
  /**
670
679
  * Check if callback registry is open
671
680
  *
@@ -690,26 +699,26 @@ const listCallbacks = () => Object.freeze(Array.from(registry.keys()));
690
699
  /**
691
700
  * Check if a callback is registered
692
701
  *
693
- * @param {string} name The name/key to check for in callback registry
702
+ * @param {CallbackRegistryKey|string} name The name/key to check for in callback registry
694
703
  * @returns {boolean} Whether or not a callback is registered
695
704
  */
696
- const hasCallback = name => registry.has(name);
705
+ const hasCallback = name => registry.has(name?.toString());
697
706
 
698
707
  /**
699
708
  * Get a callback from the registry by name/key
700
709
  *
701
- * @param {string} name The name/key of the callback to get
710
+ * @param {CallbackRegistryKey|string} name The name/key of the callback to get
702
711
  * @returns {Function|undefined} The corresponding function registered under that name/key
703
712
  */
704
- const getCallback = name => registry.get(name);
713
+ const getCallback = name => registry.get(name?.toString());
705
714
 
706
715
  /**
707
716
  * Remove a callback from the registry
708
717
  *
709
- * @param {string} name The name/key of the callback to get
718
+ * @param {CallbackRegistryKey|string} name The name/key of the callback to get
710
719
  * @returns {boolean} Whether or not the callback was successfully unregisterd
711
720
  */
712
- const unregisterCallback = name => _isRegistrationOpen && registry.delete(name);
721
+ const unregisterCallback = name => _isRegistrationOpen && registry.delete(name?.toString());
713
722
 
714
723
  /**
715
724
  * Remove all callbacks from the registry
@@ -722,21 +731,23 @@ const clearRegistry = () => registry.clear();
722
731
  * Create a registered callback with a randomly generated name
723
732
  *
724
733
  * @param {Function} callback Callback function to register
734
+ * @param {object} [config]
735
+ * @param {DisposableStack|AsyncDisposableStack} [config.stack] Optional `DisposableStack` to handle disposal and unregistering.
725
736
  * @returns {string} The automatically generated key/name of the registered callback
726
737
  */
727
- const createCallback = (callback) => registerCallback('aegis:callback:' + crypto.randomUUID(), callback);
738
+ const createCallback = (callback, { stack } = {}) => registerCallback('aegis:callback:' + crypto.randomUUID(), callback, { stack });
728
739
 
729
740
  /**
730
741
  * Call a callback fromt the registry by name/key
731
742
  *
732
- * @param {string} name The name/key of the registered function
743
+ * @param {CallbackRegistryKey|string} name The name/key of the registered function
733
744
  * @param {...any} args Any arguments to pass along to the function
734
745
  * @returns {any} Whatever the return value of the function is
735
746
  * @throws {Error} Throws if callback is not found or any error resulting from calling the function
736
747
  */
737
748
  function callCallback(name, ...args) {
738
- if (registry.has(name)) {
739
- return registry.get(name).apply(this || globalThis, args);
749
+ if (registry.has(name?.toString())) {
750
+ return registry.get(name?.toString()).apply(this || globalThis, args);
740
751
  } else {
741
752
  throw new Error(`No ${name} function registered.`);
742
753
  }
@@ -745,22 +756,33 @@ function callCallback(name, ...args) {
745
756
  /**
746
757
  * Register a named callback in registry
747
758
  *
748
- * @param {string} name The name/key to register the callback under
759
+ * @param {CallbackRegistryKey|string} name The name/key to register the callback under
749
760
  * @param {Function} callback The callback value to register
761
+ * @param {object} config
762
+ * @param {DisposableStack|AsyncDisposableStack} [config.stack] Optional `DisposableStack` to handle disposal and unregistering.
750
763
  * @returns {string} The registered name/key
751
764
  */
752
- function registerCallback(name, callback) {
753
- if (typeof name !== 'string' || name.length === 0) {
754
- throw new TypeError('Callback name must be a string.');
765
+ function registerCallback(name, callback, { stack } = {}) {
766
+ if (typeof name === 'string') {
767
+ return registerCallback(new CallbackRegistryKey(name), callback, { stack });
768
+ }else if (! (name instanceof CallbackRegistryKey)) {
769
+ throw new TypeError('Callback name must be a disposable string/CallbackRegistryKey.');
755
770
  } if (! (callback instanceof Function)) {
756
771
  throw new TypeError('Callback must be a function.');
757
772
  } else if (! _isRegistrationOpen) {
758
773
  throw new TypeError('Cannot register new callbacks because registry is closed.');
759
- } else if (registry.has(name)) {
774
+ } else if (registry.has(name?.toString())) {
760
775
  throw new Error(`Handler "${name}" is already registered.`);
776
+ } else if (stack instanceof DisposableStack || stack instanceof AsyncDisposableStack) {
777
+ const key = stack.use(new CallbackRegistryKey(name));
778
+ registry.set(key.toString(), callback);
779
+
780
+ return key;
761
781
  } else {
762
- registry.set(name, callback);
763
- return name;
782
+ const key = new CallbackRegistryKey(name);
783
+ registry.set(key.toString(), callback);
784
+
785
+ return key;
764
786
  }
765
787
  }
766
788
 
@@ -784,10 +806,10 @@ function getHost(target) {
784
806
  }
785
807
  }
786
808
 
787
- function on(event, callback, { capture: capture$1 = false, passive: passive$1 = false, once: once$1 = false, signal: signal$1 } = {}) {
809
+ function on(event, callback, { capture: capture$1 = false, passive: passive$1 = false, once: once$1 = false, signal: signal$1, stack } = {}) {
788
810
  if (callback instanceof Function) {
789
- return on(event, createCallback(callback), { capture: capture$1, passive: passive$1, once: once$1, signal: signal$1 });
790
- } else if (typeof callback !== 'string' || callback.length === 0) {
811
+ return on(event, createCallback(callback, { stack }), { capture: capture$1, passive: passive$1, once: once$1, signal: signal$1 });
812
+ } else if (! (callback instanceof String || typeof callback === 'string') || callback.length === 0) {
791
813
  throw new TypeError('Callback must be a function or a registered callback string.');
792
814
  } else if (typeof event !== 'string' || event.length === 0) {
793
815
  throw new TypeError('Event must be a non-empty string.');
@@ -820,6 +842,7 @@ function on(event, callback, { capture: capture$1 = false, passive: passive$1 =
820
842
  }
821
843
  }
822
844
 
845
+ exports.CallbackRegistryKey = CallbackRegistryKey;
823
846
  exports.FUNCS = FUNCS;
824
847
  exports.callCallback = callCallback;
825
848
  exports.clearRegistry = clearRegistry;
package/callbacks.js CHANGED
@@ -53,6 +53,9 @@ export const FUNCS = {
53
53
  },
54
54
  };
55
55
 
56
+ /**
57
+ * @type {Map<string, function>}
58
+ */
56
59
  const registry = new Map([
57
60
  [FUNCS.debug.log, console.log],
58
61
  [FUNCS.debug.warn, console.warn],
@@ -165,6 +168,12 @@ const registry = new Map([
165
168
  [FUNCS.ui.exitFullsceen, () => document.exitFullscreen()],
166
169
  ]);
167
170
 
171
+ export class CallbackRegistryKey extends String {
172
+ [Symbol.dispose]() {
173
+ registry.delete(this.toString());
174
+ }
175
+ }
176
+
168
177
  /**
169
178
  * Check if callback registry is open
170
179
  *
@@ -189,26 +198,26 @@ export const listCallbacks = () => Object.freeze(Array.from(registry.keys()));
189
198
  /**
190
199
  * Check if a callback is registered
191
200
  *
192
- * @param {string} name The name/key to check for in callback registry
201
+ * @param {CallbackRegistryKey|string} name The name/key to check for in callback registry
193
202
  * @returns {boolean} Whether or not a callback is registered
194
203
  */
195
- export const hasCallback = name => registry.has(name);
204
+ export const hasCallback = name => registry.has(name?.toString());
196
205
 
197
206
  /**
198
207
  * Get a callback from the registry by name/key
199
208
  *
200
- * @param {string} name The name/key of the callback to get
209
+ * @param {CallbackRegistryKey|string} name The name/key of the callback to get
201
210
  * @returns {Function|undefined} The corresponding function registered under that name/key
202
211
  */
203
- export const getCallback = name => registry.get(name);
212
+ export const getCallback = name => registry.get(name?.toString());
204
213
 
205
214
  /**
206
215
  * Remove a callback from the registry
207
216
  *
208
- * @param {string} name The name/key of the callback to get
217
+ * @param {CallbackRegistryKey|string} name The name/key of the callback to get
209
218
  * @returns {boolean} Whether or not the callback was successfully unregisterd
210
219
  */
211
- export const unregisterCallback = name => _isRegistrationOpen && registry.delete(name);
220
+ export const unregisterCallback = name => _isRegistrationOpen && registry.delete(name?.toString());
212
221
 
213
222
  /**
214
223
  * Remove all callbacks from the registry
@@ -221,21 +230,23 @@ export const clearRegistry = () => registry.clear();
221
230
  * Create a registered callback with a randomly generated name
222
231
  *
223
232
  * @param {Function} callback Callback function to register
233
+ * @param {object} [config]
234
+ * @param {DisposableStack|AsyncDisposableStack} [config.stack] Optional `DisposableStack` to handle disposal and unregistering.
224
235
  * @returns {string} The automatically generated key/name of the registered callback
225
236
  */
226
- export const createCallback = (callback) => registerCallback('aegis:callback:' + crypto.randomUUID(), callback);
237
+ export const createCallback = (callback, { stack } = {}) => registerCallback('aegis:callback:' + crypto.randomUUID(), callback, { stack });
227
238
 
228
239
  /**
229
240
  * Call a callback fromt the registry by name/key
230
241
  *
231
- * @param {string} name The name/key of the registered function
242
+ * @param {CallbackRegistryKey|string} name The name/key of the registered function
232
243
  * @param {...any} args Any arguments to pass along to the function
233
244
  * @returns {any} Whatever the return value of the function is
234
245
  * @throws {Error} Throws if callback is not found or any error resulting from calling the function
235
246
  */
236
247
  export function callCallback(name, ...args) {
237
- if (registry.has(name)) {
238
- return registry.get(name).apply(this || globalThis, args);
248
+ if (registry.has(name?.toString())) {
249
+ return registry.get(name?.toString()).apply(this || globalThis, args);
239
250
  } else {
240
251
  throw new Error(`No ${name} function registered.`);
241
252
  }
@@ -244,22 +255,33 @@ export function callCallback(name, ...args) {
244
255
  /**
245
256
  * Register a named callback in registry
246
257
  *
247
- * @param {string} name The name/key to register the callback under
258
+ * @param {CallbackRegistryKey|string} name The name/key to register the callback under
248
259
  * @param {Function} callback The callback value to register
260
+ * @param {object} config
261
+ * @param {DisposableStack|AsyncDisposableStack} [config.stack] Optional `DisposableStack` to handle disposal and unregistering.
249
262
  * @returns {string} The registered name/key
250
263
  */
251
- export function registerCallback(name, callback) {
252
- if (typeof name !== 'string' || name.length === 0) {
253
- throw new TypeError('Callback name must be a string.');
264
+ export function registerCallback(name, callback, { stack } = {}) {
265
+ if (typeof name === 'string') {
266
+ return registerCallback(new CallbackRegistryKey(name), callback, { stack });
267
+ }else if (! (name instanceof CallbackRegistryKey)) {
268
+ throw new TypeError('Callback name must be a disposable string/CallbackRegistryKey.');
254
269
  } if (! (callback instanceof Function)) {
255
270
  throw new TypeError('Callback must be a function.');
256
271
  } else if (! _isRegistrationOpen) {
257
272
  throw new TypeError('Cannot register new callbacks because registry is closed.');
258
- } else if (registry.has(name)) {
273
+ } else if (registry.has(name?.toString())) {
259
274
  throw new Error(`Handler "${name}" is already registered.`);
275
+ } else if (stack instanceof DisposableStack || stack instanceof AsyncDisposableStack) {
276
+ const key = stack.use(new CallbackRegistryKey(name));
277
+ registry.set(key.toString(), callback);
278
+
279
+ return key;
260
280
  } else {
261
- registry.set(name, callback);
262
- return name;
281
+ const key = new CallbackRegistryKey(name);
282
+ registry.set(key.toString(), callback);
283
+
284
+ return key;
263
285
  }
264
286
  }
265
287
 
@@ -283,10 +305,10 @@ export function getHost(target) {
283
305
  }
284
306
  }
285
307
 
286
- export function on(event, callback, { capture = false, passive = false, once = false, signal } = {}) {
308
+ export function on(event, callback, { capture = false, passive = false, once = false, signal, stack } = {}) {
287
309
  if (callback instanceof Function) {
288
- return on(event, createCallback(callback), { capture, passive, once, signal });
289
- } else if (typeof callback !== 'string' || callback.length === 0) {
310
+ return on(event, createCallback(callback, { stack }), { capture, passive, once, signal });
311
+ } else if (! (callback instanceof String || typeof callback === 'string') || callback.length === 0) {
290
312
  throw new TypeError('Callback must be a function or a registered callback string.');
291
313
  } else if (typeof event !== 'string' || event.length === 0) {
292
314
  throw new TypeError('Event must be a non-empty string.');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aegisjsproject/callback-registry",
3
- "version": "1.0.3",
3
+ "version": "2.0.0",
4
4
  "description": " A callback registry for AegisJSProject",
5
5
  "keywords": [
6
6
  "aegis",
@@ -77,9 +77,9 @@
77
77
  "homepage": "https://github.com/AegisJSProject/callback-registry#readme",
78
78
  "devDependencies": {
79
79
  "@rollup/plugin-terser": "^0.4.4",
80
- "@shgysk8zer0/eslint-config": "^1.0.1",
81
- "@shgysk8zer0/polyfills": "^0.4.13",
82
- "eslint": "^9.15.0",
80
+ "@shgysk8zer0/eslint-config": "^1.0.5",
81
+ "@shgysk8zer0/polyfills": "^0.6.0",
82
+ "eslint": "^10.0.0",
83
83
  "http-server": "^14.1.1",
84
84
  "rollup": "^4.27.2"
85
85
  }