nanosplash 4.0.8 → 4.0.16

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 (53) hide show
  1. package/.github/workflows/bun-build.reusable.yml +32 -0
  2. package/.github/workflows/bun-lint.reusable.yml +32 -0
  3. package/.github/workflows/bun-npm-publish.reusable.yml +47 -0
  4. package/.github/workflows/bun-test.reusable.yml +43 -0
  5. package/.github/workflows/ci.yml +27 -0
  6. package/.github/workflows/release.yml +13 -0
  7. package/LICENSE +21 -0
  8. package/README.md +23 -25
  9. package/bun.lock +227 -314
  10. package/package.json +24 -23
  11. package/src/composables/ns.ts +2 -2
  12. package/src/iife.ts +7 -0
  13. package/tsconfig.json +5 -2
  14. package/{src/types → types}/global.d.ts +1 -1
  15. package/{src/interfaces/INSElement.ts → types/interfaces/INSElement.d.ts} +1 -1
  16. package/{src/interfaces/INanosplash.ts → types/interfaces/INanosplash.d.ts} +2 -2
  17. package/vitest.config.ts +14 -14
  18. package/.github/workflows/ci.all.yml +0 -32
  19. package/.github/workflows/ci.prod.pull_request.yml +0 -54
  20. package/.github/workflows/ci.prod.push.yml +0 -61
  21. package/.github/workflows/ci.test.yml +0 -56
  22. package/.github/workflows/reusable.build.yml +0 -42
  23. package/.github/workflows/reusable.format.yml +0 -55
  24. package/.github/workflows/reusable.lint.yml +0 -30
  25. package/.github/workflows/reusable.npm-publish.yml +0 -61
  26. package/.github/workflows/reusable.test.yml +0 -50
  27. package/coverage/lcov-report/base.css +0 -224
  28. package/coverage/lcov-report/block-navigation.js +0 -87
  29. package/coverage/lcov-report/favicon.png +0 -0
  30. package/coverage/lcov-report/index.html +0 -176
  31. package/coverage/lcov-report/prettify.css +0 -1
  32. package/coverage/lcov-report/prettify.js +0 -2
  33. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  34. package/coverage/lcov-report/sorter.js +0 -196
  35. package/coverage/lcov-report/src/composables/index.html +0 -116
  36. package/coverage/lcov-report/src/composables/ns.ts.html +0 -547
  37. package/coverage/lcov-report/src/constants/index.html +0 -116
  38. package/coverage/lcov-report/src/constants/ns.ts.html +0 -124
  39. package/coverage/lcov-report/src/iife.ts.html +0 -100
  40. package/coverage/lcov-report/src/index.html +0 -116
  41. package/coverage/lcov-report/src/interfaces/INSElement.ts.html +0 -100
  42. package/coverage/lcov-report/src/interfaces/INanosplash.ts.html +0 -304
  43. package/coverage/lcov-report/src/interfaces/index.html +0 -131
  44. package/coverage/lcov-report/src/utils/dom-utils.ts.html +0 -289
  45. package/coverage/lcov-report/src/utils/index.html +0 -116
  46. package/coverage/lcov.info +0 -271
  47. package/dist/cjs/ns.cjs.js +0 -1
  48. package/dist/es/ns.es.js +0 -63
  49. package/dist/iife/ns.iife.js +0 -1
  50. /package/{src/types → types}/dom.d.ts +0 -0
  51. /package/{src/types → types}/generic/function.d.ts +0 -0
  52. /package/{src/types → types}/semantic/number.d.ts +0 -0
  53. /package/{src/types → types}/semantic/string.d.ts +0 -0
