wasm-idle 0.0.1 → 0.0.3

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.
@@ -5,8 +5,17 @@ import { load } from "../playground";
5
5
  import "xterm/css/xterm.css";
6
6
  const dispatch = createEventDispatcher();
7
7
  let ref, clientWidth, clientHeight, term, finish = true, input = "", sandbox, first = true;
8
+ const wait = new Promise((r) => {
9
+ const i = setInterval(() => {
10
+ if (term) {
11
+ clearInterval(i);
12
+ r();
13
+ }
14
+ }, 100);
15
+ });
8
16
  export const terminal = {
9
- clear() {
17
+ async clear() {
18
+ await wait;
10
19
  term.clear();
11
20
  term.write(`\x1B[?25l`);
12
21
  term.write("\x1B[0m");
@@ -14,6 +23,7 @@ export const terminal = {
14
23
  first = true;
15
24
  },
16
25
  async run(language, code, log = true) {
26
+ await wait;
17
27
  if (sandbox)
18
28
  await sandbox.clear();
19
29
  input = "";
@@ -95,8 +105,15 @@ onMount(() => {
95
105
  input += e.key;
96
106
  term.write(e.key);
97
107
  }
98
- } else if (ev.ctrlKey && ev.key === "c") {
108
+ } else if ((ev.ctrlKey || ev.metaKey) && ev.key === "c") {
109
+ sandbox.kill();
110
+ } else if ((ev.ctrlKey || ev.metaKey) && ev.key === "d") {
99
111
  sandbox.kill();
112
+ } else if ((ev.ctrlKey || ev.metaKey) && ev.key === "v") {
113
+ navigator.clipboard.readText().then((text) => {
114
+ term.write(text);
115
+ sandbox.write(text);
116
+ });
100
117
  }
101
118
  });
102
119
  plugin = await registerAllPlugins(term);
@@ -3,7 +3,7 @@ import 'xterm/css/xterm.css';
3
3
  declare const __propDef: {
4
4
  props: {
5
5
  terminal?: {
6
- clear(): void;
6
+ clear(): Promise<void>;
7
7
  run(language: any, code: any, log?: boolean): Promise<void>;
8
8
  } | undefined;
9
9
  dark?: boolean | undefined;
@@ -22,7 +22,7 @@ export type TerminalEvents = typeof __propDef.events;
22
22
  export type TerminalSlots = typeof __propDef.slots;
23
23
  export default class Terminal extends SvelteComponentTyped<TerminalProps, TerminalEvents, TerminalSlots> {
24
24
  get terminal(): {
25
- clear(): void;
25
+ clear(): Promise<void>;
26
26
  run(language: any, code: any, log?: boolean): Promise<void>;
27
27
  };
28
28
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wasm-idle",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "A simple web app to run C++/Python code in the browser",
5
5
  "license": "MIT",
6
6
  "type": "module",