@patch-adams/core 1.6.2 → 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 +17 -18
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +17 -18
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +17 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -5
- package/dist/index.d.ts +1 -5
- package/dist/index.js +17 -18
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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-
|
|
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
|
|
|
@@ -6304,7 +6318,6 @@ var HtmlInjector = class {
|
|
|
6304
6318
|
inject(html) {
|
|
6305
6319
|
let result = html;
|
|
6306
6320
|
result = this.addHtmlAttributes(result);
|
|
6307
|
-
result = this.injectVersionResolver(result);
|
|
6308
6321
|
if (this.config.cssBefore.enabled) {
|
|
6309
6322
|
result = this.injectCssBefore(result);
|
|
6310
6323
|
}
|
|
@@ -6408,20 +6421,6 @@ ${pluginJs}
|
|
|
6408
6421
|
escapeAttr(str) {
|
|
6409
6422
|
return str.replace(/&/g, "&").replace(/"/g, """).replace(/'/g, "'").replace(/</g, "<").replace(/>/g, ">");
|
|
6410
6423
|
}
|
|
6411
|
-
/**
|
|
6412
|
-
* Inject a tiny inline script that fetches the asset version BEFORE any loaders.
|
|
6413
|
-
* Sets window.__pa_v so CSS Before, JS Before, and all other loaders get ?v= cache bust.
|
|
6414
|
-
*/
|
|
6415
|
-
injectVersionResolver(html) {
|
|
6416
|
-
const assetVersionUrl = this.config.assetVersionUrl || "";
|
|
6417
|
-
if (!assetVersionUrl) return html;
|
|
6418
|
-
const script = `<!-- === PATCH-ADAMS: VERSION RESOLVER === -->
|
|
6419
|
-
<script data-pa="version-resolver">
|
|
6420
|
-
(function(){try{var x=new XMLHttpRequest();x.open('GET','${assetVersionUrl}',false);x.send();if(x.status===200){window.__pa_v=JSON.parse(x.responseText).v||'1'}}catch(e){window.__pa_v='1'}})();
|
|
6421
|
-
</script>`;
|
|
6422
|
-
return html.replace(/<head([^>]*)>/i, `<head$1>
|
|
6423
|
-
${script}`);
|
|
6424
|
-
}
|
|
6425
6424
|
/**
|
|
6426
6425
|
* Inject CSS Before loader at start of <head>
|
|
6427
6426
|
*/
|