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

@weex-cli/linker

v2.0.0-beta.32

Published

An abstract model framework for message resolve and dispatch

Downloads

1

Readme

@weex-cli/linker

An abstract model framework for message resolve and dispatch

index.d.ts

declare enum CHANNEL_MODE {
  P2P = 0,
  P2P_STRICT = 1,
  N2N = 2,
}

declare module '@ali/switchboard' {
  interface FromType {
    hubId: string
    terminalId: string
  }

  interface ToType {
    hubId: string
    terminalId: string
  }

  export class Message {
    private uuid
    private id
    private _discard
    private _destroy
    private _destination
    constructor(payload: any, hubId: any, terminalId: string, channelId?: string)
    channelId: string
    terminalId: string
    routed: boolean
    createTime: Date
    payload: any
    _from: FromType
    _to: ToType[]
    destination(): any[]
    reply(): void
    match(name: string): boolean
    to(hubId: string, terminalId?: string): void
    discard(): void
    isAlive(): boolean
    route(resolver?: any): void
    selectOne(to: ToType): Message | void
  }

  export class Channel {
    private hubMap: {
      [key: string]: string[]
    }
    private mode: any
    private cache: any[]
    private enableMulticast: boolean
    public id: string
    constructor(channelId?: string | number, mode?: any, enableMulticast?: boolean)
    getTerminal(hubId: string): any
    findAll(): {
      [key: string]: string[]
    }
    findOthers(hubId: string, terminalId: string, toHubId: string): any[]
    pushCache(message: Message): Message[]
    getCache(hubId: string): Message[]
    has(hubId: string, terminalId: string): boolean
    join(hubId: string, terminalId?: string): any
    leave(hubId: string, terminalId: string): any
  }

  export class Emitter {
    private eventHandler: any
    private _broadcast(target: any, context: any, data: any): void
    private _emit(prevTarget: any, namespace: string, context: any, data: any): boolean
    on(event: string | number, namespace: any, handler?: any): void
    off(event: string, namespace: string): void
    emit(event: string, namespace: string, data: any): boolean
    broadcast(event: any, namespace: string, data: any): boolean
  }

  export class Filter {
    private condition: any
    handler: any
    static resolveFilterChain(message: Message, filterChain: any[], currentIndex: number): Promise<any>
    constructor(handler: any, condition?: any)
    when(condition: any): void
    run(message: Message): void
  }
  export class Hub {
    private terminalMap: any
    private filterChain: any[]
    private _pushToRouter: any
    id: string
    router: Router
    constructor(id: string)
    static get(id: string): Hub
    static check(): void
    join(terminal: any, forced?: boolean): void
    setChannel(terminalId: string, channelId: string): void
    setupTerminal(terminal: any, forced: boolean): void
    broadcast(message: Message): void
    pushToTerminal(terminalId: string, message: Message): void
    send(message: Message): void
    filter(filter: any, condition: any): void
  }

  export class Router extends Emitter {
    private channelMap: any
    private handlerList: any
    id: string
    hubs: any
    static check(): void
    static get(id: string): Router
    static dump(): void
    static Event: {
      TERMINAL_JOINED: 0
      TERMINAL_LEAVED: 1
      MESSAGE_RECEIVED: 2
    }
    constructor(id: string)
    private _pushMessage(message: Message): void
    link(hub: Hub): void
    reply(message: Message, payload: any): void
    newChannel(channelId: string, mode?: CHANNEL_MODE): string
    pushMessageByChannelId(hubId: string, channelId: string, payload: any): void
    pushMessage(hubId: any, terminalId: any, payload?: any): void
    dispatchMessage(message: Message): void
    fetchMessage(message: Message): void
    registerHandler(handler: any): any
    event(signal: any): void
  }

  export class Handler {
    private handler: any
    private router: Router
    private fromString: string
    private condition: any
    static run(handlerList: any[], message: Message, i?: number): Promise<any>
    constructor(handler: any, router: Router)
    at(fromString: string): Handler
    when(condition: any): Handler
    test(message: Message): boolean
    run(message: Message): any
  }

  export namespace Terminal {
    export class SyncTerminal {
      private promise: any
      private resolve: any
      private syncId: string
      channelId: string
      id: string
      send(data: any): Promise<any>
      read(message: any): void
    }

    export class WebsocketTerminal {
      constructor (websocket:any, channelId?: string)
      private websocket: any
      channelId: string
      id: string
      read(message: any): void
    }
  }
}