Skip to content

Commit 8167fa4

Browse files
authored
Update dependency / types versions, and sort imports (#92)
* Update dependency / types versions, and sort imports * Update monaco-editor, only used for types I think
1 parent 4247aa1 commit 8167fa4

File tree

10 files changed

+1136
-2062
lines changed

10 files changed

+1136
-2062
lines changed

.prettierrc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
{
2-
"proseWrap": "always"
2+
"plugins": ["@trivago/prettier-plugin-sort-imports"],
3+
"proseWrap": "always",
4+
"importOrder": ["^[./]"],
5+
"importOrderSeparation": true,
6+
"importOrderSortSpecifiers": true
37
}

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ RUN npm ci
2020
COPY . .
2121
ARG GITHUB_SHA
2222
ENV VITE_SHA=${GITHUB_SHA}
23+
RUN npm run check
2324
RUN npm run build
2425

2526
FROM scratch

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html lang="en">
33
<head>
44
<meta charset="utf-8" />

package-lock.json

Lines changed: 1069 additions & 2003 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,35 @@
55
"private": true,
66
"scripts": {
77
"dev": "vite",
8+
"check": "tsc",
89
"build": "vite build",
910
"serve": "vite preview",
1011
"format": "prettier --write ."
1112
},
1213
"dependencies": {
13-
"@chakra-ui/react": "^2.8.2",
14-
"@emotion/react": "^11.7.1",
15-
"@emotion/styled": "^11.6.0",
16-
"@monaco-editor/react": "^4.3.1",
17-
"framer-motion": "^11.3.7",
14+
"@chakra-ui/react": "^2.10.4",
15+
"@emotion/react": "^11.14.0",
16+
"@emotion/styled": "^11.14.0",
17+
"@monaco-editor/react": "^4.6.0",
18+
"framer-motion": "^11.15.0",
1819
"lodash.debounce": "^4.0.8",
19-
"react": "^18.0.0",
20-
"react-dom": "^18.0.0",
21-
"react-icons": "^4.3.1",
20+
"react": "^18.3.1",
21+
"react-dom": "^18.3.1",
22+
"react-icons": "^5.4.0",
2223
"rustpad-wasm": "file:./rustpad-wasm/pkg",
23-
"use-local-storage-state": "^13.0.0"
24+
"use-local-storage-state": "^19.5.0"
2425
},
2526
"devDependencies": {
26-
"@types/lodash.debounce": "^4.0.6",
27-
"@types/react": "^17.0.38",
28-
"@types/react-dom": "^17.0.11",
29-
"@vitejs/plugin-react": "^1.1.3",
30-
"monaco-editor": "^0.31.1",
31-
"prettier": "2.5.1",
32-
"typescript": "~5.5.3",
33-
"vite": "^5.3.4",
34-
"vite-plugin-top-level-await": "^1.4.1",
35-
"vite-plugin-wasm": "^3.3.0"
36-
},
37-
"overrides": {
38-
"@swc/core": "~1.6.13"
27+
"@trivago/prettier-plugin-sort-imports": "^5.2.0",
28+
"@types/lodash.debounce": "^4.0.9",
29+
"@types/react": "^18.3.18",
30+
"@types/react-dom": "^18.3.5",
31+
"@vitejs/plugin-react": "^4.3.4",
32+
"monaco-editor": "^0.52.2",
33+
"prettier": "3.4.2",
34+
"typescript": "~5.7.2",
35+
"vite": "^6.0.6",
36+
"vite-plugin-top-level-await": "^1.4.4",
37+
"vite-plugin-wasm": "^3.4.1"
3938
}
4039
}

