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.
- package/.github/workflows/ci.yml +50 -44
- package/.github/workflows/vitepress.yml +69 -0
- package/.prettierignore +1 -0
- package/.prettierrc +10 -10
- package/README.md +11 -172
- package/bun.lockb +0 -0
- package/coverage/{core/Dom.ts.html → DomUtilities.ts.html} +141 -138
- package/coverage/{core/Service.ts.html → Service.ts.html} +250 -322
- package/coverage/{core/Splash.ts.html → Splash.ts.html} +145 -154
- package/coverage/SplashQueue.ts.html +232 -0
- package/coverage/clover.xml +557 -552
- package/coverage/coverage-final.json +5 -9043
- package/coverage/index.html +53 -23
- package/dist/cjs/ns.cjs +2 -0
- package/dist/es/ns.js +342 -0
- package/dist/iife/ns.iife.js +2 -0
- package/docs/.vitepress/config.ts +75 -0
- package/docs/.vitepress/theme/css/style.css +157 -0
- package/docs/.vitepress/theme/index.ts +16 -0
- package/docs/.vitepress/theme/vue/Card.vue +31 -0
- package/docs/.vitepress/theme/vue/CardGrid.vue +17 -0
- package/docs/.vitepress/theme/vue/Exe.vue +86 -0
- package/docs/.vitepress/theme/vue/PlayGround.vue +50 -0
- package/docs/api/doc/hide.md +69 -0
- package/docs/api/doc/show.md +47 -0
- package/docs/api/start/features.md +17 -0
- package/docs/api/start/install.md +53 -0
- package/docs/api/start/playground.md +11 -0
- package/docs/api/start/usage.md +25 -0
- package/docs/index.md +30 -0
- package/package.json +86 -87
- package/src/style/ns.sass +95 -0
- package/src/ts/core/{Dom.ts → DomUtilities.ts} +58 -57
- package/src/ts/core/Service.ts +66 -90
- package/src/ts/core/ServiceInterface.ts +5 -7
- package/src/ts/core/Splash.ts +23 -26
- package/src/ts/core/SplashInterface.ts +12 -20
- package/src/ts/core/SplashQueue.ts +49 -0
- package/src/ts/types/Types.ts +0 -9
- package/tests/{Dom.spec.ts → DomUtilities.spec.ts} +13 -23
- package/tests/Guid.spec.ts +3 -3
- package/tests/Service.spec.ts +146 -67
- package/tests/Splash.spec.ts +26 -26
- package/tests/TestUtilities.ts +48 -0
- package/tsconfig.json +1 -0
- package/vite.config.ts +1 -15
- package/coverage/core/index.html +0 -146
- package/coverage/types/Types.ts.html +0 -121
- package/coverage/types/index.html +0 -116
- package/dist/latest/cjs/ns.cjs +0 -1
- package/dist/latest/cjs/style.css +0 -1
- package/dist/latest/es/ns.js +0 -306
- package/dist/latest/es/style.css +0 -1
- package/dist/latest/iife/ns.iife.js +0 -4
- package/dist/versioned/3.0.1/cjs/ns.cjs +0 -1
- package/dist/versioned/3.0.1/cjs/style.css +0 -1
- package/dist/versioned/3.0.1/es/ns.js +0 -306
- package/dist/versioned/3.0.1/es/style.css +0 -1
- package/dist/versioned/3.0.1/iife/ns.iife.js +0 -2
- package/docs/index.6d66a821.js +0 -1
- package/docs/index.74dbd99e.css +0 -1
- package/docs/index.f34144dc.js +0 -1
- package/docs/index.html +0 -107
- package/index.html +0 -105
- package/src/sass/ns.sass +0 -95
- package/vite.demo.config.ts +0 -16
package/.github/workflows/ci.yml
CHANGED
|
@@ -1,48 +1,54 @@
|
|
|
1
|
-
name:
|
|
1
|
+
name: Main Github Actions Workflow
|
|
2
2
|
|
|
3
3
|
on:
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- production
|
|
7
|
+
pull_request:
|
|
8
|
+
branches:
|
|
9
|
+
- production
|
|
10
10
|
|
|
11
11
|
jobs:
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
12
|
+
build-and-test:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
|
|
15
|
+
steps:
|
|
16
|
+
- name: Checkout
|
|
17
|
+
uses: actions/checkout@v3
|
|
18
|
+
|
|
19
|
+
- name: Install Bun
|
|
20
|
+
uses: oven-sh/setup-bun@v1
|
|
21
|
+
|
|
22
|
+
- name: Setup Node.js
|
|
23
|
+
uses: actions/setup-node@v3
|
|
24
|
+
with:
|
|
25
|
+
node-version: 20
|
|
26
|
+
|
|
27
|
+
- name: Set up Git and update production branch
|
|
28
|
+
run: |
|
|
29
|
+
git config --global user.name "GitHub Actions"
|
|
30
|
+
git config --global user.email "actions@github.com"
|
|
31
|
+
git checkout production
|
|
32
|
+
git fetch
|
|
33
|
+
git pull --no-rebase
|
|
34
|
+
|
|
35
|
+
- name: Setup Pages
|
|
36
|
+
uses: actions/configure-pages@v3
|
|
37
|
+
|
|
38
|
+
- name: Install dependencies
|
|
39
|
+
run: bun install
|
|
40
|
+
|
|
41
|
+
- name: Build (Vite)
|
|
42
|
+
run: bun run build
|
|
43
|
+
|
|
44
|
+
- name: Test (Vitest)
|
|
45
|
+
run: bun run test
|
|
46
|
+
|
|
47
|
+
- name: Generate Code Coverage (Vitest)
|
|
48
|
+
run: bun run coverage
|
|
49
|
+
|
|
50
|
+
- name: Commit and push changes
|
|
51
|
+
run: |
|
|
52
|
+
git add .
|
|
53
|
+
git commit --allow-empty -m "Build, test, and coverage report"
|
|
54
|
+
git push
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Sample workflow for building and deploying a VitePress site to GitHub Pages
|
|
2
|
+
#
|
|
3
|
+
name: Deploy VitePress site to Pages
|
|
4
|
+
|
|
5
|
+
on:
|
|
6
|
+
# Runs on pushes targeting the `main` branch. Change this to `master` if you're
|
|
7
|
+
# using the `master` branch as the default branch.
|
|
8
|
+
push:
|
|
9
|
+
branches: [production]
|
|
10
|
+
pull_request:
|
|
11
|
+
branches: [production]
|
|
12
|
+
|
|
13
|
+
# Allows you to run this workflow manually from the Actions tab
|
|
14
|
+
workflow_dispatch:
|
|
15
|
+
|
|
16
|
+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
|
|
17
|
+
permissions:
|
|
18
|
+
contents: read
|
|
19
|
+
pages: write
|
|
20
|
+
id-token: write
|
|
21
|
+
|
|
22
|
+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
|
|
23
|
+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
|
|
24
|
+
concurrency:
|
|
25
|
+
group: pages
|
|
26
|
+
cancel-in-progress: false
|
|
27
|
+
|
|
28
|
+
jobs:
|
|
29
|
+
# Build job
|
|
30
|
+
build:
|
|
31
|
+
runs-on: ubuntu-latest
|
|
32
|
+
steps:
|
|
33
|
+
- name: Checkout
|
|
34
|
+
uses: actions/checkout@v3
|
|
35
|
+
with:
|
|
36
|
+
fetch-depth: 0 # Not needed if lastUpdated is not enabled
|
|
37
|
+
# - uses: pnpm/action-setup@v2 # Uncomment this if you're using pnpm
|
|
38
|
+
- name: Install Bun
|
|
39
|
+
uses: oven-sh/setup-bun@v1 # Uncomment this if you're using Bun
|
|
40
|
+
- name: Setup Node
|
|
41
|
+
uses: actions/setup-node@v3
|
|
42
|
+
with:
|
|
43
|
+
node-version: 20
|
|
44
|
+
cache: yarn
|
|
45
|
+
- name: Setup Pages
|
|
46
|
+
uses: actions/configure-pages@v3
|
|
47
|
+
- name: Install dependencies
|
|
48
|
+
run: yarn install
|
|
49
|
+
- name: Build with VitePress
|
|
50
|
+
run: |
|
|
51
|
+
bun run docs:build
|
|
52
|
+
touch docs/.vitepress/dist/.nojekyll
|
|
53
|
+
- name: Upload artifact
|
|
54
|
+
uses: actions/upload-pages-artifact@v2
|
|
55
|
+
with:
|
|
56
|
+
path: docs/.vitepress/dist
|
|
57
|
+
|
|
58
|
+
# Deployment job
|
|
59
|
+
deploy:
|
|
60
|
+
environment:
|
|
61
|
+
name: github-pages
|
|
62
|
+
url: ${{ steps.deployment.outputs.page_url }}
|
|
63
|
+
needs: build
|
|
64
|
+
runs-on: ubuntu-latest
|
|
65
|
+
name: Deploy
|
|
66
|
+
steps:
|
|
67
|
+
- name: Deploy to GitHub Pages
|
|
68
|
+
id: deployment
|
|
69
|
+
uses: actions/deploy-pages@v2
|
package/.prettierignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
*.sass
|
package/.prettierrc
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
"tabWidth": 4,
|
|
3
|
+
"useTabs": true,
|
|
4
|
+
"singleQuote": true,
|
|
5
|
+
"bracketSpacing": true,
|
|
6
|
+
"jsxSingleQuote": true,
|
|
7
|
+
"endOfLine": "lf",
|
|
8
|
+
"trailingComma": "es5",
|
|
9
|
+
"arrowParens": "avoid",
|
|
10
|
+
"semi": false,
|
|
11
|
+
"printWidth": 80
|
|
12
12
|
}
|
package/README.md
CHANGED
|
@@ -8,184 +8,23 @@
|
|
|
8
8
|
|
|
9
9
|
<br>
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
> 📣 **New in 3.0.2**
|
|
12
|
+
>
|
|
13
|
+
> - CSS is included inside the ES and CJS bundles 🎉
|
|
14
|
+
> - The `ns.hide` method will now delete splash screens in a FIFO sequence.
|
|
12
15
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
When installing via CDN, you will always get the latest version, and CSS is included inside the bundle.
|
|
16
|
-
|
|
17
|
-
```html
|
|
18
|
-
<script src="https://unpkg.com/nanosplash/dist/latest/iife/ns.iife.js">
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
Pros:
|
|
22
|
-
|
|
23
|
-
- Easy to get started.
|
|
24
|
-
- Always get the latest version.
|
|
25
|
-
- CSS is included inside the bundle.
|
|
26
|
-
|
|
27
|
-
Cons:
|
|
28
|
-
|
|
29
|
-
- Always get the latest version.
|
|
30
|
-
|
|
31
|
-
### Install via NPM
|
|
32
|
-
|
|
33
|
-
```bash
|
|
34
|
-
yarn add nanosplash
|
|
35
|
-
```
|
|
16
|
+
## Usage
|
|
36
17
|
|
|
37
18
|
```js
|
|
38
|
-
|
|
39
|
-
Service.start()
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
The CSS file is located in the following path:
|
|
43
|
-
|
|
44
|
-
```text
|
|
45
|
-
node_modules/nanosplash/dist/latest/es/style.css
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
### Example usage
|
|
49
|
-
|
|
50
|
-
It's so simple to use.
|
|
51
|
-
|
|
52
|
-
```js
|
|
53
|
-
// Display a fullscreen loading screen
|
|
19
|
+
// Fullscreen splash screen
|
|
54
20
|
ns.show('Loading')
|
|
55
|
-
|
|
56
|
-
axios.get('/api/users')
|
|
57
|
-
.then((response) => /* Do something */ )
|
|
58
|
-
.finally(() => {
|
|
59
|
-
// Hide it when you're done
|
|
60
|
-
ns.hide()
|
|
61
|
-
})
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
### TLDR
|
|
65
|
-
|
|
66
|
-
```js
|
|
67
|
-
// Fullscreen spinning wheel
|
|
68
|
-
ns.show()
|
|
69
|
-
|
|
70
|
-
// Fullscreen spinning wheel with text
|
|
71
|
-
ns.show('Loading')
|
|
72
|
-
|
|
73
|
-
// Display inside an element
|
|
74
|
-
ns.showInside('#my-table', 'Fetching data')
|
|
75
|
-
|
|
76
|
-
// Hide the last created loading screen (LIFO)
|
|
77
21
|
ns.hide()
|
|
78
22
|
|
|
79
|
-
//
|
|
80
|
-
ns.
|
|
81
|
-
|
|
82
|
-
// Hide specific loading screen
|
|
83
|
-
const id = ns.show('Loading')
|
|
84
|
-
ns.hideId(id)
|
|
85
|
-
|
|
86
|
-
// Hide all loading screens
|
|
87
|
-
ns.hideAll()
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
## API Documentation
|
|
91
|
-
|
|
92
|
-
### Show
|
|
93
|
-
|
|
94
|
-
This method displays a fullscreen loading screen and returns a GUID string.
|
|
95
|
-
|
|
96
|
-
```ts
|
|
97
|
-
ns.show(text?: string): GUIDString
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
If you enter no text, it will display the spinning wheel only.
|
|
101
|
-
|
|
102
|
-
```js
|
|
103
|
-
ns.show() // Spinner only
|
|
104
|
-
ns.show('Loading') // Spinner with text
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
### Show inside
|
|
108
|
-
|
|
109
|
-
This method displays a fullscreen loading screen inside an element and returns a GUID string.
|
|
110
|
-
|
|
111
|
-
```ts
|
|
112
|
-
ns.showInside(ref: Reference, text?: string): GUIDString | null
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
The `Reference` type is a union type of `string | Element`. The `string` type is a CSS selector string. The `Element` type is a DOM element.
|
|
116
|
-
|
|
117
|
-
```js
|
|
118
|
-
// Both works
|
|
119
|
-
const selector = '#my-table'
|
|
120
|
-
const element = document.getElementById('my-table')
|
|
121
|
-
ns.showInside(selector, 'Loading')
|
|
122
|
-
ns.showInside(element, 'Loading')
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
### Hide
|
|
126
|
-
|
|
127
|
-
Hides the last created loading screen (LIFO).
|
|
128
|
-
|
|
129
|
-
```ts
|
|
130
|
-
ns.hide(): GUIDString | null
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
The reason why the hide function works in a LIFO (last in first out) manner is because you should always see the loading screen that you want to hide, which will always be the last one you created.
|
|
134
|
-
|
|
135
|
-
```js
|
|
136
|
-
ns.show('a')
|
|
137
|
-
ns.show('b')
|
|
138
|
-
ns.show('c')
|
|
139
|
-
ns.hide() // Hides 'c'
|
|
140
|
-
ns.hide() // Hides 'b'
|
|
141
|
-
ns.hide() // Hides 'a'
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
> 💡 **PRO Tip:** If you have multiple loading screens open at the same time, I would recommend that you hide specific elements based on their GUID or host element. See `hideId` and `hideInside` for more information.
|
|
145
|
-
|
|
146
|
-
### Hide by ID
|
|
147
|
-
|
|
148
|
-
Hides the Nanosplash loading screen with the given GUID string.
|
|
149
|
-
|
|
150
|
-
```ts
|
|
151
|
-
ns.hideId(guid: GUIDString): GUIDString | null
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
The show methods always retrun a GUID. This identifier can be used to hide specific loading screens.
|
|
155
|
-
|
|
156
|
-
```js
|
|
157
|
-
const id = ns.show('Loading')
|
|
158
|
-
ns.hideId(id)
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
### Hide inside
|
|
162
|
-
|
|
163
|
-
Hides the Nanosplash loading screen inside another element — if any — that corresponds with the given element reference. Returns the GUID string of the loading screen that was hidden, or null if no loading screen was found inside.
|
|
164
|
-
|
|
165
|
-
```ts
|
|
166
|
-
ns.hideInside(ref: Reference): GUIDString | null
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
This method works almost the same way as `hideId`, but instead of using the GUID string as the identifier, it uses the host element as the identifier.
|
|
170
|
-
|
|
171
|
-
```js
|
|
172
|
-
const selector = '#my-table'
|
|
173
|
-
ns.showInside(selector, 'Loading')
|
|
174
|
-
ns.hideInside(selector)
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
You can also use the `Element` type as the reference.
|
|
178
|
-
|
|
179
|
-
```js
|
|
180
|
-
const element = document.getElementById('my-table')
|
|
181
|
-
ns.showInside(element, 'Loading')
|
|
182
|
-
ns.hideInside(element)
|
|
23
|
+
// Splash screen inside a DOM element
|
|
24
|
+
ns.showInside('#my-div', 'Loading')
|
|
25
|
+
ns.hide()
|
|
183
26
|
```
|
|
184
27
|
|
|
185
|
-
|
|
28
|
+
## Documentation
|
|
186
29
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
```ts
|
|
190
|
-
ns.hideAll(): void
|
|
191
|
-
```
|
|
30
|
+
[isakhauge.github.io/nanosplash/](https://isakhauge.github.io/nanosplash/)
|
package/bun.lockb
ADDED
|
Binary file
|