nanosplash 2.2.3 → 2.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/.github/workflows/production.yml +57 -0
  2. package/.github/workflows/release.yml +61 -0
  3. package/README.md +17 -14
  4. package/dist/iife/nanosplash.iife.js +1 -1
  5. package/dist/module/Nanosplash.css +1 -0
  6. package/dist/module/manifest.json +6 -3
  7. package/dist/module/nanosplash.cjs.js +1 -1
  8. package/dist/module/nanosplash.es.js +245 -329
  9. package/docs/index.html +54 -430
  10. package/docs/nanosplash.iife.js +1 -1
  11. package/docs/style.css +1 -1
  12. package/docs/typedoc/assets/highlight.css +1 -50
  13. package/docs/typedoc/assets/main.js +2 -2
  14. package/docs/typedoc/assets/search.js +1 -1
  15. package/docs/typedoc/assets/style.css +32 -2
  16. package/docs/typedoc/index.html +1 -1
  17. package/index.html +51 -412
  18. package/jest.config.ts +194 -0
  19. package/package.json +71 -66
  20. package/src/Core/Nanosplash.ts +74 -0
  21. package/src/Core/SplashInstance.ts +154 -0
  22. package/src/Factory/NanosplashFactory.ts +73 -0
  23. package/src/Interfaces/ContextualAPIInterface.ts +8 -0
  24. package/src/Interfaces/IdentityInterface.ts +3 -0
  25. package/src/Interfaces/ImageInterface.ts +5 -0
  26. package/src/Interfaces/InsideInterface.ts +5 -0
  27. package/src/Interfaces/NanosplashInterface.ts +4 -0
  28. package/src/Interfaces/ProgressInterface.ts +5 -0
  29. package/src/Interfaces/ShowInterface.ts +5 -0
  30. package/src/Interfaces/WhileInterface.ts +5 -0
  31. package/src/main.ts +2 -6
  32. package/src/repositories/NanosplashRepository.ts +34 -55
  33. package/src/style.sass +51 -61
  34. package/src/types.d.ts +45 -200
  35. package/src/utilities/dom.spec.ts +70 -0
  36. package/src/utilities/dom.ts +17 -256
  37. package/update-all.sh +3 -0
  38. package/vite.iife.config.js +46 -18
  39. package/vite.mod.config.js +48 -12
  40. package/vite.site.config.js +0 -3
  41. package/dist/module/style.css +0 -1
  42. package/docs/typedoc/classes/Nanosplash.Nanosplash-1.html +0 -56
  43. package/docs/typedoc/classes/types.Nanosplash.html +0 -56
  44. package/docs/typedoc/modules/Nanosplash.html +0 -1
  45. package/docs/typedoc/modules/types.html +0 -1
  46. package/src/Nanosplash.ts +0 -482
  47. package/src/exceptions/Exception.ts +0 -12
  48. package/src/exceptions/IllegalArgumentException.ts +0 -9
  49. package/src/exceptions/InvalidDestinationException.ts +0 -9
  50. package/src/exceptions/MissingResourceException.ts +0 -9
  51. package/update-latest.sh +0 -21
