nanosplash 3.0.2 → 3.0.3
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 +1 -1
- package/README.md +1 -1
- package/bun.lockb +0 -0
- package/coverage/DomUtilities.ts.html +1 -1
- package/coverage/Service.ts.html +1 -1
- package/coverage/Splash.ts.html +1 -1
- package/coverage/SplashQueue.ts.html +1 -1
- package/coverage/clover.xml +2 -2
- package/coverage/index.html +1 -1
- package/dist/cjs/ns.cjs +1 -1
- package/dist/es/ns.js +1 -1
- package/dist/iife/ns.iife.js +1 -1
- package/docs/api/start/features.md +1 -1
- package/docs/api/start/install.md +3 -3
- package/docs/index.md +1 -1
- package/package.json +12 -13
package/README.md
CHANGED
package/bun.lockb
CHANGED
|
Binary file
|
|
@@ -553,7 +553,7 @@ export function getRecycledSplash(targetElement: Element): Splash | null {
|
|
|
553
553
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
554
554
|
Code coverage generated by
|
|
555
555
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
556
|
-
at 2023-10-
|
|
556
|
+
at 2023-10-20T11:24:59.864Z
|
|
557
557
|
</div>
|
|
558
558
|
<script src="prettify.js"></script>
|
|
559
559
|
<script>
|
package/coverage/Service.ts.html
CHANGED
|
@@ -703,7 +703,7 @@ export default { Service }
|
|
|
703
703
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
704
704
|
Code coverage generated by
|
|
705
705
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
706
|
-
at 2023-10-
|
|
706
|
+
at 2023-10-20T11:24:59.864Z
|
|
707
707
|
</div>
|
|
708
708
|
<script src="prettify.js"></script>
|
|
709
709
|
<script>
|
package/coverage/Splash.ts.html
CHANGED
|
@@ -433,7 +433,7 @@ export class Splash implements SplashInterface {
|
|
|
433
433
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
434
434
|
Code coverage generated by
|
|
435
435
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
436
|
-
at 2023-10-
|
|
436
|
+
at 2023-10-20T11:24:59.864Z
|
|
437
437
|
</div>
|
|
438
438
|
<script src="prettify.js"></script>
|
|
439
439
|
<script>
|
|
@@ -217,7 +217,7 @@ export class SplashQueue {
|
|
|
217
217
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
218
218
|
Code coverage generated by
|
|
219
219
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
220
|
-
at 2023-10-
|
|
220
|
+
at 2023-10-20T11:24:59.864Z
|
|
221
221
|
</div>
|
|
222
222
|
<script src="prettify.js"></script>
|
|
223
223
|
<script>
|
package/coverage/clover.xml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<coverage generated="
|
|
3
|
-
<project timestamp="
|
|
2
|
+
<coverage generated="1697801099879" clover="3.2.0">
|
|
3
|
+
<project timestamp="1697801099879" name="All files">
|
|
4
4
|
<metrics statements="542" coveredstatements="529" conditionals="80" coveredconditionals="63" methods="43" coveredmethods="43" elements="665" coveredelements="635" complexity="0" loc="542" ncloc="542" packages="1" files="4" classes="4"/>
|
|
5
5
|
<file name="DomUtilities.ts" path="/home/runner/work/nanosplash/nanosplash/src/ts/core/DomUtilities.ts">
|
|
6
6
|
<metrics statements="161" coveredstatements="156" conditionals="23" coveredconditionals="18" methods="10" coveredmethods="10"/>
|
package/coverage/index.html
CHANGED
|
@@ -146,7 +146,7 @@
|
|
|
146
146
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
147
147
|
Code coverage generated by
|
|
148
148
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
149
|
-
at 2023-10-
|
|
149
|
+
at 2023-10-20T11:24:59.864Z
|
|
150
150
|
</div>
|
|
151
151
|
<script src="prettify.js"></script>
|
|
152
152
|
<script>
|
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.2",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.2", 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.2",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 merely
|
|
5
|
+
The Nanosplash bundle is merely 1.4KB 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
|
-
Since version 3.0.
|
|
11
|
+
Since version 3.0.3, 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@3.0.
|
|
18
|
+
<script src="https://unpkg.com/nanosplash@3.0.3/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@3.0.
|
|
26
|
+
<script src="https://unpkg.com/nanosplash@3.0.3/dist/iife/ns.iife.js"></script>
|
|
27
27
|
</head>
|
|
28
28
|
...
|
|
29
29
|
</html>
|
package/docs/index.md
CHANGED
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "nanosplash",
|
|
3
3
|
"description": "The tiny loading screen for web artisans",
|
|
4
4
|
"private": false,
|
|
5
|
-
"version": "3.0.
|
|
5
|
+
"version": "3.0.3",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"author": {
|
|
8
8
|
"name": "Isak K. Hauge",
|
|
@@ -32,11 +32,10 @@
|
|
|
32
32
|
"url": "https://github.com/isakhauge/nanosplash.git"
|
|
33
33
|
},
|
|
34
34
|
"license": "MIT",
|
|
35
|
-
"main": "./dist/
|
|
36
|
-
"module": "./dist/
|
|
35
|
+
"main": "./dist/es/ns.js",
|
|
36
|
+
"module": "./dist/es/ns.js",
|
|
37
37
|
"source": "./src/main.ts",
|
|
38
|
-
"unpkg": "./dist/
|
|
39
|
-
"style": "./dist/latest/es/style.css",
|
|
38
|
+
"unpkg": "./dist/iife/ns.iife.js",
|
|
40
39
|
"exports": {
|
|
41
40
|
".": {
|
|
42
41
|
"types": {
|
|
@@ -44,12 +43,12 @@
|
|
|
44
43
|
"default": "./src/ts/types/global.d.ts"
|
|
45
44
|
},
|
|
46
45
|
"browser": {
|
|
47
|
-
"require": "./dist/
|
|
48
|
-
"default": "./dist/
|
|
46
|
+
"require": "./dist/cjs/ns.cjs",
|
|
47
|
+
"default": "./dist/es/ns.js"
|
|
49
48
|
},
|
|
50
49
|
"default": {
|
|
51
|
-
"require": "./dist/
|
|
52
|
-
"default": "./dist/
|
|
50
|
+
"require": "./dist/cjs/ns.cjs",
|
|
51
|
+
"default": "./dist/es/ns.js"
|
|
53
52
|
}
|
|
54
53
|
}
|
|
55
54
|
},
|
|
@@ -70,17 +69,17 @@
|
|
|
70
69
|
"docs:preview": "vitepress preview docs"
|
|
71
70
|
},
|
|
72
71
|
"devDependencies": {
|
|
73
|
-
"@types/jsdom": "^21.1.
|
|
74
|
-
"@types/node": "^20.8.
|
|
72
|
+
"@types/jsdom": "^21.1.4",
|
|
73
|
+
"@types/node": "^20.8.7",
|
|
75
74
|
"@types/rollup": "^0.54.0",
|
|
76
75
|
"@vitest/coverage-v8": "^0.34.6",
|
|
77
76
|
"@vitest/ui": "^0.34.6",
|
|
78
77
|
"cross-env": "^7.0.3",
|
|
79
78
|
"jsdom": "^22.1.0",
|
|
80
|
-
"sass": "^1.69.
|
|
79
|
+
"sass": "^1.69.4",
|
|
81
80
|
"terser": "^5.22.0",
|
|
82
81
|
"typescript": "^5.2.2",
|
|
83
|
-
"vite": "^4.
|
|
82
|
+
"vite": "^4.5.0",
|
|
84
83
|
"vitepress": "1.0.0-rc.22",
|
|
85
84
|
"vitest": "^0.34.6"
|
|
86
85
|
}
|