@dimina-kit/devtools 0.4.0-dev.20260731100034 → 0.4.0-dev.20260801163345

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.
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Publishes real Node built-ins into the simulator document's shared JS
3
+ * world (see shared/node-bindings for the consumer-side contract).
4
+ *
5
+ * The simulator WebContentsView runs nodeIntegration:false + sandbox:false +
6
+ * contextIsolation:false: page scripts cannot require Node modules and the
7
+ * vite bundle stubs `node:*` imports, but this preload shares the page's JS
8
+ * world and has full Node access. The FileSystemManager backends and the
9
+ * vpath resolver in the simulator bundle read these bindings.
10
+ *
11
+ * Trust boundary: this preload is assigned ONLY to the simulator top document
12
+ * (devtools' own code) via webPreferences.preload — miniapp render guests and
13
+ * the service host carry their own dedicated preloads, and no preload is
14
+ * session-registered (`setPreloads` is unused repo-wide), so mini-program
15
+ * code never sees these bindings.
16
+ */
17
+ export declare function installNodeBindings(): void;
18
+ //# sourceMappingURL=node-bindings.d.ts.map
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Publishes real Node built-ins into the simulator document's shared JS
3
+ * world (see shared/node-bindings for the consumer-side contract).
4
+ *
5
+ * The simulator WebContentsView runs nodeIntegration:false + sandbox:false +
6
+ * contextIsolation:false: page scripts cannot require Node modules and the
7
+ * vite bundle stubs `node:*` imports, but this preload shares the page's JS
8
+ * world and has full Node access. The FileSystemManager backends and the
9
+ * vpath resolver in the simulator bundle read these bindings.
10
+ *
11
+ * Trust boundary: this preload is assigned ONLY to the simulator top document
12
+ * (devtools' own code) via webPreferences.preload — miniapp render guests and
13
+ * the service host carry their own dedicated preloads, and no preload is
14
+ * session-registered (`setPreloads` is unused repo-wide), so mini-program
15
+ * code never sees these bindings.
16
+ */
17
+ import fs from 'node:fs';
18
+ import os from 'node:os';
19
+ import path from 'node:path';
20
+ import crypto from 'node:crypto';
21
+ import buffer from 'node:buffer';
22
+ import { NODE_BINDINGS_GLOBAL } from '../../shared/node-bindings.js';
23
+ export function installNodeBindings() {
24
+ // contextIsolation:false means page scripts share this world: freeze the
25
+ // bag (no member swap) and publish it non-writable AND non-configurable —
26
+ // writable:false alone still leaves `delete` and a defineProperty
27
+ // redefinition open to any same-world script, so the full lock needs
28
+ // configurable:false too. A compromised page script then cannot
29
+ // substitute a spoofed `fs` for the vpath resolver / FSM backends to
30
+ // trust by any route.
31
+ const existing = Object.getOwnPropertyDescriptor(globalThis, NODE_BINDINGS_GLOBAL);
32
+ if (existing && !existing.configurable) {
33
+ // Already locked (redefining a non-configurable property throws).
34
+ return;
35
+ }
36
+ const bindings = Object.freeze({ fs, os, path, crypto, buffer });
37
+ Object.defineProperty(globalThis, NODE_BINDINGS_GLOBAL, {
38
+ value: bindings,
39
+ writable: false,
40
+ configurable: false,
41
+ enumerable: true,
42
+ });
43
+ }
44
+ //# sourceMappingURL=node-bindings.js.map