@techinject/browser 0.0.0-stage → 0.1.0-alpha.1
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/LICENSE +21 -0
- package/README.md +10 -2
- package/dist/cdn/LICENSES.txt +45 -0
- package/dist/cdn/signalkit.mjs +1 -0
- package/dist/dashboard.d.ts +8 -0
- package/dist/dashboard.d.ts.map +1 -0
- package/dist/dashboard.js +60 -0
- package/dist/dashboard.js.map +1 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +269 -0
- package/dist/index.js.map +1 -0
- package/dist/providers.d.ts +19 -0
- package/dist/providers.d.ts.map +1 -0
- package/dist/providers.js +224 -0
- package/dist/providers.js.map +1 -0
- package/package.json +38 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 SignalKit contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @techinject/browser
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
SignalKit browser adapter/package. MIT licensed, alpha candidate; unpublished.
|
|
4
|
+
|
|
5
|
+
Optional in-app connection status UI: import `mountConnectionsDashboard` from
|
|
6
|
+
`@techinject/browser/dashboard`, then call it with an existing DOM element and SDK
|
|
7
|
+
instance. The returned function unsubscribes and removes the view. No provider probes,
|
|
8
|
+
payloads, credentials, storage or polling. See the repository's
|
|
9
|
+
[dashboard guide](https://github.com/TechInjectIndia/signal-kit/blob/main/docs/CONNECTIONS-DASHBOARD.md).
|
|
10
|
+
|
|
11
|
+
See https://github.com/TechInjectIndia/signal-kit/tree/main/packages/features/signals/INTEGRATION.md for wiring, consent behavior and verification limits.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 SignalKit contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
Bundled Zod:
|
|
25
|
+
MIT License
|
|
26
|
+
|
|
27
|
+
Copyright (c) 2025 Colin McDonnell
|
|
28
|
+
|
|
29
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
30
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
31
|
+
in the Software without restriction, including without limitation the rights
|
|
32
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
33
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
34
|
+
furnished to do so, subject to the following conditions:
|
|
35
|
+
|
|
36
|
+
The above copyright notice and this permission notice shall be included in all
|
|
37
|
+
copies or substantial portions of the Software.
|
|
38
|
+
|
|
39
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
40
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
41
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
42
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
43
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
44
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
45
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function Le(e,t){return typeof t=="bigint"?t.toString():t}var me=class{constructor(t){this._getter=t,this._value=void 0}get value(){let t=this._getter;return t!==void 0&&(this._value=t(),this._getter=void 0),this._value}};function je(e){return new me(e)}function Ne(e){return e==null}function Ue(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function ne(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Fe(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function he(e){return Fe(e._zod.def)??e._zod.def.shape}function Be(e,t,r){Object.defineProperty(e,t,{get(){let n=r();return ne(this,t,n),n},enumerable:!0,configurable:!0})}function Ke(e,t,r){t in e?ne(e,t,r):e[t]=r}function jt(e,t,r,n){let o=he(t);for(let i of r){let c=Object.getOwnPropertyDescriptor(o,i);c.enumerable&&(c.get?Be(e,i,()=>{let s=t._zod.def.shape[i];return n?n(s,i):s}):Ke(e,i,n?n(c.value,i):c.value))}}function Nt(e,t){for(let r of Reflect.ownKeys(t)){let n=Object.getOwnPropertyDescriptor(t,r);n.enumerable&&(n.get?Be(e,r,()=>t[r]):Ke(e,r,n.value))}}function Ve(...e){let t={};for(let r of e){let n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}var _e="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function re(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function We(e){if(re(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(re(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function q(e,t,r){let n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function k(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function Ge(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var qe={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Xe(e,t){if(!We(t))throw new Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let o=he(e);for(let i of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(o,i)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return q(e,Ve(e._zod.def,{shape:Ut(e,t)}))}function Ut(e,t){let r={};return jt(r,e,Reflect.ownKeys(he(e))),Nt(r,t),r}function L(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function He(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function oe(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function G(e){return typeof e=="string"?e:e?.message}function ge(e,t,r){var n;for(let o=t;o<e.length;o++)(n=e[o]).schema??(n.schema=r)}function F(e,t,r){var n;let o=e.inst?._zod?.traits;o?.has("$ZodType")&&(o.has("$ZodCheck")?(n=e).schema??(n.schema=e.inst):e.schema=e.inst);let i=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,c=e.message?e.message:G(e.inst?._zod.def?.error?.(e))??G(i?.(e))??G(t?.error?.(e))??G(r.customError?.(e))??G(r.localeError?.(e))??"Invalid input",s={};for(let u of Object.keys(e))u==="inst"||u==="schema"||u==="continue"||u==="input"||u==="__proto__"||(s[u]=e[u]);return s.path??(s.path=[]),s.message=c,t?.reportInput&&(s.input=e.input),s}var Ft=/[\uD800-\uDBFF]/;function xe(e){let t=e.length;if(!Ft.test(e))return t;let r=t;for(let n=0;n<t-1;n++)(e.charCodeAt(n)&64512)===55296&&(e.charCodeAt(n+1)&64512)===56320&&(r--,n++);return r}function ve(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Je(e,t){for(let r in t){let n=Object.getOwnPropertyDescriptor(t,r);n.get?Object.defineProperty(e,r,{...n,enumerable:!1}):Bt(e,r,n.value)}}function j(e,t,r,n=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:n,value:r}),r}function $e(e,t,r){return j(e,t,r,!1)}function Bt(e,t,r){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?r:j(this,t,r.bind(this))},set(n){j(this,t,n)}})}function Kt(e,t){let r=Object.getPrototypeOf(e);return t in r?void 0:r}var de,D=!1,Vt={configurable:!0,get(){D=!0}};function X(e,t,r){let n=Object.getPrototypeOf(e._zod);if(t in n&&de!==e._zod){de=void 0;return}de=e._zod,Object.defineProperty(n,t,{configurable:!0,get(){Object.defineProperty(this,t,Vt);let o=D;D=!1;try{let i=r(this);return D?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:i}),D=D||o,i}catch(i){throw delete this[t],D=D||o,i}},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o})}})}function Ye(e,t,r,n){let o=Kt(e,t);o&&Object.defineProperty(o,t,{configurable:!0,get(){let i={configurable:!0,writable:!0,enumerable:n,value:void 0};return Object.defineProperty(this,t,i),i.value=r(this),Object.defineProperty(this,t,i),i.value},set(i){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:n,value:i})}})}var Qe;var be={value:void 0,enumerable:!1},et="captureStackTrace"in Error?Error:null;function Wt(e){let t=et;if(t){let r=t.stackTraceLimit;if(typeof r=="number"){try{t.stackTraceLimit=0}catch{return et=null,new e}try{return new e}finally{t.stackTraceLimit=r}}}return new e}function b(e,t,r,n){let o={};function i(d){this.def=d,this.constr=h,this.traits=new Set}i.prototype=o;let c=r,s=c&&new WeakSet;function u(d,_){if(d._zod){if(d._zod.traits.has(e))return}else{be.value=new i(_);try{Object.defineProperty(d,"_zod",be)}finally{be.value=void 0}}if(d._zod.traits.add(e),t(d,_),s){let v=Object.getPrototypeOf(d),p=d._zod.constr.prototype,x=v;for(;x&&x!==p;)x=Object.getPrototypeOf(x);let f=x??v;s.has(f)||(s.add(f),Je(f,c))}let g=h.prototype;for(let v in g)Object.prototype.hasOwnProperty.call(g,v)&&(v in d||(d[v]=g[v].bind(d)))}let l=n?.Parent??Object;class a extends l{}Object.defineProperty(a,"name",{value:e});function h(d){let _=n?.Parent?Wt(a):this;u(_,d);let g=_._zod.deferred;if(g){for(let p of g)p();_._zod.deferred=void 0}let v=globalThis.__zod_globalConfig?.postProcessor;return v&&v(_),_}return Object.defineProperty(h,"init",{value:u}),Object.defineProperty(h,Symbol.hasInstance,{value:d=>n?.Parent&&d instanceof n.Parent?!0:d?._zod?.traits?.has(e)}),Object.defineProperty(h,"name",{value:e}),h}var M=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};(Qe=globalThis).__zod_globalConfig??(Qe.__zod_globalConfig={});var H=globalThis.__zod_globalConfig;function B(e){return e&&Object.assign(H,e),H}function Gt(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,Le,2)),e.message}function qt(e){this._zod.message=e}var Xt={get:Gt,set:qt,enumerable:!0,configurable:!0},ze={value:void 0,enumerable:!1},tt=new WeakSet([Object.prototype,Error.prototype]),rt=(e,t)=>{e.name="$ZodError",ze.value=t,Object.defineProperty(e,"issues",ze),ze.value=void 0,Object.defineProperty(e,"message",Xt);let r=Object.getPrototypeOf(e);tt.has(r)||(tt.add(r),Object.defineProperty(r,"toString",{configurable:!0,enumerable:!1,get(){let n=()=>this.message;return Object.defineProperty(this,"toString",{value:n,configurable:!0,writable:!0}),n},set(n){Object.defineProperty(this,"toString",{value:n,configurable:!0,writable:!0})}}))},wr=b("$ZodError",rt),J=b("$ZodError",rt,void 0,{Parent:Error});var Jt=e=>{let t=(r,n,o,i)=>{let c=o?{...o,async:!1}:{async:!1},s=r._zod.run({value:n,issues:[]},c);if(s instanceof Promise)throw new M;if(s.issues.length){let u=new(i?.Err??e)(s.issues.map(l=>F(l,c,B())));throw _e(u,i?.callee??t),u}return s.value};return t},we=Jt(J),Yt=e=>{let t=async(r,n,o,i)=>{let c=o?{...o,async:!0}:{async:!0},s=r._zod.run({value:n,issues:[]},c);if(s instanceof Promise&&(s=await s),s.issues.length){let u=new(i?.Err??e)(s.issues.map(l=>F(l,c,B())));throw _e(u,i?.callee??t),u}return s.value};return t},Ze=Yt(J),Qt=e=>(t,r,n)=>{let o=n?{...n,async:!1}:{async:!1},i=t._zod.run({value:r,issues:[]},o);if(i instanceof Promise)throw new M;return i.issues.length?nt(e,i.issues,o):{success:!0,data:i.value}},Pe=Qt(J);function nt(e,t,r){let n;return{success:!1,get error(){return n||(n=new e(t.map(o=>F(o,r,B()))),t=void 0,r=void 0),n},set error(o){n=o,t=void 0,r=void 0}}}var er=e=>async(t,r,n)=>{let o=n?{...n,async:!0}:{async:!0},i=t._zod.run({value:r,issues:[]},o);return i instanceof Promise&&(i=await i),i.issues.length?nt(e,i.issues,o):{success:!0,data:i.value}},ke=er(J);var ot=/^[\s\S]{0,}$/;var it=/^-?\d+(?:\.\d+)?$/;var O=b("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])});var ct=e=>{let t=e.value;return!Ne(t)&&t.length!==void 0},ie={number:"number",bigint:"bigint",object:"date"},ut=b("$ZodCheckLessThan",(e,t)=>{O.init(e,t);let r=ie[typeof t.value];e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:ie[typeof n.value]??r,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Ae=b("$ZodCheckGreaterThan",(e,t)=>{O.init(e,t);let r=ie[typeof t.value];e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:ie[typeof n.value]??r,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}});var at=b("$ZodCheckNumberFormat",(e,t)=>{O.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),n=r?"int":"number",[o,i]=qe[t.format];e._zod.check=c=>{let s=c.value;if(r){if(!Number.isInteger(s)){c.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?c.issues.push({input:s,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort}):c.issues.push({input:s,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort});return}}s<o&&c.issues.push({origin:"number",input:s,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),s>i&&c.issues.push({origin:"number",input:s,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}});var lt=b("$ZodCheckMaxLength",(e,t)=>{var r;O.init(e,t),(r=e._zod.def).when??(r.when=ct),e._zod.check=n=>{let o=n.value,i=o.length;if((typeof o=="string"&&i>t.maximum?xe(o):i)<=t.maximum)return;let s=ve(o);n.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),pt=b("$ZodCheckMinLength",(e,t)=>{var r;O.init(e,t),(r=e._zod.def).when??(r.when=ct),e._zod.check=n=>{let o=n.value,i=o.length;if((typeof o=="string"&&i>=t.minimum&&i<t.minimum*2?xe(o):i)>=t.minimum)return;let s=ve(o);n.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}});var ft=b("$ZodCheckStringFormat",(e,t)=>{var r,n;O.init(e,t),t.pattern?(r=e._zod).check??(r.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),dt=b("$ZodCheckRegex",(e,t)=>{ft.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}});var ht={major:4,minor:6,patch:5};var U=b("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=ht;let n=e._zod.def.checks,o=e._zod.traits.has("$ZodCheck")?[e,...n??[]]:n?.length?[...n]:[];for(let i of o)for(let c of i._zod.onattach)c(e);if(o.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let i=(s,u,l)=>{if(s.memo)return s;let a=L(s),h;for(let d of u){if(d._zod.def.when){if(He(s)||!d._zod.def.when(s))continue}else if(a)continue;let _=s.issues.length,g=d._zod.check(s);if(g instanceof Promise&&l?.async===!1)throw new M;if(h||g instanceof Promise)h=(h??Promise.resolve()).then(async()=>{await g,s.issues.length!==_&&(ge(s.issues,_,e),a||(a=L(s,_)))});else{if(s.issues.length===_)continue;ge(s.issues,_,e),a||(a=L(s,_))}}return h?h.then(()=>s):s},c=(s,u,l)=>{if(L(s))return s.aborted=!0,s;let a=i(u,o,l);if(a instanceof Promise){if(l.async===!1)throw new M;return a.then(h=>e._zod.parse(h,l))}return e._zod.parse(a,l)};e._zod.run=(s,u)=>{if(u.skipChecks)return e._zod.parse(s,u);if(u.direction==="backward"){let a=e._zod.parse({value:s.value,issues:[]},{...u,skipChecks:!0});return a instanceof Promise?a.then(h=>c(h,s,u)):c(a,s,u)}let l=e._zod.parse(s,u);if(l instanceof Promise){if(u.async===!1)throw new M;return l.then(a=>i(a,o,u))}return i(l,o,u)}}},{get"~standard"(){return $e(this,"~standard",or(this))},set"~standard"(e){j(this,"~standard",e)}}),xt=(e,t)=>e.issues.length?{issues:e.issues.map(r=>F(r,t,B()))}:{value:e.value};async function nr(e,t){let r={async:!0};return xt(await e._zod.run({value:t,issues:[]},r),r)}function or(e){return{validate:t=>{let r={async:!1};try{let n=e._zod.run({value:t,issues:[]},r);if(!(n instanceof Promise))return xt(n,r)}catch{}return nr(e,t)},vendor:"zod",version:1}}var vt=b("$ZodString",(e,t)=>{U.init(e,t),e._zod.pattern=t.pattern??ot,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}});var Ce=b("$ZodNumber",(e,t)=>{U.init(e,t),e._zod.pattern=it,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}let o=r.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return r;let i=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:String(o):void 0;return r.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...i?{received:i}:{}}),r}}),$t=b("$ZodNumberFormat",(e,t)=>{at.init(e,t),Ce.init(e,t)});function _t(e,t,r){e.issues.length&&t.issues.push(...oe(r,e.issues)),t.value[r]=e.value}var bt=b("$ZodArray",(e,t)=>{U.init(e,t);let r=H.memoizer;r?.attach(e),e._zod.parse=(n,o)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),n;n.value=r?r.alloc(e,n,Array(i.length),o):Array(i.length);let c=[],s=o?.abortEarly;for(let u=0;u<i.length;u++){let l=i[u],a=t.element._zod.run({value:l,issues:[]},o);if(a instanceof Promise)c.push(a.then(h=>_t(h,n,u)));else if(_t(a,n,u),s&&a.issues.length!==0&&L(a))break}return c.length?Promise.all(c).then(()=>n):n}});function se(e,t,r,n,o,i){let c=r in n,s=i==="optional";if(!(!c&&s&&o==="optional")){if(e.issues.length){if(o!==void 0&&s&&!c)return;t.issues.push(...oe(r,e.issues))}if(!c&&o===void 0){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}e.value===void 0?(c||o==="defaulted"&&!s)&&(t.value[r]=void 0):t.value[r]=e.value}}var ir=[];function sr(e){let t=Object.keys(e.shape),r=Object.getOwnPropertySymbols(e.shape),n=r.length?r:ir,o=n.length?[...t,...n]:t;for(let c of o)if(!e.shape?.[c]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${String(c)}": expected a Zod schema`);let i=Ge(e.shape);return{...e,allKeys:o,symbolKeys:n,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(i)}}function cr(e,t,r,n,o,i,c){let s=[],u=o.keySet,l=o.catchall._zod,a=l.def.type,h=l.optin,d=l.optout,_=0;for(let g in t){if(c&&r.issues.length!==_){if(L(r,_))break;_=r.issues.length}if(u.has(g))continue;if(g==="__proto__"){a==="never"&&s.push(g);continue}if(a==="never"){s.push(g);continue}let v=l.run({value:t[g],issues:[]},n);v instanceof Promise?e.push(v.then(p=>se(p,r,g,t,h,d))):se(v,r,g,t,h,d)}return s.length&&r.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:i,continue:!0}),e.length?Promise.all(e).then(()=>r):r}var yt=b("$ZodObject",(e,t)=>{U.init(e,t);let r=Object.getOwnPropertyDescriptor(t,"shape"),n=r?.get?r.get.raw:t.shape??{};if(n){let l=()=>{let a={...n};return Object.defineProperty(t,"shape",{value:a}),l.raw=a,a};l.raw=n,Object.defineProperty(t,"shape",{get:l})}let o=je(()=>sr(t));X(e,"propValues",l=>{let a=l.def.shape,h={};for(let d in a){let _=a[d]._zod;if(_.values){Object.prototype.hasOwnProperty.call(h,d)||ne(h,d,new Set);for(let g of _.values)h[d].add(g);_.optin!==void 0&&h[d].add(void 0)}}return h});let i=re,c=t.catchall,s,u=H.memoizer;u?.attach(e),e._zod.parse=(l,a)=>{s??(s=o.value);let h=l.value;if(!i(h))return l.issues.push({expected:"object",code:"invalid_type",input:h,inst:e}),l;l.value=u?u.alloc(e,l,{},a):{};let d=[],_=s.shape,g=a?.abortEarly,v=l.issues.length;for(let p of s.allKeys){if(g&&l.issues.length!==v){if(L(l,v))break;v=l.issues.length}if(p==="__proto__")continue;let x=_[p],f=x._zod.optin,m=x._zod.optout,y=x._zod.run({value:h[p],issues:[]},a);y instanceof Promise?d.push(y.then($=>se($,l,p,h,f,m))):se(y,l,p,h,f,m)}return c?cr(d,h,l,a,o.value,e,g===!0):d.length?Promise.all(d).then(()=>l):l}});function gt(e,t){return e.value=t.issues.length?void 0:t.value,e}var zt=b("$ZodOptional",(e,t)=>{U.init(e,t),X(e,"optin",r=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",X(e,"values",r=>{let n=r.def.innerType._zod.values;return n?new Set([...n,void 0]):void 0}),X(e,"pattern",r=>{let n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${Ue(n.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(r.value===void 0){if(t.innerType._zod.optin!=="defaulted")return r;let o=t.innerType._zod.run({value:r.value,issues:[]},n);return o instanceof Promise?o.then(i=>gt(r,i)):gt(r,o)}return t.innerType._zod.run(r,n)}});function wt(e){return e.checks&&(e.checks=[...e.checks]),e}function Zt(e,t){return new e(wt({type:"string",...k(t)}))}function Pt(e,t){return new e(wt({type:"number",checks:[],...k(t)}))}function kt(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...k(t)})}function ce(e,t){return new ut({check:"less_than",...k(t),value:e,inclusive:!0})}function At(e,t){return new Ae({check:"greater_than",...k(t),value:e,inclusive:!1})}function Ee(e,t){return new Ae({check:"greater_than",...k(t),value:e,inclusive:!0})}function Ie(e){return At(0,e)}function Se(e){return Ee(0,e)}function Y(e,t){return new lt({check:"max_length",...k(t),maximum:e})}function Q(e,t){return new pt({check:"min_length",...k(t),minimum:e})}function Me(e,t){return new dt({check:"string_format",format:"regex",...k(t),pattern:e})}var ee=b("ZodMiniType",(e,t)=>{if(!e._zod)throw new Error("Uninitialized schema in ZodMiniType.");U.init(e,t),e.def=t,e.type=t.type},{get with(){return this.check},set with(e){j(this,"with",e)},parse(e,t){return we(this,e,t,{callee:this.parse})},parseAsync(e,t){return Ze(this,e,t,{callee:this.parseAsync})},safeParse(e,t){return Pe(this,e,t)},safeParseAsync(e,t){return ke(this,e,t)},check(...e){let t=this.def;return this.clone({...t,checks:[...t.checks??[],...e.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]},{parent:!0})},clone(e,t){return q(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},apply(e,...t){return t.length===0?e(this):e(this,...t)}}),lr=b("ZodMiniString",(e,t)=>{vt.init(e,t),ee.init(e,t)});function ue(e){return Zt(lr,e)}var Ct=b("ZodMiniNumber",(e,t)=>{Ce.init(e,t),ee.init(e,t)});function Et(e){return Pt(Ct,e)}var pr=b("ZodMiniNumberFormat",(e,t)=>{$t.init(e,t),Ct.init(e,t)});function It(e){return kt(pr,e)}var fr=b("ZodMiniArray",(e,t)=>{bt.init(e,t),ee.init(e,t)});function St(e,t){return new fr({type:"array",element:e,...k(t)})}var dr=b("ZodMiniObject",(e,t)=>{yt.init(e,t),ee.init(e,t),Ye(e,"shape",r=>r._zod.def.shape,!1)});function ae(e,t){let r={type:"object",shape:e??{},...k(t)};return new dr(r)}function Mt(e,t){return Xe(e,t)}var mr=b("ZodMiniOptional",(e,t)=>{zt.init(e,t),ee.init(e,t)});function te(e){return new mr({type:"optional",innerType:e})}var hr=Object.freeze({analytics:!1,marketing:!1,observability:!1}),pe=ue().check(Q(1),Y(128)),Rt=Et().check(Se()),_r=ue().check(Me(/^[A-Z]{3}$/)),gr=ae({item_id:pe,item_name:te(pe),price:te(Rt),quantity:te(It().check(Ie(),ce(1e5))),item_category:te(pe)}),le=ae({currency:_r,value:Rt,items:St(gr).check(Q(1),Y(100))}),Ot={page_view:ae({page_path:ue().check(Q(1),Y(2048))}),product_view:le,add_to_cart:le,begin_checkout:le,purchase:Mt(le,{transaction_id:pe})};function Tt(e,t){let r=e;if(!r||typeof r!="object"||!Object.hasOwn(Ot,r.name)||!/^[\w.-]{1,128}$/.test(t))return;let n=r.timestamp??Date.now();if(!Number.isFinite(n)||n<0)return;let o=Ot[r.name].safeParse(r.properties);if(o.success){if(r.name==="page_view"){let i=o.data;if(!i.page_path.startsWith("/")||i.page_path.startsWith("//"))return;i.page_path=i.page_path.split(/[?#]/)[0]??"/"}return{name:r.name,eventId:t,timestamp:n,properties:o.data}}}function K(){return globalThis.crypto.randomUUID()}function E(e,t){try{return new URL(t??String(e),"http://signalkit.invalid").pathname.split("/").map(n=>{let o;try{o=decodeURIComponent(n)}catch{return":redacted"}return o.includes("@")||o.length>64?":redacted":n}).join("/").replace(/\/[0-9]+(?=\/|$)/g,"/:id").replace(/\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}(?=\/|$)/gi,"/:id").slice(0,2048)}catch{return"/"}}function Oe(e){let t=/^00-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})$/.exec(e??"");if(!(!t||/^0+$/.test(t[1])||/^0+$/.test(t[2])))return{traceId:t[1],spanId:t[2],sampled:(Number.parseInt(t[3],16)&1)===1}}function Dt(e={}){let t=[...e.providers??[]];function r(p){return{analytics:p?.analytics===!0,marketing:p?.marketing===!0,observability:p?.observability===!0}}let n=r(e.consent),o=!1,i=t.map(p=>({name:p.name,category:p.category,consent:!1,disposed:!1,attempts:0,sent:0,failed:0,denied:0,dropped:0,invalid:0})),c=new Set,s=()=>{for(let p of c)try{p()}catch{}},u=new Set,l=new Map,a=Number.isFinite(e.timeoutMs)?Math.max(1,Math.min(e.timeoutMs,6e4)):5e3,h=Number.isFinite(e.maxPending)?Math.max(1,Math.min(Math.floor(e.maxPending),1e3)):100;function d(p){p.outcomes.forEach((x,f)=>{let m=i[f];m&&(m.attempts++,m[x.status]++,m.lastStatus=x.status,m.lastUpdated=Date.now())}),s();try{e.onDiagnostic?.(p)}catch{}return p}async function _(p,x){if(!n[p.category])return{provider:p.name,status:"denied",reason:"consent"};let f=new AbortController;l.set(f,p.category);let m;try{return await Promise.race([Promise.resolve().then(()=>{if(f.signal.aborted)throw new Error("aborted");return p.send(structuredClone(x),f.signal)}),new Promise((y,$)=>{f.signal.addEventListener("abort",()=>$(new Error("aborted")),{once:!0}),m=setTimeout(()=>{f.abort(),$(new Error("timeout"))},a)})]),{provider:p.name,status:f.signal.aborted?"dropped":"sent"}}catch{return{provider:p.name,status:f.signal.aborted?"dropped":"failed",reason:f.signal.aborted?"aborted_or_timeout":"provider_error"}}finally{m!==void 0&&clearTimeout(m),l.delete(f)}}function g(p){let x;try{x=p?.eventId}catch{}let f=typeof x=="string"&&/^[\w.-]{1,128}$/.test(x)?x:K(),m;try{m=x!==void 0&&x!==f?void 0:Tt(p,f)}catch{m=void 0}let y=m?o||u.size>=h?"dropped":void 0:"invalid";if(y)return Promise.resolve(d({eventId:f,outcomes:(t.length?t.map(z=>z.name):["core"]).map(z=>({provider:z,status:y,reason:y==="invalid"?"event_schema":"capacity_or_disposed"}))}));let $=Promise.all(t.map(z=>_(z,m))).then(z=>d({eventId:f,outcomes:z}));return u.add($),$.finally(()=>u.delete($)),$}function v(p){n=r(p);for(let x of i)x.consent=n[x.category];s();for(let[x,f]of l)n[f]||x.abort();for(let x of t)try{x.setConsent?.({...n})}catch{}}return v(n),{track:g,setConsent:v,getConsent:()=>({...n}),getConnections:()=>i.map(p=>({...p})),subscribeConnections(p){return c.add(p),()=>{c.delete(p)}},flush:async()=>{await Promise.all([...u])},dispose:()=>{o=!0;for(let p of i)p.disposed=!0;s(),u.size?Promise.all([...u]).then(()=>c.clear()):c.clear();for(let p of l.keys())p.abort();for(let p of t)try{p.dispose?.()}catch{}}}}var Z=()=>window;function Re(e,t){let r,n;return{load(o){return r||(r=new Promise((i,c)=>{if(typeof document>"u")return c(new Error("Browser provider requires a document"));n=document.createElement("script"),n.async=!0,n.src=e,t.nonce&&(n.nonce=t.nonce);let s=setTimeout(()=>l(new Error("Provider script timed out")),t.timeoutMs??4e3),u=()=>l(new Error("Provider script aborted"));function l(a){clearTimeout(s),o?.removeEventListener("abort",u),n&&(n.onload=null,n.onerror=null),a?(n?.remove(),r=void 0,c(a)):i()}if(n.onload=()=>l(),n.onerror=()=>l(new Error("Provider script blocked")),o?.aborted)return u();o?.addEventListener("abort",u,{once:!0}),document.head.appendChild(n)}),r)},dispose(){n?.remove(),n=void 0,r=void 0}}}function Te(e,t,r){if(!t.test(e))throw new Error(`Invalid ${r}`)}function xr(e){Te(e.measurementId,/^G-[A-Z0-9]+$/,"GA4 measurement ID");let t=Re(`https://www.googletagmanager.com/gtag/js?id=${encodeURIComponent(e.measurementId)}`,e),r=!1,n=()=>{let o=Z();o.dataLayer??=[],o.gtag??=function(...i){o.dataLayer?.push(i)},r||(o.gtag("consent","default",{analytics_storage:"denied",ad_storage:"denied",ad_user_data:"denied",ad_personalization:"denied"}),o.gtag("js",new Date),o.gtag("config",e.measurementId,{send_page_view:!1,page_location:location.origin+E(location.href),page_referrer:document.referrer?E(document.referrer):""}),r=!0)};return{name:"ga4",category:"analytics",async send(o,i){if(n(),await t.load(i),i?.aborted)throw new Error("Dispatch aborted");Z().gtag?.("consent","update",{analytics_storage:"granted"}),Z().gtag?.("event",o.name==="product_view"?"view_item":o.name,{...o.properties,page_location:location.origin+E(location.href),page_referrer:document.referrer?E(document.referrer):"",event_id:o.eventId,send_to:e.measurementId})},setConsent(o){r&&Z().gtag?.("consent","update",{analytics_storage:o.analytics?"granted":"denied"})},dispose(){r&&Z().gtag?.("consent","update",{analytics_storage:"denied"}),t.dispose()}}}var vr={page_view:"PageView",product_view:"ViewContent",add_to_cart:"AddToCart",begin_checkout:"InitiateCheckout",purchase:"Purchase"};function $r(e){Te(e.pixelId,/^\d+$/,"Meta pixel ID");let t=Re("https://connect.facebook.net/en_US/fbevents.js",e),r=!1,n=()=>{let o=Z();if(!o.fbq){let i=(...c)=>{i.callMethod?i.callMethod(...c):i.queue?.push(c)};i.queue=[],i.loaded=!0,i.version="2.0",i.push=i,o.fbq=i}r||(o.fbq("set","autoConfig",!1,e.pixelId),o.fbq("init",e.pixelId),r=!0)};return{name:"meta-pixel",category:"marketing",async send(o,i){if(n(),await t.load(i),i?.aborted)throw new Error("Dispatch aborted");let c=o.properties.items,s={...o.properties.currency?{currency:o.properties.currency}:{},...typeof o.properties.value=="number"?{value:o.properties.value}:{},...c?{content_type:"product",content_ids:c.map(u=>u.item_id),contents:c.map(u=>({id:u.item_id,quantity:u.quantity??1,item_price:u.price}))}:{}};Z().fbq?.("consent","grant"),Z().fbq?.("trackSingle",e.pixelId,vr[o.name],s,{eventID:o.eventId})},setConsent(o){r&&Z().fbq?.("consent",o.marketing?"grant":"revoke")},dispose(){r&&Z().fbq?.("consent","revoke"),t.dispose()}}}function br(e){Te(e.projectId,/^[a-z0-9]+$/i,"Clarity project ID");let t=Re(`https://www.clarity.ms/tag/${encodeURIComponent(e.projectId)}`,e),r=!1;return{name:"clarity",category:"analytics",async send(n,o){if(!r){let i=Z();if(!i.clarity){let c=[],s=(...u)=>{c.push(u)};Object.assign(s,{q:c}),i.clarity=s}r=!0}if(await t.load(o),o?.aborted)throw new Error("Dispatch aborted");Z().clarity?.("consentv2",{analytics_Storage:"granted",ad_Storage:"denied"}),n.name!=="page_view"&&Z().clarity?.("event",n.name)},setConsent(n){r&&Z().clarity?.("consentv2",{analytics_Storage:n.analytics?"granted":"denied",ad_Storage:"denied"})},dispose(){r&&Z().clarity?.("consentv2",{analytics_Storage:"denied",ad_Storage:"denied"}),t.dispose()}}}var fe;function Ds(e={}){let t=Dt(e),r=!1,n={},o=new Set,i=Number.isFinite(e.timeoutMs)?Math.max(1,Math.min(3e4,e.timeoutMs)):2e3;async function c(f){let m;try{await Promise.race([Promise.resolve(f()),new Promise(y=>{m=setTimeout(y,i)})])}catch{}finally{m!==void 0&&clearTimeout(m)}}let s="",u=[],l=f=>["googletagmanager.com","google-analytics.com","facebook.net","facebook.com","clarity.ms"].some(m=>f.hostname===m||f.hostname.endsWith("."+m))||(e.excludeUrls??[]).some(m=>f.href.startsWith(m)||f.pathname.startsWith(m)),a=(f,m)=>t.track({name:"page_view",...m?{eventId:m}:{},properties:{page_path:E(f??(typeof location>"u"?"/":location.href))}}),h=f=>{if(!t.getConsent().observability||!r||!e.observer||o.size>=32)return;let m=c(()=>e.observer.record(f)).finally(()=>{o.delete(m)});o.add(m)},d=()=>{if(!r)return;let f=location.pathname;f!==s&&(s=f,a())};function _(){if(r||typeof window>"u"||fe)return;fe=n,r=!0,d();for(let y of["pushState","replaceState"]){let $=history[y],z=function(...R){$.apply(this,R),d()};history[y]=z,u.push(()=>{history[y]===z&&(history[y]=$)})}window.addEventListener("popstate",d),u.push(()=>window.removeEventListener("popstate",d));let f=window.fetch;if(f){let y=async($,z)=>{if(!r)return f.call(window,$,z);let R=$ instanceof Request?$.url:String($),T;try{T=new URL(R,location.href)}catch{return f.call(window,$,z)}if(l(T)||!t.getConsent().observability)return f.call(window,$,z);let V=performance.now(),W=(z?.method??($ instanceof Request?$.method:"GET")).toUpperCase(),P=new Headers(z?.headers??($ instanceof Request?$.headers:void 0)),w=Oe(P.get("traceparent")),A=w?.traceId,I=w?.spanId;(e.traceOrigins??[]).includes(T.origin)&&!P.has("traceparent")&&(A=K().replaceAll("-","").slice(0,32),I=K().replaceAll("-","").slice(0,16),P.set("traceparent",`00-${A}-${I}-01`));let S={...A?{traceId:A}:{},...I?{spanId:I}:{}};try{let C=await f.call(window,$,{...z,headers:P});return h({kind:"request",route:E(T.href),method:W,status:C.status,durationMs:performance.now()-V,error:C.status>=400,...S}),C}catch(C){throw h({kind:"request",route:E(T.href),method:W,status:0,durationMs:performance.now()-V,error:!0,...S}),C}};window.fetch=y,u.push(()=>{window.fetch===y&&(window.fetch=f)})}let m=window.XMLHttpRequest?.prototype;if(m){let y=m.open,$=m.send,z=m.setRequestHeader,R=new WeakMap,T=function(P,w,A=!0,I,S){try{R.set(this,{url:new URL(String(w),location.href),method:P.toUpperCase(),trace:!1})}catch{R.delete(this)}return y.call(this,P,w,A,I,S)},V=function(P,w){let A=R.get(this);A&&P.toLowerCase()==="traceparent"&&(A.trace=!0,A.traceparent=w),z.call(this,P,w)},W=function(P){let w=R.get(this);if(!r)return $.call(this,P);if(!w||l(w.url)||!t.getConsent().observability)return $.call(this,P);let A=performance.now(),I=Oe(w.traceparent),S=I?.traceId,C=I?.spanId;(e.traceOrigins??[]).includes(w.url.origin)&&!w.trace&&(S=K().replaceAll("-","").slice(0,32),C=K().replaceAll("-","").slice(0,16),z.call(this,"traceparent",`00-${S}-${C}-01`));let De=()=>h({kind:"request",route:E(w.url.href),method:w.method,status:this.status,durationMs:performance.now()-A,error:this.status===0||this.status>=400,...S?{traceId:S}:{},...C?{spanId:C}:{}});this.addEventListener("loadend",De,{once:!0});try{return $.call(this,P)}catch(Lt){throw this.removeEventListener("loadend",De),Lt}};m.open=T,m.send=W,m.setRequestHeader=V,u.push(()=>{m.open===T&&(m.open=y),m.send===W&&(m.send=$),m.setRequestHeader===V&&(m.setRequestHeader=z)})}}function g(){fe===n&&(fe=void 0),r=!1,u.splice(0).reverse().forEach(f=>f())}let v=()=>{g();try{e.observer?.setConsent?.({analytics:!1,marketing:!1,observability:!1})}catch{}t.dispose();try{e.observer?.dispose?.()}catch{}},p=f=>{t.setConsent(f);try{e.observer?.setConsent?.(t.getConsent())}catch{}};try{e.observer?.setConsent?.(t.getConsent())}catch{}let x={...t,async flush(){await t.flush(),await Promise.all([...o]),e.observer?.flush&&await c(()=>e.observer.flush())},setConsent:p,page:a,start:_,stop:g,dispose:v};return e.autoTrack!==!1&&_(),x}function Ns(e,t){let r=e.ownerDocument,n=r.createElement("section");n.className="signalkit-connections",n.setAttribute("aria-label","SignalKit connections");let o=r.createElement("h2");o.textContent="Connections";let i=r.createElement("p");i.textContent="This SDK instance only. SDK send completion does not prove provider delivery or attribution. Counts reset when the instance restarts. Technical observers are not included.";let c=r.createElement("div");n.append(o,i,c),e.append(n);let s=()=>{c.replaceChildren();let l=t.getConnections();if(!l.length){let a=r.createElement("p");a.textContent="No event providers configured. Add providers to your SignalKit configuration.",c.append(a)}for(let a of l){let h=r.createElement("article"),d=r.createElement("h3");d.textContent=a.name;let _=r.createElement("p"),g={sent:"SDK send completed",denied:"Consent denied",failed:"Send failed",dropped:"Dropped (timeout, capacity or disposed)",invalid:"Invalid event"};_.textContent=a.disposed?"SDK disposed":a.consent?a.lastStatus?g[a.lastStatus]:"Configured \xB7 no outcomes yet":"Blocked by consent";let v=r.createElement("p");v.textContent=`${a.category} \xB7 ${a.attempts} outcomes \xB7 ${a.sent} completed \xB7 ${a.failed} failed \xB7 ${a.denied} denied \xB7 ${a.dropped} dropped \xB7 ${a.invalid} invalid`;let p=r.createElement("p");p.textContent=a.lastUpdated?`Last outcome: ${new Date(a.lastUpdated).toLocaleString()}`:"Waiting for a new event.",h.append(d,_,v,p),c.append(h)}};s();let u=t.subscribeConnections(s);return()=>{u(),n.remove()}}export{Ds as createBrowserSignals,br as createClarityProvider,xr as createGA4Provider,$r as createMetaPixelProvider,Ns as mountConnectionsDashboard};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ConnectionStatus } from '@techinject/core';
|
|
2
|
+
export type ConnectionSource = {
|
|
3
|
+
getConnections(): ConnectionStatus[];
|
|
4
|
+
subscribeConnections(listener: () => void): () => void;
|
|
5
|
+
};
|
|
6
|
+
/** Mount in an authenticated host page. No network requests, payloads, or credentials. */
|
|
7
|
+
export declare function mountConnectionsDashboard(element: HTMLElement, source: ConnectionSource): () => void;
|
|
8
|
+
//# sourceMappingURL=dashboard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dashboard.d.ts","sourceRoot":"","sources":["../src/dashboard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,cAAc,IAAI,gBAAgB,EAAE,CAAC;IACrC,oBAAoB,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC;CACxD,CAAC;AAEF,0FAA0F;AAC1F,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,gBAAgB,cAyDvF"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/** Mount in an authenticated host page. No network requests, payloads, or credentials. */
|
|
2
|
+
export function mountConnectionsDashboard(element, source) {
|
|
3
|
+
const document = element.ownerDocument;
|
|
4
|
+
const root = document.createElement('section');
|
|
5
|
+
root.className = 'signalkit-connections';
|
|
6
|
+
root.setAttribute('aria-label', 'SignalKit connections');
|
|
7
|
+
const heading = document.createElement('h2');
|
|
8
|
+
heading.textContent = 'Connections';
|
|
9
|
+
const note = document.createElement('p');
|
|
10
|
+
note.textContent =
|
|
11
|
+
'This SDK instance only. SDK send completion does not prove provider delivery or attribution. Counts reset when the instance restarts. Technical observers are not included.';
|
|
12
|
+
const list = document.createElement('div');
|
|
13
|
+
root.append(heading, note, list);
|
|
14
|
+
element.append(root);
|
|
15
|
+
const render = () => {
|
|
16
|
+
list.replaceChildren();
|
|
17
|
+
const connections = source.getConnections();
|
|
18
|
+
if (!connections.length) {
|
|
19
|
+
const empty = document.createElement('p');
|
|
20
|
+
empty.textContent =
|
|
21
|
+
'No event providers configured. Add providers to your SignalKit configuration.';
|
|
22
|
+
list.append(empty);
|
|
23
|
+
}
|
|
24
|
+
for (const connection of connections) {
|
|
25
|
+
const card = document.createElement('article');
|
|
26
|
+
const name = document.createElement('h3');
|
|
27
|
+
name.textContent = connection.name;
|
|
28
|
+
const status = document.createElement('p');
|
|
29
|
+
const labels = {
|
|
30
|
+
sent: 'SDK send completed',
|
|
31
|
+
denied: 'Consent denied',
|
|
32
|
+
failed: 'Send failed',
|
|
33
|
+
dropped: 'Dropped (timeout, capacity or disposed)',
|
|
34
|
+
invalid: 'Invalid event',
|
|
35
|
+
};
|
|
36
|
+
status.textContent = connection.disposed
|
|
37
|
+
? 'SDK disposed'
|
|
38
|
+
: !connection.consent
|
|
39
|
+
? 'Blocked by consent'
|
|
40
|
+
: connection.lastStatus
|
|
41
|
+
? labels[connection.lastStatus]
|
|
42
|
+
: 'Configured · no outcomes yet';
|
|
43
|
+
const detail = document.createElement('p');
|
|
44
|
+
detail.textContent = `${connection.category} · ${connection.attempts} outcomes · ${connection.sent} completed · ${connection.failed} failed · ${connection.denied} denied · ${connection.dropped} dropped · ${connection.invalid} invalid`;
|
|
45
|
+
const time = document.createElement('p');
|
|
46
|
+
time.textContent = connection.lastUpdated
|
|
47
|
+
? `Last outcome: ${new Date(connection.lastUpdated).toLocaleString()}`
|
|
48
|
+
: 'Waiting for a new event.';
|
|
49
|
+
card.append(name, status, detail, time);
|
|
50
|
+
list.append(card);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
render();
|
|
54
|
+
const unsubscribe = source.subscribeConnections(render);
|
|
55
|
+
return () => {
|
|
56
|
+
unsubscribe();
|
|
57
|
+
root.remove();
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=dashboard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dashboard.js","sourceRoot":"","sources":["../src/dashboard.ts"],"names":[],"mappings":"AAOA,0FAA0F;AAC1F,MAAM,UAAU,yBAAyB,CAAC,OAAoB,EAAE,MAAwB;IACtF,MAAM,QAAQ,GAAG,OAAO,CAAC,aAAa,CAAC;IACvC,MAAM,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;IAC/C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E,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { createSignals } from '@techinject/core';
|
|
2
|
+
import type { Consent, Observer } from '@techinject/contracts';
|
|
3
|
+
export { createGA4Provider, createMetaPixelProvider, createClarityProvider } from './providers.js';
|
|
4
|
+
export type BrowserConfig = Parameters<typeof createSignals>[0] & {
|
|
5
|
+
observer?: Observer;
|
|
6
|
+
traceOrigins?: string[];
|
|
7
|
+
excludeUrls?: string[];
|
|
8
|
+
autoTrack?: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare function createBrowserSignals(config?: BrowserConfig): {
|
|
11
|
+
flush(): Promise<void>;
|
|
12
|
+
setConsent: (consent: Consent) => void;
|
|
13
|
+
page: (path?: string, eventId?: string) => Promise<import("@techinject/contracts").DispatchResult>;
|
|
14
|
+
start: () => void;
|
|
15
|
+
stop: () => void;
|
|
16
|
+
dispose: () => void;
|
|
17
|
+
track: (input: import("@techinject/contracts").EventInput) => Promise<import("@techinject/contracts").DispatchResult>;
|
|
18
|
+
getConsent: () => {
|
|
19
|
+
analytics: boolean;
|
|
20
|
+
marketing: boolean;
|
|
21
|
+
observability: boolean;
|
|
22
|
+
};
|
|
23
|
+
getConnections: () => import("@techinject/core").ConnectionStatus[];
|
|
24
|
+
subscribeConnections(listener: () => void): () => void;
|
|
25
|
+
};
|
|
26
|
+
export type BrowserSignals = ReturnType<typeof createBrowserSignals>;
|
|
27
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA2C,MAAM,kBAAkB,CAAC;AAC1F,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAiB,MAAM,uBAAuB,CAAC;AAC9E,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACnG,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC,CAAC,CAAC,GAAG;IAChE,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,wBAAgB,oBAAoB,CAAC,MAAM,GAAE,aAAkB;;0BA4OhC,OAAO;kBAxMf,MAAM,YAAY,MAAM;;;;;;;;;;;;EAgO9C;AACD,MAAM,MAAM,cAAc,GAAG,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
import { createSignals, generateId, safeRoute, parseTraceparent } from '@techinject/core';
|
|
2
|
+
export { createGA4Provider, createMetaPixelProvider, createClarityProvider } from './providers.js';
|
|
3
|
+
let activeOwner;
|
|
4
|
+
export function createBrowserSignals(config = {}) {
|
|
5
|
+
const core = createSignals(config);
|
|
6
|
+
let running = false;
|
|
7
|
+
const owner = {};
|
|
8
|
+
const pendingRecords = new Set();
|
|
9
|
+
const observationTimeout = Number.isFinite(config.timeoutMs)
|
|
10
|
+
? Math.max(1, Math.min(30000, config.timeoutMs))
|
|
11
|
+
: 2000;
|
|
12
|
+
async function boundedObservation(deliver) {
|
|
13
|
+
let timer;
|
|
14
|
+
try {
|
|
15
|
+
await Promise.race([
|
|
16
|
+
Promise.resolve(deliver()),
|
|
17
|
+
new Promise((resolve) => {
|
|
18
|
+
timer = setTimeout(resolve, observationTimeout);
|
|
19
|
+
}),
|
|
20
|
+
]);
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
/* Observer failures cannot affect the host. */
|
|
24
|
+
}
|
|
25
|
+
finally {
|
|
26
|
+
if (timer !== undefined)
|
|
27
|
+
clearTimeout(timer);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
let lastPath = '';
|
|
31
|
+
const restores = [];
|
|
32
|
+
const excluded = (url) => [
|
|
33
|
+
'googletagmanager.com',
|
|
34
|
+
'google-analytics.com',
|
|
35
|
+
'facebook.net',
|
|
36
|
+
'facebook.com',
|
|
37
|
+
'clarity.ms',
|
|
38
|
+
].some((host) => url.hostname === host || url.hostname.endsWith('.' + host)) ||
|
|
39
|
+
(config.excludeUrls ?? []).some((value) => url.href.startsWith(value) || url.pathname.startsWith(value));
|
|
40
|
+
const page = (path, eventId) => core.track({
|
|
41
|
+
name: 'page_view',
|
|
42
|
+
...(eventId ? { eventId } : {}),
|
|
43
|
+
properties: {
|
|
44
|
+
page_path: safeRoute(path ?? (typeof location === 'undefined' ? '/' : location.href)),
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
const record = (value) => {
|
|
48
|
+
if (!core.getConsent().observability || !running)
|
|
49
|
+
return;
|
|
50
|
+
if (!config.observer || pendingRecords.size >= 32)
|
|
51
|
+
return;
|
|
52
|
+
const operation = boundedObservation(() => config.observer.record(value)).finally(() => {
|
|
53
|
+
pendingRecords.delete(operation);
|
|
54
|
+
});
|
|
55
|
+
pendingRecords.add(operation);
|
|
56
|
+
};
|
|
57
|
+
const navigation = () => {
|
|
58
|
+
if (!running)
|
|
59
|
+
return;
|
|
60
|
+
const path = location.pathname;
|
|
61
|
+
if (path === lastPath)
|
|
62
|
+
return;
|
|
63
|
+
lastPath = path;
|
|
64
|
+
void page();
|
|
65
|
+
};
|
|
66
|
+
function start() {
|
|
67
|
+
if (running || typeof window === 'undefined' || activeOwner)
|
|
68
|
+
return;
|
|
69
|
+
activeOwner = owner;
|
|
70
|
+
running = true;
|
|
71
|
+
navigation();
|
|
72
|
+
for (const name of ['pushState', 'replaceState']) {
|
|
73
|
+
const original = history[name];
|
|
74
|
+
const wrapped = function (...args) {
|
|
75
|
+
original.apply(this, args);
|
|
76
|
+
navigation();
|
|
77
|
+
};
|
|
78
|
+
history[name] = wrapped;
|
|
79
|
+
restores.push(() => {
|
|
80
|
+
if (history[name] === wrapped)
|
|
81
|
+
history[name] = original;
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
window.addEventListener('popstate', navigation);
|
|
85
|
+
restores.push(() => window.removeEventListener('popstate', navigation));
|
|
86
|
+
const originalFetch = window.fetch;
|
|
87
|
+
if (originalFetch) {
|
|
88
|
+
const wrapped = async (input, init) => {
|
|
89
|
+
if (!running)
|
|
90
|
+
return originalFetch.call(window, input, init);
|
|
91
|
+
const raw = input instanceof Request ? input.url : String(input);
|
|
92
|
+
let url;
|
|
93
|
+
try {
|
|
94
|
+
url = new URL(raw, location.href);
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
return originalFetch.call(window, input, init);
|
|
98
|
+
}
|
|
99
|
+
if (excluded(url) || !core.getConsent().observability)
|
|
100
|
+
return originalFetch.call(window, input, init);
|
|
101
|
+
const startTime = performance.now();
|
|
102
|
+
const method = (init?.method ?? (input instanceof Request ? input.method : 'GET')).toUpperCase();
|
|
103
|
+
const headers = new Headers(init?.headers ?? (input instanceof Request ? input.headers : undefined));
|
|
104
|
+
const existing = parseTraceparent(headers.get('traceparent'));
|
|
105
|
+
let traceId = existing?.traceId;
|
|
106
|
+
let spanId = existing?.spanId;
|
|
107
|
+
if ((config.traceOrigins ?? []).includes(url.origin) && !headers.has('traceparent')) {
|
|
108
|
+
traceId = generateId().replaceAll('-', '').slice(0, 32);
|
|
109
|
+
spanId = generateId().replaceAll('-', '').slice(0, 16);
|
|
110
|
+
headers.set('traceparent', `00-${traceId}-${spanId}-01`);
|
|
111
|
+
}
|
|
112
|
+
const context = { ...(traceId ? { traceId } : {}), ...(spanId ? { spanId } : {}) };
|
|
113
|
+
try {
|
|
114
|
+
const response = await originalFetch.call(window, input, { ...init, headers });
|
|
115
|
+
record({
|
|
116
|
+
kind: 'request',
|
|
117
|
+
route: safeRoute(url.href),
|
|
118
|
+
method,
|
|
119
|
+
status: response.status,
|
|
120
|
+
durationMs: performance.now() - startTime,
|
|
121
|
+
error: response.status >= 400,
|
|
122
|
+
...context,
|
|
123
|
+
});
|
|
124
|
+
return response;
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
record({
|
|
128
|
+
kind: 'request',
|
|
129
|
+
route: safeRoute(url.href),
|
|
130
|
+
method,
|
|
131
|
+
status: 0,
|
|
132
|
+
durationMs: performance.now() - startTime,
|
|
133
|
+
error: true,
|
|
134
|
+
...context,
|
|
135
|
+
});
|
|
136
|
+
throw error;
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
window.fetch = wrapped;
|
|
140
|
+
restores.push(() => {
|
|
141
|
+
if (window.fetch === wrapped)
|
|
142
|
+
window.fetch = originalFetch;
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
const proto = window.XMLHttpRequest?.prototype;
|
|
146
|
+
if (proto) {
|
|
147
|
+
const originalOpen = proto.open;
|
|
148
|
+
const originalSend = proto.send;
|
|
149
|
+
const originalHeader = proto.setRequestHeader;
|
|
150
|
+
const state = new WeakMap();
|
|
151
|
+
const open = function (method, url, async = true, username, password) {
|
|
152
|
+
try {
|
|
153
|
+
state.set(this, {
|
|
154
|
+
url: new URL(String(url), location.href),
|
|
155
|
+
method: method.toUpperCase(),
|
|
156
|
+
trace: false,
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
catch {
|
|
160
|
+
state.delete(this);
|
|
161
|
+
}
|
|
162
|
+
return originalOpen.call(this, method, url, async, username, password);
|
|
163
|
+
};
|
|
164
|
+
const setHeader = function (name, value) {
|
|
165
|
+
const entry = state.get(this);
|
|
166
|
+
if (entry && name.toLowerCase() === 'traceparent') {
|
|
167
|
+
entry.trace = true;
|
|
168
|
+
entry.traceparent = value;
|
|
169
|
+
}
|
|
170
|
+
originalHeader.call(this, name, value);
|
|
171
|
+
};
|
|
172
|
+
const send = function (body) {
|
|
173
|
+
const entry = state.get(this);
|
|
174
|
+
if (!running)
|
|
175
|
+
return originalSend.call(this, body);
|
|
176
|
+
if (!entry || excluded(entry.url) || !core.getConsent().observability)
|
|
177
|
+
return originalSend.call(this, body);
|
|
178
|
+
const startTime = performance.now();
|
|
179
|
+
const existing = parseTraceparent(entry.traceparent);
|
|
180
|
+
let traceId = existing?.traceId;
|
|
181
|
+
let spanId = existing?.spanId;
|
|
182
|
+
if ((config.traceOrigins ?? []).includes(entry.url.origin) && !entry.trace) {
|
|
183
|
+
traceId = generateId().replaceAll('-', '').slice(0, 32);
|
|
184
|
+
spanId = generateId().replaceAll('-', '').slice(0, 16);
|
|
185
|
+
originalHeader.call(this, 'traceparent', `00-${traceId}-${spanId}-01`);
|
|
186
|
+
}
|
|
187
|
+
const complete = () => record({
|
|
188
|
+
kind: 'request',
|
|
189
|
+
route: safeRoute(entry.url.href),
|
|
190
|
+
method: entry.method,
|
|
191
|
+
status: this.status,
|
|
192
|
+
durationMs: performance.now() - startTime,
|
|
193
|
+
error: this.status === 0 || this.status >= 400,
|
|
194
|
+
...(traceId ? { traceId } : {}),
|
|
195
|
+
...(spanId ? { spanId } : {}),
|
|
196
|
+
});
|
|
197
|
+
this.addEventListener('loadend', complete, { once: true });
|
|
198
|
+
try {
|
|
199
|
+
return originalSend.call(this, body);
|
|
200
|
+
}
|
|
201
|
+
catch (error) {
|
|
202
|
+
this.removeEventListener('loadend', complete);
|
|
203
|
+
throw error;
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
proto.open = open;
|
|
207
|
+
proto.send = send;
|
|
208
|
+
proto.setRequestHeader = setHeader;
|
|
209
|
+
restores.push(() => {
|
|
210
|
+
if (proto.open === open)
|
|
211
|
+
proto.open = originalOpen;
|
|
212
|
+
if (proto.send === send)
|
|
213
|
+
proto.send = originalSend;
|
|
214
|
+
if (proto.setRequestHeader === setHeader)
|
|
215
|
+
proto.setRequestHeader = originalHeader;
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
function stop() {
|
|
220
|
+
if (activeOwner === owner)
|
|
221
|
+
activeOwner = undefined;
|
|
222
|
+
running = false;
|
|
223
|
+
restores
|
|
224
|
+
.splice(0)
|
|
225
|
+
.reverse()
|
|
226
|
+
.forEach((restore) => restore());
|
|
227
|
+
}
|
|
228
|
+
const dispose = () => {
|
|
229
|
+
stop();
|
|
230
|
+
try {
|
|
231
|
+
config.observer?.setConsent?.({ analytics: false, marketing: false, observability: false });
|
|
232
|
+
}
|
|
233
|
+
catch { }
|
|
234
|
+
core.dispose();
|
|
235
|
+
try {
|
|
236
|
+
config.observer?.dispose?.();
|
|
237
|
+
}
|
|
238
|
+
catch { }
|
|
239
|
+
};
|
|
240
|
+
const setConsent = (consent) => {
|
|
241
|
+
core.setConsent(consent);
|
|
242
|
+
try {
|
|
243
|
+
config.observer?.setConsent?.(core.getConsent());
|
|
244
|
+
}
|
|
245
|
+
catch { }
|
|
246
|
+
};
|
|
247
|
+
try {
|
|
248
|
+
config.observer?.setConsent?.(core.getConsent());
|
|
249
|
+
}
|
|
250
|
+
catch { }
|
|
251
|
+
const api = {
|
|
252
|
+
...core,
|
|
253
|
+
async flush() {
|
|
254
|
+
await core.flush();
|
|
255
|
+
await Promise.all([...pendingRecords]);
|
|
256
|
+
if (config.observer?.flush)
|
|
257
|
+
await boundedObservation(() => config.observer.flush());
|
|
258
|
+
},
|
|
259
|
+
setConsent,
|
|
260
|
+
page,
|
|
261
|
+
start,
|
|
262
|
+
stop,
|
|
263
|
+
dispose,
|
|
264
|
+
};
|
|
265
|
+
if (config.autoTrack !== false)
|
|
266
|
+
start();
|
|
267
|
+
return api;
|
|
268
|
+
}
|
|
269
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;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QAAC,MAAM,CAAC,CAAA,CAAC;IACZ,CAAC,CAAC;IACF,MAAM,UAAU,GAAG,CAAC,OAAgB,EAAE,EAAE;QACtC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QACzB,IAAI,CAAC;YACH,MAAM,CAAC,QAAQ,EAAE,UAAU,EAAE,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;QACnD,CAAC;QAAC,MAAM,CAAC,CAAA,CAAC;IACZ,CAAC,CAAC;IACF,IAAI,CAAC;QACH,MAAM,CAAC,QAAQ,EAAE,UAAU,EAAE,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;IACnD,CAAC;IAAC,MAAM,CAAC,CAAA,CAAC;IACV,MAAM,GAAG,GAAG;QACV,GAAG,IAAI;QACP,KAAK,CAAC,KAAK;YACT,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;YACnB,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC;YACvC,IAAI,MAAM,CAAC,QAAQ,EAAE,KAAK;gBAAE,MAAM,kBAAkB,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,QAAS,CAAC,KAAM,EAAE,CAAC,CAAC;QACxF,CAAC;QACD,UAAU;QACV,IAAI;QACJ,KAAK;QACL,IAAI;QACJ,OAAO;KACR,CAAC;IACF,IAAI,MAAM,CAAC,SAAS,KAAK,KAAK;QAAE,KAAK,EAAE,CAAC;IACxC,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Consent, Provider } from '@techinject/contracts';
|
|
2
|
+
type ConsentProvider = Provider & {
|
|
3
|
+
setConsent(consent: Consent): void;
|
|
4
|
+
};
|
|
5
|
+
type ScriptConfig = {
|
|
6
|
+
nonce?: string;
|
|
7
|
+
timeoutMs?: number;
|
|
8
|
+
};
|
|
9
|
+
export declare function createGA4Provider(config: ScriptConfig & {
|
|
10
|
+
measurementId: string;
|
|
11
|
+
}): ConsentProvider;
|
|
12
|
+
export declare function createMetaPixelProvider(config: ScriptConfig & {
|
|
13
|
+
pixelId: string;
|
|
14
|
+
}): ConsentProvider;
|
|
15
|
+
export declare function createClarityProvider(config: ScriptConfig & {
|
|
16
|
+
projectId: string;
|
|
17
|
+
}): ConsentProvider;
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=providers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../src/providers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAe,MAAM,uBAAuB,CAAC;AAC5E,KAAK,eAAe,GAAG,QAAQ,GAAG;IAAE,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAA;CAAE,CAAC;AACzE,KAAK,YAAY,GAAG;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAgE3D,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,YAAY,GAAG;IAAE,aAAa,EAAE,MAAM,CAAA;CAAE,GAC/C,eAAe,CAwDjB;AAQD,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,YAAY,GAAG;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,GACzC,eAAe,CA6DjB;AACD,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,YAAY,GAAG;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,GAC3C,eAAe,CAyCjB"}
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import { safeRoute } from '@techinject/core';
|
|
2
|
+
const win = () => window;
|
|
3
|
+
function loader(src, config) {
|
|
4
|
+
let pending;
|
|
5
|
+
let script;
|
|
6
|
+
return {
|
|
7
|
+
load(signal) {
|
|
8
|
+
if (pending)
|
|
9
|
+
return pending;
|
|
10
|
+
pending = new Promise((resolve, reject) => {
|
|
11
|
+
if (typeof document === 'undefined')
|
|
12
|
+
return reject(new Error('Browser provider requires a document'));
|
|
13
|
+
script = document.createElement('script');
|
|
14
|
+
script.async = true;
|
|
15
|
+
script.src = src;
|
|
16
|
+
if (config.nonce)
|
|
17
|
+
script.nonce = config.nonce;
|
|
18
|
+
const timer = setTimeout(() => done(new Error('Provider script timed out')), config.timeoutMs ?? 4000);
|
|
19
|
+
const abort = () => done(new Error('Provider script aborted'));
|
|
20
|
+
function done(error) {
|
|
21
|
+
clearTimeout(timer);
|
|
22
|
+
signal?.removeEventListener('abort', abort);
|
|
23
|
+
if (script) {
|
|
24
|
+
script.onload = null;
|
|
25
|
+
script.onerror = null;
|
|
26
|
+
}
|
|
27
|
+
if (error) {
|
|
28
|
+
script?.remove();
|
|
29
|
+
pending = undefined;
|
|
30
|
+
reject(error);
|
|
31
|
+
}
|
|
32
|
+
else
|
|
33
|
+
resolve();
|
|
34
|
+
}
|
|
35
|
+
script.onload = () => done();
|
|
36
|
+
script.onerror = () => done(new Error('Provider script blocked'));
|
|
37
|
+
if (signal?.aborted)
|
|
38
|
+
return abort();
|
|
39
|
+
signal?.addEventListener('abort', abort, { once: true });
|
|
40
|
+
document.head.appendChild(script);
|
|
41
|
+
});
|
|
42
|
+
return pending;
|
|
43
|
+
},
|
|
44
|
+
dispose() {
|
|
45
|
+
script?.remove();
|
|
46
|
+
script = undefined;
|
|
47
|
+
pending = undefined;
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function id(value, pattern, label) {
|
|
52
|
+
if (!pattern.test(value))
|
|
53
|
+
throw new Error(`Invalid ${label}`);
|
|
54
|
+
}
|
|
55
|
+
export function createGA4Provider(config) {
|
|
56
|
+
id(config.measurementId, /^G-[A-Z0-9]+$/, 'GA4 measurement ID');
|
|
57
|
+
const script = loader(`https://www.googletagmanager.com/gtag/js?id=${encodeURIComponent(config.measurementId)}`, config);
|
|
58
|
+
let initialized = false;
|
|
59
|
+
const setup = () => {
|
|
60
|
+
const w = win();
|
|
61
|
+
w.dataLayer ??= [];
|
|
62
|
+
w.gtag ??= function (...args) {
|
|
63
|
+
w.dataLayer?.push(args);
|
|
64
|
+
};
|
|
65
|
+
if (!initialized) {
|
|
66
|
+
w.gtag('consent', 'default', {
|
|
67
|
+
analytics_storage: 'denied',
|
|
68
|
+
ad_storage: 'denied',
|
|
69
|
+
ad_user_data: 'denied',
|
|
70
|
+
ad_personalization: 'denied',
|
|
71
|
+
});
|
|
72
|
+
w.gtag('js', new Date());
|
|
73
|
+
w.gtag('config', config.measurementId, {
|
|
74
|
+
send_page_view: false,
|
|
75
|
+
page_location: location.origin + safeRoute(location.href),
|
|
76
|
+
page_referrer: document.referrer ? safeRoute(document.referrer) : '',
|
|
77
|
+
});
|
|
78
|
+
initialized = true;
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
return {
|
|
82
|
+
name: 'ga4',
|
|
83
|
+
category: 'analytics',
|
|
84
|
+
async send(event, signal) {
|
|
85
|
+
setup();
|
|
86
|
+
await script.load(signal);
|
|
87
|
+
if (signal?.aborted)
|
|
88
|
+
throw new Error('Dispatch aborted');
|
|
89
|
+
win().gtag?.('consent', 'update', { analytics_storage: 'granted' });
|
|
90
|
+
win().gtag?.('event', event.name === 'product_view' ? 'view_item' : event.name, {
|
|
91
|
+
...event.properties,
|
|
92
|
+
page_location: location.origin + safeRoute(location.href),
|
|
93
|
+
page_referrer: document.referrer ? safeRoute(document.referrer) : '',
|
|
94
|
+
event_id: event.eventId,
|
|
95
|
+
send_to: config.measurementId,
|
|
96
|
+
});
|
|
97
|
+
},
|
|
98
|
+
setConsent(consent) {
|
|
99
|
+
if (initialized)
|
|
100
|
+
win().gtag?.('consent', 'update', {
|
|
101
|
+
analytics_storage: consent.analytics ? 'granted' : 'denied',
|
|
102
|
+
});
|
|
103
|
+
},
|
|
104
|
+
dispose() {
|
|
105
|
+
if (initialized)
|
|
106
|
+
win().gtag?.('consent', 'update', { analytics_storage: 'denied' });
|
|
107
|
+
script.dispose();
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
const metaNames = {
|
|
112
|
+
page_view: 'PageView',
|
|
113
|
+
product_view: 'ViewContent',
|
|
114
|
+
add_to_cart: 'AddToCart',
|
|
115
|
+
begin_checkout: 'InitiateCheckout',
|
|
116
|
+
purchase: 'Purchase',
|
|
117
|
+
};
|
|
118
|
+
export function createMetaPixelProvider(config) {
|
|
119
|
+
id(config.pixelId, /^\d+$/, 'Meta pixel ID');
|
|
120
|
+
const script = loader('https://connect.facebook.net/en_US/fbevents.js', config);
|
|
121
|
+
let initialized = false;
|
|
122
|
+
const setup = () => {
|
|
123
|
+
const w = win();
|
|
124
|
+
if (!w.fbq) {
|
|
125
|
+
const fbq = (...args) => {
|
|
126
|
+
if (fbq.callMethod)
|
|
127
|
+
fbq.callMethod(...args);
|
|
128
|
+
else
|
|
129
|
+
fbq.queue?.push(args);
|
|
130
|
+
};
|
|
131
|
+
fbq.queue = [];
|
|
132
|
+
fbq.loaded = true;
|
|
133
|
+
fbq.version = '2.0';
|
|
134
|
+
fbq.push = fbq;
|
|
135
|
+
w.fbq = fbq;
|
|
136
|
+
}
|
|
137
|
+
if (!initialized) {
|
|
138
|
+
w.fbq('set', 'autoConfig', false, config.pixelId);
|
|
139
|
+
w.fbq('init', config.pixelId);
|
|
140
|
+
initialized = true;
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
return {
|
|
144
|
+
name: 'meta-pixel',
|
|
145
|
+
category: 'marketing',
|
|
146
|
+
async send(event, signal) {
|
|
147
|
+
setup();
|
|
148
|
+
await script.load(signal);
|
|
149
|
+
if (signal?.aborted)
|
|
150
|
+
throw new Error('Dispatch aborted');
|
|
151
|
+
const items = event.properties.items;
|
|
152
|
+
const properties = {
|
|
153
|
+
...(event.properties.currency ? { currency: event.properties.currency } : {}),
|
|
154
|
+
...(typeof event.properties.value === 'number' ? { value: event.properties.value } : {}),
|
|
155
|
+
...(items
|
|
156
|
+
? {
|
|
157
|
+
content_type: 'product',
|
|
158
|
+
content_ids: items.map((item) => item.item_id),
|
|
159
|
+
contents: items.map((item) => ({
|
|
160
|
+
id: item.item_id,
|
|
161
|
+
quantity: item.quantity ?? 1,
|
|
162
|
+
item_price: item.price,
|
|
163
|
+
})),
|
|
164
|
+
}
|
|
165
|
+
: {}),
|
|
166
|
+
};
|
|
167
|
+
win().fbq?.('consent', 'grant');
|
|
168
|
+
win().fbq?.('trackSingle', config.pixelId, metaNames[event.name], properties, {
|
|
169
|
+
eventID: event.eventId,
|
|
170
|
+
});
|
|
171
|
+
},
|
|
172
|
+
setConsent(consent) {
|
|
173
|
+
if (initialized)
|
|
174
|
+
win().fbq?.('consent', consent.marketing ? 'grant' : 'revoke');
|
|
175
|
+
},
|
|
176
|
+
dispose() {
|
|
177
|
+
if (initialized)
|
|
178
|
+
win().fbq?.('consent', 'revoke');
|
|
179
|
+
script.dispose();
|
|
180
|
+
},
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
export function createClarityProvider(config) {
|
|
184
|
+
id(config.projectId, /^[a-z0-9]+$/i, 'Clarity project ID');
|
|
185
|
+
const script = loader(`https://www.clarity.ms/tag/${encodeURIComponent(config.projectId)}`, config);
|
|
186
|
+
let initialized = false;
|
|
187
|
+
return {
|
|
188
|
+
name: 'clarity',
|
|
189
|
+
category: 'analytics',
|
|
190
|
+
async send(event, signal) {
|
|
191
|
+
if (!initialized) {
|
|
192
|
+
const w = win();
|
|
193
|
+
if (!w.clarity) {
|
|
194
|
+
const queue = [];
|
|
195
|
+
const clarity = (...args) => {
|
|
196
|
+
queue.push(args);
|
|
197
|
+
};
|
|
198
|
+
Object.assign(clarity, { q: queue });
|
|
199
|
+
w.clarity = clarity;
|
|
200
|
+
}
|
|
201
|
+
initialized = true;
|
|
202
|
+
}
|
|
203
|
+
await script.load(signal);
|
|
204
|
+
if (signal?.aborted)
|
|
205
|
+
throw new Error('Dispatch aborted');
|
|
206
|
+
win().clarity?.('consentv2', { analytics_Storage: 'granted', ad_Storage: 'denied' });
|
|
207
|
+
if (event.name !== 'page_view')
|
|
208
|
+
win().clarity?.('event', event.name);
|
|
209
|
+
},
|
|
210
|
+
setConsent(consent) {
|
|
211
|
+
if (initialized)
|
|
212
|
+
win().clarity?.('consentv2', {
|
|
213
|
+
analytics_Storage: consent.analytics ? 'granted' : 'denied',
|
|
214
|
+
ad_Storage: 'denied',
|
|
215
|
+
});
|
|
216
|
+
},
|
|
217
|
+
dispose() {
|
|
218
|
+
if (initialized)
|
|
219
|
+
win().clarity?.('consentv2', { analytics_Storage: 'denied', ad_Storage: 'denied' });
|
|
220
|
+
script.dispose();
|
|
221
|
+
},
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
//# sourceMappingURL=providers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"providers.js","sourceRoot":"","sources":["../src/providers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAiB7C,MAAM,GAAG,GAAG,GAAG,EAAE,CAAC,MAAiB,CAAC;AACpC,SAAS,MAAM,CAAC,GAAW,EAAE,MAAoB;IAC/C,IAAI,OAAkC,CAAC;IACvC,IAAI,MAAqC,CAAC;IAC1C,OAAO;QACL,IAAI,CAAC,MAAoB;YACvB,IAAI,OAAO;gBAAE,OAAO,OAAO,CAAC;YAC5B,OAAO,GAAG,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;gBAC9C,IAAI,OAAO,QAAQ,KAAK,WAAW;oBACjC,OAAO,MAAM,CAAC,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC,CAAC;gBACnE,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;gBAC1C,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC;gBACpB,MAAM,CAAC,GAAG,GAAG,GAAG,CAAC;gBACjB,IAAI,MAAM,CAAC,KA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C;YACtF,MAAM,CAAC,OAAO,EAAE,CAAC;QACnB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,41 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@techinject/browser",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0-alpha.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist",
|
|
8
|
+
"LICENSE",
|
|
9
|
+
"README.md"
|
|
10
|
+
],
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"import": "./dist/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./dashboard": {
|
|
17
|
+
"types": "./dist/dashboard.d.ts",
|
|
18
|
+
"import": "./dist/dashboard.js"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@techinject/core": "0.1.0-alpha.1",
|
|
23
|
+
"@techinject/contracts": "0.1.0-alpha.1"
|
|
24
|
+
},
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "git+https://github.com/TechInjectIndia/signal-kit.git",
|
|
28
|
+
"directory": "packages/features/signals/browser"
|
|
29
|
+
},
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public"
|
|
32
|
+
},
|
|
33
|
+
"engines": {},
|
|
34
|
+
"description": "SignalKit browser consent-aware telemetry package",
|
|
35
|
+
"scripts": {
|
|
36
|
+
"build": "tsc -p tsconfig.json && node ../../../../scripts/build-cdn.mjs",
|
|
37
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
38
|
+
"test": "vitest run",
|
|
39
|
+
"lint": "tsc -p tsconfig.json --noEmit"
|
|
40
|
+
}
|
|
6
41
|
}
|