nanosplash 4.0.7 → 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 (55) 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 +45 -50
  9. package/bun.lock +228 -366
  10. package/package.json +25 -26
  11. package/src/composables/ns.ts +3 -3
  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/vite.config.ts +12 -0
  18. package/vitest.config.ts +14 -14
  19. package/.github/workflows/ci.all.yml +0 -32
  20. package/.github/workflows/ci.prod.pull_request.yml +0 -54
  21. package/.github/workflows/ci.prod.push.yml +0 -61
  22. package/.github/workflows/ci.test.yml +0 -56
  23. package/.github/workflows/reusable.build.yml +0 -42
  24. package/.github/workflows/reusable.format.yml +0 -55
  25. package/.github/workflows/reusable.lint.yml +0 -30
  26. package/.github/workflows/reusable.npm-publish.yml +0 -61
  27. package/.github/workflows/reusable.test.yml +0 -50
  28. package/coverage/lcov-report/base.css +0 -224
  29. package/coverage/lcov-report/block-navigation.js +0 -87
  30. package/coverage/lcov-report/favicon.png +0 -0
  31. package/coverage/lcov-report/index.html +0 -176
  32. package/coverage/lcov-report/prettify.css +0 -1
  33. package/coverage/lcov-report/prettify.js +0 -2
  34. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  35. package/coverage/lcov-report/sorter.js +0 -196
  36. package/coverage/lcov-report/src/composables/index.html +0 -116
  37. package/coverage/lcov-report/src/composables/ns.ts.html +0 -547
  38. package/coverage/lcov-report/src/constants/index.html +0 -116
  39. package/coverage/lcov-report/src/constants/ns.ts.html +0 -124
  40. package/coverage/lcov-report/src/iife.ts.html +0 -100
  41. package/coverage/lcov-report/src/index.html +0 -116
  42. package/coverage/lcov-report/src/interfaces/INSElement.ts.html +0 -100
  43. package/coverage/lcov-report/src/interfaces/INanosplash.ts.html +0 -304
  44. package/coverage/lcov-report/src/interfaces/index.html +0 -131
  45. package/coverage/lcov-report/src/utils/dom-utils.ts.html +0 -289
  46. package/coverage/lcov-report/src/utils/index.html +0 -116
  47. package/coverage/lcov.info +0 -271
  48. package/dist/cjs/ns.cjs.js +0 -135
  49. package/dist/es/ns.es.js +0 -197
  50. package/dist/iife/ns.iife.js +0 -135
  51. package/src/style/ns.min.css +0 -2
  52. /package/{src/types → types}/dom.d.ts +0 -0
  53. /package/{src/types → types}/generic/function.d.ts +0 -0
  54. /package/{src/types → types}/semantic/number.d.ts +0 -0
  55. /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,30 +2,35 @@
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
- ## 🚀 Introduction
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
11
 
12
- Nanosplash provides a lightweight and customizable loading screen for your web applications. Whether you want a simple spinner or a fully branded loading experience, Nanosplash makes it easy to implement and customize.
12
+ ```js
13
+ // Display spinner fullscreen
14
+ show('Loading')
13
15
 
14
- ---
16
+ // Display spinner in target
17
+ show('Loading', '#my-div')
15
18
 
16
- ## Features
19
+ // Hide spinner
20
+ hide()
21
+ ```
17
22
 
18
- - 🔬 Tiny size: Only 3KB – ideal for lean, fast applications.
19
- - ⚡ High performance: Engineered for speed and responsiveness.
20
- - ✅ Zero dependencies: No extra baggage – pure JavaScript!
21
- - 🎨 Minimalistic design: Easily integrates with other designs.
22
- - 🚚 Exports in multiple formats: Supports ESM, CJS, and IIFE.
23
- - 📘 TypeScript support: Fully typed. Better DX.
24
- - ✌️ 2 Function API: Small, simple – just what you need.
23
+ ## Features
25
24
 
