tia-gpc-widget 2.0.2 → 2.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/loader.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * TIA GPC Widget Loader
3
- * @version 2.0.2
3
+ * @version 2.0.3
4
4
  */
5
5
 
6
6
  (function () {
@@ -12,7 +12,7 @@
12
12
  timeout: 15000,
13
13
  maxRetries: 3,
14
14
  retryDelay: 2000,
15
- fallbackVersion: '2.0.2',
15
+ fallbackVersion: '2.0.3',
16
16
  fallbackCdn: 'https://cdn.jsdelivr.net/npm/tia-gpc-widget'
17
17
  };
18
18
 
@@ -264,7 +264,7 @@
264
264
  }
265
265
 
266
266
  window.TiaGPCLoader = {
267
- version: '2.0.2',
267
+ version: '2.0.3',
268
268
  reload: init,
269
269
  config: CONFIG
270
270
  };
@@ -1,3 +1,3 @@
1
- /*! TIA GPC Widget Loader v2.0.1 | (c) 2025 TIA | UNLICENSED */
2
- !function(){"use strict";const e={versionUrl:"https://cdn.jsdelivr.net/npm/tia-gpc-widget@latest/dist/version.json",defaultChannel:"stable",timeout:15e3,maxRetries:3,retryDelay:2e3,fallbackVersion:"2.0.2",fallbackCdn:"https://cdn.jsdelivr.net/npm/tia-gpc-widget"};let t=0,n=Date.now();const o=function(e,t){console.warn("[TIA GPC Loader]",e,t||"")},i=function(e,t){console.error("[TIA GPC Loader]",e,t||"")};function a(e,t){window.dispatchEvent(new CustomEvent(e,{detail:t}))}function r(t){const n=e.fallbackCdn;return{version:t,js:`${n}@${t}/dist/tia-gpc-widget.standalone.js`,css:`${n}@${t}/dist/tia-gpc-widget.standalone.css`,timestamp:null}}async function s(r,d){t++;try{if(r.version,(c=r.css,new Promise((e,t)=>{if(document.querySelector(`link[href*="${c}"]`))return void e();const n=document.createElement("link");n.rel="stylesheet",n.href=c,n.crossOrigin="anonymous",n.onload=e,n.onerror=()=>t(new Error(`Failed to load CSS: ${c}`)),document.head.appendChild(n)})).catch(e=>{o("CSS loading failed, continuing anyway",e)}),await function(t,n){return new Promise((o,i)=>{const a=document.createElement("script");let r;a.src=t,a.async=!0,a.crossOrigin="anonymous",a.onload=function(){clearTimeout(r),o()},a.onerror=function(){clearTimeout(r),i(new Error(`Failed to load script: ${t}`))},r=setTimeout(()=>{i(new Error(`Timeout loading script: ${t}`))},n||e.timeout),document.head.appendChild(a)})}(r.js,e.timeout),!window.TiaGPC)throw new Error("Widget loaded but TiaGPC global not found");const i=Date.now()-n;return r.version,window.TiaGPCWidgetLoaded=!0,window.TiaGPCWidgetVersion=r.version,a("tia-gpc-loader-ready",{version:r.version,loadTime:i,attempts:t,channel:d.channel}),d.apiUrl&&function(e,t){try{fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}).catch(()=>{})}catch(e){}}(d.apiUrl,{event:"widget_loaded",version:r.version,loadTime:i,url:window.location.href}),!0}catch(n){if(i(`Failed to load widget (attempt ${t})`,n.message),t<e.maxRetries)return await new Promise(t=>setTimeout(t,e.retryDelay)),s(r,d);throw a("tia-gpc-loader-error",{error:n.message,attempts:t,version:r.version}),new Error(`Failed to load widget after ${t} attempts: ${n.message}`)}var c}async function d(){try{if(!0===window.TiaGPCWidgetLoaded||void 0!==window.TiaGPC)return void o("Widget already loaded, skipping");const t=function(){const t=document.currentScript||document.querySelector('script[src*="loader"]');return t?{channel:t.getAttribute("data-channel")||e.defaultChannel,version:t.getAttribute("data-version")||null,debug:"true"===t.getAttribute("data-debug"),apiUrl:t.getAttribute("data-api-url")||null}:{}}();t.debug;const n=await async function(t){try{if(t.version)return r(t.version);const n=Date.now(),o=`${e.versionUrl}?_=${n}`,i=await fetch(o,{cache:"no-cache",headers:{"Cache-Control":"no-cache, no-store, must-revalidate",Pragma:"no-cache"}});if(!i.ok)throw new Error(`HTTP ${i.status}: ${i.statusText}`);const a=await i.json(),s=a[t.channel]||a.stable;return{version:a.version,js:s.js,css:s.css,timestamp:a.timestamp}}catch(t){return o("Failed to fetch version info, using fallback",t.message),r(e.fallbackVersion)}}(t);t.debug,await s(n,t)}catch(e){i("Fatal error initializing widget",e);const t=document.querySelectorAll("tia-gpc-widget");t.length>0&&t.forEach(t=>{t.innerHTML=`\n <div style="padding: 20px; background: #fee; border: 2px solid #c00; border-radius: 8px; font-family: sans-serif;">\n <strong>Error loading TIA GPC Widget</strong>\n <p style="margin: 10px 0 0 0; font-size: 14px;">${e.message}</p>\n </div>\n `})}}"loading"===document.readyState?document.addEventListener("DOMContentLoaded",d):d(),window.TiaGPCLoader={version:"2.0.2",reload:d,config:e}}();
1
+ /*! TIA GPC Widget Loader v2.0.3 | (c) 2025 TIA | UNLICENSED */
2
+ !function(){"use strict";const e={versionUrl:"https://cdn.jsdelivr.net/npm/tia-gpc-widget@latest/dist/version.json",defaultChannel:"stable",timeout:15e3,maxRetries:3,retryDelay:2e3,fallbackVersion:"2.0.3",fallbackCdn:"https://cdn.jsdelivr.net/npm/tia-gpc-widget"};let t=0,n=Date.now();const o=function(e,t){console.warn("[TIA GPC Loader]",e,t||"")},i=function(e,t){console.error("[TIA GPC Loader]",e,t||"")};function a(e,t){window.dispatchEvent(new CustomEvent(e,{detail:t}))}function r(t){const n=e.fallbackCdn;return{version:t,js:`${n}@${t}/dist/tia-gpc-widget.standalone.js`,css:`${n}@${t}/dist/tia-gpc-widget.standalone.css`,timestamp:null}}async function s(r,d){t++;try{if(r.version,(c=r.css,new Promise((e,t)=>{if(document.querySelector(`link[href*="${c}"]`))return void e();const n=document.createElement("link");n.rel="stylesheet",n.href=c,n.crossOrigin="anonymous",n.onload=e,n.onerror=()=>t(new Error(`Failed to load CSS: ${c}`)),document.head.appendChild(n)})).catch(e=>{o("CSS loading failed, continuing anyway",e)}),await function(t,n){return new Promise((o,i)=>{const a=document.createElement("script");let r;a.src=t,a.async=!0,a.crossOrigin="anonymous",a.onload=function(){clearTimeout(r),o()},a.onerror=function(){clearTimeout(r),i(new Error(`Failed to load script: ${t}`))},r=setTimeout(()=>{i(new Error(`Timeout loading script: ${t}`))},n||e.timeout),document.head.appendChild(a)})}(r.js,e.timeout),!window.TiaGPC)throw new Error("Widget loaded but TiaGPC global not found");const i=Date.now()-n;return r.version,window.TiaGPCWidgetLoaded=!0,window.TiaGPCWidgetVersion=r.version,a("tia-gpc-loader-ready",{version:r.version,loadTime:i,attempts:t,channel:d.channel}),d.apiUrl&&function(e,t){try{fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}).catch(()=>{})}catch(e){}}(d.apiUrl,{event:"widget_loaded",version:r.version,loadTime:i,url:window.location.href}),!0}catch(n){if(i(`Failed to load widget (attempt ${t})`,n.message),t<e.maxRetries)return await new Promise(t=>setTimeout(t,e.retryDelay)),s(r,d);throw a("tia-gpc-loader-error",{error:n.message,attempts:t,version:r.version}),new Error(`Failed to load widget after ${t} attempts: ${n.message}`)}var c}async function d(){try{if(!0===window.TiaGPCWidgetLoaded||void 0!==window.TiaGPC)return void o("Widget already loaded, skipping");const t=function(){const t=document.currentScript||document.querySelector('script[src*="loader"]');return t?{channel:t.getAttribute("data-channel")||e.defaultChannel,version:t.getAttribute("data-version")||null,debug:"true"===t.getAttribute("data-debug"),apiUrl:t.getAttribute("data-api-url")||null}:{}}();t.debug;const n=await async function(t){try{if(t.version)return r(t.version);const n=Date.now(),o=`${e.versionUrl}?_=${n}`,i=await fetch(o,{cache:"no-cache",headers:{"Cache-Control":"no-cache, no-store, must-revalidate",Pragma:"no-cache"}});if(!i.ok)throw new Error(`HTTP ${i.status}: ${i.statusText}`);const a=await i.json(),s=a[t.channel]||a.stable;return{version:a.version,js:s.js,css:s.css,timestamp:a.timestamp}}catch(t){return o("Failed to fetch version info, using fallback",t.message),r(e.fallbackVersion)}}(t);t.debug,await s(n,t)}catch(e){i("Fatal error initializing widget",e);const t=document.querySelectorAll("tia-gpc-widget");t.length>0&&t.forEach(t=>{t.innerHTML=`\n <div style="padding: 20px; background: #fee; border: 2px solid #c00; border-radius: 8px; font-family: sans-serif;">\n <strong>Error loading TIA GPC Widget</strong>\n <p style="margin: 10px 0 0 0; font-size: 14px;">${e.message}</p>\n </div>\n `})}}"loading"===document.readyState?document.addEventListener("DOMContentLoaded",d):d(),window.TiaGPCLoader={version:"2.0.3",reload:d,config:e}}();
3
3
  //# sourceMappingURL=loader.min.js.map