@willbooster/monaco-react 1.0.5 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -39,7 +39,7 @@ import Editor, { DiffEditor, loader, useMonaco } from '@willbooster/monaco-react
39
39
 
40
40
  - `Editor`: Monaco standalone code editor component.
41
41
  - `DiffEditor`: Monaco standalone diff editor component.
42
- - `useMonaco`: React hook returning the initialized Monaco instance.
42
+ - `useMonaco`: React hook returning the initialized Monaco instance after hydration. Wrap components that call it in `Suspense`.
43
43
  - `loader`: the `@willbooster/monaco-loader` instance used by the components.
44
44
 
45
45
  ### 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;AAqPD,eAAe,UAAU,CAAC"}
@@ -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,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;AAgSD,eAAe,MAAM,CAAC"}
@@ -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
@@ -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;AAkBD,eAAe,SAAS,CAAC"}
@@ -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;AAED,eAAe,UAAU,CAAC"}
@@ -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"}
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.6",
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",