Fix type lints in editor
This commit is contained in:
parent
7ffedccf2e
commit
e087b87c19
19 changed files with 75 additions and 77 deletions
|
|
@ -1,7 +1,7 @@
|
|||
// Portions of this file are Copyright 2021 Google LLC, and licensed under GPL2+. See COPYING.
|
||||
|
||||
import { CSSProperties, useContext } from 'react';
|
||||
import { ModelContext } from './contexts';
|
||||
import React, { CSSProperties, useContext } from 'react';
|
||||
import { ModelContext } from './contexts.ts';
|
||||
|
||||
import { Dropdown } from 'primereact/dropdown';
|
||||
import { Slider } from 'primereact/slider';
|
||||
|
|
@ -9,7 +9,7 @@ import { Checkbox } from 'primereact/checkbox';
|
|||
import { InputNumber } from 'primereact/inputnumber';
|
||||
import { InputText } from 'primereact/inputtext';
|
||||
import { Fieldset } from 'primereact/fieldset';
|
||||
import { Parameter } from '../state/customizer-types';
|
||||
import { Parameter } from '../state/customizer-types.ts';
|
||||
import { Button } from 'primereact/button';
|
||||
|
||||
export default function CustomizerPanel({className, style}: {className?: string, style?: CSSProperties}) {
|
||||
|
|
|
|||
|
|
@ -2,16 +2,16 @@
|
|||
|
||||
import React, { CSSProperties, useContext, useRef, useState } from 'react';
|
||||
import Editor, { loader, Monaco } from '@monaco-editor/react';
|
||||
import openscadEditorOptions from '../language/openscad-editor-options';
|
||||
import openscadEditorOptions from '../language/openscad-editor-options.ts';
|
||||
import * as monaco from 'monaco-editor/esm/vs/editor/editor.api';
|
||||
import { InputTextarea } from 'primereact/inputtextarea';
|
||||
import { Button } from 'primereact/button';
|
||||
import { MenuItem } from 'primereact/menuitem';
|
||||
import { Menu } from 'primereact/menu';
|
||||
import { buildUrlForStateParams } from '../state/fragment-state';
|
||||
import { getBlankProjectState, defaultSourcePath } from '../state/initial-state';
|
||||
import { ModelContext, FSContext } from './contexts';
|
||||
import FilePicker, { } from './FilePicker';
|
||||
import { buildUrlForStateParams } from '../state/fragment-state.ts';
|
||||
import { getBlankProjectState, defaultSourcePath } from '../state/initial-state.ts';
|
||||
import { ModelContext, FSContext } from './contexts.ts';
|
||||
import FilePicker, { } from './FilePicker.tsx';
|
||||
|
||||
// const isMonacoSupported = false;
|
||||
const isMonacoSupported = (() => {
|
||||
|
|
@ -89,7 +89,7 @@ export default function EditorPanel({className, style}: {className?: string, sty
|
|||
{
|
||||
label: "New project",
|
||||
icon: 'pi pi-plus-circle',
|
||||
command: async () => window.open(buildUrlForStateParams(await getBlankProjectState()), '_blank'),
|
||||
command: () => window.open(buildUrlForStateParams(getBlankProjectState()), '_blank'),
|
||||
target: '_blank',
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import React, { useContext, useState } from 'react';
|
||||
import { ModelContext } from './contexts';
|
||||
import React, { useContext } from 'react';
|
||||
import { ModelContext } from './contexts.ts';
|
||||
|
||||
import { SplitButton } from 'primereact/splitbutton';
|
||||
import { MenuItem } from 'primereact/menuitem';
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
// Portions of this file are Copyright 2021 Google LLC, and licensed under GPL2+. See COPYING.
|
||||
|
||||
import { CSSProperties, useContext } from 'react';
|
||||
import React, { CSSProperties, useContext } from 'react';
|
||||
import { TreeSelect } from 'primereact/treeselect';
|
||||
import { TreeNode } from 'primereact/treenode';
|
||||
import { ModelContext, FSContext } from './contexts';
|
||||
import { getParentDir, join } from '../fs/filesystem';
|
||||
import { defaultSourcePath } from '../state/initial-state';
|
||||
import { zipArchives } from '../fs/zip-archives';
|
||||
import { ModelContext, FSContext } from './contexts.ts';
|
||||
import { getParentDir, join } from '../fs/filesystem.ts';
|
||||
import { defaultSourcePath } from '../state/initial-state.ts';
|
||||
import { zipArchives } from '../fs/zip-archives.ts';
|
||||
|
||||
const biasedCompare = (a: string, b: string) =>
|
||||
a === 'openscad' ? -1 : b === 'openscad' ? 1 : a.localeCompare(b);
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
// Portions of this file are Copyright 2021 Google LLC, and licensed under GPL2+. See COPYING.
|
||||
|
||||
import { CSSProperties, useContext, useRef } from 'react';
|
||||
import { ModelContext } from './contexts';
|
||||
import React, { CSSProperties, useContext, useRef } from 'react';
|
||||
import { ModelContext } from './contexts.ts';
|
||||
import * as monaco from 'monaco-editor/esm/vs/editor/editor.api';
|
||||
import { Button } from 'primereact/button';
|
||||
import { ProgressBar } from 'primereact/progressbar';
|
||||
import { Badge } from 'primereact/badge';
|
||||
import { Toast } from 'primereact/toast';
|
||||
import HelpMenu from './HelpMenu';
|
||||
import ExportButton from './ExportButton';
|
||||
import SettingsMenu from './SettingsMenu';
|
||||
import MultimaterialColorsDialog from './MultimaterialColorsDialog';
|
||||
import HelpMenu from './HelpMenu.tsx';
|
||||
import ExportButton from './ExportButton.tsx';
|
||||
import SettingsMenu from './SettingsMenu.tsx';
|
||||
import MultimaterialColorsDialog from './MultimaterialColorsDialog.tsx';
|
||||
|
||||
|
||||
export default function Footer({style}: {style?: CSSProperties}) {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import React, { useContext, useState } from 'react';
|
|||
import { ColorPicker } from 'primereact/colorpicker';
|
||||
import { Button } from 'primereact/button';
|
||||
import { InputText } from 'primereact/inputtext';
|
||||
import { ModelContext } from './contexts';
|
||||
import { ModelContext } from './contexts.ts';
|
||||
import { Dialog } from 'primereact/dialog';
|
||||
|
||||
export default function MultimaterialColorsDialog() {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
// Portions of this file are Copyright 2021 Google LLC, and licensed under GPL2+. See COPYING.
|
||||
|
||||
import React, { useContext } from 'react';
|
||||
import { SingleLayoutComponentId } from '../state/app-state'
|
||||
import { SingleLayoutComponentId } from '../state/app-state.ts'
|
||||
import { TabMenu } from 'primereact/tabmenu';
|
||||
import { ToggleButton } from 'primereact/togglebutton';
|
||||
import { ModelContext, FSContext } from './contexts';
|
||||
import { ModelContext } from './contexts.ts';
|
||||
|
||||
export default function PanelSwitcher() {
|
||||
const model = useContext(ModelContext);
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ import { CSSProperties, useContext, useRef } from 'react';
|
|||
import { Button } from 'primereact/button';
|
||||
import { MenuItem } from 'primereact/menuitem';
|
||||
import { Menu } from 'primereact/menu';
|
||||
import { ModelContext } from './contexts';
|
||||
import { isInStandaloneMode } from '../utils';
|
||||
import { ModelContext } from './contexts.ts';
|
||||
import { isInStandaloneMode } from '../utils.ts';
|
||||
import { confirmDialog } from 'primereact/confirmdialog';
|
||||
|
||||
export default function SettingsMenu({className, style}: {className?: string, style?: CSSProperties}) {
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
// Portions of this file are Copyright 2021 Google LLC, and licensed under GPL2+. See COPYING.
|
||||
|
||||
import { CSSProperties, useCallback, useContext, useEffect, useRef, useState } from 'react';
|
||||
import { ModelContext } from './contexts';
|
||||
import { ModelContext } from './contexts.ts';
|
||||
import { Toast } from 'primereact/toast';
|
||||
import { blurHashToImage, imageToBlurhash, imageToThumbhash, thumbHashToImage } from '../io/image_hashes';
|
||||
import { blurHashToImage, imageToBlurhash, imageToThumbhash, thumbHashToImage } from '../io/image_hashes.ts';
|
||||
|
||||
declare global {
|
||||
namespace JSX {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import React from "react";
|
||||
import { Model } from "../state/model";
|
||||
import { Model } from "../state/model.ts";
|
||||
|
||||
export const FSContext = React.createContext<FS | undefined>(undefined);
|
||||
|
||||
|
|
|
|||
|
|
@ -2,18 +2,18 @@
|
|||
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom/client';
|
||||
import {App} from './components/App';
|
||||
import { createEditorFS } from './fs/filesystem';
|
||||
import { registerOpenSCADLanguage } from './language/openscad-register-language';
|
||||
import { zipArchives } from './fs/zip-archives';
|
||||
import {readStateFromFragment} from './state/fragment-state'
|
||||
import { createInitialState } from './state/initial-state';
|
||||
import {App} from './components/App.tsx';
|
||||
import { createEditorFS } from './fs/filesystem.ts';
|
||||
import { registerOpenSCADLanguage } from './language/openscad-register-language.ts';
|
||||
import { zipArchives } from './fs/zip-archives.ts';
|
||||
import {readStateFromFragment} from './state/fragment-state.ts'
|
||||
import { createInitialState } from './state/initial-state.ts';
|
||||
import './index.css';
|
||||
|
||||
import debug from 'debug';
|
||||
import { isInStandaloneMode, registerCustomAppHeightCSSProperty } from './utils';
|
||||
import { State, StatePersister } from './state/app-state';
|
||||
import { writeStateInFragment } from "./state/fragment-state";
|
||||
import { isInStandaloneMode, registerCustomAppHeightCSSProperty } from './utils.ts';
|
||||
import { State, StatePersister } from './state/app-state.ts';
|
||||
import { writeStateInFragment } from "./state/fragment-state.ts";
|
||||
|
||||
import "primereact/resources/themes/lara-light-indigo/theme.css";
|
||||
import "primereact/resources/primereact.min.css";
|
||||
|
|
@ -89,7 +89,7 @@ window.addEventListener('load', async () => {
|
|||
};
|
||||
}
|
||||
|
||||
const initialState = await createInitialState(persistedState);
|
||||
const initialState = createInitialState(persistedState);
|
||||
|
||||
const root = ReactDOM.createRoot(
|
||||
document.getElementById('root') as HTMLElement
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
// Portions of this file are Copyright 2021 Google LLC, and licensed under GPL2+. See COPYING.
|
||||
|
||||
import * as monaco from 'monaco-editor/esm/vs/editor/editor.api';
|
||||
import { ProcessStreams, spawnOpenSCAD } from "./openscad-runner";
|
||||
import { processMergedOutputs } from "./output-parser";
|
||||
import { AbortablePromise, turnIntoDelayableExecution } from '../utils';
|
||||
import { Source } from '../state/app-state';
|
||||
import { VALID_EXPORT_FORMATS_2D, VALID_EXPORT_FORMATS_3D, VALID_RENDER_FORMATS } from '../state/formats';
|
||||
import { ParameterSet } from '../state/customizer-types';
|
||||
import { ProcessStreams, spawnOpenSCAD } from "./openscad-runner.ts";
|
||||
import { processMergedOutputs } from "./output-parser.ts";
|
||||
import { AbortablePromise, turnIntoDelayableExecution } from '../utils.ts';
|
||||
import { Source } from '../state/app-state.ts';
|
||||
import { VALID_EXPORT_FORMATS_2D, VALID_EXPORT_FORMATS_3D } from '../state/formats.ts';
|
||||
import { ParameterSet } from '../state/customizer-types.ts';
|
||||
|
||||
const syntaxDelay = 300;
|
||||
|
||||
|
|
@ -85,7 +85,7 @@ export type RenderArgs = {
|
|||
extraArgs?: string[],
|
||||
isPreview: boolean,
|
||||
mountArchives: boolean,
|
||||
renderFormat: keyof typeof VALID_EXPORT_FORMATS_2D | keyof typeof VALID_EXPORT_FORMATS_3D | keyof typeof VALID_RENDER_FORMATS,
|
||||
renderFormat: keyof typeof VALID_EXPORT_FORMATS_2D | keyof typeof VALID_EXPORT_FORMATS_3D,
|
||||
streamsCallback: (ps: ProcessStreams) => void,
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
// Portions of this file are Copyright 2021 Google LLC, and licensed under GPL2+. See COPYING.
|
||||
|
||||
import { MergedOutputs } from "./openscad-worker";
|
||||
import { AbortablePromise } from "../utils";
|
||||
import { Source } from "../state/app-state";
|
||||
import { MergedOutputs } from "./openscad-worker.ts";
|
||||
import { AbortablePromise } from "../utils.ts";
|
||||
import { Source } from "../state/app-state.ts";
|
||||
|
||||
export type OpenSCADInvocation = {
|
||||
mountArchives: boolean,
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
// Portions of this file are Copyright 2021 Google LLC, and licensed under GPL2+. See COPYING.
|
||||
|
||||
import * as monaco from 'monaco-editor/esm/vs/editor/editor.api';
|
||||
import { ParameterSet } from './customizer-types';
|
||||
import { VALID_EXPORT_FORMATS_2D, VALID_EXPORT_FORMATS_3D, VALID_RENDER_FORMATS } from './formats';
|
||||
import { ParameterSet } from './customizer-types.ts';
|
||||
import { VALID_EXPORT_FORMATS_2D, VALID_EXPORT_FORMATS_3D } from './formats.ts';
|
||||
|
||||
export type MultiLayoutComponentId = 'editor' | 'viewer' | 'customizer';
|
||||
export type SingleLayoutComponentId = MultiLayoutComponentId;
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
// Portions of this file are Copyright 2021 Google LLC, and licensed under GPL2+. See COPYING.
|
||||
|
||||
import { State } from "./app-state";
|
||||
import { VALID_EXPORT_FORMATS_2D, VALID_EXPORT_FORMATS_3D, VALID_RENDER_FORMATS } from './formats';
|
||||
import { validateArray, validateBoolean, validateString, validateStringEnum } from "../utils";
|
||||
import { createInitialState, defaultModelColor, defaultSourcePath } from "./initial-state";
|
||||
import { State } from "./app-state.ts";
|
||||
import { VALID_EXPORT_FORMATS_2D, VALID_EXPORT_FORMATS_3D } from './formats.ts';
|
||||
import { validateArray, validateBoolean, validateString, validateStringEnum } from "../utils.ts";
|
||||
import { createInitialState, defaultModelColor, defaultSourcePath } from "./initial-state.ts";
|
||||
|
||||
export function buildUrlForStateParams(state: State) {//partialState: {params: State['params'], view: State['view']}) {
|
||||
return `${location.protocol}//${location.host}${location.pathname}#${encodeStateParamsAsFragment(state)}`;
|
||||
|
|
@ -17,7 +17,6 @@ async function compressString(input: string): Promise<string> {
|
|||
controller.enqueue(new TextEncoder().encode(input));
|
||||
controller.close();
|
||||
}
|
||||
// @ts-ignore
|
||||
}).pipeThrough(new CompressionStream('gzip'))).arrayBuffer())));
|
||||
}
|
||||
|
||||
|
|
@ -27,7 +26,6 @@ async function decompressString(compressedInput: string): Promise<string> {
|
|||
controller.enqueue(Uint8Array.from(atob(compressedInput), c => c.charCodeAt(0)));
|
||||
controller.close();
|
||||
}
|
||||
// @ts-ignore
|
||||
}).pipeThrough(new DecompressionStream('gzip'))).arrayBuffer());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
// Portions of this file are Copyright 2021 Google LLC, and licensed under GPL2+. See COPYING.
|
||||
|
||||
import defaultScad from './default-scad';
|
||||
import { State } from './app-state';
|
||||
import { fetchSource } from '../utils';
|
||||
import defaultScad from './default-scad.ts';
|
||||
import { State } from './app-state.ts';
|
||||
|
||||
export const defaultSourcePath = '/playground.scad';
|
||||
export const defaultModelColor = '#f9d72c';
|
||||
const defaultBlurhash = "|KSPX^%3~qtjMx$lR*x]t7n,R%xuxbM{WBt7ayfk_3bY9FnAt8XOxanjNF%fxbMyIn%3t7NFoLaeoeV[WBo{xar^IoS1xbxcR*S0xbofRjV[j[kCNGofxaWBNHW-xasDR*WTkBxuWBM{s:t7bYahRjfkozWUadofbIW:jZ";
|
||||
|
||||
export async function createInitialState(state: State | null, source?: {content?: string, path?: string, url?: string, blurhash?: string}): Promise<State> {
|
||||
export function createInitialState(state: State | null, source?: {content?: string, path?: string, url?: string, blurhash?: string}): State {
|
||||
|
||||
type Mode = State['view']['layout']['mode'];
|
||||
|
||||
const mode: Mode = window.matchMedia("(min-width: 768px)").matches
|
||||
? 'multi' : 'single';
|
||||
|
||||
|
|
@ -87,8 +87,8 @@ export async function createInitialState(state: State | null, source?: {content?
|
|||
return initialState;
|
||||
}
|
||||
|
||||
export async function getBlankProjectState() {
|
||||
return await createInitialState(null, {
|
||||
export function getBlankProjectState() {
|
||||
return createInitialState(null, {
|
||||
path: defaultSourcePath,
|
||||
content: defaultScad,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,17 +1,17 @@
|
|||
// Portions of this file are Copyright 2021 Google LLC, and licensed under GPL2+. See COPYING.
|
||||
|
||||
import { checkSyntax, render, RenderArgs, RenderOutput } from "../runner/actions";
|
||||
import { MultiLayoutComponentId, SingleLayoutComponentId, Source, State, StatePersister } from "./app-state";
|
||||
import { VALID_EXPORT_FORMATS_2D, VALID_EXPORT_FORMATS_3D, VALID_RENDER_FORMATS } from './formats';
|
||||
import { bubbleUpDeepMutations } from "./deep-mutate";
|
||||
import { downloadUrl, fetchSource, formatBytes, formatMillis, readFileAsDataURL } from '../utils'
|
||||
import { checkSyntax, render, RenderArgs, RenderOutput } from "../runner/actions.ts";
|
||||
import { MultiLayoutComponentId, SingleLayoutComponentId, State, StatePersister } from "./app-state.ts";
|
||||
import { VALID_EXPORT_FORMATS_2D, VALID_EXPORT_FORMATS_3D } from './formats.ts';
|
||||
import { bubbleUpDeepMutations } from "./deep-mutate.ts";
|
||||
import { downloadUrl, fetchSource, formatBytes, formatMillis, readFileAsDataURL } from '../utils.ts'
|
||||
|
||||
import JSZip from 'jszip';
|
||||
import { ProcessStreams } from "../runner/openscad-runner";
|
||||
import { is2DFormatExtension } from "./formats";
|
||||
import { parseOff } from "../io/import_off";
|
||||
import { exportGlb } from "../io/export_glb";
|
||||
import { export3MF } from "../io/export_3mf";
|
||||
import { ProcessStreams } from "../runner/openscad-runner.ts";
|
||||
import { is2DFormatExtension } from "./formats.ts";
|
||||
import { parseOff } from "../io/import_off.ts";
|
||||
import { exportGlb } from "../io/export_glb.ts";
|
||||
import { export3MF } from "../io/export_3mf.ts";
|
||||
import chroma from "chroma-js";
|
||||
|
||||
const githubRx = /^https:\/\/github.com\/([^/]+)\/([^/]+)\/blob\/(.+)$/;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Portions of this file are Copyright 2021 Google LLC, and licensed under GPL2+. See COPYING.
|
||||
|
||||
import { Source } from "./state/app-state";
|
||||
import { Source } from "./state/app-state.ts";
|
||||
|
||||
export function mapObject(o: any, f: (key: string, value: any) => any, ifPred: (key: string) => boolean) {
|
||||
const ret = [];
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"lib": [
|
||||
"dom",
|
||||
"dom.iterable",
|
||||
"DOM",
|
||||
"DOM.Iterable",
|
||||
"ES2022",
|
||||
"WebWorker"
|
||||
],
|
||||
|
|
|
|||
Loading…
Reference in a new issue