@odoo/o-spreadsheet 15.0.5 → 15.0.7

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.
@@ -6595,7 +6595,7 @@ const POW = {
6595
6595
  base (number) ${_lt("The number to raise to the exponent power.")}
6596
6596
  exponent (number) ${_lt("The exponent to raise base to.")}
6597
6597
  `),
6598
- returns: ["BOOLEAN"],
6598
+ returns: ["NUMBER"],
6599
6599
  compute: function (base, exponent) {
6600
6600
  return POWER.compute(base, exponent);
6601
6601
  },
@@ -21322,13 +21322,9 @@ class Session extends EventBus {
21322
21322
  }
21323
21323
  loadInitialMessages(messages) {
21324
21324
  this.isReplayingInitialRevisions = true;
21325
- this.on("unexpected-revision-id", this, ({ revisionId }) => {
21326
- throw new Error(`The spreadsheet could not be loaded. Revision ${revisionId} is corrupted.`);
21327
- });
21328
21325
  for (const message of messages) {
21329
21326
  this.onMessageReceived(message);
21330
21327
  }
21331
- this.off("unexpected-revision-id", this);
21332
21328
  this.isReplayingInitialRevisions = false;
21333
21329
  }
21334
21330
  /**
@@ -21400,6 +21396,10 @@ class Session extends EventBus {
21400
21396
  onMessageReceived(message) {
21401
21397
  if (this.isAlreadyProcessed(message))
21402
21398
  return;
21399
+ if (this.isWrongServerRevisionId(message)) {
21400
+ this.trigger("unexpected-revision-id");
21401
+ return;
21402
+ }
21403
21403
  switch (message.type) {
21404
21404
  case "CLIENT_MOVED":
21405
21405
  this.onClientMoved(message);
@@ -21426,10 +21426,6 @@ class Session extends EventBus {
21426
21426
  });
21427
21427
  break;
21428
21428
  case "REMOTE_REVISION":
21429
- if (message.serverRevisionId !== this.serverRevisionId) {
21430
- this.trigger("unexpected-revision-id", { revisionId: message.serverRevisionId });
21431
- return;
21432
- }
21433
21429
  const { clientId, commands } = message;
21434
21430
  const revision = new Revision(message.nextRevisionId, clientId, commands);
21435
21431
  if (revision.clientId !== this.clientId) {
@@ -21558,6 +21554,17 @@ class Session extends EventBus {
21558
21554
  return false;
21559
21555
  }
21560
21556
  }
21557
+ isWrongServerRevisionId(message) {
21558
+ switch (message.type) {
21559
+ case "REMOTE_REVISION":
21560
+ case "REVISION_REDONE":
21561
+ case "REVISION_UNDONE":
21562
+ case "SNAPSHOT_CREATED":
21563
+ return message.serverRevisionId !== this.serverRevisionId;
21564
+ default:
21565
+ return false;
21566
+ }
21567
+ }
21561
21568
  dropPendingHistoryMessages() {
21562
21569
  this.waitingUndoRedoAck = false;
21563
21570
  this.pendingMessages = this.pendingMessages.filter(({ type }) => type !== "REVISION_REDONE" && type !== "REVISION_UNDONE");
@@ -24782,12 +24789,9 @@ function addFormula(cell) {
24782
24789
  else {
24783
24790
  // Shouldn't we always output the value then ?
24784
24791
  const value = cell.value;
24785
- // what if value = 0? Is this condition correct?
24786
- if (value) {
24787
- const type = getCellType(value);
24788
- attrs.push(["t", type]);
24789
- node = escapeXml /*xml*/ `<v>${value}</v>`;
24790
- }
24792
+ const type = getCellType(value);
24793
+ attrs.push(["t", type]);
24794
+ node = escapeXml /*xml*/ `<v>${value}</v>`;
24791
24795
  return { attrs, node };
24792
24796
  }
24793
24797
  }
@@ -31399,6 +31403,6 @@ exports.registries = registries;
31399
31403
  exports.setTranslationMethod = setTranslationMethod;
31400
31404
 
31401
31405
 
31402
- __info__.version = '15.0.5';
31403
- __info__.date = '2023-04-21T07:27:19.753Z';
31404
- __info__.hash = 'ef69cc7';
31406
+ __info__.version = '15.0.7';
31407
+ __info__.date = '2023-05-12T10:54:58.735Z';
31408
+ __info__.hash = 'd538be3';
@@ -640,7 +640,6 @@ interface CollaborativeEventReceived {
640
640
  }
641
641
  interface UnexpectedRevisionIdEvent {
642
642
  type: "unexpected-revision-id";
643
- revisionId: UID;
644
643
  }
645
644
  interface NewLocalStateUpdateEvent {
646
645
  type: "new-local-state-update";
@@ -2044,6 +2043,7 @@ declare class Session extends EventBus<CollaborativeEvent> {
2044
2043
  private sendPendingMessage;
2045
2044
  private acknowledge;
2046
2045
  private isAlreadyProcessed;
2046
+ isWrongServerRevisionId(message: CollaborationMessage): boolean;
2047
2047
  private dropPendingHistoryMessages;
2048
2048
  }
2049
2049
 
@@ -6572,7 +6572,7 @@ const POW = {
6572
6572
  base (number) ${_lt("The number to raise to the exponent power.")}
6573
6573
  exponent (number) ${_lt("The exponent to raise base to.")}
6574
6574
  `),
