Add stream targets

This commit is contained in:
mrjvs
2023-09-10 23:52:51 +02:00
parent a19cd3887f
commit b120b90b02
16 changed files with 106 additions and 21 deletions

35
src/main/targets.ts Normal file
View 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;
}