@@ -0,0 +1,57 @@
1
+ name: Production CI
2
+
3
+ on:
4
+ push:
5
+ branches: [production]
6
+ pull_request:
7
+ branches: [production]
8
+
9
+ workflow_dispatch:
10
+
11
+ jobs:
12
+ test:
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - uses: actions/checkout@v2
16
+ - name: Jest (TS) Testing Procedure
17
+ run: |
18
+ yarn install
19
+ yarn test
20
+
21
+ build:
22
+ runs-on: ubuntu-latest
23
+ steps:
24
+ - uses: actions/checkout@v2
25
+ with:
26
+ fetch-depth: 0
27
+
28
+ # Checkout branch
29
+ - name: Checkout
30
+ run: git checkout production
31
+
32
+ - name: Install npm packages
33
+ run: yarn install
34
+
35
+ - name: Transpile Typescript
36
+ run: yarn tsc
37
+
38
+ - name: Build IIFE bundle
39
+ run: yarn vite build -c vite.iife.config.js
40
+
41
+ - name: Build module bundles
42
+ run: yarn vite build -c vite.mod.config.js
43
+
44
+ - name: Build demo site
45
+ run: yarn vite build -c vite.site.config.js
46
+
47
+ - name: Build documentation site
48
+ run: yarn typedoc --readme none --excludePrivate --excludeInternal --out docs/typedoc --entryPoints src/Nanosplash.ts src/types.d.ts
49
+
50
+ # Persist changes and push
51
+ - name: Commit changes and push
52
+ run: |
53
+ git config user.name github-actions
54
+ git config user.email github-actions@github.com
55
+ git add .
56
+ git commit -m "Github Actions CI: Build Project for Production"
57
+ git push
@@ -0,0 +1,61 @@
1
+ name: Release CI
2
+
3
+ on:
4
+ push:
5
+ branches: [release]
6
+ pull_request:
7
+ branches: [release]
8
+
9
+ workflow_dispatch:
10
+
11
+ jobs:
12
+ test:
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - uses: actions/checkout@v2
16
+ - name: Jest (TS) Testing Procedure
17
+ run: |
18
+ yarn install
19
+ yarn test
20
+
21
+ build:
22
+ runs-on: ubuntu-latest
23
+ steps:
24
+ - uses: actions/checkout@v2
25
+
26
+ - name: Install npm packages
27
+ run: yarn install
28
+
29
+ - name: Transpile Typescript
30
+ run: yarn tsc
31
+
32
+ - name: Build IIFE bundle
33
+ run: yarn vite build -c vite.iife.config.js
34
+
35
+ - name: Build module bundles
36
+ run: yarn vite build -c vite.mod.config.js
37
+
38
+ - name: Build demo site
39
+ run: yarn vite build -c vite.site.config.js
40
+
41
+ - name: Build documentation site
42
+ run: yarn typedoc --readme none --excludePrivate --excludeInternal --out docs/typedoc --entryPoints src/Nanosplash.ts src/types.d.ts
43
+
44
+ # Persist changes and push
45
+ - name: Commit changes and push
46
+ run: |
47
+ git config user.name github-actions
48
+ git config user.email github-actions@github.com
49
+ git add .
50
+ git commit -m "Github Actions CI: Build Project for Production"
51
+ git push origin release
52
+
53
+ # Publish to NPM
54
+ publish:
55
+ runs-on: ubuntu-latest
56
+ steps:
57
+ - uses: actions/checkout@v2
58
+ - name: Publish NPM package
59
+ run: npm publish --access public
60
+ env:
61
+ NODE_AUTH_TOKEN: ${{secrets.NPM_AUTOMATION_TOKEN}}
package/README.md CHANGED
@@ -72,7 +72,8 @@ const Nanosplash = require('nanosplash')
72
72
  If you are importing Nanosplash through modules, invoking the `install` function is essential in order to make it react to changes in the browser.
73
73
 
74
74
  ```js
75
- nanosplash.install()
75
+ const ns = new Nanosplash()
76
+ window.ns = ns
76
77
  ```
77
78
 
78
79
  ## Basic usage
@@ -80,13 +81,17 @@ nanosplash.install()
80
81
  ### Display the loading screen
81
82
 
82
83
  ```js
83
- loading.show('Loading the good stuff ...')
84
+ ns.show('Loading the good stuff ...')
84
85
  ```
85
86
 
86
87
  ### Hide the loading screen
87
88
 
88
89
  ```js
89
- loading.hide()
90
+ // Hide one at a time
91
+ ns.hide()
92
+
93
+ // Hide all
94
+ ns.hideAll()
90
95
  ```
91
96
 
92
97
  ## Advanced usage
@@ -95,19 +100,12 @@ loading.hide()
95
100
 
96
101
  ```js
97
102
  // Use CSS selector string
98
- loading.show('Loading component ...').inside('#my-element')
103
+ ns.show('Loading component ...').inside('#my-element')
99
104
 
100
105
  // Use HTMLElement objects directly
101
- loading
106
+ ns
102
107
  .show('Loading component ...')
103
108
  .inside(document.getElementById('my-element'))
104
-
105
- // Use functions returning HTMLElement objects
106
- loading
107
- .show('Loading component ...')
108
- .inside(() =>
109
- Array.from(document.querySelectorAll()).filter((element.id = 'my-element'))
110
- )
111
109
  ```
112
110
 
113
111
  ### Combine Nanosplash with async tasks
@@ -116,8 +114,13 @@ loading
116
114
  const task1 = new Promise(r => setTimeout(() => r(), 3000))
117
115
  const task2 = async () => await getDataFromApi()
118
116
 
119
- loading.show('Loading resources ...').during(task1)
120
- loading.show('Fetching table data ...').inside('#my-table').during(task2)
117
+ ns.while(task1).show('Loading resources ...')
118
+ ns.while(task2).show('Fetching table data ...').inside('#my-table')
119
+
120
+ ns.progress(
121
+ [task1, 'Loading data from API ...'],
122
+ [task2, 'Processing data ...']
123
+ ).inside('#my-table')
121
124
  ```
122
125
 
123
126
  <hr>
@@ -1 +1 @@
1
- var __vite_style__=document.createElement("style");__vite_style__.innerHTML="@-webkit-keyframes pulse{0%{transform:scale(1)}to{transform:scale(1.1)}}@keyframes pulse{0%{transform:scale(1)}to{transform:scale(1.1)}}@-webkit-keyframes spin{0%{transform:rotate(0)}to{transform:rotate(1turn)}}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(1turn)}}.nanosplash-container{align-items:center;border-radius:inherit;flex-direction:column;justify-content:center;overflow:inherit;position:absolute;z-index:1}.nanosplash-container[hidden=true]{display:none}.nanosplash-container:not([hidden=true]){display:flex}.nanosplash-container[data-blur=none]:not([hidden=true])~*{filter:blur(0)}.nanosplash-container[data-blur=light]:not([hidden=true])~*{filter:blur(2px)}.nanosplash-container[data-blur=medium]:not([hidden=true])~*{filter:blur(4px)}.nanosplash-container[data-blur=heavy]:not([hidden=true])~*{filter:blur(10px)}.nanosplash-container .nanosplash-text{text-rendering:optimizeLegibility;-moz-osx-font-smoothing:grayscale;font-smoothing:antialiased;-webkit-font-smoothing:antialiased;text-shadow:0 0 2px rgba(0,0,0,.2)}.nanosplash-container img.nanosplash-img{margin-bottom:40px}.nanosplash-container[data-splash-animation=pulse]>img{-webkit-animation-direction:alternate;animation-direction:alternate;-webkit-animation-duration:.3s;animation-duration:.3s;-webkit-animation-iteration-count:infinite;animation-iteration-count:infinite;-webkit-animation-name:pulse;animation-name:pulse}.nanosplash-container[data-splash-animation=spin]>img{-webkit-animation-duration:.7s;animation-duration:.7s;-webkit-animation-iteration-count:infinite;animation-iteration-count:infinite;-webkit-animation-name:spin;animation-name:spin;-webkit-animation-timing-function:linear;animation-timing-function:linear}body>.nanosplash-container:not([hidden=true]){height:100vh;width:100%}\n",document.head.appendChild(__vite_style__),function(){"use strict";class t extends Error{constructor(t){super(t),this.name=this.constructor.name}t(){return this.constructor.name}}class i extends t{constructor(t){super(t)}}class n extends t{constructor(t){super(t)}}class s extends t{constructor(t){super(t)}}const e=t=>Array.from(document.querySelectorAll(t)),a=(t,i)=>{var n;const s=document.createElement(t);return i&&(s.id||(s.id=i.id+""),s.className||(s.className=i.className+""),null==(n=i.attributes)||n.filter((t=>t.value)).forEach((({key:t,value:i})=>u(s,t,i))),i.content&&("string"==typeof i.content?s.innerText=i.content:s.append(i.content))),s},o=(t,i)=>{t.hidden=!i,i?c(t,"hidden"):u(t,"hidden","true")},r=t=>({to:(i,n)=>{const s=Array.from(i.childNodes);if(s.length<1||!n)return void i.appendChild(t);const e=s[0];i.insertBefore(t,e)}}),l=t=>{const i=t.parentNode;i&&(n=>{const s="px",e=i===document.body;let a,o,r,l;a=e?scrollX+s:"0px",o=e?scrollY+s:"0px",r=e?"100%":n.width+s,l=e?"100vh":n.height+s,h(t,"left",a),h(t,"top",o),h(t,"width",r),h(t,"height",l)})(i.getBoundingClientRect())},h=(t,i,n)=>{t.style[i]=n},u=(t,i,n)=>{t.setAttribute(i,n)},c=(t,i)=>{t.removeAttribute(i)};class d{static i(){const t=a("div",{className:"nanosplash-container",attributes:[{key:"data-splash-animation",value:this.l.o}]});return t.style.backgroundColor=this.l.h,t}static u(){return a("img",{className:"nanosplash-img",attributes:[{key:"src",value:null},{key:"alt",value:"Nanosplash indicator"}]})}static m(){return a("div",{className:"nanosplash-text",content:this.l.p})}}d.l={v:document.body,p:"Loading ...",g:'"Arial", sans-serif',k:"medium",_:"#555",T:"26px",S:"100px",N:"auto",o:"pulse",h:"rgba(255, 255, 255, 0.90)",P:"light"};class m{constructor(t){var i,n,s,e,a;this.cache={A:""},this.O=null!=(n=null==(i=null==t?void 0:t.default)?void 0:i.text)?n:d.l.p,this.I=m.C(null!=(e=null==(s=null==t?void 0:t.default)?void 0:s.destination)?e:d.l.v),this.H=d.i(),this.L=d.u(),this.D=d.m(),this.R();const h=null==(a=null==t?void 0:t.splash)?void 0:a.src;h&&(this.B(h),r(this.L).to(this.H)),r(this.D).to(this.H),r(this.H).to(this.I,!0),o(this.H,!1),l(this.H),t&&this.configure(t)}install(){var t,i,n;Object.defineProperty(window,"loading",{value:this,writable:!1}),t=window,i=()=>l(this.H),n=["resize","scroll"],(([t,s])=>{n.forEach((n=>{t?t(`on${n}`,i):s(n,i,!0)}))})([t.attachEvent,t.addEventListener]),m.W()}configure(t){var i,n,s,e,a,l,h,u,c,d,p,f;if((null==(i=null==t?void 0:t.default)?void 0:i.destination)&&(this.I=m.C(t.default.destination)),this.O||(this.O=null==(n=t.default)?void 0:n.text),(null==(s=t.text)?void 0:s.family)&&this.X(t.text.family),(null==(e=t.text)?void 0:e.weight)&&this.F(t.text.weight),(null==(a=t.text)?void 0:a.color)&&this.G(t.text.color),(null==(l=t.text)?void 0:l.size)&&this.j(t.text.size),(null==(h=t.background)?void 0:h.color)&&this.M(t.background.color),(null==(u=t.background)?void 0:u.blur)&&this.U(t.background.blur),t.splash){if(null==(c=t.splash)?void 0:c.src){this.H.contains(this.L)||r(this.L).to(this.H,!0),this.B(t.splash.src)}(null==(d=t.splash)?void 0:d.width)&&this.K(t.splash.width),(null==(p=t.splash)?void 0:p.height)&&this.Y(t.splash.height),(null==(f=t.splash)?void 0:f.animation)&&this.Z(t.splash.animation)}else o(this.L,!1);return this}show(t){this.$(null!=t?t:d.l.p),o(this.H,!0);const i=t=>t.finally((()=>this.hide()));return{inside:t=>{this.q();const n=m.C(t);return r(this.H).to(n,!0),l(this.H),this.J(),{during:i}},during:i}}hide(){this.q(),o(this.H,!1),this.$(this.O),r(this.H).to(this.I,!0),l(this.H)}R(){this.X(d.l.g),this.F(d.l.k),this.G(d.l._),this.j(d.l.T),this.K(d.l.S),this.Y(d.l.N),this.Z(d.l.o),this.M(d.l.h),this.U(d.l.P)}V(t){var i;(i=this.H.parentElement)&&t(i)}tt(t){this.V((i=>{h(i,"position",t)}))}it(){this.V((t=>{this.cache.A=t.style.position}))}q(){this.tt(this.cache.A)}J(){this.it(),this.tt("relative")}$(t){this.D.innerText=t}X(t){h(this.D,"fontFamily",t)}F(t){h(this.D,"fontWeight",t)}G(t){h(this.D,"color",t)}j(t){h(this.D,"fontSize",t)}B(t){this.L.src=t,o(this.L,!0)}K(t){h(this.L,"width",t)}Y(t){h(this.L,"height",t)}Z(t){u(this.H,"data-splash-animation",t)}M(t){h(this.H,"backgroundColor",t)}U(t){u(this.H,"data-blur",t)}static W(){const t=e('link[href*="nanosplash"]'),i=e("style").filter((t=>/\.nanosplash/.test(t.innerText)));if(!(t.length>0||i.length>0))throw new s("Missing the Nanosplash CSS")}static C(t){const s="string"==typeof t,e=(a=t)&&"[object Function]"==={}.toString.call(a);var a;const o=(t=>t instanceof Element||t instanceof Node)(t);let r;if(s)l=t,r=document.querySelector(l);else if(e)r=t();else{if(!o)throw new i;r=t}var l;if(!r)throw new n;return r}}window&&window instanceof Window&&(new m).install()}();
1
+ var t=Object.defineProperty,s=Object.defineProperties,e=Object.getOwnPropertyDescriptors,i=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable,h=(s,e,i)=>e in s?t(s,e,{t:!0,i:!0,writable:!0,value:i}):s[e]=i,o=document.createElement("style");o.innerHTML=".ns-blur,body .ns-fs~*{filter:blur(5px);overflow:hidden}.ns-wrapper{position:relative}.ns-fs{left:0;min-height:100vh;min-width:100%;position:fixed;top:0;z-index:2}.ns-window{align-items:center;background-color:#fffc;display:flex;height:100%;justify-content:center;left:0;position:absolute;top:0;width:100%;z-index:1}.ns-img{margin-bottom:1rem;max-height:9rem;max-width:9rem}.ns-text{color:#333;text-align:center}\n",document.head.appendChild(o),function(){const t=t=>document.createElement(t);function o(t,...s){t.classList.add(...s)}function c(t,s,e){t.setAttribute(s,e)}class a{static h(t){if("string"==typeof t){const e=(s=t,document.querySelector(s));if(!e)throw new Error(`No match with ${t}`);return e}if(t instanceof Node)return t;var s;throw new Error("Destination argument must string or Node")}static o(t){const o={getId:()=>t.getId(),remove:()=>t.delete(),moveTo:s=>t.moveTo(s),getText:()=>t.getText(),setText:s=>t.setText(s),getImgSrc:()=>t.getImgSrc(),setImgSrc:s=>t.setImgSrc(s)};return c=((t,s)=>{for(var e in s||(s={}))n.call(s,e)&&h(t,e,s[e]);if(i)for(var e of i(s))r.call(s,e)&&h(t,e,s[e]);return t})({},o),s(c,e({inside:s=>(t.moveTo(s),o)}));var c}}class u{constructor(s,e,i){var n;this.u=t("div"),this.l=t("div"),this.m=t("div"),this.g=t("div"),this.p=t("img"),this.v=t("div"),this.id=Math.random().toString(36).substring(2),this.S=s,this.v.innerText=e,this.I=i,this.p.src=null!=(n=this.I)?n:"",this.p.alt=d.O,this.j(),this.setImgSrc(i)}F(){o(this.g,"ns-container"),o(this.l,"ns-blur"),o(this.p,"ns-img"),o(this.v,"ns-text"),o(this.m,"ns","ns-window"),o(this.u,"ns-wrapper")}N(){this.g.append(this.p,this.v),this.m.append(this.g),this.u.append(this.l,this.m)}j(){this.u.id=this.getId(),c(this.u,"data-ctx","nanosplash"),this.N(),this.F()}getId(){return this.id}getText(){return this.v.innerText}setText(t){return this.v.innerText=t,this}getImgSrc(){return this.I}setImgSrc(t){return this.p.src=null!=t?t:"",this.p.style.display=t?"block":"none",this.N(),this}T(){const t=this.u.parentElement;t&&this.C(t)}A(){c(this.u,"style",""),this.u.classList.remove("ns-fs")}M(t){const s=t.parentNode;s&&(this.C(s),s.replaceChild(this.u,t),this.l.appendChild(t))}W(){this.u.classList.add("ns-fs"),((t,s,e=!1)=>{t&&s&&(s.hasChildNodes()&&e?s.insertBefore(t,s.firstChild):s.appendChild(t))})(this.u,document.body,!0)}moveTo(t){this.T();const s=a.h(t);s===document.body?this.W():(this.A(),this.M(s)),this.j()}k(t){Array.from(this.l.childNodes).forEach(t)}C(t){this.k((s=>t.insertBefore(s,this.u)))}D(){[this.v,this.p,this.g,this.l,this.m,this.u].forEach((t=>t.remove()))}delete(){this.T(),this.D(),this.S.delete(this)}}class l{static $(t,s,e,i){var n;return t||(t=new u(s,e,i)),t.setText(e).setImgSrc(null!=(n=t.getImgSrc())?n:i)}static P(t,s){return e=>(s=l.$(s,t,"",e),{show:l.R(t,s),progress:l.q(t,s),while:l.B(t,s)})}static R(t,s){return e=>(s=l.$(s,t,e),t.G.set(s.getId(),s),s.moveTo(document.body),a.o(s))}static q(t,s){return(...e)=>((s=l.$(s,t,"")).moveTo(document.body),(async()=>{for(const[t,[i,n]]of e.entries())s.setText(n),await i;s.delete()})(),a.o(s))}static B(t,s){return e=>(s=l.$(s,t,""),{show:i=>(t.G.set(s.getId(),s),s.moveTo(document.body),s.setText(i),e.finally((()=>s.delete())),a.o(s))})}}class d{constructor(){this.G=new Map}img(t){return l.P(this,new u(this,"",t))(t)}show(t){return l.R(this,new u(this,t))(t)}progress(...t){return l.q(this,new u(this,""))(...t)}while(t){return l.B(this,new u(this,""))(t)}H(t){let s=0;const e=this.G.entries();for(const[i,n]of e)if(!t(i,n,s++))break}delete(t){this.G.delete(t.getId())}hideAll(){this.G.forEach((t=>t.delete()))}hide(t){if(t){const s=this.G.get(t);if(!s)throw new Error(`Could not find element with id: ${t}`);s.delete()}else this.H(((t,s,e)=>{const i=0===e;return i&&s.delete(),i}))}}d.O="Nanosplash",window.addEventListener("load",(()=>window.ns=new d))}();
@@ -0,0 +1 @@
1
+ .ns-blur,body .ns-fs~*{filter:blur(5px);overflow:hidden}.ns-wrapper{position:relative}.ns-fs{left:0;min-height:100vh;min-width:100%;position:fixed;top:0;z-index:2}.ns-window{align-items:center;background-color:#fffc;display:flex;height:100%;justify-content:center;left:0;position:absolute;top:0;width:100%;z-index:1}.ns-img{margin-bottom:1rem;max-height:9rem;max-width:9rem}.ns-text{color:#333;text-align:center}
@@ -1,7 +1,10 @@
1
1
  {
2
- "src/Nanosplash.ts": {
2
+ "src/Core/Nanosplash.ts": {
3
3
  "file": "nanosplash.cjs.js",
4
- "src": "src/Nanosplash.ts",
5
- "isEntry": true
4
+ "src": "src/Core/Nanosplash.ts",
5
+ "isEntry": true,
6
+ "css": [
7
+ "Nanosplash.css"
8
+ ]
6
9
  }
7
10
  }
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"t",{value:!0}),exports[Symbol.toStringTag]="Module";class t extends Error{constructor(t){super(t),this.name=this.constructor.name}i(){return this.constructor.name}}class s extends t{constructor(t){super(t)}}class i extends t{constructor(t){super(t)}}class e extends t{constructor(t){super(t)}}const n=t=>Array.from(document.querySelectorAll(t)),h=(t,s)=>{var i;const e=document.createElement(t);return s&&(e.id||(e.id=s.id+""),e.className||(e.className=s.className+""),null==(i=s.attributes)||i.filter((t=>t.value)).forEach((({key:t,value:s})=>u(e,t,s))),s.content&&("string"==typeof s.content?e.innerText=s.content:e.append(s.content))),e},o=(t,s)=>{t.hidden=!s,s?c(t,"hidden"):u(t,"hidden","true")},l=t=>({to:(s,i)=>{const e=Array.from(s.childNodes);if(e.length<1||!i)return void s.appendChild(t);const n=e[0];s.insertBefore(t,n)}}),a=t=>{const s=t.parentNode;s&&(i=>{const e="px",n=s===document.body;let h,o,l,a;h=n?scrollX+e:"0px",o=n?scrollY+e:"0px",l=n?"100%":i.width+e,a=n?"100vh":i.height+e,r(t,"left",h),r(t,"top",o),r(t,"width",l),r(t,"height",a)})(s.getBoundingClientRect())},r=(t,s,i)=>{t.style[s]=i},u=(t,s,i)=>{t.setAttribute(s,i)},c=(t,s)=>{t.removeAttribute(s)};class d{static h(){const t=h("div",{className:"nanosplash-container",attributes:[{key:"data-splash-animation",value:this.l.o}]});return t.style.backgroundColor=this.l.u,t}static v(){return h("img",{className:"nanosplash-img",attributes:[{key:"src",value:null},{key:"alt",value:"Nanosplash indicator"}]})}static p(){return h("div",{className:"nanosplash-text",content:this.l.m})}}d.l={T:document.body,m:"Loading ...",g:'"Arial", sans-serif',S:"medium",N:"#555",P:"26px",k:"100px",A:"auto",o:"pulse",u:"rgba(255, 255, 255, 0.90)",O:"light"};class v{constructor(t){var s,i,e,n,h;this.cache={_:""},this.I=null!=(i=null==(s=null==t?void 0:t.default)?void 0:s.text)?i:d.l.m,this.C=v.H(null!=(n=null==(e=null==t?void 0:t.default)?void 0:e.destination)?n:d.l.T),this.D=d.h(),this.L=d.v(),this.R=d.p(),this.B();const r=null==(h=null==t?void 0:t.X)?void 0:h.src;r&&(this.F(r),l(this.L).to(this.D)),l(this.R).to(this.D),l(this.D).to(this.C,!0),o(this.D,!1),a(this.D),t&&this.configure(t)}install(){var t,s,i;Object.defineProperty(window,"loading",{value:this,writable:!1}),t=window,s=()=>a(this.D),i=["resize","scroll"],(([t,e])=>{i.forEach((i=>{t?t(`on${i}`,s):e(i,s,!0)}))})([t.attachEvent,t.addEventListener]),v.M()}configure(t){var s,i,e,n,h,a,r,u,c,d,p,m;if((null==(s=null==t?void 0:t.default)?void 0:s.destination)&&(this.C=v.H(t.default.destination)),this.I||(this.I=null==(i=t.default)?void 0:i.text),(null==(e=t.text)?void 0:e.family)&&this.W(t.text.family),(null==(n=t.text)?void 0:n.weight)&&this.G(t.text.weight),(null==(h=t.text)?void 0:h.color)&&this.j(t.text.color),(null==(a=t.text)?void 0:a.size)&&this.U(t.text.size),(null==(r=t.background)?void 0:r.color)&&this.K(t.background.color),(null==(u=t.background)?void 0:u.blur)&&this.Y(t.background.blur),t.X){if(null==(c=t.X)?void 0:c.src){this.D.contains(this.L)||l(this.L).to(this.D,!0),this.F(t.X.src)}(null==(d=t.X)?void 0:d.width)&&this.Z(t.X.width),(null==(p=t.X)?void 0:p.height)&&this.$(t.X.height),(null==(m=t.X)?void 0:m.animation)&&this.q(t.X.animation)}else o(this.L,!1);return this}show(t){this.J(null!=t?t:d.l.m),o(this.D,!0);const s=t=>t.finally((()=>this.hide()));return{inside:t=>{this.V();const i=v.H(t);return l(this.D).to(i,!0),a(this.D),this.tt(),{during:s}},during:s}}hide(){this.V(),o(this.D,!1),this.J(this.I),l(this.D).to(this.C,!0),a(this.D)}B(){this.W(d.l.g),this.G(d.l.S),this.j(d.l.N),this.U(d.l.P),this.Z(d.l.k),this.$(d.l.A),this.q(d.l.o),this.K(d.l.u),this.Y(d.l.O)}st(t){var s;(s=this.D.parentElement)&&t(s)}it(t){this.st((s=>{r(s,"position",t)}))}et(){this.st((t=>{this.cache._=t.style.position}))}V(){this.it(this.cache._)}tt(){this.et(),this.it("relative")}J(t){this.R.innerText=t}W(t){r(this.R,"fontFamily",t)}G(t){r(this.R,"fontWeight",t)}j(t){r(this.R,"color",t)}U(t){r(this.R,"fontSize",t)}F(t){this.L.src=t,o(this.L,!0)}Z(t){r(this.L,"width",t)}$(t){r(this.L,"height",t)}q(t){u(this.D,"data-splash-animation",t)}K(t){r(this.D,"backgroundColor",t)}Y(t){u(this.D,"data-blur",t)}static M(){const t=n('link[href*="nanosplash"]'),s=n("style").filter((t=>/\.nanosplash/.test(t.innerText)));if(!(t.length>0||s.length>0))throw new e("Missing the Nanosplash CSS")}static H(t){const e="string"==typeof t,n=(h=t)&&"[object Function]"==={}.toString.call(h);var h;const o=(t=>t instanceof Element||t instanceof Node)(t);let l;if(e)a=t,l=document.querySelector(a);else if(n)l=t();else{if(!o)throw new s;l=t}var a;if(!l)throw new i;return l}}exports.Nanosplash=v;
1
+ var t=Object.defineProperty,s=Object.defineProperties,e=Object.getOwnPropertyDescriptors,i=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable,h=(s,e,i)=>e in s?t(s,e,{t:!0,i:!0,writable:!0,value:i}):s[e]=i;Object.defineProperties(exports,{h:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=t=>document.createElement(t);function c(t,...s){t.classList.add(...s)}function a(t,s,e){t.setAttribute(s,e)}class u{static o(t){if("string"==typeof t){const e=(s=t,document.querySelector(s));if(!e)throw new Error(`No match with ${t}`);return e}if(t instanceof Node)return t;var s;throw new Error("Destination argument must string or Node")}static u(t){const o={getId:()=>t.getId(),remove:()=>t.delete(),moveTo:s=>t.moveTo(s),getText:()=>t.getText(),setText:s=>t.setText(s),getImgSrc:()=>t.getImgSrc(),setImgSrc:s=>t.setImgSrc(s)};return c=((t,s)=>{for(var e in s||(s={}))r.call(s,e)&&h(t,e,s[e]);if(i)for(var e of i(s))n.call(s,e)&&h(t,e,s[e]);return t})({},o),s(c,e({inside:s=>(t.moveTo(s),o)}));var c}}class l{constructor(t,s,e){var i;this.l=o("div"),this.m=o("div"),this.g=o("div"),this.v=o("div"),this.p=o("img"),this.S=o("div"),this.id=Math.random().toString(36).substring(2),this.O=t,this.S.innerText=s,this.I=e,this.p.src=null!=(i=this.I)?i:"",this.p.alt=d.j,this.F(),this.setImgSrc(e)}N(){c(this.v,"ns-container"),c(this.m,"ns-blur"),c(this.p,"ns-img"),c(this.S,"ns-text"),c(this.g,"ns","ns-window"),c(this.l,"ns-wrapper")}T(){this.v.append(this.p,this.S),this.g.append(this.v),this.l.append(this.m,this.g)}F(){this.l.id=this.getId(),a(this.l,"data-ctx","nanosplash"),this.T(),this.N()}getId(){return this.id}getText(){return this.S.innerText}setText(t){return this.S.innerText=t,this}getImgSrc(){return this.I}setImgSrc(t){return this.p.src=null!=t?t:"",this.p.style.display=t?"block":"none",this.T(),this}M(){const t=this.l.parentElement;t&&this.C(t)}A(){a(this.l,"style",""),this.l.classList.remove("ns-fs")}W(t){const s=t.parentNode;s&&(this.C(s),s.replaceChild(this.l,t),this.m.appendChild(t))}D(){this.l.classList.add("ns-fs"),((t,s,e=!1)=>{t&&s&&(s.hasChildNodes()&&e?s.insertBefore(t,s.firstChild):s.appendChild(t))})(this.l,document.body,!0)}moveTo(t){this.M();const s=u.o(t);s===document.body?this.D():(this.A(),this.W(s)),this.F()}k(t){Array.from(this.m.childNodes).forEach(t)}C(t){this.k((s=>t.insertBefore(s,this.l)))}$(){[this.S,this.p,this.v,this.m,this.g,this.l].forEach((t=>t.remove()))}delete(){this.M(),this.$(),this.O.delete(this)}}class m{static _(t,s,e,i){var r;return t||(t=new l(s,e,i)),t.setText(e).setImgSrc(null!=(r=t.getImgSrc())?r:i)}static P(t,s){return e=>(s=m._(s,t,"",e),{show:m.R(t,s),progress:m.q(t,s),while:m.B(t,s)})}static R(t,s){return e=>(s=m._(s,t,e),t.G.set(s.getId(),s),s.moveTo(document.body),u.u(s))}static q(t,s){return(...e)=>((s=m._(s,t,"")).moveTo(document.body),(async()=>{for(const[t,[i,r]]of e.entries())s.setText(r),await i;s.delete()})(),u.u(s))}static B(t,s){return e=>(s=m._(s,t,""),{show:i=>(t.G.set(s.getId(),s),s.moveTo(document.body),s.setText(i),e.finally((()=>s.delete())),u.u(s))})}}class d{constructor(){this.G=new Map}img(t){return m.P(this,new l(this,"",t))(t)}show(t){return m.R(this,new l(this,t))(t)}progress(...t){return m.q(this,new l(this,""))(...t)}while(t){return m.B(this,new l(this,""))(t)}H(t){let s=0;const e=this.G.entries();for(const[i,r]of e)if(!t(i,r,s++))break}delete(t){this.G.delete(t.getId())}hideAll(){this.G.forEach((t=>t.delete()))}hide(t){if(t){const s=this.G.get(t);if(!s)throw new Error(`Could not find element with id: ${t}`);s.delete()}else this.H(((t,s,e)=>{const i=0===e;return i&&s.delete(),i}))}}d.j="Nanosplash",exports.Nanosplash=d;