From 10f56e44f5fd2aa1f779ec0e5326c30e06ae4ce0 Mon Sep 17 00:00:00 2001 From: Zane Starr Date: Thu, 19 Dec 2024 17:24:24 -0800 Subject: [PATCH] fix: wip everything builds properly --- .gitignore | 1 + package-lock.json | 55 ++++++++----- package.json | 2 +- packages/docs-react/package.json | 1 + packages/inspector/package.json | 4 +- packages/inspector/src/index.tsx | 7 +- packages/inspector/tsconfig.json | 3 +- packages/logs-react/package.json | 12 +-- packages/logs-react/src/exports.ts | 5 +- packages/logs-react/src/index.tsx | 17 +++- packages/logs-react/src/react-app-env.d.ts | 1 - packages/logs-react/tsconfig.json | 8 +- packages/monaco-editor-react/.editorconfig | 14 ++++ packages/monaco-editor-react/.gitignore | 4 + packages/monaco-editor-react/.nvmrc | 1 + packages/monaco-editor-react/.releaserc | 3 + packages/monaco-editor-react/README.md | 63 +++++++++++++++ packages/monaco-editor-react/jest.config.js | 9 +++ packages/monaco-editor-react/package.json | 42 ++++++++++ .../src/MonacoContainer.tsx | 39 ++++++++++ .../monaco-editor-react/src/MonacoEditor.tsx | 77 +++++++++++++++++++ packages/monaco-editor-react/src/index.ts | 2 + packages/monaco-editor-react/tsconfig.json | 9 +++ packages/monaco-editor-react/tslint.json | 11 +++ packages/playground/package.json | 9 ++- packages/playground/src/OpenRPCEditor.tsx | 2 +- packages/playground/tsconfig.json | 3 +- packages/playground/vite.config.ts | 28 +++++-- tsconfig.json | 4 +- turbo.json | 4 +- 30 files changed, 388 insertions(+), 52 deletions(-) delete mode 100644 packages/logs-react/src/react-app-env.d.ts create mode 100644 packages/monaco-editor-react/.editorconfig create mode 100644 packages/monaco-editor-react/.gitignore create mode 100644 packages/monaco-editor-react/.nvmrc create mode 100644 packages/monaco-editor-react/.releaserc create mode 100644 packages/monaco-editor-react/README.md create mode 100644 packages/monaco-editor-react/jest.config.js create mode 100644 packages/monaco-editor-react/package.json create mode 100644 packages/monaco-editor-react/src/MonacoContainer.tsx create mode 100644 packages/monaco-editor-react/src/MonacoEditor.tsx create mode 100644 packages/monaco-editor-react/src/index.ts create mode 100644 packages/monaco-editor-react/tsconfig.json create mode 100644 packages/monaco-editor-react/tslint.json diff --git a/.gitignore b/.gitignore index 8083453..0dea73b 100755 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ LLMLOG.md .turbo/ **/*/.turbo tsconfig.tsbuildinfo +dist/ diff --git a/package-lock.json b/package-lock.json index b916330..fb9934a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4436,6 +4436,10 @@ "integrity": "sha512-2/CbDzOVpcaSnMs28TsRv8MKJwJi0TTYFlQ6q6qobAH26oIuhYgcZooKf4l71emgntU6MMcFQCA0h4mJ4dBCdA==", "license": "Apache-2.0" }, + "node_modules/@open-rpc/monaco-editor-react": { + "resolved": "packages/monaco-editor-react", + "link": true + }, "node_modules/@open-rpc/playground": { "resolved": "packages/playground", "link": true @@ -23594,6 +23598,7 @@ }, "node_modules/npm/node_modules/lodash._baseindexof": { "version": "3.1.0", + "extraneous": true, "inBundle": true, "license": "MIT" }, @@ -23608,16 +23613,19 @@ }, "node_modules/npm/node_modules/lodash._bindcallback": { "version": "3.0.1", + "extraneous": true, "inBundle": true, "license": "MIT" }, "node_modules/npm/node_modules/lodash._cacheindexof": { "version": "3.0.2", + "extraneous": true, "inBundle": true, "license": "MIT" }, "node_modules/npm/node_modules/lodash._createcache": { "version": "3.1.2", + "extraneous": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -23631,6 +23639,7 @@ }, "node_modules/npm/node_modules/lodash._getnative": { "version": "3.9.1", + "extraneous": true, "inBundle": true, "license": "MIT" }, @@ -23646,6 +23655,7 @@ }, "node_modules/npm/node_modules/lodash.restparam": { "version": "3.6.1", + "extraneous": true, "inBundle": true, "license": "MIT" }, @@ -38555,6 +38565,29 @@ "monaco-editor": ">=0.33.0" } }, + "packages/monaco-editor-react": { + "name": "@open-rpc/monaco-editor-react", + "version": "0.0.0-development", + "license": "Apache-2.0", + "dependencies": { + "@material-ui/core": "^4.7.2", + "monaco-editor": "0.52.2", + "react": "^16.12.0" + }, + "devDependencies": { + "eslint": "^8.0.0", + "typescript": "^5.0.0" + }, + "engines": { + "node": ">=18.20.5" + } + }, + "packages/monaco-editor-react/node_modules/monaco-editor": { + "version": "0.52.2", + "resolved": "https://registry.npmjs.org/monaco-editor/-/monaco-editor-0.52.2.tgz", + "integrity": "sha512-GEQWEZmfkOGLdd3XK8ryrfWz3AIP8YymVXiPHEdewrUq7mh0qrKrfHLNCXcbB6sTnMLnOZ3ztSiKcciFUkIJwQ==", + "license": "MIT" + }, "packages/playground": { "name": "@open-rpc/playground", "version": "0.0.0-development", @@ -38567,6 +38600,7 @@ "@open-rpc/examples": "^1.3.3", "@open-rpc/inspector": "*", "@open-rpc/meta-schema": "^1.14.9", + "@open-rpc/monaco-editor-react": "*", "@open-rpc/schema-utils-js": "^1.14.3", "@use-it/interval": "^0.1.3", "ajv": "^6.10.0", @@ -38602,8 +38636,7 @@ "@vitejs/plugin-react": "^4.2.1", "css-mediaquery": "^0.1.2", "eslint": "^6.6.0", - "vite": "^5.1.4", - "vite-plugin-monaco-editor": "^1.1.0" + "vite": "^5.1.4" }, "engines": { "node": ">=18.20.5" @@ -39112,14 +39145,6 @@ "node": ">=6" } }, - "packages/playground/node_modules/monaco-editor": { - "version": "0.52.0", - "resolved": "https://registry.npmjs.org/monaco-editor/-/monaco-editor-0.52.0.tgz", - "integrity": "sha512-OeWhNpABLCeTqubfqLMXGsqf6OmPU6pHM85kF3dhy6kq5hnhuVS1p3VrEW/XhWHc71P2tHyS5JFySD8mgs1crw==", - "dev": true, - "license": "MIT", - "peer": true - }, "packages/playground/node_modules/mute-stream": { "version": "0.0.8", "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.8.tgz", @@ -39377,16 +39402,6 @@ "optional": true } } - }, - "packages/playground/node_modules/vite-plugin-monaco-editor": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/vite-plugin-monaco-editor/-/vite-plugin-monaco-editor-1.1.0.tgz", - "integrity": "sha512-IvtUqZotrRoVqwT0PBBDIZPNraya3BxN/bfcNfnxZ5rkJiGcNtO5eAOWWSgT7zullIAEqQwxMU83yL9J5k7gww==", - "dev": true, - "license": "MIT", - "peerDependencies": { - "monaco-editor": ">=0.33.0" - } } } } diff --git a/package.json b/package.json index 197ce3f..c7e7bb6 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "main": "jest.config.js", "scripts": { "build": "turbo run build", - "build:package": "turbo run build:package --filter=@open-rpc/logs-react^... --filter=@open-rpc/inspector^...", + "build:package": "turbo run build:package --filter=@open-rpc/monaco-editor-react --filter=@open-rpc/docs-react --filter=@open-rpc/logs-react --filter=@open-rpc/inspector --filter=@open-rpc/playground", "test": "turbo run test", "lint": "turbo run lint", "watch": "turbo run build test --watch", diff --git a/packages/docs-react/package.json b/packages/docs-react/package.json index 55ed3ab..3d6b582 100644 --- a/packages/docs-react/package.json +++ b/packages/docs-react/package.json @@ -15,6 +15,7 @@ "scripts": { "lint": "eslint 'src/**/*.{ts,tsx}'", "build": "tsc --project tsconfig.json && cp src/ContentDescriptor/ContentDescriptor.css build/ContentDescriptor/", + "build:package": "tsc --build tsconfig.json && cp src/ContentDescriptor/ContentDescriptor.css build/ContentDescriptor/", "test": "jest", "start": "react-scripts start", "clean": "rm -rf build coverage", diff --git a/packages/inspector/package.json b/packages/inspector/package.json index df88ab6..5e4f2f7 100644 --- a/packages/inspector/package.json +++ b/packages/inspector/package.json @@ -22,7 +22,7 @@ "build": "rescripts build", "lint": "eslint 'src/**/*.{ts,tsx}'", "test": "jest", - "build:package": "tsc --build tsconfig.json", + "build:package": "tsc --build tsconfig.json && cp -r src/*.css build/", "clean": "rm -rf build coverage", "format": "prettier --write 'src/**/*.{ts,tsx,js,jsx,json,md}'" }, @@ -57,7 +57,7 @@ "@material-ui/lab": "4.0.0-alpha.47", "@monaco-editor/react": "^4.0.0", "@open-rpc/client-js": "^1.6.3", - "@open-rpc/logs-react": "workspace:*", + "@open-rpc/logs-react": "*", "@open-rpc/meta-schema": "^1.14.9", "@open-rpc/schema-utils-js": "^1.14.3", "@rehooks/window-size": "^1.0.2", diff --git a/packages/inspector/src/index.tsx b/packages/inspector/src/index.tsx index 729e3ca..6512644 100644 --- a/packages/inspector/src/index.tsx +++ b/packages/inspector/src/index.tsx @@ -4,4 +4,9 @@ import App from "./containers/App"; import "./App.css"; import "./splitpane.css"; -ReactDOM.render(, document.getElementById("root")); +import {default as Inspector} from "./containers/Inspector"; +export default Inspector; + +if (typeof document !== 'undefined') { + ReactDOM.render(, document.getElementById("root")); +} diff --git a/packages/inspector/tsconfig.json b/packages/inspector/tsconfig.json index def6124..5d09654 100644 --- a/packages/inspector/tsconfig.json +++ b/packages/inspector/tsconfig.json @@ -7,5 +7,6 @@ "include": ["src"], "references": [ { "path": "../logs-react" } - ] + ], + "include": ["src/**/*", "src/**/*.css"] } diff --git a/packages/logs-react/package.json b/packages/logs-react/package.json index 0d2f17c..8eb6162 100644 --- a/packages/logs-react/package.json +++ b/packages/logs-react/package.json @@ -3,12 +3,14 @@ "version": "0.0.0-development", "description": "", "main": "build/index.js", - "module": "build/index.js", - "types": "build/index.d.ts", + "module": "build/exports.js", + "types": "build/exports.d.ts", "exports": { ".": { - "types": "./build/index.d.ts", - "import": "./build/index.js" + "types": "./build/exports.d.ts", + "import": "./build/exports.js", + "default": "./build/exports.js", + "require": "./build/exports.js" } }, "homepage": "https://open-rpc.github.io/logs-react/", @@ -21,7 +23,7 @@ "scripts": { "start": "vite", "build": "vite build", - "build:package": "tsc --build tsconfig.json && cp -r src/**/*.css build/", + "build:package": "tsc --build tsconfig.json && cd src && find . -name '*.css' -exec cp -v --parents -t ../build {} +", "lint": "eslint 'src/**/*.{ts,tsx}'", "test": "jest", "clean": "rm -rf build coverage", diff --git a/packages/logs-react/src/exports.ts b/packages/logs-react/src/exports.ts index 05753d0..c8aba93 100644 --- a/packages/logs-react/src/exports.ts +++ b/packages/logs-react/src/exports.ts @@ -1,3 +1,4 @@ -import JSONRPCLogger, {IJSONRPCLog} from "./components/logsReact/logsReact"; -export type JSONRPCLog = IJSONRPCLog; +import JSONRPCLogger from "./components/logsReact/logsReact"; +export type { IJSONRPCLog as JSONRPCLog } from "./components/logsReact/logsReact"; +export { JSONRPCLogger }; export default JSONRPCLogger; diff --git a/packages/logs-react/src/index.tsx b/packages/logs-react/src/index.tsx index 35b9682..fd5d073 100644 --- a/packages/logs-react/src/index.tsx +++ b/packages/logs-react/src/index.tsx @@ -1,5 +1,20 @@ import ReactDOM from "react-dom"; import React from "react"; import MyApp from "./containers/MyApp"; +import JSONRPCLogger from "./components/logsReact/logsReact"; -ReactDOM.render(, document.getElementById("root")); +// NOTE: This isn't what we want to do here, but it allows us to cross package build +//TODO: ReactDOM.render(, document.getElementById("root")); + +import type { IJSONRPCLog } from "./components/logsReact/logsReact"; + +export type { IJSONRPCLog as JSONRPCLog }; +export { JSONRPCLogger }; +export default JSONRPCLogger; + +// Keep the app rendering for development +if (typeof document !== 'undefined') { + const MyApp = require('./containers/MyApp').default; + const ReactDOM = require('react-dom'); + ReactDOM.render(, document.getElementById("root")); +} \ No newline at end of file diff --git a/packages/logs-react/src/react-app-env.d.ts b/packages/logs-react/src/react-app-env.d.ts deleted file mode 100644 index 6431bc5..0000000 --- a/packages/logs-react/src/react-app-env.d.ts +++ /dev/null @@ -1 +0,0 @@ -/// diff --git a/packages/logs-react/tsconfig.json b/packages/logs-react/tsconfig.json index 922fbe2..b6fda06 100644 --- a/packages/logs-react/tsconfig.json +++ b/packages/logs-react/tsconfig.json @@ -3,7 +3,11 @@ "compilerOptions": { "outDir": "./build", "rootDir": "./src", - "composite": true + "composite": true, + "paths": { + "@/*": ["./src/exports"], + "@exports": ["./src/exports"] + } }, - "include": ["src"] + "include": ["src/**/*", "src/**/*.css"] } diff --git a/packages/monaco-editor-react/.editorconfig b/packages/monaco-editor-react/.editorconfig new file mode 100644 index 0000000..14787e2 --- /dev/null +++ b/packages/monaco-editor-react/.editorconfig @@ -0,0 +1,14 @@ +# EditorConfig is awesome: http://EditorConfig.org + +# top-most EditorConfig file +root = true + +# Unix-style newlines with a newline ending every file +[*] +indent_style = space +indent_size = 2 +tab_width = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true \ No newline at end of file diff --git a/packages/monaco-editor-react/.gitignore b/packages/monaco-editor-react/.gitignore new file mode 100644 index 0000000..d7ee263 --- /dev/null +++ b/packages/monaco-editor-react/.gitignore @@ -0,0 +1,4 @@ +node_modules +build +coverage +*.tgz diff --git a/packages/monaco-editor-react/.nvmrc b/packages/monaco-editor-react/.nvmrc new file mode 100644 index 0000000..1117d41 --- /dev/null +++ b/packages/monaco-editor-react/.nvmrc @@ -0,0 +1 @@ +18.20.5 diff --git a/packages/monaco-editor-react/.releaserc b/packages/monaco-editor-react/.releaserc new file mode 100644 index 0000000..2f0d580 --- /dev/null +++ b/packages/monaco-editor-react/.releaserc @@ -0,0 +1,3 @@ +{ + "tagFormat": "${version}" +} diff --git a/packages/monaco-editor-react/README.md b/packages/monaco-editor-react/README.md new file mode 100644 index 0000000..4006c24 --- /dev/null +++ b/packages/monaco-editor-react/README.md @@ -0,0 +1,63 @@ +# docs-react +OpenRPC documentation as a react component + +#### What is this? +This is a react component that will render documentation for a given OpenRPC document. + +**Screenshot**: + +![image](https://user-images.githubusercontent.com/364566/54795109-1b1f5b80-4c08-11e9-9ba9-cc2f2d96c692.png) + + +#### How do I use this? + +##### Installation: +``` +npm install --save @open-rpc/docs-react +``` +##### Usage: +``` +import Documentation from "@open-rpc/docs-react"; +``` +and then use it somewhere: + +``` + +``` + +##### Example in a new project: + +###### create a new typescript project with `create-react-app` + +``` +npx create-react-app --typescript +``` + +``` +cd +npm install . +npm install @open-rpc/docs-react @open-rpc/meta-schema --save +``` + +###### index.ts +``` +import React from 'react'; +import ReactDOM from 'react-dom'; +import Documentation from "@open-rpc/docs-react"; +import { OpenrpcDocument } from '@open-rpc/meta-schema'; + +const schema: OpenrpcDocument = { + openrpc: "1.2.4", + info: { + "version": "0.0.0-development", + "title": "My New API" + }, + methods: [] +}; + +ReactDOM.render(, document.getElementById("root")); + +``` + +###### screenshot +![image](https://user-images.githubusercontent.com/364566/54797953-920e2180-4c13-11e9-9ff8-723a836d0e2c.png) diff --git a/packages/monaco-editor-react/jest.config.js b/packages/monaco-editor-react/jest.config.js new file mode 100644 index 0000000..b256f15 --- /dev/null +++ b/packages/monaco-editor-react/jest.config.js @@ -0,0 +1,9 @@ +module.exports = { + clearMocks: true, + coverageDirectory: '../coverage', + resetMocks: true, + restoreMocks: true, + rootDir: './src', + testEnvironment: 'jsdom', + preset: 'ts-jest' +}; \ No newline at end of file diff --git a/packages/monaco-editor-react/package.json b/packages/monaco-editor-react/package.json new file mode 100644 index 0000000..f113a3e --- /dev/null +++ b/packages/monaco-editor-react/package.json @@ -0,0 +1,42 @@ +{ + "name": "@open-rpc/monaco-editor-react", + "version": "0.0.0-development", + "description": "", + "type": "module", + "main": "build/index.js", + "module": "build/index.js", + "types": "build/index.d.ts", + "exports": { + ".": { + "types": "./build/index.d.ts", + "import": "./build/index.js" + } + }, + "publishConfig": { + "access": "public" + }, + "scripts": { + "build": "tsc", + "build:package": "tsc --build tsconfig.json --verbose ", + "lint": "eslint 'src/**/*.{ts,tsx}'", + "test": "npm run lint && jest --coverage --passWithNoTests", + "format": "prettier --write 'src/**/*.{ts,tsx,js,jsx,json,md}'" + }, + "author": "", + "license": "Apache-2.0", + "dependencies": { + "@material-ui/core": "^4.7.2", + "monaco-editor": "0.52.2", + "react": "^16.12.0" + }, + "devDependencies": { + "eslint": "^8.0.0", + "typescript": "^5.0.0" + }, + "files": [ + "build" + ], + "engines": { + "node": ">=18.20.5" + } +} diff --git a/packages/monaco-editor-react/src/MonacoContainer.tsx b/packages/monaco-editor-react/src/MonacoContainer.tsx new file mode 100644 index 0000000..11049f6 --- /dev/null +++ b/packages/monaco-editor-react/src/MonacoContainer.tsx @@ -0,0 +1,39 @@ +import React, { RefObject } from "react"; +import { makeStyles } from "@material-ui/core/styles"; + +interface IProps { + width?: string | number; + height?: string | number; + loading?: Element | string; + isEditorReady: boolean; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + reference: RefObject; +} + +const useStyles = makeStyles({ + wrapper: { + display: "flex", + position: "relative", + textAlign: "initial", + }, + fullWidth: { + width: "100%", + }, + hide: { + display: "none", + }, +}); + +const MonacoContainer: React.FC = ({ width, height, reference }) => { + const classes = useStyles({}); + return ( +
+
+
+ ); +}; + +export default MonacoContainer; \ No newline at end of file diff --git a/packages/monaco-editor-react/src/MonacoEditor.tsx b/packages/monaco-editor-react/src/MonacoEditor.tsx new file mode 100644 index 0000000..29a13c0 --- /dev/null +++ b/packages/monaco-editor-react/src/MonacoEditor.tsx @@ -0,0 +1,77 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +import React, { useState, useRef, useEffect, RefObject } from "react"; +import MonacoContainer from "./MonacoContainer"; +import * as monaco from "monaco-editor"; + +interface IProps { + value: string; + language: string; + editorDidMount: (editor: any, ref: React.RefObject) => any; + onChange?: (ev: any, value: string) => any; + editorOptions?: any; + line?: number; + loading?: Element | string; + width?: string | number; + height?: string | number; + controlled?: boolean; +} + +const MonacoEditor: React.FC = + ({ width, height, loading, value, language, editorOptions, editorDidMount, onChange }) => { + const [isEditorReady, setIsEditorReady] = useState(false); + const previousValue = useRef(value); + const containerRef = useRef(null); + const editorRef = useRef(null); + + const createEditor = () => { + if (!containerRef || !containerRef.current) { + return; + } + const resultOptions = { + value, + language, + ...editorOptions, + }; + editorRef.current = monaco.editor.create(containerRef.current, resultOptions); + editorDidMount(editorRef.current.getValue.bind(editorRef.current), editorRef.current); + + setIsEditorReady(true); + editorRef.current.onDidChangeModelContent((ev: any) => { + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + const currentValue = editorRef.current!.getValue(); + if ((currentValue !== previousValue.current) && !(ev.isUndoing || ev.isRedoing)) { + previousValue.current = currentValue; + if (onChange) { + onChange(ev, currentValue); + } + } + }); + }; + + useEffect(() => { + if (editorOptions && editorOptions.readOnly && editorRef.current && editorRef.current.getValue() !== value) { + editorRef.current.setValue(value); + } else if (editorRef.current && editorRef.current.getValue() !== value) { + editorRef.current.executeEdits("", [{ + range: editorRef.current.getModel().getFullModelRange(), + text: value, + }]); + } + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [value]); + + useEffect(() => { + createEditor(); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); + + return ; + }; + +export default MonacoEditor; \ No newline at end of file diff --git a/packages/monaco-editor-react/src/index.ts b/packages/monaco-editor-react/src/index.ts new file mode 100644 index 0000000..39aa70c --- /dev/null +++ b/packages/monaco-editor-react/src/index.ts @@ -0,0 +1,2 @@ +import MonacoEditor from "./MonacoEditor"; +export default MonacoEditor; \ No newline at end of file diff --git a/packages/monaco-editor-react/tsconfig.json b/packages/monaco-editor-react/tsconfig.json new file mode 100644 index 0000000..922fbe2 --- /dev/null +++ b/packages/monaco-editor-react/tsconfig.json @@ -0,0 +1,9 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": "./build", + "rootDir": "./src", + "composite": true + }, + "include": ["src"] +} diff --git a/packages/monaco-editor-react/tslint.json b/packages/monaco-editor-react/tslint.json new file mode 100644 index 0000000..7c0122b --- /dev/null +++ b/packages/monaco-editor-react/tslint.json @@ -0,0 +1,11 @@ +{ + "extends": [ + "tslint:recommended" + ], + "rules": { + "ordered-imports": false, + "no-var-requires": false, + "no-console": [true, "log"], + "indent": [true, "spaces", 2] + } +} \ No newline at end of file diff --git a/packages/playground/package.json b/packages/playground/package.json index 0a4a8fc..2cc640c 100644 --- a/packages/playground/package.json +++ b/packages/playground/package.json @@ -15,7 +15,8 @@ "@material-ui/core": "4.9.8", "@material-ui/icons": "4.9.1", "@material-ui/lab": "4.0.0-alpha.47", - "@open-rpc/docs-react": "workspace:*", + "@open-rpc/docs-react": "*", + "@open-rpc/monaco-editor-react": "*", "@open-rpc/examples": "^1.3.3", "@open-rpc/inspector": "*", "@open-rpc/meta-schema": "^1.14.9", @@ -42,6 +43,7 @@ "scripts": { "start": "vite", "build": "vite build", + "build:package": "vite build", "preview": "vite preview", "lint": "eslint 'src/**/*.{ts,tsx}'", "clean": "rm -rf dist coverage", @@ -64,9 +66,8 @@ "@types/react-dom": "^16.9.4", "@vitejs/plugin-react": "^4.2.1", "css-mediaquery": "^0.1.2", - "vite": "^5.1.4", - "vite-plugin-monaco-editor": "^1.1.0", - "eslint": "^6.6.0" + "eslint": "^6.6.0", + "vite": "^5.1.4" }, "engines": { "node": ">=18.20.5" diff --git a/packages/playground/src/OpenRPCEditor.tsx b/packages/playground/src/OpenRPCEditor.tsx index 42f9b73..148f696 100644 --- a/packages/playground/src/OpenRPCEditor.tsx +++ b/packages/playground/src/OpenRPCEditor.tsx @@ -1,5 +1,5 @@ import React, { useRef, useEffect } from "react"; -import MonacoEditor from "@etclabscore/react-monaco-editor"; +import MonacoEditor from "@open-rpc/monaco-editor-react"; import * as monaco from "monaco-editor"; import useWindowSize from "@rehooks/window-size"; import { addDiagnostics } from "@etclabscore/monaco-add-json-schema-diagnostics"; diff --git a/packages/playground/tsconfig.json b/packages/playground/tsconfig.json index 2e63b7f..3a6bb35 100644 --- a/packages/playground/tsconfig.json +++ b/packages/playground/tsconfig.json @@ -10,7 +10,8 @@ "noEmit": true }, "references": [ - { "path": "../logs-react" } + { "path": "../logs-react" }, + { "path": "../inspector" } ], "include": [ "src" diff --git a/packages/playground/vite.config.ts b/packages/playground/vite.config.ts index f866ef6..823eb66 100644 --- a/packages/playground/vite.config.ts +++ b/packages/playground/vite.config.ts @@ -1,20 +1,34 @@ import { defineConfig } from 'vite' import react from '@vitejs/plugin-react' -import monacoEditorPlugin from 'vite-plugin-monaco-editor' export default defineConfig({ - plugins: [ - react(), - monacoEditorPlugin({}) - ], + plugins: [react()], resolve: { - preserveSymlinks: true + preserveSymlinks: true, + alias: { + 'monaco-editor': 'monaco-editor/esm/vs/editor/editor.api' + } }, build: { outDir: 'dist', - sourcemap: true + sourcemap: true, + rollupOptions: { + output: { + manualChunks: { + 'monaco-editor': ['monaco-editor'] + } + } + } }, server: { port: 3000 + }, + define: { + 'process.env': {}, + 'process': { + 'env': {}, + 'platform': 'browser' + }, + 'global': 'globalThis' } }) diff --git a/tsconfig.json b/tsconfig.json index 3e688ee..7b7d826 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -18,6 +18,8 @@ { "path": "packages/logs-react" }, { "path": "packages/inspector" }, { "path": "packages/docs-react" }, + { "path": "packages/monaco-editor-react" }, { "path": "packages/playground" } - ] + ], + "include": ["src/**/*", "src/**/*.css","src/**/*/*.css"], } diff --git a/turbo.json b/turbo.json index f65c298..4fac201 100644 --- a/turbo.json +++ b/turbo.json @@ -1,11 +1,11 @@ { - "$schema": "https://turborepo.org/schema.json", + "$schema": "https://turbo.build/schema.json", "pipeline": { "build:package": { "outputs": ["dist/**", "build/**"] }, "build": { - "dependsOn": ["^build-package"], + "dependsOn": ["^build:package"], "outputs": ["dist/**", "build/**"] }, "test": {