nanosplash 2.2.2 → 2.3.0

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 (51) hide show
  1. package/.github/workflows/production.yml +57 -0
  2. package/.github/workflows/release.yml +61 -0
  3. package/README.md +33 -9
  4. package/dist/iife/nanosplash.iife.js +1 -1
  5. package/dist/module/Nanosplash.css +1 -0
  6. package/dist/module/manifest.json +6 -3
  7. package/dist/module/nanosplash.cjs.js +1 -1
  8. package/dist/module/nanosplash.es.js +249 -285
  9. package/docs/index.html +54 -415
  10. package/docs/nanosplash.iife.js +1 -1
  11. package/docs/style.css +1 -1
  12. package/docs/typedoc/assets/highlight.css +1 -50
  13. package/docs/typedoc/assets/main.js +2 -2
  14. package/docs/typedoc/assets/search.js +1 -1
  15. package/docs/typedoc/assets/style.css +32 -2
  16. package/docs/typedoc/classes/Core_Nanosplash.Nanosplash.html +1 -0
  17. package/docs/typedoc/index.html +1 -1
  18. package/docs/typedoc/modules/types.html +1 -1
  19. package/index.html +51 -397
  20. package/jest.config.ts +194 -0
  21. package/package.json +71 -66
  22. package/src/Core/Nanosplash.ts +74 -0
  23. package/src/Core/SplashInstance.ts +154 -0
  24. package/src/Factory/NanosplashFactory.ts +73 -0
  25. package/src/Interfaces/ContextualAPIInterface.ts +8 -0
  26. package/src/Interfaces/IdentityInterface.ts +3 -0
  27. package/src/Interfaces/ImageInterface.ts +5 -0
  28. package/src/Interfaces/InsideInterface.ts +5 -0
  29. package/src/Interfaces/NanosplashInterface.ts +4 -0
  30. package/src/Interfaces/ProgressInterface.ts +5 -0
  31. package/src/Interfaces/ShowInterface.ts +5 -0
  32. package/src/Interfaces/WhileInterface.ts +5 -0
  33. package/src/main.ts +2 -6
  34. package/src/repositories/NanosplashRepository.ts +34 -57
  35. package/src/style.sass +36 -61
  36. package/src/types.d.ts +45 -197
  37. package/src/utilities/dom.spec.ts +70 -0
  38. package/src/utilities/dom.ts +17 -246
  39. package/update-all.sh +3 -0
  40. package/vite.iife.config.js +46 -18
  41. package/vite.mod.config.js +48 -12
  42. package/vite.site.config.js +0 -3
  43. package/dist/module/style.css +0 -1
  44. package/docs/typedoc/classes/Nanosplash.Nanosplash-1.html +0 -56
  45. package/docs/typedoc/classes/types.Nanosplash.html +0 -56
  46. package/docs/typedoc/modules/Nanosplash.html +0 -1
  47. package/src/Nanosplash.ts +0 -421
  48. package/src/exceptions/Exception.ts +0 -11
  49. package/src/exceptions/IllegalArgumentException.ts +0 -9
  50. package/src/exceptions/InvalidDestinationException.ts +0 -9
  51. package/update-latest.sh +0 -21
