janela 0.17.0 → 0.17.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/bin/janela.mjs +24 -2
- package/bin/lib.mjs +22 -0
- package/package.json +1 -1
package/bin/janela.mjs
CHANGED
|
@@ -22,6 +22,7 @@ import { fileURLToPath } from "node:url";
|
|
|
22
22
|
import {
|
|
23
23
|
ANDROID_ABI, ANDROID_TARGET_SDK, androidConf, ffiManifest, iosConf,
|
|
24
24
|
installCommand, libraryProfile, mimeFor, NAME_RE, packageManager as pmFor,
|
|
25
|
+
shimCacheKey,
|
|
25
26
|
patchPeSubsystem, PeError, rewriteHostSpecifier, suggestName,
|
|
26
27
|
} from "./lib.mjs";
|
|
27
28
|
|
|
@@ -730,10 +731,29 @@ function buildShim(cacheDir) {
|
|
|
730
731
|
// part of an MSVC toolchain, and a lone object needs no archive index.
|
|
731
732
|
const obj = join(cacheDir, win ? "wvshim.obj" : "wvshim.o");
|
|
732
733
|
const lib = win ? obj : join(cacheDir, "libwvshim.a");
|
|
733
|
-
|
|
734
|
+
const inc = `-I${join(KIT, "vendor-webview", "core", "include")}`;
|
|
735
|
+
|
|
736
|
+
// Keyed on the shim's CONTENT, not its mtime.
|
|
737
|
+
//
|
|
738
|
+
// The mtime test this replaces was wrong in the one case that matters:
|
|
739
|
+
// upgrading janela. pnpm's store is content-addressed and hard-links files
|
|
740
|
+
// into node_modules with the STORE's mtime, which is older than a cached
|
|
741
|
+
// object built minutes earlier from the previous version — so the cache
|
|
742
|
+
// looked fresh and a stale archive was reused. The symptom is a link failure
|
|
743
|
+
// naming symbols the new shim exports and the old object does not
|
|
744
|
+
// ("Undefined symbols: _wv_set_menu, _wv_on_menu"), which reads as a broken
|
|
745
|
+
// install rather than a stale cache.
|
|
746
|
+
//
|
|
747
|
+
// The version is in the key too: a shim that happens to be byte-identical
|
|
748
|
+
// across versions still gets recompiled if anything else about the build
|
|
749
|
+
// moved, which is cheap insurance against the next variant of this.
|
|
750
|
+
const key = shimCacheKey(readFileSync(src), VERSION, process.platform, inc);
|
|
751
|
+
const keyFile = join(cacheDir, "wvshim.key");
|
|
752
|
+
if (existsSync(lib) && existsSync(keyFile) && readFileSync(keyFile, "utf8") === key) {
|
|
753
|
+
return lib;
|
|
754
|
+
}
|
|
734
755
|
|
|
735
756
|
console.log("janela: compiling webview shim");
|
|
736
|
-
const inc = `-I${join(KIT, "vendor-webview", "core", "include")}`;
|
|
737
757
|
if (win) {
|
|
738
758
|
console.log(`janela: building for ${winCcOrFail()}`);
|
|
739
759
|
run([
|
|
@@ -743,6 +763,7 @@ function buildShim(cacheDir) {
|
|
|
743
763
|
`-I${join(KIT, "vendor-webview", "compatibility", "mingw", "include")}`,
|
|
744
764
|
"-DWIN32_LEAN_AND_MEAN", "-D_WIN32_WINNT=0x0601",
|
|
745
765
|
]);
|
|
766
|
+
writeFileSync(keyFile, key);
|
|
746
767
|
return lib;
|
|
747
768
|
}
|
|
748
769
|
if (process.platform === "darwin") {
|
|
@@ -752,6 +773,7 @@ function buildShim(cacheDir) {
|
|
|
752
773
|
run(["g++", "-c", src, "-o", obj, "-std=c++17", "-O2", inc, ...cflags]);
|
|
753
774
|
}
|
|
754
775
|
run(["ar", "rcs", lib, obj]);
|
|
776
|
+
writeFileSync(keyFile, key);
|
|
755
777
|
return lib;
|
|
756
778
|
}
|
|
757
779
|
|
package/bin/lib.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
1
2
|
/**
|
|
2
3
|
* Pure helpers shared by the CLI and its tests.
|
|
3
4
|
*
|
|
@@ -384,3 +385,24 @@ export function installCommand(pm) {
|
|
|
384
385
|
if (pm === "npm") return ["npm", "install", "--no-fund", "--no-audit"];
|
|
385
386
|
return [pm, "install"];
|
|
386
387
|
}
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* The cache key for the compiled webview shim.
|
|
391
|
+
*
|
|
392
|
+
* Keyed on the shim's CONTENT, not its mtime. The mtime test this replaced was
|
|
393
|
+
* wrong in the one case that matters — upgrading janela: pnpm's store is
|
|
394
|
+
* content-addressed and hard-links files into node_modules carrying the
|
|
395
|
+
* STORE's mtime, which is older than an object compiled minutes earlier from
|
|
396
|
+
* the previous version. The cache then looked fresh, the stale archive was
|
|
397
|
+
* reused, and the link failed naming symbols the new shim exports and the old
|
|
398
|
+
* object does not.
|
|
399
|
+
*
|
|
400
|
+
* `version` is in the key so a shim that happens to be byte-identical across
|
|
401
|
+
* releases still recompiles when anything else about the build moved.
|
|
402
|
+
*/
|
|
403
|
+
export function shimCacheKey(source, version, platform, includeFlag) {
|
|
404
|
+
return createHash("sha256")
|
|
405
|
+
.update(source)
|
|
406
|
+
.update(`\u0000${version}\u0000${platform}\u0000${includeFlag}`)
|
|
407
|
+
.digest("hex");
|
|
408
|
+
}
|