1
0
mirror of https://github.com/spacebarchat/client.git synced 2024-11-23 19:02:29 +01:00

fix tauri builds

This commit is contained in:
Puyodead1 2023-09-15 12:20:16 -04:00
parent f8b96bf341
commit 876ffce940
No known key found for this signature in database
GPG Key ID: BA5F91AAEF68E5CE
16 changed files with 116 additions and 65 deletions

View File

@ -8,7 +8,9 @@
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-unused-vars": "off",
"react-hooks/exhaustive-deps": "off"
"react-hooks/exhaustive-deps": "off",
"react-hooks/rules-of-hooks": "warn",
"@typescript-eslint/ban-ts-comment": "warn"
},
"env": {
"browser": true,

View File

@ -19,7 +19,7 @@
property="og:description"
content="Spacebar is a free and open source software compatible with Discord. It's a chat, voice and video platform similar to Slack and Rocket.chat."
/>
<meta property="og:image" content="%PUBLIC_URL%/Spacebar.png" />
<meta property="og:image" content="/Spacebar.png" />
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image" />
@ -29,7 +29,7 @@
property="twitter:description"
content="Spacebar is a free and open source software compatible with Discord. It's a chat, voice and video platform similar to Slack and Rocket.chat."
/>
<meta property="twitter:image" content="%PUBLIC_URL%/Spacebar.png" />
<meta property="twitter:image" content="/Spacebar.png" />
<link rel="apple-touch-icon" href="/logo192.png" />
<link rel="icon" href="/favicon.ico" />

View File

@ -29,6 +29,7 @@
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"dayjs": "^1.11.9",
"framer-motion": "^10.16.4",
"missing-native-js-functions": "^1.4.3",
"mobx": "^6.10.2",
@ -42,7 +43,6 @@
"react-hook-form": "^7.46.1",
"react-infinite-scroll-component": "^6.1.0",
"react-loading-skeleton": "^3.3.1",
"react-moment": "^1.1.3",
"react-router-dom": "^6.16.0",
"react-secure-storage": "^1.3.0",
"react-select-search": "^4.1.6",
@ -70,6 +70,7 @@
"vite": "^4.4.5",
"vite-plugin-chunk-split": "^0.4.7",
"vite-plugin-clean": "^1.0.0",
"vite-plugin-html": "^3.2.0",
"vite-plugin-progress": "^0.0.7",
"vite-plugin-svgr": "^3.2.0"
},

View File

