@willbooster/monaco-react 1.0.4 → 1.0.6

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.
Files changed (123) hide show
  1. package/README.md +3 -3
  2. package/dist/DiffEditor/DiffEditor.cjs +3 -0
  3. package/dist/DiffEditor/DiffEditor.cjs.map +1 -0
  4. package/dist/DiffEditor/DiffEditor.d.ts +5 -0
  5. package/dist/DiffEditor/DiffEditor.d.ts.map +1 -0
  6. package/dist/DiffEditor/DiffEditor.js +3 -0
  7. package/dist/DiffEditor/DiffEditor.js.map +1 -0
  8. package/dist/DiffEditor/index.cjs +2 -0
  9. package/dist/DiffEditor/index.cjs.map +1 -0
  10. package/dist/DiffEditor/index.d.ts +5 -0
  11. package/dist/DiffEditor/index.d.ts.map +1 -0
  12. package/dist/DiffEditor/index.js +2 -0
  13. package/dist/DiffEditor/index.js.map +1 -0
  14. package/dist/DiffEditor/index.spec.d.ts +2 -0
  15. package/dist/DiffEditor/index.spec.d.ts.map +1 -0
  16. package/dist/DiffEditor/types.d.ts +101 -0
  17. package/dist/DiffEditor/types.d.ts.map +1 -0
  18. package/dist/Editor/Editor.cjs +3 -0
  19. package/dist/Editor/Editor.cjs.map +1 -0
  20. package/dist/Editor/Editor.d.ts +5 -0
  21. package/dist/Editor/Editor.d.ts.map +1 -0
  22. package/dist/Editor/Editor.js +3 -0
  23. package/dist/Editor/Editor.js.map +1 -0
  24. package/dist/Editor/index.cjs +2 -0
  25. package/dist/Editor/index.cjs.map +1 -0
  26. package/dist/Editor/index.d.ts +5 -0
  27. package/dist/Editor/index.d.ts.map +1 -0
  28. package/dist/Editor/index.js +2 -0
  29. package/dist/Editor/index.js.map +1 -0
  30. package/dist/Editor/index.spec.d.ts +2 -0
  31. package/dist/Editor/index.spec.d.ts.map +1 -0
  32. package/dist/Editor/types.d.ts +116 -0
  33. package/dist/Editor/types.d.ts.map +1 -0
  34. package/dist/Loading/Loading.cjs +2 -0
  35. package/dist/Loading/Loading.cjs.map +1 -0
  36. package/dist/Loading/Loading.d.ts +4 -0
  37. package/dist/Loading/Loading.d.ts.map +1 -0
  38. package/dist/Loading/Loading.js +2 -0
  39. package/dist/Loading/Loading.js.map +1 -0
  40. package/dist/Loading/index.cjs +2 -0
  41. package/dist/Loading/index.cjs.map +1 -0
  42. package/dist/Loading/index.d.ts +3 -0
  43. package/dist/Loading/index.d.ts.map +1 -0
  44. package/dist/Loading/index.js +2 -0
  45. package/dist/Loading/index.js.map +1 -0
  46. package/dist/Loading/index.spec.d.ts +2 -0
  47. package/dist/Loading/index.spec.d.ts.map +1 -0
  48. package/dist/Loading/styles.cjs +2 -0
  49. package/dist/Loading/styles.cjs.map +1 -0
  50. package/dist/Loading/styles.d.ts +4 -0
  51. package/dist/Loading/styles.d.ts.map +1 -0
  52. package/dist/Loading/styles.js +2 -0
  53. package/dist/Loading/styles.js.map +1 -0
  54. package/dist/MonacoContainer/MonacoContainer.cjs +2 -0
  55. package/dist/MonacoContainer/MonacoContainer.cjs.map +1 -0
  56. package/dist/MonacoContainer/MonacoContainer.d.ts +5 -0
  57. package/dist/MonacoContainer/MonacoContainer.d.ts.map +1 -0
  58. package/dist/MonacoContainer/MonacoContainer.js +2 -0
  59. package/dist/MonacoContainer/MonacoContainer.js.map +1 -0
  60. package/dist/MonacoContainer/index.cjs +2 -0
  61. package/dist/MonacoContainer/index.cjs.map +1 -0
  62. package/dist/MonacoContainer/index.d.ts +4 -0
  63. package/dist/MonacoContainer/index.d.ts.map +1 -0
  64. package/dist/MonacoContainer/index.js +2 -0
  65. package/dist/MonacoContainer/index.js.map +1 -0
  66. package/dist/MonacoContainer/index.spec.d.ts +2 -0
  67. package/dist/MonacoContainer/index.spec.d.ts.map +1 -0
  68. package/dist/MonacoContainer/styles.cjs +2 -0
  69. package/dist/MonacoContainer/styles.cjs.map +1 -0
  70. package/dist/MonacoContainer/styles.d.ts +4 -0
  71. package/dist/MonacoContainer/styles.d.ts.map +1 -0
  72. package/dist/MonacoContainer/styles.js +2 -0
  73. package/dist/MonacoContainer/styles.js.map +1 -0
  74. package/dist/MonacoContainer/types.d.ts +11 -0
  75. package/dist/MonacoContainer/types.d.ts.map +1 -0
  76. package/dist/_virtual/_rollupPluginBabelHelpers.cjs +2 -0
  77. package/dist/_virtual/_rollupPluginBabelHelpers.cjs.map +1 -0
  78. package/dist/_virtual/_rollupPluginBabelHelpers.js +2 -0
  79. package/dist/_virtual/_rollupPluginBabelHelpers.js.map +1 -0
  80. package/dist/hooks/useMonaco/index.cjs +2 -0
  81. package/dist/hooks/useMonaco/index.cjs.map +1 -0
  82. package/dist/hooks/useMonaco/index.d.ts +4 -0
  83. package/dist/hooks/useMonaco/index.d.ts.map +1 -0
  84. package/dist/hooks/useMonaco/index.js +2 -0
  85. package/dist/hooks/useMonaco/index.js.map +1 -0
  86. package/dist/hooks/useMonaco/initMonaco.cjs +2 -0
  87. package/dist/hooks/useMonaco/initMonaco.cjs.map +1 -0
  88. package/dist/hooks/useMonaco/initMonaco.d.ts +4 -0
  89. package/dist/hooks/useMonaco/initMonaco.d.ts.map +1 -0
  90. package/dist/hooks/useMonaco/initMonaco.js +2 -0
  91. package/dist/hooks/useMonaco/initMonaco.js.map +1 -0
  92. package/dist/hooks/useMount/index.cjs +2 -0
  93. package/dist/hooks/useMount/index.cjs.map +1 -0
  94. package/dist/hooks/useMount/index.d.ts +4 -0
  95. package/dist/hooks/useMount/index.d.ts.map +1 -0
  96. package/dist/hooks/useMount/index.js +2 -0
  97. package/dist/hooks/useMount/index.js.map +1 -0
  98. package/dist/hooks/usePrevious/index.cjs +2 -0
  99. package/dist/hooks/usePrevious/index.cjs.map +1 -0
  100. package/dist/hooks/usePrevious/index.d.ts +3 -0
  101. package/dist/hooks/usePrevious/index.d.ts.map +1 -0
  102. package/dist/hooks/usePrevious/index.js +2 -0
  103. package/dist/hooks/usePrevious/index.js.map +1 -0
  104. package/dist/hooks/useUpdate/index.cjs +2 -0
  105. package/dist/hooks/useUpdate/index.cjs.map +1 -0
  106. package/dist/hooks/useUpdate/index.d.ts +4 -0
  107. package/dist/hooks/useUpdate/index.d.ts.map +1 -0
  108. package/dist/hooks/useUpdate/index.js +2 -0
  109. package/dist/hooks/useUpdate/index.js.map +1 -0
  110. package/dist/index.cjs +3 -625
  111. package/dist/index.cjs.map +1 -1
  112. package/dist/index.d.ts +15 -231
  113. package/dist/index.d.ts.map +1 -0
  114. package/dist/index.js +3 -588
  115. package/dist/index.js.map +1 -1
  116. package/dist/utils/index.cjs +2 -0
  117. package/dist/utils/index.cjs.map +1 -0
  118. package/dist/utils/index.d.ts +20 -0
  119. package/dist/utils/index.d.ts.map +1 -0
  120. package/dist/utils/index.js +2 -0
  121. package/dist/utils/index.js.map +1 -0
  122. package/package.json +5 -4
  123. package/dist/index.d.cts +0 -231
