nanosplash 3.0.1 → 3.0.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.
- package/.github/workflows/ci.yml +50 -44
- package/.github/workflows/vitepress.yml +69 -0
- package/.prettierignore +1 -0
- package/.prettierrc +10 -10
- package/README.md +11 -172
- package/bun.lockb +0 -0
- package/coverage/{core/Dom.ts.html → DomUtilities.ts.html} +141 -138
- package/coverage/{core/Service.ts.html → Service.ts.html} +250 -322
- package/coverage/{core/Splash.ts.html → Splash.ts.html} +145 -154
- package/coverage/SplashQueue.ts.html +232 -0
- package/coverage/clover.xml +557 -552
- package/coverage/coverage-final.json +5 -9043
- package/coverage/index.html +53 -23
- package/dist/cjs/ns.cjs +2 -0
- package/dist/es/ns.js +342 -0
- package/dist/iife/ns.iife.js +2 -0
- package/docs/.vitepress/config.ts +75 -0
- package/docs/.vitepress/theme/css/style.css +157 -0
- package/docs/.vitepress/theme/index.ts +16 -0
- package/docs/.vitepress/theme/vue/Card.vue +31 -0
- package/docs/.vitepress/theme/vue/CardGrid.vue +17 -0
- package/docs/.vitepress/theme/vue/Exe.vue +86 -0
- package/docs/.vitepress/theme/vue/PlayGround.vue +50 -0
- package/docs/api/doc/hide.md +69 -0
- package/docs/api/doc/show.md +47 -0
- package/docs/api/start/features.md +17 -0
- package/docs/api/start/install.md +53 -0
- package/docs/api/start/playground.md +11 -0
- package/docs/api/start/usage.md +25 -0
- package/docs/index.md +30 -0
- package/package.json +86 -87
- package/src/style/ns.sass +95 -0
- package/src/ts/core/{Dom.ts → DomUtilities.ts} +58 -57
- package/src/ts/core/Service.ts +66 -90
- package/src/ts/core/ServiceInterface.ts +5 -7
- package/src/ts/core/Splash.ts +23 -26
- package/src/ts/core/SplashInterface.ts +12 -20
- package/src/ts/core/SplashQueue.ts +49 -0
- package/src/ts/types/Types.ts +0 -9
- package/tests/{Dom.spec.ts → DomUtilities.spec.ts} +13 -23
- package/tests/Guid.spec.ts +3 -3
- package/tests/Service.spec.ts +146 -67
- package/tests/Splash.spec.ts +26 -26
- package/tests/TestUtilities.ts +48 -0
- package/tsconfig.json +1 -0
- package/vite.config.ts +1 -15
- package/coverage/core/index.html +0 -146
- package/coverage/types/Types.ts.html +0 -121
- package/coverage/types/index.html +0 -116
- package/dist/latest/cjs/ns.cjs +0 -1
- package/dist/latest/cjs/style.css +0 -1
- package/dist/latest/es/ns.js +0 -306
- package/dist/latest/es/style.css +0 -1
- package/dist/latest/iife/ns.iife.js +0 -4
- package/dist/versioned/3.0.1/cjs/ns.cjs +0 -1
- package/dist/versioned/3.0.1/cjs/style.css +0 -1
- package/dist/versioned/3.0.1/es/ns.js +0 -306
- package/dist/versioned/3.0.1/es/style.css +0 -1
- package/dist/versioned/3.0.1/iife/ns.iife.js +0 -2
- package/docs/index.6d66a821.js +0 -1
- package/docs/index.74dbd99e.css +0 -1
- package/docs/index.f34144dc.js +0 -1
- package/docs/index.html +0 -107
- package/index.html +0 -105
- package/src/sass/ns.sass +0 -95
- package/vite.demo.config.ts +0 -16
package/coverage/index.html
CHANGED
|
@@ -23,30 +23,30 @@
|
|
|
23
23
|
<div class='clearfix'>
|
|
24
24
|
|
|
25
25
|
<div class='fl pad1y space-right2'>
|
|
26
|
-
<span class="strong">
|
|
26
|
+
<span class="strong">97.6% </span>
|
|
27
27
|
<span class="quiet">Statements</span>
|
|
28
|
-
<span class='fraction'>
|
|
28
|
+
<span class='fraction'>529/542</span>
|
|
29
29
|
</div>
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
<div class='fl pad1y space-right2'>
|
|
33
|
-
<span class="strong">
|
|
33
|
+
<span class="strong">78.75% </span>
|
|
34
34
|
<span class="quiet">Branches</span>
|
|
35
|
-
<span class='fraction'>
|
|
35
|
+
<span class='fraction'>63/80</span>
|
|
36
36
|
</div>
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
<div class='fl pad1y space-right2'>
|
|
40
40
|
<span class="strong">100% </span>
|
|
41
41
|
<span class="quiet">Functions</span>
|
|
42
|
-
<span class='fraction'>
|
|
42
|
+
<span class='fraction'>43/43</span>
|
|
43
43
|
</div>
|
|
44
44
|
|
|
45
45
|
|
|
46
46
|
<div class='fl pad1y space-right2'>
|
|
47
|
-
<span class="strong">
|
|
47
|
+
<span class="strong">97.6% </span>
|
|
48
48
|
<span class="quiet">Lines</span>
|
|
49
|
-
<span class='fraction'>
|
|
49
|
+
<span class='fraction'>529/542</span>
|
|
50
50
|
</div>
|
|
51
51
|
|
|
52
52
|
|
|
@@ -79,33 +79,63 @@
|
|
|
79
79
|
</tr>
|
|
80
80
|
</thead>
|
|
81
81
|
<tbody><tr>
|
|
82
|
-
<td class="file high" data-value="
|
|
83
|
-
<td data-value="
|
|
82
|
+
<td class="file high" data-value="DomUtilities.ts"><a href="DomUtilities.ts.html">DomUtilities.ts</a></td>
|
|
83
|
+
<td data-value="96.89" class="pic high">
|
|
84
|
+
<div class="chart"><div class="cover-fill" style="width: 96%"></div><div class="cover-empty" style="width: 4%"></div></div>
|
|
85
|
+
</td>
|
|
86
|
+
<td data-value="96.89" class="pct high">96.89%</td>
|
|
87
|
+
<td data-value="161" class="abs high">156/161</td>
|
|
88
|
+
<td data-value="78.26" class="pct medium">78.26%</td>
|
|
89
|
+
<td data-value="23" class="abs medium">18/23</td>
|
|
90
|
+
<td data-value="100" class="pct high">100%</td>
|
|
91
|
+
<td data-value="10" class="abs high">10/10</td>
|
|
92
|
+
<td data-value="96.89" class="pct high">96.89%</td>
|
|
93
|
+
<td data-value="161" class="abs high">156/161</td>
|
|
94
|
+
</tr>
|
|
95
|
+
|
|
96
|
+
<tr>
|
|
97
|
+
<td class="file high" data-value="Service.ts"><a href="Service.ts.html">Service.ts</a></td>
|
|
98
|
+
<td data-value="96.68" class="pic high">
|
|
99
|
+
<div class="chart"><div class="cover-fill" style="width: 96%"></div><div class="cover-empty" style="width: 4%"></div></div>
|
|
100
|
+
</td>
|
|
101
|
+
<td data-value="96.68" class="pct high">96.68%</td>
|
|
102
|
+
<td data-value="211" class="abs high">204/211</td>
|
|
103
|
+
<td data-value="67.74" class="pct medium">67.74%</td>
|
|
104
|
+
<td data-value="31" class="abs medium">21/31</td>
|
|
105
|
+
<td data-value="100" class="pct high">100%</td>
|
|
106
|
+
<td data-value="16" class="abs high">16/16</td>
|
|
107
|
+
<td data-value="96.68" class="pct high">96.68%</td>
|
|
108
|
+
<td data-value="211" class="abs high">204/211</td>
|
|
109
|
+
</tr>
|
|
110
|
+
|
|
111
|
+
<tr>
|
|
112
|
+
<td class="file high" data-value="Splash.ts"><a href="Splash.ts.html">Splash.ts</a></td>
|
|
113
|
+
<td data-value="99.17" class="pic high">
|
|
84
114
|
<div class="chart"><div class="cover-fill" style="width: 99%"></div><div class="cover-empty" style="width: 1%"></div></div>
|
|
85
115
|
</td>
|
|
86
|
-
<td data-value="99.
|
|
87
|
-
<td data-value="
|
|
88
|
-
<td data-value="
|
|
89
|
-
<td data-value="
|
|
116
|
+
<td data-value="99.17" class="pct high">99.17%</td>
|
|
117
|
+
<td data-value="121" class="abs high">120/121</td>
|
|
118
|
+
<td data-value="94.11" class="pct high">94.11%</td>
|
|
119
|
+
<td data-value="17" class="abs high">16/17</td>
|
|
90
120
|
<td data-value="100" class="pct high">100%</td>
|
|
91
|
-
<td data-value="
|
|
92
|
-
<td data-value="99.
|
|
93
|
-
<td data-value="
|
|
121
|
+
<td data-value="11" class="abs high">11/11</td>
|
|
122
|
+
<td data-value="99.17" class="pct high">99.17%</td>
|
|
123
|
+
<td data-value="121" class="abs high">120/121</td>
|
|
94
124
|
</tr>
|
|
95
125
|
|
|
96
126
|
<tr>
|
|
97
|
-
<td class="file high" data-value="
|
|
127
|
+
<td class="file high" data-value="SplashQueue.ts"><a href="SplashQueue.ts.html">SplashQueue.ts</a></td>
|
|
98
128
|
<td data-value="100" class="pic high">
|
|
99
129
|
<div class="chart"><div class="cover-fill cover-full" style="width: 100%"></div><div class="cover-empty" style="width: 0%"></div></div>
|
|
100
130
|
</td>
|
|
101
131
|
<td data-value="100" class="pct high">100%</td>
|
|
102
|
-
<td data-value="
|
|
103
|
-
<td data-value="
|
|
104
|
-
<td data-value="
|
|
132
|
+
<td data-value="49" class="abs high">49/49</td>
|
|
133
|
+
<td data-value="88.88" class="pct high">88.88%</td>
|
|
134
|
+
<td data-value="9" class="abs high">8/9</td>
|
|
105
135
|
<td data-value="100" class="pct high">100%</td>
|
|
106
|
-
<td data-value="
|
|
136
|
+
<td data-value="6" class="abs high">6/6</td>
|
|
107
137
|
<td data-value="100" class="pct high">100%</td>
|
|
108
|
-
<td data-value="
|
|
138
|
+
<td data-value="49" class="abs high">49/49</td>
|
|
109
139
|
</tr>
|
|
110
140
|
|
|
111
141
|
</tbody>
|
|
@@ -116,7 +146,7 @@
|
|
|
116
146
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
117
147
|
Code coverage generated by
|
|
118
148
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
119
|
-
at 2023-
|
|
149
|
+
at 2023-10-19T21:38:28.926Z
|
|
120
150
|
</div>
|
|
121
151
|
<script src="prettify.js"></script>
|
|
122
152
|
<script>
|
package/dist/cjs/ns.cjs
ADDED
|
@@ -0,0 +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",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
|
+
`;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
ADDED
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
var m = Object.defineProperty;
|
|
2
|
+
var v = (s, e, t) => e in s ? m(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
|
|
3
|
+
var r = (s, e, t) => (v(s, typeof e != "symbol" ? e + "" : e, t), t);
|
|
4
|
+
const y = "3.0.1", a = class a {
|
|
5
|
+
/**
|
|
6
|
+
* # Constructor
|
|
7
|
+
* Creates a new Nanosplash instance.
|
|
8
|
+
*/
|
|
9
|
+
constructor() {
|
|
10
|
+
/**
|
|
11
|
+
* # ID
|
|
12
|
+
* Each Nanosplash instance is given a unique GUID.
|
|
13
|
+
*/
|
|
14
|
+
r(this, "id");
|
|
15
|
+
/**
|
|
16
|
+
* # Element
|
|
17
|
+
* The root element of the Nanosplash component.
|
|
18
|
+
*/
|
|
19
|
+
r(this, "element");
|
|
20
|
+
this.element = w(), this.element.id = this.id = a.generateGUID();
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* # Generate GUID
|
|
24
|
+
* @returns {GUIDString} A GUID string.
|
|
25
|
+
* @private
|
|
26
|
+
*/
|
|
27
|
+
static generateGUID() {
|
|
28
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (e) => {
|
|
29
|
+
const t = Math.random() * 16 | 0;
|
|
30
|
+
return (e === "x" ? t : t & 3 | 8).toString(16);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* @inheritdoc
|
|
35
|
+
*/
|
|
36
|
+
getId() {
|
|
37
|
+
return this.id;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* @inheritdoc
|
|
41
|
+
*/
|
|
42
|
+
getElement() {
|
|
43
|
+
return this.element;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* @inheritdoc
|
|
47
|
+
*/
|
|
48
|
+
getTextElement() {
|
|
49
|
+
var e, t;
|
|
50
|
+
return ((t = (e = this.getElement()) == null ? void 0 : e.firstElementChild) == null ? void 0 : t.firstElementChild) ?? null;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* @inheritdoc
|
|
54
|
+
*/
|
|
55
|
+
setText(e) {
|
|
56
|
+
return this.getTextElement().innerText = e, e.length > 0 ? this.showText() : this.hideText(), this;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* @inheritdoc
|
|
60
|
+
*/
|
|
61
|
+
showText() {
|
|
62
|
+
return I(this.getTextElement()), this;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* @inheritdoc
|
|
66
|
+
*/
|
|
67
|
+
hideText() {
|
|
68
|
+
return S(this.getTextElement()), this;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* @inheritdoc
|
|
72
|
+
*/
|
|
73
|
+
delete() {
|
|
74
|
+
return this.id = null, this.element !== null && (this.element.innerHTML = "", this.element.remove(), this.element = null), this.element === null;
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* # CSS Class Name
|
|
79
|
+
* The main CSS class name of the root element of a Nanosplash component.
|
|
80
|
+
*/
|
|
81
|
+
r(a, "NSClass", "ns"), /**
|
|
82
|
+
* # Host CSS Class Name
|
|
83
|
+
* The CSS class name of the host element of a Nanosplash component.
|
|
84
|
+
* The host element is the element that the Nanosplash is attached to.
|
|
85
|
+
*/
|
|
86
|
+
r(a, "NSHostClass", "nsh");
|
|
87
|
+
let o = a;
|
|
88
|
+
function x(s) {
|
|
89
|
+
return ((e) => (
|
|
90
|
+
// @ts-ignore
|
|
91
|
+
(() => e.firstChild)(e.innerHTML = s)
|
|
92
|
+
))(
|
|
93
|
+
document.createElement("div")
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
function w() {
|
|
97
|
+
return x(
|
|
98
|
+
'<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>'
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
function b(s, e) {
|
|
102
|
+
e.children.length > 0 ? e.insertBefore(s, e.children.item(0)) : e.append(s);
|
|
103
|
+
}
|
|
104
|
+
function p(s) {
|
|
105
|
+
s == null || s.classList.add(o.NSHostClass);
|
|
106
|
+
}
|
|
107
|
+
function g(s) {
|
|
108
|
+
s == null || s.classList.remove(o.NSHostClass);
|
|
109
|
+
}
|
|
110
|
+
function I(s) {
|
|
111
|
+
s.style.display = "flex";
|
|
112
|
+
}
|
|
113
|
+
function S(s) {
|
|
114
|
+
s.style.display = "none";
|
|
115
|
+
}
|
|
116
|
+
function h(s) {
|
|
117
|
+
switch (typeof s) {
|
|
118
|
+
case "object":
|
|
119
|
+
const e = s === document.body, t = s instanceof Element;
|
|
120
|
+
if (e || t)
|
|
121
|
+
return s;
|
|
122
|
+
throw new Error(
|
|
123
|
+
"Reference is an object but not an Element instance."
|
|
124
|
+
);
|
|
125
|
+
case "string":
|
|
126
|
+
return document.querySelector(s);
|
|
127
|
+
default:
|
|
128
|
+
throw new Error("Reference is not an object or a string.");
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
function k(s, e) {
|
|
132
|
+
g(s.parentElement), p(e), b(s, e);
|
|
133
|
+
}
|
|
134
|
+
function f(s) {
|
|
135
|
+
const e = Array.from(s.children || []), t = d.getInstance();
|
|
136
|
+
let n = null;
|
|
137
|
+
const c = e.length;
|
|
138
|
+
for (let l = 0; l < c; l++) {
|
|
139
|
+
const u = e[l];
|
|
140
|
+
if (u.classList.contains(o.NSClass)) {
|
|
141
|
+
n = t.nsQueue.get(u.id) ?? null;
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return n;
|
|
146
|
+
}
|
|
147
|
+
const E = `.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}}
|
|
148
|
+
`;
|
|
149
|
+
class T {
|
|
150
|
+
constructor() {
|
|
151
|
+
r(this, "queue");
|
|
152
|
+
this.queue = [];
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* # Enqueue
|
|
156
|
+
* Add a new item to the queue.
|
|
157
|
+
* @param item The item to add to the queue.
|
|
158
|
+
*/
|
|
159
|
+
enqueue(e) {
|
|
160
|
+
return this.queue.push(e), this;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* # Dequeue
|
|
164
|
+
* Remove the first item from the queue.
|
|
165
|
+
* @returns The first item from the queue.
|
|
166
|
+
*/
|
|
167
|
+
dequeue() {
|
|
168
|
+
return this.queue.shift();
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* # Get
|
|
172
|
+
* @param id The GUID of the Nanosplash to get.
|
|
173
|
+
* @returns The Nanosplash with the given GUID.
|
|
174
|
+
*/
|
|
175
|
+
get(e) {
|
|
176
|
+
return this.queue.find((t) => t.getId() === e);
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* # Delete
|
|
180
|
+
* @param id The GUID of the Nanosplash to delete.
|
|
181
|
+
* @returns The deleted Nanosplash.
|
|
182
|
+
*/
|
|
183
|
+
delete(e) {
|
|
184
|
+
const t = this.queue.findIndex((n) => n.getId() === e);
|
|
185
|
+
if (t !== -1)
|
|
186
|
+
return this.queue.splice(t, 1)[0];
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
const i = class i {
|
|
190
|
+
/**
|
|
191
|
+
* # Constructor
|
|
192
|
+
* Private constructor to prevent multiple instances.
|
|
193
|
+
* @private
|
|
194
|
+
*/
|
|
195
|
+
constructor() {
|
|
196
|
+
/**
|
|
197
|
+
* # Version
|
|
198
|
+
*/
|
|
199
|
+
r(this, "version");
|
|
200
|
+
/**
|
|
201
|
+
* @inheritdoc
|
|
202
|
+
*/
|
|
203
|
+
r(this, "nsQueue");
|
|
204
|
+
this.version = y, this.nsQueue = new T(), i.addStyle();
|
|
205
|
+
}
|
|
206
|
+
/**e
|
|
207
|
+
* # Add Style
|
|
208
|
+
* Add Nanosplash CSS to the DOM.
|
|
209
|
+
*/
|
|
210
|
+
static addStyle() {
|
|
211
|
+
const e = x(`<style>${E}</style>`);
|
|
212
|
+
document.body.append(e);
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* # Get Instance
|
|
216
|
+
* Singleton instance accessor
|
|
217
|
+
* @returns {Service} NanosplashService instance
|
|
218
|
+
*/
|
|
219
|
+
static getInstance() {
|
|
220
|
+
return i.instance || (i.instance = new i()), i.instance;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* # Assign To Window
|
|
224
|
+
* Assign a NanosplashService instance to the Window object.
|
|
225
|
+
* The NanosplashService instance can be accessed in the window object
|
|
226
|
+
* using the key window accessor key.
|
|
227
|
+
* @see WindowAccessorKey
|
|
228
|
+
* @private
|
|
229
|
+
*/
|
|
230
|
+
static assignToWindow() {
|
|
231
|
+
Object.defineProperty(window, i.WindowAccessorKey, {
|
|
232
|
+
value: i.getInstance(),
|
|
233
|
+
writable: !1
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* # Start
|
|
238
|
+
* Initialize and attach a Nanosplash Service instance to the Window object.
|
|
239
|
+
*/
|
|
240
|
+
static start() {
|
|
241
|
+
window[i.WindowAccessorKey] || i.assignToWindow();
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* # Create Nanosplash
|
|
245
|
+
* Return new Nanosplash instance and push it to the stack.
|
|
246
|
+
* @param text Text to display.
|
|
247
|
+
* @returns {Splash} Nanosplash instance.
|
|
248
|
+
* @private
|
|
249
|
+
*/
|
|
250
|
+
createNS(e) {
|
|
251
|
+
const t = new o().setText(e || "");
|
|
252
|
+
return this.nsQueue.enqueue(t), t;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* # Clean And Remove From DOM
|
|
256
|
+
* Remove Nanosplash from DOM and clean its parent.
|
|
257
|
+
* @param ns Nanosplash instance.
|
|
258
|
+
* @returns True if Nanosplash was removed from DOM.
|
|
259
|
+
* @private
|
|
260
|
+
*/
|
|
261
|
+
cleanAndRemoveFromDOM(e) {
|
|
262
|
+
var t;
|
|
263
|
+
return e ? (g(((t = e.getElement()) == null ? void 0 : t.parentElement) ?? null), e.delete()) : !1;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* # Delete NS
|
|
267
|
+
* Remove Nanosplash instance from both the stack and the
|
|
268
|
+
* @param guid Nanosplash ID.
|
|
269
|
+
* @returns True if Nanosplash was removed from DOM.
|
|
270
|
+
* @private
|
|
271
|
+
*/
|
|
272
|
+
deleteNS(e) {
|
|
273
|
+
return this.cleanAndRemoveFromDOM(this.nsQueue.delete(e) ?? null);
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* @inheritdoc
|
|
277
|
+
*/
|
|
278
|
+
show(e) {
|
|
279
|
+
return this.showInside(document.body, e);
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* @inheritdoc
|
|
283
|
+
*/
|
|
284
|
+
showInside(e, t) {
|
|
285
|
+
try {
|
|
286
|
+
const n = h(e), c = f(n) ?? this.createNS();
|
|
287
|
+
k(c.getElement(), n);
|
|
288
|
+
const l = t ? String(t) : "";
|
|
289
|
+
return c.setText(l).getId();
|
|
290
|
+
} catch (n) {
|
|
291
|
+
return console.error(n), null;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* @inheritdoc
|
|
296
|
+
*/
|
|
297
|
+
hide() {
|
|
298
|
+
const e = this.nsQueue.dequeue();
|
|
299
|
+
return e ? (this.cleanAndRemoveFromDOM(e), e.getId()) : null;
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* @inheritdoc
|
|
303
|
+
*/
|
|
304
|
+
hideAll() {
|
|
305
|
+
let e = this.nsQueue.dequeue();
|
|
306
|
+
for (; e; )
|
|
307
|
+
this.cleanAndRemoveFromDOM(e), e = this.nsQueue.dequeue();
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* @inheritdoc
|
|
311
|
+
*/
|
|
312
|
+
hideId(e) {
|
|
313
|
+
return this.deleteNS(e) ? e : null;
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* @inheritdoc
|
|
317
|
+
*/
|
|
318
|
+
hideInside(e) {
|
|
319
|
+
try {
|
|
320
|
+
const t = f(h(e)), n = (t == null ? void 0 : t.getId()) ?? "";
|
|
321
|
+
return this.deleteNS(n ?? "") ? n : null;
|
|
322
|
+
} catch (t) {
|
|
323
|
+
return console.error(t), null;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
};
|
|
327
|
+
/**
|
|
328
|
+
* # Window Accessor Key
|
|
329
|
+
* Key to access NanosplashService instance in the Window object.
|
|
330
|
+
*/
|
|
331
|
+
r(i, "WindowAccessorKey", "ns"), /**
|
|
332
|
+
* # Instance
|
|
333
|
+
* Singleton instance of NanosplashService.
|
|
334
|
+
* @private
|
|
335
|
+
*/
|
|
336
|
+
r(i, "instance");
|
|
337
|
+
let d = i;
|
|
338
|
+
const q = { Service: d };
|
|
339
|
+
export {
|
|
340
|
+
d as Service,
|
|
341
|
+
q as default
|
|
342
|
+
};
|
|
@@ -0,0 +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",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
|
+
`;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)}})();
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { defineConfig } from 'vitepress'
|
|
2
|
+
|
|
3
|
+
// https://vitepress.dev/reference/site-config
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
title: 'Nanosplash',
|
|
6
|
+
description: 'The tiny loading screen for web artisans',
|
|
7
|
+
base: '/nanosplash/',
|
|
8
|
+
themeConfig: {
|
|
9
|
+
nav: [
|
|
10
|
+
{ text: 'Home', link: '/' },
|
|
11
|
+
{ text: 'Get started', link: '/api/start/install' },
|
|
12
|
+
{ text: 'Playground', link: '/api/start/playground' },
|
|
13
|
+
{ text: 'API documentation', link: '/api/doc/show' },
|
|
14
|
+
],
|
|
15
|
+
|
|
16
|
+
sidebar: {
|
|
17
|
+
'/api/': [
|
|
18
|
+
{
|
|
19
|
+
text: 'Get started',
|
|
20
|
+
items: [
|
|
21
|
+
{
|
|
22
|
+
text: 'Installation',
|
|
23
|
+
link: '/api/start/install',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
text: 'Usage',
|
|
27
|
+
link: '/api/start/usage',
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
text: 'Playground',
|
|
31
|
+
link: '/api/start/playground',
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
text: 'API Documentation',
|
|
37
|
+
items: [
|
|
38
|
+
{
|
|
39
|
+
text: 'Methods',
|
|
40
|
+
items: [
|
|
41
|
+
{
|
|
42
|
+
text: 'Show',
|
|
43
|
+
link: '/api/doc/show',
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
text: 'Hide',
|
|
47
|
+
link: '/api/doc/hide',
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
text: 'Features',
|
|
55
|
+
link: '/api/start/features',
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
|
|
60
|
+
socialLinks: [
|
|
61
|
+
{ icon: 'github', link: 'https://github.com/isakhauge/nanosplash' },
|
|
62
|
+
{ icon: 'twitter', link: 'https://twitter.com/isakhauge' },
|
|
63
|
+
{ icon: 'linkedin', link: 'https://www.linkedin.com/in/isakhauge' },
|
|
64
|
+
],
|
|
65
|
+
|
|
66
|
+
search: {
|
|
67
|
+
provider: 'local',
|
|
68
|
+
},
|
|
69
|
+
|
|
70
|
+
footer: {
|
|
71
|
+
message:
|
|
72
|
+
'Made with 🤍 by <a href="https://twitter.com/isakhauge">Isak Hauge</a>',
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
})
|