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 🙏

© 2026 – Pkg Stats / Ryan Hefner

monaco-recorder

v1.1.3

Published

Monaco事件录制

Downloads

22

Readme

安装使用

npm install monaco-recorder

命令

// 打包
npm run build

// 测试
npm run test

发布

npm login
npm publish

模块

<!-- 
  CDN方式引入

  window.monacoRecorder
  window.monacoPlayer
-->
<script src="/player.umd.js"></script>
<script src="/recorder.umd.js"></script>

<!-- es module -->
<!-- npm install monaco-recorder -->
<script lang="ts">
import {
  Monitor, // 监视器
  Memorizer, // 存储器
  Recorder, // 记录器 <完整的 事件监听|存储上传|直播 方案>
  Player, // 播放器
} from 'monaco-recorder'

import type {
  EditorFileItem,
  File,
  InitData,
  MonacoEditor,
  MonacoEvent,
  MonacoEventType,
  RecorderOptions
} from 'monaco-recorder'

</script>

使用

监视器

<script>
Vue.createApp({
  // ...

  async mounted() {
    // import { Recorder as monacoRecorder } from 'monaco-recorder'
    // window.monacoRecorder
    this.recorder = monacoRecorder.getInstance()
  },
  unmounted() {
      // 卸载关闭直播
      if (this.recordId) {
        axios.post("/stopRecord?id=" + this.recordId);
      }
  },
  methods: {
    async loadFiles() {
        this.files = await request
          .get(`/xxxx`)

        // 监听文件列表变化
        this.recorder.changeFileList(this.files.filter(i => i.objectType !== 'root').map(i => ({
          id: i.name,
          name: i.name,
          type: i.objectType,
        })))
    },

    openFile(file) {
      // ...
      //  const editor = createEditor(file._editor, file._content, lang, {})
      // 监听该文件
      editor.then(r => monacoRecorder.open(file.name, r, lang))
    },
    closeTab(tab) {
      // ...
      // close file
      monacoRecorder.close(tab.id)
    },

    start(recordId = "fullstack_" + Date.now()) {
      if (this.recorder.recordingStatus) return;

      var recordName = prompt('发起直播,请输入名称');
      if (recordName) {
          return
      }

      // 创建录像
      axios.post("/postRecord", {
          record_id: recordId,
          name: trecordName,
          type: 'fullstack',
          live: 1
      });
      var fileList = this.files.filter(i => i.objectType !== 'root').map(i => ({
          id: i.name,
          name: i.name,
          type: i.objectType,
      }))
      var categories = JSON.parse(JSON.stringify(this.categories));

      this.recorder.initialize({
          id: recordId,
          name: trecordName,
          initData: {
              categories,
              fileList,
          },
          pushEventApi(data) {
              console.log(data)
              const result = data.map(i => {
                  return {
                      record_id: i.record_id,
                      order: i.order,
                      json: JSON.stringify(i)
                  }
              })
              return axios.post("/postEvent", result);
          },
          memorizerConfig: {
              maxTotal: 100,
              interval: 1000
          },
      })
  },
  stop() {
      if (this.recorder?.recordingStatus) {
          axios.post("/stopRecord?id=" + this.recorder.recordId);
      }
      this.recorder?.dispose()
      this.recorder = monacoRecorder.getInstance()
  }

  }
})

</script>

播放器

<script>
async mounted() {
  // import { Player as monacoPlayer } from 'monaco-recorder'
  // window.monacoPlayer

  this.player = new monacoPlayer(monaco, (id, content, lang) => {
      return new Promise(resolve => {
          // monaco的dom出现晚一点
          this.$nextTick(() => {
              resolve(createEditor(this.player.getDom(id), content, lang, {onChangeContent() { } }))
          })
      })
  })

    const qs = new URLSearchParams(location.search);
    this.recordId = qs.get("id");
    var isLive = qs.get("live") === 'true';

    const data = (await axios.get("/getRecord?id=" + this.recordId)).data
    // this.player.bindExport((event, isInverse) => {
    //     console.log(event, isInverse)
    // })
    this.player.load(data)

    // 自动播放
    this.player.play();

    if (isLive) {
        this.player.createPoll((order) => {
            return axios.get('/pollRecord', {
                params: {
                    id: this.recordId,
                    order
                }
            }).then(res => {
                return res.data
            })
        });
    }

    // 加载分类
    this.categories = this.player?.other?.categories;

},

</script>

录制控制

import { Recorder } from "monaco-recorder";
import request from "@/utils/request";
import dayjs from "dayjs";

// 录制状态
const recorderStatus = ref(false);
const start = () => {
  Recorder.start(
    {
      id: "Pages_" + dayjs().format("HH:mm"),
      fileList: pageStore.list.map((i) => ({ id: i.id, name: i.name })),
      postRecordApi(data: any) {
        console.log(data);
        return request.post("http://localhost:2247/", data, undefined, {
          hiddenLoading: true,
        });
      },
      pushEventApi(data: any) {
        console.log(data);
        return request.post("http://localhost:2247/", data, undefined, {
          hiddenLoading: true,
        });
      },
      memorizerConfig: {
        maxTotal: 15,
      },
    },
    () => {
      recorderStatus.value = true;
    }
  );
};

const stop = () => {
  Recorder.stop(() => {
    recorderStatus.value = false;
  });
};

编辑器监听

// use
<MonacoEditor
  ref="editor"
  v-model="model.body"
  language="html"
  k-script
  @open="recorder?.open(props.id, ($event as any))"
  @close="recorder?.close(props.id)"
/>

// MonacoEditor
const emit = defineEmits<{
  (e: "update:modelValue", value: string): void;
  (e: "open", value: monacoTypes.editor.IStandaloneCodeEditor): void;
  (e: "close"): void;
}>();


onMounted(async () => {
  // ...
  // editor = monaco.editor.create(...);
  readyCompleter.resolve(null);
  emit("open", editor);
});

onUnmounted(() => {
  model?.dispose();
  emit("close");
});