├── .yarnrc ├── web ├── src │ ├── components │ │ ├── reusable │ │ │ ├── LinkOpener.css │ │ │ ├── WysiwygEditor.css │ │ │ ├── SuspenseFallback.css │ │ │ ├── README.md │ │ │ ├── SuspenseFallback.tsx │ │ │ ├── Loading.tsx │ │ │ ├── RegionEditor.css │ │ │ ├── GoBoard.css │ │ │ ├── MeetingScreen.css │ │ │ ├── ErrorFallback.tsx │ │ │ ├── TalkyStarter.tsx │ │ │ ├── GitHubCorner.css │ │ │ ├── TalkyStarter.css │ │ │ ├── MediaShare.css │ │ │ ├── Loading.css │ │ │ ├── FaceCard.css │ │ │ ├── Landing.css │ │ │ ├── LinkOpener.tsx │ │ │ ├── GitHubCorner.tsx │ │ │ ├── WysiwygEditor.tsx │ │ │ ├── MomentaryChat.css │ │ │ ├── FaceCard.tsx │ │ │ ├── Landing.tsx │ │ │ ├── MeetingScreen.tsx │ │ │ ├── RegionEditor.tsx │ │ │ ├── MomentaryChat.tsx │ │ │ ├── MediaShare.tsx │ │ │ └── GoBoard.tsx │ │ ├── MySetting.css │ │ ├── SingleRoom.css │ │ ├── App.css │ │ ├── FaceList.css │ │ ├── SingleRoomEntrance.css │ │ ├── App.test.tsx │ │ ├── MemberList.css │ │ ├── App.tsx │ │ ├── SingleRoom.tsx │ │ ├── ControlPanel.css │ │ ├── GatherArea.css │ │ ├── FaceList.tsx │ │ ├── MySetting.tsx │ │ ├── MemberList.tsx │ │ ├── SingleRoomEntrance.tsx │ │ └── ControlPanel.tsx │ ├── vite-env.d.ts │ ├── utils │ │ ├── sleep.ts │ │ ├── __mocks__ │ │ │ └── crypto.ts │ │ ├── excalidraw.ts │ │ ├── types.ts │ │ ├── emoji.ts │ │ ├── base64.ts │ │ ├── storage.ts │ │ ├── url.ts │ │ └── crypto.ts │ ├── setupTests.ts │ ├── index.tsx │ ├── index.css │ ├── media │ │ ├── screen.ts │ │ ├── audio.ts │ │ ├── video.ts │ │ ├── devices.ts │ │ ├── capture.ts │ │ └── imagePresets.ts │ ├── network │ │ ├── ipfs-pubsub-room.d.ts │ │ ├── room.ts │ │ ├── common.ts │ │ ├── pubsubUtils.ts │ │ ├── trackUtils.ts │ │ ├── ipfsUtils.ts │ │ └── peerjsUtils.ts │ ├── hooks │ │ ├── useNotification.ts │ │ ├── useInputAvatar.ts │ │ ├── useNicknameMap.ts │ │ ├── useAvailableDevices.ts │ │ ├── useGoBoard.ts │ │ ├── useMomentaryChat.ts │ │ ├── useMediaShare.ts │ │ ├── useFaceImages.ts │ │ ├── useGatherArea.ts │ │ └── useFaceVideos.ts │ └── states │ │ ├── global.ts │ │ └── roomMap.ts ├── public │ ├── favicon.ico │ ├── logo192.png │ ├── logo512.png │ ├── robots.txt │ ├── manifest.json │ ├── stream_viewer.html │ ├── audio-decoder.js │ └── audio-encoder.js ├── vite.config.ts ├── tsconfig.json ├── index.html ├── .eslintrc.json └── package.json ├── images ├── logo.png └── screen01.png ├── electron ├── build │ ├── icon.icns │ ├── icon.ico │ └── icon.svg ├── src │ ├── preload.js │ ├── prompt-polyfill.js │ ├── get-display-media-polyfill.js │ └── main.js └── package.json ├── .gitignore ├── .gitmodules ├── package.json ├── .github └── workflows │ ├── ci.yml │ └── cd.yml ├── LICENSE ├── libopus └── Makefile ├── CONTRIBUTING.md ├── ckeditor5 ├── webpack.config.js ├── package.json └── src │ └── ckeditor.js └── README.md /.yarnrc: -------------------------------------------------------------------------------- 1 | ignore-engines true 2 | -------------------------------------------------------------------------------- /web/src/components/reusable/LinkOpener.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /web/src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /web/src/components/MySetting.css: -------------------------------------------------------------------------------- 1 | .MySetting-container { 2 | } 3 | -------------------------------------------------------------------------------- /images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SD11892/Remote_face/HEAD/images/logo.png -------------------------------------------------------------------------------- /images/screen01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SD11892/Remote_face/HEAD/images/screen01.png -------------------------------------------------------------------------------- /electron/build/icon.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SD11892/Remote_face/HEAD/electron/build/icon.icns -------------------------------------------------------------------------------- /electron/build/icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SD11892/Remote_face/HEAD/electron/build/icon.ico -------------------------------------------------------------------------------- /web/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SD11892/Remote_face/HEAD/web/public/favicon.ico -------------------------------------------------------------------------------- /web/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SD11892/Remote_face/HEAD/web/public/logo192.png -------------------------------------------------------------------------------- /web/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SD11892/Remote_face/HEAD/web/public/logo512.png -------------------------------------------------------------------------------- /web/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /web/src/components/SingleRoom.css: -------------------------------------------------------------------------------- 1 | .SingleRoom-container { 2 | width: 100%; 3 | height: 100%; 4 | } 5 | -------------------------------------------------------------------------------- /web/src/components/App.css: -------------------------------------------------------------------------------- 1 | .App { 2 | height: 100vh; 3 | margin: 0; 4 | -webkit-app-region: drag; 5 | } 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | *.swp 3 | node_modules 4 | dist 5 | .DS_Store 6 | .eslintcache 7 | /web/build 8 | /ckeditor5/build 9 | -------------------------------------------------------------------------------- /web/src/components/reusable/WysiwygEditor.css: -------------------------------------------------------------------------------- 1 | .ck-body .ck.ck-balloon-panel:first-of-type { 2 | z-index: 1001; 3 | } 4 | -------------------------------------------------------------------------------- /electron/src/preload.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | require('./get-display-media-polyfill.js'); 3 | require('./prompt-polyfill'); 4 | -------------------------------------------------------------------------------- /web/src/components/reusable/SuspenseFallback.css: -------------------------------------------------------------------------------- 1 | .SuspenseFallback-container { 2 | display: flex; 3 | justify-content: center; 4 | } 5 | -------------------------------------------------------------------------------- /web/src/utils/sleep.ts: -------------------------------------------------------------------------------- 1 | export const sleep = (ms: number) => 2 | new Promise((resolve) => { 3 | setTimeout(resolve, ms); 4 | }); 5 | -------------------------------------------------------------------------------- /web/src/components/reusable/README.md: -------------------------------------------------------------------------------- 1 | ## Note 2 | 3 | Reusable components are components that don't depend on global state. 4 | (Depending on `getRoomState` is okay.) 5 | -------------------------------------------------------------------------------- /web/src/utils/__mocks__/crypto.ts: -------------------------------------------------------------------------------- 1 | export const secureRandomId = () => { 2 | const arrbuf = new Uint8Array(16).map(() => Math.random() * 256); 3 | const arr = Array.from(arrbuf); 4 | const hex = arr.map((b) => b.toString(16).padStart(2, "0")).join(""); 5 | return hex; 6 | }; 7 | -------------------------------------------------------------------------------- /web/src/components/reusable/SuspenseFallback.tsx: -------------------------------------------------------------------------------- 1 | import { memo } from "react"; 2 | 3 | import "./SuspenseFallback.css"; 4 | 5 | export const SuspenseFallback = memo(() => ( 6 |
7 |
Loading...
8 |
9 | )); 10 | -------------------------------------------------------------------------------- /web/src/setupTests.ts: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import "@testing-library/jest-dom/extend-expect"; 6 | -------------------------------------------------------------------------------- /web/src/components/reusable/Loading.tsx: -------------------------------------------------------------------------------- 1 | import { memo } from "react"; 2 | 3 | import "./Loading.css"; 4 | 5 | export const Loading = memo(() => ( 6 |
7 |
8 |
Loading...
9 |
10 |
11 | )); 12 | -------------------------------------------------------------------------------- /web/src/components/FaceList.css: -------------------------------------------------------------------------------- 1 | .FaceList-list { 2 | overflow: scroll; 3 | height: 100vh; 4 | } 5 | 6 | .FaceList-list::-webkit-scrollbar { 7 | display: none; 8 | } 9 | 10 | .FaceList-item { 11 | width: 36px; 12 | margin: 0 0 2px 0; 13 | box-shadow: 1px 1px 2px 0 rgba(0, 0, 0, 0.2); 14 | } 15 | -------------------------------------------------------------------------------- /web/src/components/SingleRoomEntrance.css: -------------------------------------------------------------------------------- 1 | .SingleRoomEntrance-container { 2 | } 3 | 4 | .SingleRoomEntrance-input { 5 | display: flex; 6 | flex-direction: column; 7 | align-items: center; 8 | } 9 | 10 | .SingleRoomEntrance-input input, 11 | .SingleRoomEntrance-input button { 12 | margin: 0.5rem; 13 | } 14 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "libopus/opus"] 2 | path = libopus/opus 3 | url = https://github.com/xiph/opus.git 4 | [submodule "libopus/speexdsp"] 5 | path = libopus/speexdsp 6 | url = https://github.com/xiph/speexdsp.git 7 | [submodule "ckeditor5/upstream"] 8 | path = ckeditor5/upstream 9 | url = https://github.com/ckeditor/ckeditor5.git 10 | -------------------------------------------------------------------------------- /web/src/components/reusable/RegionEditor.css: -------------------------------------------------------------------------------- 1 | .RegionEditor-container input { 2 | width: 40px; 3 | } 4 | 5 | .RegionEditor-toggle { 6 | text-align: left; 7 | cursor: pointer; 8 | border: none; 9 | background: none; 10 | padding: 0.1rem; 11 | color: gray; 12 | font-size: 0.5rem; 13 | } 14 | 15 | .RegionEditor-toggle:focus { 16 | outline:0; 17 | } 18 | -------------------------------------------------------------------------------- /web/src/components/reusable/GoBoard.css: -------------------------------------------------------------------------------- 1 | .GoBoard-container { 2 | overflow: scroll; 3 | display: flex; 4 | flex-direction: column; 5 | width: 100%; 6 | height: 100%; 7 | } 8 | 9 | .GoBoard-toolbar { 10 | font-size: x-small; 11 | } 12 | 13 | .GoBoard-toolbar button { 14 | font-size: x-small; 15 | } 16 | 17 | .GoBoard-canvas { 18 | flex: 1; 19 | margin: auto; 20 | } 21 | -------------------------------------------------------------------------------- /web/src/index.tsx: -------------------------------------------------------------------------------- 1 | import { StrictMode } from "react"; 2 | import { createRoot } from "react-dom/client"; 3 | import "./index.css"; 4 | import { App } from "./components/App"; 5 | 6 | const ele = document.getElementById("root"); 7 | if (!ele) { 8 | throw new Error("no root"); 9 | } 10 | 11 | createRoot(ele).render( 12 | 13 | 14 | 15 | ); 16 | -------------------------------------------------------------------------------- /web/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 12 | monospace; 13 | } 14 | -------------------------------------------------------------------------------- /electron/src/prompt-polyfill.js: -------------------------------------------------------------------------------- 1 | /* eslint-env browser */ 2 | 3 | // https://github.com/konsumer/electron-prompt 4 | // https://github.com/electron/electron-quick-start/compare/master...konsumer:master 5 | 6 | const { ipcRenderer } = require('electron'); 7 | 8 | window.prompt = (title, val) => ipcRenderer.sendSync('prompt', { title, val }); 9 | 10 | window.promptRespond = (val) => { 11 | ipcRenderer.send('prompt-response', val); 12 | }; 13 | -------------------------------------------------------------------------------- /web/src/utils/excalidraw.ts: -------------------------------------------------------------------------------- 1 | import { ROOM_ID_PREFIX_LEN } from "../network/room"; 2 | import { importCryptoKey } from "./crypto"; 3 | 4 | export const generateExcalidrawURL = async (roomId: string) => { 5 | const id = roomId.slice(0, 20); 6 | const imported = await importCryptoKey(roomId.slice(ROOM_ID_PREFIX_LEN)); 7 | const key = (await window.crypto.subtle.exportKey("jwk", imported)).k; 8 | return `https://excalidraw.com/#room=${id},${key}`; 9 | }; 10 | -------------------------------------------------------------------------------- /web/src/components/App.test.tsx: -------------------------------------------------------------------------------- 1 | import { render, waitForElementToBeRemoved } from "@testing-library/react"; 2 | import { App } from "./App"; 3 | 4 | jest.mock("../utils/crypto"); 5 | 6 | test("renders App", async () => { 7 | const { getByText, getAllByText } = render(); 8 | await waitForElementToBeRemoved(getByText(/loading/i)); 9 | const elements = getAllByText(/create a new room/i); 10 | expect(elements.length).toBeGreaterThanOrEqual(1); 11 | }); 12 | -------------------------------------------------------------------------------- /web/src/media/screen.ts: -------------------------------------------------------------------------------- 1 | export const getScreenStream = async () => { 2 | try { 3 | const constraints = { video: true }; 4 | const stream = (await (navigator.mediaDevices as any).getDisplayMedia( 5 | constraints 6 | )) as MediaStream; 7 | const [track] = stream.getVideoTracks(); 8 | const dispose = () => { 9 | track.stop(); 10 | }; 11 | return { 12 | stream, 13 | dispose, 14 | }; 15 | } catch (e) { 16 | return null; 17 | } 18 | }; 19 | -------------------------------------------------------------------------------- /web/src/network/ipfs-pubsub-room.d.ts: -------------------------------------------------------------------------------- 1 | declare module "ipfs-pubsub-room" { 2 | class PubSubRoom { 3 | constructor(ipfs: any, topic: string); 4 | 5 | getPeers(): string[]; 6 | 7 | hasPeer(peer: string): boolean; 8 | 9 | async leave(): Promise; 10 | 11 | async broadcast(message: Uint8Array | string): Promise; 12 | 13 | sendTo(peer: string, message: Uint8Array | string): void; 14 | 15 | on(name: string, listener: (...args: any) => void); 16 | } 17 | export = PubSubRoom; 18 | } 19 | -------------------------------------------------------------------------------- /web/src/components/reusable/MeetingScreen.css: -------------------------------------------------------------------------------- 1 | .MeetingScreen-container { 2 | -webkit-app-region: no-drag; 3 | overflow: scroll; 4 | width: 100%; 5 | height: 100%; 6 | } 7 | 8 | .MeetingScreen-toolbar { 9 | border-bottom: gray 1px solid; 10 | } 11 | 12 | .MeetingScreen-toolbar > button, select { 13 | margin: 2px; 14 | font-size: 0.7rem; 15 | } 16 | 17 | .MeetingScreen-body { 18 | } 19 | 20 | .MeetingScreen-opener { 21 | float: left; 22 | margin: 2px; 23 | } 24 | 25 | .MeetingScreen-opener > button { 26 | font-size: 0.7rem; 27 | } 28 | -------------------------------------------------------------------------------- /web/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "Remote Faces", 3 | "name": "Remote Faces", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "remote-faces", 3 | "description": "A small app to share webcam still images periodically", 4 | "private": true, 5 | "author": "Daishi Kato", 6 | "workspaces": { 7 | "packages": [ 8 | "web", 9 | "electron", 10 | "ckeditor5" 11 | ], 12 | "nohoist": [ 13 | "**/electron", 14 | "**/electron/**" 15 | ] 16 | }, 17 | "scripts": { 18 | "test": "yarn workspaces run test", 19 | "postinstall": "patch-package" 20 | }, 21 | "devDependencies": { 22 | "patch-package": "^6.4.7", 23 | "postinstall-postinstall": "^2.1.0" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /web/src/media/audio.ts: -------------------------------------------------------------------------------- 1 | export const getAudioStream = async (deviceId?: string) => { 2 | const constraints = deviceId 3 | ? { 4 | audio: { deviceId }, 5 | } 6 | : { audio: true }; 7 | const stream = await navigator.mediaDevices.getUserMedia(constraints); 8 | const [track] = stream.getAudioTracks(); 9 | await track.applyConstraints({ 10 | echoCancellation: true, 11 | echoCancellationType: { ideal: "system" }, 12 | noiseSuppression: { ideal: true }, 13 | } as MediaTrackConstraints); 14 | const dispose = () => { 15 | track.stop(); 16 | }; 17 | return { 18 | stream, 19 | dispose, 20 | }; 21 | }; 22 | -------------------------------------------------------------------------------- /web/src/hooks/useNotification.ts: -------------------------------------------------------------------------------- 1 | import { useEffect, useCallback, useRef } from "react"; 2 | 3 | export const useNotification = () => { 4 | const notificationRef = useRef(); 5 | const sendNotification = useCallback((mesg: string) => { 6 | if (Notification.permission === "granted") { 7 | if (notificationRef.current) { 8 | notificationRef.current.close(); 9 | } 10 | notificationRef.current = new Notification(mesg); 11 | } 12 | }, []); 13 | useEffect(() => { 14 | if (Notification.permission !== "granted") { 15 | Notification.requestPermission(); 16 | } 17 | }, []); 18 | return sendNotification; 19 | }; 20 | -------------------------------------------------------------------------------- /web/vite.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from "vite"; 2 | import react from "@vitejs/plugin-react"; 3 | import NodeGlobalsPolyfillPlugin from "@esbuild-plugins/node-globals-polyfill"; 4 | 5 | // https://vitejs.dev/config/ 6 | export default defineConfig({ 7 | plugins: [react()], 8 | optimizeDeps: { 9 | esbuildOptions: { 10 | define: { 11 | global: "window", 12 | }, 13 | plugins: [ 14 | NodeGlobalsPolyfillPlugin({ 15 | process: true, 16 | buffer: true, 17 | }), 18 | ], 19 | target: "es2020", 20 | }, 21 | }, 22 | base: './', 23 | build: { 24 | target: "es2020", 25 | outDir: "build", 26 | }, 27 | }); 28 | -------------------------------------------------------------------------------- /web/src/network/room.ts: -------------------------------------------------------------------------------- 1 | import { hasIpfsConfigInUrl, hasPubsubConfigInUrl } from "../utils/url"; 2 | import type { CreateRoom } from "./common"; 3 | 4 | export type { NetworkStatus, PeerInfo } from "./common"; 5 | export { ROOM_ID_PREFIX_LEN } from "./common"; 6 | 7 | export const createRoom: CreateRoom = async (...args) => { 8 | let createRoomImpl: CreateRoom; 9 | if (hasIpfsConfigInUrl()) { 10 | createRoomImpl = (await import("./ipfsRoom")).createRoom; 11 | } else if (hasPubsubConfigInUrl()) { 12 | createRoomImpl = (await import("./pubsubRoom")).createRoom; 13 | } else { 14 | createRoomImpl = (await import("./peerjsRoom")).createRoom; 15 | } 16 | return createRoomImpl(...args); 17 | }; 18 | -------------------------------------------------------------------------------- /web/src/components/reusable/ErrorFallback.tsx: -------------------------------------------------------------------------------- 1 | import { memo, useEffect, useState } from "react"; 2 | 3 | export const ErrorFallback = memo<{ 4 | err: Error; 5 | }>(({ err }) => { 6 | const [waitSec, setWaitSec] = useState(30); 7 | 8 | useEffect(() => { 9 | if (waitSec > 0) { 10 | setTimeout(() => { 11 | setWaitSec(waitSec - 1); 12 | }, 1000); 13 | } else { 14 | window.location.reload(); 15 | } 16 | }); 17 | 18 | return ( 19 |
20 |

