@sheetxl/scripting 0.8.0-beta.2 → 0.8.0-beta.21
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,162 @@
|
|
|
1
|
+
import { n as x } from "./BxiAkxNyUQseLNBv.mjs";
|
|
2
|
+
import { r as U } from "./DfSFyaySrD6y1NJY.mjs";
|
|
3
|
+
import { analyzeModule as V } from "./CUERvTrIURHqOWKm.mjs";
|
|
4
|
+
import { t as I } from "./4VkvY2rXOd49uHcQ.mjs";
|
|
5
|
+
import { CommonUtils as X } from "@sheetxl/utils";
|
|
6
|
+
var f = null, w = null, q = { compilerOptions: { target: "esnext" } };
|
|
7
|
+
async function H(t, m, p = "/script.js", u = x, n = !1) {
|
|
8
|
+
try {
|
|
9
|
+
const d = await (async function() {
|
|
10
|
+
if (f) return f;
|
|
11
|
+
if (w) {
|
|
12
|
+
if (await w, !f) throw new Error("ESBuild initialization promise resolved, but instance is not available.");
|
|
13
|
+
return f;
|
|
14
|
+
}
|
|
15
|
+
let i, o;
|
|
16
|
+
w = new Promise((r, l) => {
|
|
17
|
+
i = r, o = l;
|
|
18
|
+
});
|
|
19
|
+
try {
|
|
20
|
+
const { initialize: r } = await import("./D9jTpNifykCuQkTL.mjs");
|
|
21
|
+
return f = await r(), i(), f;
|
|
22
|
+
} catch (r) {
|
|
23
|
+
throw console.error("Failed to import or initialize esbuild:", r), w = null, o(r), r;
|
|
24
|
+
}
|
|
25
|
+
})(), c = "@sheetxl/primitives", s = `
|
|
26
|
+
export const FormulaContext = globalThis.${u}?.FormulaContext;
|
|
27
|
+
export const ScalarType = globalThis.${u}?.ScalarType;
|
|
28
|
+
export const Observable = globalThis.${u}?.Observable;
|
|
29
|
+
export const IRange = globalThis.${u}?.IRange;
|
|
30
|
+
export const FormulaError = globalThis.${u}?.FormulaError;
|
|
31
|
+
// Add more exports as needed
|
|
32
|
+
`, a = await d.build({ entryPoints: [p], bundle: !0, write: !1, format: "esm", plugins: [{ name: "sheetxl-esbuild-in-memory", setup(i) {
|
|
33
|
+
const o = "sheetxl-" + (/* @__PURE__ */ new Date()).getTime();
|
|
34
|
+
i.onResolve({ filter: new RegExp(`^(${p.replace("/", "\\/")}|${c})$`) }, (r) => ({ path: r.path, namespace: o })), i.onResolve({ filter: /.*/ }, (r) => {
|
|
35
|
+
if (r.namespace !== o) return console.warn(`esbuild: Treating import "${r.path}" as external.`), { path: r.path, external: !0 };
|
|
36
|
+
}), i.onLoad({ filter: /.*/, namespace: o }, (r) => {
|
|
37
|
+
let l;
|
|
38
|
+
if (r.path === p) l = m;
|
|
39
|
+
else {
|
|
40
|
+
if (r.path !== c) return { errors: [{ text: `Cannot load unknown path in ${o}: ${r.path}` }] };
|
|
41
|
+
l = s;
|
|
42
|
+
}
|
|
43
|
+
return { contents: l, loader: "ts" };
|
|
44
|
+
});
|
|
45
|
+
} }], sourcemap: "inline", tsconfigRaw: q, minify: n, platform: "neutral" });
|
|
46
|
+
if (a.outputFiles && a.outputFiles.length > 0) return a.outputFiles[0].text;
|
|
47
|
+
throw a.errors && a.errors.length > 0 ? new Error(`esbuild bundling failed: ${a.errors.map((i) => i.text).join(`
|
|
48
|
+
`)}`) : new Error("esbuild did not produce an output file.");
|
|
49
|
+
} catch (d) {
|
|
50
|
+
throw console.error("esbuild bundling process failed:", d), d;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function Y(t, m, p) {
|
|
54
|
+
return (u) => {
|
|
55
|
+
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) => {
|
|
56
|
+
const i = a.statements;
|
|
57
|
+
let o = 0;
|
|
58
|
+
for (; o < i.length && t.isExpressionStatement(i[o]) && t.isStringLiteral(i[o].expression); ) o++;
|
|
59
|
+
return n.updateBlock(a, [...i.slice(0, o), d(), ...i.slice(o)]);
|
|
60
|
+
}, s = (a) => {
|
|
61
|
+
if (((i) => t.isForStatement(i) || t.isForInStatement(i) || t.isForOfStatement(i) || t.isWhileStatement(i) || t.isDoStatement(i))(a)) {
|
|
62
|
+
const i = a.statement;
|
|
63
|
+
return t.visitEachChild(a, (o) => {
|
|
64
|
+
const r = s(o);
|
|
65
|
+
return o === i ? (l = r, t.isBlock(l) ? c(l) : n.createBlock([d(), l], !0)) : r;
|
|
66
|
+
var l;
|
|
67
|
+
}, u);
|
|
68
|
+
}
|
|
69
|
+
if (t.isFunctionLike(a) && a.body) {
|
|
70
|
+
const i = a.body;
|
|
71
|
+
return t.visitEachChild(a, (o) => {
|
|
72
|
+
const r = s(o);
|
|
73
|
+
return o === i ? (l = r, t.isBlock(l) ? c(l) : n.createBlock([d(), n.createReturnStatement(l)], !0)) : r;
|
|
74
|
+
var l;
|
|
75
|
+
}, u);
|
|
76
|
+
}
|
|
77
|
+
return t.visitEachChild(a, s, u);
|
|
78
|
+
};
|
|
79
|
+
return (a) => t.visitNode(a, s);
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
var Z = async () => `
|
|
83
|
+
interface FirstTest {
|
|
84
|
+
isTrue?: boolean;
|
|
85
|
+
}
|
|
86
|
+
`, 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;
|
|
87
|
+
async function ee() {
|
|
88
|
+
return R || (R = import("./B_2CC0NvNtPBw_ad.mjs").then(async (t) => {
|
|
89
|
+
const m = await j();
|
|
90
|
+
return t.readLibFile(m, "lib.es5.d.ts") !== void 0 ? t.readLibFile : null;
|
|
91
|
+
})), R;
|
|
92
|
+
}
|
|
93
|
+
async function j() {
|
|
94
|
+
if (v) return v;
|
|
95
|
+
try {
|
|
96
|
+
const t = await (await import("./B_2CC0NvNtPBw_ad.mjs")).initialize();
|
|
97
|
+
if (!t) throw new Error("TypeScript could not be loaded. Check your connection and try again.");
|
|
98
|
+
return t;
|
|
99
|
+
} catch (t) {
|
|
100
|
+
throw v = null, t;
|
|
101
|
+
} finally {
|
|
102
|
+
v = null;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
async function le(t) {
|
|
106
|
+
const m = t?.source ?? null;
|
|
107
|
+
if (!m) return { module: null, diagnostics: [] };
|
|
108
|
+
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;
|
|
109
|
+
let s = "";
|
|
110
|
+
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", g = { [o]: m, [r]: `
|
|
111
|
+
/**
|
|
112
|
+
* Represents the completion of an asynchronous operation
|
|
113
|
+
*/
|
|
114
|
+
interface Promise<T> {
|
|
115
|
+
/**
|
|
116
|
+
* Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The
|
|
117
|
+
* resolved value cannot be modified from the callback.
|
|
118
|
+
* @param onfinally The callback to execute when the Promise is settled (fulfilled or rejected).
|
|
119
|
+
* @returns A Promise for the completion of the callback.
|
|
120
|
+
*/
|
|
121
|
+
finally(onfinally?: (() => void) | undefined | null): Promise<T>;
|
|
122
|
+
}
|
|
123
|
+
`, [l]: u, ...c ? { [L]: c, [N]: `declare module '@sheetxl/primitives' { export = SheetXL; }
|
|
124
|
+
` } : {} }, S = (e) => g[e] ?? (d && e.startsWith("lib.") ? d(n, e) : void 0), z = { getSourceFile: (e, $, te, ne) => {
|
|
125
|
+
if (e === L) return D?.text !== c && (D = { text: c, file: n.createSourceFile(e, c, n.ScriptTarget.Latest, !1) }), D.file;
|
|
126
|
+
if (g[e] === void 0) {
|
|
127
|
+
let y = O.get(e);
|
|
128
|
+
if (!y) {
|
|
129
|
+
const B = S(e);
|
|
130
|
+
if (B === void 0) return;
|
|
131
|
+
y = n.createSourceFile(e, B, n.ScriptTarget.Latest, !1), O.set(e, y);
|
|
132
|
+
}
|
|
133
|
+
return y;
|
|
134
|
+
}
|
|
135
|
+
return n.createSourceFile(e, g[e], n.ScriptTarget.Latest, !0);
|
|
136
|
+
}, fileExists: (e) => S(e) !== void 0, readFile: S, writeFile: (e, $) => {
|
|
137
|
+
g[e] = $;
|
|
138
|
+
}, getCurrentDirectory: () => "./", getCanonicalFileName: (e) => e, useCaseSensitiveFileNames: () => !0, getDefaultLibFileName: (e) => r, getNewLine: () => `
|
|
139
|
+
` }, h = n.createProgram([o, l, ...c ? [L, N] : []], a, z), A = h.getTypeChecker(), T = h.getSourceFile(o), F = t.runGuard;
|
|
140
|
+
h.emit(void 0, void 0, void 0, void 0, F ? { before: [Y(n, F.key, F.timeoutMs)] } : void 0), s = g[`${i}.js`] ?? "";
|
|
141
|
+
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, `
|
|
142
|
+
`) }), 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 });
|
|
143
|
+
let b = [...W, ...G, ...k.diagnostics];
|
|
144
|
+
t.lenient && (b = b.filter((e) => e.code !== U.MissingType));
|
|
145
|
+
const J = k.functions, P = k.autoRun, K = b.some((e) => e.severity === "error"), Q = `${X.uuidV4()}-script`;
|
|
146
|
+
let C = null;
|
|
147
|
+
if (K) s = "";
|
|
148
|
+
else {
|
|
149
|
+
try {
|
|
150
|
+
p || (s = await H(0, s, i, void 0, t.minify ?? !1));
|
|
151
|
+
} catch {
|
|
152
|
+
console.warn("Error bundling script");
|
|
153
|
+
}
|
|
154
|
+
const e = s.indexOf(I);
|
|
155
|
+
e > -1 && (C = s.substring(e + I.length + 1, s.length), s = s.substring(0, e), s = s.replaceAll("globalThis." + x, x));
|
|
156
|
+
}
|
|
157
|
+
const E = { functions: J, commitId: Q, source: m, language: "typescript", compiled: s };
|
|
158
|
+
return C && (E.sourceMap = C), P && (E.autoRun = P), { module: E, diagnostics: b };
|
|
159
|
+
}
|
|
160
|
+
export {
|
|
161
|
+
le as compileModule
|
|
162
|
+
};
|