6575
- returns: ["BOOLEAN"],
6575
+ returns: ["NUMBER"],
6576
6576
  compute: function (base, exponent) {
6577
6577
  return POWER.compute(base, exponent);
6578
6578
  },
@@ -21299,13 +21299,9 @@ class Session extends EventBus {
21299
21299
  }
21300
21300
  loadInitialMessages(messages) {
21301
21301
  this.isReplayingInitialRevisions = true;
21302
- this.on("unexpected-revision-id", this, ({ revisionId }) => {
21303
- throw new Error(`The spreadsheet could not be loaded. Revision ${revisionId} is corrupted.`);
21304
- });
21305
21302
  for (const message of messages) {
21306
21303
  this.onMessageReceived(message);
21307
21304
  }
21308
- this.off("unexpected-revision-id", this);
21309
21305
  this.isReplayingInitialRevisions = false;
21310
21306
  }
21311
21307
  /**
@@ -21377,6 +21373,10 @@ class Session extends EventBus {
21377
21373
  onMessageReceived(message) {
21378
21374
  if (this.isAlreadyProcessed(message))
21379
21375
  return;
21376
+ if (this.isWrongServerRevisionId(message)) {
21377
+ this.trigger("unexpected-revision-id");
21378
+ return;
21379
+ }
21380
21380
  switch (message.type) {
21381
21381
  case "CLIENT_MOVED":
21382
21382
  this.onClientMoved(message);
@@ -21403,10 +21403,6 @@ class Session extends EventBus {
21403
21403
  });
21404
21404
  break;
21405
21405
  case "REMOTE_REVISION":
21406
- if (message.serverRevisionId !== this.serverRevisionId) {
21407
- this.trigger("unexpected-revision-id", { revisionId: message.serverRevisionId });
21408
- return;
21409
- }
21410
21406
  const { clientId, commands } = message;
21411
21407
  const revision = new Revision(message.nextRevisionId, clientId, commands);
21412
21408
  if (revision.clientId !== this.clientId) {
@@ -21535,6 +21531,17 @@ class Session extends EventBus {
21535
21531
  return false;
21536
21532
  }
21537
21533
  }
21534
+ isWrongServerRevisionId(message) {
21535
+ switch (message.type) {
21536
+ case "REMOTE_REVISION":
21537
+ case "REVISION_REDONE":
21538
+ case "REVISION_UNDONE":
21539
+ case "SNAPSHOT_CREATED":
21540
+ return message.serverRevisionId !== this.serverRevisionId;
21541
+ default:
21542
+ return false;
21543
+ }
21544
+ }
21538
21545
  dropPendingHistoryMessages() {
21539
21546
  this.waitingUndoRedoAck = false;
21540
21547
  this.pendingMessages = this.pendingMessages.filter(({ type }) => type !== "REVISION_REDONE" && type !== "REVISION_UNDONE");
@@ -24759,12 +24766,9 @@ function addFormula(cell) {
24759
24766
  else {
24760
24767
  // Shouldn't we always output the value then ?
24761
24768
  const value = cell.value;
24762
- // what if value = 0? Is this condition correct?
24763
- if (value) {
24764
- const type = getCellType(value);
24765
- attrs.push(["t", type]);
24766
- node = escapeXml /*xml*/ `<v>${value}</v>`;
24767
- }
24769
+ const type = getCellType(value);
24770
+ attrs.push(["t", type]);
24771
+ node = escapeXml /*xml*/ `<v>${value}</v>`;
24768
24772
  return { attrs, node };
24769
24773
  }
24770
24774
  }
