@sheetxl/scripting 0.7.27 → 0.7.28-beta.2
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 +206 -247
- package/browser/cjs/1_xhnTjP6m5oj6za.cjs +21 -0
- package/browser/cjs/BORYwPSa8kRcVDlM.cjs +1 -0
- package/browser/cjs/Bu4cZ8iSZ3rij-oV.cjs +1 -0
- package/browser/cjs/BvG8N7G_8CXIAlT-.cjs +1 -0
- package/browser/cjs/C_7w8EJZpHw8ueuq.cjs +1 -0
- package/browser/cjs/C_IEgjM-hSJCv6Gm.cjs +1 -0
- package/browser/cjs/CctaCN_w3o34V9AR.cjs +1 -0
- package/browser/cjs/CqbcIt-9sTIdv_ug.cjs +1 -0
- package/browser/cjs/DSEShe7kGtxvljOr.cjs +1 -0
- package/browser/cjs/index.cjs +1 -6
- package/browser/cjs/qWYyYsBboXc9p0Lw.cjs +7 -0
- package/browser/esm/72v2d4qsosqg1Cgv.mjs +15 -0
- package/browser/esm/BIiaEInWozFgpkWC.mjs +23 -0
- package/browser/esm/Bq3YfOBk9RFlBHtk.mjs +87 -0
- package/browser/esm/Bv3EhbPBMrGW7NDq.mjs +12 -0
- package/browser/esm/CKvR1IN7_TI4kPx6.mjs +8 -0
- package/browser/esm/CL8euJo0EsPuPpZl.mjs +152 -0
- package/browser/esm/CLqOyDb_IJNUTbG8.mjs +25 -0
- package/browser/esm/DRkPaLiKBwSjazvd.mjs +421 -0
- package/browser/esm/DgjuQb7lhsbj961d.mjs +105 -0
- package/browser/esm/DkZX-H-Uk1_qxqXf.mjs +27 -0
- package/browser/esm/index.mjs +40 -20
- package/node/esm/6UeJvVusjuaH96XM.mjs +27 -0
- package/node/esm/BZfP0vRloO2ytyYI.mjs +23 -0
- package/node/esm/BgcAlmuRDUXtWc6N.mjs +152 -0
- package/node/esm/C1DzF9OG-x6uKG3C.mjs +17 -0
- package/node/esm/C2giStTbGzggycVj.mjs +12 -0
- package/node/esm/C5iqdlaIw6-vUlOg.mjs +14 -0
- package/node/esm/CKvR1IN7_TI4kPx6.mjs +8 -0
- package/node/esm/grRsXc2BMcF-WBs2.mjs +421 -0
- package/node/esm/index.mjs +144 -20
- package/package.json +11 -8
- package/types/index.d.ts +2 -165
- package/types/src/ScriptCompiler.d.ts +40 -0
- package/types/src/compiler/Bundler.d.ts +7 -0
- package/types/src/compiler/TypescriptCompiler.d.ts +27 -0
- package/types/src/compiler/TypescriptCompiler.impl.d.ts +17 -0
- package/types/src/compiler/TypescriptCompiler.worker.d.ts +2 -0
- package/types/src/compiler/compiler.browser.d.ts +8 -0
- package/types/src/compiler/compiler.node.d.ts +14 -0
- package/types/src/compiler/constants.d.ts +10 -0
- package/types/src/compiler/insertYieldBetweenStatements.d.ts +5 -0
- package/types/src/compiler/transformAwaitToYield.d.ts +6 -0
- package/types/src/index.d.ts +7 -0
- package/types/src/lib/esbuild/esbuild.browser.d.ts +4 -0
- package/types/src/lib/esbuild/esbuild.node.d.ts +11 -0
- package/types/src/lib/typescript/typescript.browser.d.ts +4 -0
- package/types/src/lib/typescript/typescript.node.d.ts +4 -0
- package/types/src/linter/Linter.d.ts +63 -0
- package/types/src/linter/index.d.ts +2 -0
- package/types/src/loader/index.d.ts +2 -0
- package/types/src/loader/loadCompiledModule.d.ts +19 -0
- package/types/src/loader/moduleLoader.browser.d.ts +11 -0
- package/types/src/loader/moduleLoader.node.d.ts +15 -0
- package/types/src/plugin/generate.d.ts +17 -0
- package/types/src/plugin/vite.d.ts +24 -0
- package/types/src/runtime/Constants.d.ts +9 -0
- package/types/src/runtime/index.d.ts +2 -0
- package/types/src/tags/DocTags.d.ts +46 -0
- package/types/src/tags/index.d.ts +2 -0
- package/types/src/type/CompileOptions.d.ts +58 -0
- package/types/src/type/CompiledModule.d.ts +70 -0
- package/types/src/type/Diagnostic.d.ts +120 -0
- package/types/src/type/Types.d.ts +72 -0
- package/types/src/type/index.d.ts +6 -0
- package/types/src/worker/WorkerWrapper.d.ts +44 -0
- package/types/src/worker/index.d.ts +2 -0
- package/browser/cjs/B4lAANRqTGnvOqGs.cjs +0 -1518
- package/browser/cjs/BRnBwa7X_-2hZkPR.cjs +0 -6
- package/browser/cjs/BgmE5dDR60P-0D05.cjs +0 -6
- package/browser/cjs/C6FgXFuZyUBSYx74.cjs +0 -6
- package/browser/cjs/Cmsp48m0ZoKEApI_.cjs +0 -32
- package/browser/esm/BCtqf7TlVX2XI9Sk.mjs +0 -29
- package/browser/esm/BUrlmQqFvt49Snxt.mjs +0 -1593
- package/browser/esm/BeDi9Rjq6Mj_zC_O.mjs +0 -24
- package/browser/esm/C1nmZG6Nh598I5Cy.mjs +0 -266
- package/browser/esm/C9oTtQ5kcPvveo9r.mjs +0 -21
- package/node/esm/B8mFYKKfM-fFEqr4.mjs +0 -1593
- package/node/esm/D3tC0pmcUWYhM3aH.mjs +0 -14
- package/node/esm/DUk3E5XxCEk6dBja.mjs +0 -16
- package/node/esm/Db6wgeAGcGPbeesO.mjs +0 -266
- package/node/esm/YSXanagcUr6QMDaF.mjs +0 -29
package/types/index.d.ts
CHANGED
|
@@ -1,165 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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,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
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as esbuild from 'esbuild-wasm';
|
|
2
|
+
export type EsbuildInstance = typeof esbuild;
|
|
3
|
+
/**
|
|
4
|
+
* Initializes esbuild-wasm under Node.
|
|
5
|
+
*
|
|
6
|
+
* The Node entry of esbuild-wasm runs the wasm via a child process and rejects all browser-only
|
|
7
|
+
* options (`wasmURL`, `wasmModule`, `worker`). So `initialize()` must be called with no options -
|
|
8
|
+
* no network fetch, no native binary, always version-matched to the installed package.
|
|
9
|
+
*/
|
|
10
|
+
export declare function initialize(): Promise<EsbuildInstance>;
|
|
11
|
+
//# sourceMappingURL=esbuild.node.d.ts.map
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { default as ts } from 'typescript';
|
|
2
|
+
import { IFunction } from '@sheetxl/primitives';
|
|
3
|
+
import { Diagnostic } from '../type';
|
|
4
|
+
/**
|
|
5
|
+
* The result of analyzing a script module: the function declarations/descriptors that the compiler
|
|
6
|
+
* needs, the auto-run entry point (if any), and the positioned diagnostics produced by our semantic
|
|
7
|
+
* rules.
|
|
8
|
+
*/
|
|
9
|
+
export interface Analysis {
|
|
10
|
+
/**
|
|
11
|
+
* The `Declaration`/`Descriptor` pairs for each exported function. Always populated for functions
|
|
12
|
+
* that parsed, even when error-severity diagnostics exist (so partial results remain useful).
|
|
13
|
+
*/
|
|
14
|
+
functions: [IFunction.DeclarationJSON, IFunction.DescriptorJSON][];
|
|
15
|
+
/**
|
|
16
|
+
* The name of the `export default` function to run automatically, if any.
|
|
17
|
+
*/
|
|
18
|
+
autoRun: string | null;
|
|
19
|
+
/**
|
|
20
|
+
* Positioned diagnostics (errors + warnings).
|
|
21
|
+
*/
|
|
22
|
+
diagnostics: Diagnostic[];
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* What the analysis needs from the host — facts this package cannot know on its own.
|
|
26
|
+
*/
|
|
27
|
+
export interface AnalyzeOptions {
|
|
28
|
+
/**
|
|
29
|
+
* The names of the host's built-in functions. A calculation function that takes one is reported
|
|
30
|
+
* ({@link DiagnosticCode.BuiltInName}); omitted, the rule does not run. Compared
|
|
31
|
+
* case-insensitively.
|
|
32
|
+
*/
|
|
33
|
+
builtInNames?: readonly string[];
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Walks an already-parsed/checked source file and applies SheetXL's semantic authoring rules.
|
|
37
|
+
*
|
|
38
|
+
* @param ts The TypeScript module (compiler API).
|
|
39
|
+
* @param sourceFile The script source file (must be created with `setParentNodes = true`).
|
|
40
|
+
* @param checker The type checker from the program containing `sourceFile`.
|
|
41
|
+
* @param options {@link AnalyzeOptions} — host facts the rules need.
|
|
42
|
+
*
|
|
43
|
+
* @remarks
|
|
44
|
+
* This is the single environment-agnostic engine. It does not emit, bundle, touch the DOM, or read
|
|
45
|
+
* the filesystem. {@link compileModule} calls it to build declarations and decide whether to emit;
|
|
46
|
+
* {@link lintScript} calls it to produce diagnostics for editors/CLIs.
|
|
47
|
+
*/
|
|
48
|
+
export declare function analyzeModule(ts: typeof import('typescript'), sourceFile: ts.SourceFile, checker: ts.TypeChecker, options?: AnalyzeOptions): Analysis;
|
|
49
|
+
/**
|
|
50
|
+
* Lints a script source string and returns positioned diagnostics.
|
|
51
|
+
*
|
|
52
|
+
* @param ts The TypeScript module (compiler API).
|
|
53
|
+
* @param source The script source to lint.
|
|
54
|
+
* @param options {@link AnalyzeOptions} — host facts the rules need (the built-in function names).
|
|
55
|
+
*
|
|
56
|
+
* @remarks
|
|
57
|
+
* This is the public, environment-agnostic entry point for adapters (Monaco markers, the `sheetxl
|
|
58
|
+
* lint` CLI, a VSCode language-service plugin). It builds a lightweight, emit-free program — our
|
|
59
|
+
* rules match type names by text, so the ambient SheetXL types do not need to be loaded here.
|
|
60
|
+
* TypeScript's own type checking is layered separately by each editor's TS worker.
|
|
61
|
+
*/
|
|
62
|
+
export declare function lintScript(ts: typeof import('typescript'), source: string, options?: AnalyzeOptions): Diagnostic[];
|
|
63
|
+
//# sourceMappingURL=Linter.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loads a compiled module string and returns its namespace (the executor side of scripting).
|
|
3
|
+
*
|
|
4
|
+
* This is the public, environment-agnostic entry point. The actual loading is environment-split
|
|
5
|
+
* behind the internal `@sheetxl/scripting/loader` conditional export - a real temp `.mjs` under Node
|
|
6
|
+
* (breakpoints, Bun, Vitest), a `data:` URL in the browser.
|
|
7
|
+
*
|
|
8
|
+
* The explicit `Promise<any>` signature is deliberate: it keeps this module's generated declaration
|
|
9
|
+
* self-contained, so cross-package consumers (the sdk runtime) depend only on `@sheetxl/scripting`'s
|
|
10
|
+
* public types - never on the internal loader's per-file declarations (which avoids a composite
|
|
11
|
+
* project-reference build error).
|
|
12
|
+
*
|
|
13
|
+
* @param compiled The compiled JavaScript module source.
|
|
14
|
+
* @param options Optional `sourceMap` to append for debugging.
|
|
15
|
+
*/
|
|
16
|
+
export declare function loadCompiledModule(compiled: string, options?: {
|
|
17
|
+
sourceMap?: string;
|
|
18
|
+
}): Promise<any>;
|
|
19
|
+
//# sourceMappingURL=loadCompiledModule.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser/`default` half of the `@sheetxl/scripting/loader` conditional export.
|
|
3
|
+
*
|
|
4
|
+
* Loads a compiled module string by importing it as a `data:` URL. The `new Function` indirection
|
|
5
|
+
* keeps bundlers (webpack/vite) from statically analyzing the dynamic import. CSP-aware and the path
|
|
6
|
+
* used when applying a script to live client state.
|
|
7
|
+
*/
|
|
8
|
+
export declare function loadCompiledModule(compiled: string, options?: {
|
|
9
|
+
sourceMap?: string;
|
|
10
|
+
}): Promise<any>;
|
|
11
|
+
//# sourceMappingURL=moduleLoader.browser.d.ts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node half of the `@sheetxl/scripting/loader` conditional export.
|
|
3
|
+
*
|
|
4
|
+
* Writes the compiled module to a uniquely-named `.mjs` in the OS temp dir and imports the file URL.
|
|
5
|
+
* Unlike a `data:` URL this gives the module a real path - so breakpoints and stack traces resolve
|
|
6
|
+
* in vscode - and it runs under Bun and Vitest's VM (where `data:` dynamic imports fail).
|
|
7
|
+
*
|
|
8
|
+
* The file is intentionally left on disk: the module's functions execute lazily (a macro runs when
|
|
9
|
+
* invoked, not at import), so a debugger must still be able to resolve the source afterwards. The OS
|
|
10
|
+
* reclaims its temp dir; session-scoped cleanup can be tied to module disposal later.
|
|
11
|
+
*/
|
|
12
|
+
export declare function loadCompiledModule(compiled: string, options?: {
|
|
13
|
+
sourceMap?: string;
|
|
14
|
+
}): Promise<any>;
|
|
15
|
+
//# sourceMappingURL=moduleLoader.node.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Simple logging interface that matches console methods
|
|
3
|
+
* This removes the dependency on Vite's Logger
|
|
4
|
+
*/
|
|
5
|
+
export interface SimpleLogger {
|
|
6
|
+
info(message: string): void;
|
|
7
|
+
warn(message: string): void;
|
|
8
|
+
error(message: string): void;
|
|
9
|
+
}
|
|
10
|
+
export interface CompileOptions {
|
|
11
|
+
inputDir: string;
|
|
12
|
+
outputDir: string;
|
|
13
|
+
/** Simple logger interface */
|
|
14
|
+
logger?: SimpleLogger;
|
|
15
|
+
}
|
|
16
|
+
export declare function compile(options: CompileOptions): Promise<any>;
|
|
17
|
+
//# sourceMappingURL=generate.d.ts.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Plugin } from 'vite';
|
|
2
|
+
/**
|
|
3
|
+
* Vite plugin to compile built-in formulas from TypeScript files.
|
|
4
|
+
* This plugin generates a single `index.ts` file containing all built-in formulas
|
|
5
|
+
* and watches for changes in the input directory during development.
|
|
6
|
+
*/
|
|
7
|
+
export interface FormulaCompilerPluginOptions {
|
|
8
|
+
/** Directory containing input TypeScript files (relative to {@link root}). */
|
|
9
|
+
inputDir: string;
|
|
10
|
+
/** Directory to output compiled files (relative to {@link root}). */
|
|
11
|
+
outputDir: string;
|
|
12
|
+
/** Base for resolving {@link inputDir}/{@link outputDir}. Defaults to the Vite project root (`process.cwd()`). */
|
|
13
|
+
root?: string;
|
|
14
|
+
/** Whether to run compiler during build (default: true) */
|
|
15
|
+
runOnBuild?: boolean;
|
|
16
|
+
/** Whether to watch for file changes in dev mode (default: true) */
|
|
17
|
+
watchInDev?: boolean;
|
|
18
|
+
/** Enable verbose logging (default: false) */
|
|
19
|
+
verbose?: boolean;
|
|
20
|
+
/** Skip if output is newer than input (default: false) */
|
|
21
|
+
skipIfUpCurrent?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export declare function FormulaCompilerPlugin(options: FormulaCompilerPluginOptions): Plugin;
|
|
24
|
+
//# sourceMappingURL=vite.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The global variable the compiled script reads its formula/run context from (`globalThis.__SHEETXL`).
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Language-agnostic runtime contract: the compiled script references it and any executor must match
|
|
6
|
+
* it.
|
|
7
|
+
*/
|
|
8
|
+
export declare const GLOBAL_CONTEXT_VARIABLE = "__SHEETXL";
|
|
9
|
+
//# sourceMappingURL=Constants.d.ts.map
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Definition for JSDoc tags the script compiler understands.
|
|
3
|
+
*/
|
|
4
|
+
export interface DocTagDef {
|
|
5
|
+
/** Canonical tag name, lower-case, without the leading `@`. */
|
|
6
|
+
readonly name: string;
|
|
7
|
+
/** Alternate spellings (lower-case) that resolve to this tag, e.g. `return` for `returns`. */
|
|
8
|
+
readonly aliases?: readonly string[];
|
|
9
|
+
/** Human readable description (shown in editor autocomplete). */
|
|
10
|
+
readonly description: string;
|
|
11
|
+
/**
|
|
12
|
+
* Whether the tag is meaningful with no trailing value (e.g. `@deprecated`, `@hidden`).
|
|
13
|
+
* Non-standalone tags require a value/comment.
|
|
14
|
+
*/
|
|
15
|
+
readonly standalone?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Where the tag originates - `'sheetxl'` for SheetXL-specific tags, `'jsdoc'` for standard ones.
|
|
18
|
+
* Used as the autocomplete detail label.
|
|
19
|
+
*/
|
|
20
|
+
readonly group: 'sheetxl' | 'jsdoc';
|
|
21
|
+
/**
|
|
22
|
+
* Optional editor insertion snippet (without the leading `@`); may contain `${n:placeholder}`
|
|
23
|
+
* fields. Falls back to {@link JSDocTagDef.name} when omitted.
|
|
24
|
+
*/
|
|
25
|
+
readonly snippet?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The recognized Doc tags.
|
|
29
|
+
*
|
|
30
|
+
* @remarks
|
|
31
|
+
* Keep aligned with the tag handling in {@link analyzeModule}.
|
|
32
|
+
*/
|
|
33
|
+
export declare const DocTags: readonly DocTagDef[];
|
|
34
|
+
/**
|
|
35
|
+
* Resolves a tag definition by name or alias (case-insensitive).
|
|
36
|
+
*
|
|
37
|
+
* @param name The tag name with or without a leading `@`.
|
|
38
|
+
*/
|
|
39
|
+
export declare function getJSDocTag(name: string): DocTagDef | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* Whether a tag is meaningful with no trailing value (e.g. `@deprecated`, `@hidden`).
|
|
42
|
+
*
|
|
43
|
+
* @param name The tag name with or without a leading `@`.
|
|
44
|
+
*/
|
|
45
|
+
export declare function isStandaloneJSDocTag(name: string): boolean;
|
|
46
|
+
//# sourceMappingURL=DocTags.d.ts.map
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { CompiledModule } from './CompiledModule';
|
|
2
|
+
import { Diagnostic } from './Diagnostic';
|
|
3
|
+
/**
|
|
4
|
+
* Options for compiling a script module.
|
|
5
|
+
*/
|
|
6
|
+
export interface CompileOptions {
|
|
7
|
+
/**
|
|
8
|
+
* The source code of the script module to compile.
|
|
9
|
+
*/
|
|
10
|
+
source: string;
|
|
11
|
+
/**
|
|
12
|
+
* If true, this will not include the bundle in the compiled module.
|
|
13
|
+
*
|
|
14
|
+
* @remarks
|
|
15
|
+
* This is useful for validation
|
|
16
|
+
*/
|
|
17
|
+
disableBundle?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* If true, this will not include the source map in the compiled module.
|
|
20
|
+
*/
|
|
21
|
+
disableSourceMap?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* For validation
|
|
24
|
+
*/
|
|
25
|
+
declarationsOnly?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* The commit ID for the compilation.
|
|
28
|
+
*/
|
|
29
|
+
commitId?: string;
|
|
30
|
+
/**
|
|
31
|
+
* The names of the host's built-in functions, so a calculation function that takes one can be
|
|
32
|
+
* reported here rather than at registration.
|
|
33
|
+
*
|
|
34
|
+
* @remarks
|
|
35
|
+
* Supplied by the caller because this package has no registry of its own: the names come from
|
|
36
|
+
* wherever the script will run (a workbook's calculation engine). Omitted, the rule simply does
|
|
37
|
+
* not run - the collision is still refused when the function is registered, just later and
|
|
38
|
+
* without a position. Compared case-insensitively.
|
|
39
|
+
*/
|
|
40
|
+
builtInNames?: readonly string[];
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The result of a compile operation: the compiled artifact plus this compile's positioned
|
|
44
|
+
* diagnostics.
|
|
45
|
+
*
|
|
46
|
+
* @remarks
|
|
47
|
+
* Diagnostics live HERE — on the transient operation result — NOT on the persisted
|
|
48
|
+
* {@link CompiledModule}/`.sxlm` artifact (they are a function of the source and recomputable).
|
|
49
|
+
* When any diagnostic has `severity: 'error'`, `module.compiled` is omitted and the artifact must
|
|
50
|
+
* not run. Conceptually mirrors a run's `RunResults` (outcome + diagnostics).
|
|
51
|
+
*/
|
|
52
|
+
export interface CompileResult {
|
|
53
|
+
/** The compiled artifact, or `null` when there was no source to compile. */
|
|
54
|
+
module: CompiledModule | null;
|
|
55
|
+
/** Positioned diagnostics (errors + warnings) produced by this compile. */
|
|
56
|
+
diagnostics: Diagnostic[];
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=CompileOptions.d.ts.map
|