mirror of
https://github.com/ritz078/transform.git
synced 2026-11-20 16:22:53 +03:00
* rename exported functions * replace monaco editor with compiled version * fixes * cancel old API requests
This commit is contained in:
1 parent
3b1eb48149
commit
4ebf5472cd
77 files changed
+869
-235534
No files matched your search
@@ -6,3 +6,4 @@ dist
|
||||
.DS_Store
|
||||
public/static/monaco/*.worker.js.map
|
||||
.tool-versions
|
||||
heroku
|
||||
@@ -1,6 +1,6 @@
|
||||
import React from "react";
|
||||
|
||||
export default function() {
|
||||
export default function Error404() {
|
||||
return (
|
||||
<svg
|
||||
data-name="Layer 1"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React from "react";
|
||||
|
||||
export default function() {
|
||||
export default function Error500() {
|
||||
return (
|
||||
<svg
|
||||
data-name="Layer 1"
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import React from "react";
|
||||
|
||||
export default function() {
|
||||
export default function Npm() {
|
||||
return (
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ import isEmpty from "lodash/isEmpty";
|
||||
* @param t
|
||||
* @returns {{visitor: {ArrayExpression: (function(*)), NullLiteral: (function(*)), StringLiteral: (function(*)), NumericLiteral: (function(*)), ArrowFunctionExpression: (function(*)), FunctionExpression: (function(*)), BooleanLiteral: (function(*)), Program: (function(*, *)), ObjectExpression: (function(*))}}}
|
||||
*/
|
||||
export default function({ types: t }) {
|
||||
export default function BabelPluginJsToMobxStateTree({ types: t }) {
|
||||
return {
|
||||
visitor: {
|
||||
ArrayExpression(path) {
|
||||
|
||||
Vendored
-12276
File diff suppressed because it is too large.
Load diff
@@ -1,10 +1,8 @@
|
||||
import { editor } from "monaco-editor";
|
||||
import {
|
||||
Button,
|
||||
FilePicker,
|
||||
Heading,
|
||||
HTMLInputEvent,
|
||||
Icon,
|
||||
IconButton,
|
||||
Pane,
|
||||
Popover,
|
||||
@@ -16,7 +14,6 @@ import {
|
||||
import React, { useCallback, useEffect, useRef, useState } from "react";
|
||||
import dynamic from "next/dynamic";
|
||||
import copy from "clipboard-copy";
|
||||
import { getWorker, Wrapper } from "@utils/workerWrapper";
|
||||
import Npm from "@assets/svgs/Npm";
|
||||
import { supportedLanguages } from "@utils/prettier";
|
||||
import { useDropzone } from "react-dropzone";
|
||||
@@ -46,12 +43,6 @@ export interface EditorPanelProps {
|
||||
};
|
||||
}
|
||||
|
||||
let prettierWorker: Wrapper;
|
||||
if (IN_BROWSER) {
|
||||
const PrettierWorker = require("@workers/prettier.worker");
|
||||
prettierWorker = getWorker(PrettierWorker);
|
||||
}
|
||||
|
||||
const Monaco = dynamic(() => import("../components/Monaco"), {
|
||||
ssr: false,
|
||||
loading: () => (
|
||||
@@ -67,16 +58,14 @@ const Monaco = dynamic(() => import("../components/Monaco"), {
|
||||
)
|
||||
});
|
||||
|
||||
export default function({
|
||||
export default function EditorPanel({
|
||||
editable = true,
|
||||
title,
|
||||
settingElement,
|
||||
hasLoad,
|
||||
acceptFiles,
|
||||
hasClear,
|
||||
previewElement,
|
||||
hasCopy = true,
|
||||
hasPrettier = true,
|
||||
topNotifications,
|
||||
language,
|
||||
defaultValue,
|
||||
@@ -85,12 +74,10 @@ export default function({
|
||||
packageDetails
|
||||
}: EditorPanelProps) {
|
||||
const [showSettingsDialogue, setSettingsDialog] = useState(false);
|
||||
const [showPreview, setPreviewVisibility] = useState(true);
|
||||
const [value, setValue] = useState(defaultValue);
|
||||
const editorRef = useRef(null);
|
||||
const [fetchingUrl, setFetchingUrl] = useState("");
|
||||
|
||||
const options: editor.IEditorOptions = {
|
||||
const options = {
|
||||
fontSize: 14,
|
||||
readOnly: !editable,
|
||||
codeLens: false,
|
||||
@@ -99,7 +86,8 @@ export default function({
|
||||
enabled: false
|
||||
},
|
||||
quickSuggestions: false,
|
||||
lineNumbers: "on"
|
||||
lineNumbers: "on",
|
||||
renderValidationDecorations: "off"
|
||||
};
|
||||
|
||||
const _toggleSettingsDialog = useCallback(
|
||||
@@ -162,19 +150,6 @@ export default function({
|
||||
});
|
||||
}, [value]);
|
||||
|
||||
const prettify = useCallback(() => {
|
||||
prettierWorker
|
||||
.send({
|
||||
language,
|
||||
value
|
||||
})
|
||||
.then(setValue);
|
||||
}, [language, value]);
|
||||
|
||||
useEffect(() => {
|
||||
editorRef.current && editorRef.current.reLayout();
|
||||
}, [showPreview]);
|
||||
|
||||
const fetchFile = useCallback(
|
||||
close => {
|
||||
(async () => {
|
||||
@@ -277,18 +252,6 @@ export default function({
|
||||
</Tooltip>
|
||||
)}
|
||||
|
||||
{previewElement && (
|
||||
<Tooltip content="Preview">
|
||||
<IconButton
|
||||
height={28}
|
||||
icon={"eye-open"}
|
||||
marginRight={10}
|
||||
isActive={showPreview}
|
||||
onClick={() => setPreviewVisibility(!showPreview)}
|
||||
/>
|
||||
</Tooltip>
|
||||
)}
|
||||
|
||||
{packageDetails && (
|
||||
<a
|
||||
href={packageDetails.url}
|
||||
@@ -314,12 +277,6 @@ export default function({
|
||||
Copy
|
||||
</Button>
|
||||
)}
|
||||
|
||||
{hasPrettier && supportedLanguages.includes(language) && (
|
||||
<Button appearance="primary" onClick={prettify} height={28}>
|
||||
Prettify
|
||||
</Button>
|
||||
)}
|
||||
</Pane>
|
||||
|
||||
<div
|
||||
@@ -345,45 +302,8 @@ export default function({
|
||||
setValue(value);
|
||||
onChange(value);
|
||||
}}
|
||||
innerRef={editorRef}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{IN_BROWSER && showPreview && previewElement && (
|
||||
<Pane display="flex" flex={1} flexDirection="column" overflow="hidden">
|
||||
<Pane
|
||||
height={50}
|
||||
backgroundColor="#fff"
|
||||
zIndex={2}
|
||||
borderTop
|
||||
position={"relative"}
|
||||
alignItems={"center"}
|
||||
display="flex"
|
||||
paddingX={20}
|
||||
>
|
||||
<Heading size={500} flex={1}>
|
||||
Preview
|
||||
</Heading>
|
||||
<Icon
|
||||
size={20}
|
||||
cursor="pointer"
|
||||
icon="cross"
|
||||
onClick={() => setPreviewVisibility(false)}
|
||||
/>
|
||||
</Pane>
|
||||
<Pane
|
||||
height={"40vh"}
|
||||
display="flex"
|
||||
width={"100%"}
|
||||
borderTop
|
||||
backgroundColor="#fff"
|
||||
zIndex={2}
|
||||
overflow="hidden"
|
||||
>
|
||||
{previewElement(value)}
|
||||
</Pane>
|
||||
</Pane>
|
||||
)}
|
||||
</Pane>
|
||||
);
|
||||
}
|
||||
+25
-161
@@ -1,39 +1,5 @@
|
||||
import React from "react";
|
||||
import { editor, languages } from "monaco-editor";
|
||||
import { Pane } from "evergreen-ui";
|
||||
import { lightEditor } from "@utils/theme";
|
||||
|
||||
languages.typescript.typescriptDefaults.setDiagnosticsOptions({
|
||||
noSemanticValidation: true,
|
||||
noSyntaxValidation: true
|
||||
});
|
||||
|
||||
languages.css.cssDefaults.setDiagnosticsOptions({
|
||||
lint: {
|
||||
unknownAtRules: "ignore"
|
||||
} as any
|
||||
});
|
||||
|
||||
// @ts-ignore
|
||||
self.MonacoEnvironment = {
|
||||
getWorkerUrl: function(_moduleId, label) {
|
||||
if (label === "json") {
|
||||
return `/static/monaco/json.worker.js`;
|
||||
}
|
||||
if (label === "css") {
|
||||
return `/static/monaco/css.worker.js`;
|
||||
}
|
||||
if (label === "html") {
|
||||
return `/static/monaco/html.worker.js`;
|
||||
}
|
||||
if (label === "typescript" || label === "javascript") {
|
||||
return `/static/monaco/typescript.worker.js`;
|
||||
}
|
||||
return `/static/monaco/editor.worker.js`;
|
||||
}
|
||||
};
|
||||
|
||||
function noop() {}
|
||||
import Editor from "@monaco-editor/react";
|
||||
|
||||
export function processSize(size) {
|
||||
return !/^\d+$/.test(size) ? size : `${size}px`;
|
||||
@@ -45,133 +11,31 @@ interface MonacoProps {
|
||||
value?: string;
|
||||
width?: number | string;
|
||||
height?: number | string;
|
||||
options?: editor.IEditorOptions;
|
||||
options?: any;
|
||||
defaultValue?: string;
|
||||
editorDidMount?: (editor: editor.IStandaloneCodeEditor) => void;
|
||||
onChange: (value: string, event: editor.IModelContentChangedEvent) => void;
|
||||
onChange: (value: string) => void;
|
||||
}
|
||||
|
||||
export class MonacoEditor extends React.PureComponent<MonacoProps> {
|
||||
private editor: editor.IStandaloneCodeEditor;
|
||||
private containerElement: React.RefObject<HTMLDivElement> = React.createRef();
|
||||
private __prevent_trigger_change_event: boolean;
|
||||
export const Monaco: React.FC<MonacoProps> = ({
|
||||
language,
|
||||
value,
|
||||
defaultValue,
|
||||
height,
|
||||
width,
|
||||
options,
|
||||
onChange
|
||||
}) => {
|
||||
return (
|
||||
<Editor
|
||||
defaultLanguage={language}
|
||||
defaultValue={defaultValue}
|
||||
value={value}
|
||||
height={height}
|
||||
width={width}
|
||||
options={options}
|
||||
onChange={onChange}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
static defaultProps = {
|
||||
width: "100%",
|
||||
height: "100%",
|
||||
value: null,
|
||||
language: "javascript",
|
||||
options: {},
|
||||
editorDidMount: noop,
|
||||
theme: "light"
|
||||
};
|
||||
|
||||
public reLayout = () => {
|
||||
this.editor && this.editor.layout();
|
||||
};
|
||||
|
||||
componentDidMount() {
|
||||
this.initMonaco();
|
||||
|
||||
window.addEventListener("resize", this.reLayout);
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps: MonacoProps) {
|
||||
const { value, language, theme, width, height, options } = this.props;
|
||||
|
||||
if (value !== prevProps.value) {
|
||||
this.__prevent_trigger_change_event = true;
|
||||
this.editor.setValue(typeof value === "string" ? value : "");
|
||||
this.__prevent_trigger_change_event = false;
|
||||
}
|
||||
|
||||
if (prevProps.language !== language) {
|
||||
editor.setModelLanguage(this.editor.getModel(), language);
|
||||
}
|
||||
if (prevProps.theme !== theme) {
|
||||
editor.setTheme(theme);
|
||||
}
|
||||
if (
|
||||
this.editor &&
|
||||
(width !== prevProps.width || height !== prevProps.height)
|
||||
) {
|
||||
this.reLayout();
|
||||
}
|
||||
if (prevProps.options !== options) {
|
||||
this.editor.updateOptions(options);
|
||||
}
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
this.destroyMonaco();
|
||||
|
||||
window.removeEventListener("resize", this.reLayout);
|
||||
}
|
||||
|
||||
destroyMonaco() {
|
||||
if (this.editor) {
|
||||
this.editor.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
initMonaco() {
|
||||
const { value, language, theme, options } = this.props;
|
||||
|
||||
if (this.containerElement.current) {
|
||||
this.editor = editor.create(this.containerElement.current, {
|
||||
value,
|
||||
language,
|
||||
...options
|
||||
});
|
||||
|
||||
editor.defineTheme("light", lightEditor);
|
||||
|
||||
if (theme) {
|
||||
editor.setTheme(theme);
|
||||
}
|
||||
// After initializing monaco editor
|
||||
this.editorDidMount(this.editor);
|
||||
}
|
||||
}
|
||||
|
||||
editorDidMount(editor) {
|
||||
this.props.editorDidMount(editor);
|
||||
editor.onDidChangeModelContent(event => {
|
||||
const value = editor.getValue();
|
||||
|
||||
// Only invoking when user input changed
|
||||
if (!this.__prevent_trigger_change_event) {
|
||||
this.props.onChange(value, event);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
const { width, height } = this.props;
|
||||
const fixedWidth = processSize(width);
|
||||
const fixedHeight = processSize(height);
|
||||
const style = {
|
||||
width: fixedWidth,
|
||||
height: fixedHeight
|
||||
};
|
||||
|
||||
return (
|
||||
<Pane display={"flex"} flex={1} backgroundColor={"#fafafa"}>
|
||||
<div
|
||||
ref={this.containerElement}
|
||||
style={style}
|
||||
className="react-monaco-editor-container"
|
||||
/>
|
||||
</Pane>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default React.memo(
|
||||
({
|
||||
innerRef,
|
||||
...props
|
||||
}: MonacoProps & { innerRef?: React.RefObject<MonacoEditor> }) => (
|
||||
<MonacoEditor {...props} ref={innerRef} />
|
||||
)
|
||||
);
|
||||
export default Monaco;
|
||||
@@ -5,7 +5,7 @@ import Link from "next/link";
|
||||
import { useRouter } from "next/router";
|
||||
import SearchBox from "@components/Searchbox";
|
||||
|
||||
export default function() {
|
||||
export default function Navigator() {
|
||||
const router = useRouter();
|
||||
|
||||
return (
|
||||
|
||||
+1
-25
@@ -1,6 +1,4 @@
|
||||
const withCSS = require("@zeit/next-css");
|
||||
const webpack = require("webpack");
|
||||
const MonacoWebpackPlugin = require("monaco-editor-webpack-plugin");
|
||||
|
||||
const config = {
|
||||
webpack(config, options) {
|
||||
@@ -16,28 +14,6 @@ const config = {
|
||||
"process.env.DEV": JSON.stringify(options.dev),
|
||||
IN_BROWSER: !options.isServer,
|
||||
IS_DEV: options.dev
|
||||
}),
|
||||
new MonacoWebpackPlugin({
|
||||
output: "../../public/static/monaco",
|
||||
languages: [
|
||||
"json",
|
||||
"typescript",
|
||||
"css",
|
||||
"javascript",
|
||||
"html",
|
||||
"sql",
|
||||
"xml",
|
||||
"yaml",
|
||||
"rust",
|
||||
"markdown",
|
||||
"go",
|
||||
"graphql",
|
||||
"scala",
|
||||
"plaintext",
|
||||
"java",
|
||||
"pug"
|
||||
],
|
||||
features: ["folding"]
|
||||
})
|
||||
);
|
||||
|
||||
@@ -67,4 +43,4 @@ const config = {
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = withCSS(config);
|
||||
module.exports = config;
|
||||
+6
-9
@@ -37,12 +37,14 @@
|
||||
"@graphql-codegen/typescript-stencil-apollo": "^1.17.7",
|
||||
"@graphql-codegen/typescript-urql": "^2.0.0",
|
||||
"@khanacademy/flow-to-ts": "^0.1.6",
|
||||
"@monaco-editor/react": "^4.2.1",
|
||||
"@openapi-contrib/json-schema-to-openapi-schema": "^1.2.0",
|
||||
"@svgr/core": "^5.4.0",
|
||||
"@svgr/plugin-jsx": "^5.4.0",
|
||||
"@types/jsonld": "^1.5.1",
|
||||
"@walmartlabs/json-to-simple-graphql-schema": "^2.0.3",
|
||||
"autoprefixer": "^9.8.6",
|
||||
"axios": "^0.21.1",
|
||||
"babel-plugin-json-to-proptypes": "^0.1.0",
|
||||
"babel-plugin-object-styles-to-template": "^0.2.2",
|
||||
"babel-standalone": "^6.26.0",
|
||||
@@ -66,19 +68,16 @@
|
||||
"jsonschema-protobuf": "^1.0.2",
|
||||
"lodash": "^4.17.19",
|
||||
"markdown": "^0.5.0",
|
||||
"monaco-editor": "0.17.1",
|
||||
"next": "9.4.4",
|
||||
"next": "10.2.3",
|
||||
"nprogress": "^0.2.0",
|
||||
"postcss": "^7.0.32",
|
||||
"postcss-js": "^3.0.0",
|
||||
"prettier": "^1.18.2",
|
||||
"qrcode.react": "^1.0.0",
|
||||
"react": "^16.13.1",
|
||||
"react-dom": "^16.13.1",
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.2",
|
||||
"react-dropzone": "^11.0.1",
|
||||
"rust-keywords": "^1.1.0",
|
||||
"sha1": "^1.1.1",
|
||||
"snack-sdk": "^2.6.3",
|
||||
"stringify-object": "^3.3.0",
|
||||
"svg-to-dataurl": "^1.0.0",
|
||||
"svgo": "^1.3.2",
|
||||
@@ -87,7 +86,7 @@
|
||||
"text-encoding-utf-8": "^1.0.2",
|
||||
"transform-json-types": "^0.7.0",
|
||||
"ts-json-schema-generator": "^0.70.2",
|
||||
"typescript": "3.9.7",
|
||||
"typescript": "4.3.4",
|
||||
"xml-js": "^1.6.11",
|
||||
"yaml": "^1.10.0"
|
||||
},
|
||||
@@ -97,11 +96,9 @@
|
||||
"@types/prettier": "^2.0.2",
|
||||
"@types/react": "^16.9.45",
|
||||
"@types/svgo": "^1.3.3",
|
||||
"@zeit/next-css": "^1.0.1",
|
||||
"husky": "^4.2.5",
|
||||
"imagemin-lint-staged": "^0.4.0",
|
||||
"lint-staged": "^10.2.11",
|
||||
"monaco-editor-webpack-plugin": "^1.7.0",
|
||||
"patch-package": "^6.1.2",
|
||||
"postinstall-postinstall": "^2.0.0",
|
||||
"pretty-quick": "^2.0.1",
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
import React from "react";
|
||||
import Document, { Head, Main, NextScript } from "next/document";
|
||||
import Document, { Head, Main, NextScript, Html } from "next/document";
|
||||
import { extractStyles } from "evergreen-ui";
|
||||
|
||||
interface DocumentProps {
|
||||
@@ -23,7 +23,7 @@ export default class MyDocument extends Document<DocumentProps> {
|
||||
const { css, hydrationScript } = this.props;
|
||||
|
||||
return (
|
||||
<html>
|
||||
<Html>
|
||||
<Head>
|
||||
<meta charSet="utf-8" />
|
||||
<meta
|
||||
@@ -63,7 +63,7 @@ export default class MyDocument extends Document<DocumentProps> {
|
||||
{hydrationScript}
|
||||
<NextScript />
|
||||
</body>
|
||||
</html>
|
||||
</Html>
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ import tailwindCss from "@utils/tailwindcss";
|
||||
|
||||
export default async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
try {
|
||||
const { tailwindConfig, postCssInput } = JSON.parse(req.body);
|
||||
const { tailwindConfig, postCssInput } = req.body;
|
||||
const css = await tailwindCss(tailwindConfig, postCssInput);
|
||||
res.status(200).send(css);
|
||||
} catch (e) {
|
||||
|
||||
@@ -4,7 +4,7 @@ import * as ts from "typescript";
|
||||
|
||||
export default (req: NextApiRequest, res: NextApiResponse) => {
|
||||
try {
|
||||
const { value, declarationOnly, isTS } = JSON.parse(req.body);
|
||||
const { value, declarationOnly, isTS } = req.body;
|
||||
|
||||
const tsCode = isTS ? value : convert(value);
|
||||
|
||||
|
||||
@@ -3,7 +3,8 @@ import html2pug from "html2pug";
|
||||
|
||||
export default (req: NextApiRequest, res: NextApiResponse) => {
|
||||
try {
|
||||
const { value, settings } = JSON.parse(req.body);
|
||||
const { value, settings } = req.body;
|
||||
|
||||
const result = html2pug(value, settings);
|
||||
res.status(200).send(result);
|
||||
} catch (e) {
|
||||
|
||||
@@ -4,7 +4,8 @@ import toOpenApi from "@openapi-contrib/json-schema-to-openapi-schema";
|
||||
export default async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
try {
|
||||
const jsonSchema = req.body;
|
||||
const openApiSchema = await toOpenApi(JSON.parse(jsonSchema), {
|
||||
|
||||
const openApiSchema = await toOpenApi(jsonSchema, {
|
||||
cloneSchema: true
|
||||
});
|
||||
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import PostCssWorker from "@workers/postcss.worker";
|
||||
import { useSettings } from "@hooks/useSettings";
|
||||
|
||||
let postCssWorker;
|
||||
export default function() {
|
||||
export default function CssToJs() {
|
||||
const name = "CSS to JS";
|
||||
|
||||
// TODO
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import ConversionPanel, { Transformer } from "@components/ConversionPanel";
|
||||
import NoSSR from "@components/NoSSR";
|
||||
import { editor } from "monaco-editor";
|
||||
import * as React from "react";
|
||||
import { useState, useCallback, useMemo } from "react";
|
||||
import request from "@utils/request";
|
||||
@@ -28,7 +27,7 @@ const Monaco = dynamic(() => import("../components/Monaco"), {
|
||||
ssr: false
|
||||
});
|
||||
|
||||
const options: editor.IEditorOptions = {
|
||||
const options = {
|
||||
fontSize: 14,
|
||||
readOnly: false,
|
||||
codeLens: false,
|
||||
@@ -207,7 +206,7 @@ ${selector} {
|
||||
return `/* ${success.length}/${results.length} base rules are converted successfully. */\n/* Gather results from the console with \`copy(window.cssToTailwindResults)\` */\n\n${content}`;
|
||||
}
|
||||
|
||||
export default function({ defaultSettings }) {
|
||||
export default function CssToTailwind({ defaultSettings }) {
|
||||
const [settings, setSettings] = useSettings(
|
||||
"css-to-tailwind",
|
||||
defaultSettings
|
||||
|
||||
@@ -4,7 +4,7 @@ import { useCallback } from "react";
|
||||
import request from "@utils/request";
|
||||
import { Alert } from "evergreen-ui";
|
||||
|
||||
export default function() {
|
||||
export default function FlowToTypescriptDeclaration() {
|
||||
const transformer = useCallback(
|
||||
({ value }) =>
|
||||
request("/api/flow-to-typescript", {
|
||||
|
||||
@@ -4,7 +4,7 @@ import { useCallback } from "react";
|
||||
import request from "@utils/request";
|
||||
import { Alert } from "evergreen-ui";
|
||||
|
||||
export default function() {
|
||||
export default function FlowToTypescript() {
|
||||
const transformer = useCallback(
|
||||
({ value }) =>
|
||||
request("/api/flow-to-typescript", {
|
||||
|
||||
@@ -12,7 +12,7 @@ const props = {
|
||||
acceptFiles: ".graphql, .gql"
|
||||
};
|
||||
|
||||
export default function() {
|
||||
export default function GraphqlToComponents() {
|
||||
const [output, setOutput] = useState(
|
||||
GraphqlTransforms.TO_REACT_APOLLO.toString(10)
|
||||
);
|
||||
|
||||
@@ -11,7 +11,7 @@ const props = {
|
||||
acceptFiles: ".graphql, .gql"
|
||||
};
|
||||
|
||||
export default function() {
|
||||
export default function GraphqlToFlow() {
|
||||
const transformer = useCallback<Transformer>(
|
||||
async ({ value, splitEditorValue }) => {
|
||||
graphqlWorker = graphqlWorker || getWorker(GrapqlWorker);
|
||||
|
||||
@@ -11,7 +11,7 @@ const props = {
|
||||
acceptFiles: ".graphql, .gql"
|
||||
};
|
||||
|
||||
export default function() {
|
||||
export default function GraphqlToFragmentMatcher() {
|
||||
const transformer = useCallback<Transformer>(async ({ value }) => {
|
||||
graphqlWorker = graphqlWorker || getWorker(GrapqlWorker);
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ const props = {
|
||||
acceptFiles: ".graphql, .gql"
|
||||
};
|
||||
|
||||
export default function() {
|
||||
export default function GraphqlToIntrospectionJson() {
|
||||
const transformer = useCallback<Transformer>(async ({ value }) => {
|
||||
graphqlWorker = graphqlWorker || getWorker(GrapqlWorker);
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ const props = {
|
||||
acceptFiles: ".graphql, .gql"
|
||||
};
|
||||
|
||||
export default function() {
|
||||
export default function GraphqlToJava() {
|
||||
const transformer = useCallback<Transformer>(async ({ value }) => {
|
||||
graphqlWorker = graphqlWorker || getWorker(GrapqlWorker);
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ const langMap = {
|
||||
[GraphqlTransforms.TO_JAVA_RESOLVERS_SIGNATURE]: "java"
|
||||
};
|
||||
|
||||
export default function() {
|
||||
export default function GraphqlToResolversSignature() {
|
||||
const [output, setOutput] = useState(
|
||||
GraphqlTransforms.TO_TYPESCRIPT_RESOLVERS_SIGNATURE.toString(10)
|
||||
);
|
||||
|
||||
@@ -11,7 +11,7 @@ const props = {
|
||||
acceptFiles: ".graphql, .gql"
|
||||
};
|
||||
|
||||
export default function() {
|
||||
export default function GraphqlToSchemaAst() {
|
||||
const transformer = useCallback<Transformer>(async ({ value }) => {
|
||||
graphqlWorker = graphqlWorker || getWorker(GrapqlWorker);
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ const props = {
|
||||
acceptFiles: ".graphql, .gql"
|
||||
};
|
||||
|
||||
export default function() {
|
||||
export default function GraphqlToTypescriptMongodb() {
|
||||
const transformer = useCallback<Transformer>(async ({ value }) => {
|
||||
graphqlWorker = graphqlWorker || getWorker(GrapqlWorker);
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ const props = {
|
||||
acceptFiles: ".graphql, .gql"
|
||||
};
|
||||
|
||||
export default function() {
|
||||
export default function GraphqlToTypescript() {
|
||||
const transformer = useCallback<Transformer>(
|
||||
async ({ value, splitEditorValue }) => {
|
||||
graphqlWorker = graphqlWorker || getWorker(GrapqlWorker);
|
||||
|
||||
@@ -22,7 +22,7 @@ const formFields = [
|
||||
}
|
||||
];
|
||||
|
||||
export default function() {
|
||||
export default function HtmlToJsxComponent() {
|
||||
const name = "HTML to JSX";
|
||||
|
||||
const [settings, setSettings] = useSettings(name, {
|
||||
@@ -69,7 +69,7 @@ export default function() {
|
||||
<ConversionPanel
|
||||
transformer={transformer}
|
||||
editorTitle="HTML"
|
||||
resultLanguage={settings.createFunction ? "javascript" : "text"}
|
||||
resultLanguage={"javascript"}
|
||||
resultTitle="JSX"
|
||||
editorLanguage="html"
|
||||
editorSettingsElement={getSettingsElement}
|
||||
|
||||
@@ -35,7 +35,7 @@ const defaultSettings = {
|
||||
fragment: false
|
||||
};
|
||||
|
||||
export default function() {
|
||||
export default function HtmlToPug() {
|
||||
const name = "HTML to Pug";
|
||||
|
||||
const [settings, setSettings] = useSettings(name, defaultSettings);
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ import SvgrWorker from "@workers/svgr.worker";
|
||||
import SvgoWorker from "@workers/svgo.worker";
|
||||
|
||||
let prettier, svgo, svgr;
|
||||
export default function() {
|
||||
export default function Index() {
|
||||
const name = "SVG to JSX";
|
||||
const [settings, setSettings] = useState(defaultSettings);
|
||||
const [optimizedValue, setOptimizedValue] = useState("");
|
||||
|
||||
@@ -2,7 +2,7 @@ import ConversionPanel from "@components/ConversionPanel";
|
||||
import { useCallback } from "react";
|
||||
import * as React from "react";
|
||||
|
||||
export default function() {
|
||||
export default function JsObjectToJson() {
|
||||
const transformer = useCallback(async ({ value }) => {
|
||||
return JSON.stringify(eval("(" + value + ")"), null, 2);
|
||||
}, []);
|
||||
|
||||
@@ -4,11 +4,14 @@ import { useCallback } from "react";
|
||||
import request from "@utils/request";
|
||||
import { Alert } from "evergreen-ui";
|
||||
|
||||
export default function() {
|
||||
const transformer = useCallback(
|
||||
({ value }) => request("/api/json-schema-to-openapi-schema", value),
|
||||
[]
|
||||
);
|
||||
export default function JsonSchemaToOpenapiSchema() {
|
||||
const transformer = useCallback(async ({ value }) => {
|
||||
const json = await request(
|
||||
"/api/json-schema-to-openapi-schema",
|
||||
JSON.parse(value)
|
||||
);
|
||||
return JSON.stringify(json, null, 2);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<ConversionPanel
|
||||
|
||||
@@ -3,7 +3,7 @@ import * as React from "react";
|
||||
import { useCallback } from "react";
|
||||
import convert from "jsonschema-protobuf";
|
||||
|
||||
export default function() {
|
||||
export default function JsonSchemaToProtobuf() {
|
||||
const transformer = useCallback<Transformer>(
|
||||
async ({ value }) => convert(value),
|
||||
[]
|
||||
|
||||
@@ -3,7 +3,7 @@ import * as React from "react";
|
||||
import { useCallback } from "react";
|
||||
import { compile } from "json-schema-to-typescript";
|
||||
|
||||
export default function() {
|
||||
export default function JsonSchemaToTypescript() {
|
||||
const transformer = useCallback(async ({ value }) => {
|
||||
return compile(JSON.parse(value), "MySchema", {
|
||||
bannerComment: ""
|
||||
|
||||
@@ -3,7 +3,7 @@ import { useCallback } from "react";
|
||||
import * as React from "react";
|
||||
import gs from "generate-schema";
|
||||
|
||||
export default function() {
|
||||
export default function JsonToBigQuery() {
|
||||
const transformer = useCallback(async ({ value }) => {
|
||||
return JSON.stringify(gs.bigquery(JSON.parse(value)), null, 2);
|
||||
}, []);
|
||||
|
||||
@@ -31,7 +31,7 @@ const defaultSettings = {
|
||||
rootName: "RootObject"
|
||||
};
|
||||
|
||||
export default function() {
|
||||
export default function JsonToFlow() {
|
||||
const name = "json-to-flow";
|
||||
|
||||
const [settings, setSettings] = useSettings(name, defaultSettings);
|
||||
|
||||
@@ -2,7 +2,7 @@ import ConversionPanel, { Transformer } from "@components/ConversionPanel";
|
||||
import * as React from "react";
|
||||
import { useCallback } from "react";
|
||||
|
||||
export default function() {
|
||||
export default function JsonToGoBson() {
|
||||
const transformer = useCallback<Transformer>(async ({ value }) => {
|
||||
return JSON.stringify(JSON.parse(value || "{}"), null, 2)
|
||||
.replace(/\{/gm, "bson.M{")
|
||||
|
||||
@@ -4,7 +4,7 @@ import * as React from "react";
|
||||
import jsonToGo from "json-to-go";
|
||||
import gofmt from "gofmt.js";
|
||||
|
||||
export default function() {
|
||||
export default function JsonToGo() {
|
||||
const transformer = useCallback(({ value }) => {
|
||||
return gofmt(jsonToGo(value).go);
|
||||
}, []);
|
||||
|
||||
@@ -3,7 +3,7 @@ import { useCallback } from "react";
|
||||
import * as React from "react";
|
||||
import { jsonToSchema } from "@walmartlabs/json-to-simple-graphql-schema/lib";
|
||||
|
||||
export default function() {
|
||||
export default function JsonToGraphql() {
|
||||
const transformer = useCallback(({ value }) => {
|
||||
return jsonToSchema({ jsonInput: value }).value;
|
||||
}, []);
|
||||
|
||||
@@ -3,7 +3,7 @@ import ConversionPanel, { Transformer } from "@components/ConversionPanel";
|
||||
import * as React from "react";
|
||||
import { useCallback } from "react";
|
||||
|
||||
export default function() {
|
||||
export default function JsonToIoTs() {
|
||||
const transformer = useCallback<Transformer>(async ({ value }) => {
|
||||
const code = transform(value, {
|
||||
lang: "io-ts"
|
||||
|
||||
@@ -3,7 +3,7 @@ import * as React from "react";
|
||||
import { useCallback } from "react";
|
||||
import { convert } from "@assets/vendor/json-to-jsdoc";
|
||||
|
||||
export default function() {
|
||||
export default function JsonToJsdoc() {
|
||||
const transformer = useCallback<Transformer>(async ({ value }) => {
|
||||
return convert(value);
|
||||
}, []);
|
||||
|
||||
@@ -2,7 +2,7 @@ import ConversionPanel from "@components/ConversionPanel";
|
||||
import * as React from "react";
|
||||
import { useCallback } from "react";
|
||||
|
||||
export default function() {
|
||||
export default function JsonToJsonSchema() {
|
||||
const transformer = useCallback(async ({ value }) => {
|
||||
const { run } = await import("json_typegen_wasm");
|
||||
return run(
|
||||
|
||||
@@ -2,7 +2,7 @@ import ConversionPanel from "@components/ConversionPanel";
|
||||
import * as React from "react";
|
||||
import { useCallback } from "react";
|
||||
|
||||
export default function() {
|
||||
export default function JsonToKotlin() {
|
||||
const transformer = useCallback(async ({ value }) => {
|
||||
const { run } = await import("json_typegen_wasm");
|
||||
return run(
|
||||
|
||||
@@ -6,7 +6,7 @@ import { getWorker } from "@utils/workerWrapper";
|
||||
import { BabelTransforms } from "@constants/babelTransforms";
|
||||
|
||||
let babelWorker;
|
||||
export default function() {
|
||||
export default function JsonToMobxStateTree() {
|
||||
const transformer = useCallback(async ({ value }) => {
|
||||
babelWorker = babelWorker || getWorker(BabelWorker);
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import { useCallback } from "react";
|
||||
import * as React from "react";
|
||||
import gs from "generate-schema";
|
||||
|
||||
export default function() {
|
||||
export default function JsonToMongoose() {
|
||||
const transformer = useCallback(async ({ value }) => {
|
||||
return JSON.stringify(gs.mongoose(JSON.parse(value)), null, 2);
|
||||
}, []);
|
||||
|
||||
@@ -3,7 +3,7 @@ import { useCallback } from "react";
|
||||
import * as React from "react";
|
||||
import gs from "generate-schema";
|
||||
|
||||
export default function() {
|
||||
export default function JsonToMysql() {
|
||||
const transformer = useCallback(({ value }) => {
|
||||
return gs.mysql(JSON.parse(value));
|
||||
}, []);
|
||||
|
||||
@@ -4,7 +4,7 @@ import ConversionPanel, { Transformer } from "@components/ConversionPanel";
|
||||
import { getWorker } from "@utils/workerWrapper";
|
||||
import { BabelTransforms } from "@constants/babelTransforms";
|
||||
|
||||
export default function() {
|
||||
export default function JsonToProptypes() {
|
||||
const transformer = useCallback<Transformer>(async ({ value }) => {
|
||||
const Worker = require("@workers/babel.worker");
|
||||
return getWorker(Worker).send({
|
||||
|
||||
@@ -30,7 +30,7 @@ const defaultSettings = {
|
||||
property_name_format: "camelCase"
|
||||
};
|
||||
|
||||
export default function() {
|
||||
export default function JsonToRustSerde() {
|
||||
const name = "json-to-rust-serde";
|
||||
|
||||
const [settings, setSettings] = useSettings(name, defaultSettings);
|
||||
|
||||
@@ -3,7 +3,7 @@ import ConversionPanel, { Transformer } from "@components/ConversionPanel";
|
||||
import * as React from "react";
|
||||
import { useCallback } from "react";
|
||||
|
||||
export default function() {
|
||||
export default function JsonToSarcastic() {
|
||||
const transformer = useCallback<Transformer>(async ({ value }) => {
|
||||
const code = transform(value, {
|
||||
lang: "sarcastic"
|
||||
|
||||
@@ -3,7 +3,7 @@ import ConversionPanel, { Transformer } from "@components/ConversionPanel";
|
||||
import * as React from "react";
|
||||
import { useCallback } from "react";
|
||||
|
||||
export default function() {
|
||||
export default function JsonToScalaCaseClass() {
|
||||
const transformer = useCallback<Transformer>(async ({ value }) => {
|
||||
return transform(value, {
|
||||
lang: "scala"
|
||||
|
||||
@@ -2,7 +2,7 @@ import ConversionPanel from "@components/ConversionPanel";
|
||||
import * as React from "react";
|
||||
import { useCallback } from "react";
|
||||
|
||||
export default function() {
|
||||
export default function JsonToTypescript() {
|
||||
const transformer = useCallback(async ({ value }) => {
|
||||
const { run } = await import("json_typegen_wasm");
|
||||
return run(
|
||||
|
||||
@@ -3,7 +3,7 @@ import { useCallback } from "react";
|
||||
import * as React from "react";
|
||||
import { stringify } from "yaml";
|
||||
|
||||
export default function() {
|
||||
export default function JsonToYaml() {
|
||||
const transformer = useCallback(
|
||||
({ value }) => Promise.resolve(stringify(JSON.parse(value))),
|
||||
[]
|
||||
|
||||
@@ -3,7 +3,7 @@ import { useCallback } from "react";
|
||||
import * as React from "react";
|
||||
import { compact } from "jsonld";
|
||||
|
||||
export default function() {
|
||||
export default function JsonldToCompacted() {
|
||||
const transformer = useCallback<Transformer>(
|
||||
async ({ value, splitEditorValue }) => {
|
||||
const jsonLd = await compact(
|
||||
|
||||
@@ -3,7 +3,7 @@ import { useCallback } from "react";
|
||||
import * as React from "react";
|
||||
import { expand } from "jsonld";
|
||||
|
||||
export default function() {
|
||||
export default function JsonldToExpanded() {
|
||||
const transformer = useCallback(async ({ value }) => {
|
||||
const jsonLd = await expand(JSON.parse(value));
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import { useCallback } from "react";
|
||||
import * as React from "react";
|
||||
import { flatten } from "jsonld";
|
||||
|
||||
export default function() {
|
||||
export default function JsonldToFlattened() {
|
||||
const transformer = useCallback<Transformer>(
|
||||
async ({ value, splitEditorValue }) => {
|
||||
const jsonLd = await flatten(
|
||||
|
||||
@@ -3,7 +3,7 @@ import { useCallback } from "react";
|
||||
import * as React from "react";
|
||||
import { frame } from "jsonld";
|
||||
|
||||
export default function() {
|
||||
export default function JsonldToFramed() {
|
||||
const transformer = useCallback<Transformer>(
|
||||
async ({ value, splitEditorValue }) => {
|
||||
const jsonLd = await frame(
|
||||
|
||||
@@ -3,7 +3,7 @@ import { useCallback } from "react";
|
||||
import * as React from "react";
|
||||
import { normalize } from "jsonld";
|
||||
|
||||
export default function() {
|
||||
export default function JsonldToNormalized() {
|
||||
const transformer = useCallback(async ({ value }) => {
|
||||
return normalize(JSON.parse(value));
|
||||
}, []);
|
||||
|
||||
@@ -3,7 +3,7 @@ import { useCallback } from "react";
|
||||
import * as React from "react";
|
||||
import { toRDF } from "jsonld";
|
||||
|
||||
export default function() {
|
||||
export default function JsonldToNquads() {
|
||||
const transformer = useCallback(async ({ value }) => {
|
||||
return (toRDF(JSON.parse(value), {
|
||||
format: "application/n-quads"
|
||||
|
||||
@@ -3,7 +3,7 @@ import { useCallback } from "react";
|
||||
import * as React from "react";
|
||||
import { markdown } from "markdown";
|
||||
|
||||
export default function() {
|
||||
export default function MarkdownToHtml() {
|
||||
const transformer = useCallback(({ value }) => {
|
||||
return markdown.toHTML(value);
|
||||
}, []);
|
||||
|
||||
@@ -27,7 +27,7 @@ const formFields = [
|
||||
];
|
||||
|
||||
let babelWorker;
|
||||
export default function() {
|
||||
export default function ObjectStylesToTemplateLiteral() {
|
||||
const name = "object-styles-to-template-literal";
|
||||
const [settings, setSettings] = useSettings(name, {
|
||||
css: true,
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import * as React from "react";
|
||||
import BabelWorker from "@workers/babel.worker";
|
||||
import { SvgConverter } from "@components/SvgConverter";
|
||||
import { useCallback, useEffect, useRef, useState } from "react";
|
||||
import QRCode from "qrcode.react";
|
||||
import { Pane, Heading, Link } from "evergreen-ui";
|
||||
import { useCallback, useState } from "react";
|
||||
import {
|
||||
defaultNativeSettings,
|
||||
formFields,
|
||||
@@ -15,48 +13,11 @@ import SvgoWorker from "@workers/svgo.worker";
|
||||
import { Transformer } from "@components/ConversionPanel";
|
||||
import SvgrWorker from "@workers/svgr.worker";
|
||||
|
||||
let SnackSession;
|
||||
if (IN_BROWSER) {
|
||||
SnackSession = require("@assets/vendor/snack-sdk").SnackSession;
|
||||
}
|
||||
|
||||
let svgo, _babelWorker, svgr;
|
||||
export default function() {
|
||||
export default function SvgToReactNative() {
|
||||
const name = "SVG to React Native";
|
||||
const [value, setValue] = useState("");
|
||||
const [url, setUrl] = useState("");
|
||||
const [settings, setSettings] = useState(defaultNativeSettings);
|
||||
const [optimizedValue, setOptimizedValue] = useState("");
|
||||
const snackSession = useRef<any>();
|
||||
|
||||
useEffect(() => {
|
||||
(async function() {
|
||||
snackSession.current = new SnackSession({
|
||||
files: { "App.js": { contents: "", type: "CODE" } },
|
||||
sessionId: Math.random()
|
||||
.toString(36)
|
||||
.substr(2, 8),
|
||||
sdkVersion: "37.0.0"
|
||||
});
|
||||
|
||||
snackSession.current.startAsync();
|
||||
await snackSession.current.addModuleAsync("react-native-svg", "12.x.x");
|
||||
const url = await snackSession.current.getUrlAsync();
|
||||
setUrl(url);
|
||||
})();
|
||||
|
||||
return () => {
|
||||
snackSession.current && snackSession.current.stopAsync();
|
||||
};
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
(async function() {
|
||||
await snackSession.current.sendCodeAsync({
|
||||
"App.js": { contents: value, type: "CODE" }
|
||||
});
|
||||
})();
|
||||
}, [value]);
|
||||
|
||||
const transformer = useCallback<Transformer>(
|
||||
async ({ value }) => {
|
||||
@@ -83,8 +44,6 @@ export default function() {
|
||||
value: _value
|
||||
});
|
||||
|
||||
setValue(_value);
|
||||
|
||||
return _value;
|
||||
},
|
||||
[settings]
|
||||
@@ -102,34 +61,6 @@ export default function() {
|
||||
formFields={formFields(defaultNativeSettings)}
|
||||
optimizedValue={optimizedValue}
|
||||
/>
|
||||
|
||||
{url && (
|
||||
<Pane
|
||||
display={"flex"}
|
||||
flexDirection="column"
|
||||
padding={10}
|
||||
position="absolute"
|
||||
backgroundColor="#fff"
|
||||
elevation={2}
|
||||
right={20}
|
||||
bottom={20}
|
||||
borderRadius={2}
|
||||
>
|
||||
<QRCode value={url} />
|
||||
<Heading size={400} marginTop={10}>
|
||||
Scan on{" "}
|
||||
<Link
|
||||
is="a"
|
||||
href="https://expo.io/tools#client"
|
||||
size={400}
|
||||
target="_blank"
|
||||
>
|
||||
expo
|
||||
</Link>{" "}
|
||||
app.
|
||||
</Heading>
|
||||
</Pane>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import { useCallback } from "react";
|
||||
import request from "@utils/request";
|
||||
import { Alert } from "evergreen-ui";
|
||||
|
||||
export default function() {
|
||||
export default function TypescriptToFlow() {
|
||||
const transformer = useCallback(
|
||||
({ value }) => request("/api/typescript-to-flow", value),
|
||||
[]
|
||||
|
||||
@@ -4,11 +4,15 @@ import { useCallback } from "react";
|
||||
import request from "@utils/request";
|
||||
import { Alert } from "evergreen-ui";
|
||||
|
||||
export default function() {
|
||||
const transformer = useCallback(
|
||||
({ value }) => request("/api/typescript-to-json-schema", value),
|
||||
[]
|
||||
);
|
||||
export default function TypescriptToJsonSchema() {
|
||||
const transformer = useCallback(async ({ value }) => {
|
||||
const x = await request(
|
||||
"/api/typescript-to-json-schema",
|
||||
value,
|
||||
"text/plain"
|
||||
);
|
||||
return JSON.stringify(x, null, 2);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<ConversionPanel
|
||||
|
||||
@@ -4,7 +4,7 @@ import { useCallback } from "react";
|
||||
import request from "@utils/request";
|
||||
import { Alert } from "evergreen-ui";
|
||||
|
||||
export default function() {
|
||||
export default function TypescriptToTypescriptDeclaration() {
|
||||
const transformer = useCallback(
|
||||
({ value }) =>
|
||||
request("/api/flow-to-typescript", {
|
||||
|
||||
@@ -3,7 +3,7 @@ import { useCallback } from "react";
|
||||
import * as React from "react";
|
||||
import { xml2json } from "xml-js";
|
||||
|
||||
export default function() {
|
||||
export default function XmlToJson() {
|
||||
const transformer = useCallback(async ({ value }) => {
|
||||
return JSON.stringify(
|
||||
JSON.parse(
|
||||
|
||||
@@ -3,7 +3,7 @@ import { useCallback } from "react";
|
||||
import * as React from "react";
|
||||
import yaml from "yaml";
|
||||
|
||||
export default function() {
|
||||
export default function YamlToJson() {
|
||||
const transformer = useCallback(async ({ value }) => {
|
||||
return JSON.stringify(yaml.parse(value));
|
||||
}, []);
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
diff --git a/node_modules/worker-loader/dist/workers/InlineWorker.js b/node_modules/worker-loader/dist/workers/InlineWorker.js
|
||||
index b1e2185..384d1c6 100644
|
||||
--- a/node_modules/worker-loader/dist/workers/InlineWorker.js
|
||||
+++ b/node_modules/worker-loader/dist/workers/InlineWorker.js
|
||||
@@ -23,7 +23,12 @@ module.exports = function (content, url) {
|
||||
blob = new Blob([content]);
|
||||
}
|
||||
|
||||
- return new Worker(URL.createObjectURL(blob));
|
||||
+ var URL = window.URL || window.webkitURL;
|
||||
+ var objectURL = URL.createObjectURL(blob);
|
||||
+ var worker = new window.Worker(objectURL);
|
||||
+ URL.revokeObjectURL(objectURL);
|
||||
+
|
||||
+ return worker;
|
||||
} catch (e) {
|
||||
return new Worker('data:application/javascript,' + encodeURIComponent(content));
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
+17
-5
@@ -1,8 +1,20 @@
|
||||
export default async function request(url: string, data: any) {
|
||||
const res = await fetch(url, {
|
||||
method: "POST",
|
||||
body: typeof data === "object" ? JSON.stringify(data) : data
|
||||
import axios, { CancelTokenSource } from "axios";
|
||||
import { type } from "os";
|
||||
|
||||
let cancelTokenSource: CancelTokenSource;
|
||||
export default async function request(
|
||||
url: string,
|
||||
data: any,
|
||||
contentType = "application/json"
|
||||
) {
|
||||
if (cancelTokenSource) cancelTokenSource.cancel();
|
||||
cancelTokenSource = axios.CancelToken.source();
|
||||
|
||||
const res = await axios.post(url, data, {
|
||||
cancelToken: cancelTokenSource.token,
|
||||
headers: { "Content-Type": contentType }
|
||||
});
|
||||
|
||||
return await res.text();
|
||||
cancelTokenSource = null;
|
||||
return res.data;
|
||||
}
|
||||
-315
@@ -1,315 +0,0 @@
|
||||
import React from "react";
|
||||
import { editor } from "monaco-editor";
|
||||
|
||||
export const ThemeContext = React.createContext({
|
||||
theme: "light",
|
||||
toggleTheme: () => {}
|
||||
});
|
||||
|
||||
export const lightEditor: editor.IStandaloneThemeData = {
|
||||
base: "vs",
|
||||
inherit: true,
|
||||
rules: [
|
||||
{
|
||||
foreground: "940494",
|
||||
background: "444494",
|
||||
token: "punctuation.definition.list"
|
||||
},
|
||||
{
|
||||
foreground: "404f50",
|
||||
background: "5f0fff",
|
||||
fontStyle: "italic",
|
||||
token: "comment"
|
||||
},
|
||||
{
|
||||
foreground: "5a5f9b",
|
||||
background: "aaafdb",
|
||||
token: "string"
|
||||
},
|
||||
{
|
||||
foreground: "4f827b",
|
||||
background: "77c2bb",
|
||||
token: "constant.numeric"
|
||||
},
|
||||
{
|
||||
foreground: "025f69",
|
||||
background: "7f2299",
|
||||
token: "constant.character"
|
||||
},
|
||||
{
|
||||
foreground: "025f69",
|
||||
background: "7f2299",
|
||||
token: "constant.other"
|
||||
},
|
||||
{
|
||||
foreground: "7d7e52",
|
||||
background: "bdbe82",
|
||||
token: "constant.language"
|
||||
},
|
||||
{
|
||||
foreground: "7b5d8f",
|
||||
background: "9b9ffd",
|
||||
fontStyle: "bold",
|
||||
token: "storage.modifier"
|
||||
},
|
||||
{
|
||||
foreground: "7b5cbf",
|
||||
background: "8b5ddf",
|
||||
fontStyle: "bold",
|
||||
token: "storage"
|
||||
},
|
||||
{
|
||||
foreground: "025f49",
|
||||
background: "22ff49",
|
||||
token: "entity.name.function"
|
||||
},
|
||||
{
|
||||
foreground: "9d7e62",
|
||||
background: "bdbe82",
|
||||
token: "support.function"
|
||||
},
|
||||
{
|
||||
foreground: "939469",
|
||||
background: "e3e4a9",
|
||||
token: "entity.name.function.misc"
|
||||
},
|
||||
{
|
||||
foreground: "856f63",
|
||||
background: "a5df93",
|
||||
token: "entity.name.function.predicate"
|
||||
},
|
||||
{
|
||||
foreground: "af938c",
|
||||
background: "dfb3ac",
|
||||
token: "entity.name.function.io"
|
||||
},
|
||||
{
|
||||
foreground: "7bafad",
|
||||
background: "bbdfdd",
|
||||
token: "variable.other.external-symbol"
|
||||
},
|
||||
{
|
||||
foreground: "316fcf",
|
||||
background: "3aafff",
|
||||
token: "variable.language"
|
||||
},
|
||||
{
|
||||
foreground: "316fcf",
|
||||
background: "3aafff",
|
||||
token: "variable.other"
|
||||
},
|
||||
{
|
||||
foreground: "33969f",
|
||||
background: "05d6f9",
|
||||
fontStyle: "italic",
|
||||
token: "variable.parameter"
|
||||
},
|
||||
{
|
||||
foreground: "674aa8",
|
||||
background: "a3aad8",
|
||||
token: "keyword"
|
||||
},
|
||||
{
|
||||
foreground: "b9986f",
|
||||
background: "b998df",
|
||||
fontStyle: "bold",
|
||||
token: "entity.name.class"
|
||||
},
|
||||
{
|
||||
foreground: "22af9d",
|
||||
background: "b998df",
|
||||
token: "entity.name.structure"
|
||||
},
|
||||
{
|
||||
foreground: "af47a9",
|
||||
background: "af77a9",
|
||||
token: "entity.name.type"
|
||||
},
|
||||
{
|
||||
foreground: "cc4357",
|
||||
background: "ffddff",
|
||||
token: "entity.name.class"
|
||||
},
|
||||
{
|
||||
foreground: "cc4357",
|
||||
background: "ffddff",
|
||||
token: "entity.name.type.class"
|
||||
},
|
||||
{
|
||||
foreground: "ef6aa7",
|
||||
background: "ef6aa7",
|
||||
token: "support.class"
|
||||
},
|
||||
{
|
||||
foreground: "dfdfd5",
|
||||
background: "cc1b27",
|
||||
token: "invalid"
|
||||
},
|
||||
{
|
||||
foreground: "13499f",
|
||||
background: "0099ff",
|
||||
fontStyle: "italic",
|
||||
token: "string source"
|
||||
},
|
||||
{
|
||||
foreground: "3976a2",
|
||||
background: "49a6d2",
|
||||
token: "entity.name.tag"
|
||||
},
|
||||
{
|
||||
foreground: "4946c2",
|
||||
background: "4986c2",
|
||||
token: "entity.other.attribute-name"
|
||||
}
|
||||
],
|
||||
colors: {
|
||||
"editor.foreground": "#0f0009",
|
||||
"editor.background": "#f9f8f9",
|
||||
"editor.selectionBackground": "#BAD6FD",
|
||||
"editor.lineHighlightBackground": "#ffffff",
|
||||
"editorCursor.foreground": "#100011",
|
||||
"editorWhitespace.foreground": "#000000",
|
||||
"editor.selectionHighlightBorder": "#B3B3B3"
|
||||
}
|
||||
};
|
||||
|
||||
export const darkEditor: editor.IStandaloneThemeData = {
|
||||
base: "vs-dark",
|
||||
inherit: true,
|
||||
rules: [
|
||||
{
|
||||
foreground: "75715e",
|
||||
token: "comment"
|
||||
},
|
||||
{
|
||||
foreground: "e6db74",
|
||||
token: "string"
|
||||
},
|
||||
{
|
||||
foreground: "ae81ff",
|
||||
token: "constant.numeric"
|
||||
},
|
||||
{
|
||||
foreground: "ae81ff",
|
||||
token: "constant.language"
|
||||
},
|
||||
{
|
||||
foreground: "ae81ff",
|
||||
token: "constant.character"
|
||||
},
|
||||
{
|
||||
foreground: "ae81ff",
|
||||
token: "constant.other"
|
||||
},
|
||||
{
|
||||
foreground: "f92672",
|
||||
token: "keyword"
|
||||
},
|
||||
{
|
||||
foreground: "f92672",
|
||||
token: "storage"
|
||||
},
|
||||
{
|
||||
foreground: "66d9ef",
|
||||
fontStyle: "italic",
|
||||
token: "storage.type"
|
||||
},
|
||||
{
|
||||
foreground: "a6e22e",
|
||||
fontStyle: "underline",
|
||||
token: "entity.name.class"
|
||||
},
|
||||
{
|
||||
foreground: "a6e22e",
|
||||
fontStyle: "italic underline",
|
||||
token: "entity.other.inherited-class"
|
||||
},
|
||||
{
|
||||
foreground: "a6e22e",
|
||||
token: "entity.name.function"
|
||||
},
|
||||
{
|
||||
foreground: "fd971f",
|
||||
fontStyle: "italic",
|
||||
token: "variable.parameter"
|
||||
},
|
||||
{
|
||||
foreground: "f92672",
|
||||
token: "entity.name.tag"
|
||||
},
|
||||
{
|
||||
foreground: "a6e22e",
|
||||
token: "entity.other.attribute-name"
|
||||
},
|
||||
{
|
||||
foreground: "66d9ef",
|
||||
token: "support.function"
|
||||
},
|
||||
{
|
||||
foreground: "66d9ef",
|
||||
token: "support.constant"
|
||||
},
|
||||
{
|
||||
foreground: "66d9ef",
|
||||
fontStyle: "italic",
|
||||
token: "support.type"
|
||||
},
|
||||
{
|
||||
foreground: "66d9ef",
|
||||
fontStyle: "italic",
|
||||
token: "support.class"
|
||||
},
|
||||
{
|
||||
foreground: "f8f8f0",
|
||||
background: "f92672",
|
||||
token: "invalid"
|
||||
},
|
||||
{
|
||||
foreground: "f8f8f0",
|
||||
background: "ae81ff",
|
||||
token: "invalid.deprecated"
|
||||
},
|
||||
{
|
||||
foreground: "cfcfc2",
|
||||
token: "meta.structure.dictionary.json string.quoted.double.json"
|
||||
},
|
||||
{
|
||||
foreground: "75715e",
|
||||
token: "meta.diff"
|
||||
},
|
||||
{
|
||||
foreground: "75715e",
|
||||
token: "meta.diff.header"
|
||||
},
|
||||
{
|
||||
foreground: "f92672",
|
||||
token: "markup.deleted"
|
||||
},
|
||||
{
|
||||
foreground: "a6e22e",
|
||||
token: "markup.inserted"
|
||||
},
|
||||
{
|
||||
foreground: "e6db74",
|
||||
token: "markup.changed"
|
||||
},
|
||||
{
|
||||
foreground: "ae81ff",
|
||||
token: "constant.numeric.line-number.find-in-files - match"
|
||||
},
|
||||
{
|
||||
foreground: "e6db74",
|
||||
token: "entity.name.filename.find-in-files"
|
||||
}
|
||||
],
|
||||
colors: {
|
||||
"editor.foreground": "#F8F8F2",
|
||||
"editor.background": "#272822",
|
||||
"editor.selectionBackground": "#49483E",
|
||||
"editor.lineHighlightBackground": "#3E3D32",
|
||||
"editorCursor.foreground": "#F8F8F0",
|
||||
"editorWhitespace.foreground": "#3B3A32",
|
||||
"editorIndentGuide.activeBackground": "#9D550F",
|
||||
"editor.selectionHighlightBorder": "#222218"
|
||||
}
|
||||
};
|
||||
Reference in new issue
Block a user