@@ -0,0 +1,32 @@
1
+ # .github/workflows/reusables/bun-build.yml
2
+ name: Reusable - Bun Build
3
+
4
+ on:
5
+ workflow_call:
6
+ inputs:
7
+ working-directory:
8
+ description: "Directory of the project (if not repo root)"
9
+ required: false
10
+ type: string
11
+ default: "."
12
+
13
+ jobs:
14
+ build:
15
+ runs-on: ubuntu-latest
16
+
17
+ defaults:
18
+ run:
19
+ working-directory: ${{ inputs.working-directory }}
20
+
21
+ steps:
22
+ - name: Checkout
23
+ uses: actions/checkout@v4
24
+
25
+ - name: Setup Bun
26
+ uses: oven-sh/setup-bun@v2
27
+
28
+ - name: Install dependencies
29
+ run: bun install --frozen-lockfile
30
+
31
+ - name: Build
32
+ run: bun run build
@@ -0,0 +1,32 @@
1
+ # .github/workflows/reusables/bun-lint.yml
2
+ name: Reusable - Bun Lint
3
+
4
+ on:
5
+ workflow_call:
6
+ inputs:
7
+ working-directory:
8
+ description: "Directory of the project (if not repo root)"
9
+ required: false
10
+ type: string
11
+ default: "."
12
+
13
+ jobs:
14
+ lint:
15
+ runs-on: ubuntu-latest
16
+
17
+ defaults:
18
+ run:
19
+ working-directory: ${{ inputs.working-directory }}
20
+
21
+ steps:
22
+ - name: Checkout
23
+ uses: actions/checkout@v4
24
+
25
+ - name: Setup Bun
26
+ uses: oven-sh/setup-bun@v2
27
+
28
+ - name: Install dependencies
29
+ run: bun install --frozen-lockfile
30
+
31
+ - name: Lint
32
+ run: bun run lint
@@ -0,0 +1,47 @@
1
+ name: Reusable - Bun NPM Publish (Trusted Publisher)
2
+
3
+ on:
4
+ workflow_call:
5
+ inputs:
6
+ working-directory:
7
+ description: "Directory of the package"
8
+ required: false
9
+ type: string
10
+ default: "."
11
+
12
+ jobs:
13
+ publish:
14
+ runs-on: ubuntu-latest
15
+
16
+ # Required for npm Trusted Publishing (OIDC)
17
+ permissions:
18
+ id-token: write
19
+ contents: read
20
+
21
+ defaults:
22
+ run:
23
+ working-directory: ${{ inputs.working-directory }}
24
+
25
+ steps:
26
+ - name: Checkout
27
+ uses: actions/checkout@v4
28
+
29
+ # 1) Use Bun for install & build
30
+ - name: Setup Bun
31
+ uses: oven-sh/setup-bun@v2
32
+ with:
33
+ bun-version: latest
34
+
35
+ - name: Install dependencies
36
+ run: bun install --frozen-lockfile
37
+
38
+ - name: Build package
39
+ run: bun run build
40
+
41
+ # 2) Use Node 24 + newest npm *just* for publication
42
+ - name: Setup Node for publish
43
+ uses: actions/setup-node@v4
44
+ with:
45
+ node-version: "24.x"
46
+ registry-url: "https://registry.npmjs.org"
47
+ - run: npm publish
@@ -0,0 +1,43 @@
1
+ name: Reusable - Bun Test + Coverage (Coveralls)
2
+
3
+ on:
4
+ workflow_call:
5
+ inputs:
6
+ working-directory:
7
+ description: "Directory of the project (if not repo root)"
8
+ required: false
9
+ type: string
10
+ default: "."
11
+ upload-to-coveralls:
12
+ description: "Whether to upload coverage to Coveralls"
13
+ required: false
14
+ type: boolean
15
+ default: true
16
+
17
+ jobs:
18
+ test-coverage:
19
+ runs-on: ubuntu-latest
20
+
21
+ defaults:
22
+ run:
23
+ working-directory: ${{ inputs.working-directory }}
24
+
25
+ steps:
26
+ - name: Checkout
27
+ uses: actions/checkout@v4
28
+
29
+ - name: Setup Bun
30
+ uses: oven-sh/setup-bun@v2
31
+
32
+ - name: Install dependencies
33
+ run: bun install --frozen-lockfile
34
+
35
+ - name: Run tests with coverage
36
+ run: bun run test
37
+
38
+ # - name: Upload coverage to Coveralls
39
+ # if: ${{ inputs.upload-to-coveralls }}
40
+ # uses: coverallsapp/github-action@v2
41
+ # with:
42
+ # github-token: ${{ secrets.GITHUB_TOKEN }}
43
+ # path-to-lcov: ${{ inputs.working-directory }}/coverage/lcov.info
@@ -0,0 +1,27 @@
1
+ # .github/workflows/ci.yml
2
+ name: Nanosplash CI
3
+
4
+ on:
5
+ push:
6
+ branches: [ main, develop ]
7
+ pull_request:
8
+ branches: [ main, develop ]
9
+
10
+ jobs:
11
+ build:
12
+ uses: ./.github/workflows/bun-build.reusable.yml
13
+ with:
14
+ working-directory: .
15
+
16
+ test:
17
+ needs: build
18
+ uses: ./.github/workflows/bun-test.reusable.yml
19
+ with:
20
+ working-directory: .
21
+ upload-to-coveralls: true
22
+
23
+ lint:
24
+ needs: build
25
+ uses: ./.github/workflows/bun-lint.reusable.yml
26
+ with:
27
+ working-directory: .
@@ -0,0 +1,13 @@
1
+ # .github/workflows/release.yml
2
+ name: Release Nanosplash
3
+
4
+ on:
5
+ push:
6
+ tags:
7
+ - "v*.*.*" # e.g. v1.2.3
8
+
9
+ jobs:
10
+ publish:
11
+ uses: ./.github/workflows/bun-npm-publish.reusable.yml
12
+ with:
13
+ working-directory: .
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Nanosplash, Copyright (c) 2025 Isak Hauge
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -2,12 +2,23 @@
2
2
 
3
3
  **The tiny loading screen for web artisans**
4
4
 