package/dist/index.js CHANGED
@@ -1,588 +1,3 @@
1
- 'use client';
2
-
3
- // src/index.ts
4
- import loader4 from "@willbooster/monaco-loader";
5
-
6
- // src/DiffEditor/index.ts
7
- import { memo as memo2 } from "react";
8
-
9
- // src/DiffEditor/DiffEditor.tsx
10
- import { useState, useRef as useRef2, useCallback, useEffect as useEffect3 } from "react";
11
- import loader from "@willbooster/monaco-loader";
12
-
13
- // src/MonacoContainer/index.ts
14
- import { memo } from "react";
15
-
16
- // src/MonacoContainer/styles.ts
17
- var styles = {
18
- wrapper: {
19
- display: "flex",
20
- position: "relative",
21
- textAlign: "initial"
22
- },
23
- fullWidth: {
24
- width: "100%"
25
- },
26
- hide: {
27
- display: "none"
28
- }
29
- };
30
- var styles_default = styles;
31
-
32
- // src/Loading/styles.ts
33
- var styles2 = {
34
- container: {
35
- display: "flex",
36
- height: "100%",
37
- width: "100%",
38
- justifyContent: "center",
39
- alignItems: "center"
40
- }
41
- };
42
- var styles_default2 = styles2;
43
-
44
- // src/Loading/Loading.tsx
45
- import { jsx } from "react/jsx-runtime";
46
- function Loading({ children }) {
47
- return /* @__PURE__ */ jsx("div", { style: styles_default2.container, children });
48
- }
49
- var Loading_default = Loading;
50
-
51
- // src/Loading/index.ts
52
- var Loading_default2 = Loading_default;
53
-
54
- // src/MonacoContainer/MonacoContainer.tsx
55
- import { jsx as jsx2, jsxs } from "react/jsx-runtime";
56
- function MonacoContainer({
57
- width,
58
- height,
59
- isEditorReady,
60
- loading,
61
- _ref,
62
- className,
63
- wrapperProps
64
- }) {
65
- return /* @__PURE__ */ jsxs("section", { style: { ...styles_default.wrapper, width, height }, ...wrapperProps, children: [
66
- !isEditorReady && /* @__PURE__ */ jsx2(Loading_default2, { children: loading }),
67
- /* @__PURE__ */ jsx2("div", { ref: _ref, style: { ...styles_default.fullWidth, ...!isEditorReady && styles_default.hide }, className })
68
- ] });
69
- }
70
- var MonacoContainer_default = MonacoContainer;
71
-
72
- // src/MonacoContainer/index.ts
73
- var MonacoContainer_default2 = memo(MonacoContainer_default);
74
-
75
- // src/hooks/useMount/index.ts
76
- import { useEffect } from "react";
77
- function useMount(effect) {
78
- useEffect(effect, []);
79
- }
80
- var useMount_default = useMount;
81
-
82
- // src/hooks/useUpdate/index.ts
83
- import { useEffect as useEffect2, useRef } from "react";
84
- function useUpdate(effect, deps, applyChanges = true) {
85
- const isInitialMount = useRef(true);
86
- useEffect2(
87
- isInitialMount.current || !applyChanges ? () => {
88
- isInitialMount.current = false;
89
- } : effect,
90
- deps
91
- );
92
- }
93
- var useUpdate_default = useUpdate;
94
-
95
- // src/utils/index.ts
96
- function noop() {
97
- }
98
- function getOrCreateModel(monaco, value, language, path) {
99
- return getModel(monaco, path) ?? createModel(monaco, value, language, path);
100
- }
101
- function getModel(monaco, path) {
102
- return monaco.editor.getModel(createModelUri(monaco, path));
103
- }
104
- function createModel(monaco, value, language, path) {
105
- return monaco.editor.createModel(value, language, path ? createModelUri(monaco, path) : void 0);
106
- }
107
- function createModelUri(monaco, path) {
108
- return monaco.Uri.parse(path);
109
- }
110
-
111
- // src/DiffEditor/DiffEditor.tsx
112
- import { jsx as jsx3 } from "react/jsx-runtime";
113
- function DiffEditor({
114
- original,
115
- modified,
116
- language,
117
- originalLanguage,
118
- modifiedLanguage,
119
- originalModelPath,
120
- modifiedModelPath,
121
- keepCurrentOriginalModel = false,
122
- keepCurrentModifiedModel = false,
123
- theme = "light",
124
- loading = "Loading...",
125
- options = {},
126
- height = "100%",
127
- width = "100%",
128
- className,
129
- wrapperProps = {},
130
- beforeMount = noop,
131
- onMount = noop
132
- }) {
133
- const [isEditorReady, setIsEditorReady] = useState(false);
134
- const [isMonacoMounting, setIsMonacoMounting] = useState(true);
135
- const editorRef = useRef2(null);
136
- const monacoRef = useRef2(null);
137
- const containerRef = useRef2(null);
138
- const onMountRef = useRef2(onMount);
139
- const beforeMountRef = useRef2(beforeMount);
140
- const preventCreation = useRef2(false);
141
- useMount_default(() => {
142
- const cancelable = loader.init();
143
- cancelable.then((monaco) => (monacoRef.current = monaco) && setIsMonacoMounting(false)).catch((error) => error?.type !== "cancelation" && console.error("Monaco initialization: error:", error));
144
- return () => editorRef.current ? disposeEditor() : cancelable.cancel();
145
- });
146
- useUpdate_default(
147
- () => {
148
- if (editorRef.current && monacoRef.current) {
149
- const originalEditor = editorRef.current.getOriginalEditor();
150
- const model = getOrCreateModel(
151
- monacoRef.current,
152
- original || "",
153
- originalLanguage || language || "text",
154
- originalModelPath || ""
155
- );
156
- if (model !== originalEditor.getModel()) {
157
- originalEditor.setModel(model);
158
- }
159
- }
160
- },
161
- [originalModelPath],
162
- isEditorReady
163
- );
164
- useUpdate_default(
165
- () => {
166
- if (editorRef.current && monacoRef.current) {
167
- const modifiedEditor = editorRef.current.getModifiedEditor();
168
- const model = getOrCreateModel(
169
- monacoRef.current,
170
- modified || "",
171
- modifiedLanguage || language || "text",
172
- modifiedModelPath || ""
173
- );
174
- if (model !== modifiedEditor.getModel()) {
175
- modifiedEditor.setModel(model);
176
- }
177
- }
178
- },
179
- [modifiedModelPath],
180
- isEditorReady
181
- );
182
- useUpdate_default(
183
- () => {
184
- const modifiedEditor = editorRef.current.getModifiedEditor();
185
- if (modifiedEditor.getOption(monacoRef.current.editor.EditorOption.readOnly)) {
186
- modifiedEditor.setValue(modified || "");
187
- } else {
188
- if (modified !== modifiedEditor.getValue()) {
189
- modifiedEditor.executeEdits("", [
190
- {
191
- range: modifiedEditor.getModel().getFullModelRange(),
192
- text: modified || "",
193
- forceMoveMarkers: true
194
- }
195
- ]);
196
- modifiedEditor.pushUndoStop();
197
- }
198
- }
199
- },
200
- [modified],
201
- isEditorReady
202
- );
203
- useUpdate_default(
204
- () => {
205
- editorRef.current?.getModel()?.original.setValue(original || "");
206
- },
207
- [original],
208
- isEditorReady
209
- );
210
- useUpdate_default(
211
- () => {
212
- const { original: original2, modified: modified2 } = editorRef.current.getModel();
213
- monacoRef.current.editor.setModelLanguage(original2, originalLanguage || language || "text");
214
- monacoRef.current.editor.setModelLanguage(modified2, modifiedLanguage || language || "text");
215
- },
216
- [language, originalLanguage, modifiedLanguage],
217
- isEditorReady
218
- );
219
- useUpdate_default(
220
- () => {
221
- monacoRef.current?.editor.setTheme(theme);
222
- },
223
- [theme],
224
- isEditorReady
225
- );
226
- useUpdate_default(
227
- () => {
228
- editorRef.current?.updateOptions(options);
229
- },
230
- [options],
231
- isEditorReady
232
- );
233
- const setModels = useCallback(() => {
234
- if (!monacoRef.current) return;
235
- beforeMountRef.current(monacoRef.current);
236
- const originalModel = getOrCreateModel(
237
- monacoRef.current,
238
- original || "",
239
- originalLanguage || language || "text",
240
- originalModelPath || ""
241
- );
242
- const modifiedModel = getOrCreateModel(
243
- monacoRef.current,
244
- modified || "",
245
- modifiedLanguage || language || "text",
246
- modifiedModelPath || ""
247
- );
248
- editorRef.current?.setModel({
249
- original: originalModel,
250
- modified: modifiedModel
251
- });
252
- }, [language, modified, modifiedLanguage, original, originalLanguage, originalModelPath, modifiedModelPath]);
253
- const createEditor = useCallback(() => {
254
- if (!preventCreation.current && containerRef.current) {
255
- editorRef.current = monacoRef.current.editor.createDiffEditor(containerRef.current, {
256
- automaticLayout: true,
257
- ...options
258
- });
259
- setModels();
260
- monacoRef.current?.editor.setTheme(theme);
261
- setIsEditorReady(true);
262
- preventCreation.current = true;
263
- }
264
- }, [options, theme, setModels]);
265
- useEffect3(() => {
266
- if (isEditorReady) {
267
- onMountRef.current(editorRef.current, monacoRef.current);
268
- }
269
- }, [isEditorReady]);
270
- useEffect3(() => {
271
- if (!isMonacoMounting && !isEditorReady) {
272
- createEditor();
273
- }
274
- }, [isMonacoMounting, isEditorReady, createEditor]);
275
- function disposeEditor() {
276
- const editor = editorRef.current;
277
- const models = editor?.getModel();
278
- editor?.setModel(null);
279
- editor?.dispose();
280
- if (!keepCurrentOriginalModel && !models?.original.isDisposed()) {
281
- models?.original?.dispose();
282
- }
283
- if (!keepCurrentModifiedModel && !models?.modified.isDisposed()) {
284
- models?.modified?.dispose();
285
- }
286
- editorRef.current = null;
287
- preventCreation.current = false;
288
- setIsEditorReady(false);
289
- }
290
- return /* @__PURE__ */ jsx3(
291
- MonacoContainer_default2,
292
- {
293
- width,
294
- height,
295
- isEditorReady,
296
- loading,
297
- _ref: containerRef,
298
- className,
299
- wrapperProps
300
- }
301
- );
302
- }
303
- var DiffEditor_default = DiffEditor;
304
-
305
- // src/DiffEditor/index.ts
306
- var DiffEditor_default2 = memo2(DiffEditor_default);
307
-
308
- // src/hooks/useMonaco/index.ts
309
- import { useState as useState2 } from "react";
310
- import loader2 from "@willbooster/monaco-loader";
311
- function useMonaco() {
312
- const [monaco, setMonaco] = useState2(loader2.__getMonacoInstance());
313
- useMount_default(() => {
314
- let cancelable;
315
- if (!monaco) {
316
- cancelable = loader2.init();
317
- void cancelable.then((monaco2) => {
318
- setMonaco(monaco2);
319
- return;
320
- }).catch((error) => {
321
- if (error?.type !== "cancelation") {
322
- console.error("Monaco initialization: error:", error);
323
- }
324
- });
325
- }
326
- return () => cancelable?.cancel();
327
- });
328
- return monaco;
329
- }
330
- var useMonaco_default = useMonaco;
331
-
332
- // src/Editor/index.ts
333
- import { memo as memo3 } from "react";
334
-
335
- // src/Editor/Editor.tsx
336
- import { useState as useState3, useEffect as useEffect5, useRef as useRef4, useCallback as useCallback2 } from "react";
337
- import loader3 from "@willbooster/monaco-loader";
338
-
339
- // src/hooks/usePrevious/index.ts
340
- import { useEffect as useEffect4, useRef as useRef3 } from "react";
341
- function usePrevious(value) {
342
- const ref = useRef3(void 0);
343
- useEffect4(() => {
344
- ref.current = value;
345
- }, [value]);
346
- return ref.current;
347
- }
348
- var usePrevious_default = usePrevious;
349
-
350
- // src/Editor/Editor.tsx
351
- import { jsx as jsx4 } from "react/jsx-runtime";
352
- var viewStates = /* @__PURE__ */ new Map();
353
- function Editor({
354
- defaultValue,
355
- defaultLanguage,
356
- defaultPath,
357
- value,
358
- language,
359
- path,
360
- /* === */
361
- theme = "light",
362
- line,
363
- loading = "Loading...",
364
- options = {},
365
- overrideServices = {},
366
- saveViewState = true,
367
- keepCurrentModel = false,
368
- /* === */
369
- width = "100%",
370
- height = "100%",
371
- className,
372
- wrapperProps = {},
373
- /* === */
374
- beforeMount = noop,
375
- onMount = noop,
376
- onChange,
377
- onValidate = noop
378
- }) {
379
- const [isEditorReady, setIsEditorReady] = useState3(false);
380
- const [isMonacoMounting, setIsMonacoMounting] = useState3(true);
381
- const monacoRef = useRef4(null);
382
- const editorRef = useRef4(null);
383
- const containerRef = useRef4(null);
384
- const onMountRef = useRef4(onMount);
385
- const beforeMountRef = useRef4(beforeMount);
386
- const subscriptionRef = useRef4(void 0);
387
- const valueRef = useRef4(value);
388
- const previousPath = usePrevious_default(path);
389
- const preventCreation = useRef4(false);
390
- const preventTriggerChangeEvent = useRef4(false);
391
- useMount_default(() => {
392
- const cancelable = loader3.init();
393
- cancelable.then((monaco) => (monacoRef.current = monaco) && setIsMonacoMounting(false)).catch((error) => error?.type !== "cancelation" && console.error("Monaco initialization: error:", error));
394
- return () => editorRef.current ? disposeEditor() : cancelable.cancel();
395
- });
396
- useUpdate_default(
397
- () => {
398
- const model = getOrCreateModel(
399
- monacoRef.current,
400
- defaultValue || value || "",
401
- defaultLanguage || language || "",
402
- path || defaultPath || ""
403
- );
404
- if (model !== editorRef.current?.getModel()) {
405
- if (saveViewState) viewStates.set(previousPath, editorRef.current?.saveViewState());
406
- editorRef.current?.setModel(model);
407
- if (saveViewState) editorRef.current?.restoreViewState(viewStates.get(path));
408
- }
409
- },
410
- [path],
411
- isEditorReady
412
- );
413
- useUpdate_default(
414
- () => {
415
- editorRef.current?.updateOptions(options);
416
- },
417
- [options],
418
- isEditorReady
419
- );
420
- useUpdate_default(
421
- () => {
422
- if (!editorRef.current || value === void 0) return;
423
- if (editorRef.current.getOption(monacoRef.current.editor.EditorOption.readOnly)) {
424
- editorRef.current.setValue(value);
425
- } else if (value !== editorRef.current.getValue()) {
426
- preventTriggerChangeEvent.current = true;
427
- editorRef.current.executeEdits("", [
428
- {
429
- range: editorRef.current.getModel().getFullModelRange(),
430
- text: value,
431
- forceMoveMarkers: true
432
- }
433
- ]);
434
- editorRef.current.pushUndoStop();
435
- preventTriggerChangeEvent.current = false;
436
- }
437
- },
438
- [value],
439
- isEditorReady
440
- );
441
- useUpdate_default(
442
- () => {
443
- const model = editorRef.current?.getModel();
444
- if (isEditorReady && model && language) {
445
- monacoRef.current?.editor.setModelLanguage(model, language);
446
- }
447
- },
448
- [language, isEditorReady],
449
- isEditorReady
450
- );
451
- useUpdate_default(
452
- () => {
453
- if (line !== void 0) {
454
- editorRef.current?.revealLine(line);
455
- }
456
- },
457
- [line],
458
- isEditorReady
459
- );
460
- useUpdate_default(
461
- () => {
462
- monacoRef.current?.editor.setTheme(theme);
463
- },
464
- [theme],
465
- isEditorReady
466
- );
467
- const createEditor = useCallback2(() => {
468
- if (!containerRef.current || !monacoRef.current) return;
469
- if (!preventCreation.current) {
470
- beforeMountRef.current(monacoRef.current);
471
- const autoCreatedModelPath = path || defaultPath;
472
- const defaultModel = getOrCreateModel(
473
- monacoRef.current,
474
- value || defaultValue || "",
475
- defaultLanguage || language || "",
476
- autoCreatedModelPath || ""
477
- );
478
- const editor = monacoRef.current.editor.create(
479
- containerRef.current,
480
- {
481
- model: defaultModel,
482
- automaticLayout: true,
483
- ...options
484
- },
485
- overrideServices
486
- );
487
- editorRef.current = editor;
488
- saveViewState && editor.restoreViewState(viewStates.get(autoCreatedModelPath));
489
- monacoRef.current.editor.setTheme(theme);
490
- if (line !== void 0) {
491
- editor.revealLine(line);
492
- }
493
- setIsEditorReady(true);
494
- preventCreation.current = true;
495
- }
496
- }, [
497
- defaultValue,
498
- defaultLanguage,
499
- defaultPath,
500
- value,
501
- language,
502
- path,
503
- options,
504
- overrideServices,
505
- saveViewState,
506
- theme,
507
- line
508
- ]);
509
- useEffect5(() => {
510
- if (isEditorReady) {
511
- onMountRef.current(editorRef.current, monacoRef.current);
512
- }
513
- }, [isEditorReady]);
514
- useEffect5(() => {
515
- !isMonacoMounting && !isEditorReady && createEditor();
516
- }, [isMonacoMounting, isEditorReady, createEditor]);
517
- valueRef.current = value;
518
- useEffect5(() => {
519
- if (isEditorReady && onChange) {
520
- subscriptionRef.current?.dispose();
521
- subscriptionRef.current = editorRef.current?.onDidChangeModelContent((event) => {
522
- if (!preventTriggerChangeEvent.current) {
523
- onChange(editorRef.current.getValue(), event);
524
- }
525
- });
526
- }
527
- }, [isEditorReady, onChange]);
528
- useEffect5(() => {
529
- if (isEditorReady) {
530
- const changeMarkersListener = monacoRef.current.editor.onDidChangeMarkers((uris) => {
531
- const editorUri = editorRef.current.getModel()?.uri;
532
- if (editorUri) {
533
- const currentEditorHasMarkerChanges = uris.find((uri) => uri.path === editorUri.path);
534
- if (currentEditorHasMarkerChanges) {
535
- const markers = monacoRef.current.editor.getModelMarkers({
536
- resource: editorUri
537
- });
538
- onValidate?.(markers);
539
- }
540
- }
541
- });
542
- return () => {
543
- changeMarkersListener?.dispose();
544
- };
545
- }
546
- return () => {
547
- };
548
- }, [isEditorReady, onValidate]);
549
- function disposeEditor() {
550
- subscriptionRef.current?.dispose();
551
- if (keepCurrentModel) {
552
- saveViewState && viewStates.set(path, editorRef.current.saveViewState());
553
- } else {
554
- editorRef.current.getModel()?.dispose();
555
- }
556
- editorRef.current.dispose();
557
- editorRef.current = null;
558
- preventCreation.current = false;
559
- setIsEditorReady(false);
560
- }
561
- return /* @__PURE__ */ jsx4(
562
- MonacoContainer_default2,
563
- {
564
- width,
565
- height,
566
- isEditorReady,
567
- loading,
568
- _ref: containerRef,
569
- className,
570
- wrapperProps
571
- }
572
- );
573
- }
574
- var Editor_default = Editor;
575
-
576
- // src/Editor/index.ts
577
- var Editor_default2 = memo3(Editor_default);
578
-
579
- // src/index.ts
580
- var index_default = Editor_default2;
581
- export {
582
- DiffEditor_default2 as DiffEditor,
583
- Editor_default2 as Editor,
584
- index_default as default,
585
- loader4 as loader,
586
- useMonaco_default as useMonaco
587
- };
588
- //# sourceMappingURL=index.js.map
1
+ "use client";
2
+ export{default as loader}from"@willbooster/monaco-loader";export{default as DiffEditor}from"./DiffEditor/index.js";export{default as useMonaco}from"./hooks/useMonaco/index.js";import o from"./Editor/index.js";export{o as Editor,o as default};
3
+ //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/DiffEditor/index.ts","../src/DiffEditor/DiffEditor.tsx","../src/MonacoContainer/index.ts","../src/MonacoContainer/styles.ts","../src/Loading/styles.ts","../src/Loading/Loading.tsx","../src/Loading/index.ts","../src/MonacoContainer/MonacoContainer.tsx","../src/hooks/useMount/index.ts","../src/hooks/useUpdate/index.ts","../src/utils/index.ts","../src/hooks/useMonaco/index.ts","../src/Editor/index.ts","../src/Editor/Editor.tsx","../src/hooks/usePrevious/index.ts"],"sourcesContent":["import loader from '@willbooster/monaco-loader';\nexport { loader };\n\nimport DiffEditor from './DiffEditor';\nexport * from './DiffEditor/types';\nexport { DiffEditor };\n\nimport useMonaco from './hooks/useMonaco';\nexport { useMonaco };\n\nimport Editor from './Editor';\nexport * from './Editor/types';\nexport { Editor };\nexport default Editor;\n\n// Monaco\nimport type * as monaco from 'monaco-editor/esm/vs/editor/editor.api.js';\nexport type Monaco = typeof monaco;\n\n// Default themes\nexport type Theme = 'vs-dark' | 'light';\n","import { memo } from 'react';\n\nimport DiffEditor from './DiffEditor';\n\nexport * from './types';\n\nexport default memo(DiffEditor);\n","'use client';\n\nimport { useState, useRef, useCallback, useEffect } from 'react';\nimport type { ReactElement } from 'react';\nimport loader from '@willbooster/monaco-loader';\n\nimport MonacoContainer from '../MonacoContainer';\nimport useMount from '../hooks/useMount';\nimport useUpdate from '../hooks/useUpdate';\nimport { noop, getOrCreateModel } from '../utils';\nimport type { DiffEditorProps, MonacoDiffEditor } from './types';\nimport type { Monaco } from '..';\n\nfunction DiffEditor({\n original,\n modified,\n language,\n originalLanguage,\n modifiedLanguage,\n originalModelPath,\n modifiedModelPath,\n keepCurrentOriginalModel = false,\n keepCurrentModifiedModel = false,\n theme = 'light',\n loading = 'Loading...',\n options = {},\n height = '100%',\n width = '100%',\n className,\n wrapperProps = {},\n beforeMount = noop,\n onMount = noop,\n}: DiffEditorProps): ReactElement {\n const [isEditorReady, setIsEditorReady] = useState(false);\n const [isMonacoMounting, setIsMonacoMounting] = useState(true);\n const editorRef = useRef<MonacoDiffEditor | null>(null);\n const monacoRef = useRef<Monaco | null>(null);\n const containerRef = useRef<HTMLDivElement | null>(null);\n const onMountRef = useRef(onMount);\n const beforeMountRef = useRef(beforeMount);\n const preventCreation = useRef(false);\n\n useMount(() => {\n const cancelable = loader.init();\n\n cancelable\n .then((monaco) => (monacoRef.current = monaco as Monaco) && setIsMonacoMounting(false))\n .catch((error) => error?.type !== 'cancelation' && console.error('Monaco initialization: error:', error));\n\n return () => (editorRef.current ? disposeEditor() : cancelable.cancel());\n });\n\n useUpdate(\n () => {\n if (editorRef.current && monacoRef.current) {\n const originalEditor = editorRef.current.getOriginalEditor();\n const model = getOrCreateModel(\n monacoRef.current,\n original || '',\n originalLanguage || language || 'text',\n originalModelPath || ''\n );\n\n if (model !== originalEditor.getModel()) {\n originalEditor.setModel(model);\n }\n }\n },\n [originalModelPath],\n isEditorReady\n );\n\n useUpdate(\n () => {\n if (editorRef.current && monacoRef.current) {\n const modifiedEditor = editorRef.current.getModifiedEditor();\n const model = getOrCreateModel(\n monacoRef.current,\n modified || '',\n modifiedLanguage || language || 'text',\n modifiedModelPath || ''\n );\n\n if (model !== modifiedEditor.getModel()) {\n modifiedEditor.setModel(model);\n }\n }\n },\n [modifiedModelPath],\n isEditorReady\n );\n\n useUpdate(\n () => {\n const modifiedEditor = editorRef.current!.getModifiedEditor();\n if (modifiedEditor.getOption(monacoRef.current!.editor.EditorOption.readOnly)) {\n modifiedEditor.setValue(modified || '');\n } else {\n if (modified !== modifiedEditor.getValue()) {\n modifiedEditor.executeEdits('', [\n {\n range: modifiedEditor.getModel()!.getFullModelRange(),\n text: modified || '',\n forceMoveMarkers: true,\n },\n ]);\n\n modifiedEditor.pushUndoStop();\n }\n }\n },\n [modified],\n isEditorReady\n );\n\n useUpdate(\n () => {\n editorRef.current?.getModel()?.original.setValue(original || '');\n },\n [original],\n isEditorReady\n );\n\n useUpdate(\n () => {\n const { original, modified } = editorRef.current!.getModel()!;\n\n monacoRef.current!.editor.setModelLanguage(original, originalLanguage || language || 'text');\n monacoRef.current!.editor.setModelLanguage(modified, modifiedLanguage || language || 'text');\n },\n [language, originalLanguage, modifiedLanguage],\n isEditorReady\n );\n\n useUpdate(\n () => {\n monacoRef.current?.editor.setTheme(theme);\n },\n [theme],\n isEditorReady\n );\n\n useUpdate(\n () => {\n editorRef.current?.updateOptions(options);\n },\n [options],\n isEditorReady\n );\n\n const setModels = useCallback(() => {\n if (!monacoRef.current) return;\n beforeMountRef.current(monacoRef.current);\n const originalModel = getOrCreateModel(\n monacoRef.current,\n original || '',\n originalLanguage || language || 'text',\n originalModelPath || ''\n );\n\n const modifiedModel = getOrCreateModel(\n monacoRef.current,\n modified || '',\n modifiedLanguage || language || 'text',\n modifiedModelPath || ''\n );\n\n editorRef.current?.setModel({\n original: originalModel,\n modified: modifiedModel,\n });\n }, [language, modified, modifiedLanguage, original, originalLanguage, originalModelPath, modifiedModelPath]);\n\n const createEditor = useCallback(() => {\n if (!preventCreation.current && containerRef.current) {\n editorRef.current = monacoRef.current!.editor.createDiffEditor(containerRef.current, {\n automaticLayout: true,\n ...options,\n });\n\n setModels();\n\n monacoRef.current?.editor.setTheme(theme);\n\n setIsEditorReady(true);\n preventCreation.current = true;\n }\n }, [options, theme, setModels]);\n\n useEffect(() => {\n if (isEditorReady) {\n onMountRef.current(editorRef.current!, monacoRef.current!);\n }\n }, [isEditorReady]);\n\n useEffect(() => {\n if (!isMonacoMounting && !isEditorReady) {\n createEditor();\n }\n }, [isMonacoMounting, isEditorReady, createEditor]);\n\n function disposeEditor(): void {\n const editor = editorRef.current;\n const models = editor?.getModel();\n\n // oxlint-disable-next-line unicorn/no-null -- Monaco detaches diff models with null.\n editor?.setModel(null);\n editor?.dispose();\n\n if (!keepCurrentOriginalModel && !models?.original.isDisposed()) {\n models?.original?.dispose();\n }\n\n if (!keepCurrentModifiedModel && !models?.modified.isDisposed()) {\n models?.modified?.dispose();\n }\n\n // oxlint-disable-next-line unicorn/no-null -- React refs use null after unmount.\n editorRef.current = null;\n preventCreation.current = false;\n setIsEditorReady(false);\n }\n\n return (\n <MonacoContainer\n width={width}\n height={height}\n isEditorReady={isEditorReady}\n loading={loading}\n _ref={containerRef}\n className={className}\n wrapperProps={wrapperProps}\n />\n );\n}\n\nexport default DiffEditor;\n","import { memo } from 'react';\n\nimport MonacoContainer from './MonacoContainer';\n\nexport default memo(MonacoContainer);\n","import type { CSSProperties } from 'react';\n\nconst styles: Record<string, CSSProperties> = {\n wrapper: {\n display: 'flex',\n position: 'relative',\n textAlign: 'initial',\n },\n fullWidth: {\n width: '100%',\n },\n hide: {\n display: 'none',\n },\n};\n\nexport default styles;\n","import type { CSSProperties } from 'react';\n\nconst styles: Record<string, CSSProperties> = {\n container: {\n display: 'flex',\n height: '100%',\n width: '100%',\n justifyContent: 'center',\n alignItems: 'center',\n },\n};\n\nexport default styles;\n","import type { PropsWithChildren, ReactElement } from 'react';\n\nimport styles from './styles';\n\nfunction Loading({ children }: PropsWithChildren): ReactElement {\n return <div style={styles.container}>{children}</div>;\n}\n\nexport default Loading;\n","import Loading from './Loading';\n\nexport default Loading;\n","import type { ReactElement } from 'react';\n\nimport styles from './styles';\nimport Loading from '../Loading';\nimport type { ContainerProps } from './types';\n\n// ** forwardref render functions do not support proptypes or defaultprops **\n// one of the reasons why we use a separate prop for passing ref instead of using forwardref\n\nfunction MonacoContainer({\n width,\n height,\n isEditorReady,\n loading,\n _ref,\n className,\n wrapperProps,\n}: ContainerProps): ReactElement {\n return (\n <section style={{ ...styles.wrapper, width, height }} {...wrapperProps}>\n {!isEditorReady && <Loading>{loading}</Loading>}\n <div ref={_ref} style={{ ...styles.fullWidth, ...(!isEditorReady && styles.hide) }} className={className} />\n </section>\n );\n}\n\nexport default MonacoContainer;\n","import { useEffect } from 'react';\nimport type { EffectCallback } from 'react';\n\nfunction useMount(effect: EffectCallback): void {\n useEffect(effect, []);\n}\n\nexport default useMount;\n","import { useEffect, useRef } from 'react';\nimport type { DependencyList, EffectCallback } from 'react';\n\nfunction useUpdate(effect: EffectCallback, deps: DependencyList, applyChanges = true): void {\n const isInitialMount = useRef(true);\n\n useEffect(\n isInitialMount.current || !applyChanges\n ? () => {\n isInitialMount.current = false;\n }\n : effect,\n deps\n );\n}\n\nexport default useUpdate;\n","import type { Monaco } from '..';\nimport type { Uri, editor } from 'monaco-editor/esm/vs/editor/editor.api.js';\n\n/**\n * noop is a helper function that does nothing\n * @returns undefined\n */\nfunction noop(): void {\n /** no-op */\n}\n\n/**\n * getOrCreateModel is a helper function that will return a model if it exists\n * or create a new model if it does not exist.\n * This is useful for when you want to create a model for a file that may or may not exist yet.\n * @param monaco The monaco instance\n * @param value The value of the model\n * @param language The language of the model\n * @param path The path of the model\n * @returns The model that was found or created\n */\nfunction getOrCreateModel(monaco: Monaco, value: string, language: string, path: string): editor.ITextModel {\n return getModel(monaco, path) ?? createModel(monaco, value, language, path);\n}\n\n/**\n * getModel is a helper function that will return a model if it exists\n * or return undefined if it does not exist.\n * @param monaco The monaco instance\n * @param path The path of the model\n * @returns The model that was found or undefined\n */\nfunction getModel(monaco: Monaco, path: string): editor.ITextModel | null {\n return monaco.editor.getModel(createModelUri(monaco, path));\n}\n\n/**\n * createModel is a helper function that will create a new model\n * @param monaco The monaco instance\n * @param value The value of the model\n * @param language The language of the model\n * @param path The path of the model\n * @returns The model that was created\n */\nfunction createModel(monaco: Monaco, value: string, language?: string, path?: string): editor.ITextModel {\n return monaco.editor.createModel(value, language, path ? createModelUri(monaco, path) : undefined);\n}\n\n/**\n * createModelUri is a helper function that will create a new model uri\n * @param monaco The monaco instance\n * @param path The path of the model\n * @returns The model uri that was created\n */\nfunction createModelUri(monaco: Monaco, path: string): Uri {\n return monaco.Uri.parse(path);\n}\n\nexport { noop, getOrCreateModel };\n","import { useState } from 'react';\nimport loader from '@willbooster/monaco-loader';\n\nimport useMount from '../useMount';\nimport type { Monaco } from '../..';\n\nfunction useMonaco(): Monaco | undefined {\n const [monaco, setMonaco] = useState<Monaco | undefined>(loader.__getMonacoInstance() as Monaco | undefined);\n\n useMount(() => {\n let cancelable: ReturnType<typeof loader.init>;\n\n if (!monaco) {\n cancelable = loader.init();\n\n void cancelable\n .then((monaco) => {\n setMonaco(monaco as Monaco);\n return;\n })\n .catch((error: unknown) => {\n if ((error as { type?: unknown })?.type !== 'cancelation') {\n console.error('Monaco initialization: error:', error);\n }\n });\n }\n\n return () => cancelable?.cancel();\n });\n\n return monaco;\n}\n\nexport default useMonaco;\n","import { memo } from 'react';\n\nimport Editor from './Editor';\n\nexport * from './types';\n\nexport default memo(Editor);\n","'use client';\n\nimport { useState, useEffect, useRef, useCallback } from 'react';\nimport type { ReactElement } from 'react';\nimport loader from '@willbooster/monaco-loader';\nimport useMount from '../hooks/useMount';\nimport useUpdate from '../hooks/useUpdate';\nimport usePrevious from '../hooks/usePrevious';\nimport type { IDisposable, Uri, editor } from 'monaco-editor/esm/vs/editor/editor.api.js';\nimport { noop, getOrCreateModel } from '../utils';\nimport type { EditorProps } from './types';\nimport type { Monaco } from '..';\nimport MonacoContainer from '../MonacoContainer';\n\nconst viewStates = new Map();\n\nfunction Editor({\n defaultValue,\n defaultLanguage,\n defaultPath,\n value,\n language,\n path,\n /* === */\n theme = 'light',\n line,\n loading = 'Loading...',\n options = {},\n overrideServices = {},\n saveViewState = true,\n keepCurrentModel = false,\n /* === */\n width = '100%',\n height = '100%',\n className,\n wrapperProps = {},\n /* === */\n beforeMount = noop,\n onMount = noop,\n onChange,\n onValidate = noop,\n}: EditorProps): ReactElement {\n const [isEditorReady, setIsEditorReady] = useState(false);\n const [isMonacoMounting, setIsMonacoMounting] = useState(true);\n const monacoRef = useRef<Monaco | null>(null);\n const editorRef = useRef<editor.IStandaloneCodeEditor | null>(null);\n const containerRef = useRef<HTMLDivElement | null>(null);\n const onMountRef = useRef(onMount);\n const beforeMountRef = useRef(beforeMount);\n const subscriptionRef = useRef<IDisposable | undefined>(undefined);\n const valueRef = useRef(value);\n const previousPath = usePrevious(path);\n const preventCreation = useRef(false);\n const preventTriggerChangeEvent = useRef<boolean>(false);\n\n useMount(() => {\n const cancelable = loader.init();\n\n cancelable\n .then((monaco) => (monacoRef.current = monaco as Monaco) && setIsMonacoMounting(false))\n .catch((error) => error?.type !== 'cancelation' && console.error('Monaco initialization: error:', error));\n\n return () => (editorRef.current ? disposeEditor() : cancelable.cancel());\n });\n\n useUpdate(\n () => {\n const model = getOrCreateModel(\n monacoRef.current!,\n defaultValue || value || '',\n defaultLanguage || language || '',\n path || defaultPath || ''\n );\n\n if (model !== editorRef.current?.getModel()) {\n if (saveViewState) viewStates.set(previousPath, editorRef.current?.saveViewState());\n editorRef.current?.setModel(model);\n if (saveViewState) editorRef.current?.restoreViewState(viewStates.get(path));\n }\n },\n [path],\n isEditorReady\n );\n\n useUpdate(\n () => {\n editorRef.current?.updateOptions(options);\n },\n [options],\n isEditorReady\n );\n\n useUpdate(\n () => {\n if (!editorRef.current || value === undefined) return;\n if (editorRef.current.getOption(monacoRef.current!.editor.EditorOption.readOnly)) {\n editorRef.current.setValue(value);\n } else if (value !== editorRef.current.getValue()) {\n preventTriggerChangeEvent.current = true;\n editorRef.current.executeEdits('', [\n {\n range: editorRef.current.getModel()!.getFullModelRange(),\n text: value,\n forceMoveMarkers: true,\n },\n ]);\n\n editorRef.current.pushUndoStop();\n preventTriggerChangeEvent.current = false;\n }\n },\n [value],\n isEditorReady\n );\n\n useUpdate(\n () => {\n const model = editorRef.current?.getModel();\n if (isEditorReady && model && language) {\n monacoRef.current?.editor.setModelLanguage(model, language);\n }\n },\n [language, isEditorReady],\n isEditorReady\n );\n\n useUpdate(\n () => {\n // reason for undefined check: https://github.com/suren-atoyan/monaco-react/pull/188\n if (line !== undefined) {\n editorRef.current?.revealLine(line);\n }\n },\n [line],\n isEditorReady\n );\n\n useUpdate(\n () => {\n monacoRef.current?.editor.setTheme(theme);\n },\n [theme],\n isEditorReady\n );\n\n const createEditor = useCallback(() => {\n if (!containerRef.current || !monacoRef.current) return;\n if (!preventCreation.current) {\n beforeMountRef.current(monacoRef.current);\n const autoCreatedModelPath = path || defaultPath;\n\n const defaultModel = getOrCreateModel(\n monacoRef.current,\n value || defaultValue || '',\n defaultLanguage || language || '',\n autoCreatedModelPath || ''\n );\n\n const editor = monacoRef.current.editor.create(\n containerRef.current,\n {\n model: defaultModel,\n automaticLayout: true,\n ...options,\n },\n overrideServices\n );\n editorRef.current = editor;\n\n saveViewState && editor.restoreViewState(viewStates.get(autoCreatedModelPath));\n\n monacoRef.current.editor.setTheme(theme);\n\n if (line !== undefined) {\n editor.revealLine(line);\n }\n\n setIsEditorReady(true);\n preventCreation.current = true;\n }\n }, [\n defaultValue,\n defaultLanguage,\n defaultPath,\n value,\n language,\n path,\n options,\n overrideServices,\n saveViewState,\n theme,\n line,\n ]);\n\n useEffect(() => {\n if (isEditorReady) {\n onMountRef.current(editorRef.current!, monacoRef.current!);\n }\n }, [isEditorReady]);\n\n useEffect(() => {\n !isMonacoMounting && !isEditorReady && createEditor();\n }, [isMonacoMounting, isEditorReady, createEditor]);\n\n // subscription\n // to avoid unnecessary updates (attach - dispose listener) in subscription\n valueRef.current = value;\n\n // onChange\n useEffect(() => {\n if (isEditorReady && onChange) {\n subscriptionRef.current?.dispose();\n subscriptionRef.current = editorRef.current?.onDidChangeModelContent((event) => {\n if (!preventTriggerChangeEvent.current) {\n onChange(editorRef.current!.getValue(), event);\n }\n });\n }\n }, [isEditorReady, onChange]);\n\n // onValidate\n useEffect(() => {\n if (isEditorReady) {\n const changeMarkersListener = monacoRef.current!.editor.onDidChangeMarkers((uris: readonly Uri[]) => {\n const editorUri = editorRef.current!.getModel()?.uri;\n\n if (editorUri) {\n const currentEditorHasMarkerChanges = uris.find((uri: Uri) => uri.path === editorUri.path);\n if (currentEditorHasMarkerChanges) {\n const markers = monacoRef.current!.editor.getModelMarkers({\n resource: editorUri,\n });\n onValidate?.(markers);\n }\n }\n });\n\n return () => {\n changeMarkersListener?.dispose();\n };\n }\n return () => {\n // eslint happy\n };\n }, [isEditorReady, onValidate]);\n\n function disposeEditor(): void {\n subscriptionRef.current?.dispose();\n\n if (keepCurrentModel) {\n saveViewState && viewStates.set(path, editorRef.current!.saveViewState());\n } else {\n editorRef.current!.getModel()?.dispose();\n }\n\n editorRef.current!.dispose();\n\n editorRef.current = null;\n preventCreation.current = false;\n setIsEditorReady(false);\n }\n\n return (\n <MonacoContainer\n width={width}\n height={height}\n isEditorReady={isEditorReady}\n loading={loading}\n _ref={containerRef}\n className={className}\n wrapperProps={wrapperProps}\n />\n );\n}\n\nexport default Editor;\n","import { useEffect, useRef } from 'react';\n\nfunction usePrevious<T>(value: T): T | undefined {\n const ref = useRef<T | undefined>(undefined);\n\n useEffect(() => {\n ref.current = value;\n }, [value]);\n\n return ref.current;\n}\n\nexport default useP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AAA,MACA;AAAA;AAAA,EACF;AAEJ;AAEA,IAAO,iBAAQ;;;AD7Qf,IAAOC,kBAAQC,MAAK,cAAM;;;AbO1B,IAAO,gBAAQC;","names":["loader","memo","useRef","useEffect","styles","styles_default","styles_default","Loading_default","jsx","Loading_default","MonacoContainer_default","useEffect","jsx","useRef","original","modified","useEffect","MonacoContainer_default","DiffEditor_default","memo","useState","loader","useState","loader","monaco","memo","useState","useEffect","useRef","useCallback","loader","useEffect","useRef","jsx","useState","useRef","loader","useCallback","useEffect","MonacoContainer_default","Editor_default","memo","Editor_default"]}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -0,0 +1,2 @@
1
+ "use strict";function e(e,r){return e.Uri.parse(r)}exports.getOrCreateModel=function(r,t,n,o){var u;return null!=(u=function(r,t){return r.editor.getModel(e(r,t))}(r,o))?u:function(r,t,n,o){return r.editor.createModel(t,n,o?e(r,o):void 0)}(r,t,n,o)},exports.noop=function(){};
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../../src/utils/index.ts"],"sourcesContent":["import type { Monaco } from '..';\nimport type { Uri, editor } from 'monaco-editor/esm/vs/editor/editor.api.js';\n\n/**\n * noop is a helper function that does nothing\n * @returns undefined\n */\nfunction noop(): void {\n /** no-op */\n}\n\n/**\n * getOrCreateModel is a helper function that will return a model if it exists\n * or create a new model if it does not exist.\n * This is useful for when you want to create a model for a file that may or may not exist yet.\n * @param monaco The monaco instance\n * @param value The value of the model\n * @param language The language of the model\n * @param path The path of the model\n * @returns The model that was found or created\n */\nfunction getOrCreateModel(monaco: Monaco, value: string, language: string, path: string): editor.ITextModel {\n return getModel(monaco, path) ?? createModel(monaco, value, language, path);\n}\n\n/**\n * getModel is a helper function that will return a model if it exists\n * or return undefined if it does not exist.\n * @param monaco The monaco instance\n * @param path The path of the model\n * @returns The model that was found or undefined\n */\nfunction getModel(monaco: Monaco, path: string): editor.ITextModel | null {\n return monaco.editor.getModel(createModelUri(monaco, path));\n}\n\n/**\n * createModel is a helper function that will create a new model\n * @param monaco The monaco instance\n * @param value The value of the model\n * @param language The language of the model\n * @param path The path of the model\n * @returns The model that was created\n */\nfunction createModel(monaco: Monaco, value: string, language?: string, path?: string): editor.ITextModel {\n return monaco.editor.createModel(value, language, path ? createModelUri(monaco, path) : undefined);\n}\n\n/**\n * createModelUri is a helper function that will create a new model uri\n * @param monaco The monaco instance\n * @param path The path of the model\n * @returns The model uri that was created\n */\nfunction createModelUri(monaco: Monaco, path: string): Uri {\n return monaco.Uri.parse(path);\n}\n\nexport { noop, getOrCreateModel };\n"],"names":["createModelUri","monaco","path","Uri","parse","value","language","_getModel","editor","getModel","createModel","undefined"],"mappings":"aAsDA,SAASA,EAAeC,EAAgBC,GACtC,OAAOD,EAAOE,IAAIC,MAAMF,EAC1B,0BAnCA,SAA0BD,EAAgBI,EAAeC,EAAkBJ,GAAiC,IAAAK,EAC1G,OAA6B,OAA7BA,EAUF,SAAkBN,EAAgBC,GAChC,OAAOD,EAAOO,OAAOC,SAAST,EAAeC,EAAQC,GACvD,CAZSO,CAASR,EAAQC,IAAKK,EAsB/B,SAAqBN,EAAgBI,EAAeC,EAAmBJ,GACrE,OAAOD,EAAOO,OAAOE,YAAYL,EAAOC,EAAUJ,EAAOF,EAAeC,EAAQC,QAAQS,EAC1F,CAxBmCD,CAAYT,EAAQI,EAAOC,EAAUJ,EACxE,eAhBA,WACE"}