corequery 0.1.6 → 0.1.8
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/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import fsp from "fs/promises";
|
|
3
3
|
import { parse } from "node-html-parser";
|
|
4
|
+
import crypto from "crypto";
|
|
4
5
|
export class WebServerAssetPreparer {
|
|
5
6
|
_config;
|
|
6
7
|
constructor(_config) {
|
|
@@ -12,6 +13,9 @@ export class WebServerAssetPreparer {
|
|
|
12
13
|
await this._replaceIndexHtmlTags(indexHtmlPath);
|
|
13
14
|
await this._replaceWebManifest(webManifestPath);
|
|
14
15
|
await this._replaceIcons(distFolderPath);
|
|
16
|
+
// Must come last, otherwise we'll calculate hashes before the file contents
|
|
17
|
+
// are swapped.
|
|
18
|
+
await this._replaceServiceWorkerRevisionHashes(distFolderPath);
|
|
15
19
|
}
|
|
16
20
|
async _replaceWebManifest(filePath) {
|
|
17
21
|
const manifestStr = await fsp.readFile(filePath, "utf-8");
|
|
@@ -31,7 +35,7 @@ export class WebServerAssetPreparer {
|
|
|
31
35
|
function requireTag(selector) {
|
|
32
36
|
const tag = indexHtml.querySelector(selector);
|
|
33
37
|
if (tag == null)
|
|
34
|
-
throw new Error(
|
|
38
|
+
throw new Error(`"${selector}" tag not found.`);
|
|
35
39
|
return tag;
|
|
36
40
|
}
|
|
37
41
|
const titleTag = requireTag("title");
|
|
@@ -59,5 +63,38 @@ export class WebServerAssetPreparer {
|
|
|
59
63
|
await fsp.copyFile(sourcePath, destPath);
|
|
60
64
|
}
|
|
61
65
|
}
|
|
66
|
+
async _replaceServiceWorkerRevisionHashes(distFolderPath) {
|
|
67
|
+
const serviceWorkerPath = path.join(distFolderPath, "sw.js");
|
|
68
|
+
const serviceWorkerStr = await fsp.readFile(serviceWorkerPath, "utf-8");
|
|
69
|
+
// Any files this class modifies should be listed here.
|
|
70
|
+
const filesRequiringRevisionUpdates = [
|
|
71
|
+
"index.html",
|
|
72
|
+
"manifest.webmanifest",
|
|
73
|
+
"favicon.svg",
|
|
74
|
+
"apple-touch-icon.png",
|
|
75
|
+
"pwa-192x192.png",
|
|
76
|
+
"pwa-512x512.png",
|
|
77
|
+
"pwa-maskable-192x192.png",
|
|
78
|
+
"pwa-maskable-512x512.png",
|
|
79
|
+
];
|
|
80
|
+
const matches = Array.from(serviceWorkerStr.matchAll(/{url:"([^"]+)",revision:"[^"]+"}/g)).map((match) => ({
|
|
81
|
+
fullText: match[0],
|
|
82
|
+
url: match[1],
|
|
83
|
+
}));
|
|
84
|
+
let newServiceWorkerStr = serviceWorkerStr;
|
|
85
|
+
for (const file of filesRequiringRevisionUpdates) {
|
|
86
|
+
// Filter, as some assets (e.g. pwa-192x192.png) are in there twice.
|
|
87
|
+
const entries = matches.filter((m) => m.url === file);
|
|
88
|
+
if (entries.length === 0)
|
|
89
|
+
throw new Error(`"${file}" had no revisions.`);
|
|
90
|
+
const fullFilePath = path.join(distFolderPath, file);
|
|
91
|
+
const fileContent = await fsp.readFile(fullFilePath);
|
|
92
|
+
const hash = crypto.createHash("md5").update(fileContent).digest("hex");
|
|
93
|
+
for (const entry of entries) {
|
|
94
|
+
newServiceWorkerStr = newServiceWorkerStr.replace(entry.fullText, `{url:"${entry.url}",revision:"${hash}"}`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
await fsp.writeFile(serviceWorkerPath, newServiceWorkerStr);
|
|
98
|
+
}
|
|
62
99
|
}
|
|
63
100
|
//# sourceMappingURL=web-server-asset-preparer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web-server-asset-preparer.js","sourceRoot":"","sources":["../../web-server-asset-preparer.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,GAAG,MAAM,aAAa,CAAC;AAC9B,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;
|
|
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AAE,KAAK,CAAC,CAAC,CAAC;SACd,CAAC,CAAC,CAAC;QAEJ,IAAI,mBAAmB,GAAG,gBAAgB,CAAC;QAE3C,KAAK,MAAM,IAAI,IAAI,6BAA6B,EAAE,CAAC;YACjD,oEAAoE;YACpE,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,IAAI,CAAC,CAAC;YACtD,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;gBAAE,MAAM,IAAI,KAAK,CAAC,IAAI,IAAI,qBAAqB,CAAC,CAAC;YAEzE,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC;YACrD,MAAM,WAAW,GAAG,MAAM,GAAG,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;YACrD,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAExE,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;gBAC5B,mBAAmB,GAAG,mBAAmB,CAAC,OAAO,CAC/C,KAAK,CAAC,QAAQ,EACd,SAAS,KAAK,CAAC,GAAG,eAAe,IAAI,IAAI,CAC1C,CAAC;YACJ,CAAC;QACH,CAAC;QAED,MAAM,GAAG,CAAC,SAAS,CAAC,iBAAiB,EAAE,mBAAmB,CAAC,CAAC;IAC9D,CAAC;CACF"}
|
package/web/dist/sw.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
if(!self.define){let e,s={};const i=(i,n)=>(i=new URL(i+".js",n).href,s[i]||new Promise(s=>{if("document"in self){const e=document.createElement("script");e.src=i,e.onload=s,document.head.appendChild(e)}else e=i,importScripts(i),s()}).then(()=>{let e=s[i];if(!e)throw new Error(`Module ${i} didn’t register its module`);return e}));self.define=(n,r)=>{const l=e||("document"in self?document.currentScript.src:"")||location.href;if(s[l])return;let o={};const
|
|
1
|
+
if(!self.define){let e,s={};const i=(i,n)=>(i=new URL(i+".js",n).href,s[i]||new Promise(s=>{if("document"in self){const e=document.createElement("script");e.src=i,e.onload=s,document.head.appendChild(e)}else e=i,importScripts(i),s()}).then(()=>{let e=s[i];if(!e)throw new Error(`Module ${i} didn’t register its module`);return e}));self.define=(n,r)=>{const l=e||("document"in self?document.currentScript.src:"")||location.href;if(s[l])return;let o={};const a=e=>i(e,l),d={module:{uri:l},exports:o,require:a};s[l]=Promise.all(n.map(e=>d[e]||a(e))).then(e=>(r(...e),o))}}define(["./workbox-1ef09536"],function(e){"use strict";self.addEventListener("message",e=>{e.data&&"SKIP_WAITING"===e.data.type&&self.skipWaiting()}),e.precacheAndRoute([{url:"pwa-maskable-512x512.png",revision:"9e859d049e78f70ddb5872a3bce2622b"},{url:"pwa-maskable-192x192.png",revision:"f1e5f837a116221b26c9cb9447db5e92"},{url:"pwa-512x512.png",revision:"e5560dba9f85e2959637abbb546643cd"},{url:"pwa-192x192.png",revision:"8b590313fc6296f57d609982dc21f302"},{url:"index.html",revision:"b43ae22243524e27688e47b8d6299fb9"},{url:"favicon.svg",revision:"570c2a249bbd511b386a843cd96545e7"},{url:"apple-touch-icon.png",revision:"d5d6ea39bc40ffd5b045b9593da0c890"},{url:"assets/workbox-window.prod.es5-BIl4cyR9.js",revision:null},{url:"assets/index-DPgpp2iG.js",revision:null},{url:"assets/NotFound-iEZNehaH.js",revision:null},{url:"assets/Nav-BmJ5gVHE.js",revision:null},{url:"assets/Home-h_rCrXOP.js",revision:null},{url:"assets/About-DPPma4Gx.js",revision:null},{url:"pwa-192x192.png",revision:"8b590313fc6296f57d609982dc21f302"},{url:"pwa-512x512.png",revision:"e5560dba9f85e2959637abbb546643cd"},{url:"pwa-maskable-192x192.png",revision:"f1e5f837a116221b26c9cb9447db5e92"},{url:"pwa-maskable-512x512.png",revision:"9e859d049e78f70ddb5872a3bce2622b"},{url:"manifest.webmanifest",revision:"209d92f34008caf0c68fc089a11e31f0"}],{}),e.cleanupOutdatedCaches(),e.registerRoute(new e.NavigationRoute(e.createHandlerBoundToURL("index.html")))});
|