Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Miscellaneous changes #314

Open
wants to merge 45 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
d5be766
Bump dependencies in lockfile
RichDom2185 May 21, 2024
e833b1e
Update some versions in package.json
RichDom2185 May 21, 2024
472c53a
Bump js-slang to v1.0.74
RichDom2185 May 21, 2024
52c0cfe
Bump more dependencies
RichDom2185 May 21, 2024
f3fe745
Deduplicate dependencies
RichDom2185 May 21, 2024
90037ae
Remove unused ESLint plugin
RichDom2185 May 21, 2024
e3e3c3b
Bump Vite to v5
RichDom2185 May 21, 2024
49bcd65
Update Vite config
RichDom2185 May 21, 2024
5ff6342
Migrate to React 18 `createRoot`
RichDom2185 May 21, 2024
12fff08
Simplify Ace mode string
RichDom2185 May 21, 2024
d06442a
Fix Ace editor runtime error
RichDom2185 May 21, 2024
f4c38de
Clean up Playground and Editor components
RichDom2185 May 21, 2024
f31c0e3
Reformat test tab
RichDom2185 May 21, 2024
87960de
Remove `react-hotkeys` dependency
RichDom2185 May 21, 2024
a180f85
Remove `react-responsive` dependency
RichDom2185 May 21, 2024
0154670
Bump esbuild and remove resolution
RichDom2185 May 21, 2024
bb975a0
Remove unused classes
RichDom2185 May 21, 2024
995769f
Fix Vite types
RichDom2185 May 21, 2024
59db905
Remove unused ESLint disable directives
RichDom2185 May 21, 2024
69a3526
Bump husky from v5 to v9
RichDom2185 May 21, 2024
81db412
Bump gl resolution to v8
RichDom2185 May 22, 2024
9579c47
Revert "Bump gl resolution to v8"
RichDom2185 May 22, 2024
022e4f8
Make curve render functions have nice toStrings
leeyi45 May 24, 2024
3a1550c
Use parseInt instead of Number.parseFloat
leeyi45 May 24, 2024
86523a6
Fix too many lines at end of file
leeyi45 May 24, 2024
b9b7cba
Fix naming of test cases
leeyi45 May 24, 2024
b70eb1e
Merge branch 'master' of https://github.com/source-academy/modules in…
RichDom2185 Jul 18, 2024
1258bdb
Merge branch 'master' into misc-20240522
RichDom2185 Aug 25, 2024
b7947e1
Merge branch 'master' of https://github.com/source-academy/modules in…
RichDom2185 Sep 17, 2024
ece2212
Update lockfile post-merge
RichDom2185 Sep 17, 2024
ba219a7
Merge branch 'master' into misc-20240522
leeyi45 Oct 2, 2024
7894eab
Remove vscode setting now that flat configs are default
leeyi45 Oct 2, 2024
d443a8c
Update curve module tests
leeyi45 Sep 5, 2024
b77738b
Add a test for checking json documentation building
leeyi45 Sep 5, 2024
96f22e7
Update yarn lock
leeyi45 Sep 5, 2024
297452b
Fix lock file
leeyi45 Sep 5, 2024
80768e9
Update eslint config to use tseslint helper and fix new linting issues
leeyi45 Oct 22, 2024
be33e5e
Add new type imports linting config
leeyi45 Oct 23, 2024
233dd39
Run linting
leeyi45 Oct 23, 2024
5e94ed4
Move hextocolor to utilities
leeyi45 Oct 23, 2024
0e0be2c
Add building the linting plugin to the script building command
leeyi45 Oct 23, 2024
d619284
Fix scripts not compiling
leeyi45 Oct 23, 2024
1e745b1
Fix linting of scripts
leeyi45 Oct 24, 2024
b94848a
Update devserver
leeyi45 Oct 24, 2024
bbdbc47
Fix formatting
leeyi45 Oct 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ build/*
/package-lock.json
coverage/

scripts/build/database.json
scripts/bin.js
scripts/dist

# Compiled source #
###################
Expand Down
3 changes: 0 additions & 3 deletions .husky/post-checkout
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn yarnhook
3 changes: 0 additions & 3 deletions .husky/post-merge
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn yarnhook
3 changes: 0 additions & 3 deletions .husky/post-rewrite
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn yarnhook
3 changes: 0 additions & 3 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn test --color
3 changes: 0 additions & 3 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn build --lint --tsc
4 changes: 0 additions & 4 deletions .vscode/settings.json

This file was deleted.

10 changes: 3 additions & 7 deletions devserver/src/components/Playground.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import createContext from 'js-slang/dist/createContext';
import { Chapter, Variant } from 'js-slang/dist/types';
import { stringify } from 'js-slang/dist/utils/stringify';
import React, { useCallback } from 'react';
import { HotKeys } from 'react-hotkeys';
import mockModuleContext from '../mockModuleContext';
import type { InterpreterOutput } from '../types';
import Workspace, { type WorkspaceProps } from './Workspace';
Expand Down Expand Up @@ -39,7 +38,7 @@ const createContextHelper = () => {
return tempContext;
};

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

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

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

return (
<HotKeys
className={classNames('Playground', Classes.DARK)}
>
<div className={classNames('Playground', Classes.DARK)}>
<OverlayToaster ref={toaster} />
<Workspace {...workspaceProps} />
</HotKeys>
</div>
);
};

Expand Down
53 changes: 7 additions & 46 deletions devserver/src/components/editor/Editor.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import { type Ace, require as acequire } from 'ace-builds';
import { Card } from '@blueprintjs/core';
import { require as acequire, type Ace } from 'ace-builds';
import 'ace-builds/src-noconflict/ace';
import 'ace-builds/src-noconflict/ext-language_tools';
import 'ace-builds/src-noconflict/ext-searchbox';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the js-slang theme work for you? It still doesn't for me

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bumping this comment

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, I think your previous comment wasn't published yet that's why I couldn't see it. It's broken on Source Academy @ NUS as well. I suspect it's a js-slang issue, specifically the ace-builds version there is way too old. But I haven't looked at it yet

import 'ace-builds/esm-resolver';

import 'js-slang/dist/editors/ace/theme/source';

import React from 'react';
import AceEditor, { type IAceEditorProps } from 'react-ace';
import { HotKeys } from 'react-hotkeys';

import { getModeString, selectMode } from '../utils/AceHelper';
import { modeString, selectMode } from '../utils/AceHelper';
import type { KeyFunction } from './EditorHotkeys';

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

/* Override handler, so does not trigger when focus is in editor */
const handlers = {
goGreen() {}
};

