@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.
@@ -0,0 +1 @@
1
+ export declare function injectScript(url: string): Promise<void>;
@@ -0,0 +1 @@
1
+ export declare const FORCE_PLAIN_KEY = "_forcePlain";
@@ -0,0 +1,5 @@
1
+ /// <reference types="node" />
2
+ declare global {
3
+ type NodeBuffer = Buffer;
4
+ }
5
+ export declare function initBrowserFS(): Promise<any>;
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-master.7",
3
+ "version": "0.0.1-mz-warmup.1",
4
4
  "description": "",
5
- "main": "daemon.js",
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,10 @@
1
+ export interface IScreenOptions {
2
+ screenID: string;
3
+ screenDriver: string;
4
+ screenHost: string;
5
+ metadataDriver: string;
6
+ metadataHost: string;
7
+ clientID: string;
8
+ clientSecret: string;
9
+ secure: boolean;
10
+ }
@@ -0,0 +1 @@
1
+ export declare function startPlainScreen(): Promise<void>;
@@ -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 options = parseQueryOptions();
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, options);
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
- if (localStorage.getItem(FORCE_PLAIN_KEY) || window.WebAssembly === void 0) {
17508
- await startPlainScreen();
17509
- } else {
17510
- await startWasmScreen();
17511
- }
17516
+ await startScreen();
17517
+ } catch (error) {
17518
+ console.error("Error process", error);
17512
17519
  } finally {
17513
- console.error("Reloading window");
17520
+ console.log("Reloading window");
17514
17521
  location.reload();
17515
17522
  }
17516
17523
  });