Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NUSSOC/glide
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.4.0
Choose a base ref
...
head repository: NUSSOC/glide
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 20 commits
  • 11 files changed
  • 2 contributors

Commits on Apr 13, 2023

  1. Copy the full SHA
    af83e68 View commit details
  2. Copy the full SHA
    d68f132 View commit details
  3. Copy the full SHA
    3ab6925 View commit details

Commits on Sep 6, 2023

  1. Copy the full SHA
    ecd4e7d View commit details
  2. chore(deps-dev): bump @types/react from 18.0.30 to 18.2.21

    Bumps [@types/react](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/react) from 18.0.30 to 18.2.21.
    - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
    - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/react)
    
    ---
    updated-dependencies:
    - dependency-name: "@types/react"
      dependency-type: direct:development
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and purfectliterature committed Sep 6, 2023
    Copy the full SHA
    c44565b View commit details
  3. chore(deps-dev): bump eslint from 8.37.0 to 8.48.0

    Bumps [eslint](https://github.com/eslint/eslint) from 8.37.0 to 8.48.0.
    - [Release notes](https://github.com/eslint/eslint/releases)
    - [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md)
    - [Commits](eslint/eslint@v8.37.0...v8.48.0)
    
    ---
    updated-dependencies:
    - dependency-name: eslint
      dependency-type: direct:development
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and purfectliterature committed Sep 6, 2023
    Copy the full SHA
    ed9334e View commit details
  4. chore(deps): bump @heroicons/react from 2.0.16 to 2.0.18

    Bumps [@heroicons/react](https://github.com/tailwindlabs/heroicons) from 2.0.16 to 2.0.18.
    - [Release notes](https://github.com/tailwindlabs/heroicons/releases)
    - [Changelog](https://github.com/tailwindlabs/heroicons/blob/master/CHANGELOG.md)
    - [Commits](tailwindlabs/heroicons@v2.0.16...v2.0.18)
    
    ---
    updated-dependencies:
    - dependency-name: "@heroicons/react"
      dependency-type: direct:production
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and purfectliterature committed Sep 6, 2023
    Copy the full SHA
    79a22b4 View commit details
  5. chore(deps): bump xterm-addon-webgl from 0.14.0 to 0.15.0

    Bumps [xterm-addon-webgl](https://github.com/xtermjs/xterm.js) from 0.14.0 to 0.15.0.
    - [Release notes](https://github.com/xtermjs/xterm.js/releases)
    - [Commits](xtermjs/xterm.js@0.14...0.15)
    
    ---
    updated-dependencies:
    - dependency-name: xterm-addon-webgl
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and purfectliterature committed Sep 6, 2023
    Copy the full SHA
    a41f74c View commit details
  6. chore(deps-dev): bump @babel/preset-react from 7.18.6 to 7.22.15

    Bumps [@babel/preset-react](https://github.com/babel/babel/tree/HEAD/packages/babel-preset-react) from 7.18.6 to 7.22.15.
    - [Release notes](https://github.com/babel/babel/releases)
    - [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
    - [Commits](https://github.com/babel/babel/commits/v7.22.15/packages/babel-preset-react)
    
    ---
    updated-dependencies:
    - dependency-name: "@babel/preset-react"
      dependency-type: direct:development
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and purfectliterature committed Sep 6, 2023
    Copy the full SHA
    2f99588 View commit details
  7. chore(deps): bump semver from 6.3.0 to 6.3.1

    Bumps [semver](https://github.com/npm/node-semver) from 6.3.0 to 6.3.1.
    - [Release notes](https://github.com/npm/node-semver/releases)
    - [Changelog](https://github.com/npm/node-semver/blob/v6.3.1/CHANGELOG.md)
    - [Commits](npm/node-semver@v6.3.0...v6.3.1)
    
    ---
    updated-dependencies:
    - dependency-name: semver
      dependency-type: indirect
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and purfectliterature committed Sep 6, 2023
    Copy the full SHA
    b0f27f9 View commit details
  8. chore(deps): bump @reduxjs/toolkit from 1.9.3 to 1.9.5

    Bumps [@reduxjs/toolkit](https://github.com/reduxjs/redux-toolkit) from 1.9.3 to 1.9.5.
    - [Release notes](https://github.com/reduxjs/redux-toolkit/releases)
    - [Commits](reduxjs/redux-toolkit@v1.9.3...v1.9.5)
    
    ---
    updated-dependencies:
    - dependency-name: "@reduxjs/toolkit"
      dependency-type: direct:production
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and purfectliterature committed Sep 6, 2023
    Copy the full SHA
    8d2921c View commit details
  9. chore(deps-dev): bump postcss-loader from 7.1.0 to 7.3.3

    Bumps [postcss-loader](https://github.com/webpack-contrib/postcss-loader) from 7.1.0 to 7.3.3.
    - [Release notes](https://github.com/webpack-contrib/postcss-loader/releases)
    - [Changelog](https://github.com/webpack-contrib/postcss-loader/blob/master/CHANGELOG.md)
    - [Commits](webpack-contrib/postcss-loader@v7.1.0...v7.3.3)
    
    ---
    updated-dependencies:
    - dependency-name: postcss-loader
      dependency-type: direct:development
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and purfectliterature committed Sep 6, 2023
    Copy the full SHA
    6a69e9c View commit details
  10. chore(deps-dev): bump webpack from 5.76.3 to 5.88.2

    Bumps [webpack](https://github.com/webpack/webpack) from 5.76.3 to 5.88.2.
    - [Release notes](https://github.com/webpack/webpack/releases)
    - [Commits](webpack/webpack@v5.76.3...v5.88.2)
    
    ---
    updated-dependencies:
    - dependency-name: webpack
      dependency-type: direct:development
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and purfectliterature committed Sep 6, 2023
    Copy the full SHA
    fe4fb4d View commit details
  11. chore(deps-dev): bump cssnano from 6.0.0 to 6.0.1

    Bumps [cssnano](https://github.com/cssnano/cssnano) from 6.0.0 to 6.0.1.
    - [Release notes](https://github.com/cssnano/cssnano/releases)
    - [Commits](https://github.com/cssnano/cssnano/compare/cssnano@6.0.0...cssnano@6.0.1)
    
    ---
    updated-dependencies:
    - dependency-name: cssnano
      dependency-type: direct:development
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and purfectliterature committed Sep 6, 2023
    Copy the full SHA
    cbacdd4 View commit details
  12. chore(deps-dev): bump tailwindcss from 3.3.0 to 3.3.3

    Bumps [tailwindcss](https://github.com/tailwindlabs/tailwindcss) from 3.3.0 to 3.3.3.
    - [Release notes](https://github.com/tailwindlabs/tailwindcss/releases)
    - [Changelog](https://github.com/tailwindlabs/tailwindcss/blob/master/CHANGELOG.md)
    - [Commits](tailwindlabs/tailwindcss@v3.3.0...v3.3.3)
    
    ---
    updated-dependencies:
    - dependency-name: tailwindcss
      dependency-type: direct:development
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and purfectliterature committed Sep 6, 2023
    Copy the full SHA
    59b907b View commit details
  13. Copy the full SHA
    61b9e99 View commit details
  14. Copy the full SHA
    5b12d3a View commit details
  15. Copy the full SHA
    7838ef7 View commit details

Commits on Oct 28, 2023

  1. Copy the full SHA
    37cead5 View commit details
  2. Copy the full SHA
    47ffa1b View commit details
Showing with 549 additions and 430 deletions.
  1. +7 −0 .github/dependabot.yml
  2. +2 −0 .gitignore
  3. +11 −11 package.json
  4. +3 −0 src/assets/console.py
  5. +2 −2 src/components/Button.tsx
  6. +2 −2 src/components/Item.tsx
  7. +4 −0 src/components/Prompt.tsx
  8. +46 −2 src/components/Terminal.tsx
  9. +2 −3 src/components/TerminalMenu.tsx
  10. +29 −18 src/workers/interpreter.worker.ts
  11. +441 −392 yarn.lock
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
open-pull-requests-limit: 10
schedule:
interval: "daily"
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -21,3 +21,5 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*

.vscode
22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "glide",
"version": "0.4.0",
"version": "0.4.2",
"private": true,
"license": "MIT",
"scripts": {
@@ -9,9 +9,9 @@
},
"dependencies": {
"@headlessui/react": "^1.7.13",
"@heroicons/react": "^2.0.16",
"@heroicons/react": "^2.0.18",
"@monaco-editor/react": "^4.4.6",
"@reduxjs/toolkit": "^1.9.3",
"@reduxjs/toolkit": "^1.9.5",
"immer": "^9.0.21",
"localforage": "^1.10.0",
"monaco-editor": "^0.36.1",
@@ -24,40 +24,40 @@
"xterm": "^5.1.0",
"xterm-addon-canvas": "^0.3.0",
"xterm-addon-fit": "^0.7.0",
"xterm-addon-webgl": "^0.14.0"
"xterm-addon-webgl": "^0.15.0"
},
"devDependencies": {
"@babel/core": "^7.21.3",
"@babel/preset-env": "^7.20.2",
"@babel/preset-react": "^7.18.6",
"@babel/preset-react": "^7.22.15",
"@babel/preset-typescript": "^7.21.0",
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.10",
"@svgr/webpack": "^7.0.0",
"@types/node": "^18.15.10",
"@types/react": "^18.0.30",
"@types/react": "^18.2.21",
"@types/react-dom": "^18.0.11",
"autoprefixer": "^10.4.14",
"babel-loader": "^9.1.2",
"compression-webpack-plugin": "^10.0.0",
"copy-webpack-plugin": "^11.0.0",
"css-loader": "^6.7.3",
"cssnano": "^6.0.0",
"eslint": "^8.37.0",
"cssnano": "^6.0.1",
"eslint": "^8.48.0",
"eslint-config-react-app": "^7.0.1",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-simple-import-sort": "^10.0.0",
"eslint-webpack-plugin": "^4.0.0",
"fork-ts-checker-webpack-plugin": "^8.0.0",
"html-webpack-plugin": "^5.5.0",
"postcss": "^8.4.21",
"postcss-loader": "^7.1.0",
"postcss-loader": "^7.3.3",
"prettier": "^2.8.7",
"prettier-plugin-tailwindcss": "^0.2.5",
"react-refresh": "^0.14.0",
"style-loader": "^3.3.2",
"tailwindcss": "^3.3.0",
"tailwindcss": "^3.3.3",
"typescript": "^5.0.2",
"webpack": "^5.76.3",
"webpack": "^5.88.2",
"webpack-cli": "^5.0.1",
"webpack-dev-server": "^4.13.1",
"webpack-merge": "^5.8.0"
3 changes: 3 additions & 0 deletions src/assets/console.py
Original file line number Diff line number Diff line change
@@ -2,6 +2,9 @@
from pyodide.console import PyodideConsole, repr_shorten, BANNER
import __main__
import builtins
import sys

del sys.modules['js']

async def await_fut(fut):
result = await fut
4 changes: 2 additions & 2 deletions src/components/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ComponentProps, ElementType, SVGProps } from 'react';
import { ComponentProps, ElementType } from 'react';

interface ButtonProps extends ComponentProps<'button'> {
icon?: ElementType<SVGProps<SVGSVGElement>>;
icon?: ElementType;
}

const Button = (props: ButtonProps): JSX.Element => {
4 changes: 2 additions & 2 deletions src/components/Item.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ComponentProps, ElementType, SVGProps } from 'react';
import { ComponentProps, ElementType } from 'react';

interface ItemProps extends ComponentProps<'div'> {
icon?: ElementType<SVGProps<SVGSVGElement>>;
icon?: ElementType;
iconClassName?: string;
labelClassName?: string;
selected?: boolean;
4 changes: 4 additions & 0 deletions src/components/Prompt.tsx
Original file line number Diff line number Diff line change
@@ -45,6 +45,9 @@ const Prompt = forwardRef<PromptRef, PromptProps>((props, ref): JSX.Element => {

<input
ref={inputRef}
autoCapitalize="off"
autoComplete="off"
autoCorrect="off"
className="w-full bg-transparent py-2 pr-2 font-mono text-sm outline-none"
onChange={(e) => {
setCommand({ dirty: true, command: e.target.value });
@@ -76,6 +79,7 @@ const Prompt = forwardRef<PromptRef, PromptProps>((props, ref): JSX.Element => {
setCommand({ dirty: false, command: history.next() ?? '' });
}
}}
spellCheck={false}
value={command}
/>
</div>
48 changes: 46 additions & 2 deletions src/components/Terminal.tsx
Original file line number Diff line number Diff line change
@@ -5,8 +5,9 @@ import {
useImperativeHandle,
useLayoutEffect,
useRef,
useState,
} from 'react';
import { StopIcon } from '@heroicons/react/24/outline';
import { DocumentDuplicateIcon, StopIcon } from '@heroicons/react/24/outline';
import { slate, yellow } from 'tailwindcss/colors';
import { Terminal as Xterm } from 'xterm';
import { CanvasAddon } from 'xterm-addon-canvas';
@@ -18,6 +19,11 @@ import Prompt from './Prompt';
import TerminalMenu from './TerminalMenu';
import 'xterm/css/xterm.css';

interface Position {
x: number;
y: number;
}

interface TerminalRef {
append: (result?: string) => void;
write: (result?: string) => void;
@@ -64,6 +70,9 @@ const Terminal = forwardRef<TerminalRef, TerminalProps>(
const containerRef = useRef<HTMLDivElement>(null);
const promptRef = useRef<ComponentRef<typeof Prompt>>(null);

const [selection, setSelection] = useState<string>();
const [selectionPosition, setSelectionPosition] = useState<Position>();

useLayoutEffect(() => {
const container = containerRef.current;
if (!container) return;
@@ -99,6 +108,8 @@ const Terminal = forwardRef<TerminalRef, TerminalProps>(
xterm.loadAddon(new CanvasAddon());
}

xterm.onSelectionChange(() => setSelection(xterm.getSelection()));

xterm.onKey(({ key }) => {
if (!(isASCIIPrintable(key) || key >= '\u00a0')) return;

@@ -142,9 +153,25 @@ const Terminal = forwardRef<TerminalRef, TerminalProps>(
write('\u001b[33m' + (result ?? '') + '\u001b[0m'),
}));

const copySelectionToClipboard = () => {
if (!selection) return;

navigator.clipboard.writeText(selection);
};

return (
<section ref={containerRef} className="relative h-full w-full">
<div ref={terminalRef} className="windowed h-full" />
<div
ref={terminalRef}
className="windowed h-full"
onMouseUp={(e) => {
const rectangle = e.currentTarget.getBoundingClientRect();
const x = e.clientX - rectangle.left;
const y = e.clientY - rectangle.top;

setSelectionPosition({ x, y });
}}
/>

<div className="absolute bottom-0 left-0 z-40 flex w-full space-x-2 px-2 pb-2">
<Prompt
@@ -165,6 +192,23 @@ const Terminal = forwardRef<TerminalRef, TerminalProps>(
/>
</div>

{selection && selectionPosition && (
<div
className="absolute z-20 opacity-20 hover:opacity-50"
style={{
left: selectionPosition.x + 5,
top: selectionPosition.y - 10,
}}
>
<Button
icon={DocumentDuplicateIcon}
onClick={copySelectionToClipboard}
>
Copy
</Button>
</div>
)}

{props.showStopButton && (
<div className="absolute right-3 top-3 z-20 space-x-2 opacity-50 hover:opacity-100">
<Button icon={StopIcon} onClick={props.onStop}>
5 changes: 2 additions & 3 deletions src/components/TerminalMenu.tsx
Original file line number Diff line number Diff line change
@@ -2,8 +2,7 @@ import {
ElementType,
Fragment,
MouseEventHandler,
ReactNode,
SVGProps,
ReactNode
} from 'react';
import { Menu, Transition } from '@headlessui/react';
import {
@@ -23,7 +22,7 @@ interface MenuItemProps {
children: ReactNode;
onClick?: MouseEventHandler<HTMLButtonElement>;
className?: string;
icon?: ElementType<SVGProps<SVGSVGElement>>;
icon?: ElementType;
iconClassName?: string;
}

47 changes: 29 additions & 18 deletions src/workers/interpreter.worker.ts
Original file line number Diff line number Diff line change
@@ -77,6 +77,12 @@ const preparePyodide = async () => {

if (interruptBuffer) pyodide.setInterruptBuffer(interruptBuffer);

/**
* Replaces Pyodide's `js` import with a stub `object`. This must also be
* paired with some `del sys.modules['js']` in Pyodide's initialisation.
*/
pyodide.registerJsModule('js', {});

const banner = setUpREPLEnvironment();
post.writeln(banner);
post.prompt(false);
@@ -100,6 +106,24 @@ const prepareExports = (exports?: { name: string; content: string }[]) => {
});
};

/**
* Pyodide may sometimes not catch `RecursionError`s and excessively
* recursive code spills as JavaScript `RangeError`, causing Pyodide to
* fatally crash. We need to restart Pyodide in this case.
* @see https://github.com/pyodide/pyodide/issues/951
*/
const handleRangeErrorAndRestartPyodide = async (error: unknown) => {
if (!(error instanceof RangeError)) return;

post.system(
'\nOops, something happened and we have to restart the interpreter. ' +
"Don't worry, it's not your fault. " +
'You may continue once you see the prompt again.\n',
);

await preparePyodide();
};

const listeners = {
initialize: async (newInterruptBuffer?: Uint8Array) => {
pyodide ??= await preparePyodide();
@@ -132,25 +156,10 @@ const listeners = {

post.writeln(result?.toString());
} catch (error) {
if (error instanceof Error) {
post.error(error.message);
}

/**
* Pyodide may sometimes not catch `RecursionError`s and excessively
* recursive code spills as JavaScript `RangeError`, causing Pyodide to
* fatally crash. We need to restart Pyodide in this case.
* @see https://github.com/pyodide/pyodide/issues/951
*/
if (error instanceof RangeError) {
post.system(
"\nOops, something happened and we have to restart the interpreter. Don't worry, it's not your fault. You may continue once you see the prompt again.\n",
);

await preparePyodide();
}
if (!(error instanceof Error)) throw error;

throw error;
post.error(error.message);
handleRangeErrorAndRestartPyodide(error);
} finally {
post.prompt();
post.unlock();
@@ -209,6 +218,8 @@ const listeners = {

const message = future.formatted_error || error.message;
post.error(message.trimEnd());

handleRangeErrorAndRestartPyodide(error);
} finally {
post.prompt();
future.destroy();
Loading