@zero-dependency/dom 1.2.0 → 1.3.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/dist/index.cjs.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function u(o,e,...n){const t=document.createElement(o);return typeof e=="string"?t.append(i(e)):Array.isArray(e)?t.append(...e):(Object.assign(t,e),Object.assign(t.style,e?.style)),n.length&&t.append(...n),t}function i(o){return document.createTextNode(o)}function h(){return i(" ")}class a{#e={};on(e,n){const t=this.#e[e]??[];return this.#e[e]=t,t.push(n),this}addListener(e,n){return this.on(e,n)}once(e,n){const t=(...r)=>{this.off(e,t),n(...r)};return this.on(e,t),this}emit(e,...n){const t=this.#e[e]??[];for(let r=0;r<t.length;r++)t[r](...n);return!!t.length}off(e,n){return this.#e[e]&&(this.#e[e]=this.#e[e].filter(t=>t!==n)),this}removeListener(e,n){return this.off(e,n)}removeAllListeners(e){return e?delete this.#e[e]:this.#e={},this}eventNames(){return Reflect.ownKeys(this.#e)}listeners(e){return this.#e[e]??[]}listenerCount(e){return this.#e[e]?.length??0}}class p extends a{constructor(){super();const{history:e,location:n}=window,{pushState:t,replaceState:r}=e;e.pushState=(...s)=>{t.apply(e,s),this.emit("pushState",n,s[0])},e.replaceState=(...s)=>{r.apply(e,s),this.emit("replaceState",n,s[0])},window.addEventListener("popstate",s=>{this.emit("popState",n,s)})}}function c(o,e,n){const t=new MutationObserver((r,s)=>{for(const l of r)e(l,s)});return t.observe(o,{childList:!0,subtree:!0,...n}),()=>t.disconnect()}function f(o,e=document.documentElement){return new Promise(n=>{c(e,(t,r)=>{const s=e.querySelector(o);s&&(r.disconnect(),n(s))})})}exports.LocationObserver=p;exports.el=u;exports.nbsp=h;exports.observeElement=c;exports.text=i;exports.waitElement=f;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function a(s,e,...t){const n=document.createElement(s);return typeof e=="string"?n.append(c(e)):Array.isArray(e)?n.append(...e):(Object.assign(n,e),Object.assign(n.style,e?.style)),t.length&&n.append(...t),n}function c(s){return document.createTextNode(s)}function p(){return c(" ")}class u{#e={};constructor(){const{history:e,location:t}=window,{pushState:n,replaceState:r}=e;e.pushState=(...o)=>{n.apply(e,o),this.#e?.pushState(t,o[0])},e.replaceState=(...o)=>{r.apply(e,o),this.#e?.replaceState(t,o[0])},window.addEventListener("popstate",o=>{this.#e?.popState(t,o)})}on(e,t){return this.#e[e]=t,()=>this.off(e)}off(e){delete this.#e[e]}}function i(s,e,t){const n=new MutationObserver((r,o)=>{for(const l of r)e(l,o)});return n.observe(s,{childList:!0,subtree:!0,...t}),()=>n.disconnect()}function d(s,e=document.documentElement){return new Promise(t=>{i(e,(n,r)=>{const o=e.querySelector(s);o&&(r.disconnect(),t(o))})})}exports.LocationObserver=u;exports.el=a;exports.nbsp=p;exports.observeElement=i;exports.text=c;exports.waitElement=d;
2
2
  //# sourceMappingURL=index.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":["../src/html.ts","../../emitter/dist/index.es.js","../src/location-observer.ts","../src/mutation-observers.ts"],"sourcesContent":["// prettier-ignore\ntype Attributes<T extends keyof HTMLElementTagNameMap> = Partial<{\n style: Partial<CSSStyleDeclaration>\n} & Omit<HTMLElementTagNameMap[T], 'style'>>\n\ntype Children = (string | Node | HTMLElement)[]\n\n/**\n * Create an element\n * @param tag The tag name of the element to create\n * @param attributes The attributes or children to set on the element\n * @param children The children to append to the element\n * @returns The created element\n * @example\n * el('div', { id: 'foo' }, 'Hello world')\n * el('div', 'Hello world')\n * el('div', [el('span', 'Hello'), el('span', 'world')])\n * el('div', el('span', 'Hello world'))\n * el('div', el('span', 'Hello'), el('span', 'world'))\n * el('div', el('span', 'Hello world'), 'world')\n */\nexport function el<T extends keyof HTMLElementTagNameMap>(\n tag: T,\n attributes?: Attributes<T> | Children,\n ...children: Children\n): HTMLElementTagNameMap[T] {\n const el = document.createElement(tag)\n\n if (typeof attributes === 'string') {\n el.append(text(attributes))\n } else if (Array.isArray(attributes)) {\n el.append(...attributes)\n } else {\n Object.assign(el, attributes)\n Object.assign(el.style, attributes?.style)\n }\n\n if (children.length) {\n el.append(...children)\n }\n\n return el\n}\n\n/**\n * Create a text node\n * @param text The string to create a text node from\n */\nexport function text(text: string): Text {\n return document.createTextNode(text)\n}\n\n/**\n * A non-breaking space\n */\nexport function nbsp(): Text {\n return text('\\u00a0')\n}\n","class n {\n #t = {};\n /**\n * Add an event listener\n * @param event The event name\n * @param listener The listener function\n * @returns The emitter\n */\n on(t, e) {\n const s = this.#t[t] ?? [];\n return this.#t[t] = s, s.push(e), this;\n }\n /**\n * Alias for `addListener`\n */\n addListener(t, e) {\n return this.on(t, e);\n }\n /**\n * Add an event listener that will be called only once\n * @note The listener is wrapped in a wrapper function, so it cannot be equal to the original listener\n * @param event The event name\n * @param listener The listener function\n * @returns The emitter\n */\n once(t, e) {\n const s = (...r) => {\n this.off(t, s), e(...r);\n };\n return this.on(t, s), this;\n }\n /**\n * Emit an event\n * @param event The event name\n * @param args The arguments to pass to the listeners\n * @returns `true` if the event had listeners, `false` otherwise\n */\n emit(t, ...e) {\n const s = this.#t[t] ?? [];\n for (let r = 0; r < s.length; r++)\n s[r](...e);\n return !!s.length;\n }\n /**\n * Remove an event listener\n * @param event The event name\n * @param listener The listener function\n * @returns The emitter\n */\n off(t, e) {\n return this.#t[t] && (this.#t[t] = this.#t[t].filter((s) => s !== e)), this;\n }\n /**\n * Alias for `off`\n */\n removeListener(t, e) {\n return this.off(t, e);\n }\n /**\n * Remove all event listeners\n * @param event The event name\n * @returns The emitter\n */\n removeAllListeners(t) {\n return t ? delete this.#t[t] : this.#t = {}, this;\n }\n /**\n * Get the list of event names\n * @returns An array of event names\n */\n eventNames() {\n return Reflect.ownKeys(this.#t);\n }\n /**\n * Get the list of listeners for an event\n * @param event The event name\n * @returns An array of listeners\n */\n listeners(t) {\n return this.#t[t] ?? [];\n }\n /**\n * Get the number of listeners for an event\n * @param event The event name\n * @returns The number of listeners for the event\n */\n listenerCount(t) {\n return this.#t[t]?.length ?? 0;\n }\n}\nexport {\n n as Emitter\n};\n//# sourceMappingURL=index.es.js.map\n","import { Emitter } from '@zero-dependency/emitter'\n\ntype LocationCallback<T = any> = (location: Location, args: T) => void\n\ntype Events<T> = {\n pushState: LocationCallback<T>\n replaceState: LocationCallback<T>\n popState: LocationCallback<\n Omit<PopStateEvent, 'state'> & { readonly state: T }\n >\n}\n\n/**\n * Observe changes to the location\n * @example\n * const observer = new LocationObserver<{ id: string }>()\n * observer.on('pushState', (location, state) => {\n * console.log(state.id)\n * })\n */\nexport class LocationObserver<T> extends Emitter<Events<T>> {\n constructor() {\n super()\n\n const { history, location } = window\n const { pushState, replaceState } = history\n\n history.pushState = (...args) => {\n pushState.apply(history, args)\n this.emit('pushState', location, args[0])\n }\n\n history.replaceState = (...args) => {\n replaceState.apply(history, args)\n this.emit('replaceState', location, args[0])\n }\n\n window.addEventListener('popstate', (event) => {\n this.emit('popState', location, event)\n })\n }\n}\n","type Disconnect = () => void\n\n/**\n * Observe mutations on an element\n * @param el The element to observe\n * @param callback The callback to call when a mutation occurs\n * @param options The options to pass to the `MutationObserver`\n * @returns A function to disconnect the observer\n */\nexport function observeElement<T extends Element = Element>(\n el: T,\n callback: (mutation: MutationRecord, observer: MutationObserver) => void,\n options?: MutationObserverInit\n): Disconnect {\n const observe = new MutationObserver((mutations, observer) => {\n for (const mutation of mutations) {\n callback(mutation, observer)\n }\n })\n\n observe.observe(el, {\n childList: true,\n subtree: true,\n ...options\n })\n\n return () => observe.disconnect()\n}\n\n/**\n * Wait for an element to appear in the DOM\n * @param selector The selector to wait for\n * @param target The element to search in\n * @returns A promise that resolves when the element is found\n */\nexport function waitElement<T extends Element = Element>(\n selector: string,\n target = document.documentElement\n): Promise<T> {\n return new Promise((resolve) => {\n observeElement(target, (_, observer) => {\n const el = target.querySelector<T>(selector)\n if (el) {\n observer.disconnect()\n resolve(el)\n }\n })\n })\n}\n"],"names":["el","tag","attributes","children","text","nbsp","n","#t","t","e","s","LocationObserver","Emitter","history","location","pushState","replaceState","args","event","observeElement","callback","options","observe","mutations","observer","mutation","waitElement","selector","target","resolve","_"],"mappings":"gFAqBgB,SAAAA,EACdC,EACAC,KACGC,EACuB,CACpBH,MAAAA,EAAK,SAAS,cAAcC,CAAG,EAEjC,OAAA,OAAOC,GAAe,SACxBF,EAAG,OAAOI,EAAKF,CAAU,CAAC,EACjB,MAAM,QAAQA,CAAU,EACjCF,EAAG,OAAO,GAAGE,CAAU,GAEhB,OAAA,OAAOF,EAAIE,CAAU,EAC5B,OAAO,OAAOF,EAAG,MAAOE,GAAY,KAAK,GAGvCC,EAAS,QACXH,EAAG,OAAO,GAAGG,CAAQ,EAGhBH,CACT,CAMO,SAASI,EAAKA,EAAoB,CAChC,OAAA,SAAS,eAAeA,CAAI,CACrC,CAKO,SAASC,GAAa,CAC3B,OAAOD,EAAK,GAAQ,CACtB,CCzDA,MAAME,CAAE,CACNC,GAAK,CAAA,EAOL,GAAGC,EAAGC,EAAG,CACP,MAAMC,EAAI,KAAKH,GAAGC,CAAC,GAAK,CAAA,EACxB,OAAO,KAAKD,GAAGC,CAAC,EAAIE,EAAGA,EAAE,KAAKD,CAAC,EAAG,IACnC,CAID,YAAYD,EAAGC,EAAG,CAChB,OAAO,KAAK,GAAGD,EAAGC,CAAC,CACpB,CAQD,KAAKD,EAAGC,EAAG,CACT,MAAMC,EAAI,IAAI,IAAM,CAClB,KAAK,IAAIF,EAAGE,CAAC,EAAGD,EAAE,GAAG,CAAC,CAC5B,EACI,OAAO,KAAK,GAAGD,EAAGE,CAAC,EAAG,IACvB,CAOD,KAAKF,KAAMC,EAAG,CACZ,MAAMC,EAAI,KAAKH,GAAGC,CAAC,GAAK,CAAA,EACxB,QAAS,EAAI,EAAG,EAAIE,EAAE,OAAQ,IAC5BA,EAAE,CAAC,EAAE,GAAGD,CAAC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AQtB,EAAI,CAClB,UAAW,GACX,QAAS,GACT,GAAGqB,CAAA,CACJ,EAEM,IAAMC,EAAQ,YACvB,CAQO,SAASI,EACdC,EACAC,EAAS,SAAS,gBACN,CACL,OAAA,IAAI,QAASC,GAAY,CACfV,EAAAS,EAAQ,CAACE,EAAGN,IAAa,CAChC,MAAAxB,EAAK4B,EAAO,cAAiBD,CAAQ,EACvC3B,IACFwB,EAAS,WAAW,EACpBK,EAAQ7B,CAAE,EACZ,CACD,CAAA,CACF,CACH"}
1
+ {"version":3,"file":"index.cjs.js","sources":["../src/html.ts","../src/location-observer.ts","../src/mutation-observers.ts"],"sourcesContent":["// prettier-ignore\ntype Attributes<T extends keyof HTMLElementTagNameMap> = Partial<{\n style: Partial<CSSStyleDeclaration>\n} & Omit<HTMLElementTagNameMap[T], 'style'>>\n\ntype Children = (string | Node | HTMLElement)[]\n\n/**\n * Create an element\n * @param tag The tag name of the element to create\n * @param attributes The attributes or children to set on the element\n * @param children The children to append to the element\n * @returns The created element\n * @example\n * el('div', { id: 'foo' }, 'Hello world')\n * el('div', 'Hello world')\n * el('div', [el('span', 'Hello'), el('span', 'world')])\n * el('div', el('span', 'Hello world'))\n * el('div', el('span', 'Hello'), el('span', 'world'))\n * el('div', el('span', 'Hello world'), 'world')\n */\nexport function el<T extends keyof HTMLElementTagNameMap>(\n tag: T,\n attributes?: Attributes<T> | Children,\n ...children: Children\n): HTMLElementTagNameMap[T] {\n const el = document.createElement(tag)\n\n if (typeof attributes === 'string') {\n el.append(text(attributes))\n } else if (Array.isArray(attributes)) {\n el.append(...attributes)\n } else {\n Object.assign(el, attributes)\n Object.assign(el.style, attributes?.style)\n }\n\n if (children.length) {\n el.append(...children)\n }\n\n return el\n}\n\n/**\n * Create a text node\n * @param text The string to create a text node from\n */\nexport function text(text: string): Text {\n return document.createTextNode(text)\n}\n\n/**\n * A non-breaking space\n */\nexport function nbsp(): Text {\n return text('\\u00a0')\n}\n","type LocationCallback<T = any> = (location: Location, args: T) => void\n\ntype Events<T> = {\n pushState: LocationCallback<T>\n replaceState: LocationCallback<T>\n popState: LocationCallback<\n Omit<PopStateEvent, 'state'> & { readonly state: T }\n >\n}\n\n/**\n * Observe changes to the location\n * @example\n * const observer = new LocationObserver<{ id: string }>()\n * observer.on('pushState', (location, state) => {\n * console.log(state.id)\n * })\n */\nexport class LocationObserver<T> {\n #events = {} as Record<keyof Events<T>, LocationCallback<any>>\n\n constructor() {\n const { history, location } = window\n const { pushState, replaceState } = history\n\n history.pushState = (...args) => {\n pushState.apply(history, args)\n this.#events?.pushState(location, args[0])\n }\n\n history.replaceState = (...args) => {\n replaceState.apply(history, args)\n this.#events?.replaceState(location, args[0])\n }\n\n window.addEventListener('popstate', (event) => {\n this.#events?.popState(location, event)\n })\n }\n\n on<E extends keyof Events<T>>(event: E, listener: Events<T>[E]): () => void {\n this.#events[event] = listener\n return () => this.off(event)\n }\n\n off<E extends keyof Events<T>>(event: E): void {\n delete this.#events[event]\n }\n}\n","type Disconnect = () => void\n\n/**\n * Observe mutations on an element\n * @param el The element to observe\n * @param callback The callback to call when a mutation occurs\n * @param options The options to pass to the `MutationObserver`\n * @returns A function to disconnect the observer\n */\nexport function observeElement<T extends Element = Element>(\n el: T,\n callback: (mutation: MutationRecord, observer: MutationObserver) => void,\n options?: MutationObserverInit\n): Disconnect {\n const observe = new MutationObserver((mutations, observer) => {\n for (const mutation of mutations) {\n callback(mutation, observer)\n }\n })\n\n observe.observe(el, {\n childList: true,\n subtree: true,\n ...options\n })\n\n return () => observe.disconnect()\n}\n\n/**\n * Wait for an element to appear in the DOM\n * @param selector The selector to wait for\n * @param target The element to search in\n * @returns A promise that resolves when the element is found\n */\nexport function waitElement<T extends Element = Element>(\n selector: string,\n target = document.documentElement\n): Promise<T> {\n return new Promise((resolve) => {\n observeElement(target, (_, observer) => {\n const el = target.querySelector<T>(selector)\n if (el) {\n observer.disconnect()\n resolve(el)\n }\n })\n })\n}\n"],"names":["el","tag","attributes","children","text","nbsp","LocationObserver","#events","history","location","pushState","replaceState","args","event","listener","observeElement","callback","options","observe","mutations","observer","mutation","waitElement","selector","target","resolve","_"],"mappings":"gFAqBgB,SAAAA,EACdC,EACAC,KACGC,EACuB,CACpBH,MAAAA,EAAK,SAAS,cAAcC,CAAG,EAEjC,OAAA,OAAOC,GAAe,SACxBF,EAAG,OAAOI,EAAKF,CAAU,CAAC,EACjB,MAAM,QAAQA,CAAU,EACjCF,EAAG,OAAO,GAAGE,CAAU,GAEhB,OAAA,OAAOF,EAAIE,CAAU,EAC5B,OAAO,OAAOF,EAAG,MAAOE,GAAY,KAAK,GAGvCC,EAAS,QACXH,EAAG,OAAO,GAAGG,CAAQ,EAGhBH,CACT,CAMO,SAASI,EAAKA,EAAoB,CAChC,OAAA,SAAS,eAAeA,CAAI,CACrC,CAKO,SAASC,GAAa,CAC3B,OAAOD,EAAK,GAAQ,CACtB,CCvCO,MAAME,CAAoB,CAC/BC,GAAU,CAAA,EAEV,aAAc,CACN,KAAA,CAAE,QAAAC,EAAS,SAAAC,CAAa,EAAA,OACxB,CAAE,UAAAC,EAAW,aAAAC,CAAiB,EAAAH,EAE5BA,EAAA,UAAY,IAAII,IAAS,CACrBF,EAAA,MAAMF,EAASI,CAAI,EAC7B,KAAKL,IAAS,UAAUE,EAAUG,EAAK,CAAC,CAAC,CAAA,EAGnCJ,EAAA,aAAe,IAAII,IAAS,CACrBD,EAAA,MAAMH,EAASI,CAAI,EAChC,KAAKL,IAAS,aAAaE,EAAUG,EAAK,CAAC,CAAC,CAAA,EAGvC,OAAA,iBAAiB,WAAaC,GAAU,CACxC,KAAAN,IAAS,SAASE,EAAUI,CAAK,CAAA,CACvC,CACH,CAEA,GAA8BA,EAAUC,EAAoC,CACrE,YAAAP,GAAQM,CAAK,EAAIC,EACf,IAAM,KAAK,IAAID,CAAK,CAC7B,CAEA,IAA+BA,EAAgB,CACtC,OAAA,KAAKN,GAAQM,CAAK,CAC3B,CACF,CCvCgB,SAAAE,EACdf,EACAgB,EACAC,EACY,CACZ,MAAMC,EAAU,IAAI,iBAAiB,CAACC,EAAWC,IAAa,CAC5D,UAAWC,KAAYF,EACrBH,EAASK,EAAUD,CAAQ,CAC7B,CACD,EAED,OAAAF,EAAQ,QAAQlB,EAAI,CAClB,UAAW,GACX,QAAS,GACT,GAAGiB,CAAA,CACJ,EAEM,IAAMC,EAAQ,YACvB,CAQO,SAASI,EACdC,EACAC,EAAS,SAAS,gBACN,CACL,OAAA,IAAI,QAASC,GAAY,CACfV,EAAAS,EAAQ,CAACE,EAAGN,IAAa,CAChC,MAAApB,EAAKwB,EAAO,cAAiBD,CAAQ,EACvCvB,IACFoB,EAAS,WAAW,EACpBK,EAAQzB,CAAE,EACZ,CACD,CAAA,CACF,CACH"}
package/dist/index.es.js CHANGED
@@ -1,141 +1,57 @@
1
- function h(o, e, ...n) {
2
- const t = document.createElement(o);
3
- return typeof e == "string" ? t.append(i(e)) : Array.isArray(e) ? t.append(...e) : (Object.assign(t, e), Object.assign(t.style, e?.style)), n.length && t.append(...n), t;
1
+ function a(s, e, ...t) {
2
+ const n = document.createElement(s);
3
+ return typeof e == "string" ? n.append(r(e)) : Array.isArray(e) ? n.append(...e) : (Object.assign(n, e), Object.assign(n.style, e?.style)), t.length && n.append(...t), n;
4
4
  }
5
- function i(o) {
6
- return document.createTextNode(o);
5
+ function r(s) {
6
+ return document.createTextNode(s);
7
7
  }
8
- function p() {
9
- return i(" ");
8
+ function l() {
9
+ return r(" ");
10
10
  }
11
- class l {
11
+ class u {
12
12
  #e = {};
13
- /**
14
- * Add an event listener
15
- * @param event The event name
16
- * @param listener The listener function
17
- * @returns The emitter
18
- */
19
- on(e, n) {
20
- const t = this.#e[e] ?? [];
21
- return this.#e[e] = t, t.push(n), this;
22
- }
23
- /**
24
- * Alias for `addListener`
25
- */
26
- addListener(e, n) {
27
- return this.on(e, n);
28
- }
29
- /**
30
- * Add an event listener that will be called only once
31
- * @note The listener is wrapped in a wrapper function, so it cannot be equal to the original listener
32
- * @param event The event name
33
- * @param listener The listener function
34
- * @returns The emitter
35
- */
36
- once(e, n) {
37
- const t = (...r) => {
38
- this.off(e, t), n(...r);
39
- };
40
- return this.on(e, t), this;
41
- }
42
- /**
43
- * Emit an event
44
- * @param event The event name
45
- * @param args The arguments to pass to the listeners
46
- * @returns `true` if the event had listeners, `false` otherwise
47
- */
48
- emit(e, ...n) {
49
- const t = this.#e[e] ?? [];
50
- for (let r = 0; r < t.length; r++)
51
- t[r](...n);
52
- return !!t.length;
53
- }
54
- /**
55
- * Remove an event listener
56
- * @param event The event name
57
- * @param listener The listener function
58
- * @returns The emitter
59
- */
60
- off(e, n) {
61
- return this.#e[e] && (this.#e[e] = this.#e[e].filter((t) => t !== n)), this;
62
- }
63
- /**
64
- * Alias for `off`
65
- */
66
- removeListener(e, n) {
67
- return this.off(e, n);
68
- }
69
- /**
70
- * Remove all event listeners
71
- * @param event The event name
72
- * @returns The emitter
73
- */
74
- removeAllListeners(e) {
75
- return e ? delete this.#e[e] : this.#e = {}, this;
76
- }
77
- /**
78
- * Get the list of event names
79
- * @returns An array of event names
80
- */
81
- eventNames() {
82
- return Reflect.ownKeys(this.#e);
83
- }
84
- /**
85
- * Get the list of listeners for an event
86
- * @param event The event name
87
- * @returns An array of listeners
88
- */
89
- listeners(e) {
90
- return this.#e[e] ?? [];
91
- }
92
- /**
93
- * Get the number of listeners for an event
94
- * @param event The event name
95
- * @returns The number of listeners for the event
96
- */
97
- listenerCount(e) {
98
- return this.#e[e]?.length ?? 0;
99
- }
100
- }
101
- class a extends l {
102
13
  constructor() {
103
- super();
104
- const { history: e, location: n } = window, { pushState: t, replaceState: r } = e;
105
- e.pushState = (...s) => {
106
- t.apply(e, s), this.emit("pushState", n, s[0]);
107
- }, e.replaceState = (...s) => {
108
- r.apply(e, s), this.emit("replaceState", n, s[0]);
109
- }, window.addEventListener("popstate", (s) => {
110
- this.emit("popState", n, s);
14
+ const { history: e, location: t } = window, { pushState: n, replaceState: c } = e;
15
+ e.pushState = (...o) => {
16
+ n.apply(e, o), this.#e?.pushState(t, o[0]);
17
+ }, e.replaceState = (...o) => {
18
+ c.apply(e, o), this.#e?.replaceState(t, o[0]);
19
+ }, window.addEventListener("popstate", (o) => {
20
+ this.#e?.popState(t, o);
111
21
  });
112
22
  }
23
+ on(e, t) {
24
+ return this.#e[e] = t, () => this.off(e);
25
+ }
26
+ off(e) {
27
+ delete this.#e[e];
28
+ }
113
29
  }
114
- function u(o, e, n) {
115
- const t = new MutationObserver((r, s) => {
116
- for (const c of r)
117
- e(c, s);
30
+ function p(s, e, t) {
31
+ const n = new MutationObserver((c, o) => {
32
+ for (const i of c)
33
+ e(i, o);
118
34
  });
119
- return t.observe(o, {
35
+ return n.observe(s, {
120
36
  childList: !0,
121
37
  subtree: !0,
122
- ...n
123
- }), () => t.disconnect();
38
+ ...t
39
+ }), () => n.disconnect();
124
40
  }
125
- function f(o, e = document.documentElement) {
126
- return new Promise((n) => {
127
- u(e, (t, r) => {
128
- const s = e.querySelector(o);
129
- s && (r.disconnect(), n(s));
41
+ function f(s, e = document.documentElement) {
42
+ return new Promise((t) => {
43
+ p(e, (n, c) => {
44
+ const o = e.querySelector(s);
45
+ o && (c.disconnect(), t(o));
130
46
  });
131
47
  });
132
48
  }
133
49
  export {
134
- a as LocationObserver,
135
- h as el,
136
- p as nbsp,
137
- u as observeElement,
138
- i as text,
50
+ u as LocationObserver,
51
+ a as el,
52
+ l as nbsp,
53
+ p as observeElement,
54
+ r as text,
139
55
  f as waitElement
140
56
  };
141
57
  //# sourceMappingURL=index.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.es.js","sources":["../src/html.ts","../../emitter/dist/index.es.js","../src/location-observer.ts","../src/mutation-observers.ts"],"sourcesContent":["// prettier-ignore\ntype Attributes<T extends keyof HTMLElementTagNameMap> = Partial<{\n style: Partial<CSSStyleDeclaration>\n} & Omit<HTMLElementTagNameMap[T], 'style'>>\n\ntype Children = (string | Node | HTMLElement)[]\n\n/**\n * Create an element\n * @param tag The tag name of the element to create\n * @param attributes The attributes or children to set on the element\n * @param children The children to append to the element\n * @returns The created element\n * @example\n * el('div', { id: 'foo' }, 'Hello world')\n * el('div', 'Hello world')\n * el('div', [el('span', 'Hello'), el('span', 'world')])\n * el('div', el('span', 'Hello world'))\n * el('div', el('span', 'Hello'), el('span', 'world'))\n * el('div', el('span', 'Hello world'), 'world')\n */\nexport function el<T extends keyof HTMLElementTagNameMap>(\n tag: T,\n attributes?: Attributes<T> | Children,\n ...children: Children\n): HTMLElementTagNameMap[T] {\n const el = document.createElement(tag)\n\n if (typeof attributes === 'string') {\n el.append(text(attributes))\n } else if (Array.isArray(attributes)) {\n el.append(...attributes)\n } else {\n Object.assign(el, attributes)\n Object.assign(el.style, attributes?.style)\n }\n\n if (children.length) {\n el.append(...children)\n }\n\n return el\n}\n\n/**\n * Create a text node\n * @param text The string to create a text node from\n */\nexport function text(text: string): Text {\n return document.createTextNode(text)\n}\n\n/**\n * A non-breaking space\n */\nexport function nbsp(): Text {\n return text('\\u00a0')\n}\n","class n {\n #t = {};\n /**\n * Add an event listener\n * @param event The event name\n * @param listener The listener function\n * @returns The emitter\n */\n on(t, e) {\n const s = this.#t[t] ?? [];\n return this.#t[t] = s, s.push(e), this;\n }\n /**\n * Alias for `addListener`\n */\n addListener(t, e) {\n return this.on(t, e);\n }\n /**\n * Add an event listener that will be called only once\n * @note The listener is wrapped in a wrapper function, so it cannot be equal to the original listener\n * @param event The event name\n * @param listener The listener function\n * @returns The emitter\n */\n once(t, e) {\n const s = (...r) => {\n this.off(t, s), e(...r);\n };\n return this.on(t, s), this;\n }\n /**\n * Emit an event\n * @param event The event name\n * @param args The arguments to pass to the listeners\n * @returns `true` if the event had listeners, `false` otherwise\n */\n emit(t, ...e) {\n const s = this.#t[t] ?? [];\n for (let r = 0; r < s.length; r++)\n s[r](...e);\n return !!s.length;\n }\n /**\n * Remove an event listener\n * @param event The event name\n * @param listener The listener function\n * @returns The emitter\n */\n off(t, e) {\n return this.#t[t] && (this.#t[t] = this.#t[t].filter((s) => s !== e)), this;\n }\n /**\n * Alias for `off`\n */\n removeListener(t, e) {\n return this.off(t, e);\n }\n /**\n * Remove all event listeners\n * @param event The event name\n * @returns The emitter\n */\n removeAllListeners(t) {\n return t ? delete this.#t[t] : this.#t = {}, this;\n }\n /**\n * Get the list of event names\n * @returns An array of event names\n */\n eventNames() {\n return Reflect.ownKeys(this.#t);\n }\n /**\n * Get the list of listeners for an event\n * @param event The event name\n * @returns An array of listeners\n */\n listeners(t) {\n return this.#t[t] ?? [];\n }\n /**\n * Get the number of listeners for an event\n * @param event The event name\n * @returns The number of listeners for the event\n */\n listenerCount(t) {\n return this.#t[t]?.length ?? 0;\n }\n}\nexport {\n n as Emitter\n};\n//# sourceMappingURL=index.es.js.map\n","import { Emitter } from '@zero-dependency/emitter'\n\ntype LocationCallback<T = any> = (location: Location, args: T) => void\n\ntype Events<T> = {\n pushState: LocationCallback<T>\n replaceState: LocationCallback<T>\n popState: LocationCallback<\n Omit<PopStateEvent, 'state'> & { readonly state: T }\n >\n}\n\n/**\n * Observe changes to the location\n * @example\n * const observer = new LocationObserver<{ id: string }>()\n * observer.on('pushState', (location, state) => {\n * console.log(state.id)\n * })\n */\nexport class LocationObserver<T> extends Emitter<Events<T>> {\n constructor() {\n super()\n\n const { history, location } = window\n const { pushState, replaceState } = history\n\n history.pushState = (...args) => {\n pushState.apply(history, args)\n this.emit('pushState', location, args[0])\n }\n\n history.replaceState = (...args) => {\n replaceState.apply(history, args)\n this.emit('replaceState', location, args[0])\n }\n\n window.addEventListener('popstate', (event) => {\n this.emit('popState', location, event)\n })\n }\n}\n","type Disconnect = () => void\n\n/**\n * Observe mutations on an element\n * @param el The element to observe\n * @param callback The callback to call when a mutation occurs\n * @param options The options to pass to the `MutationObserver`\n * @returns A function to disconnect the observer\n */\nexport function observeElement<T extends Element = Element>(\n el: T,\n callback: (mutation: MutationRecord, observer: MutationObserver) => void,\n options?: MutationObserverInit\n): Disconnect {\n const observe = new MutationObserver((mutations, observer) => {\n for (const mutation of mutations) {\n callback(mutation, observer)\n }\n })\n\n observe.observe(el, {\n childList: true,\n subtree: true,\n ...options\n })\n\n return () => observe.disconnect()\n}\n\n/**\n * Wait for an element to appear in the DOM\n * @param selector The selector to wait for\n * @param target The element to search in\n * @returns A promise that resolves when the element is found\n */\nexport function waitElement<T extends Element = Element>(\n selector: string,\n target = document.documentElement\n): Promise<T> {\n return new Promise((resolve) => {\n observeElement(target, (_, observer) => {\n const el = target.querySelector<T>(selector)\n if (el) {\n observer.disconnect()\n resolve(el)\n }\n })\n })\n}\n"],"names":["el","tag","attributes","children","text","nbsp","n","#t","t","e","s","LocationObserver","Emitter","history","location","pushState","replaceState","args","event","observeElement","callback","options","observe","mutations","observer","mutation","waitElement","selector","target","resolve","_"],"mappings":"AAqBgB,SAAAA,EACdC,GACAC,MACGC,GACuB;AACpBH,QAAAA,IAAK,SAAS,cAAcC,CAAG;AAEjC,SAAA,OAAOC,KAAe,WACxBF,EAAG,OAAOI,EAAKF,CAAU,CAAC,IACjB,MAAM,QAAQA,CAAU,IACjCF,EAAG,OAAO,GAAGE,CAAU,KAEhB,OAAA,OAAOF,GAAIE,CAAU,GAC5B,OAAO,OAAOF,EAAG,OAAOE,GAAY,KAAK,IAGvCC,EAAS,UACXH,EAAG,OAAO,GAAGG,CAAQ,GAGhBH;AACT;AAMO,SAASI,EAAKA,GAAoB;AAChC,SAAA,SAAS,eAAeA,CAAI;AACrC;AAKO,SAASC,IAAa;AAC3B,SAAOD,EAAK,GAAQ;AACtB;ACzDA,MAAME,EAAE;AAAA,EACNC,KAAK,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOL,GAAGC,GAAGC,GAAG;AACP,UAAMC,IAAI,KAAKH,GAAGC,CAAC,KAAK,CAAA;AACxB,WAAO,KAAKD,GAAGC,CAAC,IAAIE,GAAGA,EAAE,KAAKD,CAAC,GAAG;AAAA,EACnC;AAAA;AAAA;AAAA;AA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"index.es.js","sources":["../src/html.ts","../src/location-observer.ts","../src/mutation-observers.ts"],"sourcesContent":["// prettier-ignore\ntype Attributes<T extends keyof HTMLElementTagNameMap> = Partial<{\n style: Partial<CSSStyleDeclaration>\n} & Omit<HTMLElementTagNameMap[T], 'style'>>\n\ntype Children = (string | Node | HTMLElement)[]\n\n/**\n * Create an element\n * @param tag The tag name of the element to create\n * @param attributes The attributes or children to set on the element\n * @param children The children to append to the element\n * @returns The created element\n * @example\n * el('div', { id: 'foo' }, 'Hello world')\n * el('div', 'Hello world')\n * el('div', [el('span', 'Hello'), el('span', 'world')])\n * el('div', el('span', 'Hello world'))\n * el('div', el('span', 'Hello'), el('span', 'world'))\n * el('div', el('span', 'Hello world'), 'world')\n */\nexport function el<T extends keyof HTMLElementTagNameMap>(\n tag: T,\n attributes?: Attributes<T> | Children,\n ...children: Children\n): HTMLElementTagNameMap[T] {\n const el = document.createElement(tag)\n\n if (typeof attributes === 'string') {\n el.append(text(attributes))\n } else if (Array.isArray(attributes)) {\n el.append(...attributes)\n } else {\n Object.assign(el, attributes)\n Object.assign(el.style, attributes?.style)\n }\n\n if (children.length) {\n el.append(...children)\n }\n\n return el\n}\n\n/**\n * Create a text node\n * @param text The string to create a text node from\n */\nexport function text(text: string): Text {\n return document.createTextNode(text)\n}\n\n/**\n * A non-breaking space\n */\nexport function nbsp(): Text {\n return text('\\u00a0')\n}\n","type LocationCallback<T = any> = (location: Location, args: T) => void\n\ntype Events<T> = {\n pushState: LocationCallback<T>\n replaceState: LocationCallback<T>\n popState: LocationCallback<\n Omit<PopStateEvent, 'state'> & { readonly state: T }\n >\n}\n\n/**\n * Observe changes to the location\n * @example\n * const observer = new LocationObserver<{ id: string }>()\n * observer.on('pushState', (location, state) => {\n * console.log(state.id)\n * })\n */\nexport class LocationObserver<T> {\n #events = {} as Record<keyof Events<T>, LocationCallback<any>>\n\n constructor() {\n const { history, location } = window\n const { pushState, replaceState } = history\n\n history.pushState = (...args) => {\n pushState.apply(history, args)\n this.#events?.pushState(location, args[0])\n }\n\n history.replaceState = (...args) => {\n replaceState.apply(history, args)\n this.#events?.replaceState(location, args[0])\n }\n\n window.addEventListener('popstate', (event) => {\n this.#events?.popState(location, event)\n })\n }\n\n on<E extends keyof Events<T>>(event: E, listener: Events<T>[E]): () => void {\n this.#events[event] = listener\n return () => this.off(event)\n }\n\n off<E extends keyof Events<T>>(event: E): void {\n delete this.#events[event]\n }\n}\n","type Disconnect = () => void\n\n/**\n * Observe mutations on an element\n * @param el The element to observe\n * @param callback The callback to call when a mutation occurs\n * @param options The options to pass to the `MutationObserver`\n * @returns A function to disconnect the observer\n */\nexport function observeElement<T extends Element = Element>(\n el: T,\n callback: (mutation: MutationRecord, observer: MutationObserver) => void,\n options?: MutationObserverInit\n): Disconnect {\n const observe = new MutationObserver((mutations, observer) => {\n for (const mutation of mutations) {\n callback(mutation, observer)\n }\n })\n\n observe.observe(el, {\n childList: true,\n subtree: true,\n ...options\n })\n\n return () => observe.disconnect()\n}\n\n/**\n * Wait for an element to appear in the DOM\n * @param selector The selector to wait for\n * @param target The element to search in\n * @returns A promise that resolves when the element is found\n */\nexport function waitElement<T extends Element = Element>(\n selector: string,\n target = document.documentElement\n): Promise<T> {\n return new Promise((resolve) => {\n observeElement(target, (_, observer) => {\n const el = target.querySelector<T>(selector)\n if (el) {\n observer.disconnect()\n resolve(el)\n }\n })\n })\n}\n"],"names":["el","tag","attributes","children","text","nbsp","LocationObserver","#events","history","location","pushState","replaceState","args","event","listener","observeElement","callback","options","observe","mutations","observer","mutation","waitElement","selector","target","resolve","_"],"mappings":"AAqBgB,SAAAA,EACdC,GACAC,MACGC,GACuB;AACpBH,QAAAA,IAAK,SAAS,cAAcC,CAAG;AAEjC,SAAA,OAAOC,KAAe,WACxBF,EAAG,OAAOI,EAAKF,CAAU,CAAC,IACjB,MAAM,QAAQA,CAAU,IACjCF,EAAG,OAAO,GAAGE,CAAU,KAEhB,OAAA,OAAOF,GAAIE,CAAU,GAC5B,OAAO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AAQ;AACvB;AAQO,SAASI,EACdC,GACAC,IAAS,SAAS,iBACN;AACL,SAAA,IAAI,QAAQ,CAACC,MAAY;AACf,IAAAV,EAAAS,GAAQ,CAACE,GAAGN,MAAa;AAChC,YAAApB,IAAKwB,EAAO,cAAiBD,CAAQ;AAC3C,MAAIvB,MACFoB,EAAS,WAAW,GACpBK,EAAQzB,CAAE;AAAA,IACZ,CACD;AAAA,EAAA,CACF;AACH;"}
package/dist/index.umd.js CHANGED
@@ -1,2 +1,2 @@
1
- (function(i,c){typeof exports=="object"&&typeof module<"u"?c(exports):typeof define=="function"&&define.amd?define(["exports"],c):(i=typeof globalThis<"u"?globalThis:i||self,c(i["@zero-dependency/dom"]={}))})(this,function(i){"use strict";function c(r,e,...n){const t=document.createElement(r);return typeof e=="string"?t.append(u(e)):Array.isArray(e)?t.append(...e):(Object.assign(t,e),Object.assign(t.style,e?.style)),n.length&&t.append(...n),t}function u(r){return document.createTextNode(r)}function h(){return u(" ")}class f{#e={};on(e,n){const t=this.#e[e]??[];return this.#e[e]=t,t.push(n),this}addListener(e,n){return this.on(e,n)}once(e,n){const t=(...o)=>{this.off(e,t),n(...o)};return this.on(e,t),this}emit(e,...n){const t=this.#e[e]??[];for(let o=0;o<t.length;o++)t[o](...n);return!!t.length}off(e,n){return this.#e[e]&&(this.#e[e]=this.#e[e].filter(t=>t!==n)),this}removeListener(e,n){return this.off(e,n)}removeAllListeners(e){return e?delete this.#e[e]:this.#e={},this}eventNames(){return Reflect.ownKeys(this.#e)}listeners(e){return this.#e[e]??[]}listenerCount(e){return this.#e[e]?.length??0}}class d extends f{constructor(){super();const{history:e,location:n}=window,{pushState:t,replaceState:o}=e;e.pushState=(...s)=>{t.apply(e,s),this.emit("pushState",n,s[0])},e.replaceState=(...s)=>{o.apply(e,s),this.emit("replaceState",n,s[0])},window.addEventListener("popstate",s=>{this.emit("popState",n,s)})}}function l(r,e,n){const t=new MutationObserver((o,s)=>{for(const a of o)e(a,s)});return t.observe(r,{childList:!0,subtree:!0,...n}),()=>t.disconnect()}function p(r,e=document.documentElement){return new Promise(n=>{l(e,(t,o)=>{const s=e.querySelector(r);s&&(o.disconnect(),n(s))})})}i.LocationObserver=d,i.el=c,i.nbsp=h,i.observeElement=l,i.text=u,i.waitElement=p,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
1
+ (function(i,c){typeof exports=="object"&&typeof module<"u"?c(exports):typeof define=="function"&&define.amd?define(["exports"],c):(i=typeof globalThis<"u"?globalThis:i||self,c(i["@zero-dependency/dom"]={}))})(this,function(i){"use strict";function c(s,e,...t){const n=document.createElement(s);return typeof e=="string"?n.append(d(e)):Array.isArray(e)?n.append(...e):(Object.assign(n,e),Object.assign(n.style,e?.style)),t.length&&n.append(...t),n}function d(s){return document.createTextNode(s)}function u(){return d(" ")}class f{#e={};constructor(){const{history:e,location:t}=window,{pushState:n,replaceState:r}=e;e.pushState=(...o)=>{n.apply(e,o),this.#e?.pushState(t,o[0])},e.replaceState=(...o)=>{r.apply(e,o),this.#e?.replaceState(t,o[0])},window.addEventListener("popstate",o=>{this.#e?.popState(t,o)})}on(e,t){return this.#e[e]=t,()=>this.off(e)}off(e){delete this.#e[e]}}function l(s,e,t){const n=new MutationObserver((r,o)=>{for(const a of r)e(a,o)});return n.observe(s,{childList:!0,subtree:!0,...t}),()=>n.disconnect()}function p(s,e=document.documentElement){return new Promise(t=>{l(e,(n,r)=>{const o=e.querySelector(s);o&&(r.disconnect(),t(o))})})}i.LocationObserver=f,i.el=c,i.nbsp=u,i.observeElement=l,i.text=d,i.waitElement=p,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
2
2
  //# sourceMappingURL=index.umd.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.umd.js","sources":["../src/html.ts","../../emitter/dist/index.es.js","../src/location-observer.ts","../src/mutation-observers.ts"],"sourcesContent":["// prettier-ignore\ntype Attributes<T extends keyof HTMLElementTagNameMap> = Partial<{\n style: Partial<CSSStyleDeclaration>\n} & Omit<HTMLElementTagNameMap[T], 'style'>>\n\ntype Children = (string | Node | HTMLElement)[]\n\n/**\n * Create an element\n * @param tag The tag name of the element to create\n * @param attributes The attributes or children to set on the element\n * @param children The children to append to the element\n * @returns The created element\n * @example\n * el('div', { id: 'foo' }, 'Hello world')\n * el('div', 'Hello world')\n * el('div', [el('span', 'Hello'), el('span', 'world')])\n * el('div', el('span', 'Hello world'))\n * el('div', el('span', 'Hello'), el('span', 'world'))\n * el('div', el('span', 'Hello world'), 'world')\n */\nexport function el<T extends keyof HTMLElementTagNameMap>(\n tag: T,\n attributes?: Attributes<T> | Children,\n ...children: Children\n): HTMLElementTagNameMap[T] {\n const el = document.createElement(tag)\n\n if (typeof attributes === 'string') {\n el.append(text(attributes))\n } else if (Array.isArray(attributes)) {\n el.append(...attributes)\n } else {\n Object.assign(el, attributes)\n Object.assign(el.style, attributes?.style)\n }\n\n if (children.length) {\n el.append(...children)\n }\n\n return el\n}\n\n/**\n * Create a text node\n * @param text The string to create a text node from\n */\nexport function text(text: string): Text {\n return document.createTextNode(text)\n}\n\n/**\n * A non-breaking space\n */\nexport function nbsp(): Text {\n return text('\\u00a0')\n}\n","class n {\n #t = {};\n /**\n * Add an event listener\n * @param event The event name\n * @param listener The listener function\n * @returns The emitter\n */\n on(t, e) {\n const s = this.#t[t] ?? [];\n return this.#t[t] = s, s.push(e), this;\n }\n /**\n * Alias for `addListener`\n */\n addListener(t, e) {\n return this.on(t, e);\n }\n /**\n * Add an event listener that will be called only once\n * @note The listener is wrapped in a wrapper function, so it cannot be equal to the original listener\n * @param event The event name\n * @param listener The listener function\n * @returns The emitter\n */\n once(t, e) {\n const s = (...r) => {\n this.off(t, s), e(...r);\n };\n return this.on(t, s), this;\n }\n /**\n * Emit an event\n * @param event The event name\n * @param args The arguments to pass to the listeners\n * @returns `true` if the event had listeners, `false` otherwise\n */\n emit(t, ...e) {\n const s = this.#t[t] ?? [];\n for (let r = 0; r < s.length; r++)\n s[r](...e);\n return !!s.length;\n }\n /**\n * Remove an event listener\n * @param event The event name\n * @param listener The listener function\n * @returns The emitter\n */\n off(t, e) {\n return this.#t[t] && (this.#t[t] = this.#t[t].filter((s) => s !== e)), this;\n }\n /**\n * Alias for `off`\n */\n removeListener(t, e) {\n return this.off(t, e);\n }\n /**\n * Remove all event listeners\n * @param event The event name\n * @returns The emitter\n */\n removeAllListeners(t) {\n return t ? delete this.#t[t] : this.#t = {}, this;\n }\n /**\n * Get the list of event names\n * @returns An array of event names\n */\n eventNames() {\n return Reflect.ownKeys(this.#t);\n }\n /**\n * Get the list of listeners for an event\n * @param event The event name\n * @returns An array of listeners\n */\n listeners(t) {\n return this.#t[t] ?? [];\n }\n /**\n * Get the number of listeners for an event\n * @param event The event name\n * @returns The number of listeners for the event\n */\n listenerCount(t) {\n return this.#t[t]?.length ?? 0;\n }\n}\nexport {\n n as Emitter\n};\n//# sourceMappingURL=index.es.js.map\n","import { Emitter } from '@zero-dependency/emitter'\n\ntype LocationCallback<T = any> = (location: Location, args: T) => void\n\ntype Events<T> = {\n pushState: LocationCallback<T>\n replaceState: LocationCallback<T>\n popState: LocationCallback<\n Omit<PopStateEvent, 'state'> & { readonly state: T }\n >\n}\n\n/**\n * Observe changes to the location\n * @example\n * const observer = new LocationObserver<{ id: string }>()\n * observer.on('pushState', (location, state) => {\n * console.log(state.id)\n * })\n */\nexport class LocationObserver<T> extends Emitter<Events<T>> {\n constructor() {\n super()\n\n const { history, location } = window\n const { pushState, replaceState } = history\n\n history.pushState = (...args) => {\n pushState.apply(history, args)\n this.emit('pushState', location, args[0])\n }\n\n history.replaceState = (...args) => {\n replaceState.apply(history, args)\n this.emit('replaceState', location, args[0])\n }\n\n window.addEventListener('popstate', (event) => {\n this.emit('popState', location, event)\n })\n }\n}\n","type Disconnect = () => void\n\n/**\n * Observe mutations on an element\n * @param el The element to observe\n * @param callback The callback to call when a mutation occurs\n * @param options The options to pass to the `MutationObserver`\n * @returns A function to disconnect the observer\n */\nexport function observeElement<T extends Element = Element>(\n el: T,\n callback: (mutation: MutationRecord, observer: MutationObserver) => void,\n options?: MutationObserverInit\n): Disconnect {\n const observe = new MutationObserver((mutations, observer) => {\n for (const mutation of mutations) {\n callback(mutation, observer)\n }\n })\n\n observe.observe(el, {\n childList: true,\n subtree: true,\n ...options\n })\n\n return () => observe.disconnect()\n}\n\n/**\n * Wait for an element to appear in the DOM\n * @param selector The selector to wait for\n * @param target The element to search in\n * @returns A promise that resolves when the element is found\n */\nexport function waitElement<T extends Element = Element>(\n selector: string,\n target = document.documentElement\n): Promise<T> {\n return new Promise((resolve) => {\n observeElement(target, (_, observer) => {\n const el = target.querySelector<T>(selector)\n if (el) {\n observer.disconnect()\n resolve(el)\n }\n })\n })\n}\n"],"names":["el","tag","attributes","children","text","nbsp","n","#t","t","e","s","r","LocationObserver","Emitter","history","location","pushState","replaceState","args","event","observeElement","callback","options","observe","mutations","observer","mutation","waitElement","selector","target","resolve","_"],"mappings":"+OAqBgB,SAAAA,EACdC,EACAC,KACGC,EACuB,CACpBH,MAAAA,EAAK,SAAS,cAAcC,CAAG,EAEjC,OAAA,OAAOC,GAAe,SACxBF,EAAG,OAAOI,EAAKF,CAAU,CAAC,EACjB,MAAM,QAAQA,CAAU,EACjCF,EAAG,OAAO,GAAGE,CAAU,GAEhB,OAAA,OAAOF,EAAIE,CAAU,EAC5B,OAAO,OAAOF,EAAG,MAAOE,GAAY,KAAK,GAGvCC,EAAS,QACXH,EAAG,OAAO,GAAGG,CAAQ,EAGhBH,CACT,CAMO,SAASI,EAAKA,EAAoB,CAChC,OAAA,SAAS,eAAeA,CAAI,CACrC,CAKO,SAASC,GAAa,CAC3B,OAAOD,EAAK,GAAQ,CACtB,CCzDA,MAAME,CAAE,CACNC,GAAK,CAAA,EAOL,GAAGC,EAAGC,EAAG,CACP,MAAMC,EAAI,KAAKH,GAAGC,CAAC,GAAK,CAAA,EACxB,OAAO,KAAKD,GAAGC,CAAC,EAAIE,EAAGA,EAAE,KAAKD,CAAC,EAAG,I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C,CAAC,CAAA,EAGlCJ,EAAA,aAAe,IAAII,IAAS,CACrBD,EAAA,MAAMH,EAASI,CAAI,EAChC,KAAK,KAAK,eAAgBH,EAAUG,EAAK,CAAC,CAAC,CAAA,EAGtC,OAAA,iBAAiB,WAAaC,GAAU,CACxC,KAAA,KAAK,WAAYJ,EAAUI,CAAK,CAAA,CACtC,CACH,CACF,CChCgB,SAAAC,EACdpB,EACAqB,EACAC,EACY,CACZ,MAAMC,EAAU,IAAI,iBAAiB,CAACC,EAAWC,IAAa,CAC5D,UAAWC,KAAYF,EACrBH,EAASK,EAAUD,CAAQ,CAC7B,CACD,EAED,OAAAF,EAAQ,QAAQvB,EAAI,CAClB,UAAW,GACX,QAAS,GACT,GAAGsB,CAAA,CACJ,EAEM,IAAMC,EAAQ,YACvB,CAQO,SAASI,EACdC,EACAC,EAAS,SAAS,gBACN,CACL,OAAA,IAAI,QAASC,GAAY,CACfV,EAAAS,EAAQ,CAACE,EAAGN,IAAa,CAChC,MAAAzB,EAAK6B,EAAO,cAAiBD,CAAQ,EACvC5B,IACFyB,EAAS,WAAW,EACpBK,EAAQ9B,CAAE,EACZ,CACD,CAAA,CACF,CACH"}
1
+ {"version":3,"file":"index.umd.js","sources":["../src/html.ts","../src/location-observer.ts","../src/mutation-observers.ts"],"sourcesContent":["// prettier-ignore\ntype Attributes<T extends keyof HTMLElementTagNameMap> = Partial<{\n style: Partial<CSSStyleDeclaration>\n} & Omit<HTMLElementTagNameMap[T], 'style'>>\n\ntype Children = (string | Node | HTMLElement)[]\n\n/**\n * Create an element\n * @param tag The tag name of the element to create\n * @param attributes The attributes or children to set on the element\n * @param children The children to append to the element\n * @returns The created element\n * @example\n * el('div', { id: 'foo' }, 'Hello world')\n * el('div', 'Hello world')\n * el('div', [el('span', 'Hello'), el('span', 'world')])\n * el('div', el('span', 'Hello world'))\n * el('div', el('span', 'Hello'), el('span', 'world'))\n * el('div', el('span', 'Hello world'), 'world')\n */\nexport function el<T extends keyof HTMLElementTagNameMap>(\n tag: T,\n attributes?: Attributes<T> | Children,\n ...children: Children\n): HTMLElementTagNameMap[T] {\n const el = document.createElement(tag)\n\n if (typeof attributes === 'string') {\n el.append(text(attributes))\n } else if (Array.isArray(attributes)) {\n el.append(...attributes)\n } else {\n Object.assign(el, attributes)\n Object.assign(el.style, attributes?.style)\n }\n\n if (children.length) {\n el.append(...children)\n }\n\n return el\n}\n\n/**\n * Create a text node\n * @param text The string to create a text node from\n */\nexport function text(text: string): Text {\n return document.createTextNode(text)\n}\n\n/**\n * A non-breaking space\n */\nexport function nbsp(): Text {\n return text('\\u00a0')\n}\n","type LocationCallback<T = any> = (location: Location, args: T) => void\n\ntype Events<T> = {\n pushState: LocationCallback<T>\n replaceState: LocationCallback<T>\n popState: LocationCallback<\n Omit<PopStateEvent, 'state'> & { readonly state: T }\n >\n}\n\n/**\n * Observe changes to the location\n * @example\n * const observer = new LocationObserver<{ id: string }>()\n * observer.on('pushState', (location, state) => {\n * console.log(state.id)\n * })\n */\nexport class LocationObserver<T> {\n #events = {} as Record<keyof Events<T>, LocationCallback<any>>\n\n constructor() {\n const { history, location } = window\n const { pushState, replaceState } = history\n\n history.pushState = (...args) => {\n pushState.apply(history, args)\n this.#events?.pushState(location, args[0])\n }\n\n history.replaceState = (...args) => {\n replaceState.apply(history, args)\n this.#events?.replaceState(location, args[0])\n }\n\n window.addEventListener('popstate', (event) => {\n this.#events?.popState(location, event)\n })\n }\n\n on<E extends keyof Events<T>>(event: E, listener: Events<T>[E]): () => void {\n this.#events[event] = listener\n return () => this.off(event)\n }\n\n off<E extends keyof Events<T>>(event: E): void {\n delete this.#events[event]\n }\n}\n","type Disconnect = () => void\n\n/**\n * Observe mutations on an element\n * @param el The element to observe\n * @param callback The callback to call when a mutation occurs\n * @param options The options to pass to the `MutationObserver`\n * @returns A function to disconnect the observer\n */\nexport function observeElement<T extends Element = Element>(\n el: T,\n callback: (mutation: MutationRecord, observer: MutationObserver) => void,\n options?: MutationObserverInit\n): Disconnect {\n const observe = new MutationObserver((mutations, observer) => {\n for (const mutation of mutations) {\n callback(mutation, observer)\n }\n })\n\n observe.observe(el, {\n childList: true,\n subtree: true,\n ...options\n })\n\n return () => observe.disconnect()\n}\n\n/**\n * Wait for an element to appear in the DOM\n * @param selector The selector to wait for\n * @param target The element to search in\n * @returns A promise that resolves when the element is found\n */\nexport function waitElement<T extends Element = Element>(\n selector: string,\n target = document.documentElement\n): Promise<T> {\n return new Promise((resolve) => {\n observeElement(target, (_, observer) => {\n const el = target.querySelector<T>(selector)\n if (el) {\n observer.disconnect()\n resolve(el)\n }\n })\n })\n}\n"],"names":["el","tag","attributes","children","text","nbsp","LocationObserver","#events","history","location","pushState","replaceState","args","event","listener","observeElement","callback","options","observe","mutations","observer","mutation","waitElement","selector","target","resolve","_"],"mappings":"+OAqBgB,SAAAA,EACdC,EACAC,KACGC,EACuB,CACpBH,MAAAA,EAAK,SAAS,cAAcC,CAAG,EAEjC,OAAA,OAAOC,GAAe,SACxBF,EAAG,OAAOI,EAAKF,CAAU,CAAC,EACjB,MAAM,QAAQA,CAAU,EACjCF,EAAG,OAAO,GAAGE,CAAU,GAEhB,OAAA,OAAOF,EAAIE,CAAU,EAC5B,OAAO,OAAOF,EAAG,MAAOE,GAAY,KAAK,GAGvCC,EAAS,QACXH,EAAG,OAAO,GAAGG,CAAQ,EAGhBH,CACT,CAMO,SAASI,EAAKA,EAAoB,CAChC,OAAA,SAAS,eAAeA,CAAI,CACrC,CAKO,SAASC,GAAa,CAC3B,OAAOD,EAAK,GAAQ,CACtB,CCvCO,MAAME,CAAoB,CAC/BC,GAAU,CAAA,EAEV,aAAc,CACN,KAAA,CAAE,QAAAC,EAAS,SAAAC,CAAa,EAAA,OACxB,CAAE,UAAAC,EAAW,aAAAC,CAAiB,EAAAH,EAE5BA,EAAA,UAAY,IAAII,IAAS,CACrBF,EAAA,MAAMF,EAASI,CAAI,EAC7B,KAAKL,IAAS,UAAUE,EAAUG,EAAK,CAAC,CAAC,CAAA,EAGnCJ,EAAA,aAAe,IAAII,IAAS,CACrBD,EAAA,MAAMH,EAASI,CAAI,EAChC,KAAKL,IAAS,aAAaE,EAAUG,EAAK,CAAC,CAAC,CAAA,EAGvC,OAAA,iBAAiB,WAAaC,GAAU,CACxC,KAAAN,IAAS,SAASE,EAAUI,CAAK,CAAA,CACvC,CACH,CAEA,GAA8BA,EAAUC,EAAoC,CACrE,YAAAP,GAAQM,CAAK,EAAIC,EACf,IAAM,KAAK,IAAID,CAAK,CAC7B,CAEA,IAA+BA,EAAgB,CACtC,OAAA,KAAKN,GAAQM,CAAK,CAC3B,CACF,CCvCgB,SAAAE,EACdf,EACAgB,EACAC,EACY,CACZ,MAAMC,EAAU,IAAI,iBAAiB,CAACC,EAAWC,IAAa,CAC5D,UAAWC,KAAYF,EACrBH,EAASK,EAAUD,CAAQ,CAC7B,CACD,EAED,OAAAF,EAAQ,QAAQlB,EAAI,CAClB,UAAW,GACX,QAAS,GACT,GAAGiB,CAAA,CACJ,EAEM,IAAMC,EAAQ,YACvB,CAQO,SAASI,EACdC,EACAC,EAAS,SAAS,gBACN,CACL,OAAA,IAAI,QAASC,GAAY,CACfV,EAAAS,EAAQ,CAACE,EAAGN,IAAa,CAChC,MAAApB,EAAKwB,EAAO,cAAiBD,CAAQ,EACvCvB,IACFoB,EAAS,WAAW,EACpBK,EAAQzB,CAAE,EACZ,CACD,CAAA,CACF,CACH"}
@@ -1,4 +1,3 @@
1
- import { Emitter } from '@zero-dependency/emitter';
2
1
  type LocationCallback<T = any> = (location: Location, args: T) => void;
3
2
  type Events<T> = {
4
3
  pushState: LocationCallback<T>;
@@ -15,7 +14,10 @@ type Events<T> = {
15
14
  * console.log(state.id)
16
15
  * })
17
16
  */
18
- export declare class LocationObserver<T> extends Emitter<Events<T>> {
17
+ export declare class LocationObserver<T> {
18
+ #private;
19
19
  constructor();
20
+ on<E extends keyof Events<T>>(event: E, listener: Events<T>[E]): () => void;
21
+ off<E extends keyof Events<T>>(event: E): void;
20
22
  }
21
23
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zero-dependency/dom",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "type": "module",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./dist/index.umd.js",
@@ -33,9 +33,6 @@
33
33
  "vite-plugin-dts": "^2.1.0",
34
34
  "vitest": "^0.29.8"
35
35
  },
36
- "dependencies": {
37
- "@zero-dependency/emitter": "1.1.5"
38
- },
39
36
  "scripts": {
40
37
  "dev": "vite build --watch",
41
38
  "build": "vite build",