diff --git a/dist/img/photo1.png b/dist/img/photo1.png deleted file mode 100644 index 7b3258b..0000000 Binary files a/dist/img/photo1.png and /dev/null differ diff --git a/dist/img/photo2.jpg b/dist/img/photo2.jpg deleted file mode 100644 index c53dafd..0000000 Binary files a/dist/img/photo2.jpg and /dev/null differ diff --git a/dist/img/photo3.svg b/dist/img/photo3.svg deleted file mode 100644 index 4295ae6..0000000 --- a/dist/img/photo3.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/dist/index.html b/dist/index.html index 4163ff6..2d3ce36 100644 --- a/dist/index.html +++ b/dist/index.html @@ -1,3 +1,3 @@ Meta-lightbox Demo

Meta-lightbox Demo

NODE_ENV: production

Loading data

Load an Image
Load JSON


Load Partial AJAX HTML
Not Found test

Embeds

Embed Youtube link
Embed Vimeo link
Embed SoundCloud link
Embed Instagram

Other

Use [data-toggle="lightbox"] attribute to attach lightbox action and [href] to specify URL.

Use [data-gallery="YOUR_GALLERY_NAME"] to group ligthboxes with next/prev arrows

Use [data-toggle="lightbox"] + [data-href] attribute to toggle lightbox on regular elements. Click me!

\ No newline at end of file + }

Meta-lightbox Demo

