@sheetxl/scripting 0.1.96

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.
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@sheetxl/scripting",
3
+ "description": "SheetXL scripting utilities including TypeScript compilation.",
4
+ "version": "0.0.0",
5
+ "license": "SEE LICENSE IN <LICENSE>",
6
+ "type": "module",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./types/index.d.ts",
10
+ "browser": "./browser/esm/index.mjs",
11
+ "node": "./node/esm/index.mjs",
12
+ "import": "./browser/esm/index.mjs",
13
+ "require": "./browser/cjs/index.cjs"
14
+ }
15
+ },
16
+ "types": "./types/index.d.ts",
17
+ "module": "./browser/esm/index.mjs",
18
+ "main": "./browser/cjs/index.cjs",
19
+ "publishConfig": {
20
+ "access": "public"
21
+ },
22
+ "sideEffects": true,
23
+ "engines": {
24
+ "node": ">=22"
25
+ },
26
+ "engineStrict": true,
27
+ "author": "Michael T Ford",
28
+ "keywords": [
29
+ "sheetxl",
30
+ "spreadsheet",
31
+ "scripting",
32
+ "typescript"
33
+ ],
34
+ "dependencies": {
35
+ "@sheetxl/primitives": "^0.0.0",
36
+ "@sheetxl/utils": "^0.0.0",
37
+ "path-browserify": "^1.0.1"
38
+ },
39
+ "peerDependencies": {
40
+ "esbuild-wasm": "^0.25.7",
41
+ "typescript": "^5.8.3"
42
+ }
43
+ }
@@ -0,0 +1,166 @@
1
+ import { IFormulaContext } from '@sheetxl/primitives';
2
+ import { IFunction } from '@sheetxl/primitives';
3
+
4
+ /**
5
+ * Represents a compile collections of functions.
6
+ *
7
+ */
8
+ export declare interface CompiledModule {
9
+ /**
10
+ * An array of `Declaration` and `Description pairs describing the functions within the script.
11
+ *
12
+ * @remarks
13
+ * This array can be empty. It is possible that a script might contain only comments or other non-executable code.
14
+ */
15
+ functions: [IFunction.DeclarationJSON, IFunction.DescriptorJSON][];
16
+ /**
17
+ * The human-readable source code of the script.
18
+ *
19
+ * @remarks
20
+ * If this property is missing, the script will not be displayed but the 'actions' will still be available if `compiled` is present.
21
+ */
22
+ source?: string;
23
+ /**
24
+ * The compiled or pre-processed version of the script, ready for execution.
25
+ *
26
+ * @remarks
27
+ * If this property is missing, the script will be compiled on demand if possible.
28
+ */
29
+ compiled?: string;
30
+ /**
31
+ * The language the function is written in.
32
+ *
33
+ * @defaultValue typescript
34
+ */
35
+ language?: string;
36
+ /**
37
+ * The name of the module.
38
+ */
39
+ name?: string;
40
+ /**
41
+ * A unique identifier for the function (e.g., a Git commit ID).
42
+ * // https://stackoverflow.com/questions/29106996/what-is-a-git-commit-id
43
+ */
44
+ commitId?: string;
45
+ /**
46
+ * The name of the function to run automatically when the script is loaded.
47
+ */
48
+ autoRun?: string;
49
+ /**
50
+ * ** NOT IMPLEMENTED **
51
+ * Available in functions via the 'this' value.
52
+ * Will auto persist values on save.
53
+ *
54
+ * TODO - this doesn't belong here.
55
+ * Create a new interface for session state.
56
+ * TODO - rename to sessionData
57
+ */
58
+ scope?: any;
59
+ }
60
+
61
+ /**
62
+ * Options for compiling a script module.
63
+ */
64
+ export declare interface CompileOptions {
65
+ /**
66
+ * The source code of the script module to compile.
67
+ */
68
+ source: string;
69
+ /**
70
+ * If true, this will not include the bundle in the compiled module.
71
+ *
72
+ * @remarks
73
+ * This is useful for validation
74
+ */
75
+ disableBundle?: boolean;
76
+ /**
77
+ * If true, this will not include the source map in the compiled module.
78
+ */
79
+ disableSourceMap?: boolean;
80
+ /**
81
+ * For validation
82
+ */
83
+ declarationsOnly?: boolean;
84
+ /**
85
+ * The commit ID for the compilation.
86
+ */
87
+ commitId?: string;
88
+ }
89
+
90
+ /**
91
+ * The return type for Compile.
92
+ */
93
+ export declare interface CompileResults {
94
+ module: CompiledModule;
95
+ errors: any;
96
+ }
97
+
98
+ /**
99
+ * Converts a typescript string into a `CompiledModule`.
100
+ *
101
+ * @param options Optional compilation options
102
+ */
103
+ declare function compileTypescript(options: CompileOptions): Promise<CompiledModule>;
104
+
105
+ export declare interface DescriptorModule {
106
+ default: MinifiedDescriptors;
107
+ }
108
+
109
+ export declare type DynamicDescriptors = () => Promise<DescriptorModule>;
110
+
111
+ /**
112
+ * Type for bind signature for typed functions.
113
+ */
114
+ export declare interface FunctionBinder {
115
+ (mapBind: Map<string, IFunction>, getContext: () => IFormulaContext, implementations: Implementations, declarations: MinifiedDeclarations, getDynamicDescriptors?: DynamicDescriptors, defaultCategory?: string): void;
116
+ }
117
+
118
+ export declare interface Implementations {
119
+ [functionName: string]: (...args: any) => any;
120
+ }
121
+
122
+ /**
123
+ * The function declaration needed to autoMarshall and execute.
124
+ */
125
+ export declare interface MinifiedDeclaration {
126
+ fn?: string;
127
+ c?: boolean;
128
+ p?: MinifiedParameter[];
129
+ }
130
+
131
+ export declare type MinifiedDeclarations = {
132
+ [name: string]: MinifiedDeclaration;
133
+ };
134
+
135
+ /**
136
+ * The descriptor used for a function
137
+ */
138
+ export declare interface MinifiedDescriptor {
139
+ s?: string;
140
+ c?: string;
141
+ p?: Record<string, any>;
142
+ h?: string | boolean;
143
+ l?: [url: string, text?: string][];
144
+ }
145
+
146
+ export declare interface MinifiedDescriptors {
147
+ [name: string]: MinifiedDescriptor;
148
+ }
149
+
150
+ /**
151
+ * Minified params.
152
+ */
153
+ export declare interface MinifiedParameter {
154
+ n: string;
155
+ s?: string;
156
+ r?: 'r' | 'l' | 'a';
157
+ d?: number;
158
+ m?: '?' | '...';
159
+ e?: string[];
160
+ }
161
+
162
+ export declare const ScriptingUtils: Readonly<{
163
+ compileTypescript: typeof compileTypescript;
164
+ }>;
165
+
166
+ export { }
package/package.json ADDED
@@ -0,0 +1,62 @@
1
+ {
2
+ "name": "@sheetxl/scripting",
3
+ "description": "SheetXL scripting utilities including TypeScript compilation.",
4
+ "version": "0.1.96",
5
+ "license": "SEE LICENSE IN <LICENSE>",
6
+ "author": "Michael T Ford",
7
+ "private": false,
8
+ "publishConfig": {
9
+ "access": "public"
10
+ },
11
+ "files": [
12
+ "build"
13
+ ],
14
+ "type": "module",
15
+ "exports": {
16
+ ".": {
17
+ "development": "./src/index.ts",
18
+ "types": "./build/types/index.d.ts",
19
+ "import": {
20
+ "node": "./build/node/esm/index.mjs",
21
+ "browser": "./build/browser/esm/index.mjs",
22
+ "default": "./build/browser/esm/index.mjs"
23
+ }
24
+ },
25
+ "./lib/esbuild": {
26
+ "node": "./src/lib/esbuild/esbuild.node.js",
27
+ "browser": "./src/lib/esbuild/esbuild.browser.js",
28
+ "default": "./src/lib/esbuild/esbuild.node.js"
29
+ },
30
+ "./lib/typescript": {
31
+ "node": "./src/lib/typescript/typescript.node.js",
32
+ "browser": "./src/lib/typescript/typescript.browser.js",
33
+ "default": "./src/lib/typescript/typescript.node.js"
34
+ }
35
+ },
36
+ "scripts": {
37
+ "build:node": "cross-env BUILD_ENV=node vite build",
38
+ "build:browser": "vite build",
39
+ "build": "pnpm run build:node && pnpm run build:browser",
40
+ "clean": "rimraf ./build",
41
+ "clean:all": "git clean -fdX .",
42
+ "lint": "eslint .",
43
+ "test": "vitest"
44
+ },
45
+ "peerDependencies": {
46
+ "esbuild-wasm": "^0.25.7",
47
+ "typescript": "^5.8.3"
48
+ },
49
+ "dependencies": {
50
+ "@sheetxl/primitives": "0.0.0",
51
+ "@sheetxl/utils": "0.1.96",
52
+ "path-browserify": "^1.0.1"
53
+ },
54
+ "sideEffects": true,
55
+ "keywords": [
56
+ "sheetxl",
57
+ "spreadsheet",
58
+ "scripting",
59
+ "typescript"
60
+ ],
61
+ "gitHead": "59c9cce471e1b296d1d9196cd06a53a4e53ff4b8"
62
+ }