@odoo/o-spreadsheet 16.0.52 → 16.0.54

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.
@@ -18638,7 +18638,10 @@ function parsePrefix(current, tokens) {
18638
18638
  return { type: "FUNCALL", value: current.value, args };
18639
18639
  }
18640
18640
  case "INVALID_REFERENCE":
18641
- throw new InvalidReferenceError();
18641
+ return {
18642
+ type: "REFERENCE",
18643
+ value: CellErrorType.InvalidReference,
18644
+ };
18642
18645
  case "REFERENCE":
18643
18646
  if (((_b = tokens[0]) === null || _b === void 0 ? void 0 : _b.value) === ":" && ((_c = tokens[1]) === null || _c === void 0 ? void 0 : _c.type) === "REFERENCE") {
18644
18647
  tokens.shift();
@@ -33954,11 +33957,7 @@ class FindAndReplacePlugin extends UIPlugin {
33954
33957
  }
33955
33958
  if (cell &&
33956
33959
  this.currentSearchRegex &&
33957
- this.currentSearchRegex.test(this.searchOptions.searchFormulas
33958
- ? cell.isFormula()
33959
- ? cell.content
33960
- : String(cell.evaluated.value)
33961
- : String(cell.evaluated.value))) {
33960
+ this.currentSearchRegex.test(this.searchOptions.searchFormulas ? cell.content : String(cell.evaluated.value))) {
33962
33961
  const position = this.getters.getCellPosition(cell.id);
33963
33962
  const match = { col: position.col, row: position.row, selected: false };
33964
33963
  matches.push(match);
@@ -36596,6 +36595,7 @@ class Session extends EventBus {
36596
36595
  case "REMOTE_REVISION":
36597
36596
  case "REVISION_REDONE":
36598
36597
  case "REVISION_UNDONE":
36598
+ case "SNAPSHOT_CREATED":
36599
36599
  return this.processedRevisions.has(message.nextRevisionId);
36600
36600
  default:
36601
36601
  return false;
@@ -41863,13 +41863,14 @@ function addFormula(cell) {
41863
41863
  .filter((tk) => tk.type === "FUNCTION")
41864
41864
  .every((tk) => functions[tk.value.toUpperCase()].isExported);
41865
41865
  const type = getCellType(cell.value);
41866
+ const exportedValue = adaptFormulaValueToExcel(cell.value);
41866
41867
  if (isExported) {
41867
41868
  const XlsxFormula = adaptFormulaToExcel(formula);
41868
41869
  node = escapeXml /*xml*/ `
41869
41870
  <f>
41870
41871
  ${XlsxFormula}
41871
41872
  </f>
41872
- ${escapeXml /*xml*/ `<v>${cell.value}</v>`}
41873
+ ${escapeXml /*xml*/ `<v>${exportedValue}</v>`}
41873
41874
  `;
41874
41875
  attrs.push(["t", type]);
41875
41876
  return { attrs, node };
@@ -41879,10 +41880,10 @@ function addFormula(cell) {
41879
41880
  // nothing* ,we don't export it.
41880
41881
  // * non-falsy value are relevant and so are 0 and FALSE, which only leaves
41881
41882
  // the empty string.
41882
- if (cell.value === "")
41883
+ if (exportedValue === "")
41883
41884
  return undefined;
41884
41885
  attrs.push(["t", type]);
41885
- node = escapeXml /*xml*/ `<v>${cell.value}</v>`;
41886
+ node = escapeXml /*xml*/ `<v>${exportedValue}</v>`;
41886
41887
  return { attrs, node };
41887
41888
  }
41888
41889
  }
@@ -41917,8 +41918,14 @@ function adaptFormulaToExcel(formulaText) {
41917
41918
  ast = addMissingRequiredArgs(ast);
41918
41919
  return ast;
41919
41920
  });
41921
+ ast = convertAstNodes(ast, "REFERENCE", (ast) => {
41922
+ return ast.value === CellErrorType.InvalidReference ? { ...ast, value: "#REF!" } : ast;
41923
+ });
41920
41924
  return ast ? astToFormula(ast) : formulaText;
41921
41925
  }
41926
+ function adaptFormulaValueToExcel(formulaValue) {
41927
+ return formulaValue === CellErrorType.InvalidReference ? "#REF!" : formulaValue;
41928
+ }
41922
41929
  /**
41923
41930
  * Some Excel function need required args that might not be mandatory in o-spreadsheet.
41924
41931
  * This adds those missing args.
@@ -43106,6 +43113,9 @@ class Model extends EventBus {
43106
43113
  this.selection.observe(this, {
43107
43114
  handleEvent: () => this.trigger("update"),
43108
43115
  });
43116
+ // move in "Loading" mode where we ignore redundant calls to finalize triggered by the
43117
+ // replay of stateUpdateMessages in the session
43118
+ this.isLoading = true;
43109
43119
  // This should be done after construction of LocalHistory due to order of
43110
43120
  // events
43111
43121
  this.setupSessionEvents();
@@ -43118,6 +43128,9 @@ class Model extends EventBus {
43118
43128
  // mark all models as "raw", so they will not be turned into reactive objects
43119
43129
  // by owl, since we do not rely on reactivity
43120
43130
  owl.markRaw(this);
43131
+ this.isLoading = false;
43132
+ // ensure propre recomputation of plugin states after the message replays
43133
+ this.finalize();
43121
43134
  }
43122
43135
  joinSession() {
43123
43136
  this.session.join(this.config.client);
@@ -43227,6 +43240,9 @@ class Model extends EventBus {
43227
43240
  return DispatchResult.Success;
43228
43241
  }
43229
43242
  finalize() {
43243
+ if (this.isLoading) {
43244
+ return;
43245
+ }
43230
43246
  this.status = 3 /* Status.Finalizing */;
43231
43247
  for (const h of this.handlers) {
43232
43248
  h.finalize();
@@ -43443,6 +43459,6 @@ exports.setTranslationMethod = setTranslationMethod;
43443
43459
  exports.tokenize = tokenize;
43444
43460
 
43445
43461
 
43446
- __info__.version = '16.0.52';
43447
- __info__.date = '2024-09-05T09:28:56.522Z';
43448
- __info__.hash = '2d666d7';
43462
+ __info__.version = '16.0.54';
43463
+ __info__.date = '2024-11-08T12:11:01.946Z';
43464
+ __info__.hash = 'fdfa7dc';
@@ -1078,6 +1078,7 @@ declare class Model extends EventBus<any> implements CommandDispatcher {
1078
1078
  * can just iterate on it
1079
1079
  */
1080
1080
  private renderers;
1081
+ private isLoading;
1081
1082
  /**
1082
1083
  * Internal status of the model. Important for command handling coordination
1083
1084
  */
@@ -18634,7 +18634,10 @@ function parsePrefix(current, tokens) {
18634
18634
  return { type: "FUNCALL", value: current.value, args };
18635
18635
  }
18636
18636
  case "INVALID_REFERENCE":
18637
- throw new InvalidReferenceError();
18637
+ return {
18638
+ type: "REFERENCE",
18639
+ value: CellErrorType.InvalidReference,
18640
+ };
18638
18641
  case "REFERENCE":
18639
18642
  if (((_b = tokens[0]) === null || _b === void 0 ? void 0 : _b.value) === ":" && ((_c = tokens[1]) === null || _c === void 0 ? void 0 : _c.type) === "REFERENCE") {
18640
18643
  tokens.shift();
@@ -33950,11 +33953,7 @@ class FindAndReplacePlugin extends UIPlugin {
33950
33953
  }
33951
33954
  if (cell &&
33952
33955
  this.currentSearchRegex &&
33953
- this.currentSearchRegex.test(this.searchOptions.searchFormulas
33954
- ? cell.isFormula()
33955
- ? cell.content
33956
- : String(cell.evaluated.value)
33957
- : String(cell.evaluated.value))) {
33956
+ this.currentSearchRegex.test(this.searchOptions.searchFormulas ? cell.content : String(cell.evaluated.value))) {
33958
33957
  const position = this.getters.getCellPosition(cell.id);
33959
33958
  const match = { col: position.col, row: position.row, selected: false };
33960
33959
  matches.push(match);
@@ -36592,6 +36591,7 @@ class Session extends EventBus {
36592
36591
  case "REMOTE_REVISION":
36593
36592
  case "REVISION_REDONE":
36594
36593
  case "REVISION_UNDONE":
36594
+ case "SNAPSHOT_CREATED":
36595
36595
  return this.processedRevisions.has(message.nextRevisionId);
36596
36596
  default:
36597
36597
  return false;
@@ -41859,13 +41859,14 @@ function addFormula(cell) {
41859
41859
  .filter((tk) => tk.type === "FUNCTION")
41860
41860
  .every((tk) => functions[tk.value.toUpperCase()].isExported);
41861
41861
  const type = getCellType(cell.value);
41862
+ const exportedValue = adaptFormulaValueToExcel(cell.value);
41862
41863
  if (isExported) {
41863
41864
  const XlsxFormula = adaptFormulaToExcel(formula);
41864
41865
  node = escapeXml /*xml*/ `
41865
41866
  <f>
41866
41867
  ${XlsxFormula}
41867
41868
  </f>
41868
- ${escapeXml /*xml*/ `<v>${cell.value}</v>`}
41869
+ ${escapeXml /*xml*/ `<v>${exportedValue}</v>`}
41869
41870
  `;
41870
41871
  attrs.push(["t", type]);
41871
41872
  return { attrs, node };
@@ -41875,10 +41876,10 @@ function addFormula(cell) {
41875
41876
  // nothing* ,we don't export it.
41876
41877
  // * non-falsy value are relevant and so are 0 and FALSE, which only leaves
41877
41878
  // the empty string.
41878
- if (cell.value === "")
41879
+ if (exportedValue === "")
41879
41880
  return undefined;
41880
41881
  attrs.push(["t", type]);
41881
- node = escapeXml /*xml*/ `<v>${cell.value}</v>`;
41882
+ node = escapeXml /*xml*/ `<v>${exportedValue}</v>`;
41882
41883
  return { attrs, node };
41883
41884
  }
41884
41885
  }
@@ -41913,8 +41914,14 @@ function adaptFormulaToExcel(formulaText) {
41913
41914
  ast = addMissingRequiredArgs(ast);
41914
41915
  return ast;
41915
41916
  });
41917
+ ast = convertAstNodes(ast, "REFERENCE", (ast) => {
41918
+ return ast.value === CellErrorType.InvalidReference ? { ...ast, value: "#REF!" } : ast;
41919
+ });
41916
41920
  return ast ? astToFormula(ast) : formulaText;
41917
41921
  }
41922
+ function adaptFormulaValueToExcel(formulaValue) {
41923
+ return formulaValue === CellErrorType.InvalidReference ? "#REF!" : formulaValue;
41924
+ }
41918
41925
  /**
41919
41926
  * Some Excel function need required args that might not be mandatory in o-spreadsheet.
41920
41927
  * This adds those missing args.
@@ -43102,6 +43109,9 @@ class Model extends EventBus {
43102
43109
  this.selection.observe(this, {
43103
43110
  handleEvent: () => this.trigger("update"),
43104
43111
  });
43112
+ // move in "Loading" mode where we ignore redundant calls to finalize triggered by the
43113
+ // replay of stateUpdateMessages in the session
43114
+ this.isLoading = true;
43105
43115
  // This should be done after construction of LocalHistory due to order of
43106
43116
  // events
43107
43117
  this.setupSessionEvents();
@@ -43114,6 +43124,9 @@ class Model extends EventBus {
43114
43124
  // mark all models as "raw", so they will not be turned into reactive objects
43115
43125
  // by owl, since we do not rely on reactivity
43116
43126
  markRaw(this);
43127
+ this.isLoading = false;
43128
+ // ensure propre recomputation of plugin states after the message replays
43129
+ this.finalize();
43117
43130
  }
43118
43131
  joinSession() {
43119
43132
  this.session.join(this.config.client);
@@ -43223,6 +43236,9 @@ class Model extends EventBus {
43223
43236
  return DispatchResult.Success;
43224
43237
  }
43225
43238
  finalize() {
43239
+ if (this.isLoading) {
43240
+ return;
43241
+ }
43226
43242
  this.status = 3 /* Status.Finalizing */;
43227
43243
  for (const h of this.handlers) {
43228
43244
  h.finalize();
@@ -43411,6 +43427,6 @@ function addFunction(functionName, functionDescription) {
43411
43427
  export { AbstractChart, CommandResult, CorePlugin, DATETIME_FORMAT, DispatchResult, EvaluationError, Model, Registry, Revision, SPREADSHEET_DIMENSIONS, Spreadsheet, UIPlugin, __info__, addFunction, astToFormula, cellTypes, compile, components, convertAstNodes, coreTypes, findCellInNewZone, functionCache, helpers, invalidateEvaluationCommands, load, parse, readonlyAllowedCommands, registries, setTranslationMethod, tokenize };
43412
43428
 
43413
43429
 
43414
- __info__.version = '16.0.52';
43415
- __info__.date = '2024-09-05T09:28:56.522Z';
43416
- __info__.hash = '2d666d7';
43430
+ __info__.version = '16.0.54';
43431
+ __info__.date = '2024-11-08T12:11:01.946Z';
43432
+ __info__.hash = 'fdfa7dc';
@@ -18635,7 +18635,10 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
18635
18635
  return { type: "FUNCALL", value: current.value, args };
18636
18636
  }
18637
18637
  case "INVALID_REFERENCE":
18638
- throw new InvalidReferenceError();
18638
+ return {
18639
+ type: "REFERENCE",
18640
+ value: CellErrorType.InvalidReference,
18641
+ };
18639
18642
  case "REFERENCE":
18640
18643
  if (((_b = tokens[0]) === null || _b === void 0 ? void 0 : _b.value) === ":" && ((_c = tokens[1]) === null || _c === void 0 ? void 0 : _c.type) === "REFERENCE") {
18641
18644
  tokens.shift();
@@ -33951,11 +33954,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
33951
33954
  }
33952
33955
  if (cell &&
33953
33956
  this.currentSearchRegex &&
33954
- this.currentSearchRegex.test(this.searchOptions.searchFormulas
33955
- ? cell.isFormula()
33956
- ? cell.content
33957
- : String(cell.evaluated.value)
33958
- : String(cell.evaluated.value))) {
33957
+ this.currentSearchRegex.test(this.searchOptions.searchFormulas ? cell.content : String(cell.evaluated.value))) {
33959
33958
  const position = this.getters.getCellPosition(cell.id);
33960
33959
  const match = { col: position.col, row: position.row, selected: false };
33961
33960
  matches.push(match);
@@ -36593,6 +36592,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
36593
36592
  case "REMOTE_REVISION":
36594
36593
  case "REVISION_REDONE":
36595
36594
  case "REVISION_UNDONE":
36595
+ case "SNAPSHOT_CREATED":
36596
36596
  return this.processedRevisions.has(message.nextRevisionId);
36597
36597
  default:
36598
36598
  return false;
@@ -41860,13 +41860,14 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
41860
41860
  .filter((tk) => tk.type === "FUNCTION")
41861
41861
  .every((tk) => functions[tk.value.toUpperCase()].isExported);
41862
41862
  const type = getCellType(cell.value);
41863
+ const exportedValue = adaptFormulaValueToExcel(cell.value);
41863
41864
  if (isExported) {
41864
41865
  const XlsxFormula = adaptFormulaToExcel(formula);
41865
41866
  node = escapeXml /*xml*/ `
41866
41867
  <f>
41867
41868
  ${XlsxFormula}
41868
41869
  </f>
41869
- ${escapeXml /*xml*/ `<v>${cell.value}</v>`}
41870
+ ${escapeXml /*xml*/ `<v>${exportedValue}</v>`}
41870
41871
  `;
41871
41872
  attrs.push(["t", type]);
41872
41873
  return { attrs, node };
@@ -41876,10 +41877,10 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
41876
41877
  // nothing* ,we don't export it.
41877
41878
  // * non-falsy value are relevant and so are 0 and FALSE, which only leaves
41878
41879
  // the empty string.
41879
- if (cell.value === "")
41880
+ if (exportedValue === "")
41880
41881
  return undefined;
41881
41882
  attrs.push(["t", type]);
41882
- node = escapeXml /*xml*/ `<v>${cell.value}</v>`;
41883
+ node = escapeXml /*xml*/ `<v>${exportedValue}</v>`;
41883
41884
  return { attrs, node };
41884
41885
  }
41885
41886
  }
@@ -41914,8 +41915,14 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
41914
41915
  ast = addMissingRequiredArgs(ast);
41915
41916
  return ast;
41916
41917
  });
41918
+ ast = convertAstNodes(ast, "REFERENCE", (ast) => {
41919
+ return ast.value === CellErrorType.InvalidReference ? { ...ast, value: "#REF!" } : ast;
41920
+ });
41917
41921
  return ast ? astToFormula(ast) : formulaText;
41918
41922
  }
41923
+ function adaptFormulaValueToExcel(formulaValue) {
41924
+ return formulaValue === CellErrorType.InvalidReference ? "#REF!" : formulaValue;
41925
+ }
41919
41926
  /**
41920
41927
  * Some Excel function need required args that might not be mandatory in o-spreadsheet.
41921
41928
  * This adds those missing args.
@@ -43103,6 +43110,9 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
43103
43110
  this.selection.observe(this, {
43104
43111
  handleEvent: () => this.trigger("update"),
43105
43112
  });
43113
+ // move in "Loading" mode where we ignore redundant calls to finalize triggered by the
43114
+ // replay of stateUpdateMessages in the session
43115
+ this.isLoading = true;
43106
43116
  // This should be done after construction of LocalHistory due to order of
43107
43117
  // events
43108
43118
  this.setupSessionEvents();
@@ -43115,6 +43125,9 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
43115
43125
  // mark all models as "raw", so they will not be turned into reactive objects
43116
43126
  // by owl, since we do not rely on reactivity
43117
43127
  owl.markRaw(this);
43128
+ this.isLoading = false;
43129
+ // ensure propre recomputation of plugin states after the message replays
43130
+ this.finalize();
43118
43131
  }
43119
43132
  joinSession() {
43120
43133
  this.session.join(this.config.client);
@@ -43224,6 +43237,9 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
43224
43237
  return DispatchResult.Success;
43225
43238
  }
43226
43239
  finalize() {
43240
+ if (this.isLoading) {
43241
+ return;
43242
+ }
43227
43243
  this.status = 3 /* Status.Finalizing */;
43228
43244
  for (const h of this.handlers) {
43229
43245
  h.finalize();
@@ -43442,9 +43458,9 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
43442
43458
  Object.defineProperty(exports, '__esModule', { value: true });
43443
43459
 
43444
43460
 
43445
- __info__.version = '16.0.52';
43446
- __info__.date = '2024-09-05T09:28:56.522Z';
43447
- __info__.hash = '2d666d7';
43461
+ __info__.version = '16.0.54';
43462
+ __info__.date = '2024-11-08T12:11:01.946Z';
43463
+ __info__.hash = 'fdfa7dc';
43448
43464
 
43449
43465
 
43450
43466
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);