@stagepass/loader 2.5.0 → 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,16 +12,24 @@ npm install @stagepass/loader@2
12
12
 
13
13
  ## CDN Usage
14
14
 
15
- Prefer the major pin `@2` in production on jsDelivr. Stagepass follows strict semver: no breaking changes within v2; breaking changes only in a new major (v3). Exact pins (e.g. `@2.4.0`) are optional for maximum control. jsDelivr may cache `@2` for a while; purge with `https://purge.jsdelivr.net/npm/@stagepass/loader@2/dist/loader.min.js`. See [Version pinning](https://github.com/arobertherz/stagepass/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.jsdelivr.net/npm/@stagepass/loader@2/dist/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
- unpkg serves the same paths if you need an alternative CDN. Always embed the full `/dist/loader.min.js` path (not a short package URL that redirects); otherwise session chunks resolve from the wrong folder. Or set `data-stagepass-flag-base`.
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`.
25
33
 
26
34
  ## Known limits (scoped acceptance)
27
35
 
@@ -29,7 +37,7 @@ Acceptance for `live.min.js` / live reload is **scoped localhost only**. It is n
29
37
 
30
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.
31
39
 
32
- `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.
33
41
 
34
42
  See [MIGRATION.md](../../MIGRATION.md) for breaking changes from 1.x.
35
43
 
@@ -68,8 +76,8 @@ See [MIGRATION.md](../../MIGRATION.md) for breaking changes from 1.x.
68
76
  | `data-src` / `data-href` | Production URL for legacy mode (default). Required unless live-src opt-in uses native `src` / `href`. |
69
77
  | `data-stagepass-path` | Local path under the linked project root (optional). |
70
78
  | `data-stagepass-v` | Per-asset production `?v=<version>` (overrides loader `data-stagepass-version`). |
71
- | `data-stagepass-nocache` | 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. |
72
- | `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. |
73
81
  | `data-stagepass-processed` | Internal; set after processing. |
74
82
 
75
83
  ## URL Modes
@@ -84,6 +92,10 @@ After handling, `?stagepass=` is removed with `history.replaceState` (other quer
84
92
 
85
93
  Storage key: `localStorage.stagepass_domain` → JSON `{ "domain": "…", "expires": <ms> }`. Legacy plain-string values are cleared.
86
94
 
95
+ ## Privacy / storage
96
+
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.
98
+
87
99
  ## Dev flag
88
100
 
89
101
  Shown only while a session is active (including debug).
@@ -107,26 +119,29 @@ Shown only while a session is active (including debug).
107
119
 
108
120
  ## Zero-cost production mode
109
121
 
110
- 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.
111
123
 
112
124
  ## Permanent per-asset cache busting
113
125
 
114
- `data-stagepass-nocache` 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.
115
127
 
116
128
  ```html
117
129
  <script
118
130
  data-stagepass
119
- 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"
120
133
  data-stagepass-nocache
121
134
  ></script>
135
+ <!-- production URL becomes:
136
+ https://cdn.example.com/js/forms-embed.js?foo=1&v=2.5.1&_cb=<timestamp>#_section -->
122
137
  ```
123
138
 
124
139
  - Boolean attribute: present (any value, including empty) or `="true"` turns it on; `="false"` turns it off (same as omitting it).
125
140
  - Scoped to exactly that asset. All other `data-stagepass` assets keep the existing version-only cache strategy.
126
- - 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.
127
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.
128
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.
129
- - `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.
130
145
 
131
146
  ## Runtime API
132
147
 
@@ -174,4 +189,4 @@ With an active session (or debug), the loader warns when two tagged assets resol
174
189
 
175
190
  ## Repository
176
191
 
177
- - 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
@@ -190,14 +190,16 @@ var Stagepass = (() => {
190
190
  return { preferred: v || "no-preference", current: v || "unknown" };
191
191
  }
192
192
  function hasStorage(type) {
193
+ const cache = hasStorage;
194
+ if (type in cache) return cache[type];
193
195
  try {
194
196
  const storage = window[type];
195
197
  const key = "__stagepass_test__";
196
198
  storage.setItem(key, "1");
197
199
  storage.removeItem(key);
198
- return true;
200
+ return cache[type] = true;
199
201
  } catch (_) {
200
- return false;
202
+ return cache[type] = false;
201
203
  }
202
204
  }
203
205
  function hasServiceWorker() {
@@ -230,8 +232,13 @@ var Stagepass = (() => {
230
232
  },
231
233
  capabilities: {
232
234
  cookiesEnabled: navigator.cookieEnabled === true,
233
- localStorage: hasStorage("localStorage"),
234
- sessionStorage: hasStorage("sessionStorage")
235
+ // First read probes. `can()` hits the same getter, so the result is shared.
236
+ get localStorage() {
237
+ return hasStorage("localStorage");
238
+ },
239
+ get sessionStorage() {
240
+ return hasStorage("sessionStorage");
241
+ }
235
242
  }
236
243
  };
237
244
  }
@@ -297,7 +304,7 @@ var Stagepass = (() => {
297
304
  const W = window;
298
305
  const d = document;
299
306
  const loc = location;
300
- const PKG_VERSION = true ? "2.5.0" : "0.0.0";
307
+ const PKG_VERSION = true ? "2.5.2" : "0.0.0";
301
308
  const LOADER_RE = /loader(?:\.min)?\.js/i;
302
309
  function flagBase(v, file) {
303
310
  if (typeof v !== "string" || !(v = v.trim())) return null;
@@ -570,7 +577,9 @@ var Stagepass = (() => {
570
577
  const opt = attr("flag-base") ?? W.stagepassFlagBase;
571
578
  let base = flagBase(opt, false);
572
579
  if (opt != null && !base) spWarn("Ignored flag base (http(s) or relative only): " + cut(String(opt), 99));
573
- 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));
574
583
  if (!base) {
575
584
  base = `https://cdn.jsdelivr.net/npm/@stagepass/loader@${PKG_VERSION}/dist/`;
576
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 Le="stagepass_domain",V=12;function $e(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 Oe(t,s=V,o=Date.now()){let c=Number.isFinite(s)&&s>0?s:V;return{domain:t,expires:o+c*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 c=encodeURIComponent(o),p=t.indexOf("#"),b=p>=0?t.slice(p):"",v=p>=0?t.slice(0,p):t;s==="_cb"&&(v=v.replace(/\?.*/,j=>j.replace(/[&?]_cb(=[^&]*)?(?=&|$)/g,"").replace(/^&/,"?")));let $=v.includes("?")?"&":"?";return`${v}${$}${encodeURIComponent(s)}=${c}${b}`}function q(t,s,o){let c=s.startsWith("/")?s.slice(1):s;return`https://${t}/${c}?_cb=${o}`}async function Ce(){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 c=await t.query({name:o}),p=c&&c.state;if(p==="granted"||p==="prompt"||p==="denied")return p}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 Ne(t,s){let o=s.hasAttribute("async"),c=s.hasAttribute("defer");o?t.async=!0:(t.async=!1,c||(t.defer=!0))}var B="data-stagepass-nocache";function je(t){return t.hasAttribute(B)?t.getAttribute(B)!=="false":!1}function Fe(t){return!t||typeof t!="string"?[]:t.split(",").map(s=>s.trim().toLowerCase()).filter(Boolean)}function Te(t,s,o=[]){if(s&&s.endsWith(".sp"))return"local";let c=(t||"").toLowerCase();return c.endsWith(".webflow.io")||o.some(p=>p===c)?"staging":"production"}function Me(t){return!t||typeof t!="string"?!1:/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(t)}function Pe(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 c=t.match(o);if(c)return{family:s,major:Number(c[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 ie(){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 De(t){try{let s=window[t],o="__stagepass_test__";return s.setItem(o,"1"),s.removeItem(o),!0}catch{return!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:ie(),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,localStorage:De("localStorage"),sessionStorage:De("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),c=new Map;function p(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),c.set(b,v),!0}catch(k){return s(`Module "${b}" failed to register:`,k),!1}}return{use:p,registered:c}}(function(){let t=Le,s="stagepass",o=window,c=document,p=location,b="2.5.0",v=/loader(?:\.min)?\.js/i;function $(e,n){if(typeof e!="string"||!(e=e.trim()))return null;try{let r=new URL(e,c.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(c.currentScript instanceof HTMLScriptElement)return c.currentScript}catch{}try{let e=c.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"),ce=Fe(k("staging-hosts")),O=k("alias"),le=k("live-src")==="true",H=new URLSearchParams(p.search),_=!1,A={n:[0,0],m:[],f:[],swapped:0,v:b,vd:N},F=null,ue=()=>F&&F(),fe=()=>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,de=(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 i=Object.keys(e),a=i.slice(0,20).map(l=>(r?"":l+": ")+de(e[l],n+1));return i.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 i=n;i<r.length;i++){let a=r[i].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",I=(e,n,r="",i="",a="",l="",u)=>{A.n[e]++;let f=A.m,m={type:e?"error":"warn",time:fe(),src:u||(r?Ge(r):""),file:W(r),url:r.split(/[?#]/)[0],line:i?String(i):"",col:a?String(a):"",text:z(n,500),stack:z(l,2e3),c:1},S=d=>d.type+d.text+d.url+d.line+d.col;for(let d=f.length-1;d>=0;d--)if(S(f[d])===S(m)){m.c=f[d].c+1,f.splice(d,1);break}f.push(m),f.length>50&&f.shift(),ue()},J=(e,n,r,i)=>{let a=r.find(f=>f instanceof Error),l=a&&a.stack||"",u=G(l)||i;I(e,n+r.map(f=>de(f)).join(" "),u?u[0]:"",u?u[1]:"",u?u[2]:"",l)},T=!1,Je=e=>{T=!0;try{e()}catch{}T=!1};function R(e,...n){if(!_)return;let r=G(new Error().stack||"",3);(e==="warn"||e==="error")&&J(e==="warn"?0:1,"",n,r),Je(()=>{let i=`[\u{1F3AB} ${fe()}${r?" | "+W(r[0])+":"+r[1]:""}]`,a=console;e==="error"?a.log(`%c${i}`,"color:red;font-weight:bold",...n):a[e]?a[e](i,...n):a.log(i,e,...n)})}function Ke(...e){let n=e[0]==="warn"||e[0]==="error"?e.shift():"log";R(n,...e)}let M=(...e)=>R("warn",...e),pe=(...e)=>R("error",...e),K=(e,n)=>{let r=_;_=!0,R(e,n),_=r};function Ze(){try{let e=localStorage.getItem(t),n=$e(e);return!n&&e&&localStorage.removeItem(t),n?n.domain:null}catch{return null}}function Z(){try{localStorage.removeItem(t)}catch{}}let ge=!1,y=Ze();if(H.has(s)){let e=H.get(s);if(e==="off"||e==="0"||e==="false")Z(),y=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(Oe(n,qe)))}catch{}y=n,ge=!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({},"",p.pathname+(n?`?${n}`:"")+p.hash)}catch{}}y&&!N(y)&&(Z(),y=null);let P=y==="debug";_=!!y,y&&!ge&&!P&&R("log",`\u{1F50C} Stagepass connected to: ${y}`);let me=!!y,w=me&&!P;h=w?se(y):null;let Q=w?Date.now():0,L=p.hostname,Qe=L==="localhost"||L==="127.0.0.1"||L.startsWith("localhost:")||L.startsWith("127.0.0.1:"),he=w||Qe,be=he?"local":L.endsWith(".webflow.io")||ce.includes(L.toLowerCase())?"staging":"production";if(Ve&&be==="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{}}),C=He();try{let e=()=>Y("theme",{...Object.assign(C.theme,ie())});["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=C.viewport;e.width=o.innerWidth||0,e.height=o.innerHeight||0,e.dpr=o.devicePixelRatio||1});let g=o.stagepass||{},Ye=Ue(b,M),Se=Object.freeze({isLocal:he,env:be,domain:h||L,timestamp:Q,version:b,client:C});if(g.vars=Se,g.log=Ke,g.warn=M,g.error=pe,g.resolveLocalUrl=e=>w&&h&&e?q(h,e,Se.timestamp||Date.now()):"",g.env=()=>Te(L,h,ce),g.is=e=>g.env()===e,g.can=e=>We(C,e),g.client=e=>e==null||e===""?C:C[e],g.on=(e,n)=>{let r=ye[e];return!r||e!=="theme"&&e!=="session"?()=>{}:(r.add(n),()=>{r.delete(n)})},g.use=(e,n,r)=>Ye.use(e,n,r,g),o.stagepass=o.sp=g,globalThis.stagepass=globalThis.sp=g,O&&Me(O)&&O!=="sp"&&O!=="stagepass"&&[o,globalThis].forEach(e=>{Pe(e,O)&&(e[O]=g)}),me)try{let e=Symbol.for("stagepass.flag.v2"),n=k("flag-base")??o.stagepassFlagBase,r=$(n,!1);n!=null&&!r&&M("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/`,P&&M("Loader URL unknown, flag loads from "+r+". Set data-stagepass-flag-base")),Object.assign(A,{debug:P,domain:h,card:r+"flag-card.min.js",end:()=>{Z(),_=!0,R("log","\u{1F50C} Stagepass disconnected."),Y("session",{active:!1,domain:null,swap:!1,debug:!1}),p.reload()}}),Object.defineProperty(g,e,{configurable:!0,value:l=>{delete g[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"?ve.has(u)||I(1,"Failed to load "+f.split(/[?#]/)[0],f):/^Script error\.?$/.test(l.message||"")&&!l.filename?I(1,"Error in a cross-origin script (details only in DevTools console)","","","","","external"):I(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 i=console;["warn","error"].forEach((l,u)=>{let f=i[l];typeof f=="function"&&(i[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=c.createElement("script");a.src=r+"flag.min.js",a.async=!0,a.onerror=()=>M("Stagepass flag could not be loaded: "+a.src),(c.head||c.documentElement).appendChild(a)}catch{}Y("session",{active:_,domain:y,swap:w,debug:P});function Xe(e,n,r){if(w&&r&&h)return q(h,r,Q);let i=e.getAttribute("data-stagepass-v")||Be,a=i?oe(n,"v",i):n;return je(e)&&(a=oe(a,"_cb",Date.now())),a}function we(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 ve=new WeakSet,X="";function ke(e,n,r,i,a,l){let u={live:n,local:r,type:i?"js":"css",st:""};l&&(u.x=!0);let f=W(r);ve.add(e),A.f.push(u),e.addEventListener("load",()=>{u.st="ok",A.swapped++,ue()}),e.addEventListener("error",()=>{let m=(d,re,U)=>{u.st=d,I(re,U,r)},S=o.fetch;if(typeof S!="function")return m("failed",1,`Failed to load ${f}`);S(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}`),()=>S(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)),I(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])',Ee="onbeforescriptexecute"in c;function xe(e){try{let n=e.tagName==="SCRIPT";if(n&&(Ee||c.currentScript===e))return;let r=n?"src":"href",i=e.getAttribute(r);if(!i)return;e.setAttribute("data-stagepass-processed","true");let a=e.getAttribute("data-stagepass-path"),l=a||we(i);if(!l)return;let u=q(h,l,Q);e.removeAttribute("integrity"),e.hasAttribute("crossorigin")||e.setAttribute("crossorigin","anonymous"),e[r]=u,ke(e,i,u,n,null,!!a)}catch{}}let te=e=>{try{e.matches&&e.matches(ee)&&xe(e),e.querySelectorAll(ee).forEach(xe)}catch{}};function ne(e,n,r){c.querySelectorAll(`${e}:not([data-stagepass-processed])`).forEach(i=>{try{let a=i.getAttribute("data-stagepass-path"),l=!!a,u=i.getAttribute(n);if(!u)return;i.setAttribute("data-stagepass-processed","true"),!a&&w&&h&&(a=we(u));let f=Xe(i,u,a);if(!f)return;let m=w&&a&&h,S=r==="script",d=U=>{let E=c.createElement(r);U&&(E.crossOrigin="anonymous"),S?E.src=f:(E.rel="stylesheet",E.href=f);for(let D of Array.from(i.attributes))D.name!==n&&!et.includes(D.name)&&D.name!==(S?"src":"href")&&E.setAttribute(D.name,D.value);return m&&E.removeAttribute("integrity"),S&&Ne(E,i),m&&ke(E,u,f,S,U?d:null,l),E},re=d(!!m&&!i.hasAttribute("crossorigin"));i.parentNode?(i.parentNode.insertBefore(re,i),i.remove()):pe(`${r} injection failed: No parent node`)}catch{}})}if(w&&le)try{new MutationObserver(e=>{for(let n of e)for(let r of n.addedNodes)r.nodeType===1&&te(r)}).observe(c.documentElement,{childList:!0,subtree:!0}),Ee&&c.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(c)}catch{}let tt=()=>{try{ne("script[data-stagepass]","data-src","script"),ne('link[rel="stylesheet"][data-stagepass]',"data-href","link"),w&&le&&te(c),F&&F()}catch{}},_e=null,nt=()=>_e=_e||(w?Ce().then(e=>{X=e}).catch(()=>{}):Promise.resolve()),Ae=()=>{nt().then(tt)};Ae(),c.readyState==="loading"&&c.addEventListener("DOMContentLoaded",Ae)})();})();
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.0",
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",