@harnessio/yaml-editor 0.18.0 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/YamlEditor.d.ts +1 -0
- package/dist/hooks/useProblems.d.ts +2 -0
- package/dist/hooks/useTheme.d.ts +1 -1
- package/dist/index.cjs +22 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +580 -540
- package/dist/index.js.map +1 -1
- package/dist/utils/schema-utils.d.ts +6 -1
- package/dist/utils/utils.d.ts +7 -0
- package/package.json +1 -1
|
@@ -2,6 +2,8 @@ import { RefObject } from 'react';
|
|
|
2
2
|
|
|
3
3
|
import * as monaco from 'monaco-editor';
|
|
4
4
|
export type UseProblems = (arg: {
|
|
5
|
+
instanceId?: string;
|
|
5
6
|
monacoRef: RefObject<typeof monaco | undefined>;
|
|
7
|
+
editorRef: RefObject<monaco.editor.IStandaloneCodeEditor | null | undefined>;
|
|
6
8
|
}) => void;
|
|
7
9
|
export declare const useProblems: UseProblems;
|
package/dist/hooks/useTheme.d.ts
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var qe=Object.defineProperty;var Ye=(e,t,r)=>t in e?qe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var Se=(e,t,r)=>(Ye(e,typeof t!="symbol"?t+"":t,r),r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react"),J=require("monaco-editor"),me=require("monaco-yaml");function Be(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const V=Be(J);var Ie={exports:{}},X={};/*
|
|
2
2
|
object-assign
|
|
3
3
|
(c) Sindre Sorhus
|
|
4
4
|
@license MIT
|
|
5
|
-
*/var
|
|
5
|
+
*/var we=Object.getOwnPropertySymbols,He=Object.prototype.hasOwnProperty,We=Object.prototype.propertyIsEnumerable;function Ke(e){if(e==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}function Ge(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de",Object.getOwnPropertyNames(e)[0]==="5")return!1;for(var t={},r=0;r<10;r++)t["_"+String.fromCharCode(r)]=r;var n=Object.getOwnPropertyNames(t).map(function(a){return t[a]});if(n.join("")!=="0123456789")return!1;var o={};return"abcdefghijklmnopqrst".split("").forEach(function(a){o[a]=a}),Object.keys(Object.assign({},o)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}Ge();/** @license React v17.0.2
|
|
6
6
|
* react-jsx-runtime.production.min.js
|
|
7
7
|
*
|
|
8
8
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
9
9
|
*
|
|
10
10
|
* This source code is licensed under the MIT license found in the
|
|
11
11
|
* LICENSE file in the root directory of this source tree.
|
|
12
|
-
*/var Ze=i,
|
|
13
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ut(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function
|
|
12
|
+
*/var Ze=i,De=60103;X.Fragment=60107;if(typeof Symbol=="function"&&Symbol.for){var Me=Symbol.for;De=Me("react.element"),X.Fragment=Me("react.fragment")}var Je=Ze.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Qe=Object.prototype.hasOwnProperty,Xe={key:!0,ref:!0,__self:!0,__source:!0};function Te(e,t,r){var n,o={},a=null,c=null;r!==void 0&&(a=""+r),t.key!==void 0&&(a=""+t.key),t.ref!==void 0&&(c=t.ref);for(n in t)Qe.call(t,n)&&!Xe.hasOwnProperty(n)&&(o[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps,t)o[n]===void 0&&(o[n]=t[n]);return{$$typeof:De,type:e,key:a,ref:c,props:o,_owner:Je.current}}X.jsx=Te;X.jsxs=Te;Ie.exports=X;var A=Ie.exports;function et(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Ee(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),r.push.apply(r,n)}return r}function je(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Ee(Object(r),!0).forEach(function(n){et(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Ee(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function tt(e,t){if(e==null)return{};var r={},n=Object.keys(e),o,a;for(a=0;a<n.length;a++)o=n[a],!(t.indexOf(o)>=0)&&(r[o]=e[o]);return r}function rt(e,t){if(e==null)return{};var r=tt(e,t),n,o;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(o=0;o<a.length;o++)n=a[o],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function nt(e,t){return ot(e)||at(e,t)||it(e,t)||ct()}function ot(e){if(Array.isArray(e))return e}function at(e,t){if(!(typeof Symbol>"u"||!(Symbol.iterator in Object(e)))){var r=[],n=!0,o=!1,a=void 0;try{for(var c=e[Symbol.iterator](),s;!(n=(s=c.next()).done)&&(r.push(s.value),!(t&&r.length===t));n=!0);}catch(f){o=!0,a=f}finally{try{!n&&c.return!=null&&c.return()}finally{if(o)throw a}}return r}}function it(e,t){if(e){if(typeof e=="string")return Pe(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Pe(e,t)}}function Pe(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function ct(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
13
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ut(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function xe(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),r.push.apply(r,n)}return r}function Ce(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?xe(Object(r),!0).forEach(function(n){ut(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):xe(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function st(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return function(n){return t.reduceRight(function(o,a){return a(o)},n)}}function K(e){return function t(){for(var r=this,n=arguments.length,o=new Array(n),a=0;a<n;a++)o[a]=arguments[a];return o.length>=e.length?e.apply(this,o):function(){for(var c=arguments.length,s=new Array(c),f=0;f<c;f++)s[f]=arguments[f];return t.apply(r,[].concat(o,s))}}}function ne(e){return{}.toString.call(e).includes("Object")}function lt(e){return!Object.keys(e).length}function Q(e){return typeof e=="function"}function ft(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function dt(e,t){return ne(t)||z("changeType"),Object.keys(t).some(function(r){return!ft(e,r)})&&z("changeField"),t}function mt(e){Q(e)||z("selectorType")}function pt(e){Q(e)||ne(e)||z("handlerType"),ne(e)&&Object.values(e).some(function(t){return!Q(t)})&&z("handlersType")}function gt(e){e||z("initialIsRequired"),ne(e)||z("initialType"),lt(e)&&z("initialContent")}function ht(e,t){throw new Error(e[t]||e.default)}var vt={initialIsRequired:"initial state is required",initialType:"initial state should be an object",initialContent:"initial state shouldn't be an empty object",handlerType:"handler should be an object or a function",handlersType:"all handlers should be a functions",selectorType:"selector should be a function",changeType:"provided value of changes should be an object",changeField:'it seams you want to change a field in the state which is not specified in the "initial" state',default:"an unknown error accured in `state-local` package"},z=K(ht)(vt),te={changes:dt,selector:mt,handler:pt,initial:gt};function bt(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};te.initial(e),te.handler(t);var r={current:e},n=K(St)(r,t),o=K(Ot)(r),a=K(te.changes)(e),c=K(yt)(r);function s(){var l=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(h){return h};return te.selector(l),l(r.current)}function f(l){st(n,o,a,c)(l)}return[s,f]}function yt(e,t){return Q(t)?t(e.current):t}function Ot(e,t){return e.current=Ce(Ce({},e.current),t),t}function St(e,t,r){return Q(t)?t(e.current):Object.keys(r).forEach(function(n){var o;return(o=t[n])===null||o===void 0?void 0:o.call(t,e.current[n])}),r}var wt={create:bt},Mt={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.52.2/min/vs"}};function Et(e){return function t(){for(var r=this,n=arguments.length,o=new Array(n),a=0;a<n;a++)o[a]=arguments[a];return o.length>=e.length?e.apply(this,o):function(){for(var c=arguments.length,s=new Array(c),f=0;f<c;f++)s[f]=arguments[f];return t.apply(r,[].concat(o,s))}}}function jt(e){return{}.toString.call(e).includes("Object")}function Pt(e){return e||$e("configIsRequired"),jt(e)||$e("configType"),e.urls?(xt(),{paths:{vs:e.urls.monacoBase}}):e}function xt(){console.warn(Le.deprecation)}function Ct(e,t){throw new Error(e[t]||e.default)}var Le={configIsRequired:"the configuration object is required",configType:"the configuration object should be an object",default:"an unknown error accured in `@monaco-editor/loader` package",deprecation:`Deprecation warning!
|
|
14
14
|
You are using deprecated way of configuration.
|
|
15
15
|
|
|
16
16
|
Instead of using
|
|
@@ -19,7 +19,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
19
19
|
monaco.config({ paths: { vs: '...' } })
|
|
20
20
|
|
|
21
21
|
For more please check the link https://github.com/suren-atoyan/monaco-loader#config
|
|
22
|
-
`},Ce=Et(xt)(Re),$t={config:Pt},Lt=function(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return function(o){return r.reduceRight(function(a,c){return c(a)},o)}};function Te(e,t){return Object.keys(t).forEach(function(r){t[r]instanceof Object&&e[r]&&Object.assign(t[r],Te(e[r],t[r]))}),Me(Me({},e),t)}var Dt={type:"cancelation",msg:"operation is manually canceled"};function se(e){var t=!1,r=new Promise(function(n,o){e.then(function(a){return t?o(Dt):n(a)}),e.catch(o)});return r.cancel=function(){return t=!0},r}var Rt=wt.create({config:Mt,isInitialized:!1,resolve:null,reject:null,monaco:null}),Ie=nt(Rt,2),ee=Ie[0],ae=Ie[1];function Tt(e){var t=$t.config(e),r=t.monaco,n=rt(t,["monaco"]);ae(function(o){return{config:Te(o.config,n),monaco:r}})}function It(){var e=ee(function(t){var r=t.monaco,n=t.isInitialized,o=t.resolve;return{monaco:r,isInitialized:n,resolve:o}});if(!e.isInitialized){if(ae({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),se(le);if(window.monaco&&window.monaco.editor)return Ne(window.monaco),e.resolve(window.monaco),se(le);Lt(Nt,_t)(At)}return se(le)}function Nt(e){return document.body.appendChild(e)}function kt(e){var t=document.createElement("script");return e&&(t.src=e),t}function _t(e){var t=ee(function(n){var o=n.config,a=n.reject;return{config:o,reject:a}}),r=kt("".concat(t.config.paths.vs,"/loader.js"));return r.onload=function(){return e()},r.onerror=t.reject,r}function At(){var e=ee(function(r){var n=r.config,o=r.resolve,a=r.reject;return{config:n,resolve:o,reject:a}}),t=window.require;t.config(e.config),t(["vs/editor/editor.main"],function(r){Ne(r),e.resolve(r)},function(r){e.reject(r)})}function Ne(e){ee().monaco||ae({monaco:e})}function Vt(){return ee(function(e){var t=e.monaco;return t})}var le=new Promise(function(e,t){return ae({resolve:e,reject:t})}),F={config:Tt,init:It,__getMonacoInstance:Vt},Ut={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},de=Ut,zt={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},Ft=zt;function qt({children:e}){return i.createElement("div",{style:Ft.container},e)}var Yt=qt,Bt=Yt;function Ht({width:e,height:t,isEditorReady:r,loading:n,_ref:o,className:a,wrapperProps:c}){return i.createElement("section",{style:{...de.wrapper,width:e,height:t},...c},!r&&i.createElement(Bt,null,n),i.createElement("div",{ref:o,style:{...de.fullWidth,...!r&&de.hide},className:a}))}var Wt=Ht,ke=i.memo(Wt);function Kt(e){i.useEffect(e,[])}var pe=Kt;function Gt(e,t,r=!0){let n=i.useRef(!0);i.useEffect(n.current||!r?()=>{n.current=!1}:e,t)}var k=Gt;function G(){}function B(e,t,r,n){return Zt(e,n)||Jt(e,t,r,n)}function Zt(e,t){return e.editor.getModel(_e(e,t))}function Jt(e,t,r,n){return e.editor.createModel(t,r,n?_e(e,n):void 0)}function _e(e,t){return e.Uri.parse(t)}function Qt({original:e,modified:t,language:r,originalLanguage:n,modifiedLanguage:o,originalModelPath:a,modifiedModelPath:c,keepCurrentOriginalModel:l=!1,keepCurrentModifiedModel:d=!1,theme:p="light",loading:y="Loading...",options:m={},height:g="100%",width:L="100%",className:O,wrapperProps:I={},beforeMount:M=G,onMount:S=G}){let[h,E]=i.useState(!1),[R,j]=i.useState(!0),P=i.useRef(null),w=i.useRef(null),A=i.useRef(null),f=i.useRef(S),s=i.useRef(M),D=i.useRef(!1);pe(()=>{let u=F.init();return u.then(v=>(w.current=v)&&j(!1)).catch(v=>(v==null?void 0:v.type)!=="cancelation"&&console.error("Monaco initialization: error:",v)),()=>P.current?$():u.cancel()}),k(()=>{if(P.current&&w.current){let u=P.current.getOriginalEditor(),v=B(w.current,e||"",n||r||"text",a||"");v!==u.getModel()&&u.setModel(v)}},[a],h),k(()=>{if(P.current&&w.current){let u=P.current.getModifiedEditor(),v=B(w.current,t||"",o||r||"text",c||"");v!==u.getModel()&&u.setModel(v)}},[c],h),k(()=>{let u=P.current.getModifiedEditor();u.getOption(w.current.editor.EditorOption.readOnly)?u.setValue(t||""):t!==u.getValue()&&(u.executeEdits("",[{range:u.getModel().getFullModelRange(),text:t||"",forceMoveMarkers:!0}]),u.pushUndoStop())},[t],h),k(()=>{var u,v;(v=(u=P.current)==null?void 0:u.getModel())==null||v.original.setValue(e||"")},[e],h),k(()=>{let{original:u,modified:v}=P.current.getModel();w.current.editor.setModelLanguage(u,n||r||"text"),w.current.editor.setModelLanguage(v,o||r||"text")},[r,n,o],h),k(()=>{var u;(u=w.current)==null||u.editor.setTheme(p)},[p],h),k(()=>{var u;(u=P.current)==null||u.updateOptions(m)},[m],h);let C=i.useCallback(()=>{var U;if(!w.current)return;s.current(w.current);let u=B(w.current,e||"",n||r||"text",a||""),v=B(w.current,t||"",o||r||"text",c||"");(U=P.current)==null||U.setModel({original:u,modified:v})},[r,t,o,e,n,a,c]),T=i.useCallback(()=>{var u;!D.current&&A.current&&(P.current=w.current.editor.createDiffEditor(A.current,{automaticLayout:!0,...m}),C(),(u=w.current)==null||u.editor.setTheme(p),E(!0),D.current=!0)},[m,p,C]);i.useEffect(()=>{h&&f.current(P.current,w.current)},[h]),i.useEffect(()=>{!R&&!h&&T()},[R,h,T]);function $(){var v,U,q,H;let u=(v=P.current)==null?void 0:v.getModel();l||((U=u==null?void 0:u.original)==null||U.dispose()),d||((q=u==null?void 0:u.modified)==null||q.dispose()),(H=P.current)==null||H.dispose()}return i.createElement(ke,{width:L,height:g,isEditorReady:h,loading:y,_ref:A,className:O,wrapperProps:I})}var Xt=Qt,er=i.memo(Xt);function tr(){let[e,t]=i.useState(F.__getMonacoInstance());return pe(()=>{let r;return e||(r=F.init(),r.then(n=>{t(n)})),()=>r==null?void 0:r.cancel()}),e}var ie=tr;function rr(e){let t=i.useRef();return i.useEffect(()=>{t.current=e},[e]),t.current}var nr=rr,re=new Map;function or({defaultValue:e,defaultLanguage:t,defaultPath:r,value:n,language:o,path:a,theme:c="light",line:l,loading:d="Loading...",options:p={},overrideServices:y={},saveViewState:m=!0,keepCurrentModel:g=!1,width:L="100%",height:O="100%",className:I,wrapperProps:M={},beforeMount:S=G,onMount:h=G,onChange:E,onValidate:R=G}){let[j,P]=i.useState(!1),[w,A]=i.useState(!0),f=i.useRef(null),s=i.useRef(null),D=i.useRef(null),C=i.useRef(h),T=i.useRef(S),$=i.useRef(),u=i.useRef(n),v=nr(a),U=i.useRef(!1),q=i.useRef(!1);pe(()=>{let b=F.init();return b.then(x=>(f.current=x)&&A(!1)).catch(x=>(x==null?void 0:x.type)!=="cancelation"&&console.error("Monaco initialization: error:",x)),()=>s.current?ze():b.cancel()}),k(()=>{var x,N,W,Y;let b=B(f.current,e||n||"",t||o||"",a||r||"");b!==((x=s.current)==null?void 0:x.getModel())&&(m&&re.set(v,(N=s.current)==null?void 0:N.saveViewState()),(W=s.current)==null||W.setModel(b),m&&((Y=s.current)==null||Y.restoreViewState(re.get(a))))},[a],j),k(()=>{var b;(b=s.current)==null||b.updateOptions(p)},[p],j),k(()=>{!s.current||n===void 0||(s.current.getOption(f.current.editor.EditorOption.readOnly)?s.current.setValue(n):n!==s.current.getValue()&&(q.current=!0,s.current.executeEdits("",[{range:s.current.getModel().getFullModelRange(),text:n,forceMoveMarkers:!0}]),s.current.pushUndoStop(),q.current=!1))},[n],j),k(()=>{var x,N;let b=(x=s.current)==null?void 0:x.getModel();b&&o&&((N=f.current)==null||N.editor.setModelLanguage(b,o))},[o],j),k(()=>{var b;l!==void 0&&((b=s.current)==null||b.revealLine(l))},[l],j),k(()=>{var b;(b=f.current)==null||b.editor.setTheme(c)},[c],j);let H=i.useCallback(()=>{var b;if(!(!D.current||!f.current)&&!U.current){T.current(f.current);let x=a||r,N=B(f.current,n||e||"",t||o||"",x||"");s.current=(b=f.current)==null?void 0:b.editor.create(D.current,{model:N,automaticLayout:!0,...p},y),m&&s.current.restoreViewState(re.get(x)),f.current.editor.setTheme(c),l!==void 0&&s.current.revealLine(l),P(!0),U.current=!0}},[e,t,r,n,o,a,p,y,m,c,l]);i.useEffect(()=>{j&&C.current(s.current,f.current)},[j]),i.useEffect(()=>{!w&&!j&&H()},[w,j,H]),u.current=n,i.useEffect(()=>{var b,x;j&&E&&((b=$.current)==null||b.dispose(),$.current=(x=s.current)==null?void 0:x.onDidChangeModelContent(N=>{q.current||E(s.current.getValue(),N)}))},[j,E]),i.useEffect(()=>{if(j){let b=f.current.editor.onDidChangeMarkers(x=>{var W;let N=(W=s.current.getModel())==null?void 0:W.uri;if(N&&x.find(Y=>Y.path===N.path)){let Y=f.current.editor.getModelMarkers({resource:N});R==null||R(Y)}});return()=>{b==null||b.dispose()}}return()=>{}},[j,R]);function ze(){var b,x;(b=$.current)==null||b.dispose(),g?m&&re.set(a,s.current.saveViewState()):(x=s.current.getModel())==null||x.dispose(),s.current.dispose()}return i.createElement(ke,{width:L,height:O,isEditorReady:j,loading:d,_ref:D,className:I,wrapperProps:M})}var ar=or,ir=i.memo(ar),me=ir;const ce={selectOnLineNumbers:!0,scrollBeyondLastLine:!1,padding:{top:16,bottom:16},minimap:{enabled:!1},fontSize:13,fontFamily:'"JetBrains Mono", "monospace"',lineHeight:20,scrollbar:{verticalScrollbarSize:14,horizontalScrollbarSize:14,verticalSliderSize:6,horizontalSliderSize:6},overviewRulerBorder:!1,overviewRulerLanes:0,renderLineHighlight:"none"},ue=e=>{const{themeConfig:t,editor:r,theme:n}=e,{defaultTheme:o}=t??{},[a,c]=i.useState(n??o??"vs-dark");return i.useEffect(()=>{var l;(l=t==null?void 0:t.themes)==null||l.forEach(d=>{V.editor.defineTheme(d.themeName,d.themeData)})},[V]),i.useEffect(()=>{V.editor&&n&&(V.editor.setTheme(n),c(n))},[r,n]),{theme:a}};function cr(e){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let r="";for(let n=0;n<e;n++)r+=t.charAt(Math.floor(Math.random()*t.length));return r}function ur(e){return e.replace("'","'")}function sr({instanceId:e,lineNumbersPosition:t}){let r="";return t==="center"&&(r+=`
|
|
22
|
+
`},$e=Et(Ct)(Le),$t={config:Pt},It=function(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return function(o){return r.reduceRight(function(a,c){return c(a)},o)}};function Re(e,t){return Object.keys(t).forEach(function(r){t[r]instanceof Object&&e[r]&&Object.assign(t[r],Re(e[r],t[r]))}),je(je({},e),t)}var Dt={type:"cancelation",msg:"operation is manually canceled"};function se(e){var t=!1,r=new Promise(function(n,o){e.then(function(a){return t?o(Dt):n(a)}),e.catch(o)});return r.cancel=function(){return t=!0},r}var Tt=wt.create({config:Mt,isInitialized:!1,resolve:null,reject:null,monaco:null}),Ne=nt(Tt,2),ee=Ne[0],ae=Ne[1];function Lt(e){var t=$t.config(e),r=t.monaco,n=rt(t,["monaco"]);ae(function(o){return{config:Re(o.config,n),monaco:r}})}function Rt(){var e=ee(function(t){var r=t.monaco,n=t.isInitialized,o=t.resolve;return{monaco:r,isInitialized:n,resolve:o}});if(!e.isInitialized){if(ae({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),se(le);if(window.monaco&&window.monaco.editor)return ke(window.monaco),e.resolve(window.monaco),se(le);It(Nt,_t)(At)}return se(le)}function Nt(e){return document.body.appendChild(e)}function kt(e){var t=document.createElement("script");return e&&(t.src=e),t}function _t(e){var t=ee(function(n){var o=n.config,a=n.reject;return{config:o,reject:a}}),r=kt("".concat(t.config.paths.vs,"/loader.js"));return r.onload=function(){return e()},r.onerror=t.reject,r}function At(){var e=ee(function(r){var n=r.config,o=r.resolve,a=r.reject;return{config:n,resolve:o,reject:a}}),t=window.require;t.config(e.config),t(["vs/editor/editor.main"],function(r){ke(r),e.resolve(r)},function(r){e.reject(r)})}function ke(e){ee().monaco||ae({monaco:e})}function Vt(){return ee(function(e){var t=e.monaco;return t})}var le=new Promise(function(e,t){return ae({resolve:e,reject:t})}),q={config:Lt,init:Rt,__getMonacoInstance:Vt},Ut={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},fe=Ut,Ft={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},zt=Ft;function qt({children:e}){return i.createElement("div",{style:zt.container},e)}var Yt=qt,Bt=Yt;function Ht({width:e,height:t,isEditorReady:r,loading:n,_ref:o,className:a,wrapperProps:c}){return i.createElement("section",{style:{...fe.wrapper,width:e,height:t},...c},!r&&i.createElement(Bt,null,n),i.createElement("div",{ref:o,style:{...fe.fullWidth,...!r&&fe.hide},className:a}))}var Wt=Ht,_e=i.memo(Wt);function Kt(e){i.useEffect(e,[])}var pe=Kt;function Gt(e,t,r=!0){let n=i.useRef(!0);i.useEffect(n.current||!r?()=>{n.current=!1}:e,t)}var _=Gt;function G(){}function B(e,t,r,n){return Zt(e,n)||Jt(e,t,r,n)}function Zt(e,t){return e.editor.getModel(Ae(e,t))}function Jt(e,t,r,n){return e.editor.createModel(t,r,n?Ae(e,n):void 0)}function Ae(e,t){return e.Uri.parse(t)}function Qt({original:e,modified:t,language:r,originalLanguage:n,modifiedLanguage:o,originalModelPath:a,modifiedModelPath:c,keepCurrentOriginalModel:s=!1,keepCurrentModifiedModel:f=!1,theme:l="light",loading:h="Loading...",options:m={},height:g="100%",width:I="100%",className:v,wrapperProps:R={},beforeMount:C=G,onMount:S=G}){let[b,L]=i.useState(!1),[x,M]=i.useState(!0),E=i.useRef(null),j=i.useRef(null),U=i.useRef(null),w=i.useRef(S),d=i.useRef(C),P=i.useRef(!1);pe(()=>{let u=q.init();return u.then(y=>(j.current=y)&&M(!1)).catch(y=>(y==null?void 0:y.type)!=="cancelation"&&console.error("Monaco initialization: error:",y)),()=>E.current?D():u.cancel()}),_(()=>{if(E.current&&j.current){let u=E.current.getOriginalEditor(),y=B(j.current,e||"",n||r||"text",a||"");y!==u.getModel()&&u.setModel(y)}},[a],b),_(()=>{if(E.current&&j.current){let u=E.current.getModifiedEditor(),y=B(j.current,t||"",o||r||"text",c||"");y!==u.getModel()&&u.setModel(y)}},[c],b),_(()=>{let u=E.current.getModifiedEditor();u.getOption(j.current.editor.EditorOption.readOnly)?u.setValue(t||""):t!==u.getValue()&&(u.executeEdits("",[{range:u.getModel().getFullModelRange(),text:t||"",forceMoveMarkers:!0}]),u.pushUndoStop())},[t],b),_(()=>{var u,y;(y=(u=E.current)==null?void 0:u.getModel())==null||y.original.setValue(e||"")},[e],b),_(()=>{let{original:u,modified:y}=E.current.getModel();j.current.editor.setModelLanguage(u,n||r||"text"),j.current.editor.setModelLanguage(y,o||r||"text")},[r,n,o],b),_(()=>{var u;(u=j.current)==null||u.editor.setTheme(l)},[l],b),_(()=>{var u;(u=E.current)==null||u.updateOptions(m)},[m],b);let p=i.useCallback(()=>{var N;if(!j.current)return;d.current(j.current);let u=B(j.current,e||"",n||r||"text",a||""),y=B(j.current,t||"",o||r||"text",c||"");(N=E.current)==null||N.setModel({original:u,modified:y})},[r,t,o,e,n,a,c]),T=i.useCallback(()=>{var u;!P.current&&U.current&&(E.current=j.current.editor.createDiffEditor(U.current,{automaticLayout:!0,...m}),p(),(u=j.current)==null||u.editor.setTheme(l),L(!0),P.current=!0)},[m,l,p]);i.useEffect(()=>{b&&w.current(E.current,j.current)},[b]),i.useEffect(()=>{!x&&!b&&T()},[x,b,T]);function D(){var y,N,F,H;let u=(y=E.current)==null?void 0:y.getModel();s||((N=u==null?void 0:u.original)==null||N.dispose()),f||((F=u==null?void 0:u.modified)==null||F.dispose()),(H=E.current)==null||H.dispose()}return i.createElement(_e,{width:I,height:g,isEditorReady:b,loading:h,_ref:U,className:v,wrapperProps:R})}var Xt=Qt,er=i.memo(Xt);function tr(){let[e,t]=i.useState(q.__getMonacoInstance());return pe(()=>{let r;return e||(r=q.init(),r.then(n=>{t(n)})),()=>r==null?void 0:r.cancel()}),e}var ie=tr;function rr(e){let t=i.useRef();return i.useEffect(()=>{t.current=e},[e]),t.current}var nr=rr,re=new Map;function or({defaultValue:e,defaultLanguage:t,defaultPath:r,value:n,language:o,path:a,theme:c="light",line:s,loading:f="Loading...",options:l={},overrideServices:h={},saveViewState:m=!0,keepCurrentModel:g=!1,width:I="100%",height:v="100%",className:R,wrapperProps:C={},beforeMount:S=G,onMount:b=G,onChange:L,onValidate:x=G}){let[M,E]=i.useState(!1),[j,U]=i.useState(!0),w=i.useRef(null),d=i.useRef(null),P=i.useRef(null),p=i.useRef(b),T=i.useRef(S),D=i.useRef(),u=i.useRef(n),y=nr(a),N=i.useRef(!1),F=i.useRef(!1);pe(()=>{let O=q.init();return O.then($=>(w.current=$)&&U(!1)).catch($=>($==null?void 0:$.type)!=="cancelation"&&console.error("Monaco initialization: error:",$)),()=>d.current?ze():O.cancel()}),_(()=>{var $,k,W,Y;let O=B(w.current,e||n||"",t||o||"",a||r||"");O!==(($=d.current)==null?void 0:$.getModel())&&(m&&re.set(y,(k=d.current)==null?void 0:k.saveViewState()),(W=d.current)==null||W.setModel(O),m&&((Y=d.current)==null||Y.restoreViewState(re.get(a))))},[a],M),_(()=>{var O;(O=d.current)==null||O.updateOptions(l)},[l],M),_(()=>{!d.current||n===void 0||(d.current.getOption(w.current.editor.EditorOption.readOnly)?d.current.setValue(n):n!==d.current.getValue()&&(F.current=!0,d.current.executeEdits("",[{range:d.current.getModel().getFullModelRange(),text:n,forceMoveMarkers:!0}]),d.current.pushUndoStop(),F.current=!1))},[n],M),_(()=>{var $,k;let O=($=d.current)==null?void 0:$.getModel();O&&o&&((k=w.current)==null||k.editor.setModelLanguage(O,o))},[o],M),_(()=>{var O;s!==void 0&&((O=d.current)==null||O.revealLine(s))},[s],M),_(()=>{var O;(O=w.current)==null||O.editor.setTheme(c)},[c],M);let H=i.useCallback(()=>{var O;if(!(!P.current||!w.current)&&!N.current){T.current(w.current);let $=a||r,k=B(w.current,n||e||"",t||o||"",$||"");d.current=(O=w.current)==null?void 0:O.editor.create(P.current,{model:k,automaticLayout:!0,...l},h),m&&d.current.restoreViewState(re.get($)),w.current.editor.setTheme(c),s!==void 0&&d.current.revealLine(s),E(!0),N.current=!0}},[e,t,r,n,o,a,l,h,m,c,s]);i.useEffect(()=>{M&&p.current(d.current,w.current)},[M]),i.useEffect(()=>{!j&&!M&&H()},[j,M,H]),u.current=n,i.useEffect(()=>{var O,$;M&&L&&((O=D.current)==null||O.dispose(),D.current=($=d.current)==null?void 0:$.onDidChangeModelContent(k=>{F.current||L(d.current.getValue(),k)}))},[M,L]),i.useEffect(()=>{if(M){let O=w.current.editor.onDidChangeMarkers($=>{var W;let k=(W=d.current.getModel())==null?void 0:W.uri;if(k&&$.find(Y=>Y.path===k.path)){let Y=w.current.editor.getModelMarkers({resource:k});x==null||x(Y)}});return()=>{O==null||O.dispose()}}return()=>{}},[M,x]);function ze(){var O,$;(O=D.current)==null||O.dispose(),g?m&&re.set(a,d.current.saveViewState()):($=d.current.getModel())==null||$.dispose(),d.current.dispose()}return i.createElement(_e,{width:I,height:v,isEditorReady:M,loading:f,_ref:P,className:R,wrapperProps:C})}var ar=or,ir=i.memo(ar),ge=ir;const ce={selectOnLineNumbers:!0,scrollBeyondLastLine:!1,padding:{top:16,bottom:16},minimap:{enabled:!1},fontSize:14,fontFamily:'"JetBrains Mono", "monospace"',lineHeight:20,scrollbar:{verticalScrollbarSize:14,horizontalScrollbarSize:14,verticalSliderSize:6,horizontalSliderSize:6},overviewRulerBorder:!1,overviewRulerLanes:0,renderLineHighlight:"none",automaticLayout:!0},ue=e=>{const{themeConfig:t,editor:r,theme:n}=e,{defaultTheme:o}=t??{},[a,c]=i.useState(n??o??"vs-dark");return i.useEffect(()=>{var s;(s=t==null?void 0:t.monacoThemes)==null||s.forEach(f=>{V.editor.defineTheme(f.themeName,f.themeData)})},[V]),i.useEffect(()=>{V.editor&&n&&(V.editor.setTheme(n),c(n))},[r,n]),{theme:a}};function cr(e){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let r="";for(let n=0;n<e;n++)r+=t.charAt(Math.floor(Math.random()*t.length));return r}function ur(e){return e.replace("'","'")}const sr=e=>{const t=new Intl.RelativeTimeFormat("en",{numeric:"auto"});if(e<60)return t.format(-e,"second");const r=Math.floor(e/60);if(r<60)return t.format(-r,"minute");const n=Math.floor(r/60);if(n<24)return t.format(-n,"hour");const o=Math.floor(n/24);if(o<30)return t.format(-o,"day");const a=Math.floor(o/30);if(a<12)return t.format(-a,"month");const c=Math.floor(a/12);return t.format(-c,"year")},lr=e=>{const t=new Date(e),n=Math.floor((new Date().getTime()-t.getTime())/1e3),o=Math.abs(n);return sr(o)};function fr({instanceId:e,lineNumbersPosition:t}){let r="";return t==="center"&&(r+=`
|
|
23
23
|
.monaco-editor-${e} .monaco-scrollable-element.editor-scrollable {
|
|
24
24
|
width: 100% !important;
|
|
25
25
|
left: 0px !important;
|
|
@@ -44,30 +44,30 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
44
44
|
|
|
45
45
|
.monaco-editor-${e} .view-line .blame-editor-commit {
|
|
46
46
|
display: inline-block;
|
|
47
|
-
color: var(--
|
|
48
|
-
}`,r}function
|
|
47
|
+
color: var(--cn-text-1);
|
|
48
|
+
}`,r}function dr({instanceId:e,blameData:t,dateWidth:r,avatarSize:n}){let o="";return t.forEach(a=>{var l,h,m,g,I,v,R,C;const c=(h=(l=a==null?void 0:a.commitInfo)==null?void 0:l.author)==null?void 0:h.avatarUrl,s=(g=(m=a==null?void 0:a.commitInfo)==null?void 0:m.author)==null?void 0:g.initials,f=c?`background: url('${(v=(I=a==null?void 0:a.commitInfo)==null?void 0:I.author)==null?void 0:v.avatarUrl}');`:"";for(let S=a.fromLineNumber;S<=a.toLineNumber;S++)S===a.fromLineNumber?o+=`
|
|
49
49
|
.monaco-editor-${e} .view-line .blame-editor-commit-${S}:before {
|
|
50
|
-
content: '${ur(((
|
|
50
|
+
content: '${ur(lr(((C=(R=a==null?void 0:a.commitInfo)==null?void 0:R.author)==null?void 0:C.when)||""))}';
|
|
51
51
|
position: absolute;
|
|
52
52
|
left: 10px;
|
|
53
53
|
top: 0px;
|
|
54
|
-
color:
|
|
54
|
+
color: var(--cn-text-3);
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
.monaco-editor-${e} .view-line .blame-editor-commit-${S}:after {
|
|
58
|
-
content: '${
|
|
58
|
+
content: '${s??" "}';
|
|
59
59
|
position: absolute;
|
|
60
60
|
border-radius: 50%;
|
|
61
61
|
padding: 4px;
|
|
62
62
|
text-align: center;
|
|
63
|
-
background:
|
|
63
|
+
background: var(--cn-set-gray-soft-bg);
|
|
64
64
|
line-height: 17px;
|
|
65
65
|
left: ${r+10}px;
|
|
66
66
|
top: -4px;
|
|
67
|
-
color:
|
|
67
|
+
color: var(--cn-text-3);
|
|
68
68
|
width: ${n}px;
|
|
69
69
|
height: ${n}px;
|
|
70
|
-
${
|
|
70
|
+
${f}
|
|
71
71
|
background-size: 100% 100%;
|
|
72
72
|
}`:o+=`
|
|
73
73
|
.monaco-editor-${e} .view-line .blame-editor-commit-${S}:before {
|
|
@@ -75,15 +75,15 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
75
75
|
left: 10px;
|
|
76
76
|
top: 0px;
|
|
77
77
|
color: gray;
|
|
78
|
-
}`}),o}function
|
|
79
|
-
.monaco-editor-${
|
|
80
|
-
left: ${
|
|
78
|
+
}`}),o}function mr(e,t){let r="";return e.length>t?r=e.slice(0,t-3)+"...":e.length<t?r=e+" ".repeat(t-e.length):r=e," ".repeat(25)+r+" ".repeat(10)}q.config({monaco:V});const de=450,pr=30,gr=140,hr=24,vr={...ce,readOnly:!0,matchBrackets:"never",renderValidationDecorations:"off",guides:{indentation:!1},folding:!1,stickyScroll:{enabled:!1},renderWhitespace:"none",renderLineHighlight:"none"};function br({code:e,language:t,themeConfig:r,lineNumbersPosition:n="left",blameData:o,showSeparators:a=!0,theme:c,height:s="75vh",options:f}){const l=i.useRef(o),h=i.useRef(cr(5));ie();const[m,g]=i.useState(),[I,v]=i.useState(0),R=i.useRef(null),C=i.useRef(null);i.useEffect(()=>{l.current=o},[o]);function S(){const w=C.current,d=R.current;if(!w||!d)return;a&&w.changeViewZones(function(p){p.addZone({afterLineNumber:0,heightInPx:10,domNode:document.createElement("div")}),l.current.forEach((T,D)=>{if(D!==l.current.length-1){const u=document.createElement("div");u.style.borderTop="1px solid var(--cn-border-2)",u.style.marginTop="9px",u.className="blame-editor-separator",p.addZone({afterLineNumber:T.toLineNumber,heightInPx:20,domNode:u})}})});const P=[];l.current.forEach(p=>{var T;for(let D=p.fromLineNumber;D<=p.toLineNumber;D++)P.push({range:new d.Range(D,0,D+1,0),options:{before:{content:mr(D===p.fromLineNumber&&((T=p==null?void 0:p.commitInfo)==null?void 0:T.title)||"",pr),cursorStops:d.editor.InjectedTextCursorStops.None,inlineClassName:`blame-editor-commit blame-editor-commit-${D}`}}})}),w.createDecorationsCollection(P)}function b(w,d){var P,p,T,D,u,y;C.current=w,R.current=d,w.setValue(e),g(w),(T=(p=(P=d.languages.typescript)==null?void 0:P.typescriptDefaults)==null?void 0:p.setDiagnosticsOptions)==null||T.call(p,{noSuggestionDiagnostics:!0,noSyntaxValidation:!0,noSemanticValidation:!0}),(y=(u=(D=d.languages.typescript)==null?void 0:D.javascriptDefaults)==null?void 0:u.setDiagnosticsOptions)==null||y.call(u,{noSuggestionDiagnostics:!0,noSyntaxValidation:!0,noSemanticValidation:!0}),S()}i.useEffect(()=>{m==null||m.setValue(e)},[e]);const{theme:L}=ue({monacoRef:R,themeConfig:r,editor:m,theme:c}),x=i.useMemo(()=>fr({instanceId:h.current,lineNumbersPosition:n}),[o]),M=i.useMemo(()=>dr({instanceId:h.current,blameData:o,avatarSize:hr,dateWidth:gr}),[o]);i.useEffect(()=>{if(n==="center"){const w=document.getElementsByClassName("lines-content")[0];if(w){const d={attributes:!0},P=T=>{for(const D of T){const u=parseInt(getComputedStyle(w).left);v(u)}},p=new MutationObserver(P);return p.observe(w,d),()=>{p.disconnect()}}}});const E=i.useMemo(()=>`
|
|
79
|
+
.monaco-editor-${h.current} .margin {
|
|
80
|
+
left: ${de+16+I}px !important;
|
|
81
81
|
pointer-events: none;
|
|
82
|
-
}`,[
|
|
83
|
-
.monaco-editor-${
|
|
84
|
-
clip-path: polygon(${
|
|
82
|
+
}`,[I]),j=`
|
|
83
|
+
.monaco-editor-${h.current} .view-overlays {
|
|
84
|
+
clip-path: polygon(${de+16}px 0, 100% 0%, 100% 100%, ${de+16}px 100%);
|
|
85
85
|
height:100% !important;
|
|
86
|
-
}`,
|
|
87
|
-
`),
|
|
88
|
-
`}])),
|
|
86
|
+
}`,U=i.useMemo(()=>({...vr,...f}),[f]);return A.jsxs(A.Fragment,{children:[A.jsx("style",{dangerouslySetInnerHTML:{__html:`${x} ${M} ${E} ${j}`}}),A.jsx(ge,{className:`monaco-editor-${h.current} overflow-hidden rounded-b-md border-x border-b`,height:s,language:t,theme:L,options:U,onMount:b})]})}q.config({monaco:V});const yr={...ce};function Or({codeRevision:e,onCodeRevisionChange:t,language:r,themeConfig:n,options:o,theme:a,height:c="75vh",className:s}){ie();const[f,l]=i.useState(),h=i.useRef(),m=i.useRef({code:"",revisionId:0}),g=i.useRef(null),I=i.useCallback((C,S)=>{var b,L,x,M,E,j;g.current=C,h.current=S,C.setValue(e.code),l(C),(x=(L=(b=S.languages.typescript)==null?void 0:b.typescriptDefaults)==null?void 0:L.setDiagnosticsOptions)==null||x.call(L,{noSuggestionDiagnostics:!0,noSyntaxValidation:!0,noSemanticValidation:!0}),(j=(E=(M=S.languages.typescript)==null?void 0:M.javascriptDefaults)==null?void 0:E.setDiagnosticsOptions)==null||j.call(E,{noSuggestionDiagnostics:!0,noSyntaxValidation:!0,noSemanticValidation:!0})},[e.code]);i.useEffect(()=>{var C,S;if(g.current&&(!e.revisionId||e.revisionId>Number((C=m.current)==null?void 0:C.revisionId))){const b=g.current.getModel();b&&(o!=null&&o.readOnly?(S=g.current)==null||S.setValue(e.code):(g.current.pushUndoStop(),g.current.executeEdits("edit",[{range:b.getFullModelRange(),text:e.code}]),g.current.pushUndoStop()))}},[e,g.current]);const{theme:v}=ue({monacoRef:h,themeConfig:n,editor:f,theme:a}),R=i.useMemo(()=>({...yr,...o||{}}),[o]);return A.jsx(A.Fragment,{children:A.jsx(ge,{className:s,height:c,onChange:(C,S)=>{m.current={code:C??"",revisionId:S.versionId},t({...m.current},S)},language:r,theme:v,options:R,onMount:I})})}q.config({monaco:V});const Sr={...ce,codeLens:!1,smartSelect:{selectLeadingAndTrailingWhitespace:!0},originalEditable:!1,overviewRulerBorder:!1};function wr({original:e,modified:t,language:r,themeConfig:n,options:o,theme:a,height:c="75vh"}){ie();const[s,f]=i.useState(),l=i.useRef(),{theme:h}=ue({monacoRef:l,themeConfig:n,editor:s,theme:a}),m=i.useMemo(()=>({...Sr,...o||{}}),[o]);return A.jsx(A.Fragment,{children:A.jsx(er,{className:"overflow-hidden rounded-b-md border-x border-b",language:r,theme:h,original:e,modified:t,height:c,options:m,onMount:f})})}var he=(e=>(e.ContainsPath="ContainsPath",e))(he||{});function Mr(e){const{pathSymbolMap:t,inlineActions:r=[],commandId:n}=e,o=Object.fromEntries(t.entries()),a=[];return r==null||r.forEach(c=>{const s=c.actions;c.selectors.forEach(l=>{switch(l.type){case he.ContainsPath:{l.paths.forEach(h=>{let g=Object.keys(o).map(v=>({fullPath:v,path:v,symbol:o[v]})).filter(v=>v.path.startsWith(l.basePath));g=g.map(v=>({...v,path:v.path.substring(l.basePath.length)})),g.filter(v=>h.test(v.path)).forEach(v=>{const R=v.fullPath,C=v.symbol,S=C.range;s.forEach(b=>{const L={range:S,symbols:[C],onClick:b.onClick,data:b.data,path:R};a.push({range:S,command:{id:n,title:b.title,arguments:[L]}})})})});break}}})}),a}const Z=class Z{static set(t){Z.data=t}static get(){return Z.data}};Se(Z,"data",{});let oe=Z;async function Ve(e){const t=oe.get(),{documentSymbolProvider:r}=t.StandaloneServices.get(t.ILanguageFeaturesService);return await t.OutlineModel.create(r,e)}function Ue(e){const t=new Map;return ve({pathSymbolMap:t,parentPath:"",children:e.children,parentKind:J.languages.SymbolKind.Module}),t}function ve(e){switch(e.parentKind){case J.languages.SymbolKind.Module:{Er(e);break}case J.languages.SymbolKind.Array:{jr(e);break}default:Pr(e)}}function Er(e){e.children.forEach(t=>{var n;let r=e.parentPath;t.symbol&&(r=e.parentPath?`${e.parentPath}.${t.symbol.name}`:t.symbol.name,e.pathSymbolMap.set(r,t.symbol)),ve({pathSymbolMap:e.pathSymbolMap,parentPath:r,children:t.children,parentKind:((n=t==null?void 0:t.symbol)==null?void 0:n.kind)??e.parentKind})})}function jr(e){let t=0;e.children.forEach(r=>{const n=e.parentPath?`${e.parentPath}.${t}`:`${t}`;e.pathSymbolMap.set(n,r.symbol),t+=1,ve({pathSymbolMap:e.pathSymbolMap,parentPath:n,children:r.children,parentKind:r.symbol.kind})})}function Pr(e){const t=e.children.get("0");if(t){const r=e.parentPath?`${e.parentPath}.${t.symbol.name}`:t==null?void 0:t.symbol.name;e.pathSymbolMap.set(r,t.symbol)}}function xr({editorRef:e,inlineActions:t}){i.useEffect(()=>V.languages.registerCodeLensProvider("yaml",{provideCodeLenses:async n=>{var f;const o=await Ve(n),a=Ue(o),c=(f=e==null?void 0:e.current)==null?void 0:f.addCommand(0,(l,{onClick:h,path:m,range:g,data:I})=>{h({path:m,range:g,data:I})});return c?{lenses:Mr({pathSymbolMap:a,inlineActions:t,commandId:c}),dispose:()=>{}}:void 0}}).dispose,[t,e])}const Cr=({editorRef:e,selection:t})=>{const[r,n]=i.useState(),o=i.useMemo(()=>async(a,c,s)=>{var g,I,v;const f=(g=e==null?void 0:e.current)==null?void 0:g.getModel();if(!f||!c)return n(void 0);const l=await Ve(f),m=(I=Ue(l).get(c))==null?void 0:I.range;m&&(n(m),s&&((v=e==null?void 0:e.current)==null||v.revealLineInCenter(m.startLineNumber)))},[]);i.useEffect(()=>{if("requestIdleCallback"in window){const a=requestIdleCallback(()=>{o(e,t==null?void 0:t.path,t==null?void 0:t.revealInCenter)});return()=>cancelIdleCallback(a)}else{const a=setTimeout(()=>{o(e,t==null?void 0:t.path,t==null?void 0:t.revealInCenter)},100);return()=>clearTimeout(a)}},[t==null?void 0:t.path,t==null?void 0:t.revealInCenter,e,o]),i.useEffect(()=>{var c;if(!r)return;const a=(c=e==null?void 0:e.current)==null?void 0:c.createDecorationsCollection([{range:{...r,startColumn:1},options:{isWholeLine:!1,className:t==null?void 0:t.className}}]);return()=>a==null?void 0:a.clear()},[r,e,t==null?void 0:t.className])},be=i.createContext({markers:[],setMarkers:()=>{},editor:null,setEditor:e=>{},updateCursorPosition:e=>{}});function $r({children:e}){const[t,r]=i.useState([]),[n,o]=i.useState(null),a=i.useCallback(c=>{n==null||n.setPosition(c),n==null||n.revealLineInCenterIfOutsideViewport(c.lineNumber),n==null||n.focus()},[n]);return A.jsx(be.Provider,{value:{markers:t,setMarkers:r,editor:n,setEditor:o,updateCursorPosition:a},children:e})}function ye(){return i.useContext(be)}const Ir=({monacoRef:e,editorRef:t,instanceId:r})=>{const{setMarkers:n}=ye();i.useEffect(()=>{let o;const a=setTimeout(()=>{var s;const c=(s=e.current)==null?void 0:s.editor;c&&(o=c.onDidChangeMarkers(f=>{var m;const l=(m=t.current)==null?void 0:m.getModel();if(!l)return;const h=l.uri.toString();if(f.some(g=>g.toString()===h)){const g=V.editor.getModelMarkers({resource:l.uri});n(g)}}))},100);return()=>{clearTimeout(a),o==null||o.dispose()}},[e,r,n])};function Dr(e){var n,o;const t=((o=(n=me.yamlDefaults)==null?void 0:n.diagnosticsOptions)==null?void 0:o.schemas)??[],r=t.findIndex(a=>a.fileMatch[0]===e.fileMatch[0]);r!==-1?t[r]=e:t.push(e),Fe(t)}function Tr(e){var n,o;const r=(((o=(n=me.yamlDefaults)==null?void 0:n.diagnosticsOptions)==null?void 0:o.schemas)??[]).filter(a=>a.fileMatch[0]!==Oe(e));Fe(r)}function Fe(e){const t={hover:!0,completion:!0,enableSchemaRequest:!1,validate:!0,schemas:e};me.yamlDefaults.setDiagnosticsOptions({...t})}const Oe=e=>J.Uri.parse(`file://${e}`).toString(),Lr=e=>{const{schemaConfig:t,instanceId:r}=e;i.useEffect(()=>{if(t!=null&&t.schema)return Dr({fileMatch:[Oe(r.toString())],...t}),()=>{Tr(r)}},[t==null?void 0:t.schema,r])};q.config({monaco:V});const Rr={...ce,folding:!0},Nr=function(t){const{yamlRevision:r,schemaConfig:n,inlineActions:o,themeConfig:a,onYamlRevisionChange:c,selection:s,theme:f,options:l,animateOnUpdate:h=!1,onAnimateEnd:m,instanceId:g}=t,I=ie(),[v]=i.useState(g??`yaml-editor-${Math.random()}`),{editor:R,setEditor:C}=ye(),S=i.useRef(null),b=i.useRef(),L=i.useRef({yaml:"",revisionId:0}),x=i.useRef(null),M=i.useRef(null),E=i.useCallback(P=>{var D,u,y;const p=P.split(`
|
|
87
|
+
`),T=(D=x.current)==null?void 0:D.getModel();if(T){(u=x.current)==null||u.pushUndoStop(),T.setValue("");let N=0;M.current=window.setInterval(()=>{var F;N<p.length?(I&&((F=x.current)==null||F.executeEdits("addLine",[{range:new I.Range(N+1,1,N+1,1),text:p[N]+`
|
|
88
|
+
`}])),N++):M.current&&(clearInterval(M.current),m==null||m())},100),(y=x.current)==null||y.pushUndoStop()}},[I]);i.useEffect(()=>()=>{M.current&&clearInterval(M.current)},[]);function j(P,p){x.current=P,b.current=p,P.setValue(r.yaml),C(P),setTimeout(()=>{var T;(T=S.current)!=null&&T.style&&(S.current.style.opacity="1")},50)}i.useEffect(()=>{var P;if(x.current&&(!r.revisionId||r.revisionId>Number((P=L.current)==null?void 0:P.revisionId))){const p=x.current.getModel();p&&(x.current.executeEdits("edit",[{range:p.getFullModelRange(),text:h?"":r.yaml}]),h&&E(r.yaml))}},[E,r,h]),Lr({schemaConfig:n,instanceId:v}),xr({editorRef:x,inlineActions:o});const{theme:U}=ue({monacoRef:b,themeConfig:a,editor:R,theme:f});Ir({monacoRef:b,editorRef:x,instanceId:v}),Cr({editorRef:x,selection:s});const w=i.useMemo(()=>Oe(v),[]),d=i.useMemo(()=>({...Rr,...l}),[l]);return A.jsx("div",{style:{width:"100%",height:"100%",opacity:0},ref:S,children:A.jsx(ge,{onChange:(P,p)=>{L.current={yaml:P??"",revisionId:p.versionId},c({...L.current},p)},language:"yaml",theme:U,options:d,path:w,onMount:j})})};exports.BlameEditor=br;exports.CodeDiffEditor=wr;exports.CodeEditor=Or;exports.MonacoGlobals=oe;exports.SelectorType=he;exports.YamlEditor=Nr;exports.YamlEditorContext=be;exports.YamlEditorContextProvider=$r;exports.useYamlEditorContext=ye;
|
|
89
89
|
//# sourceMappingURL=index.cjs.map
|