Skip to content

Commit 0aa06b3

Browse files
RichDom2185leeyi45
andauthored
Miscellaneous changes (#314)
* Bump dependencies in lockfile * Update some versions in package.json * Bump js-slang to v1.0.74 * Bump more dependencies * Deduplicate dependencies * Remove unused ESLint plugin * Bump Vite to v5 * Update Vite config * Migrate to React 18 `createRoot` * Simplify Ace mode string * Fix Ace editor runtime error * Clean up Playground and Editor components * Remove unused `react-hotkeys` * Use Blueprint components instead of CSS API * Remove commented/unnecessary code * Reformat test tab * Remove `react-hotkeys` dependency * Remove `react-responsive` dependency * Bump esbuild and remove resolution Was previously causing dependency errors on Apple Silicon. * Remove unused classes * Fix Vite types * Remove unused ESLint disable directives * Bump husky from v5 to v9 * Bump gl resolution to v8 Done to make use of their prebuilt binaries for Node 20. * Revert "Bump gl resolution to v8" This reverts commit 81db412. * Make curve render functions have nice toStrings * Use parseInt instead of Number.parseFloat * Fix too many lines at end of file * Fix naming of test cases * Update lockfile post-merge * Remove vscode setting now that flat configs are default * Update curve module tests * Add a test for checking json documentation building * Update yarn lock * Fix lock file * Update eslint config to use tseslint helper and fix new linting issues * Add new type imports linting config * Run linting * Move hextocolor to utilities * Add building the linting plugin to the script building command * Fix scripts not compiling * Fix linting of scripts * Update devserver * Fix formatting --------- Co-authored-by: Lee Yi <[email protected]>
1 parent d2b843c commit 0aa06b3

File tree

93 files changed

+3231
-1979
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+3231
-1979
lines changed

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ build/*
77
/package-lock.json
88
coverage/
99

10-
scripts/build/database.json
11-
scripts/bin.js
10+
scripts/dist
1211

1312
# Compiled source #
1413
###################

.husky/post-checkout

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
#!/bin/sh
2-
. "$(dirname "$0")/_/husky.sh"
3-
41
yarn yarnhook

.husky/post-merge

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
#!/bin/sh
2-
. "$(dirname "$0")/_/husky.sh"
3-
41
yarn yarnhook

.husky/post-rewrite

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
#!/bin/sh
2-
. "$(dirname "$0")/_/husky.sh"
3-
41
yarn yarnhook

.husky/pre-commit

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
#!/bin/sh
2-
. "$(dirname "$0")/_/husky.sh"
3-
41
yarn test --color

.husky/pre-push

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
#!/bin/sh
2-
. "$(dirname "$0")/_/husky.sh"
3-
41
yarn build --lint --tsc

.vscode/settings.json

Lines changed: 0 additions & 4 deletions
This file was deleted.

devserver/src/components/Playground.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import createContext from 'js-slang/dist/createContext';
88
import { Chapter, Variant } from 'js-slang/dist/types';
99
import { stringify } from 'js-slang/dist/utils/stringify';
1010
import React, { useCallback } from 'react';
11-
import { HotKeys } from 'react-hotkeys';
1211
import mockModuleContext from '../mockModuleContext';
1312
import type { InterpreterOutput } from '../types';
1413
import Workspace, { type WorkspaceProps } from './Workspace';
@@ -39,7 +38,7 @@ const createContextHelper = () => {
3938
return tempContext;
4039
};
4140

42-
const Playground: React.FC<{}> = () => {
41+
const Playground: React.FC = () => {
4342
const [dynamicTabs, setDynamicTabs] = React.useState<SideContentTab[]>([]);
4443
const [selectedTabId, setSelectedTab] = React.useState(testTabContent.id);
4544
const [codeContext, setCodeContext] = React.useState<Context>(createContextHelper());
@@ -111,7 +110,6 @@ const Playground: React.FC<{}> = () => {
111110

112111
const evalCode = () => {
113112
codeContext.errors = [];
114-
// eslint-disable-next-line no-multi-assign
115113
codeContext.moduleContexts = mockModuleContext.moduleContexts = {};
116114

117115
runInContext(editorValue, codeContext)
@@ -191,12 +189,10 @@ const Playground: React.FC<{}> = () => {
191189
};
192190

193191
return (
194-
<HotKeys
195-
className={classNames('Playground', Classes.DARK)}
196-
>
192+
<div className={classNames('Playground', Classes.DARK)}>
197193
<OverlayToaster ref={toaster} />
198194
<Workspace {...workspaceProps} />
199-
</HotKeys>
195+
</div>
200196
);
201197
};
202198

devserver/src/components/editor/Editor.tsx

Lines changed: 7 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
1-
import { type Ace, require as acequire } from 'ace-builds';
1+
import { Card } from '@blueprintjs/core';
2+
import { require as acequire, type Ace } from 'ace-builds';
3+
import 'ace-builds/src-noconflict/ace';
24
import 'ace-builds/src-noconflict/ext-language_tools';
35
import 'ace-builds/src-noconflict/ext-searchbox';
4-
import 'ace-builds/esm-resolver';
5-
66
import 'js-slang/dist/editors/ace/theme/source';
7-
87
import React from 'react';
98
import AceEditor, { type IAceEditorProps } from 'react-ace';
10-
import { HotKeys } from 'react-hotkeys';
11-
12-
import { getModeString, selectMode } from '../utils/AceHelper';
9+
import { modeString, selectMode } from '../utils/AceHelper';
1310
import type { KeyFunction } from './EditorHotkeys';
1411

1512
export type EditorKeyBindingHandlers = { [key in KeyFunction]?: () => void };
@@ -60,11 +57,6 @@ const moveCursor = (editor: AceEditor['editor'], position: Position) => {
6057
editor.renderer.scrollCursorIntoView(position, 0.5);
6158
};
6259

63-
/* Override handler, so does not trigger when focus is in editor */
64-
const handlers = {
65-
goGreen() {}
66-
};
67-
6860
const Editor: React.FC<EditorProps> = (props: EditorProps) => {
6961
const reactAceRef: React.MutableRefObject<AceEditor | null> = React.useRef(null);
7062

@@ -115,7 +107,7 @@ const Editor: React.FC<EditorProps> = (props: EditorProps) => {
115107
fontSize: 17,
116108
height: '100%',
117109
highlightActiveLine: false,
118-
mode: getModeString(),
110+
mode: modeString,
119111
theme: 'source',
120112
value: props.editorValue,
121113
width: '100%',
@@ -137,47 +129,16 @@ const Editor: React.FC<EditorProps> = (props: EditorProps) => {
137129
},
138130
exec: props.handleEditorEval
139131
}
140-
// {
141-
// name: 'navigate',
142-
// bindKey: {
143-
// win: 'Ctrl-B',
144-
// mac: 'Command-B'
145-
// }
146-
// },
147-
// {
148-
// name: 'refactor',
149-
// bindKey: {
150-
// win: 'Ctrl-M',
151-
// mac: 'Command-M'
152-
// }
153-
// },
154-
// {
155-
// name: 'highlightScope',
156-
// bindKey: {
157-
// win: 'Ctrl-Shift-H',
158-
// mac: 'Command-Shift-H'
159-
// },
160-
// },
161-
// {
162-
// name: ' typeInferenceDisplay',
163-
// bindKey: {
164-
// win: 'Ctrl-Shift-M',
165-
// mac: 'Command-Shift-M'
166-
// }
167-
// }
168132
]
169-
// commands: Object.entries(keyHandlers)
170-
// .filter(([_, exec]) => exec)
171-
// .map(([name, exec]) => ({ name, bindKey: keyBindings[name], exec: exec! }))
172133
};
173134

