├── src ├── utilities │ ├── tasks │ │ ├── Task.ts │ │ ├── FixedTaskRunner.ts │ │ ├── FixedDebouncer.ts │ │ ├── FixedThrottler.ts │ │ └── TaskRunner.ts │ ├── Observer.ts │ ├── monaco-editor │ │ ├── monaco-editor.css │ │ └── monaco-editor-with-projections.css │ ├── math.ts │ ├── types.ts │ ├── components │ │ ├── CodeRange.tsx │ │ └── color-pickers │ │ │ ├── color-picker.css │ │ │ ├── RgbColorPicker.tsx │ │ │ └── RgbaColorPicker.tsx │ ├── SplitRegex.ts │ ├── Valuable.ts │ ├── ValueWithUnit.ts │ ├── ValueCondition.ts │ ├── ArrayMap.ts │ ├── ProgrammableFunction.ts │ ├── languages │ │ └── markdown │ │ │ └── markdown-utilities.ts │ └── array.ts ├── core │ ├── renderers │ │ ├── RendererSettings.ts │ │ └── RendererProvider.ts │ ├── user-interfaces │ │ ├── UserInterfaceSettings.ts │ │ ├── error │ │ │ ├── user-interface-error.css │ │ │ ├── UserInterfaceError.tsx │ │ │ └── UserInterfaceErrorCatcherAndDisplay.tsx │ │ └── UserInterfaceProvider.ts │ ├── fragments │ │ ├── FragmentType.ts │ │ ├── Fragment.ts │ │ ├── FragmentProvider.ts │ │ ├── syntactic │ │ │ ├── SyntacticFragment.ts │ │ │ └── TreePatternFinder.ts │ │ └── textual │ │ │ ├── TextualFragment.ts │ │ │ └── RegexPatternFinder.ts │ ├── languages │ │ ├── Language.ts │ │ ├── Parser.ts │ │ ├── SyntaxTreeVisitor.ts │ │ ├── plain-text.ts │ │ ├── SyntaxTree.ts │ │ ├── SyntaxTreeNode.ts │ │ └── SyntaxTreePattern.ts │ ├── projections │ │ ├── ProjectionRequirements.ts │ │ ├── ProjectionUid.ts │ │ ├── ProjectionSpecification.ts │ │ └── ProjectionMatcher.ts │ ├── runtime │ │ ├── request-providers │ │ │ ├── RuntimeRequestProvider.ts │ │ │ ├── ProgrammableRuntimeRequestProvider.ts │ │ │ └── RuntimeRequestList.ts │ │ ├── RuntimeResponse.ts │ │ └── RuntimeRequest.ts │ ├── templates │ │ ├── evaluators │ │ │ ├── numeric │ │ │ │ ├── NumericEvaluatorSettings.ts │ │ │ │ └── NumericEvaluator.ts │ │ │ ├── textual │ │ │ │ ├── TextualEvaluatorSettings.ts │ │ │ │ └── TextualEvaluator.ts │ │ │ └── boolean │ │ │ │ ├── BooleanEvaluatorSettings.ts │ │ │ │ └── BooleanEvaluator.ts │ │ ├── textual │ │ │ └── TextualTemplateSlot.ts │ │ ├── syntactic │ │ │ ├── SyntacticTemplateSlot.ts │ │ │ └── TreePatternTemplate.ts │ │ └── TemplateSlot.ts │ ├── documents │ │ ├── TransientDocumentEditor.ts │ │ ├── DocumentPosition.ts │ │ ├── DocumentRange.ts │ │ └── DocumentEdit.ts │ ├── mappings │ │ ├── ForwardMapping.ts │ │ ├── BackwardMapping.ts │ │ ├── ProgrammableBackwardMapping.ts │ │ └── ProgrammableForwardMapping.ts │ ├── code-editor │ │ ├── DecoratedRange.ts │ │ └── CodeEditor.tsx │ └── lorgnette │ │ └── LorgnetteContext.tsx ├── presets │ ├── user-interfaces │ │ ├── table │ │ │ ├── table.css │ │ │ └── TableSettings.ts │ │ ├── form │ │ │ ├── form-elements │ │ │ │ ├── helpers │ │ │ │ │ ├── Icon.tsx │ │ │ │ │ ├── Label.tsx │ │ │ │ │ ├── Section.tsx │ │ │ │ │ ├── SingleRow.tsx │ │ │ │ │ └── ButtonGroup.tsx │ │ │ │ ├── Switch.tsx │ │ │ │ ├── StringInput.tsx │ │ │ │ ├── ButtonColorPicker.tsx │ │ │ │ ├── NumberInput.tsx │ │ │ │ ├── EditableText.tsx │ │ │ │ └── Button.tsx │ │ │ ├── FormSettings.tsx │ │ │ ├── FormContext.tsx │ │ │ ├── form.css │ │ │ └── FormEntry.ts │ │ ├── value-history │ │ │ ├── ValueHistorySettings.ts │ │ │ └── value-history.css │ │ ├── style-inspector │ │ │ ├── Style.ts │ │ │ └── inspectors │ │ │ │ ├── MarginInspector.tsx │ │ │ │ └── BackgroundInspector.tsx │ │ ├── object-inspector │ │ │ ├── ObjectInspectorComponent.tsx │ │ │ └── ObjectInspector.tsx │ │ ├── tree │ │ │ └── tree-component.css │ │ ├── user-interfaces-presets.ts │ │ ├── regex-editor │ │ │ ├── regex-editor.css │ │ │ ├── LargeRegexDiagramComponent.tsx │ │ │ ├── RegexEditorComponent.tsx │ │ │ ├── RegexEditor.tsx │ │ │ └── RegulexIframe.tsx │ │ └── color-picker │ │ │ └── ColorPicker.tsx │ ├── renderers │ │ ├── side │ │ │ ├── side-renderer.css │ │ │ └── SideRendererSettings.ts │ │ ├── renderer-presets.ts │ │ ├── popup │ │ │ ├── ButtonPopupRendererSettings.ts │ │ │ ├── popup-renderer.css │ │ │ └── ButtonPopupRenderer.tsx │ │ └── popover │ │ │ ├── ButtonPopoverRendererSettings.ts │ │ │ ├── popover-renderer.css │ │ │ └── ButtonPopoverRenderer.tsx │ ├── languages │ │ ├── css │ │ │ ├── language.ts │ │ │ ├── CssSyntaxTree.ts │ │ │ └── CssParser.ts │ │ ├── json │ │ │ ├── language.ts │ │ │ ├── nodes │ │ │ │ ├── NullNode.ts │ │ │ │ ├── BooleanNode.ts │ │ │ │ ├── NumberNode.ts │ │ │ │ ├── KeyNode.ts │ │ │ │ ├── StringNode.ts │ │ │ │ ├── ObjectNode.ts │ │ │ │ ├── ArrayNode.ts │ │ │ │ └── PropertyNode.ts │ │ │ ├── JsonSyntaxTreeNode.ts │ │ │ ├── JsonSyntaxTree.ts │ │ │ └── JsonParser.ts │ │ ├── python │ │ │ ├── language.ts │ │ │ ├── nodes │ │ │ │ ├── NoneNode.ts │ │ │ │ ├── BooleanNode.ts │ │ │ │ ├── NumberNode.ts │ │ │ │ ├── IdentifierNode.ts │ │ │ │ ├── PositionalArgumentNode.ts │ │ │ │ ├── ProgramNode.ts │ │ │ │ ├── NamedArgumentNode.ts │ │ │ │ ├── StringNode.ts │ │ │ │ ├── ArgumentListNode.ts │ │ │ │ ├── ExpressionNode.ts │ │ │ │ ├── FunctionCallNode.ts │ │ │ │ ├── NamedAccessNode.ts │ │ │ │ └── IndexedAccessNode.ts │ │ │ ├── PythonSyntaxTreeNode.ts │ │ │ ├── PythonParser.ts │ │ │ └── PythonSyntaxTree.ts │ │ ├── markdown │ │ │ ├── language.ts │ │ │ ├── MarkdownSyntaxTree.ts │ │ │ ├── MarkdownParser.ts │ │ │ └── MarkdownSyntaxTreeNode.ts │ │ ├── typescript │ │ │ ├── language.ts │ │ │ ├── TypescriptSyntaxTree.ts │ │ │ ├── TypescriptParser.ts │ │ │ └── TypescriptSyntaxTreeNode.ts │ │ └── language-presets.ts │ └── projections │ │ ├── hexadecimal-color-picker.ts │ │ ├── regex-literal-diagram.ts │ │ └── runtime-value-tracer.ts └── apps │ ├── playground │ ├── local-store │ │ ├── LocalStore.ts │ │ └── LocalStoreManager.ts │ ├── index.html │ ├── examples │ │ ├── seaborn.ts │ │ ├── Example.ts │ │ ├── css.ts │ │ ├── typescript.ts │ │ ├── vega.ts │ │ └── markdown.ts │ ├── index.tsx │ └── syntax-tree │ │ └── syntax-tree.css │ ├── vscode-editor │ ├── VscodeApi.ts │ ├── vscode-editor-app.css │ ├── index.html │ └── index.tsx │ └── global-style.css ├── misc ├── lorgnette-markdown-table-demo.gif └── lorgnette-python-barplot-demo.gif ├── .gitignore ├── vite.config.ts ├── tsconfig.json ├── .eslintrc.cjs ├── LICENSE ├── .github └── workflows │ └── build-and-publish-playground.yml └── package.json /src/utilities/tasks/Task.ts: -------------------------------------------------------------------------------- 1 | export type Task = () => (any | Promise); 2 | -------------------------------------------------------------------------------- /src/core/renderers/RendererSettings.ts: -------------------------------------------------------------------------------- 1 | export interface RendererSettings { 2 | 3 | } 4 | -------------------------------------------------------------------------------- /src/presets/user-interfaces/table/table.css: -------------------------------------------------------------------------------- 1 | .ui.table { 2 | background-color: red; 3 | } 4 | -------------------------------------------------------------------------------- /src/utilities/Observer.ts: -------------------------------------------------------------------------------- 1 | export interface Observer { 2 | processChange(data: T): void; 3 | } -------------------------------------------------------------------------------- /src/core/user-interfaces/UserInterfaceSettings.ts: -------------------------------------------------------------------------------- 1 | export interface UserInterfaceSettings { 2 | 3 | } -------------------------------------------------------------------------------- /src/core/fragments/FragmentType.ts: -------------------------------------------------------------------------------- 1 | export const enum FragmentType { 2 | Textual = "Textual", 3 | Syntactic = "Syntactic" 4 | } -------------------------------------------------------------------------------- /misc/lorgnette-markdown-table-demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exsitu-projects/lorgnette/HEAD/misc/lorgnette-markdown-table-demo.gif -------------------------------------------------------------------------------- /misc/lorgnette-python-barplot-demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exsitu-projects/lorgnette/HEAD/misc/lorgnette-python-barplot-demo.gif -------------------------------------------------------------------------------- /src/apps/playground/local-store/LocalStore.ts: -------------------------------------------------------------------------------- 1 | export interface LocalStore { 2 | documentLanguageId: string; 3 | documentContent: string; 4 | } 5 | -------------------------------------------------------------------------------- /src/apps/vscode-editor/VscodeApi.ts: -------------------------------------------------------------------------------- 1 | export const vscode = (window as any).acquireVsCodeApi() as { 2 | postMessage(message: any): void; 3 | }; 4 | 5 | // export const vscode = {postMessage: (m: any) => {}} -------------------------------------------------------------------------------- /src/utilities/monaco-editor/monaco-editor.css: -------------------------------------------------------------------------------- 1 | .monaco-editor-wrapper { 2 | width: 100%; 3 | height: 100%; 4 | } 5 | 6 | .monaco-editor { 7 | width: 100%; 8 | height: 100%; 9 | } 10 | -------------------------------------------------------------------------------- /src/core/languages/Language.ts: -------------------------------------------------------------------------------- 1 | import { Parser } from "./Parser"; 2 | 3 | export interface Language { 4 | name: string; 5 | id: string; 6 | codeEditorLanguageId: string; 7 | parser?: Parser; 8 | } 9 | -------------------------------------------------------------------------------- /src/core/languages/Parser.ts: -------------------------------------------------------------------------------- 1 | import { Document } from "../documents/Document"; 2 | import { SyntaxTree } from "./SyntaxTree"; 3 | 4 | export interface Parser { 5 | parse(document: Document): Promise; 6 | } -------------------------------------------------------------------------------- /src/core/languages/SyntaxTreeVisitor.ts: -------------------------------------------------------------------------------- 1 | import { SyntaxTreeNode } from "./SyntaxTreeNode"; 2 | 3 | export interface SyntaxTeeeVisitor { 4 | visitNode(node: SyntaxTreeNode, extraData: T): void | boolean; 5 | } 6 | -------------------------------------------------------------------------------- /src/core/languages/plain-text.ts: -------------------------------------------------------------------------------- 1 | import { Language } from "./Language"; 2 | 3 | export const PLAIN_TEXT_LANGUAGE: Language = { 4 | name: "Plain text", 5 | id: "plaintext", 6 | codeEditorLanguageId: "plaintext" 7 | }; -------------------------------------------------------------------------------- /src/presets/renderers/side/side-renderer.css: -------------------------------------------------------------------------------- 1 | .projection-renderer.side { 2 | position: absolute; 3 | background-color: rgba(255, 255, 255, 0.8); 4 | box-shadow: 0 0 10px rgba(255, 255, 255, 0.8); 5 | z-index: 500; 6 | } 7 | -------------------------------------------------------------------------------- /src/core/fragments/Fragment.ts: -------------------------------------------------------------------------------- 1 | import { DocumentRange } from "../documents/DocumentRange"; 2 | import { FragmentType } from "./FragmentType"; 3 | 4 | export interface Fragment { 5 | type: FragmentType; 6 | range: DocumentRange; 7 | text: string; 8 | } -------------------------------------------------------------------------------- /src/apps/vscode-editor/vscode-editor-app.css: -------------------------------------------------------------------------------- 1 | body { 2 | background-color: #FAFAFA; 3 | margin: 0; 4 | padding: 0; 5 | } 6 | 7 | #lorgnette-vscode-editor-app { 8 | width: 100vw; 9 | height: 100vh; 10 | font-family: "Roboto", sans-serif; 11 | font-size: 16px; 12 | } 13 | -------------------------------------------------------------------------------- /src/presets/languages/css/language.ts: -------------------------------------------------------------------------------- 1 | import { Language } from "../../../core/languages/Language"; 2 | import { CssParser } from "./CssParser"; 3 | 4 | export const CSS_LANGUAGE: Language = { 5 | name: "CSS", 6 | id: "css", 7 | codeEditorLanguageId: "css", 8 | parser: new CssParser() 9 | }; -------------------------------------------------------------------------------- /src/core/projections/ProjectionRequirements.ts: -------------------------------------------------------------------------------- 1 | export interface ProjectionRequirements { 2 | /** 3 | * List of the IDs of the languages that are supported by the projection. 4 | * Not specifying the parameter is equivalent to specifying all languages. 5 | */ 6 | languages?: string[]; 7 | } -------------------------------------------------------------------------------- /src/presets/languages/json/language.ts: -------------------------------------------------------------------------------- 1 | import { Language } from "../../../core/languages/Language"; 2 | import { JsonParser } from "./JsonParser"; 3 | 4 | export const JSON_LANGUAGE: Language = { 5 | name: "JSON", 6 | id: "json", 7 | codeEditorLanguageId: "json", 8 | parser: new JsonParser() 9 | }; -------------------------------------------------------------------------------- /src/apps/global-style.css: -------------------------------------------------------------------------------- 1 | /* Imports required to use the Blueprint UI library. */ 2 | @import "normalize.css"; 3 | @import "@blueprintjs/core/lib/css/blueprint.css"; 4 | @import "@blueprintjs/icons/lib/css/blueprint-icons.css"; 5 | 6 | body { 7 | position: absolute; 8 | width: 100%; 9 | height: 100%; 10 | } -------------------------------------------------------------------------------- /src/presets/languages/python/language.ts: -------------------------------------------------------------------------------- 1 | import { Language } from "../../../core/languages/Language"; 2 | import { PythonParser } from "./PythonParser"; 3 | 4 | export const PYTHON_LANGUAGE: Language = { 5 | name: "Python (subset)", 6 | id: "python", 7 | codeEditorLanguageId: "python", 8 | parser: new PythonParser() 9 | }; -------------------------------------------------------------------------------- /src/presets/languages/markdown/language.ts: -------------------------------------------------------------------------------- 1 | import { Language } from "../../../core/languages/Language"; 2 | import { MarkdownParser } from "./MarkdownParser"; 3 | 4 | export const MARKDOWN_LANGUAGE: Language = { 5 | name: "Markdown", 6 | id: "markdown", 7 | codeEditorLanguageId: "markdown", 8 | parser: new MarkdownParser() 9 | }; -------------------------------------------------------------------------------- /src/core/fragments/FragmentProvider.ts: -------------------------------------------------------------------------------- 1 | import { Document } from "../documents/Document"; 2 | import { Fragment } from "./Fragment"; 3 | import { FragmentType } from "./FragmentType"; 4 | 5 | export interface FragmentProvider { 6 | type: FragmentType; 7 | provideFragmentsForDocument(document: Document): Promise; 8 | } -------------------------------------------------------------------------------- /src/core/projections/ProjectionUid.ts: -------------------------------------------------------------------------------- 1 | export type ProjectionUid = number; 2 | 3 | // Provide a generator of unique projection IDs. 4 | let nextUnusedProjectionUid = 1; 5 | 6 | export function getUnusedUid(): ProjectionUid { 7 | const unusedUid = nextUnusedProjectionUid; 8 | nextUnusedProjectionUid += 1; 9 | 10 | return unusedUid; 11 | } -------------------------------------------------------------------------------- /src/presets/languages/typescript/language.ts: -------------------------------------------------------------------------------- 1 | import { Language } from "../../../core/languages/Language"; 2 | import { TypescriptParser } from "./TypescriptParser"; 3 | 4 | export const TYPESCRIPT_LANGUAGE: Language = { 5 | name: "TypeScript", 6 | id: "typescript", 7 | codeEditorLanguageId: "typescript", 8 | parser: new TypescriptParser() 9 | }; -------------------------------------------------------------------------------- /src/utilities/tasks/FixedTaskRunner.ts: -------------------------------------------------------------------------------- 1 | import { Task } from "./Task"; 2 | 3 | export abstract class FixedTaskRunner { 4 | protected task: Task; 5 | protected isRunningTask: boolean; 6 | 7 | constructor(task: Task) { 8 | this.task = task; 9 | this.isRunningTask = false; 10 | } 11 | 12 | abstract runTask(): void; 13 | } -------------------------------------------------------------------------------- /src/core/user-interfaces/error/user-interface-error.css: -------------------------------------------------------------------------------- 1 | .ui-error { 2 | border: 2px solid #f00; 3 | background-color: #ffefef; 4 | padding: 1em; 5 | } 6 | 7 | .ui-error .title { 8 | display: block; 9 | margin: 0 0 1ex 0; 10 | font-weight: bold; 11 | text-align: center; 12 | } 13 | 14 | .ui-error .body { 15 | font-size: 0.9em; 16 | } -------------------------------------------------------------------------------- /src/apps/playground/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Lorgnette playground 7 | 8 | 9 |
10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/apps/vscode-editor/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Lorgnette editor for VS Code 7 | 8 | 9 |
10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/core/renderers/RendererProvider.ts: -------------------------------------------------------------------------------- 1 | import { ClassOf } from "../../utilities/types"; 2 | import { Renderer } from "./Renderer"; 3 | import { RendererSettings } from "./RendererSettings"; 4 | 5 | export interface RendererProvider { 6 | provide(): ClassOf; 7 | } 8 | 9 | export type ConfigurableRendererProvider< 10 | S extends RendererSettings = RendererSettings 11 | > = (settings: S) => RendererProvider; 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | /pnpm-lock.yaml 22 | 23 | npm-debug.log* 24 | yarn-debug.log* 25 | yarn-error.log* 26 | -------------------------------------------------------------------------------- /src/presets/user-interfaces/form/form-elements/helpers/Icon.tsx: -------------------------------------------------------------------------------- 1 | import React, { ReactElement } from "react"; 2 | import { Icon as BlueprintIcon, IconProps as BlueprintIconProps } from "@blueprintjs/core"; 3 | 4 | export type IconProps = { 5 | id: BlueprintIconProps["icon"]; 6 | }; 7 | 8 | export class Icon extends React.PureComponent { 9 | render(): ReactElement { 10 | return ; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/core/languages/SyntaxTree.ts: -------------------------------------------------------------------------------- 1 | import { SyntaxTreeNode } from "./SyntaxTreeNode"; 2 | import { SyntaxTeeeVisitor } from "./SyntaxTreeVisitor"; 3 | 4 | export abstract class SyntaxTree { 5 | readonly root: N; 6 | 7 | constructor(root: N) { 8 | this.root = root; 9 | } 10 | 11 | visitWith(visitor: SyntaxTeeeVisitor, extraData: T) { 12 | this.root.visitWith(visitor, extraData); 13 | } 14 | } -------------------------------------------------------------------------------- /src/utilities/math.ts: -------------------------------------------------------------------------------- 1 | export function clamp( 2 | min: number, 3 | value: number, 4 | max: number, 5 | ): number { 6 | return Math.max(Math.min(value, max), min); 7 | } 8 | 9 | // Adapted from https://stackoverflow.com/a/41716722 10 | export function round( 11 | value: number, 12 | nbDecimals: number 13 | ): number { 14 | const tenPowerNbDecimals = 10**nbDecimals; 15 | return Math.round((value + Number.EPSILON) * tenPowerNbDecimals) / tenPowerNbDecimals; 16 | } -------------------------------------------------------------------------------- /src/presets/renderers/renderer-presets.ts: -------------------------------------------------------------------------------- 1 | import { ButtonPopoverRenderer } from "./popover/ButtonPopoverRenderer"; 2 | import { ButtonPopupRenderer } from "./popup/ButtonPopupRenderer"; 3 | import { SideRenderer } from "./side/SideRenderer"; 4 | 5 | export const RENDERER_PRESETS = { 6 | "side": SideRenderer.makeConfigurableProvider(), 7 | "button-popup": ButtonPopupRenderer.makeConfigurableProvider(), 8 | "button-popover": ButtonPopoverRenderer.makeConfigurableProvider(), 9 | } as const; 10 | -------------------------------------------------------------------------------- /src/presets/user-interfaces/value-history/ValueHistorySettings.ts: -------------------------------------------------------------------------------- 1 | export interface ValueHistorySettings { 2 | maximumNbValues: number; 3 | } 4 | 5 | export const DEFAULT_VALUE_HISTORY_SETTINGS: ValueHistorySettings = { 6 | maximumNbValues: 64 7 | }; 8 | 9 | export const deriveValueHistorySettingsFrom = (partialSettings: Partial): ValueHistorySettings => { 10 | return { 11 | ...DEFAULT_VALUE_HISTORY_SETTINGS, 12 | ...partialSettings 13 | }; 14 | }; 15 | -------------------------------------------------------------------------------- /src/utilities/types.ts: -------------------------------------------------------------------------------- 1 | export type ClassOf = { new(...args: any[]): T }; 2 | 3 | // Adapted from https://stackoverflow.com/a/43001581 4 | export type DeepOptionalProperties = { 5 | [P in keyof T]+?: 6 | T[P] extends Array 7 | ? T[P] 8 | : DeepOptionalProperties 9 | }; 10 | 11 | export type DeepRequiredProperties = { 12 | [P in keyof Required]-?: 13 | T[P] extends Array 14 | ? T[P] 15 | : DeepRequiredProperties 16 | }; -------------------------------------------------------------------------------- /src/core/runtime/request-providers/RuntimeRequestProvider.ts: -------------------------------------------------------------------------------- 1 | import { Document } from "../../documents/Document"; 2 | import { Fragment } from "../../fragments/Fragment"; 3 | import { RuntimeRequest } from "../RuntimeRequest"; 4 | 5 | export interface RuntimeRequestContext { 6 | fragment: F; 7 | document: Document; 8 | } 9 | 10 | export interface RuntimeRequestProvider { 11 | provideRuntimeRequests(context: RuntimeRequestContext): RuntimeRequest[]; 12 | } 13 | -------------------------------------------------------------------------------- /src/utilities/tasks/FixedDebouncer.ts: -------------------------------------------------------------------------------- 1 | import { Debouncer } from "./Debouncer"; 2 | import { FixedTaskRunner } from "./FixedTaskRunner"; 3 | import { Task } from "./Task"; 4 | 5 | export class FixedDebouncer extends FixedTaskRunner { 6 | readonly debouncer: Debouncer; 7 | 8 | constructor(task: Task, minimumDelayBetweenTasks: number) { 9 | super(task); 10 | this.debouncer = new Debouncer(minimumDelayBetweenTasks); 11 | } 12 | 13 | runTask(): void { 14 | this.debouncer.addTask(this.task); 15 | } 16 | } -------------------------------------------------------------------------------- /src/utilities/tasks/FixedThrottler.ts: -------------------------------------------------------------------------------- 1 | import { Throttler } from "./Throttler"; 2 | import { FixedTaskRunner } from "./FixedTaskRunner"; 3 | import { Task } from "./Task"; 4 | 5 | export class FixedThrottler extends FixedTaskRunner { 6 | readonly throttler: Throttler; 7 | 8 | constructor(task: Task, minimumDelayBetweenTasks: number) { 9 | super(task); 10 | this.throttler = new Throttler(minimumDelayBetweenTasks); 11 | } 12 | 13 | runTask(): void { 14 | this.throttler.addTask(this.task); 15 | } 16 | } -------------------------------------------------------------------------------- /src/utilities/components/CodeRange.tsx: -------------------------------------------------------------------------------- 1 | 2 | import { PureComponent } from "react"; 3 | import { Range } from "../../core/documents/Range"; 4 | 5 | type Props = { 6 | range: Range; 7 | } 8 | 9 | export class CodeRange extends PureComponent { 10 | render() { 11 | const start = this.props.range.start; 12 | const end = this.props.range.end; 13 | 14 | return ( 15 | 16 | {start.row};{start.column}–{end.row};{end.column} 17 | ); 18 | } 19 | } -------------------------------------------------------------------------------- /src/utilities/components/color-pickers/color-picker.css: -------------------------------------------------------------------------------- 1 | .floating-color-picker-wrapper { 2 | z-index: 1000; 3 | } 4 | 5 | .floating-color-picker-wrapper .color-picker { 6 | border-radius: 10px; 7 | box-shadow: 0 0 10px rgba(0, 0, 0, 0.25); 8 | 9 | } 10 | 11 | .bp5-button.color-picker-button { 12 | padding: 2px; 13 | min-height: auto; 14 | min-width: auto; 15 | } 16 | 17 | .color-picker-button .color-preview { 18 | height: 24px; 19 | width: 48px; 20 | border: 1px solid rgba(0, 0, 0, 0.25); 21 | border-radius: 2px; 22 | } 23 | -------------------------------------------------------------------------------- /src/presets/user-interfaces/style-inspector/Style.ts: -------------------------------------------------------------------------------- 1 | import { BackgroundProperties } from "./inspectors/BackgroundInspector"; 2 | import { BorderProperties } from "./inspectors/BorderInspector"; 3 | import { FontProperties } from "./inspectors/FontInspector"; 4 | import { MarginProperties } from "./inspectors/MarginInspector"; 5 | 6 | export type Style = { 7 | background?: BackgroundProperties; 8 | border?: BorderProperties; 9 | font?: FontProperties; 10 | margin?: MarginProperties; 11 | }; 12 | 13 | export type FullStyle = { [K in keyof Required