@univerjs/sheets-formula 0.16.1 → 0.17.0-insiders.20260318-d69dc16

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.
Files changed (116) hide show
  1. package/lib/cjs/facade.js +1 -1
  2. package/lib/cjs/index.js +1 -1
  3. package/lib/cjs/locale/ca-ES.js +1 -1
  4. package/lib/cjs/locale/en-US.js +1 -1
  5. package/lib/cjs/locale/es-ES.js +1 -1
  6. package/lib/cjs/locale/fa-IR.js +1 -1
  7. package/lib/cjs/locale/fr-FR.js +1 -1
  8. package/lib/cjs/locale/ja-JP.js +1 -1
  9. package/lib/cjs/locale/ko-KR.js +1 -1
  10. package/lib/cjs/locale/ru-RU.js +1 -1
  11. package/lib/cjs/locale/sk-SK.js +1 -1
  12. package/lib/cjs/locale/vi-VN.js +1 -1
  13. package/lib/cjs/locale/zh-CN.js +1 -1
  14. package/lib/cjs/locale/zh-TW.js +1 -1
  15. package/lib/es/facade.js +1 -170
  16. package/lib/es/index.js +1 -16506
  17. package/lib/es/locale/ca-ES.js +1 -14
  18. package/lib/es/locale/en-US.js +1 -14
  19. package/lib/es/locale/es-ES.js +1 -14
  20. package/lib/es/locale/fa-IR.js +1 -14
  21. package/lib/es/locale/fr-FR.js +1 -14
  22. package/lib/es/locale/ja-JP.js +1 -14
  23. package/lib/es/locale/ko-KR.js +1 -14
  24. package/lib/es/locale/ru-RU.js +1 -14
  25. package/lib/es/locale/sk-SK.js +1 -14
  26. package/lib/es/locale/vi-VN.js +1 -14
  27. package/lib/es/locale/zh-CN.js +1 -14
  28. package/lib/es/locale/zh-TW.js +1 -14
  29. package/lib/facade.js +1 -170
  30. package/lib/index.js +1 -16506
  31. package/lib/locale/ca-ES.js +1 -14
  32. package/lib/locale/en-US.js +1 -14
  33. package/lib/locale/es-ES.js +1 -14
  34. package/lib/locale/fa-IR.js +1 -14
  35. package/lib/locale/fr-FR.js +1 -14
  36. package/lib/locale/ja-JP.js +1 -14
  37. package/lib/locale/ko-KR.js +1 -14
  38. package/lib/locale/ru-RU.js +1 -14
  39. package/lib/locale/sk-SK.js +1 -14
  40. package/lib/locale/vi-VN.js +1 -14
  41. package/lib/locale/zh-CN.js +1 -14
  42. package/lib/locale/zh-TW.js +1 -14
  43. package/lib/types/commands/commands/insert-function.command.d.ts +16 -1
  44. package/lib/types/commands/commands/quick-sum.command.d.ts +16 -1
  45. package/lib/types/{controllers/config.schema.d.ts → config/config.d.ts} +17 -2
  46. package/lib/types/controllers/active-dirty.controller.d.ts +15 -0
  47. package/lib/types/controllers/array-formula-cell-interceptor.controller.d.ts +15 -0
  48. package/lib/types/controllers/defined-name.controller.d.ts +15 -0
  49. package/lib/types/{services/__test__/formula-ref.spec.d.ts → controllers/formula-auto-fill.controller.d.ts} +10 -1
  50. package/lib/types/controllers/formula.controller.d.ts +15 -0
  51. package/lib/types/controllers/image-formula-cell-interceptor.controller.d.ts +15 -0
  52. package/lib/types/controllers/super-table.controller.d.ts +15 -0
  53. package/lib/types/controllers/trigger-calculation.controller.d.ts +16 -1
  54. package/lib/types/controllers/update-defined-name.controller.d.ts +15 -0
  55. package/lib/types/controllers/update-formula.controller.d.ts +15 -0
  56. package/lib/types/controllers/utils/offset-formula-data.d.ts +17 -2
  57. package/lib/types/controllers/utils/ref-range-formula.d.ts +17 -2
  58. package/lib/types/controllers/utils/ref-range-move.d.ts +17 -2
  59. package/lib/types/controllers/utils/ref-range-param.d.ts +17 -2
  60. package/lib/types/facade/f-enum.d.ts +15 -0
  61. package/lib/types/facade/f-formula.d.ts +18 -3
  62. package/lib/types/facade/f-range.d.ts +16 -1
  63. package/lib/types/facade/f-univer.d.ts +17 -2
  64. package/lib/types/facade/f-workbook.d.ts +16 -1
  65. package/lib/types/index.d.ts +3 -2
  66. package/lib/types/locale/ca-ES.d.ts +16 -1
  67. package/lib/types/locale/es-ES.d.ts +16 -1
  68. package/lib/types/locale/fa-IR.d.ts +16 -1
  69. package/lib/types/locale/fr-FR.d.ts +16 -1
  70. package/lib/types/locale/ja-JP.d.ts +16 -1
  71. package/lib/types/locale/ko-KR.d.ts +16 -1
  72. package/lib/types/locale/ru-RU.d.ts +16 -1
  73. package/lib/types/locale/sk-SK.d.ts +16 -1
  74. package/lib/types/locale/vi-VN.d.ts +16 -1
  75. package/lib/types/locale/zh-CN.d.ts +16 -1
  76. package/lib/types/locale/zh-TW.d.ts +16 -1
  77. package/lib/types/plugin.d.ts +20 -1
  78. package/lib/types/services/description.service.d.ts +20 -3
  79. package/lib/types/services/formula-ref-range.service.d.ts +19 -2
  80. package/lib/types/services/function-list/array.d.ts +16 -1
  81. package/lib/types/services/function-list/compatibility.d.ts +16 -1
  82. package/lib/types/services/function-list/cube.d.ts +16 -1
  83. package/lib/types/services/function-list/database.d.ts +16 -1
  84. package/lib/types/services/function-list/date.d.ts +16 -1
  85. package/lib/types/services/function-list/engineering.d.ts +16 -1
  86. package/lib/types/services/function-list/financial.d.ts +16 -1
  87. package/lib/types/services/function-list/function-list.d.ts +16 -1
  88. package/lib/types/services/function-list/information.d.ts +16 -1
  89. package/lib/types/services/function-list/logical.d.ts +16 -1
  90. package/lib/types/services/function-list/lookup.d.ts +16 -1
  91. package/lib/types/services/function-list/math.d.ts +16 -1
  92. package/lib/types/services/function-list/statistical.d.ts +16 -1
  93. package/lib/types/services/function-list/text.d.ts +16 -1
  94. package/lib/types/services/function-list/univer.d.ts +16 -1
  95. package/lib/types/services/function-list/web.d.ts +16 -1
  96. package/lib/types/services/register-function.service.d.ts +20 -3
  97. package/lib/types/services/remote/remote-register-function.service.d.ts +16 -1
  98. package/lib/types/services/utils.d.ts +17 -2
  99. package/lib/types/util/calculate.d.ts +17 -2
  100. package/lib/umd/facade.js +1 -1
  101. package/lib/umd/index.js +1 -1
  102. package/lib/umd/locale/ca-ES.js +1 -1
  103. package/lib/umd/locale/en-US.js +1 -1
  104. package/lib/umd/locale/es-ES.js +1 -1
  105. package/lib/umd/locale/fa-IR.js +1 -1
  106. package/lib/umd/locale/fr-FR.js +1 -1
  107. package/lib/umd/locale/ja-JP.js +1 -1
  108. package/lib/umd/locale/ko-KR.js +1 -1
  109. package/lib/umd/locale/ru-RU.js +1 -1
  110. package/lib/umd/locale/sk-SK.js +1 -1
  111. package/lib/umd/locale/vi-VN.js +1 -1
  112. package/lib/umd/locale/zh-CN.js +1 -1
  113. package/lib/umd/locale/zh-TW.js +1 -1
  114. package/package.json +12 -11
  115. package/LICENSE +0 -176
  116. package/lib/types/services/__test__/util.d.ts +0 -7
