@supraio/client-daemon-js 0.0.1-master.7 → 0.0.1-mz-warmup.1
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/daemon/plain.d.ts +1 -0
- package/daemon/wasm.d.ts +11 -0
- package/daemon.d.ts +1 -0
- package/daemon.js +317 -83
- package/daemon.js.map +3 -3
- package/dom/script.d.ts +1 -0
- package/env/consts.d.ts +1 -0
- package/fs/browserfs.d.ts +5 -0
- package/go/go.d.ts +16 -0
- package/package.json +5 -2
- package/screen/options.d.ts +10 -0
- package/screen/plain.d.ts +1 -0
- package/screen/wasm.d.ts +15 -0
- package/screen.d.ts +1 -0
- package/screen.js +16 -9
- package/screen.js.map +3 -3
- package/sdk.d.ts +4 -0
- package/sdk.js +17558 -0
- package/sdk.js.map +7 -0
- package/supra-client-daemon.js +359 -298
- package/supra-client-daemon.js.map +1 -1
- package/supra-client-daemon.wasm +0 -0
- package/supra-client-screen.js +359 -298
- package/supra-client-screen.js.map +1 -1
- package/supra-client-screen.wasm +0 -0
- package/wasm_exec.js +2 -2
package/dom/script.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function injectScript(url: string): Promise<void>;
|
package/env/consts.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const FORCE_PLAIN_KEY = "_forcePlain";
|
package/go/go.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
class Go {
|
|
3
|
+
/** Accessed by x264/decode_wasm.go directly to optimize memory usage */
|
|
4
|
+
h264: WebAssembly.Memory;
|
|
5
|
+
env: {
|
|
6
|
+
[name: string]: string;
|
|
7
|
+
};
|
|
8
|
+
importObject: WebAssembly.Imports;
|
|
9
|
+
argv: string[];
|
|
10
|
+
run(instance: WebAssembly.Instance): Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export declare function getGoEnv(): {
|
|
14
|
+
HOME: string;
|
|
15
|
+
USER: string;
|
|
16
|
+
};
|
package/package.json
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@supraio/client-daemon-js",
|
|
3
|
-
"version": "0.0.1-
|
|
3
|
+
"version": "0.0.1-mz-warmup.1",
|
|
4
4
|
"description": "",
|
|
5
|
-
"main": "
|
|
5
|
+
"main": "sdk.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build-daemon": "esbuild --bundle --sourcemap --target=chrome88,firefox86,edge89 --outfile=dist/daemon.js daemon.ts",
|
|
8
8
|
"build-screen": "esbuild --bundle --sourcemap --target=chrome88,firefox86,edge89 --outfile=dist/screen.js screen.ts",
|
|
9
|
+
"build-sdk": "esbuild --bundle --sourcemap --target=chrome88,firefox86,edge89 --outfile=dist/sdk.js --format=cjs sdk.ts",
|
|
10
|
+
"build-types": "tsc --declaration --emitDeclarationOnly",
|
|
11
|
+
"clean": "rm -rf dist/*",
|
|
9
12
|
"check": "tsc --noEmit",
|
|
10
13
|
"lint": "eslint \"**/*.ts\""
|
|
11
14
|
},
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function startPlainScreen(): Promise<void>;
|
package/screen/wasm.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import '../go/go';
|
|
3
|
+
import { H264Decoder } from 'h264decoder';
|
|
4
|
+
import nodeFs from 'fs';
|
|
5
|
+
import { IScreenOptions } from './options';
|
|
6
|
+
declare global {
|
|
7
|
+
interface Window {
|
|
8
|
+
/** Make it global accessible for x264/decode_wasm.go */
|
|
9
|
+
h264Decoder: H264Decoder;
|
|
10
|
+
/** Make it global accessible for wasm_exec.js */
|
|
11
|
+
fs: typeof nodeFs;
|
|
12
|
+
module: any;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export declare function startWasmScreen(options?: IScreenOptions): Promise<void>;
|
package/screen.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/screen.js
CHANGED
|
@@ -17432,15 +17432,15 @@
|
|
|
17432
17432
|
// screen/wasm.ts
|
|
17433
17433
|
var SCREEN_WASM_URL = "supra-client-screen.wasm";
|
|
17434
17434
|
var WASM_EXEC_URL = "wasm_exec.js";
|
|
17435
|
-
async function startWasmScreen() {
|
|
17436
|
-
const
|
|
17435
|
+
async function startWasmScreen(options) {
|
|
17436
|
+
const screenOptions = options ?? parseQueryOptions();
|
|
17437
17437
|
const fs = await initBrowserFS();
|
|
17438
17438
|
const h264Decoder = await createH264Decoder();
|
|
17439
17439
|
window.h264Decoder = h264Decoder;
|
|
17440
17440
|
window.fs = fs;
|
|
17441
17441
|
window.module = {};
|
|
17442
17442
|
await injectScript(WASM_EXEC_URL);
|
|
17443
|
-
await startGoScreen(h264Decoder,
|
|
17443
|
+
await startGoScreen(h264Decoder, screenOptions);
|
|
17444
17444
|
}
|
|
17445
17445
|
function parseQueryOptions() {
|
|
17446
17446
|
const params = import_querystring.default.parse(window.location.search.substr(1));
|
|
@@ -17497,6 +17497,15 @@
|
|
|
17497
17497
|
];
|
|
17498
17498
|
}
|
|
17499
17499
|
|
|
17500
|
+
// sdk.ts
|
|
17501
|
+
async function startScreen(options) {
|
|
17502
|
+
if (localStorage.getItem(FORCE_PLAIN_KEY) || window.WebAssembly === void 0) {
|
|
17503
|
+
await startPlainScreen();
|
|
17504
|
+
} else {
|
|
17505
|
+
await startWasmScreen(options);
|
|
17506
|
+
}
|
|
17507
|
+
}
|
|
17508
|
+
|
|
17500
17509
|
// screen.ts
|
|
17501
17510
|
window.addEventListener("contextmenu", (ev) => ev.preventDefault());
|
|
17502
17511
|
window.addEventListener("beforeunload", (ev) => {
|
|
@@ -17504,13 +17513,11 @@
|
|
|
17504
17513
|
});
|
|
17505
17514
|
window.addEventListener("load", async () => {
|
|
17506
17515
|
try {
|
|
17507
|
-
|
|
17508
|
-
|
|
17509
|
-
|
|
17510
|
-
await startWasmScreen();
|
|
17511
|
-
}
|
|
17516
|
+
await startScreen();
|
|
17517
|
+
} catch (error) {
|
|
17518
|
+
console.error("Error process", error);
|
|
17512
17519
|
} finally {
|
|
17513
|
-
console.
|
|
17520
|
+
console.log("Reloading window");
|
|
17514
17521
|
location.reload();
|
|
17515
17522
|
}
|
|
17516
17523
|
});
|