R: Remove unused dependencies

This commit is contained in:
Ivan 2025-04-13 23:13:04 +03:00
parent 7e0c59709d
commit 1f15a6a53c
14 changed files with 60 additions and 99 deletions

View File

@ -1,4 +1,4 @@
export { Checkbox, type CheckboxProps } from './checkbox'; export { Checkbox } from './checkbox';
export { CheckboxTristate } from './checkbox-tristate'; export { CheckboxTristate } from './checkbox-tristate';
export { ErrorField } from './error-field'; export { ErrorField } from './error-field';
export { FileInput } from './file-input'; export { FileInput } from './file-input';

View File

@ -5,9 +5,7 @@ export {
type IUpdateLibraryItemDTO, type IUpdateLibraryItemDTO,
type IVersionInfo, type IVersionInfo,
LibraryItemType, LibraryItemType,
schemaLibraryItem, schemaUpdateLibraryItem
schemaUpdateLibraryItem,
schemaVersionInfo
} from './backend/types'; } from './backend/types';
export { BASIC_SCHEMAS, type CurrentVersion, type ILibraryItemReference, LocationHead } from './models/library'; export { BASIC_SCHEMAS, type CurrentVersion, type ILibraryItemReference, LocationHead } from './models/library';
export { useLibrarySearchStore } from './stores/library-search'; export { useLibrarySearchStore } from './stores/library-search';

View File

