@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 +1 -1
- package/dist/DiffEditor/DiffEditor.cjs +1 -1
- package/dist/DiffEditor/DiffEditor.d.ts +1 -1
- package/dist/DiffEditor/DiffEditor.d.ts.map +1 -1
- package/dist/DiffEditor/DiffEditor.js +1 -1
- package/dist/Editor/Editor.cjs +1 -1
- package/dist/Editor/Editor.d.ts +1 -1
- package/dist/Editor/Editor.d.ts.map +1 -1
- package/dist/Editor/Editor.js +1 -1
- package/dist/MonacoContainer/types.d.ts +1 -1
- package/dist/MonacoContainer/types.d.ts.map +1 -1
- package/dist/hooks/useMonaco/index.cjs +1 -1
- package/dist/hooks/useMonaco/index.cjs.map +1 -1
- package/dist/hooks/useMonaco/index.d.ts.map +1 -1
- package/dist/hooks/useMonaco/index.js +1 -1
- package/dist/hooks/useMonaco/index.js.map +1 -1
- package/dist/hooks/useMonaco/initMonaco.cjs +2 -0
- package/dist/hooks/useMonaco/initMonaco.cjs.map +1 -0
- package/dist/hooks/useMonaco/initMonaco.d.ts +4 -0
- package/dist/hooks/useMonaco/initMonaco.d.ts.map +1 -0
- package/dist/hooks/useMonaco/initMonaco.js +2 -0
- package/dist/hooks/useMonaco/initMonaco.js.map +1 -0
- package/package.json +1 -1
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("
|
|
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(
|
|
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,
|
|
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{
|
|
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
|
package/dist/Editor/Editor.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";var e=require("../_virtual/_rollupPluginBabelHelpers.cjs"),r=require("react"),t=require("
|
|
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
|
package/dist/Editor/Editor.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ReactElement } from 'react';
|
|
2
2
|
import type { EditorProps } from './types';
|
|
3
|
-
declare function Editor(
|
|
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,
|
|
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"}
|
package/dist/Editor/Editor.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{objectSpread2 as e}from"../_virtual/_rollupPluginBabelHelpers.js";import{
|
|
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":"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;
|
|
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("
|
|
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 {
|
|
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":"
|
|
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{
|
|
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 {
|
|
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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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.
|
|
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",
|