const Editor: React.FC<EditorProps> = (props: EditorProps) => {
const reactAceRef: React.MutableRefObject<AceEditor | null> = React.useRef(null);

Expand Down Expand Up @@ -115,7 +107,7 @@ const Editor: React.FC<EditorProps> = (props: EditorProps) => {
fontSize: 17,
height: '100%',
highlightActiveLine: false,
mode: getModeString(),
mode: modeString,
theme: 'source',
value: props.editorValue,
width: '100%',
Expand All @@ -137,47 +129,16 @@ const Editor: React.FC<EditorProps> = (props: EditorProps) => {
},
exec: props.handleEditorEval
}
// {
// name: 'navigate',
// bindKey: {
// win: 'Ctrl-B',
// mac: 'Command-B'
// }
// },
// {
// name: 'refactor',
// bindKey: {
// win: 'Ctrl-M',
// mac: 'Command-M'
// }
// },
// {
// name: 'highlightScope',
// bindKey: {
// win: 'Ctrl-Shift-H',
// mac: 'Command-Shift-H'
// },
// },
// {
// name: ' typeInferenceDisplay',
// bindKey: {
// win: 'Ctrl-Shift-M',
// mac: 'Command-Shift-M'
// }
// }
]
// commands: Object.entries(keyHandlers)
// .filter(([_, exec]) => exec)
// .map(([name, exec]) => ({ name, bindKey: keyBindings[name], exec: exec! }))
};

return (
<div className="editor-container">
<HotKeys className="Editor bp4-card bp4-elevation-0" handlers={handlers}>
<Card className="Editor">
<div className="row editor-react-ace" data-testid="Editor">
<AceEditor {...aceEditorProps} ref={reactAceRef} />
</div>
</HotKeys>
</Card>
</div>
);
};
Expand Down
27 changes: 14 additions & 13 deletions devserver/src/components/sideContent/TestTab.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
import { IconNames } from '@blueprintjs/icons';
import type { SideContentTab } from './types';

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

