@patch-adams/core 1.6.1 → 1.6.2
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 +30 -12
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +30 -12
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +30 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +30 -12
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -5640,18 +5640,21 @@ window.pa_patcher = window.pa_patcher || {
|
|
|
5640
5640
|
|
|
5641
5641
|
(function() {
|
|
5642
5642
|
'use strict';
|
|
5643
|
-
//
|
|
5644
|
-
|
|
5645
|
-
window.__pa_v
|
|
5646
|
-
|
|
5647
|
-
|
|
5648
|
-
|
|
5649
|
-
|
|
5650
|
-
|
|
5651
|
-
|
|
5652
|
-
|
|
5653
|
-
|
|
5654
|
-
|
|
5643
|
+
// Cache version \u2014 normally set by version resolver (injected before CSS Before).
|
|
5644
|
+
// Fallback: fetch here if version resolver didn't run (older patched packages).
|
|
5645
|
+
if (typeof window.__pa_v === 'undefined') {
|
|
5646
|
+
var ASSET_VERSION_URL = "${assetVersionUrl || ""}";
|
|
5647
|
+
window.__pa_v = '';
|
|
5648
|
+
if (ASSET_VERSION_URL) {
|
|
5649
|
+
try {
|
|
5650
|
+
var xhr = new XMLHttpRequest();
|
|
5651
|
+
xhr.open('GET', ASSET_VERSION_URL, false);
|
|
5652
|
+
xhr.send();
|
|
5653
|
+
if (xhr.status === 200) {
|
|
5654
|
+
window.__pa_v = JSON.parse(xhr.responseText).v || '1';
|
|
5655
|
+
}
|
|
5656
|
+
} catch(e) { window.__pa_v = '1'; }
|
|
5657
|
+
}
|
|
5655
5658
|
}
|
|
5656
5659
|
|
|
5657
5660
|
var REMOTE_URL = "${remoteUrl}" + (window.__pa_v ? "?v=" + window.__pa_v : "");
|
|
@@ -6301,6 +6304,7 @@ var HtmlInjector = class {
|
|
|
6301
6304
|
inject(html) {
|
|
6302
6305
|
let result = html;
|
|
6303
6306
|
result = this.addHtmlAttributes(result);
|
|
6307
|
+
result = this.injectVersionResolver(result);
|
|
6304
6308
|
if (this.config.cssBefore.enabled) {
|
|
6305
6309
|
result = this.injectCssBefore(result);
|
|
6306
6310
|
}
|
|
@@ -6404,6 +6408,20 @@ ${pluginJs}
|
|
|
6404
6408
|
escapeAttr(str) {
|
|
6405
6409
|
return str.replace(/&/g, "&").replace(/"/g, """).replace(/'/g, "'").replace(/</g, "<").replace(/>/g, ">");
|
|
6406
6410
|
}
|
|
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
|
+
}
|
|
6407
6425
|
/**
|
|
6408
6426
|
* Inject CSS Before loader at start of <head>
|
|
6409
6427
|
*/
|