@walkeros/web-core 4.8.1 → 4.8.2
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 +29 -0
- package/dist/dev.d.mts +28 -0
- package/dist/dev.d.ts +28 -0
- package/dist/dev.js +1 -0
- package/dist/dev.js.map +1 -0
- package/dist/dev.mjs +1 -0
- package/dist/dev.mjs.map +1 -0
- package/dist/index.d.mts +111 -2
- package/dist/index.d.ts +111 -2
- 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/package.json +9 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# @walkeros/web-core
|
|
2
2
|
|
|
3
|
+
## 4.8.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- b1d65e2: `loadVendor` injects the script into the document that `env`
|
|
8
|
+
provides, falling back to the page's own, and fails with `vendor-not-ready`
|
|
9
|
+
when there is no document at all. The new `@walkeros/web-core/dev` entry
|
|
10
|
+
exports `mockScriptDocument()` for examples and tests that run without a
|
|
11
|
+
browser.
|
|
12
|
+
- 964590a: `@walkeros/web-core` exports `moin`, `browserSwapActivator` and
|
|
13
|
+
`pageObserveSlot`, and `@walkeros/web-core/dev` exports `page` for the
|
|
14
|
+
conformance tests of web steps.
|
|
15
|
+
- 2374f54: `sendWeb` now throws a `StepError` instead of resolving
|
|
16
|
+
`{ ok: false }`: `transport` with the status for an error answer or a network
|
|
17
|
+
error, `timeout`, or `beacon-rejected`. A fetch skips `keepalive` past the
|
|
18
|
+
browser's 64 KiB limit. New `loadVendor` loads a vendor script once per page
|
|
19
|
+
and reports `vendor-not-loaded`, `vendor-not-ready` or `vendor-timeout`.
|
|
20
|
+
- Updated dependencies [2374f54]
|
|
21
|
+
- Updated dependencies [7e5fc27]
|
|
22
|
+
- Updated dependencies [2374f54]
|
|
23
|
+
- Updated dependencies [964590a]
|
|
24
|
+
- Updated dependencies [4100ede]
|
|
25
|
+
- Updated dependencies [2374f54]
|
|
26
|
+
- Updated dependencies [2374f54]
|
|
27
|
+
- Updated dependencies [15eb7b2]
|
|
28
|
+
- Updated dependencies [33a2779]
|
|
29
|
+
- Updated dependencies [33a2779]
|
|
30
|
+
- @walkeros/core@4.8.2
|
|
31
|
+
|
|
3
32
|
## 4.8.1
|
|
4
33
|
|
|
5
34
|
### Patch Changes
|
package/dist/dev.d.mts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Flow } from '@walkeros/core';
|
|
2
|
+
|
|
3
|
+
/** A script element, as far as `loadVendor` uses one. */
|
|
4
|
+
type MockScript = {
|
|
5
|
+
src: string;
|
|
6
|
+
async: boolean;
|
|
7
|
+
getAttribute(name: string): string | null;
|
|
8
|
+
setAttribute(name: string, value: string): void;
|
|
9
|
+
addEventListener(type: string, listener: () => void): void;
|
|
10
|
+
};
|
|
11
|
+
/** A document, as far as `loadVendor` injects into one. */
|
|
12
|
+
type MockScriptDocument = {
|
|
13
|
+
querySelectorAll(selector: string): MockScript[];
|
|
14
|
+
createElement(tagName: string): MockScript;
|
|
15
|
+
head: {
|
|
16
|
+
appendChild(script: MockScript): void;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* A document without a DOM for `loadVendor` to inject into, for an examples
|
|
21
|
+
* env (tests, simulation in Node). It keeps the scripts appended to its head,
|
|
22
|
+
* so each src goes in once, and an appended script loads at once.
|
|
23
|
+
*/
|
|
24
|
+
declare function mockScriptDocument(): MockScriptDocument;
|
|
25
|
+
|
|
26
|
+
declare const page: Flow.StepPage;
|
|
27
|
+
|
|
28
|
+
export { type MockScript, type MockScriptDocument, mockScriptDocument, page };
|
package/dist/dev.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Flow } from '@walkeros/core';
|
|
2
|
+
|
|
3
|
+
/** A script element, as far as `loadVendor` uses one. */
|
|
4
|
+
type MockScript = {
|
|
5
|
+
src: string;
|
|
6
|
+
async: boolean;
|
|
7
|
+
getAttribute(name: string): string | null;
|
|
8
|
+
setAttribute(name: string, value: string): void;
|
|
9
|
+
addEventListener(type: string, listener: () => void): void;
|
|
10
|
+
};
|
|
11
|
+
/** A document, as far as `loadVendor` injects into one. */
|
|
12
|
+
type MockScriptDocument = {
|
|
13
|
+
querySelectorAll(selector: string): MockScript[];
|
|
14
|
+
createElement(tagName: string): MockScript;
|
|
15
|
+
head: {
|
|
16
|
+
appendChild(script: MockScript): void;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* A document without a DOM for `loadVendor` to inject into, for an examples
|
|
21
|
+
* env (tests, simulation in Node). It keeps the scripts appended to its head,
|
|
22
|
+
* so each src goes in once, and an appended script loads at once.
|
|
23
|
+
*/
|
|
24
|
+
declare function mockScriptDocument(): MockScriptDocument;
|
|
25
|
+
|
|
26
|
+
declare const page: Flow.StepPage;
|
|
27
|
+
|
|
28
|
+
export { type MockScript, type MockScriptDocument, mockScriptDocument, page };
|
package/dist/dev.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e,t=Object.defineProperty,r=Object.getOwnPropertyDescriptor,s=Object.getOwnPropertyNames,n=Object.prototype.hasOwnProperty,o={};function a(){const e=[],t=new WeakMap;return{querySelectorAll:()=>[...e],createElement:()=>{const e=new Map,r={src:"",async:!1,getAttribute:t=>{var s;return"src"===t?r.src:null!=(s=e.get(t))?s:null},setAttribute:(t,r)=>{e.set(t,r)},addEventListener:(e,s)=>{var n;"load"===e&&t.set(r,[...null!=(n=t.get(r))?n:[],s])}};return r},head:{appendChild:r=>{var s;e.push(r),(null!=(s=t.get(r))?s:[]).forEach(e=>e())}}}}((e,r)=>{for(var s in r)t(e,s,{get:r[s],enumerable:!0})})(o,{mockScriptDocument:()=>a,page:()=>h}),module.exports=(e=o,((e,o,a,i)=>{if(o&&"object"==typeof o||"function"==typeof o)for(let l of s(o))n.call(e,l)||l===a||t(e,l,{get:()=>o[l],enumerable:!(i=r(o,l))||i.enumerable});return e})(t({},"__esModule",{value:!0}),e));require("@walkeros/core");var i="data-walkeros-vendor";function l(e,t,r){const s=Object.getOwnPropertyDescriptor(e,t);return Object.defineProperty(e,t,{value:r,configurable:!0,writable:!0}),()=>{s?Object.defineProperty(e,t,s):Reflect.deleteProperty(e,t)}}function u(e){return Array.from(e.querySelectorAll("script"))}function c(e){return class{constructor(){this.status=0,this.statusText="",this.response="",this.responseText="",this.readyState=0,this.onload=null,this.onerror=null,this.onreadystatechange=null,this.method="GET",this.url="",this.async=!0}open(e,t,r=!0){this.method=e,this.url=t,this.async=r,this.readyState=1}setRequestHeader(){}addEventListener(e,t){"load"===e&&(this.onload=t),"error"===e&&(this.onerror=t)}send(t){const{answer:r,settle:s}=e(["XMLHttpRequest",this.method,this.url,t]),n=()=>{var e,t,n,o,a;if(s(),this.readyState=4,r.error){if(!this.async)throw new Error("NetworkError");null==(e=this.onerror)||e.call(this)}else this.status=null!=(t=r.status)?t:200,this.statusText=null!=(n=r.statusText)?n:"",this.responseText=function(e){return void 0===e?"":"string"==typeof e?e:JSON.stringify(e)}(r.body),this.response=this.responseText,null==(o=this.onreadystatechange)||o.call(this),null==(a=this.onload)||a.call(this)};this.async?new Promise(e=>setTimeout(e,0)).then(n):n()}}}var h={open(e){if("undefined"==typeof document)throw new Error("the web page needs a document: run it in a jsdom test environment");const t=document,r=new Set(u(t)),s=()=>u(t).filter(e=>!r.has(e)),n=[l(window,"XMLHttpRequest",c(e)),l(navigator,"sendBeacon",(t,r)=>{var s;const{answer:n,settle:o}=e(["sendBeacon",t,r]);return o(),!n.error&&(null!=(s=n.status)?s:200)<400})];return{globals:{document:t},scripts:()=>{const e=s(),t=e.filter(e=>e.hasAttribute(i)).length;return{marked:t,unmarked:e.length-t}},failScripts:()=>{t.querySelectorAll(`script[${i}]`).forEach(e=>e.dispatchEvent(new Event("error")))},close:()=>{n.splice(0).forEach(e=>e()),s().forEach(e=>e.remove())}}}};//# sourceMappingURL=dev.js.map
|
package/dist/dev.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/dev.ts","../src/mockScriptDocument.ts","../src/loadVendor.ts","../src/dev/page.ts"],"sourcesContent":["export { mockScriptDocument } from './mockScriptDocument';\nexport type { MockScript, MockScriptDocument } from './mockScriptDocument';\nexport { page } from './dev/page';\n","/** A script element, as far as `loadVendor` uses one. */\nexport type MockScript = {\n src: string;\n async: boolean;\n getAttribute(name: string): string | null;\n setAttribute(name: string, value: string): void;\n addEventListener(type: string, listener: () => void): void;\n};\n\n/** A document, as far as `loadVendor` injects into one. */\nexport type MockScriptDocument = {\n querySelectorAll(selector: string): MockScript[];\n createElement(tagName: string): MockScript;\n head: { appendChild(script: MockScript): void };\n};\n\n/**\n * A document without a DOM for `loadVendor` to inject into, for an examples\n * env (tests, simulation in Node). It keeps the scripts appended to its head,\n * so each src goes in once, and an appended script loads at once.\n */\nexport function mockScriptDocument(): MockScriptDocument {\n const scripts: MockScript[] = [];\n const loads = new WeakMap<MockScript, Array<() => void>>();\n\n return {\n querySelectorAll: () => [...scripts],\n createElement: () => {\n const attributes = new Map<string, string>();\n const script: MockScript = {\n src: '',\n async: false,\n getAttribute: (name) =>\n name === 'src' ? script.src : (attributes.get(name) ?? null),\n setAttribute: (name, value) => {\n attributes.set(name, value);\n },\n addEventListener: (type, listener) => {\n if (type === 'load')\n loads.set(script, [...(loads.get(script) ?? []), listener]);\n },\n };\n return script;\n },\n head: {\n appendChild: (script) => {\n scripts.push(script);\n (loads.get(script) ?? []).forEach((listener) => listener());\n },\n },\n };\n}\n","import { resolveDestinationTimeout, StepError } from '@walkeros/core';\n\n/** Attribute on every script `loadVendor` injects. */\nexport const VENDOR_SCRIPT_MARKER = 'data-walkeros-vendor';\n\nexport interface LoadVendorOptions {\n /** The destination's timeout; the load deadline is its resolved value. */\n timeout?: number;\n /**\n * Attributes the vendor's tag needs (e.g. `data-domain`), set before the\n * script is inserted. `src` and the marker cannot be overwritten.\n */\n attributes?: Record<string, string>;\n /**\n * The document the script goes into, and whose scripts are the registry:\n * the destination's env one (`getEnv(env).document`). The global document\n * without it.\n */\n document?: Document;\n}\n\nexport interface Vendor<T> {\n /**\n * Resolves with the vendor once its script loaded and `get()` finds it.\n * Rejects `vendor-not-loaded` after the script's `error` (final for the\n * page), `vendor-not-ready` when the vendor is missing, `vendor-timeout`\n * when the script did not load by the deadline. Past the deadline, and\n * without a script, it checks `get()` on each call.\n */\n ready(): Promise<T>;\n /**\n * For vendors that replay their own stub (called synchronously): throws\n * `vendor-not-loaded` once the injected script fired `error`.\n */\n check(): void;\n}\n\ntype Outcome = 'loaded' | 'failed' | 'expired';\n\ninterface Injected {\n state: 'loading' | 'loaded' | 'failed';\n /** The deadline passed before the script loaded or failed. */\n expired: boolean;\n timeout: number;\n waiting: Array<(outcome: Outcome) => void>;\n}\n\n/** The state of each vendor script, kept with its element. */\nconst injected = new WeakMap<Element, Injected>();\n\n/**\n * The page's script for `src`. The page itself is the registry: its one\n * marked script with that src means the src was injected (once per page, a\n * failure is never re-injected), and another document has its own.\n */\nfunction scriptOf(doc: Document, src: string): HTMLScriptElement | undefined {\n const marked = doc.querySelectorAll<HTMLScriptElement>(\n `script[${VENDOR_SCRIPT_MARKER}]`,\n );\n return Array.from(marked).find(\n (script) => script.getAttribute('src') === src,\n );\n}\n\nfunction inject(\n doc: Document,\n src: string,\n timeout: number,\n attributes: Record<string, string>,\n available: () => boolean,\n): Injected {\n const existing = scriptOf(doc, src);\n const known = existing && injected.get(existing);\n if (known) return known;\n\n const entry: Injected = {\n state: 'loading',\n expired: false,\n timeout,\n waiting: [],\n };\n\n // A marked script without state (another bundle's) is adopted, not\n // doubled. Its `load` may have fired already: with the vendor there, it is\n // ready at once; otherwise it is watched like an own script.\n if (existing && available()) {\n entry.state = 'loaded';\n injected.set(existing, entry);\n return entry;\n }\n const script = existing ?? doc.createElement('script');\n\n const settle = (outcome: Outcome) => {\n const waiting = entry.waiting;\n entry.waiting = [];\n waiting.forEach((notify) => notify(outcome));\n };\n\n const timer = setTimeout(() => {\n entry.expired = true;\n settle('expired');\n }, timeout);\n\n injected.set(script, entry);\n script.addEventListener('load', () => {\n clearTimeout(timer);\n entry.state = 'loaded';\n settle('loaded');\n });\n script.addEventListener('error', () => {\n clearTimeout(timer);\n entry.state = 'failed';\n settle('failed');\n });\n\n if (!existing) {\n for (const [name, value] of Object.entries(attributes))\n script.setAttribute(name, value);\n // After the attributes, so they never replace the src or the marker.\n script.src = src;\n script.async = true;\n script.setAttribute(VENDOR_SCRIPT_MARKER, '');\n doc.head.appendChild(script);\n }\n\n return entry;\n}\n\nconst notLoaded = () =>\n new StepError('Vendor script failed to load', { code: 'vendor-not-loaded' });\n\nconst notReady = () =>\n new StepError('Vendor not ready: its global is missing', {\n code: 'vendor-not-ready',\n });\n\nconst timedOut = (timeout: number) =>\n new StepError(`Vendor script did not load within ${timeout}ms`, {\n code: 'vendor-timeout',\n });\n\n/**\n * Injects a vendor script once per `src` on the page (marked\n * `data-walkeros-vendor`, with the `attributes` its tag needs) and reports\n * its readiness. The deadline runs from the injection and equals the\n * destination's resolved timeout, so an awaited `ready()` settles before the\n * push's own timeout. Without `src` (the page loads the vendor) nothing is\n * injected and there is no deadline. A `src` with no document to inject\n * into (neither `options.document` nor a global one) throws\n * `vendor-not-ready`.\n */\nexport function loadVendor<T>(\n src: string | undefined,\n get: () => T | undefined,\n options: LoadVendorOptions = {},\n): Vendor<T> {\n const available = () => {\n const vendor = get();\n return vendor !== undefined && vendor !== null;\n };\n\n let script: Injected | undefined;\n if (src) {\n const doc =\n options.document ??\n (typeof document !== 'undefined' ? document : undefined);\n if (!doc)\n throw new StepError(`Vendor script ${src} has no document to go into`, {\n code: 'vendor-not-ready',\n });\n script = inject(\n doc,\n src,\n resolveDestinationTimeout(options.timeout),\n options.attributes ?? {},\n available,\n );\n }\n\n const present = (): Promise<T> => {\n const vendor = get();\n return vendor === undefined || vendor === null\n ? Promise.reject(notReady())\n : Promise.resolve(vendor);\n };\n\n return {\n ready() {\n if (!script) return present();\n if (script.state === 'failed') return Promise.reject(notLoaded());\n if (script.state === 'loaded' || script.expired) return present();\n\n return new Promise<T>((resolve, reject) => {\n script.waiting.push((outcome) => {\n if (outcome === 'failed') reject(notLoaded());\n else if (outcome === 'expired') reject(timedOut(script.timeout));\n else present().then(resolve, reject);\n });\n });\n },\n check() {\n if (script?.state === 'failed') throw notLoaded();\n },\n };\n}\n","import type { Flow } from '@walkeros/core';\nimport { VENDOR_SCRIPT_MARKER } from '../loadVendor';\n\n/**\n * The page a web step runs on in the conformance kit and the examples runner\n * of `@walkeros/collector/dev`. While a run is open, `navigator.sendBeacon`\n * and `XMLHttpRequest` answer through the kit's boundary (`sendWeb` runs on\n * them), and the scripts the run adds are tracked; closing the run restores\n * both and removes those scripts, so the next run starts on the page it\n * found (the page is loadVendor's once-per-src registry).\n */\n\nconst macrotask = () => new Promise<void>((resolve) => setTimeout(resolve, 0));\n\nfunction bodyText(body: unknown): string {\n if (body === undefined) return '';\n return typeof body === 'string' ? body : JSON.stringify(body);\n}\n\n/**\n * Replace one property for a run; returns its restore. A property that did\n * not exist is deleted again.\n */\nfunction replace(target: object, key: string, value: unknown): () => void {\n const original = Object.getOwnPropertyDescriptor(target, key);\n Object.defineProperty(target, key, {\n value,\n configurable: true,\n writable: true,\n });\n return () => {\n if (original) Object.defineProperty(target, key, original);\n else Reflect.deleteProperty(target, key);\n };\n}\n\nfunction scriptsOf(doc: Document): HTMLScriptElement[] {\n return Array.from(doc.querySelectorAll('script'));\n}\n\n/**\n * `XMLHttpRequest` at the boundary: synchronous by default, as sendWeb opens\n * it; the async form answers late.\n */\nfunction kitXMLHttpRequest(record: Flow.StepRecord) {\n return class KitXMLHttpRequest {\n status = 0;\n statusText = '';\n response: unknown = '';\n responseText = '';\n readyState = 0;\n onload: (() => void) | null = null;\n onerror: (() => void) | null = null;\n onreadystatechange: (() => void) | null = null;\n private method = 'GET';\n private url = '';\n private async = true;\n\n open(method: string, url: string, async = true) {\n this.method = method;\n this.url = url;\n this.async = async;\n this.readyState = 1;\n }\n setRequestHeader() {}\n addEventListener(type: string, listener: () => void) {\n if (type === 'load') this.onload = listener;\n if (type === 'error') this.onerror = listener;\n }\n send(body?: unknown) {\n const { answer, settle } = record([\n 'XMLHttpRequest',\n this.method,\n this.url,\n body,\n ]);\n const done = () => {\n settle();\n this.readyState = 4;\n if (answer.error) {\n if (!this.async) throw new Error('NetworkError');\n this.onerror?.();\n return;\n }\n this.status = answer.status ?? 200;\n this.statusText = answer.statusText ?? '';\n this.responseText = bodyText(answer.body);\n this.response = this.responseText;\n this.onreadystatechange?.();\n this.onload?.();\n };\n if (this.async) macrotask().then(done);\n else done();\n }\n };\n}\n\nexport const page: Flow.StepPage = {\n open(record) {\n if (typeof document === 'undefined')\n throw new Error(\n 'the web page needs a document: run it in a jsdom test environment',\n );\n const doc = document;\n const before = new Set(scriptsOf(doc));\n const added = () => scriptsOf(doc).filter((script) => !before.has(script));\n\n const beacon = (url: string, data?: unknown): boolean => {\n const { answer, settle } = record(['sendBeacon', url, data]);\n settle();\n return !answer.error && (answer.status ?? 200) < 400;\n };\n const restores = [\n replace(window, 'XMLHttpRequest', kitXMLHttpRequest(record)),\n replace(navigator, 'sendBeacon', beacon),\n ];\n\n return {\n globals: { document: doc },\n scripts: () => {\n const scripts = added();\n const marked = scripts.filter((script) =>\n script.hasAttribute(VENDOR_SCRIPT_MARKER),\n ).length;\n return { marked, unmarked: scripts.length - marked };\n },\n failScripts: () => {\n doc\n .querySelectorAll(`script[${VENDOR_SCRIPT_MARKER}]`)\n .forEach((script) => script.dispatchEvent(new Event('error')));\n },\n close: () => {\n restores.splice(0).forEach((restore) => restore());\n added().forEach((script) => script.remove());\n },\n };\n },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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,OAAO,CAAC;AAAA,MAC7C;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
package/dist/dev.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function t(){const t=[],e=new WeakMap;return{querySelectorAll:()=>[...t],createElement:()=>{const t=new Map,r={src:"",async:!1,getAttribute:e=>{var s;return"src"===e?r.src:null!=(s=t.get(e))?s:null},setAttribute:(e,r)=>{t.set(e,r)},addEventListener:(t,s)=>{var n;"load"===t&&e.set(r,[...null!=(n=e.get(r))?n:[],s])}};return r},head:{appendChild:r=>{var s;t.push(r),(null!=(s=e.get(r))?s:[]).forEach(t=>t())}}}}import{resolveDestinationTimeout as e,StepError as r}from"@walkeros/core";var s="data-walkeros-vendor";function n(t,e,r){const s=Object.getOwnPropertyDescriptor(t,e);return Object.defineProperty(t,e,{value:r,configurable:!0,writable:!0}),()=>{s?Object.defineProperty(t,e,s):Reflect.deleteProperty(t,e)}}function o(t){return Array.from(t.querySelectorAll("script"))}function a(t){return class{constructor(){this.status=0,this.statusText="",this.response="",this.responseText="",this.readyState=0,this.onload=null,this.onerror=null,this.onreadystatechange=null,this.method="GET",this.url="",this.async=!0}open(t,e,r=!0){this.method=t,this.url=e,this.async=r,this.readyState=1}setRequestHeader(){}addEventListener(t,e){"load"===t&&(this.onload=e),"error"===t&&(this.onerror=e)}send(e){const{answer:r,settle:s}=t(["XMLHttpRequest",this.method,this.url,e]),n=()=>{var t,e,n,o,a;if(s(),this.readyState=4,r.error){if(!this.async)throw new Error("NetworkError");null==(t=this.onerror)||t.call(this)}else this.status=null!=(e=r.status)?e:200,this.statusText=null!=(n=r.statusText)?n:"",this.responseText=function(t){return void 0===t?"":"string"==typeof t?t:JSON.stringify(t)}(r.body),this.response=this.responseText,null==(o=this.onreadystatechange)||o.call(this),null==(a=this.onload)||a.call(this)};this.async?new Promise(t=>setTimeout(t,0)).then(n):n()}}}var i={open(t){if("undefined"==typeof document)throw new Error("the web page needs a document: run it in a jsdom test environment");const e=document,r=new Set(o(e)),i=()=>o(e).filter(t=>!r.has(t)),l=[n(window,"XMLHttpRequest",a(t)),n(navigator,"sendBeacon",(e,r)=>{var s;const{answer:n,settle:o}=t(["sendBeacon",e,r]);return o(),!n.error&&(null!=(s=n.status)?s:200)<400})];return{globals:{document:e},scripts:()=>{const t=i(),e=t.filter(t=>t.hasAttribute(s)).length;return{marked:e,unmarked:t.length-e}},failScripts:()=>{e.querySelectorAll(`script[${s}]`).forEach(t=>t.dispatchEvent(new Event("error")))},close:()=>{l.splice(0).forEach(t=>t()),i().forEach(t=>t.remove())}}}};export{t as mockScriptDocument,i as page};//# sourceMappingURL=dev.mjs.map
|
package/dist/dev.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/mockScriptDocument.ts","../src/loadVendor.ts","../src/dev/page.ts"],"sourcesContent":["/** A script element, as far as `loadVendor` uses one. */\nexport type MockScript = {\n src: string;\n async: boolean;\n getAttribute(name: string): string | null;\n setAttribute(name: string, value: string): void;\n addEventListener(type: string, listener: () => void): void;\n};\n\n/** A document, as far as `loadVendor` injects into one. */\nexport type MockScriptDocument = {\n querySelectorAll(selector: string): MockScript[];\n createElement(tagName: string): MockScript;\n head: { appendChild(script: MockScript): void };\n};\n\n/**\n * A document without a DOM for `loadVendor` to inject into, for an examples\n * env (tests, simulation in Node). It keeps the scripts appended to its head,\n * so each src goes in once, and an appended script loads at once.\n */\nexport function mockScriptDocument(): MockScriptDocument {\n const scripts: MockScript[] = [];\n const loads = new WeakMap<MockScript, Array<() => void>>();\n\n return {\n querySelectorAll: () => [...scripts],\n createElement: () => {\n const attributes = new Map<string, string>();\n const script: MockScript = {\n src: '',\n async: false,\n getAttribute: (name) =>\n name === 'src' ? script.src : (attributes.get(name) ?? null),\n setAttribute: (name, value) => {\n attributes.set(name, value);\n },\n addEventListener: (type, listener) => {\n if (type === 'load')\n loads.set(script, [...(loads.get(script) ?? []), listener]);\n },\n };\n return script;\n },\n head: {\n appendChild: (script) => {\n scripts.push(script);\n (loads.get(script) ?? []).forEach((listener) => listener());\n },\n },\n };\n}\n","import { resolveDestinationTimeout, StepError } from '@walkeros/core';\n\n/** Attribute on every script `loadVendor` injects. */\nexport const VENDOR_SCRIPT_MARKER = 'data-walkeros-vendor';\n\nexport interface LoadVendorOptions {\n /** The destination's timeout; the load deadline is its resolved value. */\n timeout?: number;\n /**\n * Attributes the vendor's tag needs (e.g. `data-domain`), set before the\n * script is inserted. `src` and the marker cannot be overwritten.\n */\n attributes?: Record<string, string>;\n /**\n * The document the script goes into, and whose scripts are the registry:\n * the destination's env one (`getEnv(env).document`). The global document\n * without it.\n */\n document?: Document;\n}\n\nexport interface Vendor<T> {\n /**\n * Resolves with the vendor once its script loaded and `get()` finds it.\n * Rejects `vendor-not-loaded` after the script's `error` (final for the\n * page), `vendor-not-ready` when the vendor is missing, `vendor-timeout`\n * when the script did not load by the deadline. Past the deadline, and\n * without a script, it checks `get()` on each call.\n */\n ready(): Promise<T>;\n /**\n * For vendors that replay their own stub (called synchronously): throws\n * `vendor-not-loaded` once the injected script fired `error`.\n */\n check(): void;\n}\n\ntype Outcome = 'loaded' | 'failed' | 'expired';\n\ninterface Injected {\n state: 'loading' | 'loaded' | 'failed';\n /** The deadline passed before the script loaded or failed. */\n expired: boolean;\n timeout: number;\n waiting: Array<(outcome: Outcome) => void>;\n}\n\n/** The state of each vendor script, kept with its element. */\nconst injected = new WeakMap<Element, Injected>();\n\n/**\n * The page's script for `src`. The page itself is the registry: its one\n * marked script with that src means the src was injected (once per page, a\n * failure is never re-injected), and another document has its own.\n */\nfunction scriptOf(doc: Document, src: string): HTMLScriptElement | undefined {\n const marked = doc.querySelectorAll<HTMLScriptElement>(\n `script[${VENDOR_SCRIPT_MARKER}]`,\n );\n return Array.from(marked).find(\n (script) => script.getAttribute('src') === src,\n );\n}\n\nfunction inject(\n doc: Document,\n src: string,\n timeout: number,\n attributes: Record<string, string>,\n available: () => boolean,\n): Injected {\n const existing = scriptOf(doc, src);\n const known = existing && injected.get(existing);\n if (known) return known;\n\n const entry: Injected = {\n state: 'loading',\n expired: false,\n timeout,\n waiting: [],\n };\n\n // A marked script without state (another bundle's) is adopted, not\n // doubled. Its `load` may have fired already: with the vendor there, it is\n // ready at once; otherwise it is watched like an own script.\n if (existing && available()) {\n entry.state = 'loaded';\n injected.set(existing, entry);\n return entry;\n }\n const script = existing ?? doc.createElement('script');\n\n const settle = (outcome: Outcome) => {\n const waiting = entry.waiting;\n entry.waiting = [];\n waiting.forEach((notify) => notify(outcome));\n };\n\n const timer = setTimeout(() => {\n entry.expired = true;\n settle('expired');\n }, timeout);\n\n injected.set(script, entry);\n script.addEventListener('load', () => {\n clearTimeout(timer);\n entry.state = 'loaded';\n settle('loaded');\n });\n script.addEventListener('error', () => {\n clearTimeout(timer);\n entry.state = 'failed';\n settle('failed');\n });\n\n if (!existing) {\n for (const [name, value] of Object.entries(attributes))\n script.setAttribute(name, value);\n // After the attributes, so they never replace the src or the marker.\n script.src = src;\n script.async = true;\n script.setAttribute(VENDOR_SCRIPT_MARKER, '');\n doc.head.appendChild(script);\n }\n\n return entry;\n}\n\nconst notLoaded = () =>\n new StepError('Vendor script failed to load', { code: 'vendor-not-loaded' });\n\nconst notReady = () =>\n new StepError('Vendor not ready: its global is missing', {\n code: 'vendor-not-ready',\n });\n\nconst timedOut = (timeout: number) =>\n new StepError(`Vendor script did not load within ${timeout}ms`, {\n code: 'vendor-timeout',\n });\n\n/**\n * Injects a vendor script once per `src` on the page (marked\n * `data-walkeros-vendor`, with the `attributes` its tag needs) and reports\n * its readiness. The deadline runs from the injection and equals the\n * destination's resolved timeout, so an awaited `ready()` settles before the\n * push's own timeout. Without `src` (the page loads the vendor) nothing is\n * injected and there is no deadline. A `src` with no document to inject\n * into (neither `options.document` nor a global one) throws\n * `vendor-not-ready`.\n */\nexport function loadVendor<T>(\n src: string | undefined,\n get: () => T | undefined,\n options: LoadVendorOptions = {},\n): Vendor<T> {\n const available = () => {\n const vendor = get();\n return vendor !== undefined && vendor !== null;\n };\n\n let script: Injected | undefined;\n if (src) {\n const doc =\n options.document ??\n (typeof document !== 'undefined' ? document : undefined);\n if (!doc)\n throw new StepError(`Vendor script ${src} has no document to go into`, {\n code: 'vendor-not-ready',\n });\n script = inject(\n doc,\n src,\n resolveDestinationTimeout(options.timeout),\n options.attributes ?? {},\n available,\n );\n }\n\n const present = (): Promise<T> => {\n const vendor = get();\n return vendor === undefined || vendor === null\n ? Promise.reject(notReady())\n : Promise.resolve(vendor);\n };\n\n return {\n ready() {\n if (!script) return present();\n if (script.state === 'failed') return Promise.reject(notLoaded());\n if (script.state === 'loaded' || script.expired) return present();\n\n return new Promise<T>((resolve, reject) => {\n script.waiting.push((outcome) => {\n if (outcome === 'failed') reject(notLoaded());\n else if (outcome === 'expired') reject(timedOut(script.timeout));\n else present().then(resolve, reject);\n });\n });\n },\n check() {\n if (script?.state === 'failed') throw notLoaded();\n },\n };\n}\n","import type { Flow } from '@walkeros/core';\nimport { VENDOR_SCRIPT_MARKER } from '../loadVendor';\n\n/**\n * The page a web step runs on in the conformance kit and the examples runner\n * of `@walkeros/collector/dev`. While a run is open, `navigator.sendBeacon`\n * and `XMLHttpRequest` answer through the kit's boundary (`sendWeb` runs on\n * them), and the scripts the run adds are tracked; closing the run restores\n * both and removes those scripts, so the next run starts on the page it\n * found (the page is loadVendor's once-per-src registry).\n */\n\nconst macrotask = () => new Promise<void>((resolve) => setTimeout(resolve, 0));\n\nfunction bodyText(body: unknown): string {\n if (body === undefined) return '';\n return typeof body === 'string' ? body : JSON.stringify(body);\n}\n\n/**\n * Replace one property for a run; returns its restore. A property that did\n * not exist is deleted again.\n */\nfunction replace(target: object, key: string, value: unknown): () => void {\n const original = Object.getOwnPropertyDescriptor(target, key);\n Object.defineProperty(target, key, {\n value,\n configurable: true,\n writable: true,\n });\n return () => {\n if (original) Object.defineProperty(target, key, original);\n else Reflect.deleteProperty(target, key);\n };\n}\n\nfunction scriptsOf(doc: Document): HTMLScriptElement[] {\n return Array.from(doc.querySelectorAll('script'));\n}\n\n/**\n * `XMLHttpRequest` at the boundary: synchronous by default, as sendWeb opens\n * it; the async form answers late.\n */\nfunction kitXMLHttpRequest(record: Flow.StepRecord) {\n return class KitXMLHttpRequest {\n status = 0;\n statusText = '';\n response: unknown = '';\n responseText = '';\n readyState = 0;\n onload: (() => void) | null = null;\n onerror: (() => void) | null = null;\n onreadystatechange: (() => void) | null = null;\n private method = 'GET';\n private url = '';\n private async = true;\n\n open(method: string, url: string, async = true) {\n this.method = method;\n this.url = url;\n this.async = async;\n this.readyState = 1;\n }\n setRequestHeader() {}\n addEventListener(type: string, listener: () => void) {\n if (type === 'load') this.onload = listener;\n if (type === 'error') this.onerror = listener;\n }\n send(body?: unknown) {\n const { answer, settle } = record([\n 'XMLHttpRequest',\n this.method,\n this.url,\n body,\n ]);\n const done = () => {\n settle();\n this.readyState = 4;\n if (answer.error) {\n if (!this.async) throw new Error('NetworkError');\n this.onerror?.();\n return;\n }\n this.status = answer.status ?? 200;\n this.statusText = answer.statusText ?? '';\n this.responseText = bodyText(answer.body);\n this.response = this.responseText;\n this.onreadystatechange?.();\n this.onload?.();\n };\n if (this.async) macrotask().then(done);\n else done();\n }\n };\n}\n\nexport const page: Flow.StepPage = {\n open(record) {\n if (typeof document === 'undefined')\n throw new Error(\n 'the web page needs a document: run it in a jsdom test environment',\n );\n const doc = document;\n const before = new Set(scriptsOf(doc));\n const added = () => scriptsOf(doc).filter((script) => !before.has(script));\n\n const beacon = (url: string, data?: unknown): boolean => {\n const { answer, settle } = record(['sendBeacon', url, data]);\n settle();\n return !answer.error && (answer.status ?? 200) < 400;\n };\n const restores = [\n replace(window, 'XMLHttpRequest', kitXMLHttpRequest(record)),\n replace(navigator, 'sendBeacon', beacon),\n ];\n\n return {\n globals: { document: doc },\n scripts: () => {\n const scripts = added();\n const marked = scripts.filter((script) =>\n script.hasAttribute(VENDOR_SCRIPT_MARKER),\n ).length;\n return { marked, unmarked: scripts.length - marked };\n },\n failScripts: () => {\n doc\n .querySelectorAll(`script[${VENDOR_SCRIPT_MARKER}]`)\n .forEach((script) => script.dispatchEvent(new Event('error')));\n },\n close: () => {\n restores.splice(0).forEach((restore) => restore());\n added().forEach((script) => script.remove());\n },\n };\n },\n};\n"],"mappings":";AAqBO,SAAS,qBAAyC;AACvD,QAAM,UAAwB,CAAC;AAC/B,QAAM,QAAQ,oBAAI,QAAuC;AAEzD,SAAO;AAAA,IACL,kBAAkB,MAAM,CAAC,GAAG,OAAO;AAAA,IACnC,eAAe,MAAM;AACnB,YAAM,aAAa,oBAAI,IAAoB;AAC3C,YAAM,SAAqB;AAAA,QACzB,KAAK;AAAA,QACL,OAAO;AAAA,QACP,cAAc,CAAC,SAAM;AAhC7B;AAiCU,0BAAS,QAAQ,OAAO,OAAO,gBAAW,IAAI,IAAI,MAAnB,YAAwB;AAAA;AAAA,QACzD,cAAc,CAAC,MAAM,UAAU;AAC7B,qBAAW,IAAI,MAAM,KAAK;AAAA,QAC5B;AAAA,QACA,kBAAkB,CAAC,MAAM,aAAa;AArC9C;AAsCU,cAAI,SAAS;AACX,kBAAM,IAAI,QAAQ,CAAC,IAAI,WAAM,IAAI,MAAM,MAAhB,YAAqB,CAAC,GAAI,QAAQ,CAAC;AAAA,QAC9D;AAAA,MACF;AACA,aAAO;AAAA,IACT;AAAA,IACA,MAAM;AAAA,MACJ,aAAa,CAAC,WAAW;AA7C/B;AA8CQ,gBAAQ,KAAK,MAAM;AACnB,UAAC,WAAM,IAAI,MAAM,MAAhB,YAAqB,CAAC,GAAG,QAAQ,CAAC,aAAa,SAAS,CAAC;AAAA,MAC5D;AAAA,IACF;AAAA,EACF;AACF;;;ACnDA,SAAS,2BAA2B,iBAAiB;AAG9C,IAAM,uBAAuB;;;ACSpC,IAAM,YAAY,MAAM,IAAI,QAAc,CAAC,YAAY,WAAW,SAAS,CAAC,CAAC;AAE7E,SAAS,SAAS,MAAuB;AACvC,MAAI,SAAS,OAAW,QAAO;AAC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,CAAC,WAAW,OAAO,cAAc,IAAI,MAAM,OAAO,CAAC,CAAC;AAAA,MACjE;AAAA,MACA,OAAO,MAAM;AACX,iBAAS,OAAO,CAAC,EAAE,QAAQ,CAAC,YAAY,QAAQ,CAAC;AACjD,cAAM,EAAE,QAAQ,CAAC,WAAW,OAAO,OAAO,CAAC;AAAA,MAC7C;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Elb, Destination as Destination$1, SendHeaders, SendResponse, SendDataValue, StorageType, WalkerOS, Source as Source$1, Collector as Collector$1, Hooks, On } from '@walkeros/core';
|
|
1
|
+
import { Elb, Destination as Destination$1, MoinTarget, ObserveSlot, PreviewKey, PreviewCrypto, SendHeaders, SendResponse, SendDataValue, StorageType, WalkerOS, Source as Source$1, Collector as Collector$1, Hooks, On } from '@walkeros/core';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Get attribute value from element
|
|
@@ -161,6 +161,107 @@ declare function shadowHostsAbove(node: Element, win: Window): Element[];
|
|
|
161
161
|
*/
|
|
162
162
|
declare function isVisible(element: HTMLElement, win: Window, doc: Document): boolean;
|
|
163
163
|
|
|
164
|
+
/** Attribute on every script `loadVendor` injects. */
|
|
165
|
+
declare const VENDOR_SCRIPT_MARKER = "data-walkeros-vendor";
|
|
166
|
+
interface LoadVendorOptions {
|
|
167
|
+
/** The destination's timeout; the load deadline is its resolved value. */
|
|
168
|
+
timeout?: number;
|
|
169
|
+
/**
|
|
170
|
+
* Attributes the vendor's tag needs (e.g. `data-domain`), set before the
|
|
171
|
+
* script is inserted. `src` and the marker cannot be overwritten.
|
|
172
|
+
*/
|
|
173
|
+
attributes?: Record<string, string>;
|
|
174
|
+
/**
|
|
175
|
+
* The document the script goes into, and whose scripts are the registry:
|
|
176
|
+
* the destination's env one (`getEnv(env).document`). The global document
|
|
177
|
+
* without it.
|
|
178
|
+
*/
|
|
179
|
+
document?: Document;
|
|
180
|
+
}
|
|
181
|
+
interface Vendor<T> {
|
|
182
|
+
/**
|
|
183
|
+
* Resolves with the vendor once its script loaded and `get()` finds it.
|
|
184
|
+
* Rejects `vendor-not-loaded` after the script's `error` (final for the
|
|
185
|
+
* page), `vendor-not-ready` when the vendor is missing, `vendor-timeout`
|
|
186
|
+
* when the script did not load by the deadline. Past the deadline, and
|
|
187
|
+
* without a script, it checks `get()` on each call.
|
|
188
|
+
*/
|
|
189
|
+
ready(): Promise<T>;
|
|
190
|
+
/**
|
|
191
|
+
* For vendors that replay their own stub (called synchronously): throws
|
|
192
|
+
* `vendor-not-loaded` once the injected script fired `error`.
|
|
193
|
+
*/
|
|
194
|
+
check(): void;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Injects a vendor script once per `src` on the page (marked
|
|
198
|
+
* `data-walkeros-vendor`, with the `attributes` its tag needs) and reports
|
|
199
|
+
* its readiness. The deadline runs from the injection and equals the
|
|
200
|
+
* destination's resolved timeout, so an awaited `ready()` settles before the
|
|
201
|
+
* push's own timeout. Without `src` (the page loads the vendor) nothing is
|
|
202
|
+
* injected and there is no deadline. A `src` with no document to inject
|
|
203
|
+
* into (neither `options.document` nor a global one) throws
|
|
204
|
+
* `vendor-not-ready`.
|
|
205
|
+
*/
|
|
206
|
+
declare function loadVendor<T>(src: string | undefined, get: () => T | undefined, options?: LoadVendorOptions): Vendor<T>;
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* The Tag Mode loader. Armed only by `?elbMoin` or the tab flag it leaves in
|
|
210
|
+
* sessionStorage, and only in the top frame; it then waits for one message
|
|
211
|
+
* from `target.app` naming a script by its hash, and loads that script from
|
|
212
|
+
* `target.base` with the same hash as its integrity. Not armed, it adds no
|
|
213
|
+
* listener, makes no request and writes nothing.
|
|
214
|
+
*/
|
|
215
|
+
declare function moin(target?: MoinTarget): void;
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* The page's Observe credential slot, for a web `observe` config:
|
|
219
|
+
* `startFlow({ observe: { url, binding, slot: pageObserveSlot() } })`.
|
|
220
|
+
*
|
|
221
|
+
* The credential arrives out-of-band as the `elbObserve` URL param, or in
|
|
222
|
+
* the `localStorage` slot the preview activator ferries it into. A URL
|
|
223
|
+
* credential wins over a stored one. Once kept, a URL-borne copy is
|
|
224
|
+
* stripped from the address bar: it is a bearer credential and must not
|
|
225
|
+
* linger there. Every page access is guarded, so no method throws.
|
|
226
|
+
*/
|
|
227
|
+
declare function pageObserveSlot(): ObserveSlot;
|
|
228
|
+
|
|
229
|
+
interface SwapActivatorConfig {
|
|
230
|
+
keyring: PreviewKey[];
|
|
231
|
+
iss: string;
|
|
232
|
+
/** This bundle's project binding. Absent on demo hosts (see acceptForeign). */
|
|
233
|
+
pb?: string;
|
|
234
|
+
acceptForeign?: boolean;
|
|
235
|
+
demoAllowlist?: string[];
|
|
236
|
+
/** Bare CDN hostname, e.g. 'cdn.walkeros.io'. */
|
|
237
|
+
previewOrigin: string;
|
|
238
|
+
/** Injectable for tests. */
|
|
239
|
+
now?: () => number;
|
|
240
|
+
crypto?: PreviewCrypto;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Storage slot for the session-forwarding companion grant. The web arm never
|
|
244
|
+
* verifies it (it is session-bound by design; the session container is its
|
|
245
|
+
* verifier): the activator only ferries it from the activation URL into
|
|
246
|
+
* storage, where the seamed preview artifact reads it to stamp the
|
|
247
|
+
* `X-Walkeros-Preview` header. It lives and dies with the activation state:
|
|
248
|
+
* set (or cleared) whenever a URL activation succeeds, cleared whenever the
|
|
249
|
+
* stored activation clears.
|
|
250
|
+
*/
|
|
251
|
+
declare const SESSION_STORAGE_KEY = "elbPreviewSession";
|
|
252
|
+
/**
|
|
253
|
+
* Decide whether a preview bundle should boot in place of this bundle's own flow.
|
|
254
|
+
*
|
|
255
|
+
* Returns true iff a preview took over, in which case the caller must not boot
|
|
256
|
+
* the production flow. Every failure path deterministically returns false: the
|
|
257
|
+
* loader never throws, never retries, and never leaves a page without a walker.
|
|
258
|
+
*
|
|
259
|
+
* Anti-griefing invariant: a rejected URL grant never touches stored state,
|
|
260
|
+
* the activator falls back to the stored grant instead. Only a failing stored
|
|
261
|
+
* grant clears storage (self-heal), plus `off` and `swap-failed`.
|
|
262
|
+
*/
|
|
263
|
+
declare function browserSwapActivator(cfg: SwapActivatorConfig): Promise<boolean>;
|
|
264
|
+
|
|
164
265
|
type SendWebTransport = 'fetch' | 'beacon' | 'xhr';
|
|
165
266
|
interface SendWebOptions {
|
|
166
267
|
headers?: SendHeaders;
|
|
@@ -174,6 +275,14 @@ interface SendWebOptionsFetch extends SendWebOptions {
|
|
|
174
275
|
}
|
|
175
276
|
type SendWebOptionsDynamic<T extends SendWebTransport> = T extends 'fetch' ? SendWebOptionsFetch : SendWebOptions;
|
|
176
277
|
type SendWebReturn<T extends SendWebTransport> = T extends 'fetch' ? Promise<SendResponse> : SendResponse;
|
|
278
|
+
/**
|
|
279
|
+
* Send a request with `fetch` (default), `navigator.sendBeacon` or a
|
|
280
|
+
* synchronous XHR. Resolves (fetch) or returns (beacon, xhr) `{ data }` when
|
|
281
|
+
* the request was sent, and throws a `StepError` otherwise: `transport` with
|
|
282
|
+
* `status` and `body` for a non-2xx answer or a network error, `timeout` for
|
|
283
|
+
* a fetch past its timeout, `beacon-rejected` when the browser refuses a
|
|
284
|
+
* beacon. The body stays on the error, never in its message.
|
|
285
|
+
*/
|
|
177
286
|
declare function sendWeb<T extends SendWebTransport>(url: string, data?: SendDataValue, options?: SendWebOptionsDynamic<T> & {
|
|
178
287
|
transport?: T;
|
|
179
288
|
}): SendWebReturn<T>;
|
|
@@ -329,4 +438,4 @@ declare namespace collector {
|
|
|
329
438
|
export type { collector_Collector as Collector, collector_Config as Config, collector_Destinations as Destinations, collector_InitConfig as InitConfig, collector_Scope as Scope, collector_State as State };
|
|
330
439
|
}
|
|
331
440
|
|
|
332
|
-
export { destination as DestinationWeb, elb as Elb, type SendWebOptions, type SendWebOptionsFetch, type SendWebReturn, type SendWebTransport, source as SourceWeb, type StorageEnv, type StorageValue, walker as Walker, collector as WebCollector, composedAncestors, deepElementFromPoint, elb$1 as elb, getAttribute, getEnv, getHashWeb, getLanguage, getScreenSize, getTimezone, isVisible, parseInlineConfig, sendWeb, sendWebAsBeacon, sendWebAsFetch, sendWebAsXhr, shadowHostsAbove, splitAttribute, splitKeyVal, storageDelete, storageRead, storageWrite };
|
|
441
|
+
export { destination as DestinationWeb, elb as Elb, type LoadVendorOptions, SESSION_STORAGE_KEY, type SendWebOptions, type SendWebOptionsFetch, type SendWebReturn, type SendWebTransport, source as SourceWeb, type StorageEnv, type StorageValue, type SwapActivatorConfig, VENDOR_SCRIPT_MARKER, type Vendor, walker as Walker, collector as WebCollector, browserSwapActivator, composedAncestors, deepElementFromPoint, elb$1 as elb, getAttribute, getEnv, getHashWeb, getLanguage, getScreenSize, getTimezone, isVisible, loadVendor, moin, pageObserveSlot, parseInlineConfig, sendWeb, sendWebAsBeacon, sendWebAsFetch, sendWebAsXhr, shadowHostsAbove, splitAttribute, splitKeyVal, storageDelete, storageRead, storageWrite };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Elb, Destination as Destination$1, SendHeaders, SendResponse, SendDataValue, StorageType, WalkerOS, Source as Source$1, Collector as Collector$1, Hooks, On } from '@walkeros/core';
|
|
1
|
+
import { Elb, Destination as Destination$1, MoinTarget, ObserveSlot, PreviewKey, PreviewCrypto, SendHeaders, SendResponse, SendDataValue, StorageType, WalkerOS, Source as Source$1, Collector as Collector$1, Hooks, On } from '@walkeros/core';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Get attribute value from element
|
|
@@ -161,6 +161,107 @@ declare function shadowHostsAbove(node: Element, win: Window): Element[];
|
|
|
161
161
|
*/
|
|
162
162
|
declare function isVisible(element: HTMLElement, win: Window, doc: Document): boolean;
|
|
163
163
|
|
|
164
|
+
/** Attribute on every script `loadVendor` injects. */
|
|
165
|
+
declare const VENDOR_SCRIPT_MARKER = "data-walkeros-vendor";
|
|
166
|
+
interface LoadVendorOptions {
|
|
167
|
+
/** The destination's timeout; the load deadline is its resolved value. */
|
|
168
|
+
timeout?: number;
|
|
169
|
+
/**
|
|
170
|
+
* Attributes the vendor's tag needs (e.g. `data-domain`), set before the
|
|
171
|
+
* script is inserted. `src` and the marker cannot be overwritten.
|
|
172
|
+
*/
|
|
173
|
+
attributes?: Record<string, string>;
|
|
174
|
+
/**
|
|
175
|
+
* The document the script goes into, and whose scripts are the registry:
|
|
176
|
+
* the destination's env one (`getEnv(env).document`). The global document
|
|
177
|
+
* without it.
|
|
178
|
+
*/
|
|
179
|
+
document?: Document;
|
|
180
|
+
}
|
|
181
|
+
interface Vendor<T> {
|
|
182
|
+
/**
|
|
183
|
+
* Resolves with the vendor once its script loaded and `get()` finds it.
|
|
184
|
+
* Rejects `vendor-not-loaded` after the script's `error` (final for the
|
|
185
|
+
* page), `vendor-not-ready` when the vendor is missing, `vendor-timeout`
|
|
186
|
+
* when the script did not load by the deadline. Past the deadline, and
|
|
187
|
+
* without a script, it checks `get()` on each call.
|
|
188
|
+
*/
|
|
189
|
+
ready(): Promise<T>;
|
|
190
|
+
/**
|
|
191
|
+
* For vendors that replay their own stub (called synchronously): throws
|
|
192
|
+
* `vendor-not-loaded` once the injected script fired `error`.
|
|
193
|
+
*/
|
|
194
|
+
check(): void;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Injects a vendor script once per `src` on the page (marked
|
|
198
|
+
* `data-walkeros-vendor`, with the `attributes` its tag needs) and reports
|
|
199
|
+
* its readiness. The deadline runs from the injection and equals the
|
|
200
|
+
* destination's resolved timeout, so an awaited `ready()` settles before the
|
|
201
|
+
* push's own timeout. Without `src` (the page loads the vendor) nothing is
|
|
202
|
+
* injected and there is no deadline. A `src` with no document to inject
|
|
203
|
+
* into (neither `options.document` nor a global one) throws
|
|
204
|
+
* `vendor-not-ready`.
|
|
205
|
+
*/
|
|
206
|
+
declare function loadVendor<T>(src: string | undefined, get: () => T | undefined, options?: LoadVendorOptions): Vendor<T>;
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* The Tag Mode loader. Armed only by `?elbMoin` or the tab flag it leaves in
|
|
210
|
+
* sessionStorage, and only in the top frame; it then waits for one message
|
|
211
|
+
* from `target.app` naming a script by its hash, and loads that script from
|
|
212
|
+
* `target.base` with the same hash as its integrity. Not armed, it adds no
|
|
213
|
+
* listener, makes no request and writes nothing.
|
|
214
|
+
*/
|
|
215
|
+
declare function moin(target?: MoinTarget): void;
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* The page's Observe credential slot, for a web `observe` config:
|
|
219
|
+
* `startFlow({ observe: { url, binding, slot: pageObserveSlot() } })`.
|
|
220
|
+
*
|
|
221
|
+
* The credential arrives out-of-band as the `elbObserve` URL param, or in
|
|
222
|
+
* the `localStorage` slot the preview activator ferries it into. A URL
|
|
223
|
+
* credential wins over a stored one. Once kept, a URL-borne copy is
|
|
224
|
+
* stripped from the address bar: it is a bearer credential and must not
|
|
225
|
+
* linger there. Every page access is guarded, so no method throws.
|
|
226
|
+
*/
|
|
227
|
+
declare function pageObserveSlot(): ObserveSlot;
|
|
228
|
+
|
|
229
|
+
interface SwapActivatorConfig {
|
|
230
|
+
keyring: PreviewKey[];
|
|
231
|
+
iss: string;
|
|
232
|
+
/** This bundle's project binding. Absent on demo hosts (see acceptForeign). */
|
|
233
|
+
pb?: string;
|
|
234
|
+
acceptForeign?: boolean;
|
|
235
|
+
demoAllowlist?: string[];
|
|
236
|
+
/** Bare CDN hostname, e.g. 'cdn.walkeros.io'. */
|
|
237
|
+
previewOrigin: string;
|
|
238
|
+
/** Injectable for tests. */
|
|
239
|
+
now?: () => number;
|
|
240
|
+
crypto?: PreviewCrypto;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Storage slot for the session-forwarding companion grant. The web arm never
|
|
244
|
+
* verifies it (it is session-bound by design; the session container is its
|
|
245
|
+
* verifier): the activator only ferries it from the activation URL into
|
|
246
|
+
* storage, where the seamed preview artifact reads it to stamp the
|
|
247
|
+
* `X-Walkeros-Preview` header. It lives and dies with the activation state:
|
|
248
|
+
* set (or cleared) whenever a URL activation succeeds, cleared whenever the
|
|
249
|
+
* stored activation clears.
|
|
250
|
+
*/
|
|
251
|
+
declare const SESSION_STORAGE_KEY = "elbPreviewSession";
|
|
252
|
+
/**
|
|
253
|
+
* Decide whether a preview bundle should boot in place of this bundle's own flow.
|
|
254
|
+
*
|
|
255
|
+
* Returns true iff a preview took over, in which case the caller must not boot
|
|
256
|
+
* the production flow. Every failure path deterministically returns false: the
|
|
257
|
+
* loader never throws, never retries, and never leaves a page without a walker.
|
|
258
|
+
*
|
|
259
|
+
* Anti-griefing invariant: a rejected URL grant never touches stored state,
|
|
260
|
+
* the activator falls back to the stored grant instead. Only a failing stored
|
|
261
|
+
* grant clears storage (self-heal), plus `off` and `swap-failed`.
|
|
262
|
+
*/
|
|
263
|
+
declare function browserSwapActivator(cfg: SwapActivatorConfig): Promise<boolean>;
|
|
264
|
+
|
|
164
265
|
type SendWebTransport = 'fetch' | 'beacon' | 'xhr';
|
|
165
266
|
interface SendWebOptions {
|
|
166
267
|
headers?: SendHeaders;
|
|
@@ -174,6 +275,14 @@ interface SendWebOptionsFetch extends SendWebOptions {
|
|
|
174
275
|
}
|
|
175
276
|
type SendWebOptionsDynamic<T extends SendWebTransport> = T extends 'fetch' ? SendWebOptionsFetch : SendWebOptions;
|
|
176
277
|
type SendWebReturn<T extends SendWebTransport> = T extends 'fetch' ? Promise<SendResponse> : SendResponse;
|
|
278
|
+
/**
|
|
279
|
+
* Send a request with `fetch` (default), `navigator.sendBeacon` or a
|
|
280
|
+
* synchronous XHR. Resolves (fetch) or returns (beacon, xhr) `{ data }` when
|
|
281
|
+
* the request was sent, and throws a `StepError` otherwise: `transport` with
|
|
282
|
+
* `status` and `body` for a non-2xx answer or a network error, `timeout` for
|
|
283
|
+
* a fetch past its timeout, `beacon-rejected` when the browser refuses a
|
|
284
|
+
* beacon. The body stays on the error, never in its message.
|
|
285
|
+
*/
|
|
177
286
|
declare function sendWeb<T extends SendWebTransport>(url: string, data?: SendDataValue, options?: SendWebOptionsDynamic<T> & {
|
|
178
287
|
transport?: T;
|
|
179
288
|
}): SendWebReturn<T>;
|
|
@@ -329,4 +438,4 @@ declare namespace collector {
|
|
|
329
438
|
export type { collector_Collector as Collector, collector_Config as Config, collector_Destinations as Destinations, collector_InitConfig as InitConfig, collector_Scope as Scope, collector_State as State };
|
|
330
439
|
}
|
|
331
440
|
|
|
332
|
-
export { destination as DestinationWeb, elb as Elb, type SendWebOptions, type SendWebOptionsFetch, type SendWebReturn, type SendWebTransport, source as SourceWeb, type StorageEnv, type StorageValue, walker as Walker, collector as WebCollector, composedAncestors, deepElementFromPoint, elb$1 as elb, getAttribute, getEnv, getHashWeb, getLanguage, getScreenSize, getTimezone, isVisible, parseInlineConfig, sendWeb, sendWebAsBeacon, sendWebAsFetch, sendWebAsXhr, shadowHostsAbove, splitAttribute, splitKeyVal, storageDelete, storageRead, storageWrite };
|
|
441
|
+
export { destination as DestinationWeb, elb as Elb, type LoadVendorOptions, SESSION_STORAGE_KEY, type SendWebOptions, type SendWebOptionsFetch, type SendWebReturn, type SendWebTransport, source as SourceWeb, type StorageEnv, type StorageValue, type SwapActivatorConfig, VENDOR_SCRIPT_MARKER, type Vendor, walker as Walker, collector as WebCollector, browserSwapActivator, composedAncestors, deepElementFromPoint, elb$1 as elb, getAttribute, getEnv, getHashWeb, getLanguage, getScreenSize, getTimezone, isVisible, loadVendor, moin, pageObserveSlot, parseInlineConfig, sendWeb, sendWebAsBeacon, sendWebAsFetch, sendWebAsXhr, shadowHostsAbove, splitAttribute, splitKeyVal, storageDelete, storageRead, storageWrite };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e,t=Object.defineProperty,o=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,r=Object.prototype.hasOwnProperty,s={};function i(e,t){return(e.getAttribute(t)||"").trim()}function a(e,t=";"){if(!e)return[];const o=new RegExp(`(?:\\\\[\\s\\S]?|'(?:\\\\[\\s\\S]|[^'\\\\])*'(?![\\w\\u0080-\\uffff])|[^${t}\\\\])+`,"g");return e.match(o)||[]}function c(e){const[,t=e,o=""]=e.match(/^((?:\\[\s\S]|[^\\:])*):([\s\S]*)$/)||[];return[u(t),u(o)]}function u(e){return e.replace(/^\s*'|\\([\s\S])|'\s*$/g,(e,t)=>t||"").trim()}function l(e){const t={};return a(e).forEach(e=>{const[o,n]=c(e);o&&("true"===n?t[o]=!0:"false"===n?t[o]=!1:n&&/^\d+$/.test(n)?t[o]=parseInt(n,10):n&&/^\d+\.\d+$/.test(n)?t[o]=parseFloat(n):t[o]=n||!0)}),t}function d(e){return e.language}function f(){return Intl.DateTimeFormat().resolvedOptions().timeZone}function m(e){return`${e.screen.width}x${e.screen.height}`}((e,o)=>{for(var n in o)t(e,n,{get:o[n],enumerable:!0})})(s,{DestinationWeb:()=>T,Elb:()=>I,SourceWeb:()=>$,Walker:()=>D,WebCollector:()=>V,composedAncestors:()=>y,deepElementFromPoint:()=>b,elb:()=>w,getAttribute:()=>i,getEnv:()=>h,getHashWeb:()=>S,getLanguage:()=>d,getScreenSize:()=>m,getTimezone:()=>f,isVisible:()=>C,parseInlineConfig:()=>l,sendWeb:()=>R,sendWebAsBeacon:()=>A,sendWebAsFetch:()=>O,sendWebAsXhr:()=>_,shadowHostsAbove:()=>v,splitAttribute:()=>a,splitKeyVal:()=>c,storageDelete:()=>W,storageRead:()=>x,storageWrite:()=>N}),module.exports=(e=s,((e,s,i,a)=>{if(s&&"object"==typeof s||"function"==typeof s)for(let c of n(s))r.call(e,c)||c===i||t(e,c,{get:()=>s[c],enumerable:!(a=o(s,c))||a.enumerable});return e})(t({},"__esModule",{value:!0}),e));var w=function(){const e=window;(e.elbLayer=e.elbLayer||[]).push(arguments)},g=require("@walkeros/core");function h(e){const t={window:"undefined"!=typeof window?window:globalThis.window,document:"undefined"!=typeof document?document:globalThis.document,...e},o=e&&e[g.OBSERVE_ENV_KEY];if(("undefined"==typeof __WALKEROS_OBSERVE__||__WALKEROS_OBSERVE__)&&(0,g.isEnvObserve)(o)){delete t[g.OBSERVE_ENV_KEY];const e=(0,g.observeEnv)(t,o.paths,o.record).env,n=new Set;for(const e of o.paths){const o=(0,g.parseCallPath)(e)[0];if(void 0===o)continue;const r=t[o];null!==r&&"object"==typeof r&&n.add(o)}const r=Array.from(n,t=>[t,e[t]]);for(const[e,o]of r)t[e]=o}return t}var p=require("@walkeros/core");async function S(e,t){return(await async function(e){const t=(0,p.isDefined)(window)&&window.crypto?window.crypto:void 0;if(!t||!t.subtle||!TextEncoder)return;const o=(new TextEncoder).encode(e),n=await t.subtle.digest("SHA-256",o);return Array.from(new Uint8Array(n)).map(e=>e.toString(16).padStart(2,"0")).join("")}(e)||"").slice(0,t)}function b(e,t,o){let n=e.elementFromPoint(t,o);for(;n&&n.shadowRoot;){const e=n.shadowRoot.elementFromPoint(t,o);if(!e||e===n)break;n=e}return n}function y(e,t){const o=[];let n=e;for(;n;){let e=n.parentElement;if(!e){const o=n.getRootNode();o instanceof t.self.ShadowRoot&&(e=o.host)}if(!e)break;o.push(e),n=e}return o}function v(e,t){const o=[];let n=e.getRootNode();for(;n instanceof t.self.ShadowRoot;)o.push(n.host),n=n.host.getRootNode();return o}function C(e,t,o){if(!function(e,t){const o=t.getComputedStyle(e);if("none"===o.display)return!1;if("visible"!==o.visibility)return!1;let n=e;for(;n;){const e=t.getComputedStyle(n).opacity;if(e&&Number(e)<.1)return!1;const o=n.parentElement;if(o){n=o;continue}const r=n.getRootNode();n=r instanceof t.self.ShadowRoot?r.host:null}return!0}(e,t))return!1;const n=e.getBoundingClientRect(),r=o.documentElement.clientWidth||t.innerWidth,s=o.documentElement.clientHeight||t.innerHeight,i=Math.max(n.left,0),a=Math.max(n.top,0),c=Math.min(n.right,r),u=Math.min(n.bottom,s);if(c<=i||u<=a)return!1;const l=b(o,(i+c)/2,(a+u)/2);return!!l&&(l===e||(!!y(l,t).includes(e)||!!v(e,t).includes(l)))}var E=require("@walkeros/core"),k=1e4;function R(e,t,o={transport:"fetch"}){switch(o.transport||"fetch"){case"beacon":return A(e,t);case"xhr":return _(e,t,o);default:return O(e,t,o)}}async function O(e,t,o={}){const n=(0,E.getHeaders)(o.headers),r=(0,E.transformData)(t),s=o.timeout,i="number"==typeof s&&Number.isFinite(s)&&s>0?s:k,a=new AbortController,c=setTimeout(()=>a.abort(),i);return(0,E.tryCatchAsync)(async()=>{try{const t=await fetch(e,{method:o.method||"POST",headers:n,keepalive:!0,credentials:o.credentials||"same-origin",mode:o.noCors?"no-cors":"cors",body:r,signal:a.signal}),s=o.noCors?"":await t.text();return{ok:t.ok,data:s,error:t.ok?void 0:t.statusText}}finally{clearTimeout(c)}},e=>(clearTimeout(c),{ok:!1,error:e.message}))()}function A(e,t){const o=(0,E.transformData)(t),n=navigator.sendBeacon(e,o);return{ok:n,error:n?void 0:"Failed to send beacon"}}function _(e,t,o={}){const n=(0,E.getHeaders)(o.headers),r=o.method||"POST",s=(0,E.transformData)(t);return(0,E.tryCatch)(()=>{const t=new XMLHttpRequest;t.open(r,e,!1);for(const e in n)t.setRequestHeader(e,n[e]);t.send(s);const o=t.status>=200&&t.status<300;return{ok:o,data:(0,E.tryCatch)(JSON.parse,()=>t.response)(t.response),error:o?void 0:`${t.status} ${t.statusText}`}},e=>({ok:!1,error:e.message}))()}var U=require("@walkeros/core");function W(e,t=U.Const.Utils.Storage.Session,o,n){try{switch(t){case U.Const.Utils.Storage.Cookie:N(e,"",0,t,o,n);break;case U.Const.Utils.Storage.Local:(n?.window??window).localStorage.removeItem(e);break;case U.Const.Utils.Storage.Session:(n?.window??window).sessionStorage.removeItem(e)}}catch(e){}}function x(e,t=U.Const.Utils.Storage.Session,o){function n(e){try{return JSON.parse(e||"")}catch(t){let o=1,n="";return e&&(o=0,n=e),{e:o,v:n}}}let r,s;try{switch(t){case U.Const.Utils.Storage.Cookie:r=decodeURIComponent((o?.document??document).cookie.split("; ").find(t=>t.startsWith(e+"="))?.split("=")[1]||"");break;case U.Const.Utils.Storage.Local:s=n((o?.window??window).localStorage.getItem(e));break;case U.Const.Utils.Storage.Session:s=n((o?.window??window).sessionStorage.getItem(e))}}catch(e){return(0,U.castValue)("")}return s&&(r=s.v,0!=s.e&&s.e<Date.now()&&(W(e,t,void 0,o),r="")),(0,U.castValue)(r||"")}function N(e,t,o=30,n=U.Const.Utils.Storage.Session,r,s){const i={e:Date.now()+6e4*o,v:String(t)},a=JSON.stringify(i);try{switch(n){case U.Const.Utils.Storage.Cookie:{t="object"==typeof t?JSON.stringify(t):t;let n=`${e}=${encodeURIComponent(t)}; max-age=${60*o}; path=/; SameSite=Lax; secure`;r&&(n+="; domain="+r),(s?.document??document).cookie=n;break}case U.Const.Utils.Storage.Local:(s?.window??window).localStorage.setItem(e,a);break;case U.Const.Utils.Storage.Session:(s?.window??window).sessionStorage.setItem(e,a)}}catch(e){return(0,U.castValue)("")}return x(e,n,s)}var T={},$={},I={},V={},D={};//# sourceMappingURL=index.js.map
|
|
1
|
+
"use strict";var e,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,r=Object.prototype.hasOwnProperty,i={};function a(e,t){return(e.getAttribute(t)||"").trim()}function s(e,t=";"){if(!e)return[];const n=new RegExp(`(?:\\\\[\\s\\S]?|'(?:\\\\[\\s\\S]|[^'\\\\])*'(?![\\w\\u0080-\\uffff])|[^${t}\\\\])+`,"g");return e.match(n)||[]}function c(e){const[,t=e,n=""]=e.match(/^((?:\\[\s\S]|[^\\:])*):([\s\S]*)$/)||[];return[l(t),l(n)]}function l(e){return e.replace(/^\s*'|\\([\s\S])|'\s*$/g,(e,t)=>t||"").trim()}function u(e){const t={};return s(e).forEach(e=>{const[n,o]=c(e);n&&("true"===o?t[n]=!0:"false"===o?t[n]=!1:o&&/^\d+$/.test(o)?t[n]=parseInt(o,10):o&&/^\d+\.\d+$/.test(o)?t[n]=parseFloat(o):t[n]=o||!0)}),t}function d(e){return e.language}function f(){return Intl.DateTimeFormat().resolvedOptions().timeZone}function w(e){return`${e.screen.width}x${e.screen.height}`}((e,n)=>{for(var o in n)t(e,o,{get:n[o],enumerable:!0})})(i,{DestinationWeb:()=>ie,Elb:()=>se,SESSION_STORAGE_KEY:()=>W,SourceWeb:()=>ae,VENDOR_SCRIPT_MARKER:()=>O,Walker:()=>le,WebCollector:()=>ce,browserSwapActivator:()=>H,composedAncestors:()=>y,deepElementFromPoint:()=>v,elb:()=>g,getAttribute:()=>a,getEnv:()=>p,getHashWeb:()=>S,getLanguage:()=>d,getScreenSize:()=>w,getTimezone:()=>f,isVisible:()=>E,loadVendor:()=>C,moin:()=>L,pageObserveSlot:()=>x,parseInlineConfig:()=>u,sendWeb:()=>z,sendWebAsBeacon:()=>Z,sendWebAsFetch:()=>X,sendWebAsXhr:()=>Q,shadowHostsAbove:()=>b,splitAttribute:()=>s,splitKeyVal:()=>c,storageDelete:()=>ne,storageRead:()=>oe,storageWrite:()=>re}),module.exports=(e=i,((e,i,a,s)=>{if(i&&"object"==typeof i||"function"==typeof i)for(let c of o(i))r.call(e,c)||c===a||t(e,c,{get:()=>i[c],enumerable:!(s=n(i,c))||s.enumerable});return e})(t({},"__esModule",{value:!0}),e));var g=function(){const e=window;(e.elbLayer=e.elbLayer||[]).push(arguments)},m=require("@walkeros/core");function p(e){const t={window:"undefined"!=typeof window?window:globalThis.window,document:"undefined"!=typeof document?document:globalThis.document,...e},n=e&&e[m.OBSERVE_ENV_KEY];if(("undefined"==typeof __WALKEROS_OBSERVE__||__WALKEROS_OBSERVE__)&&(0,m.isEnvObserve)(n)){delete t[m.OBSERVE_ENV_KEY];const e=(0,m.observeEnv)(t,n.paths,n.record).env,o=new Set;for(const e of n.paths){const n=(0,m.parseCallPath)(e)[0];if(void 0===n)continue;const r=t[n];null!==r&&"object"==typeof r&&o.add(n)}const r=Array.from(o,t=>[t,e[t]]);for(const[e,n]of r)t[e]=n}return t}var h=require("@walkeros/core");async function S(e,t){return(await async function(e){const t=(0,h.isDefined)(window)&&window.crypto?window.crypto:void 0;if(!t||!t.subtle||!TextEncoder)return;const n=(new TextEncoder).encode(e),o=await t.subtle.digest("SHA-256",n);return Array.from(new Uint8Array(o)).map(e=>e.toString(16).padStart(2,"0")).join("")}(e)||"").slice(0,t)}function v(e,t,n){let o=e.elementFromPoint(t,n);for(;o&&o.shadowRoot;){const e=o.shadowRoot.elementFromPoint(t,n);if(!e||e===o)break;o=e}return o}function y(e,t){const n=[];let o=e;for(;o;){let e=o.parentElement;if(!e){const n=o.getRootNode();n instanceof t.self.ShadowRoot&&(e=n.host)}if(!e)break;n.push(e),o=e}return n}function b(e,t){const n=[];let o=e.getRootNode();for(;o instanceof t.self.ShadowRoot;)n.push(o.host),o=o.host.getRootNode();return n}function E(e,t,n){if(!function(e,t){const n=t.getComputedStyle(e);if("none"===n.display)return!1;if("visible"!==n.visibility)return!1;let o=e;for(;o;){const e=t.getComputedStyle(o).opacity;if(e&&Number(e)<.1)return!1;const n=o.parentElement;if(n){o=n;continue}const r=o.getRootNode();o=r instanceof t.self.ShadowRoot?r.host:null}return!0}(e,t))return!1;const o=e.getBoundingClientRect(),r=n.documentElement.clientWidth||t.innerWidth,i=n.documentElement.clientHeight||t.innerHeight,a=Math.max(o.left,0),s=Math.max(o.top,0),c=Math.min(o.right,r),l=Math.min(o.bottom,i);if(c<=a||l<=s)return!1;const u=v(n,(a+c)/2,(s+l)/2);return!!u&&(u===e||(!!y(u,t).includes(e)||!!b(e,t).includes(u)))}var R=require("@walkeros/core"),O="data-walkeros-vendor",A=new WeakMap;function _(e,t,n,o,r){const i=function(e,t){const n=e.querySelectorAll(`script[${O}]`);return Array.from(n).find(e=>e.getAttribute("src")===t)}(e,t),a=i&&A.get(i);if(a)return a;const s={state:"loading",expired:!1,timeout:n,waiting:[]};if(i&&r())return s.state="loaded",A.set(i,s),s;const c=null!=i?i:e.createElement("script"),l=e=>{const t=s.waiting;s.waiting=[],t.forEach(t=>t(e))},u=setTimeout(()=>{s.expired=!0,l("expired")},n);if(A.set(c,s),c.addEventListener("load",()=>{clearTimeout(u),s.state="loaded",l("loaded")}),c.addEventListener("error",()=>{clearTimeout(u),s.state="failed",l("failed")}),!i){for(const[e,t]of Object.entries(o))c.setAttribute(e,t);c.src=t,c.async=!0,c.setAttribute(O,""),e.head.appendChild(c)}return s}var k=()=>new R.StepError("Vendor script failed to load",{code:"vendor-not-loaded"}),P=()=>new R.StepError("Vendor not ready: its global is missing",{code:"vendor-not-ready"}),$=e=>new R.StepError(`Vendor script did not load within ${e}ms`,{code:"vendor-timeout"});function C(e,t,n={}){var o,r;const i=()=>{const e=t();return null!=e};let a;if(e){const t=null!=(o=n.document)?o:"undefined"!=typeof document?document:void 0;if(!t)throw new R.StepError(`Vendor script ${e} has no document to go into`,{code:"vendor-not-ready"});a=_(t,e,(0,R.resolveDestinationTimeout)(n.timeout),null!=(r=n.attributes)?r:{},i)}const s=()=>{const e=t();return null==e?Promise.reject(P()):Promise.resolve(e)};return{ready:()=>a?"failed"===a.state?Promise.reject(k()):"loaded"===a.state||a.expired?s():new Promise((e,t)=>{a.waiting.push(n=>{"failed"===n?t(k()):"expired"===n?t($(a.timeout)):s().then(e,t)})}):s(),check(){if("failed"===(null==a?void 0:a.state))throw k()}}}var T=require("@walkeros/core");function I(e,t,n){return new Promise(o=>{let r,i,a=!1;const s=e=>{a||(a=!0,o(e),void 0!==i&&clearTimeout(i),!e&&(null==r?void 0:r.parentNode)&&r.parentNode.removeChild(r))};try{if("undefined"==typeof document)return void s(!1);r=document.createElement("script"),void 0!==n&&(i=setTimeout(()=>s(!1),n)),r.onload=()=>s(!0),r.onerror=()=>s(!1),r.setAttribute("integrity",t),r.setAttribute("crossorigin","anonymous"),r.async=!0,r.src=e,document.head.appendChild(r)}catch(e){s(!1)}})}var U=/^[A-Za-z0-9_-]{64}$/,V=Symbol.for("walkeros.moin");function L(e=T.MOIN_PRODUCTION){"undefined"!=typeof window&&function(e,t){try{if("undefined"==typeof URLSearchParams||e.top!==e||Reflect.get(e,V))return;let n=new URLSearchParams(e.location.search).has(T.MOIN_PARAM);try{const t=e.sessionStorage;n=n||"1"===t.getItem(T.MOIN_PARAM),n&&t.setItem(T.MOIN_PARAM,"1")}catch(e){}if(!n)return;Reflect.set(e,V,!0);const o=n=>{if(n.origin!==t.app)return;const r=n.data;if("object"!=typeof r||null===r)return;if(1!==Reflect.get(r,"elbMoin"))return;const i=Reflect.get(r,"file");"string"==typeof i&&U.test(i)&&(e.removeEventListener("message",o,!0),I(`${t.base}${i}.js`,`sha384-${i.replace(/-/g,"+").replace(/_/g,"/")}`))};e.addEventListener("message",o,!0)}catch(e){}}(window,e)}var N=require("@walkeros/core");function x(){return{read(){const e=function(){var e;try{const t=new URLSearchParams(window.location.search.replace(/^\?/,"")).getAll(N.OBSERVE_STORAGE_KEY);return t.length>0&&null!=(e=t[t.length-1])?e:null}catch(e){return null}}(),t=null!=e?e:function(){try{return window.localStorage.getItem(N.OBSERVE_STORAGE_KEY)}catch(e){return null}}();return t?{raw:t,fromUrl:null!==e}:null},keep(e,t){!function(e){try{window.localStorage.setItem(N.OBSERVE_STORAGE_KEY,e)}catch(e){}}(e),t&&function(){try{const e=window.location.href,t=e.indexOf("#"),n=t>=0?e.slice(t):"",o=t>=0?e.slice(0,t):e,r=o.indexOf("?"),i=r>=0?o.slice(0,r):o,a=new URLSearchParams(r>=0?o.slice(r+1):"");a.delete(N.OBSERVE_STORAGE_KEY);const s=a.toString();window.history.replaceState({},"",`${i}${s?`?${s}`:""}${n}`)}catch(e){}}()},clear(e){!function(e){try{window.localStorage.getItem(N.OBSERVE_STORAGE_KEY)===e&&window.localStorage.removeItem(N.OBSERVE_STORAGE_KEY)}catch(e){}}(e)}}}var M=require("@walkeros/core"),j="elbPreview",W="elbPreviewSession",B="[walkerOS:preview]",D=5e3;function K(e){let t=null;return{get(){var n;try{return null!=(n=window.localStorage.getItem(e))?n:t}catch(e){return t}},set(n){try{window.localStorage.setItem(e,n)}catch(e){t=n}},clear(){t=null;try{window.localStorage.removeItem(e)}catch(e){}}}}function q(){if("undefined"!=typeof URLSearchParams)try{const e=window.location.href,t=e.indexOf("#"),n=t>=0?e.slice(t):"",o=t>=0?e.slice(0,t):e,r=o.indexOf("?"),i=r>=0?o.slice(0,r):o,a=new URLSearchParams(r>=0?o.slice(r+1):"");a.delete("elbPreview"),a.delete("elbPreviewSession"),a.delete("elbObserve");const s=a.toString();window.history.replaceState({},"",`${i}${s?`?${s}`:""}${n}`)}catch(e){}}async function H(e){var t,n,o,r;if("undefined"==typeof window||"undefined"==typeof document)return!1;const i=window,a=K(j),s=K(W),c=K(M.OBSERVE_STORAGE_KEY),l=null!=(t=e.now)?t:()=>Date.now(),u=e=>console.warn(`${B} ${e}`);let d=null,f=null,w=null;if("undefined"!=typeof URLSearchParams)try{const e=new URLSearchParams(i.location.search.replace(/^\?/,"")),t=e.getAll("elbPreview");d=t.length>0&&null!=(n=t[t.length-1])?n:null;const a=e.getAll("elbPreviewSession");f=a.length>0&&null!=(o=a[a.length-1])?o:null;const s=e.getAll("elbObserve");w=s.length>0&&null!=(r=s[s.length-1])?r:null}catch(e){d=null,f=null,w=null}if("off"===d)return a.clear(),s.clear(),c.clear(),q(),!1;const g=a.get();if(!d&&!g)return!1;const m=(t,n)=>(0,M.verifyActivation)(t,{keyring:e.keyring,iss:e.iss,origin:i.location.origin,pb:e.pb,acceptForeign:e.acceptForeign,demoAllowlist:e.demoAllowlist,source:n,now:l(),crypto:e.crypto});let p=null;if(d){const e=await m(d,"url");e.ok?(p=e.grant,a.set(d),f?s.set(f):s.clear(),w?c.set(w):c.clear()):u(e.reason),q()}if(!p&&g){const e=await m(g,"storage");e.ok?p=e.grant:(u(e.reason),"no-subtle"!==e.reason&&(a.clear(),s.clear(),c.clear()))}if(!p)return!1;const h=`https://${e.previewOrigin}/preview/${p.art}.js`;return await I(h,p.sri,D)?(console.info(`${B} active ${p.art} ends ${new Date(1e3*p.sxp).toISOString()}`),!0):(u("swap-failed"),a.clear(),s.clear(),c.clear(),!1)}var Y=require("@walkeros/core"),F=1e4,G=65536,J=0;function z(e,t,n={transport:"fetch"}){switch(n.transport||"fetch"){case"beacon":return Z(e,t);case"xhr":return Q(e,t,n);default:return X(e,t,n)}}async function X(e,t,n={}){const o=(0,Y.getHeaders)(n.headers),r=(0,Y.transformData)(t),i=n.timeout,a="number"==typeof i&&Number.isFinite(i)&&i>0?i:F,s=new AbortController,c=setTimeout(()=>s.abort(),a),l=r?ee(r):0,u=J+l<=G;u&&(J+=l);try{let t;try{t=await fetch(e,{method:n.method||"POST",headers:o,keepalive:u,credentials:n.credentials||"same-origin",mode:n.noCors?"no-cors":"cors",body:r,signal:s.signal})}catch(e){if(s.signal.aborted)throw new Y.StepError(`Request timed out after ${a}ms`,{code:"timeout",cause:e});throw new Y.StepError((0,Y.networkErrorMessage)(e),{code:"transport",cause:e})}if(n.noCors)return{data:""};const i=await t.text();if(!t.ok)throw new Y.StepError(`HTTP ${t.status}`,{code:"transport",status:t.status,body:i});return{data:i}}finally{clearTimeout(c),u&&(J-=l)}}function Z(e,t){const n=(0,Y.transformData)(t);if(!navigator.sendBeacon(e,n)){const e=n?ee(n):0;throw new Y.StepError("Beacon rejected by the browser",{code:"beacon-rejected",retryable:e<=G})}return{}}function Q(e,t,n={}){const o=(0,Y.getHeaders)(n.headers),r=n.method||"POST",i=(0,Y.transformData)(t);let a;try{a=new XMLHttpRequest,a.open(r,e,!1);for(const e in o)a.setRequestHeader(e,o[e]);a.send(i)}catch(e){throw new Y.StepError((0,Y.networkErrorMessage)(e),{code:"transport",cause:e})}const s=(0,Y.tryCatch)(JSON.parse,()=>a.response)(a.response);if(a.status<200||a.status>=300)throw new Y.StepError(`HTTP ${a.status}`,{code:"transport",status:a.status||void 0,body:s});return{data:s}}function ee(e){let t=0;for(let n=0;n<e.length;n++){const o=e.charCodeAt(n);o<128?t+=1:o<2048?t+=2:o>=55296&&o<=56319?(t+=4,n++):t+=3}return t}var te=require("@walkeros/core");function ne(e,t=te.Const.Utils.Storage.Session,n,o){var r,i;try{switch(t){case te.Const.Utils.Storage.Cookie:re(e,"",0,t,n,o);break;case te.Const.Utils.Storage.Local:(null!=(r=null==o?void 0:o.window)?r:window).localStorage.removeItem(e);break;case te.Const.Utils.Storage.Session:(null!=(i=null==o?void 0:o.window)?i:window).sessionStorage.removeItem(e)}}catch(e){}}function oe(e,t=te.Const.Utils.Storage.Session,n){var o,r,i,a;function s(e){try{return JSON.parse(e||"")}catch(t){let n=1,o="";return e&&(n=0,o=e),{e:n,v:o}}}let c,l;try{switch(t){case te.Const.Utils.Storage.Cookie:c=decodeURIComponent((null==(r=(null!=(o=null==n?void 0:n.document)?o:document).cookie.split("; ").find(t=>t.startsWith(e+"=")))?void 0:r.split("=")[1])||"");break;case te.Const.Utils.Storage.Local:l=s((null!=(i=null==n?void 0:n.window)?i:window).localStorage.getItem(e));break;case te.Const.Utils.Storage.Session:l=s((null!=(a=null==n?void 0:n.window)?a:window).sessionStorage.getItem(e))}}catch(e){return(0,te.castValue)("")}return l&&(c=l.v,0!=l.e&&l.e<Date.now()&&(ne(e,t,void 0,n),c="")),(0,te.castValue)(c||"")}function re(e,t,n=30,o=te.Const.Utils.Storage.Session,r,i){var a,s,c;const l={e:Date.now()+6e4*n,v:String(t)},u=JSON.stringify(l);try{switch(o){case te.Const.Utils.Storage.Cookie:{t="object"==typeof t?JSON.stringify(t):t;let o=`${e}=${encodeURIComponent(t)}; max-age=${60*n}; path=/; SameSite=Lax; secure`;r&&(o+="; domain="+r),(null!=(a=null==i?void 0:i.document)?a:document).cookie=o;break}case te.Const.Utils.Storage.Local:(null!=(s=null==i?void 0:i.window)?s:window).localStorage.setItem(e,u);break;case te.Const.Utils.Storage.Session:(null!=(c=null==i?void 0:i.window)?c:window).sessionStorage.setItem(e,u)}}catch(e){return(0,te.castValue)("")}return oe(e,o,i)}var ie={},ae={},se={},ce={},le={};//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/attributes.ts","../src/browser.ts","../src/elb.ts","../src/environment.ts","../src/getHashWeb.ts","../src/isVisible.ts","../src/sendWeb.ts","../src/storage.ts","../src/types/destination.ts","../src/types/source.ts","../src/types/elb.ts","../src/types/collector.ts","../src/types/walker.ts"],"sourcesContent":["export * from './attributes';\nexport * from './browser';\nexport * from './elb';\nexport * from './environment';\nexport * from './getHashWeb';\nexport * from './isVisible';\nexport * from './sendWeb';\nexport * from './storage';\n\n// Export web-specific types\nexport * from './types';\n","/**\n * Get attribute value from element\n * @param element - DOM element\n * @param name - Attribute name\n * @returns Trimmed attribute value or empty string\n */\nexport function getAttribute(element: Element, name: string): string {\n return (element.getAttribute(name) || '').trim();\n}\n\n/**\n * Split attribute string by separator (semicolon by default)\n * Handles quoted values containing the separator and backslash escapes:\n * a backslash keeps the next character, e.g. `\\;`, in the current part.\n * Parts keep their quotes and escapes, splitKeyVal removes them.\n * @param str - String to split\n * @param separator - Separator character (default: ';')\n * @returns Array of attribute strings\n */\nexport function splitAttribute(str: string, separator = ';'): string[] {\n if (!str) return [];\n // An escape pair, a quote group, or any other non-separator char. A quote\n // followed by an ASCII letter, a digit, `_` or any non-ASCII character never\n // closes a group, so a quote that closes none, like the apostrophe in\n // \"Men's\", is a plain character.\n const reg = new RegExp(\n `(?:\\\\\\\\[\\\\s\\\\S]?|'(?:\\\\\\\\[\\\\s\\\\S]|[^'\\\\\\\\])*'(?![\\\\w\\\\u0080-\\\\uffff])|[^${separator}\\\\\\\\])+`,\n 'g',\n );\n return str.match(reg) || [];\n}\n\n/**\n * Split key-value pair by the first unescaped colon\n * Removes surrounding whitespace and quotes and resolves backslash escapes\n * in both key and value.\n * @param str - String in format \"key:value\"\n * @returns Tuple of [key, value]\n */\nexport function splitKeyVal(str: string): [string, string] {\n const [, key = str, value = ''] =\n str.match(/^((?:\\\\[\\s\\S]|[^\\\\:])*):([\\s\\S]*)$/) || [];\n return [unquote(key), unquote(value)];\n}\n\n// Drop unescaped surrounding quotes, resolve escapes and trim whitespace.\nfunction unquote(str: string): string {\n return str\n .replace(/^\\s*'|\\\\([\\s\\S])|'\\s*$/g, (_, char?: string) => char || '')\n .trim();\n}\n\n/**\n * Parse inline configuration string into object\n * Supports type conversion for boolean and numeric values\n * @param str - Configuration string (e.g., \"elb:track;run:false;port:3000\")\n * @returns Parsed configuration object\n */\nexport function parseInlineConfig(str: string): Record<string, unknown> {\n const config: Record<string, unknown> = {};\n\n splitAttribute(str).forEach((pair) => {\n const [key, value] = splitKeyVal(pair);\n if (key) {\n // Type conversion\n if (value === 'true') {\n config[key] = true;\n } else if (value === 'false') {\n config[key] = false;\n } else if (value && /^\\d+$/.test(value)) {\n config[key] = parseInt(value, 10);\n } else if (value && /^\\d+\\.\\d+$/.test(value)) {\n config[key] = parseFloat(value);\n } else if (value) {\n config[key] = value;\n } else {\n // Key without value defaults to true\n config[key] = true;\n }\n }\n });\n\n return config;\n}\n","export function getLanguage(navigatorRef: Navigator): string | undefined {\n return navigatorRef.language;\n}\n\nexport function getTimezone(): string | undefined {\n return Intl.DateTimeFormat().resolvedOptions().timeZone;\n}\n\nexport function getScreenSize(windowRef: Window): string {\n return `${windowRef.screen.width}x${windowRef.screen.height}`;\n}\n","import type { Elb } from '@walkeros/core';\n\nexport const elb: Elb.Fn<void> = function () {\n const w = window as unknown as Record<string, unknown[]>;\n (w.elbLayer = w.elbLayer || []).push(arguments);\n};\n","import type { Env } from './types/destination';\nimport {\n OBSERVE_ENV_KEY,\n isEnvObserve,\n observeEnv,\n parseCallPath,\n} from '@walkeros/core';\n\n/**\n * Helper function to get environment globals with fallbacks\n *\n * Returns window and document by default, with optional environment overrides.\n * Generic over the caller's `Env` so a destination that narrows `window`/\n * `document` (and augments the DOM globals via `declare global`) gets those\n * narrowed types back without casting at the call site.\n *\n * When the collector injects an observe recorder under `OBSERVE_ENV_KEY` (trace\n * level, live-web paths wrapEnv could not resolve), the resolved roots are\n * wrapped in a transparent recording Proxy and the key is stripped before the\n * env reaches the destination. Outside trace the key is absent, so the guard is\n * a single property read with no wrapping cost.\n *\n * @param env - Optional environment overrides\n * @returns Env with window/document defaults and any provided overrides\n */\nexport function getEnv<E extends Env = Env>(env?: E) {\n // The DOM globals (typed `Window`/`Document`) are merged with the caller's\n // narrowed `Env` overrides. This intersection is asserted once here, at the\n // single boundary where the loose `Record`-typed base meets the real DOM\n // globals, so no destination has to cast `window`/`document` per call.\n const merged: Record<string, unknown> = {\n window: typeof window !== 'undefined' ? window : globalThis.window,\n document: typeof document !== 'undefined' ? document : globalThis.document,\n ...env,\n };\n\n // Build flag (see @walkeros/core build-flags): a lean bundle without\n // observe folds the recorder out; its collector never injects the key.\n const observe = env && env[OBSERVE_ENV_KEY];\n if (\n (typeof __WALKEROS_OBSERVE__ === 'undefined' || __WALKEROS_OBSERVE__) &&\n isEnvObserve(observe)\n ) {\n // Strip the recorder so it never reaches the destination (mirrors wrapEnv\n // stripping `simulation`).\n delete merged[OBSERVE_ENV_KEY];\n\n // The shared core recorder (the same one wrapEnv uses) returns a Proxy\n // view; only the tracked roots are swapped in, so untracked globals are\n // never touched. Writes fall through to the real target, so patterns like\n // gtm's `window[dataLayerName] = ...` mutate the actual global. A missing\n // or non-object root is left as-is (its leaf stays unresolvable).\n const view = observeEnv(merged, observe.paths, observe.record).env;\n const roots = new Set<string>();\n for (const path of observe.paths) {\n const root = parseCallPath(path)[0];\n if (root === undefined) continue;\n const target = merged[root];\n if (target !== null && typeof target === 'object') roots.add(root);\n }\n // Read every root view before swapping any in, so no view wraps another.\n const wrapped = Array.from(roots, (root) => [root, view[root]] as const);\n for (const [root, value] of wrapped) merged[root] = value;\n }\n\n return merged as Omit<E, 'window' | 'document'> & {\n window: Window & NonNullable<E['window']>;\n document: Document & NonNullable<E['document']>;\n };\n}\n","import { isDefined } from '@walkeros/core';\n\nasync function sha256(message: string): Promise<string | undefined> {\n const crypto: Crypto | undefined =\n isDefined(window) && window.crypto ? window.crypto : undefined;\n\n // Crypto API not available\n if (!crypto || !crypto.subtle || !TextEncoder) return;\n\n const msgBuffer = new TextEncoder().encode(message);\n const hashBuffer = await crypto.subtle.digest('SHA-256', msgBuffer);\n const hashArray = Array.from(new Uint8Array(hashBuffer));\n const hashHex = hashArray\n .map((b) => b.toString(16).padStart(2, '0'))\n .join('');\n return hashHex;\n}\n\nexport async function getHashWeb(\n str: string,\n length?: number,\n): Promise<string> {\n return ((await sha256(str)) || '').slice(0, length);\n}\n","/**\n * Resolve the topmost element at a point, descending into shadow trees.\n * `elementFromPoint` does not pierce shadow boundaries, so this re-probes each\n * open shadow root's own `elementFromPoint`. It descends through open roots and\n * stops at a closed host, whose `shadowRoot` is null.\n * @param root - Document or shadow root to probe from\n * @param x - Viewport x coordinate\n * @param y - Viewport y coordinate\n * @returns Deepest element at the point, or null when nothing is hit\n */\nexport function deepElementFromPoint(\n root: DocumentOrShadowRoot,\n x: number,\n y: number,\n): Element | null {\n let el = root.elementFromPoint(x, y);\n while (el && el.shadowRoot) {\n const inner = el.shadowRoot.elementFromPoint(x, y);\n if (!inner || inner === el) break;\n el = inner;\n }\n return el;\n}\n\n/**\n * Collect the composed ancestor chain of an element, walking `parentElement`\n * and hopping across shadow-host boundaries when a shadow root is reached.\n * Ancestry follows the flattened tree by DOM containment; it does not resolve\n * slot distribution (slotted light-DOM parents are not tracked).\n * @param node - Element to walk up from\n * @param win - Window owning the element, used for its realm's ShadowRoot\n * @returns Ancestors from nearest to furthest\n */\nexport function composedAncestors(node: Element, win: Window): Element[] {\n const chain: Element[] = [];\n let current: Element | null = node;\n while (current) {\n let parent: Element | null = current.parentElement;\n if (!parent) {\n const root = current.getRootNode();\n // `win.self` is load-bearing: the ShadowRoot constructor lives on\n // `Window & typeof globalThis` (the type of `win.self`), not the bare\n // `Window` parameter, so `win.ShadowRoot` would fail typecheck.\n if (root instanceof win.self.ShadowRoot) parent = root.host;\n }\n if (!parent) break;\n chain.push(parent);\n current = parent;\n }\n return chain;\n}\n\n/**\n * Collect the shadow hosts enclosing an element, crossing only shadow-host\n * boundaries. Unlike composedAncestors, plain light-DOM parents are skipped, so\n * the result contains hosts alone, ordered from innermost to outermost.\n * @param node - Element to walk up from\n * @param win - Window owning the element, used for its realm's ShadowRoot\n * @returns Enclosing shadow hosts, innermost first\n */\nexport function shadowHostsAbove(node: Element, win: Window): Element[] {\n const hosts: Element[] = [];\n let root = node.getRootNode();\n // `win.self` is load-bearing: the ShadowRoot constructor lives on\n // `Window & typeof globalThis` (the type of `win.self`), not the bare\n // `Window` parameter, so `win.ShadowRoot` would fail typecheck.\n while (root instanceof win.self.ShadowRoot) {\n hosts.push(root.host);\n root = root.host.getRootNode();\n }\n return hosts;\n}\n\n/**\n * True when the composed chain renders the element at all. `visibility`\n * inherits, so the element's own computed value is enough. `opacity` does NOT\n * inherit: a transparent ancestor leaves the element's own opacity at 1 while\n * hiding it, and elementFromPoint does not help because a transparent element\n * is still hit-testable. Walk the chain, crossing shadow-host boundaries.\n */\nfunction isRendered(element: HTMLElement, win: Window): boolean {\n const style = win.getComputedStyle(element);\n if (style.display === 'none') return false;\n if (style.visibility !== 'visible') return false;\n\n let current: Element | null = element;\n while (current) {\n const opacity = win.getComputedStyle(current).opacity;\n if (opacity && Number(opacity) < 0.1) return false;\n\n const parent: Element | null = current.parentElement;\n if (parent) {\n current = parent;\n continue;\n }\n const root = current.getRootNode();\n current = root instanceof win.self.ShadowRoot ? root.host : null;\n }\n\n return true;\n}\n\n/**\n * Whether the element is actually seen by the user: rendered, on screen, and\n * not painted over. Geometry (how much of it is showing) is decided by the\n * IntersectionObserver, which computes it during layout for free; this function\n * answers only the two questions the observer is blind to, so it runs once per\n * candidate impression rather than on every scroll frame.\n */\nexport function isVisible(\n element: HTMLElement,\n win: Window,\n doc: Document,\n): boolean {\n if (!isRendered(element, win)) return false;\n\n const rect = element.getBoundingClientRect();\n const viewportWidth = doc.documentElement.clientWidth || win.innerWidth;\n const viewportHeight = doc.documentElement.clientHeight || win.innerHeight;\n\n // Clip the element against the viewport. Probing the centre of this visible\n // band, rather than the centre of the element, is what removes the need for a\n // separate large-element branch: an element taller than the viewport has its\n // own centre off screen, which the previous implementation read as hidden.\n const left = Math.max(rect.left, 0);\n const top = Math.max(rect.top, 0);\n const right = Math.min(rect.right, viewportWidth);\n const bottom = Math.min(rect.bottom, viewportHeight);\n if (right <= left || bottom <= top) return false;\n\n const pointX = (left + right) / 2;\n const pointY = (top + bottom) / 2;\n\n const hit = deepElementFromPoint(doc, pointX, pointY);\n if (!hit) return false;\n if (hit === element) return true;\n if (composedAncestors(hit, win).includes(element)) return true;\n // Clause 3 is deliberately shadowHostsAbove (shadow-host hops only), not a\n // general ancestor walk. A plain light-DOM ancestor returned by\n // elementFromPoint (target has pointer-events:none, a transparent center, or\n // is covered via stacking) must NOT count as visible; restricting to shadow\n // hosts preserves light-DOM occlusion. Do not merge this with clause 2.\n if (shadowHostsAbove(element, win).includes(hit)) return true;\n return false;\n}\n","import type { SendDataValue, SendHeaders, SendResponse } from '@walkeros/core';\nimport {\n getHeaders,\n transformData,\n tryCatch,\n tryCatchAsync,\n} from '@walkeros/core';\n\nexport type SendWebTransport = 'fetch' | 'beacon' | 'xhr';\n\nexport interface SendWebOptions {\n headers?: SendHeaders;\n transport?: SendWebTransport;\n method?: string;\n}\n\nexport interface SendWebOptionsFetch extends SendWebOptions {\n credentials?: 'omit' | 'same-origin' | 'include'; // Add credentials option\n noCors?: boolean; // Add noCors option for fetch transport\n timeout?: number; // Abort the request after this many ms (default 10000)\n}\n\nconst DEFAULT_FETCH_TIMEOUT = 10000;\n\ntype SendWebOptionsDynamic<T extends SendWebTransport> = T extends 'fetch'\n ? SendWebOptionsFetch\n : SendWebOptions;\n\nexport type SendWebReturn<T extends SendWebTransport> = T extends 'fetch'\n ? Promise<SendResponse>\n : SendResponse;\n\nexport function sendWeb<T extends SendWebTransport>(\n url: string,\n data?: SendDataValue,\n options: SendWebOptionsDynamic<T> & { transport?: T } = {\n transport: 'fetch' as T,\n },\n): SendWebReturn<T> {\n const transport = options.transport || 'fetch';\n\n switch (transport) {\n case 'beacon':\n return sendWebAsBeacon(url, data) as SendWebReturn<T>;\n case 'xhr':\n return sendWebAsXhr(url, data, options) as SendWebReturn<T>;\n case 'fetch':\n default:\n return sendWebAsFetch(url, data, options) as SendWebReturn<T>;\n }\n}\n\nexport async function sendWebAsFetch(\n url: string,\n data?: SendDataValue,\n options: SendWebOptionsFetch = {},\n): Promise<SendResponse> {\n const headers = getHeaders(options.headers);\n const body = transformData(data);\n const requested = options.timeout;\n const timeout =\n typeof requested === 'number' && Number.isFinite(requested) && requested > 0\n ? requested\n : DEFAULT_FETCH_TIMEOUT;\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), timeout);\n\n return tryCatchAsync(\n async () => {\n try {\n const response = await fetch(url, {\n method: options.method || 'POST',\n headers,\n keepalive: true,\n credentials: options.credentials || 'same-origin',\n mode: options.noCors ? 'no-cors' : 'cors',\n body,\n signal: controller.signal,\n });\n\n const responseData = options.noCors ? '' : await response.text();\n\n return {\n ok: response.ok,\n data: responseData,\n error: response.ok ? undefined : response.statusText,\n };\n } finally {\n clearTimeout(timeoutId);\n }\n },\n (error) => {\n clearTimeout(timeoutId);\n return {\n ok: false,\n error: (error as Error).message,\n };\n },\n )();\n}\n\nexport function sendWebAsBeacon(\n url: string,\n data?: SendDataValue,\n): SendResponse {\n const body = transformData(data);\n const ok = navigator.sendBeacon(url, body);\n\n return {\n ok,\n error: ok ? undefined : 'Failed to send beacon',\n };\n}\n\nexport function sendWebAsXhr(\n url: string,\n data?: SendDataValue,\n options: SendWebOptions = {},\n): SendResponse {\n const headers = getHeaders(options.headers);\n const method = options.method || 'POST';\n const body = transformData(data);\n\n return tryCatch(\n () => {\n const xhr = new XMLHttpRequest();\n xhr.open(method, url, false); // Synchronous request\n for (const header in headers) {\n xhr.setRequestHeader(header, headers[header]);\n }\n xhr.send(body);\n\n const ok = xhr.status >= 200 && xhr.status < 300;\n\n const parsedData = tryCatch(JSON.parse, () => xhr.response)(xhr.response);\n\n return {\n ok,\n data: parsedData,\n error: ok ? undefined : `${xhr.status} ${xhr.statusText}`,\n };\n },\n (error) => {\n return {\n ok: false,\n error: (error as Error).message,\n };\n },\n )();\n}\n","import type { WalkerOS } from '@walkeros/core';\nimport type { StorageType } from '@walkeros/core';\nimport { castValue, Const } from '@walkeros/core';\n\nexport interface StorageValue {\n e: number; // Expiration timestamp\n v: string; // Value\n}\n\nexport interface StorageEnv {\n window?: Window & typeof globalThis;\n document?: Document;\n}\n\nexport function storageDelete(\n key: string,\n storage: StorageType = Const.Utils.Storage.Session,\n domain?: string,\n env?: StorageEnv,\n) {\n try {\n switch (storage) {\n case Const.Utils.Storage.Cookie:\n storageWrite(key, '', 0, storage, domain, env);\n break;\n case Const.Utils.Storage.Local:\n (env?.window ?? window).localStorage.removeItem(key);\n break;\n case Const.Utils.Storage.Session:\n (env?.window ?? window).sessionStorage.removeItem(key);\n break;\n }\n } catch (err) {\n // Storage may be disabled (SecurityError in private browsing, sandboxed\n // iframes, or restrictive browser settings). Silently ignore.\n }\n}\n\nexport function storageRead(\n key: string,\n storage: StorageType = Const.Utils.Storage.Session,\n env?: StorageEnv,\n): WalkerOS.PropertyType {\n // Helper function for local and session storage to support expiration\n function parseItem(string: string | null): StorageValue {\n try {\n return JSON.parse(string || '');\n } catch (err) {\n let e = 1,\n v = '';\n\n // Remove expiration date\n if (string) {\n e = 0;\n v = string;\n }\n\n return { e, v };\n }\n }\n let value, item;\n\n try {\n switch (storage) {\n case Const.Utils.Storage.Cookie:\n value = decodeURIComponent(\n (env?.document ?? document).cookie\n .split('; ')\n .find((row) => row.startsWith(key + '='))\n ?.split('=')[1] || '',\n );\n break;\n case Const.Utils.Storage.Local:\n item = parseItem((env?.window ?? window).localStorage.getItem(key));\n break;\n case Const.Utils.Storage.Session:\n item = parseItem((env?.window ?? window).sessionStorage.getItem(key));\n break;\n }\n } catch (err) {\n // Storage may be disabled or inaccessible. Return empty string.\n return castValue('');\n }\n\n // Check if item is expired\n if (item) {\n value = item.v;\n\n if (item.e != 0 && item.e < Date.now()) {\n storageDelete(key, storage, undefined, env);\n value = ''; // Conceal the outdated value\n }\n }\n\n return castValue(value || '');\n}\n\nexport function storageWrite(\n key: string,\n value: WalkerOS.PropertyType,\n maxAgeInMinutes = 30,\n storage: StorageType = Const.Utils.Storage.Session,\n domain?: string,\n env?: StorageEnv,\n): WalkerOS.PropertyType {\n const e = Date.now() + 1000 * 60 * maxAgeInMinutes;\n const item: StorageValue = { e, v: String(value) };\n const stringifiedItem = JSON.stringify(item);\n\n try {\n switch (storage) {\n case Const.Utils.Storage.Cookie: {\n value = typeof value === 'object' ? JSON.stringify(value) : value;\n let cookie = `${key}=${encodeURIComponent(value)}; max-age=${\n maxAgeInMinutes * 60\n }; path=/; SameSite=Lax; secure`;\n\n if (domain) cookie += '; domain=' + domain;\n\n (env?.document ?? document).cookie = cookie;\n break;\n }\n case Const.Utils.Storage.Local:\n (env?.window ?? window).localStorage.setItem(key, stringifiedItem);\n break;\n case Const.Utils.Storage.Session:\n (env?.window ?? window).sessionStorage.setItem(key, stringifiedItem);\n break;\n }\n } catch (err) {\n // Storage may be disabled (SecurityError) or full (QuotaExceededError).\n // Return empty string to signal the write did not persist.\n return castValue('');\n }\n\n return storageRead(key, storage, env);\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { Destination as WalkerOSDestination } from '@walkeros/core';\n\nexport type TypesGeneric = WalkerOSDestination.TypesGeneric;\n\nexport interface Destination<T extends TypesGeneric = WalkerOSDestination.Types>\n extends WalkerOSDestination.Instance<T> {}\n\nexport type Init = WalkerOSDestination.Init;\n\nexport type Config<T extends TypesGeneric = WalkerOSDestination.Types> =\n WalkerOSDestination.Config<T>;\n\nexport type PartialConfig<T extends TypesGeneric = WalkerOSDestination.Types> =\n WalkerOSDestination.PartialConfig<T>;\n\nexport type InitFn<T extends TypesGeneric = WalkerOSDestination.Types> =\n WalkerOSDestination.InitFn<T>;\n\nexport type PushFn<T extends TypesGeneric = WalkerOSDestination.Types> =\n WalkerOSDestination.PushFn<T>;\n\nexport type PushEvent<Mapping = unknown> =\n WalkerOSDestination.PushEvent<Mapping>;\n\nexport type PushEvents<Mapping = unknown> =\n WalkerOSDestination.PushEvents<Mapping>;\n\n/**\n * Web-specific environment requirements interface\n *\n * Extends the core Env interface with web-specific\n * globals like window and document for browser destinations.\n */\nexport interface Env extends WalkerOSDestination.BaseEnv {\n /**\n * Properties to be added to the global `window` object\n *\n * Used by web destinations that expect browser-specific\n * global functions like analytics APIs.\n *\n * @example\n * ```typescript\n * window: {\n * gtag: () => {},\n * fbq: () => {},\n * dataLayer: []\n * }\n * ```\n */\n window?: Record<string, unknown>;\n\n /**\n * Properties to be added to the global `document` object\n *\n * Used by destinations that need DOM manipulation capabilities\n * for script loading or element creation.\n *\n * @example\n * ```typescript\n * document: {\n * createElement: () => ({ src: '', async: false }),\n * head: { appendChild: () => {} }\n * }\n * ```\n */\n document?: Record<string, unknown>;\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { Collector, WalkerOS, Source as CoreSource } from '@walkeros/core';\n\nexport type TypesGeneric = CoreSource.TypesGeneric;\n\nexport interface Source<T extends TypesGeneric = CoreSource.Types>\n extends CoreSource.Instance<T> {\n settings?: CoreSource.Settings<T>;\n mapping?: CoreSource.Mapping<T>;\n}\n\nexport type Init = Partial<Omit<Source, 'init'>> & Pick<Source, 'type'>;\n\nexport type Config<T extends TypesGeneric = CoreSource.Types> =\n CoreSource.Instance<T> & {\n settings: CoreSource.Settings<T>;\n mapping?: CoreSource.Mapping<T>;\n };\n\nexport type PartialConfig<T extends TypesGeneric = CoreSource.Types> = Partial<\n Config<T>\n>;\n\nexport type InitFn<T extends TypesGeneric = CoreSource.Types> = (\n collector: Collector.Instance,\n config: Config<T>,\n) => void | Promise<void>;\n","import type { Elb } from '@walkeros/core';\n\n// Simple re-exports from core\nexport type PushResult = Elb.PushResult;\nexport type Layer = Elb.Layer;\n","import type {\n Collector as CoreCollector,\n Elb,\n Hooks,\n WalkerOS,\n Destination as WalkerOSDestination,\n On,\n} from '@walkeros/core';\nimport type { Destination, Config as DestConfig } from './destination';\nimport type { Layer } from './elb';\nimport type { Events, Trigger } from './walker';\n\ndeclare global {\n interface Window {\n elbwalker: Collector;\n walkerjs: CoreCollector.Instance;\n elbLayer?: Layer;\n dataLayer: WalkerOS.Events | unknown | unknown[];\n elb: Elb.Fn<Promise<Elb.PushResult>>;\n }\n}\n\nexport interface Collector extends Omit<CoreCollector.Instance, 'config'> {\n config: Config & CoreCollector.Config;\n destinations: Destinations;\n push: Elb.Fn<Promise<Elb.PushResult>>;\n getAllEvents: (scope: Element, prefix: string) => Events;\n getEvents: (target: Element, trigger: Trigger, prefix: string) => Events;\n getGlobals: () => WalkerOS.Properties;\n _visibilityState?: {\n observer: IntersectionObserver | undefined;\n timers: WeakMap<HTMLElement, number>;\n duration: number;\n elementConfigs?: WeakMap<\n HTMLElement,\n { multiple: boolean; blocked: boolean }\n >;\n };\n}\n\nexport interface State {\n config: Config;\n destinations: Destinations;\n}\n\nexport interface Config {\n dataLayer: boolean;\n dataLayerConfig: DestConfig;\n elbLayer: Layer;\n listeners: boolean;\n pageview: boolean;\n prefix: string;\n run: boolean;\n scope: Scope;\n elb?: string;\n name?: string;\n}\n\nexport interface InitConfig extends Partial<Config> {\n consent?: WalkerOS.Consent;\n custom?: WalkerOS.Properties;\n destinations?: WalkerOSDestination.InitDestinations;\n hooks?: Hooks.Functions;\n on?: On.OnConfig;\n user?: WalkerOS.User;\n}\n\nexport interface Destinations {\n [name: string]: Destination;\n}\n\nexport type Scope = Element | Document;\n","import type { WalkerOS } from '@walkeros/core';\n\nexport type Events = Event[];\n\nexport interface Event {\n entity: string;\n action: string;\n data?: WalkerOS.Properties;\n context?: WalkerOS.OrderedProperties;\n trigger?: Trigger;\n nested: WalkerOS.Entities;\n}\n\nexport type KeyVal = [string, string];\n\nexport type Attributes = Array<string>;\n\nexport type Trigger =\n | 'click'\n | 'custom'\n | 'hover'\n | 'load'\n | 'pulse'\n | 'scroll'\n | 'submit'\n | 'visible'\n | 'visibles'\n | 'wait'\n | string;\n\nexport interface Filter {\n [name: string]: boolean;\n}\n\nexport interface TriggersActionGroups {\n [trigger: string]: TriggerActions;\n}\n\nexport type TriggerActions = Array<TriggerAction>;\n\ninterface TriggerAction {\n trigger: string;\n triggerParams?: string;\n action: string;\n actionParams?: string;\n}\n\nexport type ScrollElements = Array<[HTMLElement, number]>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACMO,SAAS,aAAa,SAAkB,MAAsB;AACnE,UAAQ,QAAQ,aAAa,IAAI,KAAK,IAAI,KAAK;AACjD;AAWO,SAAS,eAAe,KAAa,YAAY,KAAe;AACrE,MAAI,CAAC,IAAK,QAAO,CAAC;AAKlB,QAAM,MAAM,IAAI;AAAA,IACd,2EAA2E,SAAS;AAAA,IACpF;AAAA,EACF;AACA,SAAO,IAAI,MAAM,GAAG,KAAK,CAAC;AAC5B;AASO,SAAS,YAAY,KAA+B;AACzD,QAAM,CAAC,EAAE,MAAM,KAAK,QAAQ,EAAE,IAC5B,IAAI,MAAM,oCAAoC,KAAK,CAAC;AACtD,SAAO,CAAC,QAAQ,GAAG,GAAG,QAAQ,KAAK,CAAC;AACtC;AAGA,SAAS,QAAQ,KAAqB;AACpC,SAAO,IACJ,QAAQ,2BAA2B,CAAC,GAAG,SAAkB,QAAQ,EAAE,EACnE,KAAK;AACV;AAQ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UAAU,QAAQ,eAAe,QAAQ,KAAK,eAAe;AACnE;AAAA,IACJ;AAAA,EACF,SAAS,KAAK;AAGZ,eAAO,wBAAU,EAAE;AAAA,EACrB;AAEA,SAAO,YAAY,KAAK,SAAS,GAAG;AACtC;;;ACxIA;;;ACAA;;;ACAA;;;ACAA;;;ACAA;","names":["import_core","import_core","import_core"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/attributes.ts","../src/browser.ts","../src/elb.ts","../src/environment.ts","../src/getHashWeb.ts","../src/isVisible.ts","../src/loadVendor.ts","../src/moin.ts","../src/injectScript.ts","../src/observeSlot.ts","../src/previewActivator.ts","../src/sendWeb.ts","../src/storage.ts","../src/types/destination.ts","../src/types/source.ts","../src/types/elb.ts","../src/types/collector.ts","../src/types/walker.ts"],"sourcesContent":["export * from './attributes';\nexport * from './browser';\nexport * from './elb';\nexport * from './environment';\nexport * from './getHashWeb';\nexport * from './isVisible';\nexport * from './loadVendor';\nexport { moin } from './moin';\nexport { pageObserveSlot } from './observeSlot';\nexport { browserSwapActivator, SESSION_STORAGE_KEY } from './previewActivator';\nexport type { SwapActivatorConfig } from './previewActivator';\nexport * from './sendWeb';\nexport * from './storage';\n\n// Export web-specific types\nexport * from './types';\n","/**\n * Get attribute value from element\n * @param element - DOM element\n * @param name - Attribute name\n * @returns Trimmed attribute value or empty string\n */\nexport function getAttribute(element: Element, name: string): string {\n return (element.getAttribute(name) || '').trim();\n}\n\n/**\n * Split attribute string by separator (semicolon by default)\n * Handles quoted values containing the separator and backslash escapes:\n * a backslash keeps the next character, e.g. `\\;`, in the current part.\n * Parts keep their quotes and escapes, splitKeyVal removes them.\n * @param str - String to split\n * @param separator - Separator character (default: ';')\n * @returns Array of attribute strings\n */\nexport function splitAttribute(str: string, separator = ';'): string[] {\n if (!str) return [];\n // An escape pair, a quote group, or any other non-separator char. A quote\n // followed by an ASCII letter, a digit, `_` or any non-ASCII character never\n // closes a group, so a quote that closes none, like the apostrophe in\n // \"Men's\", is a plain character.\n const reg = new RegExp(\n `(?:\\\\\\\\[\\\\s\\\\S]?|'(?:\\\\\\\\[\\\\s\\\\S]|[^'\\\\\\\\])*'(?![\\\\w\\\\u0080-\\\\uffff])|[^${separator}\\\\\\\\])+`,\n 'g',\n );\n return str.match(reg) || [];\n}\n\n/**\n * Split key-value pair by the first unescaped colon\n * Removes surrounding whitespace and quotes and resolves backslash escapes\n * in both key and value.\n * @param str - String in format \"key:value\"\n * @returns Tuple of [key, value]\n */\nexport function splitKeyVal(str: string): [string, string] {\n const [, key = str, value = ''] =\n str.match(/^((?:\\\\[\\s\\S]|[^\\\\:])*):([\\s\\S]*)$/) || [];\n return [unquote(key), unquote(value)];\n}\n\n// Drop unescaped surrounding quotes, resolve escapes and trim whitespace.\nfunction unquote(str: string): string {\n return str\n .replace(/^\\s*'|\\\\([\\s\\S])|'\\s*$/g, (_, char?: string) => char || '')\n .trim();\n}\n\n/**\n * Parse inline configuration string into object\n * Supports type conversion for boolean and numeric values\n * @param str - Configuration string (e.g., \"elb:track;run:false;port:3000\")\n * @returns Parsed configuration object\n */\nexport function parseInlineConfig(str: string): Record<string, unknown> {\n const config: Record<string, unknown> = {};\n\n splitAttribute(str).forEach((pair) => {\n const [key, value] = splitKeyVal(pair);\n if (key) {\n // Type conversion\n if (value === 'true') {\n config[key] = true;\n } else if (value === 'false') {\n config[key] = false;\n } else if (value && /^\\d+$/.test(value)) {\n config[key] = parseInt(value, 10);\n } else if (value && /^\\d+\\.\\d+$/.test(value)) {\n config[key] = parseFloat(value);\n } else if (value) {\n config[key] = value;\n } else {\n // Key without value defaults to true\n config[key] = true;\n }\n }\n });\n\n return config;\n}\n","export function getLanguage(navigatorRef: Navigator): string | undefined {\n return navigatorRef.language;\n}\n\nexport function getTimezone(): string | undefined {\n return Intl.DateTimeFormat().resolvedOptions().timeZone;\n}\n\nexport function getScreenSize(windowRef: Window): string {\n return `${windowRef.screen.width}x${windowRef.screen.height}`;\n}\n","import type { Elb } from '@walkeros/core';\n\nexport const elb: Elb.Fn<void> = function () {\n const w = window as unknown as Record<string, unknown[]>;\n (w.elbLayer = w.elbLayer || []).push(arguments);\n};\n","import type { Env } from './types/destination';\nimport {\n OBSERVE_ENV_KEY,\n isEnvObserve,\n observeEnv,\n parseCallPath,\n} from '@walkeros/core';\n\n/**\n * Helper function to get environment globals with fallbacks\n *\n * Returns window and document by default, with optional environment overrides.\n * Generic over the caller's `Env` so a destination that narrows `window`/\n * `document` (and augments the DOM globals via `declare global`) gets those\n * narrowed types back without casting at the call site.\n *\n * When the collector injects an observe recorder under `OBSERVE_ENV_KEY` (trace\n * level, live-web paths wrapEnv could not resolve), the resolved roots are\n * wrapped in a transparent recording Proxy and the key is stripped before the\n * env reaches the destination. Outside trace the key is absent, so the guard is\n * a single property read with no wrapping cost.\n *\n * @param env - Optional environment overrides\n * @returns Env with window/document defaults and any provided overrides\n */\nexport function getEnv<E extends Env = Env>(env?: E) {\n // The DOM globals (typed `Window`/`Document`) are merged with the caller's\n // narrowed `Env` overrides. This intersection is asserted once here, at the\n // single boundary where the loose `Record`-typed base meets the real DOM\n // globals, so no destination has to cast `window`/`document` per call.\n const merged: Record<string, unknown> = {\n window: typeof window !== 'undefined' ? window : globalThis.window,\n document: typeof document !== 'undefined' ? document : globalThis.document,\n ...env,\n };\n\n // Build flag (see @walkeros/core build-flags): a lean bundle without\n // observe folds the recorder out; its collector never injects the key.\n const observe = env && env[OBSERVE_ENV_KEY];\n if (\n (typeof __WALKEROS_OBSERVE__ === 'undefined' || __WALKEROS_OBSERVE__) &&\n isEnvObserve(observe)\n ) {\n // Strip the recorder so it never reaches the destination (mirrors wrapEnv\n // stripping `simulation`).\n delete merged[OBSERVE_ENV_KEY];\n\n // The shared core recorder (the same one wrapEnv uses) returns a Proxy\n // view; only the tracked roots are swapped in, so untracked globals are\n // never touched. Writes fall through to the real target, so patterns like\n // gtm's `window[dataLayerName] = ...` mutate the actual global. A missing\n // or non-object root is left as-is (its leaf stays unresolvable).\n const view = observeEnv(merged, observe.paths, observe.record).env;\n const roots = new Set<string>();\n for (const path of observe.paths) {\n const root = parseCallPath(path)[0];\n if (root === undefined) continue;\n const target = merged[root];\n if (target !== null && typeof target === 'object') roots.add(root);\n }\n // Read every root view before swapping any in, so no view wraps another.\n const wrapped = Array.from(roots, (root) => [root, view[root]] as const);\n for (const [root, value] of wrapped) merged[root] = value;\n }\n\n return merged as Omit<E, 'window' | 'document'> & {\n window: Window & NonNullable<E['window']>;\n document: Document & NonNullable<E['document']>;\n };\n}\n","import { isDefined } from '@walkeros/core';\n\nasync function sha256(message: string): Promise<string | undefined> {\n const crypto: Crypto | undefined =\n isDefined(window) && window.crypto ? window.crypto : undefined;\n\n // Crypto API not available\n if (!crypto || !crypto.subtle || !TextEncoder) return;\n\n const msgBuffer = new TextEncoder().encode(message);\n const hashBuffer = await crypto.subtle.digest('SHA-256', msgBuffer);\n const hashArray = Array.from(new Uint8Array(hashBuffer));\n const hashHex = hashArray\n .map((b) => b.toString(16).padStart(2, '0'))\n .join('');\n return hashHex;\n}\n\nexport async function getHashWeb(\n str: string,\n length?: number,\n): Promise<string> {\n return ((await sha256(str)) || '').slice(0, length);\n}\n","/**\n * Resolve the topmost element at a point, descending into shadow trees.\n * `elementFromPoint` does not pierce shadow boundaries, so this re-probes each\n * open shadow root's own `elementFromPoint`. It descends through open roots and\n * stops at a closed host, whose `shadowRoot` is null.\n * @param root - Document or shadow root to probe from\n * @param x - Viewport x coordinate\n * @param y - Viewport y coordinate\n * @returns Deepest element at the point, or null when nothing is hit\n */\nexport function deepElementFromPoint(\n root: DocumentOrShadowRoot,\n x: number,\n y: number,\n): Element | null {\n let el = root.elementFromPoint(x, y);\n while (el && el.shadowRoot) {\n const inner = el.shadowRoot.elementFromPoint(x, y);\n if (!inner || inner === el) break;\n el = inner;\n }\n return el;\n}\n\n/**\n * Collect the composed ancestor chain of an element, walking `parentElement`\n * and hopping across shadow-host boundaries when a shadow root is reached.\n * Ancestry follows the flattened tree by DOM containment; it does not resolve\n * slot distribution (slotted light-DOM parents are not tracked).\n * @param node - Element to walk up from\n * @param win - Window owning the element, used for its realm's ShadowRoot\n * @returns Ancestors from nearest to furthest\n */\nexport function composedAncestors(node: Element, win: Window): Element[] {\n const chain: Element[] = [];\n let current: Element | null = node;\n while (current) {\n let parent: Element | null = current.parentElement;\n if (!parent) {\n const root = current.getRootNode();\n // `win.self` is load-bearing: the ShadowRoot constructor lives on\n // `Window & typeof globalThis` (the type of `win.self`), not the bare\n // `Window` parameter, so `win.ShadowRoot` would fail typecheck.\n if (root instanceof win.self.ShadowRoot) parent = root.host;\n }\n if (!parent) break;\n chain.push(parent);\n current = parent;\n }\n return chain;\n}\n\n/**\n * Collect the shadow hosts enclosing an element, crossing only shadow-host\n * boundaries. Unlike composedAncestors, plain light-DOM parents are skipped, so\n * the result contains hosts alone, ordered from innermost to outermost.\n * @param node - Element to walk up from\n * @param win - Window owning the element, used for its realm's ShadowRoot\n * @returns Enclosing shadow hosts, innermost first\n */\nexport function shadowHostsAbove(node: Element, win: Window): Element[] {\n const hosts: Element[] = [];\n let root = node.getRootNode();\n // `win.self` is load-bearing: the ShadowRoot constructor lives on\n // `Window & typeof globalThis` (the type of `win.self`), not the bare\n // `Window` parameter, so `win.ShadowRoot` would fail typecheck.\n while (root instanceof win.self.ShadowRoot) {\n hosts.push(root.host);\n root = root.host.getRootNode();\n }\n return hosts;\n}\n\n/**\n * True when the composed chain renders the element at all. `visibility`\n * inherits, so the element's own computed value is enough. `opacity` does NOT\n * inherit: a transparent ancestor leaves the element's own opacity at 1 while\n * hiding it, and elementFromPoint does not help because a transparent element\n * is still hit-testable. Walk the chain, crossing shadow-host boundaries.\n */\nfunction isRendered(element: HTMLElement, win: Window): boolean {\n const style = win.getComputedStyle(element);\n if (style.display === 'none') return false;\n if (style.visibility !== 'visible') return false;\n\n let current: Element | null = element;\n while (current) {\n const opacity = win.getComputedStyle(current).opacity;\n if (opacity && Number(opacity) < 0.1) return false;\n\n const parent: Element | null = current.parentElement;\n if (parent) {\n current = parent;\n continue;\n }\n const root = current.getRootNode();\n current = root instanceof win.self.ShadowRoot ? root.host : null;\n }\n\n return true;\n}\n\n/**\n * Whether the element is actually seen by the user: rendered, on screen, and\n * not painted over. Geometry (how much of it is showing) is decided by the\n * IntersectionObserver, which computes it during layout for free; this function\n * answers only the two questions the observer is blind to, so it runs once per\n * candidate impression rather than on every scroll frame.\n */\nexport function isVisible(\n element: HTMLElement,\n win: Window,\n doc: Document,\n): boolean {\n if (!isRendered(element, win)) return false;\n\n const rect = element.getBoundingClientRect();\n const viewportWidth = doc.documentElement.clientWidth || win.innerWidth;\n const viewportHeight = doc.documentElement.clientHeight || win.innerHeight;\n\n // Clip the element against the viewport. Probing the centre of this visible\n // band, rather than the centre of the element, is what removes the need for a\n // separate large-element branch: an element taller than the viewport has its\n // own centre off screen, which the previous implementation read as hidden.\n const left = Math.max(rect.left, 0);\n const top = Math.max(rect.top, 0);\n const right = Math.min(rect.right, viewportWidth);\n const bottom = Math.min(rect.bottom, viewportHeight);\n if (right <= left || bottom <= top) return false;\n\n const pointX = (left + right) / 2;\n const pointY = (top + bottom) / 2;\n\n const hit = deepElementFromPoint(doc, pointX, pointY);\n if (!hit) return false;\n if (hit === element) return true;\n if (composedAncestors(hit, win).includes(element)) return true;\n // Clause 3 is deliberately shadowHostsAbove (shadow-host hops only), not a\n // general ancestor walk. A plain light-DOM ancestor returned by\n // elementFromPoint (target has pointer-events:none, a transparent center, or\n // is covered via stacking) must NOT count as visible; restricting to shadow\n // hosts preserves light-DOM occlusion. Do not merge this with clause 2.\n if (shadowHostsAbove(element, win).includes(hit)) return true;\n return false;\n}\n","import { resolveDestinationTimeout, StepError } from '@walkeros/core';\n\n/** Attribute on every script `loadVendor` injects. */\nexport const VENDOR_SCRIPT_MARKER = 'data-walkeros-vendor';\n\nexport interface LoadVendorOptions {\n /** The destination's timeout; the load deadline is its resolved value. */\n timeout?: number;\n /**\n * Attributes the vendor's tag needs (e.g. `data-domain`), set before the\n * script is inserted. `src` and the marker cannot be overwritten.\n */\n attributes?: Record<string, string>;\n /**\n * The document the script goes into, and whose scripts are the registry:\n * the destination's env one (`getEnv(env).document`). The global document\n * without it.\n */\n document?: Document;\n}\n\nexport interface Vendor<T> {\n /**\n * Resolves with the vendor once its script loaded and `get()` finds it.\n * Rejects `vendor-not-loaded` after the script's `error` (final for the\n * page), `vendor-not-ready` when the vendor is missing, `vendor-timeout`\n * when the script did not load by the deadline. Past the deadline, and\n * without a script, it checks `get()` on each call.\n */\n ready(): Promise<T>;\n /**\n * For vendors that replay their own stub (called synchronously): throws\n * `vendor-not-loaded` once the injected script fired `error`.\n */\n check(): void;\n}\n\ntype Outcome = 'loaded' | 'failed' | 'expired';\n\ninterface Injected {\n state: 'loading' | 'loaded' | 'failed';\n /** The deadline passed before the script loaded or failed. */\n expired: boolean;\n timeout: number;\n waiting: Array<(outcome: Outcome) => void>;\n}\n\n/** The state of each vendor script, kept with its element. */\nconst injected = new WeakMap<Element, Injected>();\n\n/**\n * The page's script for `src`. The page itself is the registry: its one\n * marked script with that src means the src was injected (once per page, a\n * failure is never re-injected), and another document has its own.\n */\nfunction scriptOf(doc: Document, src: string): HTMLScriptElement | undefined {\n const marked = doc.querySelectorAll<HTMLScriptElement>(\n `script[${VENDOR_SCRIPT_MARKER}]`,\n );\n return Array.from(marked).find(\n (script) => script.getAttribute('src') === src,\n );\n}\n\nfunction inject(\n doc: Document,\n src: string,\n timeout: number,\n attributes: Record<string, string>,\n available: () => boolean,\n): Injected {\n const existing = scriptOf(doc, src);\n const known = existing && injected.get(existing);\n if (known) return known;\n\n const entry: Injected = {\n state: 'loading',\n expired: false,\n timeout,\n waiting: [],\n };\n\n // A marked script without state (another bundle's) is adopted, not\n // doubled. Its `load` may have fired already: with the vendor there, it is\n // ready at once; otherwise it is watched like an own script.\n if (existing && available()) {\n entry.state = 'loaded';\n injected.set(existing, entry);\n return entry;\n }\n const script = existing ?? doc.createElement('script');\n\n const settle = (outcome: Outcome) => {\n const waiting = entry.waiting;\n entry.waiting = [];\n waiting.forEach((notify) => notify(outcome));\n };\n\n const timer = setTimeout(() => {\n entry.expired = true;\n settle('expired');\n }, timeout);\n\n injected.set(script, entry);\n script.addEventListener('load', () => {\n clearTimeout(timer);\n entry.state = 'loaded';\n settle('loaded');\n });\n script.addEventListener('error', () => {\n clearTimeout(timer);\n entry.state = 'failed';\n settle('failed');\n });\n\n if (!existing) {\n for (const [name, value] of Object.entries(attributes))\n script.setAttribute(name, value);\n // After the attributes, so they never replace the src or the marker.\n script.src = src;\n script.async = true;\n script.setAttribute(VENDOR_SCRIPT_MARKER, '');\n doc.head.appendChild(script);\n }\n\n return entry;\n}\n\nconst notLoaded = () =>\n new StepError('Vendor script failed to load', { code: 'vendor-not-loaded' });\n\nconst notReady = () =>\n new StepError('Vendor not ready: its global is missing', {\n code: 'vendor-not-ready',\n });\n\nconst timedOut = (timeout: number) =>\n new StepError(`Vendor script did not load within ${timeout}ms`, {\n code: 'vendor-timeout',\n });\n\n/**\n * Injects a vendor script once per `src` on the page (marked\n * `data-walkeros-vendor`, with the `attributes` its tag needs) and reports\n * its readiness. The deadline runs from the injection and equals the\n * destination's resolved timeout, so an awaited `ready()` settles before the\n * push's own timeout. Without `src` (the page loads the vendor) nothing is\n * injected and there is no deadline. A `src` with no document to inject\n * into (neither `options.document` nor a global one) throws\n * `vendor-not-ready`.\n */\nexport function loadVendor<T>(\n src: string | undefined,\n get: () => T | undefined,\n options: LoadVendorOptions = {},\n): Vendor<T> {\n const available = () => {\n const vendor = get();\n return vendor !== undefined && vendor !== null;\n };\n\n let script: Injected | undefined;\n if (src) {\n const doc =\n options.document ??\n (typeof document !== 'undefined' ? document : undefined);\n if (!doc)\n throw new StepError(`Vendor script ${src} has no document to go into`, {\n code: 'vendor-not-ready',\n });\n script = inject(\n doc,\n src,\n resolveDestinationTimeout(options.timeout),\n options.attributes ?? {},\n available,\n );\n }\n\n const present = (): Promise<T> => {\n const vendor = get();\n return vendor === undefined || vendor === null\n ? Promise.reject(notReady())\n : Promise.resolve(vendor);\n };\n\n return {\n ready() {\n if (!script) return present();\n if (script.state === 'failed') return Promise.reject(notLoaded());\n if (script.state === 'loaded' || script.expired) return present();\n\n return new Promise<T>((resolve, reject) => {\n script.waiting.push((outcome) => {\n if (outcome === 'failed') reject(notLoaded());\n else if (outcome === 'expired') reject(timedOut(script.timeout));\n else present().then(resolve, reject);\n });\n });\n },\n check() {\n if (script?.state === 'failed') throw notLoaded();\n },\n };\n}\n","import type { MoinTarget } from '@walkeros/core';\nimport { MOIN_PARAM, MOIN_PRODUCTION } from '@walkeros/core';\nimport { injectScript } from './injectScript';\n\n// The base64url sha384 of the script's bytes: names the file and is its\n// integrity value.\nconst FILE = /^[A-Za-z0-9_-]{64}$/;\n\n// Shared by every copy on the page, so the first loader is the only one.\nconst GUARD = Symbol.for('walkeros.moin');\n\n/**\n * The Tag Mode loader. Armed only by `?elbMoin` or the tab flag it leaves in\n * sessionStorage, and only in the top frame; it then waits for one message\n * from `target.app` naming a script by its hash, and loads that script from\n * `target.base` with the same hash as its integrity. Not armed, it adds no\n * listener, makes no request and writes nothing.\n */\nexport function moin(target: MoinTarget = MOIN_PRODUCTION): void {\n if (typeof window === 'undefined') return;\n runMoin(window, target);\n}\n\n/** `moin` against an explicit window. */\nexport function runMoin(win: Window, target: MoinTarget): void {\n // The loader runs first in every bundle: nothing here may stop it.\n try {\n if (\n typeof URLSearchParams === 'undefined' ||\n win.top !== win ||\n Reflect.get(win, GUARD)\n )\n return;\n\n let armed = new URLSearchParams(win.location.search).has(MOIN_PARAM);\n try {\n const storage = win.sessionStorage;\n armed = armed || storage.getItem(MOIN_PARAM) === '1';\n if (armed) storage.setItem(MOIN_PARAM, '1');\n } catch {\n // Storage denied: the parameter alone arms.\n }\n if (!armed) return;\n Reflect.set(win, GUARD, true);\n\n const onMessage = (event: MessageEvent): void => {\n if (event.origin !== target.app) return;\n const data: unknown = event.data;\n if (typeof data !== 'object' || data === null) return;\n if (Reflect.get(data, 'elbMoin') !== 1) return;\n const file: unknown = Reflect.get(data, 'file');\n if (typeof file !== 'string' || !FILE.test(file)) return;\n win.removeEventListener('message', onMessage, true);\n void injectScript(\n `${target.base}${file}.js`,\n `sha384-${file.replace(/-/g, '+').replace(/_/g, '/')}`,\n );\n };\n // In the capture phase: a site that screens messages by origin and stops\n // the ones it does not know would otherwise keep the app's ping from the\n // loader. On the window, a capture listener runs before every listener of\n // the bubble phase.\n win.addEventListener('message', onMessage, true);\n } catch {\n // A broken page global leaves the loader off.\n }\n}\n","/**\n * Append an async `<script>` that only runs if its bytes match `integrity`.\n *\n * Resolves true on load and false on error, on a missing document, when the\n * page refuses the script (a Trusted Types policy throws on a plain string\n * URL), or when `timeoutMs` passes first; a script that did not load is\n * removed. Without `timeoutMs` it waits for load or error alone. Never\n * rejects.\n */\nexport function injectScript(\n src: string,\n integrity: string,\n timeoutMs?: number,\n): Promise<boolean> {\n return new Promise((resolve) => {\n let script: HTMLScriptElement | undefined;\n let settled = false;\n let timer: ReturnType<typeof setTimeout> | undefined;\n const done = (ok: boolean) => {\n if (settled) return;\n settled = true;\n resolve(ok);\n if (timer !== undefined) clearTimeout(timer);\n if (!ok && script?.parentNode) script.parentNode.removeChild(script);\n };\n try {\n if (typeof document === 'undefined') {\n done(false);\n return;\n }\n script = document.createElement('script');\n if (timeoutMs !== undefined)\n timer = setTimeout(() => done(false), timeoutMs);\n script.onload = () => done(true);\n script.onerror = () => done(false);\n script.setAttribute('integrity', integrity);\n script.setAttribute('crossorigin', 'anonymous');\n script.async = true;\n script.src = src;\n document.head.appendChild(script);\n } catch {\n done(false);\n }\n });\n}\n","import type { ObserveSlot } from '@walkeros/core';\nimport { OBSERVE_STORAGE_KEY } from '@walkeros/core';\n\n/**\n * Last `elbObserve` URL param value, or null. The param name and the\n * storage slot share the `elbObserve` key by design (the preview activator\n * ferries the former into the latter). Never throws.\n */\nfunction readObserveParam(): string | null {\n try {\n const search = new URLSearchParams(\n window.location.search.replace(/^\\?/, ''),\n );\n const values = search.getAll(OBSERVE_STORAGE_KEY);\n return values.length > 0 ? (values[values.length - 1] ?? null) : null;\n } catch {\n return null;\n }\n}\n\n/** Stored `elbObserve` slot, or null. Never throws (Safari private mode). */\nfunction readObserveSlot(): string | null {\n try {\n return window.localStorage.getItem(OBSERVE_STORAGE_KEY);\n } catch {\n return null;\n }\n}\n\nfunction writeObserveSlot(value: string): void {\n try {\n window.localStorage.setItem(OBSERVE_STORAGE_KEY, value);\n } catch {\n // Slot persistence is best-effort; the session still attaches this page.\n }\n}\n\n/**\n * CAS-style slot clear: remove the slot only when it still holds exactly\n * `expected`, so a credential re-minted by another tab (or a later\n * activation) is never destroyed by a stale poster's self-heal.\n */\nfunction clearObserveSlotIf(expected: string): void {\n try {\n if (window.localStorage.getItem(OBSERVE_STORAGE_KEY) === expected) {\n window.localStorage.removeItem(OBSERVE_STORAGE_KEY);\n }\n } catch {\n // Storage unavailable: nothing to heal.\n }\n}\n\n/**\n * Remove the `elbObserve` param from the address bar after it has been\n * persisted to the slot, keeping every other param and the hash intact.\n * Same history.replaceState mechanics as the preview activator's\n * stripParam, but scoped to the one param this slot owns.\n */\nfunction stripObserveParam(): void {\n try {\n const href = window.location.href;\n const hashIdx = href.indexOf('#');\n const hash = hashIdx >= 0 ? href.slice(hashIdx) : '';\n const withoutHash = hashIdx >= 0 ? href.slice(0, hashIdx) : href;\n const qIdx = withoutHash.indexOf('?');\n const path = qIdx >= 0 ? withoutHash.slice(0, qIdx) : withoutHash;\n const params = new URLSearchParams(\n qIdx >= 0 ? withoutHash.slice(qIdx + 1) : '',\n );\n params.delete(OBSERVE_STORAGE_KEY);\n const query = params.toString();\n window.history.replaceState(\n {},\n '',\n `${path}${query ? `?${query}` : ''}${hash}`,\n );\n } catch {\n // A page that forbids history writes still attaches; the param stays.\n }\n}\n\n/**\n * The page's Observe credential slot, for a web `observe` config:\n * `startFlow({ observe: { url, binding, slot: pageObserveSlot() } })`.\n *\n * The credential arrives out-of-band as the `elbObserve` URL param, or in\n * the `localStorage` slot the preview activator ferries it into. A URL\n * credential wins over a stored one. Once kept, a URL-borne copy is\n * stripped from the address bar: it is a bearer credential and must not\n * linger there. Every page access is guarded, so no method throws.\n */\nexport function pageObserveSlot(): ObserveSlot {\n return {\n read() {\n const param = readObserveParam();\n const raw = param ?? readObserveSlot();\n // Truly absent (or empty) is null: the web arm does zero work.\n if (!raw) return null;\n return { raw, fromUrl: param !== null };\n },\n keep(raw, fromUrl) {\n writeObserveSlot(raw);\n if (fromUrl) stripObserveParam();\n },\n clear(raw) {\n clearObserveSlotIf(raw);\n },\n };\n}\n","import type {\n ActivationGrant,\n PreviewCrypto,\n PreviewKey,\n} from '@walkeros/core';\nimport { OBSERVE_STORAGE_KEY, verifyActivation } from '@walkeros/core';\nimport { injectScript } from './injectScript';\n\nexport interface SwapActivatorConfig {\n keyring: PreviewKey[];\n iss: string;\n /** This bundle's project binding. Absent on demo hosts (see acceptForeign). */\n pb?: string;\n acceptForeign?: boolean;\n demoAllowlist?: string[];\n /** Bare CDN hostname, e.g. 'cdn.walkeros.io'. */\n previewOrigin: string;\n /** Injectable for tests. */\n now?: () => number;\n crypto?: PreviewCrypto;\n}\n\nconst STORAGE_KEY = 'elbPreview';\n/**\n * Storage slot for the session-forwarding companion grant. The web arm never\n * verifies it (it is session-bound by design; the session container is its\n * verifier): the activator only ferries it from the activation URL into\n * storage, where the seamed preview artifact reads it to stamp the\n * `X-Walkeros-Preview` header. It lives and dies with the activation state:\n * set (or cleared) whenever a URL activation succeeds, cleared whenever the\n * stored activation clears.\n */\nexport const SESSION_STORAGE_KEY = 'elbPreviewSession';\nconst LOG = '[walkerOS:preview]';\nconst SWAP_TIMEOUT_MS = 5000;\n\ninterface PreviewStore {\n get(): string | null;\n set(value: string): void;\n clear(): void;\n}\n\n/** localStorage under `key`, with an in-memory fallback for Safari private mode. */\nfunction createStore(key: string): PreviewStore {\n let memory: string | null = null;\n return {\n get() {\n try {\n return window.localStorage.getItem(key) ?? memory;\n } catch {\n return memory;\n }\n },\n set(value) {\n try {\n window.localStorage.setItem(key, value);\n } catch {\n memory = value;\n }\n },\n clear() {\n memory = null;\n try {\n window.localStorage.removeItem(key);\n } catch {\n // in-memory copy already cleared\n }\n },\n };\n}\n\nfunction stripParam(): void {\n if (typeof URLSearchParams === 'undefined') return;\n try {\n const href = window.location.href;\n const hashIdx = href.indexOf('#');\n const hash = hashIdx >= 0 ? href.slice(hashIdx) : '';\n const withoutHash = hashIdx >= 0 ? href.slice(0, hashIdx) : href;\n const qIdx = withoutHash.indexOf('?');\n const path = qIdx >= 0 ? withoutHash.slice(0, qIdx) : withoutHash;\n const params = new URLSearchParams(\n qIdx >= 0 ? withoutHash.slice(qIdx + 1) : '',\n );\n params.delete('elbPreview');\n params.delete('elbPreviewSession');\n params.delete('elbObserve');\n const query = params.toString();\n window.history.replaceState(\n {},\n '',\n `${path}${query ? `?${query}` : ''}${hash}`,\n );\n } catch {\n // A page that forbids history writes still previews; the param just stays.\n }\n}\n\n/**\n * Decide whether a preview bundle should boot in place of this bundle's own flow.\n *\n * Returns true iff a preview took over, in which case the caller must not boot\n * the production flow. Every failure path deterministically returns false: the\n * loader never throws, never retries, and never leaves a page without a walker.\n *\n * Anti-griefing invariant: a rejected URL grant never touches stored state,\n * the activator falls back to the stored grant instead. Only a failing stored\n * grant clears storage (self-heal), plus `off` and `swap-failed`.\n */\nexport async function browserSwapActivator(\n cfg: SwapActivatorConfig,\n): Promise<boolean> {\n if (typeof window === 'undefined' || typeof document === 'undefined')\n return false;\n const win = window;\n\n const store = createStore(STORAGE_KEY);\n const sessionStore = createStore(SESSION_STORAGE_KEY);\n const observeStore = createStore(OBSERVE_STORAGE_KEY);\n const now = cfg.now ?? (() => Date.now());\n const warn = (reason: string) => console.warn(`${LOG} ${reason}`);\n\n let param: string | null = null;\n let companion: string | null = null;\n let observeCompanion: string | null = null;\n if (typeof URLSearchParams !== 'undefined') {\n try {\n const search = new URLSearchParams(\n win.location.search.replace(/^\\?/, ''),\n );\n const values = search.getAll('elbPreview');\n param = values.length > 0 ? (values[values.length - 1] ?? null) : null;\n const companions = search.getAll('elbPreviewSession');\n companion =\n companions.length > 0\n ? (companions[companions.length - 1] ?? null)\n : null;\n const observes = search.getAll('elbObserve');\n observeCompanion =\n observes.length > 0 ? (observes[observes.length - 1] ?? null) : null;\n } catch {\n param = null;\n companion = null;\n observeCompanion = null;\n }\n }\n\n if (param === 'off') {\n store.clear();\n sessionStore.clear();\n observeStore.clear();\n stripParam();\n return false;\n }\n\n const stored = store.get();\n\n // Zero-work fast path: the overwhelmingly common case on a production page.\n // No crypto, no storage writes, no DOM work.\n if (!param && !stored) return false;\n\n const verify = (raw: string, source: 'url' | 'storage') =>\n verifyActivation(raw, {\n keyring: cfg.keyring,\n iss: cfg.iss,\n origin: win.location.origin,\n pb: cfg.pb,\n acceptForeign: cfg.acceptForeign,\n demoAllowlist: cfg.demoAllowlist,\n source,\n now: now(),\n crypto: cfg.crypto,\n });\n\n let grant: ActivationGrant | null = null;\n\n // 1) URL grant first. Rejection for any reason (malformed, unsigned, bad\n // signature, expired, wrong aud) is warned and ignored, and must never\n // clear stored state: verification runs cheap checks before crypto, so\n // at rejection time we cannot know whether the value was even one of\n // ours, and a crafted link must not end someone's active session.\n if (param) {\n const result = await verify(param, 'url');\n if (result.ok) {\n grant = result.grant;\n store.set(param);\n // The URL activation defines the session context: carry its companion\n // forwarding grant into storage, or clear a stale one from an earlier\n // session. Never verified here: the session container is its verifier.\n if (companion) sessionStore.set(companion);\n else sessionStore.clear();\n // Same rule for the observe ingest credential: ferried raw, never\n // verified here (the observer is its verifier).\n if (observeCompanion) observeStore.set(observeCompanion);\n else observeStore.clear();\n } else {\n warn(result.reason);\n }\n stripParam();\n }\n\n // 2) Fall back to the stored grant. This one clears on failure: it came\n // from our own storage, so clearing is self-healing, not griefable.\n // (Except `no-subtle`: that is the environment's fault, not the grant's.)\n if (!grant && stored) {\n const result = await verify(stored, 'storage');\n if (result.ok) {\n grant = result.grant;\n } else {\n warn(result.reason);\n if (result.reason !== 'no-subtle') {\n store.clear();\n sessionStore.clear();\n observeStore.clear();\n }\n }\n }\n\n if (!grant) return false;\n\n const src = `https://${cfg.previewOrigin}/preview/${grant.art}.js`;\n const loaded = await injectScript(src, grant.sri, SWAP_TIMEOUT_MS);\n\n if (!loaded) {\n warn('swap-failed');\n store.clear();\n sessionStore.clear();\n observeStore.clear();\n return false;\n }\n\n console.info(\n `${LOG} active ${grant.art} ends ${new Date(grant.sxp * 1000).toISOString()}`,\n );\n return true;\n}\n","import type { SendDataValue, SendHeaders, SendResponse } from '@walkeros/core';\nimport {\n getHeaders,\n networkErrorMessage,\n StepError,\n transformData,\n tryCatch,\n} from '@walkeros/core';\n\nexport type SendWebTransport = 'fetch' | 'beacon' | 'xhr';\n\nexport interface SendWebOptions {\n headers?: SendHeaders;\n transport?: SendWebTransport;\n method?: string;\n}\n\nexport interface SendWebOptionsFetch extends SendWebOptions {\n credentials?: 'omit' | 'same-origin' | 'include'; // Add credentials option\n noCors?: boolean; // Add noCors option for fetch transport\n timeout?: number; // Abort the request after this many ms (default 10000)\n}\n\nconst DEFAULT_FETCH_TIMEOUT = 10000;\n\n/** Keepalive and beacon bodies a browser accepts in flight per page. */\nconst KEEPALIVE_LIMIT = 64 * 1024;\n\n/** Bytes of the keepalive fetches in flight on this page. */\nlet keepaliveBytes = 0;\n\ntype SendWebOptionsDynamic<T extends SendWebTransport> = T extends 'fetch'\n ? SendWebOptionsFetch\n : SendWebOptions;\n\nexport type SendWebReturn<T extends SendWebTransport> = T extends 'fetch'\n ? Promise<SendResponse>\n : SendResponse;\n\n/**\n * Send a request with `fetch` (default), `navigator.sendBeacon` or a\n * synchronous XHR. Resolves (fetch) or returns (beacon, xhr) `{ data }` when\n * the request was sent, and throws a `StepError` otherwise: `transport` with\n * `status` and `body` for a non-2xx answer or a network error, `timeout` for\n * a fetch past its timeout, `beacon-rejected` when the browser refuses a\n * beacon. The body stays on the error, never in its message.\n */\nexport function sendWeb<T extends SendWebTransport>(\n url: string,\n data?: SendDataValue,\n options: SendWebOptionsDynamic<T> & { transport?: T } = {\n transport: 'fetch' as T,\n },\n): SendWebReturn<T> {\n const transport = options.transport || 'fetch';\n\n switch (transport) {\n case 'beacon':\n return sendWebAsBeacon(url, data) as SendWebReturn<T>;\n case 'xhr':\n return sendWebAsXhr(url, data, options) as SendWebReturn<T>;\n case 'fetch':\n default:\n return sendWebAsFetch(url, data, options) as SendWebReturn<T>;\n }\n}\n\nexport async function sendWebAsFetch(\n url: string,\n data?: SendDataValue,\n options: SendWebOptionsFetch = {},\n): Promise<SendResponse> {\n const headers = getHeaders(options.headers);\n const body = transformData(data);\n const requested = options.timeout;\n const timeout =\n typeof requested === 'number' && Number.isFinite(requested) && requested > 0\n ? requested\n : DEFAULT_FETCH_TIMEOUT;\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), timeout);\n\n // Browsers refuse a keepalive request once the keepalive bodies in flight\n // exceed 64 KiB; past that a request goes out without keepalive instead.\n const size = body ? byteLength(body) : 0;\n const keepalive = keepaliveBytes + size <= KEEPALIVE_LIMIT;\n if (keepalive) keepaliveBytes += size;\n\n try {\n let response: Response;\n try {\n response = await fetch(url, {\n method: options.method || 'POST',\n headers,\n keepalive,\n credentials: options.credentials || 'same-origin',\n mode: options.noCors ? 'no-cors' : 'cors',\n body,\n signal: controller.signal,\n });\n } catch (error) {\n if (controller.signal.aborted)\n throw new StepError(`Request timed out after ${timeout}ms`, {\n code: 'timeout',\n cause: error,\n });\n throw new StepError(networkErrorMessage(error), {\n code: 'transport',\n cause: error,\n });\n }\n\n // A no-cors response is opaque: it counts as sent once it arrived.\n if (options.noCors) return { data: '' };\n\n const responseData = await response.text();\n if (!response.ok)\n throw new StepError(`HTTP ${response.status}`, {\n code: 'transport',\n status: response.status,\n body: responseData,\n });\n\n return { data: responseData };\n } finally {\n clearTimeout(timeoutId);\n if (keepalive) keepaliveBytes -= size;\n }\n}\n\nexport function sendWebAsBeacon(\n url: string,\n data?: SendDataValue,\n): SendResponse {\n const body = transformData(data);\n\n if (!navigator.sendBeacon(url, body)) {\n // Over the browser's 64 KiB quota a retry cannot help; a full queue can.\n const size = body ? byteLength(body) : 0;\n throw new StepError('Beacon rejected by the browser', {\n code: 'beacon-rejected',\n retryable: size <= KEEPALIVE_LIMIT,\n });\n }\n\n return {};\n}\n\nexport function sendWebAsXhr(\n url: string,\n data?: SendDataValue,\n options: SendWebOptions = {},\n): SendResponse {\n const headers = getHeaders(options.headers);\n const method = options.method || 'POST';\n const body = transformData(data);\n\n let xhr: XMLHttpRequest;\n try {\n xhr = new XMLHttpRequest();\n xhr.open(method, url, false); // Synchronous request\n for (const header in headers) {\n xhr.setRequestHeader(header, headers[header]);\n }\n xhr.send(body);\n } catch (error) {\n throw new StepError(networkErrorMessage(error), {\n code: 'transport',\n cause: error,\n });\n }\n\n const parsedData: unknown = tryCatch(\n JSON.parse,\n () => xhr.response,\n )(xhr.response);\n\n if (xhr.status < 200 || xhr.status >= 300)\n throw new StepError(`HTTP ${xhr.status}`, {\n code: 'transport',\n status: xhr.status || undefined,\n body: parsedData,\n });\n\n return { data: parsedData };\n}\n\n/** UTF-8 length of a request body, without TextEncoder. */\nfunction byteLength(text: string): number {\n let bytes = 0;\n for (let i = 0; i < text.length; i++) {\n const code = text.charCodeAt(i);\n if (code < 0x80) bytes += 1;\n else if (code < 0x800) bytes += 2;\n else if (code >= 0xd800 && code <= 0xdbff) {\n bytes += 4;\n i++; // The low surrogate belongs to this character.\n } else bytes += 3;\n }\n return bytes;\n}\n","import type { WalkerOS } from '@walkeros/core';\nimport type { StorageType } from '@walkeros/core';\nimport { castValue, Const } from '@walkeros/core';\n\nexport interface StorageValue {\n e: number; // Expiration timestamp\n v: string; // Value\n}\n\nexport interface StorageEnv {\n window?: Window & typeof globalThis;\n document?: Document;\n}\n\nexport function storageDelete(\n key: string,\n storage: StorageType = Const.Utils.Storage.Session,\n domain?: string,\n env?: StorageEnv,\n) {\n try {\n switch (storage) {\n case Const.Utils.Storage.Cookie:\n storageWrite(key, '', 0, storage, domain, env);\n break;\n case Const.Utils.Storage.Local:\n (env?.window ?? window).localStorage.removeItem(key);\n break;\n case Const.Utils.Storage.Session:\n (env?.window ?? window).sessionStorage.removeItem(key);\n break;\n }\n } catch (err) {\n // Storage may be disabled (SecurityError in private browsing, sandboxed\n // iframes, or restrictive browser settings). Silently ignore.\n }\n}\n\nexport function storageRead(\n key: string,\n storage: StorageType = Const.Utils.Storage.Session,\n env?: StorageEnv,\n): WalkerOS.PropertyType {\n // Helper function for local and session storage to support expiration\n function parseItem(string: string | null): StorageValue {\n try {\n return JSON.parse(string || '');\n } catch (err) {\n let e = 1,\n v = '';\n\n // Remove expiration date\n if (string) {\n e = 0;\n v = string;\n }\n\n return { e, v };\n }\n }\n let value, item;\n\n try {\n switch (storage) {\n case Const.Utils.Storage.Cookie:\n value = decodeURIComponent(\n (env?.document ?? document).cookie\n .split('; ')\n .find((row) => row.startsWith(key + '='))\n ?.split('=')[1] || '',\n );\n break;\n case Const.Utils.Storage.Local:\n item = parseItem((env?.window ?? window).localStorage.getItem(key));\n break;\n case Const.Utils.Storage.Session:\n item = parseItem((env?.window ?? window).sessionStorage.getItem(key));\n break;\n }\n } catch (err) {\n // Storage may be disabled or inaccessible. Return empty string.\n return castValue('');\n }\n\n // Check if item is expired\n if (item) {\n value = item.v;\n\n if (item.e != 0 && item.e < Date.now()) {\n storageDelete(key, storage, undefined, env);\n value = ''; // Conceal the outdated value\n }\n }\n\n return castValue(value || '');\n}\n\nexport function storageWrite(\n key: string,\n value: WalkerOS.PropertyType,\n maxAgeInMinutes = 30,\n storage: StorageType = Const.Utils.Storage.Session,\n domain?: string,\n env?: StorageEnv,\n): WalkerOS.PropertyType {\n const e = Date.now() + 1000 * 60 * maxAgeInMinutes;\n const item: StorageValue = { e, v: String(value) };\n const stringifiedItem = JSON.stringify(item);\n\n try {\n switch (storage) {\n case Const.Utils.Storage.Cookie: {\n value = typeof value === 'object' ? JSON.stringify(value) : value;\n let cookie = `${key}=${encodeURIComponent(value)}; max-age=${\n maxAgeInMinutes * 60\n }; path=/; SameSite=Lax; secure`;\n\n if (domain) cookie += '; domain=' + domain;\n\n (env?.document ?? document).cookie = cookie;\n break;\n }\n case Const.Utils.Storage.Local:\n (env?.window ?? window).localStorage.setItem(key, stringifiedItem);\n break;\n case Const.Utils.Storage.Session:\n (env?.window ?? window).sessionStorage.setItem(key, stringifiedItem);\n break;\n }\n } catch (err) {\n // Storage may be disabled (SecurityError) or full (QuotaExceededError).\n // Return empty string to signal the write did not persist.\n return castValue('');\n }\n\n return storageRead(key, storage, env);\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { Destination as WalkerOSDestination } from '@walkeros/core';\n\nexport type TypesGeneric = WalkerOSDestination.TypesGeneric;\n\nexport interface Destination<T extends TypesGeneric = WalkerOSDestination.Types>\n extends WalkerOSDestination.Instance<T> {}\n\nexport type Init = WalkerOSDestination.Init;\n\nexport type Config<T extends TypesGeneric = WalkerOSDestination.Types> =\n WalkerOSDestination.Config<T>;\n\nexport type PartialConfig<T extends TypesGeneric = WalkerOSDestination.Types> =\n WalkerOSDestination.PartialConfig<T>;\n\nexport type InitFn<T extends TypesGeneric = WalkerOSDestination.Types> =\n WalkerOSDestination.InitFn<T>;\n\nexport type PushFn<T extends TypesGeneric = WalkerOSDestination.Types> =\n WalkerOSDestination.PushFn<T>;\n\nexport type PushEvent<Mapping = unknown> =\n WalkerOSDestination.PushEvent<Mapping>;\n\nexport type PushEvents<Mapping = unknown> =\n WalkerOSDestination.PushEvents<Mapping>;\n\n/**\n * Web-specific environment requirements interface\n *\n * Extends the core Env interface with web-specific\n * globals like window and document for browser destinations.\n */\nexport interface Env extends WalkerOSDestination.BaseEnv {\n /**\n * Properties to be added to the global `window` object\n *\n * Used by web destinations that expect browser-specific\n * global functions like analytics APIs.\n *\n * @example\n * ```typescript\n * window: {\n * gtag: () => {},\n * fbq: () => {},\n * dataLayer: []\n * }\n * ```\n */\n window?: Record<string, unknown>;\n\n /**\n * Properties to be added to the global `document` object\n *\n * Used by destinations that need DOM manipulation capabilities\n * for script loading or element creation.\n *\n * @example\n * ```typescript\n * document: {\n * createElement: () => ({ src: '', async: false }),\n * head: { appendChild: () => {} }\n * }\n * ```\n */\n document?: Record<string, unknown>;\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { Collector, WalkerOS, Source as CoreSource } from '@walkeros/core';\n\nexport type TypesGeneric = CoreSource.TypesGeneric;\n\nexport interface Source<T extends TypesGeneric = CoreSource.Types>\n extends CoreSource.Instance<T> {\n settings?: CoreSource.Settings<T>;\n mapping?: CoreSource.Mapping<T>;\n}\n\nexport type Init = Partial<Omit<Source, 'init'>> & Pick<Source, 'type'>;\n\nexport type Config<T extends TypesGeneric = CoreSource.Types> =\n CoreSource.Instance<T> & {\n settings: CoreSource.Settings<T>;\n mapping?: CoreSource.Mapping<T>;\n };\n\nexport type PartialConfig<T extends TypesGeneric = CoreSource.Types> = Partial<\n Config<T>\n>;\n\nexport type InitFn<T extends TypesGeneric = CoreSource.Types> = (\n collector: Collector.Instance,\n config: Config<T>,\n) => void | Promise<void>;\n","import type { Elb } from '@walkeros/core';\n\n// Simple re-exports from core\nexport type PushResult = Elb.PushResult;\nexport type Layer = Elb.Layer;\n","import type {\n Collector as CoreCollector,\n Elb,\n Hooks,\n WalkerOS,\n Destination as WalkerOSDestination,\n On,\n} from '@walkeros/core';\nimport type { Destination, Config as DestConfig } from './destination';\nimport type { Layer } from './elb';\nimport type { Events, Trigger } from './walker';\n\ndeclare global {\n interface Window {\n elbwalker: Collector;\n walkerjs: CoreCollector.Instance;\n elbLayer?: Layer;\n dataLayer: WalkerOS.Events | unknown | unknown[];\n elb: Elb.Fn<Promise<Elb.PushResult>>;\n }\n}\n\nexport interface Collector extends Omit<CoreCollector.Instance, 'config'> {\n config: Config & CoreCollector.Config;\n destinations: Destinations;\n push: Elb.Fn<Promise<Elb.PushResult>>;\n getAllEvents: (scope: Element, prefix: string) => Events;\n getEvents: (target: Element, trigger: Trigger, prefix: string) => Events;\n getGlobals: () => WalkerOS.Properties;\n _visibilityState?: {\n observer: IntersectionObserver | undefined;\n timers: WeakMap<HTMLElement, number>;\n duration: number;\n elementConfigs?: WeakMap<\n HTMLElement,\n { multiple: boolean; blocked: boolean }\n >;\n };\n}\n\nexport interface State {\n config: Config;\n destinations: Destinations;\n}\n\nexport interface Config {\n dataLayer: boolean;\n dataLayerConfig: DestConfig;\n elbLayer: Layer;\n listeners: boolean;\n pageview: boolean;\n prefix: string;\n run: boolean;\n scope: Scope;\n elb?: string;\n name?: string;\n}\n\nexport interface InitConfig extends Partial<Config> {\n consent?: WalkerOS.Consent;\n custom?: WalkerOS.Properties;\n destinations?: WalkerOSDestination.InitDestinations;\n hooks?: Hooks.Functions;\n on?: On.OnConfig;\n user?: WalkerOS.User;\n}\n\nexport interface Destinations {\n [name: string]: Destination;\n}\n\nexport type Scope = Element | Document;\n","import type { WalkerOS } from '@walkeros/core';\n\nexport type Events = Event[];\n\nexport interface Event {\n entity: string;\n action: string;\n data?: WalkerOS.Properties;\n context?: WalkerOS.OrderedProperties;\n trigger?: Trigger;\n nested: WalkerOS.Entities;\n}\n\nexport type KeyVal = [string, string];\n\nexport type Attributes = Array<string>;\n\nexport type Trigger =\n | 'click'\n | 'custom'\n | 'hover'\n | 'load'\n | 'pulse'\n | 'scroll'\n | 'submit'\n | 'visible'\n | 'visibles'\n | 'wait'\n | string;\n\nexport interface Filter {\n [name: string]: boolean;\n}\n\nexport interface TriggersActionGroups {\n [trigger: string]: TriggerActions;\n}\n\nexport type TriggerActions = Array<TriggerAction>;\n\ninterface TriggerAction {\n trigger: string;\n triggerParams?: string;\n action: string;\n actionParams?: string;\n}\n\nexport type ScrollElements = Array<[HTMLElement, number]>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAA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AAM,MAAM,QAAQ,SAC3C,QACA,KACuB;AAxGzB;AAyGE,QAAM,IAAI,KAAK,IAAI,IAAI,MAAO,KAAK;AACnC,QAAM,OAAqB,EAAE,GAAG,GAAG,OAAO,KAAK,EAAE;AACjD,QAAM,kBAAkB,KAAK,UAAU,IAAI;AAE3C,MAAI;AACF,YAAQ,SAAS;AAAA,MACf,KAAK,mBAAM,MAAM,QAAQ,QAAQ;AAC/B,gBAAQ,OAAO,UAAU,WAAW,KAAK,UAAU,KAAK,IAAI;AAC5D,YAAI,SAAS,GAAG,GAAG,IAAI,mBAAmB,KAAK,CAAC,aAC9C,kBAAkB,EACpB;AAEA,YAAI,OAAQ,WAAU,cAAc;AAEpC,UAAC,gCAAK,aAAL,YAAiB,UAAU,SAAS;AACrC;AAAA,MACF;AAAA,MACA,KAAK,mBAAM,MAAM,QAAQ;AACvB,UAAC,gCAAK,WAAL,YAAe,QAAQ,aAAa,QAAQ,KAAK,eAAe;AACjE;AAAA,MACF,KAAK,mBAAM,MAAM,QAAQ;AACvB,UAAC,gCAAK,WAAL,YAAe,QAAQ,eAAe,QAAQ,KAAK,eAAe;AACnE;AAAA,IACJ;AAAA,EACF,SAAS,KAAK;AAGZ,eAAO,wBAAU,EAAE;AAAA,EACrB;AAEA,SAAO,YAAY,KAAK,SAAS,GAAG;AACtC;;;ACxIA;;;ACAA;;;ACAA;;;ACAA;;;ACAA;","names":["import_core","import_core","import_core","import_core","import_core","import_core","import_core"]}
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function t(t,e){return(t.getAttribute(e)||"").trim()}function e(t,e=";"){if(!t)return[];const o=new RegExp(`(?:\\\\[\\s\\S]?|'(?:\\\\[\\s\\S]|[^'\\\\])*'(?![\\w\\u0080-\\uffff])|[^${e}\\\\])+`,"g");return t.match(o)||[]}function o(t){const[,e=t,o=""]=t.match(/^((?:\\[\s\S]|[^\\:])*):([\s\S]*)$/)||[];return[n(e),n(o)]}function n(t){return t.replace(/^\s*'|\\([\s\S])|'\s*$/g,(t,e)=>e||"").trim()}function r(t){const n={};return e(t).forEach(t=>{const[e,r]=o(t);e&&("true"===r?n[e]=!0:"false"===r?n[e]=!1:r&&/^\d+$/.test(r)?n[e]=parseInt(r,10):r&&/^\d+\.\d+$/.test(r)?n[e]=parseFloat(r):n[e]=r||!0)}),n}function s(t){return t.language}function i(){return Intl.DateTimeFormat().resolvedOptions().timeZone}function a(t){return`${t.screen.width}x${t.screen.height}`}var c=function(){const t=window;(t.elbLayer=t.elbLayer||[]).push(arguments)};import{OBSERVE_ENV_KEY as u,isEnvObserve as d,observeEnv as l,parseCallPath as f}from"@walkeros/core";function m(t){const e={window:"undefined"!=typeof window?window:globalThis.window,document:"undefined"!=typeof document?document:globalThis.document,...t},o=t&&t[u];if(("undefined"==typeof __WALKEROS_OBSERVE__||__WALKEROS_OBSERVE__)&&d(o)){delete e[u];const t=l(e,o.paths,o.record).env,n=new Set;for(const t of o.paths){const o=f(t)[0];if(void 0===o)continue;const r=e[o];null!==r&&"object"==typeof r&&n.add(o)}const r=Array.from(n,e=>[e,t[e]]);for(const[t,o]of r)e[t]=o}return e}import{isDefined as w}from"@walkeros/core";async function g(t,e){return(await async function(t){const e=w(window)&&window.crypto?window.crypto:void 0;if(!e||!e.subtle||!TextEncoder)return;const o=(new TextEncoder).encode(t),n=await e.subtle.digest("SHA-256",o);return Array.from(new Uint8Array(n)).map(t=>t.toString(16).padStart(2,"0")).join("")}(t)||"").slice(0,e)}function S(t,e,o){let n=t.elementFromPoint(e,o);for(;n&&n.shadowRoot;){const t=n.shadowRoot.elementFromPoint(e,o);if(!t||t===n)break;n=t}return n}function h(t,e){const o=[];let n=t;for(;n;){let t=n.parentElement;if(!t){const o=n.getRootNode();o instanceof e.self.ShadowRoot&&(t=o.host)}if(!t)break;o.push(t),n=t}return o}function p(t,e){const o=[];let n=t.getRootNode();for(;n instanceof e.self.ShadowRoot;)o.push(n.host),n=n.host.getRootNode();return o}function b(t,e,o){if(!function(t,e){const o=e.getComputedStyle(t);if("none"===o.display)return!1;if("visible"!==o.visibility)return!1;let n=t;for(;n;){const t=e.getComputedStyle(n).opacity;if(t&&Number(t)<.1)return!1;const o=n.parentElement;if(o){n=o;continue}const r=n.getRootNode();n=r instanceof e.self.ShadowRoot?r.host:null}return!0}(t,e))return!1;const n=t.getBoundingClientRect(),r=o.documentElement.clientWidth||e.innerWidth,s=o.documentElement.clientHeight||e.innerHeight,i=Math.max(n.left,0),a=Math.max(n.top,0),c=Math.min(n.right,r),u=Math.min(n.bottom,s);if(c<=i||u<=a)return!1;const d=S(o,(i+c)/2,(a+u)/2);return!!d&&(d===t||(!!h(d,e).includes(t)||!!p(t,e).includes(d)))}import{getHeaders as y,transformData as k,tryCatch as v,tryCatchAsync as R}from"@walkeros/core";function E(t,e,o={transport:"fetch"}){switch(o.transport||"fetch"){case"beacon":return x(t,e);case"xhr":return C(t,e,o);default:return U(t,e,o)}}async function U(t,e,o={}){const n=y(o.headers),r=k(e),s=o.timeout,i="number"==typeof s&&Number.isFinite(s)&&s>0?s:1e4,a=new AbortController,c=setTimeout(()=>a.abort(),i);return R(async()=>{try{const e=await fetch(t,{method:o.method||"POST",headers:n,keepalive:!0,credentials:o.credentials||"same-origin",mode:o.noCors?"no-cors":"cors",body:r,signal:a.signal}),s=o.noCors?"":await e.text();return{ok:e.ok,data:s,error:e.ok?void 0:e.statusText}}finally{clearTimeout(c)}},t=>(clearTimeout(c),{ok:!1,error:t.message}))()}function x(t,e){const o=k(e),n=navigator.sendBeacon(t,o);return{ok:n,error:n?void 0:"Failed to send beacon"}}function C(t,e,o={}){const n=y(o.headers),r=o.method||"POST",s=k(e);return v(()=>{const e=new XMLHttpRequest;e.open(r,t,!1);for(const t in n)e.setRequestHeader(t,n[t]);e.send(s);const o=e.status>=200&&e.status<300;return{ok:o,data:v(JSON.parse,()=>e.response)(e.response),error:o?void 0:`${e.status} ${e.statusText}`}},t=>({ok:!1,error:t.message}))()}import{castValue as T,Const as $}from"@walkeros/core";function O(t,e=$.Utils.Storage.Session,o,n){try{switch(e){case $.Utils.Storage.Cookie:N(t,"",0,e,o,n);break;case $.Utils.Storage.Local:(n?.window??window).localStorage.removeItem(t);break;case $.Utils.Storage.Session:(n?.window??window).sessionStorage.removeItem(t)}}catch(t){}}function I(t,e=$.Utils.Storage.Session,o){function n(t){try{return JSON.parse(t||"")}catch(e){let o=1,n="";return t&&(o=0,n=t),{e:o,v:n}}}let r,s;try{switch(e){case $.Utils.Storage.Cookie:r=decodeURIComponent((o?.document??document).cookie.split("; ").find(e=>e.startsWith(t+"="))?.split("=")[1]||"");break;case $.Utils.Storage.Local:s=n((o?.window??window).localStorage.getItem(t));break;case $.Utils.Storage.Session:s=n((o?.window??window).sessionStorage.getItem(t))}}catch(t){return T("")}return s&&(r=s.v,0!=s.e&&s.e<Date.now()&&(O(t,e,void 0,o),r="")),T(r||"")}function N(t,e,o=30,n=$.Utils.Storage.Session,r,s){const i={e:Date.now()+6e4*o,v:String(e)},a=JSON.stringify(i);try{switch(n){case $.Utils.Storage.Cookie:{e="object"==typeof e?JSON.stringify(e):e;let n=`${t}=${encodeURIComponent(e)}; max-age=${60*o}; path=/; SameSite=Lax; secure`;r&&(n+="; domain="+r),(s?.document??document).cookie=n;break}case $.Utils.Storage.Local:(s?.window??window).localStorage.setItem(t,a);break;case $.Utils.Storage.Session:(s?.window??window).sessionStorage.setItem(t,a)}}catch(t){return T("")}return I(t,n,s)}var _={},L={},W={},A={},F={};export{_ as DestinationWeb,W as Elb,L as SourceWeb,F as Walker,A as WebCollector,h as composedAncestors,S as deepElementFromPoint,c as elb,t as getAttribute,m as getEnv,g as getHashWeb,s as getLanguage,a as getScreenSize,i as getTimezone,b as isVisible,r as parseInlineConfig,E as sendWeb,x as sendWebAsBeacon,U as sendWebAsFetch,C as sendWebAsXhr,p as shadowHostsAbove,e as splitAttribute,o as splitKeyVal,O as storageDelete,I as storageRead,N as storageWrite};//# sourceMappingURL=index.mjs.map
|
|
1
|
+
function e(e,t){return(e.getAttribute(t)||"").trim()}function t(e,t=";"){if(!e)return[];const n=new RegExp(`(?:\\\\[\\s\\S]?|'(?:\\\\[\\s\\S]|[^'\\\\])*'(?![\\w\\u0080-\\uffff])|[^${t}\\\\])+`,"g");return e.match(n)||[]}function n(e){const[,t=e,n=""]=e.match(/^((?:\\[\s\S]|[^\\:])*):([\s\S]*)$/)||[];return[o(t),o(n)]}function o(e){return e.replace(/^\s*'|\\([\s\S])|'\s*$/g,(e,t)=>t||"").trim()}function r(e){const o={};return t(e).forEach(e=>{const[t,r]=n(e);t&&("true"===r?o[t]=!0:"false"===r?o[t]=!1:r&&/^\d+$/.test(r)?o[t]=parseInt(r,10):r&&/^\d+\.\d+$/.test(r)?o[t]=parseFloat(r):o[t]=r||!0)}),o}function i(e){return e.language}function a(){return Intl.DateTimeFormat().resolvedOptions().timeZone}function s(e){return`${e.screen.width}x${e.screen.height}`}var c=function(){const e=window;(e.elbLayer=e.elbLayer||[]).push(arguments)};import{OBSERVE_ENV_KEY as l,isEnvObserve as u,observeEnv as d,parseCallPath as f}from"@walkeros/core";function w(e){const t={window:"undefined"!=typeof window?window:globalThis.window,document:"undefined"!=typeof document?document:globalThis.document,...e},n=e&&e[l];if(("undefined"==typeof __WALKEROS_OBSERVE__||__WALKEROS_OBSERVE__)&&u(n)){delete t[l];const e=d(t,n.paths,n.record).env,o=new Set;for(const e of n.paths){const n=f(e)[0];if(void 0===n)continue;const r=t[n];null!==r&&"object"==typeof r&&o.add(n)}const r=Array.from(o,t=>[t,e[t]]);for(const[e,n]of r)t[e]=n}return t}import{isDefined as m}from"@walkeros/core";async function h(e,t){return(await async function(e){const t=m(window)&&window.crypto?window.crypto:void 0;if(!t||!t.subtle||!TextEncoder)return;const n=(new TextEncoder).encode(e),o=await t.subtle.digest("SHA-256",n);return Array.from(new Uint8Array(o)).map(e=>e.toString(16).padStart(2,"0")).join("")}(e)||"").slice(0,t)}function g(e,t,n){let o=e.elementFromPoint(t,n);for(;o&&o.shadowRoot;){const e=o.shadowRoot.elementFromPoint(t,n);if(!e||e===o)break;o=e}return o}function p(e,t){const n=[];let o=e;for(;o;){let e=o.parentElement;if(!e){const n=o.getRootNode();n instanceof t.self.ShadowRoot&&(e=n.host)}if(!e)break;n.push(e),o=e}return n}function S(e,t){const n=[];let o=e.getRootNode();for(;o instanceof t.self.ShadowRoot;)n.push(o.host),o=o.host.getRootNode();return n}function y(e,t,n){if(!function(e,t){const n=t.getComputedStyle(e);if("none"===n.display)return!1;if("visible"!==n.visibility)return!1;let o=e;for(;o;){const e=t.getComputedStyle(o).opacity;if(e&&Number(e)<.1)return!1;const n=o.parentElement;if(n){o=n;continue}const r=o.getRootNode();o=r instanceof t.self.ShadowRoot?r.host:null}return!0}(e,t))return!1;const o=e.getBoundingClientRect(),r=n.documentElement.clientWidth||t.innerWidth,i=n.documentElement.clientHeight||t.innerHeight,a=Math.max(o.left,0),s=Math.max(o.top,0),c=Math.min(o.right,r),l=Math.min(o.bottom,i);if(c<=a||l<=s)return!1;const u=g(n,(a+c)/2,(s+l)/2);return!!u&&(u===e||(!!p(u,t).includes(e)||!!S(e,t).includes(u)))}import{resolveDestinationTimeout as v,StepError as b}from"@walkeros/core";var $="data-walkeros-vendor",k=new WeakMap;function R(e,t,n,o,r){const i=function(e,t){const n=e.querySelectorAll(`script[${$}]`);return Array.from(n).find(e=>e.getAttribute("src")===t)}(e,t),a=i&&k.get(i);if(a)return a;const s={state:"loading",expired:!1,timeout:n,waiting:[]};if(i&&r())return s.state="loaded",k.set(i,s),s;const c=null!=i?i:e.createElement("script"),l=e=>{const t=s.waiting;s.waiting=[],t.forEach(t=>t(e))},u=setTimeout(()=>{s.expired=!0,l("expired")},n);if(k.set(c,s),c.addEventListener("load",()=>{clearTimeout(u),s.state="loaded",l("loaded")}),c.addEventListener("error",()=>{clearTimeout(u),s.state="failed",l("failed")}),!i){for(const[e,t]of Object.entries(o))c.setAttribute(e,t);c.src=t,c.async=!0,c.setAttribute($,""),e.head.appendChild(c)}return s}var E=()=>new b("Vendor script failed to load",{code:"vendor-not-loaded"});function P(e,t,n={}){var o,r;const i=()=>{const e=t();return null!=e};let a;if(e){const t=null!=(o=n.document)?o:"undefined"!=typeof document?document:void 0;if(!t)throw new b(`Vendor script ${e} has no document to go into`,{code:"vendor-not-ready"});a=R(t,e,v(n.timeout),null!=(r=n.attributes)?r:{},i)}const s=()=>{const e=t();return null==e?Promise.reject(new b("Vendor not ready: its global is missing",{code:"vendor-not-ready"})):Promise.resolve(e)};return{ready:()=>a?"failed"===a.state?Promise.reject(E()):"loaded"===a.state||a.expired?s():new Promise((e,t)=>{a.waiting.push(n=>{var o;"failed"===n?t(E()):"expired"===n?t((o=a.timeout,new b(`Vendor script did not load within ${o}ms`,{code:"vendor-timeout"}))):s().then(e,t)})}):s(),check(){if("failed"===(null==a?void 0:a.state))throw E()}}}import{MOIN_PARAM as A,MOIN_PRODUCTION as U}from"@walkeros/core";function O(e,t,n){return new Promise(o=>{let r,i,a=!1;const s=e=>{a||(a=!0,o(e),void 0!==i&&clearTimeout(i),!e&&(null==r?void 0:r.parentNode)&&r.parentNode.removeChild(r))};try{if("undefined"==typeof document)return void s(!1);r=document.createElement("script"),void 0!==n&&(i=setTimeout(()=>s(!1),n)),r.onload=()=>s(!0),r.onerror=()=>s(!1),r.setAttribute("integrity",t),r.setAttribute("crossorigin","anonymous"),r.async=!0,r.src=e,document.head.appendChild(r)}catch(e){s(!1)}})}var x=/^[A-Za-z0-9_-]{64}$/,L=Symbol.for("walkeros.moin");function I(e=U){"undefined"!=typeof window&&function(e,t){try{if("undefined"==typeof URLSearchParams||e.top!==e||Reflect.get(e,L))return;let n=new URLSearchParams(e.location.search).has(A);try{const t=e.sessionStorage;n=n||"1"===t.getItem(A),n&&t.setItem(A,"1")}catch(e){}if(!n)return;Reflect.set(e,L,!0);const o=n=>{if(n.origin!==t.app)return;const r=n.data;if("object"!=typeof r||null===r)return;if(1!==Reflect.get(r,"elbMoin"))return;const i=Reflect.get(r,"file");"string"==typeof i&&x.test(i)&&(e.removeEventListener("message",o,!0),O(`${t.base}${i}.js`,`sha384-${i.replace(/-/g,"+").replace(/_/g,"/")}`))};e.addEventListener("message",o,!0)}catch(e){}}(window,e)}import{OBSERVE_STORAGE_KEY as T}from"@walkeros/core";function C(){return{read(){const e=function(){var e;try{const t=new URLSearchParams(window.location.search.replace(/^\?/,"")).getAll(T);return t.length>0&&null!=(e=t[t.length-1])?e:null}catch(e){return null}}(),t=null!=e?e:function(){try{return window.localStorage.getItem(T)}catch(e){return null}}();return t?{raw:t,fromUrl:null!==e}:null},keep(e,t){!function(e){try{window.localStorage.setItem(T,e)}catch(e){}}(e),t&&function(){try{const e=window.location.href,t=e.indexOf("#"),n=t>=0?e.slice(t):"",o=t>=0?e.slice(0,t):e,r=o.indexOf("?"),i=r>=0?o.slice(0,r):o,a=new URLSearchParams(r>=0?o.slice(r+1):"");a.delete(T);const s=a.toString();window.history.replaceState({},"",`${i}${s?`?${s}`:""}${n}`)}catch(e){}}()},clear(e){!function(e){try{window.localStorage.getItem(T)===e&&window.localStorage.removeItem(T)}catch(e){}}(e)}}}import{OBSERVE_STORAGE_KEY as _,verifyActivation as N}from"@walkeros/core";var j="elbPreviewSession",W="[walkerOS:preview]";function F(e){let t=null;return{get(){var n;try{return null!=(n=window.localStorage.getItem(e))?n:t}catch(e){return t}},set(n){try{window.localStorage.setItem(e,n)}catch(e){t=n}},clear(){t=null;try{window.localStorage.removeItem(e)}catch(e){}}}}function H(){if("undefined"!=typeof URLSearchParams)try{const e=window.location.href,t=e.indexOf("#"),n=t>=0?e.slice(t):"",o=t>=0?e.slice(0,t):e,r=o.indexOf("?"),i=r>=0?o.slice(0,r):o,a=new URLSearchParams(r>=0?o.slice(r+1):"");a.delete("elbPreview"),a.delete("elbPreviewSession"),a.delete("elbObserve");const s=a.toString();window.history.replaceState({},"",`${i}${s?`?${s}`:""}${n}`)}catch(e){}}async function M(e){var t,n,o,r;if("undefined"==typeof window||"undefined"==typeof document)return!1;const i=window,a=F("elbPreview"),s=F(j),c=F(_),l=null!=(t=e.now)?t:()=>Date.now(),u=e=>console.warn(`${W} ${e}`);let d=null,f=null,w=null;if("undefined"!=typeof URLSearchParams)try{const e=new URLSearchParams(i.location.search.replace(/^\?/,"")),t=e.getAll("elbPreview");d=t.length>0&&null!=(n=t[t.length-1])?n:null;const a=e.getAll("elbPreviewSession");f=a.length>0&&null!=(o=a[a.length-1])?o:null;const s=e.getAll("elbObserve");w=s.length>0&&null!=(r=s[s.length-1])?r:null}catch(e){d=null,f=null,w=null}if("off"===d)return a.clear(),s.clear(),c.clear(),H(),!1;const m=a.get();if(!d&&!m)return!1;const h=(t,n)=>N(t,{keyring:e.keyring,iss:e.iss,origin:i.location.origin,pb:e.pb,acceptForeign:e.acceptForeign,demoAllowlist:e.demoAllowlist,source:n,now:l(),crypto:e.crypto});let g=null;if(d){const e=await h(d,"url");e.ok?(g=e.grant,a.set(d),f?s.set(f):s.clear(),w?c.set(w):c.clear()):u(e.reason),H()}if(!g&&m){const e=await h(m,"storage");e.ok?g=e.grant:(u(e.reason),"no-subtle"!==e.reason&&(a.clear(),s.clear(),c.clear()))}if(!g)return!1;const p=`https://${e.previewOrigin}/preview/${g.art}.js`;return await O(p,g.sri,5e3)?(console.info(`${W} active ${g.art} ends ${new Date(1e3*g.sxp).toISOString()}`),!0):(u("swap-failed"),a.clear(),s.clear(),c.clear(),!1)}import{getHeaders as V,networkErrorMessage as B,StepError as D,transformData as q,tryCatch as J}from"@walkeros/core";var K=0;function Z(e,t,n={transport:"fetch"}){switch(n.transport||"fetch"){case"beacon":return G(e,t);case"xhr":return X(e,t,n);default:return z(e,t,n)}}async function z(e,t,n={}){const o=V(n.headers),r=q(t),i=n.timeout,a="number"==typeof i&&Number.isFinite(i)&&i>0?i:1e4,s=new AbortController,c=setTimeout(()=>s.abort(),a),l=r?Y(r):0,u=K+l<=65536;u&&(K+=l);try{let t;try{t=await fetch(e,{method:n.method||"POST",headers:o,keepalive:u,credentials:n.credentials||"same-origin",mode:n.noCors?"no-cors":"cors",body:r,signal:s.signal})}catch(e){if(s.signal.aborted)throw new D(`Request timed out after ${a}ms`,{code:"timeout",cause:e});throw new D(B(e),{code:"transport",cause:e})}if(n.noCors)return{data:""};const i=await t.text();if(!t.ok)throw new D(`HTTP ${t.status}`,{code:"transport",status:t.status,body:i});return{data:i}}finally{clearTimeout(c),u&&(K-=l)}}function G(e,t){const n=q(t);if(!navigator.sendBeacon(e,n)){const e=n?Y(n):0;throw new D("Beacon rejected by the browser",{code:"beacon-rejected",retryable:e<=65536})}return{}}function X(e,t,n={}){const o=V(n.headers),r=n.method||"POST",i=q(t);let a;try{a=new XMLHttpRequest,a.open(r,e,!1);for(const e in o)a.setRequestHeader(e,o[e]);a.send(i)}catch(e){throw new D(B(e),{code:"transport",cause:e})}const s=J(JSON.parse,()=>a.response)(a.response);if(a.status<200||a.status>=300)throw new D(`HTTP ${a.status}`,{code:"transport",status:a.status||void 0,body:s});return{data:s}}function Y(e){let t=0;for(let n=0;n<e.length;n++){const o=e.charCodeAt(n);o<128?t+=1:o<2048?t+=2:o>=55296&&o<=56319?(t+=4,n++):t+=3}return t}import{castValue as Q,Const as ee}from"@walkeros/core";function te(e,t=ee.Utils.Storage.Session,n,o){var r,i;try{switch(t){case ee.Utils.Storage.Cookie:oe(e,"",0,t,n,o);break;case ee.Utils.Storage.Local:(null!=(r=null==o?void 0:o.window)?r:window).localStorage.removeItem(e);break;case ee.Utils.Storage.Session:(null!=(i=null==o?void 0:o.window)?i:window).sessionStorage.removeItem(e)}}catch(e){}}function ne(e,t=ee.Utils.Storage.Session,n){var o,r,i,a;function s(e){try{return JSON.parse(e||"")}catch(t){let n=1,o="";return e&&(n=0,o=e),{e:n,v:o}}}let c,l;try{switch(t){case ee.Utils.Storage.Cookie:c=decodeURIComponent((null==(r=(null!=(o=null==n?void 0:n.document)?o:document).cookie.split("; ").find(t=>t.startsWith(e+"=")))?void 0:r.split("=")[1])||"");break;case ee.Utils.Storage.Local:l=s((null!=(i=null==n?void 0:n.window)?i:window).localStorage.getItem(e));break;case ee.Utils.Storage.Session:l=s((null!=(a=null==n?void 0:n.window)?a:window).sessionStorage.getItem(e))}}catch(e){return Q("")}return l&&(c=l.v,0!=l.e&&l.e<Date.now()&&(te(e,t,void 0,n),c="")),Q(c||"")}function oe(e,t,n=30,o=ee.Utils.Storage.Session,r,i){var a,s,c;const l={e:Date.now()+6e4*n,v:String(t)},u=JSON.stringify(l);try{switch(o){case ee.Utils.Storage.Cookie:{t="object"==typeof t?JSON.stringify(t):t;let o=`${e}=${encodeURIComponent(t)}; max-age=${60*n}; path=/; SameSite=Lax; secure`;r&&(o+="; domain="+r),(null!=(a=null==i?void 0:i.document)?a:document).cookie=o;break}case ee.Utils.Storage.Local:(null!=(s=null==i?void 0:i.window)?s:window).localStorage.setItem(e,u);break;case ee.Utils.Storage.Session:(null!=(c=null==i?void 0:i.window)?c:window).sessionStorage.setItem(e,u)}}catch(e){return Q("")}return ne(e,o,i)}var re={},ie={},ae={},se={},ce={};export{re as DestinationWeb,ae as Elb,j as SESSION_STORAGE_KEY,ie as SourceWeb,$ as VENDOR_SCRIPT_MARKER,ce as Walker,se as WebCollector,M as browserSwapActivator,p as composedAncestors,g as deepElementFromPoint,c as elb,e as getAttribute,w as getEnv,h as getHashWeb,i as getLanguage,s as getScreenSize,a as getTimezone,y as isVisible,P as loadVendor,I as moin,C as pageObserveSlot,r as parseInlineConfig,Z as sendWeb,G as sendWebAsBeacon,z as sendWebAsFetch,X as sendWebAsXhr,S as shadowHostsAbove,t as splitAttribute,n as splitKeyVal,te as storageDelete,ne as storageRead,oe as storageWrite};//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/attributes.ts","../src/browser.ts","../src/elb.ts","../src/environment.ts","../src/getHashWeb.ts","../src/isVisible.ts","../src/sendWeb.ts","../src/storage.ts","../src/types/destination.ts","../src/types/source.ts","../src/types/elb.ts","../src/types/collector.ts","../src/types/walker.ts"],"sourcesContent":["/**\n * Get attribute value from element\n * @param element - DOM element\n * @param name - Attribute name\n * @returns Trimmed attribute value or empty string\n */\nexport function getAttribute(element: Element, name: string): string {\n return (element.getAttribute(name) || '').trim();\n}\n\n/**\n * Split attribute string by separator (semicolon by default)\n * Handles quoted values containing the separator and backslash escapes:\n * a backslash keeps the next character, e.g. `\\;`, in the current part.\n * Parts keep their quotes and escapes, splitKeyVal removes them.\n * @param str - String to split\n * @param separator - Separator character (default: ';')\n * @returns Array of attribute strings\n */\nexport function splitAttribute(str: string, separator = ';'): string[] {\n if (!str) return [];\n // An escape pair, a quote group, or any other non-separator char. A quote\n // followed by an ASCII letter, a digit, `_` or any non-ASCII character never\n // closes a group, so a quote that closes none, like the apostrophe in\n // \"Men's\", is a plain character.\n const reg = new RegExp(\n `(?:\\\\\\\\[\\\\s\\\\S]?|'(?:\\\\\\\\[\\\\s\\\\S]|[^'\\\\\\\\])*'(?![\\\\w\\\\u0080-\\\\uffff])|[^${separator}\\\\\\\\])+`,\n 'g',\n );\n return str.match(reg) || [];\n}\n\n/**\n * Split key-value pair by the first unescaped colon\n * Removes surrounding whitespace and quotes and resolves backslash escapes\n * in both key and value.\n * @param str - String in format \"key:value\"\n * @returns Tuple of [key, value]\n */\nexport function splitKeyVal(str: string): [string, string] {\n const [, key = str, value = ''] =\n str.match(/^((?:\\\\[\\s\\S]|[^\\\\:])*):([\\s\\S]*)$/) || [];\n return [unquote(key), unquote(value)];\n}\n\n// Drop unescaped surrounding quotes, resolve escapes and trim whitespace.\nfunction unquote(str: string): string {\n return str\n .replace(/^\\s*'|\\\\([\\s\\S])|'\\s*$/g, (_, char?: string) => char || '')\n .trim();\n}\n\n/**\n * Parse inline configuration string into object\n * Supports type conversion for boolean and numeric values\n * @param str - Configuration string (e.g., \"elb:track;run:false;port:3000\")\n * @returns Parsed configuration object\n */\nexport function parseInlineConfig(str: string): Record<string, unknown> {\n const config: Record<string, unknown> = {};\n\n splitAttribute(str).forEach((pair) => {\n const [key, value] = splitKeyVal(pair);\n if (key) {\n // Type conversion\n if (value === 'true') {\n config[key] = true;\n } else if (value === 'false') {\n config[key] = false;\n } else if (value && /^\\d+$/.test(value)) {\n config[key] = parseInt(value, 10);\n } else if (value && /^\\d+\\.\\d+$/.test(value)) {\n config[key] = parseFloat(value);\n } else if (value) {\n config[key] = value;\n } else {\n // Key without value defaults to true\n config[key] = true;\n }\n }\n });\n\n return config;\n}\n","export function getLanguage(navigatorRef: Navigator): string | undefined {\n return navigatorRef.language;\n}\n\nexport function getTimezone(): string | undefined {\n return Intl.DateTimeFormat().resolvedOptions().timeZone;\n}\n\nexport function getScreenSize(windowRef: Window): string {\n return `${windowRef.screen.width}x${windowRef.screen.height}`;\n}\n","import type { Elb } from '@walkeros/core';\n\nexport const elb: Elb.Fn<void> = function () {\n const w = window as unknown as Record<string, unknown[]>;\n (w.elbLayer = w.elbLayer || []).push(arguments);\n};\n","import type { Env } from './types/destination';\nimport {\n OBSERVE_ENV_KEY,\n isEnvObserve,\n observeEnv,\n parseCallPath,\n} from '@walkeros/core';\n\n/**\n * Helper function to get environment globals with fallbacks\n *\n * Returns window and document by default, with optional environment overrides.\n * Generic over the caller's `Env` so a destination that narrows `window`/\n * `document` (and augments the DOM globals via `declare global`) gets those\n * narrowed types back without casting at the call site.\n *\n * When the collector injects an observe recorder under `OBSERVE_ENV_KEY` (trace\n * level, live-web paths wrapEnv could not resolve), the resolved roots are\n * wrapped in a transparent recording Proxy and the key is stripped before the\n * env reaches the destination. Outside trace the key is absent, so the guard is\n * a single property read with no wrapping cost.\n *\n * @param env - Optional environment overrides\n * @returns Env with window/document defaults and any provided overrides\n */\nexport function getEnv<E extends Env = Env>(env?: E) {\n // The DOM globals (typed `Window`/`Document`) are merged with the caller's\n // narrowed `Env` overrides. This intersection is asserted once here, at the\n // single boundary where the loose `Record`-typed base meets the real DOM\n // globals, so no destination has to cast `window`/`document` per call.\n const merged: Record<string, unknown> = {\n window: typeof window !== 'undefined' ? window : globalThis.window,\n document: typeof document !== 'undefined' ? document : globalThis.document,\n ...env,\n };\n\n // Build flag (see @walkeros/core build-flags): a lean bundle without\n // observe folds the recorder out; its collector never injects the key.\n const observe = env && env[OBSERVE_ENV_KEY];\n if (\n (typeof __WALKEROS_OBSERVE__ === 'undefined' || __WALKEROS_OBSERVE__) &&\n isEnvObserve(observe)\n ) {\n // Strip the recorder so it never reaches the destination (mirrors wrapEnv\n // stripping `simulation`).\n delete merged[OBSERVE_ENV_KEY];\n\n // The shared core recorder (the same one wrapEnv uses) returns a Proxy\n // view; only the tracked roots are swapped in, so untracked globals are\n // never touched. Writes fall through to the real target, so patterns like\n // gtm's `window[dataLayerName] = ...` mutate the actual global. A missing\n // or non-object root is left as-is (its leaf stays unresolvable).\n const view = observeEnv(merged, observe.paths, observe.record).env;\n const roots = new Set<string>();\n for (const path of observe.paths) {\n const root = parseCallPath(path)[0];\n if (root === undefined) continue;\n const target = merged[root];\n if (target !== null && typeof target === 'object') roots.add(root);\n }\n // Read every root view before swapping any in, so no view wraps another.\n const wrapped = Array.from(roots, (root) => [root, view[root]] as const);\n for (const [root, value] of wrapped) merged[root] = value;\n }\n\n return merged as Omit<E, 'window' | 'document'> & {\n window: Window & NonNullable<E['window']>;\n document: Document & NonNullable<E['document']>;\n };\n}\n","import { isDefined } from '@walkeros/core';\n\nasync function sha256(message: string): Promise<string | undefined> {\n const crypto: Crypto | undefined =\n isDefined(window) && window.crypto ? window.crypto : undefined;\n\n // Crypto API not available\n if (!crypto || !crypto.subtle || !TextEncoder) return;\n\n const msgBuffer = new TextEncoder().encode(message);\n const hashBuffer = await crypto.subtle.digest('SHA-256', msgBuffer);\n const hashArray = Array.from(new Uint8Array(hashBuffer));\n const hashHex = hashArray\n .map((b) => b.toString(16).padStart(2, '0'))\n .join('');\n return hashHex;\n}\n\nexport async function getHashWeb(\n str: string,\n length?: number,\n): Promise<string> {\n return ((await sha256(str)) || '').slice(0, length);\n}\n","/**\n * Resolve the topmost element at a point, descending into shadow trees.\n * `elementFromPoint` does not pierce shadow boundaries, so this re-probes each\n * open shadow root's own `elementFromPoint`. It descends through open roots and\n * stops at a closed host, whose `shadowRoot` is null.\n * @param root - Document or shadow root to probe from\n * @param x - Viewport x coordinate\n * @param y - Viewport y coordinate\n * @returns Deepest element at the point, or null when nothing is hit\n */\nexport function deepElementFromPoint(\n root: DocumentOrShadowRoot,\n x: number,\n y: number,\n): Element | null {\n let el = root.elementFromPoint(x, y);\n while (el && el.shadowRoot) {\n const inner = el.shadowRoot.elementFromPoint(x, y);\n if (!inner || inner === el) break;\n el = inner;\n }\n return el;\n}\n\n/**\n * Collect the composed ancestor chain of an element, walking `parentElement`\n * and hopping across shadow-host boundaries when a shadow root is reached.\n * Ancestry follows the flattened tree by DOM containment; it does not resolve\n * slot distribution (slotted light-DOM parents are not tracked).\n * @param node - Element to walk up from\n * @param win - Window owning the element, used for its realm's ShadowRoot\n * @returns Ancestors from nearest to furthest\n */\nexport function composedAncestors(node: Element, win: Window): Element[] {\n const chain: Element[] = [];\n let current: Element | null = node;\n while (current) {\n let parent: Element | null = current.parentElement;\n if (!parent) {\n const root = current.getRootNode();\n // `win.self` is load-bearing: the ShadowRoot constructor lives on\n // `Window & typeof globalThis` (the type of `win.self`), not the bare\n // `Window` parameter, so `win.ShadowRoot` would fail typecheck.\n if (root instanceof win.self.ShadowRoot) parent = root.host;\n }\n if (!parent) break;\n chain.push(parent);\n current = parent;\n }\n return chain;\n}\n\n/**\n * Collect the shadow hosts enclosing an element, crossing only shadow-host\n * boundaries. Unlike composedAncestors, plain light-DOM parents are skipped, so\n * the result contains hosts alone, ordered from innermost to outermost.\n * @param node - Element to walk up from\n * @param win - Window owning the element, used for its realm's ShadowRoot\n * @returns Enclosing shadow hosts, innermost first\n */\nexport function shadowHostsAbove(node: Element, win: Window): Element[] {\n const hosts: Element[] = [];\n let root = node.getRootNode();\n // `win.self` is load-bearing: the ShadowRoot constructor lives on\n // `Window & typeof globalThis` (the type of `win.self`), not the bare\n // `Window` parameter, so `win.ShadowRoot` would fail typecheck.\n while (root instanceof win.self.ShadowRoot) {\n hosts.push(root.host);\n root = root.host.getRootNode();\n }\n return hosts;\n}\n\n/**\n * True when the composed chain renders the element at all. `visibility`\n * inherits, so the element's own computed value is enough. `opacity` does NOT\n * inherit: a transparent ancestor leaves the element's own opacity at 1 while\n * hiding it, and elementFromPoint does not help because a transparent element\n * is still hit-testable. Walk the chain, crossing shadow-host boundaries.\n */\nfunction isRendered(element: HTMLElement, win: Window): boolean {\n const style = win.getComputedStyle(element);\n if (style.display === 'none') return false;\n if (style.visibility !== 'visible') return false;\n\n let current: Element | null = element;\n while (current) {\n const opacity = win.getComputedStyle(current).opacity;\n if (opacity && Number(opacity) < 0.1) return false;\n\n const parent: Element | null = current.parentElement;\n if (parent) {\n current = parent;\n continue;\n }\n const root = current.getRootNode();\n current = root instanceof win.self.ShadowRoot ? root.host : null;\n }\n\n return true;\n}\n\n/**\n * Whether the element is actually seen by the user: rendered, on screen, and\n * not painted over. Geometry (how much of it is showing) is decided by the\n * IntersectionObserver, which computes it during layout for free; this function\n * answers only the two questions the observer is blind to, so it runs once per\n * candidate impression rather than on every scroll frame.\n */\nexport function isVisible(\n element: HTMLElement,\n win: Window,\n doc: Document,\n): boolean {\n if (!isRendered(element, win)) return false;\n\n const rect = element.getBoundingClientRect();\n const viewportWidth = doc.documentElement.clientWidth || win.innerWidth;\n const viewportHeight = doc.documentElement.clientHeight || win.innerHeight;\n\n // Clip the element against the viewport. Probing the centre of this visible\n // band, rather than the centre of the element, is what removes the need for a\n // separate large-element branch: an element taller than the viewport has its\n // own centre off screen, which the previous implementation read as hidden.\n const left = Math.max(rect.left, 0);\n const top = Math.max(rect.top, 0);\n const right = Math.min(rect.right, viewportWidth);\n const bottom = Math.min(rect.bottom, viewportHeight);\n if (right <= left || bottom <= top) return false;\n\n const pointX = (left + right) / 2;\n const pointY = (top + bottom) / 2;\n\n const hit = deepElementFromPoint(doc, pointX, pointY);\n if (!hit) return false;\n if (hit === element) return true;\n if (composedAncestors(hit, win).includes(element)) return true;\n // Clause 3 is deliberately shadowHostsAbove (shadow-host hops only), not a\n // general ancestor walk. A plain light-DOM ancestor returned by\n // elementFromPoint (target has pointer-events:none, a transparent center, or\n // is covered via stacking) must NOT count as visible; restricting to shadow\n // hosts preserves light-DOM occlusion. Do not merge this with clause 2.\n if (shadowHostsAbove(element, win).includes(hit)) return true;\n return false;\n}\n","import type { SendDataValue, SendHeaders, SendResponse } from '@walkeros/core';\nimport {\n getHeaders,\n transformData,\n tryCatch,\n tryCatchAsync,\n} from '@walkeros/core';\n\nexport type SendWebTransport = 'fetch' | 'beacon' | 'xhr';\n\nexport interface SendWebOptions {\n headers?: SendHeaders;\n transport?: SendWebTransport;\n method?: string;\n}\n\nexport interface SendWebOptionsFetch extends SendWebOptions {\n credentials?: 'omit' | 'same-origin' | 'include'; // Add credentials option\n noCors?: boolean; // Add noCors option for fetch transport\n timeout?: number; // Abort the request after this many ms (default 10000)\n}\n\nconst DEFAULT_FETCH_TIMEOUT = 10000;\n\ntype SendWebOptionsDynamic<T extends SendWebTransport> = T extends 'fetch'\n ? SendWebOptionsFetch\n : SendWebOptions;\n\nexport type SendWebReturn<T extends SendWebTransport> = T extends 'fetch'\n ? Promise<SendResponse>\n : SendResponse;\n\nexport function sendWeb<T extends SendWebTransport>(\n url: string,\n data?: SendDataValue,\n options: SendWebOptionsDynamic<T> & { transport?: T } = {\n transport: 'fetch' as T,\n },\n): SendWebReturn<T> {\n const transport = options.transport || 'fetch';\n\n switch (transport) {\n case 'beacon':\n return sendWebAsBeacon(url, data) as SendWebReturn<T>;\n case 'xhr':\n return sendWebAsXhr(url, data, options) as SendWebReturn<T>;\n case 'fetch':\n default:\n return sendWebAsFetch(url, data, options) as SendWebReturn<T>;\n }\n}\n\nexport async function sendWebAsFetch(\n url: string,\n data?: SendDataValue,\n options: SendWebOptionsFetch = {},\n): Promise<SendResponse> {\n const headers = getHeaders(options.headers);\n const body = transformData(data);\n const requested = options.timeout;\n const timeout =\n typeof requested === 'number' && Number.isFinite(requested) && requested > 0\n ? requested\n : DEFAULT_FETCH_TIMEOUT;\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), timeout);\n\n return tryCatchAsync(\n async () => {\n try {\n const response = await fetch(url, {\n method: options.method || 'POST',\n headers,\n keepalive: true,\n credentials: options.credentials || 'same-origin',\n mode: options.noCors ? 'no-cors' : 'cors',\n body,\n signal: controller.signal,\n });\n\n const responseData = options.noCors ? '' : await response.text();\n\n return {\n ok: response.ok,\n data: responseData,\n error: response.ok ? undefined : response.statusText,\n };\n } finally {\n clearTimeout(timeoutId);\n }\n },\n (error) => {\n clearTimeout(timeoutId);\n return {\n ok: false,\n error: (error as Error).message,\n };\n },\n )();\n}\n\nexport function sendWebAsBeacon(\n url: string,\n data?: SendDataValue,\n): SendResponse {\n const body = transformData(data);\n const ok = navigator.sendBeacon(url, body);\n\n return {\n ok,\n error: ok ? undefined : 'Failed to send beacon',\n };\n}\n\nexport function sendWebAsXhr(\n url: string,\n data?: SendDataValue,\n options: SendWebOptions = {},\n): SendResponse {\n const headers = getHeaders(options.headers);\n const method = options.method || 'POST';\n const body = transformData(data);\n\n return tryCatch(\n () => {\n const xhr = new XMLHttpRequest();\n xhr.open(method, url, false); // Synchronous request\n for (const header in headers) {\n xhr.setRequestHeader(header, headers[header]);\n }\n xhr.send(body);\n\n const ok = xhr.status >= 200 && xhr.status < 300;\n\n const parsedData = tryCatch(JSON.parse, () => xhr.response)(xhr.response);\n\n return {\n ok,\n data: parsedData,\n error: ok ? undefined : `${xhr.status} ${xhr.statusText}`,\n };\n },\n (error) => {\n return {\n ok: false,\n error: (error as Error).message,\n };\n },\n )();\n}\n","import type { WalkerOS } from '@walkeros/core';\nimport type { StorageType } from '@walkeros/core';\nimport { castValue, Const } from '@walkeros/core';\n\nexport interface StorageValue {\n e: number; // Expiration timestamp\n v: string; // Value\n}\n\nexport interface StorageEnv {\n window?: Window & typeof globalThis;\n document?: Document;\n}\n\nexport function storageDelete(\n key: string,\n storage: StorageType = Const.Utils.Storage.Session,\n domain?: string,\n env?: StorageEnv,\n) {\n try {\n switch (storage) {\n case Const.Utils.Storage.Cookie:\n storageWrite(key, '', 0, storage, domain, env);\n break;\n case Const.Utils.Storage.Local:\n (env?.window ?? window).localStorage.removeItem(key);\n break;\n case Const.Utils.Storage.Session:\n (env?.window ?? window).sessionStorage.removeItem(key);\n break;\n }\n } catch (err) {\n // Storage may be disabled (SecurityError in private browsing, sandboxed\n // iframes, or restrictive browser settings). Silently ignore.\n }\n}\n\nexport function storageRead(\n key: string,\n storage: StorageType = Const.Utils.Storage.Session,\n env?: StorageEnv,\n): WalkerOS.PropertyType {\n // Helper function for local and session storage to support expiration\n function parseItem(string: string | null): StorageValue {\n try {\n return JSON.parse(string || '');\n } catch (err) {\n let e = 1,\n v = '';\n\n // Remove expiration date\n if (string) {\n e = 0;\n v = string;\n }\n\n return { e, v };\n }\n }\n let value, item;\n\n try {\n switch (storage) {\n case Const.Utils.Storage.Cookie:\n value = decodeURIComponent(\n (env?.document ?? document).cookie\n .split('; ')\n .find((row) => row.startsWith(key + '='))\n ?.split('=')[1] || '',\n );\n break;\n case Const.Utils.Storage.Local:\n item = parseItem((env?.window ?? window).localStorage.getItem(key));\n break;\n case Const.Utils.Storage.Session:\n item = parseItem((env?.window ?? window).sessionStorage.getItem(key));\n break;\n }\n } catch (err) {\n // Storage may be disabled or inaccessible. Return empty string.\n return castValue('');\n }\n\n // Check if item is expired\n if (item) {\n value = item.v;\n\n if (item.e != 0 && item.e < Date.now()) {\n storageDelete(key, storage, undefined, env);\n value = ''; // Conceal the outdated value\n }\n }\n\n return castValue(value || '');\n}\n\nexport function storageWrite(\n key: string,\n value: WalkerOS.PropertyType,\n maxAgeInMinutes = 30,\n storage: StorageType = Const.Utils.Storage.Session,\n domain?: string,\n env?: StorageEnv,\n): WalkerOS.PropertyType {\n const e = Date.now() + 1000 * 60 * maxAgeInMinutes;\n const item: StorageValue = { e, v: String(value) };\n const stringifiedItem = JSON.stringify(item);\n\n try {\n switch (storage) {\n case Const.Utils.Storage.Cookie: {\n value = typeof value === 'object' ? JSON.stringify(value) : value;\n let cookie = `${key}=${encodeURIComponent(value)}; max-age=${\n maxAgeInMinutes * 60\n }; path=/; SameSite=Lax; secure`;\n\n if (domain) cookie += '; domain=' + domain;\n\n (env?.document ?? document).cookie = cookie;\n break;\n }\n case Const.Utils.Storage.Local:\n (env?.window ?? window).localStorage.setItem(key, stringifiedItem);\n break;\n case Const.Utils.Storage.Session:\n (env?.window ?? window).sessionStorage.setItem(key, stringifiedItem);\n break;\n }\n } catch (err) {\n // Storage may be disabled (SecurityError) or full (QuotaExceededError).\n // Return empty string to signal the write did not persist.\n return castValue('');\n }\n\n return storageRead(key, storage, env);\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { Destination as WalkerOSDestination } from '@walkeros/core';\n\nexport type TypesGeneric = WalkerOSDestination.TypesGeneric;\n\nexport interface Destination<T extends TypesGeneric = WalkerOSDestination.Types>\n extends WalkerOSDestination.Instance<T> {}\n\nexport type Init = WalkerOSDestination.Init;\n\nexport type Config<T extends TypesGeneric = WalkerOSDestination.Types> =\n WalkerOSDestination.Config<T>;\n\nexport type PartialConfig<T extends TypesGeneric = WalkerOSDestination.Types> =\n WalkerOSDestination.PartialConfig<T>;\n\nexport type InitFn<T extends TypesGeneric = WalkerOSDestination.Types> =\n WalkerOSDestination.InitFn<T>;\n\nexport type PushFn<T extends TypesGeneric = WalkerOSDestination.Types> =\n WalkerOSDestination.PushFn<T>;\n\nexport type PushEvent<Mapping = unknown> =\n WalkerOSDestination.PushEvent<Mapping>;\n\nexport type PushEvents<Mapping = unknown> =\n WalkerOSDestination.PushEvents<Mapping>;\n\n/**\n * Web-specific environment requirements interface\n *\n * Extends the core Env interface with web-specific\n * globals like window and document for browser destinations.\n */\nexport interface Env extends WalkerOSDestination.BaseEnv {\n /**\n * Properties to be added to the global `window` object\n *\n * Used by web destinations that expect browser-specific\n * global functions like analytics APIs.\n *\n * @example\n * ```typescript\n * window: {\n * gtag: () => {},\n * fbq: () => {},\n * dataLayer: []\n * }\n * ```\n */\n window?: Record<string, unknown>;\n\n /**\n * Properties to be added to the global `document` object\n *\n * Used by destinations that need DOM manipulation capabilities\n * for script loading or element creation.\n *\n * @example\n * ```typescript\n * document: {\n * createElement: () => ({ src: '', async: false }),\n * head: { appendChild: () => {} }\n * }\n * ```\n */\n document?: Record<string, unknown>;\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { Collector, WalkerOS, Source as CoreSource } from '@walkeros/core';\n\nexport type TypesGeneric = CoreSource.TypesGeneric;\n\nexport interface Source<T extends TypesGeneric = CoreSource.Types>\n extends CoreSource.Instance<T> {\n settings?: CoreSource.Settings<T>;\n mapping?: CoreSource.Mapping<T>;\n}\n\nexport type Init = Partial<Omit<Source, 'init'>> & Pick<Source, 'type'>;\n\nexport type Config<T extends TypesGeneric = CoreSource.Types> =\n CoreSource.Instance<T> & {\n settings: CoreSource.Settings<T>;\n mapping?: CoreSource.Mapping<T>;\n };\n\nexport type PartialConfig<T extends TypesGeneric = CoreSource.Types> = Partial<\n Config<T>\n>;\n\nexport type InitFn<T extends TypesGeneric = CoreSource.Types> = (\n collector: Collector.Instance,\n config: Config<T>,\n) => void | Promise<void>;\n","import type { Elb } from '@walkeros/core';\n\n// Simple re-exports from core\nexport type PushResult = Elb.PushResult;\nexport type Layer = Elb.Layer;\n","import type {\n Collector as CoreCollector,\n Elb,\n Hooks,\n WalkerOS,\n Destination as WalkerOSDestination,\n On,\n} from '@walkeros/core';\nimport type { Destination, Config as DestConfig } from './destination';\nimport type { Layer } from './elb';\nimport type { Events, Trigger } from './walker';\n\ndeclare global {\n interface Window {\n elbwalker: Collector;\n walkerjs: CoreCollector.Instance;\n elbLayer?: Layer;\n dataLayer: WalkerOS.Events | unknown | unknown[];\n elb: Elb.Fn<Promise<Elb.PushResult>>;\n }\n}\n\nexport interface Collector extends Omit<CoreCollector.Instance, 'config'> {\n config: Config & CoreCollector.Config;\n destinations: Destinations;\n push: Elb.Fn<Promise<Elb.PushResult>>;\n getAllEvents: (scope: Element, prefix: string) => Events;\n getEvents: (target: Element, trigger: Trigger, prefix: string) => Events;\n getGlobals: () => WalkerOS.Properties;\n _visibilityState?: {\n observer: IntersectionObserver | undefined;\n timers: WeakMap<HTMLElement, number>;\n duration: number;\n elementConfigs?: WeakMap<\n HTMLElement,\n { multiple: boolean; blocked: boolean }\n >;\n };\n}\n\nexport interface State {\n config: Config;\n destinations: Destinations;\n}\n\nexport interface Config {\n dataLayer: boolean;\n dataLayerConfig: DestConfig;\n elbLayer: Layer;\n listeners: boolean;\n pageview: boolean;\n prefix: string;\n run: boolean;\n scope: Scope;\n elb?: string;\n name?: string;\n}\n\nexport interface InitConfig extends Partial<Config> {\n consent?: WalkerOS.Consent;\n custom?: WalkerOS.Properties;\n destinations?: WalkerOSDestination.InitDestinations;\n hooks?: Hooks.Functions;\n on?: On.OnConfig;\n user?: WalkerOS.User;\n}\n\nexport interface Destinations {\n [name: string]: Destination;\n}\n\nexport type Scope = Element | Document;\n","import type { WalkerOS } from '@walkeros/core';\n\nexport type Events = Event[];\n\nexport interface Event {\n entity: string;\n action: string;\n data?: WalkerOS.Properties;\n context?: WalkerOS.OrderedProperties;\n trigger?: Trigger;\n nested: WalkerOS.Entities;\n}\n\nexport type KeyVal = [string, string];\n\nexport type Attributes = Array<string>;\n\nexport type Trigger =\n | 'click'\n | 'custom'\n | 'hover'\n | 'load'\n | 'pulse'\n | 'scroll'\n | 'submit'\n | 'visible'\n | 'visibles'\n | 'wait'\n | string;\n\nexport interface Filter {\n [name: string]: boolean;\n}\n\nexport interface TriggersActionGroups {\n [trigger: string]: TriggerActions;\n}\n\nexport type TriggerActions = Array<TriggerAction>;\n\ninterface TriggerAction {\n trigger: string;\n triggerParams?: string;\n action: string;\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,EAAE;AAC9B;AAEO,SAAS,aACd,KACA,OACA,kBAAkB,IAClB,UAAuB,MAAM,MAAM,QAAQ,SAC3C,QACA,KACuB;AACvB,QAAM,IAAI,KAAK,IAAI,IAAI,MAAO,KAAK;AACnC,QAAM,OAAqB,EAAE,GAAG,GAAG,OAAO,KAAK,EAAE;AACjD,QAAM,kBAAkB,KAAK,UAAU,IAAI;AAE3C,MAAI;AACF,YAAQ,SAAS;AAAA,MACf,KAAK,MAAM,MAAM,QAAQ,QAAQ;AAC/B,gBAAQ,OAAO,UAAU,WAAW,KAAK,UAAU,KAAK,IAAI;AAC5D,YAAI,SAAS,GAAG,GAAG,IAAI,mBAAmB,KAAK,CAAC,aAC9C,kBAAkB,EACpB;AAEA,YAAI,OAAQ,WAAU,cAAc;AAEpC,SAAC,KAAK,YAAY,UAAU,SAAS;AACrC;AAAA,MACF;AAAA,MACA,KAAK,MAAM,MAAM,QAAQ;AACvB,SAAC,KAAK,UAAU,QAAQ,aAAa,QAAQ,KAAK,eAAe;AACjE;AAAA,MACF,KAAK,MAAM,MAAM,QAAQ;AACvB,SAAC,KAAK,UAAU,QAAQ,eAAe,QAAQ,KAAK,eAAe;AACnE;AAAA,IACJ;AAAA,EACF,SAAS,KAAK;AAGZ,WAAO,UAAU,EAAE;AAAA,EACrB;AAEA,SAAO,YAAY,KAAK,SAAS,GAAG;AACtC;;;ACxIA;;;ACAA;;;ACAA;;;ACAA;;;ACAA;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/attributes.ts","../src/browser.ts","../src/elb.ts","../src/environment.ts","../src/getHashWeb.ts","../src/isVisible.ts","../src/loadVendor.ts","../src/moin.ts","../src/injectScript.ts","../src/observeSlot.ts","../src/previewActivator.ts","../src/sendWeb.ts","../src/storage.ts","../src/types/destination.ts","../src/types/source.ts","../src/types/elb.ts","../src/types/collector.ts","../src/types/walker.ts"],"sourcesContent":["/**\n * Get attribute value from element\n * @param element - DOM element\n * @param name - Attribute name\n * @returns Trimmed attribute value or empty string\n */\nexport function getAttribute(element: Element, name: string): string {\n return (element.getAttribute(name) || '').trim();\n}\n\n/**\n * Split attribute string by separator (semicolon by default)\n * Handles quoted values containing the separator and backslash escapes:\n * a backslash keeps the next character, e.g. `\\;`, in the current part.\n * Parts keep their quotes and escapes, splitKeyVal removes them.\n * @param str - String to split\n * @param separator - Separator character (default: ';')\n * @returns Array of attribute strings\n */\nexport function splitAttribute(str: string, separator = ';'): string[] {\n if (!str) return [];\n // An escape pair, a quote group, or any other non-separator char. A quote\n // followed by an ASCII letter, a digit, `_` or any non-ASCII character never\n // closes a group, so a quote that closes none, like the apostrophe in\n // \"Men's\", is a plain character.\n const reg = new RegExp(\n `(?:\\\\\\\\[\\\\s\\\\S]?|'(?:\\\\\\\\[\\\\s\\\\S]|[^'\\\\\\\\])*'(?![\\\\w\\\\u0080-\\\\uffff])|[^${separator}\\\\\\\\])+`,\n 'g',\n );\n return str.match(reg) || [];\n}\n\n/**\n * Split key-value pair by the first unescaped colon\n * Removes surrounding whitespace and quotes and resolves backslash escapes\n * in both key and value.\n * @param str - String in format \"key:value\"\n * @returns Tuple of [key, value]\n */\nexport function splitKeyVal(str: string): [string, string] {\n const [, key = str, value = ''] =\n str.match(/^((?:\\\\[\\s\\S]|[^\\\\:])*):([\\s\\S]*)$/) || [];\n return [unquote(key), unquote(value)];\n}\n\n// Drop unescaped surrounding quotes, resolve escapes and trim whitespace.\nfunction unquote(str: string): string {\n return str\n .replace(/^\\s*'|\\\\([\\s\\S])|'\\s*$/g, (_, char?: string) => char || '')\n .trim();\n}\n\n/**\n * Parse inline configuration string into object\n * Supports type conversion for boolean and numeric values\n * @param str - Configuration string (e.g., \"elb:track;run:false;port:3000\")\n * @returns Parsed configuration object\n */\nexport function parseInlineConfig(str: string): Record<string, unknown> {\n const config: Record<string, unknown> = {};\n\n splitAttribute(str).forEach((pair) => {\n const [key, value] = splitKeyVal(pair);\n if (key) {\n // Type conversion\n if (value === 'true') {\n config[key] = true;\n } else if (value === 'false') {\n config[key] = false;\n } else if (value && /^\\d+$/.test(value)) {\n config[key] = parseInt(value, 10);\n } else if (value && /^\\d+\\.\\d+$/.test(value)) {\n config[key] = parseFloat(value);\n } else if (value) {\n config[key] = value;\n } else {\n // Key without value defaults to true\n config[key] = true;\n }\n }\n });\n\n return config;\n}\n","export function getLanguage(navigatorRef: Navigator): string | undefined {\n return navigatorRef.language;\n}\n\nexport function getTimezone(): string | undefined {\n return Intl.DateTimeFormat().resolvedOptions().timeZone;\n}\n\nexport function getScreenSize(windowRef: Window): string {\n return `${windowRef.screen.width}x${windowRef.screen.height}`;\n}\n","import type { Elb } from '@walkeros/core';\n\nexport const elb: Elb.Fn<void> = function () {\n const w = window as unknown as Record<string, unknown[]>;\n (w.elbLayer = w.elbLayer || []).push(arguments);\n};\n","import type { Env } from './types/destination';\nimport {\n OBSERVE_ENV_KEY,\n isEnvObserve,\n observeEnv,\n parseCallPath,\n} from '@walkeros/core';\n\n/**\n * Helper function to get environment globals with fallbacks\n *\n * Returns window and document by default, with optional environment overrides.\n * Generic over the caller's `Env` so a destination that narrows `window`/\n * `document` (and augments the DOM globals via `declare global`) gets those\n * narrowed types back without casting at the call site.\n *\n * When the collector injects an observe recorder under `OBSERVE_ENV_KEY` (trace\n * level, live-web paths wrapEnv could not resolve), the resolved roots are\n * wrapped in a transparent recording Proxy and the key is stripped before the\n * env reaches the destination. Outside trace the key is absent, so the guard is\n * a single property read with no wrapping cost.\n *\n * @param env - Optional environment overrides\n * @returns Env with window/document defaults and any provided overrides\n */\nexport function getEnv<E extends Env = Env>(env?: E) {\n // The DOM globals (typed `Window`/`Document`) are merged with the caller's\n // narrowed `Env` overrides. This intersection is asserted once here, at the\n // single boundary where the loose `Record`-typed base meets the real DOM\n // globals, so no destination has to cast `window`/`document` per call.\n const merged: Record<string, unknown> = {\n window: typeof window !== 'undefined' ? window : globalThis.window,\n document: typeof document !== 'undefined' ? document : globalThis.document,\n ...env,\n };\n\n // Build flag (see @walkeros/core build-flags): a lean bundle without\n // observe folds the recorder out; its collector never injects the key.\n const observe = env && env[OBSERVE_ENV_KEY];\n if (\n (typeof __WALKEROS_OBSERVE__ === 'undefined' || __WALKEROS_OBSERVE__) &&\n isEnvObserve(observe)\n ) {\n // Strip the recorder so it never reaches the destination (mirrors wrapEnv\n // stripping `simulation`).\n delete merged[OBSERVE_ENV_KEY];\n\n // The shared core recorder (the same one wrapEnv uses) returns a Proxy\n // view; only the tracked roots are swapped in, so untracked globals are\n // never touched. Writes fall through to the real target, so patterns like\n // gtm's `window[dataLayerName] = ...` mutate the actual global. A missing\n // or non-object root is left as-is (its leaf stays unresolvable).\n const view = observeEnv(merged, observe.paths, observe.record).env;\n const roots = new Set<string>();\n for (const path of observe.paths) {\n const root = parseCallPath(path)[0];\n if (root === undefined) continue;\n const target = merged[root];\n if (target !== null && typeof target === 'object') roots.add(root);\n }\n // Read every root view before swapping any in, so no view wraps another.\n const wrapped = Array.from(roots, (root) => [root, view[root]] as const);\n for (const [root, value] of wrapped) merged[root] = value;\n }\n\n return merged as Omit<E, 'window' | 'document'> & {\n window: Window & NonNullable<E['window']>;\n document: Document & NonNullable<E['document']>;\n };\n}\n","import { isDefined } from '@walkeros/core';\n\nasync function sha256(message: string): Promise<string | undefined> {\n const crypto: Crypto | undefined =\n isDefined(window) && window.crypto ? window.crypto : undefined;\n\n // Crypto API not available\n if (!crypto || !crypto.subtle || !TextEncoder) return;\n\n const msgBuffer = new TextEncoder().encode(message);\n const hashBuffer = await crypto.subtle.digest('SHA-256', msgBuffer);\n const hashArray = Array.from(new Uint8Array(hashBuffer));\n const hashHex = hashArray\n .map((b) => b.toString(16).padStart(2, '0'))\n .join('');\n return hashHex;\n}\n\nexport async function getHashWeb(\n str: string,\n length?: number,\n): Promise<string> {\n return ((await sha256(str)) || '').slice(0, length);\n}\n","/**\n * Resolve the topmost element at a point, descending into shadow trees.\n * `elementFromPoint` does not pierce shadow boundaries, so this re-probes each\n * open shadow root's own `elementFromPoint`. It descends through open roots and\n * stops at a closed host, whose `shadowRoot` is null.\n * @param root - Document or shadow root to probe from\n * @param x - Viewport x coordinate\n * @param y - Viewport y coordinate\n * @returns Deepest element at the point, or null when nothing is hit\n */\nexport function deepElementFromPoint(\n root: DocumentOrShadowRoot,\n x: number,\n y: number,\n): Element | null {\n let el = root.elementFromPoint(x, y);\n while (el && el.shadowRoot) {\n const inner = el.shadowRoot.elementFromPoint(x, y);\n if (!inner || inner === el) break;\n el = inner;\n }\n return el;\n}\n\n/**\n * Collect the composed ancestor chain of an element, walking `parentElement`\n * and hopping across shadow-host boundaries when a shadow root is reached.\n * Ancestry follows the flattened tree by DOM containment; it does not resolve\n * slot distribution (slotted light-DOM parents are not tracked).\n * @param node - Element to walk up from\n * @param win - Window owning the element, used for its realm's ShadowRoot\n * @returns Ancestors from nearest to furthest\n */\nexport function composedAncestors(node: Element, win: Window): Element[] {\n const chain: Element[] = [];\n let current: Element | null = node;\n while (current) {\n let parent: Element | null = current.parentElement;\n if (!parent) {\n const root = current.getRootNode();\n // `win.self` is load-bearing: the ShadowRoot constructor lives on\n // `Window & typeof globalThis` (the type of `win.self`), not the bare\n // `Window` parameter, so `win.ShadowRoot` would fail typecheck.\n if (root instanceof win.self.ShadowRoot) parent = root.host;\n }\n if (!parent) break;\n chain.push(parent);\n current = parent;\n }\n return chain;\n}\n\n/**\n * Collect the shadow hosts enclosing an element, crossing only shadow-host\n * boundaries. Unlike composedAncestors, plain light-DOM parents are skipped, so\n * the result contains hosts alone, ordered from innermost to outermost.\n * @param node - Element to walk up from\n * @param win - Window owning the element, used for its realm's ShadowRoot\n * @returns Enclosing shadow hosts, innermost first\n */\nexport function shadowHostsAbove(node: Element, win: Window): Element[] {\n const hosts: Element[] = [];\n let root = node.getRootNode();\n // `win.self` is load-bearing: the ShadowRoot constructor lives on\n // `Window & typeof globalThis` (the type of `win.self`), not the bare\n // `Window` parameter, so `win.ShadowRoot` would fail typecheck.\n while (root instanceof win.self.ShadowRoot) {\n hosts.push(root.host);\n root = root.host.getRootNode();\n }\n return hosts;\n}\n\n/**\n * True when the composed chain renders the element at all. `visibility`\n * inherits, so the element's own computed value is enough. `opacity` does NOT\n * inherit: a transparent ancestor leaves the element's own opacity at 1 while\n * hiding it, and elementFromPoint does not help because a transparent element\n * is still hit-testable. Walk the chain, crossing shadow-host boundaries.\n */\nfunction isRendered(element: HTMLElement, win: Window): boolean {\n const style = win.getComputedStyle(element);\n if (style.display === 'none') return false;\n if (style.visibility !== 'visible') return false;\n\n let current: Element | null = element;\n while (current) {\n const opacity = win.getComputedStyle(current).opacity;\n if (opacity && Number(opacity) < 0.1) return false;\n\n const parent: Element | null = current.parentElement;\n if (parent) {\n current = parent;\n continue;\n }\n const root = current.getRootNode();\n current = root instanceof win.self.ShadowRoot ? root.host : null;\n }\n\n return true;\n}\n\n/**\n * Whether the element is actually seen by the user: rendered, on screen, and\n * not painted over. Geometry (how much of it is showing) is decided by the\n * IntersectionObserver, which computes it during layout for free; this function\n * answers only the two questions the observer is blind to, so it runs once per\n * candidate impression rather than on every scroll frame.\n */\nexport function isVisible(\n element: HTMLElement,\n win: Window,\n doc: Document,\n): boolean {\n if (!isRendered(element, win)) return false;\n\n const rect = element.getBoundingClientRect();\n const viewportWidth = doc.documentElement.clientWidth || win.innerWidth;\n const viewportHeight = doc.documentElement.clientHeight || win.innerHeight;\n\n // Clip the element against the viewport. Probing the centre of this visible\n // band, rather than the centre of the element, is what removes the need for a\n // separate large-element branch: an element taller than the viewport has its\n // own centre off screen, which the previous implementation read as hidden.\n const left = Math.max(rect.left, 0);\n const top = Math.max(rect.top, 0);\n const right = Math.min(rect.right, viewportWidth);\n const bottom = Math.min(rect.bottom, viewportHeight);\n if (right <= left || bottom <= top) return false;\n\n const pointX = (left + right) / 2;\n const pointY = (top + bottom) / 2;\n\n const hit = deepElementFromPoint(doc, pointX, pointY);\n if (!hit) return false;\n if (hit === element) return true;\n if (composedAncestors(hit, win).includes(element)) return true;\n // Clause 3 is deliberately shadowHostsAbove (shadow-host hops only), not a\n // general ancestor walk. A plain light-DOM ancestor returned by\n // elementFromPoint (target has pointer-events:none, a transparent center, or\n // is covered via stacking) must NOT count as visible; restricting to shadow\n // hosts preserves light-DOM occlusion. Do not merge this with clause 2.\n if (shadowHostsAbove(element, win).includes(hit)) return true;\n return false;\n}\n","import { resolveDestinationTimeout, StepError } from '@walkeros/core';\n\n/** Attribute on every script `loadVendor` injects. */\nexport const VENDOR_SCRIPT_MARKER = 'data-walkeros-vendor';\n\nexport interface LoadVendorOptions {\n /** The destination's timeout; the load deadline is its resolved value. */\n timeout?: number;\n /**\n * Attributes the vendor's tag needs (e.g. `data-domain`), set before the\n * script is inserted. `src` and the marker cannot be overwritten.\n */\n attributes?: Record<string, string>;\n /**\n * The document the script goes into, and whose scripts are the registry:\n * the destination's env one (`getEnv(env).document`). The global document\n * without it.\n */\n document?: Document;\n}\n\nexport interface Vendor<T> {\n /**\n * Resolves with the vendor once its script loaded and `get()` finds it.\n * Rejects `vendor-not-loaded` after the script's `error` (final for the\n * page), `vendor-not-ready` when the vendor is missing, `vendor-timeout`\n * when the script did not load by the deadline. Past the deadline, and\n * without a script, it checks `get()` on each call.\n */\n ready(): Promise<T>;\n /**\n * For vendors that replay their own stub (called synchronously): throws\n * `vendor-not-loaded` once the injected script fired `error`.\n */\n check(): void;\n}\n\ntype Outcome = 'loaded' | 'failed' | 'expired';\n\ninterface Injected {\n state: 'loading' | 'loaded' | 'failed';\n /** The deadline passed before the script loaded or failed. */\n expired: boolean;\n timeout: number;\n waiting: Array<(outcome: Outcome) => void>;\n}\n\n/** The state of each vendor script, kept with its element. */\nconst injected = new WeakMap<Element, Injected>();\n\n/**\n * The page's script for `src`. The page itself is the registry: its one\n * marked script with that src means the src was injected (once per page, a\n * failure is never re-injected), and another document has its own.\n */\nfunction scriptOf(doc: Document, src: string): HTMLScriptElement | undefined {\n const marked = doc.querySelectorAll<HTMLScriptElement>(\n `script[${VENDOR_SCRIPT_MARKER}]`,\n );\n return Array.from(marked).find(\n (script) => script.getAttribute('src') === src,\n );\n}\n\nfunction inject(\n doc: Document,\n src: string,\n timeout: number,\n attributes: Record<string, string>,\n available: () => boolean,\n): Injected {\n const existing = scriptOf(doc, src);\n const known = existing && injected.get(existing);\n if (known) return known;\n\n const entry: Injected = {\n state: 'loading',\n expired: false,\n timeout,\n waiting: [],\n };\n\n // A marked script without state (another bundle's) is adopted, not\n // doubled. Its `load` may have fired already: with the vendor there, it is\n // ready at once; otherwise it is watched like an own script.\n if (existing && available()) {\n entry.state = 'loaded';\n injected.set(existing, entry);\n return entry;\n }\n const script = existing ?? doc.createElement('script');\n\n const settle = (outcome: Outcome) => {\n const waiting = entry.waiting;\n entry.waiting = [];\n waiting.forEach((notify) => notify(outcome));\n };\n\n const timer = setTimeout(() => {\n entry.expired = true;\n settle('expired');\n }, timeout);\n\n injected.set(script, entry);\n script.addEventListener('load', () => {\n clearTimeout(timer);\n entry.state = 'loaded';\n settle('loaded');\n });\n script.addEventListener('error', () => {\n clearTimeout(timer);\n entry.state = 'failed';\n settle('failed');\n });\n\n if (!existing) {\n for (const [name, value] of Object.entries(attributes))\n script.setAttribute(name, value);\n // After the attributes, so they never replace the src or the marker.\n script.src = src;\n script.async = true;\n script.setAttribute(VENDOR_SCRIPT_MARKER, '');\n doc.head.appendChild(script);\n }\n\n return entry;\n}\n\nconst notLoaded = () =>\n new StepError('Vendor script failed to load', { code: 'vendor-not-loaded' });\n\nconst notReady = () =>\n new StepError('Vendor not ready: its global is missing', {\n code: 'vendor-not-ready',\n });\n\nconst timedOut = (timeout: number) =>\n new StepError(`Vendor script did not load within ${timeout}ms`, {\n code: 'vendor-timeout',\n });\n\n/**\n * Injects a vendor script once per `src` on the page (marked\n * `data-walkeros-vendor`, with the `attributes` its tag needs) and reports\n * its readiness. The deadline runs from the injection and equals the\n * destination's resolved timeout, so an awaited `ready()` settles before the\n * push's own timeout. Without `src` (the page loads the vendor) nothing is\n * injected and there is no deadline. A `src` with no document to inject\n * into (neither `options.document` nor a global one) throws\n * `vendor-not-ready`.\n */\nexport function loadVendor<T>(\n src: string | undefined,\n get: () => T | undefined,\n options: LoadVendorOptions = {},\n): Vendor<T> {\n const available = () => {\n const vendor = get();\n return vendor !== undefined && vendor !== null;\n };\n\n let script: Injected | undefined;\n if (src) {\n const doc =\n options.document ??\n (typeof document !== 'undefined' ? document : undefined);\n if (!doc)\n throw new StepError(`Vendor script ${src} has no document to go into`, {\n code: 'vendor-not-ready',\n });\n script = inject(\n doc,\n src,\n resolveDestinationTimeout(options.timeout),\n options.attributes ?? {},\n available,\n );\n }\n\n const present = (): Promise<T> => {\n const vendor = get();\n return vendor === undefined || vendor === null\n ? Promise.reject(notReady())\n : Promise.resolve(vendor);\n };\n\n return {\n ready() {\n if (!script) return present();\n if (script.state === 'failed') return Promise.reject(notLoaded());\n if (script.state === 'loaded' || script.expired) return present();\n\n return new Promise<T>((resolve, reject) => {\n script.waiting.push((outcome) => {\n if (outcome === 'failed') reject(notLoaded());\n else if (outcome === 'expired') reject(timedOut(script.timeout));\n else present().then(resolve, reject);\n });\n });\n },\n check() {\n if (script?.state === 'failed') throw notLoaded();\n },\n };\n}\n","import type { MoinTarget } from '@walkeros/core';\nimport { MOIN_PARAM, MOIN_PRODUCTION } from '@walkeros/core';\nimport { injectScript } from './injectScript';\n\n// The base64url sha384 of the script's bytes: names the file and is its\n// integrity value.\nconst FILE = /^[A-Za-z0-9_-]{64}$/;\n\n// Shared by every copy on the page, so the first loader is the only one.\nconst GUARD = Symbol.for('walkeros.moin');\n\n/**\n * The Tag Mode loader. Armed only by `?elbMoin` or the tab flag it leaves in\n * sessionStorage, and only in the top frame; it then waits for one message\n * from `target.app` naming a script by its hash, and loads that script from\n * `target.base` with the same hash as its integrity. Not armed, it adds no\n * listener, makes no request and writes nothing.\n */\nexport function moin(target: MoinTarget = MOIN_PRODUCTION): void {\n if (typeof window === 'undefined') return;\n runMoin(window, target);\n}\n\n/** `moin` against an explicit window. */\nexport function runMoin(win: Window, target: MoinTarget): void {\n // The loader runs first in every bundle: nothing here may stop it.\n try {\n if (\n typeof URLSearchParams === 'undefined' ||\n win.top !== win ||\n Reflect.get(win, GUARD)\n )\n return;\n\n let armed = new URLSearchParams(win.location.search).has(MOIN_PARAM);\n try {\n const storage = win.sessionStorage;\n armed = armed || storage.getItem(MOIN_PARAM) === '1';\n if (armed) storage.setItem(MOIN_PARAM, '1');\n } catch {\n // Storage denied: the parameter alone arms.\n }\n if (!armed) return;\n Reflect.set(win, GUARD, true);\n\n const onMessage = (event: MessageEvent): void => {\n if (event.origin !== target.app) return;\n const data: unknown = event.data;\n if (typeof data !== 'object' || data === null) return;\n if (Reflect.get(data, 'elbMoin') !== 1) return;\n const file: unknown = Reflect.get(data, 'file');\n if (typeof file !== 'string' || !FILE.test(file)) return;\n win.removeEventListener('message', onMessage, true);\n void injectScript(\n `${target.base}${file}.js`,\n `sha384-${file.replace(/-/g, '+').replace(/_/g, '/')}`,\n );\n };\n // In the capture phase: a site that screens messages by origin and stops\n // the ones it does not know would otherwise keep the app's ping from the\n // loader. On the window, a capture listener runs before every listener of\n // the bubble phase.\n win.addEventListener('message', onMessage, true);\n } catch {\n // A broken page global leaves the loader off.\n }\n}\n","/**\n * Append an async `<script>` that only runs if its bytes match `integrity`.\n *\n * Resolves true on load and false on error, on a missing document, when the\n * page refuses the script (a Trusted Types policy throws on a plain string\n * URL), or when `timeoutMs` passes first; a script that did not load is\n * removed. Without `timeoutMs` it waits for load or error alone. Never\n * rejects.\n */\nexport function injectScript(\n src: string,\n integrity: string,\n timeoutMs?: number,\n): Promise<boolean> {\n return new Promise((resolve) => {\n let script: HTMLScriptElement | undefined;\n let settled = false;\n let timer: ReturnType<typeof setTimeout> | undefined;\n const done = (ok: boolean) => {\n if (settled) return;\n settled = true;\n resolve(ok);\n if (timer !== undefined) clearTimeout(timer);\n if (!ok && script?.parentNode) script.parentNode.removeChild(script);\n };\n try {\n if (typeof document === 'undefined') {\n done(false);\n return;\n }\n script = document.createElement('script');\n if (timeoutMs !== undefined)\n timer = setTimeout(() => done(false), timeoutMs);\n script.onload = () => done(true);\n script.onerror = () => done(false);\n script.setAttribute('integrity', integrity);\n script.setAttribute('crossorigin', 'anonymous');\n script.async = true;\n script.src = src;\n document.head.appendChild(script);\n } catch {\n done(false);\n }\n });\n}\n","import type { ObserveSlot } from '@walkeros/core';\nimport { OBSERVE_STORAGE_KEY } from '@walkeros/core';\n\n/**\n * Last `elbObserve` URL param value, or null. The param name and the\n * storage slot share the `elbObserve` key by design (the preview activator\n * ferries the former into the latter). Never throws.\n */\nfunction readObserveParam(): string | null {\n try {\n const search = new URLSearchParams(\n window.location.search.replace(/^\\?/, ''),\n );\n const values = search.getAll(OBSERVE_STORAGE_KEY);\n return values.length > 0 ? (values[values.length - 1] ?? null) : null;\n } catch {\n return null;\n }\n}\n\n/** Stored `elbObserve` slot, or null. Never throws (Safari private mode). */\nfunction readObserveSlot(): string | null {\n try {\n return window.localStorage.getItem(OBSERVE_STORAGE_KEY);\n } catch {\n return null;\n }\n}\n\nfunction writeObserveSlot(value: string): void {\n try {\n window.localStorage.setItem(OBSERVE_STORAGE_KEY, value);\n } catch {\n // Slot persistence is best-effort; the session still attaches this page.\n }\n}\n\n/**\n * CAS-style slot clear: remove the slot only when it still holds exactly\n * `expected`, so a credential re-minted by another tab (or a later\n * activation) is never destroyed by a stale poster's self-heal.\n */\nfunction clearObserveSlotIf(expected: string): void {\n try {\n if (window.localStorage.getItem(OBSERVE_STORAGE_KEY) === expected) {\n window.localStorage.removeItem(OBSERVE_STORAGE_KEY);\n }\n } catch {\n // Storage unavailable: nothing to heal.\n }\n}\n\n/**\n * Remove the `elbObserve` param from the address bar after it has been\n * persisted to the slot, keeping every other param and the hash intact.\n * Same history.replaceState mechanics as the preview activator's\n * stripParam, but scoped to the one param this slot owns.\n */\nfunction stripObserveParam(): void {\n try {\n const href = window.location.href;\n const hashIdx = href.indexOf('#');\n const hash = hashIdx >= 0 ? href.slice(hashIdx) : '';\n const withoutHash = hashIdx >= 0 ? href.slice(0, hashIdx) : href;\n const qIdx = withoutHash.indexOf('?');\n const path = qIdx >= 0 ? withoutHash.slice(0, qIdx) : withoutHash;\n const params = new URLSearchParams(\n qIdx >= 0 ? withoutHash.slice(qIdx + 1) : '',\n );\n params.delete(OBSERVE_STORAGE_KEY);\n const query = params.toString();\n window.history.replaceState(\n {},\n '',\n `${path}${query ? `?${query}` : ''}${hash}`,\n );\n } catch {\n // A page that forbids history writes still attaches; the param stays.\n }\n}\n\n/**\n * The page's Observe credential slot, for a web `observe` config:\n * `startFlow({ observe: { url, binding, slot: pageObserveSlot() } })`.\n *\n * The credential arrives out-of-band as the `elbObserve` URL param, or in\n * the `localStorage` slot the preview activator ferries it into. A URL\n * credential wins over a stored one. Once kept, a URL-borne copy is\n * stripped from the address bar: it is a bearer credential and must not\n * linger there. Every page access is guarded, so no method throws.\n */\nexport function pageObserveSlot(): ObserveSlot {\n return {\n read() {\n const param = readObserveParam();\n const raw = param ?? readObserveSlot();\n // Truly absent (or empty) is null: the web arm does zero work.\n if (!raw) return null;\n return { raw, fromUrl: param !== null };\n },\n keep(raw, fromUrl) {\n writeObserveSlot(raw);\n if (fromUrl) stripObserveParam();\n },\n clear(raw) {\n clearObserveSlotIf(raw);\n },\n };\n}\n","import type {\n ActivationGrant,\n PreviewCrypto,\n PreviewKey,\n} from '@walkeros/core';\nimport { OBSERVE_STORAGE_KEY, verifyActivation } from '@walkeros/core';\nimport { injectScript } from './injectScript';\n\nexport interface SwapActivatorConfig {\n keyring: PreviewKey[];\n iss: string;\n /** This bundle's project binding. Absent on demo hosts (see acceptForeign). */\n pb?: string;\n acceptForeign?: boolean;\n demoAllowlist?: string[];\n /** Bare CDN hostname, e.g. 'cdn.walkeros.io'. */\n previewOrigin: string;\n /** Injectable for tests. */\n now?: () => number;\n crypto?: PreviewCrypto;\n}\n\nconst STORAGE_KEY = 'elbPreview';\n/**\n * Storage slot for the session-forwarding companion grant. The web arm never\n * verifies it (it is session-bound by design; the session container is its\n * verifier): the activator only ferries it from the activation URL into\n * storage, where the seamed preview artifact reads it to stamp the\n * `X-Walkeros-Preview` header. It lives and dies with the activation state:\n * set (or cleared) whenever a URL activation succeeds, cleared whenever the\n * stored activation clears.\n */\nexport const SESSION_STORAGE_KEY = 'elbPreviewSession';\nconst LOG = '[walkerOS:preview]';\nconst SWAP_TIMEOUT_MS = 5000;\n\ninterface PreviewStore {\n get(): string | null;\n set(value: string): void;\n clear(): void;\n}\n\n/** localStorage under `key`, with an in-memory fallback for Safari private mode. */\nfunction createStore(key: string): PreviewStore {\n let memory: string | null = null;\n return {\n get() {\n try {\n return window.localStorage.getItem(key) ?? memory;\n } catch {\n return memory;\n }\n },\n set(value) {\n try {\n window.localStorage.setItem(key, value);\n } catch {\n memory = value;\n }\n },\n clear() {\n memory = null;\n try {\n window.localStorage.removeItem(key);\n } catch {\n // in-memory copy already cleared\n }\n },\n };\n}\n\nfunction stripParam(): void {\n if (typeof URLSearchParams === 'undefined') return;\n try {\n const href = window.location.href;\n const hashIdx = href.indexOf('#');\n const hash = hashIdx >= 0 ? href.slice(hashIdx) : '';\n const withoutHash = hashIdx >= 0 ? href.slice(0, hashIdx) : href;\n const qIdx = withoutHash.indexOf('?');\n const path = qIdx >= 0 ? withoutHash.slice(0, qIdx) : withoutHash;\n const params = new URLSearchParams(\n qIdx >= 0 ? withoutHash.slice(qIdx + 1) : '',\n );\n params.delete('elbPreview');\n params.delete('elbPreviewSession');\n params.delete('elbObserve');\n const query = params.toString();\n window.history.replaceState(\n {},\n '',\n `${path}${query ? `?${query}` : ''}${hash}`,\n );\n } catch {\n // A page that forbids history writes still previews; the param just stays.\n }\n}\n\n/**\n * Decide whether a preview bundle should boot in place of this bundle's own flow.\n *\n * Returns true iff a preview took over, in which case the caller must not boot\n * the production flow. Every failure path deterministically returns false: the\n * loader never throws, never retries, and never leaves a page without a walker.\n *\n * Anti-griefing invariant: a rejected URL grant never touches stored state,\n * the activator falls back to the stored grant instead. Only a failing stored\n * grant clears storage (self-heal), plus `off` and `swap-failed`.\n */\nexport async function browserSwapActivator(\n cfg: SwapActivatorConfig,\n): Promise<boolean> {\n if (typeof window === 'undefined' || typeof document === 'undefined')\n return false;\n const win = window;\n\n const store = createStore(STORAGE_KEY);\n const sessionStore = createStore(SESSION_STORAGE_KEY);\n const observeStore = createStore(OBSERVE_STORAGE_KEY);\n const now = cfg.now ?? (() => Date.now());\n const warn = (reason: string) => console.warn(`${LOG} ${reason}`);\n\n let param: string | null = null;\n let companion: string | null = null;\n let observeCompanion: string | null = null;\n if (typeof URLSearchParams !== 'undefined') {\n try {\n const search = new URLSearchParams(\n win.location.search.replace(/^\\?/, ''),\n );\n const values = search.getAll('elbPreview');\n param = values.length > 0 ? (values[values.length - 1] ?? null) : null;\n const companions = search.getAll('elbPreviewSession');\n companion =\n companions.length > 0\n ? (companions[companions.length - 1] ?? null)\n : null;\n const observes = search.getAll('elbObserve');\n observeCompanion =\n observes.length > 0 ? (observes[observes.length - 1] ?? null) : null;\n } catch {\n param = null;\n companion = null;\n observeCompanion = null;\n }\n }\n\n if (param === 'off') {\n store.clear();\n sessionStore.clear();\n observeStore.clear();\n stripParam();\n return false;\n }\n\n const stored = store.get();\n\n // Zero-work fast path: the overwhelmingly common case on a production page.\n // No crypto, no storage writes, no DOM work.\n if (!param && !stored) return false;\n\n const verify = (raw: string, source: 'url' | 'storage') =>\n verifyActivation(raw, {\n keyring: cfg.keyring,\n iss: cfg.iss,\n origin: win.location.origin,\n pb: cfg.pb,\n acceptForeign: cfg.acceptForeign,\n demoAllowlist: cfg.demoAllowlist,\n source,\n now: now(),\n crypto: cfg.crypto,\n });\n\n let grant: ActivationGrant | null = null;\n\n // 1) URL grant first. Rejection for any reason (malformed, unsigned, bad\n // signature, expired, wrong aud) is warned and ignored, and must never\n // clear stored state: verification runs cheap checks before crypto, so\n // at rejection time we cannot know whether the value was even one of\n // ours, and a crafted link must not end someone's active session.\n if (param) {\n const result = await verify(param, 'url');\n if (result.ok) {\n grant = result.grant;\n store.set(param);\n // The URL activation defines the session context: carry its companion\n // forwarding grant into storage, or clear a stale one from an earlier\n // session. Never verified here: the session container is its verifier.\n if (companion) sessionStore.set(companion);\n else sessionStore.clear();\n // Same rule for the observe ingest credential: ferried raw, never\n // verified here (the observer is its verifier).\n if (observeCompanion) observeStore.set(observeCompanion);\n else observeStore.clear();\n } else {\n warn(result.reason);\n }\n stripParam();\n }\n\n // 2) Fall back to the stored grant. This one clears on failure: it came\n // from our own storage, so clearing is self-healing, not griefable.\n // (Except `no-subtle`: that is the environment's fault, not the grant's.)\n if (!grant && stored) {\n const result = await verify(stored, 'storage');\n if (result.ok) {\n grant = result.grant;\n } else {\n warn(result.reason);\n if (result.reason !== 'no-subtle') {\n store.clear();\n sessionStore.clear();\n observeStore.clear();\n }\n }\n }\n\n if (!grant) return false;\n\n const src = `https://${cfg.previewOrigin}/preview/${grant.art}.js`;\n const loaded = await injectScript(src, grant.sri, SWAP_TIMEOUT_MS);\n\n if (!loaded) {\n warn('swap-failed');\n store.clear();\n sessionStore.clear();\n observeStore.clear();\n return false;\n }\n\n console.info(\n `${LOG} active ${grant.art} ends ${new Date(grant.sxp * 1000).toISOString()}`,\n );\n return true;\n}\n","import type { SendDataValue, SendHeaders, SendResponse } from '@walkeros/core';\nimport {\n getHeaders,\n networkErrorMessage,\n StepError,\n transformData,\n tryCatch,\n} from '@walkeros/core';\n\nexport type SendWebTransport = 'fetch' | 'beacon' | 'xhr';\n\nexport interface SendWebOptions {\n headers?: SendHeaders;\n transport?: SendWebTransport;\n method?: string;\n}\n\nexport interface SendWebOptionsFetch extends SendWebOptions {\n credentials?: 'omit' | 'same-origin' | 'include'; // Add credentials option\n noCors?: boolean; // Add noCors option for fetch transport\n timeout?: number; // Abort the request after this many ms (default 10000)\n}\n\nconst DEFAULT_FETCH_TIMEOUT = 10000;\n\n/** Keepalive and beacon bodies a browser accepts in flight per page. */\nconst KEEPALIVE_LIMIT = 64 * 1024;\n\n/** Bytes of the keepalive fetches in flight on this page. */\nlet keepaliveBytes = 0;\n\ntype SendWebOptionsDynamic<T extends SendWebTransport> = T extends 'fetch'\n ? SendWebOptionsFetch\n : SendWebOptions;\n\nexport type SendWebReturn<T extends SendWebTransport> = T extends 'fetch'\n ? Promise<SendResponse>\n : SendResponse;\n\n/**\n * Send a request with `fetch` (default), `navigator.sendBeacon` or a\n * synchronous XHR. Resolves (fetch) or returns (beacon, xhr) `{ data }` when\n * the request was sent, and throws a `StepError` otherwise: `transport` with\n * `status` and `body` for a non-2xx answer or a network error, `timeout` for\n * a fetch past its timeout, `beacon-rejected` when the browser refuses a\n * beacon. The body stays on the error, never in its message.\n */\nexport function sendWeb<T extends SendWebTransport>(\n url: string,\n data?: SendDataValue,\n options: SendWebOptionsDynamic<T> & { transport?: T } = {\n transport: 'fetch' as T,\n },\n): SendWebReturn<T> {\n const transport = options.transport || 'fetch';\n\n switch (transport) {\n case 'beacon':\n return sendWebAsBeacon(url, data) as SendWebReturn<T>;\n case 'xhr':\n return sendWebAsXhr(url, data, options) as SendWebReturn<T>;\n case 'fetch':\n default:\n return sendWebAsFetch(url, data, options) as SendWebReturn<T>;\n }\n}\n\nexport async function sendWebAsFetch(\n url: string,\n data?: SendDataValue,\n options: SendWebOptionsFetch = {},\n): Promise<SendResponse> {\n const headers = getHeaders(options.headers);\n const body = transformData(data);\n const requested = options.timeout;\n const timeout =\n typeof requested === 'number' && Number.isFinite(requested) && requested > 0\n ? requested\n : DEFAULT_FETCH_TIMEOUT;\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), timeout);\n\n // Browsers refuse a keepalive request once the keepalive bodies in flight\n // exceed 64 KiB; past that a request goes out without keepalive instead.\n const size = body ? byteLength(body) : 0;\n const keepalive = keepaliveBytes + size <= KEEPALIVE_LIMIT;\n if (keepalive) keepaliveBytes += size;\n\n try {\n let response: Response;\n try {\n response = await fetch(url, {\n method: options.method || 'POST',\n headers,\n keepalive,\n credentials: options.credentials || 'same-origin',\n mode: options.noCors ? 'no-cors' : 'cors',\n body,\n signal: controller.signal,\n });\n } catch (error) {\n if (controller.signal.aborted)\n throw new StepError(`Request timed out after ${timeout}ms`, {\n code: 'timeout',\n cause: error,\n });\n throw new StepError(networkErrorMessage(error), {\n code: 'transport',\n cause: error,\n });\n }\n\n // A no-cors response is opaque: it counts as sent once it arrived.\n if (options.noCors) return { data: '' };\n\n const responseData = await response.text();\n if (!response.ok)\n throw new StepError(`HTTP ${response.status}`, {\n code: 'transport',\n status: response.status,\n body: responseData,\n });\n\n return { data: responseData };\n } finally {\n clearTimeout(timeoutId);\n if (keepalive) keepaliveBytes -= size;\n }\n}\n\nexport function sendWebAsBeacon(\n url: string,\n data?: SendDataValue,\n): SendResponse {\n const body = transformData(data);\n\n if (!navigator.sendBeacon(url, body)) {\n // Over the browser's 64 KiB quota a retry cannot help; a full queue can.\n const size = body ? byteLength(body) : 0;\n throw new StepError('Beacon rejected by the browser', {\n code: 'beacon-rejected',\n retryable: size <= KEEPALIVE_LIMIT,\n });\n }\n\n return {};\n}\n\nexport function sendWebAsXhr(\n url: string,\n data?: SendDataValue,\n options: SendWebOptions = {},\n): SendResponse {\n const headers = getHeaders(options.headers);\n const method = options.method || 'POST';\n const body = transformData(data);\n\n let xhr: XMLHttpRequest;\n try {\n xhr = new XMLHttpRequest();\n xhr.open(method, url, false); // Synchronous request\n for (const header in headers) {\n xhr.setRequestHeader(header, headers[header]);\n }\n xhr.send(body);\n } catch (error) {\n throw new StepError(networkErrorMessage(error), {\n code: 'transport',\n cause: error,\n });\n }\n\n const parsedData: unknown = tryCatch(\n JSON.parse,\n () => xhr.response,\n )(xhr.response);\n\n if (xhr.status < 200 || xhr.status >= 300)\n throw new StepError(`HTTP ${xhr.status}`, {\n code: 'transport',\n status: xhr.status || undefined,\n body: parsedData,\n });\n\n return { data: parsedData };\n}\n\n/** UTF-8 length of a request body, without TextEncoder. */\nfunction byteLength(text: string): number {\n let bytes = 0;\n for (let i = 0; i < text.length; i++) {\n const code = text.charCodeAt(i);\n if (code < 0x80) bytes += 1;\n else if (code < 0x800) bytes += 2;\n else if (code >= 0xd800 && code <= 0xdbff) {\n bytes += 4;\n i++; // The low surrogate belongs to this character.\n } else bytes += 3;\n }\n return bytes;\n}\n","import type { WalkerOS } from '@walkeros/core';\nimport type { StorageType } from '@walkeros/core';\nimport { castValue, Const } from '@walkeros/core';\n\nexport interface StorageValue {\n e: number; // Expiration timestamp\n v: string; // Value\n}\n\nexport interface StorageEnv {\n window?: Window & typeof globalThis;\n document?: Document;\n}\n\nexport function storageDelete(\n key: string,\n storage: StorageType = Const.Utils.Storage.Session,\n domain?: string,\n env?: StorageEnv,\n) {\n try {\n switch (storage) {\n case Const.Utils.Storage.Cookie:\n storageWrite(key, '', 0, storage, domain, env);\n break;\n case Const.Utils.Storage.Local:\n (env?.window ?? window).localStorage.removeItem(key);\n break;\n case Const.Utils.Storage.Session:\n (env?.window ?? window).sessionStorage.removeItem(key);\n break;\n }\n } catch (err) {\n // Storage may be disabled (SecurityError in private browsing, sandboxed\n // iframes, or restrictive browser settings). Silently ignore.\n }\n}\n\nexport function storageRead(\n key: string,\n storage: StorageType = Const.Utils.Storage.Session,\n env?: StorageEnv,\n): WalkerOS.PropertyType {\n // Helper function for local and session storage to support expiration\n function parseItem(string: string | null): StorageValue {\n try {\n return JSON.parse(string || '');\n } catch (err) {\n let e = 1,\n v = '';\n\n // Remove expiration date\n if (string) {\n e = 0;\n v = string;\n }\n\n return { e, v };\n }\n }\n let value, item;\n\n try {\n switch (storage) {\n case Const.Utils.Storage.Cookie:\n value = decodeURIComponent(\n (env?.document ?? document).cookie\n .split('; ')\n .find((row) => row.startsWith(key + '='))\n ?.split('=')[1] || '',\n );\n break;\n case Const.Utils.Storage.Local:\n item = parseItem((env?.window ?? window).localStorage.getItem(key));\n break;\n case Const.Utils.Storage.Session:\n item = parseItem((env?.window ?? window).sessionStorage.getItem(key));\n break;\n }\n } catch (err) {\n // Storage may be disabled or inaccessible. Return empty string.\n return castValue('');\n }\n\n // Check if item is expired\n if (item) {\n value = item.v;\n\n if (item.e != 0 && item.e < Date.now()) {\n storageDelete(key, storage, undefined, env);\n value = ''; // Conceal the outdated value\n }\n }\n\n return castValue(value || '');\n}\n\nexport function storageWrite(\n key: string,\n value: WalkerOS.PropertyType,\n maxAgeInMinutes = 30,\n storage: StorageType = Const.Utils.Storage.Session,\n domain?: string,\n env?: StorageEnv,\n): WalkerOS.PropertyType {\n const e = Date.now() + 1000 * 60 * maxAgeInMinutes;\n const item: StorageValue = { e, v: String(value) };\n const stringifiedItem = JSON.stringify(item);\n\n try {\n switch (storage) {\n case Const.Utils.Storage.Cookie: {\n value = typeof value === 'object' ? JSON.stringify(value) : value;\n let cookie = `${key}=${encodeURIComponent(value)}; max-age=${\n maxAgeInMinutes * 60\n }; path=/; SameSite=Lax; secure`;\n\n if (domain) cookie += '; domain=' + domain;\n\n (env?.document ?? document).cookie = cookie;\n break;\n }\n case Const.Utils.Storage.Local:\n (env?.window ?? window).localStorage.setItem(key, stringifiedItem);\n break;\n case Const.Utils.Storage.Session:\n (env?.window ?? window).sessionStorage.setItem(key, stringifiedItem);\n break;\n }\n } catch (err) {\n // Storage may be disabled (SecurityError) or full (QuotaExceededError).\n // Return empty string to signal the write did not persist.\n return castValue('');\n }\n\n return storageRead(key, storage, env);\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { Destination as WalkerOSDestination } from '@walkeros/core';\n\nexport type TypesGeneric = WalkerOSDestination.TypesGeneric;\n\nexport interface Destination<T extends TypesGeneric = WalkerOSDestination.Types>\n extends WalkerOSDestination.Instance<T> {}\n\nexport type Init = WalkerOSDestination.Init;\n\nexport type Config<T extends TypesGeneric = WalkerOSDestination.Types> =\n WalkerOSDestination.Config<T>;\n\nexport type PartialConfig<T extends TypesGeneric = WalkerOSDestination.Types> =\n WalkerOSDestination.PartialConfig<T>;\n\nexport type InitFn<T extends TypesGeneric = WalkerOSDestination.Types> =\n WalkerOSDestination.InitFn<T>;\n\nexport type PushFn<T extends TypesGeneric = WalkerOSDestination.Types> =\n WalkerOSDestination.PushFn<T>;\n\nexport type PushEvent<Mapping = unknown> =\n WalkerOSDestination.PushEvent<Mapping>;\n\nexport type PushEvents<Mapping = unknown> =\n WalkerOSDestination.PushEvents<Mapping>;\n\n/**\n * Web-specific environment requirements interface\n *\n * Extends the core Env interface with web-specific\n * globals like window and document for browser destinations.\n */\nexport interface Env extends WalkerOSDestination.BaseEnv {\n /**\n * Properties to be added to the global `window` object\n *\n * Used by web destinations that expect browser-specific\n * global functions like analytics APIs.\n *\n * @example\n * ```typescript\n * window: {\n * gtag: () => {},\n * fbq: () => {},\n * dataLayer: []\n * }\n * ```\n */\n window?: Record<string, unknown>;\n\n /**\n * Properties to be added to the global `document` object\n *\n * Used by destinations that need DOM manipulation capabilities\n * for script loading or element creation.\n *\n * @example\n * ```typescript\n * document: {\n * createElement: () => ({ src: '', async: false }),\n * head: { appendChild: () => {} }\n * }\n * ```\n */\n document?: Record<string, unknown>;\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { Collector, WalkerOS, Source as CoreSource } from '@walkeros/core';\n\nexport type TypesGeneric = CoreSource.TypesGeneric;\n\nexport interface Source<T extends TypesGeneric = CoreSource.Types>\n extends CoreSource.Instance<T> {\n settings?: CoreSource.Settings<T>;\n mapping?: CoreSource.Mapping<T>;\n}\n\nexport type Init = Partial<Omit<Source, 'init'>> & Pick<Source, 'type'>;\n\nexport type Config<T extends TypesGeneric = CoreSource.Types> =\n CoreSource.Instance<T> & {\n settings: CoreSource.Settings<T>;\n mapping?: CoreSource.Mapping<T>;\n };\n\nexport type PartialConfig<T extends TypesGeneric = CoreSource.Types> = Partial<\n Config<T>\n>;\n\nexport type InitFn<T extends TypesGeneric = CoreSource.Types> = (\n collector: Collector.Instance,\n config: Config<T>,\n) => void | Promise<void>;\n","import type { Elb } from '@walkeros/core';\n\n// Simple re-exports from core\nexport type PushResult = Elb.PushResult;\nexport type Layer = Elb.Layer;\n","import type {\n Collector as CoreCollector,\n Elb,\n Hooks,\n WalkerOS,\n Destination as WalkerOSDestination,\n On,\n} from '@walkeros/core';\nimport type { Destination, Config as DestConfig } from './destination';\nimport type { Layer } from './elb';\nimport type { Events, Trigger } from './walker';\n\ndeclare global {\n interface Window {\n elbwalker: Collector;\n walkerjs: CoreCollector.Instance;\n elbLayer?: Layer;\n dataLayer: WalkerOS.Events | unknown | unknown[];\n elb: Elb.Fn<Promise<Elb.PushResult>>;\n }\n}\n\nexport interface Collector extends Omit<CoreCollector.Instance, 'config'> {\n config: Config & CoreCollector.Config;\n destinations: Destinations;\n push: Elb.Fn<Promise<Elb.PushResult>>;\n getAllEvents: (scope: Element, prefix: string) => Events;\n getEvents: (target: Element, trigger: Trigger, prefix: string) => Events;\n getGlobals: () => WalkerOS.Properties;\n _visibilityState?: {\n observer: IntersectionObserver | undefined;\n timers: WeakMap<HTMLElement, number>;\n duration: number;\n elementConfigs?: WeakMap<\n HTMLElement,\n { multiple: boolean; blocked: boolean }\n >;\n };\n}\n\nexport interface State {\n config: Config;\n destinations: Destinations;\n}\n\nexport interface Config {\n dataLayer: boolean;\n dataLayerConfig: DestConfig;\n elbLayer: Layer;\n listeners: boolean;\n pageview: boolean;\n prefix: string;\n run: boolean;\n scope: Scope;\n elb?: string;\n name?: string;\n}\n\nexport interface InitConfig extends Partial<Config> {\n consent?: WalkerOS.Consent;\n custom?: WalkerOS.Properties;\n destinations?: WalkerOSDestination.InitDestinations;\n hooks?: Hooks.Functions;\n on?: On.OnConfig;\n user?: WalkerOS.User;\n}\n\nexport interface Destinations {\n [name: string]: Destination;\n}\n\nexport type Scope = Element | Document;\n","import type { WalkerOS } from '@walkeros/core';\n\nexport type Events = Event[];\n\nexport interface Event {\n entity: string;\n action: string;\n data?: WalkerOS.Properties;\n context?: WalkerOS.OrderedProperties;\n trigger?: Trigger;\n nested: WalkerOS.Entities;\n}\n\nexport type KeyVal = [string, string];\n\nexport type Attributes = Array<string>;\n\nexport type Trigger =\n | 'click'\n | 'custom'\n | 'hover'\n | 'load'\n | 'pulse'\n | 'scroll'\n | 'submit'\n | 'visible'\n | 'visibles'\n | 'wait'\n | string;\n\nexport interface Filter {\n [name: string]: boolean;\n}\n\nexport interface TriggersActionGroups {\n [trigger: string]: TriggerActions;\n}\n\nexport type TriggerActions = Array<TriggerAction>;\n\ninterface TriggerAction {\n trigger: string;\n triggerParams?: string;\n action: string;\n actionParams?: string;\n}\n\nexport type ScrollElements = Array<[HTMLElement, number]>;\n"],"mappings":";AAMO,SAAS,aAAa,SAAkB,MAAsB;AACnE,UAAQ,QAAQ,aAAa,IAAI,KAAK,IAAI,KAAK;AACjD;AAWO,SAAS,eAAe,KAAa,YAAY,KAAe;AACrE,MAAI,CAAC,IAAK,QAAO,CAAC;AAKlB,QAAM,MAAM,IAAI;AAAA,IACd,2EAA2E,SAAS;AAAA,IACpF;AAAA,EACF;AACA,SAAO,IAAI,MAAM,GAAG,KAAK,CAAC;AAC5B;AASO,SAAS,YAAY,KAA+B;AACzD,QAAM,CAAC,EAAE,MAAM,KAAK,QAAQ,EAAE,IAC5B,IAAI,MAAM,oCAAoC,KAAK,CAAC;AACtD,SAAO,CAAC,QAAQ,GAAG,GAAG,QAAQ,KAAK,CAAC;AACtC;AAGA,SAAS,QAAQ,KAAqB;AACpC,SAAO,IACJ,QAAQ,2BAA2B,CAAC,GAAG,SAAkB,QAAQ,EAAE,EACnE,KAAK;AACV;AAQO,SAAS,kBAAkB,KAAsC;AACtE,QAAM,SAAkC,CAAC;AAEzC,iBAAe,GAAG,EAAE,QAAQ,CAAC,SAAS;AACpC,UAAM,CAAC,KAAK,KAAK,IAAI,YAAY,IAAI;AACrC,QAAI,KAAK;AAEP,UAAI,UAAU,QAAQ;AACpB,eAAO,GAAG,IAAI;AAAA,MAChB,WAAW,UAAU,SAAS;AAC5B,eAAO,GAAG,IAAI;AAAA,MAChB,WAAW,SAAS,QAAQ,KAAK,KAAK,GAAG;AACvC,eAAO,GAAG,I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|
{
|
|
2
2
|
"name": "@walkeros/web-core",
|
|
3
3
|
"description": "Web-specific utilities for walkerOS",
|
|
4
|
-
"version": "4.8.
|
|
4
|
+
"version": "4.8.2",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"module": "./dist/index.mjs",
|
|
@@ -11,6 +11,11 @@
|
|
|
11
11
|
"types": "./dist/index.d.ts",
|
|
12
12
|
"import": "./dist/index.mjs",
|
|
13
13
|
"require": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./dev": {
|
|
16
|
+
"types": "./dist/dev.d.ts",
|
|
17
|
+
"import": "./dist/dev.mjs",
|
|
18
|
+
"require": "./dist/dev.js"
|
|
14
19
|
}
|
|
15
20
|
},
|
|
16
21
|
"files": [
|
|
@@ -27,7 +32,8 @@
|
|
|
27
32
|
"update": "npx npm-check-updates -u && npm update"
|
|
28
33
|
},
|
|
29
34
|
"devDependencies": {
|
|
30
|
-
"@walkeros/
|
|
35
|
+
"@walkeros/collector": "4.8.2",
|
|
36
|
+
"@walkeros/core": "4.8.2"
|
|
31
37
|
},
|
|
32
38
|
"repository": {
|
|
33
39
|
"url": "git+https://github.com/elbwalker/walkerOS.git",
|
|
@@ -51,6 +57,6 @@
|
|
|
51
57
|
}
|
|
52
58
|
],
|
|
53
59
|
"dependencies": {
|
|
54
|
-
"@walkeros/core": "4.8.
|
|
60
|
+
"@walkeros/core": "4.8.2"
|
|
55
61
|
}
|
|
56
62
|
}
|