@ -17,6 +17,7 @@ import {
type IOssLayout, type IOssLayout,
type ITargetOperation, type ITargetOperation,
schemaConstituentaReference, schemaConstituentaReference,
schemaInputCreatedResponse,
schemaOperationCreatedResponse, schemaOperationCreatedResponse,
schemaOperationSchema schemaOperationSchema
} from './types'; } from './types';
@ -68,6 +69,7 @@ export const ossApi = {
}), }),
inputCreate: ({ itemID, data }: { itemID: number; data: ITargetOperation }) => inputCreate: ({ itemID, data }: { itemID: number; data: ITargetOperation }) =>
axiosPatch<ITargetOperation, IInputCreatedResponse>({ axiosPatch<ITargetOperation, IInputCreatedResponse>({
schema: schemaInputCreatedResponse,
endpoint: `/api/oss/${itemID}/create-input`, endpoint: `/api/oss/${itemID}/create-input`,
request: { request: {
data: data, data: data,

View File

@ -1,2 +1 @@
export { type IOperationSchemaDTO } from './backend/types'; export { type IOperationSchemaDTO } from './backend/types';
export { type IOperation } from './models/oss';

View File

@ -10,7 +10,7 @@ export const OssTabID = {
} as const; } as const;
export type OssTabID = (typeof OssTabID)[keyof typeof OssTabID]; export type OssTabID = (typeof OssTabID)[keyof typeof OssTabID];
export interface IOssEditContext { interface IOssEditContext {
schema: IOperationSchema; schema: IOperationSchema;
selected: number[]; selected: number[];

View File

@ -44,9 +44,6 @@ export type ParsingStatus = (typeof ParsingStatus)[keyof typeof ParsingStatus];
/** Represents Constituenta basic persistent data. */ /** Represents Constituenta basic persistent data. */
export type IConstituentaBasicsDTO = z.infer<typeof schemaConstituentaBasics>; export type IConstituentaBasicsDTO = z.infer<typeof schemaConstituentaBasics>;
/** Represents {@link IConstituenta} data from server. */
export type IConstituentaDTO = z.infer<typeof schemaConstituenta>;
/** Represents data for {@link IRSForm} provided by backend. */ /** Represents data for {@link IRSForm} provided by backend. */
export type IRSFormDTO = z.infer<typeof schemaRSForm>; export type IRSFormDTO = z.infer<typeof schemaRSForm>;

View File

@ -14,7 +14,7 @@ import { type IConstituenta, type IRSForm } from '../../models/rsform';
import { RefEntity } from './parse/parser.terms'; import { RefEntity } from './parse/parser.terms';
import { findReferenceAt } from './utils'; import { findReferenceAt } from './utils';
export const tooltipProducer = (schema: IRSForm, canClick?: boolean) => { const tooltipProducer = (schema: IRSForm, canClick?: boolean) => {
return hoverTooltip((view, pos) => { return hoverTooltip((view, pos) => {
const parse = findReferenceAt(pos, view.state); const parse = findReferenceAt(pos, view.state);
if (!parse) { if (!parse) {

View File

@ -5,7 +5,7 @@ import { createContext, use } from 'react';
import { type IConstituenta } from '../../models/rsform'; import { type IConstituenta } from '../../models/rsform';
import { type IArgumentValue } from '../../models/rslang'; import { type IArgumentValue } from '../../models/rslang';
export interface ITemplateContext { interface ITemplateContext {
args: IArgumentValue[]; args: IArgumentValue[];
prototype: IConstituenta | null; prototype: IConstituenta | null;
templateID: number | null; templateID: number | null;

View File

@ -4,7 +4,6 @@ export {
type IRSFormDTO, type IRSFormDTO,
type IVersionCreatedResponse, type IVersionCreatedResponse,
ParsingStatus, ParsingStatus,
schemaCstSubstitute,
schemaRSForm, schemaRSForm,
schemaVersionCreatedResponse schemaVersionCreatedResponse
} from './backend/types'; } from './backend/types';

View File

@ -2,8 +2,12 @@
* Module: Models for formal representation for systems of concepts. * Module: Models for formal representation for systems of concepts.
*/ */
import { type ILibraryItemData, type IVersionInfo } from '@/features/library/backend/types'; import {
import { type CurrentVersion, type ILibraryItemReference } from '@/features/library/models/library'; type CurrentVersion,
type ILibraryItemData,
type ILibraryItemReference,
type IVersionInfo
} from '@/features/library';
import { type Graph } from '@/models/graph'; import { type Graph } from '@/models/graph';

View File

@ -18,29 +18,6 @@ const COMPLEX_SYMBOLS_REGEXP = /[∀∃×ℬ;|:]/g;
const TYPIFICATION_SET = /^+\([\(X\d+\)×]*\)$/g; const TYPIFICATION_SET = /^+\([\(X\d+\)×]*\)$/g;
// cspell:enable // cspell:enable
/**
* Text substitution guided by mapping and regular expression.
*/
export function applyPattern(text: string, mapping: AliasMapping, pattern: RegExp): string {
if (text === '' || pattern === null) {
return text;
}
let posInput = 0;
let output = '';
const patternMatches = text.matchAll(pattern);
for (const segment of patternMatches) {
const entity = segment[0];
const start = segment.index ?? 0;
if (entity in mapping) {
output += text.substring(posInput, start);
output += mapping[entity];
posInput = start + segment[0].length;
}
}
output += text.substring(posInput);
return output;
}
/** /**
* Extracts global variable names from a given expression. * Extracts global variable names from a given expression.
*/ */
@ -147,25 +124,6 @@ export function substituteTemplateArgs(expression: string, args: IArgumentValue[
} }
} }
const ERROR_LEXER_MASK = 512;
const ERROR_PARSER_MASK = 1024;
const ERROR_SEMANTIC_MASK = 2048;
/**
* Infers error class from error type (code).
*/
export function inferErrorClass(error: RSErrorType): RSErrorClass {
if ((error & ERROR_LEXER_MASK) !== 0) {
return RSErrorClass.LEXER;
} else if ((error & ERROR_PARSER_MASK) !== 0) {
return RSErrorClass.PARSER;
} else if ((error & ERROR_SEMANTIC_MASK) !== 0) {
return RSErrorClass.SEMANTIC;
} else {
return RSErrorClass.UNKNOWN;
}
}
/** /**
* Generate ErrorID label. * Generate ErrorID label.
*/ */
@ -293,3 +251,42 @@ export function transformAST(tree: Tree): SyntaxTree {
} }
return result; return result;
} }
// ====== Internals =========
/** Text substitution guided by mapping and regular expression. */
function applyPattern(text: string, mapping: AliasMapping, pattern: RegExp): string {
if (text === '' || pattern === null) {
return text;
}
let posInput = 0;
let output = '';
const patternMatches = text.matchAll(pattern);
for (const segment of patternMatches) {
const entity = segment[0];
const start = segment.index ?? 0;
if (entity in mapping) {
output += text.substring(posInput, start);
output += mapping[entity];
posInput = start + segment[0].length;
}
}
output += text.substring(posInput);
return output;
}
const ERROR_LEXER_MASK = 512;
const ERROR_PARSER_MASK = 1024;
const ERROR_SEMANTIC_MASK = 2048;
/** Infers error class from error type (code). */
function inferErrorClass(error: RSErrorType): RSErrorClass {
if ((error & ERROR_LEXER_MASK) !== 0) {
return RSErrorClass.LEXER;
} else if ((error & ERROR_PARSER_MASK) !== 0) {
return RSErrorClass.PARSER;
} else if ((error & ERROR_SEMANTIC_MASK) !== 0) {
return RSErrorClass.SEMANTIC;
} else {
return RSErrorClass.UNKNOWN;
}
}

View File

@ -13,7 +13,7 @@ export const RSTabID = {
} as const; } as const;
export type RSTabID = (typeof RSTabID)[keyof typeof RSTabID]; export type RSTabID = (typeof RSTabID)[keyof typeof RSTabID];
export interface IRSEditContext { interface IRSEditContext {
schema: IRSForm; schema: IRSForm;
selected: number[]; selected: number[];
focusCst: IConstituenta | null; focusCst: IConstituenta | null;

View File

@ -5,18 +5,14 @@ import { syntaxTree } from '@codemirror/language';
import { type NodeType, type Tree, type TreeCursor } from '@lezer/common'; import { type NodeType, type Tree, type TreeCursor } from '@lezer/common';
import { type ReactCodeMirrorRef, type SelectionRange } from '@uiw/react-codemirror'; import { type ReactCodeMirrorRef, type SelectionRange } from '@uiw/react-codemirror';
/** /** Represents syntax tree node data. */
* Represents syntax tree node data.
*/
interface SyntaxNode { interface SyntaxNode {
type: NodeType; type: NodeType;
from: number; from: number;
to: number; to: number;
} }
/** /** Represents syntax tree cursor data. */
* Represents syntax tree cursor data.
*/
interface CursorNode extends SyntaxNode { interface CursorNode extends SyntaxNode {
isLeaf: boolean; isLeaf: boolean;
} }
@ -31,10 +27,8 @@ interface TreeTraversalOptions {
onLeave?: (node: CursorNode) => false | void; onLeave?: (node: CursorNode) => false | void;
} }
/** /** Implements depth-first traversal. */
* Implements depth-first traversal. function traverseTree(tree: Tree, { beforeEnter, onEnter, onLeave }: TreeTraversalOptions) {
*/
export function traverseTree(tree: Tree, { beforeEnter, onEnter, onLeave }: TreeTraversalOptions) {
const cursor = tree.cursor(); const cursor = tree.cursor();
for (;;) { for (;;) {
let node = cursorNode(cursor); let node = cursorNode(cursor);
@ -59,9 +53,7 @@ export function traverseTree(tree: Tree, { beforeEnter, onEnter, onLeave }: Tree
} }
} }
/** /** Prints tree to compact string. */
* Prints tree to compact string.
*/
export function printTree(tree: Tree): string { export function printTree(tree: Tree): string {
const state = { const state = {
output: '', output: '',
@ -79,9 +71,7 @@ export function printTree(tree: Tree): string {
return state.output; return state.output;
} }
/** /** Retrieves a list of all nodes, containing given range and corresponding to a filter. */
* Retrieves a list of all nodes, containing given range and corresponding to a filter.
*/
export function findEnvelopingNodes(start: number, finish: number, tree: Tree, filter?: number[]): SyntaxNode[] { export function findEnvelopingNodes(start: number, finish: number, tree: Tree, filter?: number[]): SyntaxNode[] {
const result: SyntaxNode[] = []; const result: SyntaxNode[] = [];
tree.cursor().iterate(node => { tree.cursor().iterate(node => {
@ -96,9 +86,7 @@ export function findEnvelopingNodes(start: number, finish: number, tree: Tree, f
return result; return result;
} }
/** /** Retrieves a list of all nodes, contained in given range and corresponding to a filter. */
* Retrieves a list of all nodes, contained in given range and corresponding to a filter.
*/
export function findContainedNodes(start: number, finish: number, tree: Tree, filter?: number[]): SyntaxNode[] { export function findContainedNodes(start: number, finish: number, tree: Tree, filter?: number[]): SyntaxNode[] {
const result: SyntaxNode[] = []; const result: SyntaxNode[] = [];
tree.cursor().iterate(node => { tree.cursor().iterate(node => {

View File

@ -7,15 +7,6 @@ import { type AxiosError, type AxiosHeaderValue, type AxiosResponse, isAxiosErro
import { infoMsg, promptText } from './labels'; import { infoMsg, promptText } from './labels';
/**
* Checks if arguments is Node.
*/
export function assertIsNode(e: EventTarget | null): asserts e is Node {
if (e === null || !('nodeType' in e)) {
throw new TypeError(`Expected 'Node' but received '${e?.constructor.name ?? 'null'}'`);
}
}
/** /**
* Wrapper class for generalized text matching. * Wrapper class for generalized text matching.
* *
@ -88,20 +79,6 @@ export function isResponseHtml(response?: AxiosResponse) {
return header.includes('text/html'); return header.includes('text/html');
} }
/**
* Convert base64 string to Blob uint8.
*/
export function convertBase64ToBlob(base64String: string): Uint8Array {
const arr = base64String.split(',');
const bstr = atob(arr[1]);
let n = bstr.length;
const uint8Array = new Uint8Array(n);
while (n--) {
uint8Array[n] = bstr.charCodeAt(n);
}
return uint8Array;
}
/** /**
* Prompt user of confirming discarding changes before continue. * Prompt user of confirming discarding changes before continue.
*/ */