@ -80,6 +80,9 @@ dependencies:
'@testing-library/user-event':
specifier: ^13.5.0
version: 13.5.0(@testing-library/dom@9.3.1)
dayjs:
specifier: ^1.11.9
version: 1.11.9
framer-motion:
specifier: ^10.16.4
version: 10.16.4(react-dom@18.2.0)(react@18.2.0)
@ -119,9 +122,6 @@ dependencies:
react-loading-skeleton:
specifier: ^3.3.1
version: 3.3.1(react@18.2.0)
react-moment:
specifier: ^1.1.3
version: 1.1.3(moment@2.29.4)(prop-types@15.8.1)(react@18.2.0)
react-router-dom:
specifier: ^6.16.0
version: 6.16.0(react-dom@18.2.0)(react@18.2.0)
@ -199,6 +199,9 @@ devDependencies:
vite-plugin-clean:
specifier: ^1.0.0
version: 1.0.0
vite-plugin-html:
specifier: ^3.2.0
version: 3.2.0(vite@4.4.9)
vite-plugin-progress:
specifier: ^0.0.7
version: 0.0.7(vite@4.4.9)
@ -2715,7 +2718,7 @@ packages:
dependencies:
'@jridgewell/set-array': 1.1.2
'@jridgewell/sourcemap-codec': 1.4.15
'@jridgewell/trace-mapping': 0.3.18
'@jridgewell/trace-mapping': 0.3.19
/@jridgewell/resolve-uri@3.1.0:
resolution: {integrity: sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==}
@ -2724,7 +2727,6 @@ packages:
/@jridgewell/resolve-uri@3.1.1:
resolution: {integrity: sha512-dSYZh7HhCDtCKm4QakX0xFpsRDqjjtZf/kjI/v3T3Nwt5r8/qz/M19F9ySyOqU94SXBmeG9ttTul+YnR4LOxFA==}
engines: {node: '>=6.0.0'}
dev: true
/@jridgewell/set-array@1.1.2:
resolution: {integrity: sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==}
@ -2754,7 +2756,6 @@ packages:
dependencies:
'@jridgewell/resolve-uri': 3.1.1
'@jridgewell/sourcemap-codec': 1.4.15
dev: true
/@jridgewell/trace-mapping@0.3.9:
resolution: {integrity: sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==}
@ -5334,11 +5335,20 @@ packages:
resolution: {integrity: sha512-JsPKdmh8ZkmnHxDk55FZ1TqVLvEQTvoByJZRN9jzI0UjxK/QgAmsphz7PGtqgPieQZ/CQcHWXCR7ATDNhGe+YA==}
dev: true
/connect-history-api-fallback@1.6.0:
resolution: {integrity: sha512-e54B99q/OUoH64zYYRf3HBP5z24G38h5D3qXu23JGRoigpX5Ss4r9ZnDk3g0Z8uQC2x2lPaJ+UlWBc1ZWBWdLg==}
engines: {node: '>=0.8'}
dev: true
/connect-history-api-fallback@2.0.0:
resolution: {integrity: sha512-U73+6lQFmfiNPrYbXqr6kZ1i1wiRqXnp2nhMsINseWXO8lDau0LGEffJ8kQi4EjLZympVgRdvqjAgiZ1tgzDDA==}
engines: {node: '>=0.8'}
dev: true
/consola@2.15.3:
resolution: {integrity: sha512-9vAdYbHj6x2fLKC4+oPH0kFzY/orMZyG2Aj+kNylHxKGJ/Ed4dpNyAQYwJOdqO4zdM7XpVHmyejQDcQHrnuXbw==}
dev: true
/content-disposition@0.5.4:
resolution: {integrity: sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==}
engines: {node: '>= 0.6'}
@ -5718,6 +5728,10 @@ packages:
whatwg-url: 8.7.0
dev: true
/dayjs@1.11.9:
resolution: {integrity: sha512-QvzAURSbQ0pKdIye2txOzNaHmxtUBXerpY0FJsFXUMKbIZeFm5ht1LS/jFsrncjnmtv8HsG0W2g6c0zUjZWmpA==}
dev: false
/debug@2.6.9:
resolution: {integrity: sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==}
peerDependencies:
@ -6002,11 +6016,21 @@ packages:
resolution: {integrity: sha512-YXQl1DSa4/PQyRfgrv6aoNjhasp/p4qs9FjJ4q4cQk+8m4r6k4ZSiEyytKG8f8W9gi8WsQtIObNmKd+tMzNTmA==}
dev: true
/dotenv-expand@8.0.3:
resolution: {integrity: sha512-SErOMvge0ZUyWd5B0NXMQlDkN+8r+HhVUsxgOO7IoPDOdDRD2JjExpN6y3KnFR66jsJMwSn1pqIivhU5rcJiNg==}
engines: {node: '>=12'}
dev: true
/dotenv@10.0.0:
resolution: {integrity: sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==}
engines: {node: '>=10'}
dev: true
/dotenv@16.3.1:
resolution: {integrity: sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==}
engines: {node: '>=12'}
dev: true
/duplexer@0.1.2:
resolution: {integrity: sha512-jtD6YG370ZCIi/9GTaJKQxWTZD045+4R4hTk/x1UyoqadyJ9x9CgSi1RlVDQF8U2sxLLSnFkCaMihqljHIWgMg==}
dev: true
@ -9033,10 +9057,6 @@ packages:
resolution: {integrity: sha512-B1UGC3ieK3boCjnMEcZSwxqRDMdzX65H/8zOHbuTY8ZhvrIjTUoLRR2TP2bPqIgYRfb3+dUigu8yMZufNjn0LQ==}
dev: false
/moment@2.29.4:
resolution: {integrity: sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==}
dev: false
/ms@2.0.0:
resolution: {integrity: sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==}
dev: true
@ -9102,6 +9122,13 @@ packages:
engines: {node: '>= 6.13.0'}
dev: true
/node-html-parser@5.4.2:
resolution: {integrity: sha512-RaBPP3+51hPne/OolXxcz89iYvQvKOydaqoePpOgXcrOKZhjVIzmpKZz+Hd/RBO2/zN2q6CNJhQzucVz+u3Jyw==}
dependencies:
css-select: 4.3.0
he: 1.2.0
dev: true
/node-int64@0.4.0:
resolution: {integrity: sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw==}
dev: true
@ -9437,6 +9464,10 @@ packages:
resolution: {integrity: sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==}
engines: {node: '>=8'}
/pathe@0.2.0:
resolution: {integrity: sha512-sTitTPYnn23esFR3RlqYBWn4c45WGeLcsKzQiUpXJAyfcWkolvlYpV8FLo7JishK946oQwMFUCHXQ9AjGPKExw==}
dev: true
/performance-now@2.1.0:
resolution: {integrity: sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow==}
dev: true
@ -10539,18 +10570,6 @@ packages:
react: 18.2.0
dev: false
/react-moment@1.1.3(moment@2.29.4)(prop-types@15.8.1)(react@18.2.0):
resolution: {integrity: sha512-8EPvlUL8u6EknPp1ISF5MQ3wx2OHJVXIP/iZc4wRh3iV3XozftZERDv9ANZeAtMlhNNQHdFoqcZHFUkBSTONfA==}
peerDependencies:
moment: ^2.29.0
prop-types: ^15.7.0
react: ^16.0 || ^17.0.0 || ^18.0.0
dependencies:
moment: 2.29.4
prop-types: 15.8.1
react: 18.2.0
dev: false
/react-refresh@0.11.0:
resolution: {integrity: sha512-F27qZr8uUqwhWZboondsPx8tnC3Ct3SxZA3V5WyEvujRyyNv0VYPhoBg1gZ8/MV5tubQp76Trw8lTv9hzRBa+A==}
engines: {node: '>=0.10.0'}
@ -12219,6 +12238,26 @@ packages:
- stylus
dev: true
/vite-plugin-html@3.2.0(vite@4.4.9):
resolution: {integrity: sha512-2VLCeDiHmV/BqqNn5h2V+4280KRgQzCFN47cst3WiNK848klESPQnzuC3okH5XHtgwHH/6s1Ho/YV6yIO0pgoQ==}
peerDependencies:
vite: '>=2.0.0'
dependencies:
'@rollup/pluginutils': 4.2.1
colorette: 2.0.20
connect-history-api-fallback: 1.6.0
consola: 2.15.3
dotenv: 16.3.1
dotenv-expand: 8.0.3
ejs: 3.1.9
fast-glob: 3.3.1
fs-extra: 10.1.0
html-minifier-terser: 6.1.0
node-html-parser: 5.4.2
pathe: 0.2.0
vite: 4.4.9(@types/node@16.18.50)
dev: true
/vite-plugin-progress@0.0.7(vite@4.4.9):
resolution: {integrity: sha512-zyvKdcc/X+6hnw3J1HVV1TKrlFKC4Rh8GnDnWG/2qhRXjqytTcM++xZ+SAPnoDsSyWl8O93ymK0wZRgHAoglEQ==}
engines: {node: '>=14', pnpm: '>=7.0.0'}

