nanosplash 3.0.9 → 3.1.1

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.
@@ -1,7 +1,26 @@
1
1
  import { DOMSelector, UTCInteger } from './Types'
2
2
 
3
3
  export interface NanosplashInterface {
4
+ /**
5
+ * # Show
6
+ * Display Nanosplash inside the window.
7
+ * @param {string | undefined} text Optional text
8
+ * @param {string | Element | undefined} inside Optional element reference
9
+ * @returns {number | null} The internal ID of the created Nanosplash.
10
+ */
4
11
  show(text?: string, inside?: DOMSelector | HTMLElement): UTCInteger | null
5
- hide(id?: UTCInteger): void
6
- hideAll(): void
12
+ /**
13
+ * # Hide
14
+ * Remove Nanosplash in multiple ways depending on the passed argument.
15
+ * - Pass ID: Remove specific.
16
+ * - Pass '*': Remove all in window.
17
+ * - Pass nothing: Remove in FIFO order.
18
+ * @param id The internal ID, an asterisk, or nothing.
19
+ */
20
+ hide(id?: UTCInteger | '*'): void
21
+ /**
22
+ * # Version
23
+ * The current version of Nanosplash.
24
+ */
25
+ version: string
7
26
  }
@@ -1,6 +1,7 @@
1
1
  import { NanosplashInterface } from './NanosplashInterface'
2
2
 
3
- export type UTCInteger = number
3
+ export type Integer = number
4
+ export type UTCInteger = Integer
4
5
  export type DOMSelector = string
5
6
  export type ElementReference = DOMSelector | Element
6
7
 
@@ -1,16 +1,20 @@
1
1
  import { describe, it, test, expect, beforeEach } from 'vitest'
2
- import { useNs } from '../src/ts/Nanosplash'
3
2
  import { JSDOM } from 'jsdom'
3
+ import { NanosplashInterface } from '../src/ts/types/NanosplashInterface'
4
4
 
5
- let ns
5
+ let dom = new JSDOM()
6
+ let document: Document | null = null
7
+ let ns: NanosplashInterface | null = null
6
8
 
7
- beforeEach(() => {
8
- const dom = new JSDOM()
9
+ async function updateGlobals() {
10
+ dom = new JSDOM()
9
11
  // @ts-ignore
10
12
  globalThis.window = dom.window
11
- globalThis.document = window.document
12
- globalThis.window.ns = ns = useNs()
13
- })
13
+ document = globalThis.document = dom.window.document
14
+ ns = globalThis.window.ns = (await import('../src/ts/Nanosplash')).useNs()
15
+ }
16
+
17
+ beforeEach(updateGlobals)
14
18
 
15
19
  describe('Nanosplash API', () => {
16
20
  it('should be defined', () => {
@@ -25,10 +29,6 @@ describe('Nanosplash API', () => {
25
29
  expect(window.ns.hide).toBeDefined()
26
30
  })
27
31
 
28
- it('should have the "hideAll" method', () => {
29
- expect(window.ns.hideAll).toBeDefined()
30
- })
31
-
32
32
  it('should have the global instance', () => {
33
33
  expect(window.ns).toBe(ns)
34
34
  })
package/bun.lockb DELETED
Binary file