@aegisjsproject/callback-registry 1.0.2 → 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 +15 -0
- package/callbackRegistry.cjs +79 -20
- package/callbackRegistry.mjs +1 -1
- package/callbackRegistry.mjs.map +1 -1
- package/callbacks.cjs +78 -20
- package/callbacks.js +72 -20
- package/events.js +3 -0
- package/package.json +4 -3
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,21 @@ 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
|
+
|
|
18
|
+
## [v1.0.3] - 2025-09-29
|
|
19
|
+
|
|
20
|
+
### Added
|
|
21
|
+
- Add `onCommand` to handle `CommandEvent`s
|
|
22
|
+
- Add `FUNCS.ui.open` and `FUNCS.ui.close` for `<details>` elements
|
|
23
|
+
- Add `FUNCS.ui.reques*tFullscreen` for requesting, exiting, and toggling fullscreen
|
|
24
|
+
|
|
10
25
|
## [v1.0.2] - 2024-11-22
|
|
11
26
|
|
|
12
27
|
### Added
|
package/callbackRegistry.cjs
CHANGED
|
@@ -27,6 +27,7 @@ const onCanplaythrough = EVENT_PREFIX + 'canplaythrough';
|
|
|
27
27
|
const onChange = EVENT_PREFIX + 'change';
|
|
28
28
|
const onClick = EVENT_PREFIX + 'click';
|
|
29
29
|
const onClose = EVENT_PREFIX + 'close';
|
|
30
|
+
const onCommand = EVENT_PREFIX + 'command';
|
|
30
31
|
const onContextmenu = EVENT_PREFIX + 'contextmenu';
|
|
31
32
|
const onCopy = EVENT_PREFIX + 'copy';
|
|
32
33
|
const onCuechange = EVENT_PREFIX + 'cuechange';
|
|
@@ -124,6 +125,7 @@ const eventAttrs = [
|
|
|
124
125
|
onChange,
|
|
125
126
|
onClick,
|
|
126
127
|
onClose,
|
|
128
|
+
onCommand,
|
|
127
129
|
onContextmenu,
|
|
128
130
|
onCopy,
|
|
129
131
|
onCuechange,
|
|
@@ -293,6 +295,7 @@ const EVENTS = {
|
|
|
293
295
|
onChange,
|
|
294
296
|
onClick,
|
|
295
297
|
onClose,
|
|
298
|
+
onCommand,
|
|
296
299
|
onContextmenu,
|
|
297
300
|
onCopy,
|
|
298
301
|
onCuechange,
|
|
@@ -606,6 +609,9 @@ const $$ = (selector, base = document) => base.querySelectorAll(selector);
|
|
|
606
609
|
|
|
607
610
|
const $ = (selector, base = document) => base.querySelector(selector);
|
|
608
611
|
|
|
612
|
+
const requestFullscreen = { attr: 'data-request-fullscreen-selector', data: 'requestFullscreenSelector' };
|
|
613
|
+
const toggleFullsceen = { attr: 'data-toggle-fullscreen-selector', data: 'toggleFullscreenSelector' };
|
|
614
|
+
|
|
609
615
|
const FUNCS = {
|
|
610
616
|
debug: {
|
|
611
617
|
log: 'aegis:debug:log',
|
|
@@ -622,6 +628,7 @@ const FUNCS = {
|
|
|
622
628
|
popup: 'aegis:navigate:popup',
|
|
623
629
|
},
|
|
624
630
|
ui: {
|
|
631
|
+
command: 'aegis:ui:command',
|
|
625
632
|
print: 'aegis:ui:print',
|
|
626
633
|
remove: 'aegis:ui:remove',
|
|
627
634
|
hide: 'aegis:ui:hide',
|
|
@@ -637,10 +644,18 @@ const FUNCS = {
|
|
|
637
644
|
prevent: 'aegis:ui:prevent',
|
|
638
645
|
revokeObjectURL: 'aegis:ui:revokeObjectURL',
|
|
639
646
|
cancelAnimationFrame: 'aegis:ui:cancelAnimationFrame',
|
|
647
|
+
requestFullscreen: 'aegis:ui:requestFullscreen',
|
|
648
|
+
toggleFullscreen: 'aegis:ui:toggleFullsceen',
|
|
649
|
+
exitFullsceen: 'aegis:ui:exitFullscreen',
|
|
650
|
+
open: 'aegis:ui:open',
|
|
651
|
+
close: 'aegis:ui:close',
|
|
640
652
|
abortController: 'aegis:ui:controller:abort',
|
|
641
653
|
},
|
|
642
654
|
};
|
|
643
655
|
|
|
656
|
+
/**
|
|
657
|
+
* @type {Map<string, function>}
|
|
658
|
+
*/
|
|
644
659
|
const registry = new Map([
|
|
645
660
|
[FUNCS.debug.log, console.log],
|
|
646
661
|
[FUNCS.debug.warn, console.warn],
|
|
@@ -693,6 +708,8 @@ const registry = new Map([
|
|
|
693
708
|
[FUNCS.ui.clearInterval, ({ currentTarget }) => clearInterval(parseInt(currentTarget.dataset.clearInterval))],
|
|
694
709
|
[FUNCS.ui.clearTimeout, ({ currentTarget }) => clearTimeout(parseInt(currentTarget.dataset.timeout))],
|
|
695
710
|
[FUNCS.ui.abortController, ({ currentTarget }) => abortController(currentTarget.dataset.aegisEventController, currentTarget.dataset.aegisControllerReason)],
|
|
711
|
+
[FUNCS.ui.open, ({ currentTarget }) => document.querySelector(currentTarget.dataset.openSelector).open = true],
|
|
712
|
+
[FUNCS.ui.close, ({ currentTarget }) => document.querySelector(currentTarget.dataset.closeSelector).open = false],
|
|
696
713
|
[FUNCS.ui.showModal, ({ currentTarget }) => {
|
|
697
714
|
const target = $(currentTarget.dataset.showModalSelector);
|
|
698
715
|
|
|
@@ -730,8 +747,33 @@ const registry = new Map([
|
|
|
730
747
|
}],
|
|
731
748
|
[FUNCS.ui.print, () => globalThis.print()],
|
|
732
749
|
[FUNCS.ui.prevent, event => event.preventDefault()],
|
|
750
|
+
[FUNCS.ui.requestFullscreen, ({ currentTarget}) => {
|
|
751
|
+
if (currentTarget.dataset.hasOwnProperty(requestFullscreen.data)) {
|
|
752
|
+
document.getElementById(currentTarget.dataset[requestFullscreen.data]).requestFullscreen();
|
|
753
|
+
} else {
|
|
754
|
+
currentTarget.requestFullscreen();
|
|
755
|
+
}
|
|
756
|
+
}],
|
|
757
|
+
[FUNCS.ui.toggleFullscreen, ({ currentTarget }) => {
|
|
758
|
+
const target = currentTarget.dataset.hasOwnProperty(toggleFullsceen.data)
|
|
759
|
+
? document.getElementById(currentTarget.dataset[toggleFullsceen.data])
|
|
760
|
+
: currentTarget;
|
|
761
|
+
|
|
762
|
+
if (target.isSameNode(document.fullscreenElement)) {
|
|
763
|
+
document.exitFullscreen();
|
|
764
|
+
} else {
|
|
765
|
+
target.requestFullscreen();
|
|
766
|
+
}
|
|
767
|
+
}],
|
|
768
|
+
[FUNCS.ui.exitFullsceen, () => document.exitFullscreen()],
|
|
733
769
|
]);
|
|
734
770
|
|
|
771
|
+
class CallbackRegistryKey extends String {
|
|
772
|
+
[Symbol.dispose]() {
|
|
773
|
+
registry.delete(this.toString());
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
|
|
735
777
|
/**
|
|
736
778
|
* Check if callback registry is open
|
|
737
779
|
*
|
|
@@ -756,26 +798,26 @@ const listCallbacks = () => Object.freeze(Array.from(registry.keys()));
|
|
|
756
798
|
/**
|
|
757
799
|
* Check if a callback is registered
|
|
758
800
|
*
|
|
759
|
-
* @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
|
|
760
802
|
* @returns {boolean} Whether or not a callback is registered
|
|
761
803
|
*/
|
|
762
|
-
const hasCallback = name => registry.has(name);
|
|
804
|
+
const hasCallback = name => registry.has(name?.toString());
|
|
763
805
|
|
|
764
806
|
/**
|
|
765
807
|
* Get a callback from the registry by name/key
|
|
766
808
|
*
|
|
767
|
-
* @param {string} name The name/key of the callback to get
|
|
809
|
+
* @param {CallbackRegistryKey|string} name The name/key of the callback to get
|
|
768
810
|
* @returns {Function|undefined} The corresponding function registered under that name/key
|
|
769
811
|
*/
|
|
770
|
-
const getCallback = name => registry.get(name);
|
|
812
|
+
const getCallback = name => registry.get(name?.toString());
|
|
771
813
|
|
|
772
814
|
/**
|
|
773
815
|
* Remove a callback from the registry
|
|
774
816
|
*
|
|
775
|
-
* @param {string} name The name/key of the callback to get
|
|
817
|
+
* @param {CallbackRegistryKey|string} name The name/key of the callback to get
|
|
776
818
|
* @returns {boolean} Whether or not the callback was successfully unregisterd
|
|
777
819
|
*/
|
|
778
|
-
const unregisterCallback = name => _isRegistrationOpen && registry.delete(name);
|
|
820
|
+
const unregisterCallback = name => _isRegistrationOpen && registry.delete(name?.toString());
|
|
779
821
|
|
|
780
822
|
/**
|
|
781
823
|
* Remove all callbacks from the registry
|
|
@@ -788,21 +830,23 @@ const clearRegistry = () => registry.clear();
|
|
|
788
830
|
* Create a registered callback with a randomly generated name
|
|
789
831
|
*
|
|
790
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.
|
|
791
835
|
* @returns {string} The automatically generated key/name of the registered callback
|
|
792
836
|
*/
|
|
793
|
-
const createCallback = (callback) => registerCallback('aegis:callback:' + crypto.randomUUID(), callback);
|
|
837
|
+
const createCallback = (callback, { stack } = {}) => registerCallback('aegis:callback:' + crypto.randomUUID(), callback, { stack });
|
|
794
838
|
|
|
795
839
|
/**
|
|
796
840
|
* Call a callback fromt the registry by name/key
|
|
797
841
|
*
|
|
798
|
-
* @param {string} name The name/key of the registered function
|
|
842
|
+
* @param {CallbackRegistryKey|string} name The name/key of the registered function
|
|
799
843
|
* @param {...any} args Any arguments to pass along to the function
|
|
800
844
|
* @returns {any} Whatever the return value of the function is
|
|
801
845
|
* @throws {Error} Throws if callback is not found or any error resulting from calling the function
|
|
802
846
|
*/
|
|
803
847
|
function callCallback(name, ...args) {
|
|
804
|
-
if (registry.has(name)) {
|
|
805
|
-
return registry.get(name).apply(this || globalThis, args);
|
|
848
|
+
if (registry.has(name?.toString())) {
|
|
849
|
+
return registry.get(name?.toString()).apply(this || globalThis, args);
|
|
806
850
|
} else {
|
|
807
851
|
throw new Error(`No ${name} function registered.`);
|
|
808
852
|
}
|
|
@@ -811,22 +855,33 @@ function callCallback(name, ...args) {
|
|
|
811
855
|
/**
|
|
812
856
|
* Register a named callback in registry
|
|
813
857
|
*
|
|
814
|
-
* @param {string} name The name/key to register the callback under
|
|
858
|
+
* @param {CallbackRegistryKey|string} name The name/key to register the callback under
|
|
815
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.
|
|
816
862
|
* @returns {string} The registered name/key
|
|
817
863
|
*/
|
|
818
|
-
function registerCallback(name, callback) {
|
|
819
|
-
if (typeof name
|
|
820
|
-
|
|
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.');
|
|
821
869
|
} if (! (callback instanceof Function)) {
|
|
822
870
|
throw new TypeError('Callback must be a function.');
|
|
823
871
|
} else if (! _isRegistrationOpen) {
|
|
824
872
|
throw new TypeError('Cannot register new callbacks because registry is closed.');
|
|
825
|
-
} else if (registry.has(name)) {
|
|
873
|
+
} else if (registry.has(name?.toString())) {
|
|
826
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;
|
|
827
880
|
} else {
|
|
828
|
-
|
|
829
|
-
|
|
881
|
+
const key = new CallbackRegistryKey(name);
|
|
882
|
+
registry.set(key.toString(), callback);
|
|
883
|
+
|
|
884
|
+
return key;
|
|
830
885
|
}
|
|
831
886
|
}
|
|
832
887
|
|
|
@@ -850,10 +905,10 @@ function getHost(target) {
|
|
|
850
905
|
}
|
|
851
906
|
}
|
|
852
907
|
|
|
853
|
-
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 } = {}) {
|
|
854
909
|
if (callback instanceof Function) {
|
|
855
|
-
return on(event, createCallback(callback), { capture: capture$1, passive: passive$1, once: once$1, signal: signal$1 });
|
|
856
|
-
} else if (typeof callback
|
|
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) {
|
|
857
912
|
throw new TypeError('Callback must be a function or a registered callback string.');
|
|
858
913
|
} else if (typeof event !== 'string' || event.length === 0) {
|
|
859
914
|
throw new TypeError('Event must be a non-empty string.');
|
|
@@ -886,6 +941,7 @@ function on(event, callback, { capture: capture$1 = false, passive: passive$1 =
|
|
|
886
941
|
}
|
|
887
942
|
}
|
|
888
943
|
|
|
944
|
+
exports.CallbackRegistryKey = CallbackRegistryKey;
|
|
889
945
|
exports.EVENTS = EVENTS;
|
|
890
946
|
exports.FUNCS = FUNCS;
|
|
891
947
|
exports.abortController = abortController;
|
|
@@ -925,6 +981,7 @@ exports.onCanplaythrough = onCanplaythrough;
|
|
|
925
981
|
exports.onChange = onChange;
|
|
926
982
|
exports.onClick = onClick;
|
|
927
983
|
exports.onClose = onClose;
|
|
984
|
+
exports.onCommand = onCommand;
|
|
928
985
|
exports.onContextmenu = onContextmenu;
|
|
929
986
|
exports.onCopy = onCopy;
|
|
930
987
|
exports.onCuechange = onCuechange;
|
|
@@ -1011,8 +1068,10 @@ exports.registerCallback = registerCallback;
|
|
|
1011
1068
|
exports.registerController = registerController;
|
|
1012
1069
|
exports.registerEventAttribute = registerEventAttribute;
|
|
1013
1070
|
exports.registerSignal = registerSignal;
|
|
1071
|
+
exports.requestFullscreen = requestFullscreen;
|
|
1014
1072
|
exports.setGlobalErrorHandler = setGlobalErrorHandler;
|
|
1015
1073
|
exports.signal = signal;
|
|
1074
|
+
exports.toggleFullsceen = toggleFullsceen;
|
|
1016
1075
|
exports.unregisterCallback = unregisterCallback;
|
|
1017
1076
|
exports.unregisterController = unregisterController;
|
|
1018
1077
|
exports.unregisterSignal = unregisterSignal;
|
package/callbackRegistry.mjs
CHANGED
|
@@ -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",h=t+"cancel",f=t+"auxclick",m=t+"beforeinput",v=t+"beforetoggle",w=t+"canplay",y=t+"canplaythrough",T=t+"change",E=t+"click",S=t+"close",k=t+"contextmenu",A=t+"copy",P=t+"cuechange",C=t+"cut",M=t+"dblclick",L=t+"drag",D=t+"dragend",O=t+"dragenter",F=t+"dragexit",I=t+"dragleave",U=t+"dragover",N=t+"dragstart",R=t+"drop",j=t+"durationchange",$=t+"emptied",x=t+"ended",z=t+"formdata",W=t+"input",q=t+"invalid",H=t+"keydown",V=t+"keypress",B=t+"keyup",K=t+"load",G=t+"loadeddata",_=t+"loadedmetadata",J=t+"loadstart",Q=t+"mousedown",X=t+"mouseenter",Y=t+"mouseleave",Z=t+"mousemove",ee=t+"mouseout",te=t+"mouseover",ne=t+"mouseup",oe=t+"wheel",re=t+"paste",ae=t+"pause",ie=t+"play",se=t+"playing",le=t+"progress",ce=t+"ratechange",ue=t+"reset",ge=t+"resize",de=t+"scroll",pe=t+"scrollend",be=t+"securitypolicyviolation",he=t+"seeked",fe=t+"seeking",me=t+"select",ve=t+"slotchange",we=t+"stalled",ye=t+"submit",Te=t+"suspend",Ee=t+"timeupdate",Se=t+"volumechange",ke=t+"waiting",Ae=t+"selectstart",Pe=t+"selectionchange",Ce=t+"toggle",Me=t+"pointercancel",Le=t+"pointerdown",De=t+"pointerup",Oe=t+"pointermove",Fe=t+"pointerout",Ie=t+"pointerover",Ue=t+"pointerenter",Ne=t+"pointerleave",Re=t+"gotpointercapture",je=t+"lostpointercapture",$e=t+"mozfullscreenchange",xe=t+"mozfullscreenerror",ze=t+"animationcancel",We=t+"animationend",qe=t+"animationiteration",He=t+"animationstart",Ve=t+"transitioncancel",Be=t+"transitionend",Ke=t+"transitionrun",Ge=t+"transitionstart",_e=t+"webkitanimationend",Je=t+"webkitanimationiteration",Qe=t+"webkitanimationstart",Xe=t+"webkittransitionend",Ye=t+"error",Ze=[d,p,b,h,f,m,v,w,y,T,E,S,k,A,P,C,M,L,D,O,F,I,U,N,R,j,$,x,z,W,q,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,he,fe,me,ve,we,ye,Te,Ee,Se,ke,Ae,Pe,Ce,Me,Le,De,Oe,Fe,Ie,Ue,Ne,Re,je,$e,xe,ze,We,qe,He,Ve,Be,Ke,Ge,_e,Je,Qe,Xe,Ye];let et=Ze.map((e=>`[${CSS.escape(e)}]`)).join(", ");const tt=e=>t+e,nt=e=>Ze.includes(t+e),ot=([e])=>e.startsWith(n);function rt(e,{signal:t,attrFilter:n=it}={}){const o=e.dataset;for(const[r,a]of Object.entries(o).filter(ot))try{const i="on"+r.substring(12);n.hasOwnProperty(i)&&Mt(a)&&e.addEventListener(i.substring(2).toLowerCase(),Lt(a),{passive:o.hasOwnProperty("aegisEventPassive"),capture:o.hasOwnProperty("aegisEventCapture"),once:o.hasOwnProperty("aegisEventOnce"),signal:o.hasOwnProperty("aegisEventSignal")?bt(o.aegisEventSignal):t})}catch(e){reportError(e)}}const at=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&&Mt(e.oldValue)&&e.target.removeEventListener(e.attributeName.substring(20),Lt(e.oldValue),{once:e.target.hasAttribute(s),capture:e.target.hasAttribute(c),passive:e.target.hasAttribute(l)}),e.target.hasAttribute(e.attributeName)&&Mt(e.target.getAttribute(e.attributeName))&&e.target.addEventListener(e.attributeName.substring(20),Lt(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)?bt(e.target.getAttribute(u)):void 0})}}))})),it={onAbort:d,onBlur:p,onFocus:b,onCancel:h,onAuxclick:f,onBeforeinput:m,onBeforetoggle:v,onCanplay:w,onCanplaythrough:y,onChange:T,onClick:E,onClose:S,onContextmenu:k,onCopy:A,onCuechange:P,onCut:C,onDblclick:M,onDrag:L,onDragend:D,onDragenter:O,onDragexit:F,onDragleave:I,onDragover:U,onDragstart:N,onDrop:R,onDurationchange:j,onEmptied:$,onEnded:x,onFormdata:z,onInput:W,onInvalid:q,onKeydown:H,onKeypress:V,onKeyup:B,onLoad:K,onLoadeddata:G,onLoadedmetadata:_,onLoadstart:J,onMousedown:Q,onMouseenter:X,onMouseleave:Y,onMousemove:Z,onMouseout:ee,onMouseover:te,onMouseup:ne,onWheel:oe,onPaste:re,onPause:ae,onPlay:ie,onPlaying:se,onProgress:le,onRatechange:ce,onReset:ue,onResize:ge,onScroll:de,onScrollend:pe,onSecuritypolicyviolation:be,onSeeked:he,onSeeking:fe,onSelect:me,onSlotchange:ve,onStalled:we,onSubmit:ye,onSuspend:Te,onTimeupdate:Ee,onVolumechange:Se,onWaiting:ke,onSelectstart:Ae,onSelectionchange:Pe,onToggle:Ce,onPointercancel:Me,onPointerdown:Le,onPointerup:De,onPointermove:Oe,onPointerout:Fe,onPointerover:Ie,onPointerenter:Ue,onPointerleave:Ne,onGotpointercapture:Re,onLostpointercapture:je,onMozfullscreenchange:$e,onMozfullscreenerror:xe,onAnimationcancel:ze,onAnimationend:We,onAnimationiteration:qe,onAnimationstart:He,onTransitioncancel:Ve,onTransitionend:Be,onTransitionrun:Ke,onTransitionstart:Ge,onWebkitanimationend:_e,onWebkitanimationiteration:Je,onWebkitanimationstart:Qe,onWebkittransitionend:Xe,onError:Ye,once:s,passive:l,capture:c};function st(e,{addListeners:n=!1,base:o=document.body,signal:r}={}){const a=t+e.toLowerCase();if(!Ze.includes(a)){const e=`[${CSS.escape(a)}]`,t=(e=>`on${e[20].toUpperCase()}${e.substring(21)}`)(a);Ze.push(a),it[t]=a,et+=`, ${e}`,n&&requestAnimationFrame((()=>{const n={attrFilter:{[t]:e},signal:r};[o,...o.querySelectorAll(e)].forEach((e=>rt(e,n)))}))}return a}function lt(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",ct,{once:!0}),t}}throw new TypeError("Controller is not an `AbortSignal.")}function ct(e){return e instanceof AbortController?i.delete(e.signal[r]):e instanceof AbortSignal?i.delete(e[r]):i.delete(e)}function ut({signal:e}={}){const t=new AbortController;return e instanceof AbortSignal&&e.addEventListener("abort",(({target:e})=>t.abort(e.reason)),{signal:t.signal}),lt(t)}const gt=e=>i.get(e);function dt(e,t){const n=gt(e);return n instanceof AbortController&&("string"==typeof t?(n.abort(new Error(t)),!0):(n.abort(t),!0))}function pt(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 bt=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(et)?[e,...e.querySelectorAll(et)]:e.querySelectorAll(et)).forEach((e=>rt(e,{signal:t}))),e}function mt(e=document){ft(e),at.observe(e,{subtree:!0,childList:!0,attributes:!0,attributeOldValue:!0,attributeFilter:Ze})}const vt=()=>at.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 yt=!0;const Tt=(e,t=document)=>t.querySelectorAll(e),Et=(e,t=document)=>t.querySelector(e),St={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:{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",abortController:"aegis:ui:controller:abort"}},kt=new Map([[St.debug.log,console.log],[St.debug.warn,console.warn],[St.debug.error,console.error],[St.debug.info,console.info],[St.navigate.back,()=>history.back()],[St.navigate.forward,()=>history.forward()],[St.navigate.reload,()=>history.go(0)],[St.navigate.close,()=>globalThis.close()],[St.navigate.link,e=>{e.isTrusted&&(e.preventDefault(),location.href=e.currentTarget.dataset.url)}],[St.navigate.popup,e=>{e.isTrusted&&(e.preventDefault(),globalThis.open(e.currentTarget.dataset.url))}],[St.ui.hide,({currentTarget:e})=>{Tt(e.dataset.hideSelector).forEach((e=>e.hidden=!0))}],[St.ui.unhide,({currentTarget:e})=>{Tt(e.dataset.unhideSelector).forEach((e=>e.hidden=!1))}],[St.ui.disable,({currentTarget:e})=>{Tt(e.dataset.disableSelector).forEach((e=>e.disabled=!0))}],[St.ui.enable,({currentTarget:e})=>{Tt(e.dataset.enableSelector).forEach((e=>e.disabled=!1))}],[St.ui.remove,({currentTarget:e})=>{Tt(e.dataset.removeSelector).forEach((e=>e.remove()))}],[St.ui.scrollTo,({currentTarget:e})=>{const t=Et(e.dataset.scrollToSelector);t instanceof Element&&t.scrollIntoView({behavior:matchMedia("(prefers-reduced-motion: reduce)").matches?"instant":"smooth"})}],[St.ui.revokeObjectURL,({currentTarget:e})=>URL.revokeObjectURL(e.src)],[St.ui.cancelAnimationFrame,({currentTarget:e})=>cancelAnimationFrame(parseInt(e.dataset.animationFrame))],[St.ui.clearInterval,({currentTarget:e})=>clearInterval(parseInt(e.dataset.clearInterval))],[St.ui.clearTimeout,({currentTarget:e})=>clearTimeout(parseInt(e.dataset.timeout))],[St.ui.abortController,({currentTarget:e})=>dt(e.dataset.aegisEventController,e.dataset.aegisControllerReason)],[St.ui.showModal,({currentTarget:e})=>{const t=Et(e.dataset.showModalSelector);t instanceof HTMLDialogElement&&t.showModal()}],[St.ui.closeModal,({currentTarget:e})=>{const t=Et(e.dataset.closeModalSelector);t instanceof HTMLDialogElement&&t.close()}],[St.ui.showPopover,({currentTarget:e})=>{const t=Et(e.dataset.showPopoverSelector);t instanceof HTMLElement&&t.showPopover()}],[St.ui.hidePopover,({currentTarget:e})=>{const t=Et(e.dataset.hidePopoverSelector);t instanceof HTMLElement&&t.hidePopover()}],[St.ui.togglePopover,({currentTarget:e})=>{const t=Et(e.dataset.togglePopoverSelector);t instanceof HTMLElement&&t.togglePopover()}],[St.ui.print,()=>globalThis.print()],[St.ui.prevent,e=>e.preventDefault()]]),At=()=>yt,Pt=()=>yt=!1,Ct=()=>Object.freeze(Array.from(kt.keys())),Mt=e=>kt.has(e),Lt=e=>kt.get(e),Dt=e=>yt&&kt.delete(e),Ot=()=>kt.clear(),Ft=e=>Ut("aegis:callback:"+crypto.randomUUID(),e);function It(e,...t){if(kt.has(e))return kt.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(yt){if(kt.has(e))throw new Error(`Handler "${e}" is already registered.`);return kt.set(e,t),e}throw new TypeError("Cannot register new callbacks because registry is closed.")}throw new TypeError("Callback must be a function.")}function Nt(e){return e instanceof Event?Nt(e.currentTarget):e instanceof Document?e:e instanceof Element?Nt(e.getRootNode()):e instanceof ShadowRoot?e.host:null}function Rt(e,t,{capture:n=!1,passive:o=!1,once:r=!1,signal:a}={}){if(t instanceof Function)return Rt(e,Ft(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.");{nt(e)||st(e);const i=[[tt(e),t]];return n&&i.push([c,""]),o&&i.push([l,""]),r&&i.push([s,""]),a instanceof AbortSignal?i.push([u,pt(a)]):"string"==typeof a&&i.push([u,a]),i.map((([e,t])=>`${e}="${t}"`)).join(" ")}}export{it as EVENTS,St as FUNCS,dt as abortController,ft as attachListeners,It as callCallback,c as capture,Ot as clearRegistry,Pt as closeRegistration,g as controller,Ft as createCallback,ut as createController,vt as disconnectEventsObserver,Ze as eventAttrs,tt as eventToProp,Lt as getCallback,gt as getController,Nt as getHost,bt as getSignal,Mt as hasCallback,nt as hasEventAttribute,At as isRegistrationOpen,Ct as listCallbacks,mt as observeEvents,Rt as on,d as onAbort,ze as onAnimationcancel,We as onAnimationend,qe as onAnimationiteration,He as onAnimationstart,f as onAuxclick,m as onBeforeinput,v as onBeforetoggle,p as onBlur,h as onCancel,w as onCanplay,y as onCanplaythrough,T as onChange,E as onClick,S as onClose,k as onContextmenu,A as onCopy,P as onCuechange,C as onCut,M as onDblclick,L as onDrag,D as onDragend,O as onDragenter,F as onDragexit,I as onDragleave,U as onDragover,N as onDragstart,R as onDrop,j as onDurationchange,$ as onEmptied,x as onEnded,Ye as onError,b as onFocus,z as onFormdata,Re as onGotpointercapture,W as onInput,q as onInvalid,H as onKeydown,V as onKeypress,B as onKeyup,K as onLoad,G as onLoadeddata,_ as onLoadedmetadata,J as onLoadstart,je as onLostpointercapture,Q as onMousedown,X as onMouseenter,Y as onMouseleave,Z as onMousemove,ee as onMouseout,te as onMouseover,ne as onMouseup,$e as onMozfullscreenchange,xe as onMozfullscreenerror,re as onPaste,ae as onPause,ie as onPlay,se as onPlaying,Me as onPointercancel,Le as onPointerdown,Ue as onPointerenter,Ne as onPointerleave,Oe as onPointermove,Fe as onPointerout,Ie as onPointerover,De as onPointerup,le as onProgress,ce as onRatechange,ue as onReset,ge as onResize,de as onScroll,pe as onScrollend,be as onSecuritypolicyviolation,he as onSeeked,fe as onSeeking,me as onSelect,Pe as onSelectionchange,Ae as onSelectstart,ve as onSlotchange,we as onStalled,ye as onSubmit,Te as onSuspend,Ee as onTimeupdate,Ce as onToggle,Ve as onTransitioncancel,Be as onTransitionend,Ke as onTransitionrun,Ge as onTransitionstart,Se as onVolumechange,ke as onWaiting,_e as onWebkitanimationend,Je as onWebkitanimationiteration,Qe as onWebkitanimationstart,Xe as onWebkittransitionend,oe as onWheel,s as once,l as passive,Ut as registerCallback,lt as registerController,st as registerEventAttribute,pt as registerSignal,wt as setGlobalErrorHandler,u as signal,Dt as unregisterCallback,ct 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
|
package/callbackRegistry.mjs.map
CHANGED
|
@@ -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 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\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\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 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\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\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.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]);\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","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","FUNCS","debug","log","info","warn","error","navigate","back","forward","reload","close","link","popup","ui","print","remove","hide","unhide","showModal","closeModal","showPopover","hidePopover","togglePopover","enable","disable","scrollTo","prevent","revokeObjectURL","cancelAnimationFrame","registry","console","history","go","isTrusted","preventDefault","location","href","currentTarget","url","open","hideSelector","hidden","unhideSelector","disableSelector","disabled","enableSelector","removeSelector","scrollToSelector","scrollIntoView","behavior","matchMedia","URL","src","parseInt","animationFrame","clearInterval","clearTimeout","timeout","aegisEventController","aegisControllerReason","showModalSelector","HTMLDialogElement","closeModalSelector","showPopoverSelector","HTMLElement","hidePopoverSelector","togglePopoverSelector","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,IAAID,IAElBE,EAAOT,EAAS,OAChBU,EAAUV,EAAS,UACnBW,EAAUX,EAAS,UACnBY,EAASZ,EAAS,SAClBa,EAAab,EAAS,aACtBc,EAAUb,EAAe,QACzBc,EAASd,EAAe,OACxBe,EAAUf,EAAe,QACzBgB,EAAWhB,EAAe,SAC1BiB,EAAajB,EAAe,WAC5BkB,EAAgBlB,EAAe,cAC/BmB,EAAiBnB,EAAe,eAChCoB,EAAYpB,EAAe,UAC3BqB,EAAmBrB,EAAe,iBAClCsB,EAAWtB,EAAe,SAC1BuB,EAAUvB,EAAe,QACzBwB,EAAUxB,EAAe,QACzByB,EAAgBzB,EAAe,cAC/B0B,EAAS1B,EAAe,OACxB2B,EAAc3B,EAAe,YAC7B4B,EAAQ5B,EAAe,MACvB6B,EAAa7B,EAAe,WAC5B8B,EAAS9B,EAAe,OACxB+B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kBnF,EAAe,gBACjCoF,GAAgBpF,EAAe,cAC/BqF,GAAcrF,EAAe,YAC7BsF,GAAgBtF,EAAe,cAC/BuF,GAAevF,EAAe,aAC9BwF,GAAgBxF,EAAe,cAC/ByF,GAAiBzF,EAAe,eAChC0F,GAAiB1F,EAAe,eAChC2F,GAAsB3F,EAAe,oBACrC4F,GAAuB5F,EAAe,qBACtC6F,GAAwB7F,EAAe,sBACvC8F,GAAuB9F,EAAe,qBACtC+F,GAAoB/F,EAAe,kBACnCgG,GAAiBhG,EAAe,eAChCiG,GAAuBjG,EAAe,qBACtCkG,GAAmBlG,EAAe,iBAClCmG,GAAqBnG,EAAe,mBACpCoG,GAAkBpG,EAAe,gBACjCqG,GAAkBrG,EAAe,gBACjCsG,GAAoBtG,EAAe,kBACnCuG,GAAuBvG,EAAe,qBACtCwG,GAA6BxG,EAAe,2BAC5CyG,GAAyBzG,EAAe,uBACxC0G,GAAwB1G,EAAe,sBACvC2G,GAAU3G,EAAe,QAEzB4G,GAAa,CACzB/F,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,IAGD,IAAIE,GAAWD,GAAWE,KAA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,iBAEjDX,EAAOS,OAAOpB,iBACbW,EAAOW,cAAczB,UAxQCnI,IAyQtBwI,GAAYS,EAAOS,OAAOI,aAAab,EAAOW,gBAAiB,CAC9DpJ,KAAMyI,EAAOS,OAAOG,aAAarJ,GACjCE,QAASuI,EAAOS,OAAOG,aAAanJ,GACpCD,QAASwI,EAAOS,OAAOG,aAAapJ,GACpCE,OAAQsI,EAAOS,OAAOG,aAAalJ,GAAU8H,GAAUQ,EAAOS,OAAOI,aAAanJ,SAAWoJ,IAKpG,GACG,IAGUlC,GAAS,CACrBhH,UACAC,SACAC,UACAC,WACAC,aACAC,gBACAC,iBACAC,YACAC,mBACAC,WACAC,UACAC,UACAC,gBACAC,SACAC,cACAC,QACAC,aACAC,SACAC,YACAC,cACAC,aACAC,cACAC,aACAC,cACAC,SACAC,mBACAC,YACAC,UACAC,aACAC,UACAC,YACAC,YACAC,aACAC,UACAC,SACAC,eACAC,mBACAC,cACAC,cACAC,eACAC,eACAC,cACAC,cACAC,eACAC,aACAC,WACAC,WACAC,WACAC,UACAC,aACAC,cACAC,gBACAC,WACAC,YACAC,YACAC,eACAC,6BACAC,YACAC,aACAC,YACAC,gBACAC,aACAC,YACAC,aACAC,gBACAC,kBACAC,aACAC,iBACAC,qBACAC,YACAC,mBACAC,iBACAC,eACAC,iBACAC,gBACAC,iBACAC,kBACAC,kBACAC,uBACAC,wBACAC,yBACAC,wBACAC,qBACAC,kBACAC,wBACAC,oBACAC,sBACAC,mBACAC,mBACAC,qBACAC,wBACAC,8BACAC,0BACAC,yBACAC,WACAnG,OACAC,UACAC,WAaM,SAASsJ,GAAuBjD,GAAMkD,aAC5CA,GAAe,EAAKC,KACpBA,EAAOC,SAASC,KAAIzJ,OACpBA,GACG,IACH,MAAM0J,EAAWrK,EAAe+G,EAAKwB,cAErC,IAAM3B,GAAWU,SAAS+C,GAAW,CACpC,MAAMC,EAAM,IAAItD,IAAIC,OAAOoD,MACrBE,EA7LWxD,IAAQ,KAAKA,EAjNJ/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AM5I,KAAK,CAAC6I,EAAa,KAGtB/S,GACH8S,EAAM5I,KAAK,CAAC8I,EAAa,KAGtBjT,GACH+S,EAAM5I,KAAK,CAAC+I,EAAU,KAGnB/S,aAAkBmL,YACrByH,EAAM5I,KAAK,CAACgJ,EAAYtH,GAAe1L,KACX,iBAAXA,GACjB4S,EAAM5I,KAAK,CAACgJ,EAAYhT,IAGlB4S,EAAMzM,KAAI,EAAEyD,EAAMxC,KAAS,GAAGwC,MAASxC,OAAQb,KAAK,IAC7D,CACA"}
|
|
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","ShadowRoot","host","on","length","parts","captureAttr","passiveAttr","onceAttr","signalAttr"],"mappings":"AAEA,MAAMA,EAAS,oBACTC,EAAeD,EAAS,MAExBE,EAAc,eAEdC,EAAeC,OAAO,gBACtBC,EAAmBD,OAAO,oBAC1BE,EAAiB,IAAIC,IACr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3K,EACGA,aAAkB6C,QACrB4H,GAAQzK,EAAO4K,eACZ5K,aAAkB6K,WACrB7K,EAAO8K,KAEP,IAET,CAEO,SAASC,GAAGrN,EAAOgG,GAAU3M,QAAEA,GAAU,EAAKD,QAAEA,GAAU,EAAKD,KAAEA,GAAO,EAAKG,OAAEA,EAAMiT,MAAEA,GAAU,CAAA,GACvG,GAAIvG,aAAoBC,SACvB,OAAOoH,GAAGrN,EAAOsM,GAAetG,EAAU,CAAEuG,UAAU,CAAAlT,QAAEA,EAAOD,QAAEA,OAASD,EAAIG,OAAEA,IAC1E,IAAO0M,aAAoBuF,QAA8B,iBAAbvF,IAA8C,IAApBA,EAASsH,OAE/E,IAAqB,iBAAVtN,GAAuC,IAAjBA,EAAMsN,OAC7C,MAAM,IAAI9I,UAAU,qCACd,CACAvE,GAAkBD,IACvB4C,GAAuB5C,GAGxB,MAAMuN,EAAQ,CAAC,CAACxN,GAAYC,GAAQgG,IAoBpC,OAlBI3M,GACHkU,EAAMhK,KAAK,CAACiK,EAAa,KAGtBpU,GACHmU,EAAMhK,KAAK,CAACkK,EAAa,KAGtBtU,GACHoU,EAAMhK,KAAK,CAACmK,EAAU,KAGnBpU,aAAkBoL,YACrB6I,EAAMhK,KAAK,CAACoK,EAAY1I,GAAe3L,KACX,iBAAXA,GACjBiU,EAAMhK,KAAK,CAACoK,EAAYrU,IAGlBiU,EAAM7N,IAAI,EAAEyD,EAAMxC,KAAS,GAAGwC,MAASxC,MAAQb,KAAK,IAC5D,EA7BC,MAAM,IAAI0E,UAAU,+DA8BtB"}
|
package/callbacks.cjs
CHANGED
|
@@ -25,6 +25,7 @@ const onCanplaythrough = EVENT_PREFIX + 'canplaythrough';
|
|
|
25
25
|
const onChange = EVENT_PREFIX + 'change';
|
|
26
26
|
const onClick = EVENT_PREFIX + 'click';
|
|
27
27
|
const onClose = EVENT_PREFIX + 'close';
|
|
28
|
+
const onCommand = EVENT_PREFIX + 'command';
|
|
28
29
|
const onContextmenu = EVENT_PREFIX + 'contextmenu';
|
|
29
30
|
const onCopy = EVENT_PREFIX + 'copy';
|
|
30
31
|
const onCuechange = EVENT_PREFIX + 'cuechange';
|
|
@@ -122,6 +123,7 @@ const eventAttrs = [
|
|
|
122
123
|
onChange,
|
|
123
124
|
onClick,
|
|
124
125
|
onClose,
|
|
126
|
+
onCommand,
|
|
125
127
|
onContextmenu,
|
|
126
128
|
onCopy,
|
|
127
129
|
onCuechange,
|
|
@@ -291,6 +293,7 @@ const EVENTS = {
|
|
|
291
293
|
onChange,
|
|
292
294
|
onClick,
|
|
293
295
|
onClose,
|
|
296
|
+
onCommand,
|
|
294
297
|
onContextmenu,
|
|
295
298
|
onCopy,
|
|
296
299
|
onCuechange,
|
|
@@ -507,6 +510,9 @@ const $$ = (selector, base = document) => base.querySelectorAll(selector);
|
|
|
507
510
|
|
|
508
511
|
const $ = (selector, base = document) => base.querySelector(selector);
|
|
509
512
|
|
|
513
|
+
const requestFullscreen = { attr: 'data-request-fullscreen-selector', data: 'requestFullscreenSelector' };
|
|
514
|
+
const toggleFullsceen = { attr: 'data-toggle-fullscreen-selector', data: 'toggleFullscreenSelector' };
|
|
515
|
+
|
|
510
516
|
const FUNCS = {
|
|
511
517
|
debug: {
|
|
512
518
|
log: 'aegis:debug:log',
|
|
@@ -523,6 +529,7 @@ const FUNCS = {
|
|
|
523
529
|
popup: 'aegis:navigate:popup',
|
|
524
530
|
},
|
|
525
531
|
ui: {
|
|
532
|
+
command: 'aegis:ui:command',
|
|
526
533
|
print: 'aegis:ui:print',
|
|
527
534
|
remove: 'aegis:ui:remove',
|
|
528
535
|
hide: 'aegis:ui:hide',
|
|
@@ -538,10 +545,18 @@ const FUNCS = {
|
|
|
538
545
|
prevent: 'aegis:ui:prevent',
|
|
539
546
|
revokeObjectURL: 'aegis:ui:revokeObjectURL',
|
|
540
547
|
cancelAnimationFrame: 'aegis:ui:cancelAnimationFrame',
|
|
548
|
+
requestFullscreen: 'aegis:ui:requestFullscreen',
|
|
549
|
+
toggleFullscreen: 'aegis:ui:toggleFullsceen',
|
|
550
|
+
exitFullsceen: 'aegis:ui:exitFullscreen',
|
|
551
|
+
open: 'aegis:ui:open',
|
|
552
|
+
close: 'aegis:ui:close',
|
|
541
553
|
abortController: 'aegis:ui:controller:abort',
|
|
542
554
|
},
|
|
543
555
|
};
|
|
544
556
|
|
|
557
|
+
/**
|
|
558
|
+
* @type {Map<string, function>}
|
|
559
|
+
*/
|
|
545
560
|
const registry = new Map([
|
|
546
561
|
[FUNCS.debug.log, console.log],
|
|
547
562
|
[FUNCS.debug.warn, console.warn],
|
|
@@ -594,6 +609,8 @@ const registry = new Map([
|
|
|
594
609
|
[FUNCS.ui.clearInterval, ({ currentTarget }) => clearInterval(parseInt(currentTarget.dataset.clearInterval))],
|
|
595
610
|
[FUNCS.ui.clearTimeout, ({ currentTarget }) => clearTimeout(parseInt(currentTarget.dataset.timeout))],
|
|
596
611
|
[FUNCS.ui.abortController, ({ currentTarget }) => abortController(currentTarget.dataset.aegisEventController, currentTarget.dataset.aegisControllerReason)],
|
|
612
|
+
[FUNCS.ui.open, ({ currentTarget }) => document.querySelector(currentTarget.dataset.openSelector).open = true],
|
|
613
|
+
[FUNCS.ui.close, ({ currentTarget }) => document.querySelector(currentTarget.dataset.closeSelector).open = false],
|
|
597
614
|
[FUNCS.ui.showModal, ({ currentTarget }) => {
|
|
598
615
|
const target = $(currentTarget.dataset.showModalSelector);
|
|
599
616
|
|
|
@@ -631,8 +648,33 @@ const registry = new Map([
|
|
|
631
648
|
}],
|
|
632
649
|
[FUNCS.ui.print, () => globalThis.print()],
|
|
633
650
|
[FUNCS.ui.prevent, event => event.preventDefault()],
|
|
651
|
+
[FUNCS.ui.requestFullscreen, ({ currentTarget}) => {
|
|
652
|
+
if (currentTarget.dataset.hasOwnProperty(requestFullscreen.data)) {
|
|
653
|
+
document.getElementById(currentTarget.dataset[requestFullscreen.data]).requestFullscreen();
|
|
654
|
+
} else {
|
|
655
|
+
currentTarget.requestFullscreen();
|
|
656
|
+
}
|
|
657
|
+
}],
|
|
658
|
+
[FUNCS.ui.toggleFullscreen, ({ currentTarget }) => {
|
|
659
|
+
const target = currentTarget.dataset.hasOwnProperty(toggleFullsceen.data)
|
|
660
|
+
? document.getElementById(currentTarget.dataset[toggleFullsceen.data])
|
|
661
|
+
: currentTarget;
|
|
662
|
+
|
|
663
|
+
if (target.isSameNode(document.fullscreenElement)) {
|
|
664
|
+
document.exitFullscreen();
|
|
665
|
+
} else {
|
|
666
|
+
target.requestFullscreen();
|
|
667
|
+
}
|
|
668
|
+
}],
|
|
669
|
+
[FUNCS.ui.exitFullsceen, () => document.exitFullscreen()],
|
|
634
670
|
]);
|
|
635
671
|
|
|
672
|
+
class CallbackRegistryKey extends String {
|
|
673
|
+
[Symbol.dispose]() {
|
|
674
|
+
registry.delete(this.toString());
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
|
|
636
678
|
/**
|
|
637
679
|
* Check if callback registry is open
|
|
638
680
|
*
|
|
@@ -657,26 +699,26 @@ const listCallbacks = () => Object.freeze(Array.from(registry.keys()));
|
|
|
657
699
|
/**
|
|
658
700
|
* Check if a callback is registered
|
|
659
701
|
*
|
|
660
|
-
* @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
|
|
661
703
|
* @returns {boolean} Whether or not a callback is registered
|
|
662
704
|
*/
|
|
663
|
-
const hasCallback = name => registry.has(name);
|
|
705
|
+
const hasCallback = name => registry.has(name?.toString());
|
|
664
706
|
|
|
665
707
|
/**
|
|
666
708
|
* Get a callback from the registry by name/key
|
|
667
709
|
*
|
|
668
|
-
* @param {string} name The name/key of the callback to get
|
|
710
|
+
* @param {CallbackRegistryKey|string} name The name/key of the callback to get
|
|
669
711
|
* @returns {Function|undefined} The corresponding function registered under that name/key
|
|
670
712
|
*/
|
|
671
|
-
const getCallback = name => registry.get(name);
|
|
713
|
+
const getCallback = name => registry.get(name?.toString());
|
|
672
714
|
|
|
673
715
|
/**
|
|
674
716
|
* Remove a callback from the registry
|
|
675
717
|
*
|
|
676
|
-
* @param {string} name The name/key of the callback to get
|
|
718
|
+
* @param {CallbackRegistryKey|string} name The name/key of the callback to get
|
|
677
719
|
* @returns {boolean} Whether or not the callback was successfully unregisterd
|
|
678
720
|
*/
|
|
679
|
-
const unregisterCallback = name => _isRegistrationOpen && registry.delete(name);
|
|
721
|
+
const unregisterCallback = name => _isRegistrationOpen && registry.delete(name?.toString());
|
|
680
722
|
|
|
681
723
|
/**
|
|
682
724
|
* Remove all callbacks from the registry
|
|
@@ -689,21 +731,23 @@ const clearRegistry = () => registry.clear();
|
|
|
689
731
|
* Create a registered callback with a randomly generated name
|
|
690
732
|
*
|
|
691
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.
|
|
692
736
|
* @returns {string} The automatically generated key/name of the registered callback
|
|
693
737
|
*/
|
|
694
|
-
const createCallback = (callback) => registerCallback('aegis:callback:' + crypto.randomUUID(), callback);
|
|
738
|
+
const createCallback = (callback, { stack } = {}) => registerCallback('aegis:callback:' + crypto.randomUUID(), callback, { stack });
|
|
695
739
|
|
|
696
740
|
/**
|
|
697
741
|
* Call a callback fromt the registry by name/key
|
|
698
742
|
*
|
|
699
|
-
* @param {string} name The name/key of the registered function
|
|
743
|
+
* @param {CallbackRegistryKey|string} name The name/key of the registered function
|
|
700
744
|
* @param {...any} args Any arguments to pass along to the function
|
|
701
745
|
* @returns {any} Whatever the return value of the function is
|
|
702
746
|
* @throws {Error} Throws if callback is not found or any error resulting from calling the function
|
|
703
747
|
*/
|
|
704
748
|
function callCallback(name, ...args) {
|
|
705
|
-
if (registry.has(name)) {
|
|
706
|
-
return registry.get(name).apply(this || globalThis, args);
|
|
749
|
+
if (registry.has(name?.toString())) {
|
|
750
|
+
return registry.get(name?.toString()).apply(this || globalThis, args);
|
|
707
751
|
} else {
|
|
708
752
|
throw new Error(`No ${name} function registered.`);
|
|
709
753
|
}
|
|
@@ -712,22 +756,33 @@ function callCallback(name, ...args) {
|
|
|
712
756
|
/**
|
|
713
757
|
* Register a named callback in registry
|
|
714
758
|
*
|
|
715
|
-
* @param {string} name The name/key to register the callback under
|
|
759
|
+
* @param {CallbackRegistryKey|string} name The name/key to register the callback under
|
|
716
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.
|
|
717
763
|
* @returns {string} The registered name/key
|
|
718
764
|
*/
|
|
719
|
-
function registerCallback(name, callback) {
|
|
720
|
-
if (typeof name
|
|
721
|
-
|
|
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.');
|
|
722
770
|
} if (! (callback instanceof Function)) {
|
|
723
771
|
throw new TypeError('Callback must be a function.');
|
|
724
772
|
} else if (! _isRegistrationOpen) {
|
|
725
773
|
throw new TypeError('Cannot register new callbacks because registry is closed.');
|
|
726
|
-
} else if (registry.has(name)) {
|
|
774
|
+
} else if (registry.has(name?.toString())) {
|
|
727
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;
|
|
728
781
|
} else {
|
|
729
|
-
|
|
730
|
-
|
|
782
|
+
const key = new CallbackRegistryKey(name);
|
|
783
|
+
registry.set(key.toString(), callback);
|
|
784
|
+
|
|
785
|
+
return key;
|
|
731
786
|
}
|
|
732
787
|
}
|
|
733
788
|
|
|
@@ -751,10 +806,10 @@ function getHost(target) {
|
|
|
751
806
|
}
|
|
752
807
|
}
|
|
753
808
|
|
|
754
|
-
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 } = {}) {
|
|
755
810
|
if (callback instanceof Function) {
|
|
756
|
-
return on(event, createCallback(callback), { capture: capture$1, passive: passive$1, once: once$1, signal: signal$1 });
|
|
757
|
-
} else if (typeof callback
|
|
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) {
|
|
758
813
|
throw new TypeError('Callback must be a function or a registered callback string.');
|
|
759
814
|
} else if (typeof event !== 'string' || event.length === 0) {
|
|
760
815
|
throw new TypeError('Event must be a non-empty string.');
|
|
@@ -787,6 +842,7 @@ function on(event, callback, { capture: capture$1 = false, passive: passive$1 =
|
|
|
787
842
|
}
|
|
788
843
|
}
|
|
789
844
|
|
|
845
|
+
exports.CallbackRegistryKey = CallbackRegistryKey;
|
|
790
846
|
exports.FUNCS = FUNCS;
|
|
791
847
|
exports.callCallback = callCallback;
|
|
792
848
|
exports.clearRegistry = clearRegistry;
|
|
@@ -799,4 +855,6 @@ exports.isRegistrationOpen = isRegistrationOpen;
|
|
|
799
855
|
exports.listCallbacks = listCallbacks;
|
|
800
856
|
exports.on = on;
|
|
801
857
|
exports.registerCallback = registerCallback;
|
|
858
|
+
exports.requestFullscreen = requestFullscreen;
|
|
859
|
+
exports.toggleFullsceen = toggleFullsceen;
|
|
802
860
|
exports.unregisterCallback = unregisterCallback;
|
package/callbacks.js
CHANGED
|
@@ -9,6 +9,9 @@ const $$ = (selector, base = document) => base.querySelectorAll(selector);
|
|
|
9
9
|
|
|
10
10
|
const $ = (selector, base = document) => base.querySelector(selector);
|
|
11
11
|
|
|
12
|
+
export const requestFullscreen = { attr: 'data-request-fullscreen-selector', data: 'requestFullscreenSelector' };
|
|
13
|
+
export const toggleFullsceen = { attr: 'data-toggle-fullscreen-selector', data: 'toggleFullscreenSelector' };
|
|
14
|
+
|
|
12
15
|
export const FUNCS = {
|
|
13
16
|
debug: {
|
|
14
17
|
log: 'aegis:debug:log',
|
|
@@ -25,6 +28,7 @@ export const FUNCS = {
|
|
|
25
28
|
popup: 'aegis:navigate:popup',
|
|
26
29
|
},
|
|
27
30
|
ui: {
|
|
31
|
+
command: 'aegis:ui:command',
|
|
28
32
|
print: 'aegis:ui:print',
|
|
29
33
|
remove: 'aegis:ui:remove',
|
|
30
34
|
hide: 'aegis:ui:hide',
|
|
@@ -40,10 +44,18 @@ export const FUNCS = {
|
|
|
40
44
|
prevent: 'aegis:ui:prevent',
|
|
41
45
|
revokeObjectURL: 'aegis:ui:revokeObjectURL',
|
|
42
46
|
cancelAnimationFrame: 'aegis:ui:cancelAnimationFrame',
|
|
47
|
+
requestFullscreen: 'aegis:ui:requestFullscreen',
|
|
48
|
+
toggleFullscreen: 'aegis:ui:toggleFullsceen',
|
|
49
|
+
exitFullsceen: 'aegis:ui:exitFullscreen',
|
|
50
|
+
open: 'aegis:ui:open',
|
|
51
|
+
close: 'aegis:ui:close',
|
|
43
52
|
abortController: 'aegis:ui:controller:abort',
|
|
44
53
|
},
|
|
45
54
|
};
|
|
46
55
|
|
|
56
|
+
/**
|
|
57
|
+
* @type {Map<string, function>}
|
|
58
|
+
*/
|
|
47
59
|
const registry = new Map([
|
|
48
60
|
[FUNCS.debug.log, console.log],
|
|
49
61
|
[FUNCS.debug.warn, console.warn],
|
|
@@ -96,6 +108,8 @@ const registry = new Map([
|
|
|
96
108
|
[FUNCS.ui.clearInterval, ({ currentTarget }) => clearInterval(parseInt(currentTarget.dataset.clearInterval))],
|
|
97
109
|
[FUNCS.ui.clearTimeout, ({ currentTarget }) => clearTimeout(parseInt(currentTarget.dataset.timeout))],
|
|
98
110
|
[FUNCS.ui.abortController, ({ currentTarget }) => abortController(currentTarget.dataset.aegisEventController, currentTarget.dataset.aegisControllerReason)],
|
|
111
|
+
[FUNCS.ui.open, ({ currentTarget }) => document.querySelector(currentTarget.dataset.openSelector).open = true],
|
|
112
|
+
[FUNCS.ui.close, ({ currentTarget }) => document.querySelector(currentTarget.dataset.closeSelector).open = false],
|
|
99
113
|
[FUNCS.ui.showModal, ({ currentTarget }) => {
|
|
100
114
|
const target = $(currentTarget.dataset.showModalSelector);
|
|
101
115
|
|
|
@@ -133,8 +147,33 @@ const registry = new Map([
|
|
|
133
147
|
}],
|
|
134
148
|
[FUNCS.ui.print, () => globalThis.print()],
|
|
135
149
|
[FUNCS.ui.prevent, event => event.preventDefault()],
|
|
150
|
+
[FUNCS.ui.requestFullscreen, ({ currentTarget}) => {
|
|
151
|
+
if (currentTarget.dataset.hasOwnProperty(requestFullscreen.data)) {
|
|
152
|
+
document.getElementById(currentTarget.dataset[requestFullscreen.data]).requestFullscreen();
|
|
153
|
+
} else {
|
|
154
|
+
currentTarget.requestFullscreen();
|
|
155
|
+
}
|
|
156
|
+
}],
|
|
157
|
+
[FUNCS.ui.toggleFullscreen, ({ currentTarget }) => {
|
|
158
|
+
const target = currentTarget.dataset.hasOwnProperty(toggleFullsceen.data)
|
|
159
|
+
? document.getElementById(currentTarget.dataset[toggleFullsceen.data])
|
|
160
|
+
: currentTarget;
|
|
161
|
+
|
|
162
|
+
if (target.isSameNode(document.fullscreenElement)) {
|
|
163
|
+
document.exitFullscreen();
|
|
164
|
+
} else {
|
|
165
|
+
target.requestFullscreen();
|
|
166
|
+
}
|
|
167
|
+
}],
|
|
168
|
+
[FUNCS.ui.exitFullsceen, () => document.exitFullscreen()],
|
|
136
169
|
]);
|
|
137
170
|
|
|
171
|
+
export class CallbackRegistryKey extends String {
|
|
172
|
+
[Symbol.dispose]() {
|
|
173
|
+
registry.delete(this.toString());
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
138
177
|
/**
|
|
139
178
|
* Check if callback registry is open
|
|
140
179
|
*
|
|
@@ -159,26 +198,26 @@ export const listCallbacks = () => Object.freeze(Array.from(registry.keys()));
|
|
|
159
198
|
/**
|
|
160
199
|
* Check if a callback is registered
|
|
161
200
|
*
|
|
162
|
-
* @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
|
|
163
202
|
* @returns {boolean} Whether or not a callback is registered
|
|
164
203
|
*/
|
|
165
|
-
export const hasCallback = name => registry.has(name);
|
|
204
|
+
export const hasCallback = name => registry.has(name?.toString());
|
|
166
205
|
|
|
167
206
|
/**
|
|
168
207
|
* Get a callback from the registry by name/key
|
|
169
208
|
*
|
|
170
|
-
* @param {string} name The name/key of the callback to get
|
|
209
|
+
* @param {CallbackRegistryKey|string} name The name/key of the callback to get
|
|
171
210
|
* @returns {Function|undefined} The corresponding function registered under that name/key
|
|
172
211
|
*/
|
|
173
|
-
export const getCallback = name => registry.get(name);
|
|
212
|
+
export const getCallback = name => registry.get(name?.toString());
|
|
174
213
|
|
|
175
214
|
/**
|
|
176
215
|
* Remove a callback from the registry
|
|
177
216
|
*
|
|
178
|
-
* @param {string} name The name/key of the callback to get
|
|
217
|
+
* @param {CallbackRegistryKey|string} name The name/key of the callback to get
|
|
179
218
|
* @returns {boolean} Whether or not the callback was successfully unregisterd
|
|
180
219
|
*/
|
|
181
|
-
export const unregisterCallback = name => _isRegistrationOpen && registry.delete(name);
|
|
220
|
+
export const unregisterCallback = name => _isRegistrationOpen && registry.delete(name?.toString());
|
|
182
221
|
|
|
183
222
|
/**
|
|
184
223
|
* Remove all callbacks from the registry
|
|
@@ -191,21 +230,23 @@ export const clearRegistry = () => registry.clear();
|
|
|
191
230
|
* Create a registered callback with a randomly generated name
|
|
192
231
|
*
|
|
193
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.
|
|
194
235
|
* @returns {string} The automatically generated key/name of the registered callback
|
|
195
236
|
*/
|
|
196
|
-
export const createCallback = (callback) => registerCallback('aegis:callback:' + crypto.randomUUID(), callback);
|
|
237
|
+
export const createCallback = (callback, { stack } = {}) => registerCallback('aegis:callback:' + crypto.randomUUID(), callback, { stack });
|
|
197
238
|
|
|
198
239
|
/**
|
|
199
240
|
* Call a callback fromt the registry by name/key
|
|
200
241
|
*
|
|
201
|
-
* @param {string} name The name/key of the registered function
|
|
242
|
+
* @param {CallbackRegistryKey|string} name The name/key of the registered function
|
|
202
243
|
* @param {...any} args Any arguments to pass along to the function
|
|
203
244
|
* @returns {any} Whatever the return value of the function is
|
|
204
245
|
* @throws {Error} Throws if callback is not found or any error resulting from calling the function
|
|
205
246
|
*/
|
|
206
247
|
export function callCallback(name, ...args) {
|
|
207
|
-
if (registry.has(name)) {
|
|
208
|
-
return registry.get(name).apply(this || globalThis, args);
|
|
248
|
+
if (registry.has(name?.toString())) {
|
|
249
|
+
return registry.get(name?.toString()).apply(this || globalThis, args);
|
|
209
250
|
} else {
|
|
210
251
|
throw new Error(`No ${name} function registered.`);
|
|
211
252
|
}
|
|
@@ -214,22 +255,33 @@ export function callCallback(name, ...args) {
|
|
|
214
255
|
/**
|
|
215
256
|
* Register a named callback in registry
|
|
216
257
|
*
|
|
217
|
-
* @param {string} name The name/key to register the callback under
|
|
258
|
+
* @param {CallbackRegistryKey|string} name The name/key to register the callback under
|
|
218
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.
|
|
219
262
|
* @returns {string} The registered name/key
|
|
220
263
|
*/
|
|
221
|
-
export function registerCallback(name, callback) {
|
|
222
|
-
if (typeof name
|
|
223
|
-
|
|
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.');
|
|
224
269
|
} if (! (callback instanceof Function)) {
|
|
225
270
|
throw new TypeError('Callback must be a function.');
|
|
226
271
|
} else if (! _isRegistrationOpen) {
|
|
227
272
|
throw new TypeError('Cannot register new callbacks because registry is closed.');
|
|
228
|
-
} else if (registry.has(name)) {
|
|
273
|
+
} else if (registry.has(name?.toString())) {
|
|
229
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;
|
|
230
280
|
} else {
|
|
231
|
-
|
|
232
|
-
|
|
281
|
+
const key = new CallbackRegistryKey(name);
|
|
282
|
+
registry.set(key.toString(), callback);
|
|
283
|
+
|
|
284
|
+
return key;
|
|
233
285
|
}
|
|
234
286
|
}
|
|
235
287
|
|
|
@@ -253,10 +305,10 @@ export function getHost(target) {
|
|
|
253
305
|
}
|
|
254
306
|
}
|
|
255
307
|
|
|
256
|
-
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 } = {}) {
|
|
257
309
|
if (callback instanceof Function) {
|
|
258
|
-
return on(event, createCallback(callback), { capture, passive, once, signal });
|
|
259
|
-
} else if (typeof callback
|
|
310
|
+
return on(event, createCallback(callback, { stack }), { capture, passive, once, signal });
|
|
311
|
+
} else if (! (callback instanceof String || typeof callback === 'string') || callback.length === 0) {
|
|
260
312
|
throw new TypeError('Callback must be a function or a registered callback string.');
|
|
261
313
|
} else if (typeof event !== 'string' || event.length === 0) {
|
|
262
314
|
throw new TypeError('Event must be a non-empty string.');
|
package/events.js
CHANGED
|
@@ -27,6 +27,7 @@ export const onCanplaythrough = EVENT_PREFIX + 'canplaythrough';
|
|
|
27
27
|
export const onChange = EVENT_PREFIX + 'change';
|
|
28
28
|
export const onClick = EVENT_PREFIX + 'click';
|
|
29
29
|
export const onClose = EVENT_PREFIX + 'close';
|
|
30
|
+
export const onCommand = EVENT_PREFIX + 'command';
|
|
30
31
|
export const onContextmenu = EVENT_PREFIX + 'contextmenu';
|
|
31
32
|
export const onCopy = EVENT_PREFIX + 'copy';
|
|
32
33
|
export const onCuechange = EVENT_PREFIX + 'cuechange';
|
|
@@ -124,6 +125,7 @@ export const eventAttrs = [
|
|
|
124
125
|
onChange,
|
|
125
126
|
onClick,
|
|
126
127
|
onClose,
|
|
128
|
+
onCommand,
|
|
127
129
|
onContextmenu,
|
|
128
130
|
onCopy,
|
|
129
131
|
onCuechange,
|
|
@@ -293,6 +295,7 @@ export const EVENTS = {
|
|
|
293
295
|
onChange,
|
|
294
296
|
onClick,
|
|
295
297
|
onClose,
|
|
298
|
+
onCommand,
|
|
296
299
|
onContextmenu,
|
|
297
300
|
onCopy,
|
|
298
301
|
onCuechange,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aegisjsproject/callback-registry",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": " A callback registry for AegisJSProject",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"aegis",
|
|
@@ -77,8 +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.
|
|
81
|
-
"
|
|
80
|
+
"@shgysk8zer0/eslint-config": "^1.0.5",
|
|
81
|
+
"@shgysk8zer0/polyfills": "^0.6.0",
|
|
82
|
+
"eslint": "^10.0.0",
|
|
82
83
|
"http-server": "^14.1.1",
|
|
83
84
|
"rollup": "^4.27.2"
|
|
84
85
|
}
|