src/App.tsx

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
import { useEffect, useRef, useState } from "react";
21
import {
32
Box,
43
Button,
54
Container,
65
Flex,
7-
Heading,
86
HStack,
7+
Heading,
98
Icon,
109
Input,
1110
InputGroup,
@@ -17,27 +16,29 @@ import {
1716
Text,
1817
useToast,
1918
} from "@chakra-ui/react";
19+
import Editor from "@monaco-editor/react";
20+
import { editor } from "monaco-editor/esm/vs/editor/editor.api";
21+
import { useEffect, useRef, useState } from "react";
2022
import {
2123
VscChevronRight,
2224
VscFolderOpened,
2325
VscGist,
2426
VscRepoPull,
2527
} from "react-icons/vsc";
26-
import useStorage from "use-local-storage-state";
27-
import Editor from "@monaco-editor/react";
28-
import { editor } from "monaco-editor/esm/vs/editor/editor.api";
28+
import useLocalStorageState from "use-local-storage-state";
29+
2930
import rustpadRaw from "../rustpad-server/src/rustpad.rs?raw";
30-
import languages from "./languages.json";
31-
import animals from "./animals.json";
32-
import Rustpad, { UserInfo } from "./rustpad";
33-
import useHash from "./useHash";
3431
import ConnectionStatus from "./ConnectionStatus";
3532
import Footer from "./Footer";
3633
import User from "./User";
34+
import animals from "./animals.json";
35+
import languages from "./languages.json";
36+
import Rustpad, { UserInfo } from "./rustpad";
37+
import useHash from "./useHash";
3738

3839
function getWsUri(id: string) {
3940
let url = new URL(`api/socket/${id}`, window.location.href);
40-
url.protocol = (url.protocol == "https:") ? "wss:" : "ws:";
41+
url.protocol = url.protocol == "https:" ? "wss:" : "ws:";
4142
return url.href;
4243
}
4344

@@ -56,10 +57,16 @@ function App() {
5657
"connected" | "disconnected" | "desynchronized"
5758
>("disconnected");
5859
const [users, setUsers] = useState<Record<number, UserInfo>>({});
59-
const [name, setName] = useStorage("name", generateName);
60-
const [hue, setHue] = useStorage("hue", generateHue);
60+
const [name, setName] = useLocalStorageState("name", {
61+
defaultValue: generateName,
62+
});
63+
const [hue, setHue] = useLocalStorageState("hue", {
64+
defaultValue: generateHue,
65+
});
6166
const [editor, setEditor] = useState<editor.IStandaloneCodeEditor>();
62-
const [darkMode, setDarkMode] = useStorage("darkMode", () => false);
67+
const [darkMode, setDarkMode] = useLocalStorageState("darkMode", {
68+
defaultValue: false,
69+
});
6370
const rustpad = useRef<Rustpad>();
6471
const id = useHash();
6572

@@ -145,7 +152,7 @@ function App() {
145152
text: rustpadRaw,
146153
},
147154
],
148-
() => null
155+
() => null,
149156
);
150157
editor.setPosition({ column: 0, lineNumber: 0 });
151158
if (language !== "rust") {

src/User.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
import { useRef } from "react";
1919
import { FaPalette } from "react-icons/fa";
2020
import { VscAccount } from "react-icons/vsc";
21+
2122
import { UserInfo } from "./rustpad";
2223

2324
type UserProps = {
@@ -94,7 +95,7 @@ function User({
9495
</Button>
9596
</PopoverBody>
9697
<PopoverFooter
97-
d="flex"
98+
display="flex"
9899
justifyContent="flex-end"
99100
borderColor={darkMode ? "#464647" : "gray.200"}
100101
>

src/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1+
import { ChakraProvider } from "@chakra-ui/react";
12
import { StrictMode } from "react";
23
import { createRoot } from "react-dom/client";
3-
import { ChakraProvider } from "@chakra-ui/react";
44
import * as wasm from "rustpad-wasm";
5+
56
import App from "./App";
67
import "./index.css";
78

8-
const root = createRoot(document.getElementById("root"));
9-
root.render(
9+
createRoot(document.getElementById("root")!).render(
1010
<StrictMode>
1111
<ChakraProvider>
1212
<App />
1313
</ChakraProvider>
14-
</StrictMode>
14+
</StrictMode>,
1515
);

src/rustpad.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { OpSeq } from "rustpad-wasm";
1+
import debounce from "lodash.debounce";
22
import type {
3-
editor,
43
IDisposable,
54
IPosition,
5+
editor,
66
} from "monaco-editor/esm/vs/editor/editor.api";
7-
import debounce from "lodash.debounce";
7+
import { OpSeq } from "rustpad-wasm";
88

99
/** Options passed in to the Rustpad constructor. */
1010
export type RustpadOptions = {
@@ -55,7 +55,7 @@ class Rustpad {
5555
constructor(readonly options: RustpadOptions) {
5656
this.model = options.editor.getModel()!;
5757
this.onChangeHandle = options.editor.onDidChangeModelContent((e) =>
58-
this.onChange(e)
58+
this.onChange(e),
5959
);
6060
const cursorUpdate = debounce(() => this.sendCursorData(), 20);
6161
this.onCursorHandle = options.editor.onDidChangeCursorPosition((e) => {
@@ -81,7 +81,7 @@ class Rustpad {
8181
this.tryConnectId = window.setInterval(() => this.tryConnect(), interval);
8282
this.resetFailuresId = window.setInterval(
8383
() => (this.recentFailures = 0),
84-
15 * interval
84+
15 * interval,
8585
);
8686
}
8787

@@ -281,7 +281,7 @@ class Rustpad {
281281
forceMoveMarkers: true,
282282
},
283283
],
284-
() => null
284+
() => null,
285285
);
286286
} else if (op >= 0) {
287287
// Retain
@@ -305,7 +305,7 @@ class Rustpad {
305305
forceMoveMarkers: true,
306306
},
307307
],
308-
() => null
308+
() => null,
309309
);
310310
}
311311
}
@@ -376,7 +376,7 @@ class Rustpad {
376376

377377
this.oldDecorations = this.model.deltaDecorations(
378378
this.oldDecorations,
379-
decorations
379+
decorations,
380380
);
381381
}
382382

@@ -396,7 +396,7 @@ class Rustpad {
396396
const { text, rangeOffset, rangeLength } = change;
397397
const initialLength = unicodeLength(content.slice(0, rangeOffset));
398398
const deletedLength = unicodeLength(
399-
content.slice(rangeOffset, rangeOffset + rangeLength)
399+
content.slice(rangeOffset, rangeOffset + rangeLength),
400400
);
401401
const restLength =
402402
contentLength + offset - initialLength - deletedLength;

vite.config.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
1+
import react from "@vitejs/plugin-react";
12
import { defineConfig } from "vite";
2-
import wasm from "vite-plugin-wasm";
33
import topLevelAwait from "vite-plugin-top-level-await";
4-
import react from "@vitejs/plugin-react";
4+
import wasm from "vite-plugin-wasm";
55

66
export default defineConfig({
77
base: "",
88
build: {
99
chunkSizeWarningLimit: 1000,
1010
},
11-
plugins: [
12-
wasm(),
13-
topLevelAwait(),
14-
react()
15-
],
11+
plugins: [wasm(), topLevelAwait(), react()],
1612
server: {
1713
proxy: {
1814
"/api": {

0 commit comments

Comments
 (0)