@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/index.d.cts CHANGED
@@ -1047,6 +1047,7 @@ interface CssBeforeOptions {
1047
1047
  localPath: string;
1048
1048
  htmlClass: string;
1049
1049
  loadingClass: string;
1050
+ assetVersionUrl?: string;
1050
1051
  }
1051
1052
  /**
1052
1053
  * Generate the blocking CSS loader for the "before" slot
package/dist/index.d.ts CHANGED
@@ -1047,6 +1047,7 @@ interface CssBeforeOptions {
1047
1047
  localPath: string;
1048
1048
  htmlClass: string;
1049
1049
  loadingClass: string;
1050
+ assetVersionUrl?: string;
1050
1051
  }
1051
1052
  /**
1052
1053
  * Generate the blocking CSS loader for the "before" slot
package/dist/index.js CHANGED
@@ -243,8 +243,8 @@ export default config;
243
243
 
244
244
  // src/templates/css-before.ts
245
245
  function generateCssBeforeLoader(options) {
246
- const { remoteUrl, localPath, htmlClass, loadingClass } = options;
247
- return `<!-- === PATCH-ADAMS: CSS BEFORE (blocking) === -->
246
+ const { remoteUrl, localPath, htmlClass, loadingClass, assetVersionUrl } = options;
247
+ return `<!-- === PATCH-ARMS: CSS BEFORE (blocking) === -->
248
248
  <style data-pa="css-before-critical">
249
249
  /* Critical: Hide content until ready */
250
250
  html.${htmlClass}.${loadingClass} body {
@@ -254,6 +254,19 @@ html.${htmlClass}.${loadingClass} body {
254
254
  <script data-pa="css-before-loader">
255
255
  (function() {
256
256
  'use strict';
257
+ // Fetch asset version FIRST \u2014 this is the earliest loader, so it sets window.__pa_v for all others
258
+ if (typeof window.__pa_v === 'undefined') {
259
+ window.__pa_v = '';
260
+ var AVU = "${assetVersionUrl || ""}";
261
+ if (AVU) {
262
+ try {
263
+ var xhr = new XMLHttpRequest();
264
+ xhr.open('GET', AVU, false);
265
+ xhr.send();
266
+ if (xhr.status === 200) { window.__pa_v = JSON.parse(xhr.responseText).v || '1'; }
267
+ } catch(e) { window.__pa_v = '1'; }
268
+ }
269
+ }
257
270
  var v = window.__pa_v || '';
258
271
  var REMOTE_URL = "${remoteUrl}" + (v ? "?v=" + v : "");
259
272
  var LOCAL_PATH = "${localPath}";
@@ -287,7 +300,8 @@ function buildCssBeforeOptions(config) {
287
300
  remoteUrl: `${config.remoteDomain}/${config.localFolders.css}/${config.cssBefore.filename}`,
288
301
  localPath: `${config.localFolders.css}/${config.cssBefore.filename}`,
289
302
  htmlClass: config.htmlClass,
290
- loadingClass: config.loadingClass
303
+ loadingClass: config.loadingClass,
304
+ assetVersionUrl: config.assetVersionUrl
291
305
  };
292
306
  }
293
307
 
@@ -5299,18 +5313,21 @@ window.pa_patcher = window.pa_patcher || {
5299
5313
 
5300
5314
  (function() {
5301
5315
  'use strict';
5302
- // Fetch server-controlled cache version (sync, once)
5303
- var ASSET_VERSION_URL = "${assetVersionUrl || ""}";
5304
- window.__pa_v = '';
5305
- if (ASSET_VERSION_URL) {
5306
- try {
5307
- var xhr = new XMLHttpRequest();
5308
- xhr.open('GET', ASSET_VERSION_URL, false);
5309
- xhr.send();
5310
- if (xhr.status === 200) {
5311
- window.__pa_v = JSON.parse(xhr.responseText).v || '1';
5312
- }
5313
- } catch(e) { window.__pa_v = '1'; }
5316
+ // Cache version \u2014 normally set by version resolver (injected before CSS Before).
5317
+ // Fallback: fetch here if version resolver didn't run (older patched packages).
5318
+ if (typeof window.__pa_v === 'undefined') {
5319
+ var ASSET_VERSION_URL = "${assetVersionUrl || ""}";
5320
+ window.__pa_v = '';
5321
+ if (ASSET_VERSION_URL) {
5322
+ try {
5323
+ var xhr = new XMLHttpRequest();
5324
+ xhr.open('GET', ASSET_VERSION_URL, false);
5325
+ xhr.send();
5326
+ if (xhr.status === 200) {
5327
+ window.__pa_v = JSON.parse(xhr.responseText).v || '1';
5328
+ }
5329
+ } catch(e) { window.__pa_v = '1'; }
5330
+ }
5314
5331
  }
5315
5332
 
5316
5333
  var REMOTE_URL = "${remoteUrl}" + (window.__pa_v ? "?v=" + window.__pa_v : "");