refactor: improve manifest type

This commit is contained in:
WebStreamr 2025-07-21 19:08:21 +00:00
parent 453cc747a1
commit 6fe09fc459
No known key found for this signature in database
3 changed files with 12 additions and 7 deletions

View file

@ -1,5 +1,5 @@
// Adapted version of https://github.com/Stremio/stremio-addon-sdk/blob/v1.6.2/src/landingTemplate.js
import { ManifestWithConfig } from './types';
import { CustomManifest } from './types';
import { envGet } from './utils';
const STYLESHEET = `
@ -169,7 +169,7 @@ button:active {
}
`;
export function landingTemplate(manifest: ManifestWithConfig) {
export function landingTemplate(manifest: CustomManifest) {
const background = manifest.background || 'https://dl.strem.io/addon-background.jpg';
const logo = manifest.logo || 'https://dl.strem.io/addon-logo.png';
const contactHTML = manifest.contactEmail

View file

@ -7,7 +7,13 @@ export interface Context {
config: Config;
}
export type ManifestWithConfig = Manifest & { config: ManifestConfig[] };
export type CustomManifest = Manifest & {
config: ManifestConfig[];
stremioAddonsConfig: { // needed for add-on claiming on https://stremio-addons.net
issuer: string;
signature: string;
};
};
export type Config = Partial<Record<CountryCode | 'includeExternalUrls' | 'mediaFlowProxyUrl' | 'mediaFlowProxyPassword', string>>;

View file

@ -1,12 +1,12 @@
import { Source } from '../source';
import { Config, CountryCode, ManifestWithConfig } from '../types';
import { Config, CountryCode, CustomManifest } from '../types';
import { envGetAppId, envGetAppName } from './env';
import { flagFromCountryCode, languageFromCountryCode } from './language';
const typedEntries = <T extends object>(obj: T): [keyof T, T[keyof T]][] => (Object.entries(obj) as [keyof T, T[keyof T]][]);
export const buildManifest = (sources: Source[], config: Config): ManifestWithConfig => {
const manifest: ManifestWithConfig = {
export const buildManifest = (sources: Source[], config: Config): CustomManifest => {
const manifest: CustomManifest = {
id: envGetAppId(),
version: '0.39.2', // x-release-please-version
name: envGetAppName(),
@ -26,7 +26,6 @@ export const buildManifest = (sources: Source[], config: Config): ManifestWithCo
configurationRequired: Object.keys(config).length === 0,
},
config: [],
// @ts-expect-error inofficial prop needed for add-on claiming on https://stremio-addons.net
stremioAddonsConfig: {
issuer: 'https://stremio-addons.net',
signature: 'eyJhbGciOiJkaXIiLCJlbmMiOiJBMTI4Q0JDLUhTMjU2In0..D3-Wl15vxnYltwx8G52rRg.16-0VzsSgTvnv0wampIR8YPZsFhH8-7IgpuqxcUfC2p7kIJtuk8xQzrzqQOLXANEpaH_w7a4JOEpNo8wv28Zo_nMGCLOXgWbyGM3sQ-tfq6DCK3JU0ol6YMC1UDX2z_c.IOLlZyTYx_swutjYSTES0Q',