39 lines
971 B
TypeScript
39 lines
971 B
TypeScript
import type {
|
|
NativePresentationDefinition,
|
|
NativePresentationName,
|
|
} from "../types";
|
|
|
|
export function definePresentation(definition: NativePresentationDefinition) {
|
|
return definition;
|
|
}
|
|
|
|
const builtins: NativePresentationDefinition[] = [
|
|
{ name: "push", axis: "x" },
|
|
{ name: "reveal", axis: "x" },
|
|
{ name: "slide", axis: "x" },
|
|
{ name: "fade", axis: "x" },
|
|
{ name: "modal", axis: "y" },
|
|
{ name: "sheet", axis: "y" },
|
|
{ name: "none", axis: "x" },
|
|
];
|
|
|
|
export class PresentationRegistry {
|
|
private readonly definitions = new Map<
|
|
NativePresentationName,
|
|
NativePresentationDefinition
|
|
>();
|
|
|
|
constructor(custom: NativePresentationDefinition[] = []) {
|
|
for (const definition of [...builtins, ...custom])
|
|
this.register(definition);
|
|
}
|
|
|
|
register(definition: NativePresentationDefinition) {
|
|
this.definitions.set(definition.name, definition);
|
|
}
|
|
|
|
get(name: NativePresentationName) {
|
|
return this.definitions.get(name);
|
|
}
|
|
}
|