@willbooster/monaco-react 1.0.4 → 1.0.5

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 (117) hide show
  1. package/README.md +2 -2
  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/useMount/index.cjs +2 -0
  87. package/dist/hooks/useMount/index.cjs.map +1 -0
  88. package/dist/hooks/useMount/index.d.ts +4 -0
  89. package/dist/hooks/useMount/index.d.ts.map +1 -0
  90. package/dist/hooks/useMount/index.js +2 -0
  91. package/dist/hooks/useMount/index.js.map +1 -0
  92. package/dist/hooks/usePrevious/index.cjs +2 -0
  93. package/dist/hooks/usePrevious/index.cjs.map +1 -0
  94. package/dist/hooks/usePrevious/index.d.ts +3 -0
  95. package/dist/hooks/usePrevious/index.d.ts.map +1 -0
  96. package/dist/hooks/usePrevious/index.js +2 -0
  97. package/dist/hooks/usePrevious/index.js.map +1 -0
  98. package/dist/hooks/useUpdate/index.cjs +2 -0
  99. package/dist/hooks/useUpdate/index.cjs.map +1 -0
  100. package/dist/hooks/useUpdate/index.d.ts +4 -0
  101. package/dist/hooks/useUpdate/index.d.ts.map +1 -0
  102. package/dist/hooks/useUpdate/index.js +2 -0
  103. package/dist/hooks/useUpdate/index.js.map +1 -0
  104. package/dist/index.cjs +3 -625
  105. package/dist/index.cjs.map +1 -1
  106. package/dist/index.d.ts +15 -231
  107. package/dist/index.d.ts.map +1 -0
  108. package/dist/index.js +3 -588
  109. package/dist/index.js.map +1 -1
  110. package/dist/utils/index.cjs +2 -0
  111. package/dist/utils/index.cjs.map +1 -0
  112. package/dist/utils/index.d.ts +20 -0
  113. package/dist/utils/index.d.ts.map +1 -0
  114. package/dist/utils/index.js +2 -0
  115. package/dist/utils/index.js.map +1 -0
  116. package/package.json +5 -4
  117. package/dist/index.d.cts +0 -231
@@ -0,0 +1,20 @@
1
+ import type { Monaco } from '..';
2
+ import type { editor } from 'monaco-editor/esm/vs/editor/editor.api.js';
3
+ /**
4
+ * noop is a helper function that does nothing
5
+ * @returns undefined
6
+ */
7
+ declare function noop(): void;
8
+ /**
9
+ * getOrCreateModel is a helper function that will return a model if it exists
10
+ * or create a new model if it does not exist.
11
+ * This is useful for when you want to create a model for a file that may or may not exist yet.
12
+ * @param monaco The monaco instance
13
+ * @param value The value of the model
14
+ * @param language The language of the model
15
+ * @param path The path of the model
16
+ * @returns The model that was found or created
17
+ */
18
+ declare function getOrCreateModel(monaco: Monaco, value: string, language: string, path: string): editor.ITextModel;
19
+ export { noop, getOrCreateModel };
20
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AACjC,OAAO,KAAK,EAAO,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAE7E;;;GAGG;AACH,iBAAS,IAAI,IAAI,IAAI,CAEpB;AAED;;;;;;;;;GASG;AACH,iBAAS,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,UAAU,CAE1G;AAmCD,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ function n(){}function r(n,r,e,o){var u;return null!=(u=function(n,r){return n.editor.getModel(t(n,r))}(n,o))?u:function(n,r,e,o){return n.editor.createModel(r,e,o?t(n,o):void 0)}(n,r,e,o)}function t(n,r){return n.Uri.parse(r)}export{r as getOrCreateModel,n as noop};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","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":["noop","getOrCreateModel","monaco","value","language","path","_getModel","editor","getModel","createModelUri","createModel","undefined","Uri","parse"],"mappings":"AAOA,SAASA,IACP,CAaF,SAASC,EAAiBC,EAAgBC,EAAeC,EAAkBC,GAAiC,IAAAC,EAC1G,OAA6B,OAA7BA,EAUF,SAAkBJ,EAAgBG,GAChC,OAAOH,EAAOK,OAAOC,SAASC,EAAeP,EAAQG,GACvD,CAZSG,CAASN,EAAQG,IAAKC,EAsB/B,SAAqBJ,EAAgBC,EAAeC,EAAmBC,GACrE,OAAOH,EAAOK,OAAOG,YAAYP,EAAOC,EAAUC,EAAOI,EAAeP,EAAQG,QAAQM,EAC1F,CAxBmCD,CAAYR,EAAQC,EAAOC,EAAUC,EACxE,CA+BA,SAASI,EAAeP,EAAgBG,GACtC,OAAOH,EAAOU,IAAIC,MAAMR,EAC1B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/monaco-react",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "Monaco Editor for React - use the monaco-editor in any React application without needing to use webpack (or rollup/parcel/etc) configuration files / plugins",
5
5
  "keywords": [
6
6
  "code",
@@ -38,10 +38,12 @@
38
38
  "access": "public"
39
39
  },
