@sheetxl/scripting 0.8.0-beta.5 → 0.8.0-beta.7

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.
@@ -1,196 +0,0 @@
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
- };
@@ -1,8 +0,0 @@
1
- import { default as ts } from 'typescript';
2
- import { Diagnostic } from '../type';
3
- /**
4
- * The diagnostics of a `lenient` compile ({@link CompileOptions.lenient}): what cannot fail at run
5
- * time is a warning, and a missing annotation is not reported.
6
- */
7
- export declare function relaxForRun(tsm: typeof ts, sourceFile: ts.SourceFile, diagnostics: Diagnostic[]): Diagnostic[];
8
- //# sourceMappingURL=relaxForRun.d.ts.map