174135
return (
175136
<div className="editor-container">
176-
<HotKeys className="Editor bp4-card bp4-elevation-0" handlers={handlers}>
137+
<Card className="Editor">
177138
<div className="row editor-react-ace" data-testid="Editor">
178139
<AceEditor {...aceEditorProps} ref={reactAceRef} />
179140
</div>
180-
</HotKeys>
141+
</Card>
181142
</div>
182143
);
183144
};

devserver/src/components/sideContent/TestTab.tsx

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
import { IconNames } from '@blueprintjs/icons';
22
import type { SideContentTab } from './types';
33

4-
const TestTab = () => <div style={{
5-
display: 'flex',
6-
flexDirection: 'column',
7-
alignItems: 'center',
8-
marginBottom: '5px'
9-
}}>
10-
<h2>Source Academy Tab Development Server</h2>
11-
<p style={{
4+
const TestTab: React.FC = () => (
5+
<div style={{
6+
display: 'flex',
7+
flexDirection: 'column',
8+
alignItems: 'center',
9+
marginBottom: '5px'
1210
}}>
13-
Run some code that imports modules in the editor on the left. You should see the corresponding module tab spawn.<br />
14-
Whenever you make changes to the tab, the server should automatically reload and show the changes that you've made <br />
15-
If that does not happen, you can click the refresh button to manually reload tabs
16-
</p>
17-
</div>;
11+
<h2>Source Academy Tab Development Server</h2>
12+
<p>
13+
Run some code that imports modules in the editor on the left. You should see the corresponding module tab spawn.<br />
14+
Whenever you make changes to the tab, the server should automatically reload and show the changes that you've made <br />
15+
If that does not happen, you can click the refresh button to manually reload tabs
16+
</p>
17+
</div>
18+
);
1819

1920
const testTabContent: SideContentTab = {
2021
id: 'test',

0 commit comments

Comments
 (0)