@adartem/adlib-attributes 0.0.0 → 0.1.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/attributes.js CHANGED
@@ -1,2 +1,2 @@
1
- function N(e){return e.startsWith("ad-")&&e.length>3}function I(e){return e.startsWith("data-")?e.slice(5):e}function V(e){return typeof e!="object"||e===null?!1:typeof e.querySelectorAll=="function"}function j(e=document){if(!V(e))return[];let t=new Set,r=e.querySelectorAll("*");for(let i of Array.from(r))for(let s of Array.from(i.attributes)){let a=I(s.name);N(a)&&t.add(a)}return Array.from(t)}function k(){return typeof window<"u"&&typeof document<"u"}function z(e=!1){return{debug:(...t)=>{e&&console.warn("[debug]",...t)},warn:(...t)=>{console.warn("[warn]",...t)},error:(...t)=>{console.error("[error]",...t)}}}function B(e){return typeof Element<"u"&&e instanceof Element}function U(e,t){try{return e.matches(t)}catch{return!1}}function Y(e,t){let r=e;for(;r;){if(B(r)&&U(r,t))return r;r=B(r)?r.parentElement:null}return null}function W(e){return t=>{let r=e.entries.slice();for(let i of r){let s=Y(t.target,i.selector);if(s&&(i.handler(t,s),i.once)){let a=e.entries.indexOf(i);a>=0&&e.entries.splice(a,1)}}}}function J(e){return e instanceof Document?e.documentElement??e:e}function x(e={}){let t=e.root??document,r=z(!!e.debug),i=new Map,s=new Map,a=new Map;function g(u,l,o,n={}){let c=!!n.capture,f=!!n.passive,m=a.get(u);if(m)return m.entries.push({selector:l,handler:o,once:!!n.once}),()=>{let v=m.entries.findIndex(S=>S.selector===l&&S.handler===o);v>=0&&m.entries.splice(v,1),m.entries.length===0&&(t.removeEventListener(u,m.listener,{capture:m.capture}),a.delete(u))};let w={capture:c,passive:f,entries:[{selector:l,handler:o,once:!!n.once}],listener:()=>{}},_=W(w);return w.listener=_,a.set(u,w),t.addEventListener(u,_,{capture:c,passive:f}),()=>{let v=a.get(u);if(!v)return;let S=v.entries.findIndex(q=>q.selector===l&&q.handler===o);S>=0&&v.entries.splice(S,1),v.entries.length===0&&(t.removeEventListener(u,v.listener,{capture:v.capture}),a.delete(u))}}function d(u,l,o){let n=new CustomEvent(l,{detail:o,bubbles:!0});u.dispatchEvent(n)}function y(u){i.set(u.key,u)}function p(u){i.delete(u)}function M(u,l){let o=i.get(u);if(!o||s.has(u))return;let n=o.init(O);s.set(u,n)}function A(u){let l=s.get(u);l&&(l.destroy(),s.delete(u))}function h(u){for(let l of i.keys())M(l)}function R(){for(let u of s.keys())A(u)}let b=null;function D(u=t){return b?()=>{}:(b=new MutationObserver(l=>{}),b.observe(J(u),{subtree:!0,childList:!0,attributes:!1}),()=>E())}function E(){b&&(b.disconnect(),b=null)}function C(){E(),R();for(let[u,l]of a.entries())t.removeEventListener(u,l.listener,{capture:l.capture});a.clear(),i.clear(),s.clear()}function K(){return r}let O={on:g,emit:d,register:y,unregister:p,mount:M,unmount:A,mountAll:h,unmountAll:R,observe:D,stopObserving:E,destroy:C,getLogger:K};return O}var L=null;function $(e={}){return L||(L=x({autoMount:!0,...e}),(e.autoMount??!0)&&typeof document<"u"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>{L?.mountAll()},{once:!0}):L.mountAll()),L)}function X(e){return e.trim().replace(/\/+$/,"")}function Z(e){return X(e.base??e.registry)}function ee(e){return(e.version??"").trim()||"latest"}function te(e,t,r){return`${e}/@adartem/${t}@${r}/dist/index.js`}var ne={"ad-click":"ad-click"};function T(e,t){let r=Z(t),i=ee(t),s=ne[e];return s?te(r,s,i):null}var re="https://cdn.jsdelivr.net/npm";function oe(e,t){return e[t]??(e[t]={key:t,status:"idle"})}function ie(e){return e.status==="ready"||e.status==="error"}function se(e){return e instanceof Error?e:new Error(String(e))}function H(e){let t=(e??"").trim();if(t)return t.replace(/\/+$/,"")}function ue(e){let t=H(e.config?.registry)??re,r=(e.config?.version??e.version).trim()||e.version,i={registry:t,version:r},s=H(e.config?.base);return s&&(i.base=s),i}function ce(e,t){let r=e&&typeof e=="object"?e.default??e:e;if(!r||typeof r!="object")throw new Error(`Invalid module definition for ${t}`);let i=r;if(typeof i.key!="string"||typeof i.init!="function")throw new Error(`Invalid module definition for ${t}`);if(i.key!==t)throw new Error(`Module key mismatch: expected "${t}", got "${i.key}"`);return i}function Q(e){let t=e.debug??!1,r=e.auto??!1,i=e.core==null,s=e.core??x({debug:t,autoMount:!1}),a=s.getLogger(),g=ue(e),d={},y=[],p=null;function M(...o){t&&a.debug("[AdLib Runtime]",...o)}function A(...o){a.error("[AdLib Runtime]",...o)}function h(o,n){for(let c=y.length-1;c>=0;c--){let f=y[c];if(f&&f.key===o){y.splice(c,1);try{f.cb(n)}catch(m){A("push callback failed",o,m)}}}}function R(o){let n=d[o];if(n){try{n.instance?.destroy?.()}catch(c){A("destroyModule failed",o,c)}delete n.instance,delete n.def,delete n.error,delete n.promise,n.status="idle"}}async function b(o){let n=oe(d,o);if(n.status==="ready"||n.status==="error")return n;if(n.status==="loading"&&n.promise)return n.promise;let c=T(o,g);if(!c)return n.status="error",n.error=new Error(`Unknown module key: ${o}`),h(o,n),n;n.status="loading",M("load()",o,"->",c);let f=(async()=>{try{let m=await import(c),w=ce(m,o);return n.def=w,n.instance||(n.instance=w.init(s)),n.status="ready",delete n.error,delete n.promise,h(o,n),n}catch(m){return n.status="error",n.error=se(m),delete n.promise,h(o,n),n}})();return n.promise=f,f}async function D(o){return M("reload()",o),R(o),b(o)}function E(o,n){let c=d[o];if(c&&ie(c)){try{n(c)}catch(f){A("push callback failed",o,f)}return}y.push({key:o,cb:n})}function C(o=document){let n=j(o);for(let c of n)b(c)}function K(){k()&&(p||(p=new MutationObserver(o=>{for(let n of o)for(let c of Array.from(n.addedNodes))c instanceof HTMLElement&&C(c)}),p.observe(document.documentElement,{childList:!0,subtree:!0})))}function O(){p?.disconnect(),p=null}function u(o){M("destroy()"),O();for(let n of Object.values(d))try{n.instance?.destroy?.()}catch(c){A("destroy module failed",n.key,c)}if(i)try{s.destroy()}catch(n){A("core.destroy failed",n)}for(let n of Object.keys(d))delete d[n];y.length=0,!o?.keepGlobal&&typeof window<"u"&&delete window.AdLibAttributes}let l={version:e.version,config:g,core:s,debug:t,modules:d,load:b,push:E,reload:D,destroy:u};if(typeof window<"u"){let o=window.AdLibAttributesQueue;if(Array.isArray(o)&&o.length>0){let n=o.splice(0,o.length);for(let[c,f]of n)l.push(c,f)}}return r&&k()&&(C(document.body??document),K()),l}function ae(e){return typeof e=="object"&&e!==null&&typeof e.getAttributeNames=="function"}function le(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function de(e){if(typeof e!="object"||e===null)return!1;let t=e.attributes;if(typeof t!="object"||t===null)return!1;let r=t;return typeof r.length=="number"&&typeof r.item=="function"}function fe(e){return typeof e!="object"||e===null?!1:typeof e.querySelectorAll=="function"}function me(e){if(ae(e)){let t=e.getAttributeNames();if(le(t))return t}if(de(e)){let t=[];for(let r=0;r<e.attributes.length;r++){let i=e.attributes.item(r);i&&typeof i.name=="string"&&i.name&&t.push(i.name)}return t}return[]}function ge(e){let t=(e.getAttribute("type")??"").trim();if(t&&t!=="module")return!1;let r=(e.getAttribute("src")??"").trim();return r?r.includes("attributes.js"):!1}function P(e){if(typeof e!="string")return;let t=e.trim();return t||void 0}function G(e,t){if(typeof e!="string")return t;let r=e.trim().toLowerCase();return r===""||r==="true"||r==="1"||r==="yes"||r==="on"?!0:r==="false"||r==="0"||r==="no"||r==="off"?!1:t}function pe(e){let t=e.dataset??{},r=G(t.adlibDebug,!1),i=G(t.adlibAuto,!0),s=P(t.adlibRegistry),a=P(t.adlibVersion),g=P(t.adlibBase),d={};return s&&(d.registry=s),a&&(d.version=a),g&&(d.base=g),{debug:r,auto:i,config:d}}function F(e=document){if(!fe(e))return[];let t=Array.from(e.querySelectorAll("script")),r=[];for(let i of t){if(!(i instanceof HTMLScriptElement)||!ge(i))continue;let s=new Set;for(let a of me(i)){let g=I(a);N(g)&&s.add(g)}r.push({el:i,requestedKeys:Array.from(s),loaderConfig:pe(i)})}return r}var ye="0.0.0";(function(){if(!k()||window.AdLibAttributes)return;let t=F(document),r=t[0],i=r?.loaderConfig.debug??!1,s=r?.loaderConfig.auto??!0,a=r?.loaderConfig.config??{},g=$({root:document,debug:i}),d=Q({version:ye,core:g,debug:i,auto:s,config:a});window.AdLibAttributes=d;let y=new Set;for(let p of t)for(let M of p.requestedKeys)y.add(M);for(let p of y)d.load(p).catch(()=>{})})();
1
+ function N(e){return e.startsWith("ad-")&&e.length>3}function I(e){return e.startsWith("data-")?e.slice(5):e}function V(e){return typeof e!="object"||e===null?!1:typeof e.querySelectorAll=="function"}function j(e=document){if(!V(e))return[];let t=new Set,r=e.querySelectorAll("*");for(let i of Array.from(r))for(let s of Array.from(i.attributes)){let a=I(s.name);N(a)&&t.add(a)}return Array.from(t)}function k(){return typeof window<"u"&&typeof document<"u"}function z(e=!1){return{debug:(...t)=>{e&&console.warn("[debug]",...t)},warn:(...t)=>{console.warn("[warn]",...t)},error:(...t)=>{console.error("[error]",...t)}}}function B(e){return typeof Element<"u"&&e instanceof Element}function U(e,t){try{return e.matches(t)}catch{return!1}}function Y(e,t){let r=e;for(;r;){if(B(r)&&U(r,t))return r;r=B(r)?r.parentElement:null}return null}function W(e){return t=>{let r=e.entries.slice();for(let i of r){let s=Y(t.target,i.selector);if(s&&(i.handler(t,s),i.once)){let a=e.entries.indexOf(i);a>=0&&e.entries.splice(a,1)}}}}function J(e){return e instanceof Document?e.documentElement??e:e}function x(e={}){let t=e.root??document,r=z(!!e.debug),i=new Map,s=new Map,a=new Map;function g(u,l,o,n={}){let c=!!n.capture,f=!!n.passive,m=a.get(u);if(m)return m.entries.push({selector:l,handler:o,once:!!n.once}),()=>{let v=m.entries.findIndex(S=>S.selector===l&&S.handler===o);v>=0&&m.entries.splice(v,1),m.entries.length===0&&(t.removeEventListener(u,m.listener,{capture:m.capture}),a.delete(u))};let w={capture:c,passive:f,entries:[{selector:l,handler:o,once:!!n.once}],listener:()=>{}},_=W(w);return w.listener=_,a.set(u,w),t.addEventListener(u,_,{capture:c,passive:f}),()=>{let v=a.get(u);if(!v)return;let S=v.entries.findIndex(q=>q.selector===l&&q.handler===o);S>=0&&v.entries.splice(S,1),v.entries.length===0&&(t.removeEventListener(u,v.listener,{capture:v.capture}),a.delete(u))}}function d(u,l,o){let n=new CustomEvent(l,{detail:o,bubbles:!0});u.dispatchEvent(n)}function y(u){i.set(u.key,u)}function p(u){i.delete(u)}function M(u,l){let o=i.get(u);if(!o||s.has(u))return;let n=o.init(O);s.set(u,n)}function A(u){let l=s.get(u);l&&(l.destroy(),s.delete(u))}function h(u){for(let l of i.keys())M(l)}function R(){for(let u of s.keys())A(u)}let b=null;function D(u=t){return b?()=>{}:(b=new MutationObserver(l=>{}),b.observe(J(u),{subtree:!0,childList:!0,attributes:!1}),()=>E())}function E(){b&&(b.disconnect(),b=null)}function C(){E(),R();for(let[u,l]of a.entries())t.removeEventListener(u,l.listener,{capture:l.capture});a.clear(),i.clear(),s.clear()}function K(){return r}let O={on:g,emit:d,register:y,unregister:p,mount:M,unmount:A,mountAll:h,unmountAll:R,observe:D,stopObserving:E,destroy:C,getLogger:K};return O}var L=null;function $(e={}){return L||(L=x({autoMount:!0,...e}),(e.autoMount??!0)&&typeof document<"u"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>{L?.mountAll()},{once:!0}):L.mountAll()),L)}function X(e){return e.trim().replace(/\/+$/,"")}function Z(e){return X(e.base??e.registry)}function ee(e){return(e.version??"").trim()||"latest"}function te(e,t,r){return`${e}/@adartem/${t}@${r}/dist/index.js`}var ne={"ad-click":"ad-click"};function T(e,t){let r=Z(t),i=ee(t),s=ne[e];return s?te(r,s,i):null}var re="https://cdn.jsdelivr.net/npm";function oe(e,t){return e[t]??(e[t]={key:t,status:"idle"})}function ie(e){return e.status==="ready"||e.status==="error"}function se(e){return e instanceof Error?e:new Error(String(e))}function H(e){let t=(e??"").trim();if(t)return t.replace(/\/+$/,"")}function ue(e){let t=H(e.config?.registry)??re,r=(e.config?.version??e.version).trim()||e.version,i={registry:t,version:r},s=H(e.config?.base);return s&&(i.base=s),i}function ce(e,t){let r=e&&typeof e=="object"?e.default??e:e;if(!r||typeof r!="object")throw new Error(`Invalid module definition for ${t}`);let i=r;if(typeof i.key!="string"||typeof i.init!="function")throw new Error(`Invalid module definition for ${t}`);if(i.key!==t)throw new Error(`Module key mismatch: expected "${t}", got "${i.key}"`);return i}function Q(e){let t=e.debug??!1,r=e.auto??!1,i=e.core==null,s=e.core??x({debug:t,autoMount:!1}),a=s.getLogger(),g=ue(e),d={},y=[],p=null;function M(...o){t&&a.debug("[AdLib Runtime]",...o)}function A(...o){a.error("[AdLib Runtime]",...o)}function h(o,n){for(let c=y.length-1;c>=0;c--){let f=y[c];if(f&&f.key===o){y.splice(c,1);try{f.cb(n)}catch(m){A("push callback failed",o,m)}}}}function R(o){let n=d[o];if(n){try{n.instance?.destroy?.()}catch(c){A("destroyModule failed",o,c)}delete n.instance,delete n.def,delete n.error,delete n.promise,n.status="idle"}}async function b(o){let n=oe(d,o);if(n.status==="ready"||n.status==="error")return n;if(n.status==="loading"&&n.promise)return n.promise;let c=T(o,g);if(!c)return n.status="error",n.error=new Error(`Unknown module key: ${o}`),h(o,n),n;n.status="loading",M("load()",o,"->",c);let f=(async()=>{try{let m=await import(c),w=ce(m,o);return n.def=w,n.instance||(n.instance=w.init(s)),n.status="ready",delete n.error,delete n.promise,h(o,n),n}catch(m){return n.status="error",n.error=se(m),delete n.promise,h(o,n),n}})();return n.promise=f,f}async function D(o){return M("reload()",o),R(o),b(o)}function E(o,n){let c=d[o];if(c&&ie(c)){try{n(c)}catch(f){A("push callback failed",o,f)}return}y.push({key:o,cb:n})}function C(o=document){let n=j(o);for(let c of n)b(c)}function K(){k()&&(p||(p=new MutationObserver(o=>{for(let n of o)for(let c of Array.from(n.addedNodes))c instanceof HTMLElement&&C(c)}),p.observe(document.documentElement,{childList:!0,subtree:!0})))}function O(){p?.disconnect(),p=null}function u(o){M("destroy()"),O();for(let n of Object.values(d))try{n.instance?.destroy?.()}catch(c){A("destroy module failed",n.key,c)}if(i)try{s.destroy()}catch(n){A("core.destroy failed",n)}for(let n of Object.keys(d))delete d[n];y.length=0,!o?.keepGlobal&&typeof window<"u"&&delete window.AdLibAttributes}let l={version:e.version,config:g,core:s,debug:t,modules:d,load:b,push:E,reload:D,destroy:u};if(typeof window<"u"){let o=window.AdLibAttributesQueue;if(Array.isArray(o)&&o.length>0){let n=o.splice(0,o.length);for(let[c,f]of n)l.push(c,f)}}return r&&k()&&(C(document.body??document),K()),l}function ae(e){return typeof e=="object"&&e!==null&&typeof e.getAttributeNames=="function"}function le(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function de(e){if(typeof e!="object"||e===null)return!1;let t=e.attributes;if(typeof t!="object"||t===null)return!1;let r=t;return typeof r.length=="number"&&typeof r.item=="function"}function fe(e){return typeof e!="object"||e===null?!1:typeof e.querySelectorAll=="function"}function me(e){if(ae(e)){let t=e.getAttributeNames();if(le(t))return t}if(de(e)){let t=[];for(let r=0;r<e.attributes.length;r++){let i=e.attributes.item(r);i&&typeof i.name=="string"&&i.name&&t.push(i.name)}return t}return[]}function ge(e){let t=(e.getAttribute("type")??"").trim();if(t&&t!=="module")return!1;let r=(e.getAttribute("src")??"").trim();return r?r.includes("attributes.js"):!1}function P(e){if(typeof e!="string")return;let t=e.trim();return t||void 0}function G(e,t){if(typeof e!="string")return t;let r=e.trim().toLowerCase();return r===""||r==="true"||r==="1"||r==="yes"||r==="on"?!0:r==="false"||r==="0"||r==="no"||r==="off"?!1:t}function pe(e){let t=e.dataset??{},r=G(t.adlibDebug,!1),i=G(t.adlibAuto,!0),s=P(t.adlibRegistry),a=P(t.adlibVersion),g=P(t.adlibBase),d={};return s&&(d.registry=s),a&&(d.version=a),g&&(d.base=g),{debug:r,auto:i,config:d}}function F(e=document){if(!fe(e))return[];let t=Array.from(e.querySelectorAll("script")),r=[];for(let i of t){if(!(i instanceof HTMLScriptElement)||!ge(i))continue;let s=new Set;for(let a of me(i)){let g=I(a);N(g)&&s.add(g)}r.push({el:i,requestedKeys:Array.from(s),loaderConfig:pe(i)})}return r}var ye="0.1.0";(function(){if(!k()||window.AdLibAttributes)return;let t=F(document),r=t[0],i=r?.loaderConfig.debug??!1,s=r?.loaderConfig.auto??!0,a=r?.loaderConfig.config??{},g=$({root:document,debug:i}),d=Q({version:ye,core:g,debug:i,auto:s,config:a});window.AdLibAttributes=d;let y=new Set;for(let p of t)for(let M of p.requestedKeys)y.add(M);for(let p of y)d.load(p).catch(()=>{})})();
2
2
  //# sourceMappingURL=attributes.js.map
@@ -1,2 +1,2 @@
1
- function N(e){return e.startsWith("ad-")&&e.length>3}function I(e){return e.startsWith("data-")?e.slice(5):e}function V(e){return typeof e!="object"||e===null?!1:typeof e.querySelectorAll=="function"}function j(e=document){if(!V(e))return[];let t=new Set,r=e.querySelectorAll("*");for(let i of Array.from(r))for(let s of Array.from(i.attributes)){let a=I(s.name);N(a)&&t.add(a)}return Array.from(t)}function k(){return typeof window<"u"&&typeof document<"u"}function z(e=!1){return{debug:(...t)=>{e&&console.warn("[debug]",...t)},warn:(...t)=>{console.warn("[warn]",...t)},error:(...t)=>{console.error("[error]",...t)}}}function B(e){return typeof Element<"u"&&e instanceof Element}function U(e,t){try{return e.matches(t)}catch{return!1}}function Y(e,t){let r=e;for(;r;){if(B(r)&&U(r,t))return r;r=B(r)?r.parentElement:null}return null}function W(e){return t=>{let r=e.entries.slice();for(let i of r){let s=Y(t.target,i.selector);if(s&&(i.handler(t,s),i.once)){let a=e.entries.indexOf(i);a>=0&&e.entries.splice(a,1)}}}}function J(e){return e instanceof Document?e.documentElement??e:e}function x(e={}){let t=e.root??document,r=z(!!e.debug),i=new Map,s=new Map,a=new Map;function g(u,l,o,n={}){let c=!!n.capture,f=!!n.passive,m=a.get(u);if(m)return m.entries.push({selector:l,handler:o,once:!!n.once}),()=>{let v=m.entries.findIndex(S=>S.selector===l&&S.handler===o);v>=0&&m.entries.splice(v,1),m.entries.length===0&&(t.removeEventListener(u,m.listener,{capture:m.capture}),a.delete(u))};let w={capture:c,passive:f,entries:[{selector:l,handler:o,once:!!n.once}],listener:()=>{}},_=W(w);return w.listener=_,a.set(u,w),t.addEventListener(u,_,{capture:c,passive:f}),()=>{let v=a.get(u);if(!v)return;let S=v.entries.findIndex(q=>q.selector===l&&q.handler===o);S>=0&&v.entries.splice(S,1),v.entries.length===0&&(t.removeEventListener(u,v.listener,{capture:v.capture}),a.delete(u))}}function d(u,l,o){let n=new CustomEvent(l,{detail:o,bubbles:!0});u.dispatchEvent(n)}function y(u){i.set(u.key,u)}function p(u){i.delete(u)}function M(u,l){let o=i.get(u);if(!o||s.has(u))return;let n=o.init(O);s.set(u,n)}function A(u){let l=s.get(u);l&&(l.destroy(),s.delete(u))}function h(u){for(let l of i.keys())M(l)}function R(){for(let u of s.keys())A(u)}let b=null;function D(u=t){return b?()=>{}:(b=new MutationObserver(l=>{}),b.observe(J(u),{subtree:!0,childList:!0,attributes:!1}),()=>E())}function E(){b&&(b.disconnect(),b=null)}function C(){E(),R();for(let[u,l]of a.entries())t.removeEventListener(u,l.listener,{capture:l.capture});a.clear(),i.clear(),s.clear()}function K(){return r}let O={on:g,emit:d,register:y,unregister:p,mount:M,unmount:A,mountAll:h,unmountAll:R,observe:D,stopObserving:E,destroy:C,getLogger:K};return O}var L=null;function $(e={}){return L||(L=x({autoMount:!0,...e}),(e.autoMount??!0)&&typeof document<"u"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>{L?.mountAll()},{once:!0}):L.mountAll()),L)}function X(e){return e.trim().replace(/\/+$/,"")}function Z(e){return X(e.base??e.registry)}function ee(e){return(e.version??"").trim()||"latest"}function te(e,t,r){return`${e}/@adartem/${t}@${r}/dist/index.js`}var ne={"ad-click":"ad-click"};function T(e,t){let r=Z(t),i=ee(t),s=ne[e];return s?te(r,s,i):null}var re="https://cdn.jsdelivr.net/npm";function oe(e,t){return e[t]??(e[t]={key:t,status:"idle"})}function ie(e){return e.status==="ready"||e.status==="error"}function se(e){return e instanceof Error?e:new Error(String(e))}function H(e){let t=(e??"").trim();if(t)return t.replace(/\/+$/,"")}function ue(e){let t=H(e.config?.registry)??re,r=(e.config?.version??e.version).trim()||e.version,i={registry:t,version:r},s=H(e.config?.base);return s&&(i.base=s),i}function ce(e,t){let r=e&&typeof e=="object"?e.default??e:e;if(!r||typeof r!="object")throw new Error(`Invalid module definition for ${t}`);let i=r;if(typeof i.key!="string"||typeof i.init!="function")throw new Error(`Invalid module definition for ${t}`);if(i.key!==t)throw new Error(`Module key mismatch: expected "${t}", got "${i.key}"`);return i}function Q(e){let t=e.debug??!1,r=e.auto??!1,i=e.core==null,s=e.core??x({debug:t,autoMount:!1}),a=s.getLogger(),g=ue(e),d={},y=[],p=null;function M(...o){t&&a.debug("[AdLib Runtime]",...o)}function A(...o){a.error("[AdLib Runtime]",...o)}function h(o,n){for(let c=y.length-1;c>=0;c--){let f=y[c];if(f&&f.key===o){y.splice(c,1);try{f.cb(n)}catch(m){A("push callback failed",o,m)}}}}function R(o){let n=d[o];if(n){try{n.instance?.destroy?.()}catch(c){A("destroyModule failed",o,c)}delete n.instance,delete n.def,delete n.error,delete n.promise,n.status="idle"}}async function b(o){let n=oe(d,o);if(n.status==="ready"||n.status==="error")return n;if(n.status==="loading"&&n.promise)return n.promise;let c=T(o,g);if(!c)return n.status="error",n.error=new Error(`Unknown module key: ${o}`),h(o,n),n;n.status="loading",M("load()",o,"->",c);let f=(async()=>{try{let m=await import(c),w=ce(m,o);return n.def=w,n.instance||(n.instance=w.init(s)),n.status="ready",delete n.error,delete n.promise,h(o,n),n}catch(m){return n.status="error",n.error=se(m),delete n.promise,h(o,n),n}})();return n.promise=f,f}async function D(o){return M("reload()",o),R(o),b(o)}function E(o,n){let c=d[o];if(c&&ie(c)){try{n(c)}catch(f){A("push callback failed",o,f)}return}y.push({key:o,cb:n})}function C(o=document){let n=j(o);for(let c of n)b(c)}function K(){k()&&(p||(p=new MutationObserver(o=>{for(let n of o)for(let c of Array.from(n.addedNodes))c instanceof HTMLElement&&C(c)}),p.observe(document.documentElement,{childList:!0,subtree:!0})))}function O(){p?.disconnect(),p=null}function u(o){M("destroy()"),O();for(let n of Object.values(d))try{n.instance?.destroy?.()}catch(c){A("destroy module failed",n.key,c)}if(i)try{s.destroy()}catch(n){A("core.destroy failed",n)}for(let n of Object.keys(d))delete d[n];y.length=0,!o?.keepGlobal&&typeof window<"u"&&delete window.AdLibAttributes}let l={version:e.version,config:g,core:s,debug:t,modules:d,load:b,push:E,reload:D,destroy:u};if(typeof window<"u"){let o=window.AdLibAttributesQueue;if(Array.isArray(o)&&o.length>0){let n=o.splice(0,o.length);for(let[c,f]of n)l.push(c,f)}}return r&&k()&&(C(document.body??document),K()),l}function ae(e){return typeof e=="object"&&e!==null&&typeof e.getAttributeNames=="function"}function le(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function de(e){if(typeof e!="object"||e===null)return!1;let t=e.attributes;if(typeof t!="object"||t===null)return!1;let r=t;return typeof r.length=="number"&&typeof r.item=="function"}function fe(e){return typeof e!="object"||e===null?!1:typeof e.querySelectorAll=="function"}function me(e){if(ae(e)){let t=e.getAttributeNames();if(le(t))return t}if(de(e)){let t=[];for(let r=0;r<e.attributes.length;r++){let i=e.attributes.item(r);i&&typeof i.name=="string"&&i.name&&t.push(i.name)}return t}return[]}function ge(e){let t=(e.getAttribute("type")??"").trim();if(t&&t!=="module")return!1;let r=(e.getAttribute("src")??"").trim();return r?r.includes("attributes.js"):!1}function P(e){if(typeof e!="string")return;let t=e.trim();return t||void 0}function G(e,t){if(typeof e!="string")return t;let r=e.trim().toLowerCase();return r===""||r==="true"||r==="1"||r==="yes"||r==="on"?!0:r==="false"||r==="0"||r==="no"||r==="off"?!1:t}function pe(e){let t=e.dataset??{},r=G(t.adlibDebug,!1),i=G(t.adlibAuto,!0),s=P(t.adlibRegistry),a=P(t.adlibVersion),g=P(t.adlibBase),d={};return s&&(d.registry=s),a&&(d.version=a),g&&(d.base=g),{debug:r,auto:i,config:d}}function F(e=document){if(!fe(e))return[];let t=Array.from(e.querySelectorAll("script")),r=[];for(let i of t){if(!(i instanceof HTMLScriptElement)||!ge(i))continue;let s=new Set;for(let a of me(i)){let g=I(a);N(g)&&s.add(g)}r.push({el:i,requestedKeys:Array.from(s),loaderConfig:pe(i)})}return r}var ye="0.0.0";(function(){if(!k()||window.AdLibAttributes)return;let t=F(document),r=t[0],i=r?.loaderConfig.debug??!1,s=r?.loaderConfig.auto??!0,a=r?.loaderConfig.config??{},g=$({root:document,debug:i}),d=Q({version:ye,core:g,debug:i,auto:s,config:a});window.AdLibAttributes=d;let y=new Set;for(let p of t)for(let M of p.requestedKeys)y.add(M);for(let p of y)d.load(p).catch(()=>{})})();
1
+ function N(e){return e.startsWith("ad-")&&e.length>3}function I(e){return e.startsWith("data-")?e.slice(5):e}function V(e){return typeof e!="object"||e===null?!1:typeof e.querySelectorAll=="function"}function j(e=document){if(!V(e))return[];let t=new Set,r=e.querySelectorAll("*");for(let i of Array.from(r))for(let s of Array.from(i.attributes)){let a=I(s.name);N(a)&&t.add(a)}return Array.from(t)}function k(){return typeof window<"u"&&typeof document<"u"}function z(e=!1){return{debug:(...t)=>{e&&console.warn("[debug]",...t)},warn:(...t)=>{console.warn("[warn]",...t)},error:(...t)=>{console.error("[error]",...t)}}}function B(e){return typeof Element<"u"&&e instanceof Element}function U(e,t){try{return e.matches(t)}catch{return!1}}function Y(e,t){let r=e;for(;r;){if(B(r)&&U(r,t))return r;r=B(r)?r.parentElement:null}return null}function W(e){return t=>{let r=e.entries.slice();for(let i of r){let s=Y(t.target,i.selector);if(s&&(i.handler(t,s),i.once)){let a=e.entries.indexOf(i);a>=0&&e.entries.splice(a,1)}}}}function J(e){return e instanceof Document?e.documentElement??e:e}function x(e={}){let t=e.root??document,r=z(!!e.debug),i=new Map,s=new Map,a=new Map;function g(u,l,o,n={}){let c=!!n.capture,f=!!n.passive,m=a.get(u);if(m)return m.entries.push({selector:l,handler:o,once:!!n.once}),()=>{let v=m.entries.findIndex(S=>S.selector===l&&S.handler===o);v>=0&&m.entries.splice(v,1),m.entries.length===0&&(t.removeEventListener(u,m.listener,{capture:m.capture}),a.delete(u))};let w={capture:c,passive:f,entries:[{selector:l,handler:o,once:!!n.once}],listener:()=>{}},_=W(w);return w.listener=_,a.set(u,w),t.addEventListener(u,_,{capture:c,passive:f}),()=>{let v=a.get(u);if(!v)return;let S=v.entries.findIndex(q=>q.selector===l&&q.handler===o);S>=0&&v.entries.splice(S,1),v.entries.length===0&&(t.removeEventListener(u,v.listener,{capture:v.capture}),a.delete(u))}}function d(u,l,o){let n=new CustomEvent(l,{detail:o,bubbles:!0});u.dispatchEvent(n)}function y(u){i.set(u.key,u)}function p(u){i.delete(u)}function M(u,l){let o=i.get(u);if(!o||s.has(u))return;let n=o.init(O);s.set(u,n)}function A(u){let l=s.get(u);l&&(l.destroy(),s.delete(u))}function h(u){for(let l of i.keys())M(l)}function R(){for(let u of s.keys())A(u)}let b=null;function D(u=t){return b?()=>{}:(b=new MutationObserver(l=>{}),b.observe(J(u),{subtree:!0,childList:!0,attributes:!1}),()=>E())}function E(){b&&(b.disconnect(),b=null)}function C(){E(),R();for(let[u,l]of a.entries())t.removeEventListener(u,l.listener,{capture:l.capture});a.clear(),i.clear(),s.clear()}function K(){return r}let O={on:g,emit:d,register:y,unregister:p,mount:M,unmount:A,mountAll:h,unmountAll:R,observe:D,stopObserving:E,destroy:C,getLogger:K};return O}var L=null;function $(e={}){return L||(L=x({autoMount:!0,...e}),(e.autoMount??!0)&&typeof document<"u"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>{L?.mountAll()},{once:!0}):L.mountAll()),L)}function X(e){return e.trim().replace(/\/+$/,"")}function Z(e){return X(e.base??e.registry)}function ee(e){return(e.version??"").trim()||"latest"}function te(e,t,r){return`${e}/@adartem/${t}@${r}/dist/index.js`}var ne={"ad-click":"ad-click"};function T(e,t){let r=Z(t),i=ee(t),s=ne[e];return s?te(r,s,i):null}var re="https://cdn.jsdelivr.net/npm";function oe(e,t){return e[t]??(e[t]={key:t,status:"idle"})}function ie(e){return e.status==="ready"||e.status==="error"}function se(e){return e instanceof Error?e:new Error(String(e))}function H(e){let t=(e??"").trim();if(t)return t.replace(/\/+$/,"")}function ue(e){let t=H(e.config?.registry)??re,r=(e.config?.version??e.version).trim()||e.version,i={registry:t,version:r},s=H(e.config?.base);return s&&(i.base=s),i}function ce(e,t){let r=e&&typeof e=="object"?e.default??e:e;if(!r||typeof r!="object")throw new Error(`Invalid module definition for ${t}`);let i=r;if(typeof i.key!="string"||typeof i.init!="function")throw new Error(`Invalid module definition for ${t}`);if(i.key!==t)throw new Error(`Module key mismatch: expected "${t}", got "${i.key}"`);return i}function Q(e){let t=e.debug??!1,r=e.auto??!1,i=e.core==null,s=e.core??x({debug:t,autoMount:!1}),a=s.getLogger(),g=ue(e),d={},y=[],p=null;function M(...o){t&&a.debug("[AdLib Runtime]",...o)}function A(...o){a.error("[AdLib Runtime]",...o)}function h(o,n){for(let c=y.length-1;c>=0;c--){let f=y[c];if(f&&f.key===o){y.splice(c,1);try{f.cb(n)}catch(m){A("push callback failed",o,m)}}}}function R(o){let n=d[o];if(n){try{n.instance?.destroy?.()}catch(c){A("destroyModule failed",o,c)}delete n.instance,delete n.def,delete n.error,delete n.promise,n.status="idle"}}async function b(o){let n=oe(d,o);if(n.status==="ready"||n.status==="error")return n;if(n.status==="loading"&&n.promise)return n.promise;let c=T(o,g);if(!c)return n.status="error",n.error=new Error(`Unknown module key: ${o}`),h(o,n),n;n.status="loading",M("load()",o,"->",c);let f=(async()=>{try{let m=await import(c),w=ce(m,o);return n.def=w,n.instance||(n.instance=w.init(s)),n.status="ready",delete n.error,delete n.promise,h(o,n),n}catch(m){return n.status="error",n.error=se(m),delete n.promise,h(o,n),n}})();return n.promise=f,f}async function D(o){return M("reload()",o),R(o),b(o)}function E(o,n){let c=d[o];if(c&&ie(c)){try{n(c)}catch(f){A("push callback failed",o,f)}return}y.push({key:o,cb:n})}function C(o=document){let n=j(o);for(let c of n)b(c)}function K(){k()&&(p||(p=new MutationObserver(o=>{for(let n of o)for(let c of Array.from(n.addedNodes))c instanceof HTMLElement&&C(c)}),p.observe(document.documentElement,{childList:!0,subtree:!0})))}function O(){p?.disconnect(),p=null}function u(o){M("destroy()"),O();for(let n of Object.values(d))try{n.instance?.destroy?.()}catch(c){A("destroy module failed",n.key,c)}if(i)try{s.destroy()}catch(n){A("core.destroy failed",n)}for(let n of Object.keys(d))delete d[n];y.length=0,!o?.keepGlobal&&typeof window<"u"&&delete window.AdLibAttributes}let l={version:e.version,config:g,core:s,debug:t,modules:d,load:b,push:E,reload:D,destroy:u};if(typeof window<"u"){let o=window.AdLibAttributesQueue;if(Array.isArray(o)&&o.length>0){let n=o.splice(0,o.length);for(let[c,f]of n)l.push(c,f)}}return r&&k()&&(C(document.body??document),K()),l}function ae(e){return typeof e=="object"&&e!==null&&typeof e.getAttributeNames=="function"}function le(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function de(e){if(typeof e!="object"||e===null)return!1;let t=e.attributes;if(typeof t!="object"||t===null)return!1;let r=t;return typeof r.length=="number"&&typeof r.item=="function"}function fe(e){return typeof e!="object"||e===null?!1:typeof e.querySelectorAll=="function"}function me(e){if(ae(e)){let t=e.getAttributeNames();if(le(t))return t}if(de(e)){let t=[];for(let r=0;r<e.attributes.length;r++){let i=e.attributes.item(r);i&&typeof i.name=="string"&&i.name&&t.push(i.name)}return t}return[]}function ge(e){let t=(e.getAttribute("type")??"").trim();if(t&&t!=="module")return!1;let r=(e.getAttribute("src")??"").trim();return r?r.includes("attributes.js"):!1}function P(e){if(typeof e!="string")return;let t=e.trim();return t||void 0}function G(e,t){if(typeof e!="string")return t;let r=e.trim().toLowerCase();return r===""||r==="true"||r==="1"||r==="yes"||r==="on"?!0:r==="false"||r==="0"||r==="no"||r==="off"?!1:t}function pe(e){let t=e.dataset??{},r=G(t.adlibDebug,!1),i=G(t.adlibAuto,!0),s=P(t.adlibRegistry),a=P(t.adlibVersion),g=P(t.adlibBase),d={};return s&&(d.registry=s),a&&(d.version=a),g&&(d.base=g),{debug:r,auto:i,config:d}}function F(e=document){if(!fe(e))return[];let t=Array.from(e.querySelectorAll("script")),r=[];for(let i of t){if(!(i instanceof HTMLScriptElement)||!ge(i))continue;let s=new Set;for(let a of me(i)){let g=I(a);N(g)&&s.add(g)}r.push({el:i,requestedKeys:Array.from(s),loaderConfig:pe(i)})}return r}var ye="0.1.0";(function(){if(!k()||window.AdLibAttributes)return;let t=F(document),r=t[0],i=r?.loaderConfig.debug??!1,s=r?.loaderConfig.auto??!0,a=r?.loaderConfig.config??{},g=$({root:document,debug:i}),d=Q({version:ye,core:g,debug:i,auto:s,config:a});window.AdLibAttributes=d;let y=new Set;for(let p of t)for(let M of p.requestedKeys)y.add(M);for(let p of y)d.load(p).catch(()=>{})})();
2
2
  //# sourceMappingURL=attributes.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adartem/adlib-attributes",
3
- "version": "0.0.0",
3
+ "version": "0.1.0",
4
4
  "description": "Core unifié + runtime global des attributs AdLib (ad-*).",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -51,7 +51,7 @@
51
51
  "declarative"
52
52
  ],
53
53
  "dependencies": {
54
- "@adartem/adlib-utils": "0.0.0"
54
+ "@adartem/adlib-utils": "0.1.0"
55
55
  },
56
56
  "scripts": {
57
57
  "build": "pnpm run build:js && pnpm run build:types",