5
- [![CI Production: Build, Test, Publish](https://github.com/isakhauge/nanosplash/actions/workflows/ci.prod.push.yml/badge.svg)](https://github.com/isakhauge/nanosplash/actions/workflows/ci.prod.push.yml)
6
- [![Coverage Status](https://coveralls.io/repos/github/isakhauge/nanosplash/badge.svg?branch=production)](https://coveralls.io/github/isakhauge/nanosplash?branch=production)
5
+ [![CI Production: Build, Test](https://github.com/isakhauge/nanosplash/actions/workflows/ci.yml/badge.svg)](https://github.com/isakhauge/nanosplash/actions/workflows/ci.yml)
6
+ [![Coverage Status](https://coveralls.io/repos/github/isakhauge/nanosplash/badge.svg?branch=main)](https://coveralls.io/github/isakhauge/nanosplash?branch=main)
7
7
 
8
8
  ---
9
9
 
10
- ### Nanosplash is the ultra-lightweight JavaScript library that makes adding a polished loading experience to your web app effortless. Weighing in at just 3KB and with zero dependencies, it’s designed to be blazingly fast and beautifully simple. Whether you need a fullscreen spinner or a branded loading message within a specific container, Nanosplash’s dead-simple 2-function API (show and hide) and full CSS customization make it the perfect tool for any modern web project. Try it today and elevate your app’s loading experience with zero fuss!
10
+ ### Nanosplash is a 3KB zero-dependency library for effortless loading screens. Its 2-function API lets you add fullscreen or container-based spinners in seconds, fully customizable with CSS. Fast, beautiful, and simple.
11
+
12
+ ```js
13
+ // Display spinner fullscreen
14
+ show('Loading')
15
+
16
+ // Display spinner in target
17
+ show('Loading', '#my-div')
18
+
19
+ // Hide spinner
20
+ hide()
21
+ ```
11
22
 
12
23
  ## Features
13
24
 
@@ -41,38 +52,31 @@ The show function displays a Nanosplash loading indicator on your page.
41
52
  You can pass in optional text to display with the spinner, and an optional target element (or CSS selector) to control where it appears.
42
53
  If no target is provided, Nanosplash will create a fullscreen splash covering the entire viewport.
43
54
 
44
- ```txt
55
+ ```ts
45
56
  show(text?: string, target?: string | Element): number
46
57
  ```
47
58
 
48
- #### Parameters
49
-
50
- | Parameter | Type | Description |
51
- |-----------|----------------------------------|-------------------------------------------------------------|
52
- | `text` | `string \| undefined` | Optional. Text to display alongside the spinner. |
53
- | `target` | `string \| Element \| undefined` | Optional. CSS selector or an element to contain the splash. |
54
-
55
59
  #### Examples:
56
60
 
57
- - **Fullscreen spinner only:**
61
+ **Fullscreen spinner only:**
58
62
 
59
63
  ```js
60
64
  ns.show()
61
65
  ```
62
66
 
63
- - **Fullscreen text and spinner:**
67
+ **Fullscreen text and spinner:**
64
68
 
65
69
  ```js
66
70
  ns.show('Loading...')
67
71
  ```
68
72
 
69
- - **Spinner only within a specific element:**
73
+ **Spinner only within a specific element:**
70
74
 
71
75
  ```js
72
76
  ns.show(null, '#my-div')
73
77
  ```
74
78
 
75
- - **Text and spinner within a specific element:**
79
+ **Text and spinner within a specific element:**
76
80
 
77
81
  ```js
78
82
  ns.show('Please wait', '#my-div')
@@ -84,31 +88,25 @@ The hide function removes one or more Nanosplash loading indicators from your pa
84
88
  By default, it removes the oldest fullscreen splash (FIFO). If you want to remove a specific splash, you can pass its ID (returned by show).
85
89
  You can also remove all splashes at once by passing the wildcard '*'.
86
90
 
87
- ```txt
91
+ ```ts
88
92
  hide(id?: number | '*'): void
89
93
  ```
90
- #### Arguments
91
-
92
- | Parameter | Type | Description |
93
- |-----------|-----------------------|------------------------------------------------------------|
94
- | `id` | `number \| undefined` | Optional. The ID of the Nanosplash to remove. |
95
-
96
94
  #### Examples:
97
95
 
98
- - **Remove the oldest (FIFO) fullscreen Nanosplash:**
96
+ **Remove the oldest (FIFO) fullscreen Nanosplash:**
99
97
 
100
98
  ```js
101
99
  ns.hide()
102
100
  ```
103
101
 
104
- - **Remove a specific Nanosplash by ID:**
102
+ **Remove a specific Nanosplash by ID:**
105
103
 
106
104
  ```js
107
105
  const id = ns.show() // 1700000000000
108
106
  ns.hide(id)
109
107
  ```
110
108
 
111
- - **Remove all Nanosplashes:**
109
+ **Remove all Nanosplashes:**
112
110
 
113
111
  ```js
114
112
  ns.hide('*')