buninu-browser 0.0.2 → 0.1.0

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.
@@ -68,8 +68,10 @@ unmodified; its SHA-256 is
68
68
  `vendor/wasmpeg/source-v1.0.1.tar.gz`, mirrored from
69
69
  https://github.com/wasmpeg/wasmpeg/tree/v1.0.1
70
70
 
71
- The JavaScript sources, `cpu.js`, and `cpu.wasm` are copied without modification
72
- from the published CPU npm package. `cpu.wasm` is a separate file that users
71
+ `cpu.js` and `cpu.wasm` are copied without modification from the published CPU
72
+ npm package. The JavaScript sources are copied from it with the local changes
73
+ recorded in [`patches/wasmpeg/`](patches/wasmpeg/README.md): one line of
74
+ `src/js/gpu.js`, so the WASM path also resolves on Windows. `cpu.wasm` is a separate file that users
73
75
  can replace. The exact artifact hashes, source download, and rebuild command
74
76
  are in [`vendor/wasmpeg/VENDORING.md`](vendor/wasmpeg/VENDORING.md).
75
77
 
@@ -33,7 +33,8 @@ const COMPOSITOR_TIMEOUT = 10_000;
33
33
  const MAX_CHANNEL_LINE = 96 * 1024 * 1024;
34
34
  const LIFECYCLE_NAMES = new Set(["DOMContentLoaded", "load"]);
35
35
 
36
- const DEFAULT_ENTRY = new URL("./main.js", import.meta.url).pathname;
36
+ // A file path, not a URL's pathname ("/C:/..." on Windows).
37
+ const DEFAULT_ENTRY = Bun.fileURLToPath(new URL("./main.js", import.meta.url));
37
38
 
