@sheetxl/scripting 0.8.0-beta.1 → 0.8.0-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.
Files changed (72) hide show
  1. package/README.md +3 -3
  2. package/browser/cjs/B6RS19boKbA_QGQ6.cjs +2 -0
  3. package/browser/cjs/Bn3oEXST6uP5oPU2.cjs +1 -0
  4. package/browser/cjs/C83wXnFq94exmYt9.cjs +1 -0
  5. package/browser/cjs/C94szTiUbmNQa9FD.cjs +1 -0
  6. package/browser/cjs/CUd5aIyyU3_3B_V1.cjs +29 -0
  7. package/browser/cjs/D5np5QScDyDDD_WJ.cjs +1 -0
  8. package/browser/cjs/DLi7EA_dfez5uwwY.cjs +1 -0
  9. package/browser/cjs/DZAweI0sdBfrHzAk.cjs +3747 -0
  10. package/browser/cjs/DcxyEv9XIOa5qfCm.cjs +1 -0
  11. package/browser/cjs/ZKJrH74dcPwEAgmF.cjs +7 -0
  12. package/browser/cjs/index.cjs +1 -1
  13. package/browser/esm/4VkvY2rXOd49uHcQ.mjs +4 -0
  14. package/browser/esm/B73J41HhbJvswDz1.mjs +17 -0
  15. package/browser/esm/BXhWTnlrRShaRGS5.mjs +581 -0
  16. package/browser/esm/B_2CC0NvNtPBw_ad.mjs +22 -0
  17. package/browser/esm/BxiAkxNyUQseLNBv.mjs +10 -0
  18. package/browser/esm/D9jTpNifykCuQkTL.mjs +18 -0
  19. package/browser/esm/DP3uAaeZa0hNHrYJ.mjs +3818 -0
  20. package/browser/esm/NpFv8YNKRgVPGXOq.mjs +9 -0
  21. package/browser/esm/SXQ4A1qlBB6JRAEQ.mjs +23 -0
  22. package/browser/esm/index.mjs +71 -41
  23. package/browser/esm/zGQXHcrpOlM4m6Nn.mjs +197 -0
  24. package/node/esm/4VkvY2rXOd49uHcQ.mjs +4 -0
  25. package/node/esm/BRuHQvNZfkRtcqXr.mjs +196 -0
  26. package/node/esm/CZo429AzOkBwGTWk.mjs +23 -0
  27. package/node/esm/ClxOMp6IdEZdW4Qd.mjs +8 -0
  28. package/node/esm/D0CDObJV23Rxk8-r.mjs +15 -0
  29. package/node/esm/DyZ4_kNN_urjQyjU.mjs +20 -0
  30. package/node/esm/byRhqE863Yd8YyB5.mjs +581 -0
  31. package/node/esm/index.mjs +83 -148
  32. package/node/esm/og3Pk2ReS3UiORbF.mjs +21 -0
  33. package/package.json +3 -3
  34. package/types/src/compiler/insertRunGuard.d.ts +11 -0
  35. package/types/src/compiler/relaxForRun.d.ts +8 -0
  36. package/types/src/lib/typescript/typescript.browser.d.ts +6 -0
  37. package/types/src/lib/typescript/typescript.node.d.ts +11 -0
  38. package/types/src/linter/Linter.d.ts +20 -0
  39. package/types/src/runtime/RunGuard.d.ts +31 -0
  40. package/types/src/runtime/index.d.ts +1 -0
  41. package/types/src/type/CompileOptions.d.ts +47 -0
  42. package/types/src/type/CompiledModule.d.ts +36 -6
  43. package/types/src/type/Diagnostic.d.ts +25 -3
  44. package/types/src/type/Types.d.ts +44 -5
  45. package/browser/cjs/BJpcKKDPQlQbi5O5.cjs +0 -7
  46. package/browser/cjs/Bu4cZ8iSZ3rij-oV.cjs +0 -1
  47. package/browser/cjs/BvG8N7G_8CXIAlT-.cjs +0 -1
  48. package/browser/cjs/CY8w1D0xPdaNysFJ.cjs +0 -1
  49. package/browser/cjs/C_7w8EJZpHw8ueuq.cjs +0 -1
  50. package/browser/cjs/C_IEgjM-hSJCv6Gm.cjs +0 -1
  51. package/browser/cjs/CctaCN_w3o34V9AR.cjs +0 -1
  52. package/browser/cjs/DIf4GvYEqb4ayb6a.cjs +0 -1
  53. package/browser/cjs/DcNeWEf5ZqALrCr4.cjs +0 -1
  54. package/browser/cjs/_PKWNtAymIZGtvCb.cjs +0 -21
  55. package/browser/esm/1kUe1fPM50LHqYNI.mjs +0 -15
  56. package/browser/esm/3YV545IwjRqG3c1v.mjs +0 -27
  57. package/browser/esm/CFj5DZ16U361ltLj.mjs +0 -8
  58. package/browser/esm/CSXzDPdxAeONd9Br.mjs +0 -152
  59. package/browser/esm/DCIZplzRAR9pzoyD.mjs +0 -12
  60. package/browser/esm/DL0Hj5P777IybKK1.mjs +0 -25
  61. package/browser/esm/Dn3tZ47l4kfqm82M.mjs +0 -434
  62. package/browser/esm/Im_056DAe1M8tSZK.mjs +0 -23
  63. package/browser/esm/bJcM1PsEX9VZuqnT.mjs +0 -87
  64. package/browser/esm/v5FtHwExzUecgxho.mjs +0 -112
  65. package/node/esm/CFj5DZ16U361ltLj.mjs +0 -8
  66. package/node/esm/CL56uy8tfvhJRKYS.mjs +0 -434
  67. package/node/esm/CZgThiQ_9yYAaYaW.mjs +0 -152
  68. package/node/esm/DDDZ5Wv9-gK2v6Qt.mjs +0 -23
  69. package/node/esm/DEIcuGll5aCjPisP.mjs +0 -27
  70. package/node/esm/DOv0wuhb-kNvUT7-.mjs +0 -12
  71. package/node/esm/NgoqymNyfjBf3Vbn.mjs +0 -17
  72. package/node/esm/P5z0UPrc8__6uFCR.mjs +0 -14
