@sheetxl/scripting 0.7.27 → 0.7.28-beta.1

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 (83) hide show
  1. package/README.md +206 -247
  2. package/browser/cjs/1_xhnTjP6m5oj6za.cjs +21 -0
  3. package/browser/cjs/Bu4cZ8iSZ3rij-oV.cjs +1 -0
  4. package/browser/cjs/BvG8N7G_8CXIAlT-.cjs +1 -0
  5. package/browser/cjs/C_7w8EJZpHw8ueuq.cjs +1 -0
  6. package/browser/cjs/C_IEgjM-hSJCv6Gm.cjs +1 -0
  7. package/browser/cjs/CctaCN_w3o34V9AR.cjs +1 -0
  8. package/browser/cjs/DSEShe7kGtxvljOr.cjs +1 -0
  9. package/browser/cjs/btgKzY3qMXIaaNlB.cjs +1 -0
  10. package/browser/cjs/g7NzVvjLm_oCf_dd.cjs +1 -0
  11. package/browser/cjs/index.cjs +1 -6
  12. package/browser/cjs/qWYyYsBboXc9p0Lw.cjs +7 -0
  13. package/browser/esm/3M5kvBOeC9dO1anl.mjs +12 -0
  14. package/browser/esm/BO33MdJ1knSwnDFc.mjs +421 -0
  15. package/browser/esm/Buk8t7jbvkBl210h.mjs +25 -0
  16. package/browser/esm/DEMLy75ghnJrOdbg.mjs +23 -0
  17. package/browser/esm/D_RaFJ9L6p0FWrsc.mjs +87 -0
  18. package/browser/esm/DkclmJ-rIJcNsfWQ.mjs +27 -0
  19. package/browser/esm/DqlXZuvMsFv7k9Op.mjs +105 -0
  20. package/browser/esm/S3dk0h6UOMvLEQYW.mjs +152 -0
  21. package/browser/esm/SJ37xnNH-b4AhQOe.mjs +8 -0
  22. package/browser/esm/index.mjs +40 -20
  23. package/browser/esm/xhrsKI0xcttmWNAI.mjs +15 -0
  24. package/node/esm/BvEpRtUTq_sFtAnk.mjs +421 -0
  25. package/node/esm/BzB380N0KvPvx3Va.mjs +23 -0
  26. package/node/esm/CYHVS16ZrqxOoRVQ.mjs +17 -0
  27. package/node/esm/CcqVU5-hFGk6MS45.mjs +27 -0
  28. package/node/esm/DBuGDPGKGMJGN0-R.mjs +12 -0
  29. package/node/esm/Dx2TL-2TFdOTGPZo.mjs +14 -0
  30. package/node/esm/SJ37xnNH-b4AhQOe.mjs +8 -0
  31. package/node/esm/fVQ1ZTi1igB3_IOU.mjs +152 -0
  32. package/node/esm/index.mjs +144 -20
  33. package/package.json +11 -8
  34. package/types/index.d.ts +2 -165
  35. package/types/src/ScriptCompiler.d.ts +40 -0
  36. package/types/src/compiler/Bundler.d.ts +7 -0
  37. package/types/src/compiler/TypescriptCompiler.d.ts +27 -0
  38. package/types/src/compiler/TypescriptCompiler.impl.d.ts +17 -0
  39. package/types/src/compiler/TypescriptCompiler.worker.d.ts +2 -0
  40. package/types/src/compiler/compiler.browser.d.ts +8 -0
  41. package/types/src/compiler/compiler.node.d.ts +14 -0
  42. package/types/src/compiler/constants.d.ts +10 -0
  43. package/types/src/compiler/insertYieldBetweenStatements.d.ts +5 -0
  44. package/types/src/compiler/transformAwaitToYield.d.ts +6 -0
  45. package/types/src/index.d.ts +7 -0
  46. package/types/src/lib/esbuild/esbuild.browser.d.ts +4 -0
  47. package/types/src/lib/esbuild/esbuild.node.d.ts +11 -0
  48. package/types/src/lib/typescript/typescript.browser.d.ts +4 -0
  49. package/types/src/lib/typescript/typescript.node.d.ts +4 -0
  50. package/types/src/linter/Linter.d.ts +63 -0
  51. package/types/src/linter/index.d.ts +2 -0
  52. package/types/src/loader/index.d.ts +2 -0
  53. package/types/src/loader/loadCompiledModule.d.ts +19 -0
  54. package/types/src/loader/moduleLoader.browser.d.ts +11 -0
  55. package/types/src/loader/moduleLoader.node.d.ts +15 -0
  56. package/types/src/plugin/generate.d.ts +17 -0
  57. package/types/src/plugin/vite.d.ts +24 -0
  58. package/types/src/runtime/Constants.d.ts +9 -0
  59. package/types/src/runtime/index.d.ts +2 -0
  60. package/types/src/tags/DocTags.d.ts +46 -0
  61. package/types/src/tags/index.d.ts +2 -0
  62. package/types/src/type/CompileOptions.d.ts +58 -0
  63. package/types/src/type/CompiledModule.d.ts +70 -0
  64. package/types/src/type/Diagnostic.d.ts +120 -0
  65. package/types/src/type/Types.d.ts +72 -0
  66. package/types/src/type/index.d.ts +6 -0
  67. package/types/src/worker/WorkerWrapper.d.ts +44 -0
  68. package/types/src/worker/index.d.ts +2 -0
  69. package/browser/cjs/B4lAANRqTGnvOqGs.cjs +0 -1518
  70. package/browser/cjs/BRnBwa7X_-2hZkPR.cjs +0 -6
  71. package/browser/cjs/BgmE5dDR60P-0D05.cjs +0 -6
  72. package/browser/cjs/C6FgXFuZyUBSYx74.cjs +0 -6
  73. package/browser/cjs/Cmsp48m0ZoKEApI_.cjs +0 -32
  74. package/browser/esm/BCtqf7TlVX2XI9Sk.mjs +0 -29
  75. package/browser/esm/BUrlmQqFvt49Snxt.mjs +0 -1593
  76. package/browser/esm/BeDi9Rjq6Mj_zC_O.mjs +0 -24
  77. package/browser/esm/C1nmZG6Nh598I5Cy.mjs +0 -266
  78. package/browser/esm/C9oTtQ5kcPvveo9r.mjs +0 -21
  79. package/node/esm/B8mFYKKfM-fFEqr4.mjs +0 -1593
  80. package/node/esm/D3tC0pmcUWYhM3aH.mjs +0 -14
  81. package/node/esm/DUk3E5XxCEk6dBja.mjs +0 -16
  82. package/node/esm/Db6wgeAGcGPbeesO.mjs +0 -266
  83. package/node/esm/YSXanagcUr6QMDaF.mjs +0 -29
