@sheetxl/scripting-react 0.8.0-beta.2 → 0.8.0-beta.20
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 +8 -7
- package/browser/esm/{CjmZ474x4bpyM84G.mjs → ByZ1oruplQvcyzml.mjs} +3 -3
- package/browser/esm/{MkaRYDR2k57n-olj.mjs → _0P-3FrZVqtnVTn9.mjs} +162 -160
- package/browser/esm/{rgUbThqZfKTH25kz.mjs → fA_y6YIyxaaB0y76.mjs} +45 -45
- package/browser/esm/index.mjs +440 -315
- package/node/esm/index.mjs +458 -336
- package/package.json +12 -12
- package/types/src/mergeImports.d.ts +64 -0
- package/browser/cjs/BAh9DnP6CTFXt1HI.cjs +0 -1
- package/browser/cjs/Bf_pmg4C0o1aKVy-.cjs +0 -2
- package/browser/cjs/CsWMPekp2nRo3bHt.cjs +0 -11
- package/browser/cjs/index.cjs +0 -9
package/browser/esm/index.mjs
CHANGED
|
@@ -1,30 +1,32 @@
|
|
|
1
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
2
|
/**
|
|
3
|
-
* @license @sheetxl/scripting-react - Scripting React - Monaco based script editor and scripting UI for SheetXL. - v0.8.0-beta.
|
|
3
|
+
* @license @sheetxl/scripting-react - Scripting React - Monaco based script editor and scripting UI for SheetXL. - v0.8.0-beta.20
|
|
4
4
|
*
|
|
5
5
|
* (C) 2026-present SheetXL Inc. & Michael T. Ford
|
|
6
|
-
* License:
|
|
6
|
+
* License: SheetXL EULA — https://www.sheetxl.com/eula
|
|
7
7
|
*/
|
|
8
|
-
import { n as e } from "./
|
|
8
|
+
import { n as e } from "./ByZ1oruplQvcyzml.mjs";
|
|
9
9
|
import { Suspense as t, forwardRef as n, memo as r, useEffect as i, useMemo as a, useRef as o, useState as s, version as c } from "react";
|
|
10
10
|
import { createRoot as l } from "react-dom/client";
|
|
11
11
|
import { CommonUtils as u, TimerUtils as d, defineLazyModule as f, messageKey as p } from "@sheetxl/utils";
|
|
12
12
|
import { DocTags as m } from "@sheetxl/scripting";
|
|
13
13
|
import { IScript as h } from "@sheetxl/sdk";
|
|
14
|
-
import { Command as g, lazyComponent as
|
|
15
|
-
import { jsx as
|
|
16
|
-
import { DefaultTaskPaneRegistry as
|
|
17
|
-
function
|
|
14
|
+
import { Command as g, lazyComponent as _, useCallbackRef as v, useCommands as ee, useImperativeElement as te, useLazyRetry as y, useNotifier as ne, useTranslator as re } from "@sheetxl/utils-react";
|
|
15
|
+
import { jsx as b, jsxs as ie } from "react/jsx-runtime";
|
|
16
|
+
import { DefaultTaskPaneRegistry as x, useModelListener as ae, useTaskPaneArea as S, useWorkbook as oe } from "@sheetxl/react";
|
|
17
|
+
function se(e) {
|
|
18
18
|
var t, n, r = "";
|
|
19
19
|
if (typeof e == "string" || typeof e == "number") r += e;
|
|
20
|
-
else if (typeof e == "object")
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
else if (typeof e == "object") {
|
|
21
|
+
if (Array.isArray(e)) {
|
|
22
|
+
var i = e.length;
|
|
23
|
+
for (t = 0; t < i; t++) e[t] && (n = se(e[t])) && (r && (r += " "), r += n);
|
|
24
|
+
} else for (n in e) e[n] && (r && (r += " "), r += n);
|
|
25
|
+
}
|
|
24
26
|
return r;
|
|
25
27
|
}
|
|
26
28
|
function ce() {
|
|
27
|
-
for (var e, t, n = 0, r = "", i = arguments.length; n < i; n++) (e = arguments[n]) && (t =
|
|
29
|
+
for (var e, t, n = 0, r = "", i = arguments.length; n < i; n++) (e = arguments[n]) && (t = se(e)) && (r && (r += " "), r += t);
|
|
28
30
|
return r;
|
|
29
31
|
}
|
|
30
32
|
function C(e, t) {
|
|
@@ -263,7 +265,48 @@ var le = parseInt(c.split(".")[0], 10) >= 19 ? function(e) {
|
|
|
263
265
|
{ include: "common" }
|
|
264
266
|
]
|
|
265
267
|
}
|
|
266
|
-
}, ue = {
|
|
268
|
+
}, T = /(?:\s|\/\/[^\n]*|\/\*[\s\S]*?\*\/)*/y, E = /(import\b\s*(?:type\s+(?!from\b))?)(?:([^'";]*?)\s*\bfrom\s*)?(['"])([^'"\n]+)\3[ \t]*;?/y, D = (e) => e.replace(/\s+/g, " ").trim(), ue = (e) => {
|
|
269
|
+
let t = [], n = 0;
|
|
270
|
+
for (;;) {
|
|
271
|
+
T.lastIndex = n, T.exec(e), E.lastIndex = T.lastIndex;
|
|
272
|
+
let r = E.exec(e);
|
|
273
|
+
if (!r) return t;
|
|
274
|
+
let i = r[2] ?? "", a = r.index + r[1].length, o = i.indexOf("{"), s = i.lastIndexOf("}"), c = o >= 0 && s > o, l = c ? i.slice(0, o) + i.slice(s + 1) : i;
|
|
275
|
+
t.push({
|
|
276
|
+
start: r.index,
|
|
277
|
+
end: E.lastIndex,
|
|
278
|
+
text: r[0],
|
|
279
|
+
module: r[4],
|
|
280
|
+
quote: r[3],
|
|
281
|
+
typeOnly: /\btype\s+$/.test(r[1]),
|
|
282
|
+
binding: D(l).replace(/\s*,$/, ""),
|
|
283
|
+
names: c ? i.slice(o + 1, s).split(",").map(D).filter(Boolean) : null,
|
|
284
|
+
namesStart: a + o + 1,
|
|
285
|
+
namesEnd: a + s
|
|
286
|
+
}), n = E.lastIndex;
|
|
287
|
+
}
|
|
288
|
+
}, O = (e) => [
|
|
289
|
+
e.typeOnly,
|
|
290
|
+
e.binding,
|
|
291
|
+
e.names?.join(","),
|
|
292
|
+
e.module
|
|
293
|
+
].join("|"), k = (e) => `${e.typeOnly ? "type " : ""}${e.module}`, de = (e, t, n) => {
|
|
294
|
+
let r = e.slice(t.namesStart, t.namesEnd), i = r.trimEnd();
|
|
295
|
+
if (i.trim() === "") return {
|
|
296
|
+
offset: t.namesStart,
|
|
297
|
+
text: ` ${n.join(", ")}${r === "" ? " " : ""}`
|
|
298
|
+
};
|
|
299
|
+
let a = t.namesStart + i.length, o = i.endsWith(","), s = i.lastIndexOf("\n");
|
|
300
|
+
if (s < 0) return {
|
|
301
|
+
offset: a,
|
|
302
|
+
text: `${o ? " " : ", "}${n.join(", ")}`
|
|
303
|
+
};
|
|
304
|
+
let c = /^[ \t]*/.exec(i.slice(s + 1))[0];
|
|
305
|
+
return {
|
|
306
|
+
offset: a,
|
|
307
|
+
text: `${o ? "" : ","}\n${c}${n.join(`,\n${c}`)}${o ? "," : ""}`
|
|
308
|
+
};
|
|
309
|
+
}, fe = {
|
|
267
310
|
lightbulb: { enabled: !1 },
|
|
268
311
|
tabSize: 2,
|
|
269
312
|
acceptSuggestionOnCommitCharacter: !0,
|
|
@@ -326,30 +369,36 @@ var le = parseInt(c.split(".")[0], 10) >= 19 ? function(e) {
|
|
|
326
369
|
wordWrapColumn: 80,
|
|
327
370
|
wordWrapMinified: !0,
|
|
328
371
|
wrappingIndent: "none"
|
|
329
|
-
},
|
|
372
|
+
}, pe = "_script-editor_1kuph_5", me = (e) => {
|
|
330
373
|
let t = e?.getModules();
|
|
331
374
|
return t && t.getByName(h.DEFAULT_MODULE), h.DEFAULT_MODULE;
|
|
332
|
-
},
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
e(
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
|
|
375
|
+
}, A = (e) => e?.getModules()?.getByName(me(e)) ?? null, j, he = f("scripting-react:monaco", async () => {
|
|
376
|
+
(function() {
|
|
377
|
+
if (typeof window > "u") return;
|
|
378
|
+
let e = window;
|
|
379
|
+
if (e.__sxlDefineShim) return;
|
|
380
|
+
e.__sxlDefineShim = !0;
|
|
381
|
+
let t = [], n = null, r = (...e) => {
|
|
382
|
+
typeof n == "function" ? n(...e) : t.push(e);
|
|
383
|
+
};
|
|
384
|
+
Object.defineProperty(e, "define", {
|
|
385
|
+
configurable: !1,
|
|
386
|
+
enumerable: !0,
|
|
387
|
+
get: () => typeof n == "function" ? n : r,
|
|
388
|
+
set(e) {
|
|
389
|
+
if (typeof e == "function") for (n = e; t.length;) try {
|
|
390
|
+
e(...t.shift());
|
|
391
|
+
} catch {}
|
|
392
|
+
}
|
|
393
|
+
});
|
|
394
|
+
})();
|
|
395
|
+
let [e] = await Promise.all([import("./fA_y6YIyxaaB0y76.mjs"), _e().catch((e) => {
|
|
396
|
+
console.warn("cant load types", e);
|
|
397
|
+
})]);
|
|
398
|
+
return e;
|
|
399
|
+
}, { prefetch: !1 }), M = ({ error: e }) => {
|
|
400
|
+
let t = y(), n = re();
|
|
401
|
+
return ie("div", {
|
|
353
402
|
style: {
|
|
354
403
|
display: "flex",
|
|
355
404
|
flexDirection: "column",
|
|
@@ -358,20 +407,136 @@ var le = parseInt(c.split(".")[0], 10) >= 19 ? function(e) {
|
|
|
358
407
|
gap: "8px",
|
|
359
408
|
flex: "1 1 100%"
|
|
360
409
|
},
|
|
361
|
-
children: [
|
|
410
|
+
children: [b("span", { children: e instanceof Error ? e.message : String(e) }), t ? b("button", {
|
|
362
411
|
type: "button",
|
|
363
412
|
onClick: t,
|
|
364
413
|
children: n("scriptEditor.retry")
|
|
365
414
|
}) : null]
|
|
366
415
|
});
|
|
367
|
-
},
|
|
368
|
-
|
|
369
|
-
var
|
|
416
|
+
}, N = _(he.load, { renderError: ({ error: e }) => b(M, { error: e }) }), P = ["define", "require"], ge = !1, F = "@0.8.0-beta.20";
|
|
417
|
+
F !== "@local" && F !== "@0.0.0" || (F = "");
|
|
418
|
+
var I = `https://cdn.jsdelivr.net/npm/@sheetxl/sdk${F}/types/scripting.d.ts`, L = null, R = null, _e = () => (R || (R = (async () => await (await fetch(I)).text())().then((e) => (L = e, e))).catch(() => {
|
|
419
|
+
R = null;
|
|
420
|
+
}), R), z = (e) => {
|
|
370
421
|
try {
|
|
371
422
|
e.languages.setMonarchTokensProvider("typescript", w);
|
|
372
423
|
} catch {}
|
|
373
|
-
},
|
|
374
|
-
|
|
424
|
+
}, B = !1, ve = async (e, t, n) => {
|
|
425
|
+
let r = e.getModel();
|
|
426
|
+
if (!r) return;
|
|
427
|
+
let i = await (await (await t.languages.typescript.getTypeScriptWorker())(r.uri)).getNavigationTree(r.uri.toString()), a = e.getPosition(), o = { ...a };
|
|
428
|
+
o.lineNumber = 1, o.column = 1;
|
|
429
|
+
let s = !1;
|
|
430
|
+
for (let e = a.lineNumber; e >= 1; e--) if (r.getLineContent(e).trim() === "") {
|
|
431
|
+
let t = be(i, r.getOffsetAt({
|
|
432
|
+
lineNumber: e,
|
|
433
|
+
column: 1
|
|
434
|
+
}), "function");
|
|
435
|
+
if (!t || H(t)) {
|
|
436
|
+
s = !0, o.lineNumber = e + 1;
|
|
437
|
+
break;
|
|
438
|
+
}
|
|
439
|
+
{
|
|
440
|
+
let n = t.spans[0].start;
|
|
441
|
+
e = r.getPositionAt(n).lineNumber, o.lineNumber = e;
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
let c = ((e, t) => {
|
|
445
|
+
let n = ue(e), r = n.length > 0 ? n[n.length - 1].end : 0, i = ue(t);
|
|
446
|
+
if (i.length === 0) return {
|
|
447
|
+
body: t,
|
|
448
|
+
inserts: [],
|
|
449
|
+
importsEnd: r
|
|
450
|
+
};
|
|
451
|
+
let a = "", o = 0;
|
|
452
|
+
for (let e of i) a += t.slice(o, e.start), o = e.end + (/^[ \t]*\r?\n/.exec(t.slice(e.end))?.[0].length ?? 0);
|
|
453
|
+
a = (a + t.slice(o)).replace(/^(?:[ \t]*\r?\n)+/, "");
|
|
454
|
+
let s = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map();
|
|
455
|
+
for (let e of n) {
|
|
456
|
+
if (s.add(O(e)), !e.names) continue;
|
|
457
|
+
let t = k(e);
|
|
458
|
+
l.has(t) || l.set(t, e);
|
|
459
|
+
let n = c.get(t);
|
|
460
|
+
n || c.set(t, n = /* @__PURE__ */ new Set());
|
|
461
|
+
for (let t of e.names) n.add(t);
|
|
462
|
+
}
|
|
463
|
+
let u = /* @__PURE__ */ new Map(), d = [], f = /* @__PURE__ */ new Map();
|
|
464
|
+
for (let e of i) {
|
|
465
|
+
if (!e.names || e.binding) {
|
|
466
|
+
let t = O(e);
|
|
467
|
+
if (s.has(t)) continue;
|
|
468
|
+
s.add(t), d.push(e.text);
|
|
469
|
+
continue;
|
|
470
|
+
}
|
|
471
|
+
let t = k(e), n = c.get(t);
|
|
472
|
+
n || c.set(t, n = /* @__PURE__ */ new Set());
|
|
473
|
+
let r = e.typeOnly ? c.get(e.module) : void 0, i = e.names.filter((e) => !n.has(e) && !r?.has(e));
|
|
474
|
+
if (i.length === 0) continue;
|
|
475
|
+
for (let e of i) n.add(e);
|
|
476
|
+
let a = l.get(t);
|
|
477
|
+
if (a) {
|
|
478
|
+
u.set(a, [...u.get(a) ?? [], ...i]);
|
|
479
|
+
continue;
|
|
480
|
+
}
|
|
481
|
+
let o = f.get(t);
|
|
482
|
+
if (o) {
|
|
483
|
+
o.names.push(...i), o.verbatim = !1;
|
|
484
|
+
continue;
|
|
485
|
+
}
|
|
486
|
+
let p = {
|
|
487
|
+
statement: e,
|
|
488
|
+
names: i,
|
|
489
|
+
verbatim: i.length === e.names.length
|
|
490
|
+
};
|
|
491
|
+
f.set(t, p), d.push(p);
|
|
492
|
+
}
|
|
493
|
+
let p = [];
|
|
494
|
+
for (let [t, n] of u) p.push(de(e, t, n));
|
|
495
|
+
if (p.sort((e, t) => e.offset - t.offset), d.length > 0) {
|
|
496
|
+
let t = d.map((e) => {
|
|
497
|
+
if (typeof e == "string") return e;
|
|
498
|
+
let { statement: t, names: n, verbatim: r } = e;
|
|
499
|
+
if (r) return t.text;
|
|
500
|
+
let { quote: i } = t;
|
|
501
|
+
return `import ${t.typeOnly ? "type " : ""}{ ${n.join(", ")} } from ${i}${t.module}${i};`;
|
|
502
|
+
}).join("\n");
|
|
503
|
+
r > 0 ? p.push({
|
|
504
|
+
offset: r,
|
|
505
|
+
text: `\n${t}`
|
|
506
|
+
}) : p.unshift({
|
|
507
|
+
offset: 0,
|
|
508
|
+
text: `${t}\n${/^[ \t]*\r?\n/.test(e) ? "" : "\n"}`
|
|
509
|
+
});
|
|
510
|
+
}
|
|
511
|
+
return {
|
|
512
|
+
body: a,
|
|
513
|
+
inserts: p,
|
|
514
|
+
importsEnd: r
|
|
515
|
+
};
|
|
516
|
+
})(r.getValue(), n), l = c.importsEnd > 0 ? r.getPositionAt(c.importsEnd).lineNumber : 0, u = c.body, d = "";
|
|
517
|
+
o.lineNumber <= l ? l < r.getLineCount() ? (o.lineNumber = l + 1, d = u.startsWith("\n") ? "" : "\n") : (o.lineNumber = l, o.column = r.getLineMaxColumn(l), d = "\n\n") : !s && !u.startsWith("\n") && o.lineNumber > 1 && (d = "\n");
|
|
518
|
+
let f = !1;
|
|
519
|
+
r.getLineCount() > 1 && (u.endsWith("\n\n") || (u += "\n\n", f = !0));
|
|
520
|
+
let p = r.validatePosition(o), m = new t.Range(p.lineNumber, p.column, p.lineNumber, p.column), h = [];
|
|
521
|
+
for (let e of c.inserts) {
|
|
522
|
+
let n = r.getPositionAt(e.offset);
|
|
523
|
+
n.lineNumber === m.startLineNumber && n.column === m.startColumn ? d = e.text + d : h.push({
|
|
524
|
+
range: new t.Range(n.lineNumber, n.column, n.lineNumber, n.column),
|
|
525
|
+
text: e.text
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
let g = d.split("\n").length - 1, _ = [{
|
|
529
|
+
range: m,
|
|
530
|
+
text: `${d}${u}`
|
|
531
|
+
}, ...h], v = null;
|
|
532
|
+
r.pushEditOperations([], _, (e) => (v = e[0].range, g > 0 && (v.startLineNumber += g, v.startColumn = 1), f && v.endLineNumber--, [new t.Selection(v.startLineNumber, v.startColumn, v.endLineNumber, v.endColumn)])), e.setSelection({
|
|
533
|
+
startLineNumber: v.endLineNumber,
|
|
534
|
+
startColumn: v.endColumn,
|
|
535
|
+
endLineNumber: v.startLineNumber,
|
|
536
|
+
endColumn: v.startColumn
|
|
537
|
+
});
|
|
538
|
+
};
|
|
539
|
+
function ye(e, t) {
|
|
375
540
|
let n = null, r = e.length;
|
|
376
541
|
for (let i = 0; !n && i < r; i++) {
|
|
377
542
|
let r = e[i];
|
|
@@ -379,47 +544,64 @@ function he(e, t) {
|
|
|
379
544
|
}
|
|
380
545
|
return n ? n.getContext() : "formula";
|
|
381
546
|
}
|
|
382
|
-
function
|
|
547
|
+
function V(e, t, n, r, i = []) {
|
|
383
548
|
if (r.kind === "function" && r.kindModifiers === "export") {
|
|
384
549
|
let t = r.spans[0].start, a = e.getPositionAt(t);
|
|
385
550
|
i.push({
|
|
386
551
|
name: r.text,
|
|
387
|
-
type:
|
|
552
|
+
type: ye(n, r),
|
|
388
553
|
lineNumber: a.lineNumber
|
|
389
554
|
});
|
|
390
555
|
}
|
|
391
|
-
if (r.childItems) for (let a of r.childItems)
|
|
556
|
+
if (r.childItems) for (let a of r.childItems) V(e, t, n, a, i);
|
|
392
557
|
return i;
|
|
393
558
|
}
|
|
394
|
-
function
|
|
559
|
+
function be(e, t, n = "function", r) {
|
|
395
560
|
let i = e.spans, a = i.length;
|
|
396
561
|
for (let o = 0; o < a; o++) {
|
|
397
562
|
let a = i[o];
|
|
398
563
|
if (a.start <= t && t < a.start + a.length) {
|
|
399
564
|
if (e.kind === n && (!r || e.kindModifiers === r)) return e;
|
|
400
565
|
for (let i of e.childItems || []) {
|
|
401
|
-
let e =
|
|
566
|
+
let e = be(i, t, n, r);
|
|
402
567
|
if (e) return e;
|
|
403
568
|
}
|
|
404
569
|
}
|
|
405
570
|
return null;
|
|
406
571
|
}
|
|
407
572
|
}
|
|
408
|
-
function
|
|
573
|
+
function H(e) {
|
|
409
574
|
return e.kind === "comment";
|
|
410
575
|
}
|
|
411
|
-
var
|
|
412
|
-
|
|
576
|
+
var U = null, W = null, G = null, K = null, xe = !1, Se = !1, q = !1, J = { current: null }, Ce = (e, t) => {
|
|
577
|
+
W = {
|
|
413
578
|
editor: e,
|
|
414
579
|
monaco: t
|
|
415
|
-
},
|
|
416
|
-
},
|
|
417
|
-
|
|
418
|
-
|
|
580
|
+
}, G && (K = G(e, t));
|
|
581
|
+
}, we = (e) => {
|
|
582
|
+
if (q) return;
|
|
583
|
+
q = !0;
|
|
584
|
+
let t = e.languages.typescript;
|
|
585
|
+
t.typescriptDefaults.setCompilerOptions({
|
|
586
|
+
...t.typescriptDefaults.getCompilerOptions(),
|
|
587
|
+
target: t.ScriptTarget.ES2020,
|
|
588
|
+
lib: [
|
|
589
|
+
"webworker",
|
|
590
|
+
"es2020",
|
|
591
|
+
"esnext.asynciterable"
|
|
592
|
+
],
|
|
593
|
+
strict: !0,
|
|
594
|
+
downlevelIteration: !0,
|
|
595
|
+
moduleResolution: t.ModuleResolutionKind.NodeJs,
|
|
596
|
+
allowSyntheticDefaultImports: !0,
|
|
597
|
+
baseUrl: "inmemory://model/",
|
|
598
|
+
allowNonTsExtensions: !0
|
|
599
|
+
}), t.typescriptDefaults.setDiagnosticsOptions({
|
|
600
|
+
noSemanticValidation: !1,
|
|
419
601
|
noSyntaxValidation: !1,
|
|
420
602
|
diagnosticCodesToIgnore: [2307]
|
|
421
|
-
}),
|
|
422
|
-
|
|
603
|
+
}), t.typescriptDefaults.setEagerModelSync(!0), L !== null && (t.typescriptDefaults.addExtraLib(L, "inmemory://model/sheetxl.d.ts"), t.typescriptDefaults.addExtraLib("declare module '@sheetxl/primitives' { export = SheetXL; }\n", "inmemory://model/sheetxl-module-shims.d.ts")), e.languages.json.jsonDefaults.setDiagnosticsOptions({ validate: !0 }), z(e), ((e) => {
|
|
604
|
+
B || (B = !0, e.languages.registerCompletionItemProvider("typescript", {
|
|
423
605
|
triggerCharacters: ["@"],
|
|
424
606
|
provideCompletionItems: (t, n) => {
|
|
425
607
|
let r = t.getValueInRange({
|
|
@@ -493,174 +675,141 @@ var I = null, L = null, R = null, z = null, B = !1, _e = !1, V = !1, H = { curre
|
|
|
493
675
|
}
|
|
494
676
|
],
|
|
495
677
|
colors: {}
|
|
496
|
-
}), (
|
|
497
|
-
let t =
|
|
498
|
-
|
|
499
|
-
let
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
for (let n = 1; n <= o; n++) {
|
|
508
|
-
let i = a[n - 1], o = e.editor.tokenize(i, "typescript"), s = o[0].length;
|
|
509
|
-
for (let a = 0; a < s; a++) {
|
|
510
|
-
let s = o[0]?.[a];
|
|
511
|
-
if (s && s.type.startsWith("string")) {
|
|
512
|
-
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];
|
|
513
|
-
f !== "`" && f !== "'" && f !== "\"" || (c++, d = d.substring(1));
|
|
514
|
-
let p = d[d.length - 1];
|
|
515
|
-
p !== "`" && p !== "'" && p !== "\"" || (c++, d = d.substring(0, d.length - 1));
|
|
516
|
-
try {
|
|
517
|
-
H.current?.getRanges(d) && r.push({
|
|
518
|
-
range: {
|
|
519
|
-
endColumn: l,
|
|
520
|
-
endLineNumber: n,
|
|
521
|
-
startColumn: c,
|
|
522
|
-
startLineNumber: n
|
|
523
|
-
},
|
|
524
|
-
tooltip: `Goto range '${d}'`,
|
|
525
|
-
url: `/range/${d}`
|
|
526
|
-
});
|
|
527
|
-
} catch {}
|
|
528
|
-
}
|
|
529
|
-
}
|
|
530
|
-
}
|
|
531
|
-
return i;
|
|
532
|
-
} }), e.editor.registerLinkOpener({ open(e) {
|
|
533
|
-
if (e?.path?.startsWith("/range/")) {
|
|
678
|
+
}), e.languages.registerLinkProvider("*", { provideLinks: (t, n) => {
|
|
679
|
+
let r = [], i = { links: r }, a = t.getLinesContent(), o = a.length;
|
|
680
|
+
for (let n = 1; n <= o; n++) {
|
|
681
|
+
let i = a[n - 1], o = e.editor.tokenize(i, "typescript"), s = o[0].length;
|
|
682
|
+
for (let a = 0; a < s; a++) {
|
|
683
|
+
let s = o[0]?.[a];
|
|
684
|
+
if (s && s.type.startsWith("string")) {
|
|
685
|
+
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];
|
|
686
|
+
f !== "`" && f !== "'" && f !== "\"" || (c++, d = d.substring(1));
|
|
687
|
+
let p = d[d.length - 1];
|
|
688
|
+
p !== "`" && p !== "'" && p !== "\"" || (c++, d = d.substring(0, d.length - 1));
|
|
534
689
|
try {
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
690
|
+
J.current?.getRanges(d) && r.push({
|
|
691
|
+
range: {
|
|
692
|
+
endColumn: l,
|
|
693
|
+
endLineNumber: n,
|
|
694
|
+
startColumn: c,
|
|
695
|
+
startLineNumber: n
|
|
696
|
+
},
|
|
697
|
+
tooltip: `Goto range '${d}'`,
|
|
698
|
+
url: `/range/${d}`
|
|
699
|
+
});
|
|
700
|
+
} catch {}
|
|
540
701
|
}
|
|
541
|
-
return !1;
|
|
542
|
-
} }), !t) {
|
|
543
|
-
let t = e.languages.typescript.typescriptDefaults.getCompilerOptions();
|
|
544
|
-
e.languages.typescript.typescriptDefaults.setCompilerOptions({
|
|
545
|
-
...t,
|
|
546
|
-
target: e.languages.typescript.ScriptTarget.ES2020,
|
|
547
|
-
lib: [
|
|
548
|
-
"webworker",
|
|
549
|
-
"es2020",
|
|
550
|
-
"esnext.asynciterable"
|
|
551
|
-
],
|
|
552
|
-
strict: !0,
|
|
553
|
-
downlevelIteration: !0,
|
|
554
|
-
moduleResolution: e.languages.typescript.ModuleResolutionKind.NodeJs,
|
|
555
|
-
allowSyntheticDefaultImports: !0,
|
|
556
|
-
baseUrl: "inmemory://model/",
|
|
557
|
-
allowNonTsExtensions: !0
|
|
558
|
-
});
|
|
559
702
|
}
|
|
560
|
-
} finally {
|
|
561
|
-
(() => {
|
|
562
|
-
let t = e.languages.typescript.typescriptDefaults.getDiagnosticsOptions();
|
|
563
|
-
e.languages.typescript.typescriptDefaults.setDiagnosticsOptions({
|
|
564
|
-
...t,
|
|
565
|
-
noSemanticValidation: !1
|
|
566
|
-
});
|
|
567
|
-
})();
|
|
568
703
|
}
|
|
569
|
-
|
|
570
|
-
},
|
|
704
|
+
return i;
|
|
705
|
+
} }), e.editor.registerLinkOpener({ open(e) {
|
|
706
|
+
if (e?.path?.startsWith("/range/")) {
|
|
707
|
+
try {
|
|
708
|
+
J.current?.getRanges(e.path.substring(7))?.select();
|
|
709
|
+
} catch (e) {
|
|
710
|
+
console.warn("invalid range", e);
|
|
711
|
+
}
|
|
712
|
+
return !0;
|
|
713
|
+
}
|
|
714
|
+
return !1;
|
|
715
|
+
} });
|
|
716
|
+
}, Te = (e) => {
|
|
571
717
|
let t = !1, n = e ? e.length : 0;
|
|
572
718
|
for (let r = 0; !t && r < n; r++) e[r].severity === 8 && (t = !0);
|
|
573
|
-
},
|
|
574
|
-
let [e, n] = s(() =>
|
|
575
|
-
return i(() => (
|
|
576
|
-
|
|
577
|
-
}), []),
|
|
719
|
+
}, Ee = () => {
|
|
720
|
+
let [e, n] = s(() => U.props);
|
|
721
|
+
return i(() => (U && (U.setProps = n), () => {
|
|
722
|
+
U && (U.setProps = null);
|
|
723
|
+
}), []), b("div", {
|
|
578
724
|
style: {
|
|
579
725
|
display: "flex",
|
|
580
726
|
flex: "1 1 100%",
|
|
581
727
|
width: "100%",
|
|
582
728
|
height: "100%"
|
|
583
729
|
},
|
|
584
|
-
children:
|
|
730
|
+
children: b(t, { children: b(N, {
|
|
585
731
|
theme: e.theme,
|
|
586
732
|
options: e.options,
|
|
587
733
|
language: "typescript",
|
|
588
734
|
value: e.value,
|
|
589
735
|
onValidate: e.onValidate,
|
|
590
736
|
beforeMount: e.beforeMount,
|
|
591
|
-
onMount:
|
|
737
|
+
onMount: Ce
|
|
592
738
|
}) })
|
|
593
739
|
});
|
|
594
|
-
},
|
|
595
|
-
let { className: r, style: c, readOnly: f = !1, darkMode: m, loadingPanel: h, autoFocus:
|
|
740
|
+
}, De = r(n((t, n) => {
|
|
741
|
+
let { className: r, style: c, readOnly: f = !1, darkMode: m, loadingPanel: h, autoFocus: _ = !0, frame: y, scripts: x, onStatusChange: S, ...se } = t, C = re(), w = o(null), [T, E] = s(!1), D = oe(), [ue] = ee(["insertFunction"]), [O, k] = s({
|
|
596
742
|
message: "Loading",
|
|
597
743
|
cursor: "",
|
|
598
744
|
dirty: !1
|
|
599
|
-
}), [
|
|
745
|
+
}), [de, he] = s({
|
|
600
746
|
loading: !1,
|
|
601
747
|
compiling: !1,
|
|
602
748
|
errors: [],
|
|
603
749
|
warnings: []
|
|
604
|
-
}),
|
|
605
|
-
|
|
750
|
+
}), M = v((e) => {
|
|
751
|
+
k((t) => {
|
|
606
752
|
let n = {
|
|
607
753
|
...t,
|
|
608
754
|
...e
|
|
609
755
|
};
|
|
610
|
-
return u.deepEqual(n, t) ? t : (
|
|
756
|
+
return u.deepEqual(n, t) ? t : (E(n.dirty ?? !1), n);
|
|
611
757
|
});
|
|
612
|
-
}, [
|
|
758
|
+
}, [S]);
|
|
613
759
|
i(() => {
|
|
614
|
-
|
|
615
|
-
}, [
|
|
616
|
-
let
|
|
760
|
+
S?.(O);
|
|
761
|
+
}, [S, O]);
|
|
762
|
+
let N = ne(), F = v(async (e) => {
|
|
617
763
|
let t = null, n = null;
|
|
618
764
|
try {
|
|
619
|
-
e && (n = await
|
|
765
|
+
e && (n = await N.showBusy(C("scriptEditor.saving")), t = await x.createModule({ source: e })), x.addModule(me(x), t, { replace: !0 }), n?.();
|
|
620
766
|
} catch (e) {
|
|
621
|
-
n?.(), console.warn("Unable to compile", e),
|
|
767
|
+
n?.(), console.warn("Unable to compile", e), N.showError(e);
|
|
622
768
|
}
|
|
623
769
|
return t;
|
|
624
|
-
}, [
|
|
770
|
+
}, [x]), I = v(async () => {
|
|
625
771
|
if (!w.current || f) return;
|
|
626
772
|
let e = w.current.editor, t;
|
|
627
|
-
if (
|
|
773
|
+
if (O.dirty) {
|
|
628
774
|
let n = e.getValue();
|
|
629
|
-
await
|
|
775
|
+
await F(n), t = A(x);
|
|
630
776
|
let r = t?.getSource(), i = e.getValue(), a = (r?.length ?? 0) !== n.length || r !== i;
|
|
631
|
-
|
|
632
|
-
} else t =
|
|
777
|
+
M({ dirty: a });
|
|
778
|
+
} else t = A(x);
|
|
633
779
|
return t;
|
|
634
|
-
}, [
|
|
780
|
+
}, [O, x]);
|
|
635
781
|
i(() => {
|
|
636
|
-
let e =
|
|
782
|
+
let e = y?.addListener({ onBeforeHide: async () => (await I(), !0) });
|
|
637
783
|
return () => {
|
|
638
784
|
e?.();
|
|
639
785
|
};
|
|
640
|
-
}, [
|
|
641
|
-
if (
|
|
642
|
-
}, [
|
|
786
|
+
}, [y]), i(() => {
|
|
787
|
+
if (x) return x.addListeners({ onBeforeSearch: () => I() });
|
|
788
|
+
}, [x]), ae(D, {
|
|
643
789
|
onBeforeSave: async () => {
|
|
644
|
-
await
|
|
790
|
+
await I();
|
|
645
791
|
},
|
|
646
792
|
onLoad: () => {
|
|
647
793
|
let e = w.current?.editor;
|
|
648
|
-
e && e.setValue(
|
|
794
|
+
e && e.setValue(A(x)?.getSource() ?? "");
|
|
649
795
|
}
|
|
650
796
|
});
|
|
651
|
-
let
|
|
652
|
-
if (!
|
|
797
|
+
let L = v(async (e) => {
|
|
798
|
+
if (!x) return;
|
|
653
799
|
let t = typeof e == "string" ? { functionName: e } : e ?? {}, n = null;
|
|
654
800
|
if (t?.declaration || t?.functionName) {
|
|
655
801
|
let e = t.declaration ? t.declaration.getName() : t.functionName;
|
|
656
|
-
(await
|
|
802
|
+
(await x.searchFunctions({
|
|
803
|
+
name: e,
|
|
804
|
+
includeHidden: !0
|
|
805
|
+
})).length > 0 && (n = e);
|
|
657
806
|
}
|
|
658
807
|
if (n) try {
|
|
659
|
-
await
|
|
808
|
+
await x.executeMacro(n);
|
|
660
809
|
} catch (e) {
|
|
661
|
-
|
|
810
|
+
N.showError(e);
|
|
662
811
|
}
|
|
663
|
-
}, [
|
|
812
|
+
}, [x, N]), [R, _e] = s(!1), B = v(async () => {
|
|
664
813
|
if (!w.current) return null;
|
|
665
814
|
let e = w.current, t = e.editor;
|
|
666
815
|
if (!t) return null;
|
|
@@ -671,7 +820,7 @@ var I = null, L = null, R = null, z = null, B = !1, _e = !1, V = !1, H = { curre
|
|
|
671
820
|
if (!o) return null;
|
|
672
821
|
let s = o.startLineNumber === o.endLineNumber && o.startColumn === o.endColumn ? r.getLineCount() : Math.min(o.endLineNumber, r.getLineCount());
|
|
673
822
|
for (let e = o.startLineNumber; !a && e <= s; e++) {
|
|
674
|
-
let t =
|
|
823
|
+
let t = be(i, r.getOffsetAt({
|
|
675
824
|
lineNumber: e,
|
|
676
825
|
column: 1
|
|
677
826
|
}), "function", n);
|
|
@@ -679,20 +828,20 @@ var I = null, L = null, R = null, z = null, B = !1, _e = !1, V = !1, H = { curre
|
|
|
679
828
|
}
|
|
680
829
|
return a;
|
|
681
830
|
})(t, e.monaco);
|
|
682
|
-
return
|
|
831
|
+
return M({ message: (n ?? "").toUpperCase() }), n ? {
|
|
683
832
|
source: t.getValue(),
|
|
684
833
|
name: n
|
|
685
834
|
} : null;
|
|
686
835
|
}, []);
|
|
687
|
-
|
|
688
|
-
let
|
|
689
|
-
|
|
836
|
+
v(d.debounce(I, 200), []);
|
|
837
|
+
let ye = v(async (e, t, n) => {
|
|
838
|
+
he((e) => ({
|
|
690
839
|
...e,
|
|
691
840
|
compiling: !0
|
|
692
841
|
}));
|
|
693
842
|
let r = null;
|
|
694
843
|
try {
|
|
695
|
-
if (r = await
|
|
844
|
+
if (r = await x.createModule({
|
|
696
845
|
source: n?.getValue(),
|
|
697
846
|
declarationsOnly: !0
|
|
698
847
|
}), !r) return;
|
|
@@ -713,7 +862,7 @@ var I = null, L = null, R = null, z = null, B = !1, _e = !1, V = !1, H = { curre
|
|
|
713
862
|
});
|
|
714
863
|
t.editor.setModelMarkers(e, "sheetxl", r);
|
|
715
864
|
})(e, t, i), async function(e, t, n, r) {
|
|
716
|
-
let i =
|
|
865
|
+
let i = V(e, t, r, await (await (await t.languages.typescript.getTypeScriptWorker())(e.uri)).getNavigationTree(e.uri.toString())).map((e) => {
|
|
717
866
|
let n = null, r = null;
|
|
718
867
|
return e.type === "formula" ? (n = "formula.margin-icon", r = C("scriptEditor.glyph.formula")) : e.type === "macro" ? (n = "macro.margin-icon", r = C("scriptEditor.glyph.macro")) : e.type === "autoRun" && (n = "autorun.margin-icon", r = C("scriptEditor.glyph.autoRun")), {
|
|
719
868
|
range: new t.Range(e.lineNumber, 1, e.lineNumber, 1),
|
|
@@ -725,32 +874,32 @@ var I = null, L = null, R = null, z = null, B = !1, _e = !1, V = !1, H = { curre
|
|
|
725
874
|
}
|
|
726
875
|
};
|
|
727
876
|
});
|
|
728
|
-
|
|
729
|
-
}(e, t, n, r ? r.getFunctions().getItems() : u.EmptyArray),
|
|
877
|
+
X.current && X.current.clear(), X.current = n.createDecorationsCollection(i);
|
|
878
|
+
}(e, t, n, r ? r.getFunctions().getItems({ includeHidden: !0 }) : u.EmptyArray), he((e) => ({
|
|
730
879
|
...e,
|
|
731
880
|
compiling: !1,
|
|
732
881
|
errors: i.filter((e) => e.severity === "error").map((e) => `${e.code}: ${e.message}`),
|
|
733
882
|
warnings: i.filter((e) => e.severity === "warning").map((e) => `${e.code}: ${e.message}`)
|
|
734
883
|
}));
|
|
735
|
-
}, [
|
|
884
|
+
}, [x]), H = v(d.debounce(ye, 580), []), q = v(async (e) => {
|
|
736
885
|
if (!w.current) return;
|
|
737
886
|
let t = w.current.editor.getPosition(), n = { cursor: t ? t.toString() : "" };
|
|
738
|
-
e !== void 0 && (n.message = e),
|
|
887
|
+
e !== void 0 && (n.message = e), M(n);
|
|
739
888
|
}, []);
|
|
740
|
-
i(() => {}, [
|
|
741
|
-
let
|
|
742
|
-
await
|
|
743
|
-
}, [
|
|
889
|
+
i(() => {}, [de]);
|
|
890
|
+
let Ce = o(null), De = v(async () => {
|
|
891
|
+
await I(), y?.close();
|
|
892
|
+
}, [y]), Oe = v((e) => {
|
|
744
893
|
let t = w.current?.editor;
|
|
745
894
|
return !!t && (t.focus(e), !0);
|
|
746
|
-
}, [
|
|
895
|
+
}, [O]), ke = v(async () => {
|
|
747
896
|
let e = w.current?.editor, t = e?.getModel(), n = e?.getSelection();
|
|
748
897
|
if (!t || !n) return;
|
|
749
898
|
let r = n.isEmpty() ? t.getLineContent(n.positionLineNumber) + "\n" : t.getValueInRange(n);
|
|
750
899
|
try {
|
|
751
900
|
await navigator.clipboard?.writeText(r);
|
|
752
901
|
} catch {}
|
|
753
|
-
}, []),
|
|
902
|
+
}, []), Ae = v(async () => {
|
|
754
903
|
let e = w.current, t = e?.editor, n = t?.getModel(), r = t?.getSelection();
|
|
755
904
|
if (!n || !r) return;
|
|
756
905
|
let i = r.isEmpty() ? new e.monaco.Range(r.positionLineNumber, 1, r.positionLineNumber + 1, 1) : r, a = n.getValueInRange(i);
|
|
@@ -764,7 +913,7 @@ var I = null, L = null, R = null, z = null, B = !1, _e = !1, V = !1, H = { curre
|
|
|
764
913
|
text: "",
|
|
765
914
|
forceMoveMarkers: !0
|
|
766
915
|
}]), t.pushUndoStop(), t.focus();
|
|
767
|
-
}, []),
|
|
916
|
+
}, []), Y = v(async () => {
|
|
768
917
|
let e = w.current?.editor;
|
|
769
918
|
if (!e) return;
|
|
770
919
|
let t;
|
|
@@ -780,23 +929,29 @@ var I = null, L = null, R = null, z = null, B = !1, _e = !1, V = !1, H = { curre
|
|
|
780
929
|
text: t,
|
|
781
930
|
forceMoveMarkers: !0
|
|
782
931
|
}]), e.pushUndoStop(), e.focus();
|
|
783
|
-
}, []),
|
|
932
|
+
}, []), X = o(null), je = v((t, n) => {
|
|
784
933
|
w.current = {
|
|
785
934
|
monaco: n,
|
|
786
935
|
editor: t
|
|
787
|
-
},
|
|
936
|
+
}, J.current = D ?? null;
|
|
788
937
|
let r = t.getModel(), i = [];
|
|
789
|
-
|
|
790
|
-
let a =
|
|
791
|
-
return t.getValue() !== a && t.setValue(a),
|
|
792
|
-
|
|
938
|
+
_e(!0);
|
|
939
|
+
let a = A(x)?.getSource() ?? "";
|
|
940
|
+
return t.getValue() !== a && t.setValue(a), xe ? (q(""), H(r, n, t), z(n)) : (xe = !0, q("Loading Types"), import("./_0P-3FrZVqtnVTn9.mjs").then((t) => e(t.default, 1)).then(async (e) => {
|
|
941
|
+
q("");
|
|
942
|
+
let r = e.AutoTypings, i = new e.JsDelivrSourceResolver(), a = (e) => e.startsWith("@sheetxl/") || e.startsWith("@types/sheetxl__");
|
|
943
|
+
r.create(t, {
|
|
944
|
+
sourceResolver: {
|
|
945
|
+
resolvePackageJson: (e, t, n) => a(e) ? Promise.resolve(void 0) : i.resolvePackageJson(e, t, n),
|
|
946
|
+
resolveSourceFile: (e, t, n) => a(e) ? Promise.resolve(void 0) : i.resolveSourceFile(e, t, n)
|
|
947
|
+
},
|
|
793
948
|
shareCache: !0,
|
|
794
949
|
dontAdaptEditorOptions: !0,
|
|
795
950
|
monaco: n,
|
|
796
951
|
onUpdate: (e, t) => {
|
|
797
|
-
if (e.type === "LookedUpPackage" && e.success
|
|
952
|
+
if (e.type === "LookedUpPackage" && !0 === e.success) {
|
|
798
953
|
let e = n.languages.typescript.typescriptDefaults.getDiagnosticsOptions();
|
|
799
|
-
n.languages.typescript.typescriptDefaults.setDiagnosticsOptions({
|
|
954
|
+
e.diagnosticCodesToIgnore?.length && n.languages.typescript.typescriptDefaults.setDiagnosticsOptions({
|
|
800
955
|
...e,
|
|
801
956
|
diagnosticCodesToIgnore: []
|
|
802
957
|
});
|
|
@@ -806,8 +961,8 @@ var I = null, L = null, R = null, z = null, B = !1, _e = !1, V = !1, H = { curre
|
|
|
806
961
|
e === "Not implemented yet" && (e = "Compile Errors"), console.warn("Error compiling types", e);
|
|
807
962
|
}
|
|
808
963
|
}).then((e) => {
|
|
809
|
-
|
|
810
|
-
if (
|
|
964
|
+
Ce.current = e, H(t.getModel(), n, t), (() => {
|
|
965
|
+
if (ge) return;
|
|
811
966
|
let e = (e, t) => {
|
|
812
967
|
try {
|
|
813
968
|
if (t === void 0) try {
|
|
@@ -819,17 +974,17 @@ var I = null, L = null, R = null, z = null, B = !1, _e = !1, V = !1, H = { curre
|
|
|
819
974
|
}
|
|
820
975
|
else globalThis[e] = t;
|
|
821
976
|
} catch {}
|
|
822
|
-
}, t =
|
|
977
|
+
}, t = P.length;
|
|
823
978
|
for (let n = 0; n < t; n++) {
|
|
824
|
-
let t =
|
|
825
|
-
e(t,
|
|
979
|
+
let t = P[n];
|
|
980
|
+
e(t, j[t]);
|
|
826
981
|
}
|
|
827
|
-
|
|
828
|
-
})(),
|
|
982
|
+
j = void 0, ge = !0;
|
|
983
|
+
})(), z(n);
|
|
829
984
|
});
|
|
830
985
|
}).catch((e) => {
|
|
831
|
-
|
|
832
|
-
})),
|
|
986
|
+
xe = !1, q(""), console.warn("Auto typings could not be loaded:", e);
|
|
987
|
+
})), Se || (Se = !0, function(e, t) {
|
|
833
988
|
t.languages.registerInlayHintsProvider("typescript", { provideInlayHints(e, n, r) {
|
|
834
989
|
let i = [];
|
|
835
990
|
for (let n = 1; n < e.getLineCount() + 1; n++) {
|
|
@@ -858,56 +1013,56 @@ var I = null, L = null, R = null, z = null, B = !1, _e = !1, V = !1, H = { curre
|
|
|
858
1013
|
label: "Execute",
|
|
859
1014
|
keybindings: [n.KeyCode.F8],
|
|
860
1015
|
run: async (e) => {
|
|
861
|
-
let t = await
|
|
862
|
-
|
|
1016
|
+
let t = await B();
|
|
1017
|
+
L(t);
|
|
863
1018
|
}
|
|
864
1019
|
})), i.push(t.addAction({
|
|
865
1020
|
id: "saveScript",
|
|
866
1021
|
label: "Save Script",
|
|
867
1022
|
keybindings: [n.KeyMod.CtrlCmd | n.KeyCode.KeyS],
|
|
868
1023
|
run: (e) => {
|
|
869
|
-
|
|
1024
|
+
I();
|
|
870
1025
|
}
|
|
871
1026
|
})), i.push(t.onMouseDown(async (e) => {
|
|
872
1027
|
if (e.target.type === n.editor.MouseTargetType.GUTTER_GLYPH_MARGIN) {
|
|
873
1028
|
e.event.browserEvent.preventDefault();
|
|
874
|
-
let t = e.target.position.lineNumber, i = await (await (await n.languages.typescript.getTypeScriptWorker())(r.uri)).getNavigationTree(r.uri.toString()), a = await
|
|
1029
|
+
let t = e.target.position.lineNumber, i = await (await (await n.languages.typescript.getTypeScriptWorker())(r.uri)).getNavigationTree(r.uri.toString()), a = await I();
|
|
875
1030
|
if (!a) return;
|
|
876
|
-
let o = a.getFunctions().getItems(), s =
|
|
1031
|
+
let o = a.getFunctions().getItems({ includeHidden: !0 }), s = V(r, n, o, i).find((e) => e.lineNumber === t);
|
|
877
1032
|
if (s) {
|
|
878
1033
|
let t = e.event.browserEvent.button;
|
|
879
1034
|
if (t === 0) {
|
|
880
|
-
if (s.type === "macro" || s.type === "autoRun")
|
|
1035
|
+
if (s.type === "macro" || s.type === "autoRun") L({ functionName: s.name });
|
|
881
1036
|
else if (s.type === "formula") {
|
|
882
1037
|
let e = o?.find((e) => e.getName() === s.name);
|
|
883
|
-
e &&
|
|
1038
|
+
e && ue?.execute(e);
|
|
884
1039
|
}
|
|
885
1040
|
} else t === 2 && (console.log("Context menu for function:", s.name), e.event.browserEvent.preventDefault());
|
|
886
1041
|
}
|
|
887
1042
|
}
|
|
888
1043
|
})), i.push(t.onDidChangeModelContent(() => {
|
|
889
|
-
|
|
1044
|
+
M({ dirty: !0 }), H(r, n, t);
|
|
890
1045
|
})), i.push(n.editor.onDidChangeMarkers((e) => {
|
|
891
1046
|
e.some((e) => e.toString() === r.uri.toString());
|
|
892
1047
|
})), i.push(r.onDidChangeContent((e) => {
|
|
893
|
-
let n =
|
|
894
|
-
|
|
1048
|
+
let n = A(x)?.getSource(), r = t.getValue(), i = (n?.length ?? 0) !== r.length || n !== r;
|
|
1049
|
+
M({ dirty: i });
|
|
895
1050
|
})), i.push(t.onDidChangeCursorPosition((e) => {
|
|
896
|
-
|
|
1051
|
+
q();
|
|
897
1052
|
})), () => {
|
|
898
1053
|
for (let e of i) try {
|
|
899
1054
|
e.dispose();
|
|
900
1055
|
} catch {}
|
|
901
1056
|
};
|
|
902
|
-
}, [
|
|
1057
|
+
}, [x, D]), Me = a(() => R ? null : h || b("div", {
|
|
903
1058
|
style: {
|
|
904
1059
|
position: "absolute",
|
|
905
1060
|
width: "100%",
|
|
906
1061
|
height: "100%"
|
|
907
1062
|
},
|
|
908
1063
|
children: C("scriptEditor.loading")
|
|
909
|
-
}), [
|
|
910
|
-
...
|
|
1064
|
+
}), [R, h]), Z = a(() => ({
|
|
1065
|
+
...fe,
|
|
911
1066
|
fixedOverflowWidgets: !1,
|
|
912
1067
|
contextmenu: !1,
|
|
913
1068
|
readOnly: f
|
|
@@ -915,18 +1070,18 @@ var I = null, L = null, R = null, z = null, B = !1, _e = !1, V = !1, H = { curre
|
|
|
915
1070
|
i(() => {
|
|
916
1071
|
let e = {
|
|
917
1072
|
theme: m ? "extended-dark" : "extended",
|
|
918
|
-
options:
|
|
919
|
-
value:
|
|
920
|
-
beforeMount:
|
|
921
|
-
onValidate:
|
|
1073
|
+
options: Z,
|
|
1074
|
+
value: A(x)?.getSource() ?? "",
|
|
1075
|
+
beforeMount: we,
|
|
1076
|
+
onValidate: Te
|
|
922
1077
|
}, t = ((e) => {
|
|
923
|
-
if (
|
|
924
|
-
if (!
|
|
925
|
-
|
|
926
|
-
let e =
|
|
1078
|
+
if (U) return U;
|
|
1079
|
+
if (!j) {
|
|
1080
|
+
j = {};
|
|
1081
|
+
let e = P.length;
|
|
927
1082
|
for (let t = 0; t < e; t++) {
|
|
928
|
-
let e =
|
|
929
|
-
|
|
1083
|
+
let e = P[t];
|
|
1084
|
+
j[e] = globalThis[e];
|
|
930
1085
|
}
|
|
931
1086
|
}
|
|
932
1087
|
let t = document.createElement("div");
|
|
@@ -934,33 +1089,33 @@ var I = null, L = null, R = null, z = null, B = !1, _e = !1, V = !1, H = { curre
|
|
|
934
1089
|
let n = document.createElement("div");
|
|
935
1090
|
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);
|
|
936
1091
|
let r = l(n);
|
|
937
|
-
return
|
|
1092
|
+
return U = {
|
|
938
1093
|
root: r,
|
|
939
1094
|
hostEl: n,
|
|
940
1095
|
stashEl: t,
|
|
941
1096
|
props: e,
|
|
942
1097
|
setProps: null
|
|
943
|
-
}, r.render(
|
|
1098
|
+
}, r.render(b(Ee, {})), U;
|
|
944
1099
|
})(e);
|
|
945
|
-
return t.props = e, t.setProps?.(e),
|
|
946
|
-
|
|
1100
|
+
return t.props = e, t.setProps?.(e), G = (e, t) => je(e, t), Ne.current?.appendChild(t.hostEl), W && (K = je(W.editor, W.monaco)), () => {
|
|
1101
|
+
K?.(), K = null, G = null, w.current = null, U?.stashEl.appendChild(U.hostEl);
|
|
947
1102
|
};
|
|
948
1103
|
}, []), i(() => {
|
|
949
|
-
if (!
|
|
1104
|
+
if (!U) return;
|
|
950
1105
|
let e = {
|
|
951
|
-
...
|
|
1106
|
+
...U.props,
|
|
952
1107
|
theme: m ? "extended-dark" : "extended",
|
|
953
|
-
options:
|
|
1108
|
+
options: Z
|
|
954
1109
|
};
|
|
955
|
-
|
|
956
|
-
}, [m,
|
|
1110
|
+
U.props = e, U.setProps?.(e);
|
|
1111
|
+
}, [m, Z]), i(() => {
|
|
957
1112
|
let e = w.current, t = e?.editor;
|
|
958
1113
|
if (!t) return;
|
|
959
|
-
|
|
960
|
-
let n =
|
|
961
|
-
t.getValue() !== n && (t.setValue(n),
|
|
962
|
-
}, [
|
|
963
|
-
let Pe =
|
|
1114
|
+
J.current = D ?? null;
|
|
1115
|
+
let n = A(x)?.getSource() ?? "";
|
|
1116
|
+
t.getValue() !== n && (t.setValue(n), H(t.getModel(), e.monaco, t), M({ dirty: !1 }));
|
|
1117
|
+
}, [x, D]);
|
|
1118
|
+
let Pe = ie("div", {
|
|
964
1119
|
style: {
|
|
965
1120
|
display: "flex",
|
|
966
1121
|
flex: "1 1 100%",
|
|
@@ -969,7 +1124,7 @@ var I = null, L = null, R = null, z = null, B = !1, _e = !1, V = !1, H = { curre
|
|
|
969
1124
|
position: "relative",
|
|
970
1125
|
boxSizing: "border-box"
|
|
971
1126
|
},
|
|
972
|
-
children: [
|
|
1127
|
+
children: [b("div", {
|
|
973
1128
|
ref: Ne,
|
|
974
1129
|
style: {
|
|
975
1130
|
display: "flex",
|
|
@@ -977,66 +1132,32 @@ var I = null, L = null, R = null, z = null, B = !1, _e = !1, V = !1, H = { curre
|
|
|
977
1132
|
width: "100%",
|
|
978
1133
|
position: "relative"
|
|
979
1134
|
}
|
|
980
|
-
}),
|
|
981
|
-
}), Q =
|
|
1135
|
+
}), Me]
|
|
1136
|
+
}), Q = te(n, () => ({
|
|
982
1137
|
isScriptEditorElement: () => !0,
|
|
983
1138
|
showCommandPalette: () => {
|
|
984
1139
|
w.current?.editor && w.current.editor.trigger("keyboard", "editor.action.quickCommand", null);
|
|
985
1140
|
},
|
|
986
|
-
getScripts: () =>
|
|
1141
|
+
getScripts: () => x,
|
|
987
1142
|
focus: (e) => {
|
|
988
|
-
|
|
1143
|
+
Oe(e);
|
|
989
1144
|
},
|
|
990
|
-
close: () =>
|
|
991
|
-
insertSnippet: (e) => w.current?.editor ? (
|
|
992
|
-
let r = e.getModel();
|
|
993
|
-
if (!r) return;
|
|
994
|
-
let i = await (await (await t.languages.typescript.getTypeScriptWorker())(r.uri)).getNavigationTree(r.uri.toString()), a = e.getPosition(), o = { ...a };
|
|
995
|
-
o.lineNumber = 1, o.column = 1;
|
|
996
|
-
let s = !1;
|
|
997
|
-
for (let e = a.lineNumber; e >= 1; e--) if (r.getLineContent(e).trim() === "") {
|
|
998
|
-
let t = F(i, r.getOffsetAt({
|
|
999
|
-
lineNumber: e,
|
|
1000
|
-
column: 1
|
|
1001
|
-
}), "function");
|
|
1002
|
-
if (!t || ge(t)) {
|
|
1003
|
-
s = !0, o.lineNumber = e + 1;
|
|
1004
|
-
break;
|
|
1005
|
-
}
|
|
1006
|
-
{
|
|
1007
|
-
let n = t.spans[0].start;
|
|
1008
|
-
e = r.getPositionAt(n).lineNumber, o.lineNumber = e;
|
|
1009
|
-
}
|
|
1010
|
-
}
|
|
1011
|
-
let c = n, l = !1;
|
|
1012
|
-
!s && !c.startsWith("\n") && o.lineNumber > 1 && (c = "\n" + c, l = !0);
|
|
1013
|
-
let u = !1;
|
|
1014
|
-
r.getLineCount() > 1 && (c.endsWith("\n\n") || (c += "\n\n", u = !0));
|
|
1015
|
-
let d = [{
|
|
1016
|
-
range: new t.Range(o.lineNumber, o.column, o.lineNumber, o.column),
|
|
1017
|
-
text: `${c}`
|
|
1018
|
-
}], f = null;
|
|
1019
|
-
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({
|
|
1020
|
-
startLineNumber: f.endLineNumber,
|
|
1021
|
-
startColumn: f.endColumn,
|
|
1022
|
-
endLineNumber: f.startLineNumber,
|
|
1023
|
-
endColumn: f.startColumn
|
|
1024
|
-
});
|
|
1025
|
-
})(w.current.editor, w.current.monaco, e) : Promise.resolve(),
|
|
1145
|
+
close: () => De(),
|
|
1146
|
+
insertSnippet: (e) => w.current?.editor ? ve(w.current.editor, w.current.monaco, e) : Promise.resolve(),
|
|
1026
1147
|
saveSource: async () => {
|
|
1027
|
-
await
|
|
1148
|
+
await I();
|
|
1028
1149
|
},
|
|
1029
1150
|
runAction: (e) => {
|
|
1030
1151
|
let t = w.current?.editor;
|
|
1031
1152
|
t && (t.focus(), t.trigger("source", e, null));
|
|
1032
1153
|
},
|
|
1033
|
-
copy: () =>
|
|
1034
|
-
cut: () =>
|
|
1035
|
-
paste: () =>
|
|
1036
|
-
}), [
|
|
1154
|
+
copy: () => ke(),
|
|
1155
|
+
cut: () => Ae(),
|
|
1156
|
+
paste: () => Y()
|
|
1157
|
+
}), [D]), [Fe, Ie] = s(null), Le = v((e) => {
|
|
1037
1158
|
e !== null && Ie(e);
|
|
1038
1159
|
}, []), $ = g.useCommandScope();
|
|
1039
|
-
|
|
1160
|
+
i(() => {
|
|
1040
1161
|
if (!$ || !Fe) return;
|
|
1041
1162
|
let e = $.contribution();
|
|
1042
1163
|
return function(e, t) {
|
|
@@ -1058,7 +1179,7 @@ var I = null, L = null, R = null, z = null, B = !1, _e = !1, V = !1, H = { curre
|
|
|
1058
1179
|
}), 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") });
|
|
1059
1180
|
}(e, {
|
|
1060
1181
|
scriptEditor: Fe,
|
|
1061
|
-
isDirty:
|
|
1182
|
+
isDirty: T,
|
|
1062
1183
|
readOnly: f
|
|
1063
1184
|
}), () => {
|
|
1064
1185
|
e.remove();
|
|
@@ -1066,16 +1187,19 @@ var I = null, L = null, R = null, z = null, B = !1, _e = !1, V = !1, H = { curre
|
|
|
1066
1187
|
}, [
|
|
1067
1188
|
$,
|
|
1068
1189
|
Fe,
|
|
1069
|
-
|
|
1190
|
+
T,
|
|
1070
1191
|
f
|
|
1071
|
-
]), i(() => (
|
|
1192
|
+
]), i(() => (_ && requestAnimationFrame(() => {
|
|
1072
1193
|
Q.current?.focus();
|
|
1073
1194
|
}), () => {
|
|
1074
1195
|
w.current?.editor && requestAnimationFrame(() => {
|
|
1075
1196
|
Q.current?.contains(document.activeElement) && Q.current?.focus();
|
|
1076
1197
|
});
|
|
1077
|
-
}), [])
|
|
1078
|
-
|
|
1198
|
+
}), []);
|
|
1199
|
+
let Re = a(() => le(ze), ze = [Q, Le]);
|
|
1200
|
+
var ze;
|
|
1201
|
+
return b("div", {
|
|
1202
|
+
className: ce("script-editor", pe, r),
|
|
1079
1203
|
style: {
|
|
1080
1204
|
display: "flex",
|
|
1081
1205
|
flexDirection: "row",
|
|
@@ -1083,19 +1207,22 @@ var I = null, L = null, R = null, z = null, B = !1, _e = !1, V = !1, H = { curre
|
|
|
1083
1207
|
position: "relative",
|
|
1084
1208
|
...c
|
|
1085
1209
|
},
|
|
1086
|
-
ref:
|
|
1087
|
-
...
|
|
1210
|
+
ref: Re,
|
|
1211
|
+
...se,
|
|
1088
1212
|
children: Pe
|
|
1089
1213
|
});
|
|
1090
|
-
})),
|
|
1091
|
-
|
|
1092
|
-
},
|
|
1093
|
-
let { scope: t, data: n } = e, { workbook: r } = n, a =
|
|
1214
|
+
})), Oe = null, ke = (e) => {
|
|
1215
|
+
Oe = e;
|
|
1216
|
+
}, Ae = () => Oe, Y = r((e) => {
|
|
1217
|
+
let { scope: t, data: n } = e, { workbook: r } = n, a = ne(), o = S(), s = o.getOpen(), c = v(async (e) => {
|
|
1094
1218
|
if (!r) return;
|
|
1095
1219
|
let t = null, n = r.getScripts();
|
|
1096
1220
|
if (e?.declaration || e?.functionName) {
|
|
1097
1221
|
let r = e.declaration ? e.declaration.getName() : e.functionName;
|
|
1098
|
-
(await n.searchFunctions({
|
|
1222
|
+
(await n.searchFunctions({
|
|
1223
|
+
name: r,
|
|
1224
|
+
includeHidden: !0
|
|
1225
|
+
})).length > 0 && (t = r);
|
|
1099
1226
|
}
|
|
1100
1227
|
if (t) try {
|
|
1101
1228
|
await n.executeMacro(t);
|
|
@@ -1103,8 +1230,8 @@ var I = null, L = null, R = null, z = null, B = !1, _e = !1, V = !1, H = { curre
|
|
|
1103
1230
|
a.showError(e);
|
|
1104
1231
|
return;
|
|
1105
1232
|
}
|
|
1106
|
-
}, [r, a]), l =
|
|
1107
|
-
let e =
|
|
1233
|
+
}, [r, a]), l = v(() => {
|
|
1234
|
+
let e = Ae();
|
|
1108
1235
|
e ? r && e({ workbook: r }) : o.getOpen().includes("scriptEditor") ? o.close("scriptEditor") : o.activate("scriptEditor", {});
|
|
1109
1236
|
}, [r, o]), u = s.includes("scriptEditor");
|
|
1110
1237
|
return i(() => {
|
|
@@ -1124,12 +1251,12 @@ var I = null, L = null, R = null, z = null, B = !1, _e = !1, V = !1, H = { curre
|
|
|
1124
1251
|
r,
|
|
1125
1252
|
c,
|
|
1126
1253
|
l
|
|
1127
|
-
]),
|
|
1254
|
+
]), ae(r, { onLoad: () => {
|
|
1128
1255
|
r?.getScripts().start();
|
|
1129
1256
|
} }), null;
|
|
1130
1257
|
});
|
|
1131
|
-
|
|
1132
|
-
var
|
|
1258
|
+
Y.displayName = "WorkbookScriptCommands";
|
|
1259
|
+
var X = {
|
|
1133
1260
|
"reason.noChangesToSave": "No changes to save",
|
|
1134
1261
|
"reason.scriptsReadOnly": "Scripts can't be changed while the workbook structure is protected.",
|
|
1135
1262
|
"scriptEditor.glyph.autoRun": "Auto Run",
|
|
@@ -1138,7 +1265,7 @@ var xe = {
|
|
|
1138
1265
|
"scriptEditor.loading": "Loading...",
|
|
1139
1266
|
"scriptEditor.retry": "Retry",
|
|
1140
1267
|
"scriptEditor.saving": "Saving Scripts..."
|
|
1141
|
-
},
|
|
1268
|
+
}, je = [
|
|
1142
1269
|
{
|
|
1143
1270
|
sourceId: "groups",
|
|
1144
1271
|
catalog: {
|
|
@@ -1220,29 +1347,27 @@ var xe = {
|
|
|
1220
1347
|
}
|
|
1221
1348
|
}
|
|
1222
1349
|
}
|
|
1223
|
-
], { DefaultCommandCatalogService:
|
|
1350
|
+
], { DefaultCommandCatalogService: Me } = g, Z = !1, Ne = (e) => {
|
|
1224
1351
|
let { model: t, entryKey: n, frame: r, ref: i, ...a } = e;
|
|
1225
|
-
return
|
|
1352
|
+
return b(De, {
|
|
1226
1353
|
ref: i,
|
|
1227
1354
|
frame: r,
|
|
1228
1355
|
scripts: t?.getScripts(),
|
|
1229
1356
|
...a
|
|
1230
1357
|
});
|
|
1231
|
-
},
|
|
1232
|
-
|
|
1358
|
+
}, Pe = () => {
|
|
1359
|
+
x.registerTaskPane({
|
|
1233
1360
|
key: "scriptEditor",
|
|
1234
|
-
|
|
1235
|
-
getIcon: () => "ScriptRun",
|
|
1236
|
-
component: X,
|
|
1361
|
+
component: Ne,
|
|
1237
1362
|
keepMounted: !0
|
|
1238
1363
|
}, !0), function() {
|
|
1239
|
-
if (
|
|
1240
|
-
|
|
1241
|
-
let e =
|
|
1364
|
+
if (Z) return;
|
|
1365
|
+
Z = !0;
|
|
1366
|
+
let e = Me;
|
|
1242
1367
|
e.registerFromManifest("@sheetxl/scripting-react", import.meta.url, {
|
|
1243
|
-
messages:
|
|
1244
|
-
catalogs:
|
|
1368
|
+
messages: X,
|
|
1369
|
+
catalogs: je
|
|
1245
1370
|
}), e.prefetch();
|
|
1246
|
-
}(), g.DefaultCommandRegistry.registerDynamic("workbook",
|
|
1371
|
+
}(), g.DefaultCommandRegistry.registerDynamic("workbook", Y);
|
|
1247
1372
|
};
|
|
1248
|
-
export {
|
|
1373
|
+
export { De as ScriptEditor, Pe as ScriptingReactPlugin, Y as WorkbookScriptCommands, Ae as getScriptEditorOpener, ke as setScriptEditorOpener };
|