@stagepass/loader 2.5.1 → 2.5.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/README.md CHANGED
@@ -12,17 +12,23 @@ npm install @stagepass/loader@2
12
12
 
13
13
  ## CDN Usage
14
14
 
15
- Prefer an exact pin on the Stagepass CDN in production. Stagepass follows strict semver: no breaking changes within v2; breaking changes only in a new major (v3). Use the full file path (this host has no `/dist/` segment). See [Version pinning](https://github.com/stagepass-one/os/blob/master/docs/loader.md#version-pinning) in the docs.
15
+ Default embed on the Stagepass CDN is the major alias (strict semver: no breaking changes within v2). See [Version pinning](https://github.com/stagepass-one/os/blob/master/docs/loader.md#version-pinning) in the docs.
16
+
17
+ ```html
18
+ <script src="https://cdn.stagepass.one/loader@2"></script>
19
+ ```
20
+
21
+ Loader **2.5.2** and later resolves session chunks (`flag.min.js`, `flag-card.min.js`, `live.min.js`) from that folder URL. The CDN also 302-redirects root `/flag.min.js` (and the other two) to `/loader@2/<file>` as a compatibility shim. Or set `data-stagepass-flag-base`.
22
+
23
+ Exact pin when a specific build must load (optional `data-stagepass-version` for production `?v=` on tagged assets):
16
24
 
17
25
  ```html
18
26
  <script
19
- src="https://cdn.stagepass.one/loader@2.5.0/loader.min.js"
20
- data-stagepass-version="2.5.0"
27
+ src="https://cdn.stagepass.one/loader@2.5.1/loader.min.js"
28
+ data-stagepass-version="2.5.1"
21
29
  ></script>
22
30
  ```
23
31
 
24
- Always embed the full file path; the short form `https://cdn.stagepass.one/loader@2.5.0` serves the same loader bytes, but a script tag at that URL resolves session chunks from the CDN root and they 404. Or set `data-stagepass-flag-base`.
25
-
26
32
  jsDelivr is the documented alternative: `https://cdn.jsdelivr.net/npm/@stagepass/loader@2/dist/loader.min.js`. That host may cache `@2` for a while; purge with `https://purge.jsdelivr.net/npm/@stagepass/loader@2/dist/loader.min.js`.
27
33
 
28
34
  ## Known limits (scoped acceptance)
@@ -31,7 +37,7 @@ Acceptance for `live.min.js` / live reload is **scoped localhost only**. It is n
31
37
 
32
38
  A `localhost` / `localhost:<port>` session still reports `sp.env() === 'production'` (unchanged since 2.3.1 / 2.3.3). Only an active `*.sp` swap session is `local`. That is expected behaviour, not a live-reload failure.
33
39
 
34
- `live.min.js` ships since loader **2.4.0** (lazy-loaded during an active swap session; not in **2.3.3**). `@2` is a major range alias, not the npm `latest` tag; after a publish the CDN can briefly serve the previous 2.x build. Pin an exact version (e.g. `@2.5.0`) when a specific build must load.
40
+ `live.min.js` ships since loader **2.4.0** (lazy-loaded during an active swap session; not in **2.3.3**). `@2` is a major range alias, not the npm `latest` tag; after a publish the CDN can briefly serve the previous 2.x build. Pin an exact version (e.g. `@2.5.1`) when a specific build must load.
35
41
 
36
42
  See [MIGRATION.md](../../MIGRATION.md) for breaking changes from 1.x.
37
43
 
@@ -70,8 +76,8 @@ See [MIGRATION.md](../../MIGRATION.md) for breaking changes from 1.x.
70
76
  | `data-src` / `data-href` | Production URL for legacy mode (default). Required unless live-src opt-in uses native `src` / `href`. |
71
77
  | `data-stagepass-path` | Local path under the linked project root (optional). |
72
78
  | `data-stagepass-v` | Per-asset production `?v=<version>` (overrides loader `data-stagepass-version`). |
73
- | `data-stagepass-nocache` | Available in published loader **2.5.0** (npm `latest`). Requires loader **2.5.0** or later (older loaders ignore the attribute; the asset then loads cached as before). Boolean (present, or `="true"`; `="false"` turns it off). Production only: sets exactly one fresh `?_cb=<timestamp>` on **this asset's** URL on every page view, for every visitor. An existing `_cb` is replaced (never a second one). Combines with `data-stagepass-v` / `data-stagepass-version` as original query (without `_cb`), then `?v=<version>`, then `_cb`. No effect during an active local/dev swap session (local assets already get a per-page-load `_cb` stamp). Not applied to `data-stagepass-live-src="true"` assets, which stay untouched in production by design. |
74
- | `data-stagepass-cachebust` | Legacy; ignored for production timestamps in v2. |
79
+ | `data-stagepass-nocache` | Available in published loader **2.5.0** and later. Boolean (present, or `="true"`; `="false"` turns it off). Production only: sets exactly one fresh `?_cb=<timestamp>` on **this asset's** URL on every page view, for every visitor. An existing `_cb` is replaced (never a second one). Query order with version busting: original query (without `_cb`), then `v` from `data-stagepass-v` / `data-stagepass-version`, then `_cb`. No effect during an active local/dev swap session (local assets already get a per-page-load `_cb` stamp). Not applied to `data-stagepass-live-src="true"` assets. |
80
+ | `data-stagepass-cachebust` | Legacy; **not** a per-asset opt-in and **does not** timestamp every production view in v2. Use `data-stagepass-nocache` for permanent per-asset busting. |
75
81
  | `data-stagepass-processed` | Internal; set after processing. |
76
82
 
77
83
  ## URL Modes
@@ -88,7 +94,7 @@ Storage key: `localStorage.stagepass_domain` → JSON `{ "domain": "…", "expir
88
94
 
89
95
  ## Privacy / storage
90
96
 
91
- The loader sets no cookies. On each load it reads the `localStorage` key `stagepass_domain` and removes that key only when the value is stale or invalid. It writes `stagepass_domain` only when a preview session is started via `?stagepass=` (`off`, `0`, and `false` remove the key). While a session is active, the flag UI may write `stagepass:expand`, `stagepass:prev`, and `stagepass:flash`. Storage capability is probed lazily, only when `sp.can('localStorage')`, `sp.can('sessionStorage')`, or `sp.vars.client.capabilities.localStorage` / `.sessionStorage` is used.
97
+ The loader sets no cookies. On each load it reads the `localStorage` key `stagepass_domain` and removes that key only when the value is stale or invalid. It writes `stagepass_domain` only when a preview session is started via `?stagepass=` (`off`, `0`, and `false` remove the key). While a session is active, the flag UI may write `stagepass:expand`, `stagepass:prev`, and `stagepass:flash`. Storage capability is probed lazily, only when `sp.can('localStorage')`, `sp.can('sessionStorage')`, or `sp.vars.client.capabilities.localStorage` / `.sessionStorage` is used. The result of `sp.can('localStorage')` and `sp.can('sessionStorage')` is computed once per page load and cached, including when storage is unavailable. It is not retried until the next page load.
92
98
 
93
99
  ## Dev flag
94
100
 
@@ -113,26 +119,29 @@ Shown only while a session is active (including debug).
113
119
 
114
120
  ## Zero-cost production mode
115
121
 
116
- Opt-in with `data-stagepass-live-src="true"` on the loader tag (loader **2.4.0** and later). Put a normal `src` / `href` (optional `integrity` + `crossorigin`) on `data-stagepass` assets instead of `data-src` / `data-href`. Without a session the browser loads those URLs directly; with a session Stagepass rewrites them to the local `.sp` host before classic scripts run (loader must be a sync script in `<head>` before the assets). Legacy `data-src` / `data-href` stays the default and keeps working. See [Zero-cost production mode](https://github.com/arobertherz/stagepass/blob/master/docs/loader.md#zero-cost-production-mode) for migration, SRI, and limitations.
122
+ Opt-in with `data-stagepass-live-src="true"` on the loader tag (loader **2.4.0** and later). Put a normal `src` / `href` (optional `integrity` + `crossorigin`) on `data-stagepass` assets instead of `data-src` / `data-href`. Without a session the browser loads those URLs directly; with a session Stagepass rewrites them to the local `.sp` host before classic scripts run (loader must be a sync script in `<head>` before the assets). Legacy `data-src` / `data-href` stays the default and keeps working. See [Zero-cost production mode](https://github.com/stagepass-one/os/blob/master/docs/loader.md#zero-cost-production-mode) for migration, SRI, and limitations.
117
123
 
118
124
  ## Permanent per-asset cache busting
119
125
 
120
- `data-stagepass-nocache` is available in published loader **2.5.0** (npm `latest`). It requires loader **2.5.0** or later (older loaders ignore the attribute; the asset then loads cached as before). It is for the rare asset that must be fetched fresh on every page view, for every production visitor, not just during a Stagepass session. Typical case: a script that embeds third-party forms via iframes, where a stale cached copy breaks the embed.
126
+ `data-stagepass-nocache` is available in published loader **2.5.0** and later (older loaders ignore the attribute). It is for the rare asset that must be fetched fresh on every page view, for every production visitor, not just during a Stagepass session. Typical case: a script that embeds third-party forms via iframes, where a stale cached copy breaks the embed.
121
127
 
122
128
  ```html
123
129
  <script
124
130
  data-stagepass
125
- data-src="https://cdn.example.com/js/forms-embed.js"
131
+ data-src="https://cdn.example.com/js/forms-embed.js?foo=1#_section"
132
+ data-stagepass-v="2.5.1"
126
133
  data-stagepass-nocache
127
134
  ></script>
135
+ <!-- production URL becomes:
136
+ https://cdn.example.com/js/forms-embed.js?foo=1&v=2.5.1&_cb=<timestamp>#_section -->
128
137
  ```
129
138
 
130
139
  - Boolean attribute: present (any value, including empty) or `="true"` turns it on; `="false"` turns it off (same as omitting it).
131
140
  - Scoped to exactly that asset. All other `data-stagepass` assets keep the existing version-only cache strategy.
132
- - Sets exactly one `?_cb=<Date.now()>`, replacing any `_cb` already in the URL (a page-supplied `_cb` does not survive, and a second `_cb` is not appended). Any `?v=<version>` from `data-stagepass-v` / `data-stagepass-version` is applied first, so the order is original query (without `_cb`), then `v`, then `_cb`. Other query parameters and the hash stay preserved.
141
+ - Query order: keep the original query **without** `_cb`, then append `v` when `data-stagepass-v` / `data-stagepass-version` is set, then exactly one `_cb=<Date.now()>`. An existing `_cb` is replaced (never a second one). Other query keys and the hash stay preserved.
133
142
  - Production only. During an active local/dev swap session the asset resolves to the local `.sp` URL as usual (single `?_cb=<timestamp>` per page load, same as every other swapped file). `data-stagepass-nocache` has no extra effect there.
134
143
  - Not applied to `data-stagepass-live-src="true"` assets: that mode is intentionally zero-cost (untouched by the loader in production), so pair an asset that needs permanent busting with the default `data-src` / `data-href` mode instead.
135
- - `data-stagepass-cachebust` remains legacy and unrelated: it no longer timestamps every production view (see above) and is not a per-asset opt-in.
144
+ - `data-stagepass-cachebust` is legacy and unrelated: it does **not** timestamp every production view in v2 and is **not** a per-asset opt-in. Use `data-stagepass-nocache` for that.
136
145
 
137
146
  ## Runtime API
138
147
 
@@ -180,4 +189,4 @@ With an active session (or debug), the loader warns when two tagged assets resol
180
189
 
181
190
  ## Repository
182
191
 
183
- - Full docs and examples: [stagepass repository](https://github.com/arobertherz/stagepass)
192
+ - Full docs and examples: [stagepass repository](https://github.com/stagepass-one/os)
package/dist/loader.js CHANGED
@@ -304,7 +304,7 @@ var Stagepass = (() => {
304
304
  const W = window;
305
305
  const d = document;
306
306
  const loc = location;
307
- const PKG_VERSION = true ? "2.5.1" : "0.0.0";
307
+ const PKG_VERSION = true ? "2.5.2" : "0.0.0";
308
308
  const LOADER_RE = /loader(?:\.min)?\.js/i;
309
309
  function flagBase(v, file) {
310
310
  if (typeof v !== "string" || !(v = v.trim())) return null;
@@ -577,7 +577,9 @@ var Stagepass = (() => {
577
577
  const opt = attr("flag-base") ?? W.stagepassFlagBase;
578
578
  let base = flagBase(opt, false);
579
579
  if (opt != null && !base) spWarn("Ignored flag base (http(s) or relative only): " + cut(String(opt), 99));
580
- base = base || flagBase(loaderScript && loaderScript.src || "", true);
580
+ const src = loaderScript && loaderScript.src || "";
581
+ const file = fileOf(src);
582
+ base = base || flagBase(src, LOADER_RE.test(file) || /\.js$/i.test(file));
581
583
  if (!base) {
582
584
  base = `https://cdn.jsdelivr.net/npm/@stagepass/loader@${PKG_VERSION}/dist/`;
583
585
  if (debug) spWarn("Loader URL unknown, flag loads from " + base + ". Set data-stagepass-flag-base");
@@ -1,2 +1,2 @@
1
- var Stagepass=(()=>{function N(t){return typeof t!="string"||!t?!1:t==="debug"||t==="localhost"?!0:t.startsWith("localhost:")?(t=t.slice(10),/^[1-9]\d{0,4}$/.test(t)&&+t<65536):/^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*\.sp$/i.test(t)}function se(t){return t?t.replace(/^https?:\/\//i,"").replace(/\/$/,""):null}var $e="stagepass_domain",V=12;function Oe(t,s=Date.now()){if(!t||!t.startsWith("{"))return null;try{let o=JSON.parse(t);return typeof o.domain!="string"||typeof o.expires!="number"||!Number.isFinite(o.expires)||!N(o.domain)||o.expires<=s?null:{domain:o.domain,expires:o.expires}}catch{return null}}function Ce(t,s=V,o=Date.now()){let i=Number.isFinite(s)&&s>0?s:V;return{domain:t,expires:o+i*60*60*1e3}}function Ie(t){return JSON.stringify(t)}function Re(t){if(t==null||t==="")return V;let s=Number(t);return!Number.isFinite(s)||s<=0?V:s}function oe(t,s,o){if(!t||typeof t!="string")return t;let i=encodeURIComponent(o),g=t.indexOf("#"),b=g>=0?t.slice(g):"",v=g>=0?t.slice(0,g):t;s==="_cb"&&(v=v.replace(/\?.*/,j=>j.replace(/[&?]_cb(=[^&]*)?(?=&|$)/g,"").replace(/^&/,"?")));let $=v.includes("?")?"&":"?";return`${v}${$}${encodeURIComponent(s)}=${i}${b}`}function q(t,s,o){let i=s.startsWith("/")?s.slice(1):s;return`https://${t}/${i}?_cb=${o}`}async function Ne(){let t=typeof navigator<"u"?navigator.permissions:void 0;if(!t||typeof t.query!="function")return"unknown";let s=["loopback-network","local-network-access"];for(let o of s)try{let i=await t.query({name:o}),g=i&&i.state;if(g==="granted"||g==="prompt"||g==="denied")return g}catch{}return"unknown"}function ae(t){return t==="prompt"?"Local network access is required. Allow local/loopback network access when Chrome prompts, then reload.":t==="denied"?"Local network access is blocked. Enable loopback/local network access for this site in Chrome settings, then reload.":null}function je(t,s){let o=s.hasAttribute("async"),i=s.hasAttribute("defer");o?t.async=!0:(t.async=!1,i||(t.defer=!0))}var B="data-stagepass-nocache";function Fe(t){return t.hasAttribute(B)?t.getAttribute(B)!=="false":!1}function Te(t){return!t||typeof t!="string"?[]:t.split(",").map(s=>s.trim().toLowerCase()).filter(Boolean)}function Pe(t,s,o=[]){if(s&&s.endsWith(".sp"))return"local";let i=(t||"").toLowerCase();return i.endsWith(".webflow.io")||o.some(g=>g===i)?"staging":"production"}function Me(t){return!t||typeof t!="string"?!1:/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(t)}function De(t,s){try{return typeof t[s]>"u"}catch{return!1}}var rt=[["edge",/Edg\/(\d+)/],["opera",/OPR\/(\d+)/],["firefox",/Firefox\/(\d+)/],["chrome",/Chrome\/(\d+)/],["safari",/Version\/(\d+).+Safari\//]],st=[["android",/Android/i],["ios",/iPhone|iPad|iPod/i],["macos",/Mac OS X|Macintosh/i],["windows",/Windows NT/i],["linux",/Linux/i]];function ot(t){for(let[s,o]of rt){let i=t.match(o);if(i)return{family:s,major:Number(i[1]),userAgent:t}}return{family:"unknown",major:null,userAgent:t}}function at(t){let s=st.find(([,o])=>o.test(t));return{family:s?s[0]:"unknown"}}function it(t){let s="ontouchstart"in window||(navigator.maxTouchPoints||0)>0,o="desktop";return/iPad|Tablet/i.test(t)?o="tablet":/Mobi|Android.+Mobile|iPhone/i.test(t)?o="mobile":/Android/i.test(t)&&s&&(o="tablet"),{type:o,touch:s}}function ce(){let t=null;try{let s=o=>matchMedia(`(prefers-color-scheme: ${o})`).matches;t=s("dark")?"dark":s("light")?"light":null}catch{}return{preferred:t||"no-preference",current:t||"unknown"}}function ie(t){let s=ie;if(t in s)return s[t];try{let o=window[t],i="__stagepass_test__";return o.setItem(i,"1"),o.removeItem(i),s[t]=!0}catch{return s[t]=!1}}function ct(){try{return typeof navigator<"u"&&"serviceWorker"in navigator}catch{return!1}}function He(){let t=navigator.userAgent||"",s=null;try{s=Intl.DateTimeFormat().resolvedOptions().timeZone||null}catch{}return{theme:ce(),browser:ot(t),os:at(t),device:it(t),viewport:{width:window.innerWidth||0,height:window.innerHeight||0,dpr:window.devicePixelRatio||1},locale:{language:navigator.language||"unknown",timezone:s},capabilities:{cookiesEnabled:navigator.cookieEnabled===!0,get localStorage(){return ie("localStorage")},get sessionStorage(){return ie("sessionStorage")}}}}function We(t,s){let o=t.capabilities;switch(s){case"localStorage":return o.localStorage===!0;case"sessionStorage":return o.sessionStorage===!0;case"cookies":return o.cookiesEnabled===!0;case"serviceWorker":return ct();default:return!1}}function ze(t){if(!t||typeof t!="string")return null;let s=t.trim().match(/^(\d+)/);if(!s)return null;let o=Number(s[1]);return Number.isFinite(o)?o:null}function Ue(t,s){let o=ze(t),i=new Map;function g(b,v,$,j){if(!b||typeof b!="string")return s("stagepass.use: invalid module name"),!1;let x=ze(v);if(o==null||x==null)return s(`stagepass.use: cannot parse version for module "${b}"`),!1;if(x!==o)return s(`Module "${b}" major ${x} does not match loader major ${o}. Skipping.`),!1;try{return $(j),i.set(b,v),!0}catch(k){return s(`Module "${b}" failed to register:`,k),!1}}return{use:g,registered:i}}(function(){let t=$e,s="stagepass",o=window,i=document,g=location,b="2.5.1",v=/loader(?:\.min)?\.js/i;function $(e,n){if(typeof e!="string"||!(e=e.trim()))return null;try{let r=new URL(e,i.baseURI);return!/^https?:$/.test(r.protocol)||r.username||r.password?null:(r.search=r.hash="",n?new URL("./",r).href:r.href.replace(/\/?$/,"/"))}catch{return null}}function j(){try{if(i.currentScript instanceof HTMLScriptElement)return i.currentScript}catch{}try{let e=i.querySelectorAll('script[src*="loader"]');for(let n=e.length-1;n>=0;n--)if(v.test(e[n].src||""))return e[n]}catch{}return null}let x=j(),k=e=>x?x.getAttribute("data-stagepass-"+e):null,Ve=k("mute-console")==="true",qe=Re(k("session-hours")),Be=k("version"),le=Te(k("staging-hosts")),O=k("alias"),ue=k("live-src")==="true",H=new URLSearchParams(g.search),_=!1,A={n:[0,0],m:[],f:[],swapped:0,v:b,vd:N},F=null,fe=()=>F&&F(),de=()=>new Date().toTimeString().slice(0,8),W=e=>(e||"").split(/[?#]/)[0].split("/").pop()||"",z=(e,n)=>e.length>n?e.slice(0,n)+"\u2026":e,ge=(e,n=0)=>{try{if(typeof e=="string")return n?JSON.stringify(e):e;if(e instanceof Error)return e.name+": "+e.message;if(!e||typeof e!="object")return String(e);if(e instanceof Node)return"<"+e.nodeName.toLowerCase()+">";let r=Array.isArray(e);if(n>2)return r?"[\u2026]":"{\u2026}";let c=Object.keys(e),a=c.slice(0,20).map(l=>(r?"":l+": ")+ge(e[l],n+1));return c.length>20&&a.push("\u2026"),z(r?"["+a.join(", ")+"]":"{"+a.join(", ")+"}",1e3)}catch{return"[unserializable]"}},G=(e,n=0)=>{let r=(e||"").split(`
2
- `);for(let c=n;c<r.length;c++){let a=r[c].match(/([a-z][\w+.-]*:\/\/[^\s()]+?):(\d+):(\d+)/i);if(a&&!v.test(W(a[1])))return[a[1],a[2],a[3]]}return null},h=null,Ge=e=>e?h&&!e.indexOf(`https://${h}/`)?"local":"live":"external",C=(e,n,r="",c="",a="",l="",u)=>{A.n[e]++;let f=A.m,m={type:e?"error":"warn",time:de(),src:u||(r?Ge(r):""),file:W(r),url:r.split(/[?#]/)[0],line:c?String(c):"",col:a?String(a):"",text:z(n,500),stack:z(l,2e3),c:1},y=d=>d.type+d.text+d.url+d.line+d.col;for(let d=f.length-1;d>=0;d--)if(y(f[d])===y(m)){m.c=f[d].c+1,f.splice(d,1);break}f.push(m),f.length>50&&f.shift(),fe()},J=(e,n,r,c)=>{let a=r.find(f=>f instanceof Error),l=a&&a.stack||"",u=G(l)||c;C(e,n+r.map(f=>ge(f)).join(" "),u?u[0]:"",u?u[1]:"",u?u[2]:"",l)},T=!1,Je=e=>{T=!0;try{e()}catch{}T=!1};function I(e,...n){if(!_)return;let r=G(new Error().stack||"",3);(e==="warn"||e==="error")&&J(e==="warn"?0:1,"",n,r),Je(()=>{let c=`[\u{1F3AB} ${de()}${r?" | "+W(r[0])+":"+r[1]:""}]`,a=console;e==="error"?a.log(`%c${c}`,"color:red;font-weight:bold",...n):a[e]?a[e](c,...n):a.log(c,e,...n)})}function Ke(...e){let n=e[0]==="warn"||e[0]==="error"?e.shift():"log";I(n,...e)}let P=(...e)=>I("warn",...e),pe=(...e)=>I("error",...e),K=(e,n)=>{let r=_;_=!0,I(e,n),_=r};function Ze(){try{let e=localStorage.getItem(t),n=Oe(e);return!n&&e&&localStorage.removeItem(t),n?n.domain:null}catch{return null}}function Z(){try{localStorage.removeItem(t)}catch{}}let me=!1,S=Ze();if(H.has(s)){let e=H.get(s);if(e==="off"||e==="0"||e==="false")Z(),S=null,K("log","\u{1F50C} Stagepass disconnected.");else if(e){let n=e==="debug"?"debug":se(e);if(n&&N(n)){try{localStorage.setItem(t,Ie(Ce(n,qe)))}catch{}S=n,me=!0,K("log",n==="debug"?"\u{1F50D} Stagepass debug mode enabled.":`\u{1F50C} Stagepass connected to: ${n}`)}else n&&K("warn",`Invalid domain: ${n}. Only .sp domains are allowed.`)}try{H.delete(s);let n=H.toString();history.replaceState({},"",g.pathname+(n?`?${n}`:"")+g.hash)}catch{}}S&&!N(S)&&(Z(),S=null);let M=S==="debug";_=!!S,S&&!me&&!M&&I("log",`\u{1F50C} Stagepass connected to: ${S}`);let he=!!S,w=he&&!M;h=w?se(S):null;let Q=w?Date.now():0,L=g.hostname,Qe=L==="localhost"||L==="127.0.0.1"||L.startsWith("localhost:")||L.startsWith("127.0.0.1:"),be=w||Qe,Se=be?"local":L.endsWith(".webflow.io")||le.includes(L.toLowerCase())?"staging":"production";if(Ve&&Se==="production"&&!_)try{console.log=console.warn=console.error=console.info=console.debug=()=>{}}catch{}let ye={theme:new Set,session:new Set},Y=(e,n)=>ye[e].forEach(r=>{try{r(n)}catch{}}),R=He();try{let e=()=>Y("theme",{...Object.assign(R.theme,ce())});["dark","light"].forEach(n=>{let r=matchMedia(`(prefers-color-scheme: ${n})`);r.addEventListener?r.addEventListener("change",e):r.addListener&&r.addListener(e)})}catch{}o.addEventListener("resize",()=>{let e=R.viewport;e.width=o.innerWidth||0,e.height=o.innerHeight||0,e.dpr=o.devicePixelRatio||1});let p=o.stagepass||{},Ye=Ue(b,P),we=Object.freeze({isLocal:be,env:Se,domain:h||L,timestamp:Q,version:b,client:R});if(p.vars=we,p.log=Ke,p.warn=P,p.error=pe,p.resolveLocalUrl=e=>w&&h&&e?q(h,e,we.timestamp||Date.now()):"",p.env=()=>Pe(L,h,le),p.is=e=>p.env()===e,p.can=e=>We(R,e),p.client=e=>e==null||e===""?R:R[e],p.on=(e,n)=>{let r=ye[e];return!r||e!=="theme"&&e!=="session"?()=>{}:(r.add(n),()=>{r.delete(n)})},p.use=(e,n,r)=>Ye.use(e,n,r,p),o.stagepass=o.sp=p,globalThis.stagepass=globalThis.sp=p,O&&Me(O)&&O!=="sp"&&O!=="stagepass"&&[o,globalThis].forEach(e=>{De(e,O)&&(e[O]=p)}),he)try{let e=Symbol.for("stagepass.flag.v2"),n=k("flag-base")??o.stagepassFlagBase,r=$(n,!1);n!=null&&!r&&P("Ignored flag base (http(s) or relative only): "+z(String(n),99)),r=r||$(x&&x.src||"",!0),r||(r=`https://cdn.jsdelivr.net/npm/@stagepass/loader@${b}/dist/`,M&&P("Loader URL unknown, flag loads from "+r+". Set data-stagepass-flag-base")),Object.assign(A,{debug:M,domain:h,card:r+"flag-card.min.js",end:()=>{Z(),_=!0,I("log","\u{1F50C} Stagepass disconnected."),Y("session",{active:!1,domain:null,swap:!1,debug:!1}),g.reload()}}),Object.defineProperty(p,e,{configurable:!0,value:l=>{delete p[e];try{F=l(A)}catch{}}}),o.addEventListener("error",l=>{let u=l.target,f=u&&u!==o&&(u.src||u.href);typeof f=="string"?ke.has(u)||C(1,"Failed to load "+f.split(/[?#]/)[0],f):/^Script error\.?$/.test(l.message||"")&&!l.filename?C(1,"Error in a cross-origin script (details only in DevTools console)","","","","","external"):C(1,l.message||"Script error",l.filename||"",l.lineno,l.colno,l.error&&l.error.stack||"")},!0),o.addEventListener("unhandledrejection",l=>J(1,"Unhandled rejection: ",[l.reason],null));let c=console;["warn","error"].forEach((l,u)=>{let f=c[l];typeof f=="function"&&(c[l]=function(...m){if(!T){T=!0;try{J(u,"",m,G(new Error().stack||"",2))}catch{}T=!1}return f.apply(this,m)})});let a=i.createElement("script");a.src=r+"flag.min.js",a.async=!0,a.onerror=()=>P("Stagepass flag could not be loaded: "+a.src),(i.head||i.documentElement).appendChild(a)}catch{}Y("session",{active:_,domain:S,swap:w,debug:M});function Xe(e,n,r){if(w&&r&&h)return q(h,r,Q);let c=e.getAttribute("data-stagepass-v")||Be,a=c?oe(n,"v",c):n;return Fe(e)&&(a=oe(a,"_cb",Date.now())),a}function ve(e){try{let n=new URL(e).pathname.split("/");return n[n.length-1]||n[n.length-2]||null}catch{let r=e.match(/\/([^\/\?#]+)(?:\?|#|$)/);return r?r[1]:null}}let ke=new WeakSet,X="";function Ee(e,n,r,c,a,l){let u={live:n,local:r,type:c?"js":"css",st:""};l&&(u.x=!0);let f=W(r);ke.add(e),A.f.push(u),e.addEventListener("load",()=>{u.st="ok",A.swapped++,fe()}),e.addEventListener("error",()=>{let m=(d,re,U)=>{u.st=d,C(re,U,r)},y=o.fetch;if(typeof y!="function")return m("failed",1,`Failed to load ${f}`);y(r,{method:"HEAD",cache:"no-store"}).then(d=>m(d.ok?"failed":String(d.status),1,d.ok?`Failed to load ${f}`:`Local file not found (${d.status}): ${f}`),()=>y(r,{method:"HEAD",mode:"no-cors",cache:"no-store"}).then(()=>{if(!a)return m("failed",1,`Failed to load ${f}`);A.f.splice(A.f.indexOf(u),1),e.replaceWith(a(!1)),C(0,`Local server sends no CORS header for ${f}. Loaded without crossorigin, error details are limited`,r)},()=>m("failed",1,`Local server not reachable: ${f}. Run stagepass doctor`+(ae(X)?". "+ae(X):""))))})}let et=["data-stagepass","data-stagepass-path","data-stagepass-cachebust","data-stagepass-v",B],ee='script[data-stagepass][src]:not([data-src]):not([data-stagepass-processed]),link[rel="stylesheet" i][data-stagepass][href]:not([data-href]):not([data-stagepass-processed])',xe="onbeforescriptexecute"in i;function _e(e){try{let n=e.tagName==="SCRIPT";if(n&&(xe||i.currentScript===e))return;let r=n?"src":"href",c=e.getAttribute(r);if(!c)return;e.setAttribute("data-stagepass-processed","true");let a=e.getAttribute("data-stagepass-path"),l=a||ve(c);if(!l)return;let u=q(h,l,Q);e.removeAttribute("integrity"),e.hasAttribute("crossorigin")||e.setAttribute("crossorigin","anonymous"),e[r]=u,Ee(e,c,u,n,null,!!a)}catch{}}let te=e=>{try{e.matches&&e.matches(ee)&&_e(e),e.querySelectorAll(ee).forEach(_e)}catch{}};function ne(e,n,r){i.querySelectorAll(`${e}:not([data-stagepass-processed])`).forEach(c=>{try{let a=c.getAttribute("data-stagepass-path"),l=!!a,u=c.getAttribute(n);if(!u)return;c.setAttribute("data-stagepass-processed","true"),!a&&w&&h&&(a=ve(u));let f=Xe(c,u,a);if(!f)return;let m=w&&a&&h,y=r==="script",d=U=>{let E=i.createElement(r);U&&(E.crossOrigin="anonymous"),y?E.src=f:(E.rel="stylesheet",E.href=f);for(let D of Array.from(c.attributes))D.name!==n&&!et.includes(D.name)&&D.name!==(y?"src":"href")&&E.setAttribute(D.name,D.value);return m&&E.removeAttribute("integrity"),y&&je(E,c),m&&Ee(E,u,f,y,U?d:null,l),E},re=d(!!m&&!c.hasAttribute("crossorigin"));c.parentNode?(c.parentNode.insertBefore(re,c),c.remove()):pe(`${r} injection failed: No parent node`)}catch{}})}if(w&&ue)try{new MutationObserver(e=>{for(let n of e)for(let r of n.addedNodes)r.nodeType===1&&te(r)}).observe(i.documentElement,{childList:!0,subtree:!0}),xe&&i.addEventListener("beforescriptexecute",e=>{let n=e.target;if(!n||!n.matches||!n.matches(ee))return;let r=n.getAttribute("src");!r||r.indexOf("https://"+h+"/")===0||(e.preventDefault(),n.setAttribute("data-src",r),n.removeAttribute("src"),ne("script[data-stagepass]","data-src","script"))},!0),te(i)}catch{}let tt=()=>{try{ne("script[data-stagepass]","data-src","script"),ne('link[rel="stylesheet"][data-stagepass]',"data-href","link"),w&&ue&&te(i),F&&F()}catch{}},Ae=null,nt=()=>Ae=Ae||(w?Ne().then(e=>{X=e}).catch(()=>{}):Promise.resolve()),Le=()=>{nt().then(tt)};Le(),i.readyState==="loading"&&i.addEventListener("DOMContentLoaded",Le)})();})();
1
+ var Stagepass=(()=>{function N(t){return typeof t!="string"||!t?!1:t==="debug"||t==="localhost"?!0:t.startsWith("localhost:")?(t=t.slice(10),/^[1-9]\d{0,4}$/.test(t)&&+t<65536):/^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*\.sp$/i.test(t)}function re(t){return t?t.replace(/^https?:\/\//i,"").replace(/\/$/,""):null}var $e="stagepass_domain",q=12;function Oe(t,r=Date.now()){if(!t||!t.startsWith("{"))return null;try{let o=JSON.parse(t);return typeof o.domain!="string"||typeof o.expires!="number"||!Number.isFinite(o.expires)||!N(o.domain)||o.expires<=r?null:{domain:o.domain,expires:o.expires}}catch{return null}}function Ce(t,r=q,o=Date.now()){let a=Number.isFinite(r)&&r>0?r:q;return{domain:t,expires:o+a*60*60*1e3}}function Ie(t){return JSON.stringify(t)}function Re(t){if(t==null||t==="")return q;let r=Number(t);return!Number.isFinite(r)||r<=0?q:r}function oe(t,r,o){if(!t||typeof t!="string")return t;let a=encodeURIComponent(o),g=t.indexOf("#"),S=g>=0?t.slice(g):"",w=g>=0?t.slice(0,g):t;r==="_cb"&&(w=w.replace(/\?.*/,j=>j.replace(/[&?]_cb(=[^&]*)?(?=&|$)/g,"").replace(/^&/,"?")));let $=w.includes("?")?"&":"?";return`${w}${$}${encodeURIComponent(r)}=${a}${S}`}function B(t,r,o){let a=r.startsWith("/")?r.slice(1):r;return`https://${t}/${a}?_cb=${o}`}async function Ne(){let t=typeof navigator<"u"?navigator.permissions:void 0;if(!t||typeof t.query!="function")return"unknown";let r=["loopback-network","local-network-access"];for(let o of r)try{let a=await t.query({name:o}),g=a&&a.state;if(g==="granted"||g==="prompt"||g==="denied")return g}catch{}return"unknown"}function ae(t){return t==="prompt"?"Local network access is required. Allow local/loopback network access when Chrome prompts, then reload.":t==="denied"?"Local network access is blocked. Enable loopback/local network access for this site in Chrome settings, then reload.":null}function je(t,r){let o=r.hasAttribute("async"),a=r.hasAttribute("defer");o?t.async=!0:(t.async=!1,a||(t.defer=!0))}var G="data-stagepass-nocache";function Fe(t){return t.hasAttribute(G)?t.getAttribute(G)!=="false":!1}function Te(t){return!t||typeof t!="string"?[]:t.split(",").map(r=>r.trim().toLowerCase()).filter(Boolean)}function Pe(t,r,o=[]){if(r&&r.endsWith(".sp"))return"local";let a=(t||"").toLowerCase();return a.endsWith(".webflow.io")||o.some(g=>g===a)?"staging":"production"}function Me(t){return!t||typeof t!="string"?!1:/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(t)}function De(t,r){try{return typeof t[r]>"u"}catch{return!1}}var st=[["edge",/Edg\/(\d+)/],["opera",/OPR\/(\d+)/],["firefox",/Firefox\/(\d+)/],["chrome",/Chrome\/(\d+)/],["safari",/Version\/(\d+).+Safari\//]],rt=[["android",/Android/i],["ios",/iPhone|iPad|iPod/i],["macos",/Mac OS X|Macintosh/i],["windows",/Windows NT/i],["linux",/Linux/i]];function ot(t){for(let[r,o]of st){let a=t.match(o);if(a)return{family:r,major:Number(a[1]),userAgent:t}}return{family:"unknown",major:null,userAgent:t}}function at(t){let r=rt.find(([,o])=>o.test(t));return{family:r?r[0]:"unknown"}}function it(t){let r="ontouchstart"in window||(navigator.maxTouchPoints||0)>0,o="desktop";return/iPad|Tablet/i.test(t)?o="tablet":/Mobi|Android.+Mobile|iPhone/i.test(t)?o="mobile":/Android/i.test(t)&&r&&(o="tablet"),{type:o,touch:r}}function ce(){let t=null;try{let r=o=>matchMedia(`(prefers-color-scheme: ${o})`).matches;t=r("dark")?"dark":r("light")?"light":null}catch{}return{preferred:t||"no-preference",current:t||"unknown"}}function ie(t){let r=ie;if(t in r)return r[t];try{let o=window[t],a="__stagepass_test__";return o.setItem(a,"1"),o.removeItem(a),r[t]=!0}catch{return r[t]=!1}}function ct(){try{return typeof navigator<"u"&&"serviceWorker"in navigator}catch{return!1}}function He(){let t=navigator.userAgent||"",r=null;try{r=Intl.DateTimeFormat().resolvedOptions().timeZone||null}catch{}return{theme:ce(),browser:ot(t),os:at(t),device:it(t),viewport:{width:window.innerWidth||0,height:window.innerHeight||0,dpr:window.devicePixelRatio||1},locale:{language:navigator.language||"unknown",timezone:r},capabilities:{cookiesEnabled:navigator.cookieEnabled===!0,get localStorage(){return ie("localStorage")},get sessionStorage(){return ie("sessionStorage")}}}}function We(t,r){let o=t.capabilities;switch(r){case"localStorage":return o.localStorage===!0;case"sessionStorage":return o.sessionStorage===!0;case"cookies":return o.cookiesEnabled===!0;case"serviceWorker":return ct();default:return!1}}function ze(t){if(!t||typeof t!="string")return null;let r=t.trim().match(/^(\d+)/);if(!r)return null;let o=Number(r[1]);return Number.isFinite(o)?o:null}function Ue(t,r){let o=ze(t),a=new Map;function g(S,w,$,j){if(!S||typeof S!="string")return r("stagepass.use: invalid module name"),!1;let x=ze(w);if(o==null||x==null)return r(`stagepass.use: cannot parse version for module "${S}"`),!1;if(x!==o)return r(`Module "${S}" major ${x} does not match loader major ${o}. Skipping.`),!1;try{return $(j),a.set(S,w),!0}catch(k){return r(`Module "${S}" failed to register:`,k),!1}}return{use:g,registered:a}}(function(){let t=$e,r="stagepass",o=window,a=document,g=location,S="2.5.2",w=/loader(?:\.min)?\.js/i;function $(e,n){if(typeof e!="string"||!(e=e.trim()))return null;try{let s=new URL(e,a.baseURI);return!/^https?:$/.test(s.protocol)||s.username||s.password?null:(s.search=s.hash="",n?new URL("./",s).href:s.href.replace(/\/?$/,"/"))}catch{return null}}function j(){try{if(a.currentScript instanceof HTMLScriptElement)return a.currentScript}catch{}try{let e=a.querySelectorAll('script[src*="loader"]');for(let n=e.length-1;n>=0;n--)if(w.test(e[n].src||""))return e[n]}catch{}return null}let x=j(),k=e=>x?x.getAttribute("data-stagepass-"+e):null,Ve=k("mute-console")==="true",qe=Re(k("session-hours")),Be=k("version"),le=Te(k("staging-hosts")),O=k("alias"),ue=k("live-src")==="true",W=new URLSearchParams(g.search),_=!1,A={n:[0,0],m:[],f:[],swapped:0,v:S,vd:N},F=null,fe=()=>F&&F(),de=()=>new Date().toTimeString().slice(0,8),T=e=>(e||"").split(/[?#]/)[0].split("/").pop()||"",z=(e,n)=>e.length>n?e.slice(0,n)+"\u2026":e,ge=(e,n=0)=>{try{if(typeof e=="string")return n?JSON.stringify(e):e;if(e instanceof Error)return e.name+": "+e.message;if(!e||typeof e!="object")return String(e);if(e instanceof Node)return"<"+e.nodeName.toLowerCase()+">";let s=Array.isArray(e);if(n>2)return s?"[\u2026]":"{\u2026}";let i=Object.keys(e),c=i.slice(0,20).map(h=>(s?"":h+": ")+ge(e[h],n+1));return i.length>20&&c.push("\u2026"),z(s?"["+c.join(", ")+"]":"{"+c.join(", ")+"}",1e3)}catch{return"[unserializable]"}},J=(e,n=0)=>{let s=(e||"").split(`
2
+ `);for(let i=n;i<s.length;i++){let c=s[i].match(/([a-z][\w+.-]*:\/\/[^\s()]+?):(\d+):(\d+)/i);if(c&&!w.test(T(c[1])))return[c[1],c[2],c[3]]}return null},b=null,Ge=e=>e?b&&!e.indexOf(`https://${b}/`)?"local":"live":"external",C=(e,n,s="",i="",c="",h="",u)=>{A.n[e]++;let l=A.m,d={type:e?"error":"warn",time:de(),src:u||(s?Ge(s):""),file:T(s),url:s.split(/[?#]/)[0],line:i?String(i):"",col:c?String(c):"",text:z(n,500),stack:z(h,2e3),c:1},m=f=>f.type+f.text+f.url+f.line+f.col;for(let f=l.length-1;f>=0;f--)if(m(l[f])===m(d)){d.c=l[f].c+1,l.splice(f,1);break}l.push(d),l.length>50&&l.shift(),fe()},K=(e,n,s,i)=>{let c=s.find(l=>l instanceof Error),h=c&&c.stack||"",u=J(h)||i;C(e,n+s.map(l=>ge(l)).join(" "),u?u[0]:"",u?u[1]:"",u?u[2]:"",h)},P=!1,Je=e=>{P=!0;try{e()}catch{}P=!1};function I(e,...n){if(!_)return;let s=J(new Error().stack||"",3);(e==="warn"||e==="error")&&K(e==="warn"?0:1,"",n,s),Je(()=>{let i=`[\u{1F3AB} ${de()}${s?" | "+T(s[0])+":"+s[1]:""}]`,c=console;e==="error"?c.log(`%c${i}`,"color:red;font-weight:bold",...n):c[e]?c[e](i,...n):c.log(i,e,...n)})}function Ke(...e){let n=e[0]==="warn"||e[0]==="error"?e.shift():"log";I(n,...e)}let M=(...e)=>I("warn",...e),pe=(...e)=>I("error",...e),Z=(e,n)=>{let s=_;_=!0,I(e,n),_=s};function Ze(){try{let e=localStorage.getItem(t),n=Oe(e);return!n&&e&&localStorage.removeItem(t),n?n.domain:null}catch{return null}}function Q(){try{localStorage.removeItem(t)}catch{}}let me=!1,y=Ze();if(W.has(r)){let e=W.get(r);if(e==="off"||e==="0"||e==="false")Q(),y=null,Z("log","\u{1F50C} Stagepass disconnected.");else if(e){let n=e==="debug"?"debug":re(e);if(n&&N(n)){try{localStorage.setItem(t,Ie(Ce(n,qe)))}catch{}y=n,me=!0,Z("log",n==="debug"?"\u{1F50D} Stagepass debug mode enabled.":`\u{1F50C} Stagepass connected to: ${n}`)}else n&&Z("warn",`Invalid domain: ${n}. Only .sp domains are allowed.`)}try{W.delete(r);let n=W.toString();history.replaceState({},"",g.pathname+(n?`?${n}`:"")+g.hash)}catch{}}y&&!N(y)&&(Q(),y=null);let D=y==="debug";_=!!y,y&&!me&&!D&&I("log",`\u{1F50C} Stagepass connected to: ${y}`);let he=!!y,v=he&&!D;b=v?re(y):null;let Y=v?Date.now():0,L=g.hostname,Qe=L==="localhost"||L==="127.0.0.1"||L.startsWith("localhost:")||L.startsWith("127.0.0.1:"),be=v||Qe,Se=be?"local":L.endsWith(".webflow.io")||le.includes(L.toLowerCase())?"staging":"production";if(Ve&&Se==="production"&&!_)try{console.log=console.warn=console.error=console.info=console.debug=()=>{}}catch{}let ye={theme:new Set,session:new Set},X=(e,n)=>ye[e].forEach(s=>{try{s(n)}catch{}}),R=He();try{let e=()=>X("theme",{...Object.assign(R.theme,ce())});["dark","light"].forEach(n=>{let s=matchMedia(`(prefers-color-scheme: ${n})`);s.addEventListener?s.addEventListener("change",e):s.addListener&&s.addListener(e)})}catch{}o.addEventListener("resize",()=>{let e=R.viewport;e.width=o.innerWidth||0,e.height=o.innerHeight||0,e.dpr=o.devicePixelRatio||1});let p=o.stagepass||{},Ye=Ue(S,M),we=Object.freeze({isLocal:be,env:Se,domain:b||L,timestamp:Y,version:S,client:R});if(p.vars=we,p.log=Ke,p.warn=M,p.error=pe,p.resolveLocalUrl=e=>v&&b&&e?B(b,e,we.timestamp||Date.now()):"",p.env=()=>Pe(L,b,le),p.is=e=>p.env()===e,p.can=e=>We(R,e),p.client=e=>e==null||e===""?R:R[e],p.on=(e,n)=>{let s=ye[e];return!s||e!=="theme"&&e!=="session"?()=>{}:(s.add(n),()=>{s.delete(n)})},p.use=(e,n,s)=>Ye.use(e,n,s,p),o.stagepass=o.sp=p,globalThis.stagepass=globalThis.sp=p,O&&Me(O)&&O!=="sp"&&O!=="stagepass"&&[o,globalThis].forEach(e=>{De(e,O)&&(e[O]=p)}),he)try{let e=Symbol.for("stagepass.flag.v2"),n=k("flag-base")??o.stagepassFlagBase,s=$(n,!1);n!=null&&!s&&M("Ignored flag base (http(s) or relative only): "+z(String(n),99));let i=x&&x.src||"",c=T(i);s=s||$(i,w.test(c)||/\.js$/i.test(c)),s||(s=`https://cdn.jsdelivr.net/npm/@stagepass/loader@${S}/dist/`,D&&M("Loader URL unknown, flag loads from "+s+". Set data-stagepass-flag-base")),Object.assign(A,{debug:D,domain:b,card:s+"flag-card.min.js",end:()=>{Q(),_=!0,I("log","\u{1F50C} Stagepass disconnected."),X("session",{active:!1,domain:null,swap:!1,debug:!1}),g.reload()}}),Object.defineProperty(p,e,{configurable:!0,value:l=>{delete p[e];try{F=l(A)}catch{}}}),o.addEventListener("error",l=>{let d=l.target,m=d&&d!==o&&(d.src||d.href);typeof m=="string"?ke.has(d)||C(1,"Failed to load "+m.split(/[?#]/)[0],m):/^Script error\.?$/.test(l.message||"")&&!l.filename?C(1,"Error in a cross-origin script (details only in DevTools console)","","","","","external"):C(1,l.message||"Script error",l.filename||"",l.lineno,l.colno,l.error&&l.error.stack||"")},!0),o.addEventListener("unhandledrejection",l=>K(1,"Unhandled rejection: ",[l.reason],null));let h=console;["warn","error"].forEach((l,d)=>{let m=h[l];typeof m=="function"&&(h[l]=function(...f){if(!P){P=!0;try{K(d,"",f,J(new Error().stack||"",2))}catch{}P=!1}return m.apply(this,f)})});let u=a.createElement("script");u.src=s+"flag.min.js",u.async=!0,u.onerror=()=>M("Stagepass flag could not be loaded: "+u.src),(a.head||a.documentElement).appendChild(u)}catch{}X("session",{active:_,domain:y,swap:v,debug:D});function Xe(e,n,s){if(v&&s&&b)return B(b,s,Y);let i=e.getAttribute("data-stagepass-v")||Be,c=i?oe(n,"v",i):n;return Fe(e)&&(c=oe(c,"_cb",Date.now())),c}function ve(e){try{let n=new URL(e).pathname.split("/");return n[n.length-1]||n[n.length-2]||null}catch{let s=e.match(/\/([^\/\?#]+)(?:\?|#|$)/);return s?s[1]:null}}let ke=new WeakSet,ee="";function Ee(e,n,s,i,c,h){let u={live:n,local:s,type:i?"js":"css",st:""};h&&(u.x=!0);let l=T(s);ke.add(e),A.f.push(u),e.addEventListener("load",()=>{u.st="ok",A.swapped++,fe()}),e.addEventListener("error",()=>{let d=(f,U,V)=>{u.st=f,C(U,V,s)},m=o.fetch;if(typeof m!="function")return d("failed",1,`Failed to load ${l}`);m(s,{method:"HEAD",cache:"no-store"}).then(f=>d(f.ok?"failed":String(f.status),1,f.ok?`Failed to load ${l}`:`Local file not found (${f.status}): ${l}`),()=>m(s,{method:"HEAD",mode:"no-cors",cache:"no-store"}).then(()=>{if(!c)return d("failed",1,`Failed to load ${l}`);A.f.splice(A.f.indexOf(u),1),e.replaceWith(c(!1)),C(0,`Local server sends no CORS header for ${l}. Loaded without crossorigin, error details are limited`,s)},()=>d("failed",1,`Local server not reachable: ${l}. Run stagepass doctor`+(ae(ee)?". "+ae(ee):""))))})}let et=["data-stagepass","data-stagepass-path","data-stagepass-cachebust","data-stagepass-v",G],te='script[data-stagepass][src]:not([data-src]):not([data-stagepass-processed]),link[rel="stylesheet" i][data-stagepass][href]:not([data-href]):not([data-stagepass-processed])',xe="onbeforescriptexecute"in a;function _e(e){try{let n=e.tagName==="SCRIPT";if(n&&(xe||a.currentScript===e))return;let s=n?"src":"href",i=e.getAttribute(s);if(!i)return;e.setAttribute("data-stagepass-processed","true");let c=e.getAttribute("data-stagepass-path"),h=c||ve(i);if(!h)return;let u=B(b,h,Y);e.removeAttribute("integrity"),e.hasAttribute("crossorigin")||e.setAttribute("crossorigin","anonymous"),e[s]=u,Ee(e,i,u,n,null,!!c)}catch{}}let ne=e=>{try{e.matches&&e.matches(te)&&_e(e),e.querySelectorAll(te).forEach(_e)}catch{}};function se(e,n,s){a.querySelectorAll(`${e}:not([data-stagepass-processed])`).forEach(i=>{try{let c=i.getAttribute("data-stagepass-path"),h=!!c,u=i.getAttribute(n);if(!u)return;i.setAttribute("data-stagepass-processed","true"),!c&&v&&b&&(c=ve(u));let l=Xe(i,u,c);if(!l)return;let d=v&&c&&b,m=s==="script",f=V=>{let E=a.createElement(s);V&&(E.crossOrigin="anonymous"),m?E.src=l:(E.rel="stylesheet",E.href=l);for(let H of Array.from(i.attributes))H.name!==n&&!et.includes(H.name)&&H.name!==(m?"src":"href")&&E.setAttribute(H.name,H.value);return d&&E.removeAttribute("integrity"),m&&je(E,i),d&&Ee(E,u,l,m,V?f:null,h),E},U=f(!!d&&!i.hasAttribute("crossorigin"));i.parentNode?(i.parentNode.insertBefore(U,i),i.remove()):pe(`${s} injection failed: No parent node`)}catch{}})}if(v&&ue)try{new MutationObserver(e=>{for(let n of e)for(let s of n.addedNodes)s.nodeType===1&&ne(s)}).observe(a.documentElement,{childList:!0,subtree:!0}),xe&&a.addEventListener("beforescriptexecute",e=>{let n=e.target;if(!n||!n.matches||!n.matches(te))return;let s=n.getAttribute("src");!s||s.indexOf("https://"+b+"/")===0||(e.preventDefault(),n.setAttribute("data-src",s),n.removeAttribute("src"),se("script[data-stagepass]","data-src","script"))},!0),ne(a)}catch{}let tt=()=>{try{se("script[data-stagepass]","data-src","script"),se('link[rel="stylesheet"][data-stagepass]',"data-href","link"),v&&ue&&ne(a),F&&F()}catch{}},Ae=null,nt=()=>Ae=Ae||(v?Ne().then(e=>{ee=e}).catch(()=>{}):Promise.resolve()),Le=()=>{nt().then(tt)};Le(),a.readyState==="loading"&&a.addEventListener("DOMContentLoaded",Le)})();})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stagepass/loader",
3
- "version": "2.5.1",
3
+ "version": "2.5.2",
4
4
  "description": "Universal loader for Stagepass - injects local files into Webflow projects",
5
5
  "main": "dist/loader.min.js",
6
6
  "types": "global.d.ts",
@@ -27,7 +27,7 @@
27
27
  ],
28
28
  "repository": {
29
29
  "type": "git",
30
- "url": "git+https://github.com/arobertherz/stagepass.git",
30
+ "url": "git+https://github.com/stagepass-one/os.git",
31
31
  "directory": "packages/loader"
32
32
  },
33
33
  "license": "MIT",