@sheetxl/scripting 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/README.md +2 -2
- package/{node/esm/byRhqE863Yd8YyB5.mjs → browser/esm/CUERvTrIURHqOWKm.mjs} +281 -282
- package/browser/esm/CwhaPB7R93eqixfq.mjs +162 -0
- package/browser/esm/DYo_7j0y20wRtntJ.mjs +4012 -0
- package/browser/esm/DfSFyaySrD6y1NJY.mjs +17 -0
- package/browser/esm/{SXQ4A1qlBB6JRAEQ.mjs → Dxfyqtw07s-Dtn7T.mjs} +1 -1
- package/browser/esm/index.mjs +3 -3
- package/node/esm/{DyZ4_kNN_urjQyjU.mjs → 2OiXgLd8VwO6IeDg.mjs} +1 -1
- package/node/esm/BDIcVjo-h3KFdXXo.mjs +161 -0
- package/node/esm/BLO91PRuOQIsW_Ow.mjs +580 -0
- package/node/esm/index.mjs +9 -9
- package/node/esm/{CZo429AzOkBwGTWk.mjs → oWHIRxwwLexnOwAn.mjs} +1 -1
- package/package.json +12 -8
- package/types/src/compiler/Bundler.d.ts +1 -1
- package/types/src/type/CompileOptions.d.ts +12 -9
- package/types/src/type/CompiledModule.d.ts +2 -2
- package/types/src/type/Diagnostic.d.ts +0 -2
- package/types/src/type/Types.d.ts +17 -0
- package/browser/cjs/B6RS19boKbA_QGQ6.cjs +0 -2
- package/browser/cjs/Bn3oEXST6uP5oPU2.cjs +0 -1
- package/browser/cjs/C83wXnFq94exmYt9.cjs +0 -1
- package/browser/cjs/C94szTiUbmNQa9FD.cjs +0 -1
- package/browser/cjs/CUd5aIyyU3_3B_V1.cjs +0 -29
- package/browser/cjs/D5np5QScDyDDD_WJ.cjs +0 -1
- package/browser/cjs/DLi7EA_dfez5uwwY.cjs +0 -1
- package/browser/cjs/DZAweI0sdBfrHzAk.cjs +0 -3747
- package/browser/cjs/DcxyEv9XIOa5qfCm.cjs +0 -1
- package/browser/cjs/ZKJrH74dcPwEAgmF.cjs +0 -7
- package/browser/cjs/index.cjs +0 -1
- package/browser/esm/B73J41HhbJvswDz1.mjs +0 -17
- package/browser/esm/BXhWTnlrRShaRGS5.mjs +0 -581
- package/browser/esm/DP3uAaeZa0hNHrYJ.mjs +0 -3818
- package/browser/esm/zGQXHcrpOlM4m6Nn.mjs +0 -197
- package/node/esm/BRuHQvNZfkRtcqXr.mjs +0 -196
- package/types/src/compiler/relaxForRun.d.ts +0 -8
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
var i = Object.freeze({ NoBody: "SXL1001", Anonymous: "SXL1002", ParseError: "SXL1003", InvalidParamType: "SXL2001", InvalidReturnType: "SXL2002", UndefinedInput: "SXL2003", MissingType: "SXL2004", UntypedArray: "SXL2005", GenericArity: "SXL2006", ContextNotFirst: "SXL2010", MultipleLambda: "SXL2020", LambdaNotLast: "SXL2021", LambdaScalarMismatch: "SXL2022", LambdaReturn: "SXL2023", FunctionReturn: "SXL2024", LambdaArity: "SXL2025", ArrayDepth: "SXL2030", RepeatingPosition: "SXL2040", MultipleRepeating: "SXL2041", RepeatingSlots: "SXL2042", RepeatingOptional: "SXL2043", RepeatingMax: "SXL2044", EnumMixed: "SXL2050", EnumMemberNotConstant: "SXL2051", EnumNotLocal: "SXL2052", EnumMissingAlias: "SXL2053", EnumPosition: "SXL2054", EnumOmittedValue: "SXL2055", NoExports: "SXL3001", UnknownParam: "SXL3002", BuiltInName: "SXL3003", UnknownReturnKind: "SXL3005", InvalidName: "SXL3006", DuplicateName: "SXL3007", MissingSummary: "SXL9001", MissingParamDescription: "SXL9002", MissingReturns: "SXL9003", EnumDuplicateValue: "SXL9004", EnumMemberUndocumented: "SXL9005" }), a = [{ name: "param", group: "jsdoc", description: "Document a parameter. A string union type becomes a dropdown of allowed options.", snippet: "param ${1:name} ${2:description}" }, { name: "returns", aliases: ["return"], group: "jsdoc", description: "Describe the return value." }, { name: "category", group: "sheetxl", description: "Group the function under a category in the function list.", snippet: "category ${1:name}" }, { name: "name", group: "sheetxl", description: "A name an identifier cannot spell: the name formulas call a function by (MY.FUNC), or an enum member's label.", snippet: "name ${1:NAME}" }, { name: "description", group: "sheetxl", description: "A longer description of the function." }, { name: "deprecated", group: "sheetxl", standalone: !0, description: "Mark the function as deprecated (optionally with a reason)." }, { name: "hidden", group: "sheetxl", standalone: !0, description: "Hide the function from the function list." }, { name: "returnkind", group: "sheetxl", description: "Declare the value kind of the return (a ValueKind word, e.g. `number`, `array`, `reference`) where the type spelling cannot say it (a union return collapses to any).", snippet: "returnKind ${1:number}" }, { name: "example", group: "jsdoc", description: "Provide a usage example." }, { name: "see", group: "jsdoc", description: "Reference a related function or link." }], r = (() => {
|
|
2
|
+
const n = /* @__PURE__ */ new Map();
|
|
3
|
+
for (const e of a) if (n.set(e.name, e), e.aliases) for (const t of e.aliases) n.set(t, e);
|
|
4
|
+
return n;
|
|
5
|
+
})();
|
|
6
|
+
function o(n) {
|
|
7
|
+
return (function(e) {
|
|
8
|
+
if (!e) return;
|
|
9
|
+
const t = (e.startsWith("@") ? e.slice(1) : e).toLowerCase();
|
|
10
|
+
return r.get(t);
|
|
11
|
+
})(n)?.standalone === !0;
|
|
12
|
+
}
|
|
13
|
+
export {
|
|
14
|
+
o as n,
|
|
15
|
+
i as r,
|
|
16
|
+
a as t
|
|
17
|
+
};
|
|
@@ -4,7 +4,7 @@ var t = class {
|
|
|
4
4
|
}
|
|
5
5
|
async getWorkerWrapper() {
|
|
6
6
|
if (this.workerWrapper) return this.workerWrapper;
|
|
7
|
-
const { createCompilerWorker: r } = await import("./
|
|
7
|
+
const { createCompilerWorker: r } = await import("./DYo_7j0y20wRtntJ.mjs");
|
|
8
8
|
return this.workerWrapper = await r(), this.workerWrapper;
|
|
9
9
|
}
|
|
10
10
|
async compileModule(r) {
|
package/browser/esm/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { r as d, t as g } from "./BxiAkxNyUQseLNBv.mjs";
|
|
2
|
-
import { r as M, t as T } from "./
|
|
2
|
+
import { r as M, t as T } from "./DfSFyaySrD6y1NJY.mjs";
|
|
3
3
|
import { CommonUtils as f } from "@sheetxl/utils";
|
|
4
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
5
|
function c(t) {
|
|
@@ -50,13 +50,13 @@ var k = Object.freeze({ compile: async function(t) {
|
|
|
50
50
|
if (l && f.deepEqual(l, t)) return a;
|
|
51
51
|
const n = await (await (async function() {
|
|
52
52
|
if (o) return o;
|
|
53
|
-
const { TypeScriptCompiler: e } = await import("./
|
|
53
|
+
const { TypeScriptCompiler: e } = await import("./Dxfyqtw07s-Dtn7T.mjs");
|
|
54
54
|
return o = new e();
|
|
55
55
|
})()).compileModule(t);
|
|
56
56
|
return a = n, l = t, n;
|
|
57
57
|
}, lint: async function(t, n) {
|
|
58
58
|
if (!t) return [];
|
|
59
|
-
const [e, { lintScript: p }] = await Promise.all([v(), import("./
|
|
59
|
+
const [e, { lintScript: p }] = await Promise.all([v(), import("./CUERvTrIURHqOWKm.mjs")]);
|
|
60
60
|
return p(e, t, n);
|
|
61
61
|
}, cleanup: function() {
|
|
62
62
|
o && (o.terminate(), o = null, a = null);
|
|
@@ -12,7 +12,7 @@ var o = class {
|
|
|
12
12
|
}
|
|
13
13
|
};
|
|
14
14
|
async function a() {
|
|
15
|
-
const { compileModule: e } = await import("./
|
|
15
|
+
const { compileModule: e } = await import("./BDIcVjo-h3KFdXXo.mjs"), t = new o((r) => e(r));
|
|
16
16
|
return await t.start(), t;
|
|
17
17
|
}
|
|
18
18
|
export {
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { DiagnosticCode as U, t as x } from "./index.mjs";
|
|
2
|
+
import { analyzeModule as V } from "./BLO91PRuOQIsW_Ow.mjs";
|
|
3
|
+
import { t as I } from "./4VkvY2rXOd49uHcQ.mjs";
|
|
4
|
+
import { CommonUtils as X } from "@sheetxl/utils";
|
|
5
|
+
var g = null, w = null, q = { compilerOptions: { target: "esnext" } };
|
|
6
|
+
async function H(t, m, p = "/script.js", u = x, n = !1) {
|
|
7
|
+
try {
|
|
8
|
+
const d = await (async function() {
|
|
9
|
+
if (g) return g;
|
|
10
|
+
if (w) {
|
|
11
|
+
if (await w, !g) throw new Error("ESBuild initialization promise resolved, but instance is not available.");
|
|
12
|
+
return g;
|
|
13
|
+
}
|
|
14
|
+
let i, o;
|
|
15
|
+
w = new Promise((r, l) => {
|
|
16
|
+
i = r, o = l;
|
|
17
|
+
});
|
|
18
|
+
try {
|
|
19
|
+
const { initialize: r } = await import("./ClxOMp6IdEZdW4Qd.mjs");
|
|
20
|
+
return g = await r(), i(), g;
|
|
21
|
+
} catch (r) {
|
|
22
|
+
throw console.error("Failed to import or initialize esbuild:", r), w = null, o(r), r;
|
|
23
|
+
}
|
|
24
|
+
})(), c = "@sheetxl/primitives", s = `
|
|
25
|
+
export const FormulaContext = globalThis.${u}?.FormulaContext;
|
|
26
|
+
export const ScalarType = globalThis.${u}?.ScalarType;
|
|
27
|
+
export const Observable = globalThis.${u}?.Observable;
|
|
28
|
+
export const IRange = globalThis.${u}?.IRange;
|
|
29
|
+
export const FormulaError = globalThis.${u}?.FormulaError;
|
|
30
|
+
// Add more exports as needed
|
|
31
|
+
`, a = await d.build({ entryPoints: [p], bundle: !0, write: !1, format: "esm", plugins: [{ name: "sheetxl-esbuild-in-memory", setup(i) {
|
|
32
|
+
const o = "sheetxl-" + (/* @__PURE__ */ new Date()).getTime();
|
|
33
|
+
i.onResolve({ filter: new RegExp(`^(${p.replace("/", "\\/")}|${c})$`) }, (r) => ({ path: r.path, namespace: o })), i.onResolve({ filter: /.*/ }, (r) => {
|
|
34
|
+
if (r.namespace !== o) return console.warn(`esbuild: Treating import "${r.path}" as external.`), { path: r.path, external: !0 };
|
|
35
|
+
}), i.onLoad({ filter: /.*/, namespace: o }, (r) => {
|
|
36
|
+
let l;
|
|
37
|
+
if (r.path === p) l = m;
|
|
38
|
+
else {
|
|
39
|
+
if (r.path !== c) return { errors: [{ text: `Cannot load unknown path in ${o}: ${r.path}` }] };
|
|
40
|
+
l = s;
|
|
41
|
+
}
|
|
42
|
+
return { contents: l, loader: "ts" };
|
|
43
|
+
});
|
|
44
|
+
} }], sourcemap: "inline", tsconfigRaw: q, minify: n, platform: "neutral" });
|
|
45
|
+
if (a.outputFiles && a.outputFiles.length > 0) return a.outputFiles[0].text;
|
|
46
|
+
throw a.errors && a.errors.length > 0 ? new Error(`esbuild bundling failed: ${a.errors.map((i) => i.text).join(`
|
|
47
|
+
`)}`) : new Error("esbuild did not produce an output file.");
|
|
48
|
+
} catch (d) {
|
|
49
|
+
throw console.error("esbuild bundling process failed:", d), d;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function Y(t, m, p) {
|
|
53
|
+
return (u) => {
|
|
54
|
+
const n = u.factory, d = () => n.createExpressionStatement(n.createCallChain(n.createPropertyAccessExpression(n.createIdentifier(x), "checkRun"), n.createToken(t.SyntaxKind.QuestionDotToken), void 0, [n.createStringLiteral(m), n.createNumericLiteral(p)])), c = (a) => {
|
|
55
|
+
const i = a.statements;
|
|
56
|
+
let o = 0;
|
|
57
|
+
for (; o < i.length && t.isExpressionStatement(i[o]) && t.isStringLiteral(i[o].expression); ) o++;
|
|
58
|
+
return n.updateBlock(a, [...i.slice(0, o), d(), ...i.slice(o)]);
|
|
59
|
+
}, s = (a) => {
|
|
60
|
+
if (((i) => t.isForStatement(i) || t.isForInStatement(i) || t.isForOfStatement(i) || t.isWhileStatement(i) || t.isDoStatement(i))(a)) {
|
|
61
|
+
const i = a.statement;
|
|
62
|
+
return t.visitEachChild(a, (o) => {
|
|
63
|
+
const r = s(o);
|
|
64
|
+
return o === i ? (l = r, t.isBlock(l) ? c(l) : n.createBlock([d(), l], !0)) : r;
|
|
65
|
+
var l;
|
|
66
|
+
}, u);
|
|
67
|
+
}
|
|
68
|
+
if (t.isFunctionLike(a) && a.body) {
|
|
69
|
+
const i = a.body;
|
|
70
|
+
return t.visitEachChild(a, (o) => {
|
|
71
|
+
const r = s(o);
|
|
72
|
+
return o === i ? (l = r, t.isBlock(l) ? c(l) : n.createBlock([d(), n.createReturnStatement(l)], !0)) : r;
|
|
73
|
+
var l;
|
|
74
|
+
}, u);
|
|
75
|
+
}
|
|
76
|
+
return t.visitEachChild(a, s, u);
|
|
77
|
+
};
|
|
78
|
+
return (a) => t.visitNode(a, s);
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
var Z = async () => `
|
|
82
|
+
interface FirstTest {
|
|
83
|
+
isTrue?: boolean;
|
|
84
|
+
}
|
|
85
|
+
`, v = null, L = "sheetxl.d.ts", N = "sheetxl-modules.d.ts", _ = ["lib.webworker.d.ts", "lib.es2020.d.ts", "lib.esnext.asynciterable.d.ts"], O = /* @__PURE__ */ new Map(), D = null, R = null;
|
|
86
|
+
async function ee() {
|
|
87
|
+
return R || (R = import("./og3Pk2ReS3UiORbF.mjs").then(async (t) => {
|
|
88
|
+
const m = await j();
|
|
89
|
+
return t.readLibFile(m, "lib.es5.d.ts") !== void 0 ? t.readLibFile : null;
|
|
90
|
+
})), R;
|
|
91
|
+
}
|
|
92
|
+
async function j() {
|
|
93
|
+
if (v) return v;
|
|
94
|
+
try {
|
|
95
|
+
const t = await (await import("./og3Pk2ReS3UiORbF.mjs")).initialize();
|
|
96
|
+
if (!t) throw new Error("TypeScript could not be loaded. Check your connection and try again.");
|
|
97
|
+
return t;
|
|
98
|
+
} catch (t) {
|
|
99
|
+
throw v = null, t;
|
|
100
|
+
} finally {
|
|
101
|
+
v = null;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
async function se(t) {
|
|
105
|
+
const m = t?.source ?? null;
|
|
106
|
+
if (!m) return { module: null, diagnostics: [] };
|
|
107
|
+
const p = (t.disableBundle || t.declarationsOnly) ?? !1, [u, n, d] = await Promise.all([Z(), j(), t.ambientTypes ? ee() : null]), c = d ? t.ambientTypes ?? null : null;
|
|
108
|
+
let s = "";
|
|
109
|
+
const a = { allowJs: !0, declaration: !1, sourceMap: !1, inlineSourceMap: !1, inlineSources: !1, isolatedModules: !0, preserveConstEnums: !1, module: 99, noResolve: !0, emitDeclarationOnly: !1, target: n.ScriptTarget.ES2020, ...c ? { lib: _, skipLibCheck: !0, strict: !0 } : {} }, i = "script", o = `${i}.ts`, r = "lib.d.ts", l = "global.d.ts", f = { [o]: m, [r]: `
|
|
110
|
+
/**
|
|
111
|
+
* Represents the completion of an asynchronous operation
|
|
112
|
+
*/
|
|
113
|
+
interface Promise<T> {
|
|
114
|
+
/**
|
|
115
|
+
* Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The
|
|
116
|
+
* resolved value cannot be modified from the callback.
|
|
117
|
+
* @param onfinally The callback to execute when the Promise is settled (fulfilled or rejected).
|
|
118
|
+
* @returns A Promise for the completion of the callback.
|
|
119
|
+
*/
|
|
120
|
+
finally(onfinally?: (() => void) | undefined | null): Promise<T>;
|
|
121
|
+
}
|
|
122
|
+
`, [l]: u, ...c ? { [L]: c, [N]: `declare module '@sheetxl/primitives' { export = SheetXL; }
|
|
123
|
+
` } : {} }, S = (e) => f[e] ?? (d && e.startsWith("lib.") ? d(n, e) : void 0), z = { getSourceFile: (e, $, te, ne) => {
|
|
124
|
+
if (e === L) return D?.text !== c && (D = { text: c, file: n.createSourceFile(e, c, n.ScriptTarget.Latest, !1) }), D.file;
|
|
125
|
+
if (f[e] === void 0) {
|
|
126
|
+
let y = O.get(e);
|
|
127
|
+
if (!y) {
|
|
128
|
+
const B = S(e);
|
|
129
|
+
if (B === void 0) return;
|
|
130
|
+
y = n.createSourceFile(e, B, n.ScriptTarget.Latest, !1), O.set(e, y);
|
|
131
|
+
}
|
|
132
|
+
return y;
|
|
133
|
+
}
|
|
134
|
+
return n.createSourceFile(e, f[e], n.ScriptTarget.Latest, !0);
|
|
135
|
+
}, fileExists: (e) => S(e) !== void 0, readFile: S, writeFile: (e, $) => {
|
|
136
|
+
f[e] = $;
|
|
137
|
+
}, getCurrentDirectory: () => "./", getCanonicalFileName: (e) => e, useCaseSensitiveFileNames: () => !0, getDefaultLibFileName: (e) => r, getNewLine: () => `
|
|
138
|
+
` }, h = n.createProgram([o, l, ...c ? [L, N] : []], a, z), A = h.getTypeChecker(), T = h.getSourceFile(o), F = t.runGuard;
|
|
139
|
+
h.emit(void 0, void 0, void 0, void 0, F ? { before: [Y(n, F.key, F.timeoutMs)] } : void 0), s = f[`${i}.js`] ?? "";
|
|
140
|
+
const M = (e) => ({ start: e.start ?? 0, length: e.length ?? 0, severity: e.category === n.DiagnosticCategory.Warning ? "warning" : "error", code: `TS${e.code}`, message: n.flattenDiagnosticMessageText(e.messageText, `
|
|
141
|
+
`) }), W = h.getSyntacticDiagnostics(T).map(M), G = c ? h.getSemanticDiagnostics(T).filter((e) => e.category === n.DiagnosticCategory.Error || e.category === n.DiagnosticCategory.Warning).map(M) : [], k = V(n, T, A, { builtInNames: t.builtInNames, isBuiltIn: t.isBuiltIn, lenient: t.lenient });
|
|
142
|
+
let b = [...W, ...G, ...k.diagnostics];
|
|
143
|
+
t.lenient && (b = b.filter((e) => e.code !== U.MissingType));
|
|
144
|
+
const J = k.functions, P = k.autoRun, K = b.some((e) => e.severity === "error"), Q = `${X.uuidV4()}-script`;
|
|
145
|
+
let C = null;
|
|
146
|
+
if (K) s = "";
|
|
147
|
+
else {
|
|
148
|
+
try {
|
|
149
|
+
p || (s = await H(0, s, i, void 0, t.minify ?? !1));
|
|
150
|
+
} catch {
|
|
151
|
+
console.warn("Error bundling script");
|
|
152
|
+
}
|
|
153
|
+
const e = s.indexOf(I);
|
|
154
|
+
e > -1 && (C = s.substring(e + I.length + 1, s.length), s = s.substring(0, e), s = s.replaceAll("globalThis." + x, x));
|
|
155
|
+
}
|
|
156
|
+
const E = { functions: J, commitId: Q, source: m, language: "typescript", compiled: s };
|
|
157
|
+
return C && (E.sourceMap = C), P && (E.autoRun = P), { module: E, diagnostics: b };
|
|
158
|
+
}
|
|
159
|
+
export {
|
|
160
|
+
se as compileModule
|
|
161
|
+
};
|