@sheetxl/scripting 0.8.0-beta.1 → 0.8.0-beta.11
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/README.md +5 -5
- package/browser/esm/4VkvY2rXOd49uHcQ.mjs +4 -0
- package/browser/esm/B73J41HhbJvswDz1.mjs +17 -0
- package/browser/esm/BPtHkO7z1Di3YIjV.mjs +162 -0
- package/browser/esm/B_2CC0NvNtPBw_ad.mjs +22 -0
- package/browser/esm/BxiAkxNyUQseLNBv.mjs +10 -0
- package/browser/esm/CV6NN6Ju5xBT1o6B.mjs +3955 -0
- package/browser/esm/Cg2-n5X_c3X8uPPp.mjs +581 -0
- package/browser/esm/D9jTpNifykCuQkTL.mjs +18 -0
- package/browser/esm/NpFv8YNKRgVPGXOq.mjs +9 -0
- package/browser/esm/_cUijEyyZifD_LZf.mjs +23 -0
- package/browser/esm/index.mjs +71 -41
- package/node/esm/4VkvY2rXOd49uHcQ.mjs +4 -0
- package/node/esm/ByvsA4Gi2N_jmjO4.mjs +161 -0
- package/node/esm/C8P-wHdBmweFS0Ex.mjs +20 -0
- package/node/esm/CLpM4kzEeZk_kWj4.mjs +23 -0
- package/node/esm/Cgbq_-KJhRYkRJw-.mjs +581 -0
- package/node/esm/ClxOMp6IdEZdW4Qd.mjs +8 -0
- package/node/esm/D0CDObJV23Rxk8-r.mjs +15 -0
- package/node/esm/index.mjs +83 -148
- package/node/esm/og3Pk2ReS3UiORbF.mjs +21 -0
- package/package.json +6 -7
- package/types/src/compiler/Bundler.d.ts +1 -1
- package/types/src/compiler/insertRunGuard.d.ts +11 -0
- package/types/src/lib/typescript/typescript.browser.d.ts +6 -0
- package/types/src/lib/typescript/typescript.node.d.ts +11 -0
- package/types/src/linter/Linter.d.ts +20 -0
- package/types/src/runtime/RunGuard.d.ts +31 -0
- package/types/src/runtime/index.d.ts +1 -0
- package/types/src/type/CompileOptions.d.ts +50 -0
- package/types/src/type/CompiledModule.d.ts +36 -6
- package/types/src/type/Diagnostic.d.ts +25 -3
- package/types/src/type/Types.d.ts +61 -5
- package/browser/cjs/BJpcKKDPQlQbi5O5.cjs +0 -7
- package/browser/cjs/Bu4cZ8iSZ3rij-oV.cjs +0 -1
- package/browser/cjs/BvG8N7G_8CXIAlT-.cjs +0 -1
- package/browser/cjs/CY8w1D0xPdaNysFJ.cjs +0 -1
- package/browser/cjs/C_7w8EJZpHw8ueuq.cjs +0 -1
- package/browser/cjs/C_IEgjM-hSJCv6Gm.cjs +0 -1
- package/browser/cjs/CctaCN_w3o34V9AR.cjs +0 -1
- package/browser/cjs/DIf4GvYEqb4ayb6a.cjs +0 -1
- package/browser/cjs/DcNeWEf5ZqALrCr4.cjs +0 -1
- package/browser/cjs/_PKWNtAymIZGtvCb.cjs +0 -21
- package/browser/cjs/index.cjs +0 -1
- package/browser/esm/1kUe1fPM50LHqYNI.mjs +0 -15
- package/browser/esm/3YV545IwjRqG3c1v.mjs +0 -27
- package/browser/esm/CFj5DZ16U361ltLj.mjs +0 -8
- package/browser/esm/CSXzDPdxAeONd9Br.mjs +0 -152
- package/browser/esm/DCIZplzRAR9pzoyD.mjs +0 -12
- package/browser/esm/DL0Hj5P777IybKK1.mjs +0 -25
- package/browser/esm/Dn3tZ47l4kfqm82M.mjs +0 -434
- package/browser/esm/Im_056DAe1M8tSZK.mjs +0 -23
- package/browser/esm/bJcM1PsEX9VZuqnT.mjs +0 -87
- package/browser/esm/v5FtHwExzUecgxho.mjs +0 -112
- package/node/esm/CFj5DZ16U361ltLj.mjs +0 -8
- package/node/esm/CL56uy8tfvhJRKYS.mjs +0 -434
- package/node/esm/CZgThiQ_9yYAaYaW.mjs +0 -152
- package/node/esm/DDDZ5Wv9-gK2v6Qt.mjs +0 -23
- package/node/esm/DEIcuGll5aCjPisP.mjs +0 -27
- package/node/esm/DOv0wuhb-kNvUT7-.mjs +0 -12
- package/node/esm/NgoqymNyfjBf3Vbn.mjs +0 -17
- package/node/esm/P5z0UPrc8__6uFCR.mjs +0 -14
package/node/esm/index.mjs
CHANGED
|
@@ -1,152 +1,87 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
for (var i in e) t(r, i, {
|
|
11
|
-
get: e[i],
|
|
12
|
-
enumerable: !0
|
|
13
|
-
});
|
|
14
|
-
return n || t(r, Symbol.toStringTag, { value: "Module" }), r;
|
|
15
|
-
}, r = Object.freeze({
|
|
16
|
-
NoBody: "SXL1001",
|
|
17
|
-
Anonymous: "SXL1002",
|
|
18
|
-
ParseError: "SXL1003",
|
|
19
|
-
InvalidParamType: "SXL2001",
|
|
20
|
-
InvalidReturnType: "SXL2002",
|
|
21
|
-
UndefinedInput: "SXL2003",
|
|
22
|
-
MissingType: "SXL2004",
|
|
23
|
-
UntypedArray: "SXL2005",
|
|
24
|
-
GenericArity: "SXL2006",
|
|
25
|
-
MultipleModifiers: "SXL2007",
|
|
26
|
-
ContextNotFirst: "SXL2010",
|
|
27
|
-
MultipleLambda: "SXL2020",
|
|
28
|
-
LambdaNotLast: "SXL2021",
|
|
29
|
-
LambdaScalarMismatch: "SXL2022",
|
|
30
|
-
LambdaReturn: "SXL2023",
|
|
31
|
-
FunctionReturn: "SXL2024",
|
|
32
|
-
LambdaArity: "SXL2025",
|
|
33
|
-
ArrayDepth: "SXL2030",
|
|
34
|
-
RepeatingPosition: "SXL2040",
|
|
35
|
-
MultipleRepeating: "SXL2041",
|
|
36
|
-
RepeatingSlots: "SXL2042",
|
|
37
|
-
RepeatingOptional: "SXL2043",
|
|
38
|
-
NoExports: "SXL3001",
|
|
39
|
-
UnknownParam: "SXL3002",
|
|
40
|
-
BuiltInName: "SXL3003",
|
|
41
|
-
UnknownCompat: "SXL3004",
|
|
42
|
-
MissingSummary: "SXL9001",
|
|
43
|
-
MissingParamDescription: "SXL9002",
|
|
44
|
-
MissingReturns: "SXL9003"
|
|
45
|
-
}), i = [
|
|
46
|
-
{
|
|
47
|
-
name: "summary",
|
|
48
|
-
group: "sheetxl",
|
|
49
|
-
description: "Short description shown in function tooltips and autocomplete."
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
name: "param",
|
|
53
|
-
group: "jsdoc",
|
|
54
|
-
description: "Document a parameter. A string union type becomes a dropdown of allowed options.",
|
|
55
|
-
snippet: "param ${1:name} ${2:description}"
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
name: "returns",
|
|
59
|
-
aliases: ["return"],
|
|
60
|
-
group: "jsdoc",
|
|
61
|
-
description: "Describe the return value."
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
name: "category",
|
|
65
|
-
group: "sheetxl",
|
|
66
|
-
description: "Group the function under a category in the function list.",
|
|
67
|
-
snippet: "category ${1:name}"
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
name: "name",
|
|
71
|
-
group: "sheetxl",
|
|
72
|
-
description: "Override the displayed function name.",
|
|
73
|
-
snippet: "name ${1:NAME}"
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
name: "description",
|
|
77
|
-
group: "sheetxl",
|
|
78
|
-
description: "A longer description of the function."
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
name: "deprecated",
|
|
82
|
-
group: "sheetxl",
|
|
83
|
-
standalone: !0,
|
|
84
|
-
description: "Mark the function as deprecated (optionally with a reason)."
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
name: "hidden",
|
|
88
|
-
group: "sheetxl",
|
|
89
|
-
standalone: !0,
|
|
90
|
-
description: "Hide the function from the function list."
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
name: "compat",
|
|
94
|
-
group: "sheetxl",
|
|
95
|
-
description: "Opt into a named engine compatibility behavior (`noReferenceLift`, `noMemberFilter`) or a family alias (`atp` = both).",
|
|
96
|
-
snippet: "compat ${1:atp}"
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
name: "example",
|
|
100
|
-
group: "jsdoc",
|
|
101
|
-
description: "Provide a usage example."
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
name: "see",
|
|
105
|
-
group: "jsdoc",
|
|
106
|
-
description: "Reference a related function or link."
|
|
107
|
-
}
|
|
108
|
-
], a = (() => {
|
|
109
|
-
let e = /* @__PURE__ */ new Map();
|
|
110
|
-
for (let t of i) if (e.set(t.name, t), t.aliases) for (let n of t.aliases) e.set(n, t);
|
|
111
|
-
return e;
|
|
1
|
+
import { CommonUtils as f } from "@sheetxl/utils";
|
|
2
|
+
var c = Object.defineProperty, p = (e, n) => {
|
|
3
|
+
let t = {};
|
|
4
|
+
for (var i in e) c(t, i, { get: e[i], enumerable: !0 });
|
|
5
|
+
return n || c(t, Symbol.toStringTag, { value: "Module" }), t;
|
|
6
|
+
}, x = Object.freeze({ NoBody: "SXL1001", Anonymous: "SXL1002", ParseError: "SXL1003", InvalidParamType: "SXL2001", InvalidReturnType: "SXL2002", UndefinedInput: "SXL2003", MissingType: "SXL2004", UntypedArray: "SXL2005", GenericArity: "SXL2006", MultipleModifiers: "SXL2007", 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" }), L = [{ 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." }], S = (() => {
|
|
7
|
+
const e = /* @__PURE__ */ new Map();
|
|
8
|
+
for (const n of L) if (e.set(n.name, n), n.aliases) for (const t of n.aliases) e.set(t, n);
|
|
9
|
+
return e;
|
|
112
10
|
})();
|
|
113
|
-
function
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
11
|
+
function v(e) {
|
|
12
|
+
return (function(n) {
|
|
13
|
+
if (!n) return;
|
|
14
|
+
const t = (n.startsWith("@") ? n.slice(1) : n).toLowerCase();
|
|
15
|
+
return S.get(t);
|
|
16
|
+
})(e)?.standalone === !0;
|
|
119
17
|
}
|
|
120
|
-
var
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
18
|
+
var N = p({ GLOBAL_CONTEXT_VARIABLE: () => X }), X = "__SHEETXL", A = p({ RUN_INTERRUPTED: () => l, abort: () => w, check: () => h, isInterrupted: () => b, release: () => M }), a = /* @__PURE__ */ new Map(), g = 256, y = 16, l = "RunInterrupted";
|
|
19
|
+
function d(e) {
|
|
20
|
+
const n = new Error(e);
|
|
21
|
+
return n.name = l, n;
|
|
124
22
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
23
|
+
function m(e) {
|
|
24
|
+
let n = a.get(e);
|
|
25
|
+
if (!n) {
|
|
26
|
+
if (a.size >= g) {
|
|
27
|
+
const t = a.keys().next().value;
|
|
28
|
+
t !== void 0 && a.delete(t);
|
|
29
|
+
}
|
|
30
|
+
n = { started: Date.now(), calls: 0, stopped: null }, a.set(e, n);
|
|
31
|
+
}
|
|
32
|
+
return n;
|
|
128
33
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
34
|
+
function h(e, n) {
|
|
35
|
+
const t = m(e);
|
|
36
|
+
if (t.stopped) throw t.stopped;
|
|
37
|
+
if (++t.calls % y === 0 && Date.now() - t.started > n) throw t.stopped = d(`Run stopped: it exceeded the ${Math.round(n / 1e3)} s time limit.`), t.stopped;
|
|
38
|
+
}
|
|
39
|
+
function w(e, n = "Run cancelled.") {
|
|
40
|
+
m(e).stopped = d(n);
|
|
41
|
+
}
|
|
42
|
+
function M(e) {
|
|
43
|
+
a.delete(e);
|
|
44
|
+
}
|
|
45
|
+
function b(e) {
|
|
46
|
+
return e?.name === l;
|
|
47
|
+
}
|
|
48
|
+
async function C(e, n) {
|
|
49
|
+
const { loadCompiledModule: t } = await import("./D0CDObJV23Rxk8-r.mjs");
|
|
50
|
+
return t(e, n);
|
|
51
|
+
}
|
|
52
|
+
var s = null, u = null, r = null, o = null;
|
|
53
|
+
async function E() {
|
|
54
|
+
return o || (o = (async () => {
|
|
55
|
+
const e = await (await import("./og3Pk2ReS3UiORbF.mjs")).initialize();
|
|
56
|
+
if (!e) throw new Error("TypeScript could not be loaded. Check your connection and try again.");
|
|
57
|
+
return e;
|
|
58
|
+
})()).catch(() => {
|
|
59
|
+
o = null;
|
|
60
|
+
}), o;
|
|
61
|
+
}
|
|
62
|
+
var D = Object.freeze({ compile: async function(e) {
|
|
63
|
+
if (!e?.source) return { module: null, diagnostics: [] };
|
|
64
|
+
if (u && f.deepEqual(u, e)) return s;
|
|
65
|
+
const n = await (await (async function() {
|
|
66
|
+
if (r) return r;
|
|
67
|
+
const { TypeScriptCompiler: t } = await import("./CLpM4kzEeZk_kWj4.mjs");
|
|
68
|
+
return r = new t();
|
|
69
|
+
})()).compileModule(e);
|
|
70
|
+
return s = n, u = e, n;
|
|
71
|
+
}, lint: async function(e, n) {
|
|
72
|
+
if (!e) return [];
|
|
73
|
+
const [t, { lintScript: i }] = await Promise.all([E(), import("./Cgbq_-KJhRYkRJw-.mjs")]);
|
|
74
|
+
return i(t, e, n);
|
|
75
|
+
}, cleanup: function() {
|
|
76
|
+
r && (r.terminate(), r = null, s = null);
|
|
77
|
+
} });
|
|
78
|
+
export {
|
|
79
|
+
N as Constants,
|
|
80
|
+
x as DiagnosticCode,
|
|
81
|
+
L as DocTags,
|
|
82
|
+
A as RunGuard,
|
|
83
|
+
D as ScriptCompiler,
|
|
84
|
+
C as loadCompiledModule,
|
|
85
|
+
v as n,
|
|
86
|
+
X as t
|
|
87
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { readFileSync as e } from "node:fs";
|
|
2
|
+
import { dirname as o, join as a } from "node:path";
|
|
3
|
+
async function l() {
|
|
4
|
+
try {
|
|
5
|
+
return await import("typescript");
|
|
6
|
+
} catch (r) {
|
|
7
|
+
throw console.error("Error initializing Node TypeScript module:", r), r;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
function s(r, t) {
|
|
11
|
+
const i = o(r.getDefaultLibFilePath({}));
|
|
12
|
+
try {
|
|
13
|
+
return e(a(i, t), "utf8");
|
|
14
|
+
} catch {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
l as initialize,
|
|
20
|
+
s as readLibFile
|
|
21
|
+
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sheetxl/scripting",
|
|
3
3
|
"description": "Scripting - Scripting engine for Macros and formulas; includes TypeScript and EsBuild.",
|
|
4
|
-
"version": "0.8.0-beta.
|
|
4
|
+
"version": "0.8.0-beta.11",
|
|
5
5
|
"license": "SEE LICENSE IN <LICENSE>",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"exports": {
|
|
@@ -9,13 +9,12 @@
|
|
|
9
9
|
"types": "./types/index.d.ts",
|
|
10
10
|
"browser": "./browser/esm/index.mjs",
|
|
11
11
|
"node": "./node/esm/index.mjs",
|
|
12
|
-
"
|
|
13
|
-
"require": "./browser/cjs/index.cjs"
|
|
12
|
+
"default": "./browser/esm/index.mjs"
|
|
14
13
|
}
|
|
15
14
|
},
|
|
16
15
|
"types": "./types/index.d.ts",
|
|
17
16
|
"module": "./browser/esm/index.mjs",
|
|
18
|
-
"main": "./browser/
|
|
17
|
+
"main": "./browser/esm/index.mjs",
|
|
19
18
|
"sideEffects": false,
|
|
20
19
|
"engines": {
|
|
21
20
|
"node": ">=22"
|
|
@@ -40,8 +39,8 @@
|
|
|
40
39
|
"scripting"
|
|
41
40
|
],
|
|
42
41
|
"dependencies": {
|
|
43
|
-
"@sheetxl/primitives": "^0.8.0-beta.
|
|
44
|
-
"@sheetxl/utils": "^0.8.0-beta.
|
|
42
|
+
"@sheetxl/primitives": "^0.8.0-beta.11",
|
|
43
|
+
"@sheetxl/utils": "^0.8.0-beta.11"
|
|
45
44
|
},
|
|
46
45
|
"peerDependencies": {
|
|
47
46
|
"esbuild-wasm": ">=0.25.7",
|
|
@@ -49,6 +48,6 @@
|
|
|
49
48
|
"vite": "^8.0.0"
|
|
50
49
|
},
|
|
51
50
|
"devDependencies": {
|
|
52
|
-
"@types/node": "^26.
|
|
51
|
+
"@types/node": "^26.6.4"
|
|
53
52
|
}
|
|
54
53
|
}
|
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
* resolving '@sheetxl/primitives' to a framework-controlled implementation.
|
|
4
4
|
* Other imports are treated as external.
|
|
5
5
|
*/
|
|
6
|
-
export declare function bundleScript(ts: typeof import('typescript'), codeAsString: string, entryPointId?: string, globalVariable?: string): Promise<string>;
|
|
6
|
+
export declare function bundleScript(ts: typeof import('typescript'), codeAsString: string, entryPointId?: string, globalVariable?: string, minify?: boolean): Promise<string>;
|
|
7
7
|
//# sourceMappingURL=Bundler.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { default as ts } from 'typescript';
|
|
2
|
+
/**
|
|
3
|
+
* An emit transformer that puts `__SHEETXL.checkRun?.(key, timeoutMs)` at the top of every loop body
|
|
4
|
+
* and every function body, so a runaway run can be stopped from inside (see `RunGuard`).
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Loops are what run away; function bodies cover recursion. An arrow's expression body becomes a
|
|
8
|
+
* block that checks and returns. A directive prologue (`'use strict'`) stays first.
|
|
9
|
+
*/
|
|
10
|
+
export declare function createRunGuardTransformer(ts: typeof import('typescript'), key: string, timeoutMs: number): ts.TransformerFactory<ts.SourceFile>;
|
|
11
|
+
//# sourceMappingURL=insertRunGuard.d.ts.map
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
type TypeScriptModule = typeof import('typescript');
|
|
2
2
|
export declare function initialize(): Promise<TypeScriptModule>;
|
|
3
|
+
/**
|
|
4
|
+
* The browser has no copy of TypeScript's library declarations, so a type-checking compile cannot
|
|
5
|
+
* run here; the editor's own language worker covers semantic checking interactively. Always
|
|
6
|
+
* `undefined` — see the node half for the contract.
|
|
7
|
+
*/
|
|
8
|
+
export declare function readLibFile(_ts: TypeScriptModule, _fileName: string): string | undefined;
|
|
3
9
|
export {};
|
|
4
10
|
//# sourceMappingURL=typescript.browser.d.ts.map
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
type TypeScriptModule = typeof import('typescript');
|
|
2
2
|
export declare function initialize(): Promise<TypeScriptModule>;
|
|
3
|
+
/**
|
|
4
|
+
* Reads one of TypeScript's own library declaration files (`lib.es2020.d.ts`, ...) from the
|
|
5
|
+
* installed package, or `undefined` when there is no such file.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* Synchronous because a compiler host's `readFile` is. Under Node the libs sit beside the module
|
|
9
|
+
* on disk, so a type-checking compile can resolve `lib` references the way `tsc` does; the browser
|
|
10
|
+
* half of this conditional export has no such directory and answers `undefined`, which is how the
|
|
11
|
+
* compiler learns that semantic checking is unavailable there.
|
|
12
|
+
*/
|
|
13
|
+
export declare function readLibFile(ts: TypeScriptModule, fileName: string): string | undefined;
|
|
3
14
|
export {};
|
|
4
15
|
//# sourceMappingURL=typescript.node.d.ts.map
|
|
@@ -31,7 +31,27 @@ export interface AnalyzeOptions {
|
|
|
31
31
|
* case-insensitively.
|
|
32
32
|
*/
|
|
33
33
|
builtInNames?: readonly string[];
|
|
34
|
+
/** Whether the source is the built-in library - see `CompileOptions.isBuiltIn`. */
|
|
35
|
+
isBuiltIn?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Code that runs once - see `CompileOptions.lenient`. The default export IS the entry, so its
|
|
38
|
+
* first parameter, left untyped, is the script context (`export default function main(ctx)`).
|
|
39
|
+
*/
|
|
40
|
+
lenient?: boolean;
|
|
34
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Walks an already-parsed/checked source file and applies SheetXL's semantic authoring rules.
|
|
44
|
+
*
|
|
45
|
+
* @param ts The TypeScript module (compiler API).
|
|
46
|
+
* @param sourceFile The script source file (must be created with `setParentNodes = true`).
|
|
47
|
+
* @param checker The type checker from the program containing `sourceFile`.
|
|
48
|
+
* @param options {@link AnalyzeOptions} — host facts the rules need.
|
|
49
|
+
*
|
|
50
|
+
* @remarks
|
|
51
|
+
* This is the single environment-agnostic engine. It does not emit, bundle, touch the DOM, or read
|
|
52
|
+
* the filesystem. {@link compileModule} calls it to build declarations and decide whether to emit;
|
|
53
|
+
* {@link lintScript} calls it to produce diagnostics for editors/CLIs.
|
|
54
|
+
*/
|
|
35
55
|
export declare function analyzeModule(ts: typeof import('typescript'), sourceFile: ts.SourceFile, checker: ts.TypeChecker, options?: AnalyzeOptions): Analysis;
|
|
36
56
|
/**
|
|
37
57
|
* Lints a script source string and returns positioned diagnostics.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stops a runaway run from inside its own code.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* A script runs on the host's thread, so nothing outside it can interrupt a synchronous loop. A
|
|
6
|
+
* compile that asks for a guard (`CompileOptions.runGuard`) inserts `check(key, timeoutMs)` at the
|
|
7
|
+
* top of every loop body and function body; the check throws once the run has been going longer
|
|
8
|
+
* than `timeoutMs`, or once {@link abort} has been called for its key.
|
|
9
|
+
*
|
|
10
|
+
* The key and the limit are compiled into the module, so any host that executes it enforces the
|
|
11
|
+
* limit — the MCP server in-process, the VS Code webview for an attended session — and concurrent
|
|
12
|
+
* runs never read each other's state. The clock starts at the first check, which is the entry
|
|
13
|
+
* function's own.
|
|
14
|
+
*
|
|
15
|
+
* Not covered: a single engine call that never returns, with no user loop around it.
|
|
16
|
+
*/
|
|
17
|
+
/** `error.name` of what a stopped run throws. */
|
|
18
|
+
export declare const RUN_INTERRUPTED = "RunInterrupted";
|
|
19
|
+
/**
|
|
20
|
+
* The compiled-in check. Throws when the run keyed `key` has exceeded `timeoutMs` or was aborted.
|
|
21
|
+
*/
|
|
22
|
+
export declare function check(key: string, timeoutMs: number): void;
|
|
23
|
+
/**
|
|
24
|
+
* Stops the run keyed `key` at its next check — including a run that has not reached its first one.
|
|
25
|
+
*/
|
|
26
|
+
export declare function abort(key: string, reason?: string): void;
|
|
27
|
+
/** Forgets a finished run. */
|
|
28
|
+
export declare function release(key: string): void;
|
|
29
|
+
/** True when `error` is what {@link check} throws. */
|
|
30
|
+
export declare function isInterrupted(error: unknown): boolean;
|
|
31
|
+
//# sourceMappingURL=RunGuard.d.ts.map
|
|
@@ -15,6 +15,14 @@ export interface CompileOptions {
|
|
|
15
15
|
* This is useful for validation
|
|
16
16
|
*/
|
|
17
17
|
disableBundle?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* If true, the bundle is minified. For a module that is stored (a workbook's scripts, a `.sxlm`).
|
|
20
|
+
*
|
|
21
|
+
* @remarks
|
|
22
|
+
* Off by default: code that is only run keeps its own names, so a runtime error reads as the
|
|
23
|
+
* author wrote it (`wb.getWorksheet is not a function`, not `a.getWorksheet`).
|
|
24
|
+
*/
|
|
25
|
+
minify?: boolean;
|
|
18
26
|
/**
|
|
19
27
|
* If true, this will not include the source map in the compiled module.
|
|
20
28
|
*/
|
|
@@ -38,6 +46,48 @@ export interface CompileOptions {
|
|
|
38
46
|
* without a position. Compared case-insensitively.
|
|
39
47
|
*/
|
|
40
48
|
builtInNames?: readonly string[];
|
|
49
|
+
/**
|
|
50
|
+
* Whether the source IS the built-in library rather than a script written against it.
|
|
51
|
+
*
|
|
52
|
+
* @remarks
|
|
53
|
+
* A built-in name is resolved before a formula reads it any other way, so it may take a name
|
|
54
|
+
* that is refused to a user function - `LOG10`, which also reads as a cell address.
|
|
55
|
+
*/
|
|
56
|
+
isBuiltIn?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* The ambient declarations the script is written against — the shipped `scripting.d.ts`.
|
|
59
|
+
*
|
|
60
|
+
* @remarks
|
|
61
|
+
* Supplied, the compile type-checks the script against that surface and reports what TypeScript
|
|
62
|
+
* finds: a member the receiver does not have (with TypeScript's own "did you mean"), a wrong
|
|
63
|
+
* argument, an unknown name. Omitted, the compile reports syntax and authoring rules only. The
|
|
64
|
+
* check also needs TypeScript's own libs, which only Node has on disk; a browser compile ignores
|
|
65
|
+
* this option and leaves semantic checking to the editor's language worker.
|
|
66
|
+
*/
|
|
67
|
+
ambientTypes?: string;
|
|
68
|
+
/**
|
|
69
|
+
* Compile in a stop check, for a host running agent-written code on its own thread.
|
|
70
|
+
*
|
|
71
|
+
* @remarks
|
|
72
|
+
* Every loop body and function body calls `RunGuard.check(key, timeoutMs)`, which throws once the
|
|
73
|
+
* run has gone on longer than `timeoutMs` or `RunGuard.abort(key)` was called. `key` identifies
|
|
74
|
+
* this compile's run, so give each run its own. Omitted, the module carries no checks.
|
|
75
|
+
*/
|
|
76
|
+
runGuard?: {
|
|
77
|
+
key: string;
|
|
78
|
+
timeoutMs: number;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Check the source as code that runs once, not as code kept to be run again.
|
|
82
|
+
*
|
|
83
|
+
* @remarks
|
|
84
|
+
* For an ad hoc run (`sheetxl -e`, the MCP `run` tool). Annotations are not required: a default
|
|
85
|
+
* export's untyped first parameter is the script context, and a missing type is not reported.
|
|
86
|
+
*
|
|
87
|
+
* A run is not type-checked before it executes - leave {@link ambientTypes} out. The types are
|
|
88
|
+
* there to explain a run that went wrong, which is `diagnoseRun` in `@sheetxl/runner`.
|
|
89
|
+
*/
|
|
90
|
+
lenient?: boolean;
|
|
41
91
|
}
|
|
42
92
|
/**
|
|
43
93
|
* The result of a compile operation: the compiled artifact plus this compile's positioned
|
|
@@ -16,9 +16,11 @@ export interface CompiledModule {
|
|
|
16
16
|
* An array of `Declaration` and `Description pairs describing the functions within the script.
|
|
17
17
|
*
|
|
18
18
|
* @remarks
|
|
19
|
-
*
|
|
19
|
+
* Absent when the module declares none — a script of only comments, or source in a language
|
|
20
|
+
* SheetXL does not execute. An empty array means the same thing and is accepted, but is not
|
|
21
|
+
* written: it is a row of nothing in every persisted workbook that imported a macro file.
|
|
20
22
|
*/
|
|
21
|
-
functions
|
|
23
|
+
functions?: [IFunction.DeclarationJSON, IFunction.DescriptorJSON][];
|
|
22
24
|
/**
|
|
23
25
|
* The human-readable source code of the script.
|
|
24
26
|
*
|
|
@@ -37,6 +39,26 @@ export interface CompiledModule {
|
|
|
37
39
|
* If provided this will include a source map for the compiled script.
|
|
38
40
|
*/
|
|
39
41
|
sourceMap?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Text that belongs to {@link CompiledModule.source} in its original format but is not source
|
|
44
|
+
* anyone reads or edits.
|
|
45
|
+
*
|
|
46
|
+
* @remarks
|
|
47
|
+
* VBA is why this exists: every module begins with a hidden `Attribute VB_*` block that the VBA
|
|
48
|
+
* editor never shows, and for a document module nobody has written in, that block is the ENTIRE
|
|
49
|
+
* content. Leaving it in `source` means the model claims a module has source when it has none,
|
|
50
|
+
* and every reader — an agent, an editor, a line count — has to know to strip it first.
|
|
51
|
+
*
|
|
52
|
+
* Kept rather than discarded because it cannot be derived on the way back out: `VB_Base` names
|
|
53
|
+
* an interface GUID and `VB_PredeclaredId`/`VB_Exposed` are per-module settings. This is
|
|
54
|
+
* interop residue, in the same sense as the workbook's `fileVersion` — carried, never
|
|
55
|
+
* synthesized.
|
|
56
|
+
*
|
|
57
|
+
* If a second kind of residue ever appears, this and {@link CompiledModule.sourceMap} are the
|
|
58
|
+
* two candidates for folding into one language-agnostic `meta` bag. One field for one known
|
|
59
|
+
* thing until then.
|
|
60
|
+
*/
|
|
61
|
+
sourceHeader?: string;
|
|
40
62
|
/**
|
|
41
63
|
* The language the function is written in.
|
|
42
64
|
*
|
|
@@ -44,9 +66,18 @@ export interface CompiledModule {
|
|
|
44
66
|
*/
|
|
45
67
|
language?: string;
|
|
46
68
|
/**
|
|
47
|
-
*
|
|
69
|
+
* What the module is bound to, for the one case its location cannot say.
|
|
70
|
+
*
|
|
71
|
+
* - `'workbook'` — owned by the workbook itself. Its functions are NOT in the formula namespace.
|
|
72
|
+
* - absent — global. Its functions are.
|
|
73
|
+
*
|
|
74
|
+
* @remarks
|
|
75
|
+
* There is deliberately no sheet value here. A sheet's modules are stored BY the sheet
|
|
76
|
+
* (`IWorksheet.JSON.modules`), so nothing has to name it and a module cannot be left behind pointing
|
|
77
|
+
* at a sheet that no longer exists. This field exists only because a workbook holds both its
|
|
78
|
+
* global modules and its own in one collection, which is the single case nesting cannot express.
|
|
48
79
|
*/
|
|
49
|
-
|
|
80
|
+
scope?: 'workbook';
|
|
50
81
|
/**
|
|
51
82
|
* A unique identifier for the function (e.g., a Git commit ID).
|
|
52
83
|
* // https://stackoverflow.com/questions/29106996/what-is-a-git-commit-id
|
|
@@ -63,8 +94,7 @@ export interface CompiledModule {
|
|
|
63
94
|
*
|
|
64
95
|
* TODO - this doesn't belong here.
|
|
65
96
|
* Create a new interface for session state.
|
|
66
|
-
* TODO - rename to sessionData
|
|
67
97
|
*/
|
|
68
|
-
|
|
98
|
+
sessionData?: any;
|
|
69
99
|
}
|
|
70
100
|
//# sourceMappingURL=CompiledModule.d.ts.map
|
|
@@ -96,15 +96,33 @@ export declare const DiagnosticCode: Readonly<{
|
|
|
96
96
|
readonly RepeatingSlots: "SXL2042";
|
|
97
97
|
/** An optional parameter/slot where a repeating group does not allow one. */
|
|
98
98
|
readonly RepeatingOptional: "SXL2043";
|
|
99
|
+
/** `Repeating<T, Max>`'s maximum argument count is not a whole number in range. */
|
|
100
|
+
readonly RepeatingMax: "SXL2044";
|
|
101
|
+
/** An enum mixes number and string members. */
|
|
102
|
+
readonly EnumMixed: "SXL2050";
|
|
103
|
+
/** An enum member is not a constant number or string. */
|
|
104
|
+
readonly EnumMemberNotConstant: "SXL2051";
|
|
105
|
+
/** A parameter type that is not declared in this module, so an enum behind it cannot be read. */
|
|
106
|
+
readonly EnumNotLocal: "SXL2052";
|
|
107
|
+
/** An `as const` object used as a parameter type without its same-name type alias. */
|
|
108
|
+
readonly EnumMissingAlias: "SXL2053";
|
|
109
|
+
/** An enum where no single argument is coerced to it (`IRange<E>`, `Lazy<E>`). */
|
|
110
|
+
readonly EnumPosition: "SXL2054";
|
|
111
|
+
/** `Omittable<E, V>` whose `V` is neither a member of `E` nor `null`. */
|
|
112
|
+
readonly EnumOmittedValue: "SXL2055";
|
|
99
113
|
/** No exported functions found in the module. */
|
|
100
114
|
readonly NoExports: "SXL3001";
|
|
101
115
|
/** A `@param` tag references a parameter that does not exist. */
|
|
102
116
|
readonly UnknownParam: "SXL3002";
|
|
103
117
|
/** A calculation function takes a built-in function's name. */
|
|
104
118
|
readonly BuiltInName: "SXL3003";
|
|
105
|
-
/** A `@
|
|
106
|
-
readonly
|
|
107
|
-
/**
|
|
119
|
+
/** A `@returnKind` tag names a value kind that does not exist, or names none at all. */
|
|
120
|
+
readonly UnknownReturnKind: "SXL3005";
|
|
121
|
+
/** A calculation function's name (its `@name`, or else its own) is not a name a formula can call. */
|
|
122
|
+
readonly InvalidName: "SXL3006";
|
|
123
|
+
/** Two functions in one module register under the same name (an `@name` repeats another's). */
|
|
124
|
+
readonly DuplicateName: "SXL3007";
|
|
125
|
+
/** A function has no JSDoc description. */
|
|
108
126
|
readonly MissingSummary: "SXL9001";
|
|
109
127
|
/** A `@param` is missing a description. */
|
|
110
128
|
readonly MissingParamDescription: "SXL9002";
|
|
@@ -114,6 +132,10 @@ export declare const DiagnosticCode: Readonly<{
|
|
|
114
132
|
* behavior via the summary, so a standalone `@returns` warning is noise.
|
|
115
133
|
*/
|
|
116
134
|
readonly MissingReturns: "SXL9003";
|
|
135
|
+
/** Two enum members share a value. */
|
|
136
|
+
readonly EnumDuplicateValue: "SXL9004";
|
|
137
|
+
/** An enum member has no doc comment. */
|
|
138
|
+
readonly EnumMemberUndocumented: "SXL9005";
|
|
117
139
|
}>;
|
|
118
140
|
/**
|
|
119
141
|
* Union of the stable diagnostic code string values.
|