@odoo/o-spreadsheet 16.4.8 → 16.4.9

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.
@@ -1197,7 +1197,17 @@ const timeRegexp = /((\d+(:\d+)?(:\d+)?\s*(AM|PM))|(\d+:\d+(:\d+)?))$/;
1197
1197
  function isDateTime(str, locale) {
1198
1198
  return parseDateTime(str, locale) !== null;
1199
1199
  }
1200
+ const CACHE = new Map();
1200
1201
  function parseDateTime(str, locale) {
1202
+ if (!CACHE.has(locale)) {
1203
+ CACHE.set(locale, new Map());
1204
+ }
1205
+ if (!CACHE.get(locale).has(str)) {
1206
+ CACHE.get(locale).set(str, _parseDateTime(str, locale));
1207
+ }
1208
+ return CACHE.get(locale).get(str);
1209
+ }
1210
+ function _parseDateTime(str, locale) {
1201
1211
  str = str.trim();
1202
1212
  let time = null;
1203
1213
  const timeMatch = str.match(timeRegexp);
@@ -3016,8 +3026,9 @@ class RangeImpl {
3016
3026
  }
3017
3027
  get zone() {
3018
3028
  const { left, top, bottom, right } = this._zone;
3019
- if (right !== undefined && bottom !== undefined)
3020
- return { left, top, right, bottom };
3029
+ if (right !== undefined && bottom !== undefined) {
3030
+ return this._zone;
3031
+ }
3021
3032
  else if (bottom === undefined && right !== undefined) {
3022
3033
  return { right, top, left, bottom: this.getSheetSize(this.sheetId).numberOfRows - 1 };
3023
3034
  }
@@ -4287,7 +4298,7 @@ var LAYERS;
4287
4298
  const SORT_TYPES_ORDER = ["number", "string", "boolean", "undefined"];
4288
4299
  function assert(condition, message) {
4289
4300
  if (!condition()) {
4290
- throw new Error(message);
4301
+ throw new EvaluationError(CellErrorType.GenericError, message);
4291
4302
  }
4292
4303
  }
4293
4304
  // -----------------------------------------------------------------------------
@@ -4932,7 +4943,7 @@ function _createEvaluatedCell(value, localeFormat) {
4932
4943
  return textCell((value || "").toString(), localeFormat);
4933
4944
  }
4934
4945
  catch (error) {
4935
- return errorCell((value || "").toString(), new EvaluationError(CellErrorType.GenericError, error.message || DEFAULT_ERROR_MESSAGE));
4946
+ return errorCell(new EvaluationError(CellErrorType.GenericError, error.message || DEFAULT_ERROR_MESSAGE));
4936
4947
  }
4937
4948
  }
4938
4949
  function textCell(value, localeFormat) {
@@ -4999,7 +5010,7 @@ function booleanCell(value, localeFormat) {
4999
5010
  formattedValue,
5000
5011
  };
5001
5012
  }
5002
- function errorCell(content, error) {
5013
+ function errorCell(error) {
5003
5014
  return {
5004
5015
  type: CellValueType.error,
5005
5016
  value: error.errorType,
@@ -31821,10 +31832,11 @@ class CellPlugin extends CorePlugin {
31821
31832
  * Reconstructs the original formula string based on a normalized form and its dependencies
31822
31833
  */
31823
31834
  buildFormulaContent(sheetId, cell, dependencies) {
31824
- const ranges = dependencies || [...cell.dependencies];
31835
+ const ranges = dependencies || cell.dependencies;
31836
+ let rangeIndex = 0;
31825
31837
  return concat(cell.compiledFormula.tokens.map((token) => {
31826
31838
  if (token.type === "REFERENCE") {
31827
- const range = ranges.shift();
31839
+ const range = ranges[rangeIndex++];
31828
31840
  return this.getters.getRangeString(range, sheetId);
31829
31841
  }
31830
31842
  return token.value;
@@ -35432,7 +35444,7 @@ class CompilationParametersBuilder {
35432
35444
  const evaluatedCell = this.getEvaluatedCell(position);
35433
35445
  if (evaluatedCell.type === CellValueType.empty) {
35434
35446
  const cell = this.getters.getCell(position);
35435
- if (!cell || cell.content === "") {
35447
+ if (!cell || (!cell.isFormula && cell.content === "")) {
35436
35448
  return undefined;
35437
35449
  }
35438
35450
  }
@@ -35652,7 +35664,7 @@ class Evaluator {
35652
35664
  constructor(context, getters) {
35653
35665
  this.context = context;
35654
35666
  this.getters = getters;
35655
- this.compilationParams = buildCompilationParameters(context, getters, (position) => this.computeCell(this.encodePosition(position)));
35667
+ this.compilationParams = buildCompilationParameters(this.context, this.getters, this.computeAndSave.bind(this));
35656
35668
  }
35657
35669
  getEvaluatedCell(position) {
35658
35670
  return (this.evaluatedCells.get(this.encodePosition(position)) ||
@@ -35680,7 +35692,7 @@ class Evaluator {
35680
35692
  this.formulaDependencies().addDependencies(positionId, dependencies);
35681
35693
  }
35682
35694
  updateCompilationParameters() {
35683
- this.compilationParams = buildCompilationParameters(this.context, this.getters, (position) => this.computeCell(this.encodePosition(position)));
35695
+ this.compilationParams = buildCompilationParameters(this.context, this.getters, this.computeAndSave.bind(this));
35684
35696
  }
35685
35697
  evaluateCells(positions) {
35686
35698
  const cells = positions.map(this.encodePosition.bind(this));
@@ -35796,15 +35808,21 @@ class Evaluator {
35796
35808
  this.cellsBeingComputed.delete(cellId);
35797
35809
  }
35798
35810
  }
35811
+ computeAndSave(position) {
35812
+ const positionId = this.encodePosition(position);
35813
+ const evaluatedCell = this.computeCell(positionId);
35814
+ if (!this.evaluatedCells.has(positionId)) {
35815
+ this.setEvaluatedCell(positionId, evaluatedCell);
35816
+ }
35817
+ return evaluatedCell;
35818
+ }
35799
35819
  handleError(e, cell) {
35800
- if (!(e instanceof Error)) {
35801
- e = new Error(e);
35820
+ if (!(e instanceof EvaluationError)) {
35821
+ e = new EvaluationError(CellErrorType.GenericError, e.message);
35802
35822
  }
35803
- const msg = e?.errorType || CellErrorType.GenericError;
35804
- // apply function name
35805
35823
  const __lastFnCalled = this.compilationParams[2].__lastFnCalled || "";
35806
- const error = new EvaluationError(msg, e.message.replace("[[FUNCTION_NAME]]", __lastFnCalled), e.logLevel !== undefined ? e.logLevel : CellErrorLevel.error);
35807
- return errorCell(cell.content, error);
35824
+ e.message = e.message.replace("[[FUNCTION_NAME]]", __lastFnCalled);
35825
+ return errorCell(e);
35808
35826
  }
35809
35827
  computeFormulaCell(cellData) {
35810
35828
  const cellId = cellData.id;
@@ -50693,6 +50711,6 @@ exports.setTranslationMethod = setTranslationMethod;
50693
50711
  exports.tokenize = tokenize;
50694
50712
 
50695
50713
 
50696
- __info__.version = '16.4.8';
50697
- __info__.date = '2023-10-03T12:45:33.807Z';
50698
- __info__.hash = 'c614d64';
50714
+ __info__.version = '16.4.9';
50715
+ __info__.date = '2023-10-10T07:28:12.772Z';
50716
+ __info__.hash = '998c612';
@@ -962,7 +962,7 @@ declare class RangeImpl implements Range {
962
962
  constructor(args: ConstructorArgs, getSheetSize: (sheetId: UID) => ZoneDimension);
963
963
  static fromRange(range: Range, getters: CoreGetters): RangeImpl;
964
964
  get unboundedZone(): UnboundedZone;
965
- get zone(): Zone;
965
+ get zone(): Readonly<Zone>;
966
966
  static getRangeParts(xc: string, zone: UnboundedZone): RangePart[];
967
967
  get isFullCol(): boolean;
968
968
  get isFullRow(): boolean;
@@ -1193,7 +1193,17 @@ const timeRegexp = /((\d+(:\d+)?(:\d+)?\s*(AM|PM))|(\d+:\d+(:\d+)?))$/;
1193
1193
  function isDateTime(str, locale) {
1194
1194
  return parseDateTime(str, locale) !== null;
1195
1195
  }
1196
+ const CACHE = new Map();
1196
1197
  function parseDateTime(str, locale) {
1198
+ if (!CACHE.has(locale)) {
1199
+ CACHE.set(locale, new Map());
1200
+ }
1201
+ if (!CACHE.get(locale).has(str)) {
1202
+ CACHE.get(locale).set(str, _parseDateTime(str, locale));
1203
+ }
1204
+ return CACHE.get(locale).get(str);
1205
+ }
1206
+ function _parseDateTime(str, locale) {
1197
1207
  str = str.trim();
1198
1208
  let time = null;
1199
1209
  const timeMatch = str.match(timeRegexp);
@@ -3012,8 +3022,9 @@ class RangeImpl {
3012
3022
  }
3013
3023
  get zone() {
3014
3024
  const { left, top, bottom, right } = this._zone;
3015
- if (right !== undefined && bottom !== undefined)
3016
- return { left, top, right, bottom };
3025
+ if (right !== undefined && bottom !== undefined) {
3026
+ return this._zone;
3027
+ }
3017
3028
  else if (bottom === undefined && right !== undefined) {
3018
3029
  return { right, top, left, bottom: this.getSheetSize(this.sheetId).numberOfRows - 1 };
3019
3030
  }
@@ -4283,7 +4294,7 @@ var LAYERS;
4283
4294
  const SORT_TYPES_ORDER = ["number", "string", "boolean", "undefined"];
4284
4295
  function assert(condition, message) {
4285
4296
  if (!condition()) {
4286
- throw new Error(message);
4297
+ throw new EvaluationError(CellErrorType.GenericError, message);
4287
4298
  }
4288
4299
  }
4289
4300
  // -----------------------------------------------------------------------------
@@ -4928,7 +4939,7 @@ function _createEvaluatedCell(value, localeFormat) {
4928
4939
  return textCell((value || "").toString(), localeFormat);
4929
4940
  }
4930
4941
  catch (error) {
4931
- return errorCell((value || "").toString(), new EvaluationError(CellErrorType.GenericError, error.message || DEFAULT_ERROR_MESSAGE));
4942
+ return errorCell(new EvaluationError(CellErrorType.GenericError, error.message || DEFAULT_ERROR_MESSAGE));
4932
4943
  }
4933
4944
  }
4934
4945
  function textCell(value, localeFormat) {
@@ -4995,7 +5006,7 @@ function booleanCell(value, localeFormat) {
4995
5006
  formattedValue,
4996
5007
  };
4997
5008
  }
4998
- function errorCell(content, error) {
5009
+ function errorCell(error) {
4999
5010
  return {
5000
5011
  type: CellValueType.error,
5001
5012
  value: error.errorType,
@@ -31817,10 +31828,11 @@ class CellPlugin extends CorePlugin {
31817
31828
  * Reconstructs the original formula string based on a normalized form and its dependencies
31818
31829
  */
31819
31830
  buildFormulaContent(sheetId, cell, dependencies) {
31820
- const ranges = dependencies || [...cell.dependencies];
31831
+ const ranges = dependencies || cell.dependencies;
31832
+ let rangeIndex = 0;
31821
31833
  return concat(cell.compiledFormula.tokens.map((token) => {
31822
31834
  if (token.type === "REFERENCE") {
31823
- const range = ranges.shift();
31835
+ const range = ranges[rangeIndex++];
31824
31836
  return this.getters.getRangeString(range, sheetId);
31825
31837
  }
31826
31838
  return token.value;
@@ -35428,7 +35440,7 @@ class CompilationParametersBuilder {
35428
35440
  const evaluatedCell = this.getEvaluatedCell(position);
35429
35441
  if (evaluatedCell.type === CellValueType.empty) {
35430
35442
  const cell = this.getters.getCell(position);
35431
- if (!cell || cell.content === "") {
35443
+ if (!cell || (!cell.isFormula && cell.content === "")) {
35432
35444
  return undefined;
35433
35445
  }
35434
35446
  }
@@ -35648,7 +35660,7 @@ class Evaluator {
35648
35660
  constructor(context, getters) {
35649
35661
  this.context = context;
35650
35662
  this.getters = getters;
35651
- this.compilationParams = buildCompilationParameters(context, getters, (position) => this.computeCell(this.encodePosition(position)));
35663
+ this.compilationParams = buildCompilationParameters(this.context, this.getters, this.computeAndSave.bind(this));
35652
35664
  }
35653
35665
  getEvaluatedCell(position) {
35654
35666
  return (this.evaluatedCells.get(this.encodePosition(position)) ||
@@ -35676,7 +35688,7 @@ class Evaluator {
35676
35688
  this.formulaDependencies().addDependencies(positionId, dependencies);
35677
35689
  }
35678
35690
  updateCompilationParameters() {
35679
- this.compilationParams = buildCompilationParameters(this.context, this.getters, (position) => this.computeCell(this.encodePosition(position)));
35691
+ this.compilationParams = buildCompilationParameters(this.context, this.getters, this.computeAndSave.bind(this));
35680
35692
  }
35681
35693
  evaluateCells(positions) {
35682
35694
  const cells = positions.map(this.encodePosition.bind(this));
@@ -35792,15 +35804,21 @@ class Evaluator {
35792
35804
  this.cellsBeingComputed.delete(cellId);
35793
35805
  }
35794
35806
  }
35807
+ computeAndSave(position) {
35808
+ const positionId = this.encodePosition(position);
35809
+ const evaluatedCell = this.computeCell(positionId);
35810
+ if (!this.evaluatedCells.has(positionId)) {
35811
+ this.setEvaluatedCell(positionId, evaluatedCell);
35812
+ }
35813
+ return evaluatedCell;
35814
+ }
35795
35815
  handleError(e, cell) {
35796
- if (!(e instanceof Error)) {
35797
- e = new Error(e);
35816
+ if (!(e instanceof EvaluationError)) {
35817
+ e = new EvaluationError(CellErrorType.GenericError, e.message);
35798
35818
  }
35799
- const msg = e?.errorType || CellErrorType.GenericError;
35800
- // apply function name
35801
35819
  const __lastFnCalled = this.compilationParams[2].__lastFnCalled || "";
35802
- const error = new EvaluationError(msg, e.message.replace("[[FUNCTION_NAME]]", __lastFnCalled), e.logLevel !== undefined ? e.logLevel : CellErrorLevel.error);
35803
- return errorCell(cell.content, error);
35820
+ e.message = e.message.replace("[[FUNCTION_NAME]]", __lastFnCalled);
35821
+ return errorCell(e);
35804
35822
  }
35805
35823
  computeFormulaCell(cellData) {
35806
35824
  const cellId = cellData.id;
@@ -50657,6 +50675,6 @@ const constants = {
50657
50675
  export { AbstractChart, CommandResult, CorePlugin, DispatchResult, EvaluationError, Model, Registry, Revision, SPREADSHEET_DIMENSIONS, Spreadsheet, UIPlugin, __info__, addFunction, astToFormula, compile, components, constants, convertAstNodes, coreTypes, findCellInNewZone, functionCache, helpers, invalidateCFEvaluationCommands, invalidateDependenciesCommands, invalidateEvaluationCommands, iterateAstNodes, links, load, parse, readonlyAllowedCommands, registries, setDefaultSheetViewSize, setTranslationMethod, tokenize };
50658
50676
 
50659
50677
 
50660
- __info__.version = '16.4.8';
50661
- __info__.date = '2023-10-03T12:45:33.807Z';
50662
- __info__.hash = 'c614d64';
50678
+ __info__.version = '16.4.9';
50679
+ __info__.date = '2023-10-10T07:28:12.772Z';
50680
+ __info__.hash = '998c612';
@@ -1194,7 +1194,17 @@
1194
1194
  function isDateTime(str, locale) {
1195
1195
  return parseDateTime(str, locale) !== null;
1196
1196
  }
1197
+ const CACHE = new Map();
1197
1198
  function parseDateTime(str, locale) {
1199
+ if (!CACHE.has(locale)) {
1200
+ CACHE.set(locale, new Map());
1201
+ }
1202
+ if (!CACHE.get(locale).has(str)) {
1203
+ CACHE.get(locale).set(str, _parseDateTime(str, locale));
1204
+ }
1205
+ return CACHE.get(locale).get(str);
1206
+ }
1207
+ function _parseDateTime(str, locale) {
1198
1208
  str = str.trim();
1199
1209
  let time = null;
1200
1210
  const timeMatch = str.match(timeRegexp);
@@ -3013,8 +3023,9 @@
3013
3023
  }
3014
3024
  get zone() {
3015
3025
  const { left, top, bottom, right } = this._zone;
3016
- if (right !== undefined && bottom !== undefined)
3017
- return { left, top, right, bottom };
3026
+ if (right !== undefined && bottom !== undefined) {
3027
+ return this._zone;
3028
+ }
3018
3029
  else if (bottom === undefined && right !== undefined) {
3019
3030
  return { right, top, left, bottom: this.getSheetSize(this.sheetId).numberOfRows - 1 };
3020
3031
  }
@@ -4284,7 +4295,7 @@
4284
4295
  const SORT_TYPES_ORDER = ["number", "string", "boolean", "undefined"];
4285
4296
  function assert(condition, message) {
4286
4297
  if (!condition()) {
4287
- throw new Error(message);
4298
+ throw new EvaluationError(CellErrorType.GenericError, message);
4288
4299
  }
4289
4300
  }
4290
4301
  // -----------------------------------------------------------------------------
@@ -4929,7 +4940,7 @@
4929
4940
  return textCell((value || "").toString(), localeFormat);
4930
4941
  }
4931
4942
  catch (error) {
4932
- return errorCell((value || "").toString(), new EvaluationError(CellErrorType.GenericError, error.message || DEFAULT_ERROR_MESSAGE));
4943
+ return errorCell(new EvaluationError(CellErrorType.GenericError, error.message || DEFAULT_ERROR_MESSAGE));
4933
4944
  }
4934
4945
  }
4935
4946
  function textCell(value, localeFormat) {
@@ -4996,7 +5007,7 @@
4996
5007
  formattedValue,
4997
5008
  };
4998
5009
  }
4999
- function errorCell(content, error) {
5010
+ function errorCell(error) {
5000
5011
  return {
5001
5012
  type: CellValueType.error,
5002
5013
  value: error.errorType,
@@ -31818,10 +31829,11 @@
31818
31829
  * Reconstructs the original formula string based on a normalized form and its dependencies
31819
31830
  */
31820
31831
  buildFormulaContent(sheetId, cell, dependencies) {
31821
- const ranges = dependencies || [...cell.dependencies];
31832
+ const ranges = dependencies || cell.dependencies;
31833
+ let rangeIndex = 0;
31822
31834
  return concat(cell.compiledFormula.tokens.map((token) => {
31823
31835
  if (token.type === "REFERENCE") {
31824
- const range = ranges.shift();
31836
+ const range = ranges[rangeIndex++];
31825
31837
  return this.getters.getRangeString(range, sheetId);
31826
31838
  }
31827
31839
  return token.value;
@@ -35429,7 +35441,7 @@
35429
35441
  const evaluatedCell = this.getEvaluatedCell(position);
35430
35442
  if (evaluatedCell.type === CellValueType.empty) {
35431
35443
  const cell = this.getters.getCell(position);
35432
- if (!cell || cell.content === "") {
35444
+ if (!cell || (!cell.isFormula && cell.content === "")) {
35433
35445
  return undefined;
35434
35446
  }
35435
35447
  }
@@ -35649,7 +35661,7 @@
35649
35661
  constructor(context, getters) {
35650
35662
  this.context = context;
35651
35663
  this.getters = getters;
35652
- this.compilationParams = buildCompilationParameters(context, getters, (position) => this.computeCell(this.encodePosition(position)));
35664
+ this.compilationParams = buildCompilationParameters(this.context, this.getters, this.computeAndSave.bind(this));
35653
35665
  }
35654
35666
  getEvaluatedCell(position) {
35655
35667
  return (this.evaluatedCells.get(this.encodePosition(position)) ||
@@ -35677,7 +35689,7 @@
35677
35689
  this.formulaDependencies().addDependencies(positionId, dependencies);
35678
35690
  }
35679
35691
  updateCompilationParameters() {
35680
- this.compilationParams = buildCompilationParameters(this.context, this.getters, (position) => this.computeCell(this.encodePosition(position)));
35692
+ this.compilationParams = buildCompilationParameters(this.context, this.getters, this.computeAndSave.bind(this));
35681
35693
  }
35682
35694
  evaluateCells(positions) {
35683
35695
  const cells = positions.map(this.encodePosition.bind(this));
@@ -35793,15 +35805,21 @@
35793
35805
  this.cellsBeingComputed.delete(cellId);
35794
35806
  }
35795
35807
  }
35808
+ computeAndSave(position) {
35809
+ const positionId = this.encodePosition(position);
35810
+ const evaluatedCell = this.computeCell(positionId);
35811
+ if (!this.evaluatedCells.has(positionId)) {
35812
+ this.setEvaluatedCell(positionId, evaluatedCell);
35813
+ }
35814
+ return evaluatedCell;
35815
+ }
35796
35816
  handleError(e, cell) {
35797
- if (!(e instanceof Error)) {
35798
- e = new Error(e);
35817
+ if (!(e instanceof EvaluationError)) {
35818
+ e = new EvaluationError(CellErrorType.GenericError, e.message);
35799
35819
  }
35800
- const msg = e?.errorType || CellErrorType.GenericError;
35801
- // apply function name
35802
35820
  const __lastFnCalled = this.compilationParams[2].__lastFnCalled || "";
35803
- const error = new EvaluationError(msg, e.message.replace("[[FUNCTION_NAME]]", __lastFnCalled), e.logLevel !== undefined ? e.logLevel : CellErrorLevel.error);
35804
- return errorCell(cell.content, error);
35821
+ e.message = e.message.replace("[[FUNCTION_NAME]]", __lastFnCalled);
35822
+ return errorCell(e);
35805
35823
  }
35806
35824
  computeFormulaCell(cellData) {
35807
35825
  const cellId = cellData.id;
@@ -50692,9 +50710,9 @@
50692
50710
  Object.defineProperty(exports, '__esModule', { value: true });
50693
50711
 
50694
50712
 
50695
- __info__.version = '16.4.8';
50696
- __info__.date = '2023-10-03T12:45:33.807Z';
50697
- __info__.hash = 'c614d64';
50713
+ __info__.version = '16.4.9';
50714
+ __info__.date = '2023-10-10T07:28:12.772Z';
50715
+ __info__.hash = '998c612';
50698
50716
 
50699
50717
 
50700
50718
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);