mirror of
https://github.com/movie-web/providers.git
synced 2025-09-13 18:13:25 +00:00
Add stream targets
This commit is contained in:
35
src/main/targets.ts
Normal file
35
src/main/targets.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
export const flags = {
|
||||
NO_CORS: 'no-cors',
|
||||
} as const;
|
||||
|
||||
export type Flags = (typeof flags)[keyof typeof flags];
|
||||
|
||||
export const targets = {
|
||||
BROWSER: 'browser',
|
||||
NATIVE: 'native',
|
||||
} as const;
|
||||
|
||||
export type Targets = (typeof targets)[keyof typeof targets];
|
||||
|
||||
export type FeatureMap = {
|
||||
requires: readonly Flags[];
|
||||
};
|
||||
|
||||
export const targetToFeatures: Record<Targets, FeatureMap> = {
|
||||
browser: {
|
||||
requires: [flags.NO_CORS],
|
||||
},
|
||||
native: {
|
||||
requires: [],
|
||||
},
|
||||
} as const;
|
||||
|
||||
export function getTargetFeatures(target: Targets): FeatureMap {
|
||||
return targetToFeatures[target];
|
||||
}
|
||||
|
||||
export function flagsAllowedInFeatures(features: FeatureMap, inputFlags: Flags[]): boolean {
|
||||
const hasAllFlags = features.requires.every((v) => inputFlags.includes(v));
|
||||
if (!hasAllFlags) return false;
|
||||
return true;
|
||||
}
|
Reference in New Issue
Block a user