@sheetxl/scripting 0.7.21 → 0.7.23
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 +1 -1
- package/browser/cjs/{B0y4r3JJPPSwiDzx.cjs → BUf1tdk0B_mTUmGd.cjs} +1 -1
- package/browser/cjs/{CGLLj80MYA2hDUWX.cjs → C20Ff8j9vP0krR67.cjs} +325 -324
- package/browser/cjs/{CUcC81sgg70TCSkb.cjs → CShrycXagCsrhyME.cjs} +2 -2
- package/browser/cjs/CtjpyrhMvnMoSf9_.cjs +32 -0
- package/browser/cjs/{DR9eQnRTjdCvZ_vn.cjs → FOIXxvmqvNm2Ed4B.cjs} +1 -1
- package/browser/cjs/index.cjs +2 -2
- package/browser/esm/B-JtS4RbGUTBG1jc.mjs +266 -0
- package/browser/esm/{CWnC_tpttjXTMAYH.mjs → BbYnTNuvE6r2UxHt.mjs} +2 -2
- package/browser/esm/{Dfs-JW1Cpyj6GJ8P.mjs → BuowWyjSVKsr8H5b.mjs} +325 -324
- package/browser/esm/{D9QqdtRf0J6jc-i7.mjs → D5Xp35M-Yk7Q7Hu-.mjs} +1 -1
- package/browser/esm/{DpMJmUGhnNbeI2fN.mjs → DHF3lqDKT7Ee1EGe.mjs} +1 -1
- package/browser/esm/index.mjs +2 -2
- package/node/esm/{DL3QM-qR0v00NdZZ.mjs → BokJMOv4MdvINCZO.mjs} +1 -1
- package/node/esm/{u4BUV-OpkSGdvi-w.mjs → CTkRFYwgZIPVcECE.mjs} +1 -1
- package/node/esm/{CLf-vRuFGkk8X4S9.mjs → CzeXjDr8qF2U6KrQ.mjs} +2 -2
- package/node/esm/{CQR30SbeLa27Szfg.mjs → G76kmT1XS0D7becC.mjs} +325 -324
- package/node/esm/WOl2mP9qGwcrVhp5.mjs +266 -0
- package/node/esm/index.mjs +2 -2
- package/package.json +3 -3
- package/browser/cjs/CTIIZ0KnyksL075e.cjs +0 -32
- package/browser/esm/C3Kam_ffnenXH9Ry.mjs +0 -264
- package/node/esm/Bk7d3p9VfcJCsNVL.mjs +0 -264
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";/**
|
|
2
|
-
* @license @sheetxl/scripting - Scripting - Scripting engine for Macros and formulas; includes TypeScript and EsBuild. - v0.7.
|
|
2
|
+
* @license @sheetxl/scripting - Scripting - Scripting engine for Macros and formulas; includes TypeScript and EsBuild. - v0.7.23
|
|
3
3
|
*
|
|
4
4
|
* (C) 2025-present SheetXL Inc. & Michael T. Ford
|
|
5
5
|
* License: The license can be found at https://www.sheetxl.com/license.
|
|
6
|
-
*/Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});exports.TypeScriptCompiler=class{constructor(r={}){this.workerWrapper=null}async getWorkerWrapper(){if(this.workerWrapper)return this.workerWrapper;const{createCompilerWorker:r}=await Promise.resolve().then(()=>require("./
|
|
6
|
+
*/Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});exports.TypeScriptCompiler=class{constructor(r={}){this.workerWrapper=null}async getWorkerWrapper(){if(this.workerWrapper)return this.workerWrapper;const{createCompilerWorker:r}=await Promise.resolve().then(()=>require("./C20Ff8j9vP0krR67.cjs"));return this.workerWrapper=await r(),this.workerWrapper}async compileModule(r){try{return(await this.getWorkerWrapper()).execute(r)}catch(e){throw console.error("Failed to compile using worker:",e),e}}terminate(){this.workerWrapper?.terminate(),this.workerWrapper=null}};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";/**
|
|
2
|
+
* @license @sheetxl/scripting - Scripting - Scripting engine for Macros and formulas; includes TypeScript and EsBuild. - v0.7.23
|
|
3
|
+
*
|
|
4
|
+
* (C) 2025-present SheetXL Inc. & Michael T. Ford
|
|
5
|
+
* License: The license can be found at https://www.sheetxl.com/license.
|
|
6
|
+
*/Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const F=require("@sheetxl/primitives"),le=require("@sheetxl/utils");let L=null,q=null;const se={compilerOptions:{target:"esnext"}};async function ce(h,x,b="/script.js",w="__SHEETXL"){try{const K=await(async function(){if(L)return L;if(q){if(await q,!L)throw new Error("ESBuild initialization promise resolved, but instance is not available.");return L}let p,T;q=new Promise((a,S)=>{p=a,T=S});try{const{initialize:a}=await Promise.resolve().then(()=>require("./FOIXxvmqvNm2Ed4B.cjs"));return L=await a(),p(),L}catch(a){throw console.error("Failed to import or initialize esbuild:",a),q=null,T(a),a}})(),O="@sheetxl/primitives",n=`
|
|
7
|
+
export const FormulaContext = globalThis.${w}?.FormulaContext;
|
|
8
|
+
export const ScalarType = globalThis.${w}?.ScalarType;
|
|
9
|
+
export const Observable = globalThis.${w}?.Observable;
|
|
10
|
+
export const IRange = globalThis.${w}?.IRange;
|
|
11
|
+
export const FormulaError = globalThis.${w}?.FormulaError;
|
|
12
|
+
// Add more exports as needed
|
|
13
|
+
`,C={name:"sheetxl-esbuild-in-memory",setup(p){const T="sheetxl-"+new Date().getTime();p.onResolve({filter:new RegExp(`^(${b.replace("/","\\/")}|${O})$`)},a=>({path:a.path,namespace:T})),p.onResolve({filter:/.*/},a=>{if(a.namespace!==T)return console.warn(`esbuild: Treating import "${a.path}" as external.`),{path:a.path,external:!0}}),p.onLoad({filter:/.*/,namespace:T},a=>{let S;if(a.path===b)S=x;else{if(a.path!==O)return{errors:[{text:`Cannot load unknown path in ${T}: ${a.path}`}]};S=n}return{contents:S,loader:"ts"}})}},y=await K.build({entryPoints:[b],bundle:!0,write:!1,format:"esm",plugins:[C],sourcemap:"inline",tsconfigRaw:se,minify:!0,platform:"neutral"});if(y.outputFiles&&y.outputFiles.length>0)return y.outputFiles[0].text;throw y.errors&&y.errors.length>0?new Error(`esbuild bundling failed: ${y.errors.map(p=>p.text).join(`
|
|
14
|
+
`)}`):new Error("esbuild did not produce an output file.")}catch(K){throw console.error("esbuild bundling process failed:",K),K}}const de=async()=>`
|
|
15
|
+
interface FirstTest {
|
|
16
|
+
isTrue?: boolean;
|
|
17
|
+
}
|
|
18
|
+
`,ee=new Map([["IReferenceRange","r"],["IRange","l"]]),te=new Map([["IWorkbook","workbook"],["ISheet","sheet"],["ICellRanges","ranges"],["ICellRange","range"],["IFormulaContext","context"]]),X=(h,x)=>{Array.from(x.keys()).forEach(b=>{const w=x.get(b);x.set(`${h}.${b}`,w)})},ue=new Map([["Scalar","*"],["FormulaError.Known",F.ScalarType.Error],["Date","Date"],["JSON","JSON"]]),pe=new Map([]),_="SheetXL";X(_,ee),X(_,te),X(_,pe);const me=new Map([["Promise",()=>({async:!0})],["Observable",()=>({stream:!0})]]);let B=null;async function fe(){if(B)return B;try{return await(await Promise.resolve().then(()=>require("./BUf1tdk0B_mTUmGd.cjs"))).initialize()}catch(h){throw B=null,h}finally{B=null}}exports.compileModule=async function(h){const x=h?.source??null;if(!x)return null;const b=(h.disableBundle||h.declarationsOnly)??!1,w=[de(),fe()],K=await Promise.all(w),O=K[0],n=K[1];let C="",y=null;const p=[],T={allowJs:!0,declaration:!1,sourceMap:!1,inlineSourceMap:!1,inlineSources:!1,isolatedModules:!0,preserveConstEnums:!1,module:99,noResolve:!0,emitDeclarationOnly:!1,target:n.ScriptTarget.ES2020},a="script",S=`${a}.ts`,H="lib.d.ts",W="global.d.ts",M={[S]:x,[H]:`
|
|
19
|
+
/**
|
|
20
|
+
* Represents the completion of an asynchronous operation
|
|
21
|
+
*/
|
|
22
|
+
interface Promise<T> {
|
|
23
|
+
/**
|
|
24
|
+
* Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The
|
|
25
|
+
* resolved value cannot be modified from the callback.
|
|
26
|
+
* @param onfinally The callback to execute when the Promise is settled (fulfilled or rejected).
|
|
27
|
+
* @returns A Promise for the completion of the callback.
|
|
28
|
+
*/
|
|
29
|
+
finally(onfinally?: (() => void) | undefined | null): Promise<T>;
|
|
30
|
+
}
|
|
31
|
+
`,[W]:O},ne={getSourceFile:(e,t,u,m)=>n.createSourceFile(e,M[e],n.ScriptTarget.Latest,!0),fileExists:e=>M[e]!==void 0,readFile:e=>M[e],writeFile:(e,t)=>{M[e]=t},getCurrentDirectory:()=>"./",getCanonicalFileName:e=>e,useCaseSensitiveFileNames:()=>!0,getDefaultLibFileName:e=>H,getNewLine:()=>`
|
|
32
|
+
`},J=n.createProgram([S,W],T,ne),A=J.getTypeChecker(),re=J.getSourceFile(S),G=J.emit();G.diagnostics.length>0&&console.warn(G.diagnostics),C=M[`${a}.js`];const I=(e,t,u,m)=>{if(e){if(e.kind===n.SyntaxKind.NumberKeyword)t.scalar=F.ScalarType.Number;else if(e.kind===n.SyntaxKind.StringKeyword)t.scalar=F.ScalarType.String;else if(e.kind===n.SyntaxKind.BooleanKeyword)t.scalar=F.ScalarType.Boolean;else if(e.kind===n.SyntaxKind.UndefinedKeyword||e.kind===n.SyntaxKind.NullKeyword||e.kind===n.SyntaxKind.VoidKeyword){if(m)return void k(e,new Error(`'undefined' is not a valid type for input: '${e?.parent?.name?.escapedText}'.`));t.scalar=F.ScalarType.Null}else if(e.kind===n.SyntaxKind.BigIntKeyword)t.scalar=F.ScalarType.Number;else if(e.kind===n.SyntaxKind.AnyKeyword)t.scalar=F.ScalarType.Null;else if(e.kind===n.SyntaxKind.ArrayType){const o=e.elementType;if(!o)return void k(e,new Error(`'Array' must be typed: '${e?.parent?.name?.escapedText}'.`));t.arrayDepth=(t.arrayDepth??0)+1,I(o,t,u,m)}else if(e.kind!==n.SyntaxKind.TupleType){if(e.kind===n.SyntaxKind.TypeReference){const o=e.typeName?.getText?.()??null,R=ee.get(o);let E=!1;R&&(t.range=R,E=!0);const D=ue.get(o);if(D&&(t.scalar=D),D!==void 0&&(E=!0),m){const r=te.get(o);if(r)return r}else{const r=me.get(o);if(r){const l={...t,...r()};let g=0;if(l.async&&g++,l.stream&&g++,g>1)return void k(e,new Error(`'${o}' cannot have multiple modifiers: '${e?.parent?.name?.escapedText}'.`));t=l,E=!0}}if(!E)return void k("node",new Error(`'${o}' is not a valid type: '${e?.parent?.name?.escapedText}'.`));const c=e.typeArguments;if(c){if(c.length!==1)return void k(e,new Error(`'${o}' must be typed with exactly 1 type: '${e?.parent?.name?.escapedText}'.`));I(c[0],t,u,m)}}}}else k(e,new Error(`Type is not defined for '${t?.name??"return"}'.`))},z=[],k=(e,t)=>{z.push(t)};if(n.forEachChild(re,e=>{if((t=>(n.getCombinedModifierFlags(t)&n.ModifierFlags.Export)!==0)(e)&&n.isFunctionDeclaration(e)){const t={},u={parameters:{}},m=e?.name?.getText();try{t.name=m;const o=A.getSymbolAtLocation(e.name).getDocumentationComment(A);if(o&&o.length>0&&o[0].text){let c=o[0].text;c=c.replace(/[\r\n]+/g,"\\n").trim(),u.summary=c}const R={};I(e.type,R,t,!1),t.returnType=R;const E={};(c=>(n.getCombinedModifierFlags(c)&n.ModifierFlags.Default)!==0)(e)&&(E.default=!0,y=m),Object.keys(E).length>0&&(t.behavior=E),t.parameters=[];const D=new Map;for(let c=0;c<e.parameters.length;c++){const r=e.parameters[c],l={};l.name=r.name?.getText();const g=I(r.type,l,t,!0);if(g){if(t.parameters.length!==0){const s=e?.parent,i=s?.name?.getText();return void k(e,new Error(`'${t.name}' contexts must be the first parameter: '${i}'.`))}t.context=g;continue}let P;if((r.initializer!==void 0&&r.initializer!==null||r.questionToken!==void 0&&r.questionToken!==null)&&(l.optional=!0,r.initializer))try{P=r.initializer.kind===n.SyntaxKind.StringLiteral?r.initializer.text:r.initializer.kind===n.SyntaxKind.NumericLiteral?parseFloat(r.initializer.text):r.initializer.kind===n.SyntaxKind.TrueKeyword||r.initializer.kind===n.SyntaxKind.FalseKeyword?r.initializer.kind===n.SyntaxKind.TrueKeyword:r.initializer.kind===n.SyntaxKind.NullKeyword?null:r.initializer.kind===n.SyntaxKind.ObjectLiteralExpression||r.initializer.kind===n.SyntaxKind.ArrayLiteralExpression?r.initializer.getText():r.initializer.getText?.()}catch(s){console.warn(`Couldn't extract default value for parameter '${l.name}'`,s)}r.dotDotDotToken&&(l.rest=!0),t.parameters.push(l);const $={description:""};u.parameters[l.name]=$;const f=A.getSymbolAtLocation(r.name).getDocumentationComment(A);f&&f.length>0&&f[0].text&&($.description=f[0].text),P!==void 0&&($.defaultValue=P),D.set(l.name,l)}if(e.jsDoc&&e.jsDoc.length>0){const c=e.jsDoc,r=c.length;for(let l=0;l<r;l++){const g=c[l]?.tags;if(!g)continue;const P=g.length;for(let $=0;$<P;$++){const f=g[$];let s=f?.tagName?.text;if(!s)continue;s=s.toLowerCase();let i=f.comment;const Y=s==="hidden";if((typeof i=="string"||Y)&&(typeof i=="string"&&(i=i.replace(/[\r\n]+/g,"\\n").trim()),Y||!i||(i=i.split(/\\n/)[0],i&&i.length!==0))){if(i&&typeof i=="string"){const d=/\{@link(code|plain)?\s+([^}|]+)(?:\s*\|\s*([^}]+))?\}/g;let v,N=i,j=[];for(;(v=d.exec(i))!==null;){const[U,V,ae,Z]=v,oe=[ae.trim()];Z&&oe.push(Z.trim())}i=N,j.length>0&&s==="see"&&(u.links||(u.links=[]),u.links.push(...j))}if(s==="name"){const d=i;d!==m&&(u.name=d)}else if(s!=="description"){if(s==="summary"){const d=i;d&&(u.summary=d)}else if(s==="param"){const d=f.name?.text,v=D.get(d);if(!v){z.push(new Error(`Parameter '${d}' not found in function '${m}'.`));continue}if(f.typeExpression&&f.typeExpression.type)try{const N=f.typeExpression.type;if(N.kind===n.SyntaxKind.UnionType){const j=[];v.enums=j,N.types.forEach(U=>{if(U.kind===n.SyntaxKind.LiteralType){const V=U.literal.text;V&&j.push(V)}})}}catch(N){console.warn("Error parsing JSDoc type expression:",N)}}else if(s==="returns"||s==="return")t.returnType.description=i;else if(s==="category")u.category=i;else if(s==="hidden"){let d=!0;const v=i?.toLowerCase();v==="false"?d=!1:v!=="true"&&(d=i),d!==!1&&(u.hidden=d??!0)}}}}}}Object.keys(t.returnType).length===0&&delete t.returnType,p.push([t,u])}catch(o){k(e,new Error(`'${m}': ${o.message}`))}}}),z.length>0)throw console.warn(z),new Error("There were compilation errors.",{cause:z});if(p.length===0)throw new Error("No exported functions.");const ie=`${le.CommonUtils.uuidV4()}-script`;try{b||z.length!==0||(C=await ce(0,C,a))}catch{console.warn("Error bundling script")}const Q={functions:p,commitId:ie,source:x,name:"Script",language:"typescript",compiled:C};return y&&(Q.autoRun=y),Q};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";/**
|
|
2
|
-
* @license @sheetxl/scripting - Scripting - Scripting engine for Macros and formulas; includes TypeScript and EsBuild. - v0.7.
|
|
2
|
+
* @license @sheetxl/scripting - Scripting - Scripting engine for Macros and formulas; includes TypeScript and EsBuild. - v0.7.23
|
|
3
3
|
*
|
|
4
4
|
* (C) 2025-present SheetXL Inc. & Michael T. Ford
|
|
5
5
|
* License: The license can be found at https://www.sheetxl.com/license.
|
package/browser/cjs/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";/**
|
|
2
|
-
* @license @sheetxl/scripting - Scripting - Scripting engine for Macros and formulas; includes TypeScript and EsBuild. - v0.7.
|
|
2
|
+
* @license @sheetxl/scripting - Scripting - Scripting engine for Macros and formulas; includes TypeScript and EsBuild. - v0.7.23
|
|
3
3
|
*
|
|
4
4
|
* (C) 2025-present SheetXL Inc. & Michael T. Ford
|
|
5
5
|
* License: The license can be found at https://www.sheetxl.com/license.
|
|
6
|
-
*/Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("@sheetxl/utils");let l=null,n=null,t=null;const c=Object.freeze({compileTypescript:async function(e){if(!(e?.source??null))return null;if(n&&u.CommonUtils.deepEqual(n,e))return l;const i=await(async function(){if(t)return t;const{TypeScriptCompiler:o}=await Promise.resolve().then(()=>require("./
|
|
6
|
+
*/Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("@sheetxl/utils");let l=null,n=null,t=null;const c=Object.freeze({compileTypescript:async function(e){if(!(e?.source??null))return null;if(n&&u.CommonUtils.deepEqual(n,e))return l;const i=await(async function(){if(t)return t;const{TypeScriptCompiler:o}=await Promise.resolve().then(()=>require("./CShrycXagCsrhyME.cjs"));return t=new o,t})(),r=await i.compileModule(e);return l=r,n=e,r}});exports.ScriptingUtils=c;
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import { ScalarType as F } from "@sheetxl/primitives";
|
|
2
|
+
import { CommonUtils as le } from "@sheetxl/utils";
|
|
3
|
+
/**
|
|
4
|
+
* @license @sheetxl/scripting - Scripting - Scripting engine for Macros and formulas; includes TypeScript and EsBuild. - v0.7.23
|
|
5
|
+
*
|
|
6
|
+
* (C) 2025-present SheetXL Inc. & Michael T. Ford
|
|
7
|
+
* License: The license can be found at https://www.sheetxl.com/license.
|
|
8
|
+
*/
|
|
9
|
+
let L = null, B = null;
|
|
10
|
+
const se = { compilerOptions: { target: "esnext" } };
|
|
11
|
+
async function ce(h, x, S = "/script.js", w = "__SHEETXL") {
|
|
12
|
+
try {
|
|
13
|
+
const $ = await (async function() {
|
|
14
|
+
if (L) return L;
|
|
15
|
+
if (B) {
|
|
16
|
+
if (await B, !L) throw new Error("ESBuild initialization promise resolved, but instance is not available.");
|
|
17
|
+
return L;
|
|
18
|
+
}
|
|
19
|
+
let p, b;
|
|
20
|
+
B = new Promise((o, T) => {
|
|
21
|
+
p = o, b = T;
|
|
22
|
+
});
|
|
23
|
+
try {
|
|
24
|
+
const { initialize: o } = await import("./DHF3lqDKT7Ee1EGe.mjs");
|
|
25
|
+
return L = await o(), p(), L;
|
|
26
|
+
} catch (o) {
|
|
27
|
+
throw console.error("Failed to import or initialize esbuild:", o), B = null, b(o), o;
|
|
28
|
+
}
|
|
29
|
+
})(), I = "@sheetxl/primitives", n = `
|
|
30
|
+
export const FormulaContext = globalThis.${w}?.FormulaContext;
|
|
31
|
+
export const ScalarType = globalThis.${w}?.ScalarType;
|
|
32
|
+
export const Observable = globalThis.${w}?.Observable;
|
|
33
|
+
export const IRange = globalThis.${w}?.IRange;
|
|
34
|
+
export const FormulaError = globalThis.${w}?.FormulaError;
|
|
35
|
+
// Add more exports as needed
|
|
36
|
+
`, C = { name: "sheetxl-esbuild-in-memory", setup(p) {
|
|
37
|
+
const b = "sheetxl-" + (/* @__PURE__ */ new Date()).getTime();
|
|
38
|
+
p.onResolve({ filter: new RegExp(`^(${S.replace("/", "\\/")}|${I})$`) }, (o) => ({ path: o.path, namespace: b })), p.onResolve({ filter: /.*/ }, (o) => {
|
|
39
|
+
if (o.namespace !== b) return console.warn(`esbuild: Treating import "${o.path}" as external.`), { path: o.path, external: !0 };
|
|
40
|
+
}), p.onLoad({ filter: /.*/, namespace: b }, (o) => {
|
|
41
|
+
let T;
|
|
42
|
+
if (o.path === S) T = x;
|
|
43
|
+
else {
|
|
44
|
+
if (o.path !== I) return { errors: [{ text: `Cannot load unknown path in ${b}: ${o.path}` }] };
|
|
45
|
+
T = n;
|
|
46
|
+
}
|
|
47
|
+
return { contents: T, loader: "ts" };
|
|
48
|
+
});
|
|
49
|
+
} }, y = await $.build({ entryPoints: [S], bundle: !0, write: !1, format: "esm", plugins: [C], sourcemap: "inline", tsconfigRaw: se, minify: !0, platform: "neutral" });
|
|
50
|
+
if (y.outputFiles && y.outputFiles.length > 0) return y.outputFiles[0].text;
|
|
51
|
+
throw y.errors && y.errors.length > 0 ? new Error(`esbuild bundling failed: ${y.errors.map((p) => p.text).join(`
|
|
52
|
+
`)}`) : new Error("esbuild did not produce an output file.");
|
|
53
|
+
} catch ($) {
|
|
54
|
+
throw console.error("esbuild bundling process failed:", $), $;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
const de = async () => `
|
|
58
|
+
interface FirstTest {
|
|
59
|
+
isTrue?: boolean;
|
|
60
|
+
}
|
|
61
|
+
`, ee = /* @__PURE__ */ new Map([["IReferenceRange", "r"], ["IRange", "l"]]), te = /* @__PURE__ */ new Map([["IWorkbook", "workbook"], ["ISheet", "sheet"], ["ICellRanges", "ranges"], ["ICellRange", "range"], ["IFormulaContext", "context"]]), X = (h, x) => {
|
|
62
|
+
Array.from(x.keys()).forEach((S) => {
|
|
63
|
+
const w = x.get(S);
|
|
64
|
+
x.set(`${h}.${S}`, w);
|
|
65
|
+
});
|
|
66
|
+
}, ue = /* @__PURE__ */ new Map([["Scalar", "*"], ["FormulaError.Known", F.Error], ["Date", "Date"], ["JSON", "JSON"]]), pe = /* @__PURE__ */ new Map([]), _ = "SheetXL";
|
|
67
|
+
X(_, ee), X(_, te), X(_, pe);
|
|
68
|
+
const me = /* @__PURE__ */ new Map([["Promise", () => ({ async: !0 })], ["Observable", () => ({ stream: !0 })]]);
|
|
69
|
+
let J = null;
|
|
70
|
+
async function fe() {
|
|
71
|
+
if (J) return J;
|
|
72
|
+
try {
|
|
73
|
+
return await (await import("./D5Xp35M-Yk7Q7Hu-.mjs")).initialize();
|
|
74
|
+
} catch (h) {
|
|
75
|
+
throw J = null, h;
|
|
76
|
+
} finally {
|
|
77
|
+
J = null;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
async function he(h) {
|
|
81
|
+
const x = h?.source ?? null;
|
|
82
|
+
if (!x) return null;
|
|
83
|
+
const S = (h.disableBundle || h.declarationsOnly) ?? !1, w = [de(), fe()], $ = await Promise.all(w), I = $[0], n = $[1];
|
|
84
|
+
let C = "", y = null;
|
|
85
|
+
const p = [], b = { allowJs: !0, declaration: !1, sourceMap: !1, inlineSourceMap: !1, inlineSources: !1, isolatedModules: !0, preserveConstEnums: !1, module: 99, noResolve: !0, emitDeclarationOnly: !1, target: n.ScriptTarget.ES2020 }, o = "script", T = `${o}.ts`, H = "lib.d.ts", W = "global.d.ts", R = { [T]: x, [H]: `
|
|
86
|
+
/**
|
|
87
|
+
* Represents the completion of an asynchronous operation
|
|
88
|
+
*/
|
|
89
|
+
interface Promise<T> {
|
|
90
|
+
/**
|
|
91
|
+
* Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The
|
|
92
|
+
* resolved value cannot be modified from the callback.
|
|
93
|
+
* @param onfinally The callback to execute when the Promise is settled (fulfilled or rejected).
|
|
94
|
+
* @returns A Promise for the completion of the callback.
|
|
95
|
+
*/
|
|
96
|
+
finally(onfinally?: (() => void) | undefined | null): Promise<T>;
|
|
97
|
+
}
|
|
98
|
+
`, [W]: I }, ne = { getSourceFile: (e, t, u, m) => n.createSourceFile(e, R[e], n.ScriptTarget.Latest, !0), fileExists: (e) => R[e] !== void 0, readFile: (e) => R[e], writeFile: (e, t) => {
|
|
99
|
+
R[e] = t;
|
|
100
|
+
}, getCurrentDirectory: () => "./", getCanonicalFileName: (e) => e, useCaseSensitiveFileNames: () => !0, getDefaultLibFileName: (e) => H, getNewLine: () => `
|
|
101
|
+
` }, U = n.createProgram([T, W], b, ne), O = U.getTypeChecker(), re = U.getSourceFile(T), G = U.emit();
|
|
102
|
+
G.diagnostics.length > 0 && console.warn(G.diagnostics), C = R[`${o}.js`];
|
|
103
|
+
const P = (e, t, u, m) => {
|
|
104
|
+
if (e) {
|
|
105
|
+
if (e.kind === n.SyntaxKind.NumberKeyword) t.scalar = F.Number;
|
|
106
|
+
else if (e.kind === n.SyntaxKind.StringKeyword) t.scalar = F.String;
|
|
107
|
+
else if (e.kind === n.SyntaxKind.BooleanKeyword) t.scalar = F.Boolean;
|
|
108
|
+
else if (e.kind === n.SyntaxKind.UndefinedKeyword || e.kind === n.SyntaxKind.NullKeyword || e.kind === n.SyntaxKind.VoidKeyword) {
|
|
109
|
+
if (m) return void k(e, new Error(`'undefined' is not a valid type for input: '${e?.parent?.name?.escapedText}'.`));
|
|
110
|
+
t.scalar = F.Null;
|
|
111
|
+
} else if (e.kind === n.SyntaxKind.BigIntKeyword) t.scalar = F.Number;
|
|
112
|
+
else if (e.kind === n.SyntaxKind.AnyKeyword) t.scalar = F.Null;
|
|
113
|
+
else if (e.kind === n.SyntaxKind.ArrayType) {
|
|
114
|
+
const a = e.elementType;
|
|
115
|
+
if (!a) return void k(e, new Error(`'Array' must be typed: '${e?.parent?.name?.escapedText}'.`));
|
|
116
|
+
t.arrayDepth = (t.arrayDepth ?? 0) + 1, P(a, t, u, m);
|
|
117
|
+
} else if (e.kind !== n.SyntaxKind.TupleType) {
|
|
118
|
+
if (e.kind === n.SyntaxKind.TypeReference) {
|
|
119
|
+
const a = e.typeName?.getText?.() ?? null, M = ee.get(a);
|
|
120
|
+
let E = !1;
|
|
121
|
+
M && (t.range = M, E = !0);
|
|
122
|
+
const D = ue.get(a);
|
|
123
|
+
if (D && (t.scalar = D), D !== void 0 && (E = !0), m) {
|
|
124
|
+
const r = te.get(a);
|
|
125
|
+
if (r) return r;
|
|
126
|
+
} else {
|
|
127
|
+
const r = me.get(a);
|
|
128
|
+
if (r) {
|
|
129
|
+
const l = { ...t, ...r() };
|
|
130
|
+
let g = 0;
|
|
131
|
+
if (l.async && g++, l.stream && g++, g > 1) return void k(e, new Error(`'${a}' cannot have multiple modifiers: '${e?.parent?.name?.escapedText}'.`));
|
|
132
|
+
t = l, E = !0;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
if (!E) return void k("node", new Error(`'${a}' is not a valid type: '${e?.parent?.name?.escapedText}'.`));
|
|
136
|
+
const c = e.typeArguments;
|
|
137
|
+
if (c) {
|
|
138
|
+
if (c.length !== 1) return void k(e, new Error(`'${a}' must be typed with exactly 1 type: '${e?.parent?.name?.escapedText}'.`));
|
|
139
|
+
P(c[0], t, u, m);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
} else k(e, new Error(`Type is not defined for '${t?.name ?? "return"}'.`));
|
|
144
|
+
}, z = [], k = (e, t) => {
|
|
145
|
+
z.push(t);
|
|
146
|
+
};
|
|
147
|
+
if (n.forEachChild(re, (e) => {
|
|
148
|
+
if (((t) => (n.getCombinedModifierFlags(t) & n.ModifierFlags.Export) !== 0)(e) && n.isFunctionDeclaration(e)) {
|
|
149
|
+
const t = {}, u = { parameters: {} }, m = e?.name?.getText();
|
|
150
|
+
try {
|
|
151
|
+
t.name = m;
|
|
152
|
+
const a = O.getSymbolAtLocation(e.name).getDocumentationComment(O);
|
|
153
|
+
if (a && a.length > 0 && a[0].text) {
|
|
154
|
+
let c = a[0].text;
|
|
155
|
+
c = c.replace(/[\r\n]+/g, "\\n").trim(), u.summary = c;
|
|
156
|
+
}
|
|
157
|
+
const M = {};
|
|
158
|
+
P(e.type, M, t, !1), t.returnType = M;
|
|
159
|
+
const E = {};
|
|
160
|
+
((c) => (n.getCombinedModifierFlags(c) & n.ModifierFlags.Default) !== 0)(e) && (E.default = !0, y = m), Object.keys(E).length > 0 && (t.behavior = E), t.parameters = [];
|
|
161
|
+
const D = /* @__PURE__ */ new Map();
|
|
162
|
+
for (let c = 0; c < e.parameters.length; c++) {
|
|
163
|
+
const r = e.parameters[c], l = {};
|
|
164
|
+
l.name = r.name?.getText();
|
|
165
|
+
const g = P(r.type, l, t, !0);
|
|
166
|
+
if (g) {
|
|
167
|
+
if (t.parameters.length !== 0) {
|
|
168
|
+
const s = e?.parent, i = s?.name?.getText();
|
|
169
|
+
return void k(e, new Error(`'${t.name}' contexts must be the first parameter: '${i}'.`));
|
|
170
|
+
}
|
|
171
|
+
t.context = g;
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
let j;
|
|
175
|
+
if ((r.initializer !== void 0 && r.initializer !== null || r.questionToken !== void 0 && r.questionToken !== null) && (l.optional = !0, r.initializer)) try {
|
|
176
|
+
j = r.initializer.kind === n.SyntaxKind.StringLiteral ? r.initializer.text : r.initializer.kind === n.SyntaxKind.NumericLiteral ? parseFloat(r.initializer.text) : r.initializer.kind === n.SyntaxKind.TrueKeyword || r.initializer.kind === n.SyntaxKind.FalseKeyword ? r.initializer.kind === n.SyntaxKind.TrueKeyword : r.initializer.kind === n.SyntaxKind.NullKeyword ? null : r.initializer.kind === n.SyntaxKind.ObjectLiteralExpression || r.initializer.kind === n.SyntaxKind.ArrayLiteralExpression ? r.initializer.getText() : r.initializer.getText?.();
|
|
177
|
+
} catch (s) {
|
|
178
|
+
console.warn(`Couldn't extract default value for parameter '${l.name}'`, s);
|
|
179
|
+
}
|
|
180
|
+
r.dotDotDotToken && (l.rest = !0), t.parameters.push(l);
|
|
181
|
+
const v = { description: "" };
|
|
182
|
+
u.parameters[l.name] = v;
|
|
183
|
+
const f = O.getSymbolAtLocation(r.name).getDocumentationComment(O);
|
|
184
|
+
f && f.length > 0 && f[0].text && (v.description = f[0].text), j !== void 0 && (v.defaultValue = j), D.set(l.name, l);
|
|
185
|
+
}
|
|
186
|
+
if (e.jsDoc && e.jsDoc.length > 0) {
|
|
187
|
+
const c = e.jsDoc, r = c.length;
|
|
188
|
+
for (let l = 0; l < r; l++) {
|
|
189
|
+
const g = c[l]?.tags;
|
|
190
|
+
if (!g) continue;
|
|
191
|
+
const j = g.length;
|
|
192
|
+
for (let v = 0; v < j; v++) {
|
|
193
|
+
const f = g[v];
|
|
194
|
+
let s = f?.tagName?.text;
|
|
195
|
+
if (!s) continue;
|
|
196
|
+
s = s.toLowerCase();
|
|
197
|
+
let i = f.comment;
|
|
198
|
+
const Y = s === "hidden";
|
|
199
|
+
if ((typeof i == "string" || Y) && (typeof i == "string" && (i = i.replace(/[\r\n]+/g, "\\n").trim()), Y || !i || (i = i.split(/\\n/)[0], i && i.length !== 0))) {
|
|
200
|
+
if (i && typeof i == "string") {
|
|
201
|
+
const d = /\{@link(code|plain)?\s+([^}|]+)(?:\s*\|\s*([^}]+))?\}/g;
|
|
202
|
+
let K, N = i, A = [];
|
|
203
|
+
for (; (K = d.exec(i)) !== null; ) {
|
|
204
|
+
const [V, q, oe, Z] = K, ae = [oe.trim()];
|
|
205
|
+
Z && ae.push(Z.trim());
|
|
206
|
+
}
|
|
207
|
+
i = N, A.length > 0 && s === "see" && (u.links || (u.links = []), u.links.push(...A));
|
|
208
|
+
}
|
|
209
|
+
if (s === "name") {
|
|
210
|
+
const d = i;
|
|
211
|
+
d !== m && (u.name = d);
|
|
212
|
+
} else if (s !== "description") {
|
|
213
|
+
if (s === "summary") {
|
|
214
|
+
const d = i;
|
|
215
|
+
d && (u.summary = d);
|
|
216
|
+
} else if (s === "param") {
|
|
217
|
+
const d = f.name?.text, K = D.get(d);
|
|
218
|
+
if (!K) {
|
|
219
|
+
z.push(new Error(`Parameter '${d}' not found in function '${m}'.`));
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
if (f.typeExpression && f.typeExpression.type) try {
|
|
223
|
+
const N = f.typeExpression.type;
|
|
224
|
+
if (N.kind === n.SyntaxKind.UnionType) {
|
|
225
|
+
const A = [];
|
|
226
|
+
K.enums = A, N.types.forEach((V) => {
|
|
227
|
+
if (V.kind === n.SyntaxKind.LiteralType) {
|
|
228
|
+
const q = V.literal.text;
|
|
229
|
+
q && A.push(q);
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
} catch (N) {
|
|
234
|
+
console.warn("Error parsing JSDoc type expression:", N);
|
|
235
|
+
}
|
|
236
|
+
} else if (s === "returns" || s === "return") t.returnType.description = i;
|
|
237
|
+
else if (s === "category") u.category = i;
|
|
238
|
+
else if (s === "hidden") {
|
|
239
|
+
let d = !0;
|
|
240
|
+
const K = i?.toLowerCase();
|
|
241
|
+
K === "false" ? d = !1 : K !== "true" && (d = i), d !== !1 && (u.hidden = d ?? !0);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
Object.keys(t.returnType).length === 0 && delete t.returnType, p.push([t, u]);
|
|
249
|
+
} catch (a) {
|
|
250
|
+
k(e, new Error(`'${m}': ${a.message}`));
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}), z.length > 0) throw console.warn(z), new Error("There were compilation errors.", { cause: z });
|
|
254
|
+
if (p.length === 0) throw new Error("No exported functions.");
|
|
255
|
+
const ie = `${le.uuidV4()}-script`;
|
|
256
|
+
try {
|
|
257
|
+
S || z.length !== 0 || (C = await ce(0, C, o));
|
|
258
|
+
} catch {
|
|
259
|
+
console.warn("Error bundling script");
|
|
260
|
+
}
|
|
261
|
+
const Q = { functions: p, commitId: ie, source: x, name: "Script", language: "typescript", compiled: C };
|
|
262
|
+
return y && (Q.autoRun = y), Q;
|
|
263
|
+
}
|
|
264
|
+
export {
|
|
265
|
+
he as compileModule
|
|
266
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license @sheetxl/scripting - Scripting - Scripting engine for Macros and formulas; includes TypeScript and EsBuild. - v0.7.
|
|
2
|
+
* @license @sheetxl/scripting - Scripting - Scripting engine for Macros and formulas; includes TypeScript and EsBuild. - v0.7.23
|
|
3
3
|
*
|
|
4
4
|
* (C) 2025-present SheetXL Inc. & Michael T. Ford
|
|
5
5
|
* License: The license can be found at https://www.sheetxl.com/license.
|
|
@@ -10,7 +10,7 @@ class o {
|
|
|
10
10
|
}
|
|
11
11
|
async getWorkerWrapper() {
|
|
12
12
|
if (this.workerWrapper) return this.workerWrapper;
|
|
13
|
-
const { createCompilerWorker: r } = await import("./
|
|
13
|
+
const { createCompilerWorker: r } = await import("./BuowWyjSVKsr8H5b.mjs");
|
|
14
14
|
return this.workerWrapper = await r(), this.workerWrapper;
|
|
15
15
|
}
|
|
16
16
|
async compileModule(r) {
|