View File

@ -19,6 +19,7 @@ tauri-build = { version = "2.0.0-alpha", features = [] }
[dependencies]
# tauri = { version = "2.0.0-alpha", features = [] }
tauri = { git = "https://github.com/tauri-apps/tauri.git", branch = "dev", features = [
"devtools",
] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"

View File

@ -21,8 +21,11 @@ async fn close_splashscreen() {
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
std::env::set_var("RUST_BACKTRACE", "1");
std::env::set_var("RUST_LOG", "debug");
tauri::Builder::default()
.invoke_handler(tauri::generate_handler![close_splashscreen])
.invoke_handler(tauri::generate_handler![close_splashscreen,])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}

View File

@ -1,7 +1,6 @@
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
#[cfg(desktop)]
fn main() {
spacebar::run();
}

View File

@ -1,7 +1,7 @@
{
"build": {
"beforeDevCommand": "npm run dev",
"beforeBuildCommand": "npm run build",
"beforeDevCommand": "pnpm run dev",
"beforeBuildCommand": "pnpm run build",
"devPath": "http://localhost:1420",
"distDir": "../build",
"withGlobalTauri": false
@ -31,6 +31,13 @@
"sidebarImage": "./icons/sidebar.bmp",
"installerIcon": "./icons/icon.ico"
}
},
"updater": {
"active": false,
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDQxRkQwNTY1NzBEOTMyMTUKUldRVk10bHdaUVg5UWVoVm9JeDg4UEs1TkpMT3FKdzc3Y29CN2NZNk9vRE9sanJCUERqT09HVVYK",
"windows": {
"installMode": "passive"
}
}
},
"security": {
@ -41,6 +48,9 @@
"plugins": {
"shell": {
"open": true
},
"updater": {
"endpoints": ["https://update.spacebar.chat/updates/{{target}}/{{arch}}"]
}
}
}

