@disjukr/execute 0.0.0-stage → 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.
- package/README.md +42 -2
- package/bin/copy-assets.js +15 -0
- package/dist/assets/gdi32.dll +0 -0
- package/dist/assets/i386-display.dll +0 -0
- package/dist/assets/i386-dsound.dll +0 -0
- package/dist/assets/i386-gdi32.dll +0 -0
- package/dist/assets/i386-kernel32.dll +0 -0
- package/dist/assets/i386-shell32.dll +0 -0
- package/dist/assets/i386-user32.dll +0 -0
- package/dist/assets/i386-winmm.dll +0 -0
- package/dist/assets/kernelbase-936.dll +0 -0
- package/dist/assets/kernelbase-949.dll +0 -0
- package/dist/assets/kernelbase-950.dll +0 -0
- package/dist/assets/kernelbase.dll +0 -0
- package/dist/assets/pe.js +6 -0
- package/dist/assets/process-server.wasm +0 -0
- package/dist/assets/process-services.js +45 -0
- package/dist/assets/process-worker.js +73 -0
- package/dist/assets/process.wasm +0 -0
- package/dist/assets/run.js +531 -0
- package/dist/assets/server-worker.js +397 -0
- package/dist/assets/shell32.dll +0 -0
- package/dist/assets/threads.js +60 -0
- package/dist/assets/user32.dll +0 -0
- package/dist/assets/webaudio-tinysynth.min.js +1 -0
- package/dist/assets/wow64host.exe +0 -0
- package/dist/index.js +1347 -0
- package/dist/licenses/GPL-3.0-only.txt +232 -0
- package/dist/licenses/LICENSE +44 -0
- package/dist/licenses/TinySynth +201 -0
- package/dist/licenses/Wine +17 -0
- package/dist/licenses/Wine-LGPL +502 -0
- package/dist/licenses/kwemu +340 -0
- package/dist/style.css +809 -0
- package/dist/types/demo.d.ts +1 -0
- package/dist/types/executable-icon.d.ts +1 -0
- package/dist/types/file-system.d.ts +13 -0
- package/dist/types/guest-files.d.ts +29 -0
- package/dist/types/index.d.ts +27 -0
- package/dist/types/launch.d.ts +91 -0
- package/dist/types/pe.d.ts +1 -0
- package/dist/types/process-group.d.ts +1 -0
- package/dist/types/window-thumbnail.d.ts +11 -0
- package/dist/types/windows-path.d.ts +1 -0
- package/package.json +44 -4
package/README.md
CHANGED
|
@@ -1,3 +1,43 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @disjukr/execute
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A Solid 2 desktop for running Windows executables in the browser. Run `pnpm dev` from `lib/` to open the file-picker demo.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
pnpm add @disjukr/execute solid-js@2 @solidjs/web@2
|
|
7
|
+
pnpm exec execute-runtime-assets public/execute-runtime
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
```tsx
|
|
11
|
+
import { ExecuteDesktop, memoryFileSystem } from "@disjukr/execute";
|
|
12
|
+
import "@disjukr/execute/style.css";
|
|
13
|
+
|
|
14
|
+
export function App(props: { exe: File; data: File }) {
|
|
15
|
+
const path = "C:\\Apps\\Example\\app.exe";
|
|
16
|
+
const fs = memoryFileSystem({
|
|
17
|
+
[path]: props.exe,
|
|
18
|
+
"C:\\Apps\\Example\\data.bin": props.data,
|
|
19
|
+
});
|
|
20
|
+
return <div style={{ height: "100dvh" }}>
|
|
21
|
+
<ExecuteDesktop fileSystem={fs} shortcuts={[{ path, label: "Example" }]} />
|
|
22
|
+
</div>;
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Use the reactive `muted` prop to control sound. The `locale` prop selects the ANSI code page and default resource language for new launches (`ja_JP`, `ko_KR`, `zh_CN`, or `zh_TW`). The library defaults to Japanese.
|
|
27
|
+
|
|
28
|
+
Supply a reactive shortcut list to update the desktop. Implement `onShortcutRename(path, label)` and `onShortcutRemove(path)` to enable those actions. Removing a shortcut leaves its file and any running process intact.
|
|
29
|
+
|
|
30
|
+
A custom file system implements `readFile(path)` and returns a `Blob`, `Uint8Array`, or `undefined` for a missing file. Implement `writeFile(path, contents)` to allow creation and modification. It receives the complete replacement contents as a `Uint8Array`. Both methods can be asynchronous. Resolve a write once later reads will see the new contents, or reject it to report failure to the EXE.
|
|
31
|
+
|
|
32
|
+
Paths are absolute Windows drive paths. Implement case-insensitive lookup. The EXE starts in its containing directory and can use synchronous `CreateFileA/W`, `ReadFile`, `WriteFile`, and `CloseHandle`. Reuse the same `memoryFileSystem()` instance to retain changes between launches. To retain changes after a page reload, provide a persistent adapter. Windows file sharing checks apply to launches sharing the same adapter in this page.
|
|
33
|
+
|
|
34
|
+
Serve the runtime assets from the same origin (`./execute-runtime/` by default) with the Wasm MIME type `application/wasm`. The browser requires WebAssembly memory64 and shared memory. Serve the page and Workers with these headers:
|
|
35
|
+
|
|
36
|
+
```http
|
|
37
|
+
Cross-Origin-Opener-Policy: same-origin
|
|
38
|
+
Cross-Origin-Embedder-Policy: require-corp
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## License
|
|
42
|
+
|
|
43
|
+
Original Execute code is MIT-licensed. The distributed `process.wasm` is GPL-3.0-only and `process-server.wasm` is LGPL-2.1-or-later. The package includes component notices and license texts in `dist/licenses/`.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { cp, copyFile, mkdir, readdir } from 'node:fs/promises';
|
|
3
|
+
import { resolve, join } from 'node:path';
|
|
4
|
+
|
|
5
|
+
const [destination, ...extra] = process.argv.slice(2);
|
|
6
|
+
if (!destination || extra.length) {
|
|
7
|
+
console.error('Usage: execute-runtime-assets <static-directory>');
|
|
8
|
+
process.exit(2);
|
|
9
|
+
}
|
|
10
|
+
const source = resolve(import.meta.dirname, '../dist/assets');
|
|
11
|
+
await mkdir(destination, { recursive: true });
|
|
12
|
+
for (const name of await readdir(source)) {
|
|
13
|
+
await copyFile(join(source, name), join(destination, name));
|
|
14
|
+
}
|
|
15
|
+
await cp(resolve(import.meta.dirname, "../dist/licenses"), join(destination, "licenses"), { recursive: true });
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
const RPC_PROCESS_CREATE = 0;
|
|
2
|
+
const RPC_THREAD_RESUME = 1;
|
|
3
|
+
const RPC_OBJECT_WAIT = 2;
|
|
4
|
+
const RPC_PROCESS_EXIT_CODE = 3;
|
|
5
|
+
const RPC_OBJECT_CLOSE = 4;
|
|
6
|
+
const RPC_IMAGE_EXISTS = 6;
|
|
7
|
+
const RPC_PROCESS_TERMINATE = 7;
|
|
8
|
+
const RPC_THREAD_CREATE = 8;
|
|
9
|
+
const RPC_THREAD_START = 9;
|
|
10
|
+
const RPC_THREAD_EXIT = 10;
|
|
11
|
+
const RPC_THREAD_EXIT_CODE = 11;
|
|
12
|
+
const RPC_THREAD_IS_LAST = 14;
|
|
13
|
+
const GUI_INVALIDATE = 0;
|
|
14
|
+
const GUI_BEGIN_PAINT = 1;
|
|
15
|
+
const GUI_POST_QUIT = 2;
|
|
16
|
+
const GUI_ACTIVATE = 3;
|
|
17
|
+
const GUI_CLOSE = 4;
|
|
18
|
+
const GUI_GET_MESSAGE = 5;
|
|
19
|
+
const GUI_GET_WNDPROC = 6;
|
|
20
|
+
const GUI_RELEASE_WINDOW = 7;
|
|
21
|
+
const GUI_GET_FOCUS = 8;
|
|
22
|
+
const GUI_MENU_COMMAND = 9;
|
|
23
|
+
const GUI_PEEK_MESSAGE = 10;
|
|
24
|
+
const GUI_CLIENT_RECT = 11;
|
|
25
|
+
const GUI_KEYBOARD_STATE = 12;
|
|
26
|
+
const GUI_RESIZE = 13;
|
|
27
|
+
const GUI_DIALOG_CONTROL = 14;
|
|
28
|
+
const GUI_HIDE = 15;
|
|
29
|
+
const GUI_WINDOW_STYLE = 16;
|
|
30
|
+
const GUI_REQUEST_RESIZE = 17;
|
|
31
|
+
const GUI_CREATE_CHILD = 18;
|
|
32
|
+
const GUI_SET_OWNER = 19;
|
|
33
|
+
const GUI_GET_OWNER = 20;
|
|
34
|
+
const GUI_POST_NULL = 21;
|
|
35
|
+
const GUI_TRAY_NOTIFY = 22;
|
|
36
|
+
const GUI_TRACK_POPUP = 23;
|
|
37
|
+
const GUI_ICON_RESOURCE = 24;
|
|
38
|
+
const GUI_CURSOR_POSITION = 25;
|
|
39
|
+
const GUI_SHOW = 26;
|
|
40
|
+
const GUI_REQUEST_MAXIMIZE = 27;
|
|
41
|
+
const GUI_CLASS_ICON = 28;
|
|
42
|
+
const GUI_MENU_ITEM_STATE = 29;
|
|
43
|
+
const GUI_HOST_ACTIVATE = 30;
|
|
44
|
+
const GUI_HOST_DEACTIVATE = 31;
|
|
45
|
+
const GUI_SCREEN_DIMENSION = 32;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
importScripts('process-services.js','threads.js','pe.js','run.js');
|
|
2
|
+
onmessage = async ({data}) => {
|
|
3
|
+
const pending = new Map((data.jitModules ?? []).map(update => [update.slot,update]));
|
|
4
|
+
const notifications = new Int32Array(data.jitNotifications);
|
|
5
|
+
onmessage = ({data:update}) => {
|
|
6
|
+
pending.set(update.slot,update);
|
|
7
|
+
Atomics.sub(notifications,0,1);
|
|
8
|
+
};
|
|
9
|
+
const jit = {
|
|
10
|
+
publish(block) { postMessage({kind:'jitCompile',...block},[block.bytes.buffer]); },
|
|
11
|
+
retire(block) { postMessage({kind:'jitRetire',...block}); },
|
|
12
|
+
hasNotifications() { return Atomics.load(notifications,0) > 0; },
|
|
13
|
+
install(core) {
|
|
14
|
+
if (!pending.size) return;
|
|
15
|
+
const versions = new BigUint64Array(core.memory.buffer,Number(core.jitVersions()),4096);
|
|
16
|
+
for (const {slot,generation,module} of pending.values()) {
|
|
17
|
+
const f = module ? new WebAssembly.Instance(module,{env:{memory:core.memory}}).exports.f : null;
|
|
18
|
+
core.jitTable.set(slot,f);
|
|
19
|
+
versions[slot] = f ? generation : 0n;
|
|
20
|
+
}
|
|
21
|
+
pending.clear();
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
const execution = new ProcessExecution(data.tid);
|
|
25
|
+
const mailbox = new Int32Array(data.mailbox);
|
|
26
|
+
function request(message) {
|
|
27
|
+
Atomics.store(mailbox,0,0);
|
|
28
|
+
postMessage({kind:'request', message},message.op==='fileWrite' ? [message.bytes.buffer] : []);
|
|
29
|
+
execution.release();
|
|
30
|
+
while (!Atomics.load(mailbox,0)) Atomics.wait(mailbox,0,0);
|
|
31
|
+
const status = mailbox[1] >>> 0;
|
|
32
|
+
if (!status && message.op === RPC_PROCESS_TERMINATE) Atomics.store(execution.state,2,data.tid);
|
|
33
|
+
execution.acquire();
|
|
34
|
+
return {status, values:Uint32Array.from(mailbox.subarray(2,6))};
|
|
35
|
+
}
|
|
36
|
+
try {
|
|
37
|
+
const code = await runExecutable(data.module,data.file,chunk => postMessage({kind:'output',chunk:chunk.slice()}), {
|
|
38
|
+
...data, execution, request, jit, registerThread(thread) { postMessage({kind:'spawnThread',thread}); },
|
|
39
|
+
keyState:new Uint8Array(data.mailbox,24,256),
|
|
40
|
+
audio(event) { postMessage({kind:"audio",...event},event.bytes ? [event.bytes.buffer] : []); },
|
|
41
|
+
surface: {
|
|
42
|
+
sizes:new Map(),
|
|
43
|
+
registerClass(name,proc) { return request({op:'registerClass',name,proc}).values[0]; },
|
|
44
|
+
open(title,width,height,name,menu,style,exStyle,owner,x,y) {
|
|
45
|
+
const response=request({op:'windowOpen',title,width,height,name,menu,style,exStyle,owner,x,y});
|
|
46
|
+
if (response.status) return 0;
|
|
47
|
+
const hwnd=response.values[0];
|
|
48
|
+
this.sizes.set(hwnd,width*height*4);
|
|
49
|
+
return hwnd;
|
|
50
|
+
},
|
|
51
|
+
menuState(address,flags) { postMessage({kind:'menuState',address,flags}); },
|
|
52
|
+
control(hwnd,control) { postMessage({kind:'dialogControl',hwnd,control}); },
|
|
53
|
+
present(hwnd,pixels) { postMessage({kind:'surfaceFrame',hwnd,pixels},[pixels.buffer]); },
|
|
54
|
+
call(hwnd,command,arg) {
|
|
55
|
+
const reply=request({op:'windowRequest',hwnd,command,arg});
|
|
56
|
+
if (!reply.status && command===GUI_RESIZE) this.sizes.set(hwnd>>>0,(arg&65535)*(arg>>>16)*4);
|
|
57
|
+
if (!reply.status && command===GUI_RELEASE_WINDOW) this.sizes.delete(hwnd >>> 0);
|
|
58
|
+
return reply;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
},
|
|
62
|
+
ready() {
|
|
63
|
+
if (request({op:'ready'}).status) throw Error('Wine process initialization failed');
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
postMessage(code === undefined ? {kind:'threadDone'} : {kind:'exit',code});
|
|
67
|
+
execution.release();
|
|
68
|
+
} catch (e) {
|
|
69
|
+
if (e !== ProcessExecution.peerStopped)
|
|
70
|
+
postMessage({kind:'exit',code:e.ntstatus ?? 0xc0000142,error:String(e)});
|
|
71
|
+
}
|
|
72
|
+
close();
|
|
73
|
+
};
|
|
Binary file
|