26
- ---
25
+ - **Tiny**: Only 3KB
26
+ - **Performance**: Created to be fast.
27
+ - **Zero dependencies**: Pure JS.
28
+ - **Beautiful**: Good and generic design.
29
+ - **Modules**: Supports ESM, CJS, and IIFE.
30
+ - **TypeScript support**: Fully typed.
31
+ - **2 Function API**: Easy to use.
27
32
 
28
- ## 📦 Installation
33
+ ## Installation
29
34
 
30
35
  Include Nanosplash in your project via your preferred method (e.g., CDN, module bundler). Example:
31
36
 
@@ -39,79 +44,75 @@ or
39
44
  npm install nanosplash
40
45
  ```
41
46
 
42
- ---
43
-
44
- ## 🎯 API Documentation
47
+ ## API Documentation
45
48
 
46
- ### `ns.show(text?, target?)`
49
+ ### Show
47
50
 
48
- Displays a Nanosplash.
51
+ The show function displays a Nanosplash loading indicator on your page.
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.
53
+ If no target is provided, Nanosplash will create a fullscreen splash covering the entire viewport.
49
54
 
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. |
55
+ ```ts
56
+ show(text?: string, target?: string | Element): number
57
+ ```
54
58
 
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')
79
83
  ```
80
84
 
81
- ---
82
-
83
- ### `ns.hide(id?)`
84
-
85
- Hides or removes a Nanosplash.
85
+ ### Hide
86
86
 
87
- | Parameter | Type | Description |
88
- |-----------|-----------------------|------------------------------------------------------------|
89
- | `id` | `number \| undefined` | Optional. The ID of the Nanosplash to remove. |
87
+ The hide function removes one or more Nanosplash loading indicators from your page.
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).
89
+ You can also remove all splashes at once by passing the wildcard '*'.
90
90
 
91
+ ```ts
92
+ hide(id?: number | '*'): void
93
+ ```
91
94
  #### Examples:
92
95
 
93
- - **Remove the oldest (FIFO) fullscreen Nanosplash:**
96
+ **Remove the oldest (FIFO) fullscreen Nanosplash:**
94
97
 
95
98
  ```js
96
99
  ns.hide()
97
100
  ```
98
101
 
99
- - **Remove a specific Nanosplash by ID:**
102
+ **Remove a specific Nanosplash by ID:**
100
103
 
101
104
  ```js
102
105
  const id = ns.show() // 1700000000000
103
106
  ns.hide(id)
104
107
  ```
105
108
 
106
- - **Remove all Nanosplashes:**
109
+ **Remove all Nanosplashes:**
107
110
 
108
111
  ```js
109
112
  ns.hide('*')
110
113
  ```
111
114
 
112
- ---
113
-
114
- ## 🎨 Customization
115
+ ## Customization
115
116
 
116
117
  Nanosplash is designed to be fully customizable with CSS. You can style its key parts using these selectors:
117
118
 
@@ -122,9 +123,7 @@ Nanosplash is designed to be fully customizable with CSS. You can style its key
122
123
  | `.nst` | Text element |
123
124
  | `.nss` | Spinner element |
124
125
 
125
- ---
126
-
127
- ## 🛠️ Examples
126
+ ## Examples
128
127
 
129
128
  Here’s a quick snippet to show a loading indicator while fetching data:
130
129
 
@@ -147,10 +146,6 @@ Here’s a quick snippet to show a loading indicator while fetching data:
147
146
  </script>
148
147
  ```
149
148
 
150
- ---
151
-
152
149
  ## 💖 Contributing & Feedback
153
150
 
154
- Found a bug or have a feature request? Visit the [GitHub repository](https://github.com/isakhauge/nanosplash) and open an issue or pull request!
155
-
156
- ---
151
+ Found a bug or have a feature request? Visit the [GitHub repository](https://github.com/isakhauge/nanosplash) and open an issue or pull request!