@sheetxl/primitives 0.7.28-beta.4 → 0.8.0-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.
- package/browser/cjs/index.cjs +1 -1
- package/browser/esm/index.mjs +73 -46
- package/node/esm/index.mjs +79 -52
- package/package.json +1 -1
- package/types/src/Compat.d.ts +77 -0
- package/types/src/FormulaContext.d.ts +17 -0
- package/types/src/IFormulaContext.d.ts +18 -0
- package/types/src/IFunction.d.ts +15 -0
- package/types/src/IFunctionArguments.d.ts +143 -0
- package/types/src/IRange.d.ts +29 -2
- package/types/src/index.d.ts +2 -0
package/browser/cjs/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e;Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),function(e){e.MAX_TEXT_LENGTH=32767;let t=e.MAX_SIGNIFICANT_DIGITS=15;e.truncateNumberText=function(e){let n=e.length;if(n<=t)return e;let r=0,i=null;for(let a=0;a<n;a++){let n=e.charCodeAt(a);if(n>=48&&n<=57){if(r===0&&n===48)continue;r++,r>t&&((i??=e.split(``))[a]=`0`)}else if((n===69||n===101)&&r>0)break}return i===null?e:i.join(``)}}(e||={});var t,n,r,i,a={Number:`number`,String:`string`,Boolean:`boolean`,Error:`error`,RichData:`richData`,Null:`null`},o={...a,Date:`date`},s=/[.*+?^${}()|[\]\\]/,c=e=>s.test(e)?`\\`+e:e,l={isWildCard:e=>typeof e==`string`&&/[*?]/.test(e),toRegex:(e,t,n=!1)=>{let r=``,i=e.length;for(let t=0;t<i;t++){let n=e[t];if(n===`~`){let n=e[t+1];n===`*`||n===`?`||n===`~`?(r+=c(n),t++):r+=`~`;continue}n===`*`?r+=`.*`:r+=n===`?`?`.`:c(n)}return RegExp(n?`^${r}$`:r,t)}};(n=t||={}).Axis={Column:`column`,Row:`row`},n.AxisSelection={...t.Axis,Both:`both`},n.Direction={Up:`up`,Down:`down`,Left:`left`,Right:`right`},(r||={}).Aggregate={Count:`count`,NumericalCount:`numericalCount`,Sum:`sum`,Average:`average`,StdDev:`stdDev`,PopulationStdDev:`stdDevP`,Variance:`var`,PopulationVariance:`varP`,Min:`min`,Max:`max`},function(e){let t=e.Code={Parse:0,Null:1,Div0:2,Value:3,Ref:4,Name:5,Num:6,NA:7,GettingData:8,Spill:9,Connect:10,Blocked:11,Unknown:12,Field:13,Calc:14,Busy:16,Python:19,Timeout:20},n=e.Label={Parse:`#PARSE!`,Null:`#NULL!`,Div0:`#DIV/0!`,Value:`#VALUE!`,Ref:`#REF!`,Name:`#NAME?`,Num:`#NUM!`,NA:`#N/A`,GettingData:`#GETTING_DATA`,Spill:`#SPILL!`,Connect:`#CONNECT!`,Blocked:`#BLOCKED!`,Unknown:`#UNKNOWN!`,Field:`#FIELD!`,Calc:`#CALC!`,Busy:`#BUSY!`,Python:`#PYTHON!`,Timeout:`#TIMEOUT!`};class r extends Error{constructor(e,t,n,r){super(n,r),this._label=t,this._code=e,this.details=r}static{this.code=i.Code.Unknown}get isFormulaError(){return!0}getLabel(){return this._label}getCode(){return this._code}equals(e){return!!e&&(this._code===e._code||this._code===e.code)}get[Symbol.toStringTag](){return`[FormulaError]`}toString(){return this._label}}e.Known=r;class a extends r{constructor(e,r){super(t.Parse,n.Parse,e,r)}static{this.code=i.Code.Parse}getDetails(){let e=this.details;return{line:e?.line??1,column:e?.column??1,offset:e?.offset??0,length:e?.length??0}}}e.Parse=a;class o extends r{constructor(e,r){super(t.Null,n.Null,e,r)}static{this.code=i.Code.Null}}e.Null=o;class s extends r{constructor(e,r){super(t.Div0,n.Div0,e,r)}static{this.code=i.Code.Div0}}e.Div0=s;class c extends r{constructor(e,r){super(t.Value,n.Value,e,r)}static{this.code=i.Code.Value}}e.Value=c;class l extends r{constructor(e,r){super(t.Ref,n.Ref,e,r)}static{this.code=i.Code.Ref}}e.Ref=l;class u extends r{constructor(e,r){super(t.Name,n.Name,e,r)}static{this.code=i.Code.Name}}e.Name=u;class d extends r{constructor(e,r){super(t.Num,n.Num,e,r)}static{this.code=i.Code.Num}}e.Num=d;class f extends r{constructor(e,r){super(t.NA,n.NA,e,r)}static{this.code=i.Code.NA}}e.NA=f;class p extends r{constructor(e,r){super(t.GettingData,n.GettingData,e,r)}static{this.code=i.Code.GettingData}}e.GettingData=p;class m extends r{constructor(e,r){super(t.Spill,n.Spill,e,r)}static{this.code=i.Code.Spill}}e.Spill=m;class h extends r{constructor(e,r){super(t.Connect,n.Connect,e,r)}static{this.code=i.Code.Connect}}e.Connect=h;class g extends r{constructor(e,r){super(t.Blocked,n.Blocked,e,r)}static{this.code=i.Code.Blocked}}e.Blocked=g;class _ extends r{constructor(e,r){super(t.Unknown,n.Unknown,e,r)}static{this.code=i.Code.Unknown}}e.Unknown=_;class v extends r{constructor(e,r){super(t.Field,n.Field,e,r)}static{this.code=i.Code.Field}}e.Field=v;class y extends r{constructor(e,r){super(t.Calc,n.Calc,e,r)}static{this.code=i.Code.Calc}}e.Calc=y;class b extends r{constructor(e,r){super(t.Busy,n.Busy,e,r)}static{this.code=i.Code.Busy}}e.Busy=b;class x extends r{constructor(e,r){super(t.Python,n.Python,e,r)}static{this.code=i.Code.Python}}e.Python=x;class S extends r{constructor(e,r){super(t.Timeout,n.Timeout,e,r)}static{this.code=i.Code.Timeout}}e.Timeout=S}(i||={});var u={};u[i.Code.Parse]=i.Parse,u[i.Code.Null]=i.Null,u[i.Code.Div0]=i.Div0,u[i.Code.Value]=i.Value,u[i.Code.Ref]=i.Ref,u[i.Code.Name]=i.Name,u[i.Code.Num]=i.Num,u[i.Code.NA]=i.NA,u[i.Code.GettingData]=i.GettingData,u[i.Code.Spill]=i.Spill,u[i.Code.Connect]=i.Connect,u[i.Code.Blocked]=i.Blocked,u[i.Code.Unknown]=i.Unknown,u[i.Code.Field]=i.Field,u[i.Code.Calc]=i.Calc,u[i.Code.Busy]=i.Busy,u[i.Code.Python]=i.Python,u[i.Code.Timeout]=i.Timeout;var d=new Map,f=new Map,p=new Map,m=new Map,h=Object.keys(u);for(let e=0;e<h.length;e++){let t=u[h[e]],n=new t;p.set(n.getLabel(),t),m.set(n.getCode(),t),d.set(n.getLabel(),n),f.set(n.getCode(),n)}(function(e){let t=e.getBuiltInByCode=e=>f.get(e);e.BuiltIn={Parse:t(i.Code.Parse),Null:t(i.Code.Null),Div0:t(i.Code.Div0),Value:t(i.Code.Value),Ref:t(i.Code.Ref),Name:t(i.Code.Name),Num:t(i.Code.Num),NA:t(i.Code.NA),GettingData:t(i.Code.GettingData),Spill:t(i.Code.Spill),Connect:t(i.Code.Connect),Blocked:t(i.Code.Blocked),Unknown:t(i.Code.Unknown),Field:t(i.Code.Field),Calc:t(i.Code.Calc),Busy:t(i.Code.Busy),Python:t(i.Code.Python),Timeout:t(i.Code.Timeout)},e.newTypedError=(e,t,n)=>{let r;return r=typeof e==`string`?p.get(e):m.get(e),r||=i.Unknown,new r(t,n)},e.getBuiltInByLabel=e=>d.get(e),e.isError=function(e,t){return!!e&&!0===e.isFormulaError&&(t===void 0||e.getCode()===t)}})(i||={});var g=class{createRange(e,t,n){throw new v}getReference(e,t){throw new v}getResizedReference(e,t,n){throw new v}getNumberFormat(e,t){throw new v}fromSerialDate(e,t){throw new v}toSerialDate(e,t){throw new v}getDateParts(e,t){throw new v}getSerialDate(e,t,n,r,i,a,o){throw new v}getNow(){throw new v}getValueAt(e,t,n,r){return null}getEntireCoords(){return y}isValidDate(e,t){return e instanceof Date||Object.prototype.toString.call(e)===`[object Date]`?!isNaN(e.getTime()):!t&&typeof e==`number`&&!(e<0||e>x)}getRow(){return 0}getColumn(){return 0}getFormulaAt(e,t,n){return null}getSpillAt(e,t,n){return null}getSheetIndex(e){return-1}getSheetCount(){return 1}markVolatile(){}formatResults(e){}filterHidden(e,t){return e}filterTotals(e){return e}getFunction(e){return null}getAddress(e,t){throw new v}parseAsSerialDate(e,t){throw new v}parseAsDate(e,t){throw new v}parseAsNumber(e,t){throw new v}createCriteria(e){throw new v}parseAsLiteral(e){let t=e.toUpperCase();return t===`TRUE`||t!==`FALSE`&&i.getBuiltInByLabel(t)}toText(e){return typeof e==`string`?e:e==null?``:typeof e==`boolean`?e?`TRUE`:`FALSE`:e?.isFormulaError?e.getLabel():String(e)}compare(e,t,n){if(e===t)return 0;let r=_(e),i=_(t);return r===i?e<t?-1:+(e>t):r<i?-1:1}getRuntime(){return b}},_=e=>{if(e==null)return 0;switch(typeof e){case`number`:return 1;case`string`:return 2;case`boolean`:return 3;default:return 4}},v=class extends Error{constructor(e=`Not implemented in StubbedFormulaContext`){super(e),this.name=`NotImplementedError`}},y=Object.freeze({colStart:0,rowStart:0,colEnd:2**14-1,rowEnd:2**20-1}),b={isDate1904:()=>!1,getLocale:()=>w.tag,getLocaleProfile:()=>w,isR1C1:()=>!1,getNow:()=>0,getLocation:()=>`unknown`,getVersion:()=>`1.0.0`,getOS:()=>`unknown`,getUser:()=>`unidentified`,getDescription:()=>`Stubbed Formula Context`},x=2958465,S=new g,C=class{constructor(){this._scope=S}_setScope(e){this._scope=e??S}_getScope(){return this._scope}getNumberFormat(e,t){return this._getScope().getNumberFormat(e,t)}getEntireCoords(){return this._getScope().getEntireCoords()??y}parseAsSerialDate(e,t){return this._getScope().parseAsSerialDate(e,t)}parseAsDate(e,t){return this._getScope().parseAsDate(e,t)}parseAsNumber(e,t){return this._getScope().parseAsNumber(e,t)}createCriteria(e){return this._getScope().createCriteria(e)}parseAsLiteral(e){let t=this._getScope();return t.parseAsLiteral?t.parseAsLiteral(e):S.parseAsLiteral(e)}toText(e){return this._getScope().toText(e)}isValidDate(e,t=!1){return this._getScope().isValidDate(e,t)}fromSerialDate(e,t=!1){return this._getScope().fromSerialDate(e,t)}toSerialDate(e,t=!1){return this._getScope().toSerialDate(e,t)}getDateParts(e,t){return this._getScope().getDateParts(e,t)}getSerialDate(e,t,n,r=0,i=0,a=0,o=0){return this._getScope().getSerialDate(e,t,n,r,i,a,o)}getNow(){return this._getScope().getNow()}createRange(e,t,n){return this._getScope().createRange(e,t,n)}getRow(){return this._getScope().getRow?.()??0}getColumn(){return this._getScope().getColumn?.()??0}getReference(e,t){return this._getScope().getReference(e,t)}getResizedReference(e,t,n){return this._getScope().getResizedReference(e,t,n)}getValueAt(e,t,n){return this._getScope().getValueAt(e,t,n)}getFormulaAt(e,t,n){return this._getScope().getFormulaAt?.(e,t,n)??null}getSpillAt(e,t,n){return this._getScope().getSpillAt?.(e,t,n)??null}getSheetIndex(e){return this._getScope().getSheetIndex?.(e)??-1}getSheetCount(){return this._getScope().getSheetCount?.()??1}markVolatile(){this._getScope().markVolatile?.()}formatResults(e){this._getScope().formatResults?.(e)}filterHidden(e,t){return this._getScope().filterHidden?.(e,t)??e}filterTotals(e){return this._getScope().filterTotals?.(e)??e}getFunction(e){return this._getScope().getFunction?.(e)??null}getAddress(e,t){return this._getScope().getAddress(e,t)}compare(e,t,n){return this._getScope().compare?.(e,t,n)??S.compare(e,t,n)}getRuntime(){return this._getScope().getRuntime()}get[Symbol.toStringTag](){return`[FormulaContext]`}toString(){return this._getScope()?.toString?.()??`{STUB SCOPE}`}},w=Object.freeze({tag:`en-US`,numberingSystem:`latn`,decimal:`.`,group:`,`,grouping:[3],minusSign:`-`,percentSign:`%`,permilleSign:`‰`,currencyCode:`USD`,currencySymbol:`$`,currencyDisplay:`symbol`,currencyPosition:`before`,currencySpacing:`tight`,date:Object.freeze({calendar:`gregory`,short:`M/d/yy`,medium:`MMM d, y`,long:`MMMM d, y`,timeShort:`h:mm a`,timeLong:`h:mm:ss a`,am:`AM`,pm:`PM`,firstDay:0,weekend:[6,0],monthsWide:[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],monthsAbbr:[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],weekdaysWide:[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`],weekdaysAbbr:[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],hour12:!0}),listSeparator:`,`,csvDelimiter:`,`,rtl:!1,collator:Object.freeze({sensitivity:`base`,numeric:!0})}),T=new C;exports.DEFAULT_LOCALE_PROFILE=w,exports.FormulaContext=T,Object.defineProperty(exports,"FormulaError",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"IRange",{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,"IRangeStats",{enumerable:!0,get:function(){return r}}),exports.InteropScalarType=o,exports.Observable=class{constructor(e){this._subscribeFn=e}subscribe(e,t,n){let r=typeof e==`object`?{next:e.next||(()=>{}),error:e.error||(()=>{}),complete:e.complete||(()=>{}),unsubscribe:()=>{}}:{next:e||(()=>{}),error:t||(()=>{}),complete:n||(()=>{}),unsubscribe:()=>{}},i=this._subscribeFn(r);return r.unsubscribe=()=>{typeof i==`function`&&i()},r}},Object.defineProperty(exports,"Scalar",{enumerable:!0,get:function(){return e}}),exports.ScalarType=a,exports.ScopedFormulaContext=C,exports.StubbedFormulaContext=g,exports.WildCard=l;
|
|
1
|
+
var e;Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),function(e){e.MAX_TEXT_LENGTH=32767;let t=e.MAX_SIGNIFICANT_DIGITS=15;e.truncateNumberText=function(e){let n=e.length;if(n<=t)return e;let r=0,i=null;for(let a=0;a<n;a++){let n=e.charCodeAt(a);if(n>=48&&n<=57){if(r===0&&n===48)continue;r++,r>t&&((i??=e.split(``))[a]=`0`)}else if((n===69||n===101)&&r>0)break}return i===null?e:i.join(``)}}(e||={});var t,n,r,i,a={Number:`number`,String:`string`,Boolean:`boolean`,Error:`error`,RichData:`richData`,Null:`null`},o={...a,Date:`date`},s=/[.*+?^${}()|[\]\\]/,c=e=>s.test(e)?`\\`+e:e,l={isWildCard:e=>typeof e==`string`&&/[*?]/.test(e),toRegex:(e,t,n=!1)=>{let r=``,i=e.length;for(let t=0;t<i;t++){let n=e[t];if(n===`~`){let n=e[t+1];n===`*`||n===`?`||n===`~`?(r+=c(n),t++):r+=`~`;continue}n===`*`?r+=`.*`:r+=n===`?`?`.`:c(n)}return RegExp(n?`^${r}$`:r,t)}},u={noReferenceLift:`A multi-cell reference at a non-repeating scalar parameter is #VALUE! rather than a broadcast.`,noMemberFilter:`Members of a repeating scalar parameter are coerced rather than filtered; one that cannot be is #VALUE!.`},d={atp:[`noReferenceLift`,`noMemberFilter`]};function f(e){if(!e)return null;let t=e.trim().toLowerCase();for(let e of Object.keys(u))if(e.toLowerCase()===t)return e;return null}(n=t||={}).Axis={Column:`column`,Row:`row`},n.AxisSelection={...t.Axis,Both:`both`},n.Direction={Up:`up`,Down:`down`,Left:`left`,Right:`right`},(r||={}).Aggregate={Count:`count`,NumericalCount:`numericalCount`,Sum:`sum`,Average:`average`,StdDev:`stdDev`,PopulationStdDev:`stdDevP`,Variance:`var`,PopulationVariance:`varP`,Min:`min`,Max:`max`},function(e){let t=e.Code={Parse:0,Null:1,Div0:2,Value:3,Ref:4,Name:5,Num:6,NA:7,GettingData:8,Spill:9,Connect:10,Blocked:11,Unknown:12,Field:13,Calc:14,Busy:16,Python:19,Timeout:20},n=e.Label={Parse:`#PARSE!`,Null:`#NULL!`,Div0:`#DIV/0!`,Value:`#VALUE!`,Ref:`#REF!`,Name:`#NAME?`,Num:`#NUM!`,NA:`#N/A`,GettingData:`#GETTING_DATA`,Spill:`#SPILL!`,Connect:`#CONNECT!`,Blocked:`#BLOCKED!`,Unknown:`#UNKNOWN!`,Field:`#FIELD!`,Calc:`#CALC!`,Busy:`#BUSY!`,Python:`#PYTHON!`,Timeout:`#TIMEOUT!`};class r extends Error{constructor(e,t,n,r){super(n,r),this._label=t,this._code=e,this.details=r}static{this.code=i.Code.Unknown}get isFormulaError(){return!0}getLabel(){return this._label}getCode(){return this._code}equals(e){return!!e&&(this._code===e._code||this._code===e.code)}get[Symbol.toStringTag](){return`[FormulaError]`}toString(){return this._label}}e.Known=r;class a extends r{constructor(e,r){super(t.Parse,n.Parse,e,r)}static{this.code=i.Code.Parse}getDetails(){let e=this.details;return{line:e?.line??1,column:e?.column??1,offset:e?.offset??0,length:e?.length??0}}}e.Parse=a;class o extends r{constructor(e,r){super(t.Null,n.Null,e,r)}static{this.code=i.Code.Null}}e.Null=o;class s extends r{constructor(e,r){super(t.Div0,n.Div0,e,r)}static{this.code=i.Code.Div0}}e.Div0=s;class c extends r{constructor(e,r){super(t.Value,n.Value,e,r)}static{this.code=i.Code.Value}}e.Value=c;class l extends r{constructor(e,r){super(t.Ref,n.Ref,e,r)}static{this.code=i.Code.Ref}}e.Ref=l;class u extends r{constructor(e,r){super(t.Name,n.Name,e,r)}static{this.code=i.Code.Name}}e.Name=u;class d extends r{constructor(e,r){super(t.Num,n.Num,e,r)}static{this.code=i.Code.Num}}e.Num=d;class f extends r{constructor(e,r){super(t.NA,n.NA,e,r)}static{this.code=i.Code.NA}}e.NA=f;class p extends r{constructor(e,r){super(t.GettingData,n.GettingData,e,r)}static{this.code=i.Code.GettingData}}e.GettingData=p;class m extends r{constructor(e,r){super(t.Spill,n.Spill,e,r)}static{this.code=i.Code.Spill}}e.Spill=m;class h extends r{constructor(e,r){super(t.Connect,n.Connect,e,r)}static{this.code=i.Code.Connect}}e.Connect=h;class g extends r{constructor(e,r){super(t.Blocked,n.Blocked,e,r)}static{this.code=i.Code.Blocked}}e.Blocked=g;class _ extends r{constructor(e,r){super(t.Unknown,n.Unknown,e,r)}static{this.code=i.Code.Unknown}}e.Unknown=_;class v extends r{constructor(e,r){super(t.Field,n.Field,e,r)}static{this.code=i.Code.Field}}e.Field=v;class y extends r{constructor(e,r){super(t.Calc,n.Calc,e,r)}static{this.code=i.Code.Calc}}e.Calc=y;class b extends r{constructor(e,r){super(t.Busy,n.Busy,e,r)}static{this.code=i.Code.Busy}}e.Busy=b;class x extends r{constructor(e,r){super(t.Python,n.Python,e,r)}static{this.code=i.Code.Python}}e.Python=x;class S extends r{constructor(e,r){super(t.Timeout,n.Timeout,e,r)}static{this.code=i.Code.Timeout}}e.Timeout=S}(i||={});var p={};p[i.Code.Parse]=i.Parse,p[i.Code.Null]=i.Null,p[i.Code.Div0]=i.Div0,p[i.Code.Value]=i.Value,p[i.Code.Ref]=i.Ref,p[i.Code.Name]=i.Name,p[i.Code.Num]=i.Num,p[i.Code.NA]=i.NA,p[i.Code.GettingData]=i.GettingData,p[i.Code.Spill]=i.Spill,p[i.Code.Connect]=i.Connect,p[i.Code.Blocked]=i.Blocked,p[i.Code.Unknown]=i.Unknown,p[i.Code.Field]=i.Field,p[i.Code.Calc]=i.Calc,p[i.Code.Busy]=i.Busy,p[i.Code.Python]=i.Python,p[i.Code.Timeout]=i.Timeout;var m=new Map,h=new Map,g=new Map,_=new Map,v=Object.keys(p);for(let e=0;e<v.length;e++){let t=p[v[e]],n=new t;g.set(n.getLabel(),t),_.set(n.getCode(),t),m.set(n.getLabel(),n),h.set(n.getCode(),n)}(function(e){let t=e.getBuiltInByCode=e=>h.get(e);e.BuiltIn={Parse:t(i.Code.Parse),Null:t(i.Code.Null),Div0:t(i.Code.Div0),Value:t(i.Code.Value),Ref:t(i.Code.Ref),Name:t(i.Code.Name),Num:t(i.Code.Num),NA:t(i.Code.NA),GettingData:t(i.Code.GettingData),Spill:t(i.Code.Spill),Connect:t(i.Code.Connect),Blocked:t(i.Code.Blocked),Unknown:t(i.Code.Unknown),Field:t(i.Code.Field),Calc:t(i.Code.Calc),Busy:t(i.Code.Busy),Python:t(i.Code.Python),Timeout:t(i.Code.Timeout)},e.newTypedError=(e,t,n)=>{let r;return r=typeof e==`string`?g.get(e):_.get(e),r||=i.Unknown,new r(t,n)},e.getBuiltInByLabel=e=>m.get(e),e.isError=function(e,t){return!!e&&!0===e.isFormulaError&&(t===void 0||e.getCode()===t)}})(i||={});var y=class{createRange(e,t,n){throw new S}getReference(e,t){throw new S}getResizedReference(e,t,n){throw new S}getNumberFormat(e,t){throw new S}fromSerialDate(e,t){throw new S}toSerialDate(e,t){throw new S}getDateParts(e,t){throw new S}getSerialDate(e,t,n,r,i,a,o){throw new S}getNow(){throw new S}getValueAt(e,t,n,r){return null}getEntireCoords(){return C}isValidDate(e,t){return e instanceof Date||Object.prototype.toString.call(e)===`[object Date]`?!isNaN(e.getTime()):!t&&typeof e==`number`&&!(e<0||e>T)}getRow(){return 0}getColumn(){return 0}getFormulaAt(e,t,n){return null}getSpillAt(e,t,n){return null}getSheetIndex(e){return-1}getSheetCount(){return 1}markVolatile(){}formatResults(e){}filterHidden(e,t){return e}filterTotals(e){return e}getFunction(e){return null}getAddress(e,t){throw new S}parseAsSerialDate(e,t){throw new S}parseAsDate(e,t){throw new S}parseAsNumber(e,t){throw new S}createCriteria(e){throw new S}parseAsLiteral(e){let t=e.toUpperCase();return t===`TRUE`||t!==`FALSE`&&i.getBuiltInByLabel(t)}toText(e){return typeof e==`string`?e:e==null?``:typeof e==`boolean`?e?`TRUE`:`FALSE`:e?.isFormulaError?e.getLabel():String(e)}compare(e,t,n){if(e===t)return 0;let r=b(e),i=b(t);return r===i?e<t?-1:+(e>t):r<i?-1:1}getRuntime(){return w}getArgs(){throw new S(x)}},b=e=>{if(e==null)return 0;switch(typeof e){case`number`:return 1;case`string`:return 2;case`boolean`:return 3;default:return 4}},x=`FormulaContext.getArgs() is only valid while a function body is running`,S=class extends Error{constructor(e=`Not implemented in StubbedFormulaContext`){super(e),this.name=`NotImplementedError`}},C=Object.freeze({colStart:0,rowStart:0,colEnd:2**14-1,rowEnd:2**20-1}),w={isDate1904:()=>!1,getLocale:()=>O.tag,getLocaleProfile:()=>O,isR1C1:()=>!1,getNow:()=>0,getLocation:()=>`unknown`,getVersion:()=>`1.0.0`,getOS:()=>`unknown`,getUser:()=>`unidentified`,getDescription:()=>`Stubbed Formula Context`},T=2958465,E=new y,D=class{constructor(){this._scope=E,this._argsFn=null}_setScope(e){this._scope=e??E}_getScope(){return this._scope}_setArgsProvider(e){this._argsFn=e}getNumberFormat(e,t){return this._getScope().getNumberFormat(e,t)}getEntireCoords(){return this._getScope().getEntireCoords()??C}parseAsSerialDate(e,t){return this._getScope().parseAsSerialDate(e,t)}parseAsDate(e,t){return this._getScope().parseAsDate(e,t)}parseAsNumber(e,t){return this._getScope().parseAsNumber(e,t)}createCriteria(e){return this._getScope().createCriteria(e)}parseAsLiteral(e){let t=this._getScope();return t.parseAsLiteral?t.parseAsLiteral(e):E.parseAsLiteral(e)}toText(e){return this._getScope().toText(e)}isValidDate(e,t=!1){return this._getScope().isValidDate(e,t)}fromSerialDate(e,t=!1){return this._getScope().fromSerialDate(e,t)}toSerialDate(e,t=!1){return this._getScope().toSerialDate(e,t)}getDateParts(e,t){return this._getScope().getDateParts(e,t)}getSerialDate(e,t,n,r=0,i=0,a=0,o=0){return this._getScope().getSerialDate(e,t,n,r,i,a,o)}getNow(){return this._getScope().getNow()}createRange(e,t,n){return this._getScope().createRange(e,t,n)}getRow(){return this._getScope().getRow?.()??0}getColumn(){return this._getScope().getColumn?.()??0}getReference(e,t){return this._getScope().getReference(e,t)}getResizedReference(e,t,n){return this._getScope().getResizedReference(e,t,n)}getValueAt(e,t,n){return this._getScope().getValueAt(e,t,n)}getFormulaAt(e,t,n){return this._getScope().getFormulaAt?.(e,t,n)??null}getSpillAt(e,t,n){return this._getScope().getSpillAt?.(e,t,n)??null}getSheetIndex(e){return this._getScope().getSheetIndex?.(e)??-1}getSheetCount(){return this._getScope().getSheetCount?.()??1}markVolatile(){this._getScope().markVolatile?.()}formatResults(e){this._getScope().formatResults?.(e)}filterHidden(e,t){return this._getScope().filterHidden?.(e,t)??e}filterTotals(e){return this._getScope().filterTotals?.(e)??e}getFunction(e){return this._getScope().getFunction?.(e)??null}getAddress(e,t){return this._getScope().getAddress(e,t)}compare(e,t,n){return this._getScope().compare?.(e,t,n)??E.compare(e,t,n)}getRuntime(){return this._getScope().getRuntime()}getArgs(){let e=this._argsFn,t=e?e():null;if(!t)throw new S(x);return t}get[Symbol.toStringTag](){return`[FormulaContext]`}toString(){return this._getScope()?.toString?.()??`{STUB SCOPE}`}},O=Object.freeze({tag:`en-US`,numberingSystem:`latn`,decimal:`.`,group:`,`,grouping:[3],minusSign:`-`,percentSign:`%`,permilleSign:`‰`,currencyCode:`USD`,currencySymbol:`$`,currencyDisplay:`symbol`,currencyPosition:`before`,currencySpacing:`tight`,date:Object.freeze({calendar:`gregory`,short:`M/d/yy`,medium:`MMM d, y`,long:`MMMM d, y`,timeShort:`h:mm a`,timeLong:`h:mm:ss a`,am:`AM`,pm:`PM`,firstDay:0,weekend:[6,0],monthsWide:[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],monthsAbbr:[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],weekdaysWide:[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`],weekdaysAbbr:[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],hour12:!0}),listSeparator:`,`,csvDelimiter:`,`,rtl:!1,collator:Object.freeze({sensitivity:`base`,numeric:!0})}),k=new D;exports.CompatAliases=d,exports.CompatFeatures=u,exports.DEFAULT_LOCALE_PROFILE=O,exports.FormulaContext=k,Object.defineProperty(exports,"FormulaError",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"IRange",{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,"IRangeStats",{enumerable:!0,get:function(){return r}}),exports.InteropScalarType=o,exports.Observable=class{constructor(e){this._subscribeFn=e}subscribe(e,t,n){let r=typeof e==`object`?{next:e.next||(()=>{}),error:e.error||(()=>{}),complete:e.complete||(()=>{}),unsubscribe:()=>{}}:{next:e||(()=>{}),error:t||(()=>{}),complete:n||(()=>{}),unsubscribe:()=>{}},i=this._subscribeFn(r);return r.unsubscribe=()=>{typeof i==`function`&&i()},r}},Object.defineProperty(exports,"Scalar",{enumerable:!0,get:function(){return e}}),exports.ScalarType=a,exports.ScopedFormulaContext=D,exports.StubbedFormulaContext=y,exports.WildCard=l,exports.resolveCompatFeature=f,exports.resolveCompatFeatures=function(e){let t=f(e);if(t)return[t];let n=(e??``).trim().toLowerCase();for(let e of Object.keys(d))if(e.toLowerCase()===n)return d[e];return null};
|
package/browser/esm/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license @sheetxl/primitives - Primitives - Base types for SheetXL functions. - v0.
|
|
2
|
+
* @license @sheetxl/primitives - Primitives - Base types for SheetXL functions. - v0.8.0-beta.1
|
|
3
3
|
*
|
|
4
4
|
* (C) 2026-present SheetXL Inc. & Michael T. Ford
|
|
5
5
|
* License: The license can be found at https://www.sheetxl.com/license.
|
|
@@ -47,7 +47,23 @@ var t, n, r, i, a = {
|
|
|
47
47
|
}
|
|
48
48
|
return RegExp(n ? `^${r}$` : r, t);
|
|
49
49
|
}
|
|
50
|
-
}
|
|
50
|
+
}, u = {
|
|
51
|
+
noReferenceLift: "A multi-cell reference at a non-repeating scalar parameter is #VALUE! rather than a broadcast.",
|
|
52
|
+
noMemberFilter: "Members of a repeating scalar parameter are coerced rather than filtered; one that cannot be is #VALUE!."
|
|
53
|
+
}, d = { atp: ["noReferenceLift", "noMemberFilter"] };
|
|
54
|
+
function f(e) {
|
|
55
|
+
let t = p(e);
|
|
56
|
+
if (t) return [t];
|
|
57
|
+
let n = (e ?? "").trim().toLowerCase();
|
|
58
|
+
for (let e of Object.keys(d)) if (e.toLowerCase() === n) return d[e];
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
function p(e) {
|
|
62
|
+
if (!e) return null;
|
|
63
|
+
let t = e.trim().toLowerCase();
|
|
64
|
+
for (let e of Object.keys(u)) if (e.toLowerCase() === t) return e;
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
51
67
|
(n = t ||= {}).Axis = {
|
|
52
68
|
Column: "column",
|
|
53
69
|
Row: "row"
|
|
@@ -309,15 +325,15 @@ var t, n, r, i, a = {
|
|
|
309
325
|
}
|
|
310
326
|
e.Timeout = S;
|
|
311
327
|
}(i ||= {});
|
|
312
|
-
var
|
|
313
|
-
|
|
314
|
-
var
|
|
315
|
-
for (let e = 0; e <
|
|
316
|
-
let t =
|
|
317
|
-
|
|
328
|
+
var m = {};
|
|
329
|
+
m[i.Code.Parse] = i.Parse, m[i.Code.Null] = i.Null, m[i.Code.Div0] = i.Div0, m[i.Code.Value] = i.Value, m[i.Code.Ref] = i.Ref, m[i.Code.Name] = i.Name, m[i.Code.Num] = i.Num, m[i.Code.NA] = i.NA, m[i.Code.GettingData] = i.GettingData, m[i.Code.Spill] = i.Spill, m[i.Code.Connect] = i.Connect, m[i.Code.Blocked] = i.Blocked, m[i.Code.Unknown] = i.Unknown, m[i.Code.Field] = i.Field, m[i.Code.Calc] = i.Calc, m[i.Code.Busy] = i.Busy, m[i.Code.Python] = i.Python, m[i.Code.Timeout] = i.Timeout;
|
|
330
|
+
var h = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Map(), _ = /* @__PURE__ */ new Map(), v = /* @__PURE__ */ new Map(), y = Object.keys(m);
|
|
331
|
+
for (let e = 0; e < y.length; e++) {
|
|
332
|
+
let t = m[y[e]], n = new t();
|
|
333
|
+
_.set(n.getLabel(), t), v.set(n.getCode(), t), h.set(n.getLabel(), n), g.set(n.getCode(), n);
|
|
318
334
|
}
|
|
319
335
|
(function(e) {
|
|
320
|
-
let t = e.getBuiltInByCode = (e) =>
|
|
336
|
+
let t = e.getBuiltInByCode = (e) => g.get(e);
|
|
321
337
|
e.BuiltIn = {
|
|
322
338
|
Parse: t(i.Code.Parse),
|
|
323
339
|
Null: t(i.Code.Null),
|
|
@@ -339,12 +355,12 @@ for (let e = 0; e < h.length; e++) {
|
|
|
339
355
|
Timeout: t(i.Code.Timeout)
|
|
340
356
|
}, e.newTypedError = (e, t, n) => {
|
|
341
357
|
let r;
|
|
342
|
-
return r = typeof e == "string" ?
|
|
343
|
-
}, e.getBuiltInByLabel = (e) =>
|
|
358
|
+
return r = typeof e == "string" ? _.get(e) : v.get(e), r ||= i.Unknown, new r(t, n);
|
|
359
|
+
}, e.getBuiltInByLabel = (e) => h.get(e), e.isError = function(e, t) {
|
|
344
360
|
return !!e && !0 === e.isFormulaError && (t === void 0 || e.getCode() === t);
|
|
345
361
|
};
|
|
346
362
|
})(i ||= {});
|
|
347
|
-
var
|
|
363
|
+
var b = class {
|
|
348
364
|
constructor(e) {
|
|
349
365
|
this._subscribeFn = e;
|
|
350
366
|
}
|
|
@@ -364,42 +380,42 @@ var g = class {
|
|
|
364
380
|
typeof i == "function" && i();
|
|
365
381
|
}, r;
|
|
366
382
|
}
|
|
367
|
-
},
|
|
383
|
+
}, x = class {
|
|
368
384
|
createRange(e, t, n) {
|
|
369
|
-
throw new
|
|
385
|
+
throw new w();
|
|
370
386
|
}
|
|
371
387
|
getReference(e, t) {
|
|
372
|
-
throw new
|
|
388
|
+
throw new w();
|
|
373
389
|
}
|
|
374
390
|
getResizedReference(e, t, n) {
|
|
375
|
-
throw new
|
|
391
|
+
throw new w();
|
|
376
392
|
}
|
|
377
393
|
getNumberFormat(e, t) {
|
|
378
|
-
throw new
|
|
394
|
+
throw new w();
|
|
379
395
|
}
|
|
380
396
|
fromSerialDate(e, t) {
|
|
381
|
-
throw new
|
|
397
|
+
throw new w();
|
|
382
398
|
}
|
|
383
399
|
toSerialDate(e, t) {
|
|
384
|
-
throw new
|
|
400
|
+
throw new w();
|
|
385
401
|
}
|
|
386
402
|
getDateParts(e, t) {
|
|
387
|
-
throw new
|
|
403
|
+
throw new w();
|
|
388
404
|
}
|
|
389
405
|
getSerialDate(e, t, n, r, i, a, o) {
|
|
390
|
-
throw new
|
|
406
|
+
throw new w();
|
|
391
407
|
}
|
|
392
408
|
getNow() {
|
|
393
|
-
throw new
|
|
409
|
+
throw new w();
|
|
394
410
|
}
|
|
395
411
|
getValueAt(e, t, n, r) {
|
|
396
412
|
return null;
|
|
397
413
|
}
|
|
398
414
|
getEntireCoords() {
|
|
399
|
-
return
|
|
415
|
+
return T;
|
|
400
416
|
}
|
|
401
417
|
isValidDate(e, t) {
|
|
402
|
-
return e instanceof Date || Object.prototype.toString.call(e) === "[object Date]" ? !isNaN(e.getTime()) : !t && typeof e == "number" && !(e < 0 || e >
|
|
418
|
+
return e instanceof Date || Object.prototype.toString.call(e) === "[object Date]" ? !isNaN(e.getTime()) : !t && typeof e == "number" && !(e < 0 || e > D);
|
|
403
419
|
}
|
|
404
420
|
getRow() {
|
|
405
421
|
return 0;
|
|
@@ -431,19 +447,19 @@ var g = class {
|
|
|
431
447
|
return null;
|
|
432
448
|
}
|
|
433
449
|
getAddress(e, t) {
|
|
434
|
-
throw new
|
|
450
|
+
throw new w();
|
|
435
451
|
}
|
|
436
452
|
parseAsSerialDate(e, t) {
|
|
437
|
-
throw new
|
|
453
|
+
throw new w();
|
|
438
454
|
}
|
|
439
455
|
parseAsDate(e, t) {
|
|
440
|
-
throw new
|
|
456
|
+
throw new w();
|
|
441
457
|
}
|
|
442
458
|
parseAsNumber(e, t) {
|
|
443
|
-
throw new
|
|
459
|
+
throw new w();
|
|
444
460
|
}
|
|
445
461
|
createCriteria(e) {
|
|
446
|
-
throw new
|
|
462
|
+
throw new w();
|
|
447
463
|
}
|
|
448
464
|
parseAsLiteral(e) {
|
|
449
465
|
let t = e.toUpperCase();
|
|
@@ -454,13 +470,16 @@ var g = class {
|
|
|
454
470
|
}
|
|
455
471
|
compare(e, t, n) {
|
|
456
472
|
if (e === t) return 0;
|
|
457
|
-
let r =
|
|
473
|
+
let r = S(e), i = S(t);
|
|
458
474
|
return r === i ? e < t ? -1 : +(e > t) : r < i ? -1 : 1;
|
|
459
475
|
}
|
|
460
476
|
getRuntime() {
|
|
461
|
-
return
|
|
477
|
+
return E;
|
|
462
478
|
}
|
|
463
|
-
|
|
479
|
+
getArgs() {
|
|
480
|
+
throw new w(C);
|
|
481
|
+
}
|
|
482
|
+
}, S = (e) => {
|
|
464
483
|
if (e == null) return 0;
|
|
465
484
|
switch (typeof e) {
|
|
466
485
|
case "number": return 1;
|
|
@@ -468,19 +487,19 @@ var g = class {
|
|
|
468
487
|
case "boolean": return 3;
|
|
469
488
|
default: return 4;
|
|
470
489
|
}
|
|
471
|
-
},
|
|
490
|
+
}, C = "FormulaContext.getArgs() is only valid while a function body is running", w = class extends Error {
|
|
472
491
|
constructor(e = "Not implemented in StubbedFormulaContext") {
|
|
473
492
|
super(e), this.name = "NotImplementedError";
|
|
474
493
|
}
|
|
475
|
-
},
|
|
494
|
+
}, T = Object.freeze({
|
|
476
495
|
colStart: 0,
|
|
477
496
|
rowStart: 0,
|
|
478
497
|
colEnd: 2 ** 14 - 1,
|
|
479
498
|
rowEnd: 2 ** 20 - 1
|
|
480
|
-
}),
|
|
499
|
+
}), E = {
|
|
481
500
|
isDate1904: () => !1,
|
|
482
|
-
getLocale: () =>
|
|
483
|
-
getLocaleProfile: () =>
|
|
501
|
+
getLocale: () => A.tag,
|
|
502
|
+
getLocaleProfile: () => A,
|
|
484
503
|
isR1C1: () => !1,
|
|
485
504
|
getNow: () => 0,
|
|
486
505
|
getLocation: () => "unknown",
|
|
@@ -488,21 +507,24 @@ var g = class {
|
|
|
488
507
|
getOS: () => "unknown",
|
|
489
508
|
getUser: () => "unidentified",
|
|
490
509
|
getDescription: () => "Stubbed Formula Context"
|
|
491
|
-
},
|
|
510
|
+
}, D = 2958465, O = new x(), k = class {
|
|
492
511
|
constructor() {
|
|
493
|
-
this._scope =
|
|
512
|
+
this._scope = O, this._argsFn = null;
|
|
494
513
|
}
|
|
495
514
|
_setScope(e) {
|
|
496
|
-
this._scope = e ??
|
|
515
|
+
this._scope = e ?? O;
|
|
497
516
|
}
|
|
498
517
|
_getScope() {
|
|
499
518
|
return this._scope;
|
|
500
519
|
}
|
|
520
|
+
_setArgsProvider(e) {
|
|
521
|
+
this._argsFn = e;
|
|
522
|
+
}
|
|
501
523
|
getNumberFormat(e, t) {
|
|
502
524
|
return this._getScope().getNumberFormat(e, t);
|
|
503
525
|
}
|
|
504
526
|
getEntireCoords() {
|
|
505
|
-
return this._getScope().getEntireCoords() ??
|
|
527
|
+
return this._getScope().getEntireCoords() ?? T;
|
|
506
528
|
}
|
|
507
529
|
parseAsSerialDate(e, t) {
|
|
508
530
|
return this._getScope().parseAsSerialDate(e, t);
|
|
@@ -518,7 +540,7 @@ var g = class {
|
|
|
518
540
|
}
|
|
519
541
|
parseAsLiteral(e) {
|
|
520
542
|
let t = this._getScope();
|
|
521
|
-
return t.parseAsLiteral ? t.parseAsLiteral(e) :
|
|
543
|
+
return t.parseAsLiteral ? t.parseAsLiteral(e) : O.parseAsLiteral(e);
|
|
522
544
|
}
|
|
523
545
|
toText(e) {
|
|
524
546
|
return this._getScope().toText(e);
|
|
@@ -590,18 +612,23 @@ var g = class {
|
|
|
590
612
|
return this._getScope().getAddress(e, t);
|
|
591
613
|
}
|
|
592
614
|
compare(e, t, n) {
|
|
593
|
-
return this._getScope().compare?.(e, t, n) ??
|
|
615
|
+
return this._getScope().compare?.(e, t, n) ?? O.compare(e, t, n);
|
|
594
616
|
}
|
|
595
617
|
getRuntime() {
|
|
596
618
|
return this._getScope().getRuntime();
|
|
597
619
|
}
|
|
620
|
+
getArgs() {
|
|
621
|
+
let e = this._argsFn, t = e ? e() : null;
|
|
622
|
+
if (!t) throw new w(C);
|
|
623
|
+
return t;
|
|
624
|
+
}
|
|
598
625
|
get [Symbol.toStringTag]() {
|
|
599
626
|
return "[FormulaContext]";
|
|
600
627
|
}
|
|
601
628
|
toString() {
|
|
602
629
|
return this._getScope()?.toString?.() ?? "{STUB SCOPE}";
|
|
603
630
|
}
|
|
604
|
-
},
|
|
631
|
+
}, A = Object.freeze({
|
|
605
632
|
tag: "en-US",
|
|
606
633
|
numberingSystem: "latn",
|
|
607
634
|
decimal: ".",
|
|
@@ -681,5 +708,5 @@ var g = class {
|
|
|
681
708
|
sensitivity: "base",
|
|
682
709
|
numeric: !0
|
|
683
710
|
})
|
|
684
|
-
}),
|
|
685
|
-
export {
|
|
711
|
+
}), j = new k();
|
|
712
|
+
export { d as CompatAliases, u as CompatFeatures, A as DEFAULT_LOCALE_PROFILE, j as FormulaContext, i as FormulaError, t as IRange, r as IRangeStats, o as InteropScalarType, b as Observable, e as Scalar, a as ScalarType, k as ScopedFormulaContext, x as StubbedFormulaContext, l as WildCard, p as resolveCompatFeature, f as resolveCompatFeatures };
|
package/node/esm/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license @sheetxl/primitives - Primitives - Base types for SheetXL functions. - v0.
|
|
2
|
+
* @license @sheetxl/primitives - Primitives - Base types for SheetXL functions. - v0.8.0-beta.1
|
|
3
3
|
*
|
|
4
4
|
* (C) 2026-present SheetXL Inc. & Michael T. Ford
|
|
5
5
|
* License: The license can be found at https://www.sheetxl.com/license.
|
|
@@ -48,7 +48,23 @@ var t, r, o, n, s = {
|
|
|
48
48
|
}
|
|
49
49
|
return RegExp(r ? `^${o}$` : o, t);
|
|
50
50
|
}
|
|
51
|
-
}
|
|
51
|
+
}, l = {
|
|
52
|
+
noReferenceLift: "A multi-cell reference at a non-repeating scalar parameter is #VALUE! rather than a broadcast.",
|
|
53
|
+
noMemberFilter: "Members of a repeating scalar parameter are coerced rather than filtered; one that cannot be is #VALUE!."
|
|
54
|
+
}, d = { atp: ["noReferenceLift", "noMemberFilter"] };
|
|
55
|
+
function g(e) {
|
|
56
|
+
const t = p(e);
|
|
57
|
+
if (t) return [t];
|
|
58
|
+
const r = (e ?? "").trim().toLowerCase();
|
|
59
|
+
for (const e of Object.keys(d)) if (e.toLowerCase() === r) return d[e];
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
function p(e) {
|
|
63
|
+
if (!e) return null;
|
|
64
|
+
const t = e.trim().toLowerCase();
|
|
65
|
+
for (const e of Object.keys(l)) if (e.toLowerCase() === t) return e;
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
52
68
|
(r = t || (t = {})).Axis = {
|
|
53
69
|
Column: "column",
|
|
54
70
|
Row: "row"
|
|
@@ -264,7 +280,7 @@ var t, r, o, n, s = {
|
|
|
264
280
|
}
|
|
265
281
|
}
|
|
266
282
|
e.Unknown = S;
|
|
267
|
-
class
|
|
283
|
+
class f extends o {
|
|
268
284
|
constructor(e, o) {
|
|
269
285
|
super(t.Field, r.Field, e, o);
|
|
270
286
|
}
|
|
@@ -272,7 +288,7 @@ var t, r, o, n, s = {
|
|
|
272
288
|
this.code = n.Code.Field;
|
|
273
289
|
}
|
|
274
290
|
}
|
|
275
|
-
e.Field =
|
|
291
|
+
e.Field = f;
|
|
276
292
|
class w extends o {
|
|
277
293
|
constructor(e, o) {
|
|
278
294
|
super(t.Calc, r.Calc, e, o);
|
|
@@ -282,7 +298,7 @@ var t, r, o, n, s = {
|
|
|
282
298
|
}
|
|
283
299
|
}
|
|
284
300
|
e.Calc = w;
|
|
285
|
-
class
|
|
301
|
+
class b extends o {
|
|
286
302
|
constructor(e, o) {
|
|
287
303
|
super(t.Busy, r.Busy, e, o);
|
|
288
304
|
}
|
|
@@ -290,8 +306,8 @@ var t, r, o, n, s = {
|
|
|
290
306
|
this.code = n.Code.Busy;
|
|
291
307
|
}
|
|
292
308
|
}
|
|
293
|
-
e.Busy =
|
|
294
|
-
class
|
|
309
|
+
e.Busy = b;
|
|
310
|
+
class N extends o {
|
|
295
311
|
constructor(e, o) {
|
|
296
312
|
super(t.Python, r.Python, e, o);
|
|
297
313
|
}
|
|
@@ -299,7 +315,7 @@ var t, r, o, n, s = {
|
|
|
299
315
|
this.code = n.Code.Python;
|
|
300
316
|
}
|
|
301
317
|
}
|
|
302
|
-
e.Python =
|
|
318
|
+
e.Python = N;
|
|
303
319
|
class y extends o {
|
|
304
320
|
constructor(e, o) {
|
|
305
321
|
super(t.Timeout, r.Timeout, e, o);
|
|
@@ -310,15 +326,15 @@ var t, r, o, n, s = {
|
|
|
310
326
|
}
|
|
311
327
|
e.Timeout = y;
|
|
312
328
|
}(n || (n = {}));
|
|
313
|
-
var
|
|
314
|
-
|
|
315
|
-
var
|
|
316
|
-
for (let e = 0; e <
|
|
317
|
-
const t =
|
|
318
|
-
|
|
329
|
+
var h = {};
|
|
330
|
+
h[n.Code.Parse] = n.Parse, h[n.Code.Null] = n.Null, h[n.Code.Div0] = n.Div0, h[n.Code.Value] = n.Value, h[n.Code.Ref] = n.Ref, h[n.Code.Name] = n.Name, h[n.Code.Num] = n.Num, h[n.Code.NA] = n.NA, h[n.Code.GettingData] = n.GettingData, h[n.Code.Spill] = n.Spill, h[n.Code.Connect] = n.Connect, h[n.Code.Blocked] = n.Blocked, h[n.Code.Unknown] = n.Unknown, h[n.Code.Field] = n.Field, h[n.Code.Calc] = n.Calc, h[n.Code.Busy] = n.Busy, h[n.Code.Python] = n.Python, h[n.Code.Timeout] = n.Timeout;
|
|
331
|
+
var m = /* @__PURE__ */ new Map(), C = /* @__PURE__ */ new Map(), S = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map(), w = Object.keys(h);
|
|
332
|
+
for (let e = 0; e < w.length; e++) {
|
|
333
|
+
const t = h[w[e]], r = new t();
|
|
334
|
+
S.set(r.getLabel(), t), f.set(r.getCode(), t), m.set(r.getLabel(), r), C.set(r.getCode(), r);
|
|
319
335
|
}
|
|
320
336
|
(function(e) {
|
|
321
|
-
const t = e.getBuiltInByCode = (e) =>
|
|
337
|
+
const t = e.getBuiltInByCode = (e) => C.get(e);
|
|
322
338
|
e.BuiltIn = {
|
|
323
339
|
Parse: t(n.Code.Parse),
|
|
324
340
|
Null: t(n.Code.Null),
|
|
@@ -340,12 +356,12 @@ for (let e = 0; e < m.length; e++) {
|
|
|
340
356
|
Timeout: t(n.Code.Timeout)
|
|
341
357
|
}, e.newTypedError = (e, t, r) => {
|
|
342
358
|
let o;
|
|
343
|
-
return o = "string" == typeof e ?
|
|
344
|
-
}, e.getBuiltInByLabel = (e) =>
|
|
359
|
+
return o = "string" == typeof e ? S.get(e) : f.get(e), o || (o = n.Unknown), new o(t, r);
|
|
360
|
+
}, e.getBuiltInByLabel = (e) => m.get(e), e.isError = function(e, t) {
|
|
345
361
|
return !!e && !0 === e.isFormulaError && (void 0 === t || e.getCode() === t);
|
|
346
362
|
};
|
|
347
363
|
})(n || (n = {}));
|
|
348
|
-
var
|
|
364
|
+
var b = class {
|
|
349
365
|
constructor(e) {
|
|
350
366
|
this._subscribeFn = e;
|
|
351
367
|
}
|
|
@@ -365,42 +381,42 @@ var C = class {
|
|
|
365
381
|
"function" == typeof n && n();
|
|
366
382
|
}, o;
|
|
367
383
|
}
|
|
368
|
-
},
|
|
384
|
+
}, N = class {
|
|
369
385
|
createRange(e, t, r) {
|
|
370
|
-
throw new
|
|
386
|
+
throw new D();
|
|
371
387
|
}
|
|
372
388
|
getReference(e, t) {
|
|
373
|
-
throw new
|
|
389
|
+
throw new D();
|
|
374
390
|
}
|
|
375
391
|
getResizedReference(e, t, r) {
|
|
376
|
-
throw new
|
|
392
|
+
throw new D();
|
|
377
393
|
}
|
|
378
394
|
getNumberFormat(e, t) {
|
|
379
|
-
throw new
|
|
395
|
+
throw new D();
|
|
380
396
|
}
|
|
381
397
|
fromSerialDate(e, t) {
|
|
382
|
-
throw new
|
|
398
|
+
throw new D();
|
|
383
399
|
}
|
|
384
400
|
toSerialDate(e, t) {
|
|
385
|
-
throw new
|
|
401
|
+
throw new D();
|
|
386
402
|
}
|
|
387
403
|
getDateParts(e, t) {
|
|
388
|
-
throw new
|
|
404
|
+
throw new D();
|
|
389
405
|
}
|
|
390
406
|
getSerialDate(e, t, r, o, n, s, a) {
|
|
391
|
-
throw new
|
|
407
|
+
throw new D();
|
|
392
408
|
}
|
|
393
409
|
getNow() {
|
|
394
|
-
throw new
|
|
410
|
+
throw new D();
|
|
395
411
|
}
|
|
396
412
|
getValueAt(e, t, r, o) {
|
|
397
413
|
return null;
|
|
398
414
|
}
|
|
399
415
|
getEntireCoords() {
|
|
400
|
-
return
|
|
416
|
+
return _;
|
|
401
417
|
}
|
|
402
418
|
isValidDate(e, t) {
|
|
403
|
-
return e instanceof Date || "[object Date]" === Object.prototype.toString.call(e) ? !isNaN(e.getTime()) : !t && "number" == typeof e && !(e < 0 || e >
|
|
419
|
+
return e instanceof Date || "[object Date]" === Object.prototype.toString.call(e) ? !isNaN(e.getTime()) : !t && "number" == typeof e && !(e < 0 || e > R);
|
|
404
420
|
}
|
|
405
421
|
getRow() {
|
|
406
422
|
return 0;
|
|
@@ -432,19 +448,19 @@ var C = class {
|
|
|
432
448
|
return null;
|
|
433
449
|
}
|
|
434
450
|
getAddress(e, t) {
|
|
435
|
-
throw new
|
|
451
|
+
throw new D();
|
|
436
452
|
}
|
|
437
453
|
parseAsSerialDate(e, t) {
|
|
438
|
-
throw new
|
|
454
|
+
throw new D();
|
|
439
455
|
}
|
|
440
456
|
parseAsDate(e, t) {
|
|
441
|
-
throw new
|
|
457
|
+
throw new D();
|
|
442
458
|
}
|
|
443
459
|
parseAsNumber(e, t) {
|
|
444
|
-
throw new
|
|
460
|
+
throw new D();
|
|
445
461
|
}
|
|
446
462
|
createCriteria(e) {
|
|
447
|
-
throw new
|
|
463
|
+
throw new D();
|
|
448
464
|
}
|
|
449
465
|
parseAsLiteral(e) {
|
|
450
466
|
const t = e.toUpperCase();
|
|
@@ -455,13 +471,16 @@ var C = class {
|
|
|
455
471
|
}
|
|
456
472
|
compare(e, t, r) {
|
|
457
473
|
if (e === t) return 0;
|
|
458
|
-
const o =
|
|
474
|
+
const o = y(e), n = y(t);
|
|
459
475
|
return o !== n ? o < n ? -1 : 1 : e < t ? -1 : e > t ? 1 : 0;
|
|
460
476
|
}
|
|
461
477
|
getRuntime() {
|
|
462
|
-
return
|
|
478
|
+
return F;
|
|
479
|
+
}
|
|
480
|
+
getArgs() {
|
|
481
|
+
throw new D(A);
|
|
463
482
|
}
|
|
464
|
-
},
|
|
483
|
+
}, y = (e) => {
|
|
465
484
|
if (null == e) return 0;
|
|
466
485
|
switch (typeof e) {
|
|
467
486
|
case "number": return 1;
|
|
@@ -469,19 +488,19 @@ var C = class {
|
|
|
469
488
|
case "boolean": return 3;
|
|
470
489
|
default: return 4;
|
|
471
490
|
}
|
|
472
|
-
},
|
|
491
|
+
}, A = "FormulaContext.getArgs() is only valid while a function body is running", D = class extends Error {
|
|
473
492
|
constructor(e = "Not implemented in StubbedFormulaContext") {
|
|
474
493
|
super(e), this.name = "NotImplementedError";
|
|
475
494
|
}
|
|
476
|
-
},
|
|
495
|
+
}, _ = Object.freeze({
|
|
477
496
|
colStart: 0,
|
|
478
497
|
rowStart: 0,
|
|
479
498
|
colEnd: Math.pow(2, 14) - 1,
|
|
480
499
|
rowEnd: Math.pow(2, 20) - 1
|
|
481
|
-
}),
|
|
500
|
+
}), F = {
|
|
482
501
|
isDate1904: () => !1,
|
|
483
|
-
getLocale: () =>
|
|
484
|
-
getLocaleProfile: () =>
|
|
502
|
+
getLocale: () => L.tag,
|
|
503
|
+
getLocaleProfile: () => L,
|
|
485
504
|
isR1C1: () => !1,
|
|
486
505
|
getNow: () => 0,
|
|
487
506
|
getLocation: () => "unknown",
|
|
@@ -489,21 +508,24 @@ var C = class {
|
|
|
489
508
|
getOS: () => "unknown",
|
|
490
509
|
getUser: () => "unidentified",
|
|
491
510
|
getDescription: () => "Stubbed Formula Context"
|
|
492
|
-
},
|
|
511
|
+
}, R = 2958465, x = new N(), T = class {
|
|
493
512
|
constructor() {
|
|
494
|
-
this._scope =
|
|
513
|
+
this._scope = x, this._argsFn = null;
|
|
495
514
|
}
|
|
496
515
|
_setScope(e) {
|
|
497
|
-
this._scope = e ??
|
|
516
|
+
this._scope = e ?? x;
|
|
498
517
|
}
|
|
499
518
|
_getScope() {
|
|
500
519
|
return this._scope;
|
|
501
520
|
}
|
|
521
|
+
_setArgsProvider(e) {
|
|
522
|
+
this._argsFn = e;
|
|
523
|
+
}
|
|
502
524
|
getNumberFormat(e, t) {
|
|
503
525
|
return this._getScope().getNumberFormat(e, t);
|
|
504
526
|
}
|
|
505
527
|
getEntireCoords() {
|
|
506
|
-
return this._getScope().getEntireCoords() ??
|
|
528
|
+
return this._getScope().getEntireCoords() ?? _;
|
|
507
529
|
}
|
|
508
530
|
parseAsSerialDate(e, t) {
|
|
509
531
|
return this._getScope().parseAsSerialDate(e, t);
|
|
@@ -519,7 +541,7 @@ var C = class {
|
|
|
519
541
|
}
|
|
520
542
|
parseAsLiteral(e) {
|
|
521
543
|
const t = this._getScope();
|
|
522
|
-
return t.parseAsLiteral ? t.parseAsLiteral(e) :
|
|
544
|
+
return t.parseAsLiteral ? t.parseAsLiteral(e) : x.parseAsLiteral(e);
|
|
523
545
|
}
|
|
524
546
|
toText(e) {
|
|
525
547
|
return this._getScope().toText(e);
|
|
@@ -591,18 +613,23 @@ var C = class {
|
|
|
591
613
|
return this._getScope().getAddress(e, t);
|
|
592
614
|
}
|
|
593
615
|
compare(e, t, r) {
|
|
594
|
-
return this._getScope().compare?.(e, t, r) ??
|
|
616
|
+
return this._getScope().compare?.(e, t, r) ?? x.compare(e, t, r);
|
|
595
617
|
}
|
|
596
618
|
getRuntime() {
|
|
597
619
|
return this._getScope().getRuntime();
|
|
598
620
|
}
|
|
621
|
+
getArgs() {
|
|
622
|
+
const e = this._argsFn, t = e ? e() : null;
|
|
623
|
+
if (!t) throw new D(A);
|
|
624
|
+
return t;
|
|
625
|
+
}
|
|
599
626
|
get [Symbol.toStringTag]() {
|
|
600
627
|
return "[FormulaContext]";
|
|
601
628
|
}
|
|
602
629
|
toString() {
|
|
603
630
|
return this._getScope()?.toString?.() ?? "{STUB SCOPE}";
|
|
604
631
|
}
|
|
605
|
-
},
|
|
632
|
+
}, L = Object.freeze({
|
|
606
633
|
tag: "en-US",
|
|
607
634
|
numberingSystem: "latn",
|
|
608
635
|
decimal: ".",
|
|
@@ -682,5 +709,5 @@ var C = class {
|
|
|
682
709
|
sensitivity: "base",
|
|
683
710
|
numeric: !0
|
|
684
711
|
})
|
|
685
|
-
}),
|
|
686
|
-
export {
|
|
712
|
+
}), P = new T();
|
|
713
|
+
export { d as CompatAliases, l as CompatFeatures, L as DEFAULT_LOCALE_PROFILE, P as FormulaContext, n as FormulaError, t as IRange, o as IRangeStats, a as InteropScalarType, b as Observable, e as Scalar, s as ScalarType, T as ScopedFormulaContext, N as StubbedFormulaContext, u as WildCard, p as resolveCompatFeature, g as resolveCompatFeatures };
|
package/package.json
CHANGED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The behaviors `@compat` can turn on, and what each one does.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* A feature earns a place here only if the BODY cannot do it — the decision happens before the
|
|
6
|
+
* body runs, or instead of running it. Everything a body can decide for itself belongs in the
|
|
7
|
+
* body, where `FormulaContext.getArgs()` and `Omittable` already reach.
|
|
8
|
+
*
|
|
9
|
+
* Function-level until a measurement forces otherwise: `noReferenceLift` is per-function in
|
|
10
|
+
* Excel, and no function is known whose parameters disagree.
|
|
11
|
+
*
|
|
12
|
+
* @see {@link https://www.sheetxl.com/docs/guides/concepts/udf | UDF authoring guide}
|
|
13
|
+
*/
|
|
14
|
+
export declare const CompatFeatures: {
|
|
15
|
+
/**
|
|
16
|
+
* A multi-cell REFERENCE at a non-repeating scalar parameter is `#VALUE!` rather than a
|
|
17
|
+
* broadcast.
|
|
18
|
+
*
|
|
19
|
+
* Excel's Analysis-ToolPak family answers `CUMIPMT(G1:G2,120,100000,13,24,0)` with `#VALUE!`
|
|
20
|
+
* where the native `ROUND(B1:B3,3)` spills three results. A multi-cell reference has no way to
|
|
21
|
+
* become a scalar there, because these functions never intersect. An ARRAY at the same slot
|
|
22
|
+
* still lifts (`MROUND({3,4,5},5)` spills), so the refusal is about references specifically,
|
|
23
|
+
* and a REPEATING slot absorbs a container as members either way (`GCD(C1:C3)` is 4) — so this
|
|
24
|
+
* never applies to one.
|
|
25
|
+
*/
|
|
26
|
+
readonly noReferenceLift: "A multi-cell reference at a non-repeating scalar parameter is #VALUE! rather than a broadcast.";
|
|
27
|
+
/**
|
|
28
|
+
* Members of a REPEATING scalar parameter are coerced rather than filtered: numeric text
|
|
29
|
+
* parses, a blank inside a multi-cell range reads 0, and a boolean or non-numeric text member
|
|
30
|
+
* is `#VALUE!` for the whole call.
|
|
31
|
+
*
|
|
32
|
+
* The native family FILTERS — `SUM({1,"8",TRUE})` is 1, the text and the boolean skipped, and a
|
|
33
|
+
* blank cell contributes nothing. Excel's Analysis-ToolPak family coerces instead:
|
|
34
|
+
* `GCD({6,"8",12})` is 2, `GCD({6,TRUE,12})` is `#VALUE!`, `LCM(6,A1:A2)` over two blank cells
|
|
35
|
+
* is 0. A direct argument follows the same rule (`GCD(6,TRUE,12)` is `#VALUE!` where
|
|
36
|
+
* `SUM(6,TRUE,12)` is 19), and a one-cell blank reference or an omitted argument is still
|
|
37
|
+
* skipped — it never became a member.
|
|
38
|
+
*/
|
|
39
|
+
readonly noMemberFilter: "Members of a repeating scalar parameter are coerced rather than filtered; one that cannot be is #VALUE!.";
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* One of the {@link CompatFeatures} names.
|
|
43
|
+
*/
|
|
44
|
+
export type CompatFeature = keyof typeof CompatFeatures;
|
|
45
|
+
/**
|
|
46
|
+
* Family aliases: one name an author writes that expands to several {@link CompatFeatures}.
|
|
47
|
+
*
|
|
48
|
+
* @remarks
|
|
49
|
+
* Excel's Analysis-ToolPak heritage is ONE measured rule with two halves that act on disjoint
|
|
50
|
+
* parameter kinds — `noReferenceLift` at a non-repeating scalar slot, `noMemberFilter` at a
|
|
51
|
+
* repeating one — so every function in the family carries the same two bits and `@compat atp`
|
|
52
|
+
* says so in one word. The alias is expanded by the linter; only the atomic features are ever
|
|
53
|
+
* stored, so `@compat atp` and `@compat noReferenceLift noMemberFilter` emit the same declaration.
|
|
54
|
+
* The atomic names stay available for the day a function measures as disagreeing on one half.
|
|
55
|
+
*/
|
|
56
|
+
export declare const CompatAliases: Readonly<Record<string, readonly CompatFeature[]>>;
|
|
57
|
+
/**
|
|
58
|
+
* Resolves a `@compat` name — a feature or a family alias — CASE-INSENSITIVELY, to the canonical
|
|
59
|
+
* features it turns on.
|
|
60
|
+
*
|
|
61
|
+
* @param name The name as the author wrote it.
|
|
62
|
+
* @returns The canonical features, or `null` when no feature or alias goes by that name.
|
|
63
|
+
*/
|
|
64
|
+
export declare function resolveCompatFeatures(name: string): readonly CompatFeature[] | null;
|
|
65
|
+
/**
|
|
66
|
+
* Resolves a `@compat` feature name, CASE-INSENSITIVELY, to its canonical spelling.
|
|
67
|
+
*
|
|
68
|
+
* @param name The name as the author wrote it.
|
|
69
|
+
* @returns The canonical name, or `null` when no feature goes by it.
|
|
70
|
+
*
|
|
71
|
+
* @remarks
|
|
72
|
+
* Authors write `@compat noReferenceLift`; `@Compat NOREFERENCELIFT` means the same thing. Only
|
|
73
|
+
* the canonical spelling is ever stored, so the declaration a build emits does not depend on how
|
|
74
|
+
* the tag was typed.
|
|
75
|
+
*/
|
|
76
|
+
export declare function resolveCompatFeature(name: string): CompatFeature | null;
|
|
77
|
+
//# sourceMappingURL=Compat.d.ts.map
|
|
@@ -3,6 +3,7 @@ import { FormulaError } from './FormulaError';
|
|
|
3
3
|
import { IRange } from './IRange';
|
|
4
4
|
import { IReferenceRange } from './IReferenceRange';
|
|
5
5
|
import { IFunction } from './IFunction';
|
|
6
|
+
import { IFunctionArguments } from './IFunctionArguments';
|
|
6
7
|
import { IFormulaContext } from './IFormulaContext';
|
|
7
8
|
import { IRuntime } from './IRuntime';
|
|
8
9
|
import { LocaleProfile } from './LocaleProfile';
|
|
@@ -127,6 +128,8 @@ export declare class StubbedFormulaContext implements IFormulaContext {
|
|
|
127
128
|
compare(a: Scalar, b: Scalar, options?: Intl.CollatorOptions): number;
|
|
128
129
|
/** @inheritdoc IFormulaContext.getRuntime */
|
|
129
130
|
getRuntime(): IRuntime;
|
|
131
|
+
/** @inheritdoc IFormulaContext.getArgs */
|
|
132
|
+
getArgs(): IFunctionArguments;
|
|
130
133
|
}
|
|
131
134
|
/**
|
|
132
135
|
* The single, shared {@link IFormulaContext} that formula implementations use (via
|
|
@@ -144,6 +147,18 @@ export declare class ScopedFormulaContext implements IFormulaContext {
|
|
|
144
147
|
_setScope(scope: Partial<IFormulaContext> | null): void;
|
|
145
148
|
/** @hidden */
|
|
146
149
|
_getScope(): Partial<IFormulaContext>;
|
|
150
|
+
/**
|
|
151
|
+
* @hidden Installed ONCE by the runtime marshaller; answers {@link getArgs} for whichever call
|
|
152
|
+
* is currently dispatching, or `null` when none is.
|
|
153
|
+
*
|
|
154
|
+
* @remarks
|
|
155
|
+
* A provider rather than a stack because the marshaller already pools one view per dispatch
|
|
156
|
+
* DEPTH and knows the current depth. Reading a function pointer costs nothing for the ~99% of
|
|
157
|
+
* calls whose body never asks.
|
|
158
|
+
*/
|
|
159
|
+
protected _argsFn: (() => IFunctionArguments | null) | null;
|
|
160
|
+
/** @hidden */
|
|
161
|
+
_setArgsProvider(provider: (() => IFunctionArguments | null) | null): void;
|
|
147
162
|
/** @inheritdoc IFormulaContext.getNumberFormat */
|
|
148
163
|
getNumberFormat(formatText: string, value: Scalar): string | null;
|
|
149
164
|
/** @inheritdoc IFormulaContext.getEntireCoords */
|
|
@@ -209,6 +224,8 @@ export declare class ScopedFormulaContext implements IFormulaContext {
|
|
|
209
224
|
compare(a: Scalar, b: Scalar, options?: Intl.CollatorOptions): number;
|
|
210
225
|
/** @inheritdoc IFormulaContext.getRuntime */
|
|
211
226
|
getRuntime(): IRuntime;
|
|
227
|
+
/** @inheritdoc IFormulaContext.getArgs */
|
|
228
|
+
getArgs(): IFunctionArguments;
|
|
212
229
|
get [Symbol.toStringTag](): string;
|
|
213
230
|
toString(): string;
|
|
214
231
|
}
|
|
@@ -3,6 +3,7 @@ import { FormulaError } from './FormulaError';
|
|
|
3
3
|
import { IRange } from './IRange';
|
|
4
4
|
import { IReferenceRange } from './IReferenceRange';
|
|
5
5
|
import { IFunction } from './IFunction';
|
|
6
|
+
import { IFunctionArguments } from './IFunctionArguments';
|
|
6
7
|
import { IRuntime } from './IRuntime';
|
|
7
8
|
/**
|
|
8
9
|
* Everything a formula function is allowed to know about the world outside its arguments.
|
|
@@ -28,6 +29,7 @@ import { IRuntime } from './IRuntime';
|
|
|
28
29
|
* | Category | Key methods |
|
|
29
30
|
* |---|---|
|
|
30
31
|
* | Evaluation lifecycle | `markVolatile`, `getRow`, `getColumn`, `getEntireCoords` |
|
|
32
|
+
* | Argument reflection | `getArgs` |
|
|
31
33
|
* | Output hints | `formatResults` |
|
|
32
34
|
* | Range construction | `createRange`, `filterHidden` |
|
|
33
35
|
* | Dynamic references | `getReference`, `getValueAt`, `getFormulaAt`, `getSpillAt` |
|
|
@@ -482,6 +484,22 @@ export interface IFormulaContext {
|
|
|
482
484
|
* Mostly for diagnostics; the built-in `INFO` function is built on it.
|
|
483
485
|
*/
|
|
484
486
|
getRuntime(): IRuntime;
|
|
487
|
+
/**
|
|
488
|
+
* The current call's arguments — how many the caller supplied, in which positions, of what kind,
|
|
489
|
+
* and what each value was BEFORE coercion.
|
|
490
|
+
*
|
|
491
|
+
* @remarks
|
|
492
|
+
* Argument REFLECTION, for the one thing a declaration cannot say: what happened at *this* call.
|
|
493
|
+
* It exists to serve Excel's declared `any`, which means "no contract, the body decides" — every
|
|
494
|
+
* other Excel type maps onto a type we already have and the marshaller handles it.
|
|
495
|
+
*
|
|
496
|
+
* The returned view is valid ONLY while the body that asked for it is running. Views are pooled
|
|
497
|
+
* by dispatch depth, so retaining one across an `await`, a callback, or a nested evaluation hands
|
|
498
|
+
* you another call's arguments.
|
|
499
|
+
*
|
|
500
|
+
* @throws If called outside a function dispatch — there are no arguments to reflect on.
|
|
501
|
+
*/
|
|
502
|
+
getArgs(): IFunctionArguments;
|
|
485
503
|
}
|
|
486
504
|
/**
|
|
487
505
|
* {@inheritDoc IFormulaContext}
|
package/types/src/IFunction.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Scalar } from './Scalar';
|
|
2
2
|
import { ScalarType } from './ScalarType';
|
|
3
|
+
import { CompatFeature } from './Compat';
|
|
3
4
|
/**
|
|
4
5
|
* A self-describing, type-safe, executable function.
|
|
5
6
|
*
|
|
@@ -603,6 +604,20 @@ export declare namespace IFunction {
|
|
|
603
604
|
* @defaultValue false
|
|
604
605
|
*/
|
|
605
606
|
cancelable?: boolean;
|
|
607
|
+
/**
|
|
608
|
+
* Named engine behaviors this function opts into, from the `@compat` doc tag.
|
|
609
|
+
*
|
|
610
|
+
* @remarks
|
|
611
|
+
* Canonical spellings, deduplicated and in declaration order; a family alias the author wrote
|
|
612
|
+
* (`@compat atp`) has already been expanded to its atomic features. An unknown name never
|
|
613
|
+
* reaches here — the linter fails the build on one, deliberately: a compatibility rule that
|
|
614
|
+
* silently no-ops is the worst failure available, because the fixtures keep passing and the
|
|
615
|
+
* behavior is simply absent.
|
|
616
|
+
*
|
|
617
|
+
* @see {@link CompatFeatures}
|
|
618
|
+
* @see {@link CompatAliases}
|
|
619
|
+
*/
|
|
620
|
+
compat?: CompatFeature[];
|
|
606
621
|
}
|
|
607
622
|
}
|
|
608
623
|
//# sourceMappingURL=IFunction.d.ts.map
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { Scalar } from './Scalar';
|
|
2
|
+
import { IRange } from './IRange';
|
|
3
|
+
import { Lambda } from './Lambda';
|
|
4
|
+
/**
|
|
5
|
+
* The current call's arguments, as the body sees them — argument **reflection**.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* A declaration answers "what does this parameter mean?", and the marshaller coerces every
|
|
9
|
+
* argument to it. That is right for the overwhelming majority of parameters. What it cannot answer
|
|
10
|
+
* is anything about *this particular call*:
|
|
11
|
+
*
|
|
12
|
+
* - What did the caller write there — a value, a cell, an array, nothing at all?
|
|
13
|
+
* - What was the value BEFORE the parameter's type coerced it?
|
|
14
|
+
* - Was that empty slot an omission, or a blank cell the caller pointed at?
|
|
15
|
+
*
|
|
16
|
+
* Excel has measured behaviors that turn on exactly those questions, and they cluster at the
|
|
17
|
+
* parameters Excel declares `any` — where there is nothing to express as a type, because Excel
|
|
18
|
+
* declined to express one. `CUMIPMT` refuses a boolean at every slot while `FV` coerces one at
|
|
19
|
+
* every slot; the difference is not the values, it is that `CUMIPMT`'s slots are `any` and its
|
|
20
|
+
* body decides.
|
|
21
|
+
*
|
|
22
|
+
* It is REFLECTION and nothing else — two questions, and no third:
|
|
23
|
+
*
|
|
24
|
+
* | question | answers |
|
|
25
|
+
* | --- | --- |
|
|
26
|
+
* | *what was supplied* | {@link getLength}, {@link isOmittedAt} |
|
|
27
|
+
* | *what it is* | {@link getRawAt} |
|
|
28
|
+
*
|
|
29
|
+
* Coercion is deliberately absent. A body that wants a number calls
|
|
30
|
+
* {@link IFormulaContext.parseAsNumber} on the value this hands it — that already takes a value,
|
|
31
|
+
* already propagates an incoming error with its identity, and already answers `#VALUE!` for a
|
|
32
|
+
* boolean, which IS the rule an `any` slot needs. There is no coercion an index can do that a
|
|
33
|
+
* value cannot.
|
|
34
|
+
*
|
|
35
|
+
* Obtained from `FormulaContext.getArgs()`, and valid ONLY while the body that asked for it is
|
|
36
|
+
* running. A body must not retain it across an `await`, a callback, or a nested evaluation — the
|
|
37
|
+
* views are pooled by dispatch depth, so the one at your depth is handed to the next call at that
|
|
38
|
+
* depth.
|
|
39
|
+
*
|
|
40
|
+
* ```typescript
|
|
41
|
+
* export function CUMIPMT(rate: Scalar, nper: Scalar): number {
|
|
42
|
+
* const args = FormulaContext.getArgs();
|
|
43
|
+
* if (args.isOmittedAt(0)) return FormulaError.BuiltIn.NA; // `CUMIPMT(,120,…)` is #N/A
|
|
44
|
+
* const asNumber = FormulaContext.parseAsNumber(args.getRawAt(0) as Scalar); // TRUE is #VALUE!
|
|
45
|
+
* // …
|
|
46
|
+
* }
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* @see {@link IFormulaContext.getArgs}
|
|
50
|
+
*/
|
|
51
|
+
export interface IFunctionArguments {
|
|
52
|
+
/**
|
|
53
|
+
* How many PARAMETERS the caller supplied.
|
|
54
|
+
*
|
|
55
|
+
* @remarks
|
|
56
|
+
* Indexing throughout matches the BODY's own signature, never the raw call positions
|
|
57
|
+
* (see {@link getRawAt}). `index >= getLength()` is an ABSENT argument — one the caller never
|
|
58
|
+
* wrote, whose own JS initializer supplied the value. That is a different thing from an OMITTED
|
|
59
|
+
* one; see {@link isOmittedAt}.
|
|
60
|
+
*/
|
|
61
|
+
getLength(): number;
|
|
62
|
+
/**
|
|
63
|
+
* This invocation's value at `index`, uncoerced.
|
|
64
|
+
*
|
|
65
|
+
* @param index The PARAMETER index — the position in the body's own signature.
|
|
66
|
+
*
|
|
67
|
+
* @remarks
|
|
68
|
+
* A `Scalar` means the argument IS a value; an {@link IRange} means a container whose members
|
|
69
|
+
* the body reads itself (a reference materializes on demand); a {@link Lambda} means a callable.
|
|
70
|
+
*
|
|
71
|
+
* At a REPEATING parameter (`Repeating<T>`, or a rest parameter) this is the ARRAY of that
|
|
72
|
+
* group's values — one entry per argument the caller wrote — and {@link getRepeatingArgsAt} is the
|
|
73
|
+
* per-argument view of the same thing. Indexing by parameter rather than by call position is
|
|
74
|
+
* what lets a body ask its questions in the vocabulary it declared:
|
|
75
|
+
*
|
|
76
|
+
* ```typescript
|
|
77
|
+
* // IFS(condition: Repeating<[logicalTest: boolean, logicalTrue: AcceptError<any>]>)
|
|
78
|
+
* args.getRawAt(0); // [test1, value1, test2, value2, …]
|
|
79
|
+
* args.getRepeatingArgsAt(0).getRawAt(0); // test1
|
|
80
|
+
* ```
|
|
81
|
+
*
|
|
82
|
+
* **Under a lift** the call broadcasts and the body runs once per output cell; this reports the
|
|
83
|
+
* value for THIS invocation — the member at the current broadcast position for a lifted argument,
|
|
84
|
+
* the whole argument for one that is not lifting. That is what every identified caller wants: a
|
|
85
|
+
* body checking for a boolean must see the member, not the array around it.
|
|
86
|
+
*
|
|
87
|
+
* One boundary is worth knowing: under a lift at a parameter that declares a CONCRETE scalar
|
|
88
|
+
* type, the member has already been converted by that declaration, so the raw and coerced answers
|
|
89
|
+
* coincide there. At the `Scalar` slots this interface exists for, nothing coerces and the value
|
|
90
|
+
* is the member exactly as the caller's range holds it.
|
|
91
|
+
*/
|
|
92
|
+
getRawAt(index: number): IFunctionArguments.RawArg | IFunctionArguments.RawArg[];
|
|
93
|
+
/**
|
|
94
|
+
* A nested view over one REPEATING parameter's arguments, so a body can ask the same questions
|
|
95
|
+
* one level down — `getRepeatingArgsAt(0).isOmittedAt(1)`.
|
|
96
|
+
*
|
|
97
|
+
* @param index The PARAMETER index of the repeating group (or rest parameter).
|
|
98
|
+
*
|
|
99
|
+
* @remarks
|
|
100
|
+
* The nested view is FLAT over the group's arguments: a period-2 group repeated three times reads
|
|
101
|
+
* as six, in call order. That is where "which one was omitted" has an answer at all — the group
|
|
102
|
+
* as a whole cannot be omitted, only one of its arguments can.
|
|
103
|
+
*
|
|
104
|
+
* At a non-repeating parameter this returns an EMPTY view (`getLength()` of 0) rather than
|
|
105
|
+
* throwing, so a body that folds over its groups needs no special case.
|
|
106
|
+
*/
|
|
107
|
+
getRepeatingArgsAt(index: number): IFunctionArguments;
|
|
108
|
+
/**
|
|
109
|
+
* True for an OMITTED argument — one the caller supplied EMPTY, as the trailing comma of
|
|
110
|
+
* `CUMIPMT(,120,100000,13,24,0)`.
|
|
111
|
+
*
|
|
112
|
+
* @remarks
|
|
113
|
+
* There are THREE positions, not two, and Excel answers each differently:
|
|
114
|
+
*
|
|
115
|
+
* | form | position | Excel |
|
|
116
|
+
* | --- | --- | --- |
|
|
117
|
+
* | `CUMIPMT(0.01,120,100000,13,24)` | ABSENT | refused at entry |
|
|
118
|
+
* | `CUMIPMT(,120,100000,13,24,0)` | **OMITTED** | `#N/A` |
|
|
119
|
+
* | `CUMIPMT(0.01,120,100000,13,24,E1)`, E1 blank | a blank CELL | the ordinary answer |
|
|
120
|
+
*
|
|
121
|
+
* This separates the middle row from the other two. ABSENT is `index >= getLength()`; a blank
|
|
122
|
+
* cell is an ordinary value the caller pointed at and is not omitted.
|
|
123
|
+
*/
|
|
124
|
+
isOmittedAt(index: number): boolean;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* {@inheritDoc IFunctionArguments}
|
|
128
|
+
*
|
|
129
|
+
* @see
|
|
130
|
+
* ### **Interface**
|
|
131
|
+
*
|
|
132
|
+
* {@link IFunctionArguments}
|
|
133
|
+
*/
|
|
134
|
+
export declare namespace IFunctionArguments {
|
|
135
|
+
/**
|
|
136
|
+
* One argument as the caller wrote it — a value, a container, a callable, or nothing.
|
|
137
|
+
*
|
|
138
|
+
* @remarks
|
|
139
|
+
* `undefined` is an OMITTED or ABSENT argument; `null` is a blank, which is a value.
|
|
140
|
+
*/
|
|
141
|
+
type RawArg = Scalar | IRange | Lambda | undefined;
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=IFunctionArguments.d.ts.map
|
package/types/src/IRange.d.ts
CHANGED
|
@@ -244,11 +244,28 @@ export interface IRange<T extends Scalar = Scalar> {
|
|
|
244
244
|
*/
|
|
245
245
|
filter<TS extends Scalar = T>(callbackFn: (value: TS, coords: IRange.CellCoords, range: IRange<T>) => MaybeError<boolean>, options?: IRange.TraversalAxis | IRange.IteratorOptions): this;
|
|
246
246
|
/**
|
|
247
|
-
*
|
|
247
|
+
* Linearizes the range into a single column by flattened ordinal — the member at ordinal `i`
|
|
248
|
+
* lands at row `i`, column 0.
|
|
248
249
|
*
|
|
249
250
|
* @param options {@link IRange.IteratorOptions}
|
|
251
|
+
*
|
|
252
|
+
* @remarks
|
|
253
|
+
* `options.axis` is the TRAVERSAL order feeding the ordinal, not the orientation of the result:
|
|
254
|
+
* the result is always Nx1, and a row is `flatten().transpose()`. The default is row-major,
|
|
255
|
+
* which is the order Excel pairs two range operands in.
|
|
256
|
+
*
|
|
257
|
+
* `options.type` carries a read type onto the result, so a member the type filters out becomes
|
|
258
|
+
* a HOLE at its ordinal rather than compacting the column. That is what lets two operands be
|
|
259
|
+
* paired position by position — see {@link alignValues}.
|
|
260
|
+
*
|
|
261
|
+
* `options.includeEmpty` has no meaning here and is ignored: a range is inherently sparse, so
|
|
262
|
+
* an empty position is simply absent. Sparsity is preserved and nothing is materialized.
|
|
263
|
+
*
|
|
264
|
+
* Equivalent to `reshape(rows * columns, 1)`, which is where the ordinal rule is stated.
|
|
265
|
+
*
|
|
266
|
+
* @see {@link getValuesFlat} for the same linearization as a JS array.
|
|
250
267
|
*/
|
|
251
|
-
flatten
|
|
268
|
+
flatten(options?: IRange.IteratorOptions): this;
|
|
252
269
|
/**
|
|
253
270
|
* Iterates over the cells within the range, applying the provided callback function to each cell.
|
|
254
271
|
*
|
|
@@ -326,6 +343,16 @@ export interface IRange<T extends Scalar = Scalar> {
|
|
|
326
343
|
* @param options {@link IRange.ValueOptions}
|
|
327
344
|
*/
|
|
328
345
|
getValueAt<TS extends Scalar = T>(rowIndex: number, colIndex: number, options?: IRange.ValueOptions): TS;
|
|
346
|
+
/**
|
|
347
|
+
* Returns the members as a flat JS array.
|
|
348
|
+
*
|
|
349
|
+
* @param options {@link IRange.IteratorOptions}
|
|
350
|
+
*
|
|
351
|
+
* @remarks
|
|
352
|
+
* The array form of {@link flatten}. Skips empty members unless `includeEmpty` is set, where
|
|
353
|
+
* `flatten` keeps them as holes in a range.
|
|
354
|
+
*/
|
|
355
|
+
getValuesFlat<TS extends Scalar = T>(options?: IRange.IteratorOptions): TS[];
|
|
329
356
|
/**
|
|
330
357
|
* Returns the number of columns of the range.
|
|
331
358
|
*/
|
package/types/src/index.d.ts
CHANGED
|
@@ -6,11 +6,13 @@ export * from './ErrorPolicy';
|
|
|
6
6
|
export * from './Repeating';
|
|
7
7
|
export * from './Flatten';
|
|
8
8
|
export * from './Omittable';
|
|
9
|
+
export * from './Compat';
|
|
9
10
|
export * from './IRange';
|
|
10
11
|
export * from './IReferenceRange';
|
|
11
12
|
export * from './IRichData';
|
|
12
13
|
export * from './IFunction';
|
|
13
14
|
export * from './IFormulaContext';
|
|
15
|
+
export * from './IFunctionArguments';
|
|
14
16
|
export * from './LocaleProfile';
|
|
15
17
|
export * from './IRuntime';
|
|
16
18
|
export * from './IRangeStats';
|