@willbooster/monaco-react 1.0.9 → 2.0.0

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 (91) hide show
  1. package/README.md +3 -0
  2. package/dist/DiffEditor/DiffEditor.cjs +2 -3
  3. package/dist/DiffEditor/DiffEditor.cjs.map +1 -1
  4. package/dist/DiffEditor/DiffEditor.js +2 -3
  5. package/dist/DiffEditor/DiffEditor.js.map +1 -1
  6. package/dist/DiffEditor/index.cjs +2 -2
  7. package/dist/DiffEditor/index.cjs.map +1 -1
  8. package/dist/DiffEditor/index.js +2 -2
  9. package/dist/DiffEditor/index.js.map +1 -1
  10. package/dist/DiffEditor/types.d.ts +1 -1
  11. package/dist/DiffEditor/types.d.ts.map +1 -1
  12. package/dist/Editor/Editor.cjs +2 -3
  13. package/dist/Editor/Editor.cjs.map +1 -1
  14. package/dist/Editor/Editor.js +2 -3
  15. package/dist/Editor/Editor.js.map +1 -1
  16. package/dist/Editor/index.cjs +2 -2
  17. package/dist/Editor/index.cjs.map +1 -1
  18. package/dist/Editor/index.js +2 -2
  19. package/dist/Editor/index.js.map +1 -1
  20. package/dist/Editor/types.d.ts +1 -1
  21. package/dist/Editor/types.d.ts.map +1 -1
  22. package/dist/Loading/Loading.cjs +2 -2
  23. package/dist/Loading/Loading.cjs.map +1 -1
  24. package/dist/Loading/Loading.js +2 -2
  25. package/dist/Loading/Loading.js.map +1 -1
  26. package/dist/Loading/index.cjs +2 -2
  27. package/dist/Loading/index.cjs.map +1 -1
  28. package/dist/Loading/index.js +2 -2
  29. package/dist/Loading/index.js.map +1 -1
  30. package/dist/Loading/styles.cjs +2 -2
  31. package/dist/Loading/styles.cjs.map +1 -1
  32. package/dist/Loading/styles.js +2 -2
  33. package/dist/Loading/styles.js.map +1 -1
  34. package/dist/MonacoContainer/MonacoContainer.cjs +2 -2
  35. package/dist/MonacoContainer/MonacoContainer.cjs.map +1 -1
  36. package/dist/MonacoContainer/MonacoContainer.js +2 -2
  37. package/dist/MonacoContainer/MonacoContainer.js.map +1 -1
  38. package/dist/MonacoContainer/index.cjs +2 -2
  39. package/dist/MonacoContainer/index.cjs.map +1 -1
  40. package/dist/MonacoContainer/index.js +2 -2
  41. package/dist/MonacoContainer/index.js.map +1 -1
  42. package/dist/MonacoContainer/styles.cjs +2 -2
  43. package/dist/MonacoContainer/styles.cjs.map +1 -1
  44. package/dist/MonacoContainer/styles.js +2 -2
  45. package/dist/MonacoContainer/styles.js.map +1 -1
  46. package/dist/_virtual/_rolldown/runtime.cjs +1 -0
  47. package/dist/hooks/useMonaco/index.cjs +2 -2
  48. package/dist/hooks/useMonaco/index.cjs.map +1 -1
  49. package/dist/hooks/useMonaco/index.js +2 -2
  50. package/dist/hooks/useMonaco/index.js.map +1 -1
  51. package/dist/hooks/useMonaco/initMonaco.cjs +2 -2
  52. package/dist/hooks/useMonaco/initMonaco.cjs.map +1 -1
  53. package/dist/hooks/useMonaco/initMonaco.js +2 -2
  54. package/dist/hooks/useMonaco/initMonaco.js.map +1 -1
  55. package/dist/hooks/useMount/index.cjs +2 -2
  56. package/dist/hooks/useMount/index.cjs.map +1 -1
  57. package/dist/hooks/useMount/index.js +2 -2
  58. package/dist/hooks/useMount/index.js.map +1 -1
  59. package/dist/hooks/usePrevious/index.cjs +2 -2
  60. package/dist/hooks/usePrevious/index.cjs.map +1 -1
  61. package/dist/hooks/usePrevious/index.js +2 -2
  62. package/dist/hooks/usePrevious/index.js.map +1 -1
  63. package/dist/hooks/useUpdate/index.cjs +2 -2
  64. package/dist/hooks/useUpdate/index.cjs.map +1 -1
  65. package/dist/hooks/useUpdate/index.js +2 -2
  66. package/dist/hooks/useUpdate/index.js.map +1 -1
  67. package/dist/index.cjs +2 -3
  68. package/dist/index.cjs.map +1 -1
  69. package/dist/index.d.ts +1 -1
  70. package/dist/index.d.ts.map +1 -1
  71. package/dist/index.js +2 -3
  72. package/dist/index.js.map +1 -1
  73. package/dist/utils/index.cjs +2 -2
  74. package/dist/utils/index.cjs.map +1 -1
  75. package/dist/utils/index.d.ts +1 -1
  76. package/dist/utils/index.d.ts.map +1 -1
  77. package/dist/utils/index.js +2 -2
  78. package/dist/utils/index.js.map +1 -1
  79. package/package.json +23 -25
  80. package/dist/DiffEditor/index.spec.d.ts +0 -2
  81. package/dist/DiffEditor/index.spec.d.ts.map +0 -1
  82. package/dist/Editor/index.spec.d.ts +0 -2
  83. package/dist/Editor/index.spec.d.ts.map +0 -1
  84. package/dist/Loading/index.spec.d.ts +0 -2
  85. package/dist/Loading/index.spec.d.ts.map +0 -1
  86. package/dist/MonacoContainer/index.spec.d.ts +0 -2
  87. package/dist/MonacoContainer/index.spec.d.ts.map +0 -1
  88. package/dist/_virtual/_rollupPluginBabelHelpers.cjs +0 -2
  89. package/dist/_virtual/_rollupPluginBabelHelpers.cjs.map +0 -1
  90. package/dist/_virtual/_rollupPluginBabelHelpers.js +0 -2
  91. package/dist/_virtual/_rollupPluginBabelHelpers.js.map +0 -1