package/lib/cjs/facade.js CHANGED
@@ -1 +1 @@
1
- "use strict";const C=require("@univerjs/core"),I=require("@univerjs/core/facade"),s=require("@univerjs/engine-formula"),c=require("@univerjs/sheets-formula"),b=require("@univerjs/engine-formula/facade"),y=require("@univerjs/sheets"),R=require("@univerjs/sheets/facade");class p extends I.FUniver{_initialize(){this._debouncedFormulaCalculation=C.debounce(()=>{this._commandService.executeCommand(s.SetTriggerFormulaCalculationStartMutation.id,{commands:[],forceCalculation:!0},{onlyLocal:!0})},10)}registerFunction(t){let o=this._injector.get(c.IRegisterFunctionService);o||(this._injector.add([c.IRegisterFunctionService,{useClass:c.RegisterFunctionService}]),o=this._injector.get(c.IRegisterFunctionService));const e=o.registerFunctions(t);return this._debouncedFormulaCalculation(),e}}I.FUniver.extend(p);class M extends b.FFormula{_initialize(){this._debouncedFormulaCalculation=C.debounce(()=>{this._commandService.executeCommand(s.SetTriggerFormulaCalculationStartMutation.id,{commands:[],forceCalculation:!0},{onlyLocal:!0})},10)}setInitialFormulaComputing(t){const e=this._injector.get(C.LifecycleService).stage,n=this._injector.get(C.ILogService),i=this._injector.get(C.IConfigService);e>C.LifecycleStages.Starting&&n.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.");const r=i.getConfig(c.PLUGIN_CONFIG_KEY_BASE);if(!r){i.setConfig(c.PLUGIN_CONFIG_KEY_BASE,{initialFormulaComputing:t});return}r.initialFormulaComputing=t}registerFunction(t,o,e){var a;let n=this._injector.get(c.IRegisterFunctionService);n||(this._injector.add([c.IRegisterFunctionService,{useClass:c.RegisterFunctionService}]),n=this._injector.get(c.IRegisterFunctionService));const i={name:t,func:o,description:typeof e=="string"?e:(a=e==null?void 0:e.description)!=null?a:"",locales:typeof e=="object"?e.locales:void 0},r=n.registerFunction(i);return this._debouncedFormulaCalculation(),r}registerAsyncFunction(t,o,e){var a;let n=this._injector.get(c.IRegisterFunctionService);n||(this._injector.add([c.IRegisterFunctionService,{useClass:c.RegisterFunctionService}]),n=this._injector.get(c.IRegisterFunctionService));const i={name:t,func:o,description:typeof e=="string"?e:(a=e==null?void 0:e.description)!=null?a:"",locales:typeof e=="object"?e.locales:void 0},r=n.registerAsyncFunction(i);return this._debouncedFormulaCalculation(),r}calculationResultApplied(t){let o=!1,e=!1,n=null;return this._commandService.onCommandExecuted((i,r)=>{i.id!==s.SetFormulaCalculationResultMutation.id&&i.id!==y.SetRangeValuesMutation.id||(i.id===s.SetFormulaCalculationResultMutation.id&&(o=!0,n=i.params),i.id===y.SetRangeValuesMutation.id&&(r!=null&&r.applyFormulaCalculationResult)&&(e=!0),!(!o||!e)&&requestIdleCallback(()=>{t(n)}))})}onCalculationResultApplied(){return new Promise((t,o)=>{let e=!1,n=!1;const i=setTimeout(()=>{l(),o(new Error("Calculation end timeout"))},6e4),r=setTimeout(()=>{e||(l(),t())},500),a=this.calculationProcessing(g=>{const{stage:m,totalArrayFormulasToCalculate:f,totalFormulasToCalculate:d}=g;if(m===s.FormulaExecuteStageType.START_CALCULATION&&f+d===0){l(),t();return}e||(e=!0,clearTimeout(r))}),_=this.calculationResultApplied(()=>{n||(n=!0,l(),t())});function l(){clearTimeout(i),clearTimeout(r),a.dispose(),_.dispose()}})}}b.FFormula.extend(M);class j{get CalculationMode(){return c.CalculationMode}}I.FEnum.extend(j);class E extends R.FWorkbook{getAllFormulaError(){const t=[],o=this._workbook,e=o.getUnitId(),n=o.getSheets(),i=this._injector.get(s.FormulaDataModel).getArrayFormulaCellData();return n.forEach(r=>{var m;const a=r.getName(),_=r.getSheetId(),l=r.getCellMatrix(),g=((m=i==null?void 0:i[e])==null?void 0:m[_])||{};l.forValue((f,d,h)=>{var S;if(!h)return;const F=(S=g==null?void 0:g[f])==null?void 0:S[d],u=s.extractFormulaError(h,!!F);u&&t.push({sheetName:a,row:f,column:d,formula:h.f||"",errorType:u})})}),t}}R.FWorkbook.extend(E);class T extends R.FRange{getFormulaError(){var d,h;const t=[],o=this._workbook.getUnitId(),e=this._worksheet.getSheetId(),n=this._worksheet.getName(),i=this._workbook.getSheetBySheetId(e);if(!i)return t;const r=this._injector.get(s.FormulaDataModel).getArrayFormulaCellData(),a=((d=r==null?void 0:r[o])==null?void 0:d[e])||{},_=i.getCellMatrix(),{startRow:l,endRow:g,startColumn:m,endColumn:f}=this._range;for(let F=l;F<=g;F++)for(let u=m;u<=f;u++){const S=_.getValue(F,u);if(!S)continue;const k=(h=a==null?void 0:a[F])==null?void 0:h[u],x=s.extractFormulaError(S,!!k);x&&t.push({sheetName:n,row:F,column:u,formula:S.f||"",errorType:x})}return t}}R.FRange.extend(T);
1
+ let e=require(`@univerjs/core`),t=require(`@univerjs/core/facade`),n=require(`@univerjs/engine-formula`),r=require(`@univerjs/sheets-formula`),i=require(`@univerjs/engine-formula/facade`),a=require(`@univerjs/sheets`),o=require(`@univerjs/sheets/facade`);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);