@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/index.d.cts
CHANGED
|
@@ -762,11 +762,6 @@ declare class HtmlInjector {
|
|
|
762
762
|
* Escape a string for use in HTML attributes
|
|
763
763
|
*/
|
|
764
764
|
private escapeAttr;
|
|
765
|
-
/**
|
|
766
|
-
* Inject a tiny inline script that fetches the asset version BEFORE any loaders.
|
|
767
|
-
* Sets window.__pa_v so CSS Before, JS Before, and all other loaders get ?v= cache bust.
|
|
768
|
-
*/
|
|
769
|
-
private injectVersionResolver;
|
|
770
765
|
/**
|
|
771
766
|
* Inject CSS Before loader at start of <head>
|
|
772
767
|
*/
|
|
@@ -1052,6 +1047,7 @@ interface CssBeforeOptions {
|
|
|
1052
1047
|
localPath: string;
|
|
1053
1048
|
htmlClass: string;
|
|
1054
1049
|
loadingClass: string;
|
|
1050
|
+
assetVersionUrl?: string;
|
|
1055
1051
|
}
|
|
1056
1052
|
/**
|
|
1057
1053
|
* Generate the blocking CSS loader for the "before" slot
|
package/dist/index.d.ts
CHANGED
|
@@ -762,11 +762,6 @@ declare class HtmlInjector {
|
|
|
762
762
|
* Escape a string for use in HTML attributes
|
|
763
763
|
*/
|
|
764
764
|
private escapeAttr;
|
|
765
|
-
/**
|
|
766
|
-
* Inject a tiny inline script that fetches the asset version BEFORE any loaders.
|
|
767
|
-
* Sets window.__pa_v so CSS Before, JS Before, and all other loaders get ?v= cache bust.
|
|
768
|
-
*/
|
|
769
|
-
private injectVersionResolver;
|
|
770
765
|
/**
|
|
771
766
|
* Inject CSS Before loader at start of <head>
|
|
772
767
|
*/
|
|
@@ -1052,6 +1047,7 @@ interface CssBeforeOptions {
|
|
|
1052
1047
|
localPath: string;
|
|
1053
1048
|
htmlClass: string;
|
|
1054
1049
|
loadingClass: string;
|
|
1050
|
+
assetVersionUrl?: string;
|
|
1055
1051
|
}
|
|
1056
1052
|
/**
|
|
1057
1053
|
* Generate the blocking CSS loader for the "before" slot
|
package/dist/index.js
CHANGED
|
@@ -243,8 +243,8 @@ export default config;
|
|
|
243
243
|
|
|
244
244
|
// src/templates/css-before.ts
|
|
245
245
|
function generateCssBeforeLoader(options) {
|
|
246
|
-
const { remoteUrl, localPath, htmlClass, loadingClass } = options;
|
|
247
|
-
return `<!-- === PATCH-
|
|
246
|
+
const { remoteUrl, localPath, htmlClass, loadingClass, assetVersionUrl } = options;
|
|
247
|
+
return `<!-- === PATCH-ARMS: CSS BEFORE (blocking) === -->
|
|
248
248
|
<style data-pa="css-before-critical">
|
|
249
249
|
/* Critical: Hide content until ready */
|
|
250
250
|
html.${htmlClass}.${loadingClass} body {
|
|
@@ -254,6 +254,19 @@ html.${htmlClass}.${loadingClass} body {
|
|
|
254
254
|
<script data-pa="css-before-loader">
|
|
255
255
|
(function() {
|
|
256
256
|
'use strict';
|
|
257
|
+
// Fetch asset version FIRST \u2014 this is the earliest loader, so it sets window.__pa_v for all others
|
|
258
|
+
if (typeof window.__pa_v === 'undefined') {
|
|
259
|
+
window.__pa_v = '';
|
|
260
|
+
var AVU = "${assetVersionUrl || ""}";
|
|
261
|
+
if (AVU) {
|
|
262
|
+
try {
|
|
263
|
+
var xhr = new XMLHttpRequest();
|
|
264
|
+
xhr.open('GET', AVU, false);
|
|
265
|
+
xhr.send();
|
|
266
|
+
if (xhr.status === 200) { window.__pa_v = JSON.parse(xhr.responseText).v || '1'; }
|
|
267
|
+
} catch(e) { window.__pa_v = '1'; }
|
|
268
|
+
}
|
|
269
|
+
}
|
|
257
270
|
var v = window.__pa_v || '';
|
|
258
271
|
var REMOTE_URL = "${remoteUrl}" + (v ? "?v=" + v : "");
|
|
259
272
|
var LOCAL_PATH = "${localPath}";
|
|
@@ -287,7 +300,8 @@ function buildCssBeforeOptions(config) {
|
|
|
287
300
|
remoteUrl: `${config.remoteDomain}/${config.localFolders.css}/${config.cssBefore.filename}`,
|
|
288
301
|
localPath: `${config.localFolders.css}/${config.cssBefore.filename}`,
|
|
289
302
|
htmlClass: config.htmlClass,
|
|
290
|
-
loadingClass: config.loadingClass
|
|
303
|
+
loadingClass: config.loadingClass,
|
|
304
|
+
assetVersionUrl: config.assetVersionUrl
|
|
291
305
|
};
|
|
292
306
|
}
|
|
293
307
|
|
|
@@ -5963,7 +5977,6 @@ var HtmlInjector = class {
|
|
|
5963
5977
|
inject(html) {
|
|
5964
5978
|
let result = html;
|
|
5965
5979
|
result = this.addHtmlAttributes(result);
|
|
5966
|
-
result = this.injectVersionResolver(result);
|
|
5967
5980
|
if (this.config.cssBefore.enabled) {
|
|
5968
5981
|
result = this.injectCssBefore(result);
|
|
5969
5982
|
}
|
|
@@ -6067,20 +6080,6 @@ ${pluginJs}
|
|
|
6067
6080
|
escapeAttr(str) {
|
|
6068
6081
|
return str.replace(/&/g, "&").replace(/"/g, """).replace(/'/g, "'").replace(/</g, "<").replace(/>/g, ">");
|
|
6069
6082
|
}
|
|
6070
|
-
/**
|
|
6071
|
-
* Inject a tiny inline script that fetches the asset version BEFORE any loaders.
|
|
6072
|
-
* Sets window.__pa_v so CSS Before, JS Before, and all other loaders get ?v= cache bust.
|
|
6073
|
-
*/
|
|
6074
|
-
injectVersionResolver(html) {
|
|
6075
|
-
const assetVersionUrl = this.config.assetVersionUrl || "";
|
|
6076
|
-
if (!assetVersionUrl) return html;
|
|
6077
|
-
const script = `<!-- === PATCH-ADAMS: VERSION RESOLVER === -->
|
|
6078
|
-
<script data-pa="version-resolver">
|
|
6079
|
-
(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'}})();
|
|
6080
|
-
</script>`;
|
|
6081
|
-
return html.replace(/<head([^>]*)>/i, `<head$1>
|
|
6082
|
-
${script}`);
|
|
6083
|
-
}
|
|
6084
6083
|
/**
|
|
6085
6084
|
* Inject CSS Before loader at start of <head>
|
|
6086
6085
|
*/
|