@stagepass/modules 2.1.0 → 2.2.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
@@ -16,12 +16,12 @@ Without the loader, `inject` and `cookies` still attach their APIs and warn; `ma
16
16
 
17
17
  ## CDN Usage
18
18
 
19
- 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.1.0`) are optional for maximum control. jsDelivr may cache `@2` for a while; purge with the same pattern as the loader (see root README [Version pinning](../../README.md#-version-pinning)).
19
+ 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.2.0`) are optional for maximum control. jsDelivr may cache `@2` for a while; purge with the same pattern as the loader (see root README [Version pinning](../../README.md#-version-pinning)).
20
20
 
21
21
  ```html
22
22
  <script
23
23
  src="https://cdn.jsdelivr.net/npm/@stagepass/loader@2/dist/loader.min.js"
24
- data-stagepass-version="2.1.0"
24
+ data-stagepass-version="2.2.0"
25
25
  ></script>
26
26
  <script src="https://cdn.jsdelivr.net/npm/@stagepass/modules@2/dist/inject.min.js"></script>
27
27
  <script src="https://cdn.jsdelivr.net/npm/@stagepass/modules@2/dist/cookies.min.js"></script>
@@ -75,7 +75,7 @@ await sp.inject({
75
75
  | :--- | :--- |
76
76
  | `src` | Required production URL. |
77
77
  | `type` | `'script'` \| `'style'` (default: `.css` → style, else script). |
78
- | `stagepass` | When not `false` and `sp.vars.isLocal`, resolve a local URL via `sp.resolveLocalUrl` (fallback `https://<domain>/<path>?_cb=<timestamp>`). |
78
+ | `stagepass` | When not `false` and `sp.vars.isLocal`, use `sp.resolveLocalUrl` only if it returns a non-empty URL; otherwise keep the production `src` (plus optional `version` / `?v=`). |
79
79
  | `localPath` / `path` | Local path under the linked root (default: filename from `src`). |
80
80
  | `id` | Element id; skips inject if already present. |
81
81
  | `async` | If `true`, set `script.async = true`; otherwise `async = false` and keep order. |
@@ -161,7 +161,20 @@ sp.maintenance.disable();
161
161
 
162
162
  ## Types
163
163
 
164
- `global.d.ts` extends `@stagepass/loader` via declaration merging (`inject`, `cookies` / `cookie`, `consent`, `maintenance`).
164
+ The modules extend `@stagepass/loader` via declaration merging. Use one entry per module your site actually loads, so an AI assistant or teammate cannot call a module that is not there:
165
+
166
+ ```json
167
+ { "compilerOptions": { "types": ["@stagepass/loader", "@stagepass/modules/cookies"] } }
168
+ ```
169
+
170
+ | Entry | Adds |
171
+ | :--- | :--- |
172
+ | `@stagepass/modules/inject` | `sp.inject` |
173
+ | `@stagepass/modules/cookies` | `sp.cookies` / `sp.cookie`, `sp.consent` |
174
+ | `@stagepass/modules/maintenance` | `sp.maintenance` |
175
+ | `@stagepass/modules` | all of the above (unchanged since 2.0) |
176
+
177
+ Module members are optional (`sp.cookies?`), because a page may not load the file; guard calls (`if (sp.cookies) …`). `stagepass new` / `stagepass upgrade` set these entries from `stagepass.json` `modules`.
165
178
 
166
179
  ## Repository
167
180
 
package/cookies.d.ts ADDED
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Types for the Stagepass `cookies` module (`@stagepass/modules/dist/cookies.min.js`).
3
+ *
4
+ * Enable per project in tsconfig/jsconfig: `"types": ["@stagepass/loader", "@stagepass/modules/cookies"]`.
5
+ * Only list modules whose script tag is actually on the Webflow site.
6
+ */
7
+ import '@stagepass/loader';
8
+
9
+ export interface StagepassCookieWriteOptions {
10
+ days?: number;
11
+ maxAge?: number;
12
+ path?: string;
13
+ domain?: string;
14
+ secure?: boolean;
15
+ sameSite?: 'Lax' | 'Strict' | 'None';
16
+ encode?: boolean;
17
+ json?: boolean;
18
+ /** Optional category for consent gating / throwAll filtering. */
19
+ category?: string;
20
+ }
21
+
22
+ export interface StagepassCookiesAPI {
23
+ /** Write a cookie. */
24
+ bake: (name: string, value: unknown, options?: StagepassCookieWriteOptions) => void;
25
+ /** Read a cookie. */
26
+ eat: (name: string, options?: Record<string, unknown>) => unknown;
27
+ /** Delete a cookie. */
28
+ throw: (name: string, options?: Record<string, unknown>) => void;
29
+ /** Whether a cookie exists. */
30
+ has: (name: string) => boolean;
31
+ /** List cookies as a name → value map. */
32
+ list: (options?: Record<string, unknown>) => Record<string, unknown>;
33
+ /** Delete known cookies, optionally by category. */
34
+ throwAll: (options?: { category?: string }) => void;
35
+ /** Shallow copy of cookies known to this helper. */
36
+ jar: () => Record<string, unknown>;
37
+ /** Known cookie names starting with `prefix`. */
38
+ crumbs: (prefix: string) => string[];
39
+ }
40
+
41
+ /**
42
+ * Tiny consent hook used by categorized `bake`.
43
+ * Tooling helper only: not a legal compliance solution.
44
+ */
45
+ export interface StagepassConsentAPI {
46
+ allows: (category: string) => boolean;
47
+ set: (fn: (category: string) => boolean) => void;
48
+ /** Flush queued cookies against the current consent function. */
49
+ update: () => void;
50
+ }
51
+
52
+ declare module '@stagepass/loader' {
53
+ interface StagepassAPI {
54
+ /**
55
+ * Cookie helpers (`cookies` module).
56
+ * @example
57
+ * if (sp.cookies) sp.cookies.bake('visited', '1', { days: 30 });
58
+ */
59
+ cookies?: StagepassCookiesAPI;
60
+ /** Singular alias of `cookies` (`cookies` module). */
61
+ cookie?: StagepassCookiesAPI;
62
+ /**
63
+ * Consent hook for categorized cookies (`cookies` module).
64
+ * Documented as a tool, not legal compliance.
65
+ * @example
66
+ * if (sp.consent) { sp.consent.set((c) => c === 'necessary'); sp.consent.update(); }
67
+ */
68
+ consent?: StagepassConsentAPI;
69
+ }
70
+ }
package/dist/all.min.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var StagepassModules=(()=>{(function(){function b(){let e=window.stagepass||globalThis.stagepass||window.sp||globalThis.sp;return e||null}function x(){try{console.warn("[Stagepass] Core loader should be loaded before the inject module.")}catch{}}function S(){let e=b();if(!e||!e.vars)throw new Error("Stagepass core loader must be loaded before modules");return e.vars}let j=new Set(["src","href","rel","integrity","crossorigin","nonce"]);function E(e){try{let n=S();(n.env==="local"||n.env==="staging")&&console.log(`[Stagepass] ${e}`)}catch{}}function A(e){try{let n=b();if(n&&typeof n.warn=="function"){n.warn(e);return}}catch{}try{console.warn(`[Stagepass] ${e}`)}catch{}}function L(e){if(!e||typeof e!="string")return"file";try{let s=new URL(e).pathname||"";if(!s||s.length===0){let p=e.match(/\/([^\/\?#]+)(?:\?|#|$)/);return p?p[1]:"file"}let a=s.split("/");return a[a.length-1]||a[a.length-2]||"file"}catch{try{let s=e.match(/\/([^\/\?#]+)(?:\?|#|$)/);return s?s[1]:"file"}catch{return"file"}}}function I(e,n){if(n)return n;if(!e||typeof e!="string")return"script";try{if(e.split(".").pop()?.toLowerCase()==="css")return"style"}catch{}return"script"}function T(e,n,s){let a=encodeURIComponent(s),p=e.indexOf("#"),t=p>=0?e.slice(p):"",o=p>=0?e.slice(0,p):e,r=o.includes("?")?"&":"?";return`${o}${r}${encodeURIComponent(n)}=${a}${t}`}function f(e,n){if(!n||n.length===0)return!0;try{let s=new URL(e,window.location.href).hostname.toLowerCase();return n.map(p=>String(p).toLowerCase()).includes(s)}catch{return!1}}function m(e){let n=S(),{src:s,stagepass:a,localPath:p,path:t,version:o}=e;if(!s||typeof s!="string")throw new Error("Invalid src: must be a non-empty string");if(a!==!1&&n.isLocal){let r=p||t||L(s);if(!r||typeof r!="string")return s;let i=r.startsWith("/")?r.substring(1):r,c=b();if(c&&typeof c.resolveLocalUrl=="function"){let y=c.resolveLocalUrl(i);if(y)return y}return`https://${n.domain}/${i}?_cb=${n.timestamp}`}return o?T(s,"v",o):s}function w(e,n){let{id:s,type:a}=e,p=I(e.src,a);if(s&&document.getElementById(s))return E(`Skipping injection: Element with id "${s}" already exists`),!0;if(p==="script"){let t=document.getElementsByTagName("script");for(let o=0;o<t.length;o++)if(t[o].getAttribute("src")===n)return E(`Skipping injection: Resource "${n}" already loaded`),!0}else{let t=document.getElementsByTagName("link");for(let o=0;o<t.length;o++)if(t[o].getAttribute("href")===n)return E(`Skipping injection: Resource "${n}" already loaded`),!0}return!1}function O(e="body-end"){if(typeof e=="string")switch(e){case"head":return document.head;case"body-start":return document.body?.firstChild||document.body;case"body-end":return document.body;default:return document.body}let{target:n,action:s}=e,a=document.querySelector(n);return a?s==="before"?a:a.nextSibling||a.parentNode:(E(`Warning: Target selector "${n}" not found, falling back to body-end`),document.body)}function k(e,n){n.integrity&&e.setAttribute("integrity",n.integrity),n.crossorigin&&e.setAttribute("crossorigin",n.crossorigin),n.nonce&&e.setAttribute("nonce",n.nonce)}function $(e){return new Promise((n,s)=>{if(!e.src){let i=S(),c=new Error('InjectOptions must have a "src" property');i.env!=="production"&&console.error("[Stagepass]",c),s(c);return}if(!f(e.src,e.allowedHosts)){A(`inject: host not allowed for "${e.src}". Check allowedHosts.`),n();return}let a=S(),p=I(e.src,e.type),t=m(e);if(w(e,t)){n();return}let o=p==="script"?document.createElement("script"):document.createElement("link");if(p==="script"){let i=o;e.async?i.async=!0:(i.async=!1,e.defer!==!1&&(i.defer=!0)),e.id&&(i.id=e.id),e.attributes&&Object.entries(e.attributes).forEach(([c,y])=>{j.has(String(c).toLowerCase())||i.setAttribute(c,y)}),i.src=t,k(i,e),i.onload=()=>{E(`Injected: ${t}`),n()},i.onerror=()=>{let c=new Error(`Failed to load script: ${t}`);a.env!=="production"&&console.error("[Stagepass]",c),s(c)}}else{let i=o;e.id&&(i.id=e.id),e.attributes&&Object.entries(e.attributes).forEach(([y,h])=>{j.has(String(y).toLowerCase())||i.setAttribute(y,h)}),i.rel="stylesheet",i.href=t,k(i,e);let c=setInterval(()=>{(i.sheet||i.styleSheet)&&(clearInterval(c),E(`Injected: ${t}`),n())},10);setTimeout(()=>{if(clearInterval(c),!(i.sheet||i.styleSheet)){let h=new Error(`Failed to load stylesheet: ${t}`);a.env!=="production"&&console.error("[Stagepass]",h),s(h)}},5e3)}let r=O(e.position);if(!r){s(new Error("Could not find insertion point"));return}if(r===document.head||r===document.body)r.appendChild(o);else{let i=r.parentNode;i&&(typeof e.position=="object"&&e.position.action==="before"?i.insertBefore(o,r):i.insertBefore(o,r.nextSibling))}})}async function u(e){let n=[];if(!Array.isArray(e)&&typeof e=="object"&&("scripts"in e||"styles"in e)){let s=e;s.scripts&&n.push(...s.scripts.filter(a=>a&&typeof a=="object"&&"src"in a&&typeof a.src=="string"&&a.src.trim().length>0).map(a=>({...a,type:"script"}))),s.styles&&n.push(...s.styles.filter(a=>a&&typeof a=="object"&&"src"in a&&typeof a.src=="string"&&a.src.trim().length>0).map(a=>({...a,type:"style"})))}else Array.isArray(e)?n=e.filter(s=>s&&typeof s=="object"&&"src"in s&&typeof s.src=="string"&&s.src.trim().length>0):e&&typeof e=="object"&&"src"in e&&typeof e.src=="string"&&e.src.trim().length>0&&(n=[e]);for(let s of n)try{await $(s)}catch(a){try{S().env!=="production"&&console.error("[Stagepass] Injection error:",a)}catch{}}}function d(e){e.inject=u}let l=b()||{};l.vars||x(),l.vars&&typeof l.use=="function"?l.use("inject","2.0.0",d):d(l),window.stagepass=l,globalThis.stagepass=l,window.sp=l,globalThis.sp=l})();(function(){function b(){let f=window.stagepass||globalThis.stagepass||window.sp||globalThis.sp;return f||null}function x(){try{console.warn("[Stagepass] Core loader should be loaded before the cookies module.")}catch{}}function S(f,m){if(!(m==null||m==="")&&/[;\r\n]/.test(m))throw new Error(`Invalid cookie ${f}`)}function j(){return window.location.protocol==="https:"}function E(f){try{return decodeURIComponent(f)}catch{return f}}function A(f,m){let O=m.decode!==!1?E(f):f;if(!m.json)return O;try{return JSON.parse(O)}catch{return O}}function L(f){let m=new Map,w=[],O=()=>!0;function k(t,o,r={}){if(!t||typeof t!="string"||t.includes(";")||/[\r\n]/.test(t))throw new Error("Invalid cookie name");let i=r.encode!==!1,c=r.sameSite||"Lax";S("sameSite",c);let y=r.secure!==void 0?r.secure:j(),h=r.path||"/";S("path",h),S("domain",r.domain);let v=r.json?JSON.stringify(o):String(o);i||(S("value",v),S("name",t));let _=i?encodeURIComponent(t):t;v=i?encodeURIComponent(v):v;let C=[`${_}=${v}`];if(typeof r.maxAge=="number"&&C.push(`Max-Age=${Math.floor(r.maxAge)}`),typeof r.days=="number"){let M=new Date(Date.now()+r.days*24*60*60*1e3);C.push(`Expires=${M.toUTCString()}`)}h&&C.push(`Path=${h}`),r.domain&&C.push(`Domain=${r.domain}`),C.push(`SameSite=${c}`);let R=y;c==="None"&&!R&&(R=!0,typeof f.warn=="function"&&f.warn("SameSite=None requires Secure=true. Enforcing Secure for cookie write.")),R&&C.push("Secure"),document.cookie=C.join("; ")}function $(t,o,r={}){let i=r.category,c={name:t,value:o,options:{...r},category:i};if(i&&!O(i)){let h=w.findIndex(v=>v.name===t);h>=0&&w.splice(h,1),w.push(c),m.set(t,c);return}k(t,o,r),m.set(t,c);let y=w.findIndex(h=>h.name===t);y>=0&&w.splice(y,1)}function u(t,o={}){if(!t||typeof t!="string")return null;let r=o.decode===!1?t:E(t),i=document.cookie?document.cookie.split("; "):[];for(let c of i){let y=c.indexOf("=");if(y<0)continue;let h=c.substring(0,y),v=c.substring(y+1),_=E(h);if(h===r||_===r)return A(v,o)}return null}function d(t){return u(t)!==null}function l(t={}){let o=document.cookie?document.cookie.split("; "):[],r={};for(let i of o){let c=i.indexOf("=");if(c<0)continue;let y=i.substring(0,c),h=i.substring(c+1),v=t.decode===!1?y:E(y);r[v]=A(h,t)}return r}function g(t,o={}){k(t,"",{days:-1,maxAge:0,path:o.path||"/",domain:o.domain,secure:o.secure,sameSite:o.sameSite}),m.delete(t);let r=w.findIndex(i=>i.name===t);r>=0&&w.splice(r,1)}function e(t={}){let o=t.category,r=[];m.forEach((i,c)=>{(!o||i.category===o)&&r.push(c)});for(let i of r){let c=m.get(i);g(i,{path:c?.options.path,domain:c?.options.domain,secure:c?.options.secure,sameSite:c?.options.sameSite})}}function n(){let t={};return m.forEach((o,r)=>{t[r]=o.value}),t}function s(t){let o=t==null?"":String(t),r=[];return m.forEach((i,c)=>{c.startsWith(o)&&r.push(c)}),r}let a={bake:$,eat:u,throw:g,has:d,list:l,throwAll:e,jar:n,crumbs:s},p={allows(t){try{return O(t)===!0}catch{return!1}},set(t){typeof t=="function"&&(O=t)},update(){let t=w.splice(0,w.length);for(let o of t)!o.category||O(o.category)?$(o.name,o.value,o.options):w.push(o)}};f.cookies=a,f.cookie=a,f.consent=p}let I=b()||{};I.vars||x(),I.vars&&typeof I.use=="function"?I.use("cookies","2.0.0",L):L(I),window.stagepass=I,globalThis.stagepass=I,window.sp=I,globalThis.sp=I})();(function(){let b="stagepass-maintenance-overlay",x="stagepass-maintenance-badge",S="stagepass-maintenance-style",j="We will be back soon",E="This site is temporarily unavailable while we perform maintenance.";function A(){let u=window.stagepass||globalThis.stagepass||window.sp||globalThis.sp;if(!u||!u.vars){try{console.warn("[Stagepass] Core loader must be loaded before the maintenance module. Skipping registration.")}catch{}return null}return u}function L(){try{if(document.currentScript instanceof HTMLScriptElement)return document.currentScript}catch{}try{let u=document.querySelectorAll('script[src*="maintenance"]');for(let l=u.length-1;l>=0;l--){let g=u[l];if(/maintenance(?:\.min)?\.js/i.test(g.src||""))return g}let d=document.querySelectorAll('script[src*="all"]');for(let l=d.length-1;l>=0;l--){let g=d[l];if(/all(?:\.min)?\.js/i.test(g.src||"")&&g.hasAttribute("data-stagepass-maintenance"))return g}}catch{}return null}function I(u){try{if(typeof u.is=="function"&&u.is("local"))return!0}catch{}try{let d=localStorage.getItem("stagepass_domain");if(!d)return!1;if(d.startsWith("{")){let l=JSON.parse(d),g=l&&l.domain;if(g==="debug"||typeof g=="string"&&g.endsWith(".sp")||g==="localhost"||typeof g=="string"&&g.startsWith("localhost:"))return!0}}catch{}return!1}function T(){if(document.getElementById(S))return;let u=document.createElement("style");u.id=S,u.textContent=`
1
+ "use strict";var StagepassModules=(()=>{(function(){function b(){let e=window.stagepass||globalThis.stagepass||window.sp||globalThis.sp;return e||null}function x(){try{console.warn("[Stagepass] Core loader should be loaded before the inject module.")}catch{}}function S(){let e=b();if(!e||!e.vars)throw new Error("Stagepass core loader must be loaded before modules");return e.vars}let j=new Set(["src","href","rel","integrity","crossorigin","nonce"]);function E(e){try{let n=S();(n.env==="local"||n.env==="staging")&&console.log(`[Stagepass] ${e}`)}catch{}}function A(e){try{let n=b();if(n&&typeof n.warn=="function"){n.warn(e);return}}catch{}try{console.warn(`[Stagepass] ${e}`)}catch{}}function L(e){if(!e||typeof e!="string")return"file";try{let r=new URL(e).pathname||"";if(!r||r.length===0){let p=e.match(/\/([^\/\?#]+)(?:\?|#|$)/);return p?p[1]:"file"}let a=r.split("/");return a[a.length-1]||a[a.length-2]||"file"}catch{try{let r=e.match(/\/([^\/\?#]+)(?:\?|#|$)/);return r?r[1]:"file"}catch{return"file"}}}function I(e,n){if(n)return n;if(!e||typeof e!="string")return"script";try{if(e.split(".").pop()?.toLowerCase()==="css")return"style"}catch{}return"script"}function T(e,n,r){let a=encodeURIComponent(r),p=e.indexOf("#"),t=p>=0?e.slice(p):"",s=p>=0?e.slice(0,p):e,o=s.includes("?")?"&":"?";return`${s}${o}${encodeURIComponent(n)}=${a}${t}`}function f(e,n){if(!n||n.length===0)return!0;try{let r=new URL(e,window.location.href).hostname.toLowerCase();return n.map(p=>String(p).toLowerCase()).includes(r)}catch{return!1}}function m(e){let n=S(),{src:r,stagepass:a,localPath:p,path:t,version:s}=e;if(!r||typeof r!="string")throw new Error("Invalid src: must be a non-empty string");if(a!==!1&&n.isLocal){let o=p||t||L(r);if(!o||typeof o!="string")return r;let i=o.startsWith("/")?o.substring(1):o,c=b();if(c&&typeof c.resolveLocalUrl=="function"){let y=c.resolveLocalUrl(i);if(y)return y}}return s?T(r,"v",s):r}function w(e,n){let{id:r,type:a}=e,p=I(e.src,a);if(r&&document.getElementById(r))return E(`Skipping injection: Element with id "${r}" already exists`),!0;if(p==="script"){let t=document.getElementsByTagName("script");for(let s=0;s<t.length;s++)if(t[s].getAttribute("src")===n)return E(`Skipping injection: Resource "${n}" already loaded`),!0}else{let t=document.getElementsByTagName("link");for(let s=0;s<t.length;s++)if(t[s].getAttribute("href")===n)return E(`Skipping injection: Resource "${n}" already loaded`),!0}return!1}function O(e="body-end"){if(typeof e=="string")return e==="head"?document.head:document.body;let{target:n,action:r}=e,a=document.querySelector(n);return a?r==="before"?a:a.nextSibling||a.parentNode:(E(`Warning: Target selector "${n}" not found, falling back to body-end`),document.body)}function k(e,n){n.integrity&&e.setAttribute("integrity",n.integrity),n.crossorigin&&e.setAttribute("crossorigin",n.crossorigin),n.nonce&&e.setAttribute("nonce",n.nonce)}function $(e){return new Promise((n,r)=>{if(!e.src){let i=S(),c=new Error('InjectOptions must have a "src" property');i.env!=="production"&&console.error("[Stagepass]",c),r(c);return}if(!f(e.src,e.allowedHosts)){A(`inject: host not allowed for "${e.src}". Check allowedHosts.`),n();return}let a=S(),p=I(e.src,e.type),t=m(e);if(w(e,t)){n();return}let s=p==="script"?document.createElement("script"):document.createElement("link");if(p==="script"){let i=s;e.async?i.async=!0:(i.async=!1,e.defer!==!1&&(i.defer=!0)),e.id&&(i.id=e.id),e.attributes&&Object.entries(e.attributes).forEach(([c,y])=>{j.has(String(c).toLowerCase())||i.setAttribute(c,y)}),i.src=t,k(i,e),i.onload=()=>{E(`Injected: ${t}`),n()},i.onerror=()=>{let c=new Error(`Failed to load script: ${t}`);a.env!=="production"&&console.error("[Stagepass]",c),r(c)}}else{let i=s;e.id&&(i.id=e.id),e.attributes&&Object.entries(e.attributes).forEach(([y,h])=>{j.has(String(y).toLowerCase())||i.setAttribute(y,h)}),i.rel="stylesheet",i.href=t,k(i,e);let c=setInterval(()=>{(i.sheet||i.styleSheet)&&(clearInterval(c),E(`Injected: ${t}`),n())},10);setTimeout(()=>{if(clearInterval(c),!(i.sheet||i.styleSheet)){let h=new Error(`Failed to load stylesheet: ${t}`);a.env!=="production"&&console.error("[Stagepass]",h),r(h)}},5e3)}let o=O(e.position);if(!o){r(new Error("Could not find insertion point"));return}if(o===document.head||o===document.body)e.position==="body-start"?o.prepend(s):o.appendChild(s);else{let i=o.parentNode;i&&(typeof e.position=="object"&&e.position.action==="before"?i.insertBefore(s,o):i.insertBefore(s,o.nextSibling))}})}async function u(e){let n=[];if(!Array.isArray(e)&&typeof e=="object"&&("scripts"in e||"styles"in e)){let r=e;r.scripts&&n.push(...r.scripts.filter(a=>a&&typeof a=="object"&&"src"in a&&typeof a.src=="string"&&a.src.trim().length>0).map(a=>({...a,type:"script"}))),r.styles&&n.push(...r.styles.filter(a=>a&&typeof a=="object"&&"src"in a&&typeof a.src=="string"&&a.src.trim().length>0).map(a=>({...a,type:"style"})))}else Array.isArray(e)?n=e.filter(r=>r&&typeof r=="object"&&"src"in r&&typeof r.src=="string"&&r.src.trim().length>0):e&&typeof e=="object"&&"src"in e&&typeof e.src=="string"&&e.src.trim().length>0&&(n=[e]);for(let r of n)try{await $(r)}catch(a){try{S().env!=="production"&&console.error("[Stagepass] Injection error:",a)}catch{}}}function d(e){e.inject=u}let l=b()||{};l.vars||x(),l.vars&&typeof l.use=="function"?l.use("inject","2.0.0",d):d(l),window.stagepass=l,globalThis.stagepass=l,window.sp=l,globalThis.sp=l})();(function(){function b(){let f=window.stagepass||globalThis.stagepass||window.sp||globalThis.sp;return f||null}function x(){try{console.warn("[Stagepass] Core loader should be loaded before the cookies module.")}catch{}}function S(f,m){if(!(m==null||m==="")&&/[;\r\n]/.test(m))throw new Error(`Invalid cookie ${f}`)}function j(){return window.location.protocol==="https:"}function E(f){try{return decodeURIComponent(f)}catch{return f}}function A(f,m){let O=m.decode!==!1?E(f):f;if(!m.json)return O;try{return JSON.parse(O)}catch{return O}}function L(f){let m=new Map,w=[],O=()=>!0;function k(t,s,o={}){if(!t||typeof t!="string"||t.includes(";")||/[\r\n]/.test(t))throw new Error("Invalid cookie name");let i=o.encode!==!1,c=o.sameSite||"Lax";S("sameSite",c);let y=o.secure!==void 0?o.secure:j(),h=o.path||"/";S("path",h),S("domain",o.domain);let v=o.json?JSON.stringify(s):String(s);i||(S("value",v),S("name",t));let R=i?encodeURIComponent(t):t;v=i?encodeURIComponent(v):v;let C=[`${R}=${v}`];if(typeof o.maxAge=="number"&&C.push(`Max-Age=${Math.floor(o.maxAge)}`),typeof o.days=="number"){let M=new Date(Date.now()+o.days*24*60*60*1e3);C.push(`Expires=${M.toUTCString()}`)}h&&C.push(`Path=${h}`),o.domain&&C.push(`Domain=${o.domain}`),C.push(`SameSite=${c}`);let _=y;c==="None"&&!_&&(_=!0,typeof f.warn=="function"&&f.warn("SameSite=None requires Secure=true. Enforcing Secure for cookie write.")),_&&C.push("Secure"),document.cookie=C.join("; ")}function $(t,s,o={}){let i=o.category,c={name:t,value:s,options:{...o},category:i};if(i&&!O(i)){let h=w.findIndex(v=>v.name===t);h>=0&&w.splice(h,1),w.push(c),m.set(t,c);return}k(t,s,o),m.set(t,c);let y=w.findIndex(h=>h.name===t);y>=0&&w.splice(y,1)}function u(t,s={}){if(!t||typeof t!="string")return null;let o=s.decode===!1?t:E(t),i=document.cookie?document.cookie.split("; "):[];for(let c of i){let y=c.indexOf("=");if(y<0)continue;let h=c.substring(0,y),v=c.substring(y+1),R=E(h);if(h===o||R===o)return A(v,s)}return null}function d(t){return u(t)!==null}function l(t={}){let s=document.cookie?document.cookie.split("; "):[],o={};for(let i of s){let c=i.indexOf("=");if(c<0)continue;let y=i.substring(0,c),h=i.substring(c+1),v=t.decode===!1?y:E(y);o[v]=A(h,t)}return o}function g(t,s={}){k(t,"",{days:-1,maxAge:0,path:s.path||"/",domain:s.domain,secure:s.secure,sameSite:s.sameSite}),m.delete(t);let o=w.findIndex(i=>i.name===t);o>=0&&w.splice(o,1)}function e(t={}){let s=t.category,o=[];m.forEach((i,c)=>{(!s||i.category===s)&&o.push(c)});for(let i of o){let c=m.get(i);g(i,{path:c?.options.path,domain:c?.options.domain,secure:c?.options.secure,sameSite:c?.options.sameSite})}}function n(){let t={};return m.forEach((s,o)=>{t[o]=s.value}),t}function r(t){let s=t==null?"":String(t),o=[];return m.forEach((i,c)=>{c.startsWith(s)&&o.push(c)}),o}let a={bake:$,eat:u,throw:g,has:d,list:l,throwAll:e,jar:n,crumbs:r},p={allows(t){try{return O(t)===!0}catch{return!1}},set(t){typeof t=="function"&&(O=t)},update(){let t=w.splice(0,w.length);for(let s of t)!s.category||O(s.category)?$(s.name,s.value,s.options):w.push(s)}};f.cookies=a,f.cookie=a,f.consent=p}let I=b()||{};I.vars||x(),I.vars&&typeof I.use=="function"?I.use("cookies","2.0.0",L):L(I),window.stagepass=I,globalThis.stagepass=I,window.sp=I,globalThis.sp=I})();(function(){let b="stagepass-maintenance-overlay",x="stagepass-maintenance-badge",S="stagepass-maintenance-style",j="We will be back soon",E="This site is temporarily unavailable while we perform maintenance.";function A(){let u=window.stagepass||globalThis.stagepass||window.sp||globalThis.sp;if(!u||!u.vars){try{console.warn("[Stagepass] Core loader must be loaded before the maintenance module. Skipping registration.")}catch{}return null}return u}function L(){try{if(document.currentScript instanceof HTMLScriptElement)return document.currentScript}catch{}try{let u=document.querySelectorAll('script[src*="maintenance"]');for(let l=u.length-1;l>=0;l--){let g=u[l];if(/maintenance(?:\.min)?\.js/i.test(g.src||""))return g}let d=document.querySelectorAll('script[src*="all"]');for(let l=d.length-1;l>=0;l--){let g=d[l];if(/all(?:\.min)?\.js/i.test(g.src||"")&&g.hasAttribute("data-stagepass-maintenance"))return g}}catch{}return null}function I(u){try{if(typeof u.is=="function"&&u.is("local"))return!0}catch{}try{let d=localStorage.getItem("stagepass_domain");if(!d)return!1;if(d.startsWith("{")){let l=JSON.parse(d),g=l&&l.domain;if(g==="debug"||typeof g=="string"&&g.endsWith(".sp")||g==="localhost"||typeof g=="string"&&g.startsWith("localhost:"))return!0}}catch{}return!1}function T(){if(document.getElementById(S))return;let u=document.createElement("style");u.id=S,u.textContent=`
2
2
  #${b}{position:fixed;inset:0;z-index:2147483646;display:flex;align-items:center;justify-content:center;padding:24px;box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;background:#f4f4f5;color:#18181b}
3
3
  #${b} .sp-m-card{max-width:32rem;width:100%;text-align:center}
4
4
  #${b} .sp-m-title{margin:0 0 12px;font-size:1.75rem;line-height:1.2;font-weight:700}
@@ -7,4 +7,4 @@
7
7
  @media (prefers-color-scheme:dark){
8
8
  #${b}{background:#09090b;color:#fafafa}
9
9
  #${x}{background:#d97706;color:#111}
10
- }`,(document.head||document.documentElement).appendChild(u)}function f(u){let d=document.getElementById(u);d&&d.remove()}function m(u,d){T(),f(b),f(x);let l=document.createElement("div");l.id=b,l.setAttribute("role","alertdialog"),l.setAttribute("aria-modal","true"),l.setAttribute("aria-labelledby","stagepass-maintenance-title"),l.setAttribute("aria-describedby","stagepass-maintenance-desc"),l.tabIndex=-1;let g=document.createElement("div");g.className="sp-m-card";let e=document.createElement("h1");e.id="stagepass-maintenance-title",e.className="sp-m-title",e.textContent=u;let n=document.createElement("p");n.id="stagepass-maintenance-desc",n.className="sp-m-text",n.textContent=d,g.appendChild(e),g.appendChild(n),l.appendChild(g);let s=()=>{(document.body||document.documentElement).appendChild(l);try{l.focus()}catch{}};document.body?s():document.addEventListener("DOMContentLoaded",s,{once:!0})}function w(u){T(),f(b),f(x);let d=document.createElement("div");d.id=x,d.setAttribute("role","status"),d.textContent=`Maintenance mode on (visitors see: ${u})`;let l=()=>{(document.body||document.documentElement).appendChild(d)};document.body?l():document.addEventListener("DOMContentLoaded",l,{once:!0})}function O(u){let d=!1,l=j,g=E;function e(t){t?.title&&(l=String(t.title)),t?.text&&(g=String(t.text)),d=!0,I(u)?w(l):m(l,g)}function n(){d=!1,f(b),f(x)}function s(){return d}u.maintenance={enable:e,disable:n,isActive:s};let a=L();if(a?.getAttribute("data-stagepass-maintenance")==="true"){let t=a?.getAttribute("data-stagepass-maintenance-title")||j,o=a?.getAttribute("data-stagepass-maintenance-text")||E;e({title:t,text:o})}}let k=A();if(!k)return;typeof k.use=="function"?k.use("maintenance","2.0.0",O):O(k),globalThis.stagepass=k,window.sp=k,globalThis.sp=k})();})();
10
+ }`,(document.head||document.documentElement).appendChild(u)}function f(u){let d=document.getElementById(u);d&&d.remove()}function m(u,d){T(),f(b),f(x);let l=document.createElement("div");l.id=b,l.setAttribute("role","alertdialog"),l.setAttribute("aria-modal","true"),l.setAttribute("aria-labelledby","stagepass-maintenance-title"),l.setAttribute("aria-describedby","stagepass-maintenance-desc"),l.tabIndex=-1;let g=document.createElement("div");g.className="sp-m-card";let e=document.createElement("h1");e.id="stagepass-maintenance-title",e.className="sp-m-title",e.textContent=u;let n=document.createElement("p");n.id="stagepass-maintenance-desc",n.className="sp-m-text",n.textContent=d,g.appendChild(e),g.appendChild(n),l.appendChild(g);let r=()=>{(document.body||document.documentElement).appendChild(l);try{l.focus()}catch{}};document.body?r():document.addEventListener("DOMContentLoaded",r,{once:!0})}function w(u){T(),f(b),f(x);let d=document.createElement("div");d.id=x,d.setAttribute("role","status"),d.textContent=`Maintenance mode on (visitors see: ${u})`;let l=()=>{(document.body||document.documentElement).appendChild(d)};document.body?l():document.addEventListener("DOMContentLoaded",l,{once:!0})}function O(u){let d=!1,l=j,g=E;function e(t){t?.title&&(l=String(t.title)),t?.text&&(g=String(t.text)),d=!0,I(u)?w(l):m(l,g)}function n(){d=!1,f(b),f(x)}function r(){return d}u.maintenance={enable:e,disable:n,isActive:r};let a=L();if(a?.getAttribute("data-stagepass-maintenance")==="true"){let t=a?.getAttribute("data-stagepass-maintenance-title")||j,s=a?.getAttribute("data-stagepass-maintenance-text")||E;e({title:t,text:s})}}let k=A();if(!k)return;typeof k.use=="function"?k.use("maintenance","2.0.0",O):O(k),globalThis.stagepass=k,window.sp=k,globalThis.sp=k})();})();
@@ -1 +1 @@
1
- "use strict";var StagepassInject=(()=>{(function(){function y(){let t=window.stagepass||globalThis.stagepass||window.sp||globalThis.sp;return t||null}function w(){try{console.warn("[Stagepass] Core loader should be loaded before the inject module.")}catch{}}function g(){let t=y();if(!t||!t.vars)throw new Error("Stagepass core loader must be loaded before modules");return t.vars}let h=new Set(["src","href","rel","integrity","crossorigin","nonce"]);function d(t){try{let e=g();(e.env==="local"||e.env==="staging")&&console.log(`[Stagepass] ${t}`)}catch{}}function I(t){try{let e=y();if(e&&typeof e.warn=="function"){e.warn(t);return}}catch{}try{console.warn(`[Stagepass] ${t}`)}catch{}}function O(t){if(!t||typeof t!="string")return"file";try{let n=new URL(t).pathname||"";if(!n||n.length===0){let c=t.match(/\/([^\/\?#]+)(?:\?|#|$)/);return c?c[1]:"file"}let r=n.split("/");return r[r.length-1]||r[r.length-2]||"file"}catch{try{let n=t.match(/\/([^\/\?#]+)(?:\?|#|$)/);return n?n[1]:"file"}catch{return"file"}}}function b(t,e){if(e)return e;if(!t||typeof t!="string")return"script";try{if(t.split(".").pop()?.toLowerCase()==="css")return"style"}catch{}return"script"}function S(t,e,n){let r=encodeURIComponent(n),c=t.indexOf("#"),o=c>=0?t.slice(c):"",i=c>=0?t.slice(0,c):t,a=i.includes("?")?"&":"?";return`${i}${a}${encodeURIComponent(e)}=${r}${o}`}function E(t,e){if(!e||e.length===0)return!0;try{let n=new URL(t,window.location.href).hostname.toLowerCase();return e.map(c=>String(c).toLowerCase()).includes(n)}catch{return!1}}function v(t){let e=g(),{src:n,stagepass:r,localPath:c,path:o,version:i}=t;if(!n||typeof n!="string")throw new Error("Invalid src: must be a non-empty string");if(r!==!1&&e.isLocal){let a=c||o||O(n);if(!a||typeof a!="string")return n;let s=a.startsWith("/")?a.substring(1):a,l=y();if(l&&typeof l.resolveLocalUrl=="function"){let u=l.resolveLocalUrl(s);if(u)return u}return`https://${e.domain}/${s}?_cb=${e.timestamp}`}return i?S(n,"v",i):n}function $(t,e){let{id:n,type:r}=t,c=b(t.src,r);if(n&&document.getElementById(n))return d(`Skipping injection: Element with id "${n}" already exists`),!0;if(c==="script"){let o=document.getElementsByTagName("script");for(let i=0;i<o.length;i++)if(o[i].getAttribute("src")===e)return d(`Skipping injection: Resource "${e}" already loaded`),!0}else{let o=document.getElementsByTagName("link");for(let i=0;i<o.length;i++)if(o[i].getAttribute("href")===e)return d(`Skipping injection: Resource "${e}" already loaded`),!0}return!1}function L(t="body-end"){if(typeof t=="string")switch(t){case"head":return document.head;case"body-start":return document.body?.firstChild||document.body;case"body-end":return document.body;default:return document.body}let{target:e,action:n}=t,r=document.querySelector(e);return r?n==="before"?r:r.nextSibling||r.parentNode:(d(`Warning: Target selector "${e}" not found, falling back to body-end`),document.body)}function m(t,e){e.integrity&&t.setAttribute("integrity",e.integrity),e.crossorigin&&t.setAttribute("crossorigin",e.crossorigin),e.nonce&&t.setAttribute("nonce",e.nonce)}function T(t){return new Promise((e,n)=>{if(!t.src){let s=g(),l=new Error('InjectOptions must have a "src" property');s.env!=="production"&&console.error("[Stagepass]",l),n(l);return}if(!E(t.src,t.allowedHosts)){I(`inject: host not allowed for "${t.src}". Check allowedHosts.`),e();return}let r=g(),c=b(t.src,t.type),o=v(t);if($(t,o)){e();return}let i=c==="script"?document.createElement("script"):document.createElement("link");if(c==="script"){let s=i;t.async?s.async=!0:(s.async=!1,t.defer!==!1&&(s.defer=!0)),t.id&&(s.id=t.id),t.attributes&&Object.entries(t.attributes).forEach(([l,u])=>{h.has(String(l).toLowerCase())||s.setAttribute(l,u)}),s.src=o,m(s,t),s.onload=()=>{d(`Injected: ${o}`),e()},s.onerror=()=>{let l=new Error(`Failed to load script: ${o}`);r.env!=="production"&&console.error("[Stagepass]",l),n(l)}}else{let s=i;t.id&&(s.id=t.id),t.attributes&&Object.entries(t.attributes).forEach(([u,p])=>{h.has(String(u).toLowerCase())||s.setAttribute(u,p)}),s.rel="stylesheet",s.href=o,m(s,t);let l=setInterval(()=>{(s.sheet||s.styleSheet)&&(clearInterval(l),d(`Injected: ${o}`),e())},10);setTimeout(()=>{if(clearInterval(l),!(s.sheet||s.styleSheet)){let p=new Error(`Failed to load stylesheet: ${o}`);r.env!=="production"&&console.error("[Stagepass]",p),n(p)}},5e3)}let a=L(t.position);if(!a){n(new Error("Could not find insertion point"));return}if(a===document.head||a===document.body)a.appendChild(i);else{let s=a.parentNode;s&&(typeof t.position=="object"&&t.position.action==="before"?s.insertBefore(i,a):s.insertBefore(i,a.nextSibling))}})}async function A(t){let e=[];if(!Array.isArray(t)&&typeof t=="object"&&("scripts"in t||"styles"in t)){let n=t;n.scripts&&e.push(...n.scripts.filter(r=>r&&typeof r=="object"&&"src"in r&&typeof r.src=="string"&&r.src.trim().length>0).map(r=>({...r,type:"script"}))),n.styles&&e.push(...n.styles.filter(r=>r&&typeof r=="object"&&"src"in r&&typeof r.src=="string"&&r.src.trim().length>0).map(r=>({...r,type:"style"})))}else Array.isArray(t)?e=t.filter(n=>n&&typeof n=="object"&&"src"in n&&typeof n.src=="string"&&n.src.trim().length>0):t&&typeof t=="object"&&"src"in t&&typeof t.src=="string"&&t.src.trim().length>0&&(e=[t]);for(let n of e)try{await T(n)}catch(r){try{g().env!=="production"&&console.error("[Stagepass] Injection error:",r)}catch{}}}function j(t){t.inject=A}let f=y()||{};f.vars||w(),f.vars&&typeof f.use=="function"?f.use("inject","2.0.0",j):j(f),window.stagepass=f,globalThis.stagepass=f,window.sp=f,globalThis.sp=f})();})();
1
+ "use strict";var StagepassInject=(()=>{(function(){function y(){let t=window.stagepass||globalThis.stagepass||window.sp||globalThis.sp;return t||null}function w(){try{console.warn("[Stagepass] Core loader should be loaded before the inject module.")}catch{}}function g(){let t=y();if(!t||!t.vars)throw new Error("Stagepass core loader must be loaded before modules");return t.vars}let h=new Set(["src","href","rel","integrity","crossorigin","nonce"]);function d(t){try{let e=g();(e.env==="local"||e.env==="staging")&&console.log(`[Stagepass] ${t}`)}catch{}}function I(t){try{let e=y();if(e&&typeof e.warn=="function"){e.warn(t);return}}catch{}try{console.warn(`[Stagepass] ${t}`)}catch{}}function O(t){if(!t||typeof t!="string")return"file";try{let n=new URL(t).pathname||"";if(!n||n.length===0){let c=t.match(/\/([^\/\?#]+)(?:\?|#|$)/);return c?c[1]:"file"}let r=n.split("/");return r[r.length-1]||r[r.length-2]||"file"}catch{try{let n=t.match(/\/([^\/\?#]+)(?:\?|#|$)/);return n?n[1]:"file"}catch{return"file"}}}function b(t,e){if(e)return e;if(!t||typeof t!="string")return"script";try{if(t.split(".").pop()?.toLowerCase()==="css")return"style"}catch{}return"script"}function S(t,e,n){let r=encodeURIComponent(n),c=t.indexOf("#"),o=c>=0?t.slice(c):"",i=c>=0?t.slice(0,c):t,a=i.includes("?")?"&":"?";return`${i}${a}${encodeURIComponent(e)}=${r}${o}`}function E(t,e){if(!e||e.length===0)return!0;try{let n=new URL(t,window.location.href).hostname.toLowerCase();return e.map(c=>String(c).toLowerCase()).includes(n)}catch{return!1}}function v(t){let e=g(),{src:n,stagepass:r,localPath:c,path:o,version:i}=t;if(!n||typeof n!="string")throw new Error("Invalid src: must be a non-empty string");if(r!==!1&&e.isLocal){let a=c||o||O(n);if(!a||typeof a!="string")return n;let s=a.startsWith("/")?a.substring(1):a,l=y();if(l&&typeof l.resolveLocalUrl=="function"){let u=l.resolveLocalUrl(s);if(u)return u}}return i?S(n,"v",i):n}function L(t,e){let{id:n,type:r}=t,c=b(t.src,r);if(n&&document.getElementById(n))return d(`Skipping injection: Element with id "${n}" already exists`),!0;if(c==="script"){let o=document.getElementsByTagName("script");for(let i=0;i<o.length;i++)if(o[i].getAttribute("src")===e)return d(`Skipping injection: Resource "${e}" already loaded`),!0}else{let o=document.getElementsByTagName("link");for(let i=0;i<o.length;i++)if(o[i].getAttribute("href")===e)return d(`Skipping injection: Resource "${e}" already loaded`),!0}return!1}function $(t="body-end"){if(typeof t=="string")return t==="head"?document.head:document.body;let{target:e,action:n}=t,r=document.querySelector(e);return r?n==="before"?r:r.nextSibling||r.parentNode:(d(`Warning: Target selector "${e}" not found, falling back to body-end`),document.body)}function m(t,e){e.integrity&&t.setAttribute("integrity",e.integrity),e.crossorigin&&t.setAttribute("crossorigin",e.crossorigin),e.nonce&&t.setAttribute("nonce",e.nonce)}function T(t){return new Promise((e,n)=>{if(!t.src){let s=g(),l=new Error('InjectOptions must have a "src" property');s.env!=="production"&&console.error("[Stagepass]",l),n(l);return}if(!E(t.src,t.allowedHosts)){I(`inject: host not allowed for "${t.src}". Check allowedHosts.`),e();return}let r=g(),c=b(t.src,t.type),o=v(t);if(L(t,o)){e();return}let i=c==="script"?document.createElement("script"):document.createElement("link");if(c==="script"){let s=i;t.async?s.async=!0:(s.async=!1,t.defer!==!1&&(s.defer=!0)),t.id&&(s.id=t.id),t.attributes&&Object.entries(t.attributes).forEach(([l,u])=>{h.has(String(l).toLowerCase())||s.setAttribute(l,u)}),s.src=o,m(s,t),s.onload=()=>{d(`Injected: ${o}`),e()},s.onerror=()=>{let l=new Error(`Failed to load script: ${o}`);r.env!=="production"&&console.error("[Stagepass]",l),n(l)}}else{let s=i;t.id&&(s.id=t.id),t.attributes&&Object.entries(t.attributes).forEach(([u,p])=>{h.has(String(u).toLowerCase())||s.setAttribute(u,p)}),s.rel="stylesheet",s.href=o,m(s,t);let l=setInterval(()=>{(s.sheet||s.styleSheet)&&(clearInterval(l),d(`Injected: ${o}`),e())},10);setTimeout(()=>{if(clearInterval(l),!(s.sheet||s.styleSheet)){let p=new Error(`Failed to load stylesheet: ${o}`);r.env!=="production"&&console.error("[Stagepass]",p),n(p)}},5e3)}let a=$(t.position);if(!a){n(new Error("Could not find insertion point"));return}if(a===document.head||a===document.body)t.position==="body-start"?a.prepend(i):a.appendChild(i);else{let s=a.parentNode;s&&(typeof t.position=="object"&&t.position.action==="before"?s.insertBefore(i,a):s.insertBefore(i,a.nextSibling))}})}async function A(t){let e=[];if(!Array.isArray(t)&&typeof t=="object"&&("scripts"in t||"styles"in t)){let n=t;n.scripts&&e.push(...n.scripts.filter(r=>r&&typeof r=="object"&&"src"in r&&typeof r.src=="string"&&r.src.trim().length>0).map(r=>({...r,type:"script"}))),n.styles&&e.push(...n.styles.filter(r=>r&&typeof r=="object"&&"src"in r&&typeof r.src=="string"&&r.src.trim().length>0).map(r=>({...r,type:"style"})))}else Array.isArray(t)?e=t.filter(n=>n&&typeof n=="object"&&"src"in n&&typeof n.src=="string"&&n.src.trim().length>0):t&&typeof t=="object"&&"src"in t&&typeof t.src=="string"&&t.src.trim().length>0&&(e=[t]);for(let n of e)try{await T(n)}catch(r){try{g().env!=="production"&&console.error("[Stagepass] Injection error:",r)}catch{}}}function j(t){t.inject=A}let f=y()||{};f.vars||w(),f.vars&&typeof f.use=="function"?f.use("inject","2.0.0",j):j(f),window.stagepass=f,globalThis.stagepass=f,window.sp=f,globalThis.sp=f})();})();
package/global.d.ts CHANGED
@@ -1,113 +1,12 @@
1
1
  /**
2
- * Options for `stagepass.inject` / `sp.inject`.
2
+ * Types for all Stagepass modules (`@stagepass/modules`, `dist/all.min.js`).
3
+ *
4
+ * Backward compatible entry: re-exports every module type and augments
5
+ * `StagepassAPI` with `inject`, `cookies`, `cookie`, `consent`, `maintenance`.
6
+ * For projects that load only some modules, use the per-module entries
7
+ * instead: `@stagepass/modules/inject`, `@stagepass/modules/cookies`,
8
+ * `@stagepass/modules/maintenance`.
3
9
  */
4
- export interface StagepassInjectOptions {
5
- src: string;
6
- type?: 'script' | 'style';
7
- stagepass?: boolean;
8
- localPath?: string;
9
- path?: string;
10
- id?: string;
11
- async?: boolean;
12
- defer?: boolean;
13
- /** @deprecated No longer appends per-view timestamps in production. Use `version`. */
14
- cacheBust?: boolean;
15
- /** Production version token appended as `?v=`. */
16
- version?: string;
17
- attributes?: Record<string, string>;
18
- position?:
19
- | 'head'
20
- | 'body-start'
21
- | 'body-end'
22
- | { target: string; action: 'before' | 'after' };
23
- /** Subresource Integrity hash. */
24
- integrity?: string;
25
- /** CORS mode (`anonymous` / `use-credentials`). */
26
- crossorigin?: string;
27
- /** CSP nonce. */
28
- nonce?: string;
29
- /** Reject src hosts outside this list (warn + skip). */
30
- allowedHosts?: string[];
31
- }
32
-
33
- export interface StagepassInjectBatchOptions {
34
- scripts?: StagepassInjectOptions[];
35
- styles?: StagepassInjectOptions[];
36
- }
37
-
38
- export interface StagepassCookieWriteOptions {
39
- days?: number;
40
- maxAge?: number;
41
- path?: string;
42
- domain?: string;
43
- secure?: boolean;
44
- sameSite?: 'Lax' | 'Strict' | 'None';
45
- encode?: boolean;
46
- json?: boolean;
47
- /** Optional category for consent gating / throwAll filtering. */
48
- category?: string;
49
- }
50
-
51
- export interface StagepassCookiesAPI {
52
- /** Write a cookie. */
53
- bake: (name: string, value: unknown, options?: StagepassCookieWriteOptions) => void;
54
- /** Read a cookie. */
55
- eat: (name: string, options?: Record<string, unknown>) => unknown;
56
- /** Delete a cookie. */
57
- throw: (name: string, options?: Record<string, unknown>) => void;
58
- /** Whether a cookie exists. */
59
- has: (name: string) => boolean;
60
- /** List cookies as a name → value map. */
61
- list: (options?: Record<string, unknown>) => Record<string, unknown>;
62
- /** Delete known cookies, optionally by category. */
63
- throwAll: (options?: { category?: string }) => void;
64
- /** Shallow copy of cookies known to this helper. */
65
- jar: () => Record<string, unknown>;
66
- /** Known cookie names starting with `prefix`. */
67
- crumbs: (prefix: string) => string[];
68
- }
69
-
70
- /**
71
- * Tiny consent hook used by categorized `bake`.
72
- * Tooling helper only: not a legal compliance solution.
73
- */
74
- export interface StagepassConsentAPI {
75
- allows: (category: string) => boolean;
76
- set: (fn: (category: string) => boolean) => void;
77
- /** Flush queued cookies against the current consent function. */
78
- update: () => void;
79
- }
80
-
81
- export interface StagepassMaintenanceAPI {
82
- enable: (opts?: { title?: string; text?: string }) => void;
83
- disable: () => void;
84
- isActive: () => boolean;
85
- }
86
-
87
- export type StagepassInjectAPI = (
88
- options:
89
- | StagepassInjectOptions
90
- | StagepassInjectOptions[]
91
- | StagepassInjectBatchOptions
92
- ) => Promise<void>;
93
-
94
- /** Declaration merging: extend loader StagepassAPI with modules. */
95
- declare module '@stagepass/loader' {
96
- interface StagepassAPI {
97
- /** Programmatic asset injector (from `@stagepass/modules`). */
98
- inject?: StagepassInjectAPI;
99
- /** Cookie helpers (from `@stagepass/modules`). */
100
- cookies?: StagepassCookiesAPI;
101
- /** Singular alias of `cookies`. */
102
- cookie?: StagepassCookiesAPI;
103
- /**
104
- * Consent hook for categorized cookies.
105
- * Documented as a tool, not legal compliance.
106
- */
107
- consent?: StagepassConsentAPI;
108
- /** Client-side maintenance overlay (not access protection). */
109
- maintenance?: StagepassMaintenanceAPI;
110
- }
111
- }
112
-
113
- export {};
10
+ export * from './inject.js';
11
+ export * from './cookies.js';
12
+ export * from './maintenance.js';
package/inject.d.ts ADDED
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Types for the Stagepass `inject` module (`@stagepass/modules/dist/inject.min.js`).
3
+ *
4
+ * Enable per project in tsconfig/jsconfig: `"types": ["@stagepass/loader", "@stagepass/modules/inject"]`.
5
+ * Only list modules whose script tag is actually on the Webflow site.
6
+ */
7
+ import '@stagepass/loader';
8
+
9
+ /**
10
+ * Options for `stagepass.inject` / `sp.inject`.
11
+ */
12
+ export interface StagepassInjectOptions {
13
+ src: string;
14
+ type?: 'script' | 'style';
15
+ stagepass?: boolean;
16
+ localPath?: string;
17
+ path?: string;
18
+ id?: string;
19
+ async?: boolean;
20
+ defer?: boolean;
21
+ /** @deprecated No longer appends per-view timestamps in production. Use `version`. */
22
+ cacheBust?: boolean;
23
+ /** Production version token appended as `?v=`. */
24
+ version?: string;
25
+ attributes?: Record<string, string>;
26
+ position?:
27
+ | 'head'
28
+ | 'body-start'
29
+ | 'body-end'
30
+ | { target: string; action: 'before' | 'after' };
31
+ /** Subresource Integrity hash. */
32
+ integrity?: string;
33
+ /** CORS mode (`anonymous` / `use-credentials`). */
34
+ crossorigin?: string;
35
+ /** CSP nonce. */
36
+ nonce?: string;
37
+ /** Reject src hosts outside this list (warn + skip). */
38
+ allowedHosts?: string[];
39
+ }
40
+
41
+ export interface StagepassInjectBatchOptions {
42
+ scripts?: StagepassInjectOptions[];
43
+ styles?: StagepassInjectOptions[];
44
+ }
45
+
46
+ export type StagepassInjectAPI = (
47
+ options:
48
+ | StagepassInjectOptions
49
+ | StagepassInjectOptions[]
50
+ | StagepassInjectBatchOptions
51
+ ) => Promise<void>;
52
+
53
+ declare module '@stagepass/loader' {
54
+ interface StagepassAPI {
55
+ /**
56
+ * Programmatic asset injector (`inject` module).
57
+ * @example
58
+ * if (sp.inject) await sp.inject({ src: 'https://cdn.example.com/lib.js', defer: true });
59
+ */
60
+ inject?: StagepassInjectAPI;
61
+ }
62
+ }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Types for the Stagepass `maintenance` module (`@stagepass/modules/dist/maintenance.min.js`).
3
+ *
4
+ * Enable per project in tsconfig/jsconfig: `"types": ["@stagepass/loader", "@stagepass/modules/maintenance"]`.
5
+ * Only list modules whose script tag is actually on the Webflow site.
6
+ */
7
+ import '@stagepass/loader';
8
+
9
+ export interface StagepassMaintenanceAPI {
10
+ enable: (opts?: { title?: string; text?: string }) => void;
11
+ disable: () => void;
12
+ isActive: () => boolean;
13
+ }
14
+
15
+ declare module '@stagepass/loader' {
16
+ interface StagepassAPI {
17
+ /**
18
+ * Client-side maintenance overlay (`maintenance` module). Not access protection.
19
+ * @example
20
+ * if (sp.maintenance && !sp.maintenance.isActive()) sp.maintenance.enable({ title: 'Back soon' });
21
+ */
22
+ maintenance?: StagepassMaintenanceAPI;
23
+ }
24
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stagepass/modules",
3
- "version": "2.1.0",
3
+ "version": "2.2.2",
4
4
  "description": "Modular feature extensions for Stagepass",
5
5
  "type": "module",
6
6
  "main": "dist/all.min.js",
@@ -8,6 +8,9 @@
8
8
  "files": [
9
9
  "dist",
10
10
  "global.d.ts",
11
+ "inject.d.ts",
12
+ "cookies.d.ts",
13
+ "maintenance.d.ts",
11
14
  "README.md",
12
15
  "LICENSE"
13
16
  ],
@@ -16,7 +19,7 @@
16
19
  "dev": "tsup --watch",
17
20
  "test": "vitest run && npm run typecheck",
18
21
  "test:watch": "vitest",
19
- "typecheck": "tsc --noEmit -p fixtures/tsconfig.json"
22
+ "typecheck": "tsc --noEmit -p fixtures/tsconfig.json && tsc --noEmit -p fixtures/tsconfig.cookies.json && tsc --noEmit -p fixtures/tsconfig.none.json && tsc --noEmit -p fixtures/tsconfig.nodenext.json && tsc --noEmit -p fixtures/nodenext-cjs/tsconfig.json"
20
23
  },
21
24
  "keywords": [
22
25
  "stagepass",