@wasm-idle/react 1.0.0-next.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.
@@ -0,0 +1,14 @@
1
+ import { type PlaygroundBinding, type SandboxLoader, type SandboxRuntimeAssets, type TerminalControl } from '@wasm-idle/core';
2
+ export interface ReactWasmIdleHost {
3
+ binding: PlaygroundBinding;
4
+ terminal: TerminalControl | undefined;
5
+ setTerminal: (terminal: TerminalControl | undefined) => void;
6
+ terminalRef: {
7
+ current: TerminalControl | undefined;
8
+ };
9
+ terminalProps: PlaygroundBinding['terminalProps'];
10
+ }
11
+ export declare function useWasmIdlePlayground(runtimeAssets: SandboxRuntimeAssets, loadSandbox: SandboxLoader): PlaygroundBinding;
12
+ export declare function useWasmIdleHost(runtimeAssets: SandboxRuntimeAssets, loadSandbox: SandboxLoader): ReactWasmIdleHost;
13
+ export type { PlaygroundBinding, SandboxLoader, SandboxRuntimeAssets, TerminalControl } from '@wasm-idle/core';
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,KAAK,eAAe,EACpB,MAAM,iBAAiB,CAAC;AAGzB,MAAM,WAAW,iBAAiB;IACjC,OAAO,EAAE,iBAAiB,CAAC;IAC3B,QAAQ,EAAE,eAAe,GAAG,SAAS,CAAC;IACtC,WAAW,EAAE,CAAC,QAAQ,EAAE,eAAe,GAAG,SAAS,KAAK,IAAI,CAAC;IAC7D,WAAW,EAAE;QAAE,OAAO,EAAE,eAAe,GAAG,SAAS,CAAA;KAAE,CAAC;IACtD,aAAa,EAAE,iBAAiB,CAAC,eAAe,CAAC,CAAC;CAClD;AAED,wBAAgB,qBAAqB,CACpC,aAAa,EAAE,oBAAoB,EACnC,WAAW,EAAE,aAAa,GACxB,iBAAiB,CAKnB;AAED,wBAAgB,eAAe,CAC9B,aAAa,EAAE,oBAAoB,EACnC,WAAW,EAAE,aAAa,GACxB,iBAAiB,CAenB;AAED,YAAY,EACX,iBAAiB,EACjB,aAAa,EACb,oBAAoB,EACpB,eAAe,EACf,MAAM,iBAAiB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,22 @@
1
+ import { createPlaygroundBinding } from '@wasm-idle/core';
2
+ import { useCallback, useMemo, useRef, useState } from 'react';
3
+ export function useWasmIdlePlayground(runtimeAssets, loadSandbox) {
4
+ return useMemo(() => createPlaygroundBinding(runtimeAssets, loadSandbox), [runtimeAssets, loadSandbox]);
5
+ }
6
+ export function useWasmIdleHost(runtimeAssets, loadSandbox) {
7
+ const binding = useWasmIdlePlayground(runtimeAssets, loadSandbox);
8
+ const terminalRef = useRef(undefined);
9
+ const [terminal, setTerminalState] = useState(undefined);
10
+ const setTerminal = useCallback((nextTerminal) => {
11
+ terminalRef.current = nextTerminal;
12
+ setTerminalState(nextTerminal);
13
+ }, []);
14
+ return {
15
+ binding,
16
+ terminal,
17
+ setTerminal,
18
+ terminalRef,
19
+ terminalProps: binding.terminalProps
20
+ };
21
+ }
22
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,uBAAuB,EAKvB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAU/D,MAAM,UAAU,qBAAqB,CACpC,aAAmC,EACnC,WAA0B;IAE1B,OAAO,OAAO,CACb,GAAG,EAAE,CAAC,uBAAuB,CAAC,aAAa,EAAE,WAAW,CAAC,EACzD,CAAC,aAAa,EAAE,WAAW,CAAC,CAC5B,CAAC;AACH,CAAC;AAED,MAAM,UAAU,eAAe,CAC9B,aAAmC,EACnC,WAA0B;IAE1B,MAAM,OAAO,GAAG,qBAAqB,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;IAClE,MAAM,WAAW,GAAG,MAAM,CAA8B,SAAS,CAAC,CAAC;IACnE,MAAM,CAAC,QAAQ,EAAE,gBAAgB,CAAC,GAAG,QAAQ,CAA8B,SAAS,CAAC,CAAC;IACtF,MAAM,WAAW,GAAG,WAAW,CAAC,CAAC,YAAyC,EAAE,EAAE;QAC7E,WAAW,CAAC,OAAO,GAAG,YAAY,CAAC;QACnC,gBAAgB,CAAC,YAAY,CAAC,CAAC;IAChC,CAAC,EAAE,EAAE,CAAC,CAAC;IACP,OAAO;QACN,OAAO;QACP,QAAQ;QACR,WAAW;QACX,WAAW;QACX,aAAa,EAAE,OAAO,CAAC,aAAa;KACpC,CAAC;AACH,CAAC"}
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@wasm-idle/react",
3
+ "version": "1.0.0-next.0",
4
+ "description": "React hooks for wasm-idle core",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "import": "./dist/index.js",
11
+ "default": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "publishConfig": {
18
+ "access": "public",
19
+ "tag": "next"
20
+ },
21
+ "peerDependencies": {
22
+ "@wasm-idle/core": "1.0.0-next.0",
23
+ "react": ">=18"
24
+ },
25
+ "dependencies": {
26
+ "@wasm-idle/core": "1.0.0-next.0"
27
+ },
28
+ "devDependencies": {
29
+ "@types/react": "^18.3.12",
30
+ "react": "^18.3.1",
31
+ "typescript": "^6.0.2"
32
+ },
33
+ "scripts": {
34
+ "build": "rm -rf dist && tsc -p tsconfig.json",
35
+ "check": "tsc -p tsconfig.json --noEmit"
36
+ }
37
+ }