nanosplash 3.0.8 → 3.0.9
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/.prettierrc +1 -1
- package/README.md +1 -1
- package/bun.lockb +0 -0
- package/dist/cjs/ns.cjs +1 -2
- package/dist/es/ns.js +61 -340
- package/dist/iife/ns.iife.js +1 -2
- package/docs/.vitepress/{config.ts → config.mts} +41 -43
- package/docs/.vitepress/theme/css/style.css +107 -6
- package/docs/.vitepress/theme/vue/CardGrid.vue +1 -1
- package/docs/.vitepress/theme/vue/Exe.vue +58 -28
- package/docs/.vitepress/theme/vue/PlayGround.vue +5 -21
- package/docs/api/doc/hide.md +10 -31
- package/docs/api/doc/show.md +12 -13
- package/docs/api/start/features.md +1 -1
- package/docs/api/start/install.md +6 -4
- package/docs/api/start/playground.md +1 -1
- package/docs/api/start/usage.md +2 -5
- package/docs/index.md +25 -25
- package/docs/public/macos.jpg +0 -0
- package/eslint.config.js +9 -0
- package/package.json +54 -48
- package/src/style/ns.sass +100 -70
- package/src/ts/Nanosplash.ts +219 -0
- package/src/ts/main.ts +2 -8
- package/src/ts/types/NanosplashInterface.ts +7 -0
- package/src/ts/types/Types.ts +28 -3
- package/src/ts/types/global.d.ts +9 -9
- package/tests/Nanosplash.spec.ts +35 -0
- package/.prettierignore +0 -1
- package/src/ts/core/DomUtilities.ts +0 -161
- package/src/ts/core/Service.ts +0 -211
- package/src/ts/core/ServiceInterface.ts +0 -58
- package/src/ts/core/Splash.ts +0 -121
- package/src/ts/core/SplashInterface.ts +0 -46
- package/src/ts/core/SplashQueue.ts +0 -49
- package/tests/DomUtilities.spec.ts +0 -117
- package/tests/Guid.spec.ts +0 -21
- package/tests/Service.spec.ts +0 -198
- package/tests/Splash.spec.ts +0 -64
- package/tests/TestUtilities.ts +0 -48
package/.prettierrc
CHANGED
package/README.md
CHANGED
package/bun.lockb
CHANGED
|
Binary file
|
package/dist/cjs/ns.cjs
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
"use strict";
|
|
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;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p='@keyframes ns-rotate{to{transform:rotate(360deg)}}@keyframes ns-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}}@keyframes ns-fade{0%{opacity:0}to{opacity:1}}@keyframes ns-ascend{0%{opacity:0;transform:translateY(13px)}to{opacity:1;transform:translateY(0)}}:root{--ns-top: 0px}.ns,body.nsh,body.nsh:before,.nsh:before{width:100%;height:100%}.ns,.nsh:before{bottom:0;right: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, .9);--zIdx: 999999999;--blur: blur(5px)}.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,body.nsh:before{position:fixed;top:var(--ns-top);left:0}.ns{position:absolute;z-index:calc(var(--zIdx) + 2);animation:ns-fade 2s}.nsc{filter:drop-shadow(0 0 .07rem rgba(0,0,0,.25))}.nst{color:var(--color);font-size:var(--size);font-family:var(--font);font-weight:var(--weight);font-optical-sizing:auto;max-width:80dvw;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;margin-right:var(--relSize);text-shadow:0 0 .06rem rgba(47,79,79,.25);animation:ns-ascend .5s}.nss{display:block;width:var(--relSize);height:var(--relSize);animation:ns-ascend .5s}.nss>svg{animation:ns-rotate 2s linear infinite;position:relative;width:inherit;height:inherit;stroke-width:8}.nss .path{stroke:var(--color);stroke-linecap:round;animation:ns-dash 1.5s ease-in-out infinite}',u="3.0.8",m="nscss",a=e=>{const t=s=>Array.from(e.querySelectorAll(s));return{all:t,first:s=>t(s)[0]??null}},c=e=>a(document).all(e),l=e=>a(document).first(e),d=()=>c(".ns"),y=e=>{if(e instanceof Element)return e;const t=l(e);if(!t)throw new Error(`Selector (${e}) returned null`);return t},o=(e,...t)=>{const s=document.createElement("div");return e&&s.classList.add(e),s.append(...t),s},f=e=>{const t=o();return t.innerHTML=e,t.firstChild},v=()=>{const t=f('<svg viewBox="0 0 50 50"><circle class=path cx=25 cy=25 r=20 fill=none /></svg>'),s=o("ns",o("nsc",o("nst"),o("nss",t)));return s.nsId=Date.now(),s},b=()=>d().sort((e,t)=>e.nsId-t.nsId)[0]??null,w=(e,t)=>{const s=a(e),n=s.first(".nst");if(!t)return n==null?void 0:n.remove();const r=o("nst",t);if(n)n.replaceWith(r);else{const i=s.first(".nsc");i.insertBefore(r,i.firstChild)}},g=(e,t)=>{const s=t.firstElementChild;s&&t.insertBefore(e,s),t.append(e),t.classList.add("nsh")},k=(e,t)=>{const s=t?y(t):document.body;let n;const r=a(s).first("& > .ns");r?n=r:(n=v(),g(n,s)),w(n,e??"");const i=window.scrollY+"px";return window.document.body.style.setProperty("--ns-top",i),n.nsId},h=e=>{var t;(t=e==null?void 0:e.parentElement)==null||t.classList.remove("nsh"),e==null||e.remove()},x=e=>d().find(t=>t.nsId===e)??null,S=e=>{const t=e?x(e):b();h(t)},z=()=>c(".ns").forEach(h),I=()=>{var t;(t=l("#nscss"))==null||t.remove();const e=`<style id=${m}>${p}</style>`;document.body.append(f(e))},N=()=>(I(),window.ns=Object.freeze({show:k,hide:S,hideAll:z,version:u}));exports.useNs=N;
|
package/dist/es/ns.js
CHANGED
|
@@ -1,342 +1,63 @@
|
|
|
1
|
-
var m =
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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 };
|
|
1
|
+
const p = '@keyframes ns-rotate{to{transform:rotate(360deg)}}@keyframes ns-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}}@keyframes ns-fade{0%{opacity:0}to{opacity:1}}@keyframes ns-ascend{0%{opacity:0;transform:translateY(13px)}to{opacity:1;transform:translateY(0)}}:root{--ns-top: 0px}.ns,body.nsh,body.nsh:before,.nsh:before{width:100%;height:100%}.ns,.nsh:before{bottom:0;right: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, .9);--zIdx: 999999999;--blur: blur(5px)}.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,body.nsh:before{position:fixed;top:var(--ns-top);left:0}.ns{position:absolute;z-index:calc(var(--zIdx) + 2);animation:ns-fade 2s}.nsc{filter:drop-shadow(0 0 .07rem rgba(0,0,0,.25))}.nst{color:var(--color);font-size:var(--size);font-family:var(--font);font-weight:var(--weight);font-optical-sizing:auto;max-width:80dvw;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;margin-right:var(--relSize);text-shadow:0 0 .06rem rgba(47,79,79,.25);animation:ns-ascend .5s}.nss{display:block;width:var(--relSize);height:var(--relSize);animation:ns-ascend .5s}.nss>svg{animation:ns-rotate 2s linear infinite;position:relative;width:inherit;height:inherit;stroke-width:8}.nss .path{stroke:var(--color);stroke-linecap:round;animation:ns-dash 1.5s ease-in-out infinite}', m = "3.0.8", u = "nscss", a = (e) => {
|
|
2
|
+
const t = (s) => Array.from(e.querySelectorAll(s));
|
|
3
|
+
return {
|
|
4
|
+
all: t,
|
|
5
|
+
first: (s) => t(s)[0] ?? null
|
|
6
|
+
};
|
|
7
|
+
}, c = (e) => a(document).all(e), l = (e) => a(document).first(e), d = () => c(".ns"), v = (e) => {
|
|
8
|
+
if (e instanceof Element)
|
|
9
|
+
return e;
|
|
10
|
+
const t = l(e);
|
|
11
|
+
if (!t)
|
|
12
|
+
throw new Error(`Selector (${e}) returned null`);
|
|
13
|
+
return t;
|
|
14
|
+
}, o = (e, ...t) => {
|
|
15
|
+
const s = document.createElement("div");
|
|
16
|
+
return e && s.classList.add(e), s.append(...t), s;
|
|
17
|
+
}, f = (e) => {
|
|
18
|
+
const t = o();
|
|
19
|
+
return t.innerHTML = e, t.firstChild;
|
|
20
|
+
}, y = () => {
|
|
21
|
+
const t = f('<svg viewBox="0 0 50 50"><circle class=path cx=25 cy=25 r=20 fill=none /></svg>'), s = o("ns", o("nsc", o("nst"), o("nss", t)));
|
|
22
|
+
return s.nsId = Date.now(), s;
|
|
23
|
+
}, b = () => d().sort((e, t) => e.nsId - t.nsId)[0] ?? null, w = (e, t) => {
|
|
24
|
+
const s = a(e), n = s.first(".nst");
|
|
25
|
+
if (!t)
|
|
26
|
+
return n == null ? void 0 : n.remove();
|
|
27
|
+
const r = o("nst", t);
|
|
28
|
+
if (n)
|
|
29
|
+
n.replaceWith(r);
|
|
30
|
+
else {
|
|
31
|
+
const i = s.first(".nsc");
|
|
32
|
+
i.insertBefore(r, i.firstChild);
|
|
33
|
+
}
|
|
34
|
+
}, g = (e, t) => {
|
|
35
|
+
const s = t.firstElementChild;
|
|
36
|
+
s && t.insertBefore(e, s), t.append(e), t.classList.add("nsh");
|
|
37
|
+
}, k = (e, t) => {
|
|
38
|
+
const s = t ? v(t) : document.body;
|
|
39
|
+
let n;
|
|
40
|
+
const r = a(s).first("& > .ns");
|
|
41
|
+
r ? n = r : (n = y(), g(n, s)), w(n, e ?? "");
|
|
42
|
+
const i = window.scrollY + "px";
|
|
43
|
+
return window.document.body.style.setProperty("--ns-top", i), n.nsId;
|
|
44
|
+
}, h = (e) => {
|
|
45
|
+
var t;
|
|
46
|
+
(t = e == null ? void 0 : e.parentElement) == null || t.classList.remove("nsh"), e == null || e.remove();
|
|
47
|
+
}, x = (e) => d().find((t) => t.nsId === e) ?? null, z = (e) => {
|
|
48
|
+
const t = e ? x(e) : b();
|
|
49
|
+
h(t);
|
|
50
|
+
}, S = () => c(".ns").forEach(h), I = () => {
|
|
51
|
+
var t;
|
|
52
|
+
(t = l("#nscss")) == null || t.remove();
|
|
53
|
+
const e = `<style id=${u}>${p}</style>`;
|
|
54
|
+
document.body.append(f(e));
|
|
55
|
+
}, N = () => (I(), window.ns = Object.freeze({
|
|
56
|
+
show: k,
|
|
57
|
+
hide: z,
|
|
58
|
+
hideAll: S,
|
|
59
|
+
version: m
|
|
60
|
+
}));
|
|
339
61
|
export {
|
|
340
|
-
|
|
341
|
-
q as default
|
|
62
|
+
N as useNs
|
|
342
63
|
};
|
package/dist/iife/ns.iife.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
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)}})();
|
|
1
|
+
(function(){"use strict";const p='@keyframes ns-rotate{to{transform:rotate(360deg)}}@keyframes ns-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}}@keyframes ns-fade{0%{opacity:0}to{opacity:1}}@keyframes ns-ascend{0%{opacity:0;transform:translateY(13px)}to{opacity:1;transform:translateY(0)}}:root{--ns-top: 0px}.ns,body.nsh,body.nsh:before,.nsh:before{width:100%;height:100%}.ns,.nsh:before{bottom:0;right: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, .9);--zIdx: 999999999;--blur: blur(5px)}.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,body.nsh:before{position:fixed;top:var(--ns-top);left:0}.ns{position:absolute;z-index:calc(var(--zIdx) + 2);animation:ns-fade 2s}.nsc{filter:drop-shadow(0 0 .07rem rgba(0,0,0,.25))}.nst{color:var(--color);font-size:var(--size);font-family:var(--font);font-weight:var(--weight);font-optical-sizing:auto;max-width:80dvw;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;margin-right:var(--relSize);text-shadow:0 0 .06rem rgba(47,79,79,.25);animation:ns-ascend .5s}.nss{display:block;width:var(--relSize);height:var(--relSize);animation:ns-ascend .5s}.nss>svg{animation:ns-rotate 2s linear infinite;position:relative;width:inherit;height:inherit;stroke-width:8}.nss .path{stroke:var(--color);stroke-linecap:round;animation:ns-dash 1.5s ease-in-out infinite}',u="3.0.8",m="nscss",i=e=>{const t=s=>Array.from(e.querySelectorAll(s));return{all:t,first:s=>t(s)[0]??null}},c=e=>i(document).all(e),l=e=>i(document).first(e),d=()=>c(".ns"),v=e=>{if(e instanceof Element)return e;const t=l(e);if(!t)throw new Error(`Selector (${e}) returned null`);return t},o=(e,...t)=>{const s=document.createElement("div");return e&&s.classList.add(e),s.append(...t),s},f=e=>{const t=o();return t.innerHTML=e,t.firstChild},y=()=>{const t=f('<svg viewBox="0 0 50 50"><circle class=path cx=25 cy=25 r=20 fill=none /></svg>'),s=o("ns",o("nsc",o("nst"),o("nss",t)));return s.nsId=Date.now(),s},b=()=>d().sort((e,t)=>e.nsId-t.nsId)[0]??null,w=(e,t)=>{const s=i(e),n=s.first(".nst");if(!t)return n==null?void 0:n.remove();const r=o("nst",t);if(n)n.replaceWith(r);else{const a=s.first(".nsc");a.insertBefore(r,a.firstChild)}},g=(e,t)=>{const s=t.firstElementChild;s&&t.insertBefore(e,s),t.append(e),t.classList.add("nsh")},k=(e,t)=>{const s=t?v(t):document.body;let n;const r=i(s).first("& > .ns");r?n=r:(n=y(),g(n,s)),w(n,e??"");const a=window.scrollY+"px";return window.document.body.style.setProperty("--ns-top",a),n.nsId},h=e=>{var t;(t=e==null?void 0:e.parentElement)==null||t.classList.remove("nsh"),e==null||e.remove()},x=e=>d().find(t=>t.nsId===e)??null,z=e=>{const t=e?x(e):b();h(t)},S=()=>c(".ns").forEach(h),I=()=>{var t;(t=l("#nscss"))==null||t.remove();const e=`<style id=${m}>${p}</style>`;document.body.append(f(e))};I(),window.ns=Object.freeze({show:k,hide:z,hideAll:S,version:u})})();
|
|
@@ -14,49 +14,47 @@ export default defineConfig({
|
|
|
14
14
|
{ text: 'API documentation', link: '/api/doc/show' },
|
|
15
15
|
],
|
|
16
16
|
|
|
17
|
-
sidebar:
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
],
|
|
59
|
-
},
|
|
17
|
+
sidebar: [
|
|
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
|
+
],
|
|
60
58
|
|
|
61
59
|
socialLinks: [
|
|
62
60
|
{ icon: 'github', link: 'https://github.com/isakhauge/nanosplash' },
|