View File

@ -1,14 +1,6 @@
{
"tauri": {
"windows": [
{
"fullscreen": false,
"resizable": true,
"title": "Spacebar",
"maximized": true,
"visible": false,
"label": "main"
},
{
"width": 400,
"height": 200,
@ -16,6 +8,14 @@
"center": true,
"url": "splashscreen.html",
"label": "splashscreen"
},
{
"fullscreen": false,
"resizable": true,
"title": "Spacebar",
"maximized": true,
"visible": false,
"label": "main"
}
]
}

View File

@ -1,11 +1,10 @@
import { MessageType } from "@spacebarchat/spacebar-api-types/v9";
import dayjs from "dayjs";
import { observer } from "mobx-react-lite";
import React, { Fragment } from "react";
import Moment from "react-moment";
import styled from "styled-components";
import { ContextMenuContext } from "../../contexts/ContextMenuContext";
import { MessageLike } from "../../stores/objects/Message";
import { calendarStrings } from "../../utils/i18n";
import Avatar from "../Avatar";
import { Link } from "../Link";
import { IContextMenuItem } from "./../ContextMenuItem";
@ -229,10 +228,7 @@ function Message({ message, isHeader, isSending, isFailed }: Props) {
{isHeader && (
<MessageHeader>
<MessageAuthor>{message.author.username}</MessageAuthor>
<MessageTimestamp>
<Moment calendar={calendarStrings} date={new Date(message.timestamp)} />
</MessageTimestamp>
<MessageTimestamp>{dayjs(message.timestamp).calendar()}</MessageTimestamp>
</MessageHeader>
)}

View File

@ -1,8 +1,8 @@
import { useModals } from "@mattjennings/react-modal-stack";
import { APIInvite, Routes } from "@spacebarchat/spacebar-api-types/v9";
import dayjs from "dayjs";
import React from "react";
import { useForm } from "react-hook-form";
import Moment from "react-moment";
import styled from "styled-components";
import useLogger from "../../hooks/useLogger";
import { useAppStore } from "../../stores/AppStore";
@ -346,9 +346,7 @@ function CreateInviteModal(props: InviteModalProps) {
}}
>
{inviteExpiresAt ? (
<>
This invite will expire <Moment fromNow>{inviteExpiresAt}</Moment>
</>
<>This invite will expire {dayjs(inviteExpiresAt).calendar()}</>
) : (
"Invite will never expire."
)}

View File

@ -12,6 +12,9 @@ import "@fontsource/roboto/500.css";
import "@fontsource/roboto/700.css";
import "@fontsource/roboto/900.css";
import { ModalStack } from "@mattjennings/react-modal-stack";
import dayjs from "dayjs";
import calendar from "dayjs/plugin/calendar";
import relativeTime from "dayjs/plugin/relativeTime";
import ReactDOM from "react-dom/client";
import { BrowserRouter } from "react-router-dom";
import App from "./App";
@ -21,6 +24,9 @@ import { ContextMenuContextProvider } from "./contexts/ContextMenuContext";
import Theme from "./contexts/Theme";
import "./index.css";
dayjs.extend(relativeTime);
dayjs.extend(calendar);
ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
<BrowserRouter>
<ModalStack renderModals={ModalRenderer}>

View File

@ -78,5 +78,5 @@ export const getFileDetails = (fileOrAttachment: File | APIAttachment) => {
};
};
// @ts-expect-error - tauri is not defined
// @ts-ignore
export const isTauri = !!window.__TAURI__;

