@odoo/o-spreadsheet 15.2.12 → 15.2.13

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.
@@ -2709,13 +2709,6 @@ for (let font of fontSizes) {
2709
2709
  }
2710
2710
 
2711
2711
  //------------------------------------------------------------------------------
2712
- /**
2713
- * Stringify an object, like JSON.stringify, except that the first level of keys
2714
- * is ordered.
2715
- */
2716
- function stringify(obj) {
2717
- return JSON.stringify(obj, Object.keys(obj).sort());
2718
- }
2719
2712
  /**
2720
2713
  * Remove quotes from a quoted string
2721
2714
  * ```js
@@ -2940,7 +2933,7 @@ const DEBUG = {};
2940
2933
  */
2941
2934
  function getItemId(item, itemsDic) {
2942
2935
  for (let [key, value] of Object.entries(itemsDic)) {
2943
- if (stringify(value) === stringify(item)) {
2936
+ if (deepEquals(value, item)) {
2944
2937
  return parseInt(key, 10);
2945
2938
  }
2946
2939
  }
@@ -9405,7 +9398,7 @@ class BordersPlugin extends CorePlugin {
9405
9398
  */
9406
9399
  function getBorderId(border) {
9407
9400
  for (let [key, value] of Object.entries(borders)) {
9408
- if (stringify(value) === stringify(border)) {
9401
+ if (deepEquals(value, border)) {
9409
9402
  return parseInt(key, 10);
9410
9403
  }
9411
9404
  }
@@ -9643,12 +9636,10 @@ class CellPlugin extends CorePlugin {
9643
9636
  * starting an async evaluation even if it has been moved or re-allocated
9644
9637
  */
9645
9638
  getCellById(cellId) {
9646
- for (const sheet of Object.values(this.cells)) {
9647
- if (sheet[cellId]) {
9648
- return sheet[cellId];
9649
- }
9650
- }
9651
- return undefined;
9639
+ // this must be as fast as possible
9640
+ const position = this.getters.getCellPosition(cellId);
9641
+ const sheet = this.cells[position.sheetId];
9642
+ return sheet[cellId];
9652
9643
  }
9653
9644
  /**
9654
9645
  * Try to infer the cell format based on the formula dependencies.
@@ -23413,9 +23404,9 @@ function revertChanges(revisions) {
23413
23404
  * Apply the changes of the given HistoryChange to the state
23414
23405
  */
23415
23406
  function applyChange(change, target) {
23416
- let val = change.root;
23417
- let key = change.path[change.path.length - 1];
23418
- for (let pathIndex = 0; pathIndex < change.path.slice(0, -1).length; pathIndex++) {
23407
+ let val = change.path[0];
23408
+ const key = change.path[change.path.length - 1];
23409
+ for (let pathIndex = 1; pathIndex < change.path.slice(0, -1).length; pathIndex++) {
23419
23410
  const p = change.path[pathIndex];
23420
23411
  if (val[p] === undefined) {
23421
23412
  const nextPath = change.path[pathIndex + 1];
@@ -23871,13 +23862,14 @@ class StateObserver {
23871
23862
  }
23872
23863
  addChange(...args) {
23873
23864
  const val = args.pop();
23874
- const [root, ...path] = args;
23865
+ const root = args[0];
23875
23866
  let value = root;
23876
- let key = path[path.length - 1];
23877
- for (let pathIndex = 0; pathIndex <= path.length - 2; pathIndex++) {
23878
- const p = path[pathIndex];
23867
+ let key = args[args.length - 1];
23868
+ const pathLength = args.length - 2;
23869
+ for (let pathIndex = 1; pathIndex <= pathLength; pathIndex++) {
23870
+ const p = args[pathIndex];
23879
23871
  if (value[p] === undefined) {
23880
- const nextPath = path[pathIndex + 1];
23872
+ const nextPath = args[pathIndex + 1];
23881
23873
  value[p] = createEmptyStructure(nextPath);
23882
23874
  }
23883
23875
  value = value[p];
@@ -23886,8 +23878,7 @@ class StateObserver {
23886
23878
  return;
23887
23879
  }
23888
23880
  this.changes.push({
23889
- root,
23890
- path,
23881
+ path: args,
23891
23882
  before: value[key],
23892
23883
  after: val,
23893
23884
  });
@@ -25927,7 +25918,10 @@ class Model extends owl__namespace.core.EventBus {
25927
25918
  */
25928
25919
  checkDispatchAllowed(command) {
25929
25920
  const results = this.handlers.map((handler) => handler.allowDispatch(command));
25930
- return new DispatchResult(results.flat());
25921
+ if (results.some((r) => r !== 0 /* Success */)) {
25922
+ return new DispatchResult(results.flat());
25923
+ }
25924
+ return DispatchResult.Success;
25931
25925
  }
25932
25926
  finalize() {
25933
25927
  this.status = 3 /* Finalizing */;
@@ -31389,6 +31383,6 @@ exports.registries = registries;
31389
31383
  exports.setTranslationMethod = setTranslationMethod;
31390
31384
 
31391
31385
 
31392
- __info__.version = '15.2.12';
31393
- __info__.date = '2023-11-16T11:57:04.728Z';
31394
- __info__.hash = 'd0fd7c1';
31386
+ __info__.version = '15.2.13';
31387
+ __info__.date = '2023-11-24T13:06:49.659Z';
31388
+ __info__.hash = 'ea82269';
@@ -888,7 +888,7 @@ declare class StateObserver {
888
888
  commands: CoreCommand[];
889
889
  };
890
890
  addCommand(command: CoreCommand): void;
891
- addChange(...args: any[]): void;
891
+ addChange(...args: [...HistoryChange["path"], any]): void;
892
892
  }
893
893
 
894
894
  /**
@@ -3803,8 +3803,7 @@ declare type EvalContext = {
3803
3803
  };
3804
3804
 
3805
3805
  interface HistoryChange {
3806
- root: any;
3807
- path: (string | number)[];
3806
+ path: [any, ...(number | string)[]];
3808
3807
  before: any;
3809
3808
  after: any;
3810
3809
  }
@@ -2686,13 +2686,6 @@ for (let font of fontSizes) {
2686
2686
  }
2687
2687
 
2688
2688
  //------------------------------------------------------------------------------
2689
- /**
2690
- * Stringify an object, like JSON.stringify, except that the first level of keys
2691
- * is ordered.
2692
- */
2693
- function stringify(obj) {
2694
- return JSON.stringify(obj, Object.keys(obj).sort());
2695
- }
2696
2689
  /**
2697
2690
  * Remove quotes from a quoted string
2698
2691
  * ```js
@@ -2917,7 +2910,7 @@ const DEBUG = {};
2917
2910
  */
2918
2911
  function getItemId(item, itemsDic) {
2919
2912
  for (let [key, value] of Object.entries(itemsDic)) {
2920
- if (stringify(value) === stringify(item)) {
2913
+ if (deepEquals(value, item)) {
2921
2914
  return parseInt(key, 10);
2922
2915
  }
2923
2916
  }
@@ -9382,7 +9375,7 @@ class BordersPlugin extends CorePlugin {
9382
9375
  */
9383
9376
  function getBorderId(border) {
9384
9377
  for (let [key, value] of Object.entries(borders)) {
9385
- if (stringify(value) === stringify(border)) {
9378
+ if (deepEquals(value, border)) {
9386
9379
  return parseInt(key, 10);
9387
9380
  }
9388
9381
  }
@@ -9620,12 +9613,10 @@ class CellPlugin extends CorePlugin {
9620
9613
  * starting an async evaluation even if it has been moved or re-allocated
9621
9614
  */
9622
9615
  getCellById(cellId) {
9623
- for (const sheet of Object.values(this.cells)) {
9624
- if (sheet[cellId]) {
9625
- return sheet[cellId];
9626
- }
9627
- }
9628
- return undefined;
9616
+ // this must be as fast as possible
9617
+ const position = this.getters.getCellPosition(cellId);
9618
+ const sheet = this.cells[position.sheetId];
9619
+ return sheet[cellId];
9629
9620
  }
9630
9621
  /**
9631
9622
  * Try to infer the cell format based on the formula dependencies.
@@ -23390,9 +23381,9 @@ function revertChanges(revisions) {
23390
23381
  * Apply the changes of the given HistoryChange to the state
23391
23382
  */
23392
23383
  function applyChange(change, target) {
23393
- let val = change.root;
23394
- let key = change.path[change.path.length - 1];
23395
- for (let pathIndex = 0; pathIndex < change.path.slice(0, -1).length; pathIndex++) {
23384
+ let val = change.path[0];
23385
+ const key = change.path[change.path.length - 1];
23386
+ for (let pathIndex = 1; pathIndex < change.path.slice(0, -1).length; pathIndex++) {
23396
23387
  const p = change.path[pathIndex];
23397
23388
  if (val[p] === undefined) {
23398
23389
  const nextPath = change.path[pathIndex + 1];
@@ -23848,13 +23839,14 @@ class StateObserver {
23848
23839
  }
23849
23840
  addChange(...args) {
23850
23841
  const val = args.pop();
23851
- const [root, ...path] = args;
23842
+ const root = args[0];
23852
23843
  let value = root;
23853
- let key = path[path.length - 1];
23854
- for (let pathIndex = 0; pathIndex <= path.length - 2; pathIndex++) {
23855
- const p = path[pathIndex];
23844
+ let key = args[args.length - 1];
23845
+ const pathLength = args.length - 2;
23846
+ for (let pathIndex = 1; pathIndex <= pathLength; pathIndex++) {
23847
+ const p = args[pathIndex];
23856
23848
  if (value[p] === undefined) {
23857
- const nextPath = path[pathIndex + 1];
23849
+ const nextPath = args[pathIndex + 1];
23858
23850
  value[p] = createEmptyStructure(nextPath);
23859
23851
  }
23860
23852
  value = value[p];
@@ -23863,8 +23855,7 @@ class StateObserver {
23863
23855
  return;
23864
23856
  }
23865
23857
  this.changes.push({
23866
- root,
23867
- path,
23858
+ path: args,
23868
23859
  before: value[key],
23869
23860
  after: val,
23870
23861
  });
@@ -25904,7 +25895,10 @@ class Model extends owl.core.EventBus {
25904
25895
  */
25905
25896
  checkDispatchAllowed(command) {
25906
25897
  const results = this.handlers.map((handler) => handler.allowDispatch(command));
25907
- return new DispatchResult(results.flat());
25898
+ if (results.some((r) => r !== 0 /* Success */)) {
25899
+ return new DispatchResult(results.flat());
25900
+ }
25901
+ return DispatchResult.Success;
25908
25902
  }
25909
25903
  finalize() {
25910
25904
  this.status = 3 /* Finalizing */;
@@ -31343,6 +31337,6 @@ const helpers = {
31343
31337
  export { CommandResult, CorePlugin, DATETIME_FORMAT, DataSource, DispatchResult, Model, Registry, Revision, SPREADSHEET_DIMENSIONS, Spreadsheet, UIPlugin, DEBUG as __DEBUG__, __info__, astToFormula, cellTypes, compile, convertAstNodes, coreTypes, functionCache, helpers, invalidateEvaluationCommands, parse, readonlyAllowedCommands, registries, setTranslationMethod };
31344
31338
 
31345
31339
 
31346
- __info__.version = '15.2.12';
31347
- __info__.date = '2023-11-16T11:57:04.728Z';
31348
- __info__.hash = 'd0fd7c1';
31340
+ __info__.version = '15.2.13';
31341
+ __info__.date = '2023-11-24T13:06:49.659Z';
31342
+ __info__.hash = 'ea82269';
@@ -2706,13 +2706,6 @@
2706
2706
  }
2707
2707
 
2708
2708
  //------------------------------------------------------------------------------
2709
- /**
2710
- * Stringify an object, like JSON.stringify, except that the first level of keys
2711
- * is ordered.
2712
- */
2713
- function stringify(obj) {
2714
- return JSON.stringify(obj, Object.keys(obj).sort());
2715
- }
2716
2709
  /**
2717
2710
  * Remove quotes from a quoted string
2718
2711
  * ```js
@@ -2937,7 +2930,7 @@
2937
2930
  */
2938
2931
  function getItemId(item, itemsDic) {
2939
2932
  for (let [key, value] of Object.entries(itemsDic)) {
2940
- if (stringify(value) === stringify(item)) {
2933
+ if (deepEquals(value, item)) {
2941
2934
  return parseInt(key, 10);
2942
2935
  }
2943
2936
  }
@@ -9402,7 +9395,7 @@
9402
9395
  */
9403
9396
  function getBorderId(border) {
9404
9397
  for (let [key, value] of Object.entries(borders)) {
9405
- if (stringify(value) === stringify(border)) {
9398
+ if (deepEquals(value, border)) {
9406
9399
  return parseInt(key, 10);
9407
9400
  }
9408
9401
  }
@@ -9640,12 +9633,10 @@
9640
9633
  * starting an async evaluation even if it has been moved or re-allocated
9641
9634
  */
9642
9635
  getCellById(cellId) {
9643
- for (const sheet of Object.values(this.cells)) {
9644
- if (sheet[cellId]) {
9645
- return sheet[cellId];
9646
- }
9647
- }
9648
- return undefined;
9636
+ // this must be as fast as possible
9637
+ const position = this.getters.getCellPosition(cellId);
9638
+ const sheet = this.cells[position.sheetId];
9639
+ return sheet[cellId];
9649
9640
  }
9650
9641
  /**
9651
9642
  * Try to infer the cell format based on the formula dependencies.
@@ -23410,9 +23401,9 @@
23410
23401
  * Apply the changes of the given HistoryChange to the state
23411
23402
  */
23412
23403
  function applyChange(change, target) {
23413
- let val = change.root;
23414
- let key = change.path[change.path.length - 1];
23415
- for (let pathIndex = 0; pathIndex < change.path.slice(0, -1).length; pathIndex++) {
23404
+ let val = change.path[0];
23405
+ const key = change.path[change.path.length - 1];
23406
+ for (let pathIndex = 1; pathIndex < change.path.slice(0, -1).length; pathIndex++) {
23416
23407
  const p = change.path[pathIndex];
23417
23408
  if (val[p] === undefined) {
23418
23409
  const nextPath = change.path[pathIndex + 1];
@@ -23868,13 +23859,14 @@
23868
23859
  }
23869
23860
  addChange(...args) {
23870
23861
  const val = args.pop();
23871
- const [root, ...path] = args;
23862
+ const root = args[0];
23872
23863
  let value = root;
23873
- let key = path[path.length - 1];
23874
- for (let pathIndex = 0; pathIndex <= path.length - 2; pathIndex++) {
23875
- const p = path[pathIndex];
23864
+ let key = args[args.length - 1];
23865
+ const pathLength = args.length - 2;
23866
+ for (let pathIndex = 1; pathIndex <= pathLength; pathIndex++) {
23867
+ const p = args[pathIndex];
23876
23868
  if (value[p] === undefined) {
23877
- const nextPath = path[pathIndex + 1];
23869
+ const nextPath = args[pathIndex + 1];
23878
23870
  value[p] = createEmptyStructure(nextPath);
23879
23871
  }
23880
23872
  value = value[p];
@@ -23883,8 +23875,7 @@
23883
23875
  return;
23884
23876
  }
23885
23877
  this.changes.push({
23886
- root,
23887
- path,
23878
+ path: args,
23888
23879
  before: value[key],
23889
23880
  after: val,
23890
23881
  });
@@ -25924,7 +25915,10 @@
25924
25915
  */
25925
25916
  checkDispatchAllowed(command) {
25926
25917
  const results = this.handlers.map((handler) => handler.allowDispatch(command));
25927
- return new DispatchResult(results.flat());
25918
+ if (results.some((r) => r !== 0 /* Success */)) {
25919
+ return new DispatchResult(results.flat());
25920
+ }
25921
+ return DispatchResult.Success;
25928
25922
  }
25929
25923
  finalize() {
25930
25924
  this.status = 3 /* Finalizing */;
@@ -31388,9 +31382,9 @@
31388
31382
  Object.defineProperty(exports, '__esModule', { value: true });
31389
31383
 
31390
31384
 
31391
- __info__.version = '15.2.12';
31392
- __info__.date = '2023-11-16T11:57:04.728Z';
31393
- __info__.hash = 'd0fd7c1';
31385
+ __info__.version = '15.2.13';
31386
+ __info__.date = '2023-11-24T13:06:49.659Z';
31387
+ __info__.hash = 'ea82269';
31394
31388
 
31395
31389
 
31396
31390
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);