40
40
  "scripts": {
41
- "build": "tsup",
41
+ "build": "yarn run build/core",
42
+ "build/core": "build-ts lib",
42
43
  "check-all-for-ai": "yarn check-for-ai && yarn test",
43
44
  "check-for-ai": "yarn install > /dev/null && yarn format > /dev/null 2> /dev/null || true && yarn lint-fix --quiet",
44
45
  "cleanup": "yarn format && yarn lint-fix",
46
+ "common/ci-setup": "yarn run build/core",
45
47
  "format": "sort-package-json && yarn format-code",
46
48
  "format-code": "oxfmt --write --no-error-on-unmatched-pattern .",
47
49
  "lint": "oxlint --no-error-on-unmatched-pattern .",
@@ -70,6 +72,7 @@
70
72
  "@typescript/native-preview": "7.0.0-dev.20260418.1",
71
73
  "@willbooster/oxfmt-config": "1.2.1",
72
74
  "@willbooster/oxlint-config": "1.4.4",
75
+ "build-ts": "17.1.5",
73
76
  "conventional-changelog-conventionalcommits": "9.3.1",
74
77
  "jsdom": "29.0.2",
75
78
  "lefthook": "2.1.5",
@@ -81,8 +84,6 @@
81
84
  "react-dom": "19.2.5",
82
85
  "semantic-release": "25.0.3",
83
86
  "sort-package-json": "3.6.1",
84
- "tsup": "8.5.0",
85
- "typescript": "5.9.3",
86
87
  "vitest": "4.1.4"
87
88
  },