Unrecoverable error occurred.

21 | {err && ( 22 |
23 | {err.name}: {err.message} 24 |
25 | )} 26 |

Will auto reload in {waitSec} sec.

27 |
28 | ); 29 | }); 30 | -------------------------------------------------------------------------------- /web/src/components/reusable/TalkyStarter.tsx: -------------------------------------------------------------------------------- 1 | import { memo } from "react"; 2 | 3 | import "./TalkyStarter.css"; 4 | import { ROOM_ID_PREFIX_LEN } from "../../network/common"; 5 | 6 | const TalkyStarter = memo<{ 7 | roomId: string; 8 | uniqueId?: string; 9 | }>(({ roomId, uniqueId }) => { 10 | const talkyUrl = `https://talky.io/${roomId.slice(0, ROOM_ID_PREFIX_LEN)}_${ 11 | uniqueId || "default" 12 | }`; 13 | 14 | return ( 15 |
16 | 21 |
22 | ); 23 | }); 24 | 25 | export default TalkyStarter; 26 | -------------------------------------------------------------------------------- /web/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "esnext", 4 | "lib": ["dom", "dom.iterable", "esnext"], 5 | "downlevelIteration": true, 6 | "allowJs": true, 7 | "skipLibCheck": true, 8 | "esModuleInterop": true, 9 | "allowSyntheticDefaultImports": true, 10 | "strict": true, 11 | "forceConsistentCasingInFileNames": true, 12 | "module": "esnext", 13 | "moduleResolution": "node", 14 | "resolveJsonModule": true, 15 | "isolatedModules": true, 16 | "noEmit": true, 17 | "jsx": "react-jsx", 18 | "types": [ 19 | "vite/client", 20 | "w3c-image-capture", 21 | "jest" 22 | ], 23 | "noFallthroughCasesInSwitch": true 24 | }, 25 | "include": [ 26 | "src" 27 | ] 28 | } 29 | -------------------------------------------------------------------------------- /web/src/components/reusable/GitHubCorner.css: -------------------------------------------------------------------------------- 1 | .GitHubCorner-container:hover .GitHubCorner-octo-arm { 2 | animation: GitHubCorner-octocat-wave 560ms ease-in-out; 3 | } 4 | 5 | @keyframes GitHubCorner-octocat-wave { 6 | 0%, 7 | 100% { 8 | transform: rotate(0); 9 | } 10 | 20%, 11 | 60% { 12 | transform: rotate(-25deg); 13 | } 14 | 40%, 15 | 80% { 16 | transform: rotate(10deg); 17 | } 18 | } 19 | 20 | @media (max-width: 500px) { 21 | .GitHubCorner-container:hover .GitHubCorner-octo-arm { 22 | animation: none; 23 | } 24 | .GitHubCorner-octo-arm { 25 | animation: GitHubCorner-octocat-wave 560ms ease-in-out; 26 | } 27 | } 28 | 29 | @media (max-width: 300px) { 30 | .GitHubCorner-container { 31 | display: none; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /web/src/utils/types.ts: -------------------------------------------------------------------------------- 1 | export const isObject = (x: unknown): x is Record => 2 | typeof x === "object" && x !== null; 3 | 4 | export const hasStringProp = < 5 | Obj extends Record, 6 | Prop extends string 7 | >( 8 | x: Obj, 9 | prop: Prop 10 | ): x is Obj & Record => 11 | typeof (x as Record)[prop] === "string"; 12 | 13 | export const hasObjectProp = < 14 | Obj extends Record, 15 | Prop extends string 16 | >( 17 | x: Obj, 18 | prop: Prop 19 | ): x is Obj & Record> => 20 | isObject((x as Record)[prop]); 21 | 22 | export type ReturnPromiseType any> = 23 | ReturnType extends Promise ? T : never; 24 | -------------------------------------------------------------------------------- /web/src/hooks/useInputAvatar.ts: -------------------------------------------------------------------------------- 1 | import { useCallback, useState } from "react"; 2 | 3 | export const useInputAvatar = (initialAvator: string) => { 4 | const [avatar, setAvatar] = useState(initialAvator); 5 | 6 | const onChangeAvatar = useCallback((files: FileList | null) => { 7 | const file = files && files[0]; 8 | if (!file) { 9 | return; 10 | } 11 | if (file.size > 16 * 1024) { 12 | window.alert(`Too large: ${file.size}`); 13 | return; 14 | } 15 | const reader = new FileReader(); 16 | reader.onload = () => { 17 | if (typeof reader.result === "string") { 18 | setAvatar(reader.result); 19 | } 20 | }; 21 | reader.readAsDataURL(file); 22 | }, []); 23 | 24 | return [avatar, onChangeAvatar] as const; 25 | }; 26 | -------------------------------------------------------------------------------- /web/src/utils/emoji.ts: -------------------------------------------------------------------------------- 1 | import { ComponentType } from "react"; 2 | import "emoji-mart/css/emoji-mart.css"; 3 | import { BaseEmoji, Picker, getEmojiDataFromNative, Data } from "emoji-mart"; 4 | import data from "emoji-mart/data/all.json"; 5 | 6 | export { Emoji } from "emoji-mart"; 7 | export type EmojiDataType = BaseEmoji; 8 | 9 | // we do not support custom emojis 10 | export const EmojiPicker = Picker as ComponentType< 11 | | Omit 12 | | { 13 | onSelect: (emoji: BaseEmoji) => void; 14 | style: unknown; 15 | } 16 | >; 17 | 18 | export const isEmoji = (s: string) => { 19 | const emojiData: BaseEmoji | null = getEmojiDataFromNative( 20 | s, 21 | "apple", 22 | data as unknown as Data 23 | ); 24 | return !!emojiData; 25 | }; 26 | -------------------------------------------------------------------------------- /web/src/components/reusable/TalkyStarter.css: -------------------------------------------------------------------------------- 1 | .TalkyStarter-container { 2 | -webkit-app-region: no-drag; 3 | overflow: scroll; 4 | width: 100%; 5 | height: 100%; 6 | } 7 | 8 | .TalkyStarter-body { 9 | display: grid; 10 | height: 100%; 11 | } 12 | 13 | .TalkyStarter-body a { 14 | margin: auto; 15 | text-decoration: none; 16 | color: gray; 17 | background-color: lightgray; 18 | padding: 0.5rem; 19 | } 20 | 21 | @keyframes TalkyStarter-rumble { 22 | 0% { transform:translate(0, 0); } 23 | 25% { transform:translate(0, 0) rotate(5deg); } 24 | 50% { transform:translate(0, 0); } 25 | 75% { transform:translate(0, 0) rotate(-5deg); } 26 | 100% { transform:translate(0, 0); } 27 | } 28 | 29 | .TalkyStarter-body a:hover { 30 | animation:TalkyStarter-rumble 0.2s linear; 31 | } 32 | -------------------------------------------------------------------------------- /web/src/components/MemberList.css: -------------------------------------------------------------------------------- 1 | .MemberList-container { 2 | width: 260px; 3 | overflow: scroll; 4 | background: #222222; 5 | padding-bottom: 120px; 6 | } 7 | 8 | .MemberList-container::-webkit-scrollbar { 9 | display: none; 10 | } 11 | 12 | .MemberList-item { 13 | margin: 16px; 14 | display: grid; 15 | grid-template-columns: auto 1fr; 16 | grid-template-rows: auto 1fr; 17 | } 18 | 19 | .MemberList-face { 20 | grid-row: 1 / 3; 21 | width: 36px; 22 | height: 36px; 23 | border: 2px solid white; 24 | border-radius: 50%; 25 | overflow: hidden; 26 | align-self: center; 27 | margin-right: 12px; 28 | } 29 | 30 | .MemberList-name { 31 | color: #a5a5a5; 32 | font-weight: bold; 33 | font-size: 0.9rem; 34 | } 35 | 36 | .MemberList-mesg { 37 | color: #a5a5a5; 38 | word-break: break-all; 39 | font-size: 0.8rem; 40 | } 41 | -------------------------------------------------------------------------------- /web/src/components/reusable/MediaShare.css: -------------------------------------------------------------------------------- 1 | .MediaShare-container { 2 | -webkit-app-region: no-drag; 3 | overflow: scroll; 4 | width: 100%; 5 | height: 100%; 6 | } 7 | 8 | .MediaShare-toolbar { 9 | border-bottom: gray 1px solid; 10 | } 11 | 12 | .MediaShare-toolbar > button, select { 13 | margin: 4px; 14 | } 15 | 16 | .MediaShare-body { 17 | display: grid; 18 | grid-gap: 5px; 19 | grid-template-columns: repeat(1, 1fr); 20 | grid-template-rows: repeat(1, 100%); 21 | width: 100%; 22 | height: 100%; 23 | } 24 | 25 | .MediaShare-card { 26 | position: relative; 27 | width: 100%; 28 | height: 100%; 29 | } 30 | 31 | .MediaShare-video { 32 | width: 100%; 33 | height: 100%; 34 | } 35 | 36 | .MediaShare-nickname { 37 | position: absolute; 38 | top: 5px; 39 | left: 5px; 40 | color: #f5f5f5; 41 | text-shadow: 1px 1px 0 #4848487a; 42 | } 43 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | pull_request: 6 | 7 | jobs: 8 | test: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@v2 12 | 13 | - name: Setup Node 14 | uses: actions/setup-node@v1 15 | with: 16 | node-version: '14.x' 17 | 18 | - name: Get yarn cache 19 | id: yarn-cache 20 | run: echo "::set-output name=dir::$(yarn cache dir)" 21 | 22 | - name: Cache dependencies 23 | uses: actions/cache@v1 24 | with: 25 | path: ${{ steps.yarn-cache.outputs.dir }} 26 | key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} 27 | restore-keys: | 28 | ${{ runner.os }}-yarn- 29 | 30 | - name: Install dependencies 31 | run: yarn install 32 | 33 | - name: Test 34 | run: yarn test 35 | -------------------------------------------------------------------------------- /web/src/media/video.ts: -------------------------------------------------------------------------------- 1 | export const getVideoStream = async (deviceId?: string) => { 2 | const constraints = deviceId 3 | ? { 4 | video: { deviceId }, 5 | } 6 | : { video: true }; 7 | const stream = await navigator.mediaDevices.getUserMedia(constraints); 8 | const [track] = stream.getVideoTracks(); 9 | const dispose = () => { 10 | track.stop(); 11 | }; 12 | return { 13 | stream, 14 | dispose, 15 | }; 16 | }; 17 | 18 | export const getFaceVideoStream = async (deviceId?: string) => { 19 | const constraints = { 20 | video: { 21 | deviceId, 22 | frameRate: { max: 5 }, 23 | width: { exact: 72 }, 24 | height: { exact: 72 }, 25 | }, 26 | }; 27 | const stream = await navigator.mediaDevices.getUserMedia(constraints); 28 | const [track] = stream.getVideoTracks(); 29 | const dispose = () => { 30 | track.stop(); 31 | }; 32 | return { 33 | stream, 34 | dispose, 35 | }; 36 | }; 37 | -------------------------------------------------------------------------------- /web/src/components/App.tsx: -------------------------------------------------------------------------------- 1 | import { PureComponent, ReactNode, Suspense, memo } from "react"; 2 | 3 | import "./App.css"; 4 | import { ErrorFallback } from "./reusable/ErrorFallback"; 5 | import { SuspenseFallback } from "./reusable/SuspenseFallback"; 6 | import { SingleRoomEntrance } from "./SingleRoomEntrance"; 7 | import { GitHubCorner } from "./reusable/GitHubCorner"; 8 | 9 | class ErrorBoundary extends PureComponent<{ children: ReactNode }> { 10 | state: { err?: Error } = {}; 11 | 12 | static getDerivedStateFromError(err: Error) { 13 | return { err }; 14 | } 15 | 16 | render() { 17 | const { children } = this.props; 18 | const { err } = this.state; 19 | if (err) return ; 20 | return children; 21 | } 22 | } 23 | 24 | export const App = memo(() => ( 25 |
26 | 27 | }> 28 | 29 | 30 | 31 | 32 |
33 | )); 34 | -------------------------------------------------------------------------------- /web/src/utils/base64.ts: -------------------------------------------------------------------------------- 1 | export const encodeBase64Sync = (data: Uint8Array) => { 2 | const base64 = btoa(String.fromCharCode(...data)); 3 | return base64; 4 | }; 5 | 6 | export const decodeBase64Sync = (base64: string) => { 7 | const binaryString = atob(base64); 8 | const data = new Uint8Array( 9 | [].map.call(binaryString, (c: string) => 10 | c.charCodeAt(0) 11 | ) as unknown as ArrayBufferLike 12 | ); 13 | return data; 14 | }; 15 | 16 | export const encodeBase64Async = (data: Uint8Array) => 17 | new Promise((resolve) => { 18 | const reader = new FileReader(); 19 | reader.onload = () => { 20 | const result = reader.result as string; 21 | const offset = result.indexOf(",") + 1; 22 | resolve(result.slice(offset)); 23 | }; 24 | reader.readAsDataURL(new Blob([data])); 25 | }); 26 | 27 | export const decodeBase64Async = async (base64: string) => { 28 | const response = await fetch( 29 | `data:application/octet-binary;base64,${base64}` 30 | ); 31 | const buf = await response.arrayBuffer(); 32 | return new Uint8Array(buf); 33 | }; 34 | -------------------------------------------------------------------------------- /web/src/components/reusable/Loading.css: -------------------------------------------------------------------------------- 1 | .Loading-container { 2 | display: flex; 3 | align-items: center; 4 | justify-content: center; 5 | width: 36px; 6 | height: 36px; 7 | } 8 | .Loading-container .loader, 9 | .Loading-container .loader:before, 10 | .Loading-container .loader:after { 11 | background: #ddd; 12 | animation: Loading-anime 1s infinite ease-in-out; 13 | width: 4px; 14 | height: 16px; 15 | } 16 | .Loading-container .loader { 17 | color: #ddd; 18 | text-indent: -9999em; 19 | margin: auto; 20 | position: relative; 21 | transform: translateZ(0); 22 | animation-delay: -0.16s; 23 | } 24 | .Loading-container .loader:before, 25 | .Loading-container .loader:after { 26 | position: absolute; 27 | top: 0; 28 | content: ""; 29 | } 30 | .Loading-container .loader:before { 31 | left: -6px; 32 | animation-delay: -0.32s; 33 | } 34 | .Loading-container .loader:after { 35 | left: 6px; 36 | } 37 | @keyframes Loading-anime { 38 | 0%, 39 | 80%, 40 | 100% { 41 | box-shadow: 0 0; 42 | height: 16px; 43 | } 44 | 40% { 45 | box-shadow: 0 -8px; 46 | height: 20px; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /web/src/media/devices.ts: -------------------------------------------------------------------------------- 1 | type DeviceInfo = { 2 | label: string; 3 | deviceId: string; 4 | }; 5 | 6 | export const getVideoDeviceInfoList = async () => { 7 | const constraints = { 8 | video: { 9 | width: 1280, 10 | height: 720, 11 | }, 12 | }; 13 | try { 14 | await navigator.mediaDevices.getUserMedia(constraints); 15 | const devices = await navigator.mediaDevices.enumerateDevices(); 16 | const list: DeviceInfo[] = devices 17 | .filter(({ kind }) => kind === "videoinput") 18 | .map(({ label, deviceId }) => ({ label, deviceId })); 19 | return list; 20 | } catch (e) { 21 | // ignored 22 | return []; 23 | } 24 | }; 25 | 26 | export const getAudioDeviceInfoList = async () => { 27 | try { 28 | await navigator.mediaDevices.getUserMedia({ audio: true }); 29 | const devices = await navigator.mediaDevices.enumerateDevices(); 30 | const list: DeviceInfo[] = devices 31 | .filter(({ kind }) => kind === "audioinput") 32 | .map(({ label, deviceId }) => ({ label, deviceId })); 33 | return list; 34 | } catch (e) { 35 | // ignored 36 | return []; 37 | } 38 | }; 39 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2018-2020 Daishi Kato 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /web/src/components/SingleRoom.tsx: -------------------------------------------------------------------------------- 1 | import { memo, useEffect, useState } from "react"; 2 | import { useSnapshot } from "valtio"; 3 | 4 | import "./SingleRoom.css"; 5 | import { globalState } from "../states/global"; 6 | import { setRoomIdToUrl } from "../utils/url"; 7 | import { GatherArea } from "./GatherArea"; 8 | 9 | export const SingleRoom = memo(() => { 10 | const { roomId } = useSnapshot(globalState); 11 | useEffect(() => { 12 | setRoomIdToUrl(roomId); 13 | }, [roomId]); 14 | 15 | const [inactive, setInactive] = useState(false); 16 | if (inactive) { 17 | throw new Error("inactive for too long"); 18 | } 19 | useEffect(() => { 20 | let lastTime = Date.now(); 21 | const timer = setInterval(() => { 22 | const now = Date.now(); 23 | if (now - lastTime >= 4 * 60 * 60 * 1000) { 24 | setInactive(true); 25 | } 26 | lastTime = now; 27 | }, 60 * 60 * 1000); 28 | return () => { 29 | clearInterval(timer); 30 | }; 31 | }, []); 32 | 33 | return ( 34 |
35 | 36 |
37 | ); 38 | }); 39 | 40 | export default SingleRoom; 41 | -------------------------------------------------------------------------------- /web/src/components/reusable/FaceCard.css: -------------------------------------------------------------------------------- 1 | .FaceCard-container { 2 | position: relative; 3 | width: 36px; 4 | height: 36px; 5 | overflow: hidden; 6 | } 7 | 8 | .FaceCard-photo { 9 | display: block; 10 | width: 36px; 11 | height: 36px; 12 | } 13 | 14 | .FaceCard-name { 15 | position: absolute; 16 | top: 1px; 17 | left: 1px; 18 | color: #f5f5f5; 19 | font-size: 0.5rem; 20 | line-height: 0.5rem; 21 | font-family: sans-serif; 22 | text-shadow: 1px 1px 0 #4848487a; 23 | cursor: default; 24 | } 25 | 26 | .FaceCard-mesg { 27 | position: absolute; 28 | bottom: 2px; 29 | left: 1px; 30 | color: white; 31 | font-size: 0.5rem; 32 | line-height: 0.5rem; 33 | font-family: sans-serif; 34 | } 35 | 36 | .FaceCard-updated { 37 | position: absolute; 38 | bottom: 1px; 39 | right: 1px; 40 | color: #f5f5f5; 41 | font-size: 0.5rem; 42 | line-height: 0.5rem; 43 | font-family: sans-serif; 44 | text-shadow: 1px 1px 0 #4848487a; 45 | cursor: default; 46 | } 47 | 48 | .FaceCard-mic-speaker-icons { 49 | position: absolute; 50 | bottom: 1px; 51 | right: 1px; 52 | font-size: 0.5rem; 53 | line-height: 0.5rem; 54 | cursor: default; 55 | } 56 | -------------------------------------------------------------------------------- /web/src/components/reusable/Landing.css: -------------------------------------------------------------------------------- 1 | .Landing-container { 2 | display: flex; 3 | flex-direction: column; 4 | align-items: center; 5 | } 6 | 7 | .Landing-container img { 8 | max-width: 100vw; 9 | max-height: 40vh; 10 | } 11 | 12 | .Landing-features { 13 | display: grid; 14 | grid-gap: 1rem; 15 | padding: 1rem; 16 | grid-template-columns: repeat(3, 1fr); 17 | margin-top: 2.5rem; 18 | } 19 | 20 | @media (max-width: 480px) { 21 | .Landing-features { 22 | grid-template-columns: 1fr; 23 | } 24 | } 25 | 26 | .Landing-features > div { 27 | border: orange 3px dashed; 28 | border-radius: 3px; 29 | background-color: oldlace; 30 | background-radius: 3px; 31 | padding: 0.8rem; 32 | } 33 | 34 | .Landing-features h1 { 35 | margin: 0 0 0.5rem 0; 36 | font-size: 1.2rem; 37 | } 38 | 39 | .Landing-features p { 40 | margin: 0; 41 | font-size: 0.8rem; 42 | } 43 | 44 | .Landing-howto { 45 | padding: 1rem; 46 | } 47 | 48 | .Landing-howto h2 { 49 | font-size: 1.2rem; 50 | } 51 | 52 | .Landing-howto ol { 53 | margin: 1rem 3rem 2rem 1rem; 54 | } 55 | 56 | .Landing-howto li { 57 | padding-top: 1rem; 58 | padding-bottom: 1rem; 59 | line-height: 1.5; 60 | } 61 | -------------------------------------------------------------------------------- /web/src/components/reusable/LinkOpener.tsx: -------------------------------------------------------------------------------- 1 | import { memo, useEffect, useState } from "react"; 2 | 3 | import "./LinkOpener.css"; 4 | import { generateExcalidrawURL } from "../../utils/excalidraw"; 5 | 6 | const LinkOpener = memo<{ 7 | roomId: string; 8 | }>(({ roomId }) => { 9 | const [excalidrawUrl, setExcalidrawUrl] = useState(); 10 | useEffect(() => { 11 | (async () => { 12 | setExcalidrawUrl(await generateExcalidrawURL(roomId)); 13 | })(); 14 | }, [roomId]); 15 | 16 | const appLink = `remote-faces://${window.location.href.replace( 17 | /^https:\/\//, 18 | "" 19 | )}`; 20 | 21 | return ( 22 |
23 |
24 | Room Link: 25 | 26 |
27 | 32 | 37 |
38 | ); 39 | }); 40 | 41 | export default LinkOpener; 42 | -------------------------------------------------------------------------------- /libopus/Makefile: -------------------------------------------------------------------------------- 1 | DIST_FILE=../web/public/libopus.js 2 | 3 | OPTS=-O1 --memory-init-file 0 -s NO_FILESYSTEM=1 -s MODULARIZE=1 -s EXPORT_ES6=1 -s USE_ES6_IMPORT_META=0 -s WASM_ASYNC_COMPILATION=0 -s SINGLE_FILE=1 -s EXPORTED_FUNCTIONS="['_malloc', '_free', '_opus_encoder_create', '_opus_encode_float', '_opus_decoder_create', '_opus_decode_float', '_speex_resampler_init', '_speex_resampler_process_interleaved_float', '_speex_resampler_destroy']" 4 | 5 | LIBOPUS=opus/.libs/libopus.a 6 | 7 | LIBSPEEXDSP=speexdsp/libspeexdsp/.libs/libspeexdsp.a 8 | 9 | all: $(DIST_FILE) 10 | 11 | $(LIBOPUS): 12 | cd opus; ./autogen.sh 13 | cd opus; emconfigure ./configure --disable-extra-programs --disable-doc --disable-intrinsics 14 | cd opus; sed -i~ 's/-fstack-protector-strong//g' Makefile 15 | cd opus; emmake make 16 | cd opus; rm a.out* 17 | 18 | $(LIBSPEEXDSP): 19 | cd speexdsp; ./autogen.sh 20 | cd speexdsp; emconfigure ./configure --disable-examples 21 | cd speexdsp; emmake make 22 | cd speexdsp; rm a.out* 23 | 24 | $(DIST_FILE): $(LIBOPUS) $(LIBSPEEXDSP) Makefile 25 | emcc $(OPTS) -o $(DIST_FILE) $(LIBOPUS) $(LIBSPEEXDSP) 26 | echo "\n/*" >> $(DIST_FILE) 27 | cat opus/COPYING >> $(DIST_FILE) 28 | echo "\n" >> $(DIST_FILE) 29 | cat speexdsp/COPYING >> $(DIST_FILE) 30 | echo "*/" >> $(DIST_FILE) 31 | -------------------------------------------------------------------------------- /.github/workflows/cd.yml: -------------------------------------------------------------------------------- 1 | name: CD 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | 8 | jobs: 9 | deploy_web: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v2 13 | 14 | - name: Setup Node 15 | uses: actions/setup-node@v1 16 | with: 17 | node-version: '14.x' 18 | 19 | - name: Get yarn cache 20 | id: yarn-cache 21 | run: echo "::set-output name=dir::$(yarn cache dir)" 22 | 23 | - name: Cache dependencies 24 | uses: actions/cache@v1 25 | with: 26 | path: ${{ steps.yarn-cache.outputs.dir }} 27 | key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} 28 | restore-keys: | 29 | ${{ runner.os }}-yarn- 30 | 31 | - name: Install dependencies (web) 32 | run: (cd web; yarn install) 33 | 34 | - name: Test (web) 35 | run: (cd web; yarn test) 36 | 37 | - name: Copy to dist (web) 38 | run: | 39 | (cd web; CI=false yarn build) 40 | mkdir -p web/dist/d 41 | cp -r web/build web/dist/d/`date '+%Y-%m-%d'` 42 | 43 | - name: Deploy (web) 44 | uses: peaceiris/actions-gh-pages@v3 45 | with: 46 | github_token: ${{ secrets.GITHUB_TOKEN }} 47 | publish_dir: ./web/dist 48 | keep_files: true 49 | -------------------------------------------------------------------------------- /web/src/utils/storage.ts: -------------------------------------------------------------------------------- 1 | type StringItemName = 2 | | "nickname" 3 | | "avatar_img" 4 | | "take_photo" 5 | | "faceimage_video_device_id" 6 | | "faceimage_audio_device_id"; 7 | 8 | type JsonItemName = "preference"; 9 | 10 | export const setStringItem = (name: StringItemName, value: string) => { 11 | try { 12 | window.localStorage.setItem(name, value); 13 | } catch (e) { 14 | console.info("Failed to save string to localStorage", e); 15 | } 16 | }; 17 | 18 | export const getStringItem = (name: StringItemName) => { 19 | try { 20 | return window.localStorage.getItem(name) || ""; 21 | } catch (e) { 22 | // ignore 23 | return ""; 24 | } 25 | }; 26 | 27 | export const setJsonItem = (name: JsonItemName, value: unknown) => { 28 | try { 29 | window.localStorage.setItem(name, JSON.stringify(value)); 30 | } catch (e) { 31 | console.info("Failed to save json to localStorage", e); 32 | } 33 | }; 34 | 35 | export const getJsonItem = (name: JsonItemName): unknown | null => { 36 | try { 37 | return JSON.parse(window.localStorage.getItem(name) || ""); 38 | } catch (e) { 39 | // ignore 40 | return null; 41 | } 42 | }; 43 | 44 | export const removeItem = (name: StringItemName | JsonItemName) => { 45 | try { 46 | window.localStorage.removeItem(name); 47 | } catch (e) { 48 | // ignore 49 | } 50 | }; 51 | -------------------------------------------------------------------------------- /web/public/stream_viewer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 13 | 39 | 40 | 41 |