vite-plugin-react-splash 1.0.0 → 1.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/README.md CHANGED
@@ -25,7 +25,10 @@ export default defineConfig({
25
25
  plugins: [
26
26
  react(),
27
27
  viteSplashScreen({
28
- logo: `<svg ...>...</svg>`, // Your SVG string
28
+ logo: {
29
+ light: `<svg ...>...</svg>`, // Logo for light mode
30
+ dark: `<svg ...>...</svg>` // Logo for dark mode
31
+ },
29
32
  duration: 3000,
30
33
  text: 'Loading My Awesome App...',
31
34
  version: '1.0.0',
@@ -33,7 +36,9 @@ export default defineConfig({
33
36
  light: { background: '#f0f0f0', color: '#333' },
34
37
  dark: { background: '#1a1a1a', color: '#fff' }
35
38
  },
36
- animation: 'gradient-mesh' // Options: 'none', 'pulse', 'gradient-mesh'
39
+ animation: 'gradient-mesh', // Options: 'none', 'pulse', 'gradient-mesh'
40
+ onlyStandalone: true, // Only show when running as a PWA in standalone mode
41
+ showOnce: true // Only show on the very first visit
37
42
  }),
38
43
  ],
39
44
  });
@@ -65,10 +70,12 @@ function App() {
65
70
 
66
71
  | Option | Type | Description |
67
72
  | --- | --- | --- |
68
- | `logo` | `string` | SVG string to display as the logo. |
73
+ | `logo` | `string \| { light: string, dark: string }` | SVG string or object with light/dark versions. |
69
74
  | `duration` | `number` | Time in ms before the splash screen automatically hides. |
70
75
  | `text` | `string` | Text to display below the logo. |
71
76
  | `version` | `string` | Version string to display at the bottom. |
72
77
  | `theme` | `object` | Light and dark mode colors. |
73
78
  | `animation` | `string` | Animation style: `'none'`, `'pulse'`, `'gradient-mesh'`. |
79
+ | `onlyStandalone` | `boolean` | If `true`, only shows the splash screen in PWA standalone mode. |
80
+ | `showOnce` | `boolean` | If `true`, only shows the splash screen on the first load (persists via `localStorage`). |
74
81
 
package/dist/index.d.mts CHANGED
@@ -17,6 +17,8 @@ interface SplashScreenOptions {
17
17
  };
18
18
  animation?: 'none' | 'fade' | 'pulse' | 'slide-up' | 'gradient-mesh';
19
19
  meshColors?: string[];
20
+ onlyStandalone?: boolean;
21
+ showOnce?: boolean;
20
22
  }
21
23
 
22
24
  declare function useSplashScreen(): {
package/dist/index.d.ts CHANGED
@@ -17,6 +17,8 @@ interface SplashScreenOptions {
17
17
  };
18
18
  animation?: 'none' | 'fade' | 'pulse' | 'slide-up' | 'gradient-mesh';
19
19
  meshColors?: string[];
20
+ onlyStandalone?: boolean;
21
+ showOnce?: boolean;
20
22
  }
21
23
 
22
24
  declare function useSplashScreen(): {
package/dist/index.js CHANGED
@@ -1,13 +1,13 @@
1
- 'use strict';var react=require('react');var c=t=>{let{theme:e,animation:n,meshColors:r}=t,s=e?.light||{background:"#ffffff",color:"#000000"},o=e?.dark||{background:"#000000",color:"#ffffff"},i="";if(n==="pulse"&&(i+=`
1
+ 'use strict';var react=require('react');var h=s=>{let{theme:e,animation:i,meshColors:r}=s,t=e?.light||{background:"#ffffff",color:"#000000"},o=e?.dark||{background:"#000000",color:"#ffffff"},n="";if(i==="pulse"&&(n+=`
2
2
  .splash-logo { animation: splash-pulse 2s infinite; }
3
3
  @keyframes splash-pulse {
4
4
  0%, 100% { transform: scale(1); opacity: 1; }
5
5
  50% { transform: scale(1.1); opacity: 0.8; }
6
6
  }
7
- `),n==="gradient-mesh"){let p=["#3498db","#9b59b6","#2ecc71"],d=r?.length?r:p,l=["center","20% 30%","80% 70%","40% 80%","70% 20%","10% 60%","90% 40%"],h=d.map((m,f)=>`radial-gradient(circle at ${l[f%l.length]}, ${m} 0%, transparent 50%)`).join(",");i+=`
7
+ `),i==="gradient-mesh"){let a=["#3498db","#9b59b6","#2ecc71"],l=r?.length?r:a,p=["center","20% 30%","80% 70%","40% 80%","70% 20%","10% 60%","90% 40%"],d=l.map((m,f)=>`radial-gradient(circle at ${p[f%p.length]}, ${m} 0%, transparent 50%)`).join(",");n+=`
8
8
  #vite-splash-screen::before {
9
9
  content: ""; position: absolute; top: -50%; left: -50%; width: 200%; height: 200%;
10
- background: ${h}; z-index: -1; animation: rotate-mesh 20s linear infinite;
10
+ background: ${d}; z-index: -1; animation: rotate-mesh 20s linear infinite;
11
11
  opacity: 0.3; filter: blur(60px);
12
12
  }
13
13
  @keyframes rotate-mesh { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@@ -17,7 +17,7 @@
17
17
  display: flex; flex-direction: column; align-items: center; justify-content: center;
18
18
  z-index: 999999; transition: opacity 0.5s, visibility 0.5s;
19
19
  font-family: -apple-system, system-ui, sans-serif;
20
- background-color: ${s.background}; color: ${s.color};
20
+ background-color: ${t.background}; color: ${t.color};
21
21
  }
22
22
  #vite-splash-screen.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
23
23
  .splash-logo { width: 120px; height: 120px; margin-bottom: 20px; }
@@ -27,20 +27,31 @@
27
27
  @media (prefers-color-scheme: dark) {
28
28
  #vite-splash-screen { background-color: ${o.background}; color: ${o.color}; }
29
29
  }
30
- ${i}
31
- `.replace(/\s+/g," ").trim()};function g(){return {hideSplashScreen:react.useCallback(()=>{let e=document.getElementById("vite-splash-screen");e&&(e.classList.add("hidden"),setTimeout(()=>e.remove(),500));},[])}}function x(t){return {name:"vite-plugin-react-splash",transformIndexHtml(e){let n=c(t),{logo:r,text:s,version:o,duration:i=3e3}=t,a=`
32
- <style>${n}</style>
30
+ ${n}
31
+ `.replace(/\s+/g," ").trim()};function u(){return {hideSplashScreen:react.useCallback(()=>{let e=document.getElementById("vite-splash-screen");e&&(e.classList.add("hidden"),setTimeout(()=>e.remove(),500));},[])}}function x(s){return {name:"vite-plugin-react-splash",transformIndexHtml(e){let i=h(s),{logo:r,text:t,version:o,duration:n=3e3,onlyStandalone:c=false,showOnce:a=false}=s,l=`
32
+ <style>${i}</style>
33
33
  <div id="vite-splash-screen">
34
34
  <div class="splash-logo">${r}</div>
35
- ${s?`<div class="splash-text">${s}</div>`:""}
35
+ ${t?`<div class="splash-text">${t}</div>`:""}
36
36
  ${o?`<div class="splash-version">v${o}</div>`:""}
37
37
  </div>
38
38
  <script>
39
39
  (function(){
40
- var d=${i},s=document.getElementById('vite-splash-screen');
41
- if(s){setTimeout(function(){
42
- s.classList.add('hidden');
43
- setTimeout(function(){s.remove()},500);
44
- },d)}
40
+ var d=${n},o=${c},s1=${a},s=document.getElementById('vite-splash-screen');
41
+ if(s){
42
+ var isPWA = window.matchMedia('(display-mode: standalone)').matches || (window.navigator && window.navigator.standalone);
43
+ var shown = false;
44
+ try { shown = localStorage.getItem('v-splash-shown'); } catch (e) {}
45
+ if((o && !isPWA) || (s1 && shown)){
46
+ s.style.display='none';
47
+ s.remove();
48
+ return;
49
+ }
50
+ if(s1) { try { localStorage.setItem('v-splash-shown', 'true'); } catch (e) {} }
51
+ setTimeout(function(){
52
+ s.classList.add('hidden');
53
+ setTimeout(function(){s.remove()},500);
54
+ },d);
55
+ }
45
56
  })();
46
- </script>`.replace(/>\s+</g,"><").trim();return e.replace("<body>",`<body>${a}`)}}}exports.useSplashScreen=g;exports.viteSplashScreen=x;
57
+ </script>`.replace(/>\s+</g,"><").trim();return e.replace("<body>",`<body>${l}`)}}}exports.useSplashScreen=u;exports.viteSplashScreen=x;
package/dist/index.mjs CHANGED
@@ -1,13 +1,13 @@
1
- import {useCallback}from'react';var c=t=>{let{theme:e,animation:n,meshColors:r}=t,s=e?.light||{background:"#ffffff",color:"#000000"},o=e?.dark||{background:"#000000",color:"#ffffff"},i="";if(n==="pulse"&&(i+=`
1
+ import {useCallback}from'react';var h=s=>{let{theme:e,animation:i,meshColors:r}=s,t=e?.light||{background:"#ffffff",color:"#000000"},o=e?.dark||{background:"#000000",color:"#ffffff"},n="";if(i==="pulse"&&(n+=`
2
2
  .splash-logo { animation: splash-pulse 2s infinite; }
3
3
  @keyframes splash-pulse {
4
4
  0%, 100% { transform: scale(1); opacity: 1; }
5
5
  50% { transform: scale(1.1); opacity: 0.8; }
6
6
  }
7
- `),n==="gradient-mesh"){let p=["#3498db","#9b59b6","#2ecc71"],d=r?.length?r:p,l=["center","20% 30%","80% 70%","40% 80%","70% 20%","10% 60%","90% 40%"],h=d.map((m,f)=>`radial-gradient(circle at ${l[f%l.length]}, ${m} 0%, transparent 50%)`).join(",");i+=`
7
+ `),i==="gradient-mesh"){let a=["#3498db","#9b59b6","#2ecc71"],l=r?.length?r:a,p=["center","20% 30%","80% 70%","40% 80%","70% 20%","10% 60%","90% 40%"],d=l.map((m,f)=>`radial-gradient(circle at ${p[f%p.length]}, ${m} 0%, transparent 50%)`).join(",");n+=`
8
8
  #vite-splash-screen::before {
9
9
  content: ""; position: absolute; top: -50%; left: -50%; width: 200%; height: 200%;
10
- background: ${h}; z-index: -1; animation: rotate-mesh 20s linear infinite;
10
+ background: ${d}; z-index: -1; animation: rotate-mesh 20s linear infinite;
11
11
  opacity: 0.3; filter: blur(60px);
12
12
  }
13
13
  @keyframes rotate-mesh { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@@ -17,7 +17,7 @@ import {useCallback}from'react';var c=t=>{let{theme:e,animation:n,meshColors:r}=
17
17
  display: flex; flex-direction: column; align-items: center; justify-content: center;
18
18
  z-index: 999999; transition: opacity 0.5s, visibility 0.5s;
19
19
  font-family: -apple-system, system-ui, sans-serif;
20
- background-color: ${s.background}; color: ${s.color};
20
+ background-color: ${t.background}; color: ${t.color};
21
21
  }
22
22
  #vite-splash-screen.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
23
23
  .splash-logo { width: 120px; height: 120px; margin-bottom: 20px; }
@@ -27,20 +27,31 @@ import {useCallback}from'react';var c=t=>{let{theme:e,animation:n,meshColors:r}=
27
27
  @media (prefers-color-scheme: dark) {
28
28
  #vite-splash-screen { background-color: ${o.background}; color: ${o.color}; }
29
29
  }
30
- ${i}
31
- `.replace(/\s+/g," ").trim()};function g(){return {hideSplashScreen:useCallback(()=>{let e=document.getElementById("vite-splash-screen");e&&(e.classList.add("hidden"),setTimeout(()=>e.remove(),500));},[])}}function x(t){return {name:"vite-plugin-react-splash",transformIndexHtml(e){let n=c(t),{logo:r,text:s,version:o,duration:i=3e3}=t,a=`
32
- <style>${n}</style>
30
+ ${n}
31
+ `.replace(/\s+/g," ").trim()};function u(){return {hideSplashScreen:useCallback(()=>{let e=document.getElementById("vite-splash-screen");e&&(e.classList.add("hidden"),setTimeout(()=>e.remove(),500));},[])}}function x(s){return {name:"vite-plugin-react-splash",transformIndexHtml(e){let i=h(s),{logo:r,text:t,version:o,duration:n=3e3,onlyStandalone:c=false,showOnce:a=false}=s,l=`
32
+ <style>${i}</style>
33
33
  <div id="vite-splash-screen">
34
34
  <div class="splash-logo">${r}</div>
35
- ${s?`<div class="splash-text">${s}</div>`:""}
35
+ ${t?`<div class="splash-text">${t}</div>`:""}
36
36
  ${o?`<div class="splash-version">v${o}</div>`:""}
37
37
  </div>
38
38
  <script>
39
39
  (function(){
40
- var d=${i},s=document.getElementById('vite-splash-screen');
41
- if(s){setTimeout(function(){
42
- s.classList.add('hidden');
43
- setTimeout(function(){s.remove()},500);
44
- },d)}
40
+ var d=${n},o=${c},s1=${a},s=document.getElementById('vite-splash-screen');
41
+ if(s){
42
+ var isPWA = window.matchMedia('(display-mode: standalone)').matches || (window.navigator && window.navigator.standalone);
43
+ var shown = false;
44
+ try { shown = localStorage.getItem('v-splash-shown'); } catch (e) {}
45
+ if((o && !isPWA) || (s1 && shown)){
46
+ s.style.display='none';
47
+ s.remove();
48
+ return;
49
+ }
50
+ if(s1) { try { localStorage.setItem('v-splash-shown', 'true'); } catch (e) {} }
51
+ setTimeout(function(){
52
+ s.classList.add('hidden');
53
+ setTimeout(function(){s.remove()},500);
54
+ },d);
55
+ }
45
56
  })();
46
- </script>`.replace(/>\s+</g,"><").trim();return e.replace("<body>",`<body>${a}`)}}}export{g as useSplashScreen,x as viteSplashScreen};
57
+ </script>`.replace(/>\s+</g,"><").trim();return e.replace("<body>",`<body>${l}`)}}}export{u as useSplashScreen,x as viteSplashScreen};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-react-splash",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "A Vite plugin and React hook for easy splash screen management in React apps.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",