88
89
  "peerDependencies": {
package/dist/index.d.cts DELETED
@@ -1,231 +0,0 @@
1
- export { default as loader } from '@willbooster/monaco-loader';
2
- import * as react from 'react';
3
- import { ReactNode, ReactElement } from 'react';
4
- import * as monaco from 'monaco-editor/esm/vs/editor/editor.api.js';
5
- import { editor } from 'monaco-editor/esm/vs/editor/editor.api.js';
6
-
7
- type MonacoDiffEditor = editor.IStandaloneDiffEditor;
8
- type DiffOnMount = (editor: MonacoDiffEditor, monaco: Monaco) => void;
9
- type DiffBeforeMount = (monaco: Monaco) => void;
10
- interface DiffEditorProps {
11
- /**
12
- * The original source (left one) value
13
- */
14
- original?: string;
15
- /**
16
- * The modified source (right one) value
17
- */
18
- modified?: string;
19
- /**
20
- * Language for the both models - original and modified
21
- */
22
- language?: string;
23
- /**
24
- * This prop gives you the opportunity to specify the language of the
25
- * original source separately, otherwise, it will get the value of the language property
26
- */
27
- originalLanguage?: string;
28
- /**
29
- * This prop gives you the opportunity to specify the language of the
30
- * modified source separately, otherwise, it will get the value of language property
31
- */
32
- modifiedLanguage?: string;
33
- /**
34
- * Path for the "original" model
35
- * Will be passed as a third argument to `.createModel` method
36
- * `monaco.editor.createModel(..., ..., monaco.Uri.parse(originalModelPath))`
37
- */
38
- originalModelPath?: string;
39
- /**
40
- * Path for the "modified" model
41
- * Will be passed as a third argument to `.createModel` method
42
- * `monaco.editor.createModel(..., ..., monaco.Uri.parse(modifiedModelPath))`
43
- */
44
- modifiedModelPath?: string;
45
- /**
46
- * Indicator whether to dispose the current original model when the DiffEditor is unmounted or not
47
- * @default false
48
- */
49
- keepCurrentOriginalModel?: boolean;
50
- /**
51
- * Indicator whether to dispose the current modified model when the DiffEditor is unmounted or not
52
- * @default false
53
- */
54
- keepCurrentModifiedModel?: boolean;
55
- /**
56
- * The theme for the monaco
57
- * Available options "vs-dark" | "light"
58
- * Define new themes by `monaco.editor.defineTheme`
59
- * @default "light"
60
- */
61
- theme?: Theme | string;
62
- /**
63
- * The loading screen before the editor will be mounted
64
- * @default "loading..."
65
- */
66
- loading?: ReactNode;
67
- /**
68
- * IDiffEditorConstructionOptions
69
- */
70
- options?: editor.IDiffEditorConstructionOptions;
71
- /**
72
- * Width of the editor wrapper
73
- * @default "100%"
74
- */
75
- width?: number | string;
76
- /**
77
- * Height of the editor wrapper
78
- * @default "100%"
79
- */
80
- height?: number | string;
81
- /**
82
- * Class name for the editor container
83
- */
84
- className?: string;
85
- /**
86
- * Props applied to the wrapper element
87
- */
88
- wrapperProps?: object;
89
- /**
90
- * Signature: function(monaco: Monaco) => void
91
- * An event is emitted before the editor is mounted
92
- * It gets the monaco instance as a first argument
93
- * Defaults to "noop"
94
- */
95
- beforeMount?: DiffBeforeMount;
96
- /**
97
- * Signature: function(editor: monaco.editor.IStandaloneCodeEditor, monaco: Monaco) => void
98
- * An event is emitted when the editor is mounted
99
- * It gets the editor instance as a first argument and the monaco instance as a second
100
- * Defaults to "noop"
101
- */
102
- onMount?: DiffOnMount;
103
- }
104
-
105
- declare function DiffEditor({ original, modified, language, originalLanguage, modifiedLanguage, originalModelPath, modifiedModelPath, keepCurrentOriginalModel, keepCurrentModifiedModel, theme, loading, options, height, width, className, wrapperProps, beforeMount, onMount, }: DiffEditorProps): ReactElement;
106
-
107
- declare const _default$1: react.MemoExoticComponent<typeof DiffEditor>;
108
-
109
- declare function useMonaco(): Monaco | undefined;
110
-
111
- type OnMount = (editor: editor.IStandaloneCodeEditor, monaco: Monaco) => void;
112
- type BeforeMount = (monaco: Monaco) => void;
113
- type OnChange = (value: string | undefined, ev: editor.IModelContentChangedEvent) => void;
114
- type OnValidate = (markers: editor.IMarker[]) => void;
115
- interface EditorProps {
116
- /**
117
- * Default value of the current model
118
- */
119
- defaultValue?: string;
120
- /**
121
- * Default language of the current model
122
- */
123
- defaultLanguage?: string;
124
- /**
125
- * Default path of the current model
126
- * Will be passed as the third argument to `.createModel` method
127
- * `monaco.editor.createModel(..., ..., monaco.Uri.parse(defaultPath))`
128
- */
129
- defaultPath?: string;
130
- /**
131
- * Value of the current model
132
- */
133
- value?: string;
134
- /**
135
- * Language of the current model
136
- */
137
- language?: string;
138
- /**
139
- * Path of the current model
140
- * Will be passed as the third argument to `.createModel` method
141
- * `monaco.editor.createModel(..., ..., monaco.Uri.parse(defaultPath))`
142
- */
143
- path?: string;
144
- /**
145
- * The theme for the monaco
146
- * Available options "vs-dark" | "light"
147
- * Define new themes by `monaco.editor.defineTheme`
148
- * @default "light"
149
- */
150
- theme?: Theme | string;
151
- /**
152
- * The line to jump on it
153
- */
154
- line?: number;
155
- /**
156
- * The loading screen before the editor will be mounted
157
- * @default "Loading..."
158
- */
159
- loading?: ReactNode;
160
- /**
161
- * IStandaloneEditorConstructionOptions
162
- */
163
- options?: editor.IStandaloneEditorConstructionOptions;
164
- /**
165
- * IEditorOverrideServices
166
- */
167
- overrideServices?: editor.IEditorOverrideServices;
168
- /**
169
- * Indicator whether to save the models' view states between model changes or not
170
- * Defaults to true
171
- */
172
- saveViewState?: boolean;
173
- /**
174
- * Indicator whether to dispose the current model when the Editor is unmounted or not
175
- * @default false
176
- */
177
- keepCurrentModel?: boolean;
178
- /**
179
- * Width of the editor wrapper
180
- * @default "100%"
181
- */
182
- width?: number | string;
183
- /**
184
- * Height of the editor wrapper
185
- * @default "100%"
186
- */
187
- height?: number | string;
188
- /**
189
- * Class name for the editor container
190
- */
191
- className?: string;
192
- /**
193
- * Props applied to the wrapper element
194
- */
195
- wrapperProps?: object;
196
- /**
197
- * Signature: function(monaco: Monaco) => void
198
- * An event is emitted before the editor is mounted
199
- * It gets the monaco instance as a first argument
200
- * Defaults to "noop"
201
- */
202
- beforeMount?: BeforeMount;
203
- /**
204
- * Signature: function(editor: monaco.editor.IStandaloneCodeEditor, monaco: Monaco) => void
205
- * An event is emitted when the editor is mounted
206
- * It gets the editor instance as a first argument and the monaco instance as a second
207
- * Defaults to "noop"
208
- */
209
- onMount?: OnMount;
210
- /**
211
- * Signature: function(value: string | undefined, ev: monaco.editor.IModelContentChangedEvent) => void
212
- * An event is emitted when the content of the current model is changed
213
- */
214
- onChange?: OnChange;
215
- /**
216
- * Signature: function(markers: monaco.editor.IMarker[]) => void
217
- * An event is emitted when the content of the current model is changed
218
- * and the current model markers are ready
219
- * Defaults to "noop"
220
- */
221
- onValidate?: OnValidate;
222
- }
223
-
224
- declare function Editor({ defaultValue, defaultLanguage, defaultPath, value, language, path, theme, line, loading, options, overrideServices, saveViewState, keepCurrentModel, width, height, className, wrapperProps, beforeMount, onMount, onChange, onValidate, }: EditorProps): ReactElement;
225
-
226
- declare const _default: react.MemoExoticComponent<typeof Editor>;
227
-
228
- type Monaco = typeof monaco;
229
- type Theme = 'vs-dark' | 'light';
230
-
231
- export { type BeforeMount, type DiffBeforeMount, _default$1 as DiffEditor, type DiffEditorProps, type DiffOnMount, _default as Editor, type EditorProps, type Monaco, type MonacoDiffEditor, type OnChange, type OnMount, type OnValidate, type Theme, _default as default, useMonaco };