esm bundle only targets browsers with module support
This commit is contained in:
1 parent
2ca01bb4a5
commit
9242b25bc9
2 files changed
+51
-22
No files matched your search
Vendored
+1
-1
@@ -5,5 +5,5 @@
|
|||||||
*
|
*
|
||||||
* Copyright (C) 2020 Hakim El Hattab, https://hakim.se
|
* Copyright (C) 2020 Hakim El Hattab, https://hakim.se
|
||||||
*/
|
*/
|
||||||
function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function n(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),e}function a(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function r(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function s(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?r(Object(i),!0).forEach((function(t){a(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):r(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function o(e){return function(e){if(Array.isArray(e))return l(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return l(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(i);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return l(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function l(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n}var d=/registerPlugin|registerKeyboardShortcut|addKeyBinding|addEventListener/,c=/fade-(down|up|right|left|out|in-then-out|in-then-semi-out)|semi-fade-out|current-visible|shrink|grow/,u=function(e,t){for(var i in t)e[i]=t[i];return e},h=function(e,t){return Array.from(e.querySelectorAll(t))},v=function(e){if("string"==typeof e){if("null"===e)return null;if("true"===e)return!0;if("false"===e)return!1;if(e.match(/^-?[\d\.]+$/))return parseFloat(e)}return e},g=function(e,t){e.style.transform=t},f=function(e,t){for(var i=e.parentNode;i;){var n=i.matches||i.matchesSelector||i.msMatchesSelector;if(n&&n.call(i,t))return i;i=i.parentNode}return null},p=function(e,t,i){for(var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",a=e.querySelectorAll("."+i),r=0;r<a.length;r++){var s=a[r];if(s.parentNode===e)return s}var o=document.createElement(t);return o.className=i,o.innerHTML=n,e.appendChild(o),o},m=function(e){var t=document.createElement("style");return t.type="text/css",e&&e.length>0&&(t.styleSheet?t.styleSheet.cssText=e:t.appendChild(document.createTextNode(e))),document.head.appendChild(t),t},y=function(){var e={};for(var t in location.search.replace(/[A-Z0-9]+?=([\w\.%-]*)/gi,(function(t){e[t.split("=").shift()]=t.split("=").pop()})),e){var i=e[t];e[t]=v(unescape(i))}return void 0!==e.dependencies&&delete e.dependencies,e},b=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(e){var i,n=e.style.height;return e.style.height="0px",e.parentNode.style.height="auto",i=t-e.parentNode.offsetHeight,e.style.height=n+"px",e.parentNode.style.removeProperty("height"),i}return t},k=navigator.userAgent,w=document.createElement("div"),A=/(iphone|ipod|ipad|android)/gi.test(k)||"MacIntel"===navigator.platform&&navigator.maxTouchPoints>1,R=/chrome/i.test(k)&&!/edge/i.test(k),E=/android/gi.test(k),S="zoom"in w.style&&!A&&(R||/Version\/[\d\.]+.*Safari/.test(k)),L="function"==typeof window.history.replaceState&&!/PhantomJS/.test(k),x=function(){function e(i){t(this,e),this.Reveal=i,this.startEmbeddedIframe=this.startEmbeddedIframe.bind(this)}return n(e,[{key:"shouldPreload",value:function(e){var t=this.Reveal.getConfig().preloadIframes;return"boolean"!=typeof t&&(t=e.hasAttribute("data-preload")),t}},{key:"load",value:function(e){var t=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e.style.display=this.Reveal.getConfig().display,h(e,"img[data-src], video[data-src], audio[data-src], iframe[data-src]").forEach((function(e){("IFRAME"!==e.tagName||t.shouldPreload(e))&&(e.setAttribute("src",e.getAttribute("data-src")),e.setAttribute("data-lazy-loaded",""),e.removeAttribute("data-src"))})),h(e,"video, audio").forEach((function(e){var t=0;h(e,"source[data-src]").forEach((function(e){e.setAttribute("src",e.getAttribute("data-src")),e.removeAttribute("data-src"),e.setAttribute("data-lazy-loaded",""),t+=1})),t>0&&e.load()}));var n=e.slideBackgroundElement;if(n){n.style.display="block";var a=e.slideBackgroundContentElement,r=e.getAttributeLine truncated
|
function e(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function t(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,a)}return i}function i(i){for(var a=1;a<arguments.length;a++){var s=null!=arguments[a]?arguments[a]:{};a%2?t(Object(s),!0).forEach((function(t){e(i,t,s[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(s)):t(Object(s)).forEach((function(e){Object.defineProperty(i,e,Object.getOwnPropertyDescriptor(s,e))}))}return i}var a=/registerPlugin|registerKeyboardShortcut|addKeyBinding|addEventListener/,s=/fade-(down|up|right|left|out|in-then-out|in-then-semi-out)|semi-fade-out|current-visible|shrink|grow/,n=(e,t)=>{for(var i in t)e[i]=t[i];return e},r=(e,t)=>Array.from(e.querySelectorAll(t)),o=e=>{if("string"==typeof e){if("null"===e)return null;if("true"===e)return!0;if("false"===e)return!1;if(e.match(/^-?[\d\.]+$/))return parseFloat(e)}return e},l=(e,t)=>{e.style.transform=t},d=(e,t)=>{for(var i=e.parentNode;i;){var a=i.matches||i.matchesSelector||i.msMatchesSelector;if(a&&a.call(i,t))return i;i=i.parentNode}return null},c=function(e,t,i){for(var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",s=e.querySelectorAll("."+i),n=0;n<s.length;n++){var r=s[n];if(r.parentNode===e)return r}var o=document.createElement(t);return o.className=i,o.innerHTML=a,e.appendChild(o),o},h=e=>{var t=document.createElement("style");return t.type="text/css",e&&e.length>0&&(t.styleSheet?t.styleSheet.cssText=e:t.appendChild(document.createTextNode(e))),document.head.appendChild(t),t},u=()=>{var e={};for(var t in location.search.replace(/[A-Z0-9]+?=([\w\.%-]*)/gi,t=>{e[t.split("=").shift()]=t.split("=").pop()}),e){var i=e[t];e[t]=o(unescape(i))}return void 0!==e.dependencies&&delete e.dependencies,e},v=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(e){var i,a=e.style.height;return e.style.height="0px",e.parentNode.style.height="auto",i=t-e.parentNode.offsetHeight,e.style.height=a+"px",e.parentNode.style.removeProperty("height"),i}return t},g=navigator.userAgent,p=document.createElement("div"),m=/(iphone|ipod|ipad|android)/gi.test(g)||"MacIntel"===navigator.platform&&navigator.maxTouchPoints>1,f=/chrome/i.test(g)&&!/edge/i.test(g),b=/android/gi.test(g),y="zoom"in p.style&&!m&&(f||/Version\/[\d\.]+.*Safari/.test(g)),w="function"==typeof window.history.replaceState&&!/PhantomJS/.test(g);class A{constructor(e){this.Reveal=e,this.startEmbeddedIframe=this.startEmbeddedIframe.bind(this)}shouldPreload(e){var t=this.Reveal.getConfig().preloadIframes;return"boolean"!=typeof t&&(t=e.hasAttribute("data-preload")),t}load(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e.style.display=this.Reveal.getConfig().display,r(e,"img[data-src], video[data-src], audio[data-src], iframe[data-src]").forEach(e=>{("IFRAME"!==e.tagName||this.shouldPreload(e))&&(e.setAttribute("src",e.getAttribute("data-src")),e.setAttribute("data-lazy-loaded",""),e.removeAttribute("data-src"))}),r(e,"video, audio").forEach(e=>{var t=0;r(e,"source[data-src]").forEach(e=>{e.setAttribute("src",e.getAttribute("data-src")),e.removeAttribute("data-src"),e.setAttribute("data-lazy-loaded",""),t+=1}),t>0&&e.load()});var i=e.slideBackgroundElement;if(i){i.style.display="block";var a=e.slideBackgroundContentElement,s=e.getAttribute("data-background-iframe");if(!1===i.hasAttribute("data-loaded")){i.setAttribute("data-loaded","true");var n=e.getAttribute("data-background-image"),o=e.getAttribute("data-background-video"),l=e.hasAttribute("data-background-video-loop"),d=e.hasAttribute("data-background-video-muted");if(n)a.style.backgroundImage="url("+encodeURI(n)+")";else if(o&&!this.Reveal.isSpeakerNotes()){var c=document.createElement("video");l&&c.setAttribute("loop",""),d&&(c.muted=!0),m&&(c.muted=!0,c.autoplay=!0,c.setAttribute("playsinline","")),o.split(",").forEach(e=>{c.innerHTML+='<source src="'+e+'">'}),a.appendChild(c)}else if(s&&!0!==t.excludeIframes){var h=document.createElement("iframe");h.setAttribute("allowfullscreen",""),h.setAttribute("mozallowfullscreen",""),h.setAttribute("webkitallowfullscreen",""),h.setAttribute("allow","autoplay"),h.setAttribute("data-src",s),h.style.width="100%",h.style.height="100%",h.style.maxHeight="100%",h.style.maxWidth="100%",a.appendChild(h)}}var u=a.querySelector("iframe[data-src]");u&&this.shouldPreload(i)&&!/autoplay=(1|true|yes)/gi.test(s)&&u.getAttribute("src")!==s&&u.setAttribute("src",s)}}unload(e){e.style.display="none";var t=this.Reveal.getSlideBackground(e);t&&(t.style.display="none",r(t,"iframe[src]").forEach(e=>{e.removeAttribute("src")})),r(e,"video[data-lazy-loaded][src], audio[data-lazy-loaded][src], iframe[data-lazy-loaded][src]").forEach(e=>{e.setAttribute("data-src",e.getAttribute("src")),e.removeAttributLine truncated
|
||||||
//# sourceMappingURL=reveal.esm.js.map
|
//# sourceMappingURL=reveal.esm.js.map
|
||||||
+50
-21
@@ -35,39 +35,50 @@ const banner = `/*!
|
|||||||
// Prevents warnings from opening too many test pages
|
// Prevents warnings from opening too many test pages
|
||||||
process.setMaxListeners(20);
|
process.setMaxListeners(20);
|
||||||
|
|
||||||
|
const babelConfig = {
|
||||||
|
exclude: 'node_modules/**',
|
||||||
|
compact: false,
|
||||||
|
presets: [[
|
||||||
|
'@babel/preset-env',
|
||||||
|
{
|
||||||
|
corejs: 3,
|
||||||
|
useBuiltIns: 'entry',
|
||||||
|
modules: false
|
||||||
|
}
|
||||||
|
]]
|
||||||
|
};
|
||||||
|
|
||||||
const rollupConfig = {
|
const rollupConfig = {
|
||||||
plugins: [
|
plugins: [
|
||||||
babel({
|
babel( babelConfig ),
|
||||||
exclude: 'node_modules/**',
|
|
||||||
compact: false,
|
|
||||||
presets: [[
|
|
||||||
'@babel/preset-env',
|
|
||||||
{
|
|
||||||
corejs: 3,
|
|
||||||
useBuiltIns: 'entry',
|
|
||||||
modules: false
|
|
||||||
}
|
|
||||||
]]
|
|
||||||
}),
|
|
||||||
resolve(),
|
resolve(),
|
||||||
commonjs(),
|
commonjs(),
|
||||||
terser()
|
terser()
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
gulp.task('js', () => {
|
// Our ES module bundle only needs to support modern
|
||||||
|
// browser features
|
||||||
|
const babelConfigESM = JSON.parse( JSON.stringify( babelConfig ) );
|
||||||
|
babelConfigESM.presets[0][1].targets = { esmodules: true };
|
||||||
|
|
||||||
|
const rollupConfigESM = {
|
||||||
|
plugins: [
|
||||||
|
babel( babelConfigESM ),
|
||||||
|
resolve(),
|
||||||
|
commonjs(),
|
||||||
|
terser()
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
// Creates a bundle with broad browser support, exposed
|
||||||
|
// as UMD
|
||||||
|
gulp.task('js-es5', () => {
|
||||||
return rollup({
|
return rollup({
|
||||||
input: 'js/index.js',
|
input: 'js/index.js',
|
||||||
...rollupConfig
|
...rollupConfig
|
||||||
}).then( bundle => {
|
}).then( bundle => {
|
||||||
bundle.write({
|
return bundle.write({
|
||||||
file: './dist/reveal.esm.js',
|
|
||||||
format: 'es',
|
|
||||||
banner: banner,
|
|
||||||
sourcemap: true
|
|
||||||
});
|
|
||||||
|
|
||||||
bundle.write({
|
|
||||||
name: 'Reveal',
|
name: 'Reveal',
|
||||||
file: './dist/reveal.js',
|
file: './dist/reveal.js',
|
||||||
format: 'umd',
|
format: 'umd',
|
||||||
@@ -77,6 +88,24 @@ gulp.task('js', () => {
|
|||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Creates an ES module bundle
|
||||||
|
gulp.task('js-es6', () => {
|
||||||
|
return rollup({
|
||||||
|
input: 'js/index.js',
|
||||||
|
...rollupConfigESM
|
||||||
|
}).then( bundle => {
|
||||||
|
return bundle.write({
|
||||||
|
file: './dist/reveal.esm.js',
|
||||||
|
format: 'es',
|
||||||
|
banner: banner,
|
||||||
|
sourcemap: true
|
||||||
|
});
|
||||||
|
});
|
||||||
|
})
|
||||||
|
gulp.task('js', gulp.parallel('js-es5', 'js-es6'));
|
||||||
|
|
||||||
|
// Creates a UMD and ES module bundle for each of our
|
||||||
|
// built-in plugins
|
||||||
gulp.task('plugins', () => {
|
gulp.task('plugins', () => {
|
||||||
return Promise.all([
|
return Promise.all([
|
||||||
{ name: 'RevealHighlight', input: './plugin/highlight/plugin.js', output: './dist/plugin/highlight' },
|
{ name: 'RevealHighlight', input: './plugin/highlight/plugin.js', output: './dist/plugin/highlight' },
|
||||||
|
|||||||
Reference in new issue
Block a user