@omnidotdev/terminal 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/LICENSE +21 -0
- package/build/index.d.ts +30 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +26 -0
- package/build/omni_terminal_wasm.d.ts +43 -0
- package/build/omni_terminal_wasm.js +1692 -0
- package/build/omni_terminal_wasm_bg.wasm +0 -0
- package/build/omni_terminal_wasm_bg.wasm.d.ts +11 -0
- package/package.json +29 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022-present Raphael Amorim
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export interface TerminalOptions {
|
|
2
|
+
serverUrl?: string;
|
|
3
|
+
fontSize?: number;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Embeddable WebGPU terminal component.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* const terminal = await Terminal.init(
|
|
11
|
+
* document.getElementById("terminal")!,
|
|
12
|
+
* { serverUrl: "wss://example.com/ws" },
|
|
13
|
+
* );
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare class Terminal {
|
|
17
|
+
private containerId;
|
|
18
|
+
private constructor();
|
|
19
|
+
/**
|
|
20
|
+
* Initialize a terminal inside the given container element.
|
|
21
|
+
*
|
|
22
|
+
* @param container - DOM element to mount the terminal into
|
|
23
|
+
* @param options - Configuration options
|
|
24
|
+
* @returns Initialized terminal instance
|
|
25
|
+
*/
|
|
26
|
+
static init(container: HTMLElement, options?: TerminalOptions): Promise<Terminal>;
|
|
27
|
+
/** Remove the terminal from the DOM */
|
|
28
|
+
dispose(): void;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAWD;;;;;;;;;;GAUG;AACH,qBAAa,QAAQ;IACnB,OAAO,CAAC,WAAW,CAAS;IAE5B,OAAO;IAIP;;;;;;OAMG;WACU,IAAI,CACf,SAAS,EAAE,WAAW,EACtB,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,QAAQ,CAAC;IAmBpB,uCAAuC;IACvC,OAAO,IAAI,IAAI;CAIhB"}
|
package/build/index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
class Terminal {
|
|
3
|
+
containerId;
|
|
4
|
+
constructor(containerId) {
|
|
5
|
+
this.containerId = containerId;
|
|
6
|
+
}
|
|
7
|
+
static async init(container, options = {}) {
|
|
8
|
+
const id = container.id || `omni-terminal-${Date.now()}`;
|
|
9
|
+
container.id = id;
|
|
10
|
+
const wasmPath = "./omni_terminal_wasm.js";
|
|
11
|
+
const wasmModule = await import(wasmPath);
|
|
12
|
+
await wasmModule.default();
|
|
13
|
+
const serverUrl = options.serverUrl ?? `${location.protocol === "https:" ? "wss" : "ws"}://${location.host}/ws`;
|
|
14
|
+
const fontSize = options.fontSize ?? 16;
|
|
15
|
+
wasmModule.create_terminal(id, serverUrl, fontSize);
|
|
16
|
+
return new Terminal(id);
|
|
17
|
+
}
|
|
18
|
+
dispose() {
|
|
19
|
+
const el = document.getElementById(this.containerId);
|
|
20
|
+
if (el)
|
|
21
|
+
el.innerHTML = "";
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export {
|
|
25
|
+
Terminal
|
|
26
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Initialize a terminal inside the given container element
|
|
6
|
+
*/
|
|
7
|
+
export function create_terminal(container_id: string, ws_url: string, font_size: number): void;
|
|
8
|
+
|
|
9
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
10
|
+
|
|
11
|
+
export interface InitOutput {
|
|
12
|
+
readonly memory: WebAssembly.Memory;
|
|
13
|
+
readonly create_terminal: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
14
|
+
readonly __wasm_bindgen_func_elem_361: (a: number, b: number, c: number) => void;
|
|
15
|
+
readonly __wasm_bindgen_func_elem_360: (a: number, b: number) => void;
|
|
16
|
+
readonly __wasm_bindgen_func_elem_374: (a: number, b: number) => void;
|
|
17
|
+
readonly __wbindgen_export: (a: number, b: number) => number;
|
|
18
|
+
readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
19
|
+
readonly __wbindgen_export3: (a: number) => void;
|
|
20
|
+
readonly __wbindgen_export4: (a: number, b: number, c: number) => void;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
27
|
+
* a precompiled `WebAssembly.Module`.
|
|
28
|
+
*
|
|
29
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
30
|
+
*
|
|
31
|
+
* @returns {InitOutput}
|
|
32
|
+
*/
|
|
33
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
37
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
38
|
+
*
|
|
39
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
40
|
+
*
|
|
41
|
+
* @returns {Promise<InitOutput>}
|
|
42
|
+
*/
|
|
43
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|