@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.js
CHANGED
|
@@ -5630,18 +5630,21 @@ window.pa_patcher = window.pa_patcher || {
|
|
|
5630
5630
|
|
|
5631
5631
|
(function() {
|
|
5632
5632
|
'use strict';
|
|
5633
|
-
//
|
|
5634
|
-
|
|
5635
|
-
window.__pa_v
|
|
5636
|
-
|
|
5637
|
-
|
|
5638
|
-
|
|
5639
|
-
|
|
5640
|
-
|
|
5641
|
-
|
|
5642
|
-
|
|
5643
|
-
|
|
5644
|
-
|
|
5633
|
+
// Cache version \u2014 normally set by version resolver (injected before CSS Before).
|
|
5634
|
+
// Fallback: fetch here if version resolver didn't run (older patched packages).
|
|
5635
|
+
if (typeof window.__pa_v === 'undefined') {
|
|
5636
|
+
var ASSET_VERSION_URL = "${assetVersionUrl || ""}";
|
|
5637
|
+
window.__pa_v = '';
|
|
5638
|
+
if (ASSET_VERSION_URL) {
|
|
5639
|
+
try {
|
|
5640
|
+
var xhr = new XMLHttpRequest();
|
|
5641
|
+
xhr.open('GET', ASSET_VERSION_URL, false);
|
|
5642
|
+
xhr.send();
|
|
5643
|
+
if (xhr.status === 200) {
|
|
5644
|
+
window.__pa_v = JSON.parse(xhr.responseText).v || '1';
|
|
5645
|
+
}
|
|
5646
|
+
} catch(e) { window.__pa_v = '1'; }
|
|
5647
|
+
}
|
|
5645
5648
|
}
|
|
5646
5649
|
|
|
5647
5650
|
var REMOTE_URL = "${remoteUrl}" + (window.__pa_v ? "?v=" + window.__pa_v : "");
|
|
@@ -6291,6 +6294,7 @@ var HtmlInjector = class {
|
|
|
6291
6294
|
inject(html) {
|
|
6292
6295
|
let result = html;
|
|
6293
6296
|
result = this.addHtmlAttributes(result);
|
|
6297
|
+
result = this.injectVersionResolver(result);
|
|
6294
6298
|
if (this.config.cssBefore.enabled) {
|
|
6295
6299
|
result = this.injectCssBefore(result);
|
|
6296
6300
|
}
|
|
@@ -6394,6 +6398,20 @@ ${pluginJs}
|
|
|
6394
6398
|
escapeAttr(str) {
|
|
6395
6399
|
return str.replace(/&/g, "&").replace(/"/g, """).replace(/'/g, "'").replace(/</g, "<").replace(/>/g, ">");
|
|
6396
6400
|
}
|
|
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
|
+
}
|
|
6397
6415
|
/**
|
|
6398
6416
|
* Inject CSS Before loader at start of <head>
|
|
6399
6417
|
*/
|