@sheetxl/scripting-react 0.7.23-beta.2
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/LICENSE.md +11 -0
- package/README.md +25 -0
- package/browser/cjs/BAh9DnP6CTFXt1HI.cjs +1 -0
- package/browser/cjs/Bf_pmg4C0o1aKVy-.cjs +2 -0
- package/browser/cjs/CsWMPekp2nRo3bHt.cjs +11 -0
- package/browser/cjs/index.cjs +9 -0
- package/browser/esm/79R_LZrdMANq6eyF.mjs +545 -0
- package/browser/esm/C1aR3ISFO7Zp-stK.mjs +17 -0
- package/browser/esm/MBTRgCPV6sAugbR3.mjs +1483 -0
- package/browser/esm/index.mjs +1215 -0
- package/licenses/dependencies.txt +225 -0
- package/node/esm/index.mjs +1323 -0
- package/package.json +62 -0
- package/resources/contents.json +36 -0
- package/resources/locales/contents.json +58 -0
- package/resources/locales/de/groups.cmd.json +21 -0
- package/resources/locales/de/scriptEditor.cmd.json +36 -0
- package/resources/locales/de/ui.msg.json +8 -0
- package/resources/locales/de/workbookScript.cmd.json +26 -0
- package/resources/locales/en/groups.cmd.json +21 -0
- package/resources/locales/en/scriptEditor.cmd.json +36 -0
- package/resources/locales/en/ui.msg.json +8 -0
- package/resources/locales/en/workbookScript.cmd.json +26 -0
- package/types/index.d.ts +2 -0
- package/types/src/IScriptEditor.d.ts +52 -0
- package/types/src/IScriptEditor.d.ts.map +1 -0
- package/types/src/MonacoOptions.d.ts +68 -0
- package/types/src/MonacoOptions.d.ts.map +1 -0
- package/types/src/ScriptEditor.d.ts +73 -0
- package/types/src/ScriptEditor.d.ts.map +1 -0
- package/types/src/ScriptEditorCommands.d.ts +23 -0
- package/types/src/ScriptEditorCommands.d.ts.map +1 -0
- package/types/src/ScriptEditorOpener.d.ts +33 -0
- package/types/src/ScriptEditorOpener.d.ts.map +1 -0
- package/types/src/ScriptingReactPlugin.d.ts +9 -0
- package/types/src/ScriptingReactPlugin.d.ts.map +1 -0
- package/types/src/WorkbookScriptCommands.d.ts +18 -0
- package/types/src/WorkbookScriptCommands.d.ts.map +1 -0
- package/types/src/command-catalog/index.d.ts +3 -0
- package/types/src/command-catalog/index.d.ts.map +1 -0
- package/types/src/index.d.ts +6 -0
- package/types/src/index.d.ts.map +1 -0
- package/types/src/tsMonarchLanguage.d.ts +19 -0
- package/types/src/tsMonarchLanguage.d.ts.map +1 -0
|
@@ -0,0 +1,1215 @@
|
|
|
1
|
+
(function(){try{if(typeof document<`u`){var e=document.createElement(`style`);e.appendChild(document.createTextNode(`._script-editor_1kuph_5{& .monaco-editor{position:absolute;& .margin-icon{background-position:50%;background-repeat:no-repeat;background-size:contain;width:16px;height:16px;display:block}& .formula{cursor:pointer;background-image:url("data:image/svg+xml;utf8,<svg xmlns=\\"http://www.w3.org/2000/svg\\" viewBox=\\"0 0 24 24\\" fill=\\"grey\\"><path d=\\"m 12.106007,8.1692949 c 0.124174,-0.1578352 0.181773,-0.3565642 0.283755,-0.5271169 0.10273,-0.1715492 0.04413,-0.2027176 -0.129161,-0.2014713 -0.685452,0.00576 -1.371152,-0.00277 -2.056604,0.00501 C 10.021228,7.4479573 9.9586414,7.407817 9.9935503,7.2080883 10.145401,6.3413623 10.291269,5.4736396 10.51219,4.6213758 10.642847,4.1167002 10.782479,3.6117747 11.061498,3.1622046 11.339518,2.7138809 11.726751,2.5974365 12.2035,2.829328 c 0.398455,0.1934923 0.722604,0.4827333 0.990152,0.8340617 0.116944,0.1535968 0.27079,0.2740306 0.449073,0.1715499 0.343348,-0.1974819 0.644807,-0.4383502 0.819599,-0.826332 0.100985,-0.2244112 0.157836,-0.476001 0.04039,-0.7058977 C 14.339646,1.9840253 14.038187,1.7618584 13.707056,1.6394296 13.156999,1.4362128 12.562559,1.4840872 12.017239,1.6758341 11.38789,1.8970037 10.783727,2.2625445 10.259602,2.6724688 10.066109,2.8238217 9.8783519,2.9839017 9.7013165,3.1547035 9.0502751,3.7823067 8.5657962,4.529097 8.2246919,5.3651534 7.9823276,5.9595939 7.7888351,6.5660026 7.6913412,7.2015842 7.673637,7.318528 7.6357391,7.423253 7.5065759,7.4432009 7.3472438,7.4678879 7.1592376,7.4436995 6.9974121,7.4441728 6.6351128,7.4451447 6.2598478,7.3676233 5.9915515,7.6815496 5.8721151,7.8211835 5.7461952,7.9840062 5.6439635,8.1371045 c -0.1009847,0.1518511 -0.093255,0.3002122 0.085027,0.367535 0.1957362,0.073561 0.4528118,0.026182 0.6530361,0.0197 0.2645558,-0.00847 0.5291116,0.00501 0.7936674,-7.476e-4 0.1820229,-0.00374 0.2413669,0.030421 0.2064588,0.2358807 C 7.3487406,8.9587006 7.3095941,9.1492003 7.2804197,9.3464333 7.1804317,10.024404 7.0667304,10.700629 6.9525298,11.376606 6.7936963,12.314146 6.6371075,13.252434 6.4655575,14.188478 6.3017374,15.082631 6.1855427,15.985013 5.983074,16.873433 5.8249883,17.568607 5.7240037,18.277248 5.5556954,18.969682 5.4145655,19.550158 5.293882,20.143601 4.9722259,20.665731 4.7380909,21.045734 4.3959882,21.206312 3.9663652,21.104829 3.5778849,21.012322 3.2115961,20.866205 2.8951763,20.608631 2.6862246,20.438328 2.4473513,20.31141 2.1920214,20.458026 1.9519014,20.595915 1.7791048,20.851743 1.646453,21.088123 1.2205704,21.847879 1.915497,22.569984 2.6655289,22.684434 3.1692071,22.760986 3.666153,22.580208 4.1087416,22.356046 4.6996913,22.056582 5.2103511,21.635437 5.6387269,21.13874 5.9898058,20.731558 6.3575906,20.343327 6.6500737,19.890016 6.8450616,19.58756 7.0238427,19.274881 7.1866655,18.954471 7.7639005,17.817206 8.1227091,16.589926 8.4189318,15.354418 8.5613081,14.760227 8.716401,14.169777 8.8478064,13.572843 9.0268365,12.760724 9.1741996,11.934891 9.3083481,11.114294 9.3749255,10.707112 9.4310263,10.300679 9.5160532,9.8967389 9.5861222,9.5636133 9.6442168,9.2185186 9.6890985,8.8814035 9.7414633,8.4891827 9.990308,8.5136187 10.329668,8.4762164 c 0.286249,-0.03167 0.574492,-0.046376 0.861739,-0.067571 0.230395,-0.016703 0.494951,0.00396 0.711881,-0.088019 0.07754,-0.032911 0.147613,-0.080788 0.202719,-0.1513533 z\\"/><path d=\\"M 22.473802,7.8481382 C 22.426924,7.6912996 22.341898,7.5501696 22.231437,7.4294861 22.130452,7.3192756 21.987827,7.1749046 21.851933,7.1098255 21.411589,6.8988785 20.817398,7.0838898 20.436149,7.3422154 20.23343,7.479854 20.052405,7.6519026 19.871131,7.8167201 19.691352,7.9802913 19.517061,8.1488492 19.35723,8.3321177 19.025101,8.7128687 18.724639,9.1210479 18.436396,9.5354601 18.296263,9.7374301 17.901549,10.472252 17.781115,10.399942 17.654198,10.323892 17.495365,9.5905657 17.435023,9.3843566 17.351243,9.0978583 17.29539,8.8016361 17.161741,8.5323425 16.97922,8.1643081 16.865268,7.7623629 16.608941,7.4307332 16.325934,7.0639457 16.001036,6.9584722 15.558946,7.092371 c -0.43436,0.1314054 -0.78469,0.4049374 -1.128539,0.6819608 -0.503927,0.4056851 -0.879442,0.926319 -1.256951,1.4439609 -0.28226,0.387483 -0.284753,0.3857373 0.04488,0.7380631 0.206458,0.2211702 0.202718,0.2184272 0.389229,-0.00847 0.2663,-0.3251469 0.524872,-0.6595196 0.882433,-0.8934057 0.261315,-0.1713009 0.417904,-0.1368908 0.57948,0.1326518 0.07929,0.1326517 0.146866,0.2752777 0.200225,0.4208957 0.335619,0.9141014 0.590201,1.8541344 0.89191,2.7784594 0.03815,0.117691 -0.01122,0.193991 -0.06707,0.278519 -0.356565,0.538837 -0.719363,1.074182 -1.123054,1.578607 -0.320409,0.401198 -0.643312,0.803891 -1.073932,1.097621 -0.187757,0.128912 -0.40768,0.217679 -0.635831,0.156839 -0.233887,-0.06283 -0.37377,-0.27478 -0.587459,-0.373521 -0.006,-0.003 -0.01272,-0.0052 -0.01895,-0.0079 -0.09974,-0.04064 -0.249845,-0.0389 -0.353074,-0.01571 -0.454059,0.102482 -0.697669,0.614139 -0.790177,1.023813 -0.08379,0.371776 -0.0013,0.778209 0.261315,1.062463 0.228899,0.24785 0.572248,0.351327 0.901634,0.356315 0.189003,0.0028 0.39995,-0.04663 0.57549,-0.11445 0.670241,-0.262062 1.181649,-0.887172 1.605038,-1.441717 0.285501,-0.374517 0.550555,-0.763994 0.829573,-1.143499 0.230645,-0.313677 0.68595,-1.247726 0.81586,-1.250718 0.07854,-0.0017 0.09924,0.185762 0.114199,0.241117 0.03341,0.123675 0.06658,0.247351 0.102232,0.370279 0.167561,0.578481 0.343848,1.156464 0.525122,1.730458 0.120934,0.384242 0.315921,0.782697 0.560779,1.103356 0.07431,0.09749 0.167311,0.190749 0.26306,0.266799 0.371276,0.296972 0.838799,0.27453 1.266177,0.123177 0.191498,-0.06757 0.370029,-0.163071 0.539335,-0.275527 0.781948,-0.519886 1.340732,-1.244235 1.868598,-2.002495 0.124423,-0.178781 0.107467,-0.278769 -0.03441,-0.428127 -0.367286,-0.386237 -0.357062,-0.389727 -0.705149,0.01995 -0.261066,0.306446 -0.527117,0.612643 -0.879442,0.818851 -0.245855,0.144621 -0.413416,0.103229 -0.592696,-0.118439 -0.14861,-0.183518 -0.246353,-0.396709 -0.33138,-0.614886 -0.349831,-0.901136 -0.588954,-1.838675 -0.885177,-2.757515 -0.21743,-0.674231 -0.223414,-0.680464 0.20945,-1.248723 0.447575,-0.587708 0.875703,-1.1968602 1.462163,-1.6613914 0.431119,-0.3416031 0.73183,-0.3226534 1.129037,0.059094 0.0788,0.075801 0.207456,0.1388856 0.316919,0.1476127 0.369781,0.029674 0.691187,-0.3024566 0.880939,-0.5792304 0.188006,-0.2727835 0.259319,-0.6183768 0.163072,-0.9392845 z\\"/></svg>")}& .macro{cursor:pointer;background-image:url("data:image/svg+xml;utf8,<svg xmlns=\\"http://www.w3.org/2000/svg\\" viewBox=\\"0 0 24 24\\" fill=\\"grey\\"><path d=\\"m 7.3808594,2.8925781 c 0.6501558,0 1.3048608,0.1705676 1.8886719,0.5078125 l 9.2343747,5.3242188 c 1.167878,0.6758404 1.882813,1.9216266 1.882813,3.2675786 0,1.306438 -0.674828,2.517089 -1.783203,3.205078 L 9.2617188,20.595703 C 8.1035923,21.277644 6.6635531,21.275631 5.4960937,20.589844 4.3295773,19.917617 3.6132812,18.67473 3.6132813,17.330078 V 6.6660156 c 0,-1.3461361 0.7160606,-2.5932648 1.8828124,-3.265625 C 6.0817308,3.0628871 6.7318751,2.8925781 7.3808594,2.8925781 Z M 7.375,5.1835937 C 7.1238145,5.188954 6.883074,5.2521559 6.6601562,5.3691406 l -0.00781,0.00586 -0.00781,0.00391 C 6.1849913,5.6446615 5.9023438,6.1366335 5.9023437,6.6660156 V 17.330078 c 0,0.524949 0.2791508,1.016586 0.7363282,1.275391 0.4554716,0.266714 1.013907,0.272881 1.4785156,0.0098 l 9.2441405,-5.34375 c 0.450764,-0.263898 0.736328,-0.74603 0.736328,-1.27539 0,-0.52882 -0.290494,-1.018444 -0.742187,-1.277344 L 8.1171875,5.3789062 C 7.8951499,5.2512094 7.6461047,5.183439 7.375,5.1835937 Z\\"/></svg>")}& .autorun{cursor:pointer;background-image:url("data:image/svg+xml;utf8,<svg xmlns=\\"http://www.w3.org/2000/svg\\" viewBox=\\"0 0 24 24\\" fill=\\"grey\\"><path d=\\"m 11.999964,1.7500508 c -0.462401,0 -0.923676,0.3281109 -0.924272,0.9260918 V 13.159721 c -0.0012,1.23176 1.847315,1.231936 1.848545,0 V 2.6761426 c 5.97e-4,-0.598201 -0.461872,-0.9260918 -0.924273,-0.9260918 z m 5.998674,2.6454569 c -0.728133,0.068914 -1.207022,1.0512547 -0.5149,1.63931 1.880223,1.6037705 2.962848,3.9512403 2.962038,6.4226023 -4.23e-4,4.655627 -3.790565,8.443993 -8.445812,8.443993 -4.6552096,0 -8.443993,-3.789762 -8.443993,-8.445813 C 3.5560359,10.008191 4.6172167,7.6804932 6.4634264,6.0784841 7.4240529,5.2735715 6.1821863,3.8462722 5.2535029,4.6829783 -1.9571321,10.940557 2.4945266,22.78839 12.039992,22.749957 21.585452,22.711525 25.944958,10.82919 18.684564,4.6302147 18.515847,4.4852865 18.331563,4.4098479 18.146012,4.3955077 c -0.05049,-0.0039 -0.09883,-0.00459 -0.147374,0 z\\"/></svg>")}}}/*$vite$:1*/`)),document.head.appendChild(e)}}catch(e){console.error(`vite-plugin-css-injected-by-js`,e)}})();
|
|
2
|
+
/**
|
|
3
|
+
* @license @sheetxl/scripting-react - Scripting React - Monaco based script editor and scripting UI for SheetXL. - v0.7.23-beta.2
|
|
4
|
+
*
|
|
5
|
+
* (C) 2026-present SheetXL Inc. & Michael T. Ford
|
|
6
|
+
* License: The license can be found at https://www.sheetxl.com/license.
|
|
7
|
+
*/
|
|
8
|
+
import { n as e } from "./C1aR3ISFO7Zp-stK.mjs";
|
|
9
|
+
import { Suspense as t, forwardRef as n, lazy as r, memo as i, useEffect as a, useMemo as o, useRef as s, useState as c, version as l } from "react";
|
|
10
|
+
import { createRoot as u } from "react-dom/client";
|
|
11
|
+
import { CommonUtils as d, TimerUtils as f, messageKey as p } from "@sheetxl/utils";
|
|
12
|
+
import { DocTags as m } from "@sheetxl/scripting";
|
|
13
|
+
import { Command as h, useCallbackRef as g, useCommands as ee, useImperativeElement as te, useNotifier as _, useTranslator as ne } from "@sheetxl/utils-react";
|
|
14
|
+
import { DefaultTaskPaneRegistry as v, useModelListener as re, useTaskPaneArea as ie, useWorkbook as ae } from "@sheetxl/react";
|
|
15
|
+
import { jsx as y, jsxs as oe } from "react/jsx-runtime";
|
|
16
|
+
function b(e) {
|
|
17
|
+
var t, n, r = "";
|
|
18
|
+
if (typeof e == "string" || typeof e == "number") r += e;
|
|
19
|
+
else if (typeof e == "object") if (Array.isArray(e)) {
|
|
20
|
+
var i = e.length;
|
|
21
|
+
for (t = 0; t < i; t++) e[t] && (n = b(e[t])) && (r && (r += " "), r += n);
|
|
22
|
+
} else for (n in e) e[n] && (r && (r += " "), r += n);
|
|
23
|
+
return r;
|
|
24
|
+
}
|
|
25
|
+
function se() {
|
|
26
|
+
for (var e, t, n = 0, r = "", i = arguments.length; n < i; n++) (e = arguments[n]) && (t = b(e)) && (r && (r += " "), r += t);
|
|
27
|
+
return r;
|
|
28
|
+
}
|
|
29
|
+
function x(e, t) {
|
|
30
|
+
if (typeof e == "function") return e(t);
|
|
31
|
+
e && (e.current = t);
|
|
32
|
+
}
|
|
33
|
+
var ce = parseInt(l.split(".")[0], 10) >= 19 ? function(e) {
|
|
34
|
+
return (t) => {
|
|
35
|
+
let n = [];
|
|
36
|
+
for (let r of e) {
|
|
37
|
+
let e = x(r, t), i = typeof e == "function";
|
|
38
|
+
n.push(i ? e : () => x(r, null));
|
|
39
|
+
}
|
|
40
|
+
return () => {
|
|
41
|
+
for (let e of n) e();
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
} : function(e) {
|
|
45
|
+
return (t) => {
|
|
46
|
+
for (let n of e) x(n, t);
|
|
47
|
+
};
|
|
48
|
+
}, S = {
|
|
49
|
+
defaultToken: "invalid",
|
|
50
|
+
tokenPostfix: ".ts",
|
|
51
|
+
keywords: /* @__PURE__ */ "abstract.any.as.asserts.bigint.boolean.break.case.catch.class.continue.const.constructor.debugger.declare.default.delete.do.else.enum.export.extends.false.finally.for.from.function.get.if.implements.import.in.infer.instanceof.interface.is.keyof.let.module.namespace.never.new.null.number.object.out.package.private.protected.public.override.readonly.require.global.return.satisfies.set.static.string.super.switch.symbol.this.throw.true.try.type.typeof.undefined.unique.unknown.var.void.while.with.yield.async.await.of".split("."),
|
|
52
|
+
operators: /* @__PURE__ */ "<=.>=.==.!=.===.!==.=>.+.-.**.*./.%.++.--.<<.</.>>.>>>.&.|.^.!.~.&&.||.??.?.:.=.+=.-=.*=.**=./=.%=.<<=.>>=.>>>=.&=.|=.^=.@".split("."),
|
|
53
|
+
symbols: /[=><!~?:&|+\-*\/\^%]+/,
|
|
54
|
+
escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
|
|
55
|
+
digits: /\d+(_+\d+)*/,
|
|
56
|
+
octaldigits: /[0-7]+(_+[0-7]+)*/,
|
|
57
|
+
binarydigits: /[0-1]+(_+[0-1]+)*/,
|
|
58
|
+
hexdigits: /[[0-9a-fA-F]+(_+[0-9a-fA-F]+)*/,
|
|
59
|
+
regexpctl: /[(){}\[\]\$\^|\-*+?\.]/,
|
|
60
|
+
regexpesc: /\\(?:[bBdDfnrstvwWn0\\\/]|@regexpctl|c[A-Z]|x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4})/,
|
|
61
|
+
tokenizer: {
|
|
62
|
+
root: [[/[{}]/, "delimiter.bracket"], { include: "common" }],
|
|
63
|
+
common: [
|
|
64
|
+
[/#?[a-z_$][\w$]*/, { cases: {
|
|
65
|
+
"@keywords": "keyword",
|
|
66
|
+
"@default": "identifier"
|
|
67
|
+
} }],
|
|
68
|
+
[/[A-Z][\w\$]*/, "type.identifier"],
|
|
69
|
+
{ include: "@whitespace" },
|
|
70
|
+
[/\/(?=([^\\\/]|\\.)+\/([dgimsuy]*)(\s*)(\.|;|,|\)|\]|\}|$))/, {
|
|
71
|
+
token: "regexp",
|
|
72
|
+
bracket: "@open",
|
|
73
|
+
next: "@regexp"
|
|
74
|
+
}],
|
|
75
|
+
[/[()\[\]]/, "@brackets"],
|
|
76
|
+
[/[<>](?!@symbols)/, "@brackets"],
|
|
77
|
+
[/!(?=([^=]|$))/, "delimiter"],
|
|
78
|
+
[/@symbols/, { cases: {
|
|
79
|
+
"@operators": "delimiter",
|
|
80
|
+
"@default": ""
|
|
81
|
+
} }],
|
|
82
|
+
[/(@digits)[eE]([\-+]?(@digits))?/, "number.float"],
|
|
83
|
+
[/(@digits)\.(@digits)([eE][\-+]?(@digits))?/, "number.float"],
|
|
84
|
+
[/0[xX](@hexdigits)n?/, "number.hex"],
|
|
85
|
+
[/0[oO]?(@octaldigits)n?/, "number.octal"],
|
|
86
|
+
[/0[bB](@binarydigits)n?/, "number.binary"],
|
|
87
|
+
[/(@digits)n?/, "number"],
|
|
88
|
+
[/[;,.]/, "delimiter"],
|
|
89
|
+
[/"([^"\\]|\\.)*$/, "string.invalid"],
|
|
90
|
+
[/'([^'\\]|\\.)*$/, "string.invalid"],
|
|
91
|
+
[
|
|
92
|
+
/"/,
|
|
93
|
+
"string",
|
|
94
|
+
"@string_double"
|
|
95
|
+
],
|
|
96
|
+
[
|
|
97
|
+
/'/,
|
|
98
|
+
"string",
|
|
99
|
+
"@string_single"
|
|
100
|
+
],
|
|
101
|
+
[
|
|
102
|
+
/`/,
|
|
103
|
+
"string",
|
|
104
|
+
"@string_backtick"
|
|
105
|
+
]
|
|
106
|
+
],
|
|
107
|
+
whitespace: [
|
|
108
|
+
[/[ \t\r\n]+/, ""],
|
|
109
|
+
[
|
|
110
|
+
/\/\*\*(?!\/)/,
|
|
111
|
+
"comment.doc",
|
|
112
|
+
"@jsdoc"
|
|
113
|
+
],
|
|
114
|
+
[
|
|
115
|
+
/\/\*/,
|
|
116
|
+
"comment",
|
|
117
|
+
"@comment"
|
|
118
|
+
],
|
|
119
|
+
[/\/\/.*$/, "comment"]
|
|
120
|
+
],
|
|
121
|
+
comment: [
|
|
122
|
+
[/[^\/*]+/, "comment"],
|
|
123
|
+
[
|
|
124
|
+
/\*\//,
|
|
125
|
+
"comment",
|
|
126
|
+
"@pop"
|
|
127
|
+
],
|
|
128
|
+
[/[\/*]/, "comment"]
|
|
129
|
+
],
|
|
130
|
+
jsdoc: [
|
|
131
|
+
[/@(?:param|arg|argument|property|prop|template|typedef)\b/, {
|
|
132
|
+
token: "comment.doc.tag",
|
|
133
|
+
next: "@jsdoc_param"
|
|
134
|
+
}],
|
|
135
|
+
[/@\w+/, "comment.doc.tag"],
|
|
136
|
+
[/\{/, {
|
|
137
|
+
token: "comment.doc.type",
|
|
138
|
+
next: "@jsdoc_type"
|
|
139
|
+
}],
|
|
140
|
+
[/[^\/*@{]+/, "comment.doc"],
|
|
141
|
+
[
|
|
142
|
+
/\*\//,
|
|
143
|
+
"comment.doc",
|
|
144
|
+
"@pop"
|
|
145
|
+
],
|
|
146
|
+
[/[\/*]/, "comment.doc"]
|
|
147
|
+
],
|
|
148
|
+
jsdoc_type: [
|
|
149
|
+
[/[^{}]+/, "comment.doc.type"],
|
|
150
|
+
[
|
|
151
|
+
/\{/,
|
|
152
|
+
"comment.doc.type",
|
|
153
|
+
"@push"
|
|
154
|
+
],
|
|
155
|
+
[
|
|
156
|
+
/\}/,
|
|
157
|
+
"comment.doc.type",
|
|
158
|
+
"@pop"
|
|
159
|
+
]
|
|
160
|
+
],
|
|
161
|
+
jsdoc_param: [
|
|
162
|
+
[/\s+/, "comment.doc"],
|
|
163
|
+
[/\{/, {
|
|
164
|
+
token: "comment.doc.type",
|
|
165
|
+
next: "@jsdoc_type"
|
|
166
|
+
}],
|
|
167
|
+
[/\[[^\]]*\]/, {
|
|
168
|
+
token: "comment.doc.name",
|
|
169
|
+
next: "@pop"
|
|
170
|
+
}],
|
|
171
|
+
[/[\w$][\w$.]*/, {
|
|
172
|
+
token: "comment.doc.name",
|
|
173
|
+
next: "@pop"
|
|
174
|
+
}],
|
|
175
|
+
[/(?=\*\/)/, {
|
|
176
|
+
token: "comment.doc",
|
|
177
|
+
next: "@pop"
|
|
178
|
+
}],
|
|
179
|
+
[/./, {
|
|
180
|
+
token: "comment.doc",
|
|
181
|
+
next: "@pop"
|
|
182
|
+
}]
|
|
183
|
+
],
|
|
184
|
+
regexp: [
|
|
185
|
+
[/(\{)(\d+(?:,\d*)?)(\})/, [
|
|
186
|
+
"regexp.escape.control",
|
|
187
|
+
"regexp.escape.control",
|
|
188
|
+
"regexp.escape.control"
|
|
189
|
+
]],
|
|
190
|
+
[/(\[)(\^?)(?=(?:[^\]\\\/]|\\.)+)/, ["regexp.escape.control", {
|
|
191
|
+
token: "regexp.escape.control",
|
|
192
|
+
next: "@regexrange"
|
|
193
|
+
}]],
|
|
194
|
+
[/(\()(\?:|\?=|\?!)/, ["regexp.escape.control", "regexp.escape.control"]],
|
|
195
|
+
[/[()]/, "regexp.escape.control"],
|
|
196
|
+
[/@regexpctl/, "regexp.escape.control"],
|
|
197
|
+
[/[^\\\/]/, "regexp"],
|
|
198
|
+
[/@regexpesc/, "regexp.escape"],
|
|
199
|
+
[/\\\./, "regexp.invalid"],
|
|
200
|
+
[/(\/)([dgimsuy]*)/, [{
|
|
201
|
+
token: "regexp",
|
|
202
|
+
bracket: "@close",
|
|
203
|
+
next: "@pop"
|
|
204
|
+
}, "keyword.other"]]
|
|
205
|
+
],
|
|
206
|
+
regexrange: [
|
|
207
|
+
[/-/, "regexp.escape.control"],
|
|
208
|
+
[/\^/, "regexp.invalid"],
|
|
209
|
+
[/@regexpesc/, "regexp.escape"],
|
|
210
|
+
[/[^\]]/, "regexp"],
|
|
211
|
+
[/\]/, {
|
|
212
|
+
token: "regexp.escape.control",
|
|
213
|
+
next: "@pop",
|
|
214
|
+
bracket: "@close"
|
|
215
|
+
}]
|
|
216
|
+
],
|
|
217
|
+
string_double: [
|
|
218
|
+
[/[^\\"]+/, "string"],
|
|
219
|
+
[/@escapes/, "string.escape"],
|
|
220
|
+
[/\\./, "string.escape.invalid"],
|
|
221
|
+
[
|
|
222
|
+
/"/,
|
|
223
|
+
"string",
|
|
224
|
+
"@pop"
|
|
225
|
+
]
|
|
226
|
+
],
|
|
227
|
+
string_single: [
|
|
228
|
+
[/[^\\']+/, "string"],
|
|
229
|
+
[/@escapes/, "string.escape"],
|
|
230
|
+
[/\\./, "string.escape.invalid"],
|
|
231
|
+
[
|
|
232
|
+
/'/,
|
|
233
|
+
"string",
|
|
234
|
+
"@pop"
|
|
235
|
+
]
|
|
236
|
+
],
|
|
237
|
+
string_backtick: [
|
|
238
|
+
[/\$\{/, {
|
|
239
|
+
token: "delimiter.bracket",
|
|
240
|
+
next: "@bracketCounting"
|
|
241
|
+
}],
|
|
242
|
+
[/[^\\`$]+/, "string"],
|
|
243
|
+
[/@escapes/, "string.escape"],
|
|
244
|
+
[/\\./, "string.escape.invalid"],
|
|
245
|
+
[
|
|
246
|
+
/`/,
|
|
247
|
+
"string",
|
|
248
|
+
"@pop"
|
|
249
|
+
]
|
|
250
|
+
],
|
|
251
|
+
bracketCounting: [
|
|
252
|
+
[
|
|
253
|
+
/\{/,
|
|
254
|
+
"delimiter.bracket",
|
|
255
|
+
"@bracketCounting"
|
|
256
|
+
],
|
|
257
|
+
[
|
|
258
|
+
/\}/,
|
|
259
|
+
"delimiter.bracket",
|
|
260
|
+
"@pop"
|
|
261
|
+
],
|
|
262
|
+
{ include: "common" }
|
|
263
|
+
]
|
|
264
|
+
}
|
|
265
|
+
}, le = {
|
|
266
|
+
lightbulb: { enabled: !1 },
|
|
267
|
+
tabSize: 2,
|
|
268
|
+
acceptSuggestionOnCommitCharacter: !0,
|
|
269
|
+
acceptSuggestionOnEnter: "on",
|
|
270
|
+
accessibilitySupport: "auto",
|
|
271
|
+
automaticLayout: !0,
|
|
272
|
+
autoIndent: !1,
|
|
273
|
+
codeLens: !0,
|
|
274
|
+
colorDecorators: !0,
|
|
275
|
+
contextmenu: !0,
|
|
276
|
+
cursorBlinking: "blink",
|
|
277
|
+
cursorSmoothCaretAnimation: !1,
|
|
278
|
+
cursorStyle: "line",
|
|
279
|
+
disableLayerHinting: !1,
|
|
280
|
+
disableMonospaceOptimizations: !1,
|
|
281
|
+
dragAndDrop: !0,
|
|
282
|
+
glyphMargin: !0,
|
|
283
|
+
fixedOverflowWidgets: !1,
|
|
284
|
+
folding: !0,
|
|
285
|
+
foldingStrategy: "auto",
|
|
286
|
+
fontLigatures: !1,
|
|
287
|
+
formatOnPaste: !0,
|
|
288
|
+
formatOnType: !1,
|
|
289
|
+
hideCursorInOverviewRuler: !1,
|
|
290
|
+
highlightActiveIndentGuide: !0,
|
|
291
|
+
links: !0,
|
|
292
|
+
lineDecorationsWidth: 8,
|
|
293
|
+
lineNumbersMinChars: 3,
|
|
294
|
+
mouseWheelZoom: !1,
|
|
295
|
+
multiCursorMergeOverlapping: !0,
|
|
296
|
+
multiCursorModifier: "alt",
|
|
297
|
+
overviewRulerBorder: !0,
|
|
298
|
+
overviewRulerLanes: 2,
|
|
299
|
+
quickSuggestions: !0,
|
|
300
|
+
quickSuggestionsDelay: 100,
|
|
301
|
+
readOnly: !1,
|
|
302
|
+
renderControlCharacters: !1,
|
|
303
|
+
renderFinalNewline: !0,
|
|
304
|
+
renderIndentGuides: !0,
|
|
305
|
+
renderLineHighlight: "all",
|
|
306
|
+
renderWhitespace: "none",
|
|
307
|
+
revealHorizontalRightPadding: 30,
|
|
308
|
+
roundedSelection: !0,
|
|
309
|
+
rulers: [],
|
|
310
|
+
scrollBeyondLastColumn: 5,
|
|
311
|
+
scrollBeyondLastLine: !0,
|
|
312
|
+
selectOnLineNumbers: !0,
|
|
313
|
+
selectionClipboard: !0,
|
|
314
|
+
selectionHighlight: !0,
|
|
315
|
+
showLightbulbIconMode: !1,
|
|
316
|
+
showFoldingControls: "mouseover",
|
|
317
|
+
smoothScrolling: !0,
|
|
318
|
+
suggestOnTriggerCharacters: !0,
|
|
319
|
+
wordBasedSuggestions: !0,
|
|
320
|
+
wordSeparators: "~!@#$%^&*()-=+[{]}|;:'\",.<>/?",
|
|
321
|
+
wordWrap: "off",
|
|
322
|
+
wordWrapBreakAfterCharacters: " })]?|&,;",
|
|
323
|
+
wordWrapBreakBeforeCharacters: "{([+",
|
|
324
|
+
wordWrapBreakObtrusiveCharacters: ".",
|
|
325
|
+
wordWrapColumn: 80,
|
|
326
|
+
wordWrapMinified: !0,
|
|
327
|
+
wrappingIndent: "none"
|
|
328
|
+
}, ue = "_script-editor_1kuph_5", C, de = r(async () => (function() {
|
|
329
|
+
if (typeof window > "u") return;
|
|
330
|
+
let e = window;
|
|
331
|
+
if (e.__sxlDefineShim) return;
|
|
332
|
+
e.__sxlDefineShim = !0;
|
|
333
|
+
let t = [], n = null, r = (...e) => {
|
|
334
|
+
typeof n == "function" ? n(...e) : t.push(e);
|
|
335
|
+
};
|
|
336
|
+
Object.defineProperty(e, "define", {
|
|
337
|
+
configurable: !1,
|
|
338
|
+
enumerable: !0,
|
|
339
|
+
get: () => typeof n == "function" ? n : r,
|
|
340
|
+
set(e) {
|
|
341
|
+
if (typeof e == "function") for (n = e; t.length;) try {
|
|
342
|
+
e(...t.shift());
|
|
343
|
+
} catch {}
|
|
344
|
+
}
|
|
345
|
+
});
|
|
346
|
+
}(), import("./79R_LZrdMANq6eyF.mjs"))), w = ["define", "require"], fe = !1, T = "@0.7.23-beta.2";
|
|
347
|
+
T !== "@local" && T !== "@0.0.0" || (T = "");
|
|
348
|
+
var E = `https://cdn.jsdelivr.net/npm/@sheetxl/sdk${T}/types/scripting.d.ts`, D = (e) => {
|
|
349
|
+
try {
|
|
350
|
+
e.languages.setMonarchTokensProvider("typescript", S);
|
|
351
|
+
} catch {}
|
|
352
|
+
}, O = !1;
|
|
353
|
+
function pe(e, t) {
|
|
354
|
+
let n = null, r = e.length;
|
|
355
|
+
for (let i = 0; !n && i < r; i++) {
|
|
356
|
+
let r = e[i];
|
|
357
|
+
r.getName() === t.text && (n = r);
|
|
358
|
+
}
|
|
359
|
+
return n ? n.getContext() : "formula";
|
|
360
|
+
}
|
|
361
|
+
function k(e, t, n, r, i = []) {
|
|
362
|
+
if (r.kind === "function" && r.kindModifiers === "export") {
|
|
363
|
+
let t = r.spans[0].start, a = e.getPositionAt(t);
|
|
364
|
+
i.push({
|
|
365
|
+
name: r.text,
|
|
366
|
+
type: pe(n, r),
|
|
367
|
+
lineNumber: a.lineNumber
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
if (r.childItems) for (let a of r.childItems) k(e, t, n, a, i);
|
|
371
|
+
return i;
|
|
372
|
+
}
|
|
373
|
+
function A(e, t, n = "function", r) {
|
|
374
|
+
let i = e.spans, a = i.length;
|
|
375
|
+
for (let o = 0; o < a; o++) {
|
|
376
|
+
let a = i[o];
|
|
377
|
+
if (a.start <= t && t < a.start + a.length) {
|
|
378
|
+
if (e.kind === n && (!r || e.kindModifiers === r)) return e;
|
|
379
|
+
for (let i of e.childItems || []) {
|
|
380
|
+
let e = A(i, t, n, r);
|
|
381
|
+
if (e) return e;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
return null;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
function me(e) {
|
|
388
|
+
return e.kind === "comment";
|
|
389
|
+
}
|
|
390
|
+
var j = null, M = null, N = null, P = null, he = !1, ge = !1, F = !1, I = { current: null }, L = (e, t) => {
|
|
391
|
+
M = {
|
|
392
|
+
editor: e,
|
|
393
|
+
monaco: t
|
|
394
|
+
}, N && (P = N(e, t));
|
|
395
|
+
}, _e = (e) => {
|
|
396
|
+
F || (F = !0, e.languages.typescript.typescriptDefaults.setDiagnosticsOptions({
|
|
397
|
+
noSemanticValidation: !0,
|
|
398
|
+
noSyntaxValidation: !1,
|
|
399
|
+
diagnosticCodesToIgnore: [2307]
|
|
400
|
+
}), e.languages.typescript.typescriptDefaults.setEagerModelSync(!0), e.languages.json.jsonDefaults.setDiagnosticsOptions({ validate: !0 }), D(e), ((e) => {
|
|
401
|
+
O || (O = !0, e.languages.registerCompletionItemProvider("typescript", {
|
|
402
|
+
triggerCharacters: ["@"],
|
|
403
|
+
provideCompletionItems: (t, n) => {
|
|
404
|
+
let r = t.getValueInRange({
|
|
405
|
+
startLineNumber: n.lineNumber,
|
|
406
|
+
startColumn: 1,
|
|
407
|
+
endLineNumber: n.lineNumber,
|
|
408
|
+
endColumn: n.column
|
|
409
|
+
}), i = /(?:^|\s)@(\w*)$/.exec(r);
|
|
410
|
+
if (!i || !((e, t) => {
|
|
411
|
+
let n = e.getValueInRange({
|
|
412
|
+
startLineNumber: 1,
|
|
413
|
+
startColumn: 1,
|
|
414
|
+
endLineNumber: t.lineNumber,
|
|
415
|
+
endColumn: t.column
|
|
416
|
+
});
|
|
417
|
+
return n.lastIndexOf("/*") > n.lastIndexOf("*/");
|
|
418
|
+
})(t, n)) return { suggestions: [] };
|
|
419
|
+
let a = i[1], o = new e.Range(n.lineNumber, n.column - a.length, n.lineNumber, n.column);
|
|
420
|
+
return { suggestions: m.map((t) => ({
|
|
421
|
+
label: `@${t.name}`,
|
|
422
|
+
kind: e.languages.CompletionItemKind.Keyword,
|
|
423
|
+
detail: t.group === "sheetxl" ? "SheetXL" : "JSDoc",
|
|
424
|
+
documentation: { value: t.description },
|
|
425
|
+
insertText: t.snippet ?? t.name,
|
|
426
|
+
insertTextRules: t.snippet ? e.languages.CompletionItemInsertTextRule.InsertAsSnippet : void 0,
|
|
427
|
+
range: o
|
|
428
|
+
})) };
|
|
429
|
+
}
|
|
430
|
+
}));
|
|
431
|
+
})(e), e.editor.defineTheme("extended", {
|
|
432
|
+
base: "vs",
|
|
433
|
+
inherit: !0,
|
|
434
|
+
rules: [
|
|
435
|
+
{
|
|
436
|
+
token: "comment.doc",
|
|
437
|
+
foreground: "008000"
|
|
438
|
+
},
|
|
439
|
+
{
|
|
440
|
+
token: "comment.doc.tag",
|
|
441
|
+
foreground: "0000FF"
|
|
442
|
+
},
|
|
443
|
+
{
|
|
444
|
+
token: "comment.doc.type",
|
|
445
|
+
foreground: "267F99"
|
|
446
|
+
},
|
|
447
|
+
{
|
|
448
|
+
token: "comment.doc.name",
|
|
449
|
+
foreground: "001080"
|
|
450
|
+
}
|
|
451
|
+
],
|
|
452
|
+
colors: {}
|
|
453
|
+
}), e.editor.defineTheme("extended-dark", {
|
|
454
|
+
base: "vs-dark",
|
|
455
|
+
inherit: !0,
|
|
456
|
+
rules: [
|
|
457
|
+
{
|
|
458
|
+
token: "comment.doc",
|
|
459
|
+
foreground: "6A9955"
|
|
460
|
+
},
|
|
461
|
+
{
|
|
462
|
+
token: "comment.doc.tag",
|
|
463
|
+
foreground: "569CD6"
|
|
464
|
+
},
|
|
465
|
+
{
|
|
466
|
+
token: "comment.doc.type",
|
|
467
|
+
foreground: "4EC9B0"
|
|
468
|
+
},
|
|
469
|
+
{
|
|
470
|
+
token: "comment.doc.name",
|
|
471
|
+
foreground: "9CDCFE"
|
|
472
|
+
}
|
|
473
|
+
],
|
|
474
|
+
colors: {}
|
|
475
|
+
}), (async () => {
|
|
476
|
+
let t = !1;
|
|
477
|
+
try {
|
|
478
|
+
let n = await (async () => await (await fetch(E)).text())(), r = e.Uri.parse("inmemory://model/\"sheetxl-models\".d.ts"), i = e.editor.getModel(r);
|
|
479
|
+
i ? t = !0 : i = e.editor.createModel(n, "typescript", r), e.editor.setModelMarkers(i, "default", []);
|
|
480
|
+
} catch (e) {
|
|
481
|
+
console.warn("cant load types", e);
|
|
482
|
+
}
|
|
483
|
+
try {
|
|
484
|
+
if (e.languages.registerLinkProvider("*", { provideLinks: (t, n) => {
|
|
485
|
+
let r = [], i = { links: r }, a = t.getLinesContent(), o = a.length;
|
|
486
|
+
for (let n = 1; n <= o; n++) {
|
|
487
|
+
let i = a[n - 1], o = e.editor.tokenize(i, "typescript"), s = o[0].length;
|
|
488
|
+
for (let a = 0; a < s; a++) {
|
|
489
|
+
let s = o[0]?.[a];
|
|
490
|
+
if (s && s.type.startsWith("string")) {
|
|
491
|
+
let c = s.offset, l = o[0]?.[a + 1]?.offset ?? i.length, u = new e.Range(n, c + 1, n, l + 1), d = t.getValueInRange(u), f = d[0];
|
|
492
|
+
f !== "`" && f !== "'" && f !== "\"" || (c++, d = d.substring(1));
|
|
493
|
+
let p = d[d.length - 1];
|
|
494
|
+
p !== "`" && p !== "'" && p !== "\"" || (c++, d = d.substring(0, d.length - 1));
|
|
495
|
+
try {
|
|
496
|
+
I.current?.getRanges(d) && r.push({
|
|
497
|
+
range: {
|
|
498
|
+
endColumn: l,
|
|
499
|
+
endLineNumber: n,
|
|
500
|
+
startColumn: c,
|
|
501
|
+
startLineNumber: n
|
|
502
|
+
},
|
|
503
|
+
tooltip: `Goto range '${d}'`,
|
|
504
|
+
url: `/range/${d}`
|
|
505
|
+
});
|
|
506
|
+
} catch {}
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
return i;
|
|
511
|
+
} }), e.editor.registerLinkOpener({ open(e) {
|
|
512
|
+
if (e?.path?.startsWith("/range/")) {
|
|
513
|
+
try {
|
|
514
|
+
I.current?.getRanges(e.path.substring(7))?.select();
|
|
515
|
+
} catch (e) {
|
|
516
|
+
console.warn("invalid range", e);
|
|
517
|
+
}
|
|
518
|
+
return !0;
|
|
519
|
+
}
|
|
520
|
+
return !1;
|
|
521
|
+
} }), !t) {
|
|
522
|
+
let t = e.languages.typescript.typescriptDefaults.getCompilerOptions();
|
|
523
|
+
e.languages.typescript.typescriptDefaults.setCompilerOptions({
|
|
524
|
+
...t,
|
|
525
|
+
target: e.languages.typescript.ScriptTarget.ES2020,
|
|
526
|
+
lib: [
|
|
527
|
+
"webworker",
|
|
528
|
+
"es2020",
|
|
529
|
+
"esnext.asynciterable"
|
|
530
|
+
],
|
|
531
|
+
downlevelIteration: !0,
|
|
532
|
+
moduleResolution: e.languages.typescript.ModuleResolutionKind.NodeJs,
|
|
533
|
+
allowSyntheticDefaultImports: !0,
|
|
534
|
+
baseUrl: "inmemory://model/",
|
|
535
|
+
allowNonTsExtensions: !0
|
|
536
|
+
});
|
|
537
|
+
}
|
|
538
|
+
} finally {
|
|
539
|
+
(() => {
|
|
540
|
+
let t = e.languages.typescript.typescriptDefaults.getDiagnosticsOptions();
|
|
541
|
+
e.languages.typescript.typescriptDefaults.setDiagnosticsOptions({
|
|
542
|
+
...t,
|
|
543
|
+
noSemanticValidation: !1
|
|
544
|
+
});
|
|
545
|
+
})();
|
|
546
|
+
}
|
|
547
|
+
})());
|
|
548
|
+
}, ve = (e) => {
|
|
549
|
+
let t = !1, n = e ? e.length : 0;
|
|
550
|
+
for (let r = 0; !t && r < n; r++) e[r].severity === 8 && (t = !0);
|
|
551
|
+
}, ye = () => {
|
|
552
|
+
let [e, n] = c(() => j.props);
|
|
553
|
+
return a(() => (j && (j.setProps = n), () => {
|
|
554
|
+
j && (j.setProps = null);
|
|
555
|
+
}), []), y("div", {
|
|
556
|
+
style: {
|
|
557
|
+
display: "flex",
|
|
558
|
+
flex: "1 1 100%",
|
|
559
|
+
width: "100%",
|
|
560
|
+
height: "100%"
|
|
561
|
+
},
|
|
562
|
+
children: y(t, { children: y(de, {
|
|
563
|
+
theme: e.theme,
|
|
564
|
+
options: e.options,
|
|
565
|
+
language: "typescript",
|
|
566
|
+
value: e.value,
|
|
567
|
+
onValidate: e.onValidate,
|
|
568
|
+
beforeMount: e.beforeMount,
|
|
569
|
+
onMount: L
|
|
570
|
+
}) })
|
|
571
|
+
});
|
|
572
|
+
}, R = i(n((t, n) => {
|
|
573
|
+
let { className: r, style: i, readOnly: l = !1, darkMode: m, loadingPanel: v, autoFocus: ie = !0, frame: b, scripts: x, onStatusChange: S, ...de } = t, T = ne(), E = s(null), [O, pe] = c(!1), F = ae(), [L] = ee(["insertFunction"]), [R, z] = c({
|
|
574
|
+
message: "Loading",
|
|
575
|
+
cursor: "",
|
|
576
|
+
dirty: !1
|
|
577
|
+
}), [be, B] = c({
|
|
578
|
+
loading: !1,
|
|
579
|
+
compiling: !1,
|
|
580
|
+
errors: [],
|
|
581
|
+
warnings: []
|
|
582
|
+
}), V = g((e) => {
|
|
583
|
+
z((t) => {
|
|
584
|
+
let n = {
|
|
585
|
+
...t,
|
|
586
|
+
...e
|
|
587
|
+
};
|
|
588
|
+
return d.deepEqual(n, t) ? t : (pe(n.dirty ?? !1), n);
|
|
589
|
+
});
|
|
590
|
+
}, [S]);
|
|
591
|
+
a(() => {
|
|
592
|
+
S?.(R);
|
|
593
|
+
}, [S, R]);
|
|
594
|
+
let H = _(), xe = g(async (e) => {
|
|
595
|
+
let t = null, n = null;
|
|
596
|
+
try {
|
|
597
|
+
e && (n = await H.showBusy(T("scriptEditor.saving")), t = await x.createModule({ source: e })), x.addModule("scripts", t, { replace: !0 }), n?.();
|
|
598
|
+
} catch (e) {
|
|
599
|
+
n?.(), console.warn("Unable to compile", e), H.showError(e);
|
|
600
|
+
}
|
|
601
|
+
return t;
|
|
602
|
+
}, [x]), U = g(async () => {
|
|
603
|
+
if (!E.current) return;
|
|
604
|
+
let e = E.current.editor, t;
|
|
605
|
+
if (R.dirty) {
|
|
606
|
+
let n = e.getValue();
|
|
607
|
+
await xe(n), t = x.getModules().getByName("scripts");
|
|
608
|
+
let r = t?.getSource(), i = e.getValue(), a = (r?.length ?? 0) !== n.length || r !== i;
|
|
609
|
+
V({ dirty: a });
|
|
610
|
+
} else t = x.getModules().getByName("scripts");
|
|
611
|
+
return t;
|
|
612
|
+
}, [R, x]);
|
|
613
|
+
a(() => {
|
|
614
|
+
let e = b?.addListener({ onBeforeHide: async () => (await U(), !0) });
|
|
615
|
+
return () => {
|
|
616
|
+
e?.();
|
|
617
|
+
};
|
|
618
|
+
}, [b]), a(() => {
|
|
619
|
+
if (x) return x.addListeners({ onBeforeSearch: () => U() });
|
|
620
|
+
}, [x]), re(F, {
|
|
621
|
+
onBeforeSave: async () => {
|
|
622
|
+
await U();
|
|
623
|
+
},
|
|
624
|
+
onLoad: () => {
|
|
625
|
+
let e = E.current?.editor;
|
|
626
|
+
e && e.setValue(x?.getModules().getItems()[0]?.getSource() ?? "");
|
|
627
|
+
}
|
|
628
|
+
});
|
|
629
|
+
let W = g(async (e) => {
|
|
630
|
+
if (!x) return;
|
|
631
|
+
let t = typeof e == "string" ? { functionName: e } : e ?? {}, n = null;
|
|
632
|
+
if (t?.declaration || t?.functionName) {
|
|
633
|
+
let e = t.declaration ? t.declaration.getName() : t.functionName;
|
|
634
|
+
(await x.searchFunctions({ name: e })).length > 0 && (n = e);
|
|
635
|
+
}
|
|
636
|
+
if (n) try {
|
|
637
|
+
await x.executeMacro(n);
|
|
638
|
+
} catch (e) {
|
|
639
|
+
H.showError(e);
|
|
640
|
+
}
|
|
641
|
+
}, [x, H]), [G, Se] = c(!1), Ce = g(async () => {
|
|
642
|
+
if (!E.current) return null;
|
|
643
|
+
let e = E.current, t = e.editor;
|
|
644
|
+
if (!t) return null;
|
|
645
|
+
let n = await (async (e, t, n = "export") => {
|
|
646
|
+
let r = e.getModel();
|
|
647
|
+
if (!r) return null;
|
|
648
|
+
let i = await (await (await t.languages.typescript.getTypeScriptWorker())(r.uri)).getNavigationTree(r.uri.toString()), a = null, o = e.getSelection();
|
|
649
|
+
if (!o) return null;
|
|
650
|
+
let s = o.startLineNumber === o.endLineNumber && o.startColumn === o.endColumn ? r.getLineCount() : Math.min(o.endLineNumber, r.getLineCount());
|
|
651
|
+
for (let e = o.startLineNumber; !a && e <= s; e++) {
|
|
652
|
+
let t = A(i, r.getOffsetAt({
|
|
653
|
+
lineNumber: e,
|
|
654
|
+
column: 1
|
|
655
|
+
}), "function", n);
|
|
656
|
+
t && (a = t.text);
|
|
657
|
+
}
|
|
658
|
+
return a;
|
|
659
|
+
})(t, e.monaco);
|
|
660
|
+
return V({ message: (n ?? "").toUpperCase() }), n ? {
|
|
661
|
+
source: t.getValue(),
|
|
662
|
+
name: n
|
|
663
|
+
} : null;
|
|
664
|
+
}, []);
|
|
665
|
+
g(f.debounce(U, 200), []);
|
|
666
|
+
let we = g(async (e, t, n) => {
|
|
667
|
+
B((e) => ({
|
|
668
|
+
...e,
|
|
669
|
+
compiling: !0
|
|
670
|
+
}));
|
|
671
|
+
let r = null;
|
|
672
|
+
try {
|
|
673
|
+
if (r = await x.createModule({
|
|
674
|
+
source: n?.getValue(),
|
|
675
|
+
declarationsOnly: !0
|
|
676
|
+
}), !r) return;
|
|
677
|
+
} catch {}
|
|
678
|
+
let i = r ? r.getDiagnostics() : d.EmptyArray;
|
|
679
|
+
(function(e, t, n) {
|
|
680
|
+
let r = (n ?? []).map((n) => {
|
|
681
|
+
let r = e.getPositionAt(n.start), i = e.getPositionAt(n.start + Math.max(n.length, 1));
|
|
682
|
+
return {
|
|
683
|
+
message: `${n.message} (${n.code})`,
|
|
684
|
+
code: n.code,
|
|
685
|
+
severity: n.severity === "warning" ? t.MarkerSeverity.Warning : t.MarkerSeverity.Error,
|
|
686
|
+
startLineNumber: r.lineNumber,
|
|
687
|
+
startColumn: r.column,
|
|
688
|
+
endLineNumber: i.lineNumber,
|
|
689
|
+
endColumn: i.column
|
|
690
|
+
};
|
|
691
|
+
});
|
|
692
|
+
t.editor.setModelMarkers(e, "sheetxl", r);
|
|
693
|
+
})(e, t, i), async function(e, t, n, r) {
|
|
694
|
+
let i = k(e, t, r, await (await (await t.languages.typescript.getTypeScriptWorker())(e.uri)).getNavigationTree(e.uri.toString())).map((e) => {
|
|
695
|
+
let n = null, r = null;
|
|
696
|
+
return e.type === "formula" ? (n = "formula.margin-icon", r = T("scriptEditor.glyph.formula")) : e.type === "macro" ? (n = "macro.margin-icon", r = T("scriptEditor.glyph.macro")) : e.type === "autoRun" && (n = "autorun.margin-icon", r = T("scriptEditor.glyph.autoRun")), {
|
|
697
|
+
range: new t.Range(e.lineNumber, 1, e.lineNumber, 1),
|
|
698
|
+
options: {
|
|
699
|
+
isWholeLine: !1,
|
|
700
|
+
glyphMarginClassName: n,
|
|
701
|
+
glyphMarginHoverMessage: { value: r },
|
|
702
|
+
stickiness: t.editor.TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges
|
|
703
|
+
}
|
|
704
|
+
};
|
|
705
|
+
});
|
|
706
|
+
J.current && J.current.clear(), J.current = n.createDecorationsCollection(i);
|
|
707
|
+
}(e, t, n, r ? r.getFunctions().getItems() : d.EmptyArray), B((e) => ({
|
|
708
|
+
...e,
|
|
709
|
+
compiling: !1,
|
|
710
|
+
errors: i.filter((e) => e.severity === "error").map((e) => `${e.code}: ${e.message}`),
|
|
711
|
+
warnings: i.filter((e) => e.severity === "warning").map((e) => `${e.code}: ${e.message}`)
|
|
712
|
+
}));
|
|
713
|
+
}, [x]), K = g(f.debounce(we, 580), []), q = g(async (e) => {
|
|
714
|
+
if (!E.current) return;
|
|
715
|
+
let t = E.current.editor.getPosition(), n = { cursor: t ? t.toString() : "" };
|
|
716
|
+
e !== void 0 && (n.message = e), V(n);
|
|
717
|
+
}, []);
|
|
718
|
+
a(() => {}, [be]);
|
|
719
|
+
let Te = s(null), Ee = g(async () => {
|
|
720
|
+
await U(), b?.close();
|
|
721
|
+
}, [b]), De = g((e) => {
|
|
722
|
+
let t = E.current?.editor;
|
|
723
|
+
return !!t && (t.focus(e), !0);
|
|
724
|
+
}, [R]), Oe = g(async () => {
|
|
725
|
+
let e = E.current?.editor, t = e?.getModel(), n = e?.getSelection();
|
|
726
|
+
if (!t || !n) return;
|
|
727
|
+
let r = n.isEmpty() ? t.getLineContent(n.positionLineNumber) + "\n" : t.getValueInRange(n);
|
|
728
|
+
try {
|
|
729
|
+
await navigator.clipboard?.writeText(r);
|
|
730
|
+
} catch {}
|
|
731
|
+
}, []), ke = g(async () => {
|
|
732
|
+
let e = E.current, t = e?.editor, n = t?.getModel(), r = t?.getSelection();
|
|
733
|
+
if (!n || !r) return;
|
|
734
|
+
let i = r.isEmpty() ? new e.monaco.Range(r.positionLineNumber, 1, r.positionLineNumber + 1, 1) : r, a = n.getValueInRange(i);
|
|
735
|
+
try {
|
|
736
|
+
await navigator.clipboard?.writeText(a);
|
|
737
|
+
} catch {
|
|
738
|
+
return;
|
|
739
|
+
}
|
|
740
|
+
t.pushUndoStop(), t.executeEdits("cut", [{
|
|
741
|
+
range: i,
|
|
742
|
+
text: "",
|
|
743
|
+
forceMoveMarkers: !0
|
|
744
|
+
}]), t.pushUndoStop(), t.focus();
|
|
745
|
+
}, []), Ae = g(async () => {
|
|
746
|
+
let e = E.current?.editor;
|
|
747
|
+
if (!e) return;
|
|
748
|
+
let t;
|
|
749
|
+
try {
|
|
750
|
+
t = await navigator.clipboard?.readText();
|
|
751
|
+
} catch {
|
|
752
|
+
return;
|
|
753
|
+
}
|
|
754
|
+
if (!t) return;
|
|
755
|
+
let n = e.getSelection();
|
|
756
|
+
e.pushUndoStop(), e.executeEdits("paste", [{
|
|
757
|
+
range: n,
|
|
758
|
+
text: t,
|
|
759
|
+
forceMoveMarkers: !0
|
|
760
|
+
}]), e.pushUndoStop(), e.focus();
|
|
761
|
+
}, []), J = s(null), je = g((t, n) => {
|
|
762
|
+
E.current = {
|
|
763
|
+
monaco: n,
|
|
764
|
+
editor: t
|
|
765
|
+
}, I.current = F ?? null;
|
|
766
|
+
let r = t.getModel(), i = [];
|
|
767
|
+
Se(!0);
|
|
768
|
+
let a = x?.getModules().getItems()[0]?.getSource() ?? "";
|
|
769
|
+
return t.getValue() !== a && t.setValue(a), he ? (q(""), K(r, n, t), D(n)) : (he = !0, q("Loading Types"), import("./MBTRgCPV6sAugbR3.mjs").then((t) => e(t.default, 1)).then(async (e) => {
|
|
770
|
+
q(""), e.AutoTypings.create(t, {
|
|
771
|
+
shareCache: !0,
|
|
772
|
+
dontAdaptEditorOptions: !0,
|
|
773
|
+
monaco: n,
|
|
774
|
+
onUpdate: (e, t) => {
|
|
775
|
+
if (e.type === "LookedUpPackage" && e.success !== void 0) {
|
|
776
|
+
let e = n.languages.typescript.typescriptDefaults.getDiagnosticsOptions();
|
|
777
|
+
n.languages.typescript.typescriptDefaults.setDiagnosticsOptions({
|
|
778
|
+
...e,
|
|
779
|
+
diagnosticCodesToIgnore: []
|
|
780
|
+
});
|
|
781
|
+
}
|
|
782
|
+
},
|
|
783
|
+
onError: (e) => {
|
|
784
|
+
e === "Not implemented yet" && (e = "Compile Errors"), console.warn("Error compiling types", e);
|
|
785
|
+
}
|
|
786
|
+
}).then((e) => {
|
|
787
|
+
Te.current = e, K(t.getModel(), n, t), (() => {
|
|
788
|
+
if (fe) return;
|
|
789
|
+
let e = (e, t) => {
|
|
790
|
+
try {
|
|
791
|
+
if (t === void 0) try {
|
|
792
|
+
delete globalThis[e];
|
|
793
|
+
} catch {
|
|
794
|
+
try {
|
|
795
|
+
globalThis[e] = void 0;
|
|
796
|
+
} catch {}
|
|
797
|
+
}
|
|
798
|
+
else globalThis[e] = t;
|
|
799
|
+
} catch {}
|
|
800
|
+
}, t = w.length;
|
|
801
|
+
for (let n = 0; n < t; n++) {
|
|
802
|
+
let t = w[n];
|
|
803
|
+
e(t, C[t]);
|
|
804
|
+
}
|
|
805
|
+
C = void 0, fe = !0;
|
|
806
|
+
})(), D(n);
|
|
807
|
+
});
|
|
808
|
+
})), ge || (ge = !0, function(e, t) {
|
|
809
|
+
t.languages.registerInlayHintsProvider("typescript", { provideInlayHints(e, n, r) {
|
|
810
|
+
let i = [];
|
|
811
|
+
for (let n = 1; n < e.getLineCount() + 1; n++) {
|
|
812
|
+
let r = {
|
|
813
|
+
startLineNumber: n,
|
|
814
|
+
startColumn: 1,
|
|
815
|
+
endLineNumber: n,
|
|
816
|
+
endColumn: e.getLineLength(n) + 1
|
|
817
|
+
}, a = e.getValueInRange(r).indexOf("hint");
|
|
818
|
+
a !== -1 && i.push({
|
|
819
|
+
kind: t.languages.InlayHintKind.Type,
|
|
820
|
+
position: {
|
|
821
|
+
lineNumber: r.startLineNumber,
|
|
822
|
+
column: a + 4 + 1
|
|
823
|
+
},
|
|
824
|
+
label: "[hint]"
|
|
825
|
+
});
|
|
826
|
+
}
|
|
827
|
+
return {
|
|
828
|
+
hints: i,
|
|
829
|
+
dispose: () => {}
|
|
830
|
+
};
|
|
831
|
+
} });
|
|
832
|
+
}(0, n)), i.push(t.addAction({
|
|
833
|
+
id: "executeScript",
|
|
834
|
+
label: "Execute",
|
|
835
|
+
keybindings: [n.KeyCode.F8],
|
|
836
|
+
run: async (e) => {
|
|
837
|
+
let t = await Ce();
|
|
838
|
+
W(t);
|
|
839
|
+
}
|
|
840
|
+
})), i.push(t.addAction({
|
|
841
|
+
id: "saveScript",
|
|
842
|
+
label: "Save Script",
|
|
843
|
+
keybindings: [n.KeyMod.CtrlCmd | n.KeyCode.KeyS],
|
|
844
|
+
run: (e) => {
|
|
845
|
+
U();
|
|
846
|
+
}
|
|
847
|
+
})), i.push(t.onMouseDown(async (e) => {
|
|
848
|
+
if (e.target.type === n.editor.MouseTargetType.GUTTER_GLYPH_MARGIN) {
|
|
849
|
+
e.event.browserEvent.preventDefault();
|
|
850
|
+
let t = e.target.position.lineNumber, i = await (await (await n.languages.typescript.getTypeScriptWorker())(r.uri)).getNavigationTree(r.uri.toString()), a = await U();
|
|
851
|
+
if (!a) return;
|
|
852
|
+
let o = a.getFunctions().getItems(), s = k(r, n, o, i).find((e) => e.lineNumber === t);
|
|
853
|
+
if (s) {
|
|
854
|
+
let t = e.event.browserEvent.button;
|
|
855
|
+
if (t === 0) {
|
|
856
|
+
if (s.type === "macro" || s.type === "autoRun") W({ functionName: s.name });
|
|
857
|
+
else if (s.type === "formula") {
|
|
858
|
+
let e = o?.find((e) => e.getName() === s.name);
|
|
859
|
+
e && L?.execute(e);
|
|
860
|
+
}
|
|
861
|
+
} else t === 2 && (console.log("Context menu for function:", s.name), e.event.browserEvent.preventDefault());
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
})), i.push(t.onDidChangeModelContent(() => {
|
|
865
|
+
V({ dirty: !0 }), K(r, n, t);
|
|
866
|
+
})), i.push(n.editor.onDidChangeMarkers((e) => {
|
|
867
|
+
e.some((e) => e.toString() === r.uri.toString());
|
|
868
|
+
})), i.push(r.onDidChangeContent((e) => {
|
|
869
|
+
let n = x.getModules().getByName("scripts")?.getSource(), r = t.getValue(), i = (n?.length ?? 0) !== r.length || n !== r;
|
|
870
|
+
V({ dirty: i });
|
|
871
|
+
})), i.push(t.onDidChangeCursorPosition((e) => {
|
|
872
|
+
q();
|
|
873
|
+
})), () => {
|
|
874
|
+
for (let e of i) try {
|
|
875
|
+
e.dispose();
|
|
876
|
+
} catch {}
|
|
877
|
+
};
|
|
878
|
+
}, [x, F]), Me = o(() => G ? null : v || y("div", {
|
|
879
|
+
style: {
|
|
880
|
+
position: "absolute",
|
|
881
|
+
width: "100%",
|
|
882
|
+
height: "100%"
|
|
883
|
+
},
|
|
884
|
+
children: T("scriptEditor.loading")
|
|
885
|
+
}), [G, v]), Y = o(() => ({
|
|
886
|
+
...le,
|
|
887
|
+
fixedOverflowWidgets: !1,
|
|
888
|
+
contextmenu: !1,
|
|
889
|
+
readOnly: l
|
|
890
|
+
}), [l]), X = s(null);
|
|
891
|
+
a(() => {
|
|
892
|
+
let e = {
|
|
893
|
+
theme: m ? "extended-dark" : "extended",
|
|
894
|
+
options: Y,
|
|
895
|
+
value: x?.getModules()?.getByName("scripts")?.getSource() ?? "",
|
|
896
|
+
beforeMount: _e,
|
|
897
|
+
onValidate: ve
|
|
898
|
+
}, t = ((e) => {
|
|
899
|
+
if (j) return j;
|
|
900
|
+
if (!C) {
|
|
901
|
+
C = {};
|
|
902
|
+
let e = w.length;
|
|
903
|
+
for (let t = 0; t < e; t++) {
|
|
904
|
+
let e = w[t];
|
|
905
|
+
C[e] = globalThis[e];
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
let t = document.createElement("div");
|
|
909
|
+
t.style.display = "none";
|
|
910
|
+
let n = document.createElement("div");
|
|
911
|
+
n.style.width = "100%", n.style.height = "100%", n.style.display = "flex", n.style.flex = "1 1 100%", t.appendChild(n), document.body.appendChild(t);
|
|
912
|
+
let r = u(n);
|
|
913
|
+
return j = {
|
|
914
|
+
root: r,
|
|
915
|
+
hostEl: n,
|
|
916
|
+
stashEl: t,
|
|
917
|
+
props: e,
|
|
918
|
+
setProps: null
|
|
919
|
+
}, r.render(y(ye, {})), j;
|
|
920
|
+
})(e);
|
|
921
|
+
return t.props = e, t.setProps?.(e), N = (e, t) => je(e, t), X.current?.appendChild(t.hostEl), M && (P = je(M.editor, M.monaco)), () => {
|
|
922
|
+
P?.(), P = null, N = null, E.current = null, j?.stashEl.appendChild(j.hostEl);
|
|
923
|
+
};
|
|
924
|
+
}, []), a(() => {
|
|
925
|
+
if (!j) return;
|
|
926
|
+
let e = {
|
|
927
|
+
...j.props,
|
|
928
|
+
theme: m ? "extended-dark" : "extended",
|
|
929
|
+
options: Y
|
|
930
|
+
};
|
|
931
|
+
j.props = e, j.setProps?.(e);
|
|
932
|
+
}, [m, Y]), a(() => {
|
|
933
|
+
let e = E.current, t = e?.editor;
|
|
934
|
+
if (!t) return;
|
|
935
|
+
I.current = F ?? null;
|
|
936
|
+
let n = x?.getModules().getItems()[0]?.getSource() ?? "";
|
|
937
|
+
t.getValue() !== n && (t.setValue(n), K(t.getModel(), e.monaco, t), V({ dirty: !1 }));
|
|
938
|
+
}, [x, F]);
|
|
939
|
+
let Ne = oe("div", {
|
|
940
|
+
style: {
|
|
941
|
+
display: "flex",
|
|
942
|
+
flex: "1 1 100%",
|
|
943
|
+
width: "100%",
|
|
944
|
+
flexDirection: "row",
|
|
945
|
+
position: "relative",
|
|
946
|
+
boxSizing: "border-box"
|
|
947
|
+
},
|
|
948
|
+
children: [y("div", {
|
|
949
|
+
ref: X,
|
|
950
|
+
style: {
|
|
951
|
+
display: "flex",
|
|
952
|
+
flex: "1 1 100%",
|
|
953
|
+
width: "100%",
|
|
954
|
+
position: "relative"
|
|
955
|
+
}
|
|
956
|
+
}), Me]
|
|
957
|
+
}), Z = te(n, () => ({
|
|
958
|
+
isScriptEditorElement: () => !0,
|
|
959
|
+
showCommandPalette: () => {
|
|
960
|
+
E.current?.editor && E.current.editor.trigger("keyboard", "editor.action.quickCommand", null);
|
|
961
|
+
},
|
|
962
|
+
getScripts: () => x,
|
|
963
|
+
focus: (e) => {
|
|
964
|
+
De(e);
|
|
965
|
+
},
|
|
966
|
+
close: () => Ee(),
|
|
967
|
+
insertSnippet: (e) => E.current?.editor ? (async (e, t, n) => {
|
|
968
|
+
let r = e.getModel();
|
|
969
|
+
if (!r) return;
|
|
970
|
+
let i = await (await (await t.languages.typescript.getTypeScriptWorker())(r.uri)).getNavigationTree(r.uri.toString()), a = e.getPosition(), o = { ...a };
|
|
971
|
+
o.lineNumber = 1, o.column = 1;
|
|
972
|
+
let s = !1;
|
|
973
|
+
for (let e = a.lineNumber; e >= 1; e--) if (r.getLineContent(e).trim() === "") {
|
|
974
|
+
let t = A(i, r.getOffsetAt({
|
|
975
|
+
lineNumber: e,
|
|
976
|
+
column: 1
|
|
977
|
+
}), "function");
|
|
978
|
+
if (!t || me(t)) {
|
|
979
|
+
s = !0, o.lineNumber = e + 1;
|
|
980
|
+
break;
|
|
981
|
+
}
|
|
982
|
+
{
|
|
983
|
+
let n = t.spans[0].start;
|
|
984
|
+
e = r.getPositionAt(n).lineNumber, o.lineNumber = e;
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
let c = n, l = !1;
|
|
988
|
+
!s && !c.startsWith("\n") && o.lineNumber > 1 && (c = "\n" + c, l = !0);
|
|
989
|
+
let u = !1;
|
|
990
|
+
r.getLineCount() > 1 && (c.endsWith("\n\n") || (c += "\n\n", u = !0));
|
|
991
|
+
let d = [{
|
|
992
|
+
range: new t.Range(o.lineNumber, o.column, o.lineNumber, o.column),
|
|
993
|
+
text: `${c}`
|
|
994
|
+
}], f = null;
|
|
995
|
+
r.pushEditOperations([], d, (e) => (f = e[0].range, l && f.startLineNumber++, u && f.endLineNumber--, [new t.Selection(f.startLineNumber, f.startColumn, f.endLineNumber, f.endColumn)])), e.setSelection({
|
|
996
|
+
startLineNumber: f.endLineNumber,
|
|
997
|
+
startColumn: f.endColumn,
|
|
998
|
+
endLineNumber: f.startLineNumber,
|
|
999
|
+
endColumn: f.startColumn
|
|
1000
|
+
});
|
|
1001
|
+
})(E.current.editor, E.current.monaco, e) : Promise.resolve(),
|
|
1002
|
+
saveSource: async () => {
|
|
1003
|
+
await U();
|
|
1004
|
+
},
|
|
1005
|
+
runAction: (e) => {
|
|
1006
|
+
let t = E.current?.editor;
|
|
1007
|
+
t && (t.focus(), t.trigger("source", e, null));
|
|
1008
|
+
},
|
|
1009
|
+
copy: () => Oe(),
|
|
1010
|
+
cut: () => ke(),
|
|
1011
|
+
paste: () => Ae()
|
|
1012
|
+
}), [F]), [Q, Pe] = c(null), Fe = g((e) => {
|
|
1013
|
+
e !== null && Pe(e);
|
|
1014
|
+
}, []), $ = h.useCommandScope();
|
|
1015
|
+
return a(() => {
|
|
1016
|
+
if (!$ || !Q) return;
|
|
1017
|
+
let e = $.contribution();
|
|
1018
|
+
return function(e, t) {
|
|
1019
|
+
let n = t.scriptEditor, r = t;
|
|
1020
|
+
e.updateCommand("scriptingHelp", { callback: () => {
|
|
1021
|
+
window?.open("https://www.sheetxl.com/docs/guides/concepts/scripting");
|
|
1022
|
+
} }), e.updateCommand("showScriptingCommands", { callback: () => {
|
|
1023
|
+
n.showCommandPalette();
|
|
1024
|
+
} }), e.updateCommand("insertScript", { callback: (e) => n.insertSnippet(e ?? "") }), e.updateCommand("saveScripts", {
|
|
1025
|
+
disabledReasons: r?.isDirty ? [] : [p("reason.noChangesToSave")],
|
|
1026
|
+
callback: async () => {
|
|
1027
|
+
await n.saveSource();
|
|
1028
|
+
}
|
|
1029
|
+
}), e.updateCommand("copy", { callback: () => n.copy() }), e.updateCommand("cut", { callback: () => n.cut() }), e.updateCommand("paste", { callback: () => n.paste() }), e.updateCommand("selectAll", { callback: () => n.runAction("editor.action.selectAll") }), e.updateCommand("find", { callback: () => n.runAction("actions.find") }), e.updateCommand("findReplace", { callback: () => n.runAction("editor.action.startFindReplaceAction") }), e.updateCommand("goto", { callback: () => n.runAction("editor.action.gotoLine") });
|
|
1030
|
+
}(e, {
|
|
1031
|
+
scriptEditor: Q,
|
|
1032
|
+
isDirty: O
|
|
1033
|
+
}), () => {
|
|
1034
|
+
e.remove();
|
|
1035
|
+
};
|
|
1036
|
+
}, [
|
|
1037
|
+
$,
|
|
1038
|
+
Q,
|
|
1039
|
+
O
|
|
1040
|
+
]), a(() => (ie && requestAnimationFrame(() => {
|
|
1041
|
+
Z.current?.focus();
|
|
1042
|
+
}), () => {
|
|
1043
|
+
E.current?.editor && requestAnimationFrame(() => {
|
|
1044
|
+
Z.current?.contains(document.activeElement) && Z.current?.focus();
|
|
1045
|
+
});
|
|
1046
|
+
}), []), y("div", {
|
|
1047
|
+
className: se("script-editor", ue, r),
|
|
1048
|
+
style: {
|
|
1049
|
+
display: "flex",
|
|
1050
|
+
flexDirection: "row",
|
|
1051
|
+
flex: "1 1 100%",
|
|
1052
|
+
position: "relative",
|
|
1053
|
+
...i
|
|
1054
|
+
},
|
|
1055
|
+
ref: ce([Z, Fe]),
|
|
1056
|
+
...de,
|
|
1057
|
+
children: Ne
|
|
1058
|
+
});
|
|
1059
|
+
})), z = null, be = (e) => {
|
|
1060
|
+
z = e;
|
|
1061
|
+
}, B = () => z, V = i((e) => {
|
|
1062
|
+
let { scope: t, data: n } = e, { workbook: r } = n, i = _(), o = ie(), s = o.getOpen(), c = g(async (e) => {
|
|
1063
|
+
if (!r) return;
|
|
1064
|
+
let t = null, n = r.getScripts();
|
|
1065
|
+
if (e?.declaration || e?.functionName) {
|
|
1066
|
+
let r = e.declaration ? e.declaration.getName() : e.functionName;
|
|
1067
|
+
(await n.searchFunctions({ name: r })).length > 0 && (t = r);
|
|
1068
|
+
}
|
|
1069
|
+
if (t) try {
|
|
1070
|
+
await n.executeMacro(t);
|
|
1071
|
+
} catch (e) {
|
|
1072
|
+
i.showError(e);
|
|
1073
|
+
return;
|
|
1074
|
+
}
|
|
1075
|
+
}, [r, i]), l = g(() => {
|
|
1076
|
+
let e = B();
|
|
1077
|
+
e ? r && e({ workbook: r }) : o.getOpen().includes("scriptEditor") ? o.close("scriptEditor") : o.activate("scriptEditor", {});
|
|
1078
|
+
}, [r, o]), u = s.includes("scriptEditor");
|
|
1079
|
+
return a(() => {
|
|
1080
|
+
if (!t) return;
|
|
1081
|
+
let e = t.contribution();
|
|
1082
|
+
return e.updateCommand("showScriptEditor", {
|
|
1083
|
+
callback: () => {
|
|
1084
|
+
l();
|
|
1085
|
+
},
|
|
1086
|
+
state: u
|
|
1087
|
+
}), e.updateCommand("executeScript", { callback: (e) => c(e ?? {}) }), () => {
|
|
1088
|
+
e.remove();
|
|
1089
|
+
};
|
|
1090
|
+
}, [
|
|
1091
|
+
t,
|
|
1092
|
+
u,
|
|
1093
|
+
r,
|
|
1094
|
+
c,
|
|
1095
|
+
l
|
|
1096
|
+
]), re(r, { onLoad: () => {
|
|
1097
|
+
r?.getScripts().start();
|
|
1098
|
+
} }), null;
|
|
1099
|
+
});
|
|
1100
|
+
V.displayName = "WorkbookScriptCommands";
|
|
1101
|
+
var H = {
|
|
1102
|
+
"reason.noChangesToSave": "No changes to save",
|
|
1103
|
+
"scriptEditor.glyph.autoRun": "Auto Run",
|
|
1104
|
+
"scriptEditor.glyph.formula": "Formula",
|
|
1105
|
+
"scriptEditor.glyph.macro": "Macro",
|
|
1106
|
+
"scriptEditor.loading": "Loading...",
|
|
1107
|
+
"scriptEditor.saving": "Saving Scripts..."
|
|
1108
|
+
}, xe = [
|
|
1109
|
+
{
|
|
1110
|
+
sourceId: "groups",
|
|
1111
|
+
catalog: {
|
|
1112
|
+
scope: "ui",
|
|
1113
|
+
label: "Interface",
|
|
1114
|
+
tag: "en",
|
|
1115
|
+
version: 1,
|
|
1116
|
+
commands: {
|
|
1117
|
+
customFunctionOptions: {
|
|
1118
|
+
label: "Custom",
|
|
1119
|
+
description: "Insert a custom function."
|
|
1120
|
+
},
|
|
1121
|
+
scriptEditor: {
|
|
1122
|
+
label: "Script (Typescript)",
|
|
1123
|
+
icon: "ScriptRun"
|
|
1124
|
+
},
|
|
1125
|
+
scriptsOptions: {
|
|
1126
|
+
label: "Macros",
|
|
1127
|
+
description: "Run or manage macros."
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
},
|
|
1132
|
+
{
|
|
1133
|
+
sourceId: "scriptEditor",
|
|
1134
|
+
catalog: {
|
|
1135
|
+
scope: "scriptEditor",
|
|
1136
|
+
label: "Script Editor",
|
|
1137
|
+
tag: "en",
|
|
1138
|
+
version: 1,
|
|
1139
|
+
commands: {
|
|
1140
|
+
scriptingHelp: {
|
|
1141
|
+
label: "Scripting Help",
|
|
1142
|
+
description: "Open Documentation For Scripting.",
|
|
1143
|
+
groupLabels: { scriptsOptions: "Help" },
|
|
1144
|
+
icon: "Help"
|
|
1145
|
+
},
|
|
1146
|
+
showScriptingCommands: {
|
|
1147
|
+
label: "Scripting Command Palette",
|
|
1148
|
+
description: "Show commands for scripting.",
|
|
1149
|
+
groupLabels: { scriptsOptions: "Command Palette" },
|
|
1150
|
+
icon: "Keyboard",
|
|
1151
|
+
shortcut: "F1"
|
|
1152
|
+
},
|
|
1153
|
+
insertScript: {
|
|
1154
|
+
label: "Insert Script",
|
|
1155
|
+
description: "Inserts a script from a set of templates.",
|
|
1156
|
+
icon: "ScriptInsert"
|
|
1157
|
+
},
|
|
1158
|
+
saveScripts: {
|
|
1159
|
+
label: "Save Script",
|
|
1160
|
+
description: "Save the current scripts.",
|
|
1161
|
+
icon: "ScriptSave"
|
|
1162
|
+
}
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
},
|
|
1166
|
+
{
|
|
1167
|
+
sourceId: "workbookScript",
|
|
1168
|
+
catalog: {
|
|
1169
|
+
scope: "workbook",
|
|
1170
|
+
label: "Workbook",
|
|
1171
|
+
tag: "en",
|
|
1172
|
+
version: 1,
|
|
1173
|
+
commands: {
|
|
1174
|
+
showScriptEditor: {
|
|
1175
|
+
label: "Scripts",
|
|
1176
|
+
description: "Show the script editor.",
|
|
1177
|
+
groupLabels: { scriptsOptions: "Script Editor…" },
|
|
1178
|
+
icon: "ScriptRun",
|
|
1179
|
+
shortcut: ["alt+F11"]
|
|
1180
|
+
},
|
|
1181
|
+
executeScript: {
|
|
1182
|
+
label: "Run Script",
|
|
1183
|
+
description: "Run the last executed script.",
|
|
1184
|
+
icon: "ScriptRun",
|
|
1185
|
+
shortcut: "F8"
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1190
|
+
], { DefaultCommandCatalogService: U } = h, W = !1, G = (e) => {
|
|
1191
|
+
let { model: t, entryKey: n, frame: r, ref: i, ...a } = e;
|
|
1192
|
+
return y(R, {
|
|
1193
|
+
ref: i,
|
|
1194
|
+
frame: r,
|
|
1195
|
+
scripts: t?.getScripts(),
|
|
1196
|
+
...a
|
|
1197
|
+
});
|
|
1198
|
+
}, Se = () => {
|
|
1199
|
+
v.registerTaskPane({
|
|
1200
|
+
key: "scriptEditor",
|
|
1201
|
+
getTitle: () => "Script (Typescript)",
|
|
1202
|
+
getIcon: () => "ScriptRun",
|
|
1203
|
+
component: G,
|
|
1204
|
+
keepMounted: !0
|
|
1205
|
+
}, !0), function() {
|
|
1206
|
+
if (W) return;
|
|
1207
|
+
W = !0;
|
|
1208
|
+
let e = U;
|
|
1209
|
+
e.registerFromManifest("@sheetxl/scripting-react", import.meta.url, {
|
|
1210
|
+
messages: H,
|
|
1211
|
+
catalogs: xe
|
|
1212
|
+
}), e.prefetch();
|
|
1213
|
+
}(), h.DefaultCommandRegistry.registerDynamic("workbook", V);
|
|
1214
|
+
};
|
|
1215
|
+
export { R as ScriptEditor, Se as ScriptingReactPlugin, V as WorkbookScriptCommands, B as getScriptEditorOpener, be as setScriptEditorOpener };
|