@walkeros/web-source-browser 4.3.2 → 4.4.0-next-1785239495233
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 +20 -0
- package/dist/dev.d.mts +3 -3
- package/dist/dev.d.ts +3 -3
- package/dist/dev.js +1 -1
- package/dist/dev.js.map +1 -1
- package/dist/dev.mjs +1 -1
- package/dist/dev.mjs.map +1 -1
- package/dist/index.browser.js +1 -1
- package/dist/index.d.mts +50 -8
- package/dist/index.d.ts +50 -8
- package/dist/index.es5.js +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/walkerOS.json +15 -6
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,s={};((e,n)=>{for(var r in n)t(e,r,{get:n[r],enumerable:!0})})(s,{SourceBrowser:()=>me,__readInstanceGuardForTests:()=>ye,__resetInstanceCountForTests:()=>we,createTagger:()=>he,default:()=>ke,getAllEvents:()=>h,getElbAttributeName:()=>m,getElbValues:()=>b,getEvents:()=>p,getGlobals:()=>v,getUser:()=>w,sourceBrowser:()=>Ee}),module.exports=(e=s,((e,s,i,c)=>{if(s&&"object"==typeof s||"function"==typeof s)for(let l of r(s))o.call(e,l)||l===i||t(e,l,{get:()=>s[l],enumerable:!(c=n(s,l))||c.enumerable});return e})(t({},"__esModule",{value:!0}),e));var i=require("@walkeros/core"),c=require("@walkeros/collector"),l=require("@walkeros/core"),a=require("@walkeros/collector"),u=require("@walkeros/web-core"),f=require("@walkeros/core"),d=require("@walkeros/collector"),g=require("@walkeros/web-core");function m(e,t,n=!0){return e+(t=null!=t?(n?"-":"")+t:"")}function b(e,t,n,r=!0){return S((0,g.getAttribute)(t,m(e,n,r))||"").reduce((e,n)=>{let[r,o]=P(n);if(!r)return e;if(o||(r.endsWith(":")&&(r=r.slice(0,-1)),o=""),o.startsWith("#")){o=o.slice(1);try{let e=t[o];e||"selected"!==o||(e=t.options[t.selectedIndex].text),o=String(e)}catch(e){o=""}}return r.endsWith("[]")?(r=r.slice(0,-2),(0,f.isArray)(e[r])||(e[r]=[]),e[r].push((0,f.castValue)(o))):e[r]=(0,f.castValue)(o),e},{})}function h(e,t=d.Const.Commands.Prefix){var n;const r=e;if(!r)return[];let o=[];const s=d.Const.Commands.Action,i=`[${m(t,s,!1)}]`,c=e=>{Object.keys(b(t,e,s,!1)).forEach(n=>{o=o.concat(p(e,n,t))})};return r!==(r.ownerDocument||r)&&(null==(n=r.matches)?void 0:n.call(r,i))&&c(r),A(r,i,c),o}function p(e,t,n=d.Const.Commands.Prefix){const r=[],{actions:o,nearestOnly:s}=function(e,t,n){let r=t;for(;r;){const t=(0,g.getAttribute)(r,m(e,d.Const.Commands.Actions,!1));if(t){const e=y(t);if(e[n])return{actions:e[n],nearestOnly:!1}}const o=(0,g.getAttribute)(r,m(e,d.Const.Commands.Action,!1));if(o){const e=y(o);if(e[n]||"click"!==n)return{actions:e[n]||[],nearestOnly:!0}}r=O(e,r)}return{actions:[],nearestOnly:!1}}(n,e,t);return o.length?(o.forEach(o=>{const i=S(o.actionParams||"",",").reduce((e,t)=>(e[(0,f.trim)(t)]=!0,e),{}),c=E(n,e,i,s);if(!c.length){const t="page",r=`[${m(n,t)}]`,[o,s]=C(e,r,n,t);c.push({entity:t,data:o,nested:[],context:s})}c.forEach(e=>{var n;r.push({entity:e.entity,action:o.action,data:e.data,trigger:t,context:e.context,nested:null!=(n=e.nested)?n:[]})})}),r):r}function v(e=d.Const.Commands.Prefix,t){if(!t)return{};const n=m(e,d.Const.Commands.Globals,!1);let r={};return j(t,`[${n}]`,t=>{r=(0,f.assign)(r,b(e,t,d.Const.Commands.Globals,!1))}),r}function w(e=d.Const.Commands.Prefix,t){if(!t)return{};const n=m(e,d.Const.Commands.User,!1);let r={};return j(t,`[${n}]`,t=>{r=(0,f.assign)(r,b(e,t,d.Const.Commands.User,!1))}),r}function y(e){const t={};return S(e).forEach(e=>{const[n,r]=P(e),[o,s]=x(n);if(!o)return;let[i,c]=x(r||"");i=i||o,t[o]||(t[o]=[]),t[o].push({trigger:o,triggerParams:s,action:i,actionParams:c})}),t}function E(e,t,n,r=!1){const o=[];let s=t;for(n=0!==Object.keys(n||{}).length?n:void 0;s;){const i=k(e,s,t,n);if(i&&(o.push(i),r))break;s=O(e,s)}return o}function k(e,t,n,r){const o=(0,g.getAttribute)(t,m(e));if(!o||r&&!r[o])return null;const s=[t],i=`[${m(e,o)}],[${m(e,"")}]`,c=m(e,d.Const.Commands.Link,!1);let l={};const a=[],[u,h]=C(n||t,i,e,o,!0);A(t,`[${c}]`,n=>{const[r,o]=P((0,g.getAttribute)(n,c));"parent"===o&&A(t.ownerDocument.body,`[${c}="${r}:child"]`,t=>{s.push(t);const n=k(e,t);n&&a.push(n)})});const p=[];s.forEach(e=>{e.matches(i)&&p.push(e),A(e,i,e=>p.push(e))});let v={};return p.forEach(t=>{v=(0,f.assign)(v,b(e,t,"")),l=(0,f.assign)(l,b(e,t,o))}),l=(0,f.assign)((0,f.assign)(v,l),u),s.forEach(t=>{A(t,`[${m(e)}]`,t=>{const n=k(e,t);n&&a.push(n)})}),{entity:o,data:l,context:h,nested:a}}function O(e,t){const n=m(e,d.Const.Commands.Link,!1);if(t.matches(`[${n}]`)){const[e,r]=P((0,g.getAttribute)(t,n));if("child"===r){const r=t.ownerDocument;let o=null;return j(r,`[${n}="${e}:parent"]`,e=>{o||(o=e)}),o}}const r=t.ownerDocument.defaultView;return!t.parentElement&&t.getRootNode&&t.getRootNode()instanceof r.ShadowRoot?t.getRootNode().host:t.parentElement}function C(e,t,n,r,o=!1){let s={};const i={};let c=e;const l=`[${m(n,d.Const.Commands.Context,!1)}]`,a=d.Const.Commands.Scoped,u=`[${m(n,a,!1)}]`;let g=0;for(;c;)o&&a&&c.matches(u)&&(s=(0,f.assign)(b(n,c,a,!1),s)),c.matches(t)&&(s=(0,f.assign)(b(n,c,""),s),s=(0,f.assign)(b(n,c,r),s)),c.matches(l)&&(Object.entries(b(n,c,d.Const.Commands.Context,!1)).forEach(([e,t])=>{t&&!i[e]&&(i[e]=[t,g])}),++g),c=O(n,c);return[s,i]}function j(e,t,n){e.querySelectorAll(t).forEach(n)}function A(e,t,n){e.querySelectorAll(t).forEach(n);e instanceof(e.ownerDocument||e).defaultView.Element&&e.shadowRoot&&A(e.shadowRoot,t,n),e.querySelectorAll("*").forEach(e=>{e.shadowRoot&&A(e.shadowRoot,t,n)})}function S(e,t=";"){if(!e)return[];const n=new RegExp(`(?:[^${t}']+|'[^']*')+`,"ig");return e.match(n)||[]}function P(e){const[t,n]=e.split(/:(.+)/,2);return[(0,f.trim)(t),(0,f.trim)(n)]}function x(e){const[t,n]=e.split("(",2);return[t,n?n.slice(0,-1):""]}var I=require("@walkeros/core"),$=require("@walkeros/web-core");var R=Array.from({length:101},(e,t)=>t/100),D=new WeakMap;function T(e){return e.ownerDocument||e}function L(e){const t=(e.ownerDocument||e).defaultView;if(t&&t.IntersectionObserver)return(0,I.tryCatch)(()=>new t.IntersectionObserver(t=>{t.forEach(t=>function(e,t){const n=t.target,r=D.get(T(e));if(!r)return;const o=n.ownerDocument.defaultView;if(!o)return;const s=r.configs.get(n);if(!s||!s.length)return;const i=r.timers.get(n);if(function(e,t){if(!e.isIntersecting)return!1;const n=e.boundingClientRect;if(n.width<=0||n.height<=0)return!1;const r=e.rootBounds?e.rootBounds.width:t.innerWidth,o=e.rootBounds?e.rootBounds.height:t.innerHeight;if(r<=0||o<=0)return!1;const s=e.intersectionRect,i=.5*Math.min(n.width,r),c=.5*Math.min(n.height,o);return s.width>=i&&s.height>=c}(t,o)){if(s.every(e=>e.blocked))return;if(!i){const t=o.setTimeout(()=>{q(T(e),n)},r.duration);r.timers.set(n,t)}return}i&&(clearTimeout(i),r.timers.delete(n));s.forEach(e=>{e.multiple&&(e.blocked=!1)})}(e,t))},{rootMargin:"0px",threshold:R}),()=>{})()}async function q(e,t,n=!1){const r=D.get(e);if(!r)return;r.timers.delete(t);const o=t.ownerDocument,s=o.defaultView;if(!s)return;if("visible"!==o.visibilityState)return void r.timers.set(t,s.setTimeout(()=>{q(e,t,!0)},r.duration));if(n)return void r.timers.set(t,s.setTimeout(()=>{q(e,t)},r.duration));if(!(0,$.isVisible)(t,s,o))return void r.timers.set(t,s.setTimeout(()=>{q(e,t)},r.duration));const i=r.configs.get(t);if(!i)return;const c=i.filter(e=>!e.blocked);if(!c.length)return;c.forEach(e=>{e.multiple&&(e.blocked=!0)});const l=i.filter(e=>e.multiple);l.length?r.configs.set(t,l):V(e,t),await Promise.all(c.map(e=>te(e.context,t,e.trigger)))}function V(e,t){var n,r;const o=D.get(T(e));if(!o)return;null==(n=o.observer)||n.unobserve(t),null==(r=o.resizeObserver)||r.unobserve(t),o.configs.delete(t),o.zeroArea.delete(t);const s=o.timers.get(t);s&&(clearTimeout(s),o.timers.delete(t))}function M(e){const t=(e.ownerDocument||e).defaultView;if(t&&t.ResizeObserver)return(0,I.tryCatch)(()=>new t.ResizeObserver(t=>{const n=D.get(e);(null==n?void 0:n.observer)&&t.forEach(e=>{var t,r;const o=e.target,{width:s,height:i}=e.contentRect;s<=0||i<=0?n.zeroArea.add(o):n.zeroArea.has(o)&&(n.zeroArea.delete(o),null==(t=n.observer)||t.unobserve(o),null==(r=n.observer)||r.observe(o))})}),()=>{})()}function W(e,t,n={multiple:!1}){var r,o,s;const i=e.settings.scope;if(!i)return;const c=D.get(T(i));if(!(null==c?void 0:c.observer)||!t)return;const l=null!=(r=n.multiple)&&r,a=null!=(o=c.configs.get(t))?o:[],u=a.length>0,f=l?X.Visible:X.Impression,d={multiple:l,blocked:!1,context:e,trigger:f},g=a.findIndex(e=>e.trigger===f);if(g>=0?a[g]=d:a.push(d),c.configs.set(t,a),u)return;const m=t.getBoundingClientRect();(m.width<=0||m.height<=0)&&c.zeroArea.add(t),c.observer.observe(t),null==(s=c.resizeObserver)||s.observe(t)}var z,H=require("@walkeros/core"),B=require("@walkeros/collector");function N(e,t,n,r,o,s,i){const{elb:c,settings:l}=e;if((0,H.isString)(t)&&t.startsWith("walker ")){if("walker init"===t&&e.initScope){const t=function(e,t){if(G(e))return[e];if(Array.isArray(e)){const t=[];for(const n of e)G(n)&&t.push(n);return t}if(void 0===e){const e=t.scope;if(G(e))return[e];if(void 0!==globalThis.document)return[globalThis.document]}return[]}(n,l);for(const n of t)e.initScope({...e,settings:{...l,scope:n}});return Promise.resolve((0,B.createPushResult)({ok:!0}))}return c(t,n)}if((0,H.isObject)(t)){const e=t;if(!e.source&&l.scope){const t=l.scope.ownerDocument||l.scope,n=t.defaultView;e.source=_(n,t)}return!e.globals&&l.scope&&(e.globals=U(l.scope)?v(l.prefix,l.scope):{}),c(e)}const[a]=String((0,H.isObject)(t)?t.name:t).split(" ");let u,f=(0,H.isObject)(n)?n:{},d={},g=!1;if((0,H.isElementOrDocument)(n)&&(u=n,g=!0),(0,H.isElementOrDocument)(o)?u=o:(0,H.isObject)(o)&&Object.keys(o).length&&(d=o),u){const e=E(l.prefix||"data-elb",u).find(e=>e.entity===a);e&&(g&&(f=e.data),e.context&&(d=e.context))}const m=l.scope?l.scope.ownerDocument||l.scope:void 0,b=null==m?void 0:m.defaultView;"page"===a&&b&&(f.id=f.id||b.location.pathname);const h=l.scope&&U(l.scope)?v(l.prefix,l.scope):{};return c({name:String(t||""),data:f,context:d,globals:h,nested:s,custom:i,trigger:(0,H.isString)(r)?r:"",source:b&&m?_(b,m):void 0})}function _(e,t){return{type:"browser",platform:"web",url:e.location.href,referrer:t.referrer}}function G(e){if(!e||"object"!=typeof e)return!1;if("undefined"!=typeof Element&&e instanceof Element)return!0;if("undefined"!=typeof Document&&e instanceof Document)return!0;if("undefined"!=typeof ShadowRoot&&e instanceof ShadowRoot)return!0;if("nodeType"in e){const t=e.nodeType;return 1===t||9===t||11===t}return!1}function U(e){return 11!==e.nodeType}var F=new Map,J=new WeakMap;function K(e){return J.has(e)}function Q(e){var t;const n=J.get(e);if(!n)return;const r=F.get(n.scope);n.intervalIds.forEach(e=>{if(clearInterval(e),r){const t=r.intervalIds.indexOf(e);-1!==t&&r.intervalIds.splice(t,1)}}),n.timeoutIds.forEach(e=>{if(clearTimeout(e),r){const t=r.timeoutIds.indexOf(e);-1!==t&&r.timeoutIds.splice(t,1)}}),null==(t=n.hoverAbort)||t.abort(),n.observed&&(V(n.scope,e),null==r||r.observed.delete(e)),n.scroll&&r&&(r.scrollElements=r.scrollElements.filter(([t])=>t!==e)),null==r||r.registered.delete(e),J.delete(e)}var X={Click:"click",Custom:"custom",Hover:"hover",Load:"load",Pulse:"pulse",Scroll:"scroll",Submit:"submit",Impression:"impression",Visible:"visible",Wait:"wait"};function Y(e,t){if(!t.scope)return;!function(e,t){const n=t.scope;if(!n)return;z&&z.abort();z=new AbortController;const{signal:r}=z;n.addEventListener("click",(0,l.tryCatch)(function(t){oe.call(this,e,t)}),{signal:r,capture:t.capture}),n.addEventListener("submit",(0,l.tryCatch)(function(t){se.call(this,e,t)}),{signal:r,capture:t.capture})}(e,t)}function Z(e){z&&(z.abort(),z=void 0),F.forEach((e,t)=>{e.abort.abort(),e.mutationObservers.forEach(e=>e.disconnect()),e.intervalIds.forEach(e=>clearInterval(e)),e.timeoutIds.forEach(e=>clearTimeout(e)),e.observed.forEach(e=>V(t,e)),[...e.registered].forEach(e=>Q(e))}),F.forEach((e,t)=>{!function(e){var t,n;if(!e)return;const r=T(e),o=D.get(r);o&&(null==(t=o.observer)||t.disconnect(),null==(n=o.resizeObserver)||n.disconnect(),D.delete(r))}(t)}),F.clear()}function ee(e,t){const n=e.settings.scope;if(!n)return;const r=function(e){const t=F.get(e);t&&(t.abort.abort(),t.intervalIds.forEach(e=>clearInterval(e)),t.timeoutIds.forEach(e=>clearTimeout(e)),t.observed.forEach(t=>V(e,t)),[...t.registered].forEach(e=>Q(e)),t.mutationObservers.forEach(e=>e.disconnect()));const n={abort:new AbortController,intervalIds:[],timeoutIds:[],scrollElements:[],observed:new Set,registered:new Set,mutationObservers:[]};return F.set(e,n),n}(n);!function(e,t=1e3){const n=T(e);D.has(n)||D.set(n,{observer:L(n),resizeObserver:M(n),timers:new WeakMap,duration:t,configs:new WeakMap,zeroArea:new WeakSet})}(n,1e3);const o=m(e.settings.prefix,a.Const.Commands.Action,!1),s=n.ownerDocument||n,i=s.defaultView;n!==s&&i&&n instanceof i.Element&&ne(e,n,o,r,n),A(n,`[${o}]`,t=>{ne(e,t,o,r,n)}),r.scrollElements.length&&ie(e,n,r),function(e,t,n,r){const o=t.ownerDocument||t,s=o.defaultView;if(!s||!s.MutationObserver)return;const i=m(e.settings.prefix,"observe",!1),c=[];t!==o&&t instanceof s.Element&&t.matches(`[${i}]`)&&c.push(t);A(t,`[${i}]`,e=>c.push(e)),c.forEach(o=>{if(c.some(e=>e!==o&&e.contains(o)))return;const i=new s.MutationObserver((0,l.tryCatch)(n=>{const o=F.get(t);o&&n.forEach(n=>{n.addedNodes.forEach(n=>function(e,t,n,r,o){var s;const i=null==(s=t.ownerDocument)?void 0:s.defaultView;if(!(i&&t instanceof i.HTMLElement))return;ne(e,t,n,r,o),A(t,`[${n}]`,t=>{ne(e,t,n,r,o)})}(e,n,r,o,t)),o.scrollElements.length&&ie(e,t,o),n.removedNodes.forEach(t=>function(e,t){var n;if(1!==t.nodeType)return;const r=null==(n=t.ownerDocument)?void 0:n.defaultView;if(!(r&&t instanceof r.HTMLElement))return;const o=m(e.settings.prefix,a.Const.Commands.Action,!1);K(t)&&Q(t);A(t,`[${o}]`,e=>{e instanceof r.HTMLElement&&K(e)&&Q(e)})}(e,t))})}));i.observe(o,{childList:!0,subtree:!0}),n.mutationObservers.push(i)})}(e,n,r,o)}async function te(e,t,n){const r=p(t,n,e.settings.prefix);return Promise.all(r.map(t=>N(e,{name:`${t.entity} ${t.action}`,...t,trigger:n})))}function ne(e,t,n,r,o){var s;if(1!==t.nodeType)return;const i=null==(s=t.ownerDocument)?void 0:s.defaultView;if(!(i&&t instanceof i.HTMLElement))return;if(K(t))return;if(!(0,u.getAttribute)(t,n))return;const c={scope:o,intervalIds:[],timeoutIds:[],scroll:!1,observed:!1};return function(e,t,n,r,o){const s=(0,u.getAttribute)(t,n);if(!s)return;Object.values(y(s)).forEach(n=>n.forEach(n=>{switch(n.trigger){case X.Hover:!function(e,t,n){n.hoverAbort||(n.hoverAbort=new AbortController);t.addEventListener("mouseenter",(0,l.tryCatch)(function(t){const n=re(t);n&&te(e,n,X.Hover)}),{signal:n.hoverAbort.signal})}(e,t,o);break;case X.Load:!function(e,t){te(e,t,X.Load)}(e,t);break;case X.Pulse:!function(e,t,n,r,o=""){const s=t.ownerDocument,i=setInterval(()=>{s.hidden||te(e,t,X.Pulse)},parseInt(o||"")||15e3);n.intervalIds.push(i),r.intervalIds.push(i)}(e,t,r,o,n.triggerParams);break;case X.Scroll:!function(e,t,n,r=""){const o=parseInt(r||"")||50;if(o<0||o>100)return;t.scrollElements.push([e,o]),n.scroll=!0}(t,r,o,n.triggerParams);break;case X.Impression:W(e,t),r.observed.add(t),o.observed=!0;break;case X.Visible:W(e,t,{multiple:!0}),r.observed.add(t),o.observed=!0;break;case X.Wait:!function(e,t,n,r,o=""){const s=setTimeout(()=>te(e,t,X.Wait),parseInt(o||"")||15e3);n.timeoutIds.push(s),r.timeoutIds.push(s)}(e,t,r,o,n.triggerParams)}}))}(e,t,n,r,c),function(e,t,n){if(J.has(t))return!1;const r=F.get(e);!!r&&(n.scope=e,r.registered.add(t),J.set(t,n))}(o,t,c),c}function re(e){var t;const n=null==(t=e.composedPath)?void 0:t.call(e),r=(null==n?void 0:n.length)?n[0]:e.target;if(r&&"object"==typeof r&&"tagName"in r)return r}function oe(e,t){const n=re(t);n&&te(e,n,X.Click)}function se(e,t){const n=re(t);n&&te(e,n,X.Submit)}function ie(e,t,n){const r=t.ownerDocument||t,o=r.defaultView,s=(e,t)=>e.filter(([e,n])=>{const r=e.getBoundingClientRect();if(o.innerHeight<r.top)return!0;const s=r.height||e.clientHeight;return!(100*(1-(r.top+s-o.innerHeight)/(s||1))>=n)||(te(t,e,X.Scroll),!1)});if(!n.scrollListener){n.scrollListener=(0,l.throttle)(function(){n.scrollElements=s.call(t,n.scrollElements,e)});(t instanceof o.ShadowRoot?r:t).addEventListener("scroll",n.scrollListener,{signal:n.abort.signal})}}var ce=require("@walkeros/core"),le=require("@walkeros/collector"),ae=Symbol.for("@walkeros/web-source-browser:elbLayer-drained"),ue=e=>{const t=Reflect.get(e,ae);if(n=t,(0,ce.isObject)(n)&&"number"==typeof n.commands&&"number"==typeof n.events)return t;var n;const r={commands:0,events:0};return Object.defineProperty(e,ae,{value:r,writable:!0,enumerable:!1,configurable:!0}),r};function fe(e,t={}){const n=t.name||"elbLayer",r=t.window,o=t.logger,s=()=>(0,le.createPushResult)({ok:!0});if(!r)return{intake:()=>Promise.resolve(s()),start:()=>{},enqueue:e=>Promise.resolve().then(()=>e()),destroy:()=>{}};const i=Reflect.get(r,n);let c;Array.isArray(i)?c=i:(c=[],Reflect.set(r,n,c));const l=ue(c);let a=!1,u=l.commands,f=l.events,d=Promise.resolve(s()),g=Promise.resolve();const m=()=>{l.commands=u,l.events=f},b=async t=>{try{return await(t=>{if(Array.isArray(t)){const[n,...r]=t;return N(e,n,...r)}return N(e,t)})(t)}catch(e){return null==o||o.warn("elbLayer entry failed",{error:e,item:t}),(0,le.createPushResult)({ok:!1})}},h=e=>{const t=e[0];return(0,ce.isString)(t)&&t.startsWith("walker ")},p=(e,t)=>{if(!a){if(h(e)){if(t<u)return Promise.resolve(s());const n=d.then(()=>b(e));return d=n,u=t+1,m(),n}return Promise.resolve(s())}const n=g.then(()=>b(e));return g=n,u=t+1,f=t+1,m(),n},v=e=>{const t=de(e),n=c.length;return c[n]=e,t?p(t,n):Promise.resolve(s())};c.push=(...e)=>{for(const t of e)v(t);return c.length};const w=c.length;for(let e=0;e<w;e++){const t=de(c[e]);t&&p(t,e)}return{intake:e=>v(e),start:()=>{if(!a){a=!0,g=d;for(let e=f;e<c.length;e++){const t=de(c[e]);if(!t)continue;if(h(t))continue;const n=t;g=g.then(()=>b(n))}f=c.length,u=c.length,m()}},enqueue:e=>{const t=g.then(()=>e());return g=t.then(()=>{},()=>{}),t},destroy:()=>{Reflect.deleteProperty(c,"push"),a=!1,u=0,f=0,d=Promise.resolve(s()),g=Promise.resolve()}}}function de(e){const t=null!=(n=e)&&"object"==typeof n&&"[object Arguments]"===Object.prototype.toString.call(n)?[...Array.from(e)]:function(e){return null!=e&&"object"==typeof e&&"length"in e&&"number"==typeof e.length}(e)?Array.from(e):[e];var n;if(!Array.isArray(t)||0===t.length)return null;if(1===t.length&&!t[0])return null;const r=t[0];return(0,ce.isObject)(r)&&0===Object.keys(r).length||!(0,ce.isObject)(r)&&(0,ce.isString)(r)&&""===r.trim()?null:t}function ge(e={},t){return{prefix:"data-elb",pageview:!0,capture:!0,elb:"elb",elbLayer:"elbLayer",scope:t||void 0,...e}}var me={},be=require("@walkeros/core");function he(e={}){const t=e.prefix||"data-elb";return function(e){let n,r=e;const o={},s={},i={},c={},l={},a={},u={};function f(e){return Object.entries(e).map(([e,t])=>`${e}:${function(e){if(!(0,be.isDefined)(e)||null===e)return"undefined";let t=String(e);return t=t.replace(/\\/g,"\\\\"),t=t.replace(/;/g,"\\;"),t=t.replace(/:/g,"\\:"),t=t.replace(/'/g,"\\'"),t}(t)}`).join(";")}const d={entity:e=>(n=e,r=e,d),data(e,t){const n=null!=r?r:"";return o[n]||(o[n]={}),(0,be.isString)(e)?o[n][e]=t:Object.assign(o[n],e),d},scoped:(e,t)=>((0,be.isString)(e)?s[e]=t:Object.assign(s,e),d),action(e,t){if((0,be.isString)(e))if((0,be.isDefined)(t))i[e]=t;else if(e.includes(":")){const[t,n]=e.split(":",2);i[t]=n}else i[e]=e;else Object.assign(i,e);return d},actions(e,t){if((0,be.isString)(e))if((0,be.isDefined)(t))c[e]=t;else if(e.includes(":")){const[t,n]=e.split(":",2);c[t]=n}else c[e]=e;else Object.assign(c,e);return d},context:(e,t)=>((0,be.isString)(e)?l[e]=t:Object.assign(l,e),d),globals:(e,t)=>((0,be.isString)(e)?a[e]=t:Object.assign(a,e),d),link:(e,t)=>((0,be.isString)(e)?u[e]=t:Object.assign(u,e),d),get(){const e={};return n&&(e[t]=n),Object.entries(o).forEach(([n,r])=>{if(Object.keys(r).length>0){e[n?`${t}-${n}`:`${t}-`]=f(r)}}),Object.keys(s).length>0&&(e[`${t}_`]=f(s)),Object.keys(i).length>0&&(e[`${t}action`]=f(i)),Object.keys(c).length>0&&(e[`${t}actions`]=f(c)),Object.keys(l).length>0&&(e[`${t}context`]=f(l)),Object.keys(a).length>0&&(e[`${t}globals`]=f(a)),Object.keys(u).length>0&&(e[`${t}link`]=f(u)),e}};return d}}var pe=Symbol.for("@walkeros/web-source-browser:instance");function ve(e){return e||(void 0!==globalThis.window?globalThis.window:void 0)}function we(){const e=ve(void 0);e&&Reflect.deleteProperty(e,pe)}function ye(){const e=ve(void 0);return e?Reflect.get(e,pe):void 0}var Ee=async e=>{const{config:t,env:n,logger:r}=e,{elb:o,command:s,window:l,document:a}=n,u=(null==t?void 0:t.settings)||{},f=l||(void 0!==globalThis.window?globalThis.window:void 0),d=a||(void 0!==globalThis.document?globalThis.document:void 0),g=ve(f);if(g){if(Reflect.get(g,pe))return{type:"browser",config:{settings:ge({},void 0)},push:(...e)=>Promise.resolve((0,c.createPushResult)({ok:!0})),on:async()=>{},init:async()=>{},destroy:async()=>{}};Object.defineProperty(g,pe,{value:!0,enumerable:!1,configurable:!0,writable:!1})}const b=ge(u,d),h={elb:o,settings:b,initScope:ee};let p,v;const y=e=>{if(!e.pageview)return;const[t,n]=function(e,t){const n=t.ownerDocument||t,r=n.defaultView.location,o="page",s="body"in t?t.body:t,[i,c]=C(s,`[${m(e,o)}]`,e,o);return i.domain=r.hostname,i.title=n.title,i.referrer=n.referrer,r.search&&(i.search=r.search),r.hash&&(i.hash=r.hash),[i,c]}(e.prefix||"data-elb",e.scope);return N(h,"page view",t,"load",n)},E=e=>{const t=w(e.prefix||"data-elb",e.scope);if(Object.keys(t).length)return N(h,"walker user",t)},k=(...e)=>{const[t,n,r,o,s,i]=e;return N(h,t,n,r,o,s,i)};return{type:"browser",config:{settings:b},push:k,on:async e=>{if("run"===e)d&&f&&(!function(e,t){if(!t.scope)return;ee(e)}(h,b),p?(p.start(),p.enqueue(()=>E(b)).catch(()=>{}),p.enqueue(()=>y(b)).catch(()=>{})):(await E(b),y(b)))},init:async()=>{if(!f||!d)return;const e=!1!==b.elbLayer?fe(h,{name:(0,i.isString)(b.elbLayer)?b.elbLayer:"elbLayer",window:f,logger:r}):void 0;if(p=e,await async function(e,t,n){const r=()=>{e(t,n)},o=n.scope;if(!o)return void r();const s=o.ownerDocument||o;"loading"!==s.readyState?r():s.addEventListener("DOMContentLoaded",r)}(Y,h,b),(0,i.isString)(b.elb)&&b.elb){const t=e?(...t)=>e.intake(t):k;v=t,Reflect.set(f,b.elb,t)}},destroy:async()=>{Z(),null==p||p.destroy(),f&&(0,i.isString)(b.elb)&&b.elb&&Reflect.get(f,b.elb)===v&&Reflect.deleteProperty(f,b.elb),g&&Reflect.deleteProperty(g,pe),p=void 0,v=void 0}}},ke=Ee;//# sourceMappingURL=index.js.map
|
|
1
|
+
"use strict";var e,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,s={};((e,n)=>{for(var r in n)t(e,r,{get:n[r],enumerable:!0})})(s,{SourceBrowser:()=>he,__readInstanceGuardForTests:()=>we,__resetInstanceCountForTests:()=>ye,createTagger:()=>ve,default:()=>ke,getAllEvents:()=>b,getElbAttributeName:()=>g,getElbValues:()=>m,getEvents:()=>h,getGlobals:()=>p,getUser:()=>v,sourceBrowser:()=>Ee}),module.exports=(e=s,((e,s,i,c)=>{if(s&&"object"==typeof s||"function"==typeof s)for(let l of r(s))o.call(e,l)||l===i||t(e,l,{get:()=>s[l],enumerable:!(c=n(s,l))||c.enumerable});return e})(t({},"__esModule",{value:!0}),e));var i=require("@walkeros/core"),c=require("@walkeros/core"),l=require("@walkeros/collector"),a=require("@walkeros/web-core"),u=require("@walkeros/core"),f=require("@walkeros/collector"),d=require("@walkeros/web-core");function g(e,t,n=!0){return e+(t=null!=t?(n?"-":"")+t:"")}function m(e,t,n,r=!0){return A((0,d.getAttribute)(t,g(e,n,r))||"").reduce((e,n)=>{let[r,o]=S(n);if(!r)return e;if(o||(r.endsWith(":")&&(r=r.slice(0,-1)),o=""),o.startsWith("#")){o=o.slice(1);try{let e=t[o];e||"selected"!==o||(e=t.options[t.selectedIndex].text),o=String(e)}catch(e){o=""}}return r.endsWith("[]")?(r=r.slice(0,-2),(0,u.isArray)(e[r])||(e[r]=[]),e[r].push((0,u.castValue)(o))):e[r]=(0,u.castValue)(o),e},{})}function b(e,t=f.Const.Commands.Prefix){var n;const r=e;if(!r)return[];let o=[];const s=f.Const.Commands.Action,i=`[${g(t,s,!1)}]`,c=e=>{Object.keys(m(t,e,s,!1)).forEach(n=>{o=o.concat(h(e,n,t))})};return r!==(r.ownerDocument||r)&&(null==(n=r.matches)?void 0:n.call(r,i))&&c(r),j(r,i,c),o}function h(e,t,n=f.Const.Commands.Prefix){const r=[],{actions:o,nearestOnly:s}=function(e,t,n){let r=t;for(;r;){const t=(0,d.getAttribute)(r,g(e,f.Const.Commands.Actions,!1));if(t){const e=y(t);if(e[n])return{actions:e[n],nearestOnly:!1}}const o=(0,d.getAttribute)(r,g(e,f.Const.Commands.Action,!1));if(o){const e=y(o);if(e[n]||"click"!==n)return{actions:e[n]||[],nearestOnly:!0}}r=k(e,r)}return{actions:[],nearestOnly:!1}}(n,e,t);return o.length?(o.forEach(o=>{const i=A(o.actionParams||"",",").reduce((e,t)=>(e[(0,u.trim)(t)]=!0,e),{}),c=w(n,e,i,s);if(!c.length){const t="page",r=`[${g(n,t)}]`,[o,s]=O(e,r,n,t);c.push({entity:t,data:o,nested:[],context:s})}c.forEach(e=>{var n;r.push({entity:e.entity,action:o.action,data:e.data,trigger:t,context:e.context,nested:null!=(n=e.nested)?n:[]})})}),r):r}function p(e=f.Const.Commands.Prefix,t){if(!t)return{};const n=g(e,f.Const.Commands.Globals,!1);let r={};return C(t,`[${n}]`,t=>{r=(0,u.assign)(r,m(e,t,f.Const.Commands.Globals,!1))}),r}function v(e=f.Const.Commands.Prefix,t){if(!t)return{};const n=g(e,f.Const.Commands.User,!1);let r={};return C(t,`[${n}]`,t=>{r=(0,u.assign)(r,m(e,t,f.Const.Commands.User,!1))}),r}function y(e){const t={};return A(e).forEach(e=>{const[n,r]=S(e),[o,s]=P(n);if(!o)return;let[i,c]=P(r||"");i=i||o,t[o]||(t[o]=[]),t[o].push({trigger:o,triggerParams:s,action:i,actionParams:c})}),t}function w(e,t,n,r=!1){const o=[];let s=t;for(n=0!==Object.keys(n||{}).length?n:void 0;s;){const i=E(e,s,t,n);if(i&&(o.push(i),r))break;s=k(e,s)}return o}function E(e,t,n,r){const o=(0,d.getAttribute)(t,g(e));if(!o||r&&!r[o])return null;const s=[t],i=`[${g(e,o)}],[${g(e,"")}]`,c=g(e,f.Const.Commands.Link,!1);let l={};const a=[],[b,h]=O(n||t,i,e,o,!0);j(t,`[${c}]`,n=>{const[r,o]=S((0,d.getAttribute)(n,c));"parent"===o&&j(t.ownerDocument.body,`[${c}="${r}:child"]`,t=>{s.push(t);const n=E(e,t);n&&a.push(n)})});const p=[];s.forEach(e=>{e.matches(i)&&p.push(e),j(e,i,e=>p.push(e))});let v={};return p.forEach(t=>{v=(0,u.assign)(v,m(e,t,"")),l=(0,u.assign)(l,m(e,t,o))}),l=(0,u.assign)((0,u.assign)(v,l),b),s.forEach(t=>{j(t,`[${g(e)}]`,t=>{const n=E(e,t);n&&a.push(n)})}),{entity:o,data:l,context:h,nested:a}}function k(e,t){const n=g(e,f.Const.Commands.Link,!1);if(t.matches(`[${n}]`)){const[e,r]=S((0,d.getAttribute)(t,n));if("child"===r){const r=t.ownerDocument;let o=null;return C(r,`[${n}="${e}:parent"]`,e=>{o||(o=e)}),o}}const r=t.ownerDocument.defaultView;return!t.parentElement&&t.getRootNode&&t.getRootNode()instanceof r.ShadowRoot?t.getRootNode().host:t.parentElement}function O(e,t,n,r,o=!1){let s={};const i={};let c=e;const l=`[${g(n,f.Const.Commands.Context,!1)}]`,a=f.Const.Commands.Scoped,d=`[${g(n,a,!1)}]`;let b=0;for(;c;)o&&a&&c.matches(d)&&(s=(0,u.assign)(m(n,c,a,!1),s)),c.matches(t)&&(s=(0,u.assign)(m(n,c,""),s),s=(0,u.assign)(m(n,c,r),s)),c.matches(l)&&(Object.entries(m(n,c,f.Const.Commands.Context,!1)).forEach(([e,t])=>{t&&!i[e]&&(i[e]=[t,b])}),++b),c=k(n,c);return[s,i]}function C(e,t,n){e.querySelectorAll(t).forEach(n)}function j(e,t,n){e.querySelectorAll(t).forEach(n);e instanceof(e.ownerDocument||e).defaultView.Element&&e.shadowRoot&&j(e.shadowRoot,t,n),e.querySelectorAll("*").forEach(e=>{e.shadowRoot&&j(e.shadowRoot,t,n)})}function A(e,t=";"){if(!e)return[];const n=new RegExp(`(?:[^${t}']+|'[^']*')+`,"ig");return e.match(n)||[]}function S(e){const[t,n]=e.split(/:(.+)/,2);return[(0,u.trim)(t),(0,u.trim)(n)]}function P(e){const[t,n]=e.split("(",2);return[t,n?n.slice(0,-1):""]}var $=require("@walkeros/core"),x=require("@walkeros/web-core");var R=Array.from({length:101},(e,t)=>t/100);function I(e){return e.ownerDocument||e}function L(e,t){const n=t.defaultView;if(n&&n.IntersectionObserver)return(0,$.tryCatch)(()=>new n.IntersectionObserver(n=>{n.forEach(n=>function(e,t,n){const r=n.target,o=e.visibility.get(t);if(!o)return;const s=r.ownerDocument.defaultView;if(!s)return;const i=o.configs.get(r);if(!i||!i.length)return;const c=o.timers.get(r);if(function(e,t){if(!e.isIntersecting)return!1;const n=e.boundingClientRect;if(n.width<=0||n.height<=0)return!1;const r=e.rootBounds?e.rootBounds.width:t.innerWidth,o=e.rootBounds?e.rootBounds.height:t.innerHeight;if(r<=0||o<=0)return!1;const s=e.intersectionRect,i=.5*Math.min(n.width,r),c=.5*Math.min(n.height,o);return s.width>=i&&s.height>=c}(n,s)){if(i.every(e=>e.blocked))return;if(!c){const n=s.setTimeout(()=>{D(e,t,r)},o.duration);o.timers.set(r,n)}return}c&&(clearTimeout(c),o.timers.delete(r));i.forEach(e=>{e.multiple&&(e.blocked=!1)})}(e,t,n))},{rootMargin:"0px",threshold:R}),()=>{})()}async function D(e,t,n,r=!1){const o=e.visibility.get(t);if(!o)return;o.timers.delete(n);const s=t.defaultView;if(!s)return;if("visible"!==t.visibilityState)return void o.timers.set(n,s.setTimeout(()=>{D(e,t,n,!0)},o.duration));if(r)return void o.timers.set(n,s.setTimeout(()=>{D(e,t,n)},o.duration));if(!(0,x.isVisible)(n,s,t))return void o.timers.set(n,s.setTimeout(()=>{D(e,t,n)},o.duration));const i=o.configs.get(n);if(!i)return;const c=i.filter(e=>!e.blocked);if(!c.length)return;c.forEach(e=>{e.multiple&&(e.blocked=!0)});const l=i.filter(e=>e.multiple);l.length?o.configs.set(n,l):T(e,t,n),await Promise.all(c.map(e=>X(e.context,n,e.trigger)))}function T(e,t,n){var r,o;const s=e.visibility.get(I(t));if(!s)return;null==(r=s.observer)||r.unobserve(n),null==(o=s.resizeObserver)||o.unobserve(n),s.configs.delete(n),s.zeroArea.delete(n);const i=s.timers.get(n);i&&(clearTimeout(i),s.timers.delete(n))}function V(e,t){const n=t.defaultView;if(n&&n.ResizeObserver)return(0,$.tryCatch)(()=>new n.ResizeObserver(n=>{const r=e.visibility.get(t);(null==r?void 0:r.observer)&&n.forEach(e=>{var t,n;const o=e.target,{width:s,height:i}=e.contentRect;s<=0||i<=0?r.zeroArea.add(o):r.zeroArea.has(o)&&(r.zeroArea.delete(o),null==(t=r.observer)||t.unobserve(o),null==(n=r.observer)||n.observe(o))})}),()=>{})()}function q(e,t,n={multiple:!1}){var r,o,s;const i=e.settings.scope;if(!i)return;const c=e.registry.visibility.get(I(i));if(!(null==c?void 0:c.observer)||!t)return;const l=null!=(r=n.multiple)&&r,a=null!=(o=c.configs.get(t))?o:[],u=a.length>0,f=l?F.Visible:F.Impression,d={multiple:l,blocked:!1,context:e,trigger:f},g=a.findIndex(e=>e.trigger===f);if(g>=0?a[g]=d:a.push(d),c.configs.set(t,a),u)return;const m=t.getBoundingClientRect();(m.width<=0||m.height<=0)&&c.zeroArea.add(t),c.observer.observe(t),null==(s=c.resizeObserver)||s.observe(t)}var M=require("@walkeros/core"),W=require("@walkeros/collector");function z(e,t,n,r,o,s,i){const{elb:c,settings:l}=e;if((0,M.isString)(t)&&t.startsWith("walker ")){if("walker init"===t&&e.initScope){const t=function(e,t){if(B(e))return[e];if(Array.isArray(e)){const t=[];for(const n of e)B(n)&&t.push(n);return t}if(void 0===e){const e=t.scope;if(B(e))return[e];if(void 0!==globalThis.document)return[globalThis.document]}return[]}(n,l);for(const n of t)e.initScope({...e,settings:{...l,scope:n}});return Promise.resolve((0,W.createPushResult)({ok:!0}))}return c(t,n)}if((0,M.isObject)(t)){const e=t;if(!e.source&&l.scope){const t=l.scope.ownerDocument||l.scope,n=t.defaultView;e.source=H(n,t)}return!e.globals&&l.scope&&(e.globals=N(l.scope)?p(l.prefix,l.scope):{}),c(e)}const[a]=String((0,M.isObject)(t)?t.name:t).split(" ");let u,f=(0,M.isObject)(n)?n:{},d={},g=!1;if((0,M.isElementOrDocument)(n)&&(u=n,g=!0),(0,M.isElementOrDocument)(o)?u=o:(0,M.isObject)(o)&&Object.keys(o).length&&(d=o),u){const e=w(l.prefix||"data-elb",u).find(e=>e.entity===a);e&&(g&&(f=e.data),e.context&&(d=e.context))}const m=l.scope?l.scope.ownerDocument||l.scope:void 0,b=null==m?void 0:m.defaultView;"page"===a&&b&&(f.id=f.id||b.location.pathname);const h=l.scope&&N(l.scope)?p(l.prefix,l.scope):{};return c({name:String(t||""),data:f,context:d,globals:h,nested:s,custom:i,trigger:(0,M.isString)(r)?r:"",source:b&&m?H(b,m):void 0})}function H(e,t){return{type:"browser",platform:"web",url:e.location.href,referrer:t.referrer}}function B(e){if(!e||"object"!=typeof e)return!1;if("undefined"!=typeof Element&&e instanceof Element)return!0;if("undefined"!=typeof Document&&e instanceof Document)return!0;if("undefined"!=typeof ShadowRoot&&e instanceof ShadowRoot)return!0;if("nodeType"in e){const t=e.nodeType;return 1===t||9===t||11===t}return!1}function N(e){return 11!==e.nodeType}function _(e){var t,n;return new(null!=(n=null==(t=(e.ownerDocument||e).defaultView)?void 0:t.AbortController)?n:AbortController)}function G(e,t){return e.elements.has(t)}function U(e,t){var n;const r=e.elements.get(t);if(!r)return;const o=e.scopes.get(r.scope);r.intervalIds.forEach(e=>{if(clearInterval(e),o){const t=o.intervalIds.indexOf(e);-1!==t&&o.intervalIds.splice(t,1)}}),r.timeoutIds.forEach(e=>{if(clearTimeout(e),o){const t=o.timeoutIds.indexOf(e);-1!==t&&o.timeoutIds.splice(t,1)}}),null==(n=r.hoverAbort)||n.abort(),r.observed&&(T(e,r.scope,t),null==o||o.observed.delete(t)),r.scroll&&o&&(o.scrollElements=o.scrollElements.filter(([e])=>e!==t)),null==o||o.registered.delete(t),e.elements.delete(t)}var F={Click:"click",Custom:"custom",Hover:"hover",Load:"load",Pulse:"pulse",Scroll:"scroll",Submit:"submit",Impression:"impression",Visible:"visible",Wait:"wait"};function J(e,t){t.scope&&function(e){const{scope:t,capture:n}=e.settings;if(!t)return;if(e.registry.destroyed)return;const{registry:r}=e;r.root&&r.root.abort();r.root=_(t);const{signal:o}=r.root;t.addEventListener("click",(0,c.tryCatch)(function(t){ee.call(this,e,t)}),{signal:o,capture:n}),t.addEventListener("submit",(0,c.tryCatch)(function(t){te.call(this,e,t)}),{signal:o,capture:n})}(e)}function K(e){const{registry:t}=e;t.destroyed=!0,t.root&&(t.root.abort(),t.root=void 0),t.scopes.forEach((e,n)=>{e.abort.abort(),e.mutationObservers.forEach(e=>e.disconnect()),e.intervalIds.forEach(e=>clearInterval(e)),e.timeoutIds.forEach(e=>clearTimeout(e)),e.observed.forEach(e=>T(t,n,e)),[...e.registered].forEach(e=>U(t,e))}),t.scopes.forEach((e,n)=>{!function(e,t){var n,r;if(!t)return;const o=I(t),s=e.visibility.get(o);s&&(null==(n=s.observer)||n.disconnect(),null==(r=s.resizeObserver)||r.disconnect(),e.visibility.delete(o))}(t,n)}),t.scopes.clear()}function Q(e){const t=e.settings.scope;if(!t)return;if(e.registry.destroyed)return;const n=function(e,t){const n=e.scopes.get(t);n&&(n.abort.abort(),n.intervalIds.forEach(e=>clearInterval(e)),n.timeoutIds.forEach(e=>clearTimeout(e)),n.observed.forEach(n=>T(e,t,n)),[...n.registered].forEach(t=>U(e,t)),n.mutationObservers.forEach(e=>e.disconnect()));const r={abort:_(t),intervalIds:[],timeoutIds:[],scrollElements:[],observed:new Set,registered:new Set,mutationObservers:[]};return e.scopes.set(t,r),r}(e.registry,t);!function(e,t,n=1e3){const r=I(t);if(e.visibility.has(r))return;const o={observer:L(e,r),resizeObserver:V(e,r),timers:new WeakMap,duration:n,configs:new WeakMap,zeroArea:new WeakSet};e.visibility.set(r,o)}(e.registry,t,1e3);const r=g(e.settings.prefix,l.Const.Commands.Action,!1),o=t.ownerDocument||t,s=o.defaultView;t!==o&&s&&t instanceof s.Element&&Y(e,t,r,n,t),j(t,`[${r}]`,o=>{Y(e,o,r,n,t)}),n.scrollElements.length&&ne(e,t,n),function(e,t,n,r){const o=t.ownerDocument||t,s=o.defaultView;if(!s||!s.MutationObserver)return;const i=g(e.settings.prefix,"observe",!1),a=[];t!==o&&t instanceof s.Element&&t.matches(`[${i}]`)&&a.push(t);j(t,`[${i}]`,e=>a.push(e)),a.forEach(o=>{if(a.some(e=>e!==o&&e.contains(o)))return;const i=new s.MutationObserver((0,c.tryCatch)(n=>{const o=e.registry.scopes.get(t);o&&n.forEach(n=>{n.addedNodes.forEach(n=>function(e,t,n,r,o){var s;const i=null==(s=t.ownerDocument)?void 0:s.defaultView;if(!(i&&t instanceof i.HTMLElement))return;Y(e,t,n,r,o),j(t,`[${n}]`,t=>{Y(e,t,n,r,o)})}(e,n,r,o,t)),o.scrollElements.length&&ne(e,t,o),n.removedNodes.forEach(t=>function(e,t){var n;if(1!==t.nodeType)return;const r=null==(n=t.ownerDocument)?void 0:n.defaultView;if(!(r&&t instanceof r.HTMLElement))return;const{registry:o}=e,s=g(e.settings.prefix,l.Const.Commands.Action,!1);G(o,t)&&U(o,t);j(t,`[${s}]`,e=>{e instanceof r.HTMLElement&&G(o,e)&&U(o,e)})}(e,t))})}));i.observe(o,{childList:!0,subtree:!0}),n.mutationObservers.push(i)})}(e,t,n,r)}async function X(e,t,n){const r=h(t,n,e.settings.prefix);return Promise.all(r.map(t=>z(e,{name:`${t.entity} ${t.action}`,...t,trigger:n})))}function Y(e,t,n,r,o){var s;if(1!==t.nodeType)return;const i=null==(s=t.ownerDocument)?void 0:s.defaultView;if(!(i&&t instanceof i.HTMLElement))return;if(G(e.registry,t))return;if(!(0,a.getAttribute)(t,n))return;const l={scope:o,intervalIds:[],timeoutIds:[],scroll:!1,observed:!1};return function(e,t,n,r,o){const s=(0,a.getAttribute)(t,n);if(!s)return;Object.values(y(s)).forEach(n=>n.forEach(n=>{switch(n.trigger){case F.Hover:!function(e,t,n){n.hoverAbort||(n.hoverAbort=_(t));t.addEventListener("mouseenter",(0,c.tryCatch)(function(t){const n=Z(t);n&&X(e,n,F.Hover)}),{signal:n.hoverAbort.signal})}(e,t,o);break;case F.Load:!function(e,t){X(e,t,F.Load)}(e,t);break;case F.Pulse:!function(e,t,n,r,o=""){const s=t.ownerDocument,i=setInterval(()=>{s.hidden||X(e,t,F.Pulse)},parseInt(o||"")||15e3);n.intervalIds.push(i),r.intervalIds.push(i)}(e,t,r,o,n.triggerParams);break;case F.Scroll:!function(e,t,n,r=""){const o=parseInt(r||"")||50;if(o<0||o>100)return;t.scrollElements.push([e,o]),n.scroll=!0}(t,r,o,n.triggerParams);break;case F.Impression:q(e,t),r.observed.add(t),o.observed=!0;break;case F.Visible:q(e,t,{multiple:!0}),r.observed.add(t),o.observed=!0;break;case F.Wait:!function(e,t,n,r,o=""){const s=setTimeout(()=>X(e,t,F.Wait),parseInt(o||"")||15e3);n.timeoutIds.push(s),r.timeoutIds.push(s)}(e,t,r,o,n.triggerParams)}}))}(e,t,n,r,l),function(e,t,n,r){if(e.elements.has(n))return!1;const o=e.scopes.get(t);!!o&&(r.scope=t,o.registered.add(n),e.elements.set(n,r))}(e.registry,o,t,l),l}function Z(e){var t;const n=null==(t=e.composedPath)?void 0:t.call(e),r=(null==n?void 0:n.length)?n[0]:e.target;if(r&&"object"==typeof r&&"tagName"in r)return r}function ee(e,t){const n=Z(t);n&&X(e,n,F.Click)}function te(e,t){const n=Z(t);n&&X(e,n,F.Submit)}function ne(e,t,n){const r=t.ownerDocument||t,o=r.defaultView,s=(e,t)=>e.filter(([e,n])=>{const r=e.getBoundingClientRect();if(o.innerHeight<r.top)return!0;const s=r.height||e.clientHeight;return!(100*(1-(r.top+s-o.innerHeight)/(s||1))>=n)||(X(t,e,F.Scroll),!1)});if(!n.scrollListener){n.scrollListener=(0,c.throttle)(function(){n.scrollElements=s.call(t,n.scrollElements,e)});(t instanceof o.ShadowRoot?r:t).addEventListener("scroll",n.scrollListener,{signal:n.abort.signal})}}var re=require("@walkeros/core"),oe=require("@walkeros/collector"),se=require("@walkeros/core"),ie=Symbol.for("@walkeros/web-source-browser:owner"),ce=e=>null!==e&&("object"==typeof e||"function"==typeof e),le=e=>ce(e)&&"function"==typeof Reflect.get(e,"get")&&"function"==typeof Reflect.get(e,"set")&&"function"==typeof Reflect.get(e,"has");function ae(e,t){return(0,se.tryCatch)(()=>{Object.defineProperty(e,ie,{value:t,writable:!0,enumerable:!1,configurable:!0})})(),e}function ue(e){if(!ce(e))return;const t=Reflect.get(e,ie);return(e=>(0,se.isObject)(e)&&le(e.scopes)&&le(e.elements))(t)?t:void 0}function fe(e){Reflect.deleteProperty(e,ie)}var de=Symbol.for("@walkeros/web-source-browser:elbLayer-drained"),ge=e=>{const t=Reflect.get(e,de);if(n=t,(0,re.isObject)(n)&&"number"==typeof n.commands&&"number"==typeof n.events)return t;var n;const r={commands:0,events:0};return(0,re.tryCatch)(()=>{Object.defineProperty(e,de,{value:r,writable:!0,enumerable:!1,configurable:!0})})(),r};function me(e,t={}){const n=t.name||"elbLayer",r=t.window,o=t.logger,s=()=>(0,oe.createPushResult)({ok:!0}),i=()=>({intake:()=>Promise.resolve(s()),start:()=>{},enqueue:e=>Promise.resolve().then(()=>e()),destroy:()=>{}});if(!r)return i();const c=Reflect.get(r,n);let l;Array.isArray(c)?l=c:(l=[],Reflect.set(r,n,l));const{registry:a}=e,u=ue(l);if(u&&u!==a)return null==o||o.error(`elbLayer "${n}" is already adopted by another source`),i();ae(l,a);const f=ge(l);let d=!1,g=f.commands,m=f.events,b=Promise.resolve(s()),h=Promise.resolve();const p=()=>{f.commands=g,f.events=m},v=async t=>{try{return await(t=>{if(Array.isArray(t)){const[n,...r]=t;return z(e,n,...r)}return z(e,t)})(t)}catch(e){return null==o||o.warn("elbLayer entry failed",{error:e,item:t}),(0,oe.createPushResult)({ok:!1})}},y=e=>{const t=e[0];return(0,re.isString)(t)&&t.startsWith("walker ")},w=(e,t)=>{if(!d){if(y(e)){if(t<g)return Promise.resolve(s());const n=b.then(()=>v(e));return b=n,g=t+1,p(),n}return Promise.resolve(s())}const n=h.then(()=>v(e));return h=n,g=t+1,m=t+1,p(),n},E=[],k=e=>{const t=be(e),n=l.length,r=(0,re.tryCatch)(()=>(l[n]=e,!0))();return t?r?w(t,n):(e=>{if(!d){if(y(e)){const t=b.then(()=>v(e));return b=t,t}return E.push(e),Promise.resolve(s())}const t=h.then(()=>v(e));return h=t,t})(t):Promise.resolve(s())},O=(...e)=>{for(const t of e)k(t);return l.length};(0,re.tryCatch)(()=>{l.push=O})();const C=l.length;for(let e=0;e<C;e++){const t=be(l[e]);t&&w(t,e)}return{intake:e=>k(e),start:()=>{if(!d){d=!0,h=b;for(let e=m;e<l.length;e++){const t=be(l[e]);if(!t)continue;if(y(t))continue;const n=t;h=h.then(()=>v(n))}E.splice(0,E.length).forEach(e=>{h=h.then(()=>v(e))}),m=l.length,g=l.length,p()}},enqueue:e=>{const t=h.then(()=>e());return h=t.then(()=>{},()=>{}),t},destroy:()=>{l.push===O&&Reflect.deleteProperty(l,"push"),fe(l),d=!1,E.length=0,g=0,m=0,b=Promise.resolve(s()),h=Promise.resolve()}}}function be(e){const t=null!=(n=e)&&"object"==typeof n&&"[object Arguments]"===Object.prototype.toString.call(n)?[...Array.from(e)]:function(e){return null!=e&&"object"==typeof e&&"length"in e&&"number"==typeof e.length}(e)?Array.from(e):[e];var n;if(!Array.isArray(t)||0===t.length)return null;if(1===t.length&&!t[0])return null;const r=t[0];return(0,re.isObject)(r)&&0===Object.keys(r).length||!(0,re.isObject)(r)&&(0,re.isString)(r)&&""===r.trim()?null:t}var he={},pe=require("@walkeros/core");function ve(e={}){const t=e.prefix||"data-elb";return function(e){let n,r=e;const o={},s={},i={},c={},l={},a={},u={};function f(e){return Object.entries(e).map(([e,t])=>`${e}:${function(e){if(!(0,pe.isDefined)(e)||null===e)return"undefined";let t=String(e);return t=t.replace(/\\/g,"\\\\"),t=t.replace(/;/g,"\\;"),t=t.replace(/:/g,"\\:"),t=t.replace(/'/g,"\\'"),t}(t)}`).join(";")}const d={entity:e=>(n=e,r=e,d),data(e,t){const n=null!=r?r:"";return o[n]||(o[n]={}),(0,pe.isString)(e)?o[n][e]=t:Object.assign(o[n],e),d},scoped:(e,t)=>((0,pe.isString)(e)?s[e]=t:Object.assign(s,e),d),action(e,t){if((0,pe.isString)(e))if((0,pe.isDefined)(t))i[e]=t;else if(e.includes(":")){const[t,n]=e.split(":",2);i[t]=n}else i[e]=e;else Object.assign(i,e);return d},actions(e,t){if((0,pe.isString)(e))if((0,pe.isDefined)(t))c[e]=t;else if(e.includes(":")){const[t,n]=e.split(":",2);c[t]=n}else c[e]=e;else Object.assign(c,e);return d},context:(e,t)=>((0,pe.isString)(e)?l[e]=t:Object.assign(l,e),d),globals:(e,t)=>((0,pe.isString)(e)?a[e]=t:Object.assign(a,e),d),link:(e,t)=>((0,pe.isString)(e)?u[e]=t:Object.assign(u,e),d),get(){const e={};return n&&(e[t]=n),Object.entries(o).forEach(([n,r])=>{if(Object.keys(r).length>0){e[n?`${t}-${n}`:`${t}-`]=f(r)}}),Object.keys(s).length>0&&(e[`${t}_`]=f(s)),Object.keys(i).length>0&&(e[`${t}action`]=f(i)),Object.keys(c).length>0&&(e[`${t}actions`]=f(c)),Object.keys(l).length>0&&(e[`${t}context`]=f(l)),Object.keys(a).length>0&&(e[`${t}globals`]=f(a)),Object.keys(u).length>0&&(e[`${t}link`]=f(u)),e}};return d}}function ye(){}function we(){}var Ee=async e=>{const{config:t,env:n,logger:r}=e,{elb:o,command:s,window:c,document:l}=n,a=(null==t?void 0:t.settings)||{},u=c||(void 0!==globalThis.window?globalThis.window:void 0),f=l||(void 0!==globalThis.document?globalThis.document:void 0),d=function(e={},t){return{prefix:"data-elb",pageview:!0,capture:!0,elb:"elb",elbLayer:"elbLayer",scope:t||void 0,...e}}(a,f),m={settings:d},b={scopes:new Map,elements:new WeakMap,visibility:new WeakMap,destroyed:!1},h={elb:o,settings:d,registry:b,logger:r,initScope:Q};let p,y,w=!1;const E=e=>{if(!e.pageview)return;const[t,n]=function(e,t){const n=t.ownerDocument||t,r=n.defaultView.location,o="page",s="body"in t?t.body:t,[i,c]=O(s,`[${g(e,o)}]`,e,o);return i.domain=r.hostname,i.title=n.title,i.referrer=n.referrer,r.search&&(i.search=r.search),r.hash&&(i.hash=r.hash),[i,c]}(e.prefix||"data-elb",e.scope);return z(h,"page view",t,"load",n)},k=e=>{const t=v(e.prefix||"data-elb",e.scope);if(Object.keys(t).length)return z(h,"walker user",t)},C=(...e)=>{const[t,n,r,o,s,i]=e;return z(h,t,n,r,o,s,i)};return{type:"browser",config:m,push:C,on:async e=>{if("run"===e)f&&u&&!b.destroyed&&(!function(e,t){t.scope&&Q(e)}(h,d),p?(p.start(),p.enqueue(()=>k(d)).catch(()=>{}),p.enqueue(()=>E(d)).catch(()=>{})):(await k(d),E(d)))},init:async()=>{if(!u||!f)return;if(w)return;w=!0;const e=(0,i.isString)(d.elbLayer)?d.elbLayer:"elbLayer",t=!1!==d.elbLayer?me(h,{name:e,window:u,logger:r}):void 0,n=Reflect.get(u,e),o=t&&ue(n)===b?t:void 0;if(p=o,await async function(e,t,n){const r=()=>{t.registry.destroyed||e(t,n)},o=n.scope;if(!o)return void r();const s=o.ownerDocument||o;if("loading"!==s.readyState)return void r();const{registry:i}=t;i.root||(i.root=_(o)),s.addEventListener("DOMContentLoaded",r,{signal:i.root.signal})}(J,h,d),(0,i.isString)(d.elb)&&d.elb){const e=ue(Reflect.get(u,d.elb));if(e&&e!==b)null==r||r.error(`elb "${d.elb}" is already installed by another source`);else{const e=o?(...e)=>o.intake(e):C;y=ae(e,b),Reflect.set(u,d.elb,e)}}},destroy:async()=>{K(h),null==p||p.destroy(),u&&(0,i.isString)(d.elb)&&d.elb&&Reflect.get(u,d.elb)===y&&Reflect.deleteProperty(u,d.elb),y&&fe(y),p=void 0,y=void 0}}},ke=Ee;//# sourceMappingURL=index.js.map
|