vite-plugin-react-splash 1.0.2 → 1.0.4
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/README.md +1 -0
- package/dist/index.d.mts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +29 -14
- package/dist/index.mjs +29 -14
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -71,6 +71,7 @@ function App() {
|
|
|
71
71
|
| Option | Type | Description |
|
|
72
72
|
| --- | --- | --- |
|
|
73
73
|
| `logo` | `string \| { light: string, dark: string }` | SVG string or object with light/dark versions. |
|
|
74
|
+
| `mode` | `'light' \| 'dark' \| 'auto'` | Theme mode. `'auto'` detects system settings (default). |
|
|
74
75
|
| `duration` | `number` | Time in ms before the splash screen automatically hides. |
|
|
75
76
|
| `text` | `string` | Text to display below the logo. |
|
|
76
77
|
| `version` | `string` | Version string to display at the bottom. |
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { Plugin } from 'vite';
|
|
2
2
|
|
|
3
3
|
interface SplashScreenOptions {
|
|
4
|
-
logo: string
|
|
4
|
+
logo: string | {
|
|
5
|
+
light: string;
|
|
6
|
+
dark: string;
|
|
7
|
+
};
|
|
5
8
|
duration?: number;
|
|
6
9
|
text?: string;
|
|
7
10
|
version?: string;
|
|
@@ -15,6 +18,7 @@ interface SplashScreenOptions {
|
|
|
15
18
|
color: string;
|
|
16
19
|
};
|
|
17
20
|
};
|
|
21
|
+
mode?: 'light' | 'dark' | 'auto';
|
|
18
22
|
animation?: 'none' | 'fade' | 'pulse' | 'slide-up' | 'gradient-mesh';
|
|
19
23
|
meshColors?: string[];
|
|
20
24
|
onlyStandalone?: boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { Plugin } from 'vite';
|
|
2
2
|
|
|
3
3
|
interface SplashScreenOptions {
|
|
4
|
-
logo: string
|
|
4
|
+
logo: string | {
|
|
5
|
+
light: string;
|
|
6
|
+
dark: string;
|
|
7
|
+
};
|
|
5
8
|
duration?: number;
|
|
6
9
|
text?: string;
|
|
7
10
|
version?: string;
|
|
@@ -15,6 +18,7 @@ interface SplashScreenOptions {
|
|
|
15
18
|
color: string;
|
|
16
19
|
};
|
|
17
20
|
};
|
|
21
|
+
mode?: 'light' | 'dark' | 'auto';
|
|
18
22
|
animation?: 'none' | 'fade' | 'pulse' | 'slide-up' | 'gradient-mesh';
|
|
19
23
|
meshColors?: string[];
|
|
20
24
|
onlyStandalone?: boolean;
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,30 @@
|
|
|
1
|
-
'use strict';var react=require('react');var h=
|
|
1
|
+
'use strict';var react=require('react');var h=a=>{let{theme:e,animation:r,meshColors:o,mode:i="auto"}=a,s=e?.light||{background:"#ffffff",color:"#000000"},t=e?.dark||{background:"#000000",color:"#ffffff"},n="",l="";if(i==="light"?l=`
|
|
2
|
+
#vite-splash-screen { background-color: ${s.background}; color: ${s.color}; }
|
|
3
|
+
.splash-logo-light { display: block; }
|
|
4
|
+
.splash-logo-dark { display: none; }
|
|
5
|
+
`:i==="dark"?l=`
|
|
6
|
+
#vite-splash-screen { background-color: ${t.background}; color: ${t.color}; }
|
|
7
|
+
.splash-logo-light { display: none; }
|
|
8
|
+
.splash-logo-dark { display: block; }
|
|
9
|
+
`:l=`
|
|
10
|
+
#vite-splash-screen { background-color: ${s.background}; color: ${s.color}; }
|
|
11
|
+
.splash-logo-light { display: block; }
|
|
12
|
+
.splash-logo-dark { display: none; }
|
|
13
|
+
@media (prefers-color-scheme: dark) {
|
|
14
|
+
#vite-splash-screen { background-color: ${t.background}; color: ${t.color}; }
|
|
15
|
+
.splash-logo-dark { display: block; }
|
|
16
|
+
.splash-logo-light { display: none; }
|
|
17
|
+
}
|
|
18
|
+
`,r==="pulse"&&(n+=`
|
|
2
19
|
.splash-logo { animation: splash-pulse 2s infinite; }
|
|
3
20
|
@keyframes splash-pulse {
|
|
4
21
|
0%, 100% { transform: scale(1); opacity: 1; }
|
|
5
22
|
50% { transform: scale(1.1); opacity: 0.8; }
|
|
6
23
|
}
|
|
7
|
-
`),
|
|
24
|
+
`),r==="gradient-mesh"){let c=["#3498db","#9b59b6","#2ecc71"],g=o?.length?o:c,d=["center","20% 30%","80% 70%","40% 80%","70% 20%","10% 60%","90% 40%"],m=g.map((f,u)=>`radial-gradient(circle at ${d[u%d.length]}, ${f} 0%, transparent 50%)`).join(",");n+=`
|
|
8
25
|
#vite-splash-screen::before {
|
|
9
26
|
content: ""; position: absolute; top: -50%; left: -50%; width: 200%; height: 200%;
|
|
10
|
-
background: ${
|
|
27
|
+
background: ${m}; z-index: -1; animation: rotate-mesh 20s linear infinite;
|
|
11
28
|
opacity: 0.3; filter: blur(60px);
|
|
12
29
|
}
|
|
13
30
|
@keyframes rotate-mesh { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
|
|
@@ -17,27 +34,25 @@
|
|
|
17
34
|
display: flex; flex-direction: column; align-items: center; justify-content: center;
|
|
18
35
|
z-index: 999999; transition: opacity 0.5s, visibility 0.5s;
|
|
19
36
|
font-family: -apple-system, system-ui, sans-serif;
|
|
20
|
-
background-color: ${
|
|
37
|
+
background-color: ${s.background}; color: ${s.color};
|
|
21
38
|
}
|
|
22
39
|
#vite-splash-screen.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
|
|
23
40
|
.splash-logo { width: 120px; height: 120px; margin-bottom: 20px; }
|
|
24
41
|
.splash-logo svg { fill: currentColor; width: 100%; height: 100%; }
|
|
25
42
|
.splash-text { font-size: 1.2rem; font-weight: 500; }
|
|
26
43
|
.splash-version { position: absolute; bottom: 20px; font-size: 0.8rem; opacity: 0.7; }
|
|
27
|
-
|
|
28
|
-
#vite-splash-screen { background-color: ${o.background}; color: ${o.color}; }
|
|
29
|
-
}
|
|
44
|
+
${l}
|
|
30
45
|
${n}
|
|
31
|
-
`.replace(/\s+/g," ").trim()};function
|
|
32
|
-
<style>${
|
|
46
|
+
`.replace(/\s+/g," ").trim()};function y(){return {hideSplashScreen:react.useCallback(()=>{let e=document.getElementById("vite-splash-screen");e&&(e.classList.add("hidden"),setTimeout(()=>e.remove(),500));},[])}}function x(a){return {name:"vite-plugin-react-splash",transformIndexHtml(e){let r=h(a),{logo:o,text:i,version:s,duration:t=3e3,onlyStandalone:n=false,showOnce:l=false}=a,p=typeof o=="string"?`<div class="splash-logo">${o}</div>`:`<div class="splash-logo splash-logo-light">${o.light}</div><div class="splash-logo splash-logo-dark">${o.dark}</div>`,c=`
|
|
47
|
+
<style>${r}</style>
|
|
33
48
|
<div id="vite-splash-screen">
|
|
34
|
-
|
|
35
|
-
${
|
|
36
|
-
${
|
|
49
|
+
${p}
|
|
50
|
+
${i?`<div class="splash-text">${i}</div>`:""}
|
|
51
|
+
${s?`<div class="splash-version">v${s}</div>`:""}
|
|
37
52
|
</div>
|
|
38
53
|
<script>
|
|
39
54
|
(function(){
|
|
40
|
-
var d=${
|
|
55
|
+
var d=${t},o=${n},s1=${l},s=document.getElementById('vite-splash-screen');
|
|
41
56
|
if(s){
|
|
42
57
|
var isPWA = window.matchMedia('(display-mode: standalone)').matches || (window.navigator && window.navigator.standalone);
|
|
43
58
|
var shown = false;
|
|
@@ -54,4 +69,4 @@ ${o?`<div class="splash-version">v${o}</div>`:""}
|
|
|
54
69
|
},d);
|
|
55
70
|
}
|
|
56
71
|
})();
|
|
57
|
-
</script>`.replace(/>\s+</g,"><").trim();return e.replace("<body>",`<body>${
|
|
72
|
+
</script>`.replace(/>\s+</g,"><").trim();return e.replace("<body>",`<body>${c}`)}}}exports.useSplashScreen=y;exports.viteSplashScreen=x;
|
package/dist/index.mjs
CHANGED
|
@@ -1,13 +1,30 @@
|
|
|
1
|
-
import {useCallback}from'react';var h=
|
|
1
|
+
import {useCallback}from'react';var h=a=>{let{theme:e,animation:r,meshColors:o,mode:i="auto"}=a,s=e?.light||{background:"#ffffff",color:"#000000"},t=e?.dark||{background:"#000000",color:"#ffffff"},n="",l="";if(i==="light"?l=`
|
|
2
|
+
#vite-splash-screen { background-color: ${s.background}; color: ${s.color}; }
|
|
3
|
+
.splash-logo-light { display: block; }
|
|
4
|
+
.splash-logo-dark { display: none; }
|
|
5
|
+
`:i==="dark"?l=`
|
|
6
|
+
#vite-splash-screen { background-color: ${t.background}; color: ${t.color}; }
|
|
7
|
+
.splash-logo-light { display: none; }
|
|
8
|
+
.splash-logo-dark { display: block; }
|
|
9
|
+
`:l=`
|
|
10
|
+
#vite-splash-screen { background-color: ${s.background}; color: ${s.color}; }
|
|
11
|
+
.splash-logo-light { display: block; }
|
|
12
|
+
.splash-logo-dark { display: none; }
|
|
13
|
+
@media (prefers-color-scheme: dark) {
|
|
14
|
+
#vite-splash-screen { background-color: ${t.background}; color: ${t.color}; }
|
|
15
|
+
.splash-logo-dark { display: block; }
|
|
16
|
+
.splash-logo-light { display: none; }
|
|
17
|
+
}
|
|
18
|
+
`,r==="pulse"&&(n+=`
|
|
2
19
|
.splash-logo { animation: splash-pulse 2s infinite; }
|
|
3
20
|
@keyframes splash-pulse {
|
|
4
21
|
0%, 100% { transform: scale(1); opacity: 1; }
|
|
5
22
|
50% { transform: scale(1.1); opacity: 0.8; }
|
|
6
23
|
}
|
|
7
|
-
`),
|
|
24
|
+
`),r==="gradient-mesh"){let c=["#3498db","#9b59b6","#2ecc71"],g=o?.length?o:c,d=["center","20% 30%","80% 70%","40% 80%","70% 20%","10% 60%","90% 40%"],m=g.map((f,u)=>`radial-gradient(circle at ${d[u%d.length]}, ${f} 0%, transparent 50%)`).join(",");n+=`
|
|
8
25
|
#vite-splash-screen::before {
|
|
9
26
|
content: ""; position: absolute; top: -50%; left: -50%; width: 200%; height: 200%;
|
|
10
|
-
background: ${
|
|
27
|
+
background: ${m}; z-index: -1; animation: rotate-mesh 20s linear infinite;
|
|
11
28
|
opacity: 0.3; filter: blur(60px);
|
|
12
29
|
}
|
|
13
30
|
@keyframes rotate-mesh { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
|
|
@@ -17,27 +34,25 @@ import {useCallback}from'react';var h=s=>{let{theme:e,animation:i,meshColors:r}=
|
|
|
17
34
|
display: flex; flex-direction: column; align-items: center; justify-content: center;
|
|
18
35
|
z-index: 999999; transition: opacity 0.5s, visibility 0.5s;
|
|
19
36
|
font-family: -apple-system, system-ui, sans-serif;
|
|
20
|
-
background-color: ${
|
|
37
|
+
background-color: ${s.background}; color: ${s.color};
|
|
21
38
|
}
|
|
22
39
|
#vite-splash-screen.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
|
|
23
40
|
.splash-logo { width: 120px; height: 120px; margin-bottom: 20px; }
|
|
24
41
|
.splash-logo svg { fill: currentColor; width: 100%; height: 100%; }
|
|
25
42
|
.splash-text { font-size: 1.2rem; font-weight: 500; }
|
|
26
43
|
.splash-version { position: absolute; bottom: 20px; font-size: 0.8rem; opacity: 0.7; }
|
|
27
|
-
|
|
28
|
-
#vite-splash-screen { background-color: ${o.background}; color: ${o.color}; }
|
|
29
|
-
}
|
|
44
|
+
${l}
|
|
30
45
|
${n}
|
|
31
|
-
`.replace(/\s+/g," ").trim()};function
|
|
32
|
-
<style>${
|
|
46
|
+
`.replace(/\s+/g," ").trim()};function y(){return {hideSplashScreen:useCallback(()=>{let e=document.getElementById("vite-splash-screen");e&&(e.classList.add("hidden"),setTimeout(()=>e.remove(),500));},[])}}function x(a){return {name:"vite-plugin-react-splash",transformIndexHtml(e){let r=h(a),{logo:o,text:i,version:s,duration:t=3e3,onlyStandalone:n=false,showOnce:l=false}=a,p=typeof o=="string"?`<div class="splash-logo">${o}</div>`:`<div class="splash-logo splash-logo-light">${o.light}</div><div class="splash-logo splash-logo-dark">${o.dark}</div>`,c=`
|
|
47
|
+
<style>${r}</style>
|
|
33
48
|
<div id="vite-splash-screen">
|
|
34
|
-
|
|
35
|
-
${
|
|
36
|
-
${
|
|
49
|
+
${p}
|
|
50
|
+
${i?`<div class="splash-text">${i}</div>`:""}
|
|
51
|
+
${s?`<div class="splash-version">v${s}</div>`:""}
|
|
37
52
|
</div>
|
|
38
53
|
<script>
|
|
39
54
|
(function(){
|
|
40
|
-
var d=${
|
|
55
|
+
var d=${t},o=${n},s1=${l},s=document.getElementById('vite-splash-screen');
|
|
41
56
|
if(s){
|
|
42
57
|
var isPWA = window.matchMedia('(display-mode: standalone)').matches || (window.navigator && window.navigator.standalone);
|
|
43
58
|
var shown = false;
|
|
@@ -54,4 +69,4 @@ ${o?`<div class="splash-version">v${o}</div>`:""}
|
|
|
54
69
|
},d);
|
|
55
70
|
}
|
|
56
71
|
})();
|
|
57
|
-
</script>`.replace(/>\s+</g,"><").trim();return e.replace("<body>",`<body>${
|
|
72
|
+
</script>`.replace(/>\s+</g,"><").trim();return e.replace("<body>",`<body>${c}`)}}}export{y as useSplashScreen,x as viteSplashScreen};
|
package/package.json
CHANGED