From deaa0580d952b77cf9e6df024d1f71ed29f53fc0 Mon Sep 17 00:00:00 2001 From: Kristóf Marussy Date: Wed, 27 Jul 2022 16:34:14 +0200 Subject: chore: bump dependencies --- subprojects/frontend/src/editor/EditorParent.ts | 32 ++++++++--------- subprojects/frontend/src/editor/EditorStore.ts | 40 +++++++++++++--------- subprojects/frontend/src/editor/findOccurrences.ts | 3 +- .../frontend/src/editor/semanticHighlighting.ts | 5 ++- subprojects/frontend/src/index.tsx | 13 +++++-- subprojects/frontend/src/language/folding.ts | 4 +-- subprojects/frontend/src/language/indentation.ts | 2 +- .../src/language/problemLanguageSupport.ts | 2 +- subprojects/frontend/src/theme/ThemeProvider.tsx | 4 +-- .../frontend/src/xtext/ContentAssistService.ts | 8 ++--- subprojects/frontend/src/xtext/xtextMessages.ts | 10 +++--- .../frontend/src/xtext/xtextServiceResults.ts | 16 ++++----- 12 files changed, 77 insertions(+), 62 deletions(-) (limited to 'subprojects/frontend/src') diff --git a/subprojects/frontend/src/editor/EditorParent.ts b/subprojects/frontend/src/editor/EditorParent.ts index 94ca24ea..9aaf541a 100644 --- a/subprojects/frontend/src/editor/EditorParent.ts +++ b/subprojects/frontend/src/editor/EditorParent.ts @@ -119,48 +119,48 @@ export const EditorParent = styled('div')(({ theme }) => { borderColor: theme.palette.text.disabled, color: theme.palette.text.secondary, }, - '.cmt-comment': { + '.tok-comment': { fontStyle: 'italic', color: theme.palette.text.disabled, }, - '.cmt-number': { + '.tok-number': { color: '#6188a6', }, - '.cmt-string': { + '.tok-string': { color: theme.palette.secondary.dark, }, - '.cmt-keyword': { + '.tok-keyword': { color: theme.palette.primary.main, }, - '.cmt-typeName, .cmt-macroName, .cmt-atom': { + '.tok-typeName, .tok-macroName, .tok-atom': { color: theme.palette.text.primary, }, - '.cmt-variableName': { + '.tok-variableName': { color: '#c8ae9d', }, - '.cmt-problem-node': { - '&, & .cmt-variableName': { + '.tok-problem-node': { + '&, & .tok-variableName': { color: theme.palette.text.secondary, }, }, - '.cmt-problem-individual': { - '&, & .cmt-variableName': { + '.tok-problem-individual': { + '&, & .tok-variableName': { color: theme.palette.text.primary, }, }, - '.cmt-problem-abstract, .cmt-problem-new': { + '.tok-problem-abstract, .tok-problem-new': { fontStyle: 'italic', }, - '.cmt-problem-containment': { + '.tok-problem-containment': { fontWeight: 700, }, - '.cmt-problem-error': { - '&, & .cmt-typeName': { + '.tok-problem-error': { + '&, & .tok-typeName': { color: theme.palette.error.main, }, }, - '.cmt-problem-builtin': { - '&, & .cmt-typeName, & .cmt-atom, & .cmt-variableName': { + '.tok-problem-builtin': { + '&, & .tok-typeName, & .tok-atom, & .tok-variableName': { color: theme.palette.primary.main, fontWeight: 400, fontStyle: 'normal', diff --git a/subprojects/frontend/src/editor/EditorStore.ts b/subprojects/frontend/src/editor/EditorStore.ts index 5760de28..0f4d2936 100644 --- a/subprojects/frontend/src/editor/EditorStore.ts +++ b/subprojects/frontend/src/editor/EditorStore.ts @@ -1,27 +1,32 @@ -import { autocompletion, completionKeymap } from '@codemirror/autocomplete'; -import { closeBrackets, closeBracketsKeymap } from '@codemirror/closebrackets'; -import { defaultKeymap, indentWithTab } from '@codemirror/commands'; -import { commentKeymap } from '@codemirror/comment'; -import { foldGutter, foldKeymap } from '@codemirror/fold'; -import { highlightActiveLineGutter, lineNumbers } from '@codemirror/gutter'; -import { classHighlightStyle } from '@codemirror/highlight'; import { + closeBrackets, + closeBracketsKeymap, + autocompletion, + completionKeymap, +} from '@codemirror/autocomplete'; +import { + defaultKeymap, history, historyKeymap, + indentWithTab, redo, redoDepth, undo, undoDepth, -} from '@codemirror/history'; -import { indentOnInput } from '@codemirror/language'; +} from '@codemirror/commands'; +import { + bracketMatching, + foldGutter, + foldKeymap, + indentOnInput, + syntaxHighlighting, +} from '@codemirror/language'; import { Diagnostic, lintKeymap, setDiagnostics, } from '@codemirror/lint'; -import { bracketMatching } from '@codemirror/matchbrackets'; -import { rectangularSelection } from '@codemirror/rectangular-selection'; -import { searchConfig, searchKeymap } from '@codemirror/search'; +import { search, searchKeymap } from '@codemirror/search'; import { EditorState, StateCommand, @@ -33,9 +38,13 @@ import { drawSelection, EditorView, highlightActiveLine, + highlightActiveLineGutter, highlightSpecialChars, keymap, + lineNumbers, + rectangularSelection, } from '@codemirror/view'; +import { classHighlighter } from '@lezer/highlight'; import { makeAutoObservable, observable, @@ -91,7 +100,6 @@ export class EditorStore { (context) => this.client.contentAssist(context), ], }), - classHighlightStyle.extension, closeBrackets(), bracketMatching(), drawSelection(), @@ -106,10 +114,11 @@ export class EditorStore { history(), indentOnInput(), rectangularSelection(), - searchConfig({ + search({ top: true, - matchCase: true, + caseSensitive: true, }), + syntaxHighlighting(classHighlighter), semanticHighlighting, // We add the gutters to `extensions` in the order we want them to appear. lineNumbers(), @@ -117,7 +126,6 @@ export class EditorStore { keymap.of([ { key: 'Mod-Shift-f', run: () => this.formatText() }, ...closeBracketsKeymap, - ...commentKeymap, ...completionKeymap, ...foldKeymap, ...historyKeymap, diff --git a/subprojects/frontend/src/editor/findOccurrences.ts b/subprojects/frontend/src/editor/findOccurrences.ts index 92102746..c4a4e8ec 100644 --- a/subprojects/frontend/src/editor/findOccurrences.ts +++ b/subprojects/frontend/src/editor/findOccurrences.ts @@ -1,5 +1,4 @@ -import { Range, RangeSet } from '@codemirror/rangeset'; -import type { TransactionSpec } from '@codemirror/state'; +import { Range, RangeSet, type TransactionSpec } from '@codemirror/state'; import { Decoration } from '@codemirror/view'; import { decorationSetExtension } from './decorationSetExtension'; diff --git a/subprojects/frontend/src/editor/semanticHighlighting.ts b/subprojects/frontend/src/editor/semanticHighlighting.ts index 2aed421b..a5d0af7a 100644 --- a/subprojects/frontend/src/editor/semanticHighlighting.ts +++ b/subprojects/frontend/src/editor/semanticHighlighting.ts @@ -1,5 +1,4 @@ -import { RangeSet } from '@codemirror/rangeset'; -import type { TransactionSpec } from '@codemirror/state'; +import { RangeSet, type TransactionSpec } from '@codemirror/state'; import { Decoration } from '@codemirror/view'; import { decorationSetExtension } from './decorationSetExtension'; @@ -16,7 +15,7 @@ const [setSemanticHighlightingInternal, semanticHighlighting] = decorationSetExt export function setSemanticHighlighting(ranges: IHighlightRange[]): TransactionSpec { const rangeSet = RangeSet.of(ranges.map(({ from, to, classes }) => Decoration.mark({ - class: classes.map((c) => `cmt-problem-${c}`).join(' '), + class: classes.map((c) => `tok-problem-${c}`).join(' '), }).range(from, to)), true); return setSemanticHighlightingInternal(rangeSet); } diff --git a/subprojects/frontend/src/index.tsx b/subprojects/frontend/src/index.tsx index 15b26adb..6cdbbd64 100644 --- a/subprojects/frontend/src/index.tsx +++ b/subprojects/frontend/src/index.tsx @@ -1,13 +1,16 @@ import React from 'react'; -import { render } from 'react-dom'; +import { createRoot } from 'react-dom/client'; import CssBaseline from '@mui/material/CssBaseline'; import { App } from './App'; import { RootStore, RootStoreProvider } from './RootStore'; import { ThemeProvider } from './theme/ThemeProvider'; +import { getLogger } from './utils/logger'; import './index.scss'; +const log = getLogger('index'); + const initialValue = `class Family { contains Person[] members } @@ -66,4 +69,10 @@ const app = ( ); -render(app, document.getElementById('app')); +const rootElement = document.getElementById('app'); +if (rootElement === null) { + log.error('Root element not found'); +} else { + const root = createRoot(rootElement); + root.render(app); +} diff --git a/subprojects/frontend/src/language/folding.ts b/subprojects/frontend/src/language/folding.ts index 5d51f796..2560c183 100644 --- a/subprojects/frontend/src/language/folding.ts +++ b/subprojects/frontend/src/language/folding.ts @@ -52,7 +52,7 @@ export function foldDeclaration(node: SyntaxNode, state: EditorState): FoldRange if (open === null || close === null) { return null; } - const { cursor } = open; + const cursor = open.cursor(); const lineEnd = state.doc.lineAt(open.from).to; let foldFrom = open.to; while (cursor.next() && cursor.from < lineEnd) { @@ -84,7 +84,7 @@ function foldWithSibling(node: SyntaxNode): FoldRange | null { if (firstChild === null) { return null; } - const { cursor } = firstChild; + const cursor = firstChild.cursor(); let nSiblings = 0; while (cursor.nextSibling()) { if (cursor.type === node.type) { diff --git a/subprojects/frontend/src/language/indentation.ts b/subprojects/frontend/src/language/indentation.ts index 6d36ed3b..55dcd7f1 100644 --- a/subprojects/frontend/src/language/indentation.ts +++ b/subprojects/frontend/src/language/indentation.ts @@ -23,7 +23,7 @@ function findAlignmentAfterOpening(context: TreeIndentContext): number | null { const lineEnd = simulatedBreak == null || simulatedBreak <= openingLine.from ? openingLine.to : Math.min(openingLine.to, simulatedBreak); - const { cursor } = openingToken; + const cursor = openingToken.cursor(); while (cursor.next() && cursor.from < lineEnd) { if (!cursor.type.isSkipped) { return cursor.from; diff --git a/subprojects/frontend/src/language/problemLanguageSupport.ts b/subprojects/frontend/src/language/problemLanguageSupport.ts index b858ba91..b6e2f14e 100644 --- a/subprojects/frontend/src/language/problemLanguageSupport.ts +++ b/subprojects/frontend/src/language/problemLanguageSupport.ts @@ -1,4 +1,3 @@ -import { styleTags, tags as t } from '@codemirror/highlight'; import { foldInside, foldNodeProp, @@ -7,6 +6,7 @@ import { LanguageSupport, LRLanguage, } from '@codemirror/language'; +import { styleTags, tags as t } from '@lezer/highlight'; import { LRParser } from '@lezer/lr'; import { parser } from '../../build/generated/sources/lezer/problem'; diff --git a/subprojects/frontend/src/theme/ThemeProvider.tsx b/subprojects/frontend/src/theme/ThemeProvider.tsx index f5b50be1..c6194c69 100644 --- a/subprojects/frontend/src/theme/ThemeProvider.tsx +++ b/subprojects/frontend/src/theme/ThemeProvider.tsx @@ -1,10 +1,10 @@ import { observer } from 'mobx-react-lite'; import { ThemeProvider as MaterialUiThemeProvider } from '@mui/material/styles'; -import React from 'react'; +import React, { type ReactNode } from 'react'; import { useRootStore } from '../RootStore'; -export const ThemeProvider: React.FC = observer(({ children }) => { +export const ThemeProvider: React.FC<{ children: ReactNode }> = observer(({ children }) => { const { themeStore } = useRootStore(); return ( diff --git a/subprojects/frontend/src/xtext/ContentAssistService.ts b/subprojects/frontend/src/xtext/ContentAssistService.ts index 8b872e06..cf0fb49f 100644 --- a/subprojects/frontend/src/xtext/ContentAssistService.ts +++ b/subprojects/frontend/src/xtext/ContentAssistService.ts @@ -169,7 +169,7 @@ export class ContentAssistService { this.lastCompletion = { ...range, options, - span: computeSpan(prefix, entries.length), + validFor: computeSpan(prefix, entries.length), }; return this.lastCompletion; } @@ -181,15 +181,15 @@ export class ContentAssistService { return false; } const { from, to, text } = token; - const { from: lastFrom, to: lastTo, span } = this.lastCompletion; + const { from: lastFrom, to: lastTo, validFor } = this.lastCompletion; if (!lastTo) { return true; } const [transformedFrom, transformedTo] = this.mapRangeInclusive(lastFrom, lastTo); return from >= transformedFrom && to <= transformedTo - && typeof span !== 'undefined' - && span.exec(text) !== null; + && validFor instanceof RegExp + && validFor.exec(text) !== null; } private shouldInvalidateCachedCompletion(transaction: Transaction): boolean { diff --git a/subprojects/frontend/src/xtext/xtextMessages.ts b/subprojects/frontend/src/xtext/xtextMessages.ts index c4305fcf..4bf49c17 100644 --- a/subprojects/frontend/src/xtext/xtextMessages.ts +++ b/subprojects/frontend/src/xtext/xtextMessages.ts @@ -1,14 +1,14 @@ import { z } from 'zod'; export const xtextWebRequest = z.object({ - id: z.string().nonempty(), + id: z.string().min(1), request: z.unknown(), }); export type XtextWebRequest = z.infer; export const xtextWebOkResponse = z.object({ - id: z.string().nonempty(), + id: z.string().min(1), response: z.unknown(), }); @@ -19,7 +19,7 @@ export const xtextWebErrorKind = z.enum(['request', 'server']); export type XtextWebErrorKind = z.infer; export const xtextWebErrorResponse = z.object({ - id: z.string().nonempty(), + id: z.string().min(1), error: xtextWebErrorKind, message: z.string(), }); @@ -31,8 +31,8 @@ export const xtextWebPushService = z.enum(['highlight', 'validate']); export type XtextWebPushService = z.infer; export const xtextWebPushMessage = z.object({ - resource: z.string().nonempty(), - stateId: z.string().nonempty(), + resource: z.string().min(1), + stateId: z.string().min(1), service: xtextWebPushService, push: z.unknown(), }); diff --git a/subprojects/frontend/src/xtext/xtextServiceResults.ts b/subprojects/frontend/src/xtext/xtextServiceResults.ts index f79b059c..8b0dbbfb 100644 --- a/subprojects/frontend/src/xtext/xtextServiceResults.ts +++ b/subprojects/frontend/src/xtext/xtextServiceResults.ts @@ -1,13 +1,13 @@ import { z } from 'zod'; export const pongResult = z.object({ - pong: z.string().nonempty(), + pong: z.string().min(1), }); export type PongResult = z.infer; export const documentStateResult = z.object({ - stateId: z.string().nonempty(), + stateId: z.string().min(1), }); export type DocumentStateResult = z.infer; @@ -32,7 +32,7 @@ export const severity = z.enum(['error', 'warning', 'info', 'ignore']); export type Severity = z.infer; export const issue = z.object({ - description: z.string().nonempty(), + description: z.string().min(1), severity, line: z.number().int(), column: z.number().int().nonnegative(), @@ -65,14 +65,14 @@ export type TextRegion = z.infer; export const contentAssistEntry = z.object({ prefix: z.string(), - proposal: z.string().nonempty(), + proposal: z.string().min(1), label: z.string().optional(), - description: z.string().nonempty().optional(), - documentation: z.string().nonempty().optional(), + description: z.string().min(1).optional(), + documentation: z.string().min(1).optional(), escapePosition: z.number().int().nonnegative().optional(), textReplacements: replaceRegion.array(), editPositions: textRegion.array(), - kind: z.string().nonempty(), + kind: z.string().min(1), }); export type ContentAssistEntry = z.infer; @@ -86,7 +86,7 @@ export type ContentAssistResult = z.infer; export const highlightingRegion = z.object({ offset: z.number().int().nonnegative(), length: z.number().int().nonnegative(), - styleClasses: z.string().nonempty().array(), + styleClasses: z.string().min(1).array(), }); export type HighlightingRegion = z.infer; -- cgit v1.2.3-70-g09d2