@@ -31354,6 +31358,6 @@ const helpers = {
31354
31358
  export { CommandResult, CorePlugin, DATETIME_FORMAT, DataSource, DispatchResult, Model, Revision, SPREADSHEET_DIMENSIONS, Spreadsheet, UIPlugin, DEBUG as __DEBUG__, __info__, astToFormula, cellTypes, convertAstNodes, coreTypes, functionCache, helpers, invalidateEvaluationCommands, normalize, parse, readonlyAllowedCommands, registries, setTranslationMethod };
31355
31359
 
31356
31360
 
31357
- __info__.version = '15.0.5';
31358
- __info__.date = '2023-04-21T07:27:19.753Z';
31359
- __info__.hash = 'ef69cc7';
31361
+ __info__.version = '15.0.7';
31362
+ __info__.date = '2023-05-12T10:54:58.735Z';
31363
+ __info__.hash = 'd538be3';
@@ -6592,7 +6592,7 @@
6592
6592
  base (number) ${_lt("The number to raise to the exponent power.")}
6593
6593
  exponent (number) ${_lt("The exponent to raise base to.")}
6594
6594
  `),
6595
- returns: ["BOOLEAN"],
6595
+ returns: ["NUMBER"],
6596
6596
  compute: function (base, exponent) {
6597
6597
  return POWER.compute(base, exponent);
6598
6598
  },
@@ -21319,13 +21319,9 @@
21319
21319
  }
21320
21320
  loadInitialMessages(messages) {
21321
21321
  this.isReplayingInitialRevisions = true;
21322
- this.on("unexpected-revision-id", this, ({ revisionId }) => {
21323
- throw new Error(`The spreadsheet could not be loaded. Revision ${revisionId} is corrupted.`);
21324
- });
21325
21322
  for (const message of messages) {
21326
21323
  this.onMessageReceived(message);
21327
21324
  }
21328
- this.off("unexpected-revision-id", this);
21329
21325
  this.isReplayingInitialRevisions = false;
21330
21326
  }
21331
21327
  /**
@@ -21397,6 +21393,10 @@
21397
21393
  onMessageReceived(message) {
21398
21394
  if (this.isAlreadyProcessed(message))
21399
21395
  return;
21396
+ if (this.isWrongServerRevisionId(message)) {
21397
+ this.trigger("unexpected-revision-id");
21398
+ return;
21399
+ }
21400
21400
  switch (message.type) {
21401
21401
  case "CLIENT_MOVED":
21402
21402
  this.onClientMoved(message);
@@ -21423,10 +21423,6 @@
21423
21423
  });
21424
21424
  break;
21425
21425
  case "REMOTE_REVISION":
21426
- if (message.serverRevisionId !== this.serverRevisionId) {
21427
- this.trigger("unexpected-revision-id", { revisionId: message.serverRevisionId });
21428
- return;
21429
- }
21430
21426
  const { clientId, commands } = message;
21431
21427
  const revision = new Revision(message.nextRevisionId, clientId, commands);
21432
21428
  if (revision.clientId !== this.clientId) {
@@ -21555,6 +21551,17 @@
21555
21551
  return false;
21556
21552
  }
21557
21553
  }
21554
+ isWrongServerRevisionId(message) {
21555
+ switch (message.type) {
21556
+ case "REMOTE_REVISION":
21557
+ case "REVISION_REDONE":
21558
+ case "REVISION_UNDONE":
21559
+ case "SNAPSHOT_CREATED":
21560
+ return message.serverRevisionId !== this.serverRevisionId;
21561
+ default:
21562
+ return false;
21563
+ }
21564
+ }
21558
21565
  dropPendingHistoryMessages() {
21559
21566
  this.waitingUndoRedoAck = false;
21560
21567
  this.pendingMessages = this.pendingMessages.filter(({ type }) => type !== "REVISION_REDONE" && type !== "REVISION_UNDONE");
@@ -24779,12 +24786,9 @@
24779
24786
  else {
24780
24787
  // Shouldn't we always output the value then ?
24781
24788
  const value = cell.value;
24782
- // what if value = 0? Is this condition correct?
24783
- if (value) {
24784
- const type = getCellType(value);
24785
- attrs.push(["t", type]);
24786
- node = escapeXml /*xml*/ `<v>${value}</v>`;
24787
- }
24789
+ const type = getCellType(value);
24790
+ attrs.push(["t", type]);
24791
+ node = escapeXml /*xml*/ `<v>${value}</v>`;
24788
24792
  return { attrs, node };
24789
24793
  }
24790
24794
  }
@@ -31398,9 +31402,9 @@
31398
31402
  Object.defineProperty(exports, '__esModule', { value: true });
31399
31403
 
31400
31404
 
31401
- __info__.version = '15.0.5';
31402
- __info__.date = '2023-04-21T07:27:19.753Z';
31403
- __info__.hash = 'ef69cc7';
31405
+ __info__.version = '15.0.7';
31406
+ __info__.date = '2023-05-12T10:54:58.735Z';
31407
+ __info__.hash = 'd538be3';
31404
31408
 
31405
31409
 
31406
31410
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);