mirror of
https://github.com/astefanutti/decktape.git
synced 2024-09-11 22:27:11 +03:00
BREAKING CHANGE: Please run node 12.20 or higher BREAKING CHANGE: This package is now a pure esm, please [read this](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c)
54 lines
1.3 KiB
JavaScript
54 lines
1.3 KiB
JavaScript
export const create = page => new Shower(page);
|
|
|
|
class Shower {
|
|
|
|
constructor(page) {
|
|
this.page = page;
|
|
}
|
|
|
|
getName() {
|
|
return 'Shower 2.x';
|
|
}
|
|
|
|
isActive() {
|
|
return this.page.evaluate(_ =>
|
|
typeof shower === 'object' && typeof shower.modules === 'object');
|
|
}
|
|
|
|
configure() {
|
|
return new Promise(async resolve => {
|
|
await this.page.exposeFunction('onShowerInit', _ => resolve());
|
|
await this.page.evaluate(_ => {
|
|
shower.modules.require(['shower.global'], sh => {
|
|
window.decktape = {};
|
|
decktape.shower = sh.getInited()[0];
|
|
decktape.shower.container.enterSlideMode();
|
|
window.onShowerInit();
|
|
});
|
|
});
|
|
});
|
|
}
|
|
|
|
size() {
|
|
return { width: 1024, height: 640 };
|
|
}
|
|
|
|
slideCount() {
|
|
// FIXME: this does not take fragments into account which ideally should be deactivated
|
|
return this.page.evaluate(_ => decktape.shower.getSlidesCount());
|
|
}
|
|
|
|
hasNextSlide() {
|
|
return this.page.evaluate(_ =>
|
|
decktape.shower.player.getCurrentSlideIndex() + 1 < decktape.shower.getSlidesCount());
|
|
}
|
|
|
|
nextSlide() {
|
|
return this.page.evaluate(_ => decktape.shower.player.next());
|
|
}
|
|
|
|
currentSlideIndex() {
|
|
return this.page.evaluate(_ => decktape.shower.player.getCurrentSlideIndex() + 1);
|
|
}
|
|
}
|