@willbooster/monaco-react 1.0.5 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/README.md +2 -1
  2. package/dist/DiffEditor/DiffEditor.cjs +1 -1
  3. package/dist/DiffEditor/DiffEditor.d.ts +1 -1
  4. package/dist/DiffEditor/DiffEditor.d.ts.map +1 -1
  5. package/dist/DiffEditor/DiffEditor.js +1 -1
  6. package/dist/DiffEditor/index.d.ts.map +1 -1
  7. package/dist/Editor/Editor.cjs +1 -1
  8. package/dist/Editor/Editor.d.ts +1 -1
  9. package/dist/Editor/Editor.d.ts.map +1 -1
  10. package/dist/Editor/Editor.js +1 -1
  11. package/dist/Editor/index.d.ts.map +1 -1
  12. package/dist/Loading/Loading.d.ts.map +1 -1
  13. package/dist/Loading/index.d.ts.map +1 -1
  14. package/dist/Loading/styles.d.ts.map +1 -1
  15. package/dist/MonacoContainer/MonacoContainer.d.ts +1 -1
  16. package/dist/MonacoContainer/MonacoContainer.d.ts.map +1 -1
  17. package/dist/MonacoContainer/index.d.ts.map +1 -1
  18. package/dist/MonacoContainer/styles.d.ts.map +1 -1
  19. package/dist/MonacoContainer/types.d.ts +1 -1
  20. package/dist/MonacoContainer/types.d.ts.map +1 -1
  21. package/dist/hooks/useMonaco/index.cjs +1 -1
  22. package/dist/hooks/useMonaco/index.cjs.map +1 -1
  23. package/dist/hooks/useMonaco/index.d.ts.map +1 -1
  24. package/dist/hooks/useMonaco/index.js +1 -1
  25. package/dist/hooks/useMonaco/index.js.map +1 -1
  26. package/dist/hooks/useMonaco/initMonaco.cjs +2 -0
  27. package/dist/hooks/useMonaco/initMonaco.cjs.map +1 -0
  28. package/dist/hooks/useMonaco/initMonaco.d.ts +4 -0
  29. package/dist/hooks/useMonaco/initMonaco.d.ts.map +1 -0
  30. package/dist/hooks/useMonaco/initMonaco.js +2 -0
  31. package/dist/hooks/useMonaco/initMonaco.js.map +1 -0
  32. package/dist/hooks/useMount/index.d.ts.map +1 -1
  33. package/dist/hooks/usePrevious/index.d.ts.map +1 -1
  34. package/dist/hooks/useUpdate/index.d.ts.map +1 -1
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/utils/index.cjs +1 -1
  37. package/dist/utils/index.cjs.map +1 -1
  38. package/dist/utils/index.d.ts.map +1 -1
  39. package/dist/utils/index.js +1 -1
  40. package/dist/utils/index.js.map +1 -1
  41. package/package.json +27 -25
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
+
5
6
  [![monthly downloads](https://img.shields.io/npm/dm/@willbooster/monaco-react)](https://www.npmjs.com/package/@willbooster/monaco-react)
6
7
  [![npm version](https://img.shields.io/npm/v/@willbooster/monaco-react.svg?style=flat)](https://www.npmjs.com/package/@willbooster/monaco-react)
7
8
 
@@ -39,7 +40,7 @@ import Editor, { DiffEditor, loader, useMonaco } from '@willbooster/monaco-react
39
40
 
40
41
  - `Editor`: Monaco standalone code editor component.
41
42
  - `DiffEditor`: Monaco standalone diff editor component.
42
- - `useMonaco`: React hook returning the initialized Monaco instance.
43
+ - `useMonaco`: React hook returning the initialized Monaco instance after hydration. Wrap components that call it in `Suspense`.
43
44
  - `loader`: the `@willbooster/monaco-loader` instance used by the components.
44
45
 
45
46
  ### Editor
@@ -1,3 +1,3 @@
1
1
  "use client";
2
- "use strict";var e=require("../_virtual/_rollupPluginBabelHelpers.cjs"),r=require("react"),t=require("@willbooster/monaco-loader"),n=require("../MonacoContainer/index.cjs"),o=require("../hooks/useMount/index.cjs"),u=require("../hooks/useUpdate/index.cjs"),i=require("../utils/index.cjs"),l=require("react/jsx-runtime");module.exports=function({original:a,modified:d,language:c,originalLanguage:s,modifiedLanguage:g,originalModelPath:M,modifiedModelPath:f,keepCurrentOriginalModel:p=!1,keepCurrentModifiedModel:h=!1,theme:m="light",loading:x="Loading...",options:v={},height:O="100%",width:C="100%",className:E,wrapperProps:j={},beforeMount:q=i.noop,onMount:R=i.noop}){const[k,b]=r.useState(!1),[L,w]=r.useState(!0),P=r.useRef(null),y=r.useRef(null),S=r.useRef(null),D=r.useRef(R),V=r.useRef(q),_=r.useRef(!1);o(()=>{const e=t.init();return e.then(e=>(y.current=e)&&w(!1)).catch(e=>"cancelation"!==(null==e?void 0:e.type)&&console.error("Monaco initialization: error:",e)),()=>P.current?function(){const e=P.current,r=null==e?void 0:e.getModel();var t,n;null==e||e.setModel(null),null==e||e.dispose(),p||null!=r&&r.original.isDisposed()||null==r||null==(t=r.original)||t.dispose();h||null!=r&&r.modified.isDisposed()||null==r||null==(n=r.modified)||n.dispose();P.current=null,_.current=!1,b(!1)}():e.cancel()}),u(()=>{if(P.current&&y.current){const e=P.current.getOriginalEditor(),r=i.getOrCreateModel(y.current,a||"",s||c||"text",M||"");r!==e.getModel()&&e.setModel(r)}},[M],k),u(()=>{if(P.current&&y.current){const e=P.current.getModifiedEditor(),r=i.getOrCreateModel(y.current,d||"",g||c||"text",f||"");r!==e.getModel()&&e.setModel(r)}},[f],k),u(()=>{const e=P.current.getModifiedEditor();e.getOption(y.current.editor.EditorOption.readOnly)?e.setValue(d||""):d!==e.getValue()&&(e.executeEdits("",[{range:e.getModel().getFullModelRange(),text:d||"",forceMoveMarkers:!0}]),e.pushUndoStop())},[d],k),u(()=>{var e;null==(e=P.current)||null==(e=e.getModel())||e.original.setValue(a||"")},[a],k),u(()=>{const{original:e,modified:r}=P.current.getModel();y.current.editor.setModelLanguage(e,s||c||"text"),y.current.editor.setModelLanguage(r,g||c||"text")},[c,s,g],k),u(()=>{var e;null==(e=y.current)||e.editor.setTheme(m)},[m],k),u(()=>{var e;null==(e=P.current)||e.updateOptions(v)},[v],k);const N=r.useCallback(()=>{var e;if(!y.current)return;V.current(y.current);const r=i.getOrCreateModel(y.current,a||"",s||c||"text",M||""),t=i.getOrCreateModel(y.current,d||"",g||c||"text",f||"");null==(e=P.current)||e.setModel({original:r,modified:t})},[c,d,g,a,s,M,f]),T=r.useCallback(()=>{var r;!_.current&&S.current&&(P.current=y.current.editor.createDiffEditor(S.current,e.objectSpread2({automaticLayout:!0},v)),N(),null==(r=y.current)||r.editor.setTheme(m),b(!0),_.current=!0)},[v,m,N]);return r.useEffect(()=>{k&&D.current(P.current,y.current)},[k]),r.useEffect(()=>{L||k||T()},[L,k,T]),l.jsx(n,{width:C,height:O,isEditorReady:k,loading:x,_ref:S,className:E,wrapperProps:j})};
2
+ "use strict";var e=require("../_virtual/_rollupPluginBabelHelpers.cjs"),r=require("react"),t=require("../MonacoContainer/index.cjs"),n=require("../hooks/useMount/index.cjs"),o=require("../hooks/useUpdate/index.cjs"),i=require("../hooks/useMonaco/index.cjs"),u=require("../utils/index.cjs"),l=require("react/jsx-runtime");function a(r){const n=i();if(!n){const{width:e="100%",height:n="100%",loading:o="Loading...",className:i,wrapperProps:u={}}=r;return l.jsx(t,{width:e,height:n,isEditorReady:!1,loading:o,className:i,wrapperProps:u})}return l.jsx(s,e.objectSpread2(e.objectSpread2({},r),{},{monaco:n}))}function s({monaco:i,original:a,modified:s,language:d,originalLanguage:c,modifiedLanguage:g,originalModelPath:p,modifiedModelPath:f,keepCurrentOriginalModel:M=!1,keepCurrentModifiedModel:h=!1,theme:m="light",loading:x="Loading...",options:j={},height:w="100%",width:E="100%",className:v,wrapperProps:O={},beforeMount:R=u.noop,onMount:b=u.noop}){const[k,C]=r.useState(!1),P=r.useRef(null),q=r.useRef(i),L=r.useRef(null),S=r.useRef(b),N=r.useRef(R),y=r.useRef(!1);q.current=i,n(()=>()=>{P.current&&function(){const e=P.current,r=null==e?void 0:e.getModel();var t,n;null==e||e.setModel(null),null==e||e.dispose(),M||null!=r&&r.original.isDisposed()||null==r||null==(t=r.original)||t.dispose();h||null!=r&&r.modified.isDisposed()||null==r||null==(n=r.modified)||n.dispose();P.current=null,y.current=!1,C(!1)}()}),o(()=>{if(P.current&&q.current){const e=P.current.getOriginalEditor(),r=u.getOrCreateModel(q.current,a||"",c||d||"text",p||"");r!==e.getModel()&&e.setModel(r)}},[p],k),o(()=>{if(P.current&&q.current){const e=P.current.getModifiedEditor(),r=u.getOrCreateModel(q.current,s||"",g||d||"text",f||"");r!==e.getModel()&&e.setModel(r)}},[f],k),o(()=>{const e=P.current.getModifiedEditor();e.getOption(q.current.editor.EditorOption.readOnly)?e.setValue(s||""):s!==e.getValue()&&(e.executeEdits("",[{range:e.getModel().getFullModelRange(),text:s||"",forceMoveMarkers:!0}]),e.pushUndoStop())},[s],k),o(()=>{var e;null==(e=P.current)||null==(e=e.getModel())||e.original.setValue(a||"")},[a],k),o(()=>{const{original:e,modified:r}=P.current.getModel();q.current.editor.setModelLanguage(e,c||d||"text"),q.current.editor.setModelLanguage(r,g||d||"text")},[d,c,g],k),o(()=>{var e;null==(e=q.current)||e.editor.setTheme(m)},[m],k),o(()=>{var e;null==(e=P.current)||e.updateOptions(j)},[j],k);const D=r.useCallback(()=>{var e;N.current(q.current);const r=u.getOrCreateModel(q.current,a||"",c||d||"text",p||""),t=u.getOrCreateModel(q.current,s||"",g||d||"text",f||"");null==(e=P.current)||e.setModel({original:r,modified:t})},[d,s,g,a,c,p,f]),V=r.useCallback(()=>{var r;!y.current&&L.current&&(P.current=q.current.editor.createDiffEditor(L.current,e.objectSpread2({automaticLayout:!0},j)),D(),null==(r=q.current)||r.editor.setTheme(m),C(!0),y.current=!0)},[j,m,D]);return r.useEffect(()=>{k&&S.current(P.current,q.current)},[k]),r.useEffect(()=>{k||V()},[k,V]),l.jsx(t,{width:E,height:w,isEditorReady:k,loading:x,_ref:L,className:v,wrapperProps:O})}module.exports=function(n){const{width:o="100%",height:i="100%",loading:u="Loading...",className:s,wrapperProps:d={}}=n;return l.jsx(r.Suspense,{fallback:l.jsx(t,{width:o,height:i,isEditorReady:!1,loading:u,className:s,wrapperProps:d}),children:l.jsx(a,e.objectSpread2({},n))})};
3
3
  //# sourceMappingURL=DiffEditor.cjs.map
@@ -1,5 +1,5 @@
1
1
  import type { ReactElement } from 'react';
2
2
  import type { DiffEditorProps } from './types';
3
- declare function DiffEditor({ original, modified, language, originalLanguage, modifiedLanguage, originalModelPath, modifiedModelPath, keepCurrentOriginalModel, keepCurrentModifiedModel, theme, loading, options, height, width, className, wrapperProps, beforeMount, onMount }: DiffEditorProps): ReactElement;
3
+ declare function DiffEditor(props: DiffEditorProps): ReactElement;
4
4
  export default DiffEditor;
5
5
  //# sourceMappingURL=DiffEditor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DiffEditor.d.ts","sourceRoot":"","sources":["../../src/DiffEditor/DiffEditor.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAO1C,OAAO,KAAK,EAAE,eAAe,EAAoB,MAAM,SAAS,CAAC;AAGjE,iBAAS,UAAU,CAAC,EAClB,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,wBAAgC,EAChC,wBAAgC,EAChC,KAAe,EACf,OAAsB,EACtB,OAAY,EACZ,MAAe,EACf,KAAc,EACd,SAAS,EACT,YAAiB,EACjB,WAAkB,EAClB,OAAc,EACf,EAAE,eAAe,GAAG,YAAY,CA0MhC;AAED,eAAe,UAAU,CAAC"}
1
+ {"version":3,"file":"DiffEditor.d.ts","sourceRoot":"","sources":["../../src/DiffEditor/DiffEditor.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAO1C,OAAO,KAAK,EAAE,eAAe,EAAoB,MAAM,SAAS,CAAC;AAGjE,iBAAS,UAAU,CAAC,KAAK,EAAE,eAAe,GAAG,YAAY,CAmBxD;eAqPc,UAAU"}
@@ -1,3 +1,3 @@
1
1
  "use client";
2
- import{objectSpread2 as e}from"../_virtual/_rollupPluginBabelHelpers.js";import{useState as r,useRef as t,useCallback as n,useEffect as o}from"react";import i from"@willbooster/monaco-loader";import l from"../MonacoContainer/index.js";import u from"../hooks/useMount/index.js";import d from"../hooks/useUpdate/index.js";import{noop as a,getOrCreateModel as c}from"../utils/index.js";import{jsx as s}from"react/jsx-runtime";function g({original:g,modified:p,language:m,originalLanguage:f,modifiedLanguage:M,originalModelPath:h,modifiedModelPath:x,keepCurrentOriginalModel:v=!1,keepCurrentModifiedModel:j=!1,theme:E="light",loading:L="Loading...",options:O={},height:k="100%",width:w="100%",className:P,wrapperProps:b={},beforeMount:y=a,onMount:C=a}){const[D,V]=r(!1),[_,N]=r(!0),R=t(null),S=t(null),T=t(null),U=t(C),z=t(y),B=t(!1);u(()=>{const e=i.init();return e.then(e=>(S.current=e)&&N(!1)).catch(e=>"cancelation"!==(null==e?void 0:e.type)&&console.error("Monaco initialization: error:",e)),()=>R.current?function(){const e=R.current,r=null==e?void 0:e.getModel();var t,n;null==e||e.setModel(null),null==e||e.dispose(),v||null!=r&&r.original.isDisposed()||null==r||null==(t=r.original)||t.dispose();j||null!=r&&r.modified.isDisposed()||null==r||null==(n=r.modified)||n.dispose();R.current=null,B.current=!1,V(!1)}():e.cancel()}),d(()=>{if(R.current&&S.current){const e=R.current.getOriginalEditor(),r=c(S.current,g||"",f||m||"text",h||"");r!==e.getModel()&&e.setModel(r)}},[h],D),d(()=>{if(R.current&&S.current){const e=R.current.getModifiedEditor(),r=c(S.current,p||"",M||m||"text",x||"");r!==e.getModel()&&e.setModel(r)}},[x],D),d(()=>{const e=R.current.getModifiedEditor();e.getOption(S.current.editor.EditorOption.readOnly)?e.setValue(p||""):p!==e.getValue()&&(e.executeEdits("",[{range:e.getModel().getFullModelRange(),text:p||"",forceMoveMarkers:!0}]),e.pushUndoStop())},[p],D),d(()=>{var e;null==(e=R.current)||null==(e=e.getModel())||e.original.setValue(g||"")},[g],D),d(()=>{const{original:e,modified:r}=R.current.getModel();S.current.editor.setModelLanguage(e,f||m||"text"),S.current.editor.setModelLanguage(r,M||m||"text")},[m,f,M],D),d(()=>{var e;null==(e=S.current)||e.editor.setTheme(E)},[E],D),d(()=>{var e;null==(e=R.current)||e.updateOptions(O)},[O],D);const F=n(()=>{var e;if(!S.current)return;z.current(S.current);const r=c(S.current,g||"",f||m||"text",h||""),t=c(S.current,p||"",M||m||"text",x||"");null==(e=R.current)||e.setModel({original:r,modified:t})},[m,p,M,g,f,h,x]),H=n(()=>{var r;!B.current&&T.current&&(R.current=S.current.editor.createDiffEditor(T.current,e({automaticLayout:!0},O)),F(),null==(r=S.current)||r.editor.setTheme(E),V(!0),B.current=!0)},[O,E,F]);return o(()=>{D&&U.current(R.current,S.current)},[D]),o(()=>{_||D||H()},[_,D,H]),s(l,{width:w,height:k,isEditorReady:D,loading:L,_ref:T,className:P,wrapperProps:b})}export{g as default};
2
+ import{objectSpread2 as e}from"../_virtual/_rollupPluginBabelHelpers.js";import{Suspense as r,useState as t,useRef as o,useCallback as n,useEffect as i}from"react";import l from"../MonacoContainer/index.js";import u from"../hooks/useMount/index.js";import d from"../hooks/useUpdate/index.js";import a 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:n="100%",loading:i="Loading...",className:u,wrapperProps:d={}}=t;return g(r,{fallback:g(l,{width:o,height:n,isEditorReady:!1,loading:i,className:u,wrapperProps:d}),children:g(m,e({},t))})}function m(r){const t=a();if(!t){const{width:e="100%",height:t="100%",loading:o="Loading...",className:n,wrapperProps:i={}}=r;return g(l,{width:e,height:t,isEditorReady:!1,loading:o,className:n,wrapperProps:i})}return g(f,e(e({},r),{},{monaco:t}))}function f({monaco:r,original:a,modified:p,language:m,originalLanguage:f,modifiedLanguage:h,originalModelPath:M,modifiedModelPath:x,keepCurrentOriginalModel:w=!1,keepCurrentModifiedModel:v=!1,theme:E="light",loading:P="Loading...",options:j={},height:L="100%",width:k="100%",className:N,wrapperProps:O={},beforeMount:y=s,onMount:b=s}){const[R,C]=t(!1),D=o(null),V=o(r),_=o(null),S=o(b),T=o(y),U=o(!1);V.current=r,u(()=>()=>{D.current&&function(){const e=D.current,r=null==e?void 0:e.getModel();var t,o;null==e||e.setModel(null),null==e||e.dispose(),w||null!=r&&r.original.isDisposed()||null==r||null==(t=r.original)||t.dispose();v||null!=r&&r.modified.isDisposed()||null==r||null==(o=r.modified)||o.dispose();D.current=null,U.current=!1,C(!1)}()}),d(()=>{if(D.current&&V.current){const e=D.current.getOriginalEditor(),r=c(V.current,a||"",f||m||"text",M||"");r!==e.getModel()&&e.setModel(r)}},[M],R),d(()=>{if(D.current&&V.current){const e=D.current.getModifiedEditor(),r=c(V.current,p||"",h||m||"text",x||"");r!==e.getModel()&&e.setModel(r)}},[x],R),d(()=>{const e=D.current.getModifiedEditor();e.getOption(V.current.editor.EditorOption.readOnly)?e.setValue(p||""):p!==e.getValue()&&(e.executeEdits("",[{range:e.getModel().getFullModelRange(),text:p||"",forceMoveMarkers:!0}]),e.pushUndoStop())},[p],R),d(()=>{var e;null==(e=D.current)||null==(e=e.getModel())||e.original.setValue(a||"")},[a],R),d(()=>{const{original:e,modified:r}=D.current.getModel();V.current.editor.setModelLanguage(e,f||m||"text"),V.current.editor.setModelLanguage(r,h||m||"text")},[m,f,h],R),d(()=>{var e;null==(e=V.current)||e.editor.setTheme(E)},[E],R),d(()=>{var e;null==(e=D.current)||e.updateOptions(j)},[j],R);const B=n(()=>{var e;T.current(V.current);const r=c(V.current,a||"",f||m||"text",M||""),t=c(V.current,p||"",h||m||"text",x||"");null==(e=D.current)||e.setModel({original:r,modified:t})},[m,p,h,a,f,M,x]),F=n(()=>{var r;!U.current&&_.current&&(D.current=V.current.editor.createDiffEditor(_.current,e({automaticLayout:!0},j)),B(),null==(r=V.current)||r.editor.setTheme(E),C(!0),U.current=!0)},[j,E,B]);return i(()=>{R&&S.current(D.current,V.current)},[R]),i(()=>{R||F()},[R,F]),g(l,{width:k,height:L,isEditorReady:R,loading:P,_ref:_,className:N,wrapperProps:O})}export{p as default};
3
3
  //# sourceMappingURL=DiffEditor.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/DiffEditor/index.ts"],"names":[],"mappings":"AAEA,OAAO,UAAU,MAAM,cAAc,CAAC;AAEtC,cAAc,SAAS,CAAC;;AAExB,wBAAgC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/DiffEditor/index.ts"],"names":[],"mappings":"AAEA,OAAO,UAAU,MAAM,cAAc,CAAC;AAEtC,cAAc,SAAS,CAAC"}
@@ -1,3 +1,3 @@
1
1
  "use client";
2
- "use strict";var e=require("../_virtual/_rollupPluginBabelHelpers.cjs"),r=require("react"),t=require("@willbooster/monaco-loader"),n=require("../hooks/useMount/index.cjs"),u=require("../hooks/useUpdate/index.cjs"),o=require("../hooks/usePrevious/index.cjs"),c=require("../utils/index.cjs"),i=require("../MonacoContainer/index.cjs"),l=require("react/jsx-runtime");const a=new Map;module.exports=function({defaultValue:s,defaultLanguage:d,defaultPath:v,value:g,language:p,path:f,theme:h="light",line:M,loading:w="Loading...",options:R={},overrideServices:m={},saveViewState:x=!0,keepCurrentModel:S=!1,width:V="100%",height:j="100%",className:q,wrapperProps:C={},beforeMount:k=c.noop,onMount:E=c.noop,onChange:L,onValidate:O=c.noop}){const[b,P]=r.useState(!1),[y,_]=r.useState(!0),D=r.useRef(null),N=r.useRef(void 0),T=r.useRef(null),U=r.useRef(E),z=r.useRef(k),B=r.useRef(void 0),F=r.useRef(g),H=o(f),A=r.useRef(!1),G=r.useRef(!1);n(()=>{const e=t.init();return e.then(e=>(D.current=e)&&_(!1)).catch(e=>"cancelation"!==(null==e?void 0:e.type)&&console.error("Monaco initialization: error:",e)),()=>N.current?function(){var e,r;null==(e=B.current)||e.dispose(),S?x&&a.set(f,N.current.saveViewState()):null==(r=N.current.getModel())||r.dispose();N.current.dispose(),N.current=void 0,A.current=!1,P(!1)}():e.cancel()}),u(()=>{var e;const r=c.getOrCreateModel(D.current,s||g||"",d||p||"",f||v||"");var t,n,u;r!==(null==(e=N.current)?void 0:e.getModel())&&(x&&a.set(H,null==(t=N.current)?void 0:t.saveViewState()),null==(n=N.current)||n.setModel(r),x&&(null==(u=N.current)||u.restoreViewState(a.get(f))))},[f],b),u(()=>{var e;null==(e=N.current)||e.updateOptions(R)},[R],b),u(()=>{N.current&&void 0!==g&&(N.current.getOption(D.current.editor.EditorOption.readOnly)?N.current.setValue(g):g!==N.current.getValue()&&(G.current=!0,N.current.executeEdits("",[{range:N.current.getModel().getFullModelRange(),text:g,forceMoveMarkers:!0}]),N.current.pushUndoStop(),G.current=!1))},[g],b),u(()=>{var e;const r=null==(e=N.current)?void 0:e.getModel();var t;b&&r&&p&&(null==(t=D.current)||t.editor.setModelLanguage(r,p))},[p,b],b),u(()=>{var e;void 0!==M&&(null==(e=N.current)||e.revealLine(M))},[M],b),u(()=>{var e;null==(e=D.current)||e.editor.setTheme(h)},[h],b);const I=r.useCallback(()=>{if(T.current&&D.current&&!A.current){z.current(D.current);const r=f||v,t=c.getOrCreateModel(D.current,g||s||"",d||p||"",r||""),n=D.current.editor.create(T.current,e.objectSpread2({model:t,automaticLayout:!0},R),m);N.current=n,x&&n.restoreViewState(a.get(r)),D.current.editor.setTheme(h),void 0!==M&&n.revealLine(M),P(!0),A.current=!0}},[s,d,v,g,p,f,R,m,x,h,M]);return r.useEffect(()=>{b&&U.current(N.current,D.current)},[b]),r.useEffect(()=>{y||b||I()},[y,b,I]),F.current=g,r.useEffect(()=>{var e,r;b&&L&&(null==(e=B.current)||e.dispose(),B.current=null==(r=N.current)?void 0:r.onDidChangeModelContent(e=>{G.current||L(N.current.getValue(),e)}))},[b,L]),r.useEffect(()=>{if(b){const e=D.current.editor.onDidChangeMarkers(e=>{var r;const t=null==(r=N.current.getModel())?void 0:r.uri;if(t){if(e.find(e=>e.path===t.path)){const e=D.current.editor.getModelMarkers({resource:t});null==O||O(e)}}});return()=>{null==e||e.dispose()}}return()=>{}},[b,O]),l.jsx(i,{width:V,height:j,isEditorReady:b,loading:w,_ref:T,className:q,wrapperProps:C})};
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"),a=require("../MonacoContainer/index.cjs"),i=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 i.jsx(a,{width:e,height:t,isEditorReady:!1,loading:n,className:u,wrapperProps:o})}return i.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:V,wrapperProps:q={},beforeMount:C=s.noop,onMount:E=s.noop,onChange:P,onValidate:b=s.noop}){const[L,N]=r.useState(!1),O=r.useRef(o),y=r.useRef(void 0),_=r.useRef(null),D=r.useRef(E),T=r.useRef(C),U=r.useRef(void 0),B=r.useRef(g),F=u(f),H=r.useRef(!1),z=r.useRef(!1);O.current=o,t(()=>()=>{y.current&&function(){var e,r;null==(e=U.current)||e.dispose(),R?m&&c.set(f,y.current.saveViewState()):null==(r=y.current.getModel())||r.dispose();y.current.dispose(),y.current=void 0,H.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(F,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()&&(z.current=!0,y.current.executeEdits("",[{range:y.current.getModel().getFullModelRange(),text:g,forceMoveMarkers:!0}]),y.current.pushUndoStop(),z.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 A=r.useCallback(()=>{if(_.current&&!H.current){T.current(O.current);const r=f||p,t=s.getOrCreateModel(O.current,g||l||"",d||h||"",r||""),n=O.current.editor.create(_.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),H.current=!0}},[l,d,p,g,h,f,w,x,m,v,M]);return r.useEffect(()=>{L&&D.current(y.current,O.current)},[L]),r.useEffect(()=>{L||A()},[L,A]),B.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=>{z.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]),i.jsx(a,{width:S,height:k,isEditorReady:L,loading:j,_ref:_,className:V,wrapperProps:q})}module.exports=function(t){const{width:n="100%",height:u="100%",loading:o="Loading...",className:s,wrapperProps:c={}}=t;return i.jsx(r.Suspense,{fallback:i.jsx(a,{width:n,height:u,isEditorReady:!1,loading:o,className:s,wrapperProps:c}),children:i.jsx(l,e.objectSpread2({},t))})};
3
3
  //# sourceMappingURL=Editor.cjs.map
@@ -1,5 +1,5 @@
1
1
  import type { ReactElement } from 'react';
2
2
  import type { EditorProps } from './types';
3
- declare function Editor({ defaultValue, defaultLanguage, defaultPath, value, language, path, theme, line, loading, options, overrideServices, saveViewState, keepCurrentModel, width, height, className, wrapperProps, beforeMount, onMount, onChange, onValidate }: EditorProps): ReactElement;
3
+ declare function Editor(props: EditorProps): ReactElement;
4
4
  export default Editor;
5
5
  //# sourceMappingURL=Editor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Editor.d.ts","sourceRoot":"","sources":["../../src/Editor/Editor.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAO1C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAM3C,iBAAS,MAAM,CAAC,EACd,YAAY,EACZ,eAAe,EACf,WAAW,EACX,KAAK,EACL,QAAQ,EACR,IAAI,EAEJ,KAAe,EACf,IAAI,EACJ,OAAsB,EACtB,OAAY,EACZ,gBAAqB,EACrB,aAAoB,EACpB,gBAAwB,EAExB,KAAc,EACd,MAAe,EACf,SAAS,EACT,YAAiB,EAEjB,WAAkB,EAClB,OAAc,EACd,QAAQ,EACR,UAAiB,EAClB,EAAE,WAAW,GAAG,YAAY,CA8O5B;AAED,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"Editor.d.ts","sourceRoot":"","sources":["../../src/Editor/Editor.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAO1C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAM3C,iBAAS,MAAM,CAAC,KAAK,EAAE,WAAW,GAAG,YAAY,CAmBhD;eAgSc,MAAM"}
@@ -1,3 +1,3 @@
1
1
  "use client";
2
- import{objectSpread2 as e}from"../_virtual/_rollupPluginBabelHelpers.js";import{useState as r,useRef as t,useCallback as n,useEffect as o}from"react";import u from"@willbooster/monaco-loader";import i from"../hooks/useMount/index.js";import l from"../hooks/useUpdate/index.js";import a from"../hooks/usePrevious/index.js";import{noop as c,getOrCreateModel as s}from"../utils/index.js";import d from"../MonacoContainer/index.js";import{jsx as p}from"react/jsx-runtime";const v=new Map;function g({defaultValue:g,defaultLanguage:m,defaultPath:f,value:h,language:M,path:w,theme:V="light",line:x,loading:j="Loading...",options:S={},overrideServices:k={},saveViewState:C=!0,keepCurrentModel:L=!1,width:P="100%",height:b="100%",className:y,wrapperProps:O={},beforeMount:E=c,onMount:_=c,onChange:D,onValidate:N=c}){const[R,T]=r(!1),[U,z]=r(!0),B=t(null),F=t(void 0),H=t(null),q=t(_),A=t(E),G=t(void 0),I=t(h),J=a(w),K=t(!1),Q=t(!1);i(()=>{const e=u.init();return e.then(e=>(B.current=e)&&z(!1)).catch(e=>"cancelation"!==(null==e?void 0:e.type)&&console.error("Monaco initialization: error:",e)),()=>F.current?function(){var e,r;null==(e=G.current)||e.dispose(),L?C&&v.set(w,F.current.saveViewState()):null==(r=F.current.getModel())||r.dispose();F.current.dispose(),F.current=void 0,K.current=!1,T(!1)}():e.cancel()}),l(()=>{var e;const r=s(B.current,g||h||"",m||M||"",w||f||"");var t,n,o;r!==(null==(e=F.current)?void 0:e.getModel())&&(C&&v.set(J,null==(t=F.current)?void 0:t.saveViewState()),null==(n=F.current)||n.setModel(r),C&&(null==(o=F.current)||o.restoreViewState(v.get(w))))},[w],R),l(()=>{var e;null==(e=F.current)||e.updateOptions(S)},[S],R),l(()=>{F.current&&void 0!==h&&(F.current.getOption(B.current.editor.EditorOption.readOnly)?F.current.setValue(h):h!==F.current.getValue()&&(Q.current=!0,F.current.executeEdits("",[{range:F.current.getModel().getFullModelRange(),text:h,forceMoveMarkers:!0}]),F.current.pushUndoStop(),Q.current=!1))},[h],R),l(()=>{var e;const r=null==(e=F.current)?void 0:e.getModel();var t;R&&r&&M&&(null==(t=B.current)||t.editor.setModelLanguage(r,M))},[M,R],R),l(()=>{var e;void 0!==x&&(null==(e=F.current)||e.revealLine(x))},[x],R),l(()=>{var e;null==(e=B.current)||e.editor.setTheme(V)},[V],R);const W=n(()=>{if(H.current&&B.current&&!K.current){A.current(B.current);const r=w||f,t=s(B.current,h||g||"",m||M||"",r||""),n=B.current.editor.create(H.current,e({model:t,automaticLayout:!0},S),k);F.current=n,C&&n.restoreViewState(v.get(r)),B.current.editor.setTheme(V),void 0!==x&&n.revealLine(x),T(!0),K.current=!0}},[g,m,f,h,M,w,S,k,C,V,x]);return o(()=>{R&&q.current(F.current,B.current)},[R]),o(()=>{U||R||W()},[U,R,W]),I.current=h,o(()=>{var e,r;R&&D&&(null==(e=G.current)||e.dispose(),G.current=null==(r=F.current)?void 0:r.onDidChangeModelContent(e=>{Q.current||D(F.current.getValue(),e)}))},[R,D]),o(()=>{if(R){const e=B.current.editor.onDidChangeMarkers(e=>{var r;const t=null==(r=F.current.getModel())?void 0:r.uri;if(t){if(e.find(e=>e.path===t.path)){const e=B.current.editor.getModelMarkers({resource:t});null==N||N(e)}}});return()=>{null==e||e.dispose()}}return()=>{}},[R,N]),p(d,{width:P,height:b,isEditorReady:R,loading:j,_ref:H,className:y,wrapperProps:O})}export{g as default};
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 c from"../hooks/usePrevious/index.js";import l from"../hooks/useMonaco/index.js";import{noop as s,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:N="100%",className:y,wrapperProps:E={},beforeMount:b=s,onMount:O=s,onChange:R,onValidate:_=s}){const[D,T]=t(!1),U=n(r),B=n(void 0),F=n(null),H=n(O),q=n(b),z=n(void 0),A=n(f),G=c(w),I=n(!1),J=n(!1);U.current=r,i(()=>()=>{B.current&&function(){var e,r;null==(e=z.current)||e.dispose(),S?L&&h.set(w,B.current.saveViewState()):null==(r=B.current.getModel())||r.dispose();B.current.dispose(),B.current=void 0,I.current=!1,T(!1)}()}),a(()=>{var e;const r=d(U.current,l||f||"",m||M||"",w||v||"");var t,n,o;r!==(null==(e=B.current)?void 0:e.getModel())&&(L&&h.set(G,null==(t=B.current)?void 0:t.saveViewState()),null==(n=B.current)||n.setModel(r),L&&(null==(o=B.current)||o.restoreViewState(h.get(w))))},[w],D),a(()=>{var e;null==(e=B.current)||e.updateOptions(k)},[k],D),a(()=>{B.current&&void 0!==f&&(B.current.getOption(U.current.editor.EditorOption.readOnly)?B.current.setValue(f):f!==B.current.getValue()&&(J.current=!0,B.current.executeEdits("",[{range:B.current.getModel().getFullModelRange(),text:f,forceMoveMarkers:!0}]),B.current.pushUndoStop(),J.current=!1))},[f],D),a(()=>{var e;const r=null==(e=B.current)?void 0:e.getModel();var t;D&&r&&M&&(null==(t=U.current)||t.editor.setModelLanguage(r,M))},[M,D],D),a(()=>{var e;void 0!==V&&(null==(e=B.current)||e.revealLine(V))},[V],D),a(()=>{var e;null==(e=U.current)||e.editor.setTheme(x)},[x],D);const K=o(()=>{if(F.current&&!I.current){q.current(U.current);const r=w||v,t=d(U.current,f||l||"",m||M||"",r||""),n=U.current.editor.create(F.current,e({model:t,automaticLayout:!0},k),P);B.current=n,L&&n.restoreViewState(h.get(r)),U.current.editor.setTheme(x),void 0!==V&&n.revealLine(V),T(!0),I.current=!0}},[l,m,v,f,M,w,k,P,L,x,V]);return u(()=>{D&&H.current(B.current,U.current)},[D]),u(()=>{D||K()},[D,K]),A.current=f,u(()=>{var e,r;D&&R&&(null==(e=z.current)||e.dispose(),z.current=null==(r=B.current)?void 0:r.onDidChangeModelContent(e=>{J.current||R(B.current.getValue(),e)}))},[D,R]),u(()=>{if(D){const e=U.current.editor.onDidChangeMarkers(e=>{var r;const t=null==(r=B.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==_||_(e)}}});return()=>{null==e||e.dispose()}}return()=>{}},[D,_]),g(p,{width:C,height:N,isEditorReady:D,loading:j,_ref:F,className:y,wrapperProps:E})}export{m as default};
3
3
  //# sourceMappingURL=Editor.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Editor/index.ts"],"names":[],"mappings":"AAEA,OAAO,MAAM,MAAM,UAAU,CAAC;AAE9B,cAAc,SAAS,CAAC;;AAExB,wBAA4B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Editor/index.ts"],"names":[],"mappings":"AAEA,OAAO,MAAM,MAAM,UAAU,CAAC;AAE9B,cAAc,SAAS,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"Loading.d.ts","sourceRoot":"","sources":["../../src/Loading/Loading.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAI7D,iBAAS,OAAO,CAAC,EAAE,QAAQ,EAAE,EAAE,iBAAiB,GAAG,YAAY,CAE9D;AAED,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"Loading.d.ts","sourceRoot":"","sources":["../../src/Loading/Loading.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAI7D,iBAAS,OAAO,CAAC,EAAE,QAAQ,EAAE,EAAE,iBAAiB,GAAG,YAAY,CAE9D;eAEc,OAAO"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Loading/index.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,WAAW,CAAC;AAEhC,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Loading/index.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,WAAW,CAAC;eAEjB,OAAO"}
@@ -1 +1 @@
1
- {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../src/Loading/styles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C,QAAA,MAAM,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAQzC,CAAC;AAEF,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../src/Loading/styles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C,QAAA,MAAM,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAQzC,CAAC;eAEa,MAAM"}
@@ -1,5 +1,5 @@
1
1
  import type { ReactElement } from 'react';
2
2
  import type { ContainerProps } from './types';
3
- declare function MonacoContainer({ width, height, isEditorReady, loading, _ref, className, wrapperProps }: ContainerProps): ReactElement;
3
+ declare function MonacoContainer({ width, height, isEditorReady, loading, _ref, className, wrapperProps, }: ContainerProps): ReactElement;
4
4
  export default MonacoContainer;
5
5
  //# sourceMappingURL=MonacoContainer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"MonacoContainer.d.ts","sourceRoot":"","sources":["../../src/MonacoContainer/MonacoContainer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAI1C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAK9C,iBAAS,eAAe,CAAC,EACvB,KAAK,EACL,MAAM,EACN,aAAa,EACb,OAAO,EACP,IAAI,EACJ,SAAS,EACT,YAAY,EACb,EAAE,cAAc,GAAG,YAAY,CAO/B;AAED,eAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"MonacoContainer.d.ts","sourceRoot":"","sources":["../../src/MonacoContainer/MonacoContainer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAI1C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAK9C,iBAAS,eAAe,CAAC,EACvB,KAAK,EACL,MAAM,EACN,aAAa,EACb,OAAO,EACP,IAAI,EACJ,SAAS,EACT,YAAY,GACb,EAAE,cAAc,GAAG,YAAY,CAO/B;eAEc,eAAe"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/MonacoContainer/index.ts"],"names":[],"mappings":"AAEA,OAAO,eAAe,MAAM,mBAAmB,CAAC;;AAEhD,wBAAqC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/MonacoContainer/index.ts"],"names":[],"mappings":"AAEA,OAAO,eAAe,MAAM,mBAAmB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../src/MonacoContainer/styles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C,QAAA,MAAM,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAYzC,CAAC;AAEF,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../src/MonacoContainer/styles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C,QAAA,MAAM,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAYzC,CAAC;eAEa,MAAM"}
@@ -4,7 +4,7 @@ export interface ContainerProps {
4
4
  height: number | string;
5
5
  isEditorReady: boolean;
6
6
  loading: ReactNode | string;
7
- _ref: RefObject<HTMLDivElement | null>;
7
+ _ref?: RefObject<HTMLDivElement | null>;
8
8
  className?: string;
9
9
  wrapperProps?: object;
10
10
  }
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/MonacoContainer/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElD,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,aAAa,EAAE,OAAO,CAAC;IACvB,OAAO,EAAE,SAAS,GAAG,MAAM,CAAC;IAC5B,IAAI,EAAE,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/MonacoContainer/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElD,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,aAAa,EAAE,OAAO,CAAC;IACvB,OAAO,EAAE,SAAS,GAAG,MAAM,CAAC;IAC5B,IAAI,CAAC,EAAE,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IACxC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB"}
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("react"),r=require("@willbooster/monaco-loader"),n=require("../useMount/index.cjs");module.exports=function(){const[t,o]=e.useState(r.__getMonacoInstance());return n(()=>{let e;return t||(e=r.init(),e.then(e=>{o(e)}).catch(e=>{"cancelation"!==(null==e?void 0:e.type)&&console.error("Monaco initialization: error:",e)})),()=>{var r;return null==(r=e)?void 0:r.cancel()}}),t};
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
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../../src/hooks/useMonaco/index.ts"],"sourcesContent":["import { useState } from 'react';\nimport loader from '@willbooster/monaco-loader';\n\nimport useMount from '../useMount';\nimport type { Monaco } from '../..';\n\nfunction useMonaco(): Monaco | undefined {\n const [monaco, setMonaco] = useState<Monaco | undefined>(loader.__getMonacoInstance() as Monaco | undefined);\n\n useMount(() => {\n let cancelable: ReturnType<typeof loader.init>;\n\n if (!monaco) {\n cancelable = loader.init();\n\n void cancelable\n .then((monaco) => {\n setMonaco(monaco as Monaco);\n return;\n })\n .catch((error: unknown) => {\n if ((error as { type?: unknown })?.type !== 'cancelation') {\n console.error('Monaco initialization: error:', error);\n }\n });\n }\n\n return () => cancelable?.cancel();\n });\n\n return monaco;\n}\n\nexport default useMonaco;\n"],"names":["monaco","setMonaco","useState","loader","__getMonacoInstance","useMount","cancelable","init","then","catch","error","type","console","_cancelable","cancel"],"mappings":"8HAMA,WACE,MAAOA,EAAQC,GAAaC,EAAAA,SAA6BC,EAAOC,uBAuBhE,OArBAC,EAAS,KACP,IAAIC,EAiBJ,OAfKN,IACHM,EAAaH,EAAOI,OAEfD,EACFE,KAAMR,IACLC,EAAUD,KAGXS,MAAOC,IACsC,iBAAlC,MAALA,OAAK,EAALA,EAA8BC,OACjCC,QAAQF,MAAM,gCAAiCA,MAKhD,KAAA,IAAAG,EAAA,OAAgB,OAAhBA,EAAMP,QAAU,EAAVO,EAAYC,YAGpBd,CACT"}
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 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/useMonaco/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAEpC,iBAAS,SAAS,IAAI,MAAM,GAAG,SAAS,CAyBvC;AAED,eAAe,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/useMonaco/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAGpC,iBAAS,SAAS,IAAI,MAAM,GAAG,SAAS,CAQvC;eAkBc,SAAS"}
@@ -1,2 +1,2 @@
1
- import{useState as o}from"react";import n from"@willbooster/monaco-loader";import r from"../useMount/index.js";function t(){const[t,e]=o(n.__getMonacoInstance());return r(()=>{let o;return t||(o=n.init(),o.then(o=>{e(o)}).catch(o=>{"cancelation"!==(null==o?void 0:o.type)&&console.error("Monaco initialization: error:",o)})),()=>{var n;return null==(n=o)?void 0:n.cancel()}}),t}export{t as default};
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
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/hooks/useMonaco/index.ts"],"sourcesContent":["import { useState } from 'react';\nimport loader from '@willbooster/monaco-loader';\n\nimport useMount from '../useMount';\nimport type { Monaco } from '../..';\n\nfunction useMonaco(): Monaco | undefined {\n const [monaco, setMonaco] = useState<Monaco | undefined>(loader.__getMonacoInstance() as Monaco | undefined);\n\n useMount(() => {\n let cancelable: ReturnType<typeof loader.init>;\n\n if (!monaco) {\n cancelable = loader.init();\n\n void cancelable\n .then((monaco) => {\n setMonaco(monaco as Monaco);\n return;\n })\n .catch((error: unknown) => {\n if ((error as { type?: unknown })?.type !== 'cancelation') {\n console.error('Monaco initialization: error:', error);\n }\n });\n }\n\n return () => cancelable?.cancel();\n });\n\n return monaco;\n}\n\nexport default useMonaco;\n"],"names":["useMonaco","monaco","setMonaco","useState","loader","__getMonacoInstance","useMount","cancelable","init","then","catch","error","type","console","_cancelable","cancel"],"mappings":"+GAMA,SAASA,IACP,MAAOC,EAAQC,GAAaC,EAA6BC,EAAOC,uBAuBhE,OArBAC,EAAS,KACP,IAAIC,EAiBJ,OAfKN,IACHM,EAAaH,EAAOI,OAEfD,EACFE,KAAMR,IACLC,EAAUD,KAGXS,MAAOC,IACsC,iBAAlC,MAALA,OAAK,EAALA,EAA8BC,OACjCC,QAAQF,MAAM,gCAAiCA,MAKhD,KAAA,IAAAG,EAAA,OAAgB,OAAhBA,EAAMP,QAAU,EAAVO,EAAYC,YAGpBd,CACT"}
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"}
@@ -0,0 +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
@@ -0,0 +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"}
@@ -0,0 +1,4 @@
1
+ import type { Monaco } from '../..';
2
+ declare function initMonaco(): Promise<Monaco>;
3
+ export default initMonaco;
4
+ //# sourceMappingURL=initMonaco.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"initMonaco.d.ts","sourceRoot":"","sources":["../../../src/hooks/useMonaco/initMonaco.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAIpC,iBAAS,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC,CAGrC;eAEc,UAAU"}
@@ -0,0 +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
@@ -0,0 +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 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/useMount/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAE5C,iBAAS,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,CAI9C;AAED,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/useMount/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAE5C,iBAAS,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,CAI9C;eAEc,QAAQ"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/usePrevious/index.ts"],"names":[],"mappings":"AAEA,iBAAS,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,GAAG,SAAS,CAQ/C;AAED,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/usePrevious/index.ts"],"names":[],"mappings":"AAEA,iBAAS,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,GAAG,SAAS,CAQ/C;eAEc,WAAW"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/useUpdate/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAE5D,iBAAS,SAAS,CAAC,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,cAAc,EAAE,YAAY,UAAO,GAAG,IAAI,CAiB1F;AAED,eAAe,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/useUpdate/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAE5D,iBAAS,SAAS,CAAC,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,cAAc,EAAE,YAAY,UAAO,GAAG,IAAI,CAiB1F;eAEc,SAAS"}
@@ -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;AAClB,eAAe,MAAM,CAAC;AAGtB,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,2CAA2C,CAAC;AACzE,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAC;AAGnC,MAAM,MAAM,KAAK,GAAG,SAAS,GAAG,OAAO,CAAC"}
@@ -1,2 +1,2 @@
1
- "use strict";function e(e,r){return e.Uri.parse(r)}exports.getOrCreateModel=function(r,t,n,o){var u;return null!=(u=function(r,t){return r.editor.getModel(e(r,t))}(r,o))?u:function(r,t,n,o){return r.editor.createModel(t,n,o?e(r,o):void 0)}(r,t,n,o)},exports.noop=function(){};
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
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 return monaco.Uri.parse(path);\n}\n\nexport { noop, getOrCreateModel };\n"],"names":["createModelUri","monaco","path","Uri","parse","value","language","_getModel","editor","getModel","createModel","undefined"],"mappings":"aAsDA,SAASA,EAAeC,EAAgBC,GACtC,OAAOD,EAAOE,IAAIC,MAAMF,EAC1B,0BAnCA,SAA0BD,EAAgBI,EAAeC,EAAkBJ,GAAiC,IAAAK,EAC1G,OAA6B,OAA7BA,EAUF,SAAkBN,EAAgBC,GAChC,OAAOD,EAAOO,OAAOC,SAAST,EAAeC,EAAQC,GACvD,CAZSO,CAASR,EAAQC,IAAKK,EAsB/B,SAAqBN,EAAgBI,EAAeC,EAAmBJ,GACrE,OAAOD,EAAOO,OAAOE,YAAYL,EAAOC,EAAUJ,EAAOF,EAAeC,EAAQC,QAAQS,EAC1F,CAxBmCD,CAAYT,EAAQI,EAAOC,EAAUJ,EACxE,eAhBA,WACE"}
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 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AACjC,OAAO,KAAK,EAAO,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAE7E;;;GAGG;AACH,iBAAS,IAAI,IAAI,IAAI,CAEpB;AAED;;;;;;;;;GASG;AACH,iBAAS,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,UAAU,CAE1G;AAmCD,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAC"}
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,2 +1,2 @@
1
- function n(){}function r(n,r,e,o){var u;return null!=(u=function(n,r){return n.editor.getModel(t(n,r))}(n,o))?u:function(n,r,e,o){return n.editor.createModel(r,e,o?t(n,o):void 0)}(n,r,e,o)}function t(n,r){return n.Uri.parse(r)}export{r as getOrCreateModel,n as noop};
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
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 return monaco.Uri.parse(path);\n}\n\nexport { noop, getOrCreateModel };\n"],"names":["noop","getOrCreateModel","monaco","value","language","path","_getModel","editor","getModel","createModelUri","createModel","undefined","Uri","parse"],"mappings":"AAOA,SAASA,IACP,CAaF,SAASC,EAAiBC,EAAgBC,EAAeC,EAAkBC,GAAiC,IAAAC,EAC1G,OAA6B,OAA7BA,EAUF,SAAkBJ,EAAgBG,GAChC,OAAOH,EAAOK,OAAOC,SAASC,EAAeP,EAAQG,GACvD,CAZSG,CAASN,EAAQG,IAAKC,EAsB/B,SAAqBJ,EAAgBC,EAAeC,EAAmBC,GACrE,OAAOH,EAAOK,OAAOG,YAAYP,EAAOC,EAAUC,EAAOI,EAAeP,EAAQG,QAAQM,EAC1F,CAxBmCD,CAAYR,EAAQC,EAAOC,EAAUC,EACxE,CA+BA,SAASI,EAAeP,EAAgBG,GACtC,OAAOH,EAAOU,IAAIC,MAAMR,EAC1B"}
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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/monaco-react",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
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",
@@ -14,19 +14,13 @@
14
14
  "bugs": {
15
15
  "url": "https://github.com/WillBooster/monaco-react/issues"
16
16
  },
