npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@netless/window-manager

v0.4.75

Published

Multi-window mode for Netless Whiteboard

Downloads

4,602

Readme

WindowManager

MainView

MainView 也就是主白板, 是垫在所有窗口下面的主白板

因为多窗口的原因,所以抽象出来一个主白板, 并且把以前部分对 room 的操作, 迁移到对 mainView 操作

快速开始

import { WhiteWebSdk } from "white-web-sdk";
import { WindowManager, BuiltinApps } from "@netless/window-manager";
import "@netless/window-manager/dist/style.css";

const sdk = new WhiteWebSdk({
    appIdentifier: "appIdentifier",
    useMobXState: true // 请确保打开这个选项
});

sdk.joinRoom({
    uuid: "room uuid",
    roomToken: "room token",
    invisiblePlugins: [WindowManager],
    useMultiViews: true, // 多窗口必须用开启 useMultiViews
    disableMagixEventDispatchLimit: true, // 请确保打开这个选项
}).then(async room => {
    const manager = await WindowManager.mount(
        room,
        container
        // 完整配置见下方
    );
});

mount 完整参数

containerSizeRatio 为了保证窗口在不同分辨率下显示效果, 白板在相同的比例区域才能进行同步

chessboard 当挂载的区域不完全符合比例时, 白板会在挂载的 dom 中划分一个符合比例的区域出来, 此时多出来的部分会默认显示为棋盘透明背景

collector

collector 就是窗口最小化时的图标, 默认大小 width: 40px; height: 40px;

光标同步

原本的 SDK 中的 cursorAdapter 在多窗口中不可用, 如需要光标同步功能需要在 manager 中开启 cursor 选项

sdk.joinRoom({
    // cursorAdapter: cursorAdapter, 原本开启 sdk 中的 cursorAdapter 需要关闭
    userPayload: {
        nickName: "光标名称",
        avatar: "用户头像链接",
    },
});

WindowManager.mount({
    cursor: true, // 开启光标同步
});

APP

静态和动态 PPT 是作为 App 插入到白板, 并持久化到白板中

App 或会在页面刷新时自动创建出来, 不需要重复插入

如果 App 需要 scenePath 时,那么一个 scenePath 只能同时打开一个,要求为 App 实例唯一

添加静态/动态 PPT 到白板上

const appId = await manager.addApp({
    kind: BuiltinApps.DocsViewer,
    options: {
        scenePath: "/docs-viewer",
        title: "docs1", // 可选
        scenes: [], // SceneDefinition[] 静态/动态 Scene 数据
    },
});

添加音视频到白板

const appId = await manager.addApp({
    kind: BuiltinApps.MediaPlayer,
    options: {
        title: "test.mp3", // 可选
    },
    attributes: {
        src: "xxxx", // 音视频 url
    },
});

设置跟随模式

只有广播端也就是老师需要设置跟随模式, 其他端的主白板都会跟随广播端的视角

注意 managersetViewMode 不能和 room.setViewMode 同时使用

manager.setViewMode("broadcaster"); // 开启跟随模式
manager.setViewMode("freedom"); // 关闭跟随模式

获取当前的 broadcaster ID

manager.broadcaster

设置所有 appreadonly

manager.setReadonly(true); // 所有窗口变成 readonly 状态
manager.setReadonly(false); // 解锁设置的 readonly, 注意如果当前白板的 isWritable 为 false 以白板的状态为最高优先级

切换 mainView 为可写状态

manager.switchMainViewToWriter();

切换 mainView scenePath

切换主白板的 ScenePath 并把主白板设置为可写状态

manager.setMainViewScenePath(scenePath);

切换 mainView sceneIndex

切换主白板的 SceneIndex 并把主白板设置为可写状态

manager.setMainViewSceneIndex(sceneIndex);

获取 mainView scenePath

manager.getMainViewScenePath();

获取 mainView sceneIndex

manager.getMainViewSceneIndex();

监听 mainViewmode

manager.emitter.on("mainViewModeChange", mode => {
    // mode 类型为 ViewVisionMode
});

监听窗口最大化最小化

manager.emitter.on("boxStateChange", state => {
    if (state === "maximized") {
        // 最大化
    }
    if (state === "minimized") {
        // 最小化
    }
    if (state === "normal") {
        // 恢复正常
    }
});

监听 broadcaster 变化

manager.emitter.on("broadcastChange", id => {
    // broadcast id 进行了改变
})

关闭 App

manager.closeApp(appId);

手动销毁 WindowManager

manager.destroy();

开发流程

pnpm install

pnpm build

cd example

pnpm install

pnpm dev