@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/index.cjs
CHANGED
|
@@ -5308,18 +5308,21 @@ window.pa_patcher = window.pa_patcher || {
|
|
|
5308
5308
|
|
|
5309
5309
|
(function() {
|
|
5310
5310
|
'use strict';
|
|
5311
|
-
//
|
|
5312
|
-
|
|
5313
|
-
window.__pa_v
|
|
5314
|
-
|
|
5315
|
-
|
|
5316
|
-
|
|
5317
|
-
|
|
5318
|
-
|
|
5319
|
-
|
|
5320
|
-
|
|
5321
|
-
|
|
5322
|
-
|
|
5311
|
+
// Cache version \u2014 normally set by version resolver (injected before CSS Before).
|
|
5312
|
+
// Fallback: fetch here if version resolver didn't run (older patched packages).
|
|
5313
|
+
if (typeof window.__pa_v === 'undefined') {
|
|
5314
|
+
var ASSET_VERSION_URL = "${assetVersionUrl || ""}";
|
|
5315
|
+
window.__pa_v = '';
|
|
5316
|
+
if (ASSET_VERSION_URL) {
|
|
5317
|
+
try {
|
|
5318
|
+
var xhr = new XMLHttpRequest();
|
|
5319
|
+
xhr.open('GET', ASSET_VERSION_URL, false);
|
|
5320
|
+
xhr.send();
|
|
5321
|
+
if (xhr.status === 200) {
|
|
5322
|
+
window.__pa_v = JSON.parse(xhr.responseText).v || '1';
|
|
5323
|
+
}
|
|
5324
|
+
} catch(e) { window.__pa_v = '1'; }
|
|
5325
|
+
}
|
|
5323
5326
|
}
|
|
5324
5327
|
|
|
5325
5328
|
var REMOTE_URL = "${remoteUrl}" + (window.__pa_v ? "?v=" + window.__pa_v : "");
|
|
@@ -5969,6 +5972,7 @@ var HtmlInjector = class {
|
|
|
5969
5972
|
inject(html) {
|
|
5970
5973
|
let result = html;
|
|
5971
5974
|
result = this.addHtmlAttributes(result);
|
|
5975
|
+
result = this.injectVersionResolver(result);
|
|
5972
5976
|
if (this.config.cssBefore.enabled) {
|
|
5973
5977
|
result = this.injectCssBefore(result);
|
|
5974
5978
|
}
|
|
@@ -6072,6 +6076,20 @@ ${pluginJs}
|
|
|
6072
6076
|
escapeAttr(str) {
|
|
6073
6077
|
return str.replace(/&/g, "&").replace(/"/g, """).replace(/'/g, "'").replace(/</g, "<").replace(/>/g, ">");
|
|
6074
6078
|
}
|
|
6079
|
+
/**
|
|
6080
|
+
* Inject a tiny inline script that fetches the asset version BEFORE any loaders.
|
|
6081
|
+
* Sets window.__pa_v so CSS Before, JS Before, and all other loaders get ?v= cache bust.
|
|
6082
|
+
*/
|
|
6083
|
+
injectVersionResolver(html) {
|
|
6084
|
+
const assetVersionUrl = this.config.assetVersionUrl || "";
|
|
6085
|
+
if (!assetVersionUrl) return html;
|
|
6086
|
+
const script = `<!-- === PATCH-ADAMS: VERSION RESOLVER === -->
|
|
6087
|
+
<script data-pa="version-resolver">
|
|
6088
|
+
(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'}})();
|
|
6089
|
+
</script>`;
|
|
6090
|
+
return html.replace(/<head([^>]*)>/i, `<head$1>
|
|
6091
|
+
${script}`);
|
|
6092
|
+
}
|
|
6075
6093
|
/**
|
|
6076
6094
|
* Inject CSS Before loader at start of <head>
|
|
6077
6095
|
*/
|