@odoo/o-spreadsheet 15.0.12 → 15.0.14

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.
@@ -2701,13 +2701,6 @@ for (let font of fontSizes) {
2701
2701
  }
2702
2702
 
2703
2703
  //------------------------------------------------------------------------------
2704
- /**
2705
- * Stringify an object, like JSON.stringify, except that the first level of keys
2706
- * is ordered.
2707
- */
2708
- function stringify(obj) {
2709
- return JSON.stringify(obj, Object.keys(obj).sort());
2710
- }
2711
2704
  /**
2712
2705
  * Escapes a string to use as a literal string in a RegExp.
2713
2706
  * @url https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#Escaping
@@ -9426,7 +9419,7 @@ class BordersPlugin extends CorePlugin {
9426
9419
  */
9427
9420
  function getBorderId(border) {
9428
9421
  for (let [key, value] of Object.entries(borders)) {
9429
- if (stringify(value) === stringify(border)) {
9422
+ if (deepEquals(value, border)) {
9430
9423
  return parseInt(key, 10);
9431
9424
  }
9432
9425
  }
@@ -9622,7 +9615,7 @@ class CellPlugin extends CorePlugin {
9622
9615
  */
9623
9616
  function getStyleId(style) {
9624
9617
  for (let [key, value] of Object.entries(styles)) {
9625
- if (stringify(value) === stringify(style)) {
9618
+ if (deepEquals(value, style)) {
9626
9619
  return parseInt(key, 10);
9627
9620
  }
9628
9621
  }
@@ -9676,12 +9669,10 @@ class CellPlugin extends CorePlugin {
9676
9669
  * starting an async evaluation even if it has been moved or re-allocated
9677
9670
  */
9678
9671
  getCellById(cellId) {
9679
- for (const sheet of Object.values(this.cells)) {
9680
- if (sheet[cellId]) {
9681
- return sheet[cellId];
9682
- }
9683
- }
9684
- return undefined;
9672
+ // this must be as fast as possible
9673
+ const position = this.getters.getCellPosition(cellId);
9674
+ const sheet = this.cells[position.sheetId];
9675
+ return sheet[cellId];
9685
9676
  }
9686
9677
  /**
9687
9678
  * Reconstructs the original formula string based on a normalized form and its dependencies
@@ -15850,7 +15841,7 @@ const CSS$i = css$k /* scss */ `
15850
15841
  }
15851
15842
  .o-input-count {
15852
15843
  width: fit-content;
15853
- padding: 4 0 4 4;
15844
+ padding: 4px 0 4px 4px;
15854
15845
  }
15855
15846
  }
15856
15847
  }
@@ -23502,9 +23493,9 @@ function revertChanges(revisions) {
23502
23493
  * Apply the changes of the given HistoryChange to the state
23503
23494
  */
23504
23495
  function applyChange(change, target) {
23505
- let val = change.root;
23506
- let key = change.path[change.path.length - 1];
23507
- for (let pathIndex = 0; pathIndex < change.path.slice(0, -1).length; pathIndex++) {
23496
+ let val = change.path[0];
23497
+ const key = change.path[change.path.length - 1];
23498
+ for (let pathIndex = 1; pathIndex < change.path.slice(0, -1).length; pathIndex++) {
23508
23499
  const p = change.path[pathIndex];
23509
23500
  if (val[p] === undefined) {
23510
23501
  const nextPath = change.path[pathIndex + 1];
@@ -23960,13 +23951,14 @@ class StateObserver {
23960
23951
  }
23961
23952
  addChange(...args) {
23962
23953
  const val = args.pop();
23963
- const [root, ...path] = args;
23954
+ const root = args[0];
23964
23955
  let value = root;
23965
- let key = path[path.length - 1];
23966
- for (let pathIndex = 0; pathIndex <= path.length - 2; pathIndex++) {
23967
- const p = path[pathIndex];
23956
+ let key = args[args.length - 1];
23957
+ const pathLength = args.length - 2;
23958
+ for (let pathIndex = 1; pathIndex <= pathLength; pathIndex++) {
23959
+ const p = args[pathIndex];
23968
23960
  if (value[p] === undefined) {
23969
- const nextPath = path[pathIndex + 1];
23961
+ const nextPath = args[pathIndex + 1];
23970
23962
  value[p] = createEmptyStructure(nextPath);
23971
23963
  }
23972
23964
  value = value[p];
@@ -23975,8 +23967,7 @@ class StateObserver {
23975
23967
  return;
23976
23968
  }
23977
23969
  this.changes.push({
23978
- root,
23979
- path,
23970
+ path: args,
23980
23971
  before: value[key],
23981
23972
  after: val,
23982
23973
  });
@@ -26034,7 +26025,10 @@ class Model extends owl__namespace.core.EventBus {
26034
26025
  */
26035
26026
  checkDispatchAllowed(command) {
26036
26027
  const results = this.handlers.map((handler) => handler.allowDispatch(command));
26037
- return new DispatchResult(results.flat());
26028
+ if (results.some((r) => r !== 0 /* Success */)) {
26029
+ return new DispatchResult(results.flat());
26030
+ }
26031
+ return DispatchResult.Success;
26038
26032
  }
26039
26033
  finalize() {
26040
26034
  this.status = 3 /* Finalizing */;
@@ -31456,6 +31450,6 @@ exports.registries = registries;
31456
31450
  exports.setTranslationMethod = setTranslationMethod;
31457
31451
 
31458
31452
 
31459
- __info__.version = '15.0.12';
31460
- __info__.date = '2023-11-02T09:28:12.777Z';
31461
- __info__.hash = 'e82bd99';
31453
+ __info__.version = '15.0.14';
31454
+ __info__.date = '2023-11-24T13:06:57.405Z';
31455
+ __info__.hash = 'c9a805f';
@@ -922,7 +922,7 @@ declare class StateObserver {
922
922
  commands: CoreCommand[];
923
923
  };
924
924
  addCommand(command: CoreCommand): void;
925
- addChange(...args: any[]): void;
925
+ addChange(...args: [...HistoryChange["path"], any]): void;
926
926
  }
927
927
 
928
928
  /**
@@ -3890,8 +3890,7 @@ declare type EvalContext = {
3890
3890
  };
3891
3891
 
3892
3892
  interface HistoryChange {
3893
- root: any;
3894
- path: (string | number)[];
3893
+ path: [any, ...(number | string)[]];
3895
3894
  before: any;
3896
3895
  after: any;
3897
3896
  }
@@ -2678,13 +2678,6 @@ for (let font of fontSizes) {
2678
2678
  }
2679
2679
 
2680
2680
  //------------------------------------------------------------------------------
2681
- /**
2682
- * Stringify an object, like JSON.stringify, except that the first level of keys
2683
- * is ordered.
2684
- */
2685
- function stringify(obj) {
2686
- return JSON.stringify(obj, Object.keys(obj).sort());
2687
- }
2688
2681
  /**
2689
2682
  * Escapes a string to use as a literal string in a RegExp.
2690
2683
  * @url https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#Escaping
@@ -9403,7 +9396,7 @@ class BordersPlugin extends CorePlugin {
9403
9396
  */
9404
9397
  function getBorderId(border) {
9405
9398
  for (let [key, value] of Object.entries(borders)) {
9406
- if (stringify(value) === stringify(border)) {
9399
+ if (deepEquals(value, border)) {
9407
9400
  return parseInt(key, 10);
9408
9401
  }
9409
9402
  }
@@ -9599,7 +9592,7 @@ class CellPlugin extends CorePlugin {
9599
9592
  */
9600
9593
  function getStyleId(style) {
9601
9594
  for (let [key, value] of Object.entries(styles)) {
9602
- if (stringify(value) === stringify(style)) {
9595
+ if (deepEquals(value, style)) {
9603
9596
  return parseInt(key, 10);
9604
9597
  }
9605
9598
  }
@@ -9653,12 +9646,10 @@ class CellPlugin extends CorePlugin {
9653
9646
  * starting an async evaluation even if it has been moved or re-allocated
9654
9647
  */
9655
9648
  getCellById(cellId) {
9656
- for (const sheet of Object.values(this.cells)) {
9657
- if (sheet[cellId]) {
9658
- return sheet[cellId];
9659
- }
9660
- }
9661
- return undefined;
9649
+ // this must be as fast as possible
9650
+ const position = this.getters.getCellPosition(cellId);
9651
+ const sheet = this.cells[position.sheetId];
9652
+ return sheet[cellId];
9662
9653
  }
9663
9654
  /**
9664
9655
  * Reconstructs the original formula string based on a normalized form and its dependencies
@@ -15827,7 +15818,7 @@ const CSS$i = css$k /* scss */ `
15827
15818
  }
15828
15819
  .o-input-count {
15829
15820
  width: fit-content;
15830
- padding: 4 0 4 4;
15821
+ padding: 4px 0 4px 4px;
15831
15822
  }
15832
15823
  }
15833
15824
  }
@@ -23479,9 +23470,9 @@ function revertChanges(revisions) {
23479
23470
  * Apply the changes of the given HistoryChange to the state
23480
23471
  */
23481
23472
  function applyChange(change, target) {
23482
- let val = change.root;
23483
- let key = change.path[change.path.length - 1];
23484
- for (let pathIndex = 0; pathIndex < change.path.slice(0, -1).length; pathIndex++) {
23473
+ let val = change.path[0];
23474
+ const key = change.path[change.path.length - 1];
23475
+ for (let pathIndex = 1; pathIndex < change.path.slice(0, -1).length; pathIndex++) {
23485
23476
  const p = change.path[pathIndex];
23486
23477
  if (val[p] === undefined) {
23487
23478
  const nextPath = change.path[pathIndex + 1];
@@ -23937,13 +23928,14 @@ class StateObserver {
23937
23928
  }
23938
23929
  addChange(...args) {
23939
23930
  const val = args.pop();
23940
- const [root, ...path] = args;
23931
+ const root = args[0];
23941
23932
  let value = root;
23942
- let key = path[path.length - 1];
23943
- for (let pathIndex = 0; pathIndex <= path.length - 2; pathIndex++) {
23944
- const p = path[pathIndex];
23933
+ let key = args[args.length - 1];
23934
+ const pathLength = args.length - 2;
23935
+ for (let pathIndex = 1; pathIndex <= pathLength; pathIndex++) {
23936
+ const p = args[pathIndex];
23945
23937
  if (value[p] === undefined) {
23946
- const nextPath = path[pathIndex + 1];
23938
+ const nextPath = args[pathIndex + 1];
23947
23939
  value[p] = createEmptyStructure(nextPath);
23948
23940
  }
23949
23941
  value = value[p];
@@ -23952,8 +23944,7 @@ class StateObserver {
23952
23944
  return;
23953
23945
  }
23954
23946
  this.changes.push({
23955
- root,
23956
- path,
23947
+ path: args,
23957
23948
  before: value[key],
23958
23949
  after: val,
23959
23950
  });
@@ -26011,7 +26002,10 @@ class Model extends owl.core.EventBus {
26011
26002
  */
26012
26003
  checkDispatchAllowed(command) {
26013
26004
  const results = this.handlers.map((handler) => handler.allowDispatch(command));
26014
- return new DispatchResult(results.flat());
26005
+ if (results.some((r) => r !== 0 /* Success */)) {
26006
+ return new DispatchResult(results.flat());
26007
+ }
26008
+ return DispatchResult.Success;
26015
26009
  }
26016
26010
  finalize() {
26017
26011
  this.status = 3 /* Finalizing */;
@@ -31411,6 +31405,6 @@ const helpers = {
31411
31405
  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 };
31412
31406
 
31413
31407
 
31414
- __info__.version = '15.0.12';
31415
- __info__.date = '2023-11-02T09:28:12.777Z';
31416
- __info__.hash = 'e82bd99';
31408
+ __info__.version = '15.0.14';
31409
+ __info__.date = '2023-11-24T13:06:57.405Z';
31410
+ __info__.hash = 'c9a805f';
@@ -2698,13 +2698,6 @@
2698
2698
  }
2699
2699
 
2700
2700
  //------------------------------------------------------------------------------
2701
- /**
2702
- * Stringify an object, like JSON.stringify, except that the first level of keys
2703
- * is ordered.
2704
- */
2705
- function stringify(obj) {
2706
- return JSON.stringify(obj, Object.keys(obj).sort());
2707
- }
2708
2701
  /**
2709
2702
  * Escapes a string to use as a literal string in a RegExp.
2710
2703
  * @url https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#Escaping
@@ -9423,7 +9416,7 @@
9423
9416
  */
9424
9417
  function getBorderId(border) {
9425
9418
  for (let [key, value] of Object.entries(borders)) {
9426
- if (stringify(value) === stringify(border)) {
9419
+ if (deepEquals(value, border)) {
9427
9420
  return parseInt(key, 10);
9428
9421
  }
9429
9422
  }
@@ -9619,7 +9612,7 @@
9619
9612
  */
9620
9613
  function getStyleId(style) {
9621
9614
  for (let [key, value] of Object.entries(styles)) {
9622
- if (stringify(value) === stringify(style)) {
9615
+ if (deepEquals(value, style)) {
9623
9616
  return parseInt(key, 10);
9624
9617
  }
9625
9618
  }
@@ -9673,12 +9666,10 @@
9673
9666
  * starting an async evaluation even if it has been moved or re-allocated
9674
9667
  */
9675
9668
  getCellById(cellId) {
9676
- for (const sheet of Object.values(this.cells)) {
9677
- if (sheet[cellId]) {
9678
- return sheet[cellId];
9679
- }
9680
- }
9681
- return undefined;
9669
+ // this must be as fast as possible
9670
+ const position = this.getters.getCellPosition(cellId);
9671
+ const sheet = this.cells[position.sheetId];
9672
+ return sheet[cellId];
9682
9673
  }
9683
9674
  /**
9684
9675
  * Reconstructs the original formula string based on a normalized form and its dependencies
@@ -15847,7 +15838,7 @@
15847
15838
  }
15848
15839
  .o-input-count {
15849
15840
  width: fit-content;
15850
- padding: 4 0 4 4;
15841
+ padding: 4px 0 4px 4px;
15851
15842
  }
15852
15843
  }
15853
15844
  }
@@ -23499,9 +23490,9 @@
23499
23490
  * Apply the changes of the given HistoryChange to the state
23500
23491
  */
23501
23492
  function applyChange(change, target) {
23502
- let val = change.root;
23503
- let key = change.path[change.path.length - 1];
23504
- for (let pathIndex = 0; pathIndex < change.path.slice(0, -1).length; pathIndex++) {
23493
+ let val = change.path[0];
23494
+ const key = change.path[change.path.length - 1];
23495
+ for (let pathIndex = 1; pathIndex < change.path.slice(0, -1).length; pathIndex++) {
23505
23496
  const p = change.path[pathIndex];
23506
23497
  if (val[p] === undefined) {
23507
23498
  const nextPath = change.path[pathIndex + 1];
@@ -23957,13 +23948,14 @@
23957
23948
  }
23958
23949
  addChange(...args) {
23959
23950
  const val = args.pop();
23960
- const [root, ...path] = args;
23951
+ const root = args[0];
23961
23952
  let value = root;
23962
- let key = path[path.length - 1];
23963
- for (let pathIndex = 0; pathIndex <= path.length - 2; pathIndex++) {
23964
- const p = path[pathIndex];
23953
+ let key = args[args.length - 1];
23954
+ const pathLength = args.length - 2;
23955
+ for (let pathIndex = 1; pathIndex <= pathLength; pathIndex++) {
23956
+ const p = args[pathIndex];
23965
23957
  if (value[p] === undefined) {
23966
- const nextPath = path[pathIndex + 1];
23958
+ const nextPath = args[pathIndex + 1];
23967
23959
  value[p] = createEmptyStructure(nextPath);
23968
23960
  }
23969
23961
  value = value[p];
@@ -23972,8 +23964,7 @@
23972
23964
  return;
23973
23965
  }
23974
23966
  this.changes.push({
23975
- root,
23976
- path,
23967
+ path: args,
23977
23968
  before: value[key],
23978
23969
  after: val,
23979
23970
  });
@@ -26031,7 +26022,10 @@
26031
26022
  */
26032
26023
  checkDispatchAllowed(command) {
26033
26024
  const results = this.handlers.map((handler) => handler.allowDispatch(command));
26034
- return new DispatchResult(results.flat());
26025
+ if (results.some((r) => r !== 0 /* Success */)) {
26026
+ return new DispatchResult(results.flat());
26027
+ }
26028
+ return DispatchResult.Success;
26035
26029
  }
26036
26030
  finalize() {
26037
26031
  this.status = 3 /* Finalizing */;
@@ -31455,9 +31449,9 @@
31455
31449
  Object.defineProperty(exports, '__esModule', { value: true });
31456
31450
 
31457
31451
 
31458
- __info__.version = '15.0.12';
31459
- __info__.date = '2023-11-02T09:28:12.777Z';
31460
- __info__.hash = 'e82bd99';
31452
+ __info__.version = '15.0.14';
31453
+ __info__.date = '2023-11-24T13:06:57.405Z';
31454
+ __info__.hash = 'c9a805f';
31461
31455
 
31462
31456
 
31463
31457
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);