17
- "license": "MIT",
18
- "author": "WillBooster Inc.",
19
17
  "repository": {
20
18
  "type": "git",
21
19
  "url": "git+https://github.com/WillBooster/monaco-react.git"
22
20
  },
23
- "files": [
24
- "dist/"
25
- ],
21
+ "license": "MIT",
22
+ "author": "WillBooster Inc.",
26
23
  "type": "module",
27
- "main": "dist/index.cjs",
28
- "module": "dist/index.js",
29
- "types": "dist/index.d.ts",
30
24
  "exports": {
31
25
  ".": {
32
26
  "types": "./dist/index.d.ts",
@@ -34,18 +28,19 @@
34
28
  "import": "./dist/index.js"
35
29
  }
36
30
  },
37
- "publishConfig": {
38
- "access": "public"
39
- },
31
+ "main": "dist/index.cjs",
32
+ "module": "dist/index.js",
33
+ "types": "dist/index.d.ts",
34
+ "files": [
35
+ "dist/"
36
+ ],
40
37
  "scripts": {
41
38
  "build": "yarn run build/core",
42
39
  "build/core": "build-ts lib",
43
- "check-all-for-ai": "yarn check-for-ai && yarn test",
44
- "check-for-ai": "yarn install > /dev/null && yarn format > /dev/null 2> /dev/null || true && yarn lint-fix --quiet",
45
40
  "cleanup": "yarn format && yarn lint-fix",
46
41
  "common/ci-setup": "yarn run build/core",
47
42
  "format": "sort-package-json && yarn format-code",
48
- "format-code": "oxfmt --write --no-error-on-unmatched-pattern .",
43
+ "format-code": "oxfmt --write --no-error-on-unmatched-pattern . '!**/package.json'",
49
44
  "lint": "oxlint --no-error-on-unmatched-pattern .",
50
45
  "lint-fix": "yarn lint --fix",
51
46
  "prepare": "lefthook install || true",
@@ -53,7 +48,9 @@
53
48
  "test:e2e:next": "yarn build && next build e2e/next-app && playwright test --config e2e/next-app/playwright.config.ts",
54
49
  "test:unit": "vitest",
55
50
  "test/ci-setup": "playwright install chromium",
56
- "typecheck": "tsgo --noEmit"
51
+ "typecheck": "wb typecheck",
52
+ "verify": "wb verify",
53
+ "verify-full": "wb verify --full"
57
54
  },