@@ -0,0 +1,152 @@
1
+ /**
2
+ * @license @sheetxl/scripting - Scripting - Scripting engine for Macros and formulas; includes TypeScript and EsBuild. - v0.7.28-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 "./index.mjs";
8
+ import { analyzeModule as t } from "./BvEpRtUTq_sFtAnk.mjs";
9
+ import { t as n } from "./SJ37xnNH-b4AhQOe.mjs";
10
+ import { CommonUtils as r } from "@sheetxl/utils";
11
+ var i = null, a = null, o = { compilerOptions: { target: "esnext" } };
12
+ async function s(t, n, r = "/script.js", s = e) {
13
+ try {
14
+ let e = await async function() {
15
+ if (i) return i;
16
+ if (a) {
17
+ if (await a, !i) throw Error("ESBuild initialization promise resolved, but instance is not available.");
18
+ return i;
19
+ }
20
+ let e, t;
21
+ a = new Promise((n, r) => {
22
+ e = n, t = r;
23
+ });
24
+ try {
25
+ let { initialize: t } = await import("./DBuGDPGKGMJGN0-R.mjs");
26
+ return i = await t(), e(), i;
27
+ } catch (e) {
28
+ throw console.error("Failed to import or initialize esbuild:", e), a = null, t(e), e;
29
+ }
30
+ }(), t = "@sheetxl/primitives", c = `\n export const FormulaContext = globalThis.${s}?.FormulaContext;\n export const ScalarType = globalThis.${s}?.ScalarType;\n export const Observable = globalThis.${s}?.Observable;\n export const IRange = globalThis.${s}?.IRange;\n export const FormulaError = globalThis.${s}?.FormulaError;\n // Add more exports as needed\n `, l = await e.build({
31
+ entryPoints: [r],
32
+ bundle: !0,
33
+ write: !1,
34
+ format: "esm",
35
+ plugins: [{
36
+ name: "sheetxl-esbuild-in-memory",
37
+ setup(e) {
38
+ let i = "sheetxl-" + (/* @__PURE__ */ new Date()).getTime();
39
+ e.onResolve({ filter: RegExp(`^(${r.replace("/", "\\/")}|${t})$`) }, (e) => ({
40
+ path: e.path,
41
+ namespace: i
42
+ })), e.onResolve({ filter: /.*/ }, (e) => {
43
+ if (e.namespace !== i) return console.warn(`esbuild: Treating import "${e.path}" as external.`), {
44
+ path: e.path,
45
+ external: !0
46
+ };
47
+ }), e.onLoad({
48
+ filter: /.*/,
49
+ namespace: i
50
+ }, (e) => {
51
+ let a;
52
+ if (e.path === r) a = n;
53
+ else {
54
+ if (e.path !== t) return { errors: [{ text: `Cannot load unknown path in ${i}: ${e.path}` }] };
55
+ a = c;
56
+ }
57
+ return {
58
+ contents: a,
59
+ loader: "ts"
60
+ };
61
+ });
62
+ }
63
+ }],
64
+ sourcemap: "inline",
65
+ tsconfigRaw: o,
66
+ minify: !0,
67
+ platform: "neutral"
68
+ });
69
+ if (l.outputFiles && l.outputFiles.length > 0) return l.outputFiles[0].text;
70
+ throw l.errors && l.errors.length > 0 ? Error(`esbuild bundling failed: ${l.errors.map((e) => e.text).join("\n")}`) : Error("esbuild did not produce an output file.");
71
+ } catch (e) {
72
+ throw console.error("esbuild bundling process failed:", e), e;
73
+ }
74
+ }
75
+ var c = async () => "\n interface FirstTest {\n isTrue?: boolean;\n }\n", l = null;
76
+ async function u() {
77
+ if (l) return l;
78
+ try {
79
+ return await (await import("./Dx2TL-2TFdOTGPZo.mjs")).initialize();
80
+ } catch (e) {
81
+ throw l = null, e;
82
+ } finally {
83
+ l = null;
84
+ }
85
+ }
86
+ async function d(i) {
87
+ let a = i?.source ?? null;
88
+ if (!a) return {
89
+ module: null,
90
+ diagnostics: []
91
+ };
92
+ let o = (i.disableBundle || i.declarationsOnly) ?? !1, [l, d] = await Promise.all([c(), u()]), f = "", p = {
93
+ allowJs: !0,
94
+ declaration: !1,
95
+ sourceMap: !1,
96
+ inlineSourceMap: !1,
97
+ inlineSources: !1,
98
+ isolatedModules: !0,
99
+ preserveConstEnums: !1,
100
+ module: 99,
101
+ noResolve: !0,
102
+ emitDeclarationOnly: !1,
103
+ target: d.ScriptTarget.ES2020
104
+ }, m = "script", h = `${m}.ts`, g = "lib.d.ts", _ = "global.d.ts", v = {
105
+ [h]: a,
106
+ [g]: "\n/**\n * Represents the completion of an asynchronous operation\n */\ninterface Promise<T> {\n /**\n * Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The\n * resolved value cannot be modified from the callback.\n * @param onfinally The callback to execute when the Promise is settled (fulfilled or rejected).\n * @returns A Promise for the completion of the callback.\n */\n finally(onfinally?: (() => void) | undefined | null): Promise<T>;\n}\n",
107
+ [_]: l
108
+ }, y = d.createProgram([h, _], p, {
109
+ getSourceFile: (e, t, n, r) => d.createSourceFile(e, v[e], d.ScriptTarget.Latest, !0),
110
+ fileExists: (e) => v[e] !== void 0,
111
+ readFile: (e) => v[e],
112
+ writeFile: (e, t) => {
113
+ v[e] = t;
114
+ },
115
+ getCurrentDirectory: () => "./",
116
+ getCanonicalFileName: (e) => e,
117
+ useCaseSensitiveFileNames: () => !0,
118
+ getDefaultLibFileName: (e) => g,
119
+ getNewLine: () => "\n"
120
+ }), b = y.getTypeChecker(), x = y.getSourceFile(h);
121
+ y.emit(), f = v[`${m}.js`] ?? "";
122
+ let S = y.getSyntacticDiagnostics(x).map((e) => ({
123
+ start: e.start ?? 0,
124
+ length: e.length ?? 0,
125
+ severity: "error",
126
+ code: `TS${e.code}`,
127
+ message: d.flattenDiagnosticMessageText(e.messageText, "\n")
128
+ })), C = t(d, x, b, { builtInNames: i.builtInNames }), w = [...S, ...C.diagnostics], T = C.functions, E = C.autoRun, D = w.some((e) => e.severity === "error"), O = `${r.uuidV4()}-script`, k = null;
129
+ if (D) f = "";
130
+ else {
131
+ try {
132
+ o || (f = await s(0, f, m));
133
+ } catch {
134
+ console.warn("Error bundling script");
135
+ }
136
+ let t = f.indexOf(n);
137
+ t > -1 && (k = f.substring(t + n.length + 1, f.length), f = f.substring(0, t), f = f.replaceAll("globalThis." + e, e));
138
+ }
139
+ let A = {
140
+ functions: T,
141
+ commitId: O,
142
+ source: a,
143
+ name: "Script",
144
+ language: "typescript",
145
+ compiled: f
146
+ };
147
+ return k && (A.sourceMap = k), E && (A.autoRun = E), {
148
+ module: A,
149
+ diagnostics: w
150
+ };
151
+ }
152
+ export { d as compileModule };
@@ -1,21 +1,145 @@
1
- import { CommonUtils as u } from "@sheetxl/utils";
2
1
  /**
3
- * @license @sheetxl/scripting - Scripting - Scripting engine for Macros and formulas; includes TypeScript and EsBuild. - v0.7.27
4
- *
5
- * (C) 2025-present SheetXL Inc. & Michael T. Ford
6
- * License: The license can be found at https://www.sheetxl.com/license.
7
- */
8
- let i = null, n = null, e = null;
9
- const p = Object.freeze({ compileTypescript: async function(t) {
10
- if (!(t?.source ?? null)) return null;
11
- if (n && u.deepEqual(n, t)) return i;
12
- const l = await (async function() {
13
- if (e) return e;
14
- const { TypeScriptCompiler: o } = await import("./YSXanagcUr6QMDaF.mjs");
15
- return e = new o(), e;
16
- })(), r = await l.compileModule(t);
17
- return i = r, n = t, r;
18
- } });
19
- export {
20
- p as ScriptingUtils
21
- };
2
+ * @license @sheetxl/scripting - Scripting - Scripting engine for Macros and formulas; includes TypeScript and EsBuild. - v0.7.28-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 { CommonUtils as e } from "@sheetxl/utils";
8
+ var t = Object.defineProperty, n = (e, n) => {
9
+ let r = {};
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
+ MissingSummary: "SXL9001",
42
+ MissingParamDescription: "SXL9002",
43
+ MissingReturns: "SXL9003"
44
+ }), i = [
45
+ {
46
+ name: "summary",
47
+ group: "sheetxl",
48
+ description: "Short description shown in function tooltips and autocomplete."
49
+ },
50
+ {
51
+ name: "param",
52
+ group: "jsdoc",
53
+ description: "Document a parameter. A string union type becomes a dropdown of allowed options.",
54
+ snippet: "param ${1:name} ${2:description}"
55
+ },
56
+ {
57
+ name: "returns",
58
+ aliases: ["return"],
59
+ group: "jsdoc",
60
+ description: "Describe the return value."
61
+ },
62
+ {
63
+ name: "category",
64
+ group: "sheetxl",
65
+ description: "Group the function under a category in the function list.",
66
+ snippet: "category ${1:name}"
67
+ },
68
+ {
69
+ name: "name",
70
+ group: "sheetxl",
71
+ description: "Override the displayed function name.",
72
+ snippet: "name ${1:NAME}"
73
+ },
74
+ {
75
+ name: "description",
76
+ group: "sheetxl",
77
+ description: "A longer description of the function."
78
+ },
79
+ {
80
+ name: "deprecated",
81
+ group: "sheetxl",
82
+ standalone: !0,
83
+ description: "Mark the function as deprecated (optionally with a reason)."
84
+ },
85
+ {
86
+ name: "hidden",
87
+ group: "sheetxl",
88
+ standalone: !0,
89
+ description: "Hide the function from the function list."
90
+ },
91
+ {
92
+ name: "example",
93
+ group: "jsdoc",
94
+ description: "Provide a usage example."
95
+ },
96
+ {
97
+ name: "see",
98
+ group: "jsdoc",
99
+ description: "Reference a related function or link."
100
+ }
101
+ ], a = (() => {
102
+ let e = /* @__PURE__ */ new Map();
103
+ for (let t of i) if (e.set(t.name, t), t.aliases) for (let n of t.aliases) e.set(n, t);
104
+ return e;
105
+ })();
106
+ function o(e) {
107
+ return !0 === function(e) {
108
+ if (!e) return;
109
+ let t = (e.startsWith("@") ? e.slice(1) : e).toLowerCase();
110
+ return a.get(t);
111
+ }(e)?.standalone;
112
+ }
113
+ var s = n({ GLOBAL_CONTEXT_VARIABLE: () => c }), c = "__SHEETXL";
114
+ async function l(e, t) {
115
+ let { loadCompiledModule: n } = await import("./CYHVS16ZrqxOoRVQ.mjs");
116
+ return n(e, t);
117
+ }
118
+ var u = null, d = null, f = null, p = null;
119
+ async function m() {
120
+ return p ||= (async () => (await import("./Dx2TL-2TFdOTGPZo.mjs")).initialize())(), p;
121
+ }
122
+ var h = Object.freeze({
123
+ compile: async function(t) {
124
+ if (!t?.source) return {
125
+ module: null,
126
+ diagnostics: []
127
+ };
128
+ if (d && e.deepEqual(d, t)) return u;
129
+ let n = await (await async function() {
130
+ if (f) return f;
131
+ let { TypeScriptCompiler: e } = await import("./CcqVU5-hFGk6MS45.mjs");
132
+ return f = new e();
133
+ }()).compileModule(t);
134
+ return u = n, d = t, n;
135
+ },
136
+ lint: async function(e, t) {
137
+ if (!e) return [];
138
+ let [n, { lintScript: r }] = await Promise.all([m(), import("./BvEpRtUTq_sFtAnk.mjs")]);
139
+ return r(n, e, t);
140
+ },
141
+ cleanup: function() {
142
+ f && (f.terminate(), f = null, u = null);
143
+ }
144
+ });
145
+ export { s as Constants, r as DiagnosticCode, i as DocTags, h as ScriptCompiler, l as loadCompiledModule, o as n, c as t };
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.7.27",
4
+ "version": "0.7.28-beta.1",
5
5
  "license": "SEE LICENSE IN <LICENSE>",
