@gmickel/gno 1.37.0 → 1.37.1
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/assets/spa-production.json.gz +0 -0
- package/browser-extension/artifacts/{gno-browser-clipper-v1.37.0.zip → gno-browser-clipper-v1.37.1.zip} +0 -0
- package/browser-extension/artifacts/gno-browser-clipper-v1.37.1.zip.sha256 +1 -0
- package/browser-extension/dist/manifest.json +1 -1
- package/package.json +1 -1
- package/src/serve/spa-production-build.ts +53 -7
- package/browser-extension/artifacts/gno-browser-clipper-v1.37.0.zip.sha256 +0 -1
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
6954195a14c9cdff85a265043590873823a0b25b287866c036d83153a95b8b14 gno-browser-clipper-v1.37.1.zip
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
// node:fs/promises — no Bun equivalent for mkdir/rm of the temporary SPA
|
|
2
|
-
|
|
1
|
+
// node:fs/promises — no Bun equivalent for mkdir/rm of the temporary SPA
|
|
2
|
+
// outdir, or for recursive directory listing.
|
|
3
|
+
import { mkdir, readdir, rm } from "node:fs/promises";
|
|
3
4
|
// node:os — no Bun equivalent for the platform temporary directory.
|
|
4
5
|
import { tmpdir } from "node:os";
|
|
5
6
|
// node:path — no Bun path utils.
|
|
6
|
-
import { basename, join } from "node:path";
|
|
7
|
+
import { basename, join, relative } from "node:path";
|
|
7
8
|
|
|
8
9
|
export const ROOT_MOUNT_MARKER = 'getElementById("root")';
|
|
9
10
|
|
|
@@ -15,6 +16,50 @@ export type ProductionSpaFile = {
|
|
|
15
16
|
export type ProductionSpaAssets = {
|
|
16
17
|
files: Record<string, ProductionSpaFile>;
|
|
17
18
|
html: string;
|
|
19
|
+
sourceHash: string;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const productionSpaPublicDir = (): string => join(import.meta.dir, "public");
|
|
23
|
+
|
|
24
|
+
export const productionSpaEntryPath = (): string =>
|
|
25
|
+
join(productionSpaPublicDir(), "index.html");
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* SHA-256 hex of every file under `src/serve/public/`, in sorted relative-path
|
|
29
|
+
* order. Used to detect a stale `assets/spa-production.json.gz` without
|
|
30
|
+
* comparing Bun.build output (minified symbols and chunk hashes differ
|
|
31
|
+
* across Bun binaries).
|
|
32
|
+
*/
|
|
33
|
+
export const computeSpaSourceHash = async (): Promise<string> => {
|
|
34
|
+
const publicDir = productionSpaPublicDir();
|
|
35
|
+
const entries = await readdir(publicDir, {
|
|
36
|
+
recursive: true,
|
|
37
|
+
withFileTypes: true,
|
|
38
|
+
});
|
|
39
|
+
const relativePaths: string[] = [];
|
|
40
|
+
for (const entry of entries) {
|
|
41
|
+
if (!entry.isFile()) {
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
relativePaths.push(
|
|
45
|
+
relative(publicDir, join(entry.parentPath, entry.name)).replaceAll(
|
|
46
|
+
"\\",
|
|
47
|
+
"/"
|
|
48
|
+
)
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
relativePaths.sort();
|
|
52
|
+
|
|
53
|
+
const hasher = new Bun.CryptoHasher("sha256");
|
|
54
|
+
for (const relativePath of relativePaths) {
|
|
55
|
+
const bytes = await Bun.file(join(publicDir, relativePath)).bytes();
|
|
56
|
+
hasher.update(relativePath);
|
|
57
|
+
hasher.update("\0");
|
|
58
|
+
hasher.update(String(bytes.byteLength));
|
|
59
|
+
hasher.update("\0");
|
|
60
|
+
hasher.update(bytes);
|
|
61
|
+
}
|
|
62
|
+
return hasher.digest("hex");
|
|
18
63
|
};
|
|
19
64
|
|
|
20
65
|
const SCRIPT_TAG_RE = /<script\b[^>]*\bsrc="[^"]+"[^>]*><\/script>/iu;
|
|
@@ -41,9 +86,6 @@ export const isStandaloneExecutable = (): boolean =>
|
|
|
41
86
|
export const isBunfsPath = (path: string): boolean =>
|
|
42
87
|
path.includes("/$bunfs/") || path.includes("\\$bunfs\\");
|
|
43
88
|
|
|
44
|
-
export const productionSpaEntryPath = (): string =>
|
|
45
|
-
join(import.meta.dir, "public", "index.html");
|
|
46
|
-
|
|
47
89
|
const rewriteProductionHtml = (html: string, jsEntryPath: string): string => {
|
|
48
90
|
const script = `<script type="module" src="/${basename(jsEntryPath)}"></script>`;
|
|
49
91
|
let next = html.replace(BASE_TAG_RE, "");
|
|
@@ -123,7 +165,11 @@ export const buildProductionSpaAssets = async (
|
|
|
123
165
|
};
|
|
124
166
|
}
|
|
125
167
|
|
|
126
|
-
return {
|
|
168
|
+
return {
|
|
169
|
+
files,
|
|
170
|
+
html,
|
|
171
|
+
sourceHash: await computeSpaSourceHash(),
|
|
172
|
+
};
|
|
127
173
|
} finally {
|
|
128
174
|
await rm(outdir, { recursive: true, force: true });
|
|
129
175
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
497d8e90a34b7472eac55da861c3049b7453a33d9fdbd0a27e49f2ce36ccde9b gno-browser-clipper-v1.37.0.zip
|