@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.js CHANGED
@@ -593,8 +593,8 @@ export default config;
593
593
 
594
594
  // src/templates/css-before.ts
595
595
  function generateCssBeforeLoader(options) {
596
- const { remoteUrl, localPath, htmlClass, loadingClass } = options;
597
- return `<!-- === PATCH-ADAMS: CSS BEFORE (blocking) === -->
596
+ const { remoteUrl, localPath, htmlClass, loadingClass, assetVersionUrl } = options;
597
+ return `<!-- === PATCH-ARMS: CSS BEFORE (blocking) === -->
598
598
  <style data-pa="css-before-critical">
599
599
  /* Critical: Hide content until ready */
600
600
  html.${htmlClass}.${loadingClass} body {
@@ -604,6 +604,19 @@ html.${htmlClass}.${loadingClass} body {
604
604
  <script data-pa="css-before-loader">
605
605
  (function() {
606
606
  'use strict';
607
+ // Fetch asset version FIRST \u2014 this is the earliest loader, so it sets window.__pa_v for all others
608
+ if (typeof window.__pa_v === 'undefined') {
609
+ window.__pa_v = '';
610
+ var AVU = "${assetVersionUrl || ""}";
611
+ if (AVU) {
612
+ try {
613
+ var xhr = new XMLHttpRequest();
614
+ xhr.open('GET', AVU, false);
615
+ xhr.send();
616
+ if (xhr.status === 200) { window.__pa_v = JSON.parse(xhr.responseText).v || '1'; }
617
+ } catch(e) { window.__pa_v = '1'; }
618
+ }
619
+ }
607
620
  var v = window.__pa_v || '';
608
621
  var REMOTE_URL = "${remoteUrl}" + (v ? "?v=" + v : "");
609
622
  var LOCAL_PATH = "${localPath}";
@@ -637,7 +650,8 @@ function buildCssBeforeOptions(config) {
637
650
  remoteUrl: `${config.remoteDomain}/${config.localFolders.css}/${config.cssBefore.filename}`,
638
651
  localPath: `${config.localFolders.css}/${config.cssBefore.filename}`,
639
652
  htmlClass: config.htmlClass,
640
- loadingClass: config.loadingClass
653
+ loadingClass: config.loadingClass,
654
+ assetVersionUrl: config.assetVersionUrl
641
655
  };
642
656
  }
643
657
 
@@ -5630,18 +5644,21 @@ window.pa_patcher = window.pa_patcher || {
5630
5644
 
5631
5645
  (function() {
5632
5646
  'use strict';
5633
- // Fetch server-controlled cache version (sync, once)
5634
- var ASSET_VERSION_URL = "${assetVersionUrl || ""}";
5635
- window.__pa_v = '';
5636
- if (ASSET_VERSION_URL) {
5637
- try {
5638
- var xhr = new XMLHttpRequest();
5639
- xhr.open('GET', ASSET_VERSION_URL, false);
5640
- xhr.send();
5641
- if (xhr.status === 200) {
5642
- window.__pa_v = JSON.parse(xhr.responseText).v || '1';
5643
- }
5644
- } catch(e) { window.__pa_v = '1'; }
5647
+ // Cache version \u2014 normally set by version resolver (injected before CSS Before).
5648
+ // Fallback: fetch here if version resolver didn't run (older patched packages).
5649
+ if (typeof window.__pa_v === 'undefined') {
5650
+ var ASSET_VERSION_URL = "${assetVersionUrl || ""}";
5651
+ window.__pa_v = '';
5652
+ if (ASSET_VERSION_URL) {
5653
+ try {
5654
+ var xhr = new XMLHttpRequest();
5655
+ xhr.open('GET', ASSET_VERSION_URL, false);
5656
+ xhr.send();
5657
+ if (xhr.status === 200) {
5658
+ window.__pa_v = JSON.parse(xhr.responseText).v || '1';
5659
+ }
5660
+ } catch(e) { window.__pa_v = '1'; }
5661
+ }
5645
5662
  }
5646
5663
 
5647
5664
  var REMOTE_URL = "${remoteUrl}" + (window.__pa_v ? "?v=" + window.__pa_v : "");