6
6
  "type": "module",
7
7
  "exports": {
@@ -16,9 +16,9 @@
16
16
  "types": "./types/index.d.ts",
17
17
  "module": "./browser/esm/index.mjs",
18
18
  "main": "./browser/cjs/index.cjs",
19
- "sideEffects": true,
19
+ "sideEffects": false,
20
20
  "engines": {
21
- "node": ">=20 <21 || >=22"
21
+ "node": ">=22"
22
22
  },
23
23
  "engineStrict": true,
24
24
  "homepage": "https://sheetxl.com",
@@ -40,12 +40,15 @@
40
40
  "scripting"
41
41
  ],
42
42
  "dependencies": {
43
- "@sheetxl/primitives": "^0.7.27",
44
- "@sheetxl/utils": "^0.7.27",
45
- "path-browserify": "^1.0.1"
43
+ "@sheetxl/primitives": "^0.7.28-beta.1",
44
+ "@sheetxl/utils": "^0.7.28-beta.1"
46
45
  },
47
46
  "peerDependencies": {
48
- "esbuild-wasm": "^0.25.7",
49
- "typescript": "^5.9.0"
47
+ "esbuild-wasm": ">=0.25.7",
48
+ "typescript": "^5.9.0 || ^6.0.0",
49
+ "vite": "^8.0.0"
50
+ },
51
+ "devDependencies": {
52
+ "@types/node": "^26.1.2"
50
53
  }