58
55
  "dependencies": {
59
56
  "@willbooster/monaco-loader": "1.1.1",
@@ -69,17 +66,19 @@
69
66
  "@types/node": "25.6.0",
70
67
  "@types/react": "19.2.14",
71
68
  "@types/react-dom": "19.2.3",
72
- "@typescript/native-preview": "7.0.0-dev.20260418.1",
73
- "@willbooster/oxfmt-config": "1.2.1",
74
- "@willbooster/oxlint-config": "1.4.4",
75
- "build-ts": "17.1.5",
69
+ "@typescript/native-preview": "7.0.0-dev.20260421.2",
70
+ "@willbooster/oxfmt-config": "1.2.2",
71
+ "@willbooster/oxlint-config": "1.4.6",
72
+ "@willbooster/wb": "13.20.0",
73
+ "build-ts": "17.1.15",
76
74
  "conventional-changelog-conventionalcommits": "9.3.1",
77
75
  "jsdom": "29.0.2",
78
- "lefthook": "2.1.5",
76
+ "lefthook": "2.1.6",
79
77
  "next": "16.2.4",
80
- "oxfmt": "0.45.0",
81
- "oxlint": "1.60.0",
82
- "oxlint-tsgolint": "0.21.0",
78
+ "oxfmt": "0.50.0",
79
+ "oxlint": "1.65.0",
80
+ "oxlint-tsgolint": "0.22.1",
81
+ "prettier": "3.8.3",
83
82
  "react": "19.2.5",
84
83
  "react-dom": "19.2.5",
85
84
  "semantic-release": "25.0.3",
@@ -90,8 +89,11 @@
90
89
  "react": "^19.0.0",
91
90
  "react-dom": "^19.0.0"
92
91
  },
92
+ "packageManager": "yarn@4.15.0",
93
93
  "engines": {
94
94
  "node": ">=24"
95
95
  },
96
- "packageManager": "yarn@4.14.1"
96
+ "publishConfig": {
97
+ "access": "public"
98
+ }
97
99
  }