@harnessio/yaml-editor 0.18.0 → 0.19.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/index.cjs +15 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +529 -511
- package/dist/index.js.map +1 -1
- package/dist/utils/schema-utils.d.ts +6 -1
- 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/index.cjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var qe=Object.defineProperty;var Be=(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)=>(Be(e,typeof t!="symbol"?t+"":t,r),r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react"),J=require("monaco-editor"),pe=require("monaco-yaml");function Ye(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=Ye(J);var Le={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 Ie(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=Ie;X.jsxs=Ie;Le.exports=X;var A=Le.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(d){o=!0,a=d}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 Ce(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 xe(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Ce(Object(r),!0).forEach(function(n){ut(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Ce(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),d=0;d<c;d++)s[d]=arguments[d];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 dt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function ft(e,t){return ne(t)||F("changeType"),Object.keys(t).some(function(r){return!dt(e,r)})&&F("changeField"),t}function pt(e){Q(e)||F("selectorType")}function mt(e){Q(e)||ne(e)||F("handlerType"),ne(e)&&Object.values(e).some(function(t){return!Q(t)})&&F("handlersType")}function gt(e){e||F("initialIsRequired"),ne(e)||F("initialType"),lt(e)&&F("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"},F=K(ht)(vt),te={changes:ft,selector:pt,handler:mt,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 d(l){st(n,o,a,c)(l)}return[s,d]}function yt(e,t){return Q(t)?t(e.current):t}function Ot(e,t){return e.current=xe(xe({},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),d=0;d<c;d++)s[d]=arguments[d];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?(Ct(),{paths:{vs:e.urls.monacoBase}}):e}function Ct(){console.warn(Re.deprecation)}function xt(e,t){throw new Error(e[t]||e.default)}var Re={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
|
-
`}
|
|
22
|
+
`},$e=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]))}),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 It=wt.create({config:Mt,isInitialized:!1,resolve:null,reject:null,monaco:null}),Ne=nt(It,2),ee=Ne[0],ae=Ne[1];function Rt(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 Tt(){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);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){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:Rt,init:Tt,__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 Bt=qt,Yt=Bt;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(Yt,null,n),i.createElement("div",{ref:o,style:{...de.fullWidth,...!r&&de.hide},className:a}))}var Wt=Ht,_e=i.memo(Wt);function Kt(e){i.useEffect(e,[])}var me=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 Y(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:d=!1,theme:l="light",loading:h="Loading...",options:p={},height:g="100%",width:L="100%",className:v,wrapperProps:T={},beforeMount:x=G,onMount:S=G}){let[b,R]=i.useState(!1),[C,M]=i.useState(!0),E=i.useRef(null),j=i.useRef(null),U=i.useRef(null),w=i.useRef(S),f=i.useRef(x),P=i.useRef(!1);me(()=>{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=Y(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=Y(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(p)},[p],b);let m=i.useCallback(()=>{var N;if(!j.current)return;f.current(j.current);let u=Y(j.current,e||"",n||r||"text",a||""),y=Y(j.current,t||"",o||r||"text",c||"");(N=E.current)==null||N.setModel({original:u,modified:y})},[r,t,o,e,n,a,c]),I=i.useCallback(()=>{var u;!P.current&&U.current&&(E.current=j.current.editor.createDiffEditor(U.current,{automaticLayout:!0,...p}),m(),(u=j.current)==null||u.editor.setTheme(l),R(!0),P.current=!0)},[p,l,m]);i.useEffect(()=>{b&&w.current(E.current,j.current)},[b]),i.useEffect(()=>{!C&&!b&&I()},[C,b,I]);function D(){var y,N,z,H;let u=(y=E.current)==null?void 0:y.getModel();s||((N=u==null?void 0:u.original)==null||N.dispose()),d||((z=u==null?void 0:u.modified)==null||z.dispose()),(H=E.current)==null||H.dispose()}return i.createElement(_e,{width:L,height:g,isEditorReady:b,loading:h,_ref:U,className:v,wrapperProps:T})}var Xt=Qt,er=i.memo(Xt);function tr(){let[e,t]=i.useState(q.__getMonacoInstance());return me(()=>{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:d="Loading...",options:l={},overrideServices:h={},saveViewState:p=!0,keepCurrentModel:g=!1,width:L="100%",height:v="100%",className:T,wrapperProps:x={},beforeMount:S=G,onMount:b=G,onChange:R,onValidate:C=G}){let[M,E]=i.useState(!1),[j,U]=i.useState(!0),w=i.useRef(null),f=i.useRef(null),P=i.useRef(null),m=i.useRef(b),I=i.useRef(S),D=i.useRef(),u=i.useRef(n),y=nr(a),N=i.useRef(!1),z=i.useRef(!1);me(()=>{let O=q.init();return O.then($=>(w.current=$)&&U(!1)).catch($=>($==null?void 0:$.type)!=="cancelation"&&console.error("Monaco initialization: error:",$)),()=>f.current?Fe():O.cancel()}),_(()=>{var $,k,W,B;let O=Y(w.current,e||n||"",t||o||"",a||r||"");O!==(($=f.current)==null?void 0:$.getModel())&&(p&&re.set(y,(k=f.current)==null?void 0:k.saveViewState()),(W=f.current)==null||W.setModel(O),p&&((B=f.current)==null||B.restoreViewState(re.get(a))))},[a],M),_(()=>{var O;(O=f.current)==null||O.updateOptions(l)},[l],M),_(()=>{!f.current||n===void 0||(f.current.getOption(w.current.editor.EditorOption.readOnly)?f.current.setValue(n):n!==f.current.getValue()&&(z.current=!0,f.current.executeEdits("",[{range:f.current.getModel().getFullModelRange(),text:n,forceMoveMarkers:!0}]),f.current.pushUndoStop(),z.current=!1))},[n],M),_(()=>{var $,k;let O=($=f.current)==null?void 0:$.getModel();O&&o&&((k=w.current)==null||k.editor.setModelLanguage(O,o))},[o],M),_(()=>{var O;s!==void 0&&((O=f.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){I.current(w.current);let $=a||r,k=Y(w.current,n||e||"",t||o||"",$||"");f.current=(O=w.current)==null?void 0:O.editor.create(P.current,{model:k,automaticLayout:!0,...l},h),p&&f.current.restoreViewState(re.get($)),w.current.editor.setTheme(c),s!==void 0&&f.current.revealLine(s),E(!0),N.current=!0}},[e,t,r,n,o,a,l,h,p,c,s]);i.useEffect(()=>{M&&m.current(f.current,w.current)},[M]),i.useEffect(()=>{!j&&!M&&H()},[j,M,H]),u.current=n,i.useEffect(()=>{var O,$;M&&R&&((O=D.current)==null||O.dispose(),D.current=($=f.current)==null?void 0:$.onDidChangeModelContent(k=>{z.current||R(f.current.getValue(),k)}))},[M,R]),i.useEffect(()=>{if(M){let O=w.current.editor.onDidChangeMarkers($=>{var W;let k=(W=f.current.getModel())==null?void 0:W.uri;if(k&&$.find(B=>B.path===k.path)){let B=w.current.editor.getModelMarkers({resource:k});C==null||C(B)}});return()=>{O==null||O.dispose()}}return()=>{}},[M,C]);function Fe(){var O,$;(O=D.current)==null||O.dispose(),g?p&&re.set(a,f.current.saveViewState()):($=f.current.getModel())==null||$.dispose(),f.current.dispose()}return i.createElement(_e,{width:L,height:v,isEditorReady:M,loading:d,_ref:P,className:T,wrapperProps:x})}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.themes)==null||s.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+=`
|
|
23
23
|
.monaco-editor-${e} .monaco-scrollable-element.editor-scrollable {
|
|
24
24
|
width: 100% !important;
|
|
25
25
|
left: 0px !important;
|
|
@@ -45,9 +45,9 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
45
45
|
.monaco-editor-${e} .view-line .blame-editor-commit {
|
|
46
46
|
display: inline-block;
|
|
47
47
|
color: var(--canary-foreground-01);
|
|
48
|
-
}`,r}function lr({instanceId:e,blameData:t,dateWidth:r,avatarSize:n}){let o="";return t.forEach(a=>{var
|
|
48
|
+
}`,r}function lr({instanceId:e,blameData:t,dateWidth:r,avatarSize:n}){let o="";return t.forEach(a=>{var l,h,p,g,L,v,T,x;const c=(h=(l=a==null?void 0:a.commitInfo)==null?void 0:l.author)==null?void 0:h.avatarUrl,s=(g=(p=a==null?void 0:a.commitInfo)==null?void 0:p.author)==null?void 0:g.initials,d=c?`background: url('${(v=(L=a==null?void 0:a.commitInfo)==null?void 0:L.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(((x=(T=a==null?void 0:a.commitInfo)==null?void 0:T.author)==null?void 0:x.when)||"")}';
|
|
51
51
|
position: absolute;
|
|
52
52
|
left: 10px;
|
|
53
53
|
top: 0px;
|
|
@@ -55,7 +55,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
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;
|
|
@@ -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 dr(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)}
|
|
79
|
-
.monaco-editor-${
|
|
78
|
+
}`}),o}function dr(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 fe=450,fr=30,pr=140,mr=24,gr={...ce,readOnly:!0,matchBrackets:"never",renderValidationDecorations:"off",guides:{indentation:!1},folding:!1,stickyScroll:{enabled:!1},renderWhitespace:"none",renderLineHighlight:"none"};function hr({code:e,language:t,themeConfig:r,lineNumbersPosition:n="left",blameData:o,showSeparators:a=!0,theme:c,height:s="75vh",options:d}){const l=i.useRef(o),h=i.useRef(cr(5));ie();const[p,g]=i.useState(),[L,v]=i.useState(0),T=i.useRef(null),x=i.useRef(null);i.useEffect(()=>{l.current=o},[o]);function S(){const w=x.current,f=T.current;if(!w||!f)return;a&&w.changeViewZones(function(m){m.addZone({afterLineNumber:0,heightInPx:10,domNode:document.createElement("div")}),l.current.forEach((I,D)=>{if(D!==l.current.length-1){const u=document.createElement("div");u.style.borderTop="1px solid hsl(var(--canary-border-01))",u.style.marginTop="9px",u.className="blame-editor-separator",m.addZone({afterLineNumber:I.toLineNumber,heightInPx:20,domNode:u})}})});const P=[];l.current.forEach(m=>{var I;for(let D=m.fromLineNumber;D<=m.toLineNumber;D++)P.push({range:new f.Range(D,0,D+1,0),options:{before:{content:dr(D===m.fromLineNumber&&((I=m==null?void 0:m.commitInfo)==null?void 0:I.title)||"",fr),cursorStops:f.editor.InjectedTextCursorStops.None,inlineClassName:`blame-editor-commit blame-editor-commit-${D}`}}})}),w.createDecorationsCollection(P)}function b(w,f){var P,m,I,D,u,y;x.current=w,T.current=f,w.setValue(e),g(w),(I=(m=(P=f.languages.typescript)==null?void 0:P.typescriptDefaults)==null?void 0:m.setDiagnosticsOptions)==null||I.call(m,{noSuggestionDiagnostics:!0,noSyntaxValidation:!0,noSemanticValidation:!0}),(y=(u=(D=f.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(()=>{p==null||p.setValue(e)},[e]);const{theme:R}=ue({monacoRef:T,themeConfig:r,editor:p,theme:c}),C=i.useMemo(()=>sr({instanceId:h.current,lineNumbersPosition:n}),[o]),M=i.useMemo(()=>lr({instanceId:h.current,blameData:o,avatarSize:mr,dateWidth:pr}),[o]);i.useEffect(()=>{if(n==="center"){const w=document.getElementsByClassName("lines-content")[0];if(w){const f={attributes:!0},P=I=>{for(const D of I){const u=parseInt(getComputedStyle(w).left);v(u)}},m=new MutationObserver(P);return m.observe(w,f),()=>{m.disconnect()}}}});const E=i.useMemo(()=>`
|
|
79
|
+
.monaco-editor-${h.current} .margin {
|
|
80
80
|
left: ${fe+16+L}px !important;
|
|
81
81
|
pointer-events: none;
|
|
82
|
-
}`,[L]),
|
|
83
|
-
.monaco-editor-${
|
|
82
|
+
}`,[L]),j=`
|
|
83
|
+
.monaco-editor-${h.current} .view-overlays {
|
|
84
84
|
clip-path: polygon(${fe+16}px 0, 100% 0%, 100% 100%, ${fe+16}px 100%);
|
|
85
85
|
height:100% !important;
|
|
86
|
-
}`,
|
|
87
|
-
`),D=
|
|
88
|
-
`}])),
|
|
86
|
+
}`,U=i.useMemo(()=>({...gr,...d}),[d]);return A.jsxs(A.Fragment,{children:[A.jsx("style",{dangerouslySetInnerHTML:{__html:`${C} ${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:R,options:U,onMount:b})]})}q.config({monaco:V});const vr={...ce};function br({codeRevision:e,onCodeRevisionChange:t,language:r,themeConfig:n,options:o,theme:a,height:c="75vh",className:s}){ie();const[d,l]=i.useState(),h=i.useRef(),p=i.useRef({code:"",revisionId:0}),g=i.useRef(null),L=i.useCallback((x,S)=>{var b,R,C,M,E,j;g.current=x,h.current=S,x.setValue(e.code),l(x),(C=(R=(b=S.languages.typescript)==null?void 0:b.typescriptDefaults)==null?void 0:R.setDiagnosticsOptions)==null||C.call(R,{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 x,S;if(g.current&&(!e.revisionId||e.revisionId>Number((x=p.current)==null?void 0:x.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:d,theme:a}),T=i.useMemo(()=>({...vr,...o||{}}),[o]);return A.jsx(A.Fragment,{children:A.jsx(ge,{className:s,height:c,onChange:(x,S)=>{p.current={code:x??"",revisionId:S.versionId},t({...p.current},S)},language:r,theme:v,options:T,onMount:L})})}q.config({monaco:V});const yr={...ce,codeLens:!1,smartSelect:{selectLeadingAndTrailingWhitespace:!0},originalEditable:!1,overviewRulerBorder:!1};function Or({original:e,modified:t,language:r,themeConfig:n,options:o,theme:a,height:c="75vh"}){ie();const[s,d]=i.useState(),l=i.useRef(),{theme:h}=ue({monacoRef:l,themeConfig:n,editor:s,theme:a}),p=i.useMemo(()=>({...yr,...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:p,onMount:d})})}var he=(e=>(e.ContainsPath="ContainsPath",e))(he||{});function Sr(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 T=v.fullPath,x=v.symbol,S=x.range;s.forEach(b=>{const R={range:S,symbols:[x],onClick:b.onClick,data:b.data,path:T};a.push({range:S,command:{id:n,title:b.title,arguments:[R]}})})})});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:{wr(e);break}case J.languages.SymbolKind.Array:{Mr(e);break}default:Er(e)}}function wr(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 Mr(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 Er(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 jr({editorRef:e,inlineActions:t}){i.useEffect(()=>V.languages.registerCodeLensProvider("yaml",{provideCodeLenses:async n=>{var d;const o=await Ve(n),a=Ue(o),c=(d=e==null?void 0:e.current)==null?void 0:d.addCommand(0,(l,{onClick:h,path:p,range:g,data:L})=>{h({path:p,range:g,data:L})});return c?{lenses:Sr({pathSymbolMap:a,inlineActions:t,commandId:c}),dispose:()=>{}}:void 0}}).dispose,[t,e])}const Pr=({editorRef:e,selection:t})=>{const[r,n]=i.useState(),o=i.useMemo(()=>async(a,c,s)=>{var g,L,v;const d=(g=e==null?void 0:e.current)==null?void 0:g.getModel();if(!d||!c)return n(void 0);const l=await Ve(d),p=(L=Ue(l).get(c))==null?void 0:L.range;p&&(n(p),s&&((v=e==null?void 0:e.current)==null||v.revealLineInCenter(p.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 Cr({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 xr=({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(d=>{var p;const l=(p=t.current)==null?void 0:p.getModel();if(!l)return;const h=l.uri.toString();if(d.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 $r(e){var n,o;const t=((o=(n=pe.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),ze(t)}function Lr(e){var n,o;const r=(((o=(n=pe.yamlDefaults)==null?void 0:n.diagnosticsOptions)==null?void 0:o.schemas)??[]).filter(a=>a.fileMatch[0]!==Oe(e));ze(r)}function ze(e){const t={hover:!0,completion:!0,enableSchemaRequest:!1,validate:!0,schemas:e};pe.yamlDefaults.setDiagnosticsOptions({...t})}const Oe=e=>J.Uri.parse(`file://${e}`).toString(),Dr=e=>{const{schemaConfig:t,instanceId:r}=e;i.useEffect(()=>{if(t!=null&&t.schema)return $r({fileMatch:[Oe(r.toString())],...t}),()=>{Lr(r)}},[t==null?void 0:t.schema,r])};q.config({monaco:V});const Ir={...ce,folding:!0},Rr=function(t){const{yamlRevision:r,schemaConfig:n,inlineActions:o,themeConfig:a,onYamlRevisionChange:c,selection:s,theme:d,options:l,animateOnUpdate:h=!1,onAnimateEnd:p,instanceId:g}=t,L=ie(),[v]=i.useState(g??`yaml-editor-${Math.random()}`),{editor:T,setEditor:x}=ye(),S=i.useRef(null),b=i.useRef(),R=i.useRef({yaml:"",revisionId:0}),C=i.useRef(null),M=i.useRef(null),E=i.useCallback(P=>{var D,u,y;const m=P.split(`
|
|
87
|
+
`),I=(D=C.current)==null?void 0:D.getModel();if(I){(u=C.current)==null||u.pushUndoStop(),I.setValue("");let N=0;M.current=window.setInterval(()=>{var z;N<m.length?(L&&((z=C.current)==null||z.executeEdits("addLine",[{range:new L.Range(N+1,1,N+1,1),text:m[N]+`
|
|
88
|
+
`}])),N++):M.current&&(clearInterval(M.current),p==null||p())},100),(y=C.current)==null||y.pushUndoStop()}},[L]);i.useEffect(()=>()=>{M.current&&clearInterval(M.current)},[]);function j(P,m){C.current=P,b.current=m,P.setValue(r.yaml),x(P),setTimeout(()=>{var I;(I=S.current)!=null&&I.style&&(S.current.style.opacity="1")},50)}i.useEffect(()=>{var P;if(C.current&&(!r.revisionId||r.revisionId>Number((P=R.current)==null?void 0:P.revisionId))){const m=C.current.getModel();m&&(C.current.executeEdits("edit",[{range:m.getFullModelRange(),text:h?"":r.yaml}]),h&&E(r.yaml))}},[E,r,h]),Dr({schemaConfig:n,instanceId:v}),jr({editorRef:C,inlineActions:o});const{theme:U}=ue({monacoRef:b,themeConfig:a,editor:T,theme:d});xr({monacoRef:b,editorRef:C,instanceId:v}),Pr({editorRef:C,selection:s});const w=i.useMemo(()=>Oe(v),[]),f=i.useMemo(()=>({...Ir,...l}),[l]);return A.jsx("div",{style:{width:"100%",height:"100%",opacity:0},ref:S,children:A.jsx(ge,{onChange:(P,m)=>{R.current={yaml:P??"",revisionId:m.versionId},c({...R.current},m)},language:"yaml",theme:U,options:f,path:w,onMount:j})})};exports.BlameEditor=hr;exports.CodeDiffEditor=Or;exports.CodeEditor=br;exports.MonacoGlobals=oe;exports.SelectorType=he;exports.YamlEditor=Rr;exports.YamlEditorContext=be;exports.YamlEditorContextProvider=Cr;exports.useYamlEditorContext=ye;
|
|
89
89
|
//# sourceMappingURL=index.cjs.map
|