nanosplash 3.0.4 → 3.0.6
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.
- package/.github/workflows/vitepress.yml +0 -1
- package/README.md +1 -10
- package/dist/cjs/ns.cjs +1 -1
- package/dist/es/ns.js +1 -1
- package/dist/iife/ns.iife.js +1 -1
- package/docs/.vitepress/theme/vue/Exe.vue +1 -0
- package/docs/api/start/features.md +1 -1
- package/docs/api/start/install.md +3 -3
- package/docs/index.md +4 -1
- package/package.json +1 -1
- package/coverage/DomUtilities.ts.html +0 -568
- package/coverage/Service.ts.html +0 -718
- package/coverage/Splash.ts.html +0 -448
- package/coverage/SplashQueue.ts.html +0 -232
- package/coverage/base.css +0 -224
- package/coverage/block-navigation.js +0 -87
- package/coverage/clover.xml +0 -560
- package/coverage/coverage-final.json +0 -5
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +0 -161
- package/coverage/prettify.css +0 -1
- package/coverage/prettify.js +0 -2
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +0 -196
package/README.md
CHANGED
|
@@ -4,25 +4,16 @@
|
|
|
4
4
|
|
|
5
5
|
<br>
|
|
6
6
|
|
|
7
|
-
[](https://github.com/isakhauge/nanosplash/actions/workflows/ci.yml)  [](https://github.com/isakhauge/nanosplash/actions/workflows/ci.yml)  [](https://github.com/ellerbrock/typescript-badges/)
|
|
15
8
|
|
|
16
9
|
## Usage
|
|
17
10
|
|
|
18
11
|
```js
|
|
19
12
|
// Fullscreen splash screen
|
|
20
13
|
ns.show('Loading')
|
|
21
|
-
ns.hide()
|
|
22
14
|
|
|
23
15
|
// Splash screen inside a DOM element
|
|
24
16
|
ns.showInside('#my-div', 'Loading')
|
|
25
|
-
ns.hide()
|
|
26
17
|
```
|
|
27
18
|
|
|
28
19
|
## Documentation
|
package/dist/cjs/ns.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var m=Object.defineProperty;var v=(s,e,t)=>e in s?m(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var r=(s,e,t)=>(v(s,typeof e!="symbol"?e+"":e,t),t);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const y="3.0.
|
|
1
|
+
"use strict";var m=Object.defineProperty;var v=(s,e,t)=>e in s?m(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var r=(s,e,t)=>(v(s,typeof e!="symbol"?e+"":e,t),t);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const y="3.0.5",a=class a{constructor(){r(this,"id");r(this,"element");this.element=w(),this.element.id=this.id=a.generateGUID()}static generateGUID(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}getId(){return this.id}getElement(){return this.element}getTextElement(){var e,t;return((t=(e=this.getElement())==null?void 0:e.firstElementChild)==null?void 0:t.firstElementChild)??null}setText(e){return this.getTextElement().innerText=e,e.length>0?this.showText():this.hideText(),this}showText(){return S(this.getTextElement()),this}hideText(){return I(this.getTextElement()),this}delete(){return this.id=null,this.element!==null&&(this.element.innerHTML="",this.element.remove(),this.element=null),this.element===null}};r(a,"NSClass","ns"),r(a,"NSHostClass","nsh");let o=a;function x(s){return(e=>(()=>e.firstChild)(e.innerHTML=s))(document.createElement("div"))}function w(){return x('<div class=ns><div class=nsc><div class=nst></div><div class=nss><svg viewBox="0 0 50 50"><circle class=path cx=25 cy=25 r=20 fill=none></circle></svg></div></div></div>')}function b(s,e){e.children.length>0?e.insertBefore(s,e.children.item(0)):e.append(s)}function p(s){s==null||s.classList.add(o.NSHostClass)}function g(s){s==null||s.classList.remove(o.NSHostClass)}function S(s){s.style.display="flex"}function I(s){s.style.display="none"}function h(s){switch(typeof s){case"object":const e=s===document.body,t=s instanceof Element;if(e||t)return s;throw new Error("Reference is an object but not an Element instance.");case"string":return document.querySelector(s);default:throw new Error("Reference is not an object or a string.")}}function k(s,e){g(s.parentElement),p(e),b(s,e)}function f(s){const e=Array.from(s.children||[]),t=c.getInstance();let n=null;const d=e.length;for(let l=0;l<d;l++){const u=e[l];if(u.classList.contains(o.NSClass)){n=t.nsQueue.get(u.id)??null;break}}return n}const T=`.ns,.nsh:before{width:100%;height:100%}.ns,.nsh:before{top:0;left:0}.nsc,.ns{display:flex;justify-content:center;align-items:center}.nsh{--color: DarkSlateGray;--size: 20px;--relSize: calc(var(--size) * .9);--font: "Helvetica", "Arial", sans-serif;--weight: 400;--bg: rgba(255, 255, 255, .8);--zIdx: 999999999;--blur: blur(10px)}.nsh{position:relative;z-index:var(--zIdx)}.nsh:before{position:absolute;background-color:var(--bg);content:"";backdrop-filter:var(--blur);-webkit-backdrop-filter:var(--blur);z-index:calc(var(--zIdx) + 1);border-radius:inherit}body.nsh{height:100vh}.ns{position:absolute;z-index:calc(var(--zIdx) + 2)}.nsc{filter:drop-shadow(0 0 .1rem rgba(211,211,211,.5))}.nst{color:var(--color);font-size:var(--size);font-family:var(--font);font-weight:var(--weight);margin-right:var(--relSize);text-shadow:0 0 .06rem rgba(47,79,79,.25)}.nss{display:block;width:var(--relSize);height:var(--relSize)}.nss>svg{animation:Rotate 2s linear infinite;position:relative;width:inherit;height:inherit;stroke-width:8}.nss .path{stroke:var(--color);stroke-linecap:round;animation:Dash 1.5s ease-in-out infinite}@keyframes Rotate{to{transform:rotate(360deg)}}@keyframes Dash{0%{stroke-dasharray:1,150;stroke-dashoffset:0}50%{stroke-dasharray:90,150;stroke-dashoffset:-35}to{stroke-dasharray:90,150;stroke-dashoffset:-124}}
|
|
2
2
|
`;class E{constructor(){r(this,"queue");this.queue=[]}enqueue(e){return this.queue.push(e),this}dequeue(){return this.queue.shift()}get(e){return this.queue.find(t=>t.getId()===e)}delete(e){const t=this.queue.findIndex(n=>n.getId()===e);if(t!==-1)return this.queue.splice(t,1)[0]}}const i=class i{constructor(){r(this,"version");r(this,"nsQueue");this.version=y,this.nsQueue=new E,i.addStyle()}static addStyle(){const e=x(`<style>${T}</style>`);document.body.append(e)}static getInstance(){return i.instance||(i.instance=new i),i.instance}static assignToWindow(){Object.defineProperty(window,i.WindowAccessorKey,{value:i.getInstance(),writable:!1})}static start(){window[i.WindowAccessorKey]||i.assignToWindow()}createNS(e){const t=new o().setText(e||"");return this.nsQueue.enqueue(t),t}cleanAndRemoveFromDOM(e){var t;return e?(g(((t=e.getElement())==null?void 0:t.parentElement)??null),e.delete()):!1}deleteNS(e){return this.cleanAndRemoveFromDOM(this.nsQueue.delete(e)??null)}show(e){return this.showInside(document.body,e)}showInside(e,t){try{const n=h(e),d=f(n)??this.createNS();k(d.getElement(),n);const l=t?String(t):"";return d.setText(l).getId()}catch(n){return console.error(n),null}}hide(){const e=this.nsQueue.dequeue();return e?(this.cleanAndRemoveFromDOM(e),e.getId()):null}hideAll(){let e=this.nsQueue.dequeue();for(;e;)this.cleanAndRemoveFromDOM(e),e=this.nsQueue.dequeue()}hideId(e){return this.deleteNS(e)?e:null}hideInside(e){try{const t=f(h(e)),n=(t==null?void 0:t.getId())??"";return this.deleteNS(n??"")?n:null}catch(t){return console.error(t),null}}};r(i,"WindowAccessorKey","ns"),r(i,"instance");let c=i;const z={Service:c};exports.Service=c;exports.default=z;
|
package/dist/es/ns.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var m = Object.defineProperty;
|
|
2
2
|
var v = (s, e, t) => e in s ? m(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
|
|
3
3
|
var r = (s, e, t) => (v(s, typeof e != "symbol" ? e + "" : e, t), t);
|
|
4
|
-
const y = "3.0.
|
|
4
|
+
const y = "3.0.5", a = class a {
|
|
5
5
|
/**
|
|
6
6
|
* # Constructor
|
|
7
7
|
* Creates a new Nanosplash instance.
|
package/dist/iife/ns.iife.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var E=Object.defineProperty;var T=(l,s,a)=>s in l?E(l,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):l[s]=a;var o=(l,s,a)=>(T(l,typeof s!="symbol"?s+"":s,a),a);(function(){"use strict";const l="3.0.
|
|
1
|
+
var E=Object.defineProperty;var T=(l,s,a)=>s in l?E(l,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):l[s]=a;var o=(l,s,a)=>(T(l,typeof s!="symbol"?s+"":s,a),a);(function(){"use strict";const l="3.0.5",c=class c{constructor(){o(this,"id");o(this,"element");this.element=v(),this.element.id=this.id=c.generateGUID()}static generateGUID(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const n=Math.random()*16|0;return(e==="x"?n:n&3|8).toString(16)})}getId(){return this.id}getElement(){return this.element}getTextElement(){var e,n;return((n=(e=this.getElement())==null?void 0:e.firstElementChild)==null?void 0:n.firstElementChild)??null}setText(e){return this.getTextElement().innerText=e,e.length>0?this.showText():this.hideText(),this}showText(){return b(this.getTextElement()),this}hideText(){return p(this.getTextElement()),this}delete(){return this.id=null,this.element!==null&&(this.element.innerHTML="",this.element.remove(),this.element=null),this.element===null}};o(c,"NSClass","ns"),o(c,"NSHostClass","nsh");let s=c;function a(t){return(e=>(()=>e.firstChild)(e.innerHTML=t))(document.createElement("div"))}function v(){return a('<div class=ns><div class=nsc><div class=nst></div><div class=nss><svg viewBox="0 0 50 50"><circle class=path cx=25 cy=25 r=20 fill=none></circle></svg></div></div></div>')}function y(t,e){e.children.length>0?e.insertBefore(t,e.children.item(0)):e.append(t)}function w(t){t==null||t.classList.add(s.NSHostClass)}function f(t){t==null||t.classList.remove(s.NSHostClass)}function b(t){t.style.display="flex"}function p(t){t.style.display="none"}function x(t){switch(typeof t){case"object":const e=t===document.body,n=t instanceof Element;if(e||n)return t;throw new Error("Reference is an object but not an Element instance.");case"string":return document.querySelector(t);default:throw new Error("Reference is not an object or a string.")}}function I(t,e){f(t.parentElement),w(e),y(t,e)}function g(t){const e=Array.from(t.children||[]),n=u.getInstance();let r=null;const h=e.length;for(let d=0;d<h;d++){const m=e[d];if(m.classList.contains(s.NSClass)){r=n.nsQueue.get(m.id)??null;break}}return r}const k=`.ns,.nsh:before{width:100%;height:100%}.ns,.nsh:before{top:0;left:0}.nsc,.ns{display:flex;justify-content:center;align-items:center}.nsh{--color: DarkSlateGray;--size: 20px;--relSize: calc(var(--size) * .9);--font: "Helvetica", "Arial", sans-serif;--weight: 400;--bg: rgba(255, 255, 255, .8);--zIdx: 999999999;--blur: blur(10px)}.nsh{position:relative;z-index:var(--zIdx)}.nsh:before{position:absolute;background-color:var(--bg);content:"";backdrop-filter:var(--blur);-webkit-backdrop-filter:var(--blur);z-index:calc(var(--zIdx) + 1);border-radius:inherit}body.nsh{height:100vh}.ns{position:absolute;z-index:calc(var(--zIdx) + 2)}.nsc{filter:drop-shadow(0 0 .1rem rgba(211,211,211,.5))}.nst{color:var(--color);font-size:var(--size);font-family:var(--font);font-weight:var(--weight);margin-right:var(--relSize);text-shadow:0 0 .06rem rgba(47,79,79,.25)}.nss{display:block;width:var(--relSize);height:var(--relSize)}.nss>svg{animation:Rotate 2s linear infinite;position:relative;width:inherit;height:inherit;stroke-width:8}.nss .path{stroke:var(--color);stroke-linecap:round;animation:Dash 1.5s ease-in-out infinite}@keyframes Rotate{to{transform:rotate(360deg)}}@keyframes Dash{0%{stroke-dasharray:1,150;stroke-dashoffset:0}50%{stroke-dasharray:90,150;stroke-dashoffset:-35}to{stroke-dasharray:90,150;stroke-dashoffset:-124}}
|
|
2
2
|
`;class S{constructor(){o(this,"queue");this.queue=[]}enqueue(e){return this.queue.push(e),this}dequeue(){return this.queue.shift()}get(e){return this.queue.find(n=>n.getId()===e)}delete(e){const n=this.queue.findIndex(r=>r.getId()===e);if(n!==-1)return this.queue.splice(n,1)[0]}}const i=class i{constructor(){o(this,"version");o(this,"nsQueue");this.version=l,this.nsQueue=new S,i.addStyle()}static addStyle(){const e=a(`<style>${k}</style>`);document.body.append(e)}static getInstance(){return i.instance||(i.instance=new i),i.instance}static assignToWindow(){Object.defineProperty(window,i.WindowAccessorKey,{value:i.getInstance(),writable:!1})}static start(){window[i.WindowAccessorKey]||i.assignToWindow()}createNS(e){const n=new s().setText(e||"");return this.nsQueue.enqueue(n),n}cleanAndRemoveFromDOM(e){var n;return e?(f(((n=e.getElement())==null?void 0:n.parentElement)??null),e.delete()):!1}deleteNS(e){return this.cleanAndRemoveFromDOM(this.nsQueue.delete(e)??null)}show(e){return this.showInside(document.body,e)}showInside(e,n){try{const r=x(e),h=g(r)??this.createNS();I(h.getElement(),r);const d=n?String(n):"";return h.setText(d).getId()}catch(r){return console.error(r),null}}hide(){const e=this.nsQueue.dequeue();return e?(this.cleanAndRemoveFromDOM(e),e.getId()):null}hideAll(){let e=this.nsQueue.dequeue();for(;e;)this.cleanAndRemoveFromDOM(e),e=this.nsQueue.dequeue()}hideId(e){return this.deleteNS(e)?e:null}hideInside(e){try{const n=g(x(e)),r=(n==null?void 0:n.getId())??"";return this.deleteNS(r??"")?r:null}catch(n){return console.error(n),null}}};o(i,"WindowAccessorKey","ns"),o(i,"instance");let u=i;try{u.start()}catch(t){console.warn(t)}})();
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Small bundle size
|
|
4
4
|
|
|
5
|
-
The Nanosplash bundle is
|
|
5
|
+
The Nanosplash bundle is less than 3KB minified and gzipped and will not add any significant weight to your application what so ever. Go to [Bundlephobia](https://bundlephobia.com/package/nanosplash) to see for yourself.
|
|
6
6
|
|
|
7
7
|
## Simple API
|
|
8
8
|
|
|
@@ -8,14 +8,14 @@ Nanosplash can be installed either via CDN or NPM. Installing via CDN is easier
|
|
|
8
8
|
|
|
9
9
|
## CSS
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
CSS is included inside the JS bundle. 🎉
|
|
12
12
|
|
|
13
13
|
## Install via CDN
|
|
14
14
|
|
|
15
15
|
Add the following script tag to the `<head>` of your HTML document:
|
|
16
16
|
|
|
17
17
|
```html
|
|
18
|
-
<script src="https://unpkg.com/nanosplash
|
|
18
|
+
<script src="https://unpkg.com/nanosplash/dist/iife/ns.iife.js"></script>
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
```html{5}
|
|
@@ -23,7 +23,7 @@ Add the following script tag to the `<head>` of your HTML document:
|
|
|
23
23
|
<head>
|
|
24
24
|
<meta charset="UTF-8" />
|
|
25
25
|
<title>My awesome application 🚀</title>
|
|
26
|
-
<script src="https://unpkg.com/nanosplash
|
|
26
|
+
<script src="https://unpkg.com/nanosplash/dist/iife/ns.iife.js"></script>
|
|
27
27
|
</head>
|
|
28
28
|
...
|
|
29
29
|
</html>
|
package/docs/index.md
CHANGED
|
@@ -10,13 +10,16 @@ hero:
|
|
|
10
10
|
- theme: brand
|
|
11
11
|
text: Get started
|
|
12
12
|
link: /api/start/install.md
|
|
13
|
+
- theme: alt
|
|
14
|
+
text: Playground
|
|
15
|
+
link: /api/start/playground.md
|
|
13
16
|
- theme: alt
|
|
14
17
|
text: API Documentation
|
|
15
18
|
link: /api/doc/show.md
|
|
16
19
|
|
|
17
20
|
features:
|
|
18
21
|
- title: 📦 Tiny
|
|
19
|
-
details:
|
|
22
|
+
details: Less than 3KB minified and gzipped.
|
|
20
23
|
link: /api/start/features#small-bundle-size
|
|
21
24
|
- title: 🍼 Simple API
|
|
22
25
|
details: Start using Nanosplash in seconds.
|