@@ -0,0 +1,9 @@
1
+ import { t } from "./4VkvY2rXOd49uHcQ.mjs";
2
+ async function a(r, e) {
3
+ let o = r;
4
+ return e?.sourceMap && (o += `
5
+ ${t}=${e.sourceMap}`), new Function("url", "return import(url)")(`data:text/javascript,${encodeURIComponent(o)}`);
6
+ }
7
+ export {
8
+ a as loadCompiledModule
9
+ };
@@ -0,0 +1,23 @@
1
+ var t = class {
2
+ constructor(r = {}) {
3
+ this.workerWrapper = null;
4
+ }
5
+ async getWorkerWrapper() {
6
+ if (this.workerWrapper) return this.workerWrapper;
7
+ const { createCompilerWorker: r } = await import("./DP3uAaeZa0hNHrYJ.mjs");
8
+ return this.workerWrapper = await r(), this.workerWrapper;
9
+ }
10
+ async compileModule(r) {
11
+ try {
12
+ return (await this.getWorkerWrapper()).execute(r);
13
+ } catch (e) {
14
+ throw console.error("Failed to compile using worker:", e), e;
15
+ }
16
+ }
17
+ terminate() {
18
+ this.workerWrapper?.terminate(), this.workerWrapper = null;
19
+ }
20
+ };
21
+ export {
22
+ t as TypeScriptCompiler
23
+ };
@@ -1,41 +1,71 @@
1
- /**
2
- * @license @sheetxl/scripting - Scripting - Scripting engine for Macros and formulas; includes TypeScript and EsBuild. - v0.8.0-beta.1
3
- *
4
- * (C) 2026-present SheetXL Inc. & Michael T. Ford
5
- * License: The license can be found at https://www.sheetxl.com/license.
6
- */
7
- import { t as e } from "./1kUe1fPM50LHqYNI.mjs";
8
- import { r as t, t as n } from "./v5FtHwExzUecgxho.mjs";
9
- import { CommonUtils as r } from "@sheetxl/utils";
10
- async function i(e, t) {
11
- let { loadCompiledModule: n } = await import("./DCIZplzRAR9pzoyD.mjs");
12
- return n(e, t);
13
- }
14
- var a = null, o = null, s = null, c = null;
15
- async function l() {
16
- return c ||= (async () => (await import("./Im_056DAe1M8tSZK.mjs")).initialize())(), c;
17
- }
18
- var u = Object.freeze({
19
- compile: async function(e) {
20
- if (!e?.source) return {
21
- module: null,
22
- diagnostics: []
23
- };
24
- if (o && r.deepEqual(o, e)) return a;
25
- let t = await (await async function() {
26
- if (s) return s;
27
- let { TypeScriptCompiler: e } = await import("./3YV545IwjRqG3c1v.mjs");
28
- return s = new e();
29
- }()).compileModule(e);
30
- return a = t, o = e, t;
31
- },
32
- lint: async function(e, t) {
33
- if (!e) return [];
34
- let [n, { lintScript: r }] = await Promise.all([l(), import("./Dn3tZ47l4kfqm82M.mjs")]);
35
- return r(n, e, t);
36
- },
37
- cleanup: function() {
38
- s && (s.terminate(), s = null, a = null);
39
- }
40
- });
41
- export { e as Constants, t as DiagnosticCode, n as DocTags, u as ScriptCompiler, i as loadCompiledModule };
1
+ import { r as d, t as g } from "./BxiAkxNyUQseLNBv.mjs";
2
+ import { r as M, t as T } from "./B73J41HhbJvswDz1.mjs";
3
+ import { CommonUtils as f } from "@sheetxl/utils";
4
+ var S = d({ RUN_INTERRUPTED: () => u, abort: () => h, check: () => y, isInterrupted: () => R, release: () => C }), r = /* @__PURE__ */ new Map(), m = 256, w = 16, u = "RunInterrupted";
5
+ function c(t) {
6
+ const n = new Error(t);
7
+ return n.name = u, n;
8
+ }
9
+ function s(t) {
10
+ let n = r.get(t);
11
+ if (!n) {
12
+ if (r.size >= m) {
13
+ const e = r.keys().next().value;
14
+ e !== void 0 && r.delete(e);
15
+ }
16
+ n = { started: Date.now(), calls: 0, stopped: null }, r.set(t, n);
17
+ }
18
+ return n;
19
+ }
20
+ function y(t, n) {
21
+ const e = s(t);
22
+ if (e.stopped) throw e.stopped;
23
+ if (++e.calls % w === 0 && Date.now() - e.started > n) throw e.stopped = c(`Run stopped: it exceeded the ${Math.round(n / 1e3)} s time limit.`), e.stopped;
24
+ }
25
+ function h(t, n = "Run cancelled.") {
26
+ s(t).stopped = c(n);
27
+ }
28
+ function C(t) {
29
+ r.delete(t);
30
+ }
31
+ function R(t) {
32
+ return t?.name === u;
33
+ }
34
+ async function b(t, n) {
35
+ const { loadCompiledModule: e } = await import("./NpFv8YNKRgVPGXOq.mjs");
36
+ return e(t, n);
37
+ }
38
+ var a = null, l = null, o = null, i = null;
39
+ async function v() {
40
+ return i || (i = (async () => {
41
+ const t = await (await import("./B_2CC0NvNtPBw_ad.mjs")).initialize();
42
+ if (!t) throw new Error("TypeScript could not be loaded. Check your connection and try again.");
43
+ return t;
44
+ })()).catch(() => {
45
+ i = null;
46
+ }), i;
47
+ }
48
+ var k = Object.freeze({ compile: async function(t) {
49
+ if (!t?.source) return { module: null, diagnostics: [] };
50
+ if (l && f.deepEqual(l, t)) return a;
51
+ const n = await (await (async function() {
52
+ if (o) return o;
53
+ const { TypeScriptCompiler: e } = await import("./SXQ4A1qlBB6JRAEQ.mjs");
54
+ return o = new e();
55
+ })()).compileModule(t);
56
+ return a = n, l = t, n;
57
+ }, lint: async function(t, n) {
58
+ if (!t) return [];
59
+ const [e, { lintScript: p }] = await Promise.all([v(), import("./BXhWTnlrRShaRGS5.mjs")]);
60
+ return p(e, t, n);
61
+ }, cleanup: function() {
62
+ o && (o.terminate(), o = null, a = null);
63
+ } });
64
+ export {
65
+ g as Constants,
66
+ M as DiagnosticCode,
67
+ T as DocTags,
68
+ S as RunGuard,
69
+ k as ScriptCompiler,
70
+ b as loadCompiledModule
71
+ };
@@ -0,0 +1,197 @@
1
+ import { n as k } from "./BxiAkxNyUQseLNBv.mjs";
2
+ import { r as V } from "./B73J41HhbJvswDz1.mjs";
3
+ import { analyzeModule as X } from "./BXhWTnlrRShaRGS5.mjs";
4
+ import { t as M } from "./4VkvY2rXOd49uHcQ.mjs";
5
+ import { CommonUtils as H } from "@sheetxl/utils";
6
+ var g = null, E = null, Y = { compilerOptions: { target: "esnext" } };
7
+ async function Z(t, d, u = "/script.js", c = k) {
8
+ try {
9
+ const e = await (async function() {
10
+ if (g) return g;
11
+ if (E) {
12
+ if (await E, !g) throw new Error("ESBuild initialization promise resolved, but instance is not available.");
13
+ return g;
14
+ }
15
+ let r, s;
16
+ E = new Promise((i, m) => {
17
+ r = i, s = m;
18
+ });
19
+ try {
20
+ const { initialize: i } = await import("./D9jTpNifykCuQkTL.mjs");
21
+ return g = await i(), r(), g;
22
+ } catch (i) {
23
+ throw console.error("Failed to import or initialize esbuild:", i), E = null, s(i), i;
24
+ }
25
+ })(), a = "@sheetxl/primitives", l = `
26
+ export const FormulaContext = globalThis.${c}?.FormulaContext;
27
+ export const ScalarType = globalThis.${c}?.ScalarType;
28
+ export const Observable = globalThis.${c}?.Observable;
29
+ export const IRange = globalThis.${c}?.IRange;
30
+ export const FormulaError = globalThis.${c}?.FormulaError;
31
+ // Add more exports as needed
32
+ `, o = await e.build({ entryPoints: [u], bundle: !0, write: !1, format: "esm", plugins: [{ name: "sheetxl-esbuild-in-memory", setup(r) {
33
+ const s = "sheetxl-" + (/* @__PURE__ */ new Date()).getTime();
34
+ r.onResolve({ filter: new RegExp(`^(${u.replace("/", "\\/")}|${a})$`) }, (i) => ({ path: i.path, namespace: s })), r.onResolve({ filter: /.*/ }, (i) => {
35
+ if (i.namespace !== s) return console.warn(`esbuild: Treating import "${i.path}" as external.`), { path: i.path, external: !0 };
36
+ }), r.onLoad({ filter: /.*/, namespace: s }, (i) => {
37
+ let m;
38
+ if (i.path === u) m = d;
39
+ else {
40
+ if (i.path !== a) return { errors: [{ text: `Cannot load unknown path in ${s}: ${i.path}` }] };
41
+ m = l;
42
+ }
43
+ return { contents: m, loader: "ts" };
44
+ });
45
+ } }], sourcemap: "inline", tsconfigRaw: Y, minify: !0, platform: "neutral" });
46
+ if (o.outputFiles && o.outputFiles.length > 0) return o.outputFiles[0].text;
47
+ throw o.errors && o.errors.length > 0 ? new Error(`esbuild bundling failed: ${o.errors.map((r) => r.text).join(`
48
+ `)}`) : new Error("esbuild did not produce an output file.");
49
+ } catch (e) {
50
+ throw console.error("esbuild bundling process failed:", e), e;
51
+ }
52
+ }
53
+ function _(t, d, u) {
54
+ return (c) => {
55
+ const e = c.factory, a = () => e.createExpressionStatement(e.createCallChain(e.createPropertyAccessExpression(e.createIdentifier(k), "checkRun"), e.createToken(t.SyntaxKind.QuestionDotToken), void 0, [e.createStringLiteral(d), e.createNumericLiteral(u)])), l = (r) => {
56
+ const s = r.statements;
57
+ let i = 0;
58
+ for (; i < s.length && t.isExpressionStatement(s[i]) && t.isStringLiteral(s[i].expression); ) i++;
59
+ return e.updateBlock(r, [...s.slice(0, i), a(), ...s.slice(i)]);
60
+ }, o = (r) => {
61
+ if (((s) => t.isForStatement(s) || t.isForInStatement(s) || t.isForOfStatement(s) || t.isWhileStatement(s) || t.isDoStatement(s))(r)) {
62
+ const s = r.statement;
63
+ return t.visitEachChild(r, (i) => {
64
+ const m = o(i);
65
+ return i === s ? (f = m, t.isBlock(f) ? l(f) : e.createBlock([a(), f], !0)) : m;
66
+ var f;
67
+ }, c);
68
+ }
69
+ if (t.isFunctionLike(r) && r.body) {
70
+ const s = r.body;
71
+ return t.visitEachChild(r, (i) => {
72
+ const m = o(i);
73
+ return i === s ? (f = m, t.isBlock(f) ? l(f) : e.createBlock([a(), e.createReturnStatement(f)], !0)) : m;
74
+ var f;
75
+ }, c);
76
+ }
77
+ return t.visitEachChild(r, o, c);
78
+ };
79
+ return (r) => t.visitNode(r, o);
80
+ };
81
+ }
82
+ var ee = /* @__PURE__ */ new Set(["TS2339", "TS2551"]);
83
+ function te(t, d, u) {
84
+ let c = null;
85
+ const e = (a) => {
86
+ u < a.getStart(d) || u >= a.end || (a.getStart(d) === u && (c = a), t.forEachChild(a, e));
87
+ };
88
+ return t.forEachChild(d, e), c;
89
+ }
90
+ function ne(t, d) {
91
+ const u = d.parent;
92
+ if (!u || !t.isPropertyAccessExpression(u) || u.name !== d) return !1;
93
+ let c = u, e = u.parent;
94
+ for (; e && (t.isParenthesizedExpression(e) || t.isNonNullExpression(e)); ) c = e, e = e.parent;
95
+ if (!e) return !1;
96
+ if ((t.isCallExpression(e) || t.isPropertyAccessExpression(e) || t.isElementAccessExpression(e)) && e.expression === c) return !!e.questionDotToken;
97
+ if (t.isTypeOfExpression(e)) return !0;
98
+ if (t.isPrefixUnaryExpression(e)) return e.operator === t.SyntaxKind.ExclamationToken;
99
+ if (t.isConditionalExpression(e)) return e.condition === c;
100
+ if (t.isIfStatement(e) || t.isWhileStatement(e) || t.isDoStatement(e)) return e.expression === c;
101
+ if (t.isBinaryExpression(e)) {
102
+ const a = e.operatorToken.kind, l = t.SyntaxKind;
103
+ if (a === l.AmpersandAmpersandToken || a === l.BarBarToken || a === l.QuestionQuestionToken) return e.left === c;
104
+ if (a === l.EqualsEqualsEqualsToken || a === l.ExclamationEqualsEqualsToken || a === l.EqualsEqualsToken || a === l.ExclamationEqualsToken) return ((o, r) => r.kind === o.SyntaxKind.NullKeyword || o.isIdentifier(r) && r.text === "undefined")(t, e.left === c ? e.right : e.left);
105
+ }
106
+ return !1;
107
+ }
108
+ var ie = async () => `
109
+ interface FirstTest {
110
+ isTrue?: boolean;
111
+ }
112
+ `, v = null, P = "sheetxl.d.ts", q = "sheetxl-modules.d.ts", re = ["lib.webworker.d.ts", "lib.es2020.d.ts", "lib.esnext.asynciterable.d.ts"], O = /* @__PURE__ */ new Map(), R = null, B = null;
113
+ async function oe() {
114
+ return B || (B = import("./B_2CC0NvNtPBw_ad.mjs").then(async (t) => {
115
+ const d = await z();
116
+ return t.readLibFile(d, "lib.es5.d.ts") !== void 0 ? t.readLibFile : null;
117
+ })), B;
118
+ }
119
+ async function z() {
120
+ if (v) return v;
121
+ try {
122
+ const t = await (await import("./B_2CC0NvNtPBw_ad.mjs")).initialize();
123
+ if (!t) throw new Error("TypeScript could not be loaded. Check your connection and try again.");
124
+ return t;
125
+ } catch (t) {
126
+ throw v = null, t;
127
+ } finally {
128
+ v = null;
129
+ }
130
+ }
131
+ async function de(t) {
132
+ const d = t?.source ?? null;
133
+ if (!d) return { module: null, diagnostics: [] };
134
+ const u = (t.disableBundle || t.declarationsOnly) ?? !1, [c, e, a] = await Promise.all([ie(), z(), t.ambientTypes ? oe() : null]), l = a ? t.ambientTypes ?? null : null;
135
+ let o = "";
136
+ const r = { allowJs: !0, declaration: !1, sourceMap: !1, inlineSourceMap: !1, inlineSources: !1, isolatedModules: !0, preserveConstEnums: !1, module: 99, noResolve: !0, emitDeclarationOnly: !1, target: e.ScriptTarget.ES2020, ...l ? { lib: re, skipLibCheck: !0, strict: !0 } : {}, ...l && t.lenient ? { noImplicitAny: !1 } : {} }, s = "script", i = `${s}.ts`, m = "lib.d.ts", f = "global.d.ts", y = { [i]: d, [m]: `
137
+ /**
138
+ * Represents the completion of an asynchronous operation
139
+ */
140
+ interface Promise<T> {
141
+ /**
142
+ * Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The
143
+ * resolved value cannot be modified from the callback.
144
+ * @param onfinally The callback to execute when the Promise is settled (fulfilled or rejected).
145
+ * @returns A Promise for the completion of the callback.
146
+ */
147
+ finally(onfinally?: (() => void) | undefined | null): Promise<T>;
148
+ }
149
+ `, [f]: c, ...l ? { [P]: l, [q]: `declare module '@sheetxl/primitives' { export = SheetXL; }
150
+ ` } : {} }, F = (n) => y[n] ?? (a && n.startsWith("lib.") ? a(e, n) : void 0), j = { getSourceFile: (n, b, N, h) => {
151
+ if (n === P) return R?.text !== l && (R = { text: l, file: e.createSourceFile(n, l, e.ScriptTarget.Latest, !1) }), R.file;
152
+ if (y[n] === void 0) {
153
+ let p = O.get(n);
154
+ if (!p) {
155
+ const S = F(n);
156
+ if (S === void 0) return;
157
+ p = e.createSourceFile(n, S, e.ScriptTarget.Latest, !1), O.set(n, p);
158
+ }
159
+ return p;
160
+ }
161
+ return e.createSourceFile(n, y[n], e.ScriptTarget.Latest, !0);
162
+ }, fileExists: (n) => F(n) !== void 0, readFile: F, writeFile: (n, b) => {
163
+ y[n] = b;
164
+ }, getCurrentDirectory: () => "./", getCanonicalFileName: (n) => n, useCaseSensitiveFileNames: () => !0, getDefaultLibFileName: (n) => m, getNewLine: () => `
165
+ ` }, x = e.createProgram([i, f, ...l ? [P, q] : []], r, j), K = x.getTypeChecker(), T = x.getSourceFile(i), C = t.runGuard;
166
+ x.emit(void 0, void 0, void 0, void 0, C ? { before: [_(e, C.key, C.timeoutMs)] } : void 0), o = y[`${s}.js`] ?? "";
167
+ const I = (n) => ({ start: n.start ?? 0, length: n.length ?? 0, severity: n.category === e.DiagnosticCategory.Warning ? "warning" : "error", code: `TS${n.code}`, message: e.flattenDiagnosticMessageText(n.messageText, `
168
+ `) }), W = x.getSyntacticDiagnostics(T).map(I), Q = l ? x.getSemanticDiagnostics(T).filter((n) => n.category === e.DiagnosticCategory.Error || n.category === e.DiagnosticCategory.Warning).map(I) : [], $ = X(e, T, K, { builtInNames: t.builtInNames, isBuiltIn: t.isBuiltIn, lenient: !!l && t.lenient });
169
+ let w = [...W, ...Q, ...$.diagnostics];
170
+ l && t.lenient && (w = (function(n, b, N) {
171
+ const h = [];
172
+ for (const p of N) if (p.code !== V.MissingType) if (p.severity !== "error") h.push(p);
173
+ else if (p.code === "TS2774") h.push({ ...p, severity: "warning" });
174
+ else if (ee.has(p.code)) {
175
+ const S = te(n, b, p.start);
176
+ h.push(S && ne(n, S) ? { ...p, severity: "warning", message: `${p.message} Read as a probe, it is undefined.` } : p);
177
+ } else h.push(p);
178
+ return h;
179
+ })(e, T, w));
180
+ const U = $.functions, A = $.autoRun, G = w.some((n) => n.severity === "error"), J = `${H.uuidV4()}-script`;
181
+ let D = null;
182
+ if (G) o = "";
183
+ else {
184
+ try {
185
+ u || (o = await Z(0, o, s));
186
+ } catch {
187
+ console.warn("Error bundling script");
188
+ }
189
+ const n = o.indexOf(M);
190
+ n > -1 && (D = o.substring(n + M.length + 1, o.length), o = o.substring(0, n), o = o.replaceAll("globalThis." + k, k));
191
+ }
192
+ const L = { functions: U, commitId: J, source: d, language: "typescript", compiled: o };
193
+ return D && (L.sourceMap = D), A && (L.autoRun = A), { module: L, diagnostics: w };
194
+ }
195
+ export {
196
+ de as compileModule
197
+ };
@@ -0,0 +1,4 @@
1
+ var a = "//# sourceMappingURL";
2
+ export {
3
+ a as t
4
+ };
@@ -0,0 +1,196 @@
1
+ import { DiagnosticCode as V, t as k } from "./index.mjs";
2
+ import { analyzeModule as X } from "./byRhqE863Yd8YyB5.mjs";
3
+ import { t as M } from "./4VkvY2rXOd49uHcQ.mjs";
4
+ import { CommonUtils as H } from "@sheetxl/utils";
5
+ var g = null, E = null, Y = { compilerOptions: { target: "esnext" } };
6
+ async function Z(t, d, u = "/script.js", c = k) {
7
+ try {
8
+ const e = await (async function() {
9
+ if (g) return g;
10
+ if (E) {
11
+ if (await E, !g) throw new Error("ESBuild initialization promise resolved, but instance is not available.");
12
+ return g;
13
+ }
14
+ let r, s;
15
+ E = new Promise((i, f) => {
16
+ r = i, s = f;
17
+ });
18
+ try {
19
+ const { initialize: i } = await import("./ClxOMp6IdEZdW4Qd.mjs");
20
+ return g = await i(), r(), g;
21
+ } catch (i) {
22
+ throw console.error("Failed to import or initialize esbuild:", i), E = null, s(i), i;
23
+ }
24
+ })(), a = "@sheetxl/primitives", l = `
25
+ export const FormulaContext = globalThis.${c}?.FormulaContext;
26
+ export const ScalarType = globalThis.${c}?.ScalarType;
27
+ export const Observable = globalThis.${c}?.Observable;
28
+ export const IRange = globalThis.${c}?.IRange;
29
+ export const FormulaError = globalThis.${c}?.FormulaError;
30
+ // Add more exports as needed
31
+ `, o = await e.build({ entryPoints: [u], bundle: !0, write: !1, format: "esm", plugins: [{ name: "sheetxl-esbuild-in-memory", setup(r) {
32
+ const s = "sheetxl-" + (/* @__PURE__ */ new Date()).getTime();
33
+ r.onResolve({ filter: new RegExp(`^(${u.replace("/", "\\/")}|${a})$`) }, (i) => ({ path: i.path, namespace: s })), r.onResolve({ filter: /.*/ }, (i) => {
34
+ if (i.namespace !== s) return console.warn(`esbuild: Treating import "${i.path}" as external.`), { path: i.path, external: !0 };
35
+ }), r.onLoad({ filter: /.*/, namespace: s }, (i) => {
36
+ let f;
37
+ if (i.path === u) f = d;
38
+ else {
39
+ if (i.path !== a) return { errors: [{ text: `Cannot load unknown path in ${s}: ${i.path}` }] };
40
+ f = l;
41
+ }
42
+ return { contents: f, loader: "ts" };
43
+ });
44
+ } }], sourcemap: "inline", tsconfigRaw: Y, minify: !0, platform: "neutral" });
45
+ if (o.outputFiles && o.outputFiles.length > 0) return o.outputFiles[0].text;
46
+ throw o.errors && o.errors.length > 0 ? new Error(`esbuild bundling failed: ${o.errors.map((r) => r.text).join(`
47
+ `)}`) : new Error("esbuild did not produce an output file.");
48
+ } catch (e) {
49
+ throw console.error("esbuild bundling process failed:", e), e;
50
+ }
51
+ }
52
+ function _(t, d, u) {
53
+ return (c) => {
54
+ const e = c.factory, a = () => e.createExpressionStatement(e.createCallChain(e.createPropertyAccessExpression(e.createIdentifier(k), "checkRun"), e.createToken(t.SyntaxKind.QuestionDotToken), void 0, [e.createStringLiteral(d), e.createNumericLiteral(u)])), l = (r) => {
55
+ const s = r.statements;
56
+ let i = 0;
57
+ for (; i < s.length && t.isExpressionStatement(s[i]) && t.isStringLiteral(s[i].expression); ) i++;
58
+ return e.updateBlock(r, [...s.slice(0, i), a(), ...s.slice(i)]);
59
+ }, o = (r) => {
60
+ if (((s) => t.isForStatement(s) || t.isForInStatement(s) || t.isForOfStatement(s) || t.isWhileStatement(s) || t.isDoStatement(s))(r)) {
61
+ const s = r.statement;
62
+ return t.visitEachChild(r, (i) => {
63
+ const f = o(i);
64
+ return i === s ? (m = f, t.isBlock(m) ? l(m) : e.createBlock([a(), m], !0)) : f;
65
+ var m;
66
+ }, c);
67
+ }
68
+ if (t.isFunctionLike(r) && r.body) {
69
+ const s = r.body;
70
+ return t.visitEachChild(r, (i) => {
71
+ const f = o(i);
72
+ return i === s ? (m = f, t.isBlock(m) ? l(m) : e.createBlock([a(), e.createReturnStatement(m)], !0)) : f;
73
+ var m;
74
+ }, c);
75
+ }
76
+ return t.visitEachChild(r, o, c);
77
+ };
78
+ return (r) => t.visitNode(r, o);
79
+ };
80
+ }
81
+ var ee = /* @__PURE__ */ new Set(["TS2339", "TS2551"]);
82
+ function te(t, d, u) {
83
+ let c = null;
84
+ const e = (a) => {
85
+ u < a.getStart(d) || u >= a.end || (a.getStart(d) === u && (c = a), t.forEachChild(a, e));
86
+ };
87
+ return t.forEachChild(d, e), c;
88
+ }
89
+ function ne(t, d) {
90
+ const u = d.parent;
91
+ if (!u || !t.isPropertyAccessExpression(u) || u.name !== d) return !1;
92
+ let c = u, e = u.parent;
93
+ for (; e && (t.isParenthesizedExpression(e) || t.isNonNullExpression(e)); ) c = e, e = e.parent;
94
+ if (!e) return !1;
95
+ if ((t.isCallExpression(e) || t.isPropertyAccessExpression(e) || t.isElementAccessExpression(e)) && e.expression === c) return !!e.questionDotToken;
96
+ if (t.isTypeOfExpression(e)) return !0;
97
+ if (t.isPrefixUnaryExpression(e)) return e.operator === t.SyntaxKind.ExclamationToken;
98
+ if (t.isConditionalExpression(e)) return e.condition === c;
99
+ if (t.isIfStatement(e) || t.isWhileStatement(e) || t.isDoStatement(e)) return e.expression === c;
100
+ if (t.isBinaryExpression(e)) {
101
+ const a = e.operatorToken.kind, l = t.SyntaxKind;
102
+ if (a === l.AmpersandAmpersandToken || a === l.BarBarToken || a === l.QuestionQuestionToken) return e.left === c;
103
+ if (a === l.EqualsEqualsEqualsToken || a === l.ExclamationEqualsEqualsToken || a === l.EqualsEqualsToken || a === l.ExclamationEqualsToken) return ((o, r) => r.kind === o.SyntaxKind.NullKeyword || o.isIdentifier(r) && r.text === "undefined")(t, e.left === c ? e.right : e.left);
104
+ }
105
+ return !1;
106
+ }
107
+ var ie = async () => `
108
+ interface FirstTest {
109
+ isTrue?: boolean;
110
+ }
111
+ `, v = null, P = "sheetxl.d.ts", q = "sheetxl-modules.d.ts", re = ["lib.webworker.d.ts", "lib.es2020.d.ts", "lib.esnext.asynciterable.d.ts"], O = /* @__PURE__ */ new Map(), R = null, B = null;
112
+ async function oe() {
113
+ return B || (B = import("./og3Pk2ReS3UiORbF.mjs").then(async (t) => {
114
+ const d = await z();
115
+ return t.readLibFile(d, "lib.es5.d.ts") !== void 0 ? t.readLibFile : null;
116
+ })), B;
117
+ }
118
+ async function z() {
119
+ if (v) return v;
120
+ try {
121
+ const t = await (await import("./og3Pk2ReS3UiORbF.mjs")).initialize();
122
+ if (!t) throw new Error("TypeScript could not be loaded. Check your connection and try again.");
123
+ return t;
124
+ } catch (t) {
125
+ throw v = null, t;
126
+ } finally {
127
+ v = null;
128
+ }
129
+ }
130
+ async function ue(t) {
131
+ const d = t?.source ?? null;
132
+ if (!d) return { module: null, diagnostics: [] };
133
+ const u = (t.disableBundle || t.declarationsOnly) ?? !1, [c, e, a] = await Promise.all([ie(), z(), t.ambientTypes ? oe() : null]), l = a ? t.ambientTypes ?? null : null;
134
+ let o = "";
135
+ const r = { allowJs: !0, declaration: !1, sourceMap: !1, inlineSourceMap: !1, inlineSources: !1, isolatedModules: !0, preserveConstEnums: !1, module: 99, noResolve: !0, emitDeclarationOnly: !1, target: e.ScriptTarget.ES2020, ...l ? { lib: re, skipLibCheck: !0, strict: !0 } : {}, ...l && t.lenient ? { noImplicitAny: !1 } : {} }, s = "script", i = `${s}.ts`, f = "lib.d.ts", m = "global.d.ts", y = { [i]: d, [f]: `
136
+ /**
137
+ * Represents the completion of an asynchronous operation
138
+ */
139
+ interface Promise<T> {
140
+ /**
141
+ * Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The
142
+ * resolved value cannot be modified from the callback.
143
+ * @param onfinally The callback to execute when the Promise is settled (fulfilled or rejected).
144
+ * @returns A Promise for the completion of the callback.
145
+ */
146
+ finally(onfinally?: (() => void) | undefined | null): Promise<T>;
147
+ }
148
+ `, [m]: c, ...l ? { [P]: l, [q]: `declare module '@sheetxl/primitives' { export = SheetXL; }
149
+ ` } : {} }, F = (n) => y[n] ?? (a && n.startsWith("lib.") ? a(e, n) : void 0), j = { getSourceFile: (n, b, N, h) => {
150
+ if (n === P) return R?.text !== l && (R = { text: l, file: e.createSourceFile(n, l, e.ScriptTarget.Latest, !1) }), R.file;
151
+ if (y[n] === void 0) {
152
+ let p = O.get(n);
153
+ if (!p) {
154
+ const S = F(n);
155
+ if (S === void 0) return;
156
+ p = e.createSourceFile(n, S, e.ScriptTarget.Latest, !1), O.set(n, p);
157
+ }
158
+ return p;
159
+ }
160
+ return e.createSourceFile(n, y[n], e.ScriptTarget.Latest, !0);
161
+ }, fileExists: (n) => F(n) !== void 0, readFile: F, writeFile: (n, b) => {
162
+ y[n] = b;
163
+ }, getCurrentDirectory: () => "./", getCanonicalFileName: (n) => n, useCaseSensitiveFileNames: () => !0, getDefaultLibFileName: (n) => f, getNewLine: () => `
164
+ ` }, x = e.createProgram([i, m, ...l ? [P, q] : []], r, j), K = x.getTypeChecker(), T = x.getSourceFile(i), C = t.runGuard;
165
+ x.emit(void 0, void 0, void 0, void 0, C ? { before: [_(e, C.key, C.timeoutMs)] } : void 0), o = y[`${s}.js`] ?? "";
166
+ const I = (n) => ({ start: n.start ?? 0, length: n.length ?? 0, severity: n.category === e.DiagnosticCategory.Warning ? "warning" : "error", code: `TS${n.code}`, message: e.flattenDiagnosticMessageText(n.messageText, `
167
+ `) }), W = x.getSyntacticDiagnostics(T).map(I), Q = l ? x.getSemanticDiagnostics(T).filter((n) => n.category === e.DiagnosticCategory.Error || n.category === e.DiagnosticCategory.Warning).map(I) : [], $ = X(e, T, K, { builtInNames: t.builtInNames, isBuiltIn: t.isBuiltIn, lenient: !!l && t.lenient });
168
+ let w = [...W, ...Q, ...$.diagnostics];
169
+ l && t.lenient && (w = (function(n, b, N) {
170
+ const h = [];
171
+ for (const p of N) if (p.code !== V.MissingType) if (p.severity !== "error") h.push(p);
172
+ else if (p.code === "TS2774") h.push({ ...p, severity: "warning" });
173
+ else if (ee.has(p.code)) {
174
+ const S = te(n, b, p.start);
175
+ h.push(S && ne(n, S) ? { ...p, severity: "warning", message: `${p.message} Read as a probe, it is undefined.` } : p);
176
+ } else h.push(p);
177
+ return h;
178
+ })(e, T, w));
179
+ const U = $.functions, A = $.autoRun, G = w.some((n) => n.severity === "error"), J = `${H.uuidV4()}-script`;
180
+ let D = null;
181
+ if (G) o = "";
182
+ else {
183
+ try {
184
+ u || (o = await Z(0, o, s));
185
+ } catch {
186
+ console.warn("Error bundling script");
187
+ }
188
+ const n = o.indexOf(M);
189
+ n > -1 && (D = o.substring(n + M.length + 1, o.length), o = o.substring(0, n), o = o.replaceAll("globalThis." + k, k));
190
+ }
191
+ const L = { functions: U, commitId: J, source: d, language: "typescript", compiled: o };
192
+ return D && (L.sourceMap = D), A && (L.autoRun = A), { module: L, diagnostics: w };
193
+ }
194
+ export {
195
+ ue as compileModule
196
+ };
@@ -0,0 +1,23 @@
1
+ var t = class {
2
+ constructor(r = {}) {
3
+ this.workerWrapper = null;
4
+ }
5
+ async getWorkerWrapper() {
6
+ if (this.workerWrapper) return this.workerWrapper;
7
+ const { createCompilerWorker: r } = await import("./DyZ4_kNN_urjQyjU.mjs");
8
+ return this.workerWrapper = await r(), this.workerWrapper;
9
+ }
10
+ async compileModule(r) {
11
+ try {
12
+ return (await this.getWorkerWrapper()).execute(r);
13
+ } catch (e) {
14
+ throw console.error("Failed to compile using worker:", e), e;
15
+ }
16
+ }
17
+ terminate() {
18
+ this.workerWrapper?.terminate(), this.workerWrapper = null;
19
+ }
20
+ };
21
+ export {
22
+ t as TypeScriptCompiler
23
+ };
@@ -0,0 +1,8 @@
1
+ import * as n from "esbuild-wasm";
2
+ var i = null;
3
+ function r() {
4
+ return i || (i = n.initialize({}).then(() => n)), i;
5
+ }
6
+ export {
7
+ r as initialize
8
+ };
@@ -0,0 +1,15 @@
1
+ import { t as n } from "./4VkvY2rXOd49uHcQ.mjs";
2
+ async function c(r, t) {
3
+ const { writeFile: e, mkdtemp: p } = await import("node:fs/promises"), { tmpdir: m } = await import("node:os"), { join: o } = await import("node:path"), { pathToFileURL: s } = await import("node:url");
4
+ let a = r;
5
+ t?.sourceMap && (a += `
6
+ ${n}=${t.sourceMap}`);
7
+ const i = o(await p(o(m(), "sheetxl-script-")), "module.mjs");
8
+ return await e(i, a, "utf8"), import(
9
+ /* @vite-ignore */
10
+ s(i).href
11
+ );
12
+ }
13
+ export {
14
+ c as loadCompiledModule
15
+ };
@@ -0,0 +1,20 @@
1
+ var o = class {
2
+ constructor(e) {
3
+ this._onExecute = e;
4
+ }
5
+ execute(e) {
6
+ return this._onExecute(e);
7
+ }
8
+ start() {
9
+ return Promise.resolve();
10
+ }
11
+ terminate() {
12
+ }
13
+ };
14
+ async function a() {
15
+ const { compileModule: e } = await import("./BRuHQvNZfkRtcqXr.mjs"), t = new o((r) => e(r));
16
+ return await t.start(), t;
17
+ }
18
+ export {
19
+ a as createCompilerWorker
20
+ };