const testTabContent: SideContentTab = {
id: 'test',
Expand Down
12 changes: 3 additions & 9 deletions devserver/src/components/utils/AceHelper.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
/* eslint-disable new-cap */
import * as ace from 'ace-builds/src-noconflict/ace';
import { HighlightRulesSelector, ModeSelector } from 'js-slang/dist/editors/ace/modes/source';
import { Chapter, Variant } from 'js-slang/dist/types';
import ace from 'react-ace';

export const getModeString = () => `source${Chapter.SOURCE_4}${Variant.DEFAULT}${''}`;
export const modeString = `source${Chapter.SOURCE_4}${Variant.DEFAULT}`;

/**
* This _modifies global state_ and defines a new Ace mode globally, if it does not already exist.
Expand All @@ -15,12 +14,7 @@ export const selectMode = () => {
const variant = Variant.DEFAULT;
const library = '';

if (
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
typeof ace.define.modules[`ace/mode/${getModeString(chapter, variant, library)}`]?.Mode
=== 'function'
) {
if (typeof ace.define.modules[`ace/mode/${modeString}`]?.Mode === 'function') {
return;
}

Expand Down
11 changes: 6 additions & 5 deletions devserver/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import React from 'react';
import ReactDOM from 'react-dom';

import './styles/index.scss';
import ReactDOM from 'react-dom/client';
import Playground from './components/Playground';
import './styles/index.scss';

const root = ReactDOM.createRoot(document.getElementById('root')!);

ReactDOM.render(<React.StrictMode>
root.render(<React.StrictMode>
<div className="Application">
<div className="Application__main">
<Playground />
</div>
</div>
</React.StrictMode>, document.getElementById('root')!);
</React.StrictMode>);
69 changes: 0 additions & 69 deletions devserver/src/styles/_commons.scss
Original file line number Diff line number Diff line change
@@ -1,36 +1,3 @@
.ContentDisplay {
height: fit-content;
width: 100%;

&.row {
margin-right: 0px;
margin-left: 0px;
}

.#{$ns}-non-ideal-state {
padding-bottom: 0.7rem;

> .#{$ns}-non-ideal-state-visual .#{$ns}-icon {
display: flex;
}
}

.contentdisplay-content-parent {
margin-top: 20px;
margin-bottom: 20px;
padding: 0px;

.contentdisplay-content {
background-color: white;
> * {
&:last-child {
margin-bottom: 0;
}
}
}
}
}

.#{$ns}-running-text.md {
pre > code {
-webkit-box-shadow: none;
Expand Down Expand Up @@ -60,39 +27,3 @@
top: 0;
}
}

.WhiteBackground {
background-color: white;
padding: 20px;
border-radius: 10px;
}

.Horizontal {
display: flex;
flex-direction: row;
justify-content: space-evenly;
}

.Vertical {
display: flex;
flex-direction: column;
justify-content: space-evenly;
align-items: center;
}

.VerticalStack {
> * + * {
margin-top: 10px;
}
}

.Centered {
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-evenly;
}

.WaitingCursor {
cursor: wait;
}
45 changes: 0 additions & 45 deletions devserver/src/styles/_editorTabs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,48 +10,3 @@
padding-right: 8px;
}
}

.editor-tab-container {
display: flex;
flex-direction: row;
column-gap: 4px;
overflow-x: scroll;
// Hide scrollbar on Firefox.
scrollbar-width: none;
// Hide scrollbar on Webkit-based browsers.
&::-webkit-scrollbar {
width: 0;
height: 0;
}
padding-bottom: 4px;
}

.editor-tab {
padding: 5px 5px 5px 10px;
// !important is necessary to override the default Card background-color property.
background-color: $cadet-color-1 !important;
display: flex;
flex-direction: row;
column-gap: 4px;
user-select: none;
white-space: nowrap;

&:hover {
// !important is necessary to override the default Card background-color property.
background-color: $cadet-color-3 !important;
}

&.selected {
// !important is necessary to override the default Card background-color property.
background-color: $cadet-color-2 !important;
}

.remove-button {
opacity: 25%;

&:hover {
background: black;
border-radius: 10px;
}
}
}
Loading
Loading