@stagepass/modules 1.0.2 → 1.0.3

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/dist/all.min.js CHANGED
@@ -1 +1 @@
1
- "use strict";var StagepassModules=(()=>{(function(){function d(){let e=window.stagepass||globalThis.stagepass;if(!e||!e.vars)throw new Error("Stagepass core loader must be loaded before modules");return e.vars}function f(e){let r=d();(r.env==="local"||r.env==="staging")&&console.log(`[Stagepass] ${e}`)}function h(e){if(!e)return"file";try{let n=new URL(e).pathname.split("/");return n[n.length-1]||n[n.length-2]||"file"}catch{let n=e.match(/\/([^\/\?#]+)(?:\?|#|$)/);return n?n[1]:"file"}}function y(e,r){return r||(e&&e.split(".").pop()?.toLowerCase()==="css"?"style":"script")}function b(e){let r=d(),{src:n,stagepass:t,localPath:l,path:i}=e;if(t!==!1&&r.isLocal){let c=l||i||h(n),o=c.startsWith("/")?c.substring(1):c;return`https://${r.domain}/${o}?_cb=${r.timestamp}`}return n}function m(e,r){let{id:n,type:t}=e,l=y(e.src,t);if(n&&document.getElementById(n))return f(`Skipping injection: Element with id "${n}" already exists`),!0;let i=l==="script"?`script[src="${r}"]`:`link[href="${r}"]`;return document.querySelector(i)?(f(`Skipping injection: Resource "${r}" already loaded`),!0):!1}function j(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:r,action:n}=e,t=document.querySelector(r);return t?n==="before"?t:t.nextSibling||t.parentNode:(f(`Warning: Target selector "${r}" not found, falling back to body-end`),document.body)}function I(e){return new Promise((r,n)=>{if(!e.src){let s=d(),a=new Error('InjectOptions must have a "src" property');s.env!=="production"&&console.error("[Stagepass]",a),n(a);return}let t=d(),l=y(e.src,e.type),i=b(e);if(m(e,i)){r();return}let c=l==="script"?document.createElement("script"):document.createElement("link");if(l==="script"){let s=c;s.src=i,e.async?s.async=!0:e.defer!==!1&&(s.defer=!0),e.id&&(s.id=e.id),e.attributes&&Object.entries(e.attributes).forEach(([a,u])=>{s.setAttribute(a,u)}),s.onload=()=>{f(`Injected: ${i}`),r()},s.onerror=()=>{let a=new Error(`Failed to load script: ${i}`);t.env!=="production"&&console.error("[Stagepass]",a),n(a)}}else{let s=c;s.rel="stylesheet",s.href=i,e.id&&(s.id=e.id),e.attributes&&Object.entries(e.attributes).forEach(([u,p])=>{s.setAttribute(u,p)});let a=setInterval(()=>{(s.sheet||s.styleSheet)&&(clearInterval(a),f(`Injected: ${i}`),r())},10);setTimeout(()=>{if(clearInterval(a),!(s.sheet||s.styleSheet)){let p=new Error(`Failed to load stylesheet: ${i}`);t.env!=="production"&&console.error("[Stagepass]",p),n(p)}},5e3)}let o=j(e.position);if(!o){n(new Error("Could not find insertion point"));return}if(o===document.head||o===document.body)o.appendChild(c);else{let s=o.parentNode;s&&(typeof e.position=="object"&&e.position.action==="before"?s.insertBefore(c,o):s.insertBefore(c,o.nextSibling))}})}async function w(e){let r=[];if(!Array.isArray(e)&&typeof e=="object"&&("scripts"in e||"styles"in e)){let n=e;n.scripts&&r.push(...n.scripts.filter(t=>t&&typeof t=="object"&&"src"in t&&t.src).map(t=>({...t,type:"script"}))),n.styles&&r.push(...n.styles.filter(t=>t&&typeof t=="object"&&"src"in t&&t.src).map(t=>({...t,type:"style"})))}else r=(Array.isArray(e)?e:[e]).filter(t=>t&&typeof t=="object"&&"src"in t&&t.src);for(let n of r)try{await I(n)}catch(t){d().env!=="production"&&console.error("[Stagepass] Injection error:",t)}}let g=window.stagepass=window.stagepass||{};g.inject=w,globalThis.stagepass=g})();})();
1
+ "use strict";var StagepassModules=(()=>{(function(){function f(){let t=window.stagepass||globalThis.stagepass;if(!t||!t.vars)throw new Error("Stagepass core loader must be loaded before modules");return t.vars}function d(t){let r=f();(r.env==="local"||r.env==="staging")&&console.log(`[Stagepass] ${t}`)}function h(t){if(!t||typeof t!="string")return"file";try{let n=new URL(t).pathname||"";if(!n){let o=t.match(/\/([^\/\?#]+)(?:\?|#|$)/);return o?o[1]:"file"}let e=n.split("/");return e[e.length-1]||e[e.length-2]||"file"}catch{let n=t.match(/\/([^\/\?#]+)(?:\?|#|$)/);return n?n[1]:"file"}}function y(t,r){if(r)return r;if(!t||typeof t!="string")return"script";try{if(t.split(".").pop()?.toLowerCase()==="css")return"style"}catch{}return"script"}function b(t){let r=f(),{src:n,stagepass:e,localPath:o,path:i}=t;if(!n||typeof n!="string")throw new Error("Invalid src: must be a non-empty string");if(e!==!1&&r.isLocal){let c=o||i||h(n);if(!c||typeof c!="string")return n;let a=c.startsWith("/")?c.substring(1):c;return`https://${r.domain}/${a}?_cb=${r.timestamp}`}return n}function m(t,r){let{id:n,type:e}=t,o=y(t.src,e);if(n&&document.getElementById(n))return d(`Skipping injection: Element with id "${n}" already exists`),!0;let i=o==="script"?`script[src="${r}"]`:`link[href="${r}"]`;return document.querySelector(i)?(d(`Skipping injection: Resource "${r}" already loaded`),!0):!1}function j(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:r,action:n}=t,e=document.querySelector(r);return e?n==="before"?e:e.nextSibling||e.parentNode:(d(`Warning: Target selector "${r}" not found, falling back to body-end`),document.body)}function I(t){return new Promise((r,n)=>{if(!t.src){let s=f(),l=new Error('InjectOptions must have a "src" property');s.env!=="production"&&console.error("[Stagepass]",l),n(l);return}let e=f(),o=y(t.src,t.type),i=b(t);if(m(t,i)){r();return}let c=o==="script"?document.createElement("script"):document.createElement("link");if(o==="script"){let s=c;s.src=i,t.async?s.async=!0:t.defer!==!1&&(s.defer=!0),t.id&&(s.id=t.id),t.attributes&&Object.entries(t.attributes).forEach(([l,u])=>{s.setAttribute(l,u)}),s.onload=()=>{d(`Injected: ${i}`),r()},s.onerror=()=>{let l=new Error(`Failed to load script: ${i}`);e.env!=="production"&&console.error("[Stagepass]",l),n(l)}}else{let s=c;s.rel="stylesheet",s.href=i,t.id&&(s.id=t.id),t.attributes&&Object.entries(t.attributes).forEach(([u,p])=>{s.setAttribute(u,p)});let l=setInterval(()=>{(s.sheet||s.styleSheet)&&(clearInterval(l),d(`Injected: ${i}`),r())},10);setTimeout(()=>{if(clearInterval(l),!(s.sheet||s.styleSheet)){let p=new Error(`Failed to load stylesheet: ${i}`);e.env!=="production"&&console.error("[Stagepass]",p),n(p)}},5e3)}let a=j(t.position);if(!a){n(new Error("Could not find insertion point"));return}if(a===document.head||a===document.body)a.appendChild(c);else{let s=a.parentNode;s&&(typeof t.position=="object"&&t.position.action==="before"?s.insertBefore(c,a):s.insertBefore(c,a.nextSibling))}})}async function w(t){let r=[];if(!Array.isArray(t)&&typeof t=="object"&&("scripts"in t||"styles"in t)){let n=t;n.scripts&&r.push(...n.scripts.filter(e=>e&&typeof e=="object"&&"src"in e&&e.src&&typeof e.src=="string"&&e.src.trim().length>0).map(e=>({...e,type:"script"}))),n.styles&&r.push(...n.styles.filter(e=>e&&typeof e=="object"&&"src"in e&&e.src&&typeof e.src=="string"&&e.src.trim().length>0).map(e=>({...e,type:"style"})))}else r=(Array.isArray(t)?t:[t]).filter(e=>e&&typeof e=="object"&&"src"in e&&e.src&&typeof e.src=="string"&&e.src.trim().length>0);for(let n of r)try{await I(n)}catch(e){f().env!=="production"&&console.error("[Stagepass] Injection error:",e)}}let g=window.stagepass=window.stagepass||{};g.inject=w,globalThis.stagepass=g})();})();
@@ -1 +1 @@
1
- "use strict";var StagepassInject=(()=>{(function(){function d(){let e=window.stagepass||globalThis.stagepass;if(!e||!e.vars)throw new Error("Stagepass core loader must be loaded before modules");return e.vars}function f(e){let s=d();(s.env==="local"||s.env==="staging")&&console.log(`[Stagepass] ${e}`)}function h(e){if(!e)return"file";try{let n=new URL(e).pathname.split("/");return n[n.length-1]||n[n.length-2]||"file"}catch{let n=e.match(/\/([^\/\?#]+)(?:\?|#|$)/);return n?n[1]:"file"}}function y(e,s){return s||(e&&e.split(".").pop()?.toLowerCase()==="css"?"style":"script")}function b(e){let s=d(),{src:n,stagepass:t,localPath:l,path:c}=e;if(t!==!1&&s.isLocal){let i=l||c||h(n),o=i.startsWith("/")?i.substring(1):i;return`https://${s.domain}/${o}?_cb=${s.timestamp}`}return n}function m(e,s){let{id:n,type:t}=e,l=y(e.src,t);if(n&&document.getElementById(n))return f(`Skipping injection: Element with id "${n}" already exists`),!0;let c=l==="script"?`script[src="${s}"]`:`link[href="${s}"]`;return document.querySelector(c)?(f(`Skipping injection: Resource "${s}" already loaded`),!0):!1}function j(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:s,action:n}=e,t=document.querySelector(s);return t?n==="before"?t:t.nextSibling||t.parentNode:(f(`Warning: Target selector "${s}" not found, falling back to body-end`),document.body)}function I(e){return new Promise((s,n)=>{if(!e.src){let r=d(),a=new Error('InjectOptions must have a "src" property');r.env!=="production"&&console.error("[Stagepass]",a),n(a);return}let t=d(),l=y(e.src,e.type),c=b(e);if(m(e,c)){s();return}let i=l==="script"?document.createElement("script"):document.createElement("link");if(l==="script"){let r=i;r.src=c,e.async?r.async=!0:e.defer!==!1&&(r.defer=!0),e.id&&(r.id=e.id),e.attributes&&Object.entries(e.attributes).forEach(([a,u])=>{r.setAttribute(a,u)}),r.onload=()=>{f(`Injected: ${c}`),s()},r.onerror=()=>{let a=new Error(`Failed to load script: ${c}`);t.env!=="production"&&console.error("[Stagepass]",a),n(a)}}else{let r=i;r.rel="stylesheet",r.href=c,e.id&&(r.id=e.id),e.attributes&&Object.entries(e.attributes).forEach(([u,p])=>{r.setAttribute(u,p)});let a=setInterval(()=>{(r.sheet||r.styleSheet)&&(clearInterval(a),f(`Injected: ${c}`),s())},10);setTimeout(()=>{if(clearInterval(a),!(r.sheet||r.styleSheet)){let p=new Error(`Failed to load stylesheet: ${c}`);t.env!=="production"&&console.error("[Stagepass]",p),n(p)}},5e3)}let o=j(e.position);if(!o){n(new Error("Could not find insertion point"));return}if(o===document.head||o===document.body)o.appendChild(i);else{let r=o.parentNode;r&&(typeof e.position=="object"&&e.position.action==="before"?r.insertBefore(i,o):r.insertBefore(i,o.nextSibling))}})}async function w(e){let s=[];if(!Array.isArray(e)&&typeof e=="object"&&("scripts"in e||"styles"in e)){let n=e;n.scripts&&s.push(...n.scripts.filter(t=>t&&typeof t=="object"&&"src"in t&&t.src).map(t=>({...t,type:"script"}))),n.styles&&s.push(...n.styles.filter(t=>t&&typeof t=="object"&&"src"in t&&t.src).map(t=>({...t,type:"style"})))}else s=(Array.isArray(e)?e:[e]).filter(t=>t&&typeof t=="object"&&"src"in t&&t.src);for(let n of s)try{await I(n)}catch(t){d().env!=="production"&&console.error("[Stagepass] Injection error:",t)}}let g=window.stagepass=window.stagepass||{};g.inject=w,globalThis.stagepass=g})();})();
1
+ "use strict";var StagepassInject=(()=>{(function(){function f(){let t=window.stagepass||globalThis.stagepass;if(!t||!t.vars)throw new Error("Stagepass core loader must be loaded before modules");return t.vars}function d(t){let r=f();(r.env==="local"||r.env==="staging")&&console.log(`[Stagepass] ${t}`)}function h(t){if(!t||typeof t!="string")return"file";try{let n=new URL(t).pathname||"";if(!n){let o=t.match(/\/([^\/\?#]+)(?:\?|#|$)/);return o?o[1]:"file"}let e=n.split("/");return e[e.length-1]||e[e.length-2]||"file"}catch{let n=t.match(/\/([^\/\?#]+)(?:\?|#|$)/);return n?n[1]:"file"}}function y(t,r){if(r)return r;if(!t||typeof t!="string")return"script";try{if(t.split(".").pop()?.toLowerCase()==="css")return"style"}catch{}return"script"}function b(t){let r=f(),{src:n,stagepass:e,localPath:o,path:i}=t;if(!n||typeof n!="string")throw new Error("Invalid src: must be a non-empty string");if(e!==!1&&r.isLocal){let c=o||i||h(n);if(!c||typeof c!="string")return n;let a=c.startsWith("/")?c.substring(1):c;return`https://${r.domain}/${a}?_cb=${r.timestamp}`}return n}function m(t,r){let{id:n,type:e}=t,o=y(t.src,e);if(n&&document.getElementById(n))return d(`Skipping injection: Element with id "${n}" already exists`),!0;let i=o==="script"?`script[src="${r}"]`:`link[href="${r}"]`;return document.querySelector(i)?(d(`Skipping injection: Resource "${r}" already loaded`),!0):!1}function j(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:r,action:n}=t,e=document.querySelector(r);return e?n==="before"?e:e.nextSibling||e.parentNode:(d(`Warning: Target selector "${r}" not found, falling back to body-end`),document.body)}function I(t){return new Promise((r,n)=>{if(!t.src){let s=f(),l=new Error('InjectOptions must have a "src" property');s.env!=="production"&&console.error("[Stagepass]",l),n(l);return}let e=f(),o=y(t.src,t.type),i=b(t);if(m(t,i)){r();return}let c=o==="script"?document.createElement("script"):document.createElement("link");if(o==="script"){let s=c;s.src=i,t.async?s.async=!0:t.defer!==!1&&(s.defer=!0),t.id&&(s.id=t.id),t.attributes&&Object.entries(t.attributes).forEach(([l,u])=>{s.setAttribute(l,u)}),s.onload=()=>{d(`Injected: ${i}`),r()},s.onerror=()=>{let l=new Error(`Failed to load script: ${i}`);e.env!=="production"&&console.error("[Stagepass]",l),n(l)}}else{let s=c;s.rel="stylesheet",s.href=i,t.id&&(s.id=t.id),t.attributes&&Object.entries(t.attributes).forEach(([u,p])=>{s.setAttribute(u,p)});let l=setInterval(()=>{(s.sheet||s.styleSheet)&&(clearInterval(l),d(`Injected: ${i}`),r())},10);setTimeout(()=>{if(clearInterval(l),!(s.sheet||s.styleSheet)){let p=new Error(`Failed to load stylesheet: ${i}`);e.env!=="production"&&console.error("[Stagepass]",p),n(p)}},5e3)}let a=j(t.position);if(!a){n(new Error("Could not find insertion point"));return}if(a===document.head||a===document.body)a.appendChild(c);else{let s=a.parentNode;s&&(typeof t.position=="object"&&t.position.action==="before"?s.insertBefore(c,a):s.insertBefore(c,a.nextSibling))}})}async function w(t){let r=[];if(!Array.isArray(t)&&typeof t=="object"&&("scripts"in t||"styles"in t)){let n=t;n.scripts&&r.push(...n.scripts.filter(e=>e&&typeof e=="object"&&"src"in e&&e.src&&typeof e.src=="string"&&e.src.trim().length>0).map(e=>({...e,type:"script"}))),n.styles&&r.push(...n.styles.filter(e=>e&&typeof e=="object"&&"src"in e&&e.src&&typeof e.src=="string"&&e.src.trim().length>0).map(e=>({...e,type:"style"})))}else r=(Array.isArray(t)?t:[t]).filter(e=>e&&typeof e=="object"&&"src"in e&&e.src&&typeof e.src=="string"&&e.src.trim().length>0);for(let n of r)try{await I(n)}catch(e){f().env!=="production"&&console.error("[Stagepass] Injection error:",e)}}let g=window.stagepass=window.stagepass||{};g.inject=w,globalThis.stagepass=g})();})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stagepass/modules",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Modular feature extensions for Stagepass",
5
5
  "type": "module",
6
6
  "main": "dist/all.min.js",