use new event channel for mobile and web

This commit is contained in:
csf
2022-05-17 19:59:37 +08:00
parent 85a2a7cd44
commit a7af7967f6
26 changed files with 1875 additions and 480 deletions

View File

@@ -2,3 +2,8 @@ assets
js/src/gen_js_from_hbb.ts
js/src/message.ts
js/src/rendezvous.ts
ogvjs-1.8.6
libopus.js
libopus.wasm
yuv-canvas-1.2.6.js
.yarn

View File

@@ -1 +0,0 @@
<svg viewBox="0 0 375 375" style="width:32px;height:32px;margin:0 4px 4px 0" xmlns="http://www.w3.org/2000/svg"><rect transform="matrix(.91553 0 0 .91553 -152.92 116.76)" x="167.03" y="-127.54" width="409.6" height="409.6" rx="64" ry="64" fill="#0071ff"></rect><path d="M150.428 322.264c-29.063-6.202-53.897-22.439-73.115-47.804-19.507-25.746-27.838-55.355-25.723-91.414 6.655-62.013 47.667-106.753 99.687-120.411 4.509-.989 8.353-3.462 12.55-1.322 3.22 1.64 6.028 4.467 7.206 7.251 1.25 2.955 1.877 21.54.99 29.331-1.076 9.46-3.877 12.418-14.566 15.388-29.723 10.195-48.105 34.07-53.697 61.017-4.8 29.668 2.951 59.729 21.528 78.727 8.966 8.993 17.92 14.24 30.869 18.086 8.646 2.57 13.393 5.758 15.036 10.102 1.085 2.867 1.63 22.984.779 28.772-1.33 9.046-1.702 9.796-5.792 11.667-5.029 2.3-7.404 2.392-15.752.61zm50.708.29c-3.092-1.402-5.673-4.83-6.73-8.94-.134-9.408-2.366-25.754 1.02-33.373 1.88-4.128 4.65-5.999 12.433-8.396 21.267-6.551 37.593-19.88 46.806-38.213 11.11-22.108 11.877-55.183 1.808-77.975-9.154-20.723-25.7-35.217-48.555-42.534-8.872-2.84-12.004-5.065-12.968-9.21-1.002-4.31-1.435-19.87-.785-28.218.682-8.766 1.249-9.99 6.162-13.318 3.701-2.505 5.482-2.446 17.223.575 36.718 10.077 65.97 33.597 83.026 66.68 18.495 37.034 19.191 86.11 1.742 122.655-17.233 36.09-50.591 62.511-88.622 70.194-8.172 1.65-9.07 1.656-12.56.073z" fill="#fff"></path></svg>

Before

Width:  |  Height:  |  Size: 1.3 KiB

View File

@@ -1 +0,0 @@
#app{font-family:Avenir,Helvetica,Arial,sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-align:center;color:#2c3e50;margin-top:60px}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -33,8 +33,8 @@
<link rel="manifest" href="manifest.json">
<script src="ogvjs-1.8.6/ogv.js"></script>
<script src="yuv.js"></script>
<script type="module" crossorigin src="assets/index.a0538fcc.js"></script>
<link rel="modulepreload" href="assets/vendor.32e42528.js">
<script type="module" crossorigin src="js/dist/index.js"></script>
<link rel="modulepreload" href="js/dist/vendor.js">
<script src="yuv-canvas-1.2.6.js"></script>
<style>
.loading {

View File

@@ -0,0 +1 @@
nodeLinker: node-modules

View File

@@ -7,7 +7,6 @@ import { initZstd, translate } from "./common";
import PCMPlayer from "pcm-player";
var currentFrame = undefined;
var events = [];
window.curConn = undefined;
window.getRgba = () => {
@@ -25,11 +24,10 @@ export function isDesktop() {
}
export function msgbox(type, title, text) {
if (!events) return;
if (!type || (type == 'error' && !text)) return;
const text2 = text.toLowerCase();
var hasRetry = checkIfRetry(type, title, text) ? 'true' : '';
events.push({ name: 'msgbox', type, title, text, hasRetry });
onGlobalEvent(JSON.stringify({ name: 'msgbox', type, title, text, hasRetry }));
}
function jsonfyForDart(payload) {
@@ -42,10 +40,9 @@ function jsonfyForDart(payload) {
}
export function pushEvent(name, payload) {
if (!events) return;
payload = jsonfyForDart(payload);
payload.name = name;
events.push(payload);
onGlobalEvent(JSON.stringify(payload));
}
let yuvWorker;
@@ -120,7 +117,6 @@ export function getConn() {
export async function startConn(id) {
currentFrame = undefined;
events = [];
setByName('remote_id', id);
await curConn.start(id);
}
@@ -129,7 +125,6 @@ export function close() {
getConn()?.close();
setConn(undefined);
currentFrame = undefined;
events = undefined;
}
export function newConn() {
@@ -310,13 +305,6 @@ function _getByName(name, arg) {
return localStorage.getItem('remote-id');
case 'remember':
return curConn.getRemember();
case 'event':
if (events && events.length) {
const e = events[0];
events.splice(0, 1);
return JSON.stringify(e);
}
break;
case 'toggle_option':
return curConn.getOption(arg) || false;
case 'option':

View File

@@ -0,0 +1,14 @@
import { defineConfig } from 'vite';
export default defineConfig({
build: {
manifest: false,
rollupOptions: {
output: {
entryFileNames: `[name].js`,
chunkFileNames: `[name].js`,
assetFileNames: `[name].[ext]`,
}
}
},
})

File diff suppressed because it is too large Load Diff