@ws-ui/code-editor 0.1.20 → 0.1.21
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/editor/schemas/condition.schema.json.d.ts +29 -4
- package/dist/index.cjs.js +13 -13
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +52 -11
- package/dist/index.es.js.map +1 -1
- package/package.json +3 -3
|
@@ -24,6 +24,9 @@ declare const _default: {
|
|
|
24
24
|
{
|
|
25
25
|
"$ref": "#/definitions/Combination"
|
|
26
26
|
},
|
|
27
|
+
{
|
|
28
|
+
"$ref": "#/definitions/CurrentState"
|
|
29
|
+
},
|
|
27
30
|
{
|
|
28
31
|
"$ref": "#/definitions/ParentState"
|
|
29
32
|
},
|
|
@@ -76,9 +79,6 @@ declare const _default: {
|
|
|
76
79
|
"valueType": {
|
|
77
80
|
"enum": ["datasource", "hardCoded"]
|
|
78
81
|
},
|
|
79
|
-
"dataType": {
|
|
80
|
-
"enum": ["string", "number", "date", "boolean", "array", "object"]
|
|
81
|
-
},
|
|
82
82
|
"op": {
|
|
83
83
|
"enum": ["eq", "neq", "regex"]
|
|
84
84
|
}
|
|
@@ -107,6 +107,31 @@ declare const _default: {
|
|
|
107
107
|
},
|
|
108
108
|
"required": ["type", "conditions", "op"]
|
|
109
109
|
},
|
|
110
|
+
"CurrentState": {
|
|
111
|
+
"allOf": [
|
|
112
|
+
{
|
|
113
|
+
"$ref": "#/definitions/Base"
|
|
114
|
+
}
|
|
115
|
+
],
|
|
116
|
+
"properties": {
|
|
117
|
+
"type": {
|
|
118
|
+
"const": "currentState"
|
|
119
|
+
},
|
|
120
|
+
"value": {
|
|
121
|
+
"type": "string"
|
|
122
|
+
},
|
|
123
|
+
"valueType": {
|
|
124
|
+
"enum": ["datasource", "hardCoded"]
|
|
125
|
+
},
|
|
126
|
+
"dataType": {
|
|
127
|
+
"enum": ["string", "number", "date", "boolean", "array", "object"]
|
|
128
|
+
},
|
|
129
|
+
"op": {
|
|
130
|
+
"enum": ["eq", "neq", "regex", "in", "nin"]
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
"required": ["name", "type", "value", "op"]
|
|
134
|
+
},
|
|
110
135
|
"ParentState": {
|
|
111
136
|
"allOf": [
|
|
112
137
|
{
|
|
@@ -127,7 +152,7 @@ declare const _default: {
|
|
|
127
152
|
"enum": ["string", "number", "date", "boolean", "array", "object"]
|
|
128
153
|
},
|
|
129
154
|
"op": {
|
|
130
|
-
"enum": ["eq", "neq", "regex"]
|
|
155
|
+
"enum": ["eq", "neq", "regex", "in", "nin"]
|
|
131
156
|
}
|
|
132
157
|
},
|
|
133
158
|
"required": ["name", "type", "value", "op"]
|
package/dist/index.cjs.js
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
"use strict";var Ot=Object.defineProperty;var Pt=(r,n,t)=>n in r?Ot(r,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[n]=t;var V=(r,n,t)=>(Pt(r,typeof n!="symbol"?n+"":n,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("react"),
|
|
1
|
+
"use strict";var Ot=Object.defineProperty;var Pt=(r,n,t)=>n in r?Ot(r,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[n]=t;var V=(r,n,t)=>(Pt(r,typeof n!="symbol"?n+"":n,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("react"),ye=require("@monaco-editor/react"),B=require("@ws-ui/shared"),Ve=require("monaco-languageclient"),Be=require("vscode-languageclient"),W=require("monaco-editor"),xe=require("vscode-ws-jsonrpc"),J=require("vscode-languageserver-protocol"),H=require("vscode/services");function Nt(r){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const t in r)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(n,t,i.get?i:{enumerable:!0,get:()=>r[t]})}}return n.default=r,Object.freeze(n)}const c=Nt(W);var Ee={exports:{}},te={};/*
|
|
2
2
|
object-assign
|
|
3
3
|
(c) Sindre Sorhus
|
|
4
4
|
@license MIT
|
|
5
|
-
*/var be,ze;function Xe(){if(ze)return be;ze=1;var r=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,t=Object.prototype.propertyIsEnumerable;function i(u){if(u==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(u)}function
|
|
5
|
+
*/var be,ze;function Xe(){if(ze)return be;ze=1;var r=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,t=Object.prototype.propertyIsEnumerable;function i(u){if(u==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(u)}function s(){try{if(!Object.assign)return!1;var u=new String("abc");if(u[5]="de",Object.getOwnPropertyNames(u)[0]==="5")return!1;for(var d={},l=0;l<10;l++)d["_"+String.fromCharCode(l)]=l;var f=Object.getOwnPropertyNames(d).map(function(b){return d[b]});if(f.join("")!=="0123456789")return!1;var h={};return"abcdefghijklmnopqrst".split("").forEach(function(b){h[b]=b}),Object.keys(Object.assign({},h)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return be=s()?Object.assign:function(u,d){for(var l,f=i(u),h,b=1;b<arguments.length;b++){l=Object(arguments[b]);for(var S in l)n.call(l,S)&&(f[S]=l[S]);if(r){h=r(l);for(var v=0;v<h.length;v++)t.call(l,h[v])&&(f[h[v]]=l[h[v]])}}return f},be}/** @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 Ge;function jt(){if(Ge)return te;Ge=1,Xe();var r=w,n=60103;if(te.Fragment=60107,typeof Symbol=="function"&&Symbol.for){var t=Symbol.for;n=t("react.element"),te.Fragment=t("react.fragment")}var i=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,
|
|
12
|
+
*/var Ge;function jt(){if(Ge)return te;Ge=1,Xe();var r=w,n=60103;if(te.Fragment=60107,typeof Symbol=="function"&&Symbol.for){var t=Symbol.for;n=t("react.element"),te.Fragment=t("react.fragment")}var i=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s=Object.prototype.hasOwnProperty,u={key:!0,ref:!0,__self:!0,__source:!0};function d(l,f,h){var b,S={},v=null,N=null;h!==void 0&&(v=""+h),f.key!==void 0&&(v=""+f.key),f.ref!==void 0&&(N=f.ref);for(b in f)s.call(f,b)&&!u.hasOwnProperty(b)&&(S[b]=f[b]);if(l&&l.defaultProps)for(b in f=l.defaultProps,f)S[b]===void 0&&(S[b]=f[b]);return{$$typeof:n,type:l,key:v,ref:N,props:S,_owner:i.current}}return te.jsx=d,te.jsxs=d,te}var Ce={};/** @license React v17.0.2
|
|
13
13
|
* react-jsx-runtime.development.js
|
|
14
14
|
*
|
|
15
15
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
16
16
|
*
|
|
17
17
|
* This source code is licensed under the MIT license found in the
|
|
18
18
|
* LICENSE file in the root directory of this source tree.
|
|
19
|
-
*/var Ze;function At(){return Ze||(Ze=1,function(r){process.env.NODE_ENV!=="production"&&function(){var n=w,t=Xe(),i=60103,
|
|
20
|
-
`+de+e}}var fe=!1,
|
|
19
|
+
*/var Ze;function At(){return Ze||(Ze=1,function(r){process.env.NODE_ENV!=="production"&&function(){var n=w,t=Xe(),i=60103,s=60106;r.Fragment=60107;var u=60108,d=60114,l=60109,f=60110,h=60112,b=60113,S=60120,v=60115,N=60116,L=60121,j=60122,M=60117,I=60129,E=60131;if(typeof Symbol=="function"&&Symbol.for){var R=Symbol.for;i=R("react.element"),s=R("react.portal"),r.Fragment=R("react.fragment"),u=R("react.strict_mode"),d=R("react.profiler"),l=R("react.provider"),f=R("react.context"),h=R("react.forward_ref"),b=R("react.suspense"),S=R("react.suspense_list"),v=R("react.memo"),N=R("react.lazy"),L=R("react.block"),j=R("react.server.block"),M=R("react.fundamental"),R("react.scope"),R("react.opaque.id"),I=R("react.debug_trace_mode"),R("react.offscreen"),E=R("react.legacy_hidden")}var m=typeof Symbol=="function"&&Symbol.iterator,p="@@iterator";function q(e){if(e===null||typeof e!="object")return null;var o=m&&e[m]||e[p];return typeof o=="function"?o:null}var F=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function k(e){{for(var o=arguments.length,a=new Array(o>1?o-1:0),g=1;g<o;g++)a[g-1]=arguments[g];U("error",e,a)}}function U(e,o,a){{var g=F.ReactDebugCurrentFrame,O=g.getStackAddendum();O!==""&&(o+="%s",a=a.concat([O]));var P=a.map(function(y){return""+y});P.unshift("Warning: "+o),Function.prototype.apply.call(console[e],console,P)}}var ue=!1;function x(e){return!!(typeof e=="string"||typeof e=="function"||e===r.Fragment||e===d||e===I||e===u||e===b||e===S||e===E||ue||typeof e=="object"&&e!==null&&(e.$$typeof===N||e.$$typeof===v||e.$$typeof===l||e.$$typeof===f||e.$$typeof===h||e.$$typeof===M||e.$$typeof===L||e[0]===j))}function T(e,o,a){var g=o.displayName||o.name||"";return e.displayName||(g!==""?a+"("+g+")":a)}function _(e){return e.displayName||"Context"}function K(e){if(e==null)return null;if(typeof e.tag=="number"&&k("Received an unexpected object in getComponentName(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case r.Fragment:return"Fragment";case s:return"Portal";case d:return"Profiler";case u:return"StrictMode";case b:return"Suspense";case S:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case f:var o=e;return _(o)+".Consumer";case l:var a=e;return _(a._context)+".Provider";case h:return T(e,e.render,"ForwardRef");case v:return K(e.type);case L:return K(e._render);case N:{var g=e,O=g._payload,P=g._init;try{return K(P(O))}catch{return null}}}return null}var ne=0,Re,_e,we,Ie,Te,Oe,Pe;function Ne(){}Ne.__reactDisabledLog=!0;function lt(){{if(ne===0){Re=console.log,_e=console.info,we=console.warn,Ie=console.error,Te=console.group,Oe=console.groupCollapsed,Pe=console.groupEnd;var e={configurable:!0,enumerable:!0,value:Ne,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}ne++}}function ut(){{if(ne--,ne===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:t({},e,{value:Re}),info:t({},e,{value:_e}),warn:t({},e,{value:we}),error:t({},e,{value:Ie}),group:t({},e,{value:Te}),groupCollapsed:t({},e,{value:Oe}),groupEnd:t({},e,{value:Pe})})}ne<0&&k("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ce=F.ReactCurrentDispatcher,de;function oe(e,o,a){{if(de===void 0)try{throw Error()}catch(O){var g=O.stack.trim().match(/\n( *(at )?)/);de=g&&g[1]||""}return`
|
|
20
|
+
`+de+e}}var fe=!1,ae;{var ct=typeof WeakMap=="function"?WeakMap:Map;ae=new ct}function je(e,o){if(!e||fe)return"";{var a=ae.get(e);if(a!==void 0)return a}var g;fe=!0;var O=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var P;P=ce.current,ce.current=null,lt();try{if(o){var y=function(){throw Error()};if(Object.defineProperty(y.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(y,[])}catch(Z){g=Z}Reflect.construct(e,[],y)}else{try{y.call()}catch(Z){g=Z}e.call(y.prototype)}}else{try{throw Error()}catch(Z){g=Z}e()}}catch(Z){if(Z&&g&&typeof Z.stack=="string"){for(var C=Z.stack.split(`
|
|
21
21
|
`),Y=g.stack.split(`
|
|
22
22
|
`),D=C.length-1,$=Y.length-1;D>=1&&$>=0&&C[D]!==Y[$];)$--;for(;D>=1&&$>=0;D--,$--)if(C[D]!==Y[$]){if(D!==1||$!==1)do if(D--,$--,$<0||C[D]!==Y[$]){var G=`
|
|
23
|
-
`+C[D].replace(" at new "," at ");return typeof e=="function"&&
|
|
23
|
+
`+C[D].replace(" at new "," at ");return typeof e=="function"&&ae.set(e,G),G}while(D>=1&&$>=0);break}}}finally{fe=!1,ce.current=P,ut(),Error.prepareStackTrace=O}var ee=e?e.displayName||e.name:"",Ue=ee?oe(ee):"";return typeof e=="function"&&ae.set(e,Ue),Ue}function Ae(e,o,a){return je(e,!1)}function dt(e){var o=e.prototype;return!!(o&&o.isReactComponent)}function se(e,o,a){if(e==null)return"";if(typeof e=="function")return je(e,dt(e));if(typeof e=="string")return oe(e);switch(e){case b:return oe("Suspense");case S:return oe("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case h:return Ae(e.render);case v:return se(e.type,o,a);case L:return Ae(e._render);case N:{var g=e,O=g._payload,P=g._init;try{return se(P(O),o,a)}catch{}}}return""}var Le={},ke=F.ReactDebugCurrentFrame;function le(e){if(e){var o=e._owner,a=se(e.type,e._source,o?o.type:null);ke.setExtraStackFrame(a)}else ke.setExtraStackFrame(null)}function ft(e,o,a,g,O){{var P=Function.call.bind(Object.prototype.hasOwnProperty);for(var y in e)if(P(e,y)){var C=void 0;try{if(typeof e[y]!="function"){var Y=Error((g||"React class")+": "+a+" type `"+y+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[y]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw Y.name="Invariant Violation",Y}C=e[y](o,y,g,a,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(D){C=D}C&&!(C instanceof Error)&&(le(O),k("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",g||"React class",a,y,typeof C),le(null)),C instanceof Error&&!(C.message in Le)&&(Le[C.message]=!0,le(O),k("Failed %s type: %s",a,C.message),le(null))}}}var re=F.ReactCurrentOwner,ge=Object.prototype.hasOwnProperty,gt={key:!0,ref:!0,__self:!0,__source:!0},De,$e,me;me={};function mt(e){if(ge.call(e,"ref")){var o=Object.getOwnPropertyDescriptor(e,"ref").get;if(o&&o.isReactWarning)return!1}return e.ref!==void 0}function pt(e){if(ge.call(e,"key")){var o=Object.getOwnPropertyDescriptor(e,"key").get;if(o&&o.isReactWarning)return!1}return e.key!==void 0}function vt(e,o){if(typeof e.ref=="string"&&re.current&&o&&re.current.stateNode!==o){var a=K(re.current.type);me[a]||(k('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',K(re.current.type),e.ref),me[a]=!0)}}function ht(e,o){{var a=function(){De||(De=!0,k("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",o))};a.isReactWarning=!0,Object.defineProperty(e,"key",{get:a,configurable:!0})}}function bt(e,o){{var a=function(){$e||($e=!0,k("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",o))};a.isReactWarning=!0,Object.defineProperty(e,"ref",{get:a,configurable:!0})}}var Ct=function(e,o,a,g,O,P,y){var C={$$typeof:i,type:e,key:o,ref:a,props:y,_owner:P};return C._store={},Object.defineProperty(C._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(C,"_self",{configurable:!1,enumerable:!1,writable:!1,value:g}),Object.defineProperty(C,"_source",{configurable:!1,enumerable:!1,writable:!1,value:O}),Object.freeze&&(Object.freeze(C.props),Object.freeze(C)),C};function Et(e,o,a,g,O){{var P,y={},C=null,Y=null;a!==void 0&&(C=""+a),pt(o)&&(C=""+o.key),mt(o)&&(Y=o.ref,vt(o,O));for(P in o)ge.call(o,P)&&!gt.hasOwnProperty(P)&&(y[P]=o[P]);if(e&&e.defaultProps){var D=e.defaultProps;for(P in D)y[P]===void 0&&(y[P]=D[P])}if(C||Y){var $=typeof e=="function"?e.displayName||e.name||"Unknown":e;C&&ht(y,$),Y&&bt(y,$)}return Ct(e,C,Y,O,g,re.current,y)}}var pe=F.ReactCurrentOwner,Me=F.ReactDebugCurrentFrame;function Q(e){if(e){var o=e._owner,a=se(e.type,e._source,o?o.type:null);Me.setExtraStackFrame(a)}else Me.setExtraStackFrame(null)}var ve;ve=!1;function he(e){return typeof e=="object"&&e!==null&&e.$$typeof===i}function Fe(){{if(pe.current){var e=K(pe.current.type);if(e)return`
|
|
24
24
|
|
|
25
|
-
Check the render method of \``+e+"`."}return""}}function
|
|
25
|
+
Check the render method of \``+e+"`."}return""}}function yt(e){{if(e!==void 0){var o=e.fileName.replace(/^.*[\\\/]/,""),a=e.lineNumber;return`
|
|
26
26
|
|
|
27
|
-
Check your code at `+o+":"+
|
|
27
|
+
Check your code at `+o+":"+a+"."}return""}}var We={};function xt(e){{var o=Fe();if(!o){var a=typeof e=="string"?e:e.displayName||e.name;a&&(o=`
|
|
28
28
|
|
|
29
|
-
Check the top-level render call using <`+
|
|
29
|
+
Check the top-level render call using <`+a+">.")}return o}}function qe(e,o){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var a=xt(o);if(We[a])return;We[a]=!0;var g="";e&&e._owner&&e._owner!==pe.current&&(g=" It was passed a child from "+K(e._owner.type)+"."),Q(e),k('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',a,g),Q(null)}}function Ke(e,o){{if(typeof e!="object")return;if(Array.isArray(e))for(var a=0;a<e.length;a++){var g=e[a];he(g)&&qe(g,o)}else if(he(e))e._store&&(e._store.validated=!0);else if(e){var O=q(e);if(typeof O=="function"&&O!==e.entries)for(var P=O.call(e),y;!(y=P.next()).done;)he(y.value)&&qe(y.value,o)}}}function St(e){{var o=e.type;if(o==null||typeof o=="string")return;var a;if(typeof o=="function")a=o.propTypes;else if(typeof o=="object"&&(o.$$typeof===h||o.$$typeof===v))a=o.propTypes;else return;if(a){var g=K(o);ft(a,e.props,"prop",g,e)}else if(o.PropTypes!==void 0&&!ve){ve=!0;var O=K(o);k("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",O||"Unknown")}typeof o.getDefaultProps=="function"&&!o.getDefaultProps.isReactClassApproved&&k("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Rt(e){{for(var o=Object.keys(e.props),a=0;a<o.length;a++){var g=o[a];if(g!=="children"&&g!=="key"){Q(e),k("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",g),Q(null);break}}e.ref!==null&&(Q(e),k("Invalid attribute `ref` supplied to `React.Fragment`."),Q(null))}}function Ye(e,o,a,g,O,P){{var y=x(e);if(!y){var C="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(C+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var Y=yt(O);Y?C+=Y:C+=Fe();var D;e===null?D="null":Array.isArray(e)?D="array":e!==void 0&&e.$$typeof===i?(D="<"+(K(e.type)||"Unknown")+" />",C=" Did you accidentally export a JSX literal instead of a component?"):D=typeof e,k("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",D,C)}var $=Et(e,o,a,O,P);if($==null)return $;if(y){var G=o.children;if(G!==void 0)if(g)if(Array.isArray(G)){for(var ee=0;ee<G.length;ee++)Ke(G[ee],e);Object.freeze&&Object.freeze(G)}else k("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Ke(G,e)}return e===r.Fragment?Rt($):St($),$}}function _t(e,o,a){return Ye(e,o,a,!0)}function wt(e,o,a){return Ye(e,o,a,!1)}var It=wt,Tt=_t;r.jsx=It,r.jsxs=Tt}()}(Ce)),Ce}process.env.NODE_ENV==="production"?Ee.exports=jt():Ee.exports=At();var A=Ee.exports;class Lt extends xe.WebSocketMessageReader{constructor(t,i){super(t);V(this,"onMessage");this.onMessage=i}readMessage(t){this.onMessage&&this.onMessage();const[,i]=t.split(`\r
|
|
30
30
|
\r
|
|
31
|
-
`);if(this.state==="initial")this.events.splice(0,0,{message:i});else if(this.state==="listening"){const
|
|
31
|
+
`);if(this.state==="initial")this.events.splice(0,0,{message:i});else if(this.state==="listening"){const s=JSON.parse(i);this.callback(s)}}}class kt extends xe.WebSocketMessageWriter{constructor(t,i){super(t);V(this,"onSend");this.onSend=i}async write(t){try{const i=JSON.stringify(t);this.socket.send(i),this.onSend&&this.onSend()}catch(i){this.errorCount++,this.fireError(i,t,this.errorCount)}}}const Dt={base:"vs-dark",inherit:!0,colors:{"editor.background":"#313131"},rules:[{token:"",background:"#313131"}]};function z(r){return`file:///PACKAGE/Project/Sources/${r}`}function Se(r,n=0){setTimeout(r,n)}function Qe(r,n){const t=new W.Selection(n.startLineNumber,n.startColumn,n.endLineNumber||n.startLineNumber,n.endColumn||n.startColumn);Se(()=>{r.setSelection(t),r.revealRangeInCenter(t),r.focus()})}function et(r,n,t=0){t>0&&(n=t+n),Se(()=>{r.setPosition({lineNumber:n,column:1}),r.revealLineInCenter(n),r.focus()})}function $t(r,n,t){const s=r.getModel();if(s&&n){const u=s.getLineCount();for(let d=1;d<=u;d++){const l=s.getLineContent(d);if(new RegExp(`(?:Function|function) ${t}`).test(l))return d}}return 0}const Mt={getServiceOverride:({openHandler:r})=>({get[H.ICodeEditorService.toString()](){const n=H.StandaloneServices.get(H.ICodeEditorService);return r&&n.registerCodeEditorOpenHandler(r),n}})},Ft={getServiceOverride:()=>({get[H.ILanguageFeaturesService.toString()](){return H.StandaloneServices.get(H.ILanguageFeaturesService)}})},Wt={getServiceOverride:()=>({get[H.ITextModelService.toString()](){const r=H.StandaloneServices.get(H.ITextModelService);return r.createModelReference=n=>Promise.resolve({dispose:()=>{}}),r}})},qt={comments:{lineComment:"//",blockComment:["/**","**/"]},brackets:[["{","}"],["(",")"],["[","]"]],surroundingPairs:[{open:"{",close:"}"},{open:"[",close:"]"},{open:"(",close:")"},{open:'"',close:'"'},{open:"'",close:"'"}],autoClosingPairs:[{open:"(",close:")"},{open:"{",close:"}"},{open:"[",close:"]"},{open:"'",close:"'",notIn:["string","comment"]},{open:'"',close:'"',notIn:["string"]},{open:"`",close:"`",notIn:["string","comment"]},{open:"/**",close:" **/",notIn:["string"]}],autoCloseBefore:";:.,=}])>` \n ",wordPattern:new RegExp("(-?\\d*\\.\\d\\w*)|([^\\`\\~\\!\\@\\#\\%\\^\\&\\*\\(\\)\\-\\=\\+\\[\\{\\]\\}\\\\\\|\\;\\:\\'\\\"\\,\\.\\<\\>\\/\\?\\r\\n\\t\\f\\v ]+)|(?<=[a-zA-Z]) ?(?=[a-zA-Z])"),indentationRules:{increaseIndentPattern:new RegExp("(^(?![^\\s])*\\s*(class constructor))|(^(?![^\\s])*\\s*(exposed|local|\\s*){1}\\s*function{1}\\s*\\w)|(^(?![^\\s])*\\s*(If|Else|For|For each|While|Begin SQL|Case of|Use|Repeat|: *\\(.*)).*$","i"),decreaseIndentPattern:new RegExp("(^(?![^\\s])*\\s*(exposed|local|\\s*){1}\\s*function{1}\\s*\\w)|(End If|End For|Else|End for each|End While|End SQL|End case|End use|Until|: *\\(.*).*$","i")},onEnterRules:[{beforeText:new RegExp("^exposed","i"),action:{indentAction:1}}]},Kt={provideCompletionItems:async(r,n)=>{const t=r.getWordUntilPosition(n);return{suggestions:[{label:"var",kind:c.languages.CompletionItemKind.Snippet,range:new c.Range(n.lineNumber,t.startColumn,n.lineNumber,t.endColumn),insertText:["var ${1:var_name} : ${2:var_type}"].join(`
|
|
32
32
|
`),insertTextRules:c.languages.CompletionItemInsertTextRule.InsertAsSnippet},{label:"While",kind:c.languages.CompletionItemKind.Snippet,range:new c.Range(n.lineNumber,t.startColumn,n.lineNumber,t.endColumn),insertText:["While(${1:expression})"," ${2:body}","End while"].join(`
|
|
33
33
|
`),insertTextRules:c.languages.CompletionItemInsertTextRule.InsertAsSnippet},{label:"Case of",kind:c.languages.CompletionItemKind.Snippet,range:new c.Range(n.lineNumber,t.startColumn,n.lineNumber,t.endColumn),insertText:["Case of"," :(${1:boolean_expression})"," ${2:body}","End case"].join(`
|
|
34
34
|
`),insertTextRules:c.languages.CompletionItemInsertTextRule.InsertAsSnippet},{label:"Else",kind:c.languages.CompletionItemKind.Snippet,range:new c.Range(n.lineNumber,t.startColumn,n.lineNumber,t.endColumn),insertText:["Else"," "].join(`
|
|
@@ -42,11 +42,11 @@ Check the top-level render call using <`+s+">.")}return o}}function qe(e,o){{if(
|
|
|
42
42
|
`),insertTextRules:c.languages.CompletionItemInsertTextRule.InsertAsSnippet},{label:"if",kind:c.languages.CompletionItemKind.Snippet,range:new c.Range(n.lineNumber,t.startColumn,n.lineNumber,t.endColumn),insertText:["if (${1:expression})"," ${5:body}","end"].join(`
|
|
43
43
|
`),insertTextRules:c.languages.CompletionItemInsertTextRule.InsertAsSnippet},{label:"for",kind:c.languages.CompletionItemKind.Snippet,range:new c.Range(n.lineNumber,t.startColumn,n.lineNumber,t.endColumn),insertText:["for(${1:counter},${2:start},${3:end}${4:,increment})"," ${5:body}","end"].join(`
|
|
44
44
|
`),insertTextRules:c.languages.CompletionItemInsertTextRule.InsertAsSnippet},{label:"function",kind:c.languages.CompletionItemKind.Snippet,range:new c.Range(n.lineNumber,t.startColumn,n.lineNumber,t.endColumn),insertText:["function ${1:function_name}(${2:params}) -> ${3:var_name} : ${4:var_type}"," ${5:body}"].join(`
|
|
45
|
-
`),insertTextRules:c.languages.CompletionItemInsertTextRule.InsertAsSnippet}]}}},Ut=[{keybinding:W.KeyMod.CtrlCmd|W.KeyCode.NumpadAdd,command:"editor.action.fontZoomIn"},{keybinding:W.KeyMod.CtrlCmd|W.KeyCode.Equal,command:"editor.action.fontZoomIn"},{keybinding:W.KeyMod.CtrlCmd|W.KeyCode.NumpadSubtract,command:"editor.action.fontZoomOut"},{keybinding:W.KeyMod.CtrlCmd|W.KeyCode.Minus,command:"editor.action.fontZoomOut"},{keybinding:W.KeyMod.CtrlCmd|W.KeyCode.Numpad0,command:"editor.action.fontZoomReset"},{keybinding:W.KeyMod.CtrlCmd|W.KeyCode.Digit0,command:"editor.action.fontZoomReset"}],Vt=({defaultZoom:r})=>(w.useEffect(()=>{r!==void 0&&W.editor.EditorZoom.setZoomLevel(r)},[]),null);({}).VITE_DISABLE_MONACO_LOADER||
|
|
46
|
-
`),insertTextRules:c.languages.CompletionItemInsertTextRule.InsertAsSnippet}]}}},en="#/definitions/Condition",tn={Base:{type:"object",properties:{id:{type:"string"},name:{type:"string"}},required:["id"]},Condition:{oneOf:[{$ref:"#/definitions/Datasource"},{$ref:"#/definitions/Privilege"},{$ref:"#/definitions/Combination"},{$ref:"#/definitions/ParentState"},{$ref:"#/definitions/Reference"}]},Datasource:{allOf:[{$ref:"#/definitions/Base"}],properties:{type:{const:"datasource"},path:{type:"string"},value:{type:["number","string","boolean","object","array","null"]},valueType:{enum:["datasource","hardCoded"]},dataType:{enum:["string","number","date","boolean","array","object"]},op:{enum:["eq","neq","regex","in","nin","gt","gte","lt","lte"]}},required:["name","type","path","value","op"]},Privilege:{allOf:[{$ref:"#/definitions/Base"}],properties:{type:{const:"privilege"},value:{type:"string"},valueType:{enum:["datasource","hardCoded"]},
|
|
45
|
+
`),insertTextRules:c.languages.CompletionItemInsertTextRule.InsertAsSnippet}]}}},Ut=[{keybinding:W.KeyMod.CtrlCmd|W.KeyCode.NumpadAdd,command:"editor.action.fontZoomIn"},{keybinding:W.KeyMod.CtrlCmd|W.KeyCode.Equal,command:"editor.action.fontZoomIn"},{keybinding:W.KeyMod.CtrlCmd|W.KeyCode.NumpadSubtract,command:"editor.action.fontZoomOut"},{keybinding:W.KeyMod.CtrlCmd|W.KeyCode.Minus,command:"editor.action.fontZoomOut"},{keybinding:W.KeyMod.CtrlCmd|W.KeyCode.Numpad0,command:"editor.action.fontZoomReset"},{keybinding:W.KeyMod.CtrlCmd|W.KeyCode.Digit0,command:"editor.action.fontZoomReset"}],Vt=({defaultZoom:r})=>(w.useEffect(()=>{r!==void 0&&W.editor.EditorZoom.setZoomLevel(r)},[]),null);({}).VITE_DISABLE_MONACO_LOADER||ye.loader.config({monaco:c});const tt=w.createContext(void 0),Bt=({children:r,url:n,qodly:t,defaultZoom:i,openHandler:s,language:u="4d",defaultInited:d=!1})=>{const l=ye.useMonaco(),[f,h]=w.useState(d),[b,S]=w.useState(null),v=w.useRef(),N=w.useRef(0);w.useEffect(()=>{Ve.initServices({configureEditorOrViewsService:{enableViewsService:!1},debugLogging:!1,userServices:{...Mt.getServiceOverride({openHandler:s}),...Ft.getServiceOverride(),...Wt.getServiceOverride()}})},[]),w.useEffect(()=>{n&&l&&L()},[n,l]);const L=async()=>{if(!l)return;const x=await B.getMonacoTheme();l.editor.defineTheme("fd-dark",x||Dt),l.languages.register({id:u,extensions:[".4dm",".4qm",".4qs"],aliases:["4d","4D"]}),l.languages.setLanguageConfiguration(u,qt),l.languages.registerCompletionItemProvider(u,t?Yt:Kt),W.editor.addKeybindingRules(Ut),j()},j=()=>{S(null);let x;try{x=new WebSocket(localStorage.LSP_SERVER||n)}catch{S(new Event("INVALID_URL"));return}x.onopen=M,x.onclose=I,x.onerror=E,N.current=0},M=async function(){const x=xe.toSocket(this),T=new Lt(x),_=new kt(x),K=new Ve.MonacoLanguageClient({name:"4D Language Client",clientOptions:{workspaceFolder:{uri:W.Uri.parse("file:///PACKAGE")},documentSelector:[{scheme:"file",language:u}],errorHandler:{error:()=>({action:Be.ErrorAction.Continue}),closed:()=>({action:Be.CloseAction.DoNotRestart})}},connectionProvider:{get:()=>Promise.resolve({reader:T,writer:_})}});v.current=K,T.onClose(()=>{K.stop(),N.current<3?setTimeout(()=>{N.current++,j()},1e3):S(new Event("WEBSOCKET_CLOSED"))}),K.needsStart()&&await K.start(),h(!0)},I=()=>{},E=x=>{S(x)};w.useEffect(()=>{const x=B.lspSubject.subscribe(({action:T,payload:_})=>{switch(T){case B.LspActions.WILL_SAVE:R(_.filePath);break;case B.LspActions.DID_SAVE:m(_.filePath,_.content);break;case B.LspActions.WILL_CREATE:p(_.filePath);break;case B.LspActions.DID_CREATE:k(_.filePath);break;case B.LspActions.WILL_RENAME:q(_.oldPath,_.newPath);break;case B.LspActions.DID_RENAME:U(_.oldPath,_.newPath);break;case B.LspActions.WILL_DELETE:F(_.filePath);break;case B.LspActions.DID_DELETE:ue(_.filePath);break}});return()=>x.unsubscribe()},[]);const R=(x,T=J.TextDocumentSaveReason.Manual)=>{var _;(_=v.current)==null||_.sendNotification(J.WillSaveTextDocumentNotification.type,{textDocument:{uri:z(x)},reason:T})},m=(x,T)=>{var _;(_=v.current)==null||_.sendNotification(J.DidSaveTextDocumentNotification.type,{textDocument:{uri:z(x)},text:T})},p=x=>{var T;(T=v.current)==null||T.sendRequest(J.WillCreateFilesRequest.type,{files:[{uri:z(x)}]})},q=(x,T)=>{var _;(_=v.current)==null||_.sendRequest(J.WillRenameFilesRequest.type,{files:[{oldUri:z(x),newUri:z(T)}]})},F=x=>{var T;(T=v.current)==null||T.sendRequest(J.WillDeleteFilesRequest.type,{files:[{uri:z(x)}]})},k=x=>{var T;(T=v.current)==null||T.sendNotification(J.DidCreateFilesNotification.type,{files:[{uri:z(x)}]})},U=(x,T)=>{var _;(_=v.current)==null||_.sendNotification(J.DidRenameFilesNotification.type,{files:[{oldUri:z(x),newUri:z(T)}]})},ue=x=>{var T;(T=v.current)==null||T.sendNotification(J.DidDeleteFilesNotification.type,{files:[{uri:z(x)}]})};return A.jsxs(tt.Provider,{value:{inited:f||!!b,clientRef:v,lastError:b,reload:j},children:[r,A.jsx(Vt,{defaultZoom:i})]})};function zt(){const r=w.useContext(tt);if(r===void 0)throw new Error("useLSP must be used within an LSPContext");return r}const nt=w.createContext(void 0),Gt=w.memo(({children:r})=>{const[n,t]=w.useState(null);return A.jsx(nt.Provider,{value:{editor:n,setEditor:t},children:r})});function rt(){const r=w.useContext(nt),n=w.useState(null);if(r===void 0){const[t,i]=n;return{editor:t,setEditor:i}}return r}var it={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Je=w.createContext&&w.createContext(it),X=globalThis&&globalThis.__assign||function(){return X=Object.assign||function(r){for(var n,t=1,i=arguments.length;t<i;t++){n=arguments[t];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(r[s]=n[s])}return r},X.apply(this,arguments)},Zt=globalThis&&globalThis.__rest||function(r,n){var t={};for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&n.indexOf(i)<0&&(t[i]=r[i]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,i=Object.getOwnPropertySymbols(r);s<i.length;s++)n.indexOf(i[s])<0&&Object.prototype.propertyIsEnumerable.call(r,i[s])&&(t[i[s]]=r[i[s]]);return t};function ot(r){return r&&r.map(function(n,t){return w.createElement(n.tag,X({key:t},n.attr),ot(n.child))})}function at(r){return function(n){return w.createElement(Jt,X({attr:X({},r.attr)},n),ot(r.child))}}function Jt(r){var n=function(t){var i=r.attr,s=r.size,u=r.title,d=Zt(r,["attr","size","title"]),l=s||t.size||"1em",f;return t.className&&(f=t.className),r.className&&(f=(f?f+" ":"")+r.className),w.createElement("svg",X({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},t.attr,i,d,{className:f,style:X(X({color:r.color||t.color},t.style),r.style),height:l,width:l,xmlns:"http://www.w3.org/2000/svg"}),u&&w.createElement("title",null,u),r.children)};return Je!==void 0?w.createElement(Je.Consumer,null,function(t){return n(t)}):n(it)}function Ht(r){return at({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22ZM12 10.5858L9.17157 7.75736L7.75736 9.17157L10.5858 12L7.75736 14.8284L9.17157 16.2426L12 13.4142L14.8284 16.2426L16.2426 14.8284L13.4142 12L16.2426 9.17157L14.8284 7.75736L12 10.5858Z"}}]})(r)}function Xt(r){return at({tag:"svg",attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M449.07 399.08L278.64 82.58c-12.08-22.44-44.26-22.44-56.35 0L51.87 399.08A32 32 0 0080 446.25h340.89a32 32 0 0028.18-47.17zm-198.6-1.83a20 20 0 1120-20 20 20 0 01-20 20zm21.72-201.15l-5.74 122a16 16 0 01-32 0l-5.74-121.95a21.73 21.73 0 0121.5-22.69h.21a21.74 21.74 0 0121.73 22.7z"}}]})(r)}const st=({lspProps:{lastError:r,reload:n}})=>{const[t,i]=w.useState(!1),s=()=>{n()},u=()=>{i(!1)};return w.useEffect(()=>{i(!!r)},[r]),t?A.jsxs("div",{className:"flex items-center border-b border-fd-gray-darker bg-grey-800 px-2 py-1.5 text-xs text-grey-50",children:[A.jsxs("span",{className:"flex flex-1 justify-center gap-1",children:[A.jsx(Xt,{className:"h-4 w-4 text-yellow-600"}),A.jsxs("span",{children:["LSP not loaded."," ",A.jsx("button",{className:"text-primary-dark underline",onClick:s,children:"Reload?"})]})]}),A.jsx("button",{className:"focus:outline-none",children:A.jsx(Ht,{className:"h-4 w-4 text-white",onClick:u})})]}):null},Qt={provideCompletionItems:(r,n)=>{const t=r.getWordUntilPosition(n);return{suggestions:[{label:"device:xs",kind:c.languages.CompletionItemKind.Snippet,documentation:"Media query for phone device",range:new c.Range(n.lineNumber,t.startColumn,n.lineNumber,t.endColumn),insertText:["@media screen and (max-width: ${1:365px}) {"," self {"," ${2:background-color}:${3:red};"," }","}"].join(`
|
|
46
|
+
`),insertTextRules:c.languages.CompletionItemInsertTextRule.InsertAsSnippet}]}}},en="#/definitions/Condition",tn={Base:{type:"object",properties:{id:{type:"string"},name:{type:"string"}},required:["id"]},Condition:{oneOf:[{$ref:"#/definitions/Datasource"},{$ref:"#/definitions/Privilege"},{$ref:"#/definitions/Combination"},{$ref:"#/definitions/CurrentState"},{$ref:"#/definitions/ParentState"},{$ref:"#/definitions/Reference"}]},Datasource:{allOf:[{$ref:"#/definitions/Base"}],properties:{type:{const:"datasource"},path:{type:"string"},value:{type:["number","string","boolean","object","array","null"]},valueType:{enum:["datasource","hardCoded"]},dataType:{enum:["string","number","date","boolean","array","object"]},op:{enum:["eq","neq","regex","in","nin","gt","gte","lt","lte"]}},required:["name","type","path","value","op"]},Privilege:{allOf:[{$ref:"#/definitions/Base"}],properties:{type:{const:"privilege"},value:{type:"string"},valueType:{enum:["datasource","hardCoded"]},op:{enum:["eq","neq","regex"]}},required:["name","type","value","op"]},Combination:{allOf:[{$ref:"#/definitions/Base"}],properties:{type:{const:"combination"},op:{enum:["and","or"]},conditions:{type:"array",items:{$ref:"#/definitions/Condition"}}},required:["type","conditions","op"]},CurrentState:{allOf:[{$ref:"#/definitions/Base"}],properties:{type:{const:"currentState"},value:{type:"string"},valueType:{enum:["datasource","hardCoded"]},dataType:{enum:["string","number","date","boolean","array","object"]},op:{enum:["eq","neq","regex","in","nin"]}},required:["name","type","value","op"]},ParentState:{allOf:[{$ref:"#/definitions/Base"}],properties:{type:{const:"parentState"},value:{type:"string"},valueType:{enum:["datasource","hardCoded"]},dataType:{enum:["string","number","date","boolean","array","object"]},op:{enum:["eq","neq","regex","in","nin"]}},required:["name","type","value","op"]},Reference:{allOf:[{$ref:"#/definitions/Base"}],properties:{type:{const:"reference"},ref:{type:"string"}},required:["type","ref"]}},nn={$ref:en,definitions:tn};function rn(r,n){const t=document.createElement("style");t.dataset.id=n,t.textContent=r,document.head.append(t)}function on(r){return Array.from(document.styleSheets).find(n=>n.ownerNode.getAttribute("data-id")===r)}function an(r,n){const t=[];let i=[];const s=[],u=(m,p,q,F)=>{t.push({startLineNumber:m,endLineNumber:q,startColumn:p,endColumn:F}),h(),f()},d=m=>{s.indexOf(m)<0&&s.push(m)},l=m=>{const p=s.indexOf(m);p<0||s.splice(p,1)},f=()=>{for(const m of s)try{m(i)}catch(p){console.error(p)}},h=()=>{const m=r.getModel();m&&(i=ln(t.map(p=>[m.getOffsetAt({lineNumber:p.startLineNumber,column:p.startColumn}),m.getOffsetAt({lineNumber:p.endLineNumber,column:p.endColumn})]),!0),i.length>0&&(i[0][0]<=0&&(i[0][0]=Number.NEGATIVE_INFINITY),i[i.length-1][1]>=m.getValueLength()&&(i[i.length-1][1]=Number.POSITIVE_INFINITY)))},b=m=>{const p={isDeletion:!1,isAddition:!1,isReplacement:!1};return m.text===""?p.isDeletion=!0:m.range.startLineNumber===m.range.endLineNumber&&m.range.startColumn===m.range.endColumn?p.isAddition=!0:p.isReplacement=!0,p},S=r.onDidChangeModel(m=>{h(),E()}),v=r.onDidChangeModelContent(m=>{if(!m.isUndoing)for(const p of m.changes){const q=b(p);if(q.isReplacement||q.isDeletion||q.isAddition){const F=t.some(U=>p.range.startLineNumber>=U.startLineNumber&&p.range.endLineNumber<=U.endLineNumber&&p.range.startColumn>=U.startColumn&&p.range.endColumn<=U.endColumn),k=!F&&n&&p.range.startLineNumber===1&&p.range.startColumn===1&&!B.hasAttributesString(p.text);if(F||k){const U=r.getModel();if(U){U.undo();return}}}}}),N=()=>{S.dispose(),v.dispose()};let L=[],j=`
|
|
47
47
|
.idoc-readonly-mark {
|
|
48
48
|
cursor: not-allowed;
|
|
49
49
|
z-index: 1;
|
|
50
50
|
}
|
|
51
|
-
`;if(j){const m="monaco-read-only";on(m)||rn(j,m),j=null}const M=()=>{d(E),E()},I=()=>{l(E),L=r.deltaDecorations(L,[])},E=()=>{const m=r.getModel();m&&(L=r.deltaDecorations(L,i.map(
|
|
51
|
+
`;if(j){const m="monaco-read-only";on(m)||rn(j,m),j=null}const M=()=>{d(E),E()},I=()=>{l(E),L=r.deltaDecorations(L,[])},E=()=>{const m=r.getModel();m&&(L=r.deltaDecorations(L,i.map(R(m))))},R=m=>p=>{const q=m.getPositionAt(p[0]),F=m.getPositionAt(p[1]);return{range:new c.Range(q.lineNumber,q.column,F.lineNumber,F.column),options:{className:"idoc-readonly-mark"}}};return{get buffer(){return i},exclude:u,attach:d,detach:l,dispose:N,show:M,hide:I}}function sn(r,n,t){let i=!1;const s=I=>I[1]<I[0]?(i=!0,[[I[1],I[0]]]):[[...I]],u=I=>i?I.map(E=>E[1]>E[0]?l(E):E).reverse():I;let d;const l=I=>(d=I[1],I[1]=I[0],I[0]=d,I),f=s(r);let h,b,S,v,N,L,j,M;S=f[0];for(b of n)for(j=b[0],M=b[1],v=0;v<f.length;v++){if(S=f[v],N=S[0],L=S[1],N<j)L<j?h=[S]:L<=M?h=[[N,j-1]]:h=[[N,j-1],[M+1,L]];else if(N<=M)if(j===Number.NEGATIVE_INFINITY){const I=M+1;h=t===0?[]:[[I,L>I?L:I]]}else M===Number.POSITIVE_INFINITY?h=t===0?[]:[[j-1,j-1]]:L<=M?h=t<0?[[j-1,j-1]]:t>0?[[M+1,M+1]]:[]:h=[[M+1,L]];else h=[S];if(f.splice(v,1,...h),f.length===1&&f[0][1]<j)return u(f)}return u(f)}function ln(r,n){if(r.length<2)return r;const t=[];let i=null,s,u;r=r.map(d=>(d[1]<d[0]&&(s=d[1],d[1]=d[0],d[1]=s),d)).sort((d,l)=>d[0]-l[0]),t.push(r[0]);for(let d=1;d<r.length;d++)i=t[t.length-1],u=r[d],i[1]===u[0]&&!n?t.push(u):i[1]===u[0]-1&&n?(i[1]=u[1],t.splice(t.length-1,1,i)):i[1]<u[0]?t.push(u):i[1]<u[1]&&(i[1]=u[1],t.splice(t.length-1,1,i));return t}function ie(r,n){return n.bind(r)}class un{constructor(n,t){V(this,"editor");V(this,"intervals");V(this,"disposables",[]);V(this,"prefer",1);V(this,"lastPrefer",1);V(this,"onCursor",ie(this,function(n){if(n.source==="api")return;const t=this.getApprovedSelections();t.length!==0&&this.editor.setSelections(t)}));V(this,"onRectangleSelectionStart",ie(this,function({event:n}){n.middleButton&&(this.lastPrefer=this.prefer,this.prefer=0,window.addEventListener("pointerup",this.onRectangleSelectionStop))}));V(this,"onRectangleSelectionStop",ie(this,function(){this.prefer=this.lastPrefer,window.removeEventListener("pointerup",this.onRectangleSelectionStop)}));V(this,"onKey",ie(this,function(n){const t=n.keyCode,i=c.KeyCode;if(n.altKey||i.F1<=t&&t<=i.F19||n.ctrlKey&&t!==i.Backspace)return;if(t===i.UpArrow||t===i.LeftArrow||t===i.Home||t===i.PageUp){this.prefer=-1;return}if(t===i.DownArrow||t===i.RightArrow||t===i.End||t===i.PageDown){this.prefer=1;return}const s=this.getSelections(),u=this.intervals.buffer;let d;if(t===i.Delete)d=l=>l[0]===l[1]&&u.find(f=>l[1]+1===f[0])!=null;else if(t===i.Backspace)d=l=>l[0]===l[1]&&u.find(f=>f[1]+1===l[0])!=null;else return;s.findIndex(d)!==-1&&(n.stopPropagation(),n.preventDefault())}));V(this,"getOffsetAt",ie(this,function(n){let t;for(let i=0;i<this.intervals.buffer.length;i++)if(t=this.intervals.buffer[i],n<=t[1])return t[0]-n<n-t[1]?t[0]:t[1]}));var i;this.editor=n,this.intervals=an(n,t),(i=this.editor.getModel())==null||i.setEOL(c.editor.EndOfLineSequence.LF)}enable(){this.disposables.push(this.editor.onDidChangeCursorPosition(this.onCursor),this.editor.onKeyDown(this.onKey),this.editor.onMouseDown(this.onRectangleSelectionStart)),this.intervals.show()}dispose(){for(const n of this.disposables)n.dispose();this.disposables.splice(0)}exclude(n,t,i,s){arguments.length===1?this.intervals.exclude(n,0,n,Number.MAX_SAFE_INTEGER):this.intervals.exclude(n,t,i,s)}getApprovedSelections(){const n=this.editor.getModel();return this.getSelections().map(i=>sn(i,this.intervals.buffer,this.prefer)).flat().map(i=>{const s=n.getPositionAt(i[0]),u=n.getPositionAt(i[1]);return new c.Selection(s.lineNumber,s.column,u.lineNumber,u.column)})}getSelections(){const n=this.editor.getModel();return(this.editor.getSelections()||[]).map(t=>[n.getOffsetAt({lineNumber:t.selectionStartLineNumber,column:t.selectionStartColumn}),n.getOffsetAt({lineNumber:t.positionLineNumber,column:t.positionColumn})])}}const cn=new RegExp("^[ s]+(exposed|Function)","i"),He=()=>A.jsx("div",{className:"absolute inset-0 animate-pulse",children:A.jsx("div",{className:"w-full space-y-4 px-4 py-1",children:A.jsxs("div",{className:"space-y-2",children:[A.jsx("div",{className:"h-3 w-3/4 rounded bg-grey-200"}),A.jsx("div",{className:"h-3 rounded bg-grey-200"}),A.jsx("div",{className:"h-3 w-5/6 rounded bg-grey-200"}),A.jsx("div",{className:"h-3 rounded bg-grey-200"}),A.jsx("div",{className:"h-3 rounded bg-grey-200"})]})})}),dn=({path:r,initialValue:n,theme:t="fd-dark",type:i,language:s,onChange:u,options:d={},extra:l={},showAlerts:f=!1,lspProps:h,...b})=>{const{initialLineInfo:S,initialSelectionInfo:v}=l,{editor:N,setEditor:L}=rt(),{inited:j}=h;function M(E){s==="css"&&E.languages.registerCompletionItemProvider("css",Qt),s==="json"&&E.languages.json&&E.languages.json.jsonDefaults.setDiagnosticsOptions({validate:!0,schemas:[{uri:"condition-schema.json",fileMatch:["*.condition.json"],schema:nn}]})}function I(E,R){L(E);const m=E.getModel();if(m&&(m.updateOptions({insertSpaces:!1}),E.onKeyUp(()=>{var q;const p=(q=E.getPosition())==null?void 0:q.lineNumber;if(p){const F=m.getLineFirstNonWhitespaceColumn(p),k=m.getLineLength(p),U=m.getLineContent(p);cn.test(U)&&E.executeEdits("edit-handler",[{range:new R.Range(p,0,p,k),text:U.substr(F-1,k-F)}])}})),i===B.FileFolderType.METHOD&&B.hasAttributesString(n)){const p=new un(E,!0);p.exclude(1,1,1,Number.POSITIVE_INFINITY),p.enable()}}return w.useEffect(()=>{if(!N)return;const{line:E,offset:R}=S||{};E&&et(N,E,R)},[S,N]),w.useEffect(()=>{if(!N)return;const{selection:E}=v||{};E&&Qe(N,E)},[v,N]),j?A.jsxs(A.Fragment,{children:[f?A.jsx(st,{lspProps:h}):null,A.jsx(ye.Editor,{options:{readOnly:!0,fontSize:12,"semanticHighlighting.enabled":!0,...d},path:z(r),value:n,theme:"fd-dark",onChange:E=>u&&u(E||""),language:s,beforeMount:M,onMount:I,loading:A.jsx(He,{}),...b})]}):A.jsx(He,{})};exports.Alerts=st;exports.CodeEditor=dn;exports.CodeEditorProvider=Gt;exports.LSPProvider=Bt;exports._await=Se;exports.getFileSystemPath=z;exports.getFunctionOffset=$t;exports.jumpToLine=et;exports.jumpToSelection=Qe;exports.useCodeEditor=rt;exports.useLSP=zt;
|
|
52
52
|
//# sourceMappingURL=index.cjs.js.map
|