@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.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-
|
|
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
|
|
|
@@ -6294,7 +6308,6 @@ var HtmlInjector = class {
|
|
|
6294
6308
|
inject(html) {
|
|
6295
6309
|
let result = html;
|
|
6296
6310
|
result = this.addHtmlAttributes(result);
|
|
6297
|
-
result = this.injectVersionResolver(result);
|
|
6298
6311
|
if (this.config.cssBefore.enabled) {
|
|
6299
6312
|
result = this.injectCssBefore(result);
|
|
6300
6313
|
}
|
|
@@ -6398,20 +6411,6 @@ ${pluginJs}
|
|
|
6398
6411
|
escapeAttr(str) {
|
|
6399
6412
|
return str.replace(/&/g, "&").replace(/"/g, """).replace(/'/g, "'").replace(/</g, "<").replace(/>/g, ">");
|
|
6400
6413
|
}
|
|
6401
|
-
/**
|
|
6402
|
-
* Inject a tiny inline script that fetches the asset version BEFORE any loaders.
|
|
6403
|
-
* Sets window.__pa_v so CSS Before, JS Before, and all other loaders get ?v= cache bust.
|
|
6404
|
-
*/
|
|
6405
|
-
injectVersionResolver(html) {
|
|
6406
|
-
const assetVersionUrl = this.config.assetVersionUrl || "";
|
|
6407
|
-
if (!assetVersionUrl) return html;
|
|
6408
|
-
const script = `<!-- === PATCH-ADAMS: VERSION RESOLVER === -->
|
|
6409
|
-
<script data-pa="version-resolver">
|
|
6410
|
-
(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'}})();
|
|
6411
|
-
</script>`;
|
|
6412
|
-
return html.replace(/<head([^>]*)>/i, `<head$1>
|
|
6413
|
-
${script}`);
|
|
6414
|
-
}
|
|
6415
6414
|
/**
|
|
6416
6415
|
* Inject CSS Before loader at start of <head>
|
|
6417
6416
|
*/
|