@codespark/react 1.0.5 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/codemirror.d.ts +6249 -3
- package/dist/codemirror.js +5 -5
- package/dist/index.d.ts +6256 -10
- package/dist/index.js +38 -38
- package/dist/monaco.d.ts +6250 -4
- package/dist/monaco.js +22 -22
- package/package.json +3 -3
package/dist/monaco.js
CHANGED
|
@@ -10,10 +10,10 @@ import { twMerge } from "tailwind-merge";
|
|
|
10
10
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
11
|
|
|
12
12
|
//#region src/lib/editor-adapter/index.ts
|
|
13
|
-
let EditorEngine = /* @__PURE__ */ function(EditorEngine
|
|
14
|
-
EditorEngine
|
|
15
|
-
EditorEngine
|
|
16
|
-
return EditorEngine
|
|
13
|
+
let EditorEngine = /* @__PURE__ */ function(EditorEngine) {
|
|
14
|
+
EditorEngine[EditorEngine["Monaco"] = 0] = "Monaco";
|
|
15
|
+
EditorEngine[EditorEngine["CodeMirror"] = 1] = "CodeMirror";
|
|
16
|
+
return EditorEngine;
|
|
17
17
|
}({});
|
|
18
18
|
|
|
19
19
|
//#endregion
|
|
@@ -138,16 +138,16 @@ const setupOnce = async () => {
|
|
|
138
138
|
},
|
|
139
139
|
engine: createJavaScriptRegexEngine()
|
|
140
140
|
})]);
|
|
141
|
-
return mod.loader.init().then((Monaco
|
|
142
|
-
Monaco
|
|
143
|
-
Monaco
|
|
144
|
-
shikiToMonaco(highlighter, Monaco
|
|
145
|
-
Monaco
|
|
146
|
-
Monaco
|
|
141
|
+
return mod.loader.init().then((Monaco) => {
|
|
142
|
+
Monaco.languages.register({ id: "tsx" });
|
|
143
|
+
Monaco.languages.register({ id: "jsx" });
|
|
144
|
+
shikiToMonaco(highlighter, Monaco);
|
|
145
|
+
Monaco.typescript.typescriptDefaults.setEagerModelSync(true);
|
|
146
|
+
Monaco.typescript.typescriptDefaults.setDiagnosticsOptions({
|
|
147
147
|
noSemanticValidation: false,
|
|
148
148
|
noSyntaxValidation: false
|
|
149
149
|
});
|
|
150
|
-
Monaco
|
|
150
|
+
Monaco.typescript.typescriptDefaults.setCompilerOptions({
|
|
151
151
|
strict: true,
|
|
152
152
|
noImplicitAny: false,
|
|
153
153
|
noUnusedLocals: false,
|
|
@@ -155,16 +155,16 @@ const setupOnce = async () => {
|
|
|
155
155
|
allowUnreachableCode: true,
|
|
156
156
|
allowUnusedLabels: true,
|
|
157
157
|
allowImportingTsExtensions: true,
|
|
158
|
-
target: Monaco
|
|
158
|
+
target: Monaco.typescript.ScriptTarget.ESNext,
|
|
159
159
|
allowNonTsExtensions: true,
|
|
160
|
-
moduleResolution: Monaco
|
|
161
|
-
module: Monaco
|
|
160
|
+
moduleResolution: Monaco.typescript.ModuleResolutionKind.NodeJs,
|
|
161
|
+
module: Monaco.typescript.ModuleKind.ESNext,
|
|
162
162
|
noEmit: true,
|
|
163
|
-
jsx: Monaco
|
|
163
|
+
jsx: Monaco.typescript.JsxEmit.ReactJSX,
|
|
164
164
|
jsxImportSource: "react",
|
|
165
165
|
esModuleInterop: true
|
|
166
166
|
});
|
|
167
|
-
Monaco
|
|
167
|
+
Monaco.languages.registerDocumentFormattingEditProvider("typescript", { async provideDocumentFormattingEdits(model, options) {
|
|
168
168
|
const text = model.getValue();
|
|
169
169
|
const formatted = await prettier.format(text, {
|
|
170
170
|
parser: "typescript",
|
|
@@ -217,7 +217,7 @@ const MONACO_DEFAULT_OPTIONS = {
|
|
|
217
217
|
};
|
|
218
218
|
const Monaco = {
|
|
219
219
|
kind: EditorEngine.Monaco,
|
|
220
|
-
Component: memo(function Monaco
|
|
220
|
+
Component: memo(function Monaco(props) {
|
|
221
221
|
const { value = "", options = {}, onChange, onMount, width, height, id, language, files, imports, ...rest } = props;
|
|
222
222
|
const editorInstance = useRef(null);
|
|
223
223
|
const [monacoInstance, setMonacoInstance] = useState(null);
|
|
@@ -231,8 +231,8 @@ const Monaco = {
|
|
|
231
231
|
editorInstance.current = editor;
|
|
232
232
|
setMonacoInstance(monaco);
|
|
233
233
|
};
|
|
234
|
-
const handleEditorContentChange = (value
|
|
235
|
-
onChange?.(value
|
|
234
|
+
const handleEditorContentChange = (value, evt) => {
|
|
235
|
+
onChange?.(value, evt);
|
|
236
236
|
};
|
|
237
237
|
const addExtraLib = (dts = {}) => {
|
|
238
238
|
Object.entries(dts).forEach(([module, content]) => {
|
|
@@ -249,9 +249,9 @@ const Monaco = {
|
|
|
249
249
|
addedLibs.add(module);
|
|
250
250
|
});
|
|
251
251
|
};
|
|
252
|
-
const createModels = (files
|
|
252
|
+
const createModels = (files = {}) => {
|
|
253
253
|
const prefix = `file:///${id}/`;
|
|
254
|
-
const filePaths = new Set(Object.keys(files
|
|
254
|
+
const filePaths = new Set(Object.keys(files).map((p) => p.replace(/^(\.\.?\/)+/, "")));
|
|
255
255
|
monacoInstance.editor.getModels().forEach((model) => {
|
|
256
256
|
const uriStr = model.uri.toString();
|
|
257
257
|
if (uriStr.startsWith(prefix)) {
|
|
@@ -259,7 +259,7 @@ const Monaco = {
|
|
|
259
259
|
if (!filePaths.has(modelPath)) model.dispose();
|
|
260
260
|
}
|
|
261
261
|
});
|
|
262
|
-
Object.entries(files
|
|
262
|
+
Object.entries(files).forEach(([filePath, code]) => {
|
|
263
263
|
const normalizedPath = filePath.replace(/^(\.\.?\/)+/, "");
|
|
264
264
|
const uri = monacoInstance.Uri.parse(`${prefix}${normalizedPath}`);
|
|
265
265
|
if (!monacoInstance.editor.getModel(uri)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codespark/react",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "React components for codespark ecosystem",
|
|
6
6
|
"keywords": [
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"@codemirror/lang-javascript": "^6.2.4",
|
|
43
43
|
"@codemirror/lang-markdown": "^6.5.0",
|
|
44
44
|
"@codemirror/language-data": "^6.5.2",
|
|
45
|
-
"@codespark/framework": "^1.0.
|
|
45
|
+
"@codespark/framework": "^1.0.2",
|
|
46
46
|
"@monaco-editor/react": "^4.7.0",
|
|
47
47
|
"@shikijs/monaco": "^3.20.0",
|
|
48
48
|
"@uiw/react-codemirror": "^4.25.4",
|
|
@@ -67,6 +67,6 @@
|
|
|
67
67
|
"@types/react-is": "^19.2.0",
|
|
68
68
|
"monaco-editor": "^0.55.1",
|
|
69
69
|
"rollup-plugin-import-raw": "^1.0.2",
|
|
70
|
-
"tsdown": "^0.
|
|
70
|
+
"tsdown": "^0.20.3"
|
|
71
71
|
}
|
|
72
72
|
}
|