Skip to content

theacrat/stremio-types

Repository files navigation

stremio-types

TypeScript definitions for the stremio-core Rust project.

Auto-generated using ts-rs and various scripts.

Installation

Using Bun:

bun add stremio-types

Using npm:

npm i stremio-types

Usage

Basic Types

import type { MetaItem } from "stremio-types";

const item: MetaItem = {
	// Full autocompletion and type safety
};

Type Guards and Constants

Every string union from the Rust core is transformed into a const array with an associated Type Guard.

import { ExtraTypes, isExtraType } from "stremio-types";

// Access the list of valid values
console.log(ExtraTypes);

// Validate an unknown string
const input = "search";
if (isExtraType(input)) {
	// 'input' is now narrowed to ExtraType
	console.log(`System is ${input}`);
}

Development

Prerequisites

  • Bun
  • Rust (for building stremio-core)

Setup

Clone the stremio-core repository and apply the patch:

bun run setup

To test against the latest stremio-core upstream tag:

bun run setup --latest

Building

Generate types and build the package:

bun run build

This will:

  1. Run cargo tests to export TypeScript bindings from stremio-core
  2. Process and clean up the generated types
  3. Build the distribution files
  4. Save any changes as a patch file

Automation

GitHub Actions can handle upstream syncs and publishing automatically.

  • .github/workflows/sync-upstream.yml checks for new stremio-core-web-v* tags on a schedule or manual dispatch.
  • When a new upstream release exists, it regenerates the types, updates package.json, writes the new patch file, and commits the generated changes back to main.
  • .github/workflows/release.yml handles the tag creation and npm publish step, either from a direct manual version bump or after the sync workflow completes successfully.

License

See LICENSE

SPDX-License-Identifier: MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors