nanosplash 2.2.4 → 2.3.2

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 (53) hide show
  1. package/.github/workflows/production.yml +57 -0
  2. package/.github/workflows/release.yml +61 -0
  3. package/README.md +17 -15
  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 +244 -330
  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/classes/Core_Nanosplash.Nanosplash.html +1 -0
  17. package/docs/typedoc/index.html +1 -1
  18. package/docs/typedoc/modules/Core_Nanosplash.html +1 -0
  19. package/docs/typedoc/modules/types.html +1 -1
  20. package/index.html +51 -412
  21. package/jest.config.ts +194 -0
  22. package/package.json +70 -65
  23. package/src/Core/Nanosplash.ts +74 -0
  24. package/src/Core/SplashInstance.ts +154 -0
  25. package/src/Factory/NanosplashFactory.ts +73 -0
  26. package/src/Interfaces/ContextualAPIInterface.ts +8 -0
  27. package/src/Interfaces/IdentityInterface.ts +3 -0
  28. package/src/Interfaces/ImageInterface.ts +5 -0
  29. package/src/Interfaces/InsideInterface.ts +5 -0
  30. package/src/Interfaces/NanosplashInterface.ts +4 -0
  31. package/src/Interfaces/ProgressInterface.ts +5 -0
  32. package/src/Interfaces/ShowInterface.ts +5 -0
  33. package/src/Interfaces/WhileInterface.ts +5 -0
  34. package/src/main.ts +2 -6
  35. package/src/repositories/NanosplashRepository.ts +34 -55
  36. package/src/style.sass +51 -61
  37. package/src/types.d.ts +45 -200
  38. package/src/utilities/dom.spec.ts +70 -0
  39. package/src/utilities/dom.ts +17 -256
  40. package/update-all.sh +3 -0
  41. package/vite.iife.config.js +46 -18
  42. package/vite.mod.config.js +48 -12
  43. package/vite.site.config.js +0 -3
  44. package/dist/module/style.css +0 -1
  45. package/docs/typedoc/classes/Nanosplash.Nanosplash-1.html +0 -56
  46. package/docs/typedoc/classes/types.Nanosplash.html +0 -56
  47. package/docs/typedoc/modules/Nanosplash.html +0 -1
  48. package/src/Exceptions/Exception.ts +0 -12
  49. package/src/Exceptions/IllegalArgumentException.ts +0 -9
  50. package/src/Exceptions/InvalidDestinationException.ts +0 -9
  51. package/src/Exceptions/MissingResourceException.ts +0 -9
  52. package/src/Nanosplash.ts +0 -484
  53. 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,8 +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
- const nanosplash = new Nanosplash()
76
- nanosplash.install()
75
+ const ns = new Nanosplash()
76
+ window.ns = ns
77
77
  ```
78
78
 
79
79
  ## Basic usage
@@ -81,13 +81,17 @@ nanosplash.install()
81
81
  ### Display the loading screen
82
82
 
83
83
  ```js
84
- loading.show('Loading the good stuff ...')
84
+ ns.show('Loading the good stuff ...')
85
85
  ```
86
86
 
87
87
  ### Hide the loading screen
88
88
 
89
89
  ```js
90
- loading.hide()
90
+ // Hide one at a time
91
+ ns.hide()
92
+
93
+ // Hide all
94
+ ns.hideAll()
91
95
  ```
92
96
 
93
97
  ## Advanced usage
@@ -96,19 +100,12 @@ loading.hide()
96
100
 
97
101
  ```js
98
102
  // Use CSS selector string
99
- loading.show('Loading component ...').inside('#my-element')
103
+ ns.show('Loading component ...').inside('#my-element')
100
104
 
101
105
  // Use HTMLElement objects directly
102
- loading
106
+ ns
103
107
  .show('Loading component ...')
104
108
  .inside(document.getElementById('my-element'))
105
-
106
- // Use functions returning HTMLElement objects
107
- loading
108
- .show('Loading component ...')
109
- .inside(() =>
110
- Array.from(document.querySelectorAll()).filter((element.id = 'my-element'))[0]
111
- )
112
109
  ```
113
110
 
114
111
  ### Combine Nanosplash with async tasks
@@ -117,8 +114,13 @@ loading
117
114
  const task1 = new Promise(r => setTimeout(() => r(), 3000))
118
115
  const task2 = async () => await getDataFromApi()
119
116
 
120
- loading.show('Loading resources ...').during(task1)
121
- 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')
122
124
  ```
123
125
 
124
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.D=d.i(),this.H=d.u(),this.L=d.m(),this.R();const h=null==(a=null==t?void 0:t.splash)?void 0:a.src;h&&(this.B(h),r(this.H).to(this.D)),r(this.L).to(this.D),r(this.D).to(this.I,!0),o(this.D,!1),l(this.D),t&&this.configure(t)}install(){var t,i,n;Object.defineProperty(window,"loading",{value:this,writable:!1}),t=window,i=()=>l(this.D),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.D.contains(this.H)||r(this.H).to(this.D,!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.H,!1);return this}show(t){this.$(null!=t?t:d.l.p),o(this.D,!0);const i=t=>t.finally((()=>this.hide()));return{inside:t=>{this.q();const n=m.C(t);return r(this.D).to(n,!0),l(this.D),this.J(),{during:i}},during:i}}hide(){this.q(),o(this.D,!1),this.$(this.O),r(this.D).to(this.I,!0),l(this.D)}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.D.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.L.innerText=t}X(t){h(this.L,"fontFamily",t)}F(t){h(this.L,"fontWeight",t)}G(t){h(this.L,"color",t)}j(t){h(this.L,"fontSize",t)}B(t){this.H.src=t,o(this.H,!0)}K(t){h(this.H,"width",t)}Y(t){h(this.H,"height",t)}Z(t){u(this.D,"data-splash-animation",t)}M(t){h(this.D,"backgroundColor",t)}U(t){u(this.D,"data-blur",t)}static W(){window.addEventListener("load",(async function(){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("Destination element is falsy");return r}}window&&window instanceof Window&&(new m).install()}();
1
+ var t=Object.defineProperty,e=Object.defineProperties,i=Object.getOwnPropertyDescriptors,s=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable,o=(e,i,s)=>i in e?t(e,i,{t:!0,i:!0,writable:!0,value:s}):e[i]=s,h=document.createElement("style");h.innerHTML='@charset "UTF-8";.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;display:flex;text-align:center}.ns-text:after{-webkit-animation:anim 1s infinite;animation:anim 1s infinite;content:"\\a0\\a0\\a0";margin-left:.25em}@-webkit-keyframes anim{0%{content:"\\a0\\a0\\a0"}30%{content:".\\a0\\a0"}60%{content:"..\\a0"}90%{content:"..."}}@keyframes anim{0%{content:"\\a0\\a0\\a0"}30%{content:".\\a0\\a0"}60%{content:"..\\a0"}90%{content:"..."}}\n',document.head.appendChild(h),function(){const t=t=>document.createElement(t);function h(t,...e){t.classList.add(...e)}function a(t,e,i){t.setAttribute(e,i)}class c{static o(t){if("string"==typeof t){const i=(e=t,document.querySelector(e));if(!i)throw new Error(`No match with ${t}`);return i}if(t instanceof Node)return t;var e;throw new Error("Destination argument must string or Node")}static h(t){const h={getId:()=>t.getId(),remove:()=>t.delete(),moveTo:e=>t.moveTo(e),getText:()=>t.getText(),setText:e=>t.setText(e),getImgSrc:()=>t.getImgSrc(),setImgSrc:e=>t.setImgSrc(e)};return a=((t,e)=>{for(var i in e||(e={}))n.call(e,i)&&o(t,i,e[i]);if(s)for(var i of s(e))r.call(e,i)&&o(t,i,e[i]);return t})({},h),e(a,i({inside:e=>(t.moveTo(e),h)}));var a}}class u{constructor(e,i,s){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=e,this.v.innerText=i,this.I=s,this.p.src=null!=(n=this.I)?n:"",this.p.alt=m.O,this.j(),this.setImgSrc(s)}F(){h(this.g,"ns-container"),h(this.l,"ns-blur"),h(this.p,"ns-img"),h(this.v,"ns-text"),h(this.m,"ns","ns-window"),h(this.u,"ns-wrapper")}T(){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(),a(this.u,"data-ctx","nanosplash"),this.T(),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.T(),this}k(){const t=this.u.parentElement;t&&this.N(t)}C(){a(this.u,"style",""),this.u.classList.remove("ns-fs")}A(t){const e=t.parentNode;e&&(this.N(e),e.replaceChild(this.u,t),this.l.appendChild(t))}M(){this.u.classList.add("ns-fs"),((t,e,i=!1)=>{t&&e&&(e.hasChildNodes()&&i?e.insertBefore(t,e.firstChild):e.appendChild(t))})(this.u,document.body,!0)}moveTo(t){this.k();const e=c.o(t);e===document.body?this.M():(this.C(),this.A(e)),this.j()}W(t){Array.from(this.l.childNodes).forEach(t)}N(t){this.W((e=>t.insertBefore(e,this.u)))}D(){[this.v,this.p,this.g,this.l,this.m,this.u].forEach((t=>t.remove()))}delete(){this.k(),this.D(),this.S.delete(this)}}class l{static $(t,e,i,s){var n;return t||(t=new u(e,i,s)),t.setText(i).setImgSrc(null!=(n=t.getImgSrc())?n:s)}static P(t,e){return i=>(e=l.$(e,t,"",i),{show:l.R(t,e),progress:l.U(t,e),while:l.q(t,e)})}static R(t,e){return i=>(e=l.$(e,t,i),t.B.set(e.getId(),e),e.moveTo(document.body),c.h(e))}static U(t,e){return(...i)=>((e=l.$(e,t,"")).moveTo(document.body),(async()=>{for(const[t,[s,n]]of i.entries())e.setText(n),await s;e.delete()})(),c.h(e))}static q(t,e){return i=>(e=l.$(e,t,""),{show:s=>(t.B.set(e.getId(),e),e.moveTo(document.body),e.setText(s),i.finally((()=>e.delete())),c.h(e))})}}class m{constructor(){this.B=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.U(this,new u(this,""))(...t)}while(t){return l.q(this,new u(this,""))(t)}G(t){let e=0;const i=this.B.entries();for(const[s,n]of i)if(!t(s,n,e++))break}delete(t){this.B.delete(t.getId())}hideAll(){this.B.forEach((t=>t.delete()))}hide(t){if(t){const e=this.B.get(t);if(!e)throw new Error(`Could not find element with id: ${t}`);e.delete()}else this.G(((t,e,i)=>{const s=0===i;return s&&e.delete(),s}))}}m.O="Nanosplash",window.addEventListener("load",(()=>window.ns=new m))}();
@@ -0,0 +1 @@
1
+ @charset "UTF-8";.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;display:flex;text-align:center}.ns-text:after{-webkit-animation:anim 1s infinite;animation:anim 1s infinite;content:"\a0\a0\a0";margin-left:.25em}@-webkit-keyframes anim{0%{content:"\a0\a0\a0"}30%{content:".\a0\a0"}60%{content:"..\a0"}90%{content:"..."}}@keyframes anim{0%{content:"\a0\a0\a0"}30%{content:".\a0\a0"}60%{content:"..\a0"}90%{content:"..."}}
@@ -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)),o=(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},h=(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 o,h,l,a;o=n?scrollX+e:"0px",h=n?scrollY+e:"0px",l=n?"100%":i.width+e,a=n?"100vh":i.height+e,r(t,"left",o),r(t,"top",h),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 o(){const t=o("div",{className:"nanosplash-container",attributes:[{key:"data-splash-animation",value:this.l.h}]});return t.style.backgroundColor=this.l.u,t}static v(){return o("img",{className:"nanosplash-img",attributes:[{key:"src",value:null},{key:"alt",value:"Nanosplash indicator"}]})}static p(){return o("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",h:"pulse",u:"rgba(255, 255, 255, 0.90)",O:"light"};class v{constructor(t){var s,i,e,n,o;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.D(null!=(n=null==(e=null==t?void 0:t.default)?void 0:e.destination)?n:d.l.T),this.H=d.o(),this.L=d.v(),this.R=d.p(),this.B();const r=null==(o=null==t?void 0:t.X)?void 0:o.src;r&&(this.F(r),l(this.L).to(this.H)),l(this.R).to(this.H),l(this.H).to(this.C,!0),h(this.H,!1),a(this.H),t&&this.configure(t)}install(){var t,s,i;Object.defineProperty(window,"loading",{value:this,writable:!1}),t=window,s=()=>a(this.H),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,o,a,r,u,c,d,p,m;if((null==(s=null==t?void 0:t.default)?void 0:s.destination)&&(this.C=v.D(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==(o=t.text)?void 0:o.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.H.contains(this.L)||l(this.L).to(this.H,!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 h(this.L,!1);return this}show(t){this.J(null!=t?t:d.l.m),h(this.H,!0);const s=t=>t.finally((()=>this.hide()));return{inside:t=>{this.V();const i=v.D(t);return l(this.H).to(i,!0),a(this.H),this.tt(),{during:s}},during:s}}hide(){this.V(),h(this.H,!1),this.J(this.I),l(this.H).to(this.C,!0),a(this.H)}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.h),this.K(d.l.u),this.Y(d.l.O)}st(t){var s;(s=this.H.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,h(this.L,!0)}Z(t){r(this.L,"width",t)}$(t){r(this.L,"height",t)}q(t){u(this.H,"data-splash-animation",t)}K(t){r(this.H,"backgroundColor",t)}Y(t){u(this.H,"data-blur",t)}static M(){window.addEventListener("load",(async function(){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 D(t){const e="string"==typeof t,n=(o=t)&&"[object Function]"==={}.toString.call(o);var o;const h=(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(!h)throw new s;l=t}var a;if(!l)throw new i("Destination element is falsy");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;