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

@white-matrix/ide-terminal-next

v2.27.15

Published

## 实现方式

Downloads

14

Readme

终端

实现方式

实现 src/common/term.ts 文件中的 ITerminalService 类型,并在 src/browser/index.ts 中替换默认的 service 类型。

export interface ITerminalService {
  /**
   * 集成方自定义会话唯一标识的函数
   */
  makeId(): string;
  /**
   * 集成方自定义写入到 localStorage 的键值的函数
   */
  restore(): string;
  /**
   * 当关闭 IDE 的时候,允许集成方额外向每一个会话标识写入一个字符串字段,
   * 信息内容由集成方决定
   *
   * @param sessionId 会话唯一标识
   */
  meta(sessionId: string): string;
  /**
   * Xterm 终端的构造选项
   */
  getOptions(): ITerminalOptions;
  /**
   * 用于获取特定会话的相关信息,包括进程 id 以及进程描述的 name,
   * 这个函数允许返回为空
   *
   * @param sessionId 会话唯一标识
   */
  intro(sessionId: string): { pid: number, name: string } | undefined;
  /**
   *
   * @param id 会话唯一标识
   * @param message 发送的字符串信息
   */
  sendText(id: string, message: string): Promise<void>;
  /**
   *
   * @param sessionId 会话唯一标识
   * @param term 返回的 Xterm 终端实例
   * @param restore 是否是恢复一个终端
   * @param meta 恢复终端所需要的额外字段
   * @param attachMethod 将 websocket 连接和 xterm 连接起来的函数
   * @param options 创建一个新终端的进程选项
   */
  attach(sessionId: string, term: Terminal, restore: boolean, meta: string, attachMethod: (s: WebSocket) => void, options?: TerminalOptions): Promise<void>;
  /**
   *
   * @param sessionId 会话唯一标识
   * @param cols resize 的列数
   * @param rows resize 的行数
   */
  resize(sessionId: string, cols: number, rows: number): Promise<void>;
  /**
   * 销毁一个终端进程
   *
   * @param sessionId 会话唯一标识
   */
  disposeById(sessionId: string): void;
  /**
   * 异步向后端获取一个会话的进程 id
   *
   * @param sessionId 会话唯一标识
   */
  getProcessId(sessionId: string): Promise<number>;

  /**
   * 报错处理的事件
   *
   * @param handler
   */
  onError(handler: (error: ITerminalError) => void): void;
}

外部和内部 API

对于 common 中默认导出的 api 认为为外部 api,而对于 common 中没有默认导出的类型则认为为内部 api,内部 api 依然可以通过子名称获取到类型进行覆盖或者使用,但是内部 api 的任何 api 修改不作为 bk,不推荐直接使用内部 api。

接下来

  • [ ] 终端首次初始化使用对比的外层 dom 节点需要可指定,这里可能需要使用 core 内部 api 手动计算
  • [ ] 终端 Singleton 模式
  • [ ] 终端后端 Pty 代码优化,需要支持开发时重连
  • [ ] Vim 显示优化