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

ot-engine

v0.0.14

Published

Operational transformation engine

Downloads

6

Readme

ot-engine

NPM version NPM downloads Build Status

Operational transformation engine

example

https://ot-engine-rich-text.herokuapp.com/

features

  • typescript full stack
  • support local undo/redo
  • support presence(cursors)

ot type definition

export type OTType<S, P,Pr> = {
  name: string;
  create?(data: any): S;
  applyAndInvert?(snapshot: S, op: P, invert: boolean): [S, P | undefined];
  apply?(snapshot: S, op: P): S;
  invert?(op: P): P;
  invertWithDoc?(op: P, snapshot: S): P;
  transform(op: P, refOp: P, side: OTSide): P;
  transformPresence?(presence: Pr, refOp: P, isOwnOp:boolean): Pr;
  serialize?(s: S): any;
  deserialize?(data: any): S;
};

ot-engine/server

export interface Op<P> {
  version: number;
  id: string;
  content: P;
}

export interface Snapshot<S> {
  version: number;
  rollback?: boolean;
  content: S;
}

export type SnapshotAndOps<S, P> = {
  snapshot: Snapshot<S>;
  ops: Op<P>[];
};

export interface GetOpsParams {
  custom?: any;
  collection: string;
  docId: string;
  fromVersion: number;
  toVersion?: number;
}

export interface GetSnapshotParams {
  custom?: any;
  collection: string;
  docId: string;
  version?: number;
  toVersion?: number;
}

export interface CommitOpParams<P> {
  custom?: any;
  collection: string;
  docId: string;
  op: Op<P>;
}

export interface SaveSnapshotParams<S> {
  custom?: any;
  collection: string;
  docId: string;
  snapshot: Snapshot<S>;
}

export interface DB {
    getOps<P>(params: GetOpsParams): Promise<Op<P>[]>;
    getSnapshot<S, P>(params: GetSnapshotParams): Promise<SnapshotAndOps<S, P> | undefined>;
    commitOp<P>(params: CommitOpParams<P>): Promise<void>;
    saveSnapshot<S>(params: SaveSnapshotParams<S>): Promise<void>;
}
export interface PubSubData {
    data: any;
}
export interface PubSub {
    subscribe(channel: string, callback: (d: PubSubData) => void): void;
    publish(channel: string, data: any): void;
    unsubscribe(channel: string, callback: (d: PubSubData) => void): void;
}
export interface ServerConfig {
    saveInterval?: number;
    db?: DB;
    pubSub?: PubSub;
}
export interface AgentConfig<S,P,Pr,Custom> {
  /** passed to db */
  custom?:Custom;
  stream: Duplex;
  collection: string;
  docId: string;
  clientId: string;
  otType: OTType<S,P,Pr>;
}
export declare class Server {
    constructor(params?: ServerConfig);
    handleStream<S,P,Pr,Custom>(config: AgentConfig<S,P,Pr,Custom>): void;
}

ot-engine/client

import { Event,EventTarget } from 'ts-event-target';

interface DocConfig<S,P,Pr> {
    socket: WebSocket;
    otType: OTType<S,P,Pr>;
    clientId: string;
    undoStackLimit?: number;
    cacheServerOpsLimit?: number;
}
declare class OpEvent<P> extends Event<'op'> {
    ops: P[];
    undoRedo: boolean;
    source: boolean;
    constructor();
}
declare class BeforeOpEvent<P> extends Event<'beforeOp'> {
    ops: P[];
    undoRedo: boolean;
    source: boolean;
    constructor();
}
declare class RemoteDeleteDocEvent extends Event<'remoteDeleteDoc'> {
  constructor();
}
declare class RollbackEvent extends Event<'rollback'> {
  constructor();
}
export declare class Doc<S,P,Pr> extends EventTarget<[
  OpEvent<P>,
  BeforeOpEvent<P>,
  RemoteDeleteDocEvent,
  RollbackEvent
  ]> {
    constructor(config: DocConfig<S,P,Pr>);
    canUndo(): boolean;
    canRedo(): boolean;
    undo(): void;
    redo(): void;
    destroy(): void;
    submitOp(opContent: P): void;
    submitPresence(presence: Pr): void;
    delete(): Promise<void>;
    rollback(params: {version:number}): Promise<void>;
    fetch(): Promise<Snapshot<S>>;
    data:S;
    remotePresences:Record<string,Pr>;
}

dev

npm i [email protected] -g
pnpm i
pnpm dev

open: http://localhost:3000/

release workflow

npm run pub
git push heroku main:master --force