;
+ [key: string]: any;
+} = Deck;
/**
* The below is a thin shell that mimics the pre 4.0
@@ -32,17 +34,15 @@ type RevealApiFunction = (...args: any[]) => any;
let enqueuedAPICalls: RevealApiFunction[] = [];
-Reveal.initialize = ( options: PartialRevealConfig ) => {
-
+Reveal.initialize = (options?: Config) => {
// Create our singleton reveal.js instance
- Object.assign( Reveal, new Deck( document.querySelector( '.reveal' ), options ) );
+ Object.assign(Reveal, new Deck(document.querySelector('.reveal'), options));
// Invoke any enqueued API calls
- enqueuedAPICalls.map( method => method( Reveal ) );
+ enqueuedAPICalls.map((method) => method(Reveal));
return Reveal.initialize();
-
-}
+};
/**
* The pre 4.0 API let you add event listener before
@@ -50,14 +50,16 @@ Reveal.initialize = ( options: PartialRevealConfig ) => {
* queuing up premature API calls and invoking all
* of them when Reveal.initialize is called.
*/
-[ 'configure', 'on', 'off', 'addEventListener', 'removeEventListener', 'registerPlugin' ].forEach( method => {
- Reveal[method] = ( ...args: any ) => {
- enqueuedAPICalls.push( deck => deck[method].call( null, ...args ) );
+['configure', 'on', 'off', 'addEventListener', 'removeEventListener', 'registerPlugin'].forEach(
+ (method) => {
+ Reveal[method] = (...args: any) => {
+ enqueuedAPICalls.push((deck) => deck[method].call(null, ...args));
+ };
}
-} );
+);
Reveal.isReady = () => false;
Reveal.VERSION = VERSION;
-export default Reveal;
\ No newline at end of file
+export default Reveal;
diff --git a/js/reveal.js b/js/reveal.js
index 89f92f94abe..f0ae1a7eb06 100644
--- a/js/reveal.js
+++ b/js/reveal.js
@@ -17,7 +17,7 @@ import Touch from './controllers/touch.js'
import Focus from './controllers/focus.js'
import Notes from './controllers/notes.js'
import Playback from './components/playback.js'
-import defaultConfig from './config.ts'
+import { defaultConfig } from './config.ts'
import * as Util from './utils/util.js'
import * as Device from './utils/device.js'
import {
@@ -130,6 +130,8 @@ export default function( revealElement, options ) {
if( !revealElement ) throw 'Unable to find presentation root ().';
+ if( initialized ) throw 'Reveal.js has already been initialized.';
+
initialized = true;
// Cache references to key DOM elements
diff --git a/package.json b/package.json
index 182ad6744ae..cfacf02edb0 100644
--- a/package.json
+++ b/package.json
@@ -15,12 +15,9 @@
"require": "./dist/reveal.js",
"default": "./dist/reveal.js"
},
-
"./reveal.css": "./dist/reveal.css",
"./reset.css": "./dist/reset.css",
-
"./theme/*": "./dist/theme/*",
-
"./plugin/highlight": {
"import": "./dist/plugin/highlight.mjs",
"require": "./dist/plugin/highlight.js",
diff --git a/test.js b/test.js
index e9303c599ba..beec2b5e455 100644
--- a/test.js
+++ b/test.js
@@ -1,7 +1,7 @@
import { fileURLToPath } from 'url';
import { dirname } from 'path';
-import { glob } from "glob";
-import { runQunitPuppeteer, printFailedTests } from "node-qunit-puppeteer";
+import { glob } from 'glob';
+import { runQunitPuppeteer, printFailedTests } from 'node-qunit-puppeteer';
import { createServer } from 'vite';
const __filename = fileURLToPath(import.meta.url);
@@ -25,34 +25,45 @@ const startServer = async () => {
// Run tests
const runTests = async (server) => {
- await Promise.all(testFiles.map(async (file) => {
- const qunitArgs = {
- targetUrl: `http://localhost:8009/${file}`,
- timeout: 30000,
- redirectConsole: false,
- puppeteerArgs: ['--allow-file-access-from-files']
- };
+ await Promise.all(
+ testFiles.map(async (file) => {
+ const qunitArgs = {
+ targetUrl: `http://localhost:8009/${file}`,
+ timeout: 30000,
+ redirectConsole: false,
+ puppeteerArgs: ['--allow-file-access-from-files'],
+ };
- try {
- const result = await runQunitPuppeteer(qunitArgs);
- combinedResults.passed += result.stats.passed;
- combinedResults.failed += result.stats.failed;
- combinedResults.total += result.stats.total;
- combinedResults.runtime += result.stats.runtime;
+ try {
+ const result = await runQunitPuppeteer(qunitArgs);
+ combinedResults.passed += result.stats.passed;
+ combinedResults.failed += result.stats.failed;
+ combinedResults.total += result.stats.total;
+ combinedResults.runtime += result.stats.runtime;
- if (result.stats.failed > 0) {
- console.log(`${'!'} ${file} [${result.stats.passed}/${result.stats.total}] in ${result.stats.runtime}ms`.red);
- printFailedTests(result, console);
+ if (result.stats.failed > 0) {
+ console.log(
+ `${'!'} ${file} [${result.stats.passed}/${result.stats.total}] in ${
+ result.stats.runtime
+ }ms`.red
+ );
+ printFailedTests(result, console);
+ } else {
+ console.log(
+ `${'✔'} ${file} [${result.stats.passed}/${result.stats.total}] in ${
+ result.stats.runtime
+ }ms`.green
+ );
+ }
+ } catch (error) {
+ console.error(`Error running tests for ${file}:`, error);
}
- else {
- console.log(`${'✔'} ${file} [${result.stats.passed}/${result.stats.total}] in ${result.stats.runtime}ms`.green);
- }
- } catch (error) {
- console.error(`Error running tests for ${file}:`, error);
- }
- }));
+ })
+ );
- console.log(`\n${combinedResults.passed}/${combinedResults.total} tests passed, ${combinedResults.failed} failed, ${combinedResults.runtime}ms runtime`);
+ console.log(
+ `\n${combinedResults.passed}/${combinedResults.total} tests passed, ${combinedResults.failed} failed, ${combinedResults.runtime}ms runtime`
+ );
// Exit with status code 1 if any tests failed, otherwise exit with 0
process.exit(combinedResults.failed > 0 ? 1 : 0);
diff --git a/vite.config.styles.ts b/vite.config.styles.ts
index 0b100648fe6..b2d2fe8b2cc 100644
--- a/vite.config.styles.ts
+++ b/vite.config.styles.ts
@@ -1,9 +1,11 @@
-import { resolve } from 'path'
-import { defineConfig } from 'vite'
+import { resolve } from 'path';
+import { defineConfig } from 'vite';
import fs from 'fs';
// List all theme files in the css/theme directory
-const themeFiles = fs.readdirSync(resolve(__dirname, 'css/theme')).filter(file => file.endsWith('.scss'));
+const themeFiles = fs
+ .readdirSync(resolve(__dirname, 'css/theme'))
+ .filter((file) => file.endsWith('.scss'));
const themeEntries = themeFiles.reduce((acc, file) => {
acc[`theme/${file.replace('.scss', '')}`] = resolve(__dirname, `css/theme/${file}`);
return acc;
@@ -17,12 +19,12 @@ export default defineConfig({
lib: {
formats: ['es'],
entry: {
- 'reveal': resolve(__dirname, 'css/reveal.scss'),
- 'reset': resolve(__dirname, 'css/reset.css'),
+ reveal: resolve(__dirname, 'css/reveal.scss'),
+ reset: resolve(__dirname, 'css/reset.css'),
...themeEntries,
},
- }
+ },
},
plugins: [],
-})
+});
diff --git a/vite.config.ts b/vite.config.ts
index 5df8531d67c..1a3d5c9a78a 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -1,31 +1,30 @@
-import { resolve } from 'path'
+import { resolve } from 'path';
import { ModuleFormat } from 'rollup';
-import { defineConfig } from 'vite'
+import { defineConfig } from 'vite';
import dts from 'vite-plugin-dts';
-export const appendExtension = (format:ModuleFormat, name:String) : string => {
- if( format === 'es' ) {
+export const appendExtension = (format: ModuleFormat, name: String): string => {
+ if (format === 'es') {
return `${name}.mjs`;
- }
- else {
+ } else {
return `${name}.js`;
}
-}
+};
export default defineConfig({
build: {
emptyOutDir: true,
lib: {
formats: ['es', 'umd'],
- entry: resolve(__dirname, 'js/index.ts'),
+ entry: resolve(__dirname, 'js/index.ts'),
name: 'Reveal',
fileName: (format, entryName) => {
return appendExtension(format, 'reveal');
- }
+ },
},
rollupOptions: {
output: {
- assetFileNames: "reveal.[ext]",
+ assetFileNames: 'reveal.[ext]',
},
},
},
@@ -36,7 +35,5 @@ export default defineConfig({
'reveal.js': '/js',
},
},
- plugins: [
- dts({ insertTypesEntry: true }),
- ],
-})
+ plugins: [dts({ insertTypesEntry: true, rollupTypes: true })],
+});