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.
Files changed (66) hide show
  1. package/.github/workflows/ci.yml +50 -44
  2. package/.github/workflows/vitepress.yml +69 -0
  3. package/.prettierignore +1 -0
  4. package/.prettierrc +10 -10
  5. package/README.md +11 -172
  6. package/bun.lockb +0 -0
  7. package/coverage/{core/Dom.ts.html → DomUtilities.ts.html} +141 -138
  8. package/coverage/{core/Service.ts.html → Service.ts.html} +250 -322
  9. package/coverage/{core/Splash.ts.html → Splash.ts.html} +145 -154
  10. package/coverage/SplashQueue.ts.html +232 -0
  11. package/coverage/clover.xml +557 -552
  12. package/coverage/coverage-final.json +5 -9043
  13. package/coverage/index.html +53 -23
  14. package/dist/cjs/ns.cjs +2 -0
  15. package/dist/es/ns.js +342 -0
  16. package/dist/iife/ns.iife.js +2 -0
  17. package/docs/.vitepress/config.ts +75 -0
  18. package/docs/.vitepress/theme/css/style.css +157 -0
  19. package/docs/.vitepress/theme/index.ts +16 -0
  20. package/docs/.vitepress/theme/vue/Card.vue +31 -0
  21. package/docs/.vitepress/theme/vue/CardGrid.vue +17 -0
  22. package/docs/.vitepress/theme/vue/Exe.vue +86 -0
  23. package/docs/.vitepress/theme/vue/PlayGround.vue +50 -0
  24. package/docs/api/doc/hide.md +69 -0
  25. package/docs/api/doc/show.md +47 -0
  26. package/docs/api/start/features.md +17 -0
  27. package/docs/api/start/install.md +53 -0
  28. package/docs/api/start/playground.md +11 -0
  29. package/docs/api/start/usage.md +25 -0
  30. package/docs/index.md +30 -0
  31. package/package.json +86 -87
  32. package/src/style/ns.sass +95 -0
  33. package/src/ts/core/{Dom.ts → DomUtilities.ts} +58 -57
  34. package/src/ts/core/Service.ts +66 -90
  35. package/src/ts/core/ServiceInterface.ts +5 -7
  36. package/src/ts/core/Splash.ts +23 -26
  37. package/src/ts/core/SplashInterface.ts +12 -20
  38. package/src/ts/core/SplashQueue.ts +49 -0
  39. package/src/ts/types/Types.ts +0 -9
  40. package/tests/{Dom.spec.ts → DomUtilities.spec.ts} +13 -23
  41. package/tests/Guid.spec.ts +3 -3
  42. package/tests/Service.spec.ts +146 -67
  43. package/tests/Splash.spec.ts +26 -26
  44. package/tests/TestUtilities.ts +48 -0
  45. package/tsconfig.json +1 -0
  46. package/vite.config.ts +1 -15
  47. package/coverage/core/index.html +0 -146
  48. package/coverage/types/Types.ts.html +0 -121
  49. package/coverage/types/index.html +0 -116
  50. package/dist/latest/cjs/ns.cjs +0 -1
  51. package/dist/latest/cjs/style.css +0 -1
  52. package/dist/latest/es/ns.js +0 -306
  53. package/dist/latest/es/style.css +0 -1
  54. package/dist/latest/iife/ns.iife.js +0 -4
  55. package/dist/versioned/3.0.1/cjs/ns.cjs +0 -1
  56. package/dist/versioned/3.0.1/cjs/style.css +0 -1
  57. package/dist/versioned/3.0.1/es/ns.js +0 -306
  58. package/dist/versioned/3.0.1/es/style.css +0 -1
  59. package/dist/versioned/3.0.1/iife/ns.iife.js +0 -2
  60. package/docs/index.6d66a821.js +0 -1
  61. package/docs/index.74dbd99e.css +0 -1
  62. package/docs/index.f34144dc.js +0 -1
  63. package/docs/index.html +0 -107
  64. package/index.html +0 -105
  65. package/src/sass/ns.sass +0 -95
  66. package/vite.demo.config.ts +0 -16