NODE_ENV: production
\ No newline at end of file diff --git a/dist/js/app.js b/dist/js/app.js index 34bfad4..82c9250 100644 --- a/dist/js/app.js +++ b/dist/js/app.js @@ -1 +1 @@ -!function(){var e={885:function(e,t,n){e.exports=n(855)},145:function(e,t,n){"use strict";var r=n(750),o=n(149),a=n(804),i=n(642),s=n(295),c=n(279),u=n(868),f=n(865);e.exports=function xhrAdapter(e){return new Promise((function dispatchXhrRequest(t,n){var l=e.data,p=e.headers;r.isFormData(l)&&delete p["Content-Type"];var d=new XMLHttpRequest;if(e.auth){var h=e.auth.username||"",m=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";p.Authorization="Basic "+btoa(h+":"+m)}var g=s(e.baseURL,e.url);if(d.open(e.method.toUpperCase(),i(g,e.params,e.paramsSerializer),!0),d.timeout=e.timeout,d.onreadystatechange=function handleLoad(){if(d&&4===d.readyState&&(0!==d.status||d.responseURL&&0===d.responseURL.indexOf("file:"))){var r="getAllResponseHeaders"in d?c(d.getAllResponseHeaders()):null,a={data:e.responseType&&"text"!==e.responseType?d.response:d.responseText,status:d.status,statusText:d.statusText,headers:r,config:e,request:d};o(t,n,a),d=null}},d.onabort=function handleAbort(){d&&(n(f("Request aborted",e,"ECONNABORTED",d)),d=null)},d.onerror=function handleError(){n(f("Network Error",e,null,d)),d=null},d.ontimeout=function handleTimeout(){var t="timeout of "+e.timeout+"ms exceeded";e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),n(f(t,e,"ECONNABORTED",d)),d=null},r.isStandardBrowserEnv()){var y=(e.withCredentials||u(g))&&e.xsrfCookieName?a.read(e.xsrfCookieName):void 0;y&&(p[e.xsrfHeaderName]=y)}if("setRequestHeader"in d&&r.forEach(p,(function setRequestHeader(e,t){"undefined"===typeof l&&"content-type"===t.toLowerCase()?delete p[t]:d.setRequestHeader(t,e)})),r.isUndefined(e.withCredentials)||(d.withCredentials=!!e.withCredentials),e.responseType)try{d.responseType=e.responseType}catch(v){if("json"!==e.responseType)throw v}"function"===typeof e.onDownloadProgress&&d.addEventListener("progress",e.onDownloadProgress),"function"===typeof e.onUploadProgress&&d.upload&&d.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then((function onCanceled(e){d&&(d.abort(),n(e),d=null)})),l||(l=null),d.send(l)}))}},855:function(e,t,n){"use strict";var r=n(750),o=n(999),a=n(229),i=n(936);function createInstance(e){var t=new a(e),n=o(a.prototype.request,t);return r.extend(n,a.prototype,t),r.extend(n,t),n}var s=createInstance(n(822));s.Axios=a,s.create=function create(e){return createInstance(i(s.defaults,e))},s.Cancel=n(589),s.CancelToken=n(816),s.isCancel=n(882),s.all=function all(e){return Promise.all(e)},s.spread=n(867),s.isAxiosError=n(218),e.exports=s,e.exports.default=s},589:function(e){"use strict";function Cancel(e){this.message=e}Cancel.prototype.toString=function toString(){return"Cancel"+(this.message?": "+this.message:"")},Cancel.prototype.__CANCEL__=!0,e.exports=Cancel},816:function(e,t,n){"use strict";var r=n(589);function CancelToken(e){if("function"!==typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function promiseExecutor(e){t=e}));var n=this;e((function cancel(e){n.reason||(n.reason=new r(e),t(n.reason))}))}CancelToken.prototype.throwIfRequested=function throwIfRequested(){if(this.reason)throw this.reason},CancelToken.source=function source(){var e;return{token:new CancelToken((function executor(t){e=t})),cancel:e}},e.exports=CancelToken},882:function(e){"use strict";e.exports=function isCancel(e){return!(!e||!e.__CANCEL__)}},229:function(e,t,n){"use strict";var r=n(750),o=n(642),a=n(748),i=n(850),s=n(936);function Axios(e){this.defaults=e,this.interceptors={request:new a,response:new a}}Axios.prototype.request=function request(e){"string"===typeof e?(e=arguments[1]||{}).url=arguments[0]:e=e||{},(e=s(this.defaults,e)).method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var t=[i,void 0],n=Promise.resolve(e);for(this.interceptors.request.forEach((function unshiftRequestInterceptors(e){t.unshift(e.fulfilled,e.rejected)})),this.interceptors.response.forEach((function pushResponseInterceptors(e){t.push(e.fulfilled,e.rejected)}));t.length;)n=n.then(t.shift(),t.shift());return n},Axios.prototype.getUri=function getUri(e){return e=s(this.defaults,e),o(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},r.forEach(["delete","get","head","options"],(function forEachMethodNoData(e){Axios.prototype[e]=function(t,n){return this.request(s(n||{},{method:e,url:t,data:(n||{}).data}))}})),r.forEach(["post","put","patch"],(function forEachMethodWithData(e){Axios.prototype[e]=function(t,n,r){return this.request(s(r||{},{method:e,url:t,data:n}))}})),e.exports=Axios},748:function(e,t,n){"use strict";var r=n(750);function InterceptorManager(){this.handlers=[]}InterceptorManager.prototype.use=function use(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1},InterceptorManager.prototype.eject=function eject(e){this.handlers[e]&&(this.handlers[e]=null)},InterceptorManager.prototype.forEach=function forEach(e){r.forEach(this.handlers,(function forEachHandler(t){null!==t&&e(t)}))},e.exports=InterceptorManager},295:function(e,t,n){"use strict";var r=n(322),o=n(567);e.exports=function buildFullPath(e,t){return e&&!r(t)?o(e,t):t}},865:function(e,t,n){"use strict";var r=n(202);e.exports=function createError(e,t,n,o,a){var i=new Error(e);return r(i,t,n,o,a)}},850:function(e,t,n){"use strict";var r=n(750),o=n(838),a=n(882),i=n(822);function throwIfCancellationRequested(e){e.cancelToken&&e.cancelToken.throwIfRequested()}e.exports=function dispatchRequest(e){return throwIfCancellationRequested(e),e.headers=e.headers||{},e.data=o(e.data,e.headers,e.transformRequest),e.headers=r.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),r.forEach(["delete","get","head","post","put","patch","common"],(function cleanHeaderConfig(t){delete e.headers[t]})),(e.adapter||i.adapter)(e).then((function onAdapterResolution(t){return throwIfCancellationRequested(e),t.data=o(t.data,t.headers,e.transformResponse),t}),(function onAdapterRejection(t){return a(t)||(throwIfCancellationRequested(e),t&&t.response&&(t.response.data=o(t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))}},202:function(e){"use strict";e.exports=function enhanceError(e,t,n,r,o){return e.config=t,n&&(e.code=n),e.request=r,e.response=o,e.isAxiosError=!0,e.toJSON=function toJSON(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},e}},936:function(e,t,n){"use strict";var r=n(750);e.exports=function mergeConfig(e,t){t=t||{};var n={},o=["url","method","data"],a=["headers","auth","proxy","params"],i=["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","timeoutMessage","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","decompress","maxContentLength","maxBodyLength","maxRedirects","transport","httpAgent","httpsAgent","cancelToken","socketPath","responseEncoding"],s=["validateStatus"];function getMergedValue(e,t){return r.isPlainObject(e)&&r.isPlainObject(t)?r.merge(e,t):r.isPlainObject(t)?r.merge({},t):r.isArray(t)?t.slice():t}function mergeDeepProperties(o){r.isUndefined(t[o])?r.isUndefined(e[o])||(n[o]=getMergedValue(void 0,e[o])):n[o]=getMergedValue(e[o],t[o])}r.forEach(o,(function valueFromConfig2(e){r.isUndefined(t[e])||(n[e]=getMergedValue(void 0,t[e]))})),r.forEach(a,mergeDeepProperties),r.forEach(i,(function defaultToConfig2(o){r.isUndefined(t[o])?r.isUndefined(e[o])||(n[o]=getMergedValue(void 0,e[o])):n[o]=getMergedValue(void 0,t[o])})),r.forEach(s,(function merge(r){r in t?n[r]=getMergedValue(e[r],t[r]):r in e&&(n[r]=getMergedValue(void 0,e[r]))}));var c=o.concat(a).concat(i).concat(s),u=Object.keys(e).concat(Object.keys(t)).filter((function filterAxiosKeys(e){return-1===c.indexOf(e)}));return r.forEach(u,mergeDeepProperties),n}},149:function(e,t,n){"use strict";var r=n(865);e.exports=function settle(e,t,n){var o=n.config.validateStatus;n.status&&o&&!o(n.status)?t(r("Request failed with status code "+n.status,n.config,null,n.request,n)):e(n)}},838:function(e,t,n){"use strict";var r=n(750);e.exports=function transformData(e,t,n){return r.forEach(n,(function transform(n){e=n(e,t)})),e}},822:function(e,t,n){"use strict";var r=n(750),o=n(325),a={"Content-Type":"application/x-www-form-urlencoded"};function setContentTypeIfUnset(e,t){!r.isUndefined(e)&&r.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var i={adapter:function getDefaultAdapter(){var e;return("undefined"!==typeof XMLHttpRequest||"undefined"!==typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(e=n(145)),e}(),transformRequest:[function transformRequest(e,t){return o(t,"Accept"),o(t,"Content-Type"),r.isFormData(e)||r.isArrayBuffer(e)||r.isBuffer(e)||r.isStream(e)||r.isFile(e)||r.isBlob(e)?e:r.isArrayBufferView(e)?e.buffer:r.isURLSearchParams(e)?(setContentTypeIfUnset(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):r.isObject(e)?(setContentTypeIfUnset(t,"application/json;charset=utf-8"),JSON.stringify(e)):e}],transformResponse:[function transformResponse(e){if("string"===typeof e)try{e=JSON.parse(e)}catch(t){}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function validateStatus(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};r.forEach(["delete","get","head"],(function forEachMethodNoData(e){i.headers[e]={}})),r.forEach(["post","put","patch"],(function forEachMethodWithData(e){i.headers[e]=r.merge(a)})),e.exports=i},999:function(e){"use strict";e.exports=function bind(e,t){return function wrap(){for(var n=new Array(arguments.length),r=0;r=0)return;i[t]="set-cookie"===t?(i[t]?i[t]:[]).concat([n]):i[t]?i[t]+", "+n:n}})),i):i}},867:function(e){"use strict";e.exports=function spread(e){return function wrap(t){return e.apply(null,t)}}},750:function(e,t,n){"use strict";function _typeof(e){return(_typeof="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function _typeof(e){return typeof e}:function _typeof(e){return e&&"function"===typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var r=n(999),o=Object.prototype.toString;function isArray(e){return"[object Array]"===o.call(e)}function isUndefined(e){return"undefined"===typeof e}function isObject(e){return null!==e&&"object"===_typeof(e)}function isPlainObject(e){if("[object Object]"!==o.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function isFunction(e){return"[object Function]"===o.call(e)}function forEach(e,t){if(null!==e&&"undefined"!==typeof e)if("object"!==_typeof(e)&&(e=[e]),isArray(e))for(var n=0,r=e.length;ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n0&&void 0!==arguments[0]?arguments[0]:{shown:!1},o=arguments.length>1?arguments[1]:void 0;_classCallCheck(this,MetaWindow),_defineProperty(this,"state",{content:"",type:["empty"],shown:!1,loading:!1,error:!1,embed:!1,collections:[],current:null,target:null}),_defineProperty(this,"show",(function(){var t=e;console.log("".concat(t.name,": show")),t.setState({shown:!0}),n.dispatchEvent(new Event("{ui.name}.show"))})),_defineProperty(this,"hide",(function(){var t=e;console.log("".concat(t.name,": hide")),t.setState({shown:!1}),n.dispatchEvent(new Event("{ui.name}.hide"))})),_defineProperty(this,"next",(function(){var t=e,r=t.state.current.getAttribute("data-gallery"),o=t._currIndex();o0?o--:o=t.state.collections[r].length-1,t.state.collections[r][o].click(),console.log("".concat(t.name,": prev")),n.dispatchEvent(new Event("{ui.name}.prev"))})),_defineProperty(this,"reset",(function(){e.setState({content:"",type:["empty"],shown:!1,loading:!1,error:!1,embed:!1})})),_defineProperty(this,"load",(function(t){var r=e,o=r.axios;r.reset(),r.setState({loading:!0}),r.show(),o.get(t,{responseType:"arraybuffer"}).then((function(e){console.log("".concat(r.name,": response content-type: ").concat(e.headers["content-type"]));switch(e.headers["content-type"]){case"image/jpeg":case"image/png":case"image/svg+xml":case"image/bmp":case"image/gif":case"image/tiff":case"image/webp":case"image/jpg":case"image/svg":r.setContent(''),"image");break;case"application/json":case"application/ld+json":case"application/json; charset=UTF-8":r.setContent("".concat((!1).Content),"text html json");break;case"text/html":case"application/xhtml+xml":case"text/plain":case"text/html; charset=UTF-8":case"application/xhtml+xml; charset=UTF-8":case"text/plain; charset=UTF-8":r.setContent(r._abToString(e.data),"text html pajax");break;default:console.warn("".concat(r.name,": Unknown response content-type!"))}n.dispatchEvent(new Event("{ui.name}.loaded"))})).catch((function(e){console.error(e);var t="";if(e.response)switch(e.response.status){case 404:t="Not Found.";break;case 500:t="Server issue, please try again latter.";break;default:t="Something went wrong."}else e.request?t="No response received":console.warn("Error",e.message);r.setState({error:t}),n.dispatchEvent(new Event("{ui.name}.error"))})).then((function(){r.setState({loading:!1})}))})),_defineProperty(this,"_currIndex",(function(){var t=e,n=t.state.current,r=n.getAttribute("data-gallery");return t.state.collections[r].indexOf(n)})),_defineProperty(this,"embed",(function(t){var n=e;console.log("".concat(n.name,": embed")),n.reset(),n.setState({embed:t,loading:!1,type:["meta-".concat(n.name,"__embed"),"meta-".concat(n.name,"__video")]}),n.show()})),_defineProperty(this,"setCaption",(function(t){var n=e;console.log("".concat(n.name,": setCaption")),n.state.caption=t})),_defineProperty(this,"getCaption",(function(){return e.state.caption})),_defineProperty(this,"_abToString",(function(e){return String.fromCharCode.apply(null,new Uint8Array(e))})),_defineProperty(this,"_imageEncode",(function(e){new Uint8Array(e);return btoa([].reduce.call(new Uint8Array(e),(function(e,t){return e+String.fromCharCode(t)}),""))})),_defineProperty(this,"setContent",(function(t,n){var r=e;console.log("".concat(r.name,": setContent"));var o=n||["html","text"];Array.isArray(o)||(o=n.split(" ")),r.setState({content:t,type:o})})),_defineProperty(this,"getHtml",(function(){var t=e;if(t.state.embed){var n=__webpack_require__(136)(t.state.embed);t.state.content='')}return t.state.content}));var a=this;switch(a.name=a.constructor.name,console.log("".concat(a.name,": init")),a.axios=r,a.setState(t),o){case"show":case"hide":a.hide()}n.dispatchEvent(new Event("{ui.name}.init"))}return function _createClass(e,t,n){return t&&_defineProperties(e.prototype,t),n&&_defineProperties(e,n),e}(MetaWindow,[{key:"init",value:function init(){var e=this;console.log("MetaWindow: [links] init"),document.querySelectorAll('[data-toggle="lightbox"],[data-gallery="${gallery}"]').forEach((function(t){var n=t.getAttribute("data-gallery");n&&(e.state.collections[n]=[],document.querySelectorAll('[data-toggle="lightbox"][data-gallery="'.concat(n,'"]')).forEach((function(t){e.state.collections[n].push(t)}))),t.addEventListener("click",(function(t){t.preventDefault(),console.log("MetaWindow: [link] click");var n=t.currentTarget,r=n.getAttribute("href")||n.getAttribute("data-href"),o=n.getAttribute("data-embed");e.state.current=n,o?e.embed(r):e.load(r);var a=n.getAttribute("data-title");a&&e.setCaption(a)}))}))}},{key:"setState",value:function setState(e){var t=this;t.state=Object.assign({},t.state,e),t.render()}},{key:"render",value:function render(){var e,t=this,n=t.name,r=t.state.current;t.state.target.innerHTML="";var o=document.createElement("div");o.classList.add("meta-".concat(n)),(e=o.classList).add.apply(e,_toConsumableArray(t.state.type)),t.state.target.append(o);var a=document.createElement("div");a.classList.add("meta-".concat(n,"-overlay")),t.state.shown&&a.classList.add("meta-".concat(n,"-overlay__open")),t.state.loading&&a.classList.add("meta-".concat(n,"-overlay__loading")),t.state.error&&a.classList.add("meta-".concat(n,"-overlay__error")),o.append(a);var i=document.createElement("div");i.classList.add("meta-content"),a.append(i);var s=document.createElement("button");if(s.classList.add("meta-nav","meta-close","a"),s.innerHTML=' Close',s.addEventListener("click",(function(e){e.preventDefault(),t.hide()})),i.append(s),r){var c=r.getAttribute("data-gallery");if(c&&t.state.collections[c].length>1){var u=document.createElement("nav");u.classList.add("meta-navs");var f=document.createElement("button");f.classList.add("meta-nav","meta-nav-arrow","meta-nav-arrow__prev","a"),f.innerHTML=' Previous',f.addEventListener("click",(function(e){e.preventDefault(),t.prev()})),u.append(f);var l=document.createElement("button");l.classList.add("meta-nav","meta-nav-arrow","meta-nav-arrow__next","a"),l.innerHTML=' Next',l.addEventListener("click",(function(e){e.preventDefault(),t.next()})),u.append(l),i.append(u)}}var p=document.createElement("section");if(p.classList.add("meta-wrap","typography"),p.innerHTML=t.getHtml(),i.append(p),t.state.error){var d=document.createElement("div");d.classList.add("meta-error"),d.innerHTML=t.state.error,i.append(d)}else if(t.state.caption){var h=document.createElement("div");h.classList.add("meta-caption"),h.innerHTML=t.getCaption(),i.append(h)}return t}}]),MetaWindow}(),a=document.getElementById("MetaLightboxApp");a||console.log("MetaWindow: missing container");var i=new o({target:a}),s=function init(){i.init()};window.addEventListener("".concat(t),s),window.addEventListener("".concat(e),s),window.addEventListener("MetaWindow.initLinks",s);(function importAll(e){return e.keys().map(e)})(__webpack_require__(310))}()}(); \ No newline at end of file +!function(){var e={885:function(e,t,n){e.exports=n(855)},145:function(e,t,n){"use strict";var r=n(750),o=n(149),a=n(804),i=n(642),s=n(295),c=n(279),u=n(868),f=n(865);e.exports=function xhrAdapter(e){return new Promise((function dispatchXhrRequest(t,n){var l=e.data,d=e.headers;r.isFormData(l)&&delete d["Content-Type"];var p=new XMLHttpRequest;if(e.auth){var h=e.auth.username||"",m=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";d.Authorization="Basic "+btoa(h+":"+m)}var y=s(e.baseURL,e.url);if(p.open(e.method.toUpperCase(),i(y,e.params,e.paramsSerializer),!0),p.timeout=e.timeout,p.onreadystatechange=function handleLoad(){if(p&&4===p.readyState&&(0!==p.status||p.responseURL&&0===p.responseURL.indexOf("file:"))){var r="getAllResponseHeaders"in p?c(p.getAllResponseHeaders()):null,a={data:e.responseType&&"text"!==e.responseType?p.response:p.responseText,status:p.status,statusText:p.statusText,headers:r,config:e,request:p};o(t,n,a),p=null}},p.onabort=function handleAbort(){p&&(n(f("Request aborted",e,"ECONNABORTED",p)),p=null)},p.onerror=function handleError(){n(f("Network Error",e,null,p)),p=null},p.ontimeout=function handleTimeout(){var t="timeout of "+e.timeout+"ms exceeded";e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),n(f(t,e,"ECONNABORTED",p)),p=null},r.isStandardBrowserEnv()){var g=(e.withCredentials||u(y))&&e.xsrfCookieName?a.read(e.xsrfCookieName):void 0;g&&(d[e.xsrfHeaderName]=g)}if("setRequestHeader"in p&&r.forEach(d,(function setRequestHeader(e,t){"undefined"===typeof l&&"content-type"===t.toLowerCase()?delete d[t]:p.setRequestHeader(t,e)})),r.isUndefined(e.withCredentials)||(p.withCredentials=!!e.withCredentials),e.responseType)try{p.responseType=e.responseType}catch(v){if("json"!==e.responseType)throw v}"function"===typeof e.onDownloadProgress&&p.addEventListener("progress",e.onDownloadProgress),"function"===typeof e.onUploadProgress&&p.upload&&p.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then((function onCanceled(e){p&&(p.abort(),n(e),p=null)})),l||(l=null),p.send(l)}))}},855:function(e,t,n){"use strict";var r=n(750),o=n(999),a=n(229),i=n(936);function createInstance(e){var t=new a(e),n=o(a.prototype.request,t);return r.extend(n,a.prototype,t),r.extend(n,t),n}var s=createInstance(n(822));s.Axios=a,s.create=function create(e){return createInstance(i(s.defaults,e))},s.Cancel=n(589),s.CancelToken=n(816),s.isCancel=n(882),s.all=function all(e){return Promise.all(e)},s.spread=n(867),s.isAxiosError=n(218),e.exports=s,e.exports.default=s},589:function(e){"use strict";function Cancel(e){this.message=e}Cancel.prototype.toString=function toString(){return"Cancel"+(this.message?": "+this.message:"")},Cancel.prototype.__CANCEL__=!0,e.exports=Cancel},816:function(e,t,n){"use strict";var r=n(589);function CancelToken(e){if("function"!==typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function promiseExecutor(e){t=e}));var n=this;e((function cancel(e){n.reason||(n.reason=new r(e),t(n.reason))}))}CancelToken.prototype.throwIfRequested=function throwIfRequested(){if(this.reason)throw this.reason},CancelToken.source=function source(){var e;return{token:new CancelToken((function executor(t){e=t})),cancel:e}},e.exports=CancelToken},882:function(e){"use strict";e.exports=function isCancel(e){return!(!e||!e.__CANCEL__)}},229:function(e,t,n){"use strict";var r=n(750),o=n(642),a=n(748),i=n(850),s=n(936);function Axios(e){this.defaults=e,this.interceptors={request:new a,response:new a}}Axios.prototype.request=function request(e){"string"===typeof e?(e=arguments[1]||{}).url=arguments[0]:e=e||{},(e=s(this.defaults,e)).method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var t=[i,void 0],n=Promise.resolve(e);for(this.interceptors.request.forEach((function unshiftRequestInterceptors(e){t.unshift(e.fulfilled,e.rejected)})),this.interceptors.response.forEach((function pushResponseInterceptors(e){t.push(e.fulfilled,e.rejected)}));t.length;)n=n.then(t.shift(),t.shift());return n},Axios.prototype.getUri=function getUri(e){return e=s(this.defaults,e),o(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},r.forEach(["delete","get","head","options"],(function forEachMethodNoData(e){Axios.prototype[e]=function(t,n){return this.request(s(n||{},{method:e,url:t,data:(n||{}).data}))}})),r.forEach(["post","put","patch"],(function forEachMethodWithData(e){Axios.prototype[e]=function(t,n,r){return this.request(s(r||{},{method:e,url:t,data:n}))}})),e.exports=Axios},748:function(e,t,n){"use strict";var r=n(750);function InterceptorManager(){this.handlers=[]}InterceptorManager.prototype.use=function use(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1},InterceptorManager.prototype.eject=function eject(e){this.handlers[e]&&(this.handlers[e]=null)},InterceptorManager.prototype.forEach=function forEach(e){r.forEach(this.handlers,(function forEachHandler(t){null!==t&&e(t)}))},e.exports=InterceptorManager},295:function(e,t,n){"use strict";var r=n(322),o=n(567);e.exports=function buildFullPath(e,t){return e&&!r(t)?o(e,t):t}},865:function(e,t,n){"use strict";var r=n(202);e.exports=function createError(e,t,n,o,a){var i=new Error(e);return r(i,t,n,o,a)}},850:function(e,t,n){"use strict";var r=n(750),o=n(838),a=n(882),i=n(822);function throwIfCancellationRequested(e){e.cancelToken&&e.cancelToken.throwIfRequested()}e.exports=function dispatchRequest(e){return throwIfCancellationRequested(e),e.headers=e.headers||{},e.data=o(e.data,e.headers,e.transformRequest),e.headers=r.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),r.forEach(["delete","get","head","post","put","patch","common"],(function cleanHeaderConfig(t){delete e.headers[t]})),(e.adapter||i.adapter)(e).then((function onAdapterResolution(t){return throwIfCancellationRequested(e),t.data=o(t.data,t.headers,e.transformResponse),t}),(function onAdapterRejection(t){return a(t)||(throwIfCancellationRequested(e),t&&t.response&&(t.response.data=o(t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))}},202:function(e){"use strict";e.exports=function enhanceError(e,t,n,r,o){return e.config=t,n&&(e.code=n),e.request=r,e.response=o,e.isAxiosError=!0,e.toJSON=function toJSON(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},e}},936:function(e,t,n){"use strict";var r=n(750);e.exports=function mergeConfig(e,t){t=t||{};var n={},o=["url","method","data"],a=["headers","auth","proxy","params"],i=["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","timeoutMessage","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","decompress","maxContentLength","maxBodyLength","maxRedirects","transport","httpAgent","httpsAgent","cancelToken","socketPath","responseEncoding"],s=["validateStatus"];function getMergedValue(e,t){return r.isPlainObject(e)&&r.isPlainObject(t)?r.merge(e,t):r.isPlainObject(t)?r.merge({},t):r.isArray(t)?t.slice():t}function mergeDeepProperties(o){r.isUndefined(t[o])?r.isUndefined(e[o])||(n[o]=getMergedValue(void 0,e[o])):n[o]=getMergedValue(e[o],t[o])}r.forEach(o,(function valueFromConfig2(e){r.isUndefined(t[e])||(n[e]=getMergedValue(void 0,t[e]))})),r.forEach(a,mergeDeepProperties),r.forEach(i,(function defaultToConfig2(o){r.isUndefined(t[o])?r.isUndefined(e[o])||(n[o]=getMergedValue(void 0,e[o])):n[o]=getMergedValue(void 0,t[o])})),r.forEach(s,(function merge(r){r in t?n[r]=getMergedValue(e[r],t[r]):r in e&&(n[r]=getMergedValue(void 0,e[r]))}));var c=o.concat(a).concat(i).concat(s),u=Object.keys(e).concat(Object.keys(t)).filter((function filterAxiosKeys(e){return-1===c.indexOf(e)}));return r.forEach(u,mergeDeepProperties),n}},149:function(e,t,n){"use strict";var r=n(865);e.exports=function settle(e,t,n){var o=n.config.validateStatus;n.status&&o&&!o(n.status)?t(r("Request failed with status code "+n.status,n.config,null,n.request,n)):e(n)}},838:function(e,t,n){"use strict";var r=n(750);e.exports=function transformData(e,t,n){return r.forEach(n,(function transform(n){e=n(e,t)})),e}},822:function(e,t,n){"use strict";var r=n(750),o=n(325),a={"Content-Type":"application/x-www-form-urlencoded"};function setContentTypeIfUnset(e,t){!r.isUndefined(e)&&r.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var i={adapter:function getDefaultAdapter(){var e;return("undefined"!==typeof XMLHttpRequest||"undefined"!==typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(e=n(145)),e}(),transformRequest:[function transformRequest(e,t){return o(t,"Accept"),o(t,"Content-Type"),r.isFormData(e)||r.isArrayBuffer(e)||r.isBuffer(e)||r.isStream(e)||r.isFile(e)||r.isBlob(e)?e:r.isArrayBufferView(e)?e.buffer:r.isURLSearchParams(e)?(setContentTypeIfUnset(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):r.isObject(e)?(setContentTypeIfUnset(t,"application/json;charset=utf-8"),JSON.stringify(e)):e}],transformResponse:[function transformResponse(e){if("string"===typeof e)try{e=JSON.parse(e)}catch(t){}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function validateStatus(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};r.forEach(["delete","get","head"],(function forEachMethodNoData(e){i.headers[e]={}})),r.forEach(["post","put","patch"],(function forEachMethodWithData(e){i.headers[e]=r.merge(a)})),e.exports=i},999:function(e){"use strict";e.exports=function bind(e,t){return function wrap(){for(var n=new Array(arguments.length),r=0;r=0)return;i[t]="set-cookie"===t?(i[t]?i[t]:[]).concat([n]):i[t]?i[t]+", "+n:n}})),i):i}},867:function(e){"use strict";e.exports=function spread(e){return function wrap(t){return e.apply(null,t)}}},750:function(e,t,n){"use strict";function _typeof(e){return(_typeof="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function _typeof(e){return typeof e}:function _typeof(e){return e&&"function"===typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var r=n(999),o=Object.prototype.toString;function isArray(e){return"[object Array]"===o.call(e)}function isUndefined(e){return"undefined"===typeof e}function isObject(e){return null!==e&&"object"===_typeof(e)}function isPlainObject(e){if("[object Object]"!==o.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function isFunction(e){return"[object Function]"===o.call(e)}function forEach(e,t){if(null!==e&&"undefined"!==typeof e)if("object"!==_typeof(e)&&(e=[e]),isArray(e))for(var n=0,r=e.length;ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n0&&void 0!==arguments[0]?arguments[0]:{shown:!1},o=arguments.length>1?arguments[1]:void 0;_classCallCheck(this,MetaWindow),_defineProperty(this,"state",{content:"",type:["empty"],shown:!1,loading:!1,error:!1,embed:!1,collections:[],current:null,target:null}),_defineProperty(this,"show",(function(){var t=e;console.log("".concat(t.name,": show")),t.setState({shown:!0}),n.dispatchEvent(new Event("{ui.name}.show"))})),_defineProperty(this,"hide",(function(){var t=e;console.log("".concat(t.name,": hide")),t.setState({shown:!1}),n.dispatchEvent(new Event("{ui.name}.hide"))})),_defineProperty(this,"next",(function(){var t=e,r=t.state.current.getAttribute("data-gallery"),o=t._currIndex();o0?o--:o=t.state.collections[r].length-1,t.state.collections[r][o].click(),console.log("".concat(t.name,": prev")),n.dispatchEvent(new Event("{ui.name}.prev"))})),_defineProperty(this,"reset",(function(){e.setState({content:"",type:["empty"],shown:!1,loading:!1,error:!1,embed:!1})})),_defineProperty(this,"load",(function(t){var r=e,o=r.axios;r.reset(),r.setState({loading:!0}),r.show(),o.get(t,{responseType:"arraybuffer"}).then((function(e){console.log("".concat(r.name,": response content-type: ").concat(e.headers["content-type"]));switch(e.headers["content-type"]){case"image/jpeg":case"image/png":case"image/svg+xml":case"image/bmp":case"image/gif":case"image/tiff":case"image/webp":case"image/jpg":case"image/svg":r.setContent(''),"image");break;case"application/json":case"application/ld+json":case"application/json; charset=UTF-8":r.setContent("".concat((!1).Content),"text html json");break;case"text/html":case"application/xhtml+xml":case"text/plain":case"text/html; charset=UTF-8":case"application/xhtml+xml; charset=UTF-8":case"text/plain; charset=UTF-8":r.setContent(r._abToString(e.data),"text html pajax");break;default:console.warn("".concat(r.name,": Unknown response content-type!"))}n.dispatchEvent(new Event("{ui.name}.loaded"))})).catch((function(e){console.error(e);var t="";if(e.response)switch(e.response.status){case 404:t="Not Found.";break;case 500:t="Server issue, please try again latter.";break;default:t="Something went wrong."}else e.request?t="No response received":console.warn("Error",e.message);r.setState({error:t}),n.dispatchEvent(new Event("{ui.name}.error"))})).then((function(){r.setState({loading:!1})}))})),_defineProperty(this,"_currIndex",(function(){var t=e,n=t.state.current,r=n.getAttribute("data-gallery");return t.state.collections[r].indexOf(n)})),_defineProperty(this,"embed",(function(t){var n=e;console.log("".concat(n.name,": embed")),n.reset(),n.setState({embed:t,loading:!1,type:["meta-".concat(n.name,"__embed"),"meta-".concat(n.name,"__video")]}),n.show()})),_defineProperty(this,"setCaption",(function(t){var n=e;console.log("".concat(n.name,": setCaption")),n.state.caption=t})),_defineProperty(this,"getCaption",(function(){return e.state.caption})),_defineProperty(this,"_abToString",(function(e){return String.fromCharCode.apply(null,new Uint8Array(e))})),_defineProperty(this,"_imageEncode",(function(e){new Uint8Array(e);return btoa([].reduce.call(new Uint8Array(e),(function(e,t){return e+String.fromCharCode(t)}),""))})),_defineProperty(this,"setContent",(function(t,n){var r=e;console.log("".concat(r.name,": setContent"));var o=n||["html","text"];Array.isArray(o)||(o=n.split(" ")),r.setState({content:t,type:o})})),_defineProperty(this,"getHtml",(function(){var t=e;if(t.state.embed){var n=__webpack_require__(136)(t.state.embed);t.state.content='')}return t.state.content}));var a=this;switch(a.name=a.constructor.name,console.log("".concat(a.name,": init")),a.axios=r,a.setState(t),o){case"show":case"hide":a.hide()}n.dispatchEvent(new Event("{ui.name}.init"))}return function _createClass(e,t,n){return t&&_defineProperties(e.prototype,t),n&&_defineProperties(e,n),e}(MetaWindow,[{key:"init",value:function init(){var e=this;console.log("MetaWindow: [links] init"),document.querySelectorAll('[data-toggle="lightbox"],[data-gallery="${gallery}"]').forEach((function(t){var n=t.getAttribute("data-gallery");n&&(e.state.collections[n]=[],document.querySelectorAll('[data-toggle="lightbox"][data-gallery="'.concat(n,'"]')).forEach((function(t){e.state.collections[n].push(t)}))),t.addEventListener("click",(function(t){t.preventDefault(),console.log("MetaWindow: [link] click");var n=t.currentTarget,r=n.getAttribute("href")||n.getAttribute("data-href"),o=n.getAttribute("data-embed");e.state.current=n,o?e.embed(r):e.load(r);var a=n.getAttribute("data-title");a&&e.setCaption(a)}))}))}},{key:"setState",value:function setState(e){var t=this;t.state=Object.assign({},t.state,e),t.render()}},{key:"render",value:function render(){var e,t=this,n=t.name,r=t.state.current;t.state.target.innerHTML="";var o=document.createElement("div");o.classList.add("meta-".concat(n)),(e=o.classList).add.apply(e,_toConsumableArray(t.state.type)),t.state.target.append(o);var a=document.createElement("div");a.classList.add("meta-".concat(n,"-overlay")),t.state.shown&&a.classList.add("meta-".concat(n,"-overlay__open")),t.state.loading&&a.classList.add("meta-".concat(n,"-overlay__loading")),t.state.error&&a.classList.add("meta-".concat(n,"-overlay__error")),o.append(a);var i=document.createElement("div");i.classList.add("meta-content"),a.append(i);var s=document.createElement("button");if(s.classList.add("meta-nav","meta-close","a"),s.innerHTML=' Close',s.addEventListener("click",(function(e){e.preventDefault(),t.hide()})),i.append(s),r){var c=r.getAttribute("data-gallery");if(c&&t.state.collections[c].length>1){var u=document.createElement("nav");u.classList.add("meta-navs");var f=document.createElement("button");f.classList.add("meta-nav","meta-nav-arrow","meta-nav-arrow__prev","a"),f.innerHTML=' Previous',f.addEventListener("click",(function(e){e.preventDefault(),t.prev()})),u.append(f);var l=document.createElement("button");l.classList.add("meta-nav","meta-nav-arrow","meta-nav-arrow__next","a"),l.innerHTML=' Next',l.addEventListener("click",(function(e){e.preventDefault(),t.next()})),u.append(l),i.append(u)}}var d=document.createElement("section");if(d.classList.add("meta-wrap","typography"),d.innerHTML=t.getHtml(),i.append(d),t.state.error){var p=document.createElement("div");p.classList.add("meta-error"),p.innerHTML=t.state.error,i.append(p)}else if(t.state.caption){var h=document.createElement("div");h.classList.add("meta-caption"),h.innerHTML=t.getCaption(),i.append(h)}return t}}]),MetaWindow}(),a=document.getElementById("MetaLightboxApp");a||console.log("MetaWindow: missing container");var i=new o({target:a}),s=function init(){i.init()};window.addEventListener("".concat(t),s),window.addEventListener("".concat(e),s),window.addEventListener("MetaWindow.initLinks",s),window.MetaWindow=i;(function importAll(e){return e.keys().map(e)})(__webpack_require__(310))}()}(); \ No newline at end of file diff --git a/dist/records.json b/dist/records.json index 7de266c..10319fd 100644 --- a/dist/records.json +++ b/dist/records.json @@ -37,6 +37,60 @@ 143 ] }, + "mini-css-extract-plugin /mnt/data/srv/dist/repositories/meta-lightbox/node_modules/.pnpm/css-loader@6.2.0_webpack@5.49.0/node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[1].use[1]!./node_modules/.pnpm/resolve-url-loader@4.0.0/node_modules/resolve-url-loader/index.js!./node_modules/.pnpm/sass-loader@12.1.0_sass@1.37.5+webpack@5.49.0/node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[1].use[3]!./src/scss/app.scss": [ + { + "chunks": { + "byName": { + "child": 396 + }, + "bySource": { + "0 child": 396 + }, + "usedIds": [ + 396 + ] + }, + "modules": { + "byIdentifier": { + "./node_modules/.pnpm/babel-loader@8.2.2_f592160bef312780fac49010cef16c44/node_modules/babel-loader/lib/index.js??ruleSet[1].rules[0].use!./node_modules/.pnpm/css-loader@6.2.0_webpack@5.49.0/node_modules/css-loader/dist/runtime/api.js": 973, + "./node_modules/.pnpm/babel-loader@8.2.2_f592160bef312780fac49010cef16c44/node_modules/babel-loader/lib/index.js??ruleSet[1].rules[0].use!./node_modules/.pnpm/css-loader@6.2.0_webpack@5.49.0/node_modules/css-loader/dist/runtime/cssWithMappingToString.js": 763, + "./node_modules/.pnpm/css-loader@6.2.0_webpack@5.49.0/node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[1].use[1]!./node_modules/.pnpm/resolve-url-loader@4.0.0/node_modules/resolve-url-loader/index.js!./node_modules/.pnpm/sass-loader@12.1.0_sass@1.37.5+webpack@5.49.0/node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[1].use[3]!./src/scss/app.scss": 233 + }, + "usedIds": [ + 233, + 763, + 973 + ] + } + } + ], + "mini-css-extract-plugin /mnt/data/srv/dist/repositories/meta-lightbox/node_modules/.pnpm/css-loader@6.2.0_webpack@5.49.0/node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[1].use[1]!./node_modules/.pnpm/resolve-url-loader@4.0.0/node_modules/resolve-url-loader/index.js!./node_modules/.pnpm/sass-loader@12.1.0_sass@1.37.5+webpack@5.49.0/node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[1].use[3]!./src/scss/test-build.scss": [ + { + "chunks": { + "byName": { + "child": 396 + }, + "bySource": { + "0 child": 396 + }, + "usedIds": [ + 396 + ] + }, + "modules": { + "byIdentifier": { + "./node_modules/.pnpm/babel-loader@8.2.2_f592160bef312780fac49010cef16c44/node_modules/babel-loader/lib/index.js??ruleSet[1].rules[0].use!./node_modules/.pnpm/css-loader@6.2.0_webpack@5.49.0/node_modules/css-loader/dist/runtime/api.js": 973, + "./node_modules/.pnpm/babel-loader@8.2.2_f592160bef312780fac49010cef16c44/node_modules/babel-loader/lib/index.js??ruleSet[1].rules[0].use!./node_modules/.pnpm/css-loader@6.2.0_webpack@5.49.0/node_modules/css-loader/dist/runtime/cssWithMappingToString.js": 763, + "./node_modules/.pnpm/css-loader@6.2.0_webpack@5.49.0/node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[1].use[1]!./node_modules/.pnpm/resolve-url-loader@4.0.0/node_modules/resolve-url-loader/index.js!./node_modules/.pnpm/sass-loader@12.1.0_sass@1.37.5+webpack@5.49.0/node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[1].use[3]!./src/scss/test-build.scss": 842 + }, + "usedIds": [ + 763, + 842, + 973 + ] + } + } + ], "modules": { "byIdentifier": { "./node_modules/.pnpm/babel-loader@8.2.2_f592160bef312780fac49010cef16c44/node_modules/babel-loader/lib/index.js??ruleSet[1].rules[0].use!./node_modules/.pnpm/axios@0.21.1_debug@4.3.2/node_modules/axios/index.js": 885, @@ -68,9 +122,6 @@ "./node_modules/.pnpm/babel-loader@8.2.2_f592160bef312780fac49010cef16c44/node_modules/babel-loader/lib/index.js??ruleSet[1].rules[0].use!./node_modules/.pnpm/axios@0.21.1_debug@4.3.2/node_modules/axios/lib/utils.js": 750, "./node_modules/.pnpm/babel-loader@8.2.2_f592160bef312780fac49010cef16c44/node_modules/babel-loader/lib/index.js??ruleSet[1].rules[0].use!./node_modules/.pnpm/youtube-embed@1.0.0/node_modules/youtube-embed/index.js": 136, "./node_modules/.pnpm/babel-loader@8.2.2_f592160bef312780fac49010cef16c44/node_modules/babel-loader/lib/index.js??ruleSet[1].rules[0].use!./src/js/test-build.js|25da35e13a35fb5ddc981181ead45562": 848, - "./node_modules/.pnpm/img-optimize-loader@1.0.7_file-loader@6.2.0+webpack@5.49.0/node_modules/img-optimize-loader/dist/index.js??ruleSet[1].rules[4].use[0]!./src/img/photo1.png": 966, - "./node_modules/.pnpm/img-optimize-loader@1.0.7_file-loader@6.2.0+webpack@5.49.0/node_modules/img-optimize-loader/dist/index.js??ruleSet[1].rules[4].use[0]!./src/img/photo2.jpg": 731, - "./node_modules/.pnpm/img-optimize-loader@1.0.7_file-loader@6.2.0+webpack@5.49.0/node_modules/img-optimize-loader/dist/index.js??ruleSet[1].rules[4].use[0]!./src/img/photo3.svg": 887, "./src/img|sync|nonrecursive|../../../../../../\\.(png|jpe?g|svg)$/": 310 }, "usedIds": [ @@ -88,7 +139,6 @@ 567, 589, 642, - 731, 748, 750, 804, @@ -103,9 +153,7 @@ 868, 882, 885, - 887, 936, - 966, 999 ] } diff --git a/dist/report.html b/dist/report.html index 189a7ee..9d6868f 100644 --- a/dist/report.html +++ b/dist/report.html @@ -3,7 +3,7 @@ - @a2nt/meta-lightbox-js [10 Aug 2021 at 02:08] + @a2nt/meta-lightbox-js [11 Aug 2021 at 18:56] diff --git a/package.json b/package.json index 2048f81..5b1bb8f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@a2nt/meta-lightbox-js", - "version": "4.0.6", + "version": "4.0.7", "description": "Universal lightbox", "author": "Tony Air ", "license": "BSD-2-Clause", diff --git a/src/js/app.js b/src/js/app.js index 684730d..aec1208 100755 --- a/src/js/app.js +++ b/src/js/app.js @@ -9,16 +9,16 @@ import MetaWindow from './window'; const container = document.getElementById('MetaLightboxApp'); if (!container) { - console.log(`MetaWindow: missing container`); + console.log(`MetaWindow: missing container`); } const ui = new MetaWindow({ - target: container, + target: container, }); const init = () => { - ui.init(); + ui.init(); }; window.addEventListener(`${Events.LOADED}`, init); diff --git a/src/js/window.js b/src/js/window.js index ad626ee..87c8d97 100755 --- a/src/js/window.js +++ b/src/js/window.js @@ -9,431 +9,431 @@ const axios = require('axios'); class MetaWindow { state = { + content: '', + type: ['empty'], + shown: false, + loading: false, + error: false, + embed: false, + collections: [], + current: null, + target: null, + }; + + init() { + const ui = this; + console.log(`MetaWindow: [links] init`); + + // collect new collections + document.querySelectorAll('[data-toggle="lightbox"],[data-gallery="${gallery}"]').forEach((el) => { + const gallery = el.getAttribute('data-gallery'); + if (gallery) { + ui.state.collections[gallery] = []; + document + .querySelectorAll( + `[data-toggle="lightbox"][data-gallery="${gallery}"]`, + ) + .forEach((el) => { + ui.state.collections[gallery].push(el); + }); + } + + // click handler + el.addEventListener('click', (e) => { + e.preventDefault(); + console.log(`MetaWindow: [link] click`); + + const el = e.currentTarget; + const link = + el.getAttribute('href') || el.getAttribute('data-href'); + const embed = el.getAttribute('data-embed'); + ui.state.current = el; + + if (embed) { + ui.embed(link); + } else { + ui.load(link); + } + + const title = el.getAttribute('data-title'); + if (title) { + ui.setCaption(title); + } + }); + }); + } + + constructor(state = { + shown: false, + }, action) { + const ui = this; + + ui.name = ui.constructor.name; + console.log(`${ui.name}: init`); + ui.axios = axios; + + ui.setState(state); + switch (action) { + case 'show': + ui.hide(); + break; + case 'hide': + ui.hide(); + break; + } + + W.dispatchEvent(new Event(`{ui.name}.init`)); + } + + show = () => { + const ui = this; + console.log(`${ui.name}: show`); + + ui.setState({ + shown: true, + }); + W.dispatchEvent(new Event(`{ui.name}.show`)); + }; + + hide = () => { + const ui = this; + + console.log(`${ui.name}: hide`); + ui.setState({ + shown: false, + }); + W.dispatchEvent(new Event(`{ui.name}.hide`)); + }; + + next = () => { + const ui = this; + const el = ui.state.current; + const gallery = el.getAttribute('data-gallery'); + + let i = ui._currIndex(); + if (i < ui.state.collections[gallery].length - 1) { + i++; + } else { + i = 0; + } + + ui.state.collections[gallery][i].click(); + + console.log(`${ui.name}: next`); + W.dispatchEvent(new Event(`{ui.name}.next`)); + }; + + prev = () => { + const ui = this; + const el = ui.state.current; + const gallery = el.getAttribute('data-gallery'); + + let i = ui._currIndex(); + if (i > 0) { + i--; + } else { + i = ui.state.collections[gallery].length - 1; + } + + ui.state.collections[gallery][i].click(); + + console.log(`${ui.name}: prev`); + W.dispatchEvent(new Event(`{ui.name}.prev`)); + }; + + reset = () => { + const ui = this; + + ui.setState({ content: '', type: ['empty'], shown: false, loading: false, error: false, embed: false, - collections: [], - current: null, - target: null, - }; - - init() { - const ui = this; - console.log(`MetaWindow: [links] init`); - - // collect new collections - document.querySelectorAll('[data-toggle="lightbox"],[data-gallery="${gallery}"]').forEach((el) => { - const gallery = el.getAttribute('data-gallery'); - if (gallery) { - ui.state.collections[gallery] = []; - document - .querySelectorAll( - `[data-toggle="lightbox"][data-gallery="${gallery}"]`, - ) - .forEach((el) => { - ui.state.collections[gallery].push(el); - }); - } - - // click handler - el.addEventListener('click', (e) => { - e.preventDefault(); - console.log(`MetaWindow: [link] click`); - - const el = e.currentTarget; - const link = - el.getAttribute('href') || el.getAttribute('data-href'); - const embed = el.getAttribute('data-embed'); - ui.state.current = el; - - if (embed) { - ui.embed(link); - } else { - ui.load(link); - } - - const title = el.getAttribute('data-title'); - if (title) { - ui.setCaption(title); - } - }); - }); - } - - constructor(state = { - shown: false, - }, action) { - const ui = this; - - ui.name = ui.constructor.name; - console.log(`${ui.name}: init`); - ui.axios = axios; - - ui.setState(state); - switch (action) { - case 'show': - ui.hide(); - break; - case 'hide': - ui.hide(); - break; - } - - W.dispatchEvent(new Event(`{ui.name}.init`)); - } - - show = () => { - const ui = this; - console.log(`${ui.name}: show`); - - ui.setState({ - shown: true, - }); - W.dispatchEvent(new Event(`{ui.name}.show`)); - }; - - hide = () => { - const ui = this; - - console.log(`${ui.name}: hide`); - ui.setState({ - shown: false, - }); - W.dispatchEvent(new Event(`{ui.name}.hide`)); - }; - - next = () => { - const ui = this; - const el = ui.state.current; - const gallery = el.getAttribute('data-gallery'); - - let i = ui._currIndex(); - if (i < ui.state.collections[gallery].length - 1) { - i++; - } else { - i = 0; - } - - ui.state.collections[gallery][i].click(); - - console.log(`${ui.name}: next`); - W.dispatchEvent(new Event(`{ui.name}.next`)); - }; - - prev = () => { - const ui = this; - const el = ui.state.current; - const gallery = el.getAttribute('data-gallery'); - - let i = ui._currIndex(); - if (i > 0) { - i--; - } else { - i = ui.state.collections[gallery].length - 1; - } - - ui.state.collections[gallery][i].click(); - - console.log(`${ui.name}: prev`); - W.dispatchEvent(new Event(`{ui.name}.prev`)); - }; - - reset = () => { - const ui = this; - - ui.setState({ - content: '', - type: ['empty'], - shown: false, - loading: false, - error: false, - embed: false, - //collections: [], - //current: null, - //target: null, - }); + //collections: [], + //current: null, + //target: null, + }); }; load = (link) => { - const ui = this; - const axios = ui.axios; + const ui = this; + const axios = ui.axios; - ui.reset(); - ui.setState({ - loading: true, + ui.reset(); + ui.setState({ + loading: true, + }); + ui.show(); + + axios + .get(link, { + responseType: 'arraybuffer', + }) + .then((resp) => { + // handle success + console.log( + `${ui.name}: response content-type: ${resp.headers['content-type']}`, + ); + const json = false; + + switch (resp.headers['content-type']) { + case 'image/jpeg': + case 'image/png': + case 'image/svg+xml': + case 'image/bmp': + case 'image/gif': + case 'image/tiff': + case 'image/webp': + // irregular types: + case 'image/jpg': + case 'image/svg': + //json = JSON.parse(ui._abToString(resp.data)); + ui.setContent( + ``, + 'image', + ); + break; + case 'application/json': + case 'application/ld+json': + // irregular types: + case 'application/json; charset=UTF-8': + ui.setContent(`${json['Content']}`, 'text html json'); + + break; + case 'text/html': + case 'application/xhtml+xml': + case 'text/plain': + // irregular types: + case 'text/html; charset=UTF-8': + case 'application/xhtml+xml; charset=UTF-8': + case 'text/plain; charset=UTF-8': + ui.setContent( + ui._abToString(resp.data), + 'text html pajax', + ); + break; + default: + console.warn( + `${ui.name}: Unknown response content-type!`, + ); + break; + } + + W.dispatchEvent(new Event(`{ui.name}.loaded`)); + }) + .catch((error) => { + console.error(error); + + let msg = ''; + + if (error.response) { + switch (error.response.status) { + case 404: + msg = 'Not Found.'; + break; + case 500: + msg = 'Server issue, please try again latter.'; + break; + default: + msg = 'Something went wrong.'; + break; + } + } else if (error.request) { + msg = 'No response received'; + } else { + console.warn('Error', error.message); + } + + ui.setState({ + error: msg, + }); + + W.dispatchEvent(new Event(`{ui.name}.error`)); + }) + .then(() => { + ui.setState({ + loading: false, + }); }); - ui.show(); - - axios - .get(link, { - responseType: 'arraybuffer', - }) - .then((resp) => { - // handle success - console.log( - `${ui.name}: response content-type: ${resp.headers['content-type']}`, - ); - const json = false; - - switch (resp.headers['content-type']) { - case 'image/jpeg': - case 'image/png': - case 'image/svg+xml': - case 'image/bmp': - case 'image/gif': - case 'image/tiff': - case 'image/webp': - // irregular types: - case 'image/jpg': - case 'image/svg': - //json = JSON.parse(ui._abToString(resp.data)); - ui.setContent( - ``, - 'image', - ); - break; - case 'application/json': - case 'application/ld+json': - // irregular types: - case 'application/json; charset=UTF-8': - ui.setContent(`${json['Content']}`, 'text html json'); - - break; - case 'text/html': - case 'application/xhtml+xml': - case 'text/plain': - // irregular types: - case 'text/html; charset=UTF-8': - case 'application/xhtml+xml; charset=UTF-8': - case 'text/plain; charset=UTF-8': - ui.setContent( - ui._abToString(resp.data), - 'text html pajax', - ); - break; - default: - console.warn( - `${ui.name}: Unknown response content-type!`, - ); - break; - } - - W.dispatchEvent(new Event(`{ui.name}.loaded`)); - }) - .catch((error) => { - console.error(error); - - let msg = ''; - - if (error.response) { - switch (error.response.status) { - case 404: - msg = 'Not Found.'; - break; - case 500: - msg = 'Server issue, please try again latter.'; - break; - default: - msg = 'Something went wrong.'; - break; - } - } else if (error.request) { - msg = 'No response received'; - } else { - console.warn('Error', error.message); - } - - ui.setState({ - error: msg, - }); - - W.dispatchEvent(new Event(`{ui.name}.error`)); - }) - .then(() => { - ui.setState({ - loading: false, - }); - }); }; _currIndex = () => { - const ui = this; - const el = ui.state.current; - const gallery = el.getAttribute('data-gallery'); + const ui = this; + const el = ui.state.current; + const gallery = el.getAttribute('data-gallery'); - return ui.state.collections[gallery].indexOf(el); + return ui.state.collections[gallery].indexOf(el); }; embed = (link) => { - const ui = this; - console.log(`${ui.name}: embed`); + const ui = this; + console.log(`${ui.name}: embed`); - ui.reset(); - ui.setState({ - embed: link, - loading: false, - type: [`meta-${ui.name}__embed`, `meta-${ui.name}__video`], - }); + ui.reset(); + ui.setState({ + embed: link, + loading: false, + type: [`meta-${ui.name}__embed`, `meta-${ui.name}__video`], + }); - ui.show(); + ui.show(); }; setCaption = (title) => { - const ui = this; - console.log(`${ui.name}: setCaption`); + const ui = this; + console.log(`${ui.name}: setCaption`); - ui.state.caption = title; + ui.state.caption = title; }; getCaption = () => { - const ui = this; - return ui.state.caption; + const ui = this; + return ui.state.caption; } _abToString = (arrayBuffer) => { - return String.fromCharCode.apply(null, new Uint8Array(arrayBuffer)); + return String.fromCharCode.apply(null, new Uint8Array(arrayBuffer)); }; _imageEncode = (arrayBuffer) => { - const u8 = new Uint8Array(arrayBuffer); - const b64encoded = btoa( - [].reduce.call( - new Uint8Array(arrayBuffer), - (p, c) => { - return p + String.fromCharCode(c); - }, - '', - ), - ); + const u8 = new Uint8Array(arrayBuffer); + const b64encoded = btoa( + [].reduce.call( + new Uint8Array(arrayBuffer), + (p, c) => { + return p + String.fromCharCode(c); + }, + '', + ), + ); - return b64encoded; + return b64encoded; }; setContent = (html, type) => { - const ui = this; - console.log(`${ui.name}: setContent`); + const ui = this; + console.log(`${ui.name}: setContent`); - let typeArr = type ? type : ['html', 'text']; - if (!Array.isArray(typeArr)) { - typeArr = type.split(' '); - } + let typeArr = type ? type : ['html', 'text']; + if (!Array.isArray(typeArr)) { + typeArr = type.split(' '); + } - ui.setState({ - content: html, - type: typeArr, - }); + ui.setState({ + content: html, + type: typeArr, + }); }; getHtml = () => { - const ui = this; + const ui = this; - if (ui.state.embed) { - const youtubeEmbed = require('youtube-embed'); - const embedLink = youtubeEmbed(ui.state.embed); - ui.state.content = ``; - } + if (ui.state.embed) { + const youtubeEmbed = require('youtube-embed'); + const embedLink = youtubeEmbed(ui.state.embed); + ui.state.content = ``; + } - return ui.state.content; + return ui.state.content; }; setState(state) { - const ui = this; - ui.state = Object.assign({}, ui.state, state); - ui.render(); + const ui = this; + ui.state = Object.assign({}, ui.state, state); + ui.render(); } render() { - const ui = this; - const name = ui.name; + const ui = this; + const name = ui.name; - const navs = null; - const el = ui.state.current; + const navs = null; + const el = ui.state.current; - ui.state.target.innerHTML = ''; - const meta = document.createElement('div'); - meta.classList.add(`meta-${name}`); - meta.classList.add(...ui.state.type); - ui.state.target.append(meta); + ui.state.target.innerHTML = ''; + const meta = document.createElement('div'); + meta.classList.add(`meta-${name}`); + meta.classList.add(...ui.state.type); + ui.state.target.append(meta); - const metaOverlay = document.createElement('div'); - metaOverlay.classList.add(`meta-${name}-overlay`); - if (ui.state.shown) { - metaOverlay.classList.add(`meta-${name}-overlay__open`); - } - if (ui.state.loading) { - metaOverlay.classList.add(`meta-${name}-overlay__loading`); - } - if (ui.state.error) { - metaOverlay.classList.add(`meta-${name}-overlay__error`); - } - meta.append(metaOverlay); + const metaOverlay = document.createElement('div'); + metaOverlay.classList.add(`meta-${name}-overlay`); + if (ui.state.shown) { + metaOverlay.classList.add(`meta-${name}-overlay__open`); + } + if (ui.state.loading) { + metaOverlay.classList.add(`meta-${name}-overlay__loading`); + } + if (ui.state.error) { + metaOverlay.classList.add(`meta-${name}-overlay__error`); + } + meta.append(metaOverlay); - const metaContent = document.createElement('div'); - metaContent.classList.add('meta-content'); - metaOverlay.append(metaContent); + const metaContent = document.createElement('div'); + metaContent.classList.add('meta-content'); + metaOverlay.append(metaContent); - const btnClose = document.createElement('button'); - btnClose.classList.add('meta-nav', 'meta-close', 'a'); - btnClose.innerHTML = + const btnClose = document.createElement('button'); + btnClose.classList.add('meta-nav', 'meta-close', 'a'); + btnClose.innerHTML = '' + ' Close'; - btnClose.addEventListener('click', (e) => { - e.preventDefault(); - ui.hide(); - }); - metaContent.append(btnClose); + btnClose.addEventListener('click', (e) => { + e.preventDefault(); + ui.hide(); + }); + metaContent.append(btnClose); - if (el) { - const gallery = el.getAttribute('data-gallery'); - if (gallery && ui.state.collections[gallery].length > 1) { - const navs = document.createElement('nav'); - navs.classList.add('meta-navs'); + if (el) { + const gallery = el.getAttribute('data-gallery'); + if (gallery && ui.state.collections[gallery].length > 1) { + const navs = document.createElement('nav'); + navs.classList.add('meta-navs'); - const prevBtn = document.createElement('button'); - prevBtn.classList.add('meta-nav', 'meta-nav-arrow', 'meta-nav-arrow__prev', 'a'); - prevBtn.innerHTML = '' + + const prevBtn = document.createElement('button'); + prevBtn.classList.add('meta-nav', 'meta-nav-arrow', 'meta-nav-arrow__prev', 'a'); + prevBtn.innerHTML = '' + ' Previous'; - prevBtn.addEventListener('click', (e) => { - e.preventDefault(); - ui.prev(); - }); - navs.append(prevBtn); + prevBtn.addEventListener('click', (e) => { + e.preventDefault(); + ui.prev(); + }); + navs.append(prevBtn); - const nextBtn = document.createElement('button'); - nextBtn.classList.add('meta-nav', 'meta-nav-arrow', 'meta-nav-arrow__next', 'a'); - nextBtn.innerHTML = '' + + const nextBtn = document.createElement('button'); + nextBtn.classList.add('meta-nav', 'meta-nav-arrow', 'meta-nav-arrow__next', 'a'); + nextBtn.innerHTML = '' + ' Next'; - nextBtn.addEventListener('click', (e) => { - e.preventDefault(); - ui.next(); - }); - navs.append(nextBtn); + nextBtn.addEventListener('click', (e) => { + e.preventDefault(); + ui.next(); + }); + navs.append(nextBtn); - metaContent.append(navs); - } + metaContent.append(navs); } + } - const content = document.createElement('section'); - content.classList.add('meta-wrap', 'typography'); - content.innerHTML = ui.getHtml(); - metaContent.append(content); + const content = document.createElement('section'); + content.classList.add('meta-wrap', 'typography'); + content.innerHTML = ui.getHtml(); + metaContent.append(content); - if (ui.state.error) { - const error = document.createElement('div'); - error.classList.add('meta-error'); - error.innerHTML = ui.state.error; - metaContent.append(error); - } else if (ui.state.caption) { - const caption = document.createElement('div'); - caption.classList.add('meta-caption'); - caption.innerHTML = ui.getCaption(); - metaContent.append(caption); - } + if (ui.state.error) { + const error = document.createElement('div'); + error.classList.add('meta-error'); + error.innerHTML = ui.state.error; + metaContent.append(error); + } else if (ui.state.caption) { + const caption = document.createElement('div'); + caption.classList.add('meta-caption'); + caption.innerHTML = ui.getCaption(); + metaContent.append(caption); + } - return ui; + return ui; } } diff --git a/webpack.config.common.js b/webpack.config.common.js index 6279e99..3b31dfb 100755 --- a/webpack.config.common.js +++ b/webpack.config.common.js @@ -2,6 +2,7 @@ * Common Environment */ +const INDEX_NAME = 'test-build'; const YML_PATH = './webpack.yml'; const CONF_VAR = 'App\\Templates\\WebpackTemplateProvider'; @@ -9,6 +10,7 @@ const path = require('path'); const fs = require('fs'); const yaml = require('js-yaml'); const webpack = require('webpack'); +const MiniCssExtractPlugin = require('mini-css-extract-plugin'); /* * Load webpack configuration from webpack.yml @@ -19,6 +21,18 @@ const yml = yaml.load( ); const conf = yml[CONF_VAR] +const UIInfo = require('./package.json'); +const UIVERSION = JSON.stringify(UIInfo.version); +const UIMetaInfo = require('./package.json'); +const NODE_ENV = process.env.NODE_ENV; +const COMPRESS = NODE_ENV === 'production' ? true : false; + +console.log('NODE_ENV: ' + NODE_ENV); +console.log('COMPRESS: ' + COMPRESS); +console.log('WebP images: ' + conf['webp']); +console.log('GRAPHQL_API_KEY: ' + conf['GRAPHQL_API_KEY']); +console.log('HTTPS: ' + conf['HTTPS']); + let themes = []; // add themes if (conf.THEMESDIR) { @@ -57,16 +71,16 @@ const _addAppFiles = (theme) => { themeName = 'app'; } - if (fs.existsSync(path.join(dirPath, conf.SRC, 'js', 'test-build.js'))) { - includes[`${themeName}`] = path.join(dirPath, conf.SRC, 'js', 'test-build.js'); + if (fs.existsSync(path.join(dirPath, conf.SRC, 'js', INDEX_NAME + '.js'))) { + includes[`${themeName}`] = path.join(dirPath, conf.SRC, 'js', INDEX_NAME + '.js'); } else if ( - fs.existsSync(path.join(dirPath, conf.SRC, 'scss', 'app.scss')) + fs.existsSync(path.join(dirPath, conf.SRC, 'scss', INDEX_NAME + '.scss')) ) { includes[`${themeName}`] = path.join( dirPath, conf.SRC, 'scss', - 'app.scss', + INDEX_NAME + '.scss', ); } @@ -159,5 +173,46 @@ module.exports = { experiments: { topLevelAwait: true, }, - } + }, + plugins: [ + new webpack.ProvidePlugin({ + react: 'React', + 'react-dom': 'ReactDOM', + /*$: 'jquery', + jQuery: 'jquery', + Popper: ['popper.js', 'default'], + Util: 'exports-loader?Util!bootstrap/js/dist/util', + Alert: 'exports-loader?Alert!bootstrap/js/dist/alert', + Button: 'exports-loader?Button!bootstrap/js/dist/button', + Carousel: 'exports-loader?Carousel!bootstrap/js/dist/carousel', + Collapse: 'exports-loader?Collapse!bootstrap/js/dist/collapse', + Dropdown: 'exports-loader?Dropdown!bootstrap/js/dist/dropdown', + Modal: 'exports-loader?Modal!bootstrap/js/dist/modal', + Tooltip: 'exports-loader?Tooltip!bootstrap/js/dist/tooltip', + Popover: 'exports-loader?Popover!bootstrap/js/dist/popover', + Scrollspy: 'exports-loader?Scrollspy!bootstrap/js/dist/scrollspy', + Tab: 'exports-loader?Tab!bootstrap/js/dist/tab',*/ + }), + new webpack.DefinePlugin({ + 'process.env': { + NODE_ENV: JSON.stringify(NODE_ENV), + }, + UINAME: JSON.stringify(UIInfo.name), + UIVERSION: UIVERSION, + UIAUTHOR: JSON.stringify(UIInfo.author), + UIMetaNAME: JSON.stringify(UIMetaInfo.name), + UIMetaVersion: JSON.stringify(UIMetaInfo.version), + GRAPHQL_API_KEY: JSON.stringify(conf['GRAPHQL_API_KEY']), + SWVERSION: JSON.stringify(`sw-${new Date().getTime()}`), + BASE_HREF: JSON.stringify(''), + }), + new webpack.LoaderOptionsPlugin({ + minimize: COMPRESS, + debug: !COMPRESS, + }), + new MiniCssExtractPlugin({ + filename: 'css/[name].css', + //allChunks: true, + }), + ] }; diff --git a/webpack.config.js b/webpack.config.js index 2f4a6df..b779068 100755 --- a/webpack.config.js +++ b/webpack.config.js @@ -21,63 +21,13 @@ const MiniCssExtractPlugin = require('mini-css-extract-plugin'); //const ImageSpritePlugin = require('@a2nt/image-sprite-webpack-plugin'); const HtmlWebpackPlugin = require('html-webpack-plugin'); - -const UIInfo = require('./package.json'); -const UIVERSION = JSON.stringify(UIInfo.version); -const UIMetaInfo = require('./package.json'); - const NODE_ENV = conf.NODE_ENV || process.env.NODE_ENV; const COMPRESS = NODE_ENV === 'production' ? true : false; const IP = process.env.IP || conf.HOSTNAME; const PORT = process.env.PORT || conf.PORT; -console.log('NODE_ENV: ' + NODE_ENV); -console.log('COMPRESS: ' + COMPRESS); -console.log('WebP images: ' + conf['webp']); -console.log('GRAPHQL_API_KEY: ' + conf['GRAPHQL_API_KEY']); - -let plugins = [ - new webpack.ProvidePlugin({ - react: 'React', - 'react-dom': 'ReactDOM', - /*$: 'jquery', - jQuery: 'jquery', - Popper: ['popper.js', 'default'], - Util: 'exports-loader?Util!bootstrap/js/dist/util', - Alert: 'exports-loader?Alert!bootstrap/js/dist/alert', - Button: 'exports-loader?Button!bootstrap/js/dist/button', - Carousel: 'exports-loader?Carousel!bootstrap/js/dist/carousel', - Collapse: 'exports-loader?Collapse!bootstrap/js/dist/collapse', - Dropdown: 'exports-loader?Dropdown!bootstrap/js/dist/dropdown', - Modal: 'exports-loader?Modal!bootstrap/js/dist/modal', - Tooltip: 'exports-loader?Tooltip!bootstrap/js/dist/tooltip', - Popover: 'exports-loader?Popover!bootstrap/js/dist/popover', - Scrollspy: 'exports-loader?Scrollspy!bootstrap/js/dist/scrollspy', - Tab: 'exports-loader?Tab!bootstrap/js/dist/tab',*/ - }), - new webpack.DefinePlugin({ - 'process.env': { - NODE_ENV: JSON.stringify(NODE_ENV), - }, - UINAME: JSON.stringify(UIInfo.name), - UIVERSION: UIVERSION, - UIAUTHOR: JSON.stringify(UIInfo.author), - UIMetaNAME: JSON.stringify(UIMetaInfo.name), - UIMetaVersion: JSON.stringify(UIMetaInfo.version), - GRAPHQL_API_KEY: JSON.stringify(conf['GRAPHQL_API_KEY']), - SWVERSION: JSON.stringify(`sw-${new Date().getTime()}`), - BASE_HREF: JSON.stringify(''), - }), - new webpack.LoaderOptionsPlugin({ - minimize: COMPRESS, - debug: !COMPRESS, - }), - new MiniCssExtractPlugin({ - filename: 'css/[name].css', - //allChunks: true, - }), -]; +let plugins = common.plugins; if (COMPRESS) { plugins.push(require('autoprefixer')); @@ -315,7 +265,7 @@ const cfg = merge(common.webpack, { { loader: 'css-loader', options: { - sourceMap: !COMPRESS, + sourceMap: true, }, }, { @@ -324,7 +274,7 @@ const cfg = merge(common.webpack, { { loader: 'sass-loader', options: { - sourceMap: !COMPRESS, + sourceMap: true, }, }, ], }, diff --git a/webpack.config.serve.js b/webpack.config.serve.js index 4e0f591..905ec6d 100755 --- a/webpack.config.serve.js +++ b/webpack.config.serve.js @@ -19,41 +19,7 @@ const HtmlWebpackPlugin = require('html-webpack-plugin'); const IP = process.env.IP || conf.HOSTNAME; const PORT = process.env.PORT || conf.PORT; -const UIInfo = require('./package.json'); -const UIVERSION = JSON.stringify(UIInfo.version); -const UIMetaInfo = require('./package.json'); - -const NODE_ENV = 'development'; //conf.NODE_ENV || process.env.NODE_ENV; -const COMPRESS = NODE_ENV === 'production' ? true : false; - -console.log('NODE_ENV: ' + NODE_ENV); -console.log('COMPRESS: ' + COMPRESS); -console.log('WebP images: ' + conf['webp']); -console.log('GRAPHQL_API_KEY: ' + conf['GRAPHQL_API_KEY']); -console.log('HTTPS: ' + conf['HTTPS']); - -const plugins = [ - new webpack.ProvidePlugin({ - react: 'React', - 'react-dom': 'ReactDOM', - /*$: 'jquery', - jQuery: 'jquery',*/ - }), - new webpack.DefinePlugin({ - UINAME: JSON.stringify(UIInfo.name), - UIVERSION: UIVERSION, - UIAUTHOR: JSON.stringify(UIInfo.author), - UIMetaNAME: JSON.stringify(UIMetaInfo.name), - UIMetaVersion: JSON.stringify(UIMetaInfo.version), - GRAPHQL_API_KEY: JSON.stringify(conf['GRAPHQL_API_KEY']), - SWVERSION: JSON.stringify(`sw-${new Date().getTime()}`), - BASE_HREF: JSON.stringify( - `http${conf['HTTPS'] ? 's' : ''}://${IP}:${PORT}`, - ), - }), - //new webpack.HotModuleReplacementPlugin(), - new MiniCssExtractPlugin(), -]; +let plugins = common.plugins; const indexPath = path.join(__dirname, conf.APPDIR, conf.SRC, 'index.html'); if (fs.existsSync(indexPath)) { @@ -62,19 +28,16 @@ if (fs.existsSync(indexPath)) { publicPath: '', template: path.join(conf.APPDIR, conf.SRC, 'index.html'), templateParameters: { - NODE_ENV: NODE_ENV, + NODE_ENV: 'development', GRAPHQL_URL: conf['GRAPHQL_URL'], STATIC_URL: conf['STATIC_URL'], - REACT_SCRIPTS: NODE_ENV === 'production' ? - '' : '', + REACT_SCRIPTS: '', }, }), ); } const config = merge(common.webpack, { - mode: 'development', - entry: { /*hot: [ 'react-hot-loader/patch', @@ -87,9 +50,7 @@ const config = merge(common.webpack, { path: path.join(__dirname), filename: '[name].js', // necessary for HMR to know where to load the hot update chunks - publicPath: `http${conf['HTTPS'] ? 's' : ''}://${conf['HOSTNAME']}:${ - conf.PORT - }/`, + publicPath: `http${conf['HTTPS'] ? 's' : ''}://${conf['HOSTNAME']}:${conf.PORT}/`, }, module: { @@ -99,7 +60,7 @@ const config = merge(common.webpack, { use: { loader: '@sucrase/webpack-loader', //'babel-loader', options: { - transforms: ['jsx'] + transforms: ['jsx'], /*presets: [ '@babel/preset-env', '@babel/react', @@ -127,7 +88,7 @@ const config = merge(common.webpack, { { loader: 'css-loader', options: { - sourceMap: !COMPRESS, + sourceMap: true, }, }, { @@ -136,7 +97,7 @@ const config = merge(common.webpack, { { loader: 'sass-loader', options: { - sourceMap: false, + sourceMap: true, }, }, ], }, @@ -147,17 +108,22 @@ const config = merge(common.webpack, { { test: /\.(gif|png|jpg|jpeg|ttf|otf|eot|svg|webp|woff(2)?)$/, type: "asset/resource", + }, { + test: /\.(png|webp|jpg|jpeg|gif|svg)$/, + type: "asset/resource", }, ], }, plugins: plugins, + mode: 'development', + devtool: 'inline-source-map', devServer: { host: IP, port: PORT, historyApiFallback: false, static: path.resolve(__dirname, conf['APPDIR'], conf['SRC']), https: conf['HTTPS'], - hot: false, + hot: false, //true, //injectClient: conf['injectClient'], headers: {