38
39
  export class RendererHost {
39
40
  #entry;
@@ -78,7 +79,10 @@ export class RendererHost {
78
79
  constructor({
79
80
  entry = DEFAULT_ENTRY, args = [], timeout = 30_000, onRestart = null, onNavigate = null, fetch: fetchImpl = fetch,
80
81
  network = new NetworkService({ fetch: fetchImpl }), onFrame = null, onLifecycle = null,
81
- compositor = entry === DEFAULT_ENTRY,
82
+ // The compositor's channel is an extra stdio pipe used as fd 3, which
83
+ // Windows does not have (Bun hands out libuv pipes there, not file
84
+ // descriptors): there the main thread answers screenshots and scrolling.
85
+ compositor = entry === DEFAULT_ENTRY && process.platform !== "win32",
82
86
  } = {}) {
83
87
  this.#onFrame = onFrame;
84
88
  this.#onLifecycle = onLifecycle;
@@ -106,7 +110,8 @@ export class RendererHost {
106
110
  cmd: [process.execPath, this.#entry, ...this.#args,
107
111
  ...(logging ? [RENDERER_LOG_FLAG] : []), ...(compositor ? [COMPOSITOR_FLAG] : [])],
108
112
  // No inherited environment: nothing from the controller leaks in.
109
- env: {},
113
+ // Windows programs need SystemRoot to load system libraries.
114
+ env: process.platform === "win32" && process.env.SystemRoot ? { SystemRoot: process.env.SystemRoot } : {},
110
115
  // With BUNINU_LOG, output goes through the controller into the log file.
111
116
  // fd 3 is a socket to the renderer's compositor thread.
112
117
  stdio: ["ignore", logging ? "pipe" : "inherit", logging ? "pipe" : "inherit", ...(compositor ? ["pipe"] : [])],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "buninu-browser",
3
- "version": "0.0.2",
3
+ "version": "0.1.0",
4
4
  "description": "Buninu Browser is a browser engine written in JavaScript and WebAssembly for Bun.",
5
5
  "keywords": [
6
6
  "buninu",
@@ -0,0 +1,14 @@
1
+ diff --git a/src/js/gpu.js b/src/js/gpu.js
2
+ index 2bb56f8..a9f4dc6 100644
3
+ --- a/src/js/gpu.js
4
+ +++ b/src/js/gpu.js
5
+ @@ -51,7 +51,8 @@ async function instantiate(path) {
6
+ let nodeOpts = {};
7
+ if (isNode) {
8
+ const { default: fsMod } = await import('node:fs');
9
+ - nodeOpts = { wasmBinary: fsMod.readFileSync(new URL(path).pathname.replace(/\.js$/, '.wasm')) };
10
+ + const { fileURLToPath } = await import('node:url');
11
+ + nodeOpts = { wasmBinary: fsMod.readFileSync(fileURLToPath(path).replace(/\.js$/, '.wasm')) };
12
+ }
13
+ const { default: factory } = await import(/* @vite-ignore */ path);
14
+ return factory({
@@ -0,0 +1,28 @@
1
+ # wasmpeg patch queue
2
+
3
+ The vendored wasmpeg JavaScript is the `@wasmpeg/cpu` 1.0.1 npm release, which
4
+ matches upstream tag `v1.0.1`, commit `173b41e30f4dd21d15f4e564c3ad26cba5d89d80`:
5
+
6
+ - Upstream: <https://github.com/wasmpeg/wasmpeg>
7
+ - Vendored tree: `vendor/wasmpeg`
8
+ - Patch paths are relative to the root of the npm package (`vendor/wasmpeg`).
9
+
10
+ The patches change only wasmpeg's JavaScript loader; `dist/cpu.js` and
11
+ `dist/cpu.wasm` (FFmpeg) are the published files, unmodified.
12
+
13
+ For the already-patched vendored tree, verify that the recorded patch can be
14
+ removed cleanly without changing files:
15
+
16
+ ```sh
17
+ git -C vendor/wasmpeg apply --reverse --check ../../patches/wasmpeg/0001-windows-wasm-path.patch
18
+ ```
19
+
20
+ ## Patch manifest
21
+
22
+ | Patch | Modified upstream file | Reason | Verification |
23
+ |---|---|---|---|
24
+ | `0001-windows-wasm-path.patch` | `src/js/gpu.js` | Read `cpu.wasm` from `fileURLToPath(path)` instead of `new URL(path).pathname`, which is `/C:/...` on Windows and not a file path there. | `bun test test/page-scripts.test.js` (every renderer start loads the decoder) |
25
+
26
+ Keep each local change in a separate numbered patch and add it to this table
27
+ with its reason and focused test. When updating wasmpeg, re-check the queue
28
+ against the new release and update `vendor/wasmpeg/VENDORING.md`.
@@ -1,7 +1,10 @@
1
1
  # Vendored wasmpeg CPU 1.0.1
2
2
 
3
- This directory contains the unmodified JavaScript and CPU WebAssembly files
4
- from the `@wasmpeg/cpu` 1.0.1 npm release. It also keeps the release's LGPL
3
+ This directory contains the JavaScript and CPU WebAssembly files from the
4
+ `@wasmpeg/cpu` 1.0.1 npm release. The WebAssembly and `dist/cpu.js` are
5
+ unmodified; the JavaScript loader carries the local patches recorded in
6
+ [`patches/wasmpeg/`](../../patches/wasmpeg/README.md) (currently one line in
7
+ `src/js/gpu.js`, so the WASM path works on Windows). It also keeps the release's LGPL
5
8
  license and FFmpeg notice. Buninu Browser loads only `src/js/index.js` and
6
9
  `dist/cpu.js`/`dist/cpu.wasm`; no native media bindings are used.
7
10
 
@@ -12,7 +15,8 @@ license files, and build scripts. It is a `git archive` of upstream tag
12
15
  `173b41e30f4dd21d15f4e564c3ad26cba5d89d80`.
13
16
  The source archive includes FFmpeg's optional GPL files; the shipped CPU
14
17
  binary is the upstream LGPL preset and does not link those optional codecs.
15
- The vendored `src/js` files match that tag byte for byte. Upstream's CPU LGPL
18
+ The vendored `src/js` files match that tag byte for byte apart from those
19
+ patches. Upstream's CPU LGPL
16
20
  build command is `PRESET=lgpl TARGET=cpu bash scripts/build.sh`, after setting
17
21
  up Emscripten SDK 6.0.8 as described by its build instructions. This repository
18
22
  distributes the published binary rather than rebuilding it.
@@ -51,7 +51,8 @@ async function instantiate(path) {
51
51
  let nodeOpts = {};
52
52
  if (isNode) {
53
53
  const { default: fsMod } = await import('node:fs');
54
- nodeOpts = { wasmBinary: fsMod.readFileSync(new URL(path).pathname.replace(/\.js$/, '.wasm')) };
54
+ const { fileURLToPath } = await import('node:url');
55
+ nodeOpts = { wasmBinary: fsMod.readFileSync(fileURLToPath(path).replace(/\.js$/, '.wasm')) };
55
56
  }
56
57
  const { default: factory } = await import(/* @vite-ignore */ path);
57
58
  return factory({