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

@ubiquify/media

v0.1.0

Published

Client centric media storage and exchange protocol

Downloads

31

Readme

Media

Client centric media storage and exchange protocol.

Media Collection

The media collection is a persisted and versioned list of media entries.

Usage examples:

const blockStore: BlockStore = memoryBlockStoreFactory();
const linkCodec: LinkCodec = linkCodecFactory();
const valueCodec: ValueCodec = valueCodecFactory();
const versionStore: VersionStore = await versionStoreFactory({
  chunk,
  linkCodec,
  valueCodec,
  blockStore,
});
const graphStore = graphStore({
  chunk,
  linkCodec,
  valueCodec,
  blockStore,
});
const mediaCollection: MediaCollection = mediaCollectionFactory(
  versionStore,
  graphStore,
  {
    chunk,
    chunkSize,
    linkCodec,
    valueCodec,
    blockStore,
  }
);
// add media
const mediaNode0: MediaNode = {
  id: "0",
  createdAt: 12345,
  comment: "test",
  media: {
    name: "test",
    mimeType: "text/plain",
    data: new Uint8Array([1, 2, 3, 4, 5]),
  },
};
const mediaNode1: MediaNode = {
  id: "1",
  createdAt: 12345,
  comment: "test",
  media: {
    name: "test",
    mimeType: "text/plain",
    data: new Uint8Array([1, 2, 3, 4, 5]),
  },
};

mediaCollection.add(mediaNode0);
mediaCollection.add(mediaNode1);

// commit
const { currentRoot, versionStoreId, versionStoreRoot } =
  await mediaCollection.commit({ comment: "test", tags: ["test"] });

// export current version
const bundle: Block = await mediaCollection.exportCurrentVersion();

// or share it via a relay
const response: BasicPushResponse = await mediaCollection.push(
  "http://localhost:3002"
);

// elsewhere: pull the media collection
const blockStoreElsewhere: BlockStore = memoryBlockStoreFactory();
const mediaCollectionElsewhere: MediaCollection = await pullMediaCollection(
  "http://localhost:3002",
  versionStoreId,
  {
    chunk,
    chunkSize,
    linkCodec,
    valueCodec,
    blockStore: blockStoreElsewhere,
  }
);

// collaborate on it
const mediaNode3: MediaNode = {
  id: "xyz",
  createdAt: 12345,
  comment: "This is a video",
  media: {
    name: "example",
    mimeType: "video/mp4",
    data: videoData,
  },
};
mediaCollectionElsewhere.add(mediaNode3);

// commit the media collection & sign it
const {
  versionStoreId: versionStoreId2,
  versionStoreRoot: versionStoreRoot2,
  currentRoot: currentRoot2,
} = await mediaCollectionElsewhere.commit({
  comment: "Second test",
  tags: ["v0.0.2"],
  signer,
});

// share the changes
const response2: BasicPushResponse = await mediaCollectionElsewhere.push(
  "http://localhost:3002"
);

Media relay and media collection tests provide more usage examples.

Media System

The media system associates logical names (or paths) to media collections. A media system is a persisted data structure sharing the general attributes of the media collection. A simple metaphor: if a media collection could be loosely conceptualized as a versioned file, the media system could be seen as the versioned file system containing the files.

const mediaSystem: MediaSystem = mediaSystemFactory(
  versionStoreSystem,
  graphStoreSystem,
  {
    chunk,
    chunkSize,
    linkCodec,
    valueCodec,
    blockStore,
  }
);
// create a named collection
const namedMediaCollection: NamedMediaCollection = {
  name: "/tmp",
  ...mediaCollection,
};
// add named collection to media system
mediaSystem.add(namedMediaCollection);

// commit media system
await mediaSystem.commitCollection({ collectionName: "/tmp" });

Media system tests provide more usage examples.

Content Addressable

Both media collections and media systems are content addressable. Complete functionality described at @ubiquify/core:

  • local-first
  • distributed
  • conflict-free
  • immutable
  • versioned
  • trustless
  • secure

Build

npm run clean
npm install
npm run build
npm run test

Licenses

Licensed under either Apache 2.0 or MIT at your option.