View File

@ -1,6 +1,8 @@
export const calendarStrings = {
lastDay: "[Yesterday at] LT",
nextDay: "[Tomorrow at] LT",
sameDay: "[Today at] LT",
sameElse: "MM/DD/YYYY LT",
sameDay: "[Today at] h:mm A", // The same day ( Today at 2:30 AM )
nextDay: "[Tomorrow at] h:mm A", // The next day ( Tomorrow at 2:30 AM )
nextWeek: "dddd [at] h:mm A", // The next week ( Sunday at 2:30 AM )
lastDay: "[Yesterday at] h:mm A", // The day before ( Yesterday at 2:30 AM )
lastWeek: "[Last] dddd [at] h:mm A", // Last week ( Last Monday at 2:30 AM )
sameElse: "MM/DD/YYYY h:mm A", // Everything else ( 17/10/2011 )
};

View File

@ -1,4 +1,3 @@
import { esbuildCommonjs } from "@originjs/vite-plugin-commonjs";
import replace from "@rollup/plugin-replace";
import react from "@vitejs/plugin-react";
import { readFileSync } from "fs";
@ -49,16 +48,13 @@ const mobile = !!/android|ios/.exec(process.env.TAURI_PLATFORM);
// https://vitejs.dev/config/
export default defineConfig(async () => ({
plugins: [
cleanPlugin(),
react(),
svgr(),
chunkSplitPlugin({
strategy: "unbundle",
customSplitting: {
"react-vendor": ["react", "react-dom", "react-router-dom"],
},
}),
progress(),
cleanPlugin(),
replace({
__GIT_REVISION__: getGitRevision(),
__GIT_BRANCH__: getGitBranch(),
@ -85,23 +81,21 @@ export default defineConfig(async () => ({
: undefined,
strictPort: true,
},
optimizeDeps: {
esbuildOptions: {
plugins: [esbuildCommonjs(["react-moment"])],
},
},
// 3. to make use of `TAURI_DEBUG` and other env variables
// https://tauri.studio/v1/api/config#buildconfig.beforedevcommand
envPrefix: ["VITE_", "TAURI_"],
build: {
outDir: "build",
sourcemap: true,
rollupOptions: {
input: {
main: resolve(__dirname, "index.html"),
},
output: {
dir: "build",
chunkFileNames: "[hash:20].js",
entryFileNames: "asset/[hash:20].js",
chunkFileNames: "asset/[hash:20].js",
assetFileNames: "asset/[hash:20].[ext]",
},
},
},