@univerjs/sheets-formula 0.19.0 → 0.20.0

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.
@@ -13,20 +13,21 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+ import { FEnum } from '@univerjs/core/facade';
16
17
  import { CalculationMode } from '@univerjs/sheets-formula';
17
18
  /**
18
19
  * @ignore
19
20
  */
20
- export interface IFSheetsFormulaEnum {
21
+ export interface IFSheetsFormulaEnumMixin {
21
22
  /**
22
23
  * Define the calculation mode during initialization
23
24
  */
24
25
  CalculationMode: typeof CalculationMode;
25
26
  }
26
- export declare class FSheetsFormulaEnum implements IFSheetsFormulaEnum {
27
+ export declare class FSheetsFormulaEnumMixin extends FEnum implements IFSheetsFormulaEnumMixin {
27
28
  get CalculationMode(): typeof CalculationMode;
28
29
  }
29
30
  declare module '@univerjs/core/facade' {
30
- interface FEnum extends IFSheetsFormulaEnum {
31
+ interface FEnum extends IFSheetsFormulaEnumMixin {
31
32
  }
32
33
  }
package/lib/umd/facade.js CHANGED
@@ -1 +1 @@
1
- (function(e,t){typeof exports==`object`&&typeof module<`u`?t(require(`@univerjs/core`),require(`@univerjs/core/facade`),require(`@univerjs/engine-formula`),require(`@univerjs/sheets-formula`),require(`@univerjs/engine-formula/facade`),require(`@univerjs/sheets`),require(`@univerjs/sheets/facade`)):typeof define==`function`&&define.amd?define([`@univerjs/core`,`@univerjs/core/facade`,`@univerjs/engine-formula`,`@univerjs/sheets-formula`,`@univerjs/engine-formula/facade`,`@univerjs/sheets`,`@univerjs/sheets/facade`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverCore,e.UniverCoreFacade,e.UniverEngineFormula,e.UniverSheetsFormula,e.UniverEngineFormulaFacade,e.UniverSheets,e.UniverSheetsFacade))})(this,function(e,t,n,r,i,a,o){var s=class extends t.FUniver{_initialize(){this._debouncedFormulaCalculation=(0,e.debounce)(()=>{this._commandService.executeCommand(n.SetTriggerFormulaCalculationStartMutation.id,{commands:[],forceCalculation:!0},{onlyLocal:!0})},10)}registerFunction(e){let t=this._injector.get(r.IRegisterFunctionService);t||(this._injector.add([r.IRegisterFunctionService,{useClass:r.RegisterFunctionService}]),t=this._injector.get(r.IRegisterFunctionService));let n=t.registerFunctions(e);return this._debouncedFormulaCalculation(),n}};t.FUniver.extend(s);var c=class extends i.FFormula{_initialize(){this._debouncedFormulaCalculation=(0,e.debounce)(()=>{this._commandService.executeCommand(n.SetTriggerFormulaCalculationStartMutation.id,{commands:[],forceCalculation:!0},{onlyLocal:!0})},10)}setInitialFormulaComputing(t){let n=this._injector.get(e.LifecycleService).stage,i=this._injector.get(e.ILogService),a=this._injector.get(e.IConfigService);n>e.LifecycleStages.Starting&&i.warn(`[FFormula]`,`CalculationMode is called after the Starting lifecycle and will take effect the next time the Univer Sheet is constructed. If you want it to take effect when the Univer Sheet is initialized this time, consider calling it before the Ready lifecycle or using configuration.`);let o=a.getConfig(r.PLUGIN_CONFIG_KEY_BASE);if(!o){a.setConfig(r.PLUGIN_CONFIG_KEY_BASE,{initialFormulaComputing:t});return}o.initialFormulaComputing=t}registerFunction(e,t,n){var i;let a=this._injector.get(r.IRegisterFunctionService);a||(this._injector.add([r.IRegisterFunctionService,{useClass:r.RegisterFunctionService}]),a=this._injector.get(r.IRegisterFunctionService));let o={name:e,func:t,description:typeof n==`string`?n:(i=n==null?void 0:n.description)==null?``:i,locales:typeof n==`object`?n.locales:void 0},s=a.registerFunction(o);return this._debouncedFormulaCalculation(),s}registerAsyncFunction(e,t,n){var i;let a=this._injector.get(r.IRegisterFunctionService);a||(this._injector.add([r.IRegisterFunctionService,{useClass:r.RegisterFunctionService}]),a=this._injector.get(r.IRegisterFunctionService));let o={name:e,func:t,description:typeof n==`string`?n:(i=n==null?void 0:n.description)==null?``:i,locales:typeof n==`object`?n.locales:void 0},s=a.registerAsyncFunction(o);return this._debouncedFormulaCalculation(),s}calculationResultApplied(e){let t=!1,r=!1,i=null;return this._commandService.onCommandExecuted((o,s)=>{o.id!==n.SetFormulaCalculationResultMutation.id&&o.id!==a.SetRangeValuesMutation.id||(o.id===n.SetFormulaCalculationResultMutation.id&&(t=!0,i=o.params),o.id===a.SetRangeValuesMutation.id&&s!=null&&s.applyFormulaCalculationResult&&(r=!0),!(!t||!r)&&requestIdleCallback(()=>{e(i)}))})}onCalculationResultApplied(){return new Promise((e,t)=>{let r=!1,i=!1,a=setTimeout(()=>{l(),t(Error(`Calculation end timeout`))},6e4),o=setTimeout(()=>{r||(l(),e())},500),s=this.calculationProcessing(t=>{let{stage:i,totalArrayFormulasToCalculate:a,totalFormulasToCalculate:s}=t;if(i===n.FormulaExecuteStageType.START_CALCULATION&&a+s===0){l(),e();return}r||(r=!0,clearTimeout(o))}),c=this.calculationResultApplied(()=>{i||(i=!0,l(),e())});function l(){clearTimeout(a),clearTimeout(o),s.dispose(),c.dispose()}})}};i.FFormula.extend(c);var l=class{get CalculationMode(){return r.CalculationMode}};t.FEnum.extend(l);var u=class extends o.FWorkbook{getAllFormulaError(){let e=[],t=this._workbook,r=t.getUnitId(),i=t.getSheets(),a=this._injector.get(n.FormulaDataModel).getArrayFormulaCellData();return i.forEach(t=>{var i;let o=t.getName(),s=t.getSheetId(),c=t.getCellMatrix(),l=(a==null||(i=a[r])==null?void 0:i[s])||{};c.forValue((t,r,i)=>{var a;if(!i)return;let s=(0,n.extractFormulaError)(i,!!(!(l==null||(a=l[t])==null)&&a[r]));s&&e.push({sheetName:o,row:t,column:r,formula:i.f||``,errorType:s})})}),e}};o.FWorkbook.extend(u);var d=class extends o.FRange{getFormulaError(){var e;let t=[],r=this._workbook.getUnitId(),i=this._worksheet.getSheetId(),a=this._worksheet.getName(),o=this._workbook.getSheetBySheetId(i);if(!o)return t;let s=this._injector.get(n.FormulaDataModel).getArrayFormulaCellData(),c=(s==null||(e=s[r])==null?void 0:e[i])||{},l=o.getCellMatrix(),{startRow:u,endRow:d,startColumn:f,endColumn:p}=this._range;for(let e=u;e<=d;e++)for(let r=f;r<=p;r++){var m;let i=l.getValue(e,r);if(!i)continue;let o=(0,n.extractFormulaError)(i,!!(!(c==null||(m=c[e])==null)&&m[r]));o&&t.push({sheetName:a,row:e,column:r,formula:i.f||``,errorType:o})}return t}};o.FRange.extend(d)});
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(require(`@univerjs/core`),require(`@univerjs/core/facade`),require(`@univerjs/engine-formula`),require(`@univerjs/sheets-formula`),require(`@univerjs/engine-formula/facade`),require(`@univerjs/sheets`),require(`@univerjs/sheets/facade`)):typeof define==`function`&&define.amd?define([`@univerjs/core`,`@univerjs/core/facade`,`@univerjs/engine-formula`,`@univerjs/sheets-formula`,`@univerjs/engine-formula/facade`,`@univerjs/sheets`,`@univerjs/sheets/facade`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverCore,e.UniverCoreFacade,e.UniverEngineFormula,e.UniverSheetsFormula,e.UniverEngineFormulaFacade,e.UniverSheets,e.UniverSheetsFacade))})(this,function(e,t,n,r,i,a,o){var s=class extends t.FUniver{_initialize(){this._debouncedFormulaCalculation=(0,e.debounce)(()=>{this._commandService.executeCommand(n.SetTriggerFormulaCalculationStartMutation.id,{commands:[],forceCalculation:!0},{onlyLocal:!0})},10)}registerFunction(e){let t=this._injector.get(r.IRegisterFunctionService);t||(this._injector.add([r.IRegisterFunctionService,{useClass:r.RegisterFunctionService}]),t=this._injector.get(r.IRegisterFunctionService));let n=t.registerFunctions(e);return this._debouncedFormulaCalculation(),n}};t.FUniver.extend(s);var c=class extends i.FFormula{_initialize(){this._debouncedFormulaCalculation=(0,e.debounce)(()=>{this._commandService.executeCommand(n.SetTriggerFormulaCalculationStartMutation.id,{commands:[],forceCalculation:!0},{onlyLocal:!0})},10)}setInitialFormulaComputing(t){let n=this._injector.get(e.LifecycleService).stage,i=this._injector.get(e.ILogService),a=this._injector.get(e.IConfigService);n>e.LifecycleStages.Starting&&i.warn(`[FFormula]`,`CalculationMode is called after the Starting lifecycle and will take effect the next time the Univer Sheet is constructed. If you want it to take effect when the Univer Sheet is initialized this time, consider calling it before the Ready lifecycle or using configuration.`);let o=a.getConfig(r.PLUGIN_CONFIG_KEY_BASE);if(!o){a.setConfig(r.PLUGIN_CONFIG_KEY_BASE,{initialFormulaComputing:t});return}o.initialFormulaComputing=t}registerFunction(e,t,n){var i;let a=this._injector.get(r.IRegisterFunctionService);a||(this._injector.add([r.IRegisterFunctionService,{useClass:r.RegisterFunctionService}]),a=this._injector.get(r.IRegisterFunctionService));let o={name:e,func:t,description:typeof n==`string`?n:(i=n==null?void 0:n.description)==null?``:i,locales:typeof n==`object`?n.locales:void 0},s=a.registerFunction(o);return this._debouncedFormulaCalculation(),s}registerAsyncFunction(e,t,n){var i;let a=this._injector.get(r.IRegisterFunctionService);a||(this._injector.add([r.IRegisterFunctionService,{useClass:r.RegisterFunctionService}]),a=this._injector.get(r.IRegisterFunctionService));let o={name:e,func:t,description:typeof n==`string`?n:(i=n==null?void 0:n.description)==null?``:i,locales:typeof n==`object`?n.locales:void 0},s=a.registerAsyncFunction(o);return this._debouncedFormulaCalculation(),s}calculationResultApplied(e){let t=!1,r=!1,i=null;return this._commandService.onCommandExecuted((o,s)=>{o.id!==n.SetFormulaCalculationResultMutation.id&&o.id!==a.SetRangeValuesMutation.id||(o.id===n.SetFormulaCalculationResultMutation.id&&(t=!0,i=o.params),o.id===a.SetRangeValuesMutation.id&&s!=null&&s.applyFormulaCalculationResult&&(r=!0),!(!t||!r)&&requestIdleCallback(()=>{e(i)}))})}onCalculationResultApplied(){return new Promise((e,t)=>{let r=!1,i=!1,a=setTimeout(()=>{l(),t(Error(`Calculation end timeout`))},6e4),o=setTimeout(()=>{r||(l(),e())},500),s=this.calculationProcessing(t=>{let{stage:i,totalArrayFormulasToCalculate:a,totalFormulasToCalculate:s}=t;if(i===n.FormulaExecuteStageType.START_CALCULATION&&a+s===0){l(),e();return}r||(r=!0,clearTimeout(o))}),c=this.calculationResultApplied(()=>{i||(i=!0,l(),e())});function l(){clearTimeout(a),clearTimeout(o),s.dispose(),c.dispose()}})}};i.FFormula.extend(c);var l=class extends t.FEnum{get CalculationMode(){return r.CalculationMode}};t.FEnum.extend(l);var u=class extends o.FWorkbook{getAllFormulaError(){let e=[],t=this._workbook,r=t.getUnitId(),i=t.getSheets(),a=this._injector.get(n.FormulaDataModel).getArrayFormulaCellData();return i.forEach(t=>{var i;let o=t.getName(),s=t.getSheetId(),c=t.getCellMatrix(),l=(a==null||(i=a[r])==null?void 0:i[s])||{};c.forValue((t,r,i)=>{var a;if(!i)return;let s=(0,n.extractFormulaError)(i,!!(!(l==null||(a=l[t])==null)&&a[r]));s&&e.push({sheetName:o,row:t,column:r,formula:i.f||``,errorType:s})})}),e}};o.FWorkbook.extend(u);var d=class extends o.FRange{getFormulaError(){var e;let t=[],r=this._workbook.getUnitId(),i=this._worksheet.getSheetId(),a=this._worksheet.getName(),o=this._workbook.getSheetBySheetId(i);if(!o)return t;let s=this._injector.get(n.FormulaDataModel).getArrayFormulaCellData(),c=(s==null||(e=s[r])==null?void 0:e[i])||{},l=o.getCellMatrix(),{startRow:u,endRow:d,startColumn:f,endColumn:p}=this._range;for(let e=u;e<=d;e++)for(let r=f;r<=p;r++){var m;let i=l.getValue(e,r);if(!i)continue;let o=(0,n.extractFormulaError)(i,!!(!(c==null||(m=c[e])==null)&&m[r]));o&&t.push({sheetName:a,row:e,column:r,formula:i.f||``,errorType:o})}return t}};o.FRange.extend(d)});