@patch-adams/core 1.6.1 → 1.6.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/cli.cjs CHANGED
@@ -603,8 +603,8 @@ export default config;
603
603
 
604
604
  // src/templates/css-before.ts
605
605
  function generateCssBeforeLoader(options) {
606
- const { remoteUrl, localPath, htmlClass, loadingClass } = options;
607
- return `<!-- === PATCH-ADAMS: CSS BEFORE (blocking) === -->
606
+ const { remoteUrl, localPath, htmlClass, loadingClass, assetVersionUrl } = options;
607
+ return `<!-- === PATCH-ARMS: CSS BEFORE (blocking) === -->
608
608
  <style data-pa="css-before-critical">
609
609
  /* Critical: Hide content until ready */
610
610
  html.${htmlClass}.${loadingClass} body {
@@ -614,6 +614,19 @@ html.${htmlClass}.${loadingClass} body {
614
614
  <script data-pa="css-before-loader">
615
615
  (function() {
616
616
  'use strict';
617
+ // Fetch asset version FIRST \u2014 this is the earliest loader, so it sets window.__pa_v for all others
618
+ if (typeof window.__pa_v === 'undefined') {
619
+ window.__pa_v = '';
620
+ var AVU = "${assetVersionUrl || ""}";
621
+ if (AVU) {
622
+ try {
623
+ var xhr = new XMLHttpRequest();
624
+ xhr.open('GET', AVU, false);
625
+ xhr.send();
626
+ if (xhr.status === 200) { window.__pa_v = JSON.parse(xhr.responseText).v || '1'; }
627
+ } catch(e) { window.__pa_v = '1'; }
628
+ }
629
+ }
617
630
  var v = window.__pa_v || '';
618
631
  var REMOTE_URL = "${remoteUrl}" + (v ? "?v=" + v : "");
619
632
  var LOCAL_PATH = "${localPath}";
@@ -647,7 +660,8 @@ function buildCssBeforeOptions(config) {
647
660
  remoteUrl: `${config.remoteDomain}/${config.localFolders.css}/${config.cssBefore.filename}`,
648
661
  localPath: `${config.localFolders.css}/${config.cssBefore.filename}`,
649
662
  htmlClass: config.htmlClass,
650
- loadingClass: config.loadingClass
663
+ loadingClass: config.loadingClass,
664
+ assetVersionUrl: config.assetVersionUrl
651
665
  };
652
666
  }
653
667
 
@@ -5640,18 +5654,21 @@ window.pa_patcher = window.pa_patcher || {
5640
5654
 
5641
5655
  (function() {
5642
5656
  'use strict';
5643
- // Fetch server-controlled cache version (sync, once)
5644
- var ASSET_VERSION_URL = "${assetVersionUrl || ""}";
5645
- window.__pa_v = '';
5646
- if (ASSET_VERSION_URL) {
5647
- try {
5648
- var xhr = new XMLHttpRequest();
5649
- xhr.open('GET', ASSET_VERSION_URL, false);
5650
- xhr.send();
5651
- if (xhr.status === 200) {
5652
- window.__pa_v = JSON.parse(xhr.responseText).v || '1';
5653
- }
5654
- } catch(e) { window.__pa_v = '1'; }
5657
+ // Cache version \u2014 normally set by version resolver (injected before CSS Before).
5658
+ // Fallback: fetch here if version resolver didn't run (older patched packages).
5659
+ if (typeof window.__pa_v === 'undefined') {
5660
+ var ASSET_VERSION_URL = "${assetVersionUrl || ""}";
5661
+ window.__pa_v = '';
5662
+ if (ASSET_VERSION_URL) {
5663
+ try {
5664
+ var xhr = new XMLHttpRequest();
5665
+ xhr.open('GET', ASSET_VERSION_URL, false);
5666
+ xhr.send();
5667
+ if (xhr.status === 200) {
5668
+ window.__pa_v = JSON.parse(xhr.responseText).v || '1';
5669
+ }
5670
+ } catch(e) { window.__pa_v = '1'; }
5671
+ }
5655
5672
  }
5656
5673
 
5657
5674
  var REMOTE_URL = "${remoteUrl}" + (window.__pa_v ? "?v=" + window.__pa_v : "");