wongtty 0.0.0-stage → 0.0.2
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/LICENSE-APACHE +201 -0
- package/README.md +68 -2
- package/THIRD_PARTY_NOTICES.md +264 -0
- package/dist/index.d.ts +326 -0
- package/dist/index.js +866 -0
- package/dist/wongtty.wasm +0 -0
- package/dist/xterm.d.ts +6 -0
- package/dist/xterm.js +32 -0
- package/dist/xterm_web.d.ts +943 -0
- package/dist/xterm_web.js +4063 -0
- package/dist/xterm_web_bg.wasm +0 -0
- package/dist/xterm_web_bg.wasm.d.ts +179 -0
- package/package.json +67 -4
|
Binary file
|
package/dist/xterm.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from './xterm_web.js';
|
|
2
|
+
|
|
3
|
+
type WasmSource = URL | string | ArrayBuffer | ArrayBufferView | WebAssembly.Module | Response;
|
|
4
|
+
|
|
5
|
+
/** Loads the engine (`wongtty.wasm`) and the front end (`xterm_web_bg.wasm`) once; call before `new Terminal()`. */
|
|
6
|
+
export function init(engine?: WasmSource, frontEnd?: WasmSource): Promise<void>;
|
package/dist/xterm.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// wongtty/xterm: the Rust front end (xterm_web.js, generated by wasm-bindgen from crates/wongtty-web) over the wongtty
|
|
2
|
+
// engine (index.js). `init()` loads both WebAssembly modules; everything else is the generated binding.
|
|
3
|
+
import { init as initEngine } from './index.js';
|
|
4
|
+
import initFrontEnd, { Terminal as FrontEndTerminal } from './xterm_web.js';
|
|
5
|
+
|
|
6
|
+
export * from './xterm_web.js';
|
|
7
|
+
|
|
8
|
+
let ready = false;
|
|
9
|
+
|
|
10
|
+
/** The generated `Terminal`, with a clear error before `init()` has finished (the glue fails with a TypeError). */
|
|
11
|
+
export class Terminal extends FrontEndTerminal {
|
|
12
|
+
constructor(options) {
|
|
13
|
+
if (!ready) throw new Error('wongtty/xterm: await init() before new Terminal()');
|
|
14
|
+
super(options);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Loads the engine and the front end once. Sources default to the files next to this module. */
|
|
19
|
+
export async function init(engine, frontEnd) {
|
|
20
|
+
await Promise.all([initEngine(engine), initFrontEnd({ module_or_path: frontEnd ?? (await defaultFrontEnd()) })]);
|
|
21
|
+
ready = true;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Node cannot fetch file: URLs; read the file there, like index.js does for the engine.
|
|
25
|
+
async function defaultFrontEnd() {
|
|
26
|
+
const url = new URL('./xterm_web_bg.wasm', import.meta.url);
|
|
27
|
+
if (url.protocol !== 'file:') return url;
|
|
28
|
+
// Keep the name in a variable so browser bundlers do not follow the node: module.
|
|
29
|
+
const fsModule = 'node:fs/promises';
|
|
30
|
+
const { readFile } = await import(/* @vite-ignore */ /* webpackIgnore: true */ fsModule);
|
|
31
|
+
return readFile(url);
|
|
32
|
+
}
|