@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
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { IFunction } from '@sheetxl/primitives';
|
|
2
|
+
/**
|
|
3
|
+
* A compiled collection of functions — the serialized form of one module.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* This is the on-disk shape of a `.sxlm` macro artifact and the wire shape shipped from the MCP
|
|
7
|
+
* server to the VS Code webview. It is a self-contained container: human-readable {@link source},
|
|
8
|
+
* runnable {@link compiled} JS, a {@link sourceMap}, and the {@link functions} declarations. Aliased
|
|
9
|
+
* as `IModule.JSON` in the SDK. Produced by `ScriptCompiler.compile` (Node, which returns
|
|
10
|
+
* it inside a {@link CompileResult} alongside diagnostics) and executed compiler-free via
|
|
11
|
+
* `loadCompiledModule`. Compile diagnostics are NOT part of this artifact — they live on
|
|
12
|
+
* {@link CompileResult}. See `private-assets/design/SXLM-FORMAT.md` for the normative reference.
|
|
13
|
+
*/
|
|
14
|
+
export interface CompiledModule {
|
|
15
|
+
/**
|
|
16
|
+
* An array of `Declaration` and `Description pairs describing the functions within the script.
|
|
17
|
+
*
|
|
18
|
+
* @remarks
|
|
19
|
+
* This array can be empty. It is possible that a script might contain only comments or other non-executable code.
|
|
20
|
+
*/
|
|
21
|
+
functions: [IFunction.DeclarationJSON, IFunction.DescriptorJSON][];
|
|
22
|
+
/**
|
|
23
|
+
* The human-readable source code of the script.
|
|
24
|
+
*
|
|
25
|
+
* @remarks
|
|
26
|
+
* If this property is missing, the script will not be displayed but the 'actions' will still be available if `compiled` is present.
|
|
27
|
+
*/
|
|
28
|
+
source?: string;
|
|
29
|
+
/**
|
|
30
|
+
* The compiled or pre-processed version of the script, ready for execution.
|
|
31
|
+
*
|
|
32
|
+
* @remarks
|
|
33
|
+
* If this property is missing, the script will be compiled on demand if possible.
|
|
34
|
+
*/
|
|
35
|
+
compiled?: string;
|
|
36
|
+
/**
|
|
37
|
+
* If provided this will include a source map for the compiled script.
|
|
38
|
+
*/
|
|
39
|
+
sourceMap?: string;
|
|
40
|
+
/**
|
|
41
|
+
* The language the function is written in.
|
|
42
|
+
*
|
|
43
|
+
* @defaultValue typescript
|
|
44
|
+
*/
|
|
45
|
+
language?: string;
|
|
46
|
+
/**
|
|
47
|
+
* The name of the module.
|
|
48
|
+
*/
|
|
49
|
+
name?: string;
|
|
50
|
+
/**
|
|
51
|
+
* A unique identifier for the function (e.g., a Git commit ID).
|
|
52
|
+
* // https://stackoverflow.com/questions/29106996/what-is-a-git-commit-id
|
|
53
|
+
*/
|
|
54
|
+
commitId?: string;
|
|
55
|
+
/**
|
|
56
|
+
* The name of the function to run automatically when the script is loaded.
|
|
57
|
+
*/
|
|
58
|
+
autoRun?: string;
|
|
59
|
+
/**
|
|
60
|
+
* ** NOT IMPLEMENTED **
|
|
61
|
+
* Available in functions via the 'this' value.
|
|
62
|
+
* Will auto persist values on save.
|
|
63
|
+
*
|
|
64
|
+
* TODO - this doesn't belong here.
|
|
65
|
+
* Create a new interface for session state.
|
|
66
|
+
* TODO - rename to sessionData
|
|
67
|
+
*/
|
|
68
|
+
scope?: any;
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=CompiledModule.d.ts.map
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Severity of a {@link Diagnostic}.
|
|
3
|
+
*
|
|
4
|
+
* - `error` blocks compilation (the script will not run).
|
|
5
|
+
* - `warning` allows compilation but nudges authoring quality (missing docs, etc.).
|
|
6
|
+
*/
|
|
7
|
+
export type DiagnosticSeverity = 'error' | 'warning';
|
|
8
|
+
/**
|
|
9
|
+
* A positioned diagnostic produced by the SheetXL script linter.
|
|
10
|
+
*
|
|
11
|
+
* @remarks
|
|
12
|
+
* These are environment-agnostic (TypeScript compiler API only) so the same shape can be adapted to
|
|
13
|
+
* Monaco markers, a CLI reporter, or a VSCode language-service plugin. Positions are character
|
|
14
|
+
* offsets into the original source so adapters can map them to the surface they care about.
|
|
15
|
+
*/
|
|
16
|
+
export interface Diagnostic {
|
|
17
|
+
/**
|
|
18
|
+
* Zero-based character offset of the start of the offending node (`node.getStart()`).
|
|
19
|
+
*/
|
|
20
|
+
start: number;
|
|
21
|
+
/**
|
|
22
|
+
* Width of the offending node in characters (`node.getWidth()`).
|
|
23
|
+
*/
|
|
24
|
+
length: number;
|
|
25
|
+
/**
|
|
26
|
+
* Severity of the diagnostic.
|
|
27
|
+
*/
|
|
28
|
+
severity: DiagnosticSeverity;
|
|
29
|
+
/**
|
|
30
|
+
* A stable diagnostic code, e.g. `'SXL2001'`.
|
|
31
|
+
*
|
|
32
|
+
* @remarks
|
|
33
|
+
* Codes are stable across releases so adapters, docs, and agents can key off them. The leading
|
|
34
|
+
* `SXL` distinguishes our semantic rules from TypeScript's own `TS####` diagnostics. See
|
|
35
|
+
* {@link DiagnosticCode}.
|
|
36
|
+
*/
|
|
37
|
+
code: string;
|
|
38
|
+
/**
|
|
39
|
+
* A human-readable, didactic message.
|
|
40
|
+
*
|
|
41
|
+
* @remarks
|
|
42
|
+
* Messages are written to be machine-friendly: for type errors they spell out the *allowed set*.
|
|
43
|
+
* Agents iterate against this text, so message quality directly reduces iteration count.
|
|
44
|
+
*/
|
|
45
|
+
message: string;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The catalog of stable diagnostic codes emitted by the linter.
|
|
49
|
+
*
|
|
50
|
+
* @remarks
|
|
51
|
+
* `SXL1###` structural, `SXL2###` type rules, `SXL3###` module rules, `SXL9###` quality warnings.
|
|
52
|
+
* Codes are append-only — never reuse a retired number.
|
|
53
|
+
*/
|
|
54
|
+
export declare const DiagnosticCode: Readonly<{
|
|
55
|
+
/** Exported function has no body. */
|
|
56
|
+
readonly NoBody: "SXL1001";
|
|
57
|
+
/** Anonymous exported function is not allowed. */
|
|
58
|
+
readonly Anonymous: "SXL1002";
|
|
59
|
+
/** Internal parse failure while analyzing the module. */
|
|
60
|
+
readonly ParseError: "SXL1003";
|
|
61
|
+
/** Invalid parameter type. */
|
|
62
|
+
readonly InvalidParamType: "SXL2001";
|
|
63
|
+
/** Invalid return type. */
|
|
64
|
+
readonly InvalidReturnType: "SXL2002";
|
|
65
|
+
/** `undefined` / `null` / `void` is not valid as an input type. */
|
|
66
|
+
readonly UndefinedInput: "SXL2003";
|
|
67
|
+
/** A type annotation is required but missing. */
|
|
68
|
+
readonly MissingType: "SXL2004";
|
|
69
|
+
/** An `Array` must be typed (e.g. `number[]`, not bare `[]`). */
|
|
70
|
+
readonly UntypedArray: "SXL2005";
|
|
71
|
+
/** A generic type must be supplied exactly one type argument. */
|
|
72
|
+
readonly GenericArity: "SXL2006";
|
|
73
|
+
/** A return type cannot combine multiple modifiers (e.g. async + stream). */
|
|
74
|
+
readonly MultipleModifiers: "SXL2007";
|
|
75
|
+
/** A context parameter must be the first parameter. */
|
|
76
|
+
readonly ContextNotFirst: "SXL2010";
|
|
77
|
+
/** More than one `Lambda` parameter. */
|
|
78
|
+
readonly MultipleLambda: "SXL2020";
|
|
79
|
+
/** A `Lambda` parameter must be the last parameter. */
|
|
80
|
+
readonly LambdaNotLast: "SXL2021";
|
|
81
|
+
/** A `Lambda` parameter/return scalar type mismatch. */
|
|
82
|
+
readonly LambdaScalarMismatch: "SXL2022";
|
|
83
|
+
/** `Lambda` is not valid as a return type. */
|
|
84
|
+
readonly LambdaReturn: "SXL2023";
|
|
85
|
+
/** A bare function type is not valid as a return type. */
|
|
86
|
+
readonly FunctionReturn: "SXL2024";
|
|
87
|
+
/** A `Lambda` function type has the wrong number of parameters. */
|
|
88
|
+
readonly LambdaArity: "SXL2025";
|
|
89
|
+
/** Arrays of more than 2 dimensions are not supported. */
|
|
90
|
+
readonly ArrayDepth: "SXL2030";
|
|
91
|
+
/** `Repeating<T>` used somewhere it cannot be (a return type, a rest parameter, nested in an array). */
|
|
92
|
+
readonly RepeatingPosition: "SXL2040";
|
|
93
|
+
/** More than one `Repeating<T>` parameter. */
|
|
94
|
+
readonly MultipleRepeating: "SXL2041";
|
|
95
|
+
/** A `Repeating<T>` group's slots are malformed (unlabelled tuple member, or a 1-element tuple). */
|
|
96
|
+
readonly RepeatingSlots: "SXL2042";
|
|
97
|
+
/** An optional parameter/slot where a repeating group does not allow one. */
|
|
98
|
+
readonly RepeatingOptional: "SXL2043";
|
|
99
|
+
/** No exported functions found in the module. */
|
|
100
|
+
readonly NoExports: "SXL3001";
|
|
101
|
+
/** A `@param` tag references a parameter that does not exist. */
|
|
102
|
+
readonly UnknownParam: "SXL3002";
|
|
103
|
+
/** A calculation function takes a built-in function's name. */
|
|
104
|
+
readonly BuiltInName: "SXL3003";
|
|
105
|
+
/** Missing `@summary` / function description. */
|
|
106
|
+
readonly MissingSummary: "SXL9001";
|
|
107
|
+
/** A `@param` is missing a description. */
|
|
108
|
+
readonly MissingParamDescription: "SXL9002";
|
|
109
|
+
/**
|
|
110
|
+
* Missing `@returns` on a non-void function.
|
|
111
|
+
* @deprecated Retained for code stability but no longer emitted - Excel-style tooltips describe
|
|
112
|
+
* behavior via the summary, so a standalone `@returns` warning is noise.
|
|
113
|
+
*/
|
|
114
|
+
readonly MissingReturns: "SXL9003";
|
|
115
|
+
}>;
|
|
116
|
+
/**
|
|
117
|
+
* Union of the stable diagnostic code string values.
|
|
118
|
+
*/
|
|
119
|
+
export type DiagnosticCode = (typeof DiagnosticCode)[keyof typeof DiagnosticCode];
|
|
120
|
+
//# sourceMappingURL=Diagnostic.d.ts.map
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { IFunction, ScalarType, Scalar, IFormulaContext } from '@sheetxl/primitives';
|
|
2
|
+
/**
|
|
3
|
+
* Type for bind signature for typed functions.
|
|
4
|
+
*/
|
|
5
|
+
export interface FunctionBinder {
|
|
6
|
+
(mapBind: Map<string, IFunction>, getContext: () => IFormulaContext, implementations: Implementations, declarations: MinifiedDeclarations, getDynamicDescriptors?: DynamicDescriptors, defaultCategory?: string): void;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The default export of a compiled formula module (produced by the FormulaCompiler): given the
|
|
10
|
+
* runtime `getContext` and a {@link FunctionBinder}, it binds its functions into `mapBind` (creating
|
|
11
|
+
* one if omitted) and returns it. This is the unit of formula registration - a consumer passes their
|
|
12
|
+
* compiled module's default export to register custom functions.
|
|
13
|
+
*/
|
|
14
|
+
export interface FunctionProvider {
|
|
15
|
+
(getContext: () => IFormulaContext, bindFn: FunctionBinder, mapBind?: Map<string, IFunction>): Map<string, IFunction>;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Minified value.
|
|
19
|
+
*/
|
|
20
|
+
export interface MinifiedValue {
|
|
21
|
+
s?: string;
|
|
22
|
+
r?: 'p' | 'r' | 'm' | '*';
|
|
23
|
+
l?: ScalarType | '*' | 'raw';
|
|
24
|
+
a?: number;
|
|
25
|
+
d?: number;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Minified params.
|
|
29
|
+
*/
|
|
30
|
+
export interface MinifiedParameter extends MinifiedValue {
|
|
31
|
+
n: string;
|
|
32
|
+
m?: '?' | '...';
|
|
33
|
+
e?: string[];
|
|
34
|
+
o?: 'accept' | 'accept-ref';
|
|
35
|
+
g?: MinifiedParameter[];
|
|
36
|
+
v?: Scalar;
|
|
37
|
+
u?: 1;
|
|
38
|
+
w?: Scalar;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The function declaration needed to autoMarshall and execute.
|
|
42
|
+
*/
|
|
43
|
+
export interface MinifiedDeclaration {
|
|
44
|
+
fn?: string;
|
|
45
|
+
c?: boolean;
|
|
46
|
+
p?: MinifiedParameter[];
|
|
47
|
+
r?: MinifiedValue;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The descriptor used for a function
|
|
51
|
+
*/
|
|
52
|
+
export interface MinifiedDescriptor {
|
|
53
|
+
s?: string;
|
|
54
|
+
c?: string;
|
|
55
|
+
p?: Record<string, any>;
|
|
56
|
+
h?: string | boolean;
|
|
57
|
+
l?: [url: string, text?: string][];
|
|
58
|
+
}
|
|
59
|
+
export type MinifiedDeclarations = {
|
|
60
|
+
[name: string]: MinifiedDeclaration;
|
|
61
|
+
};
|
|
62
|
+
export interface Implementations {
|
|
63
|
+
[functionName: string]: (...args: any) => any;
|
|
64
|
+
}
|
|
65
|
+
export interface MinifiedDescriptors {
|
|
66
|
+
[name: string]: MinifiedDescriptor;
|
|
67
|
+
}
|
|
68
|
+
export interface DescriptorModule {
|
|
69
|
+
default: MinifiedDescriptors;
|
|
70
|
+
}
|
|
71
|
+
export type DynamicDescriptors = () => Promise<DescriptorModule>;
|
|
72
|
+
//# sourceMappingURL=Types.d.ts.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export interface IWorkerWrapper<TResult = any, TParams = any> {
|
|
2
|
+
start(): Promise<void>;
|
|
3
|
+
execute(params: TParams): Promise<TResult>;
|
|
4
|
+
terminate(): void;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Generic worker wrapper for use in libraries
|
|
8
|
+
* Takes a worker factory function to create the worker instance.
|
|
9
|
+
*/
|
|
10
|
+
export declare class WorkerWrapper<TResult = any, TParams = any> implements IWorkerWrapper<TResult, TParams> {
|
|
11
|
+
private _worker;
|
|
12
|
+
private _workerFactory;
|
|
13
|
+
private _nextId;
|
|
14
|
+
private _pendingRequests;
|
|
15
|
+
/**
|
|
16
|
+
* Creates a new worker
|
|
17
|
+
*
|
|
18
|
+
* @param workerFactory - Factory function to create the worker instance.
|
|
19
|
+
*/
|
|
20
|
+
constructor(workerFactory: () => Worker);
|
|
21
|
+
/**
|
|
22
|
+
* Initializes the worker if it hasn't been created yet
|
|
23
|
+
* Will throw an error if the environment does not support Web Workers.
|
|
24
|
+
*/
|
|
25
|
+
start(): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* Executes a task in the worker
|
|
28
|
+
* @param params - Parameters to pass to the worker
|
|
29
|
+
* @returns Promise that resolves with the worker result
|
|
30
|
+
*/
|
|
31
|
+
execute(params: TParams): Promise<TResult>;
|
|
32
|
+
/**
|
|
33
|
+
* Terminates the worker
|
|
34
|
+
*/
|
|
35
|
+
terminate(): void;
|
|
36
|
+
}
|
|
37
|
+
export declare class SyncWrapper<TResult = any, TParams = any> implements IWorkerWrapper<TResult, TParams> {
|
|
38
|
+
private _onExecute;
|
|
39
|
+
constructor(onExecute: (params: TParams) => Promise<TResult>);
|
|
40
|
+
execute(params: TParams): Promise<TResult>;
|
|
41
|
+
start(): Promise<void>;
|
|
42
|
+
terminate(): void;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=WorkerWrapper.d.ts.map
|