package/README.md CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  [![Test](https://github.com/WillBooster/monaco-react/actions/workflows/test.yml/badge.svg)](https://github.com/WillBooster/monaco-react/actions/workflows/test.yml)
4
4
  [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
5
+ [![wbfy](https://img.shields.io/badge/wbfy-8b20e47b--local-1e90ff.svg)](https://github.com/WillBooster/shared/tree/main/packages/wbfy)
5
6
 
6
7
  [![monthly downloads](https://img.shields.io/npm/dm/@willbooster/monaco-react)](https://www.npmjs.com/package/@willbooster/monaco-react)
7
8
  [![npm version](https://img.shields.io/npm/v/@willbooster/monaco-react.svg?style=flat)](https://www.npmjs.com/package/@willbooster/monaco-react)
@@ -18,6 +19,8 @@ yarn add @willbooster/monaco-react
18
19
 
19
20
  `react` and `react-dom` are peer dependencies. `monaco-editor` is a direct dependency for Monaco type resolution. This package supports React 19.x, Node.js 24 or newer, and is tested with Next.js 16.
20
21
 
22
+ TypeScript consumers need a `moduleResolution` of `bundler`, `node16`, or `nodenext`. `monaco-editor` 0.56.0 exposes its types only through its `exports` map — its legacy `typings` field points at a file that is not in the published tarball — so the legacy `node10` resolution cannot find them.
23
+
21
24
  ## Usage
22
25
 
23
26
  ```tsx
@@ -1,3 +1,2 @@
1
- "use client";
2
- "use strict";var e=require("../_virtual/_rollupPluginBabelHelpers.cjs"),r=require("react"),t=require("../MonacoContainer/index.cjs"),o=require("../hooks/useMount/index.cjs"),i=require("../hooks/useUpdate/index.cjs"),n=require("../hooks/useMonaco/index.cjs"),u=require("../utils/index.cjs"),d=require("react/jsx-runtime");function l(r){const o=n();if(!o){const{width:e="100%",height:o="100%",loading:i="Loading...",className:n,wrapperProps:u={}}=r;return d.jsx(t,{width:e,height:o,isEditorReady:!1,loading:i,className:n,wrapperProps:u})}return d.jsx(a,e.objectSpread2(e.objectSpread2({},r),{},{monaco:o}))}function a({monaco:n,original:l,modified:a,language:s,originalLanguage:c,modifiedLanguage:g,originalModelPath:p,modifiedModelPath:f,keepCurrentOriginalModel:M=!1,keepCurrentModifiedModel:h=!1,theme:m="light",loading:x="Loading...",options:j={},height:E="100%",width:w="100%",className:O,wrapperProps:R={},beforeMount:b=u.noop,onMount:k=u.noop}){const[v,C]=r.useState(!1),P=r.useRef(null),q=r.useRef(n),L=r.useRef(null),S=r.useRef(k),N=r.useRef(b),y=r.useRef(!1);q.current=n,o(()=>()=>{P.current&&function(){const e=P.current,r=null==e?void 0:e.getModel();null==e||e.getOriginalEditor().setModel(null),null==e||e.getModifiedEditor().setModel(null),null==e||e.dispose(),M||null==r||!r.original||r.original.isDisposed()||r.original.isAttachedToEditor()||r.original.dispose();h||null==r||!r.modified||r.modified.isDisposed()||r.modified.isAttachedToEditor()||r.modified.dispose();P.current=null,y.current=!1,C(!1)}()}),i(()=>{if(P.current&&q.current){const e=P.current.getOriginalEditor(),r=u.getOrCreateModel(q.current,l||"",c||s||"text",p||"");r!==e.getModel()&&e.setModel(r)}},[p],v),i(()=>{if(P.current&&q.current){const e=P.current.getModifiedEditor(),r=u.getOrCreateModel(q.current,a||"",g||s||"text",f||"");r!==e.getModel()&&e.setModel(r)}},[f],v),i(()=>{const e=P.current.getModifiedEditor();e.getOption(q.current.editor.EditorOption.readOnly)?e.setValue(a||""):a!==e.getValue()&&(e.executeEdits("",[{range:e.getModel().getFullModelRange(),text:a||"",forceMoveMarkers:!0}]),e.pushUndoStop())},[a],v),i(()=>{var e;null==(e=P.current)||null==(e=e.getModel())||e.original.setValue(l||"")},[l],v),i(()=>{const{original:e,modified:r}=P.current.getModel();q.current.editor.setModelLanguage(e,c||s||"text"),q.current.editor.setModelLanguage(r,g||s||"text")},[s,c,g],v),i(()=>{var e;null==(e=q.current)||e.editor.setTheme(m)},[m],v),i(()=>{var e;null==(e=P.current)||e.updateOptions(j)},[j],v);const T=r.useCallback(()=>{var e;N.current(q.current);const r=u.getOrCreateModel(q.current,l||"",c||s||"text",p||""),t=u.getOrCreateModel(q.current,a||"",g||s||"text",f||"");null==(e=P.current)||e.setModel({original:r,modified:t})},[s,a,g,l,c,p,f]),D=r.useCallback(()=>{var r;!y.current&&L.current&&(P.current=q.current.editor.createDiffEditor(L.current,e.objectSpread2({automaticLayout:!0},j)),T(),null==(r=q.current)||r.editor.setTheme(m),C(!0),y.current=!0)},[j,m,T]);return r.useEffect(()=>{v&&S.current(P.current,q.current)},[v]),r.useEffect(()=>{v||D()},[v,D]),d.jsx(t,{width:w,height:E,isEditorReady:v,loading:x,_ref:L,className:O,wrapperProps:R})}module.exports=function(o){const{width:i="100%",height:n="100%",loading:u="Loading...",className:a,wrapperProps:s={}}=o;return d.jsx(r.Suspense,{fallback:d.jsx(t,{width:i,height:n,isEditorReady:!1,loading:u,className:a,wrapperProps:s}),children:d.jsx(l,e.objectSpread2({},o))})};
3
- //# sourceMappingURL=DiffEditor.cjs.map
1
+ "use strict";"use client";const e=require("../MonacoContainer/index.cjs"),t=require("../hooks/useMount/index.cjs"),n=require("../hooks/useUpdate/index.cjs"),r=require("../hooks/useMonaco/index.cjs"),i=require("../utils/index.cjs");let a=require("react"),o=require("react/jsx-runtime");function s(t){let{width:n=`100%`,height:r=`100%`,loading:i=`Loading...`,className:s,wrapperProps:l={}}=t;return(0,o.jsx)(a.Suspense,{fallback:(0,o.jsx)(e.default,{width:n,height:r,isEditorReady:!1,loading:i,className:s,wrapperProps:l}),children:(0,o.jsx)(c,{...t})})}function c(t){let n=r.default();if(!n){let{width:n=`100%`,height:r=`100%`,loading:i=`Loading...`,className:a,wrapperProps:s={}}=t;return(0,o.jsx)(e.default,{width:n,height:r,isEditorReady:!1,loading:i,className:a,wrapperProps:s})}return(0,o.jsx)(l,{...t,monaco:n})}function l({monaco:r,original:s,modified:c,language:l,originalLanguage:u,modifiedLanguage:d,originalModelPath:f,modifiedModelPath:p,keepCurrentOriginalModel:m=!1,keepCurrentModifiedModel:h=!1,theme:g=`light`,loading:_=`Loading...`,options:v={},height:y=`100%`,width:b=`100%`,className:x,wrapperProps:S={},beforeMount:C=i.noop,onMount:w=i.noop}){let[T,E]=(0,a.useState)(!1),D=(0,a.useRef)(null),O=(0,a.useRef)(r),k=(0,a.useRef)(null),A=(0,a.useRef)(w),j=(0,a.useRef)(C),M=(0,a.useRef)(!1);O.current=r,t.default(()=>()=>{D.current&&F()}),n.default(()=>{if(D.current&&O.current){let e=D.current.getOriginalEditor(),t=i.getOrCreateModel(O.current,s||``,u||l||`text`,f||``);t!==e.getModel()&&e.setModel(t)}},[f],T),n.default(()=>{if(D.current&&O.current){let e=D.current.getModifiedEditor(),t=i.getOrCreateModel(O.current,c||``,d||l||`text`,p||``);t!==e.getModel()&&e.setModel(t)}},[p],T),n.default(()=>{let e=D.current.getModifiedEditor();e.getOption(O.current.editor.EditorOption.readOnly)?e.setValue(c||``):c!==e.getValue()&&(e.executeEdits(``,[{range:e.getModel().getFullModelRange(),text:c||``,forceMoveMarkers:!0}]),e.pushUndoStop())},[c],T),n.default(()=>{D.current?.getModel()?.original.setValue(s||``)},[s],T),n.default(()=>{let{original:e,modified:t}=D.current.getModel();O.current.editor.setModelLanguage(e,u||l||`text`),O.current.editor.setModelLanguage(t,d||l||`text`)},[l,u,d],T),n.default(()=>{O.current?.editor.setTheme(g)},[g],T),n.default(()=>{D.current?.updateOptions(v)},[v],T);let N=(0,a.useCallback)(()=>{j.current(O.current);let e=i.getOrCreateModel(O.current,s||``,u||l||`text`,f||``),t=i.getOrCreateModel(O.current,c||``,d||l||`text`,p||``);D.current?.setModel({original:e,modified:t})},[l,c,d,s,u,f,p]),P=(0,a.useCallback)(()=>{!M.current&&k.current&&(D.current=O.current.editor.createDiffEditor(k.current,{automaticLayout:!0,...v}),N(),O.current?.editor.setTheme(g),E(!0),M.current=!0)},[v,g,N]);(0,a.useEffect)(()=>{T&&A.current(D.current,O.current)},[T]),(0,a.useEffect)(()=>{T||P()},[T,P]);function F(){let e=D.current,t=e?.getModel();e?.getOriginalEditor().setModel(null),e?.getModifiedEditor().setModel(null),e?.dispose(),!m&&t?.original&&!t.original.isDisposed()&&!t.original.isAttachedToEditor()&&t.original.dispose(),!h&&t?.modified&&!t.modified.isDisposed()&&!t.modified.isAttachedToEditor()&&t.modified.dispose(),D.current=null,M.current=!1,E(!1)}return(0,o.jsx)(e.default,{width:b,height:y,isEditorReady:T,loading:_,_ref:k,className:x,wrapperProps:S})}exports.default=s;
2
+ //# sourceMappingURL=DiffEditor.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"DiffEditor.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
1
+ {"version":3,"file":"DiffEditor.cjs","names":["Suspense","MonacoContainer","useMonaco","noop","getOrCreateModel"],"sources":["../../src/DiffEditor/DiffEditor.tsx"],"sourcesContent":["'use client';\n\nimport { Suspense, useState, useRef, useCallback, useEffect } from 'react';\nimport type { ReactElement } from 'react';\n\nimport MonacoContainer from '../MonacoContainer';\nimport useMount from '../hooks/useMount';\nimport useUpdate from '../hooks/useUpdate';\nimport useMonaco from '../hooks/useMonaco';\nimport { noop, getOrCreateModel } from '../utils';\nimport type { DiffEditorProps, MonacoDiffEditor } from './types';\nimport type { Monaco } from '..';\n\nfunction DiffEditor(props: DiffEditorProps): ReactElement {\n const { width = '100%', height = '100%', loading = 'Loading...', className, wrapperProps = {} } = props;\n\n return (\n <Suspense\n fallback={\n <MonacoContainer\n width={width}\n height={height}\n isEditorReady={false}\n loading={loading}\n className={className}\n wrapperProps={wrapperProps}\n />\n }\n >\n <DiffEditorContent {...props} />\n </Suspense>\n );\n}\n\nfunction DiffEditorContent(props: DiffEditorProps): ReactElement {\n const monaco = useMonaco();\n\n if (!monaco) {\n const { width = '100%', height = '100%', loading = 'Loading...', className, wrapperProps = {} } = props;\n\n return (\n <MonacoContainer\n width={width}\n height={height}\n isEditorReady={false}\n loading={loading}\n className={className}\n wrapperProps={wrapperProps}\n />\n );\n }\n\n return <MountedDiffEditor {...props} monaco={monaco} />;\n}\n\nfunction MountedDiffEditor({\n monaco,\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 & { monaco: Monaco }): ReactElement {\n const [isEditorReady, setIsEditorReady] = useState(false);\n const editorRef = useRef<MonacoDiffEditor | null>(null);\n const monacoRef = useRef<Monaco>(monaco);\n const containerRef = useRef<HTMLDivElement | null>(null);\n const onMountRef = useRef(onMount);\n const beforeMountRef = useRef(beforeMount);\n const preventCreation = useRef(false);\n\n monacoRef.current = monaco;\n\n useMount(() => {\n return () => {\n if (editorRef.current) {\n disposeEditor();\n }\n };\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 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 (!isEditorReady) {\n createEditor();\n }\n }, [isEditorReady, createEditor]);\n\n function disposeEditor(): void {\n const editor = editorRef.current;\n const models = editor?.getModel();\n\n // Detach inner editor models first so editor.dispose() never reads from a model that another owner disposed.\n // oxlint-disable-next-line unicorn/no-null -- Monaco detaches editor models with null.\n editor?.getOriginalEditor().setModel(null);\n // oxlint-disable-next-line unicorn/no-null -- Monaco detaches editor models with null.\n editor?.getModifiedEditor().setModel(null);\n editor?.dispose();\n\n if (\n !keepCurrentOriginalModel &&\n models?.original &&\n !models.original.isDisposed() &&\n !models.original.isAttachedToEditor()\n ) {\n models.original.dispose();\n }\n\n if (\n !keepCurrentModifiedModel &&\n models?.modified &&\n !models.modified.isDisposed() &&\n !models.modified.isAttachedToEditor()\n ) {\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"],"mappings":"6RAaA,SAAS,EAAW,EAAsC,CACxD,GAAM,CAAE,QAAQ,OAAQ,S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AAQ,UACR,CAAC,EAAO,SAAS,WAAW,GAC5B,CAAC,EAAO,SAAS,mBAAmB,GAEpC,EAAO,SAAS,QAAQ,EAIxB,CAAC,GACD,GAAQ,UACR,CAAC,EAAO,SAAS,WAAW,GAC5B,CAAC,EAAO,SAAS,mBAAmB,GAEpC,EAAO,SAAS,QAAQ,EAI1B,EAAU,QAAU,KACpB,EAAgB,QAAU,GAC1B,EAAiB,EAAK,CACxB,CAEA,OACE,EAAA,EAAA,IAAA,CAACH,EAAAA,QAAD,CACS,QACC,SACO,gBACN,UACT,KAAM,EACK,YACG,cACf,CAAA,CAEL"}
@@ -1,3 +1,2 @@
1
- "use client";
2
- import{objectSpread2 as e}from"../_virtual/_rollupPluginBabelHelpers.js";import{Suspense as r,useState as t,useRef as o,useCallback as i,useEffect as n}from"react";import d from"../MonacoContainer/index.js";import l from"../hooks/useMount/index.js";import a from"../hooks/useUpdate/index.js";import u from"../hooks/useMonaco/index.js";import{noop as s,getOrCreateModel as c}from"../utils/index.js";import{jsx as g}from"react/jsx-runtime";function p(t){const{width:o="100%",height:i="100%",loading:n="Loading...",className:l,wrapperProps:a={}}=t;return g(r,{fallback:g(d,{width:o,height:i,isEditorReady:!1,loading:n,className:l,wrapperProps:a}),children:g(m,e({},t))})}function m(r){const t=u();if(!t){const{width:e="100%",height:t="100%",loading:o="Loading...",className:i,wrapperProps:n={}}=r;return g(d,{width:e,height:t,isEditorReady:!1,loading:o,className:i,wrapperProps:n})}return g(f,e(e({},r),{},{monaco:t}))}function f({monaco:r,original:u,modified:p,language:m,originalLanguage:f,modifiedLanguage:h,originalModelPath:M,modifiedModelPath:x,keepCurrentOriginalModel:E=!1,keepCurrentModifiedModel:w=!1,theme:P="light",loading:j="Loading...",options:v={},height:L="100%",width:k="100%",className:O,wrapperProps:N={},beforeMount:y=s,onMount:b=s}){const[R,T]=t(!1),C=o(null),D=o(r),V=o(null),_=o(b),A=o(y),S=o(!1);D.current=r,l(()=>()=>{C.current&&function(){const e=C.current,r=null==e?void 0:e.getModel();null==e||e.getOriginalEditor().setModel(null),null==e||e.getModifiedEditor().setModel(null),null==e||e.dispose(),E||null==r||!r.original||r.original.isDisposed()||r.original.isAttachedToEditor()||r.original.dispose();w||null==r||!r.modified||r.modified.isDisposed()||r.modified.isAttachedToEditor()||r.modified.dispose();C.current=null,S.current=!1,T(!1)}()}),a(()=>{if(C.current&&D.current){const e=C.current.getOriginalEditor(),r=c(D.current,u||"",f||m||"text",M||"");r!==e.getModel()&&e.setModel(r)}},[M],R),a(()=>{if(C.current&&D.current){const e=C.current.getModifiedEditor(),r=c(D.current,p||"",h||m||"text",x||"");r!==e.getModel()&&e.setModel(r)}},[x],R),a(()=>{const e=C.current.getModifiedEditor();e.getOption(D.current.editor.EditorOption.readOnly)?e.setValue(p||""):p!==e.getValue()&&(e.executeEdits("",[{range:e.getModel().getFullModelRange(),text:p||"",forceMoveMarkers:!0}]),e.pushUndoStop())},[p],R),a(()=>{var e;null==(e=C.current)||null==(e=e.getModel())||e.original.setValue(u||"")},[u],R),a(()=>{const{original:e,modified:r}=C.current.getModel();D.current.editor.setModelLanguage(e,f||m||"text"),D.current.editor.setModelLanguage(r,h||m||"text")},[m,f,h],R),a(()=>{var e;null==(e=D.current)||e.editor.setTheme(P)},[P],R),a(()=>{var e;null==(e=C.current)||e.updateOptions(v)},[v],R);const U=i(()=>{var e;A.current(D.current);const r=c(D.current,u||"",f||m||"text",M||""),t=c(D.current,p||"",h||m||"text",x||"");null==(e=C.current)||e.setModel({original:r,modified:t})},[m,p,h,u,f,M,x]),B=i(()=>{var r;!S.current&&V.current&&(C.current=D.current.editor.createDiffEditor(V.current,e({automaticLayout:!0},v)),U(),null==(r=D.current)||r.editor.setTheme(P),T(!0),S.current=!0)},[v,P,U]);return n(()=>{R&&_.current(C.current,D.current)},[R]),n(()=>{R||B()},[R,B]),g(d,{width:k,height:L,isEditorReady:R,loading:j,_ref:V,className:O,wrapperProps:N})}export{p as default};
3
- //# sourceMappingURL=DiffEditor.js.map
1
+ "use client";import e from"../MonacoContainer/index.js";import t from"../hooks/useMount/index.js";import n from"../hooks/useUpdate/index.js";import r from"../hooks/useMonaco/index.js";import{getOrCreateModel as i,noop as a}from"../utils/index.js";import{Suspense as o,useCallback as s,useEffect as c,useRef as l,useState as u}from"react";import{jsx as d}from"react/jsx-runtime";function f(t){let{width:n=`100%`,height:r=`100%`,loading:i=`Loading...`,className:a,wrapperProps:s={}}=t;return d(o,{fallback:d(e,{width:n,height:r,isEditorReady:!1,loading:i,className:a,wrapperProps:s}),children:d(p,{...t})})}function p(t){let n=r();if(!n){let{width:n=`100%`,height:r=`100%`,loading:i=`Loading...`,className:a,wrapperProps:o={}}=t;return d(e,{width:n,height:r,isEditorReady:!1,loading:i,className:a,wrapperProps:o})}return d(m,{...t,monaco:n})}function m({monaco:r,original:o,modified:f,language:p,originalLanguage:m,modifiedLanguage:h,originalModelPath:g,modifiedModelPath:_,keepCurrentOriginalModel:v=!1,keepCurrentModifiedModel:y=!1,theme:b=`light`,loading:x=`Loading...`,options:S={},height:C=`100%`,width:w=`100%`,className:T,wrapperProps:E={},beforeMount:D=a,onMount:O=a}){let[k,A]=u(!1),j=l(null),M=l(r),N=l(null),P=l(O),F=l(D),I=l(!1);M.current=r,t(()=>()=>{j.current&&z()}),n(()=>{if(j.current&&M.current){let e=j.current.getOriginalEditor(),t=i(M.current,o||``,m||p||`text`,g||``);t!==e.getModel()&&e.setModel(t)}},[g],k),n(()=>{if(j.current&&M.current){let e=j.current.getModifiedEditor(),t=i(M.current,f||``,h||p||`text`,_||``);t!==e.getModel()&&e.setModel(t)}},[_],k),n(()=>{let e=j.current.getModifiedEditor();e.getOption(M.current.editor.EditorOption.readOnly)?e.setValue(f||``):f!==e.getValue()&&(e.executeEdits(``,[{range:e.getModel().getFullModelRange(),text:f||``,forceMoveMarkers:!0}]),e.pushUndoStop())},[f],k),n(()=>{j.current?.getModel()?.original.setValue(o||``)},[o],k),n(()=>{let{original:e,modified:t}=j.current.getModel();M.current.editor.setModelLanguage(e,m||p||`text`),M.current.editor.setModelLanguage(t,h||p||`text`)},[p,m,h],k),n(()=>{M.current?.editor.setTheme(b)},[b],k),n(()=>{j.current?.updateOptions(S)},[S],k);let L=s(()=>{F.current(M.current);let e=i(M.current,o||``,m||p||`text`,g||``),t=i(M.current,f||``,h||p||`text`,_||``);j.current?.setModel({original:e,modified:t})},[p,f,h,o,m,g,_]),R=s(()=>{!I.current&&N.current&&(j.current=M.current.editor.createDiffEditor(N.current,{automaticLayout:!0,...S}),L(),M.current?.editor.setTheme(b),A(!0),I.current=!0)},[S,b,L]);c(()=>{k&&P.current(j.current,M.current)},[k]),c(()=>{k||R()},[k,R]);function z(){let e=j.current,t=e?.getModel();e?.getOriginalEditor().setModel(null),e?.getModifiedEditor().setModel(null),e?.dispose(),!v&&t?.original&&!t.original.isDisposed()&&!t.original.isAttachedToEditor()&&t.original.dispose(),!y&&t?.modified&&!t.modified.isDisposed()&&!t.modified.isAttachedToEditor()&&t.modified.dispose(),j.current=null,I.current=!1,A(!1)}return d(e,{width:w,height:C,isEditorReady:k,loading:x,_ref:N,className:T,wrapperProps:E})}export{f as default};
2
+ //# sourceMappingURL=DiffEditor.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DiffEditor.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
1
+ {"version":3,"file":"DiffEditor.js","names":["MonacoContainer"],"sources":["../../src/DiffEditor/DiffEditor.tsx"],"sourcesContent":["'use client';\n\nimport { Suspense, useState, useRef, useCallback, useEffect } from 'react';\nimport type { ReactElement } from 'react';\n\nimport MonacoContainer from '../MonacoContainer';\nimport useMount from '../hooks/useMount';\nimport useUpdate from '../hooks/useUpdate';\nimport useMonaco from '../hooks/useMonaco';\nimport { noop, getOrCreateModel } from '../utils';\nimport type { DiffEditorProps, MonacoDiffEditor } from './types';\nimport type { Monaco } from '..';\n\nfunction DiffEditor(props: DiffEditorProps): ReactElement {\n const { width = '100%', height = '100%', loading = 'Loading...', className, wrapperProps = {} } = props;\n\n return (\n <Suspense\n fallback={\n <MonacoContainer\n width={width}\n height={height}\n isEditorReady={false}\n loading={loading}\n className={className}\n wrapperProps={wrapperProps}\n />\n }\n >\n <DiffEditorContent {...props} />\n </Suspense>\n );\n}\n\nfunction DiffEditorContent(props: DiffEditorProps): ReactElement {\n const monaco = useMonaco();\n\n if (!monaco) {\n const { width = '100%', height = '100%', loading = 'Loading...', className, wrapperProps = {} } = props;\n\n return (\n <MonacoContainer\n width={width}\n height={height}\n isEditorReady={false}\n loading={loading}\n className={className}\n wrapperProps={wrapperProps}\n />\n );\n }\n\n return <MountedDiffEditor {...props} monaco={monaco} />;\n}\n\nfunction MountedDiffEditor({\n monaco,\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 & { monaco: Monaco }): ReactElement {\n const [isEditorReady, setIsEditorReady] = useState(false);\n const editorRef = useRef<MonacoDiffEditor | null>(null);\n const monacoRef = useRef<Monaco>(monaco);\n const containerRef = useRef<HTMLDivElement | null>(null);\n const onMountRef = useRef(onMount);\n const beforeMountRef = useRef(beforeMount);\n const preventCreation = useRef(false);\n\n monacoRef.current = monaco;\n\n useMount(() => {\n return () => {\n if (editorRef.current) {\n disposeEditor();\n }\n };\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 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 (!isEditorReady) {\n createEditor();\n }\n }, [isEditorReady, createEditor]);\n\n function disposeEditor(): void {\n const editor = editorRef.current;\n const models = editor?.getModel();\n\n // Detach inner editor models first so editor.dispose() never reads from a model that another owner disposed.\n // oxlint-disable-next-line unicorn/no-null -- Monaco detaches editor models with null.\n editor?.getOriginalEditor().setModel(null);\n // oxlint-disable-next-line unicorn/no-null -- Monaco detaches editor models with null.\n editor?.getModifiedEditor().setModel(null);\n editor?.dispose();\n\n if (\n !keepCurrentOriginalModel &&\n models?.original &&\n !models.original.isDisposed() &&\n !models.original.isAttachedToEditor()\n ) {\n models.original.dispose();\n }\n\n if (\n !keepCurrentModifiedModel &&\n models?.modified &&\n !models.modified.isDisposed() &&\n !models.modified.isAttachedToEditor()\n ) {\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"],"mappings":"0XAaA,SAAS,EAAW,EAAsC,CACxD,GAAM,CAAE,QAAQ,OAAQ,SAAS,OAAQ,UAAU,aAAc,YAAW,eAAe,CAAC,GAAM,EAElG,OACE,EAAC,EAAD,CACE,SACE,EAACA,EAAD,CACS,QACC,SACR,cAAe,GACN,UACE,YACG,cACf,CAAA,WAGH,EAAC,EAAD,CAAmB,GAAI,CAAQ,CAAA,CACvB,CAAA,CAEd,CAEA,SA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,SAAW,EAAa,UAC3C,EAAU,QAAU,EAAU,QAAS,OAAO,iBAAiB,EAAa,QAAS,CACnF,gBAAiB,GACjB,GAAG,CACL,CAAC,EAED,EAAU,EAEV,EAAU,SAAS,OAAO,SAAS,CAAK,EAExC,EAAiB,EAAI,EACrB,EAAgB,QAAU,GAE9B,EAAG,CAAC,EAAS,EAAO,CAAS,CAAC,EAE9B,MAAgB,CACV,GACF,EAAW,QAAQ,EAAU,QAAU,EAAU,OAAQ,CAE7D,EAAG,CAAC,CAAa,CAAC,EAElB,MAAgB,CACT,GACH,EAAa,CAEjB,EAAG,CAAC,EAAe,CAAY,CAAC,EAEhC,SAAS,GAAsB,CAC7B,IAAM,EAAS,EAAU,QACnB,EAAS,GAAQ,SAAS,EAIhC,GAAQ,kBAAkB,CAAC,CAAC,SAAS,IAAI,EAEzC,GAAQ,kBAAkB,CAAC,CAAC,SAAS,IAAI,EACzC,GAAQ,QAAQ,EAGd,CAAC,GACD,GAAQ,UACR,CAAC,EAAO,SAAS,WAAW,GAC5B,CAAC,EAAO,SAAS,mBAAmB,GAEpC,EAAO,SAAS,QAAQ,EAIxB,CAAC,GACD,GAAQ,UACR,CAAC,EAAO,SAAS,WAAW,GAC5B,CAAC,EAAO,SAAS,mBAAmB,GAEpC,EAAO,SAAS,QAAQ,EAI1B,EAAU,QAAU,KACpB,EAAgB,QAAU,GAC1B,EAAiB,EAAK,CACxB,CAEA,OACE,EAACA,EAAD,CACS,QACC,SACO,gBACN,UACT,KAAM,EACK,YACG,cACf,CAAA,CAEL"}
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("react"),r=require("./DiffEditor.cjs"),i=e.memo(r);module.exports=i;
2
- //# sourceMappingURL=index.cjs.map
1
+ "use strict";const e=require("./DiffEditor.cjs");var t=(0,require("react").memo)(e.default);exports.default=t;
2
+ //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../src/DiffEditor/index.ts"],"sourcesContent":["import { memo } from 'react';\n\nimport DiffEditor from './DiffEditor';\n\nexport * from './types';\n\nexport default memo(DiffEditor);\n"],"names":["index","memo","DiffEditor"],"mappings":"kEAMAA,EAAeC,EAAAA,KAAKC"}
1
+ {"version":3,"file":"index.cjs","names":["DiffEditor"],"sources":["../../src/DiffEditor/index.ts"],"sourcesContent":["import { memo } from 'react';\n\nimport DiffEditor from './DiffEditor';\n\nexport * from './types';\n\nexport default memo(DiffEditor);\n"],"mappings":"iDAMA,IAAA,GAAA,iBAAA,CAAA,CAAA,KAAA,CAAoBA,EAAAA,OAAU"}
@@ -1,2 +1,2 @@
1
- import{memo as r}from"react";import o from"./DiffEditor.js";var t=r(o);export{t as default};
2
- //# sourceMappingURL=index.js.map
1
+ import e from"./DiffEditor.js";import{memo as t}from"react";var n=t(e);export{n as default};
2
+ //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/DiffEditor/index.ts"],"sourcesContent":["import { memo } from 'react';\n\nimport DiffEditor from './DiffEditor';\n\nexport * from './types';\n\nexport default memo(DiffEditor);\n"],"names":["index","memo","DiffEditor"],"mappings":"4DAMA,IAAAA,EAAeC,EAAKC"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/DiffEditor/index.ts"],"sourcesContent":["import { memo } from 'react';\n\nimport DiffEditor from './DiffEditor';\n\nexport * from './types';\n\nexport default memo(DiffEditor);\n"],"mappings":"4DAMA,IAAA,EAAe,EAAK,CAAU"}
@@ -1,4 +1,4 @@
1
- import type { editor } from 'monaco-editor/esm/vs/editor/editor.api.js';
1
+ import type { editor } from 'monaco-editor';
2
2
  import type { ReactNode } from 'react';
3
3
  import type { Monaco } from '..';
4
4
  export type MonacoDiffEditor = editor.IStandaloneDiffEditor;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/DiffEditor/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAA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,CAAC;IAEhD;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAExB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAEzB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,eAAe,CAAC;IAE9B;;;;;OAKG;IACH,OAAO,CAAC,EAAE,WAAW,CAAC;CACvB"}
@@ -1,3 +1,2 @@
1
- "use client";
2
- "use strict";var e=require("../_virtual/_rollupPluginBabelHelpers.cjs"),r=require("react"),t=require("../hooks/useMount/index.cjs"),n=require("../hooks/useUpdate/index.cjs"),u=require("../hooks/usePrevious/index.cjs"),o=require("../hooks/useMonaco/index.cjs"),s=require("../utils/index.cjs"),i=require("../MonacoContainer/index.cjs"),a=require("react/jsx-runtime");const c=new Map;function l(r){const t=o();if(!t){const{width:e="100%",height:t="100%",loading:n="Loading...",className:u,wrapperProps:o={}}=r;return a.jsx(i,{width:e,height:t,isEditorReady:!1,loading:n,className:u,wrapperProps:o})}return a.jsx(d,e.objectSpread2(e.objectSpread2({},r),{},{monaco:t}))}function d({monaco:o,defaultValue:l,defaultLanguage:d,defaultPath:p,value:g,language:h,path:f,theme:v="light",line:M,loading:j="Loading...",options:w={},overrideServices:x={},saveViewState:m=!0,keepCurrentModel:R=!1,width:S="100%",height:k="100%",className:E,wrapperProps:V={},beforeMount:q=s.noop,onMount:C=s.noop,onChange:P,onValidate:b=s.noop}){const[L,N]=r.useState(!1),O=r.useRef(o),y=r.useRef(void 0),D=r.useRef(null),T=r.useRef(C),_=r.useRef(q),U=r.useRef(void 0),A=r.useRef(g),B=u(f),F=r.useRef(!1),H=r.useRef(!1);O.current=o,t(()=>()=>{y.current&&function(){var e;null==(e=U.current)||e.dispose();const r=y.current,t=r.getModel();R?(m&&c.set(f,r.saveViewState()),r.setModel(null)):t&&(r.setModel(null),t.isDisposed()||t.isAttachedToEditor()||t.dispose());r.dispose(),y.current=void 0,F.current=!1,N(!1)}()}),n(()=>{var e;const r=s.getOrCreateModel(O.current,l||g||"",d||h||"",f||p||"");var t,n,u;r!==(null==(e=y.current)?void 0:e.getModel())&&(m&&c.set(B,null==(t=y.current)?void 0:t.saveViewState()),null==(n=y.current)||n.setModel(r),m&&(null==(u=y.current)||u.restoreViewState(c.get(f))))},[f],L),n(()=>{var e;null==(e=y.current)||e.updateOptions(w)},[w],L),n(()=>{y.current&&void 0!==g&&(y.current.getOption(O.current.editor.EditorOption.readOnly)?y.current.setValue(g):g!==y.current.getValue()&&(H.current=!0,y.current.executeEdits("",[{range:y.current.getModel().getFullModelRange(),text:g,forceMoveMarkers:!0}]),y.current.pushUndoStop(),H.current=!1))},[g],L),n(()=>{var e;const r=null==(e=y.current)?void 0:e.getModel();var t;L&&r&&h&&(null==(t=O.current)||t.editor.setModelLanguage(r,h))},[h,L],L),n(()=>{var e;void 0!==M&&(null==(e=y.current)||e.revealLine(M))},[M],L),n(()=>{var e;null==(e=O.current)||e.editor.setTheme(v)},[v],L);const z=r.useCallback(()=>{if(D.current&&!F.current){_.current(O.current);const r=f||p,t=s.getOrCreateModel(O.current,g||l||"",d||h||"",r||""),n=O.current.editor.create(D.current,e.objectSpread2({model:t,automaticLayout:!0},w),x);y.current=n,m&&n.restoreViewState(c.get(r)),O.current.editor.setTheme(v),void 0!==M&&n.revealLine(M),N(!0),F.current=!0}},[l,d,p,g,h,f,w,x,m,v,M]);return r.useEffect(()=>{L&&T.current(y.current,O.current)},[L]),r.useEffect(()=>{L||z()},[L,z]),A.current=g,r.useEffect(()=>{var e,r;L&&P&&(null==(e=U.current)||e.dispose(),U.current=null==(r=y.current)?void 0:r.onDidChangeModelContent(e=>{H.current||P(y.current.getValue(),e)}))},[L,P]),r.useEffect(()=>{if(L){const e=O.current.editor.onDidChangeMarkers(e=>{var r;const t=null==(r=y.current.getModel())?void 0:r.uri;if(t){if(e.find(e=>e.path===t.path)){const e=O.current.editor.getModelMarkers({resource:t});null==b||b(e)}}});return()=>{null==e||e.dispose()}}return()=>{}},[L,b]),a.jsx(i,{width:S,height:k,isEditorReady:L,loading:j,_ref:D,className:E,wrapperProps:V})}module.exports=function(t){const{width:n="100%",height:u="100%",loading:o="Loading...",className:s,wrapperProps:c={}}=t;return a.jsx(r.Suspense,{fallback:a.jsx(i,{width:n,height:u,isEditorReady:!1,loading:o,className:s,wrapperProps:c}),children:a.jsx(l,e.objectSpread2({},t))})};
3
- //# sourceMappingURL=Editor.cjs.map
1
+ "use strict";"use client";const e=require("../MonacoContainer/index.cjs"),t=require("../hooks/useMount/index.cjs"),n=require("../hooks/useUpdate/index.cjs"),r=require("../hooks/useMonaco/index.cjs"),i=require("../utils/index.cjs"),a=require("../hooks/usePrevious/index.cjs");let o=require("react"),s=require("react/jsx-runtime");const c=new Map;function l(t){let{width:n=`100%`,height:r=`100%`,loading:i=`Loading...`,className:a,wrapperProps:c={}}=t;return(0,s.jsx)(o.Suspense,{fallback:(0,s.jsx)(e.default,{width:n,height:r,isEditorReady:!1,loading:i,className:a,wrapperProps:c}),children:(0,s.jsx)(u,{...t})})}function u(t){let n=r.default();if(!n){let{width:n=`100%`,height:r=`100%`,loading:i=`Loading...`,className:a,wrapperProps:o={}}=t;return(0,s.jsx)(e.default,{width:n,height:r,isEditorReady:!1,loading:i,className:a,wrapperProps:o})}return(0,s.jsx)(d,{...t,monaco:n})}function d({monaco:r,defaultValue:l,defaultLanguage:u,defaultPath:d,value:f,language:p,path:m,theme:h=`light`,line:g,loading:_=`Loading...`,options:v={},overrideServices:y={},saveViewState:b=!0,keepCurrentModel:x=!1,width:S=`100%`,height:C=`100%`,className:w,wrapperProps:T={},beforeMount:E=i.noop,onMount:D=i.noop,onChange:O,onValidate:k=i.noop}){let[A,j]=(0,o.useState)(!1),M=(0,o.useRef)(r),N=(0,o.useRef)(void 0),P=(0,o.useRef)(null),F=(0,o.useRef)(D),I=(0,o.useRef)(E),L=(0,o.useRef)(void 0),R=(0,o.useRef)(f),z=a.default(m),B=(0,o.useRef)(!1),V=(0,o.useRef)(!1);M.current=r,t.default(()=>()=>{N.current&&U()}),n.default(()=>{let e=i.getOrCreateModel(M.current,l||f||``,u||p||``,m||d||``);e!==N.current?.getModel()&&(b&&c.set(z,N.current?.saveViewState()),N.current?.setModel(e),b&&N.current?.restoreViewState(c.get(m)))},[m],A),n.default(()=>{N.current?.updateOptions(v)},[v],A),n.default(()=>{!N.current||f===void 0||(N.current.getOption(M.current.editor.EditorOption.readOnly)?N.current.setValue(f):f!==N.current.getValue()&&(V.current=!0,N.current.executeEdits(``,[{range:N.current.getModel().getFullModelRange(),text:f,forceMoveMarkers:!0}]),N.current.pushUndoStop(),V.current=!1))},[f],A),n.default(()=>{let e=N.current?.getModel();A&&e&&p&&M.current?.editor.setModelLanguage(e,p)},[p,A],A),n.default(()=>{g!==void 0&&N.current?.revealLine(g)},[g],A),n.default(()=>{M.current?.editor.setTheme(h)},[h],A);let H=(0,o.useCallback)(()=>{if(P.current&&!B.current){I.current(M.current);let e=m||d,t=i.getOrCreateModel(M.current,f||l||``,u||p||``,e||``),n=M.current.editor.create(P.current,{model:t,automaticLayout:!0,...v},y);N.current=n,b&&n.restoreViewState(c.get(e)),M.current.editor.setTheme(h),g!==void 0&&n.revealLine(g),j(!0),B.current=!0}},[l,u,d,f,p,m,v,y,b,h,g]);(0,o.useEffect)(()=>{A&&F.current(N.current,M.current)},[A]),(0,o.useEffect)(()=>{A||H()},[A,H]),R.current=f,(0,o.useEffect)(()=>{A&&O&&(L.current?.dispose(),L.current=N.current?.onDidChangeModelContent(e=>{V.current||O(N.current.getValue(),e)}))},[A,O]),(0,o.useEffect)(()=>{if(A){let e=M.current.editor.onDidChangeMarkers(e=>{let t=N.current.getModel()?.uri;if(t&&e.find(e=>e.path===t.path)){let e=M.current.editor.getModelMarkers({resource:t});k?.(e)}});return()=>{e?.dispose()}}return()=>{}},[A,k]);function U(){L.current?.dispose();let e=N.current,t=e.getModel();x?(b&&c.set(m,e.saveViewState()),e.setModel(null)):t&&(e.setModel(null),!t.isDisposed()&&!t.isAttachedToEditor()&&t.dispose()),e.dispose(),N.current=void 0,B.current=!1,j(!1)}return(0,s.jsx)(e.default,{width:S,height:C,isEditorReady:A,loading:_,_ref:P,className:w,wrapperProps:T})}exports.default=l;
2
+ //# sourceMappingURL=Editor.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Editor.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
1
+ {"version":3,"file":"Editor.cjs","names":["Suspense","MonacoContainer","useMonaco","noop","usePrevious","getOrCreateModel"],"sources":["../../src/Editor/Editor.tsx"],"sourcesContent":["'use client';\n\nimport { Suspense, useState, useEffect, useRef, useCallback } from 'react';\nimport type { ReactElement } from 'react';\nimport useMount from '../hooks/useMount';\nimport useUpdate from '../hooks/useUpdate';\nimport usePrevious from '../hooks/usePrevious';\nimport useMonaco from '../hooks/useMonaco';\nimport type { IDisposable, Uri, editor } from 'monaco-editor';\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(props: EditorProps): ReactElement {\n const { width = '100%', height = '100%', loading = 'Loading...', className, wrapperProps = {} } = props;\n\n return (\n <Suspense\n fallback={\n <MonacoContainer\n width={width}\n height={height}\n isEditorReady={false}\n loading={loading}\n className={className}\n wrapperProps={wrapperProps}\n />\n }\n >\n <EditorContent {...props} />\n </Suspense>\n );\n}\n\nfunction EditorContent(props: EditorProps): ReactElement {\n const monaco = useMonaco();\n\n if (!monaco) {\n const { width = '100%', height = '100%', loading = 'Loading...', className, wrapperProps = {} } = props;\n\n return (\n <MonacoContainer\n width={width}\n height={height}\n isEditorReady={false}\n loading={loading}\n className={className}\n wrapperProps={wrapperProps}\n />\n );\n }\n\n return <MountedEditor {...props} monaco={monaco} />;\n}\n\nfunction MountedEditor({\n monaco,\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 & { monaco: Monaco }): ReactElement {\n const [isEditorReady, setIsEditorReady] = useState(false);\n const monacoRef = useRef<Monaco>(monaco);\n const editorRef = useRef<editor.IStandaloneCodeEditor | undefined>(undefined);\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 monacoRef.current = monaco;\n\n useMount(() => {\n return () => {\n if (editorRef.current) {\n disposeEditor();\n }\n };\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) 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 if (saveViewState) {\n editor.restoreViewState(viewStates.get(autoCreatedModelPath));\n }\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 if (!isEditorReady) {\n createEditor();\n }\n }, [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 const editor = editorRef.current!;\n const model = editor.getModel();\n\n if (keepCurrentModel) {\n if (saveViewState) {\n viewStates.set(path, editor.saveViewState());\n }\n // oxlint-disable-next-line unicorn/no-null -- Monaco detaches editor models with null.\n editor.setModel(null);\n } else if (model) {\n // Detach first so editor.dispose() never reads from a model that another editor already disposed.\n // oxlint-disable-next-line unicorn/no-null -- Monaco detaches editor models with null.\n editor.setModel(null);\n if (!model.isDisposed() && !model.isAttachedToEditor()) {\n model.dispose();\n }\n }\n\n editor.dispose();\n\n editorRef.current = undefined;\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"],"mappings":"yUAcA,MAAM,EAAa,IAAI,IAEvB,SAAS,EAAO,EAAkC,CAChD,GAAM,CAAE,QAAQ,OAAQ,SAAS,OAAQ,UAAU,aAAc,YAAW,eAAe,CAAC,GAAM,EAElG,OACE,EAAA,EAAA,IAAA,CAACA,EAAAA,SAAD,CACE,UACE,EAAA,EAAA,IAAA,CAACC,EAAAA,QAAD,CACS,QACC,S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IACrD,EAAG,CACjC,IAAM,EAAU,EAAU,QAAS,OAAO,gBAAgB,CACxD,SAAU,CACZ,CAAC,EACD,IAAa,CAAO,CACtB,CAEJ,CAAC,EAED,UAAa,CACX,GAAuB,QAAQ,CACjC,CACF,CACA,UAAa,CAEb,CACF,EAAG,CAAC,EAAe,CAAU,CAAC,EAE9B,SAAS,GAAsB,CAC7B,EAAgB,SAAS,QAAQ,EACjC,IAAM,EAAS,EAAU,QACnB,EAAQ,EAAO,SAAS,EAE1B,GACE,GACF,EAAW,IAAI,EAAM,EAAO,cAAc,CAAC,EAG7C,EAAO,SAAS,IAAI,GACX,IAGT,EAAO,SAAS,IAAI,EAChB,CAAC,EAAM,WAAW,GAAK,CAAC,EAAM,mBAAmB,GACnD,EAAM,QAAQ,GAIlB,EAAO,QAAQ,EAEf,EAAU,QAAU,IAAA,GACpB,EAAgB,QAAU,GAC1B,EAAiB,EAAK,CACxB,CAEA,OACE,EAAA,EAAA,IAAA,CAACJ,EAAAA,QAAD,CACS,QACC,SACO,gBACN,UACT,KAAM,EACK,YACG,cACf,CAAA,CAEL"}
@@ -1,3 +1,2 @@
1
- "use client";
2
- import{objectSpread2 as e}from"../_virtual/_rollupPluginBabelHelpers.js";import{Suspense as r,useState as t,useRef as n,useCallback as o,useEffect as u}from"react";import i from"../hooks/useMount/index.js";import a from"../hooks/useUpdate/index.js";import s from"../hooks/usePrevious/index.js";import l from"../hooks/useMonaco/index.js";import{noop as c,getOrCreateModel as d}from"../utils/index.js";import p from"../MonacoContainer/index.js";import{jsx as g}from"react/jsx-runtime";const h=new Map;function m(t){const{width:n="100%",height:o="100%",loading:u="Loading...",className:i,wrapperProps:a={}}=t;return g(r,{fallback:g(p,{width:n,height:o,isEditorReady:!1,loading:u,className:i,wrapperProps:a}),children:g(v,e({},t))})}function v(r){const t=l();if(!t){const{width:e="100%",height:t="100%",loading:n="Loading...",className:o,wrapperProps:u={}}=r;return g(p,{width:e,height:t,isEditorReady:!1,loading:n,className:o,wrapperProps:u})}return g(f,e(e({},r),{},{monaco:t}))}function f({monaco:r,defaultValue:l,defaultLanguage:m,defaultPath:v,value:f,language:M,path:w,theme:x="light",line:V,loading:j="Loading...",options:k={},overrideServices:P={},saveViewState:L=!0,keepCurrentModel:S=!1,width:C="100%",height:E="100%",className:N,wrapperProps:y={},beforeMount:b=c,onMount:O=c,onChange:R,onValidate:D=c}){const[T,_]=t(!1),U=n(r),A=n(void 0),B=n(null),F=n(O),H=n(b),q=n(void 0),z=n(f),G=s(w),I=n(!1),J=n(!1);U.current=r,i(()=>()=>{A.current&&function(){var e;null==(e=q.current)||e.dispose();const r=A.current,t=r.getModel();S?(L&&h.set(w,r.saveViewState()),r.setModel(null)):t&&(r.setModel(null),t.isDisposed()||t.isAttachedToEditor()||t.dispose());r.dispose(),A.current=void 0,I.current=!1,_(!1)}()}),a(()=>{var e;const r=d(U.current,l||f||"",m||M||"",w||v||"");var t,n,o;r!==(null==(e=A.current)?void 0:e.getModel())&&(L&&h.set(G,null==(t=A.current)?void 0:t.saveViewState()),null==(n=A.current)||n.setModel(r),L&&(null==(o=A.current)||o.restoreViewState(h.get(w))))},[w],T),a(()=>{var e;null==(e=A.current)||e.updateOptions(k)},[k],T),a(()=>{A.current&&void 0!==f&&(A.current.getOption(U.current.editor.EditorOption.readOnly)?A.current.setValue(f):f!==A.current.getValue()&&(J.current=!0,A.current.executeEdits("",[{range:A.current.getModel().getFullModelRange(),text:f,forceMoveMarkers:!0}]),A.current.pushUndoStop(),J.current=!1))},[f],T),a(()=>{var e;const r=null==(e=A.current)?void 0:e.getModel();var t;T&&r&&M&&(null==(t=U.current)||t.editor.setModelLanguage(r,M))},[M,T],T),a(()=>{var e;void 0!==V&&(null==(e=A.current)||e.revealLine(V))},[V],T),a(()=>{var e;null==(e=U.current)||e.editor.setTheme(x)},[x],T);const K=o(()=>{if(B.current&&!I.current){H.current(U.current);const r=w||v,t=d(U.current,f||l||"",m||M||"",r||""),n=U.current.editor.create(B.current,e({model:t,automaticLayout:!0},k),P);A.current=n,L&&n.restoreViewState(h.get(r)),U.current.editor.setTheme(x),void 0!==V&&n.revealLine(V),_(!0),I.current=!0}},[l,m,v,f,M,w,k,P,L,x,V]);return u(()=>{T&&F.current(A.current,U.current)},[T]),u(()=>{T||K()},[T,K]),z.current=f,u(()=>{var e,r;T&&R&&(null==(e=q.current)||e.dispose(),q.current=null==(r=A.current)?void 0:r.onDidChangeModelContent(e=>{J.current||R(A.current.getValue(),e)}))},[T,R]),u(()=>{if(T){const e=U.current.editor.onDidChangeMarkers(e=>{var r;const t=null==(r=A.current.getModel())?void 0:r.uri;if(t){if(e.find(e=>e.path===t.path)){const e=U.current.editor.getModelMarkers({resource:t});null==D||D(e)}}});return()=>{null==e||e.dispose()}}return()=>{}},[T,D]),g(p,{width:C,height:E,isEditorReady:T,loading:j,_ref:B,className:N,wrapperProps:y})}export{m as default};
3
- //# sourceMappingURL=Editor.js.map
1
+ "use client";import e from"../MonacoContainer/index.js";import t from"../hooks/useMount/index.js";import n from"../hooks/useUpdate/index.js";import r from"../hooks/useMonaco/index.js";import{getOrCreateModel as i,noop as a}from"../utils/index.js";import o from"../hooks/usePrevious/index.js";import{Suspense as s,useCallback as c,useEffect as l,useRef as u,useState as d}from"react";import{jsx as f}from"react/jsx-runtime";const p=new Map;function m(t){let{width:n=`100%`,height:r=`100%`,loading:i=`Loading...`,className:a,wrapperProps:o={}}=t;return f(s,{fallback:f(e,{width:n,height:r,isEditorReady:!1,loading:i,className:a,wrapperProps:o}),children:f(h,{...t})})}function h(t){let n=r();if(!n){let{width:n=`100%`,height:r=`100%`,loading:i=`Loading...`,className:a,wrapperProps:o={}}=t;return f(e,{width:n,height:r,isEditorReady:!1,loading:i,className:a,wrapperProps:o})}return f(g,{...t,monaco:n})}function g({monaco:r,defaultValue:s,defaultLanguage:m,defaultPath:h,value:g,language:_,path:v,theme:y=`light`,line:b,loading:x=`Loading...`,options:S={},overrideServices:C={},saveViewState:w=!0,keepCurrentModel:T=!1,width:E=`100%`,height:D=`100%`,className:O,wrapperProps:k={},beforeMount:A=a,onMount:j=a,onChange:M,onValidate:N=a}){let[P,F]=d(!1),I=u(r),L=u(void 0),R=u(null),z=u(j),B=u(A),V=u(void 0),H=u(g),U=o(v),W=u(!1),G=u(!1);I.current=r,t(()=>()=>{L.current&&q()}),n(()=>{let e=i(I.current,s||g||``,m||_||``,v||h||``);e!==L.current?.getModel()&&(w&&p.set(U,L.current?.saveViewState()),L.current?.setModel(e),w&&L.current?.restoreViewState(p.get(v)))},[v],P),n(()=>{L.current?.updateOptions(S)},[S],P),n(()=>{!L.current||g===void 0||(L.current.getOption(I.current.editor.EditorOption.readOnly)?L.current.setValue(g):g!==L.current.getValue()&&(G.current=!0,L.current.executeEdits(``,[{range:L.current.getModel().getFullModelRange(),text:g,forceMoveMarkers:!0}]),L.current.pushUndoStop(),G.current=!1))},[g],P),n(()=>{let e=L.current?.getModel();P&&e&&_&&I.current?.editor.setModelLanguage(e,_)},[_,P],P),n(()=>{b!==void 0&&L.current?.revealLine(b)},[b],P),n(()=>{I.current?.editor.setTheme(y)},[y],P);let K=c(()=>{if(R.current&&!W.current){B.current(I.current);let e=v||h,t=i(I.current,g||s||``,m||_||``,e||``),n=I.current.editor.create(R.current,{model:t,automaticLayout:!0,...S},C);L.current=n,w&&n.restoreViewState(p.get(e)),I.current.editor.setTheme(y),b!==void 0&&n.revealLine(b),F(!0),W.current=!0}},[s,m,h,g,_,v,S,C,w,y,b]);l(()=>{P&&z.current(L.current,I.current)},[P]),l(()=>{P||K()},[P,K]),H.current=g,l(()=>{P&&M&&(V.current?.dispose(),V.current=L.current?.onDidChangeModelContent(e=>{G.current||M(L.current.getValue(),e)}))},[P,M]),l(()=>{if(P){let e=I.current.editor.onDidChangeMarkers(e=>{let t=L.current.getModel()?.uri;if(t&&e.find(e=>e.path===t.path)){let e=I.current.editor.getModelMarkers({resource:t});N?.(e)}});return()=>{e?.dispose()}}return()=>{}},[P,N]);function q(){V.current?.dispose();let e=L.current,t=e.getModel();T?(w&&p.set(v,e.saveViewState()),e.setModel(null)):t&&(e.setModel(null),!t.isDisposed()&&!t.isAttachedToEditor()&&t.dispose()),e.dispose(),L.current=void 0,W.current=!1,F(!1)}return f(e,{width:E,height:D,isEditorReady:P,loading:x,_ref:R,className:O,wrapperProps:k})}export{m as default};
2
+ //# sourceMappingURL=Editor.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Editor.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
1
+ {"version":3,"file":"Editor.js","names":["MonacoContainer"],"sources":["../../src/Editor/Editor.tsx"],"sourcesContent":["'use client';\n\nimport { Suspense, useState, useEffect, useRef, useCallback } from 'react';\nimport type { ReactElement } from 'react';\nimport useMount from '../hooks/useMount';\nimport useUpdate from '../hooks/useUpdate';\nimport usePrevious from '../hooks/usePrevious';\nimport useMonaco from '../hooks/useMonaco';\nimport type { IDisposable, Uri, editor } from 'monaco-editor';\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(props: EditorProps): ReactElement {\n const { width = '100%', height = '100%', loading = 'Loading...', className, wrapperProps = {} } = props;\n\n return (\n <Suspense\n fallback={\n <MonacoContainer\n width={width}\n height={height}\n isEditorReady={false}\n loading={loading}\n className={className}\n wrapperProps={wrapperProps}\n />\n }\n >\n <EditorContent {...props} />\n </Suspense>\n );\n}\n\nfunction EditorContent(props: EditorProps): ReactElement {\n const monaco = useMonaco();\n\n if (!monaco) {\n const { width = '100%', height = '100%', loading = 'Loading...', className, wrapperProps = {} } = props;\n\n return (\n <MonacoContainer\n width={width}\n height={height}\n isEditorReady={false}\n loading={loading}\n className={className}\n wrapperProps={wrapperProps}\n />\n );\n }\n\n return <MountedEditor {...props} monaco={monaco} />;\n}\n\nfunction MountedEditor({\n monaco,\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 & { monaco: Monaco }): ReactElement {\n const [isEditorReady, setIsEditorReady] = useState(false);\n const monacoRef = useRef<Monaco>(monaco);\n const editorRef = useRef<editor.IStandaloneCodeEditor | undefined>(undefined);\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 monacoRef.current = monaco;\n\n useMount(() => {\n return () => {\n if (editorRef.current) {\n disposeEditor();\n }\n };\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) 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 if (saveViewState) {\n editor.restoreViewState(viewStates.get(autoCreatedModelPath));\n }\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 if (!isEditorReady) {\n createEditor();\n }\n }, [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 const editor = editorRef.current!;\n const model = editor.getModel();\n\n if (keepCurrentModel) {\n if (saveViewState) {\n viewStates.set(path, editor.saveViewState());\n }\n // oxlint-disable-next-line unicorn/no-null -- Monaco detaches editor models with null.\n editor.setModel(null);\n } else if (model) {\n // Detach first so editor.dispose() never reads from a model that another editor already disposed.\n // oxlint-disable-next-line unicorn/no-null -- Monaco detaches editor models with null.\n editor.setModel(null);\n if (!model.isDisposed() && !model.isAttachedToEditor()) {\n model.dispose();\n }\n }\n\n editor.dispose();\n\n editorRef.current = undefined;\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"],"mappings":"uaAcA,MAAM,EAAa,IAAI,IAEvB,SAAS,EAAO,EAAkC,CAChD,GAAM,CAAE,QAAQ,OAAQ,SAAS,OAAQ,UAAU,aAAc,YAAW,eAAe,CAAC,GAAM,EAElG,OACE,EAAC,EAAD,CACE,SACE,EAACA,EAAD,CACS,QACC,SACR,cAAe,GACN,UACE,YACG,cACf,CAAA,WAGH,EAAC,EAAD,CAAe,GAAI,CAAQ,CAAA,CACnB,CAAA,CAEd,CAEA,SAAS,EAAc,EAAkC,CACvD,I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AK,CACxB,CAEA,OACE,EAACA,EAAD,CACS,QACC,SACO,gBACN,UACT,KAAM,EACK,YACG,cACf,CAAA,CAEL"}
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("react"),r=require("./Editor.cjs"),t=e.memo(r);module.exports=t;
2
- //# sourceMappingURL=index.cjs.map
1
+ "use strict";const e=require("./Editor.cjs");var t=(0,require("react").memo)(e.default);exports.default=t;
2
+ //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../src/Editor/index.ts"],"sourcesContent":["import { memo } from 'react';\n\nimport Editor from './Editor';\n\nexport * from './types';\n\nexport default memo(Editor);\n"],"names":["Editor","memo"],"mappings":"8DAMAA,EAAeC,EAAAA,KAAKD"}
1
+ {"version":3,"file":"index.cjs","names":["Editor"],"sources":["../../src/Editor/index.ts"],"sourcesContent":["import { memo } from 'react';\n\nimport Editor from './Editor';\n\nexport * from './types';\n\nexport default memo(Editor);\n"],"mappings":"6CAMA,IAAA,GAAA,iBAAA,CAAA,CAAA,KAAA,CAAoBA,EAAAA,OAAM"}
@@ -1,2 +1,2 @@
1
- import{memo as r}from"react";import o from"./Editor.js";var t=r(o);export{t as default};
2
- //# sourceMappingURL=index.js.map
1
+ import e from"./Editor.js";import{memo as t}from"react";var n=t(e);export{n as default};
2
+ //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/Editor/index.ts"],"sourcesContent":["import { memo } from 'react';\n\nimport Editor from './Editor';\n\nexport * from './types';\n\nexport default memo(Editor);\n"],"names":["Editor","memo"],"mappings":"wDAMA,IAAAA,EAAeC,EAAKD"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/Editor/index.ts"],"sourcesContent":["import { memo } from 'react';\n\nimport Editor from './Editor';\n\nexport * from './types';\n\nexport default memo(Editor);\n"],"mappings":"wDAMA,IAAA,EAAe,EAAK,CAAM"}
@@ -1,4 +1,4 @@
1
- import type { editor } from 'monaco-editor/esm/vs/editor/editor.api.js';
1
+ import type { editor } from 'monaco-editor';
2
2
  import type { Monaco } from '..';
3
3
  import type { ReactNode } from 'react';
4
4
  export type OnMount = (editor: editor.IStandaloneCodeEditor, monaco: Monaco) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/Editor/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACxE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AACjC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,MAAM,MAAM,OAAO,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,qBAAqB,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;AAErF,MAAM,MAAM,WAAW,GAAG,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;AAEnD,MAAM,MAAM,QAAQ,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,EAAE,EAAE,MAAM,CAAC,yBAAyB,KAAK,IAAI,CAAC;AAEjG,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,KAAK,IAAI,CAAC;AAE7D,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;;O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C,EAAE,UAAU,CAAC;CACzB"}
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("./styles.cjs"),r=require("react/jsx-runtime");module.exports=function({children:t}){return r.jsx("div",{style:e.container,children:t})};
2
- //# sourceMappingURL=Loading.cjs.map
1
+ "use strict";const e=require("./styles.cjs");let t=require("react/jsx-runtime");function n({children:n}){return(0,t.jsx)(`div`,{style:e.default.container,children:n})}exports.default=n;
2
+ //# sourceMappingURL=Loading.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Loading.cjs","sources":["../../src/Loading/Loading.tsx"],"sourcesContent":["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"],"names":["children","_jsx","style","styles","container"],"mappings":"yFAIA,UAAiBA,SAAEA,IACjB,OAAOC,EAAAA,IAAA,MAAA,CAAKC,MAAOC,EAAOC,UAAUJ,SAAEA,GACxC"}
1
+ {"version":3,"file":"Loading.cjs","names":["styles"],"sources":["../../src/Loading/Loading.tsx"],"sourcesContent":["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"],"mappings":"gFAIA,SAAS,EAAQ,CAAE,YAA6C,CAC9D,OAAO,EAAA,EAAA,IAAA,CAAC,MAAD,CAAK,MAAOA,EAAAA,QAAO,UAAY,UAAc,CAAA,CACtD"}
@@ -1,2 +1,2 @@
1
- import r from"./styles.js";import{jsx as t}from"react/jsx-runtime";function e({children:e}){return t("div",{style:r.container,children:e})}export{e as default};
2
- //# sourceMappingURL=Loading.js.map
1
+ import e from"./styles.js";import{jsx as t}from"react/jsx-runtime";function n({children:n}){return t(`div`,{style:e.container,children:n})}export{n as default};
2
+ //# sourceMappingURL=Loading.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Loading.js","sources":["../../src/Loading/Loading.tsx"],"sourcesContent":["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"],"names":["Loading","children","_jsx","style","styles","container"],"mappings":"mEAIA,SAASA,GAAQC,SAAEA,IACjB,OAAOC,EAAA,MAAA,CAAKC,MAAOC,EAAOC,UAAUJ,SAAEA,GACxC"}
1
+ {"version":3,"file":"Loading.js","names":[],"sources":["../../src/Loading/Loading.tsx"],"sourcesContent":["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"],"mappings":"mEAIA,SAAS,EAAQ,CAAE,YAA6C,CAC9D,OAAO,EAAC,MAAD,CAAK,MAAO,EAAO,UAAY,UAAc,CAAA,CACtD"}
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("./Loading.cjs");module.exports=e;
2
- //# sourceMappingURL=index.cjs.map
1
+ "use strict";var e=require("./Loading.cjs").default;exports.default=e;
2
+ //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
1
+ {"version":3,"file":"index.cjs","names":["Loading"],"sources":["../../src/Loading/index.ts"],"sourcesContent":["import Loading from './Loading';\n\nexport default Loading;\n"],"mappings":"aAEA,IAAA,yBAAeA,CAAAA,CAAAA"}
@@ -1,2 +1,2 @@
1
- import o from"./Loading.js";export{o as default};
2
- //# sourceMappingURL=index.js.map
1
+ import e from"./Loading.js";var t=e;export{t as default};
2
+ //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/Loading/index.ts"],"sourcesContent":["import Loading from './Loading';\n\nexport default Loading;\n"],"mappings":"4BAEA,IAAA,EAAe"}
@@ -1,2 +1,2 @@
1
- "use strict";module.exports={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}};
2
- //# sourceMappingURL=styles.cjs.map
1
+ "use strict";const e={container:{display:`flex`,height:`100%`,width:`100%`,justifyContent:`center`,alignItems:`center`}};exports.default=e;
2
+ //# sourceMappingURL=styles.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"styles.cjs","sources":["../../src/Loading/styles.ts"],"sourcesContent":["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"],"names":["container","display","height","width","justifyContent","alignItems"],"mappings":"4BAE8C,CAC5CA,UAAW,CACTC,QAAS,OACTC,OAAQ,OACRC,MAAO,OACPC,eAAgB,SAChBC,WAAY"}
1
+ {"version":3,"file":"styles.cjs","names":[],"sources":["../../src/Loading/styles.ts"],"sourcesContent":["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"],"mappings":"aAEA,MAAM,EAAwC,CAC5C,UAAW,CACT,QAAS,OACT,OAAQ,OACR,MAAO,OACP,eAAgB,SAChB,WAAY,QACd,CACF"}
@@ -1,2 +1,2 @@
1
- const t={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}};export{t as default};
2
- //# sourceMappingURL=styles.js.map
1
+ const e={container:{display:`flex`,height:`100%`,width:`100%`,justifyContent:`center`,alignItems:`center`}};export{e as default};
2
+ //# sourceMappingURL=styles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"styles.js","sources":["../../src/Loading/styles.ts"],"sourcesContent":["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"],"names":["styles","container","display","height","width","justifyContent","alignItems"],"mappings":"AAEA,MAAMA,EAAwC,CAC5CC,UAAW,CACTC,QAAS,OACTC,OAAQ,OACRC,MAAO,OACPC,eAAgB,SAChBC,WAAY"}
1
+ {"version":3,"file":"styles.js","names":[],"sources":["../../src/Loading/styles.ts"],"sourcesContent":["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"],"mappings":"AAEA,MAAM,EAAwC,CAC5C,UAAW,CACT,QAAS,OACT,OAAQ,OACR,MAAO,OACP,eAAgB,SAChB,WAAY,QACd,CACF"}
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("../_virtual/_rollupPluginBabelHelpers.cjs"),r=require("./styles.cjs"),i=require("../Loading/Loading.cjs"),t=require("react/jsx-runtime");module.exports=function({width:s,height:a,isEditorReady:d,loading:c,_ref:l,className:o,wrapperProps:p}){return t.jsxs("section",e.objectSpread2(e.objectSpread2({style:e.objectSpread2(e.objectSpread2({},r.wrapper),{},{width:s,height:a})},p),{},{children:[!d&&t.jsx(i,{children:c}),t.jsx("div",{ref:l,style:e.objectSpread2(e.objectSpread2({},r.fullWidth),!d&&r.hide),className:o})]}))};
2
- //# sourceMappingURL=MonacoContainer.cjs.map
1
+ "use strict";const e=require("./styles.cjs"),t=require("../Loading/index.cjs");let n=require("react/jsx-runtime");function r({width:r,height:i,isEditorReady:a,loading:o,_ref:s,className:c,wrapperProps:l}){return(0,n.jsxs)(`section`,{style:{...e.default.wrapper,width:r,height:i},...l,children:[!a&&(0,n.jsx)(t.default,{children:o}),(0,n.jsx)(`div`,{ref:s,style:{...e.default.fullWidth,...!a&&e.default.hide},className:c})]})}exports.default=r;
2
+ //# sourceMappingURL=MonacoContainer.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"MonacoContainer.cjs","sources":["../../src/MonacoContainer/MonacoContainer.tsx"],"sourcesContent":["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"],"names":["width","height","isEditorReady","loading","_ref","className","wrapperProps","_jsxs","_objectSpread","style","styles","wrapper","children","_jsx","Loading","ref","fullWidth","hide"],"mappings":"oLASA,UAAyBA,MACvBA,EAAKC,OACLA,EAAMC,cACNA,EAAaC,QACbA,EAAOC,KACPA,EAAIC,UACJA,EAASC,aACTA,IAEA,OACEC,OAAA,UAAAC,EAAAA,cAAAA,gBAAA,CAASC,MAAKD,EAAAA,cAAAA,gBAAA,CAAA,EAAOE,EAAOC,SAAO,GAAA,CAAEX,QAAOC,YAAcK,GAAY,GAAA,CAAAM,WAClEV,GAAiBW,EAAAA,IAACC,EAAO,CAAAF,SAAET,IAC7BU,EAAAA,IAAA,MAAA,CAAKE,IAAKX,EAAMK,MAAKD,EAAAA,cAAAA,EAAAA,iBAAOE,EAAOM,YAAgBd,GAAiBQ,EAAOO,MAASZ,UAAWA,OAGrG"}
1
+ {"version":3,"file":"MonacoContainer.cjs","names":["styles","Loading"],"sources":["../../src/MonacoContainer/MonacoContainer.tsx"],"sourcesContent":["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"],"mappings":"kHASA,SAAS,EAAgB,CACvB,QACA,SACA,gBACA,UACA,OACA,YACA,gBAC+B,CAC/B,OACE,EAAA,EAAA,KAAA,CAAC,UAAD,CAAS,MAAO,CAAE,GAAGA,EAAAA,QAAO,QAAS,QAAO,QAAO,EAAG,GAAI,WAA1D,CACG,CAAC,IAAiB,EAAA,EAAA,IAAA,CAACC,EAAAA,QAAD,CAAA,SAAU,CAAiB,CAAA,GAC9C,EAAA,EAAA,IAAA,CAAC,MAAD,CAAK,IAAK,EAAM,MAAO,CAAE,GAAGD,EAAAA,QAAO,UAAW,GAAI,CAAC,GAAiBA,EAAAA,QAAO,IAAM,EAAc,WAAY,CAAA,CACpG,GAEb"}
@@ -1,2 +1,2 @@
1
- import{objectSpread2 as r}from"../_virtual/_rollupPluginBabelHelpers.js";import e from"./styles.js";import i from"../Loading/Loading.js";import{jsxs as t,jsx as o}from"react/jsx-runtime";function s({width:s,height:a,isEditorReady:l,loading:d,_ref:p,className:m,wrapperProps:n}){return t("section",r(r({style:r(r({},e.wrapper),{},{width:s,height:a})},n),{},{children:[!l&&o(i,{children:d}),o("div",{ref:p,style:r(r({},e.fullWidth),!l&&e.hide),className:m})]}))}export{s as default};
2
- //# sourceMappingURL=MonacoContainer.js.map
1
+ import e from"./styles.js";import t from"../Loading/index.js";import{jsx as n,jsxs as r}from"react/jsx-runtime";function i({width:i,height:a,isEditorReady:o,loading:s,_ref:c,className:l,wrapperProps:u}){return r(`section`,{style:{...e.wrapper,width:i,height:a},...u,children:[!o&&n(t,{children:s}),n(`div`,{ref:c,style:{...e.fullWidth,...!o&&e.hide},className:l})]})}export{i as default};
2
+ //# sourceMappingURL=MonacoContainer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MonacoContainer.js","sources":["../../src/MonacoContainer/MonacoContainer.tsx"],"sourcesContent":["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"],"names":["MonacoContainer","width","height","isEditorReady","loading","_ref","className","wrapperProps","_jsxs","_objectSpread","style","styles","wrapper","children","_jsx","Loading","ref","fullWidth","hide"],"mappings":"2LASA,SAASA,GAAgBC,MACvBA,EAAKC,OACLA,EAAMC,cACNA,EAAaC,QACbA,EAAOC,KACPA,EAAIC,UACJA,EAASC,aACTA,IAEA,OACEC,EAAA,UAAAC,EAAAA,EAAA,CAASC,MAAKD,EAAAA,EAAA,CAAA,EAAOE,EAAOC,SAAO,GAAA,CAAEX,QAAOC,YAAcK,GAAY,GAAA,CAAAM,WAClEV,GAAiBW,EAACC,EAAO,CAAAF,SAAET,IAC7BU,EAAA,MAAA,CAAKE,IAAKX,EAAMK,MAAKD,EAAAA,KAAOE,EAAOM,YAAgBd,GAAiBQ,EAAOO,MAASZ,UAAWA,OAGrG"}
1
+ {"version":3,"file":"MonacoContainer.js","names":["Loading"],"sources":["../../src/MonacoContainer/MonacoContainer.tsx"],"sourcesContent":["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"],"mappings":"gHASA,SAAS,EAAgB,CACvB,QACA,SACA,gBACA,UACA,OACA,YACA,gBAC+B,CAC/B,OACE,EAAC,UAAD,CAAS,MAAO,CAAE,GAAG,EAAO,QAAS,QAAO,QAAO,EAAG,GAAI,WAA1D,CACG,CAAC,GAAiB,EAACA,EAAD,CAAA,SAAU,CAAiB,CAAA,EAC9C,EAAC,MAAD,CAAK,IAAK,EAAM,MAAO,CAAE,GAAG,EAAO,UAAW,GAAI,CAAC,GAAiB,EAAO,IAAM,EAAc,WAAY,CAAA,CACpG,GAEb"}
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("react"),r=require("./MonacoContainer.cjs"),o=e.memo(r);module.exports=o;
2
- //# sourceMappingURL=index.cjs.map
1
+ "use strict";const e=require("./MonacoContainer.cjs");var t=(0,require("react").memo)(e.default);exports.default=t;
2
+ //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../src/MonacoContainer/index.ts"],"sourcesContent":["import { memo } from 'react';\n\nimport MonacoContainer from './MonacoContainer';\n\nexport default memo(MonacoContainer);\n"],"names":["MonacoContainer","memo"],"mappings":"uEAIAA,EAAeC,EAAAA,KAAKD"}
1
+ {"version":3,"file":"index.cjs","names":["MonacoContainer"],"sources":["../../src/MonacoContainer/index.ts"],"sourcesContent":["import { memo } from 'react';\n\nimport MonacoContainer from './MonacoContainer';\n\nexport default memo(MonacoContainer);\n"],"mappings":"sDAIA,IAAA,GAAA,iBAAA,CAAA,CAAA,KAAA,CAAoBA,EAAAA,OAAe"}
@@ -1,2 +1,2 @@
1
- import{memo as o}from"react";import r from"./MonacoContainer.js";var a=o(r);export{a as default};
2
- //# sourceMappingURL=index.js.map
1
+ import e from"./MonacoContainer.js";import{memo as t}from"react";var n=t(e);export{n as default};
2
+ //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/MonacoContainer/index.ts"],"sourcesContent":["import { memo } from 'react';\n\nimport MonacoContainer from './MonacoContainer';\n\nexport default memo(MonacoContainer);\n"],"names":["MonacoContainer","memo"],"mappings":"iEAIA,IAAAA,EAAeC,EAAKD"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/MonacoContainer/index.ts"],"sourcesContent":["import { memo } from 'react';\n\nimport MonacoContainer from './MonacoContainer';\n\nexport default memo(MonacoContainer);\n"],"mappings":"iEAIA,IAAA,EAAe,EAAK,CAAe"}
@@ -1,2 +1,2 @@
1
- "use strict";module.exports={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}};
2
- //# sourceMappingURL=styles.cjs.map
1
+ "use strict";const e={wrapper:{display:`flex`,position:`relative`,textAlign:`initial`},fullWidth:{width:`100%`},hide:{display:`none`}};exports.default=e;
2
+ //# sourceMappingURL=styles.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"styles.cjs","sources":["../../src/MonacoContainer/styles.ts"],"sourcesContent":["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"],"names":["wrapper","display","position","textAlign","fullWidth","width","hide"],"mappings":"4BAE8C,CAC5CA,QAAS,CACPC,QAAS,OACTC,SAAU,WACVC,UAAW,WAEbC,UAAW,CACTC,MAAO,QAETC,KAAM,CACJL,QAAS"}
1
+ {"version":3,"file":"styles.cjs","names":[],"sources":["../../src/MonacoContainer/styles.ts"],"sourcesContent":["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"],"mappings":"aAEA,MAAM,EAAwC,CAC5C,QAAS,CACP,QAAS,OACT,SAAU,WACV,UAAW,SACb,EACA,UAAW,CACT,MAAO,MACT,EACA,KAAM,CACJ,QAAS,MACX,CACF"}
@@ -1,2 +1,2 @@
1
- const i={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}};export{i as default};
2
- //# sourceMappingURL=styles.js.map
1
+ const e={wrapper:{display:`flex`,position:`relative`,textAlign:`initial`},fullWidth:{width:`100%`},hide:{display:`none`}};export{e as default};
2
+ //# sourceMappingURL=styles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"styles.js","sources":["../../src/MonacoContainer/styles.ts"],"sourcesContent":["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"],"names":["styles","wrapper","display","position","textAlign","fullWidth","width","hide"],"mappings":"AAEA,MAAMA,EAAwC,CAC5CC,QAAS,CACPC,QAAS,OACTC,SAAU,WACVC,UAAW,WAEbC,UAAW,CACTC,MAAO,QAETC,KAAM,CACJL,QAAS"}
1
+ {"version":3,"file":"styles.js","names":[],"sources":["../../src/MonacoContainer/styles.ts"],"sourcesContent":["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"],"mappings":"AAEA,MAAM,EAAwC,CAC5C,QAAS,CACP,QAAS,OACT,SAAU,WACV,UAAW,SACb,EACA,UAAW,CACT,MAAO,MACT,EACA,KAAM,CACJ,QAAS,MACX,CACF"}
@@ -0,0 +1 @@
1
+ "use strict";var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));exports.__toESM=s;
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("react"),r=require("./initMonaco.cjs");function t(e){const r=setTimeout(e,0);return()=>{clearTimeout(r)}}function n(){return!0}function u(){return!1}module.exports=function(){if(e.useSyncExternalStore(t,n,u))return e.use(r())};
2
- //# sourceMappingURL=index.cjs.map
1
+ "use strict";const e=require("./initMonaco.cjs");let t=require("react");function n(){if((0,t.useSyncExternalStore)(r,i,a))return(0,t.use)(e.default())}function r(e){let t=setTimeout(e,0);return()=>{clearTimeout(t)}}function i(){return!0}function a(){return!1}exports.default=n;
2
+ //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../../src/hooks/useMonaco/index.ts"],"sourcesContent":["import { use, useSyncExternalStore } from 'react';\n\nimport type { Monaco } from '../..';\nimport initMonaco from './initMonaco';\n\nfunction useMonaco(): Monaco | undefined {\n const isHydrated = useSyncExternalStore(subscribe, getClientSnapshot, getServerSnapshot);\n\n if (!isHydrated) {\n return undefined;\n }\n\n return use(initMonaco());\n}\n\nfunction subscribe(onStoreChange: () => void): () => void {\n const timeoutId = setTimeout(onStoreChange, 0);\n\n return () => {\n clearTimeout(timeoutId);\n };\n}\n\nfunction getClientSnapshot(): boolean {\n return true;\n}\n\nfunction getServerSnapshot(): boolean {\n return false;\n}\n\nexport default useMonaco;\n"],"names":["subscribe","onStoreChange","timeoutId","setTimeout","clearTimeout","getClientSnapshot","getServerSnapshot","useSyncExternalStore","use","initMonaco"],"mappings":"kEAeA,SAASA,EAAUC,GACjB,MAAMC,EAAYC,WAAWF,EAAe,GAE5C,MAAO,KACLG,aAAaF,GAEjB,CAEA,SAASG,IACP,OAAO,CACT,CAEA,SAASC,IACP,OAAO,CACT,gBAxBA,WAGE,GAFmBC,EAAAA,qBAAqBP,EAAWK,EAAmBC,GAMtE,OAAOE,EAAAA,IAAIC,IACb"}
1
+ {"version":3,"file":"index.cjs","names":["initMonaco"],"sources":["../../../src/hooks/useMonaco/index.ts"],"sourcesContent":["import { use, useSyncExternalStore } from 'react';\n\nimport type { Monaco } from '../..';\nimport initMonaco from './initMonaco';\n\nfunction useMonaco(): Monaco | undefined {\n const isHydrated = useSyncExternalStore(subscribe, getClientSnapshot, getServerSnapshot);\n\n if (!isHydrated) {\n return undefined;\n }\n\n return use(initMonaco());\n}\n\nfunction subscribe(onStoreChange: () => void): () => void {\n const timeoutId = setTimeout(onStoreChange, 0);\n\n return () => {\n clearTimeout(timeoutId);\n };\n}\n\nfunction getClientSnapshot(): boolean {\n return true;\n}\n\nfunction getServerSnapshot(): boolean {\n return false;\n}\n\nexport default useMonaco;\n"],"mappings":"wEAKA,SAAS,GAAgC,CAGnC,IAAA,EAAA,EAAA,qBAAA,CAFoC,EAAW,EAAmB,CAExD,EAId,OAAA,EAAA,EAAA,IAAA,CAAWA,EAAAA,QAAW,CAAC,CACzB,CAEA,SAAS,EAAU,EAAuC,CACxD,IAAM,EAAY,WAAW,EAAe,CAAC,EAE7C,UAAa,CACX,aAAa,CAAS,CACxB,CACF,CAEA,SAAS,GAA6B,CACpC,MAAO,EACT,CAEA,SAAS,GAA6B,CACpC,MAAO,EACT"}
@@ -1,2 +1,2 @@
1
- import{useSyncExternalStore as t,use as n}from"react";import r from"./initMonaco.js";function o(){if(t(e,i,u))return n(r())}function e(t){const n=setTimeout(t,0);return()=>{clearTimeout(n)}}function i(){return!0}function u(){return!1}export{o as default};
2
- //# sourceMappingURL=index.js.map
1
+ import e from"./initMonaco.js";import{use as t,useSyncExternalStore as n}from"react";function r(){if(n(i,a,o))return t(e())}function i(e){let t=setTimeout(e,0);return()=>{clearTimeout(t)}}function a(){return!0}function o(){return!1}export{r as default};
2
+ //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/hooks/useMonaco/index.ts"],"sourcesContent":["import { use, useSyncExternalStore } from 'react';\n\nimport type { Monaco } from '../..';\nimport initMonaco from './initMonaco';\n\nfunction useMonaco(): Monaco | undefined {\n const isHydrated = useSyncExternalStore(subscribe, getClientSnapshot, getServerSnapshot);\n\n if (!isHydrated) {\n return undefined;\n }\n\n return use(initMonaco());\n}\n\nfunction subscribe(onStoreChange: () => void): () => void {\n const timeoutId = setTimeout(onStoreChange, 0);\n\n return () => {\n clearTimeout(timeoutId);\n };\n}\n\nfunction getClientSnapshot(): boolean {\n return true;\n}\n\nfunction getServerSnapshot(): boolean {\n return false;\n}\n\nexport default useMonaco;\n"],"names":["useMonaco","useSyncExternalStore","subscribe","getClientSnapshot","getServerSnapshot","use","initMonaco","onStoreChange","timeoutId","setTimeout","clearTimeout"],"mappings":"qFAKA,SAASA,IAGP,GAFmBC,EAAqBC,EAAWC,EAAmBC,GAMtE,OAAOC,EAAIC,IACb,CAEA,SAASJ,EAAUK,GACjB,MAAMC,EAAYC,WAAWF,EAAe,GAE5C,MAAO,KACLG,aAAaF,GAEjB,CAEA,SAASL,IACP,OAAO,CACT,CAEA,SAASC,IACP,OAAO,CACT"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/hooks/useMonaco/index.ts"],"sourcesContent":["import { use, useSyncExternalStore } from 'react';\n\nimport type { Monaco } from '../..';\nimport initMonaco from './initMonaco';\n\nfunction useMonaco(): Monaco | undefined {\n const isHydrated = useSyncExternalStore(subscribe, getClientSnapshot, getServerSnapshot);\n\n if (!isHydrated) {\n return undefined;\n }\n\n return use(initMonaco());\n}\n\nfunction subscribe(onStoreChange: () => void): () => void {\n const timeoutId = setTimeout(onStoreChange, 0);\n\n return () => {\n clearTimeout(timeoutId);\n };\n}\n\nfunction getClientSnapshot(): boolean {\n return true;\n}\n\nfunction getServerSnapshot(): boolean {\n return false;\n}\n\nexport default useMonaco;\n"],"mappings":"qFAKA,SAAS,GAAgC,CACpB,KAAqB,EAAW,EAAmB,CAExD,EAId,OAAO,EAAI,EAAW,CAAC,CACzB,CAEA,SAAS,EAAU,EAAuC,CACxD,IAAM,EAAY,WAAW,EAAe,CAAC,EAE7C,UAAa,CACX,aAAa,CAAS,CACxB,CACF,CAEA,SAAS,GAA6B,CACpC,MAAO,EACT,CAEA,SAAS,GAA6B,CACpC,MAAO,EACT"}
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("@willbooster/monaco-loader");let r;module.exports=function(){return null!=r||(r=e.init()),r};
2
- //# sourceMappingURL=initMonaco.cjs.map
1
+ "use strict";const e=require("../../_virtual/_rolldown/runtime.cjs");let t=require("@willbooster/monaco-loader");t=e.__toESM(t,1);let n;function r(){return n??=t.default.init(),n}exports.default=r;
2
+ //# sourceMappingURL=initMonaco.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"initMonaco.cjs","sources":["../../../src/hooks/useMonaco/initMonaco.ts"],"sourcesContent":["import loader from '@willbooster/monaco-loader';\n\nimport type { Monaco } from '../..';\n\nlet monacoPromise: Promise<Monaco> | undefined;\n\nfunction initMonaco(): Promise<Monaco> {\n monacoPromise ??= loader.init() as Promise<Monaco>;\n return monacoPromise;\n}\n\nexport default initMonaco;\n"],"names":["monacoPromise","loader","init"],"mappings":"yDAIA,IAAIA,iBAEJ,WAEE,OADa,MAAbA,IAAAA,EAAkBC,EAAOC,QAClBF,CACT"}
1
+ {"version":3,"file":"initMonaco.cjs","names":["loader"],"sources":["../../../src/hooks/useMonaco/initMonaco.ts"],"sourcesContent":["import loader from '@willbooster/monaco-loader';\n\nimport type { Monaco } from '../..';\n\nlet monacoPromise: Promise<Monaco> | undefined;\n\nfunction initMonaco(): Promise<Monaco> {\n monacoPromise ??= loader.init() as Promise<Monaco>;\n return monacoPromise;\n}\n\nexport default initMonaco;\n"],"mappings":"kIAIA,IAAI,EAEJ,SAAS,GAA8B,CAErC,MADA,KAAkBA,EAAAA,QAAO,KAAK,EACvB,CACT"}
@@ -1,2 +1,2 @@
1
- import o from"@willbooster/monaco-loader";let t;function l(){return null!=t||(t=o.init()),t}export{l as default};
2
- //# sourceMappingURL=initMonaco.js.map
1
+ import e from"@willbooster/monaco-loader";let t;function n(){return t??=e.init(),t}export{n as default};
2
+ //# sourceMappingURL=initMonaco.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"initMonaco.js","sources":["../../../src/hooks/useMonaco/initMonaco.ts"],"sourcesContent":["import loader from '@willbooster/monaco-loader';\n\nimport type { Monaco } from '../..';\n\nlet monacoPromise: Promise<Monaco> | undefined;\n\nfunction initMonaco(): Promise<Monaco> {\n monacoPromise ??= loader.init() as Promise<Monaco>;\n return monacoPromise;\n}\n\nexport default initMonaco;\n"],"names":["monacoPromise","initMonaco","loader","init"],"mappings":"0CAIA,IAAIA,EAEJ,SAASC,IAEP,OADa,MAAbD,IAAAA,EAAkBE,EAAOC,QAClBH,CACT"}
1
+ {"version":3,"file":"initMonaco.js","names":[],"sources":["../../../src/hooks/useMonaco/initMonaco.ts"],"sourcesContent":["import loader from '@willbooster/monaco-loader';\n\nimport type { Monaco } from '../..';\n\nlet monacoPromise: Promise<Monaco> | undefined;\n\nfunction initMonaco(): Promise<Monaco> {\n monacoPromise ??= loader.init() as Promise<Monaco>;\n return monacoPromise;\n}\n\nexport default initMonaco;\n"],"mappings":"0CAIA,IAAI,EAEJ,SAAS,GAA8B,CAErC,MADA,KAAkB,EAAO,KAAK,EACvB,CACT"}
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("react");module.exports=function(r){const t=e.useRef(r);e.useEffect(()=>t.current(),[])};
2
- //# sourceMappingURL=index.cjs.map
1
+ "use strict";let e=require("react");function t(t){let n=(0,e.useRef)(t);(0,e.useEffect)(()=>n.current(),[])}exports.default=t;
2
+ //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../../src/hooks/useMount/index.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\nimport type { EffectCallback } from 'react';\n\nfunction useMount(effect: EffectCallback): void {\n const effectRef = useRef(effect);\n\n useEffect(() => effectRef.current(), []);\n}\n\nexport default useMount;\n"],"names":["effect","effectRef","useRef","useEffect","current"],"mappings":"mDAGA,SAAkBA,GAChB,MAAMC,EAAYC,EAAAA,OAAOF,GAEzBG,EAAAA,UAAU,IAAMF,EAAUG,UAAW,GACvC"}
1
+ {"version":3,"file":"index.cjs","names":[],"sources":["../../../src/hooks/useMount/index.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\nimport type { EffectCallback } from 'react';\n\nfunction useMount(effect: EffectCallback): void {\n const effectRef = useRef(effect);\n\n useEffect(() => effectRef.current(), []);\n}\n\nexport default useMount;\n"],"mappings":"oCAGA,SAAS,EAAS,EAA8B,CAC9C,IAAM,GAAA,EAAA,EAAA,OAAA,CAAmB,CAAM,GAE/B,EAAA,EAAA,UAAA,KAAgB,EAAU,QAAQ,EAAG,CAAC,CAAC,CACzC"}
@@ -1,2 +1,2 @@
1
- import{useRef as t,useEffect as r}from"react";function o(o){const c=t(o);r(()=>c.current(),[])}export{o as default};
2
- //# sourceMappingURL=index.js.map
1
+ import{useEffect as e,useRef as t}from"react";function n(n){let r=t(n);e(()=>r.current(),[])}export{n as default};
2
+ //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/hooks/useMount/index.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\nimport type { EffectCallback } from 'react';\n\nfunction useMount(effect: EffectCallback): void {\n const effectRef = useRef(effect);\n\n useEffect(() => effectRef.current(), []);\n}\n\nexport default useMount;\n"],"names":["useMount","effect","effectRef","useRef","useEffect","current"],"mappings":"8CAGA,SAASA,EAASC,GAChB,MAAMC,EAAYC,EAAOF,GAEzBG,EAAU,IAAMF,EAAUG,UAAW,GACvC"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/hooks/useMount/index.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\nimport type { EffectCallback } from 'react';\n\nfunction useMount(effect: EffectCallback): void {\n const effectRef = useRef(effect);\n\n useEffect(() => effectRef.current(), []);\n}\n\nexport default useMount;\n"],"mappings":"8CAGA,SAAS,EAAS,EAA8B,CAC9C,IAAM,EAAY,EAAO,CAAM,EAE/B,MAAgB,EAAU,QAAQ,EAAG,CAAC,CAAC,CACzC"}
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("react");module.exports=function(r){const t=e.useRef(void 0);return e.useEffect(()=>{t.current=r},[r]),t.current};
2
- //# sourceMappingURL=index.cjs.map
1
+ "use strict";let e=require("react");function t(t){let n=(0,e.useRef)(void 0);return(0,e.useEffect)(()=>{n.current=t},[t]),n.current}exports.default=t;
2
+ //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../../src/hooks/usePrevious/index.ts"],"sourcesContent":["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 usePrevious;\n"],"names":["value","ref","useRef","undefined","useEffect","current"],"mappings":"mDAEA,SAAwBA,GACtB,MAAMC,EAAMC,EAAAA,YAAsBC,GAMlC,OAJAC,EAAAA,UAAU,KACRH,EAAII,QAAUL,GACb,CAACA,IAEGC,EAAII,OACb"}
1
+ {"version":3,"file":"index.cjs","names":[],"sources":["../../../src/hooks/usePrevious/index.ts"],"sourcesContent":["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 usePrevious;\n"],"mappings":"oCAEA,SAAS,EAAe,EAAyB,CAC/C,IAAM,GAAA,EAAA,EAAA,OAAA,CAA4B,IAAA,EAAS,EAM3C,OAJA,EAAA,EAAA,UAAA,KAAgB,CACd,EAAI,QAAU,CAChB,EAAG,CAAC,CAAK,CAAC,EAEH,EAAI,OACb"}
@@ -1,2 +1,2 @@
1
- import{useRef as r,useEffect as t}from"react";function e(e){const n=r(void 0);return t(()=>{n.current=e},[e]),n.current}export{e as default};
2
- //# sourceMappingURL=index.js.map
1
+ import{useEffect as e,useRef as t}from"react";function n(n){let r=t(void 0);return e(()=>{r.current=n},[n]),r.current}export{n as default};
2
+ //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/hooks/usePrevious/index.ts"],"sourcesContent":["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 usePrevious;\n"],"names":["usePrevious","value","ref","useRef","undefined","useEffect","current"],"mappings":"8CAEA,SAASA,EAAeC,GACtB,MAAMC,EAAMC,OAAsBC,GAMlC,OAJAC,EAAU,KACRH,EAAII,QAAUL,GACb,CAACA,IAEGC,EAAII,OACb"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/hooks/usePrevious/index.ts"],"sourcesContent":["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 usePrevious;\n"],"mappings":"8CAEA,SAAS,EAAe,EAAyB,CAC/C,IAAM,EAAM,EAAsB,IAAA,EAAS,EAM3C,OAJA,MAAgB,CACd,EAAI,QAAU,CAChB,EAAG,CAAC,CAAK,CAAC,EAEH,EAAI,OACb"}
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("react");module.exports=function(r,u,t=!0){const c=e.useRef(!0),n=e.useRef(t),s=e.useRef(r);n.current=t,s.current=r,e.useEffect(()=>{if(!c.current&&n.current)return s.current();c.current=!1},u)};
2
- //# sourceMappingURL=index.cjs.map
1
+ "use strict";let e=require("react");function t(t,n,r=!0){let i=(0,e.useRef)(!0),a=(0,e.useRef)(r),o=(0,e.useRef)(t);a.current=r,o.current=t,(0,e.useEffect)(()=>{if(i.current||!a.current){i.current=!1;return}return o.current()},n)}exports.default=t;
2
+ //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../../src/hooks/useUpdate/index.ts"],"sourcesContent":["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 const applyChangesRef = useRef(applyChanges);\n const effectRef = useRef(effect);\n\n applyChangesRef.current = applyChanges;\n effectRef.current = effect;\n\n useEffect(() => {\n if (isInitialMount.current || !applyChangesRef.current) {\n isInitialMount.current = false;\n return;\n }\n\n return effectRef.current();\n // oxlint-disable-next-line react-hooks/exhaustive-deps -- useUpdate forwards caller-owned dependencies.\n }, deps);\n}\n\nexport default useUpdate;\n"],"names":["effect","deps","applyChanges","isInitialMount","useRef","applyChangesRef","effectRef","current","useEffect"],"mappings":"mDAGA,SAAmBA,EAAwBC,EAAsBC,GAAe,GAC9E,MAAMC,EAAiBC,EAAAA,QAAO,GACxBC,EAAkBD,EAAAA,OAAOF,GACzBI,EAAYF,EAAAA,OAAOJ,GAEzBK,EAAgBE,QAAUL,EAC1BI,EAAUC,QAAUP,EAEpBQ,EAAAA,UAAU,KACR,IAAIL,EAAeI,SAAYF,EAAgBE,QAK/C,OAAOD,EAAUC,UAJfJ,EAAeI,SAAU,GAM1BN,EACL"}
1
+ {"version":3,"file":"index.cjs","names":[],"sources":["../../../src/hooks/useUpdate/index.ts"],"sourcesContent":["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 const applyChangesRef = useRef(applyChanges);\n const effectRef = useRef(effect);\n\n applyChangesRef.current = applyChanges;\n effectRef.current = effect;\n\n useEffect(() => {\n if (isInitialMount.current || !applyChangesRef.current) {\n isInitialMount.current = false;\n return;\n }\n\n return effectRef.current();\n // oxlint-disable-next-line react-hooks/exhaustive-deps -- useUpdate forwards caller-owned dependencies.\n }, deps);\n}\n\nexport default useUpdate;\n"],"mappings":"oCAGA,SAAS,EAAU,EAAwB,EAAsB,EAAe,GAAY,CAC1F,IAAM,GAAA,EAAA,EAAA,OAAA,CAAwB,EAAI,EAC5B,GAAA,EAAA,EAAA,OAAA,CAAyB,CAAY,EACrC,GAAA,EAAA,EAAA,OAAA,CAAmB,CAAM,EAE/B,EAAgB,QAAU,EAC1B,EAAU,QAAU,GAEpB,EAAA,EAAA,UAAA,KAAgB,CACd,GAAI,EAAe,SAAW,CAAC,EAAgB,QAAS,CACtD,EAAe,QAAU,GACzB,MACF,CAEA,OAAO,EAAU,QAAQ,CAE3B,EAAG,CAAI,CACT"}
@@ -1,2 +1,2 @@
1
- import{useRef as r,useEffect as t}from"react";function e(e,n,c=!0){const u=r(!0),o=r(c),f=r(e);o.current=c,f.current=e,t(()=>{if(!u.current&&o.current)return f.current();u.current=!1},n)}export{e as default};
2
- //# sourceMappingURL=index.js.map
1
+ import{useEffect as e,useRef as t}from"react";function n(n,r,i=!0){let a=t(!0),o=t(i),s=t(n);o.current=i,s.current=n,e(()=>{if(a.current||!o.current){a.current=!1;return}return s.current()},r)}export{n as default};
2
+ //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/hooks/useUpdate/index.ts"],"sourcesContent":["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 const applyChangesRef = useRef(applyChanges);\n const effectRef = useRef(effect);\n\n applyChangesRef.current = applyChanges;\n effectRef.current = effect;\n\n useEffect(() => {\n if (isInitialMount.current || !applyChangesRef.current) {\n isInitialMount.current = false;\n return;\n }\n\n return effectRef.current();\n // oxlint-disable-next-line react-hooks/exhaustive-deps -- useUpdate forwards caller-owned dependencies.\n }, deps);\n}\n\nexport default useUpdate;\n"],"names":["useUpdate","effect","deps","applyChanges","isInitialMount","useRef","applyChangesRef","effectRef","current","useEffect"],"mappings":"8CAGA,SAASA,EAAUC,EAAwBC,EAAsBC,GAAe,GAC9E,MAAMC,EAAiBC,GAAO,GACxBC,EAAkBD,EAAOF,GACzBI,EAAYF,EAAOJ,GAEzBK,EAAgBE,QAAUL,EAC1BI,EAAUC,QAAUP,EAEpBQ,EAAU,KACR,IAAIL,EAAeI,SAAYF,EAAgBE,QAK/C,OAAOD,EAAUC,UAJfJ,EAAeI,SAAU,GAM1BN,EACL"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/hooks/useUpdate/index.ts"],"sourcesContent":["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 const applyChangesRef = useRef(applyChanges);\n const effectRef = useRef(effect);\n\n applyChangesRef.current = applyChanges;\n effectRef.current = effect;\n\n useEffect(() => {\n if (isInitialMount.current || !applyChangesRef.current) {\n isInitialMount.current = false;\n return;\n }\n\n return effectRef.current();\n // oxlint-disable-next-line react-hooks/exhaustive-deps -- useUpdate forwards caller-owned dependencies.\n }, deps);\n}\n\nexport default useUpdate;\n"],"mappings":"8CAGA,SAAS,EAAU,EAAwB,EAAsB,EAAe,GAAY,CAC1F,IAAM,EAAiB,EAAO,EAAI,EAC5B,EAAkB,EAAO,CAAY,EACrC,EAAY,EAAO,CAAM,EAE/B,EAAgB,QAAU,EAC1B,EAAU,QAAU,EAEpB,MAAgB,CACd,GAAI,EAAe,SAAW,CAAC,EAAgB,QAAS,CACtD,EAAe,QAAU,GACzB,MACF,CAEA,OAAO,EAAU,QAAQ,CAE3B,EAAG,CAAI,CACT"}
package/dist/index.cjs CHANGED
@@ -1,3 +1,2 @@
1
- "use client";
2
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@willbooster/monaco-loader"),r=require("./DiffEditor/index.cjs"),o=require("./hooks/useMonaco/index.cjs"),i=require("./Editor/index.cjs");exports.loader=e,exports.DiffEditor=r,exports.useMonaco=o,exports.Editor=i,exports.default=i;
3
- //# sourceMappingURL=index.cjs.map
1
+ "use strict";"use client";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./_virtual/_rolldown/runtime.cjs"),t=require("./hooks/useMonaco/index.cjs"),n=require("./DiffEditor/index.cjs"),r=require("./Editor/index.cjs");let i=require("@willbooster/monaco-loader");i=e.__toESM(i,1);var a=r.default;exports.DiffEditor=n.default,exports.Editor=r.default,exports.default=a,exports.loader=i.default,exports.useMonaco=t.default;
2
+ //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
1
+ {"version":3,"file":"index.cjs","names":["Editor"],"sources":["../src/index.ts"],"sourcesContent":["'use client';\n\nimport 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';\nexport type Monaco = typeof monaco;\n\n// Default themes\nexport type Theme = 'vs-dark' | 'light';\n"],"mappings":"uVAeA,IAAA,EAAeA,EAAAA"}
package/dist/index.d.ts CHANGED
@@ -9,7 +9,7 @@ import Editor from './Editor';
9
9
  export * from './Editor/types';
10
10
  export { Editor };
11
11
  export default Editor;
12
- import type * as monaco from 'monaco-editor/esm/vs/editor/editor.api.js';
12
+ import type * as monaco from 'monaco-editor';
13
13
  export type Monaco = typeof monaco;
14
14
  export type Theme = 'vs-dark' | 'light';
15
15
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,MAAM,MAAM,4BAA4B,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,CAAC;AAElB,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,CAAC;AAEtB,OAAO,SAAS,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,CAAC;AAErB,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,CAAC;eACH,MAAM;AAGrB,OAAO,KAAK,KAAK,MAAM,MAAM,2CAA2C,CAAC;AACzE,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAC;AAGnC,MAAM,MAAM,KAAK,GAAG,SAAS,GAAG,OAAO,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,MAAM,MAAM,4BAA4B,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,CAAC;AAElB,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,CAAC;AAEtB,OAAO,SAAS,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,CAAC;AAErB,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,CAAC;eACH,MAAM;AAGrB,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAC;AAC7C,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAC;AAGnC,MAAM,MAAM,KAAK,GAAG,SAAS,GAAG,OAAO,CAAC"}
package/dist/index.js CHANGED
@@ -1,3 +1,2 @@
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
1
+ "use client";import e from"./hooks/useMonaco/index.js";import t from"./DiffEditor/index.js";import n from"./Editor/index.js";import r from"@willbooster/monaco-loader";var i=n;export{t as DiffEditor,n as Editor,i as default,r as loader,e as useMonaco};
2
+ //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
1
+ {"version":3,"file":"index.js","names":["Editor"],"sources":["../src/index.ts"],"sourcesContent":["'use client';\n\nimport 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';\nexport type Monaco = typeof monaco;\n\n// Default themes\nexport type Theme = 'vs-dark' | 'light';\n"],"mappings":"uKAeA,IAAA,EAAeA"}
@@ -1,2 +1,2 @@
1
- "use strict";function t(t,r){if(function(t){return/^[a-z][a-z0-9+.-]+:/i.test(t)}(r))return t.Uri.parse(r);const e=r.replaceAll("\\","/");if(e.startsWith("//")){const[r,...i]=e.slice(2).split("/");return t.Uri.from({scheme:"file",authority:r,path:`/${i.join("/")}`})}return t.Uri.from({scheme:"file",path:e.startsWith("/")?e:`/${e}`})}exports.getOrCreateModel=function(r,e,i,n){var o;return null!=(o=function(r,e){return r.editor.getModel(t(r,e))}(r,n))?o:function(r,e,i,n){return r.editor.createModel(e,i,n?t(r,n):void 0)}(r,e,i,n)},exports.noop=function(){};
2
- //# sourceMappingURL=index.cjs.map
1
+ "use strict";function e(){}function t(e,t,i,a){return n(e,a)??r(e,t,i,a)}function n(e,t){return e.editor.getModel(i(e,t))}function r(e,t,n,r){return e.editor.createModel(t,n,r?i(e,r):void 0)}function i(e,t){if(a(t))return e.Uri.parse(t);let n=t.replaceAll(`\\`,`/`);if(n.startsWith(`//`)){let[t,...r]=n.slice(2).split(`/`);return e.Uri.from({scheme:`file`,authority:t,path:`/${r.join(`/`)}`})}return e.Uri.from({scheme:`file`,path:n.startsWith(`/`)?n:`/${n}`})}function a(e){return/^[a-z][a-z0-9+.-]+:/i.test(e)}exports.getOrCreateModel=t,exports.noop=e;
2
+ //# sourceMappingURL=index.cjs.map
@@ -1 +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 if (hasUriScheme(path)) {\n return monaco.Uri.parse(path);\n }\n\n const normalizedPath = path.replaceAll('\\\\', '/');\n if (normalizedPath.startsWith('//')) {\n const [authority, ...pathParts] = normalizedPath.slice(2).split('/');\n return monaco.Uri.from({\n scheme: 'file',\n authority,\n path: `/${pathParts.join('/')}`,\n });\n }\n\n return monaco.Uri.from({\n scheme: 'file',\n path: normalizedPath.startsWith('/') ? normalizedPath : `/${normalizedPath}`,\n });\n}\n\nfunction hasUriScheme(path: string): boolean {\n return /^[a-z][a-z0-9+.-]+:/i.test(path);\n}\n\nexport { noop, getOrCreateModel };\n"],"names":["createModelUri","monaco","path","test","hasUriScheme","Uri","parse","normalizedPath","replaceAll","startsWith","authority","pathParts","slice","split","from","scheme","join","value","language","_getModel","editor","getModel","createModel","undefined"],"mappings":"aAsDA,SAASA,EAAeC,EAAgBC,GACtC,GAoBF,SAAsBA,GACpB,MAAO,uBAAuBC,KAAKD,EACrC,CAtBME,CAAaF,GACf,OAAOD,EAAOI,IAAIC,MAAMJ,GAG1B,MAAMK,EAAiBL,EAAKM,WAAW,KAAM,KAC7C,GAAID,EAAeE,WAAW,MAAO,CACnC,MAAOC,KAAcC,GAAaJ,EAAeK,MAAM,GAAGC,MAAM,KAChE,OAAOZ,EAAOI,IAAIS,KAAK,CACrBC,OAAQ,OACRL,YACAR,KAAM,IAAIS,EAAUK,KAAK,QAE7B,CAEA,OAAOf,EAAOI,IAAIS,KAAK,CACrBC,OAAQ,OACRb,KAAMK,EAAeE,WAAW,KAAOF,EAAiB,IAAIA,KAEhE,0BApDA,SAA0BN,EAAgBgB,EAAeC,EAAkBhB,GAAiC,IAAAiB,EAC1G,OAA6B,OAA7BA,EAUF,SAAkBlB,EAAgBC,GAChC,OAAOD,EAAOmB,OAAOC,SAASrB,EAAeC,EAAQC,GACvD,CAZSmB,CAASpB,EAAQC,IAAKiB,EAsB/B,SAAqBlB,EAAgBgB,EAAeC,EAAmBhB,GACrE,OAAOD,EAAOmB,OAAOE,YAAYL,EAAOC,EAAUhB,EAAOF,EAAeC,EAAQC,QAAQqB,EAC1F,CAxBmCD,CAAYrB,EAAQgB,EAAOC,EAAUhB,EACxE,eAhBA,WACE"}
1
+ {"version":3,"file":"index.cjs","names":[],"sources":["../../src/utils/index.ts"],"sourcesContent":["import type { Monaco } from '..';\nimport type { Uri, editor } from 'monaco-editor';\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 if (hasUriScheme(path)) {\n return monaco.Uri.parse(path);\n }\n\n const normalizedPath = path.replaceAll('\\\\', '/');\n if (normalizedPath.startsWith('//')) {\n const [authority, ...pathParts] = normalizedPath.slice(2).split('/');\n return monaco.Uri.from({\n scheme: 'file',\n authority,\n path: `/${pathParts.join('/')}`,\n });\n }\n\n return monaco.Uri.from({\n scheme: 'file',\n path: normalizedPath.startsWith('/') ? normalizedPath : `/${normalizedPath}`,\n });\n}\n\nfunction hasUriScheme(path: string): boolean {\n return /^[a-z][a-z0-9+.-]+:/i.test(path);\n}\n\nexport { noop, getOrCreateModel };\n"],"mappings":"aAOA,SAAS,GAAa,CAEtB,CAYA,SAAS,EAAiB,EAAgB,EAAe,EAAkB,EAAiC,CAC1G,OAAO,EAAS,EAAQ,CAAI,GAAK,EAAY,EAAQ,EAAO,EAAU,CAAI,CAC5E,CASA,SAAS,EAAS,EAAgB,EAAwC,CACxE,OAAO,EAAO,OAAO,SAAS,EAAe,EAAQ,CAAI,CAAC,CAC5D,CAUA,SAAS,EAAY,EAAgB,EAAe,EAAmB,EAAkC,CACvG,OAAO,EAAO,OAAO,YAAY,EAAO,EAAU,EAAO,EAAe,EAAQ,CAAI,EAAI,IAAA,EAAS,CACnG,CAQA,SAAS,EAAe,EAAgB,EAAmB,CACzD,GAAI,EAAa,CAAI,EACnB,OAAO,EAAO,IAAI,MAAM,CAAI,EAG9B,IAAM,EAAiB,EAAK,WAAW,KAAM,GAAG,EAChD,GAAI,EAAe,WAAW,IAAI,EAAG,CACnC,GAAM,CAAC,EAAW,GAAG,GAAa,EAAe,MAAM,CAAC,CAAC,CAAC,MAAM,GAAG,EACnE,OAAO,EAAO,IAAI,KAAK,CACrB,OAAQ,OACR,YACA,KAAM,IAAI,EAAU,KAAK,GAAG,GAC9B,CAAC,CACH,CAEA,OAAO,EAAO,IAAI,KAAK,CACrB,OAAQ,OACR,KAAM,EAAe,WAAW,GAAG,EAAI,EAAiB,IAAI,GAC9D,CAAC,CACH,CAEA,SAAS,EAAa,EAAuB,CAC3C,MAAO,uBAAuB,KAAK,CAAI,CACzC"}
@@ -1,5 +1,5 @@
1
1
  import type { Monaco } from '..';
2
- import type { editor } from 'monaco-editor/esm/vs/editor/editor.api.js';
2
+ import type { editor } from 'monaco-editor';
3
3
  /**
4
4
  * noop is a helper function that does nothing
5
5
  * @returns undefined
@@ -1 +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;AAwDD,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAC"}
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,eAAe,CAAC;AAEjD;;;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;AAwDD,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAC"}
@@ -1,2 +1,2 @@
1
- function t(){}function r(t,r,i,n){var o;return null!=(o=function(t,r){return t.editor.getModel(e(t,r))}(t,n))?o:function(t,r,i,n){return t.editor.createModel(r,i,n?e(t,n):void 0)}(t,r,i,n)}function e(t,r){if(function(t){return/^[a-z][a-z0-9+.-]+:/i.test(t)}(r))return t.Uri.parse(r);const e=r.replaceAll("\\","/");if(e.startsWith("//")){const[r,...i]=e.slice(2).split("/");return t.Uri.from({scheme:"file",authority:r,path:`/${i.join("/")}`})}return t.Uri.from({scheme:"file",path:e.startsWith("/")?e:`/${e}`})}export{r as getOrCreateModel,t as noop};
2
- //# sourceMappingURL=index.js.map
1
+ function e(){}function t(e,t,i,a){return n(e,a)??r(e,t,i,a)}function n(e,t){return e.editor.getModel(i(e,t))}function r(e,t,n,r){return e.editor.createModel(t,n,r?i(e,r):void 0)}function i(e,t){if(a(t))return e.Uri.parse(t);let n=t.replaceAll(`\\`,`/`);if(n.startsWith(`//`)){let[t,...r]=n.slice(2).split(`/`);return e.Uri.from({scheme:`file`,authority:t,path:`/${r.join(`/`)}`})}return e.Uri.from({scheme:`file`,path:n.startsWith(`/`)?n:`/${n}`})}function a(e){return/^[a-z][a-z0-9+.-]+:/i.test(e)}export{t as getOrCreateModel,e as noop};
2
+ //# sourceMappingURL=index.js.map
@@ -1 +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 if (hasUriScheme(path)) {\n return monaco.Uri.parse(path);\n }\n\n const normalizedPath = path.replaceAll('\\\\', '/');\n if (normalizedPath.startsWith('//')) {\n const [authority, ...pathParts] = normalizedPath.slice(2).split('/');\n return monaco.Uri.from({\n scheme: 'file',\n authority,\n path: `/${pathParts.join('/')}`,\n });\n }\n\n return monaco.Uri.from({\n scheme: 'file',\n path: normalizedPath.startsWith('/') ? normalizedPath : `/${normalizedPath}`,\n });\n}\n\nfunction hasUriScheme(path: string): boolean {\n return /^[a-z][a-z0-9+.-]+:/i.test(path);\n}\n\nexport { noop, getOrCreateModel };\n"],"names":["noop","getOrCreateModel","monaco","value","language","path","_getModel","editor","getModel","createModelUri","createModel","undefined","test","hasUriScheme","Uri","parse","normalizedPath","replaceAll","startsWith","authority","pathParts","slice","split","from","scheme","join"],"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,GAoBF,SAAsBA,GACpB,MAAO,uBAAuBO,KAAKP,EACrC,CAtBMQ,CAAaR,GACf,OAAOH,EAAOY,IAAIC,MAAMV,GAG1B,MAAMW,EAAiBX,EAAKY,WAAW,KAAM,KAC7C,GAAID,EAAeE,WAAW,MAAO,CACnC,MAAOC,KAAcC,GAAaJ,EAAeK,MAAM,GAAGC,MAAM,KAChE,OAAOpB,EAAOY,IAAIS,KAAK,CACrBC,OAAQ,OACRL,YACAd,KAAM,IAAIe,EAAUK,KAAK,QAE7B,CAEA,OAAOvB,EAAOY,IAAIS,KAAK,CACrBC,OAAQ,OACRnB,KAAMW,EAAeE,WAAW,KAAOF,EAAiB,IAAIA,KAEhE"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/utils/index.ts"],"sourcesContent":["import type { Monaco } from '..';\nimport type { Uri, editor } from 'monaco-editor';\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 if (hasUriScheme(path)) {\n return monaco.Uri.parse(path);\n }\n\n const normalizedPath = path.replaceAll('\\\\', '/');\n if (normalizedPath.startsWith('//')) {\n const [authority, ...pathParts] = normalizedPath.slice(2).split('/');\n return monaco.Uri.from({\n scheme: 'file',\n authority,\n path: `/${pathParts.join('/')}`,\n });\n }\n\n return monaco.Uri.from({\n scheme: 'file',\n path: normalizedPath.startsWith('/') ? normalizedPath : `/${normalizedPath}`,\n });\n}\n\nfunction hasUriScheme(path: string): boolean {\n return /^[a-z][a-z0-9+.-]+:/i.test(path);\n}\n\nexport { noop, getOrCreateModel };\n"],"mappings":"AAOA,SAAS,GAAa,CAEtB,CAYA,SAAS,EAAiB,EAAgB,EAAe,EAAkB,EAAiC,CAC1G,OAAO,EAAS,EAAQ,CAAI,GAAK,EAAY,EAAQ,EAAO,EAAU,CAAI,CAC5E,CASA,SAAS,EAAS,EAAgB,EAAwC,CACxE,OAAO,EAAO,OAAO,SAAS,EAAe,EAAQ,CAAI,CAAC,CAC5D,CAUA,SAAS,EAAY,EAAgB,EAAe,EAAmB,EAAkC,CACvG,OAAO,EAAO,OAAO,YAAY,EAAO,EAAU,EAAO,EAAe,EAAQ,CAAI,EAAI,IAAA,EAAS,CACnG,CAQA,SAAS,EAAe,EAAgB,EAAmB,CACzD,GAAI,EAAa,CAAI,EACnB,OAAO,EAAO,IAAI,MAAM,CAAI,EAG9B,IAAM,EAAiB,EAAK,WAAW,KAAM,GAAG,EAChD,GAAI,EAAe,WAAW,IAAI,EAAG,CACnC,GAAM,CAAC,EAAW,GAAG,GAAa,EAAe,MAAM,CAAC,CAAC,CAAC,MAAM,GAAG,EACnE,OAAO,EAAO,IAAI,KAAK,CACrB,OAAQ,OACR,YACA,KAAM,IAAI,EAAU,KAAK,GAAG,GAC9B,CAAC,CACH,CAEA,OAAO,EAAO,IAAI,KAAK,CACrB,OAAQ,OACR,KAAM,EAAe,WAAW,GAAG,EAAI,EAAiB,IAAI,GAC9D,CAAC,CACH,CAEA,SAAS,EAAa,EAAuB,CAC3C,MAAO,uBAAuB,KAAK,CAAI,CACzC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/monaco-react",
3
- "version": "1.0.9",
3
+ "version": "2.0.0",
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",
@@ -35,60 +35,58 @@
35
35
  "dist/"
36
36
  ],
37
37
  "scripts": {
38
- "build": "yarn run build/core",
38
+ "build": "bun run build/core",
39
39
  "build/core": "build-ts lib",
40
- "cleanup": "yarn format && yarn lint-fix",
41
- "common/ci-setup": "yarn run build/core",
42
- "format": "sort-package-json && yarn format-code",
43
- "format-code": "oxfmt --write --no-error-on-unmatched-pattern . '!**/package.json'",
44
- "lint": "oxlint --no-error-on-unmatched-pattern .",
45
- "lint-fix": "yarn lint --fix",
40
+ "cleanup": "bun wb lint --fix --format",
41
+ "common/ci-setup": "bun run build/core",
42
+ "format": "bun wb lint --format",
43
+ "lint": "bun wb lint",
44
+ "lint-fix": "bun wb lint --fix",
46
45
  "prepare": "lefthook install || true",
47
- "test": "yarn test:unit && yarn test:e2e:next",
48
- "test:e2e:next": "yarn build && next build e2e/next-app && playwright test --config e2e/next-app/playwright.config.ts",
49
- "test:unit": "vitest",
46
+ "test": "bun wb test",
50
47
  "test/ci-setup": "playwright install chromium",
51
- "typecheck": "wb typecheck",
52
- "verify": "wb verify",
53
- "verify-full": "wb verify --full"
48
+ "typecheck": "bun wb typecheck",
49
+ "verify": "bun wb verify",
50
+ "verify-full": "bun wb verify --full"
54
51
  },
55
52
  "dependencies": {
56
- "@willbooster/monaco-loader": "1.1.3",
57
- "monaco-editor": "0.55.1"
53
+ "@willbooster/monaco-loader": "2.0.0",
54
+ "monaco-editor": "0.56.0"
58
55
  },
59
56
  "devDependencies": {
60
57
  "@playwright/test": "1.59.1",
61
58
  "@testing-library/dom": "10.4.1",
62
59
  "@testing-library/jest-dom": "6.9.1",
63
60
  "@testing-library/react": "16.3.0",
61
+ "@tsconfig/bun": "1.0.10",
64
62
  "@tsconfig/node-lts": "24.0.0",
65
63
  "@tsconfig/node-ts": "23.6.4",
64
+ "@types/bun": "1.3.14",
66
65
  "@types/node": "25.6.0",
67
66
  "@types/react": "19.2.14",
68
67
  "@types/react-dom": "19.2.3",
69
- "@typescript/native-preview": "7.0.0-dev.20260421.2",
70
68
  "@willbooster/oxfmt-config": "1.2.2",
71
69
  "@willbooster/oxlint-config": "1.4.8",
72
- "@willbooster/wb": "13.22.18",
73
- "build-ts": "17.1.26",
70
+ "@willbooster/wb": "15.4.0",
71
+ "build-ts": "19.0.0",
74
72
  "conventional-changelog-conventionalcommits": "9.3.1",
75
73
  "jsdom": "29.0.2",
76
- "lefthook": "2.1.9",
77
- "next": "16.2.4",
78
- "oxfmt": "0.56.0",
79
- "oxlint": "1.71.0",
80
- "oxlint-tsgolint": "0.23.0",
74
+ "lefthook": "2.1.10",
75
+ "next": "16.3.0-preview.6",
76
+ "oxfmt": "0.59.0",
77
+ "oxlint": "1.74.0",
78
+ "oxlint-tsgolint": "7.0.2001",
81
79
  "react": "19.2.5",
82
80
  "react-dom": "19.2.5",
83
81
  "semantic-release": "25.0.3",
84
82
  "sort-package-json": "4.0.0",
83
+ "typescript": "7.0.2",
85
84
  "vitest": "4.1.4"
86
85
  },
87
86
  "peerDependencies": {
88
87
  "react": "^19.0.0",
89
88
  "react-dom": "^19.0.0"
90
89
  },
91
- "packageManager": "yarn@4.17.0",
92
90
  "engines": {
93
91
  "node": ">=24"
94
92
  },
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=index.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.spec.d.ts","sourceRoot":"","sources":["../../src/DiffEditor/index.spec.tsx"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=index.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.spec.d.ts","sourceRoot":"","sources":["../../src/Editor/index.spec.tsx"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=index.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.spec.d.ts","sourceRoot":"","sources":["../../src/Loading/index.spec.tsx"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=index.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.spec.d.ts","sourceRoot":"","sources":["../../src/MonacoContainer/index.spec.tsx"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- "use strict";function e(e,r,t){return(r=o(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function r(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,o)}return t}function t(e,r){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var o=t.call(e,r);if("object"!=typeof o)return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}function o(e){var r=t(e,"string");return"symbol"==typeof r?r:r+""}exports.defineProperty=e,exports.objectSpread2=function(t){for(var o=1;o<arguments.length;o++){var n=null!=arguments[o]?arguments[o]:{};o%2?r(Object(n),!0).forEach(function(r){e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):r(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t},exports.toPrimitive=t,exports.toPropertyKey=o;
2
- //# sourceMappingURL=_rollupPluginBabelHelpers.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"_rollupPluginBabelHelpers.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- function e(e,r,t){return(r=o(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function r(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,n)}return t}function t(t){for(var n=1;n<arguments.length;n++){var o=null!=arguments[n]?arguments[n]:{};n%2?r(Object(o),!0).forEach(function(r){e(t,r,o[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):r(Object(o)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))})}return t}function n(e,r){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,r);if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}function o(e){var r=n(e,"string");return"symbol"==typeof r?r:r+""}export{e as defineProperty,t as objectSpread2,n as toPrimitive,o as toPropertyKey};
2
- //# sourceMappingURL=_rollupPluginBabelHelpers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"_rollupPluginBabelHelpers.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}