@@ -1,321 +1,285 @@
1
- class Exception extends Error {
2
- constructor(message) {
3
- super(message);
4
- }
5
- getName() {
6
- return this.constructor.name;
7
- }
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ var style = "";
21
+ function get(selector) {
22
+ return document.querySelector(selector);
8
23
  }
9
- class InvalidDestinationException extends Exception {
10
- constructor(message) {
11
- super(message);
24
+ function move(source, destination, asFirstChild = false) {
25
+ if (source && destination) {
26
+ destination.hasChildNodes() && asFirstChild ? destination.insertBefore(source, destination.firstChild) : destination.appendChild(source);
12
27
  }
13
28
  }
14
- const ref = (cssSelector) => document.querySelector(cssSelector);
15
- const create = (tag, options) => {
16
- var _a;
17
- const element = document.createElement(tag);
18
- if (options) {
19
- element.id || (element.id = options.id + "");
20
- element.className || (element.className = options.className + "");
21
- (_a = options.attributes) == null ? void 0 : _a.filter((v) => v.value).forEach(({ key, value }) => setAttribute(element, key, value));
22
- if (options.content) {
23
- if (typeof options.content === "string") {
24
- element.innerText = options.content;
25
- } else {
26
- element.append(options.content);
29
+ const mk = (tag) => document.createElement(tag);
30
+ function addClass(node, ...classes) {
31
+ node.classList.add(...classes);
32
+ }
33
+ function setAttr(node, attribute, value) {
34
+ node.setAttribute(attribute, value);
35
+ }
36
+ class NanosplashRepository {
37
+ static destinationToNode(destination) {
38
+ if (typeof destination === "string") {
39
+ const element = get(destination);
40
+ if (!element) {
41
+ throw new Error(`No match with ${destination}`);
27
42
  }
43
+ return element;
44
+ } else if (destination instanceof Node) {
45
+ return destination;
28
46
  }
47
+ throw new Error("Destination argument must string or Node");
29
48
  }
30
- return element;
31
- };
32
- const display = (node, show) => {
33
- node.hidden = !show;
34
- if (show) {
35
- removeAttribute(node, "hidden");
36
- } else {
37
- setAttribute(node, "hidden", "true");
38
- }
39
- };
40
- const move = (node) => ({
41
- to: (targetNode, asFirstChild) => {
42
- const children = Array.from(targetNode.childNodes);
43
- const noChildren = children.length < 1;
44
- if (noChildren || !asFirstChild) {
45
- targetNode.appendChild(node);
46
- return;
47
- }
48
- const firstChild = children[0];
49
- targetNode.insertBefore(node, firstChild);
50
- }
51
- });
52
- const fitToParent = (node) => {
53
- const parent = node.parentNode;
54
- if (parent) {
55
- ((domRect) => {
56
- parent.style.position = "relative";
57
- const unit = "px";
58
- const parentIsBody = parent === document.body;
59
- let left, top, width, height;
60
- if (parentIsBody) {
61
- left = scrollX + unit;
62
- } else {
63
- left = 0 + unit;
64
- }
65
- if (parentIsBody) {
66
- top = scrollY + unit;
67
- } else {
68
- top = 0 + unit;
69
- }
70
- if (parentIsBody) {
71
- width = "100%";
72
- } else {
73
- width = domRect.width + unit;
74
- }
75
- if (parentIsBody) {
76
- height = "100vh";
77
- } else {
78
- height = domRect.height + unit;
49
+ static createContextualApiObject(splash) {
50
+ const ctx = {
51
+ getId: () => splash.getId(),
52
+ remove: () => splash.delete(),
53
+ moveTo: (selector) => splash.moveTo(selector),
54
+ getText: () => splash.getText(),
55
+ setText: (text) => splash.setText(text),
56
+ getImgSrc: () => splash.getImgSrc(),
57
+ setImgSrc: (src) => splash.setImgSrc(src)
58
+ };
59
+ return __spreadProps(__spreadValues({}, ctx), {
60
+ inside: (selector) => {
61
+ splash.moveTo(selector);
62
+ return ctx;
79
63
  }
80
- setStyle(parent, "position", "relative");
81
- setStyle(node, "left", left);
82
- setStyle(node, "top", top);
83
- setStyle(node, "width", width);
84
- setStyle(node, "height", height);
85
- })(parent.getBoundingClientRect());
86
- }
87
- };
88
- const invokeOn = (dispatcher, handler, events) => (([addEventListenerLegacy, addEventListener]) => {
89
- events.forEach((event) => {
90
- if (addEventListenerLegacy) {
91
- addEventListenerLegacy(`on${event}`, handler);
92
- } else {
93
- addEventListener(event, handler, true);
94
- }
95
- });
96
- })([dispatcher.attachEvent, dispatcher.addEventListener]);
97
- const isElementOrNode = (value) => {
98
- return value instanceof Element || value instanceof Node;
99
- };
100
- const isFunction = (value) => {
101
- return value && {}.toString.call(value) === "[object Function]";
102
- };
103
- const setStyle = (node, prop, value) => {
104
- node.style[prop] = value;
105
- };
106
- const setAttribute = (node, key, value) => {
107
- node.setAttribute(key, value);
108
- };
109
- const removeAttribute = (node, key) => {
110
- node.removeAttribute(key);
111
- };
112
- class NanosplashRepository {
113
- static makeMainElement() {
114
- const mainElement = create("div", {
115
- className: "nanosplash-container",
116
- attributes: [
117
- {
118
- key: "data-splash-animation",
119
- value: this.DEFAULT.SPLASH_ANIMATION
120
- }
121
- ]
122
- });
123
- mainElement.style.backgroundColor = this.DEFAULT.BACKGROUND_COLOR;
124
- return mainElement;
125
- }
126
- static makeSplashElement() {
127
- const splashElement = create("img", {
128
- className: "nanosplash-img",
129
- attributes: [
130
- { key: "src", value: this.DEFAULT.SPLASH_SOURCE },
131
- { key: "alt", value: "Nanosplash indicator" }
132
- ]
133
- });
134
- display(splashElement, false);
135
- return splashElement;
136
- }
137
- static makeTextElement() {
138
- return create("div", {
139
- className: "nanosplash-text",
140
- content: this.DEFAULT.TEXT
141
64
  });
142
65
  }
143
66
  }
144
- NanosplashRepository.DEFAULT = {
145
- DESTINATION_NODE: document.body,
146
- TEXT: "Loading ...",
147
- TEXT_FONT: '"Arial", sans-serif',
148
- TEXT_WEIGHT: "medium",
149
- TEXT_COLOR: "#555",
150
- TEXT_SIZE: "26px",
151
- SPLASH_SOURCE: "favicon.svg",
152
- SPLASH_WIDTH: "100px",
153
- SPLASH_HEIGHT: "auto",
154
- SPLASH_ANIMATION: "pulse",
155
- BACKGROUND_COLOR: "rgba(255, 255, 255, 0.90)",
156
- BACKGROUND_BLUR: "light"
157
- };
158
- var style = "";
159
- class Nanosplash {
160
- constructor(config) {
161
- this.cache = {
162
- parentPosition: ""
163
- };
164
- this.defaultText = NanosplashRepository.DEFAULT.TEXT;
165
- this.defaultDestination = NanosplashRepository.DEFAULT.DESTINATION_NODE;
166
- this.mainElement = NanosplashRepository.makeMainElement();
167
- this.splashElement = NanosplashRepository.makeSplashElement();
168
- this.textElement = NanosplashRepository.makeTextElement();
169
- move(this.splashElement).to(this.mainElement);
170
- move(this.textElement).to(this.mainElement);
171
- move(this.mainElement).to(this.defaultDestination, true);
172
- display(this.mainElement, false);
173
- fitToParent(this.mainElement);
174
- this.setDefaultStyles();
175
- if (config) {
176
- this.configure(config);
177
- }
67
+ class SplashInstance {
68
+ constructor(ns, text, imgSrc) {
69
+ var _a;
70
+ this.nsRootElement = mk("div");
71
+ this.nsWrapperElement = mk("div");
72
+ this.nsWindowElement = mk("div");
73
+ this.nsContentElement = mk("div");
74
+ this.nsImageElement = mk("img");
75
+ this.nsTextElement = mk("div");
76
+ this.id = Math.random().toString(36).substring(2);
77
+ this.nsInstance = ns;
78
+ this.nsTextElement.innerText = text;
79
+ this.imgSrc = imgSrc;
80
+ this.nsImageElement.src = (_a = this.imgSrc) != null ? _a : "";
81
+ this.nsImageElement.alt = Nanosplash.APP_NAME;
82
+ this.assembleNSComponent();
83
+ this.setImgSrc(imgSrc);
178
84
  }
179
- install() {
180
- Object.defineProperty(window, "loading", {
181
- value: this,
182
- writable: false
183
- });
184
- invokeOn(window, () => fitToParent(this.mainElement), ["resize", "scroll"]);
85
+ assignCSSClasses() {
86
+ addClass(this.nsContentElement, "ns-container");
87
+ addClass(this.nsWrapperElement, "ns-blur");
88
+ addClass(this.nsImageElement, "ns-img");
89
+ addClass(this.nsTextElement, "ns-text");
90
+ addClass(this.nsWindowElement, "ns", "ns-window");
91
+ addClass(this.nsRootElement, "ns-wrapper");
185
92
  }
186
- configure(config) {
187
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
188
- if ((_a = config == null ? void 0 : config.default) == null ? void 0 : _a.destination) {
189
- this.defaultDestination = Nanosplash.getDestinationElement(config.default.destination);
190
- }
191
- this.defaultText || (this.defaultText = (_b = config.default) == null ? void 0 : _b.text);
192
- if ((_c = config.text) == null ? void 0 : _c.family) {
193
- this.setTextFontFamily(config.text.family);
194
- }
195
- if ((_d = config.text) == null ? void 0 : _d.weight) {
196
- this.setTextWeight(config.text.weight);
197
- }
198
- if ((_e = config.text) == null ? void 0 : _e.color) {
199
- this.setTextColor(config.text.color);
200
- }
201
- if ((_f = config.text) == null ? void 0 : _f.size) {
202
- this.setTextSize(config.text.size);
203
- }
204
- if ((_g = config.background) == null ? void 0 : _g.color) {
205
- this.setBackgroundColor(config.background.color);
93
+ assembleElementStructure() {
94
+ this.nsContentElement.append(this.nsImageElement, this.nsTextElement);
95
+ this.nsWindowElement.append(this.nsContentElement);
96
+ this.nsRootElement.append(this.nsWrapperElement, this.nsWindowElement);
97
+ }
98
+ assembleNSComponent() {
99
+ this.nsRootElement.id = this.getId();
100
+ setAttr(this.nsRootElement, "data-ctx", "nanosplash");
101
+ this.assembleElementStructure();
102
+ this.assignCSSClasses();
103
+ }
104
+ getId() {
105
+ return this.id;
106
+ }
107
+ getText() {
108
+ return this.nsTextElement.innerText;
109
+ }
110
+ setText(text) {
111
+ this.nsTextElement.innerText = text;
112
+ return this;
113
+ }
114
+ getImgSrc() {
115
+ return this.imgSrc;
116
+ }
117
+ setImgSrc(src) {
118
+ this.nsImageElement.src = src != null ? src : "";
119
+ this.nsImageElement.style.display = src ? "block" : "none";
120
+ this.assembleElementStructure();
121
+ return this;
122
+ }
123
+ cleanup() {
124
+ const currentParent = this.nsRootElement.parentElement;
125
+ if (currentParent) {
126
+ this.restoreDOMStructure(currentParent);
206
127
  }
207
- if ((_h = config.background) == null ? void 0 : _h.blur) {
208
- this.setBackgroundBlur(config.background.blur);
128
+ }
129
+ resetFullscreenAttributes() {
130
+ setAttr(this.nsRootElement, "style", "");
131
+ this.nsRootElement.classList.remove("ns-fs");
132
+ }
133
+ moveWithRegularStrategy(targetNode) {
134
+ const targetParentNode = targetNode.parentNode;
135
+ if (targetParentNode) {
136
+ this.restoreDOMStructure(targetParentNode);
137
+ targetParentNode.replaceChild(this.nsRootElement, targetNode);
138
+ this.nsWrapperElement.appendChild(targetNode);
209
139
  }
210
- if (config.splash) {
211
- if ((_i = config.splash) == null ? void 0 : _i.src) {
212
- this.setSplashSource(config.splash.src);
213
- }
214
- if ((_j = config.splash) == null ? void 0 : _j.width) {
215
- this.setSplashWidth(config.splash.width);
216
- }
217
- if ((_k = config.splash) == null ? void 0 : _k.height) {
218
- this.setSplashHeight(config.splash.height);
219
- }
220
- if ((_l = config.splash) == null ? void 0 : _l.animation) {
221
- this.setSplashAnimation(config.splash.animation);
222
- }
140
+ }
141
+ moveWithFullscreenStrategy() {
142
+ this.nsRootElement.classList.add("ns-fs");
143
+ move(this.nsRootElement, document.body, true);
144
+ }
145
+ moveTo(destination) {
146
+ this.cleanup();
147
+ const targetNode = NanosplashRepository.destinationToNode(destination);
148
+ const targetIsBody = targetNode === document.body;
149
+ if (targetIsBody) {
150
+ this.moveWithFullscreenStrategy();
223
151
  } else {
224
- display(this.splashElement, false);
152
+ this.resetFullscreenAttributes();
153
+ this.moveWithRegularStrategy(targetNode);
225
154
  }
226
- return this;
155
+ this.assembleNSComponent();
227
156
  }
228
- show(text) {
229
- this.setText(text != null ? text : NanosplashRepository.DEFAULT.TEXT);
230
- display(this.mainElement, true);
231
- const parent = this.mainElement.parentNode;
232
- if (parent && parent !== document.body) {
233
- fitToParent(this.mainElement);
157
+ forEachWrappedNode(callback) {
158
+ Array.from(this.nsWrapperElement.childNodes).forEach(callback);
159
+ }
160
+ restoreDOMStructure(parentNode) {
161
+ this.forEachWrappedNode((child) => parentNode.insertBefore(child, this.nsRootElement));
162
+ }
163
+ removeElementsFromDOM() {
164
+ [
165
+ this.nsTextElement,
166
+ this.nsImageElement,
167
+ this.nsContentElement,
168
+ this.nsWrapperElement,
169
+ this.nsWindowElement,
170
+ this.nsRootElement
171
+ ].forEach((v) => v.remove());
172
+ }
173
+ delete() {
174
+ this.cleanup();
175
+ this.removeElementsFromDOM();
176
+ this.nsInstance.delete(this);
177
+ }
178
+ }
179
+ class NanosplashFactory {
180
+ static ensureInstance(splash, ns, text, imgSrc) {
181
+ var _a;
182
+ if (!splash) {
183
+ splash = new SplashInstance(ns, text, imgSrc);
234
184
  }
235
- const during = async (task) => {
236
- await task;
237
- this.hide();
238
- };
239
- return {
240
- inside: (destination) => {
241
- const element = Nanosplash.getDestinationElement(destination);
242
- move(this.mainElement).to(element, true);
243
- this.cache.parentPosition = element.style.position;
244
- fitToParent(this.mainElement);
245
- return { during };
246
- },
247
- during
248
- };
185
+ return splash.setText(text).setImgSrc((_a = splash.getImgSrc()) != null ? _a : imgSrc);
249
186
  }
250
- hide() {
251
- const parent = this.mainElement.parentElement;
252
- setStyle(parent, "position", this.cache.parentPosition);
253
- display(this.mainElement, false);
254
- this.setText(this.defaultText);
255
- move(this.mainElement).to(this.defaultDestination, true);
256
- fitToParent(this.mainElement);
257
- }
258
- setDefaultStyles() {
259
- this.setTextFontFamily(NanosplashRepository.DEFAULT.TEXT_FONT);
260
- this.setTextWeight(NanosplashRepository.DEFAULT.TEXT_WEIGHT);
261
- this.setTextColor(NanosplashRepository.DEFAULT.TEXT_COLOR);
262
- this.setTextSize(NanosplashRepository.DEFAULT.TEXT_SIZE);
263
- this.setSplashSource(NanosplashRepository.DEFAULT.SPLASH_SOURCE);
264
- this.setSplashWidth(NanosplashRepository.DEFAULT.SPLASH_WIDTH);
265
- this.setSplashHeight(NanosplashRepository.DEFAULT.SPLASH_HEIGHT);
266
- this.setSplashAnimation(NanosplashRepository.DEFAULT.SPLASH_ANIMATION);
267
- this.setBackgroundColor(NanosplashRepository.DEFAULT.BACKGROUND_COLOR);
268
- this.setBackgroundBlur(NanosplashRepository.DEFAULT.BACKGROUND_BLUR);
187
+ static createImgFunction(ns, splash) {
188
+ return (src) => {
189
+ splash = NanosplashFactory.ensureInstance(splash, ns, "", src);
190
+ return {
191
+ show: NanosplashFactory.createShowFunction(ns, splash),
192
+ progress: NanosplashFactory.createProgressFunction(ns, splash),
193
+ while: NanosplashFactory.createWhileFunction(ns, splash)
194
+ };
195
+ };
269
196
  }
270
- setText(text) {
271
- this.textElement.innerText = text;
197
+ static createShowFunction(ns, splash) {
198
+ return (text) => {
199
+ splash = NanosplashFactory.ensureInstance(splash, ns, text);
200
+ ns.instances.set(splash.getId(), splash);
201
+ splash.moveTo(document.body);
202
+ return NanosplashRepository.createContextualApiObject(splash);
203
+ };
272
204
  }
273
- setTextFontFamily(fontFamily) {
274
- setStyle(this.textElement, "fontFamily", fontFamily);
205
+ static createProgressFunction(ns, splash) {
206
+ return (...jobs) => {
207
+ splash = NanosplashFactory.ensureInstance(splash, ns, "");
208
+ splash.moveTo(document.body);
209
+ (async () => {
210
+ for (const [_, [job, text]] of jobs.entries()) {
211
+ splash.setText(text);
212
+ await job;
213
+ }
214
+ splash.delete();
215
+ })();
216
+ return NanosplashRepository.createContextualApiObject(splash);
217
+ };
275
218
  }
276
- setTextWeight(fontWeight) {
277
- setStyle(this.textElement, "fontWeight", fontWeight);
219
+ static createWhileFunction(ns, splash) {
220
+ return (asyncTask) => {
221
+ splash = NanosplashFactory.ensureInstance(splash, ns, "");
222
+ return {
223
+ show(text) {
224
+ ns.instances.set(splash.getId(), splash);
225
+ splash.moveTo(document.body);
226
+ splash.setText(text);
227
+ asyncTask.finally(() => splash.delete());
228
+ return NanosplashRepository.createContextualApiObject(splash);
229
+ }
230
+ };
231
+ };
278
232
  }
279
- setTextColor(color) {
280
- setStyle(this.textElement, "color", color);
233
+ }
234
+ class Nanosplash {
235
+ constructor() {
236
+ this.instances = /* @__PURE__ */ new Map();
281
237
  }
282
- setTextSize(fontSize) {
283
- setStyle(this.textElement, "fontSize", fontSize);
238
+ img(src) {
239
+ return NanosplashFactory.createImgFunction(this, new SplashInstance(this, "", src))(src);
284
240
  }
285
- setSplashSource(src) {
286
- this.splashElement.src = src;
287
- display(this.splashElement, true);
241
+ show(text) {
242
+ return NanosplashFactory.createShowFunction(this, new SplashInstance(this, text))(text);
288
243
  }
289
- setSplashWidth(width) {
290
- setStyle(this.splashElement, "width", width);
244
+ progress(...jobs) {
245
+ return NanosplashFactory.createProgressFunction(this, new SplashInstance(this, ""))(...jobs);
291
246
  }
292
- setSplashHeight(height) {
293
- setStyle(this.splashElement, "height", height);
247
+ while(asyncTask) {
248
+ return NanosplashFactory.createWhileFunction(this, new SplashInstance(this, ""))(asyncTask);
294
249
  }
295
- setSplashAnimation(animation) {
296
- setAttribute(this.mainElement, "data-splash-animation", animation);
250
+ fifoIterate(callback) {
251
+ let i = 0;
252
+ const instanceEntries = this.instances.entries();
253
+ for (const [id, splashInstance] of instanceEntries) {
254
+ if (!callback(id, splashInstance, i++)) {
255
+ break;
256
+ }
257
+ }
297
258
  }
298
- setBackgroundColor(color) {
299
- setStyle(this.mainElement, "backgroundColor", color);
259
+ delete(splashInstance) {
260
+ this.instances.delete(splashInstance.getId());
300
261
  }
301
- setBackgroundBlur(blurMode) {
302
- setAttribute(this.mainElement, "data-blur", blurMode);
262
+ hideAll() {
263
+ this.instances.forEach((instance) => instance.delete());
303
264
  }
304
- static getDestinationElement(destination) {
305
- const isString = typeof destination === "string";
306
- const isCallback = isFunction(destination);
307
- const isElement = isElementOrNode(destination);
308
- let destinationNode;
309
- if (isString) {
310
- destinationNode = ref(destination);
311
- } else if (isCallback) {
312
- destinationNode = destination();
313
- } else if (isElement) {
314
- destinationNode = destination;
265
+ hide(id) {
266
+ if (id) {
267
+ const splashInstance = this.instances.get(id);
268
+ if (splashInstance) {
269
+ splashInstance.delete();
270
+ } else {
271
+ throw new Error(`Could not find element with id: ${id}`);
272
+ }
315
273
  } else {
316
- throw new InvalidDestinationException();
274
+ this.fifoIterate((_, splashInstance, i) => {
275
+ const remove = i === 0;
276
+ if (remove) {
277
+ splashInstance.delete();
278
+ }
279
+ return remove;
280
+ });
317
281
  }
318
- return destinationNode;
319
282
  }
320
283
  }
284
+ Nanosplash.APP_NAME = "Nanosplash";
321
285
  export { Nanosplash };