@@ -1,306 +0,0 @@
1
- var m = Object.defineProperty;
2
- var S = (e, t, n) => t in e ? m(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var r = (e, t, n) => (S(e, typeof t != "symbol" ? t + "" : t, n), n);
4
- const v = "3.0.1";
5
- var o = /* @__PURE__ */ ((e) => (e.Add = "add", e.Remove = "remove", e))(o || {});
6
- const d = class d {
7
- /**
8
- * # Constructor
9
- * Creates a new Nanosplash instance.
10
- */
11
- constructor() {
12
- /**
13
- * # ID
14
- * Each Nanosplash instance is given a unique GUID.
15
- */
16
- r(this, "id");
17
- /**
18
- * # Element
19
- * The root element of the Nanosplash component.
20
- */
21
- r(this, "element");
22
- this.element = N(), this.element.id = this.id = d.generateGUID();
23
- }
24
- /**
25
- * # Generate GUID
26
- * @returns {GUIDString} A GUID string.
27
- * @private
28
- */
29
- static generateGUID() {
30
- return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (t) => {
31
- const n = Math.random() * 16 | 0;
32
- return (t === "x" ? n : n & 3 | 8).toString(16);
33
- });
34
- }
35
- /**
36
- * @inheritdoc
37
- */
38
- getNSContentElement() {
39
- return this.getNSElement().firstElementChild;
40
- }
41
- /**
42
- * @inheritdoc
43
- */
44
- getNSTextElement() {
45
- return this.getNSContentElement().firstElementChild;
46
- }
47
- /**
48
- * @inheritdoc
49
- */
50
- getId() {
51
- return this.id;
52
- }
53
- /**
54
- * @inheritdoc
55
- */
56
- getNSElement() {
57
- return this.element;
58
- }
59
- /**
60
- * @inheritdoc
61
- */
62
- setText(t) {
63
- return this.getNSTextElement().innerText = t, t.length > 0 ? this.showText() : this.hideText(), this;
64
- }
65
- /**
66
- * @inheritdoc
67
- */
68
- showText() {
69
- return I(this.getNSTextElement()), this;
70
- }
71
- /**
72
- * @inheritdoc
73
- */
74
- hideText() {
75
- return y(this.getNSTextElement()), this;
76
- }
77
- /**
78
- * @inheritdoc
79
- */
80
- remove() {
81
- var t;
82
- return this.element && ((t = this.element.parentElement) == null || t.removeChild(this.element), delete this.element), this;
83
- }
84
- };
85
- /**
86
- * # CSS Class Name
87
- * The main CSS class name of the root element of a Nanosplash component.
88
- */
89
- r(d, "NSClass", "ns"), /**
90
- * # Host CSS Class Name
91
- * The CSS class name of the host element of a Nanosplash component.
92
- * The host element is the element that the Nanosplash is attached to.
93
- */
94
- r(d, "NSHostClass", "nsh");
95
- let l = d;
96
- function N() {
97
- return new DOMParser().parseFromString(
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
- "text/html"
100
- ).body.firstChild;
101
- }
102
- function w(e, t) {
103
- t.children.length > 0 ? t.insertBefore(e, t.children.item(0)) : t.append(e);
104
- }
105
- function h(e, t) {
106
- e == null || e.classList[t](l.NSHostClass);
107
- }
108
- function E(e) {
109
- h(e.getNSElement().parentElement, o.Remove);
110
- }
111
- function I(e) {
112
- e.style.display = "flex";
113
- }
114
- function y(e) {
115
- e.style.display = "none";
116
- }
117
- function u(e) {
118
- return e instanceof Element ? e : document.querySelector(e || "");
119
- }
120
- function C(e) {
121
- var t;
122
- return ((t = e == null ? void 0 : e.classList) == null ? void 0 : t.contains(l.NSClass)) ?? !1;
123
- }
124
- function x(e, t) {
125
- h(e.parentElement, o.Remove), h(t, o.Add), w(e, t);
126
- }
127
- function f(e) {
128
- const t = e.firstElementChild;
129
- if (t !== null && C(t)) {
130
- const c = t.id;
131
- return a.getInstance().nsStack.find((g) => g.getId() === c) ?? null;
132
- }
133
- return null;
134
- }
135
- const s = class s {
136
- /**
137
- * # Constructor
138
- * Private constructor to prevent multiple instances.
139
- * @private
140
- */
141
- constructor() {
142
- /**
143
- * # Version
144
- */
145
- r(this, "version");
146
- /**
147
- * @inheritdoc
148
- */
149
- r(this, "nsStack");
150
- this.version = v, this.nsStack = [];
151
- }
152
- /**
153
- * # Find Index
154
- * Find Nanosplash stack index by callback.
155
- * @param callback Callback function that returns a boolean.
156
- * @returns {number} Index of Nanosplash instance in the stack or -1.
157
- * @private
158
- */
159
- findIndex(t) {
160
- return this.nsStack.findIndex(t);
161
- }
162
- /**
163
- * # Find
164
- * Find Nanosplash in the stack by callback.
165
- * @param callback Callback function that returns a boolean.
166
- * @returns {Splash | undefined} Nanosplash instance or undefined
167
- * @private
168
- */
169
- find(t) {
170
- return this.nsStack.find(t);
171
- }
172
- /**
173
- * # Get Instance
174
- * Singleton instance accessor
175
- * @returns {Service} NanosplashService instance
176
- */
177
- static getInstance() {
178
- return s.instance || (s.instance = new s()), s.instance;
179
- }
180
- /**
181
- * # Assign To Window
182
- * Assign a NanosplashService instance to the Window object.
183
- * The NanosplashService instance can be accessed in the window object
184
- * using the key window accessor key.
185
- * @see WindowAccessorKey
186
- * @private
187
- */
188
- static assignToWindow() {
189
- Object.defineProperty(window, s.WindowAccessorKey, {
190
- value: s.getInstance(),
191
- writable: !1
192
- });
193
- }
194
- /**
195
- * # Start
196
- * Initialize and attach a Nanosplash Service instance to the Window object.
197
- */
198
- static start() {
199
- s.assignToWindow(), window.addEventListener("load", () => {
200
- window[s.WindowAccessorKey] instanceof s || s.assignToWindow();
201
- });
202
- }
203
- /**
204
- * # Create Nanosplash
205
- * Return new Nanosplash instance and push it to the stack.
206
- * @param text Text to display.
207
- * @returns {Splash} Nanosplash instance.
208
- * @private
209
- */
210
- createNS(t) {
211
- const n = new l();
212
- return n.setText(t || ""), this.nsStack.push(n), n;
213
- }
214
- /**
215
- * # Clean And Remove
216
- * Remove Nanosplash from DOM and clean its parent.
217
- * @param ns Nanosplash instance.
218
- * @returns {GUIDString} Nanosplash ID.
219
- * @private
220
- */
221
- cleanAndRemove(t) {
222
- return E(t), t.remove().getId();
223
- }
224
- /**
225
- * # Stack Delete
226
- * Remove Nanosplash instance from the stack.
227
- * @param ns Nanosplash instance.
228
- * @returns {GUIDString | null} Nanosplash ID or null if it doesn't exist.
229
- * @private
230
- */
231
- stackDelete(t) {
232
- let n = this.findIndex((i) => i.getId() === t.getId());
233
- return n < 0 ? null : (this.nsStack.splice(n, 1), t.getId());
234
- }
235
- /**
236
- * # Delete NS
237
- * Remove Nanosplash instance from both the stack and the
238
- * @param callback Callback function.
239
- * @returns {GUIDString | null} Nanosplash ID or null if it doesn't exist.
240
- * @private
241
- */
242
- deleteNS(t) {
243
- const n = this.find(t);
244
- return n ? (this.cleanAndRemove(n), this.stackDelete(n)) : null;
245
- }
246
- /**
247
- * @inheritdoc
248
- */
249
- show(t) {
250
- let n = f(document.body);
251
- return n || (n = this.createNS(), x(n.getNSElement(), document.body)), n.setText(t || "").getId();
252
- }
253
- /**
254
- * @inheritdoc
255
- */
256
- showInside(t, n) {
257
- const i = u(t);
258
- if (i) {
259
- let c = f(i);
260
- return c || (c = this.createNS()), x(c.getNSElement(), i), c.setText(n || "").getId();
261
- }
262
- return null;
263
- }
264
- /**
265
- * @inheritdoc
266
- */
267
- hide() {
268
- const t = this.nsStack.pop();
269
- return t ? this.cleanAndRemove(t) : null;
270
- }
271
- /**
272
- * @inheritdoc
273
- */
274
- hideAll() {
275
- this.nsStack.forEach(this.cleanAndRemove), this.nsStack.splice(0, this.nsStack.length);
276
- }
277
- /**
278
- * @inheritdoc
279
- */
280
- hideId(t) {
281
- return this.deleteNS((n) => n.getId() === t);
282
- }
283
- /**
284
- * @inheritdoc
285
- */
286
- hideInside(t) {
287
- const n = u(t), i = (c) => c.getNSElement().parentElement === n;
288
- return n ? this.deleteNS(i) : null;
289
- }
290
- };
291
- /**
292
- * # Window Accessor Key
293
- * Key to access NanosplashService instance in the Window object.
294
- */
295
- r(s, "WindowAccessorKey", "ns"), /**
296
- * # Instance
297
- * Singleton instance of NanosplashService.
298
- * @private
299
- */
300
- r(s, "instance");
301
- let a = s;
302
- const A = { Service: a };
303
- export {
304
- a as Service,
305
- A as default
306
- };
@@ -1 +0,0 @@
1
- .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}}
@@ -1,2 +0,0 @@
1
- var I=Object.defineProperty;var E=(o,i,d)=>i in o?I(o,i,{enumerable:!0,configurable:!0,writable:!0,value:d}):o[i]=d;var a=(o,i,d)=>(E(o,typeof i!="symbol"?i+"":i,d),d);(function(){"use strict";var o=document.createElement("style");o.textContent=`.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
- `,document.head.appendChild(o);const i="3.0.1",d="";var u=(t=>(t.Add="add",t.Remove="remove",t))(u||{});const h=class h{constructor(){a(this,"id");a(this,"element");this.element=S(),this.element.id=this.id=h.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)})}getNSContentElement(){return this.getNSElement().firstElementChild}getNSTextElement(){return this.getNSContentElement().firstElementChild}getId(){return this.id}getNSElement(){return this.element}setText(e){return this.getNSTextElement().innerText=e,e.length>0?this.showText():this.hideText(),this}showText(){return k(this.getNSTextElement()),this}hideText(){return p(this.getNSTextElement()),this}remove(){var e;return this.element&&((e=this.element.parentElement)==null||e.removeChild(this.element),delete this.element),this}};a(h,"NSClass","ns"),a(h,"NSHostClass","nsh");let c=h;function S(){return new DOMParser().parseFromString('<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>',"text/html").body.firstChild}function w(t,e){e.children.length>0?e.insertBefore(t,e.children.item(0)):e.append(t)}function x(t,e){t==null||t.classList[e](c.NSHostClass)}function y(t){x(t.getNSElement().parentElement,u.Remove)}function k(t){t.style.display="flex"}function p(t){t.style.display="none"}function g(t){return t instanceof Element?t:document.querySelector(t||"")}function N(t){var e;return((e=t==null?void 0:t.classList)==null?void 0:e.contains(c.NSClass))??!1}function m(t,e){x(t.parentElement,u.Remove),x(e,u.Add),w(t,e)}function v(t){const e=t.firstElementChild;if(e!==null&&N(e)){const l=e.id;return f.getInstance().nsStack.find(b=>b.getId()===l)??null}return null}const s=class s{constructor(){a(this,"version");a(this,"nsStack");this.version=i,this.nsStack=[]}findIndex(e){return this.nsStack.findIndex(e)}find(e){return this.nsStack.find(e)}static getInstance(){return s.instance||(s.instance=new s),s.instance}static assignToWindow(){Object.defineProperty(window,s.WindowAccessorKey,{value:s.getInstance(),writable:!1})}static start(){s.assignToWindow(),window.addEventListener("load",()=>{window[s.WindowAccessorKey]instanceof s||s.assignToWindow()})}createNS(e){const n=new c;return n.setText(e||""),this.nsStack.push(n),n}cleanAndRemove(e){return y(e),e.remove().getId()}stackDelete(e){let n=this.findIndex(r=>r.getId()===e.getId());return n<0?null:(this.nsStack.splice(n,1),e.getId())}deleteNS(e){const n=this.find(e);return n?(this.cleanAndRemove(n),this.stackDelete(n)):null}show(e){let n=v(document.body);return n||(n=this.createNS(),m(n.getNSElement(),document.body)),n.setText(e||"").getId()}showInside(e,n){const r=g(e);if(r){let l=v(r);return l||(l=this.createNS()),m(l.getNSElement(),r),l.setText(n||"").getId()}return null}hide(){const e=this.nsStack.pop();return e?this.cleanAndRemove(e):null}hideAll(){this.nsStack.forEach(this.cleanAndRemove),this.nsStack.splice(0,this.nsStack.length)}hideId(e){return this.deleteNS(n=>n.getId()===e)}hideInside(e){const n=g(e),r=l=>l.getNSElement().parentElement===n;return n?this.deleteNS(r):null}};a(s,"WindowAccessorKey","ns"),a(s,"instance");let f=s;try{f.start()}catch(t){console.warn(t)}})();
@@ -1 +0,0 @@
1
- var S=Object.defineProperty;var N=(t,e,n)=>e in t?S(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var c=(t,e,n)=>(N(t,typeof e!="symbol"?e+"":e,n),n);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const o of s)if(o.type==="childList")for(const d of o.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&r(d)}).observe(document,{childList:!0,subtree:!0});function n(s){const o={};return s.integrity&&(o.integrity=s.integrity),s.referrerPolicy&&(o.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?o.credentials="include":s.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(s){if(s.ep)return;s.ep=!0;const o=n(s);fetch(s.href,o)}})();var u=(t=>(t.Add="add",t.Remove="remove",t))(u||{});const l=class l{constructor(){c(this,"id");c(this,"element");this.element=y(),this.element.id=this.id=l.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)})}getNSContentElement(){return this.getNSElement().firstElementChild}getNSTextElement(){return this.getNSContentElement().firstElementChild}getId(){return this.id}getNSElement(){return this.element}setText(e){return this.getNSTextElement().innerText=e,e.length>0?this.showText():this.hideText(),this}showText(){return w(this.getNSTextElement()),this}hideText(){return E(this.getNSTextElement()),this}remove(){var e;return this.element&&((e=this.element.parentElement)==null||e.removeChild(this.element),delete this.element),this}};c(l,"NSClass","ns"),c(l,"NSHostClass","nsh");let a=l;function y(){return new DOMParser().parseFromString('<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>',"text/html").body.firstChild}function p(t,e){e.children.length>0?e.insertBefore(t,e.children.item(0)):e.append(t)}function f(t,e){t==null||t.classList[e](a.NSHostClass)}function v(t){f(t.getNSElement().parentElement,u.Remove)}function w(t){t.style.display="flex"}function E(t){t.style.display="none"}function x(t){return t instanceof Element?t:document.querySelector(t||"")}function I(t){var e;return((e=t==null?void 0:t.classList)==null?void 0:e.contains(a.NSClass))??!1}function m(t,e){f(t.parentElement,u.Remove),f(e,u.Add),p(t,e)}function g(t){const e=t.firstElementChild;if(e!==null&&I(e)){const s=e.id;return h.getInstance().nsStack.find(d=>d.getId()===s)??null}return null}const i=class i{constructor(){c(this,"nsStack");this.nsStack=[]}findIndex(e){return this.nsStack.findIndex(e)}find(e){return this.nsStack.find(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(){i.assignToWindow(),window.addEventListener("load",()=>{window[i.WindowAccessorKey]instanceof i||i.assignToWindow()})}createNS(e){const n=new a;return n.setText(e||""),this.nsStack.push(n),n}cleanAndRemove(e){return v(e),e.remove().getId()}stackDelete(e){let n=this.findIndex(r=>r.getId()===e.getId());return n<0?null:(this.nsStack.splice(n,1),e.getId())}deleteNS(e){const n=this.find(e);return n?(this.cleanAndRemove(n),this.stackDelete(n)):null}show(e){let n=g(document.body);return n||(n=this.createNS(),m(n.getNSElement(),document.body)),n.setText(e||"").getId()}showInside(e,n){const r=x(e);if(r){let s=g(r);return s||(s=this.createNS()),m(s.getNSElement(),r),s.setText(n||"").getId()}return null}hide(){const e=this.nsStack.pop();return e?this.cleanAndRemove(e):null}hideAll(){this.nsStack.forEach(this.cleanAndRemove),this.nsStack=[]}hideId(e){return this.deleteNS(n=>n.getId()===e)}hideInside(e){const n=x(e),r=s=>s.getNSElement().parentElement===n;return n?this.deleteNS(r):null}};c(i,"WindowAccessorKey","ns"),c(i,"instance");let h=i;try{h.start()}catch(t){console.warn(t)}
@@ -1 +0,0 @@
1
- .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}}
@@ -1 +0,0 @@
1
- var S=Object.defineProperty;var N=(t,e,n)=>e in t?S(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var c=(t,e,n)=>(N(t,typeof e!="symbol"?e+"":e,n),n);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const o of s)if(o.type==="childList")for(const l of o.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&r(l)}).observe(document,{childList:!0,subtree:!0});function n(s){const o={};return s.integrity&&(o.integrity=s.integrity),s.referrerPolicy&&(o.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?o.credentials="include":s.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(s){if(s.ep)return;s.ep=!0;const o=n(s);fetch(s.href,o)}})();const v="3.0.1";var u=(t=>(t.Add="add",t.Remove="remove",t))(u||{});const d=class d{constructor(){c(this,"id");c(this,"element");this.element=p(),this.element.id=this.id=d.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)})}getNSContentElement(){return this.getNSElement().firstElementChild}getNSTextElement(){return this.getNSContentElement().firstElementChild}getId(){return this.id}getNSElement(){return this.element}setText(e){return this.getNSTextElement().innerText=e,e.length>0?this.showText():this.hideText(),this}showText(){return E(this.getNSTextElement()),this}hideText(){return I(this.getNSTextElement()),this}remove(){var e;return this.element&&((e=this.element.parentElement)==null||e.removeChild(this.element),delete this.element),this}};c(d,"NSClass","ns"),c(d,"NSHostClass","nsh");let a=d;function p(){return new DOMParser().parseFromString('<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>',"text/html").body.firstChild}function y(t,e){e.children.length>0?e.insertBefore(t,e.children.item(0)):e.append(t)}function f(t,e){t==null||t.classList[e](a.NSHostClass)}function w(t){f(t.getNSElement().parentElement,u.Remove)}function E(t){t.style.display="flex"}function I(t){t.style.display="none"}function x(t){return t instanceof Element?t:document.querySelector(t||"")}function C(t){var e;return((e=t==null?void 0:t.classList)==null?void 0:e.contains(a.NSClass))??!1}function m(t,e){f(t.parentElement,u.Remove),f(e,u.Add),y(t,e)}function g(t){const e=t.firstElementChild;if(e!==null&&C(e)){const s=e.id;return h.getInstance().nsStack.find(l=>l.getId()===s)??null}return null}const i=class i{constructor(){c(this,"version");c(this,"nsStack");this.version=v,this.nsStack=[]}findIndex(e){return this.nsStack.findIndex(e)}find(e){return this.nsStack.find(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(){i.assignToWindow(),window.addEventListener("load",()=>{window[i.WindowAccessorKey]instanceof i||i.assignToWindow()})}createNS(e){const n=new a;return n.setText(e||""),this.nsStack.push(n),n}cleanAndRemove(e){return w(e),e.remove().getId()}stackDelete(e){let n=this.findIndex(r=>r.getId()===e.getId());return n<0?null:(this.nsStack.splice(n,1),e.getId())}deleteNS(e){const n=this.find(e);return n?(this.cleanAndRemove(n),this.stackDelete(n)):null}show(e){let n=g(document.body);return n||(n=this.createNS(),m(n.getNSElement(),document.body)),n.setText(e||"").getId()}showInside(e,n){const r=x(e);if(r){let s=g(r);return s||(s=this.createNS()),m(s.getNSElement(),r),s.setText(n||"").getId()}return null}hide(){const e=this.nsStack.pop();return e?this.cleanAndRemove(e):null}hideAll(){this.nsStack.forEach(this.cleanAndRemove),this.nsStack.splice(0,this.nsStack.length)}hideId(e){return this.deleteNS(n=>n.getId()===e)}hideInside(e){const n=x(e),r=s=>s.getNSElement().parentElement===n;return n?this.deleteNS(r):null}};c(i,"WindowAccessorKey","ns"),c(i,"instance");let h=i;try{h.start()}catch(t){console.warn(t)}
package/docs/index.html DELETED
@@ -1,107 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
- <title>Nanosplash</title>
7
- <script src="https://cdn.tailwindcss.com"></script>
8
- <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@48,400,0,0" />
9
- <script type="module" crossorigin src="/nanosplash/index.f34144dc.js"></script>
10
- <link rel="stylesheet" href="/nanosplash/index.74dbd99e.css">
11
- </head>
12
- <body class="bg-slate-50 min-w-full min-h-screen">
13
- <div
14
- id="main"
15
- class="min-h-screen flex flex-col justify-center items-center p-5 overflow-hidden">
16
- <div class="text-slate-700 font-medium text-4xl md:text-4xl xl:text-5xl drop-shadow-md tracking-wide">
17
- Nanosplash
18
- </div>
19
- <div class="mt-5 md:mt-10 flex max-w-md justify-center flex-wrap gap-x-1 gap-y-1 drop-shadow-md">
20
- <img loading="lazy" src="https://badgen.net/npm/v/nanosplash" alt="Version">
21
- <img loading="lazy" src="https://badgen.net/npm/license/nanosplash" alt="License">
22
- <img loading="lazy" src="https://badgen.net/npm/types/nanosplash" alt="Types">
23
- <img loading="lazy" src="https://badgen.net/bundlephobia/minzip/nanosplash" alt="Minzipped size">
24
- <img loading="lazy" src="https://badgen.net/bundlephobia/dependency-count/nanosplash" alt="Dependency count">
25
- <img loading="lazy" src="https://badgen.net/bundlephobia/tree-shaking/nanosplash" alt="Tree shaking">
26
- </div>
27
- <div class="mt-5 md:mt-10 flex gap-x-3 w-full max-w-[500px] justify-center">
28
- <button
29
- id="run"
30
- type="button"
31
- class="py-2 px-3 bg-white text-slate-700 rounded-xl shadow flex items-center gap-x-2 ease-in-out duration-300 shadow-md hover:shadow-2xl hover:translate-y-[-2px] border border-[rgba(0,0,0,0.02)]">
32
- <span class="material-symbols-outlined">magic_button</span>
33
- Run demo
34
- </button>
35
- <a
36
- id="doc"
37
- href="https://github.com/isakhauge/nanosplash"
38
- type="button"
39
- class="py-2 px-3 bg-white text-slate-700 rounded-xl shadow flex items-center gap-x-2 ease-in-out duration-300 shadow-md hover:shadow-2xl hover:translate-y-[-2px] border border-[rgba(0,0,0,0.02)]">
40
- <span class="material-symbols-outlined">menu_book</span>
41
- Documentation
42
- </a>
43
- </div>
44
- <div
45
- id="wrapper"
46
- class="relative min-w-[300px] mt-5 md:mt-20 flex flex-col md:flex-row gap-y-5 md:gap-y-0 md:gap-x-5 justify-stretch items-stretch bg-white 00 p-10 md:p-10 xl:p-20 rounded-xl ease-in-out duration-500 shadow-md hover:shadow-2xl hover:translate-y-[-2px] border border-[rgba(0,0,0,0.02)]">
47
- <div class="absolute top-2 left-2 font-mono text-xs md:text-sm xl:text-base text-slate-500 cursor-default">#wrapper</div>
48
- <div
49
- id="a"
50
- class="relative bg-white p-8 md:p-10 xl:p-20 rounded-xl shadow-md ease-in-out duration-500 hover:shadow-2xl hover:translate-y-[-2px] border border-[rgba(0,0,0,0.02)]">
51
- <div class="absolute top-2 left-2 font-mono text-xs md:text-sm xl:text-base text-slate-500 cursor-default">#a</div>
52
- <div class="text-slate-500 text-base md:text-xl xl:text-2xl font-medium cursor-default">Element A</div>
53
- </div>
54
- <div
55
- id="b"
56
- class="relative bg-white p-8 md:p-10 xl:p-20 rounded-xl shadow-md ease-in-out duration-500 hover:shadow-2xl hover:translate-y-[-2px] border border-[rgba(0,0,0,0.02)]">
57
- <div class="absolute top-2 left-2 font-mono text-xs md:text-sm xl:text-base text-slate-500 cursor-default">#b</div>
58
- <div class="text-slate-500 text-base md:text-xl xl:text-2xl font-medium cursor-default">Element B</div>
59
- </div>
60
- <div
61
- id="c"
62
- class="relative bg-white p-8 md:p-10 xl:p-20 rounded-xl shadow-md ease-in-out duration-500 hover:shadow-2xl hover:translate-y-[-2px] border border-[rgba(0,0,0,0.02)]">
63
- <div class="absolute top-2 left-2 font-mono text-xs md:text-sm xl:text-base text-slate-500 cursor-default">#c</div>
64
- <div class="text-slate-500 text-base md:text-xl xl:text-2xl font-medium cursor-default">Element C</div>
65
- </div>
66
- </div>
67
- </div>
68
-
69
- <script>
70
- const wait = (ms) => new Promise(r => setTimeout(r, ms))
71
- const ref = (selector) => document.querySelector(selector)
72
- const run = ref('#run')
73
- run.onclick = async () => {
74
- console.log('Running demo')
75
- const sec = (n) => n * 1000
76
- ns.show('Nanosplash')
77
- await wait(sec(2))
78
- ns.show('Tiny loading screen')
79
- await wait(sec(2))
80
- ns.show('For web artisans')
81
- await wait(sec(2))
82
- ns.hide()
83
- ns.showInside('#wrapper', 'Display over elements')
84
- await wait(sec(2.25))
85
- ns.hide()
86
- ns.showInside('#a', 'Like this')
87
- await wait(sec(0.5))
88
- ns.showInside('#b', 'This')
89
- await wait(sec(0.5))
90
- ns.showInside('#c', 'Or this')
91
- await wait(sec(1))
92
- ns.hideAll()
93
- ns.show('Simple API')
94
- await wait(sec(1.5))
95
- ns.show('1.5kb minzipped')
96
- await wait(sec(1.5))
97
- ns.show('No dependencies')
98
- await wait(sec(1.5))
99
- ns.show('99% test coverage')
100
- await wait(sec(1.5))
101
- ns.show('Nanosplash')
102
- await wait(sec(2))
103
- ns.hide()
104
- }
105
- </script>
106
- </body>
107
- </html>
package/index.html DELETED
@@ -1,105 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
- <title>Nanosplash</title>
7
- <script src="https://cdn.tailwindcss.com"></script>
8
- <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@48,400,0,0" />
9
- </head>
10
- <body class="bg-slate-50 min-w-full min-h-screen">
11
- <div
12
- id="main"
13
- class="min-h-screen flex flex-col justify-center items-center p-5 overflow-hidden">
14
- <div class="text-slate-700 font-medium text-4xl md:text-4xl xl:text-5xl drop-shadow-md tracking-wide">
15
- Nanosplash
16
- </div>
17
- <div class="mt-5 md:mt-10 flex max-w-md justify-center flex-wrap gap-x-1 gap-y-1 drop-shadow-md">
18
- <img loading="lazy" src="https://badgen.net/npm/v/nanosplash" alt="Version">
19
- <img loading="lazy" src="https://badgen.net/npm/license/nanosplash" alt="License">
20
- <img loading="lazy" src="https://badgen.net/npm/types/nanosplash" alt="Types">
21
- <img loading="lazy" src="https://badgen.net/bundlephobia/minzip/nanosplash" alt="Minzipped size">
22
- <img loading="lazy" src="https://badgen.net/bundlephobia/dependency-count/nanosplash" alt="Dependency count">
23
- <img loading="lazy" src="https://badgen.net/bundlephobia/tree-shaking/nanosplash" alt="Tree shaking">
24
- </div>
25
- <div class="mt-5 md:mt-10 flex gap-x-3 w-full max-w-[500px] justify-center">
26
- <button
27
- id="run"
28
- type="button"
29
- class="py-2 px-3 bg-white text-slate-700 rounded-xl shadow flex items-center gap-x-2 ease-in-out duration-300 shadow-md hover:shadow-2xl hover:translate-y-[-2px] border border-[rgba(0,0,0,0.02)]">
30
- <span class="material-symbols-outlined">magic_button</span>
31
- Run demo
32
- </button>
33
- <a
34
- id="doc"
35
- href="https://github.com/isakhauge/nanosplash"
36
- type="button"
37
- class="py-2 px-3 bg-white text-slate-700 rounded-xl shadow flex items-center gap-x-2 ease-in-out duration-300 shadow-md hover:shadow-2xl hover:translate-y-[-2px] border border-[rgba(0,0,0,0.02)]">
38
- <span class="material-symbols-outlined">menu_book</span>
39
- Documentation
40
- </a>
41
- </div>
42
- <div
43
- id="wrapper"
44
- class="relative min-w-[300px] mt-5 md:mt-20 flex flex-col md:flex-row gap-y-5 md:gap-y-0 md:gap-x-5 justify-stretch items-stretch bg-white 00 p-10 md:p-10 xl:p-20 rounded-xl ease-in-out duration-500 shadow-md hover:shadow-2xl hover:translate-y-[-2px] border border-[rgba(0,0,0,0.02)]">
45
- <div class="absolute top-2 left-2 font-mono text-xs md:text-sm xl:text-base text-slate-500 cursor-default">#wrapper</div>
46
- <div
47
- id="a"
48
- class="relative bg-white p-8 md:p-10 xl:p-20 rounded-xl shadow-md ease-in-out duration-500 hover:shadow-2xl hover:translate-y-[-2px] border border-[rgba(0,0,0,0.02)]">
49
- <div class="absolute top-2 left-2 font-mono text-xs md:text-sm xl:text-base text-slate-500 cursor-default">#a</div>
50
- <div class="text-slate-500 text-base md:text-xl xl:text-2xl font-medium cursor-default">Element A</div>
51
- </div>
52
- <div
53
- id="b"
54
- class="relative bg-white p-8 md:p-10 xl:p-20 rounded-xl shadow-md ease-in-out duration-500 hover:shadow-2xl hover:translate-y-[-2px] border border-[rgba(0,0,0,0.02)]">
55
- <div class="absolute top-2 left-2 font-mono text-xs md:text-sm xl:text-base text-slate-500 cursor-default">#b</div>
56
- <div class="text-slate-500 text-base md:text-xl xl:text-2xl font-medium cursor-default">Element B</div>
57
- </div>
58
- <div
59
- id="c"
60
- class="relative bg-white p-8 md:p-10 xl:p-20 rounded-xl shadow-md ease-in-out duration-500 hover:shadow-2xl hover:translate-y-[-2px] border border-[rgba(0,0,0,0.02)]">
61
- <div class="absolute top-2 left-2 font-mono text-xs md:text-sm xl:text-base text-slate-500 cursor-default">#c</div>
62
- <div class="text-slate-500 text-base md:text-xl xl:text-2xl font-medium cursor-default">Element C</div>
63
- </div>
64
- </div>
65
- </div>
66
- <script type="module" src="src/ts/main.ts"></script>
67
- <script>
68
- const wait = (ms) => new Promise(r => setTimeout(r, ms))
69
- const ref = (selector) => document.querySelector(selector)
70
- const run = ref('#run')
71
- run.onclick = async () => {
72
- console.log('Running demo')
73
- const sec = (n) => n * 1000
74
- ns.show('Nanosplash')
75
- await wait(sec(2))
76
- ns.show('Tiny loading screen')
77
- await wait(sec(2))
78
- ns.show('For web artisans')
79
- await wait(sec(2))
80
- ns.hide()
81
- ns.showInside('#wrapper', 'Display over elements')
82
- await wait(sec(2.25))
83
- ns.hide()
84
- ns.showInside('#a', 'Like this')
85
- await wait(sec(0.5))
86
- ns.showInside('#b', 'This')
87
- await wait(sec(0.5))
88
- ns.showInside('#c', 'Or this')
89
- await wait(sec(1))
90
- ns.hideAll()
91
- ns.show('Simple API')
92
- await wait(sec(1.5))
93
- ns.show('1.5kb minzipped')
94
- await wait(sec(1.5))
95
- ns.show('No dependencies')
96
- await wait(sec(1.5))
97
- ns.show('99% test coverage')
98
- await wait(sec(1.5))
99
- ns.show('Nanosplash')
100
- await wait(sec(2))
101
- ns.hide()
102
- }
103
- </script>
104
- </body>
105
- </html>
package/src/sass/ns.sass DELETED
@@ -1,95 +0,0 @@
1
- %maximize
2
- width: 100%
3
- height: 100%
4
-
5
- %upper-left
6
- top: 0
7
- left: 0
8
-
9
- %flex-center-xy
10
- display: flex
11
- justify-content: center
12
- align-items: center
13
-
14
- // Nanosplash host scoped varibles
15
- .nsh
16
- --color: DarkSlateGray
17
- --size: 20px
18
- --relSize: calc(var(--size) * 0.9)
19
- --font: 'Helvetica', 'Arial', sans-serif
20
- --weight: 400
21
- --bg: #{ rgba(White, 0.8) }
22
- --zIdx: 999999999
23
- --blur: blur(10px)
24
-
25
- // Nanosplash host
26
- .nsh
27
- position: relative
28
- z-index: var(--zIdx)
29
- &::before
30
- @extend %maximize
31
- @extend %upper-left
32
- position: absolute
33
- background-color: var(--bg)
34
- content: ''
35
- backdrop-filter: var(--blur)
36
- -webkit-backdrop-filter: var(--blur)
37
- z-index: calc(var(--zIdx) + 1)
38
- border-radius: inherit
39
-
40
- // When Nanosplash host is the document body
41
- body.nsh
42
- height: 100vh
43
-
44
- // Nanosplash (main element)
45
- .ns
46
- @extend %maximize
47
- @extend %upper-left
48
- @extend %flex-center-xy
49
- position: absolute
50
- z-index: calc(var(--zIdx) + 2)
51
-
52
- // Nanosplash container
53
- .nsc
54
- @extend %flex-center-xy
55
- filter: drop-shadow(0 0 0.1rem #{ rgba(LightGray, 0.5) })
56
-
57
- // Nanosplash text
58
- .nst
59
- color: var(--color)
60
- font-size: var(--size)
61
- font-family: var(--font)
62
- font-weight: var(--weight)
63
- margin-right: var(--relSize)
64
- text-shadow: 0 0 0.06rem #{ rgba(DarkSlateGray, .25) }
65
-
66
- // Nanosplash spinner
67
- .nss
68
- display: block
69
- width: var(--relSize)
70
- height: var(--relSize)
71
- & > svg
72
- animation: Rotate 2s linear infinite
73
- position: relative
74
- width: inherit
75
- height: inherit
76
- stroke-width: 8
77
- & .path
78
- stroke: var(--color)
79
- stroke-linecap: round
80
- animation: Dash 1.5s ease-in-out infinite
81
-
82
- // Spinner animations:
83
- @keyframes Rotate
84
- 100%
85
- transform: rotate(360deg)
86
- @keyframes Dash
87
- 0%
88
- stroke-dasharray: 1, 150
89
- stroke-dashoffset: 0
90
- 50%
91
- stroke-dasharray: 90, 150
92
- stroke-dashoffset: -35
93
- 100%
94
- stroke-dasharray: 90, 150
95
- stroke-dashoffset: -124
@@ -1,16 +0,0 @@
1
- import { defineConfig } from 'vite'
2
-
3
- export default defineConfig(() => ({
4
- base: 'nanosplash',
5
- build: {
6
- outDir: 'docs',
7
- rollupOptions: {
8
- input: 'index.html',
9
- output: {
10
- entryFileNames: '[name].[hash].js',
11
- chunkFileNames: '[name].[hash].js',
12
- assetFileNames: '[name].[hash].[ext]',
13
- },
14
- },
15
- },
16
- }))