fix: inject app version from package.json instead of hardcoded 1.0.0
- Add Vite define for __APP_VERSION__ from package.json - Use dynamic version in gateway connect handshake and userAgent - Show version number in sidebar footer - Add globals.d.ts type declaration
This commit is contained in:
@@ -137,11 +137,12 @@ export function Sidebar({ sessions, activeSession, onSwitch, open, onClose }: Pr
|
|||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
{/* Footer glow dots */}
|
{/* Footer with version */}
|
||||||
<div className="px-4 py-3 border-t border-white/8 flex items-center justify-center gap-2">
|
<div className="px-4 py-3 border-t border-white/8 flex items-center justify-center gap-2">
|
||||||
<span className="h-1.5 w-1.5 rounded-full bg-violet-300/60 shadow-[0_0_10px_rgba(168,85,247,0.5)]" />
|
<span className="h-1.5 w-1.5 rounded-full bg-violet-300/60 shadow-[0_0_10px_rgba(168,85,247,0.5)]" />
|
||||||
<span className="h-1.5 w-1.5 rounded-full bg-cyan-300/60 shadow-[0_0_10px_rgba(34,211,238,0.5)]" />
|
<span className="h-1.5 w-1.5 rounded-full bg-cyan-300/60 shadow-[0_0_10px_rgba(34,211,238,0.5)]" />
|
||||||
<span className="h-1.5 w-1.5 rounded-full bg-indigo-300/50 shadow-[0_0_10px_rgba(99,102,241,0.4)]" />
|
<span className="h-1.5 w-1.5 rounded-full bg-indigo-300/50 shadow-[0_0_10px_rgba(99,102,241,0.4)]" />
|
||||||
|
<span className="ml-1 text-[9px] text-zinc-600 select-all" title={`PinchChat v${__APP_VERSION__}`}>v{__APP_VERSION__}</span>
|
||||||
</div>
|
</div>
|
||||||
</aside>
|
</aside>
|
||||||
</>
|
</>
|
||||||
|
|||||||
1
src/globals.d.ts
vendored
Normal file
1
src/globals.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
declare const __APP_VERSION__: string;
|
||||||
@@ -98,7 +98,7 @@ export class GatewayClient {
|
|||||||
this.request(id, 'connect', {
|
this.request(id, 'connect', {
|
||||||
minProtocol: 3,
|
minProtocol: 3,
|
||||||
maxProtocol: 3,
|
maxProtocol: 3,
|
||||||
client: { id: 'webchat', version: '1.0.0', platform: 'web', mode: 'webchat' },
|
client: { id: 'webchat', version: __APP_VERSION__, platform: 'web', mode: 'webchat' },
|
||||||
role: 'operator',
|
role: 'operator',
|
||||||
scopes: ['operator.read', 'operator.write'],
|
scopes: ['operator.read', 'operator.write'],
|
||||||
caps: [],
|
caps: [],
|
||||||
@@ -106,7 +106,7 @@ export class GatewayClient {
|
|||||||
permissions: {},
|
permissions: {},
|
||||||
auth: { token: this.authToken },
|
auth: { token: this.authToken },
|
||||||
locale: navigator.language || 'en',
|
locale: navigator.language || 'en',
|
||||||
userAgent: 'pinchchat/1.0.0',
|
userAgent: `pinchchat/${__APP_VERSION__}`,
|
||||||
}).then((res) => {
|
}).then((res) => {
|
||||||
console.log('[GW] connected!', res);
|
console.log('[GW] connected!', res);
|
||||||
this.connected = true;
|
this.connected = true;
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
import { defineConfig } from 'vite'
|
import { defineConfig } from 'vite'
|
||||||
import react from '@vitejs/plugin-react'
|
import react from '@vitejs/plugin-react'
|
||||||
import tailwindcss from '@tailwindcss/vite'
|
import tailwindcss from '@tailwindcss/vite'
|
||||||
|
import pkg from './package.json' with { type: 'json' }
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
|
define: {
|
||||||
|
__APP_VERSION__: JSON.stringify(pkg.version),
|
||||||
|
},
|
||||||
plugins: [react(), tailwindcss()],
|
plugins: [react(), tailwindcss()],
|
||||||
build: {
|
build: {
|
||||||
rollupOptions: {
|
rollupOptions: {
|
||||||
|
|||||||
Reference in New Issue
Block a user