51
54
  }
package/types/index.d.ts CHANGED
@@ -1,165 +1,2 @@
1
- import { IFormulaContext } from '@sheetxl/primitives';
2
- import { IFunction } from '@sheetxl/primitives';
3
-
4
- /**
5
- * Represents a compile collections of functions.
6
- */
7
- export declare interface CompiledModule {
8
- /**
9
- * An array of `Declaration` and `Description pairs describing the functions within the script.
10
- *
11
- * @remarks
12
- * This array can be empty. It is possible that a script might contain only comments or other non-executable code.
13
- */
14
- functions: [IFunction.DeclarationJSON, IFunction.DescriptorJSON][];
15
- /**
16
- * The human-readable source code of the script.
17
- *
18
- * @remarks
19
- * If this property is missing, the script will not be displayed but the 'actions' will still be available if `compiled` is present.
20
- */
21
- source?: string;
22
- /**
23
- * The compiled or pre-processed version of the script, ready for execution.
24
- *
25
- * @remarks
26
- * If this property is missing, the script will be compiled on demand if possible.
27
- */
28
- compiled?: string;
29
- /**
30
- * The language the function is written in.
31
- *
32
- * @defaultValue typescript
33
- */
34
- language?: string;
35
- /**
36
- * The name of the module.
37
- */
38
- name?: string;
39
- /**
40
- * A unique identifier for the function (e.g., a Git commit ID).
41
- * // https://stackoverflow.com/questions/29106996/what-is-a-git-commit-id
42
- */
43
- commitId?: string;
44
- /**
45
- * The name of the function to run automatically when the script is loaded.
46
- */
47
- autoRun?: string;
48
- /**
49
- * ** NOT IMPLEMENTED **
50
- * Available in functions via the 'this' value.
51
- * Will auto persist values on save.
52
- *
53
- * TODO - this doesn't belong here.
54
- * Create a new interface for session state.
55
- * TODO - rename to sessionData
56
- */
57
- scope?: any;
58
- }
59
-
60
- /**
61
- * Options for compiling a script module.
62
- */
63
- export declare interface CompileOptions {
64
- /**
65
- * The source code of the script module to compile.
66
- */
67
- source: string;
68
- /**
69
- * If true, this will not include the bundle in the compiled module.
70
- *
71
- * @remarks
72
- * This is useful for validation
73
- */
74
- disableBundle?: boolean;
75
- /**
76
- * If true, this will not include the source map in the compiled module.
77
- */
78
- disableSourceMap?: boolean;
79
- /**
80
- * For validation
81
- */
82
- declarationsOnly?: boolean;
83
- /**
84
- * The commit ID for the compilation.
85
- */
86
- commitId?: string;
87
- }
88
-
89
- /**
90
- * The return type for Compile.
91
- */
92
- export declare interface CompileResults {
93
- module: CompiledModule;
94
- errors: any;
95
- }
96
-
97
- /**
98
- * Converts a typescript string into a `CompiledModule`.
99
- *
100
- * @param options Optional compilation options
101
- */
102
- declare function compileTypescript(options: CompileOptions): Promise<CompiledModule>;
103
-
104
- export declare interface DescriptorModule {
105
- default: MinifiedDescriptors;
106
- }
107
-
108
- export declare type DynamicDescriptors = () => Promise<DescriptorModule>;
109
-
110
- /**
111
- * Type for bind signature for typed functions.
112
- */
113
- export declare interface FunctionBinder {
114
- (mapBind: Map<string, IFunction>, getContext: () => IFormulaContext, implementations: Implementations, declarations: MinifiedDeclarations, getDynamicDescriptors?: DynamicDescriptors, defaultCategory?: string): void;
115
- }
116
-
117
- export declare interface Implementations {
118
- [functionName: string]: (...args: any) => any;
119
- }
120
-
121
- /**
122
- * The function declaration needed to autoMarshall and execute.
123
- */
124
- export declare interface MinifiedDeclaration {
125
- fn?: string;
126
- c?: boolean;
127
- p?: MinifiedParameter[];
128
- }
129
-
130
- export declare type MinifiedDeclarations = {
131
- [name: string]: MinifiedDeclaration;
132
- };
133
-
134
- /**
135
- * The descriptor used for a function
136
- */
137
- export declare interface MinifiedDescriptor {
138
- s?: string;
139
- c?: string;
140
- p?: Record<string, any>;
141
- h?: string | boolean;
142
- l?: [url: string, text?: string][];
143
- }
144
-
145
- export declare interface MinifiedDescriptors {
146
- [name: string]: MinifiedDescriptor;
147
- }
148
-
149
- /**
150
- * Minified params.
151
- */
152
- export declare interface MinifiedParameter {
153
- n: string;
154
- s?: string;
155
- r?: 'r' | 'l' | 'a';
156
- d?: number;
157
- m?: '?' | '...';
158
- e?: string[];
159
- }
160
-
161
- export declare const ScriptingUtils: Readonly<{
162
- compileTypescript: typeof compileTypescript;
163
- }>;
164
-
165
- export { }
1
+ export * from './src/index'
2
+ export {}
@@ -0,0 +1,40 @@
1
+ import { CompileOptions, CompileResult, Diagnostic } from './type';
2
+ import { AnalyzeOptions } from './linter';
3
+ /**
4
+ * Compiles a typescript string into a {@link CompileResult} (the compiled `module` + this compile's
5
+ * `diagnostics`). Diagnostics are on the result, not the persisted module artifact.
6
+ *
7
+ * @param options Optional compilation options
8
+ */
9
+ declare function compile(options: CompileOptions): Promise<CompileResult>;
10
+ /**
11
+ * Lints TypeScript source against SheetXL's semantic authoring rules and returns positioned
12
+ * diagnostics. Does **not** emit JavaScript - this is the fast path for editors and `sheetxl lint`.
13
+ *
14
+ * @param source The script source to lint.
15
+ * @param options Host facts the rules need — today the built-in function names, without which the
16
+ * built-in-name rule does not run.
17
+ *
18
+ * @remarks
19
+ * The TypeScript module is loaded lazily on first call, so importing this does not pull the compiler
20
+ * into a bundle until linting actually happens.
21
+ */
22
+ declare function lint(source: string, options?: AnalyzeOptions): Promise<Diagnostic[]>;
23
+ /**
24
+ * Optional but recommended: A function to clean up the worker
25
+ * if the application needs to release resources.
26
+ */
27
+ declare function cleanup(): void;
28
+ /**
29
+ * The scripting compile/lint facade. Language-agnostic by intent — `compile`/`lint` take TypeScript
30
+ * today; a future backend (e.g. Python) can be dispatched behind the same entry without changing the
31
+ * public surface. The heavy engine (compiler worker / linter) is reached only lazily via dynamic
32
+ * `import()`, so referencing `ScriptCompiler` does not pull it into a consumer bundle.
33
+ */
34
+ export declare const ScriptCompiler: Readonly<{
35
+ compile: typeof compile;
36
+ lint: typeof lint;
37
+ cleanup: typeof cleanup;
38
+ }>;
39
+ export {};
40
+ //# sourceMappingURL=ScriptCompiler.d.ts.map
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Bundles a single JavaScript module string using esbuild programmatically,
3
+ * resolving '@sheetxl/primitives' to a framework-controlled implementation.
4
+ * Other imports are treated as external.
5
+ */
6
+ export declare function bundleScript(ts: typeof import('typescript'), codeAsString: string, entryPointId?: string, globalVariable?: string): Promise<string>;
7
+ //# sourceMappingURL=Bundler.d.ts.map
@@ -0,0 +1,27 @@
1
+ import { CompileOptions, CompileResult } from '../type';
2
+ /**
3
+ * Options for the TypeScript compiler worker.
4
+ */
5
+ export interface TypeScriptCompilerOptions {
6
+ }
7
+ /**
8
+ * TypeScript compiler that uses a web worker when available.
9
+ */
10
+ export declare class TypeScriptCompiler {
11
+ private workerWrapper;
12
+ constructor(options?: TypeScriptCompilerOptions);
13
+ /**
14
+ * Asynchronously gets or creates the worker instance.
15
+ * This is the core of the SSR-safe pattern.
16
+ */
17
+ private getWorkerWrapper;
18
+ /**
19
+ * Compiles a TypeScript module using a web worker.
20
+ */
21
+ compileModule(options: CompileOptions): Promise<CompileResult>;
22
+ /**
23
+ * Terminates the worker.
24
+ */
25
+ terminate(): void;
26
+ }
27
+ //# sourceMappingURL=TypescriptCompiler.d.ts.map
@@ -0,0 +1,17 @@
1
+ import { CompileOptions, CompileResult } from '../type';
2
+ /**
3
+ * Returns a function definition and javascript.
4
+ *
5
+ * @param options Compile options
6
+ *
7
+ * @remarks
8
+ * TypescriptCompiler.impl
9
+ *
10
+ * This does **not** throw on script-level errors. Semantic rule violations (invalid types, missing
11
+ * `export`, ...) and TypeScript syntax errors are returned on {@link CompileResult.diagnostics} so
12
+ * callers can render them. When any diagnostic is an error, `module.compiled` is omitted (the script
13
+ * must not run). It will still throw for infrastructure failures (e.g. the TypeScript module failing
14
+ * to load), which are not the author's fault.
15
+ */
16
+ export declare function compileModule(options: CompileOptions): Promise<CompileResult>;
17
+ //# sourceMappingURL=TypescriptCompiler.impl.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=TypescriptCompiler.worker.d.ts.map
@@ -0,0 +1,8 @@
1
+ import { IWorkerWrapper } from '../worker/WorkerWrapper';
2
+ /**
3
+ * This function exists in a separate file so it can be dynamically imported.
4
+ * This prevents the `new Worker` and `new URL` code from ever being seen
5
+ * by the server-side build process.
6
+ */
7
+ export declare function createCompilerWorker<T = any, P = any>(): Promise<IWorkerWrapper<T, P>>;
8
+ //# sourceMappingURL=compiler.browser.d.ts.map
@@ -0,0 +1,14 @@
1
+ import { IWorkerWrapper } from '../worker/WorkerWrapper';
2
+ /**
3
+ * Node resolution of the TypeScript compiler.
4
+ *
5
+ * There is no Web Worker in Node, so the compiler runs synchronously on the main thread via the
6
+ * node-safe `TypescriptCompiler.impl`.
7
+ *
8
+ * This file is the `node` half of the `@sheetxl/scripting/compiler` conditional export. It
9
+ * deliberately does NOT import `TypescriptCompiler.worker.ts?worker&inline` (a Vite-only specifier
10
+ * that fails to resolve outside a Vite pipeline) so it can be bundled and loaded under plain Node -
11
+ * CLI, MCP server, and vitest. The browser half lives in `compiler.browser.ts`.
12
+ */
13
+ export declare function createCompilerWorker<T = any, P = any>(): Promise<IWorkerWrapper<T, P>>;
14
+ //# sourceMappingURL=compiler.node.d.ts.map
@@ -0,0 +1,10 @@
1
+ /**
2
+ * The trailing sourcemap marker appended to / extracted from compiled output (`//# sourceMappingURL`).
3
+ *
4
+ * @remarks
5
+ * Compile-output specific (the compiler emits it; the loader appends it). Internal to
6
+ * `@sheetxl/scripting` — not part of the package's public export surface. Kept in a standalone file
7
+ * (no engine imports) so the loader entry can share it without pulling the compiler.
8
+ */
9
+ export declare const SOURCEMAP_IDENTIFIER = "//# sourceMappingURL";
10
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Inserts `yield;` after each top-level statement in function bodies.
3
+ */
4
+ export declare function insertYieldBetweenStatements(ts: typeof import('typescript'), sourceText: string, fileName?: string): string;
5
+ //# sourceMappingURL=insertYieldBetweenStatements.d.ts.map
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Transforms macro functions into `async function*` generators.
3
+ * Leaves `await` untouched and yields must be injected separately (e.g., via insertYieldBetweenStatements).
4
+ */
5
+ export declare function transformToAsyncGenerators(ts: typeof import("typescript"), sourceText: string, fileName?: string): string;
6
+ //# sourceMappingURL=transformAwaitToYield.d.ts.map