@fluidframework/matrix 2.1.0-276985 → 2.1.0

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.
Files changed (88) hide show
  1. package/.eslintrc.cjs +2 -5
  2. package/CHANGELOG.md +4 -0
  3. package/api-extractor/api-extractor.current.json +5 -0
  4. package/api-extractor/api-extractor.legacy.json +1 -1
  5. package/api-extractor.json +1 -1
  6. package/api-report/matrix.legacy.public.api.md +9 -0
  7. package/dist/handlecache.d.ts +7 -3
  8. package/dist/handlecache.d.ts.map +1 -1
  9. package/dist/handlecache.js +25 -7
  10. package/dist/handlecache.js.map +1 -1
  11. package/dist/handletable.d.ts +3 -1
  12. package/dist/handletable.d.ts.map +1 -1
  13. package/dist/handletable.js.map +1 -1
  14. package/dist/legacy.d.ts +1 -1
  15. package/dist/matrix.d.ts +2 -1
  16. package/dist/matrix.d.ts.map +1 -1
  17. package/dist/matrix.js +23 -9
  18. package/dist/matrix.js.map +1 -1
  19. package/dist/packageVersion.d.ts +1 -1
  20. package/dist/packageVersion.d.ts.map +1 -1
  21. package/dist/packageVersion.js +1 -1
  22. package/dist/packageVersion.js.map +1 -1
  23. package/dist/permutationvector.d.ts +5 -5
  24. package/dist/permutationvector.d.ts.map +1 -1
  25. package/dist/permutationvector.js +11 -4
  26. package/dist/permutationvector.js.map +1 -1
  27. package/dist/public.d.ts +1 -1
  28. package/dist/range.d.ts.map +1 -1
  29. package/dist/range.js.map +1 -1
  30. package/dist/runtime.d.ts.map +1 -1
  31. package/dist/runtime.js.map +1 -1
  32. package/dist/serialization.d.ts.map +1 -1
  33. package/dist/serialization.js.map +1 -1
  34. package/dist/sparsearray2d.d.ts +9 -5
  35. package/dist/sparsearray2d.d.ts.map +1 -1
  36. package/dist/sparsearray2d.js +27 -7
  37. package/dist/sparsearray2d.js.map +1 -1
  38. package/dist/undoprovider.d.ts.map +1 -1
  39. package/dist/undoprovider.js +10 -3
  40. package/dist/undoprovider.js.map +1 -1
  41. package/internal.d.ts +1 -1
  42. package/legacy.d.ts +1 -1
  43. package/lib/handlecache.d.ts +7 -3
  44. package/lib/handlecache.d.ts.map +1 -1
  45. package/lib/handlecache.js +25 -7
  46. package/lib/handlecache.js.map +1 -1
  47. package/lib/handletable.d.ts +3 -1
  48. package/lib/handletable.d.ts.map +1 -1
  49. package/lib/handletable.js.map +1 -1
  50. package/lib/legacy.d.ts +1 -1
  51. package/lib/matrix.d.ts +2 -1
  52. package/lib/matrix.d.ts.map +1 -1
  53. package/lib/matrix.js +23 -9
  54. package/lib/matrix.js.map +1 -1
  55. package/lib/packageVersion.d.ts +1 -1
  56. package/lib/packageVersion.d.ts.map +1 -1
  57. package/lib/packageVersion.js +1 -1
  58. package/lib/packageVersion.js.map +1 -1
  59. package/lib/permutationvector.d.ts +5 -5
  60. package/lib/permutationvector.d.ts.map +1 -1
  61. package/lib/permutationvector.js +11 -4
  62. package/lib/permutationvector.js.map +1 -1
  63. package/lib/public.d.ts +1 -1
  64. package/lib/range.d.ts.map +1 -1
  65. package/lib/range.js.map +1 -1
  66. package/lib/runtime.d.ts.map +1 -1
  67. package/lib/runtime.js.map +1 -1
  68. package/lib/serialization.d.ts.map +1 -1
  69. package/lib/serialization.js.map +1 -1
  70. package/lib/sparsearray2d.d.ts +9 -5
  71. package/lib/sparsearray2d.d.ts.map +1 -1
  72. package/lib/sparsearray2d.js +27 -7
  73. package/lib/sparsearray2d.js.map +1 -1
  74. package/lib/undoprovider.d.ts.map +1 -1
  75. package/lib/undoprovider.js +10 -3
  76. package/lib/undoprovider.js.map +1 -1
  77. package/package.json +36 -30
  78. package/src/handlecache.ts +31 -16
  79. package/src/handletable.ts +11 -9
  80. package/src/matrix.ts +80 -50
  81. package/src/packageVersion.ts +1 -1
  82. package/src/permutationvector.ts +38 -23
  83. package/src/range.ts +1 -1
  84. package/src/runtime.ts +5 -2
  85. package/src/serialization.ts +4 -2
  86. package/src/sparsearray2d.ts +55 -36
  87. package/src/undoprovider.ts +26 -18
  88. package/tsconfig.json +0 -1
package/.eslintrc.cjs CHANGED
@@ -4,10 +4,7 @@
4
4
  */
5
5
 
6
6
  module.exports = {
7
- extends: [
8
- require.resolve("@fluidframework/eslint-config-fluid/minimal-deprecated"),
9
- "prettier",
10
- ],
7
+ extends: [require.resolve("@fluidframework/eslint-config-fluid"), "prettier"],
11
8
 
12
9
  parserOptions: {
13
10
  project: ["./tsconfig.json", "./src/test/tsconfig.json"],
@@ -22,7 +19,7 @@ module.exports = {
22
19
  files: ["*.spec.ts", "src/test/**"],
23
20
  rules: {
24
21
  // Test files are run in node only so additional node libraries can be used.
25
- "import/no-nodejs-modules": ["error", { allow: ["assert", "path"] }],
22
+ "import/no-nodejs-modules": ["error", { allow: ["node:assert", "node:path"] }],
26
23
  },
27
24
  },
28
25
  ],
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # @fluidframework/matrix
2
2
 
3
+ ## 2.1.0
4
+
5
+ Dependency updates only.
6
+
3
7
  ## 2.0.0-rc.5.0.0
4
8
 
5
9
  ### Minor Changes
@@ -0,0 +1,5 @@
1
+ {
2
+ "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
3
+ "extends": "<projectFolder>/../../../common/build/build-common/api-extractor-report.esm.current.json",
4
+ "mainEntryPointFilePath": "<projectFolder>/lib/public.d.ts"
5
+ }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
3
- "extends": "<projectFolder>/../../../common/build/build-common/api-extractor-base.esm.legacy.json"
3
+ "extends": "<projectFolder>/../../../common/build/build-common/api-extractor-report.esm.legacy.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
3
- "extends": "../../../common/build/build-common/api-extractor-base.esm.current.json"
3
+ "extends": "../../../common/build/build-common/api-extractor-model.esm.json"
4
4
  }
@@ -0,0 +1,9 @@
1
+ ## Public API Report File for "@fluidframework/matrix"
2
+
3
+ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4
+
5
+ ```ts
6
+
7
+ // (No @packageDocumentation comment for this package)
8
+
9
+ ```
@@ -26,13 +26,17 @@ export declare class HandleCache implements IVectorConsumer<Handle> {
26
26
  * the result with 'isValidHandle(..)' to see if a handle has been allocated for
27
27
  * the given position.
28
28
  *
29
- * Throws a 'RangeError' if the provided 'position' is out-of-bounds wrt. the
29
+ * @throws A 'RangeError' if the provided 'position' is out-of-bounds with regards to the
30
30
  * PermutationVector's length.
31
31
  */
32
32
  getHandle(position: number): Handle;
33
- /** Update the cache when a handle has been allocated for a given position. */
33
+ /**
34
+ * Update the cache when a handle has been allocated for a given position.
35
+ */
34
36
  addHandle(position: number, handle: Handle): void;
35
- /** Used by 'CacheMiss()' to retrieve handles for a range of positions. */
37
+ /**
38
+ * Used by {@link HandleCache.cacheMiss} to retrieve handles for a range of positions.
39
+ */
36
40
  private getHandles;
37
41
  private cacheMiss;
38
42
  itemsChanged(start: number, removedCount: number, insertedCount: number): void;
@@ -1 +1 @@
1
- {"version":3,"file":"handlecache.d.ts","sourceRoot":"","sources":["../src/handlecache.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,EAAE,MAAM,EAAiB,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAsB,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAG/E;;;;;GAKG;AACH,qBAAa,WAAY,YAAW,eAAe,CAAC,MAAM,CAAC;aAI9B,MAAM,EAAE,iBAAiB;IAHrD,OAAO,CAAC,OAAO,CAAgB;IAC/B,OAAO,CAAC,KAAK,CAAK;gBAEU,MAAM,EAAE,iBAAiB;IAErD;;;OAGG;IACH,OAAO,CAAC,QAAQ;IAIhB;;;;;;;OAOG;IACI,SAAS,CAAC,QAAQ,EAAE,MAAM;IAajC,8EAA8E;IACvE,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAajD,0EAA0E;IAC1E,OAAO,CAAC,UAAU;IAiBlB,OAAO,CAAC,SAAS;IA4BjB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,IAAI;CAoB9E"}
1
+ {"version":3,"file":"handlecache.d.ts","sourceRoot":"","sources":["../src/handlecache.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,EAAE,MAAM,EAAiB,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAsB,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAG/E;;;;;GAKG;AACH,qBAAa,WAAY,YAAW,eAAe,CAAC,MAAM,CAAC;aAI9B,MAAM,EAAE,iBAAiB;IAHrD,OAAO,CAAC,OAAO,CAAgB;IAC/B,OAAO,CAAC,KAAK,CAAK;gBAEU,MAAM,EAAE,iBAAiB;IAErD;;;OAGG;IACH,OAAO,CAAC,QAAQ;IAIhB;;;;;;;OAOG;IACI,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IAiB1C;;OAEG;IACI,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAexD;;OAEG;IACH,OAAO,CAAC,UAAU;IAiBlB,OAAO,CAAC,SAAS;IAiCjB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,IAAI;CAoB9E"}
@@ -33,7 +33,7 @@ class HandleCache {
33
33
  * the result with 'isValidHandle(..)' to see if a handle has been allocated for
34
34
  * the given position.
35
35
  *
36
- * Throws a 'RangeError' if the provided 'position' is out-of-bounds wrt. the
36
+ * @throws A 'RangeError' if the provided 'position' is out-of-bounds with regards to the
37
37
  * PermutationVector's length.
38
38
  */
39
39
  getHandle(position) {
@@ -43,18 +43,29 @@ class HandleCache {
43
43
  // Perf: A cache hit implies that 'position' was in bounds. Therefore, we can defer
44
44
  // checking that 'position' is in bounds until 'cacheMiss(..)'. This yields an
45
45
  // ~40% speedup when the position is in the cache (node v12 x64).
46
- return index < this.handles.length ? this.handles[index] : this.cacheMiss(position);
46
+ const handle = this.handles[index];
47
+ if (handle !== undefined) {
48
+ return handle;
49
+ }
50
+ return this.cacheMiss(position);
47
51
  }
48
- /** Update the cache when a handle has been allocated for a given position. */
52
+ /**
53
+ * Update the cache when a handle has been allocated for a given position.
54
+ */
49
55
  addHandle(position, handle) {
50
56
  (0, internal_1.assert)((0, handletable_js_1.isHandleValid)(handle), 0x017 /* "Trying to add invalid handle!" */);
51
57
  const index = this.getIndex(position);
52
58
  if (index < this.handles.length) {
53
- (0, internal_1.assert)(!(0, handletable_js_1.isHandleValid)(this.handles[index]), 0x018 /* "Trying to insert handle into position with already valid handle!" */);
59
+ (0, internal_1.assert)(
60
+ // Non null asserting, above we checked that the index is less than the length.
61
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
62
+ !(0, handletable_js_1.isHandleValid)(this.handles[index]), 0x018 /* "Trying to insert handle into position with already valid handle!" */);
54
63
  this.handles[index] = handle;
55
64
  }
56
65
  }
57
- /** Used by 'CacheMiss()' to retrieve handles for a range of positions. */
66
+ /**
67
+ * Used by {@link HandleCache.cacheMiss} to retrieve handles for a range of positions.
68
+ */
58
69
  getHandles(start, end) {
59
70
  // TODO: This can be accelerated substantially using 'walkSegments()'. The only catch
60
71
  // is that
@@ -78,13 +89,20 @@ class HandleCache {
78
89
  // the cache to the next MergeTree segment boundary (within the limits of
79
90
  // the handle cache).
80
91
  if (_position < this.start) {
81
- this.handles = this.getHandles(_position, this.start).concat(this.handles);
92
+ this.handles = [...this.getHandles(_position, this.start), ...this.handles];
82
93
  this.start = _position;
94
+ // TODO why are we non null asserting here?
95
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
83
96
  return this.handles[0];
84
97
  }
85
98
  else {
86
99
  (0, range_js_1.ensureRange)(_position, this.vector.getLength());
87
- this.handles = this.handles.concat(this.getHandles(this.start + this.handles.length, _position + 1));
100
+ this.handles = [
101
+ ...this.handles,
102
+ ...this.getHandles(this.start + this.handles.length, _position + 1),
103
+ ];
104
+ // TODO why are we non null asserting here?
105
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
88
106
  return this.handles[this.handles.length - 1];
89
107
  }
90
108
  }
@@ -1 +1 @@
1
- {"version":3,"file":"handlecache.js","sourceRoot":"","sources":["../src/handlecache.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+BAA+B;AAE/B,kEAA6D;AAG7D,qDAAyD;AAEzD,yCAAyC;AAEzC;;;;;GAKG;AACH,MAAa,WAAW;IAIvB,YAA4B,MAAyB;QAAzB,WAAM,GAAN,MAAM,CAAmB;QAH7C,YAAO,GAAa,EAAE,CAAC;QACvB,UAAK,GAAG,CAAC,CAAC;IAEsC,CAAC;IAEzD;;;OAGG;IACK,QAAQ,CAAC,QAAgB;QAChC,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;IAED;;;;;;;OAOG;IACI,SAAS,CAAC,QAAgB;QAChC,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAEtC,uFAAuF;QACvF,8BAA8B;QAE9B,oFAAoF;QACpF,qFAAqF;QACrF,uEAAuE;QAEvE,OAAO,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IACrF,CAAC;IAED,8EAA8E;IACvE,SAAS,CAAC,QAAgB,EAAE,MAAc;QAChD,IAAA,iBAAM,EAAC,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,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAC3E,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;YACvB,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QACxB,CAAC;aAAM,CAAC;YACP,IAAA,sBAAW,EAAC,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC;YAEhD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CACjC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,SAAS,GAAG,CAAC,CAAC,CAChE,CAAC;YACF,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAC9C,CAAC;IACF,CAAC;IAED,0BAA0B;IAE1B,YAAY,CAAC,KAAa,EAAE,YAAoB,EAAE,aAAqB;QACtE,8EAA8E;QAC9E,6EAA6E;QAC7E,aAAa;QACb,EAAE;QACF,4EAA4E;QAC5E,wBAAwB;QACxB,EAAE;QACF,6FAA6F;QAC7F,2EAA2E;QAC3E,EAAE;QACF,gFAAgF;QAEhF,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACnC,IAAI,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;YACjC,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,KAAK,CAAC;QAC7B,CAAC;IACF,CAAC;CAGD;AAnHD,kCAmHC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable no-bitwise */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { IVectorConsumer } from \"@tiny-calc/nano\";\n\nimport { Handle, isHandleValid } from \"./handletable.js\";\nimport { PermutationSegment, PermutationVector } from \"./permutationvector.js\";\nimport { ensureRange } from \"./range.js\";\n\n/**\n * Used by PermutationVector to cache position -\\> handle lookups.\n *\n * Perf: Possibly, this should eventually be inlined into PermutationVector itself, but\n * so far there's no measurable perf penalty for being a separate object (node 12 x64)\n */\nexport class HandleCache implements IVectorConsumer<Handle> {\n\tprivate handles: Handle[] = [];\n\tprivate start = 0;\n\n\tconstructor(public readonly vector: PermutationVector) {}\n\n\t/**\n\t * Returns the index of the given position in the 'handles' array as a Uint32.\n\t * (If the position is not in the array, returns an integer greater than 'handles.length').\n\t */\n\tprivate getIndex(position: number) {\n\t\treturn (position - this.start) >>> 0;\n\t}\n\n\t/**\n\t * Returns the handle currently assigned to the given 'position' (if any). Check\n\t * the result with 'isValidHandle(..)' to see if a handle has been allocated for\n\t * the given position.\n\t *\n\t * Throws a 'RangeError' if the provided 'position' is out-of-bounds wrt. the\n\t * PermutationVector's length.\n\t */\n\tpublic getHandle(position: number) {\n\t\tconst index = this.getIndex(position);\n\n\t\t// Perf: To encourage inlining, handling of the 'cacheMiss(..)' case has been extracted\n\t\t// to a separate method.\n\n\t\t// Perf: A cache hit implies that 'position' was in bounds. Therefore, we can defer\n\t\t// checking that 'position' is in bounds until 'cacheMiss(..)'. This yields an\n\t\t// ~40% speedup when the position is in the cache (node v12 x64).\n\n\t\treturn index < this.handles.length ? this.handles[index] : this.cacheMiss(position);\n\t}\n\n\t/** Update the cache when a handle has been allocated for a given position. */\n\tpublic addHandle(position: number, handle: Handle) {\n\t\tassert(isHandleValid(handle), 0x017 /* \"Trying to add invalid handle!\" */);\n\n\t\tconst index = this.getIndex(position);\n\t\tif (index < this.handles.length) {\n\t\t\tassert(\n\t\t\t\t!isHandleValid(this.handles[index]),\n\t\t\t\t0x018 /* \"Trying to insert handle into position with already valid handle!\" */,\n\t\t\t);\n\t\t\tthis.handles[index] = handle;\n\t\t}\n\t}\n\n\t/** Used by 'CacheMiss()' to retrieve handles for a range of positions. */\n\tprivate getHandles(start: number, end: number) {\n\t\t// TODO: This can be accelerated substantially using 'walkSegments()'. The only catch\n\t\t// is that\n\n\t\tconst handles: Handle[] = [];\n\t\tconst { vector } = this;\n\n\t\tfor (let pos = start; pos < end; pos++) {\n\t\t\tconst { segment, offset } = vector.getContainingSegment(pos);\n\t\t\tconst asPerm = segment as PermutationSegment;\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\thandles.push(asPerm.start + offset!);\n\t\t}\n\n\t\treturn handles;\n\t}\n\n\tprivate cacheMiss(position: number) {\n\t\t// Coercing 'position' to an Uint32 allows us to handle a negative 'position' value\n\t\t// with the same logic that handles 'position' >= length.\n\t\tconst _position = position >>> 0;\n\n\t\t// TODO: To bound memory usage, there should be a limit on the maximum size of\n\t\t// handle[].\n\n\t\t// TODO: To reduce MergeTree lookups, this code should opportunistically grow\n\t\t// the cache to the next MergeTree segment boundary (within the limits of\n\t\t// the handle cache).\n\n\t\tif (_position < this.start) {\n\t\t\tthis.handles = this.getHandles(_position, this.start).concat(this.handles);\n\t\t\tthis.start = _position;\n\t\t\treturn this.handles[0];\n\t\t} else {\n\t\t\tensureRange(_position, this.vector.getLength());\n\n\t\t\tthis.handles = this.handles.concat(\n\t\t\t\tthis.getHandles(this.start + this.handles.length, _position + 1),\n\t\t\t);\n\t\t\treturn this.handles[this.handles.length - 1];\n\t\t}\n\t}\n\n\t// #region IVectorConsumer\n\n\titemsChanged(start: number, removedCount: number, insertedCount: number): void {\n\t\t// If positions were inserted/removed, our current policy is to trim the array\n\t\t// at the beginning of the invalidate range and lazily repopulate the handles\n\t\t// on demand.\n\t\t//\n\t\t// Some alternatives to consider that preserve the previously cached handles\n\t\t// that are still valid:\n\t\t//\n\t\t// * Eagerly populate the 'handles[]' with the newly insert values (currently guaranteed\n\t\t// to be Handle.unallocated, so we don't even need to look them up.)\n\t\t//\n\t\t// * Use a sentinel value or other mechanism to allow \"holes\" in the cache.\n\n\t\tconst index = this.getIndex(start);\n\t\tif (index < this.handles.length) {\n\t\t\tthis.handles.length = index;\n\t\t}\n\t}\n\n\t// #endregion IVectorConsumer\n}\n"]}
1
+ {"version":3,"file":"handlecache.js","sourceRoot":"","sources":["../src/handlecache.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+BAA+B;AAE/B,kEAA6D;AAG7D,qDAAyD;AAEzD,yCAAyC;AAEzC;;;;;GAKG;AACH,MAAa,WAAW;IAIvB,YAA4B,MAAyB;QAAzB,WAAM,GAAN,MAAM,CAAmB;QAH7C,YAAO,GAAa,EAAE,CAAC;QACvB,UAAK,GAAG,CAAC,CAAC;IAEsC,CAAC;IAEzD;;;OAGG;IACK,QAAQ,CAAC,QAAgB;QAChC,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;IAED;;;;;;;OAOG;IACI,SAAS,CAAC,QAAgB;QAChC,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAEtC,uFAAuF;QACvF,8BAA8B;QAE9B,oFAAoF;QACpF,qFAAqF;QACrF,uEAAuE;QAEvE,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QACnC,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YAC1B,OAAO,MAAM,CAAC;QACf,CAAC;QACD,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IACjC,CAAC;IAED;;OAEG;IACI,SAAS,CAAC,QAAgB,EAAE,MAAc;QAChD,IAAA,iBAAM,EAAC,IAAA,8BAAa,EAAC,MAAM,CAAC,EAAE,KAAK,CAAC,qCAAqC,CAAC,CAAC;QAE3E,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACtC,IAAI,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;YACjC,IAAA,iBAAM;YACL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CAAC,CAAE,CAAC;QACzB,CAAC;aAAM,CAAC;YACP,IAAA,sBAAW,EAAC,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC;YAEhD,IAAI,CAAC,OAAO,GAAG;gBACd,GAAG,IAAI,CAAC,OAAO;gBACf,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,SAAS,GAAG,CAAC,CAAC;aACnE,CAAC;YACF,2CAA2C;YAC3C,oEAAoE;YACpE,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAE,CAAC;QAC/C,CAAC;IACF,CAAC;IAED,0BAA0B;IAE1B,YAAY,CAAC,KAAa,EAAE,YAAoB,EAAE,aAAqB;QACtE,8EAA8E;QAC9E,6EAA6E;QAC7E,aAAa;QACb,EAAE;QACF,4EAA4E;QAC5E,wBAAwB;QACxB,EAAE;QACF,6FAA6F;QAC7F,2EAA2E;QAC3E,EAAE;QACF,gFAAgF;QAEhF,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACnC,IAAI,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;YACjC,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,KAAK,CAAC;QAC7B,CAAC;IACF,CAAC;CAGD;AAlID,kCAkIC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable no-bitwise */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { IVectorConsumer } from \"@tiny-calc/nano\";\n\nimport { Handle, isHandleValid } from \"./handletable.js\";\nimport { PermutationSegment, PermutationVector } from \"./permutationvector.js\";\nimport { ensureRange } from \"./range.js\";\n\n/**\n * Used by PermutationVector to cache position -\\> handle lookups.\n *\n * Perf: Possibly, this should eventually be inlined into PermutationVector itself, but\n * so far there's no measurable perf penalty for being a separate object (node 12 x64)\n */\nexport class HandleCache implements IVectorConsumer<Handle> {\n\tprivate handles: Handle[] = [];\n\tprivate start = 0;\n\n\tconstructor(public readonly vector: PermutationVector) {}\n\n\t/**\n\t * Returns the index of the given position in the 'handles' array as a Uint32.\n\t * (If the position is not in the array, returns an integer greater than 'handles.length').\n\t */\n\tprivate getIndex(position: number): number {\n\t\treturn (position - this.start) >>> 0;\n\t}\n\n\t/**\n\t * Returns the handle currently assigned to the given 'position' (if any). Check\n\t * the result with 'isValidHandle(..)' to see if a handle has been allocated for\n\t * the given position.\n\t *\n\t * @throws A 'RangeError' if the provided 'position' is out-of-bounds with regards to the\n\t * PermutationVector's length.\n\t */\n\tpublic getHandle(position: number): Handle {\n\t\tconst index = this.getIndex(position);\n\n\t\t// Perf: To encourage inlining, handling of the 'cacheMiss(..)' case has been extracted\n\t\t// to a separate method.\n\n\t\t// Perf: A cache hit implies that 'position' was in bounds. Therefore, we can defer\n\t\t// checking that 'position' is in bounds until 'cacheMiss(..)'. This yields an\n\t\t// ~40% speedup when the position is in the cache (node v12 x64).\n\n\t\tconst handle = this.handles[index];\n\t\tif (handle !== undefined) {\n\t\t\treturn handle;\n\t\t}\n\t\treturn this.cacheMiss(position);\n\t}\n\n\t/**\n\t * Update the cache when a handle has been allocated for a given position.\n\t */\n\tpublic addHandle(position: number, handle: Handle): void {\n\t\tassert(isHandleValid(handle), 0x017 /* \"Trying to add invalid handle!\" */);\n\n\t\tconst index = this.getIndex(position);\n\t\tif (index < this.handles.length) {\n\t\t\tassert(\n\t\t\t\t// Non null asserting, above we checked that the index is less than the length.\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t!isHandleValid(this.handles[index]!),\n\t\t\t\t0x018 /* \"Trying to insert handle into position with already valid handle!\" */,\n\t\t\t);\n\t\t\tthis.handles[index] = handle;\n\t\t}\n\t}\n\n\t/**\n\t * Used by {@link HandleCache.cacheMiss} to retrieve handles for a range of positions.\n\t */\n\tprivate getHandles(start: number, end: number): Handle[] {\n\t\t// TODO: This can be accelerated substantially using 'walkSegments()'. The only catch\n\t\t// is that\n\n\t\tconst handles: Handle[] = [];\n\t\tconst { vector } = this;\n\n\t\tfor (let pos = start; pos < end; pos++) {\n\t\t\tconst { segment, offset } = vector.getContainingSegment(pos);\n\t\t\tconst asPerm = segment as PermutationSegment;\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\thandles.push(asPerm.start + offset!);\n\t\t}\n\n\t\treturn handles;\n\t}\n\n\tprivate cacheMiss(position: number): Handle {\n\t\t// Coercing 'position' to an Uint32 allows us to handle a negative 'position' value\n\t\t// with the same logic that handles 'position' >= length.\n\t\tconst _position = position >>> 0;\n\n\t\t// TODO: To bound memory usage, there should be a limit on the maximum size of\n\t\t// handle[].\n\n\t\t// TODO: To reduce MergeTree lookups, this code should opportunistically grow\n\t\t// the cache to the next MergeTree segment boundary (within the limits of\n\t\t// the handle cache).\n\n\t\tif (_position < this.start) {\n\t\t\tthis.handles = [...this.getHandles(_position, this.start), ...this.handles];\n\t\t\tthis.start = _position;\n\t\t\t// TODO why are we non null asserting here?\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\treturn this.handles[0]!;\n\t\t} else {\n\t\t\tensureRange(_position, this.vector.getLength());\n\n\t\t\tthis.handles = [\n\t\t\t\t...this.handles,\n\t\t\t\t...this.getHandles(this.start + this.handles.length, _position + 1),\n\t\t\t];\n\t\t\t// TODO why are we non null asserting here?\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\treturn this.handles[this.handles.length - 1]!;\n\t\t}\n\t}\n\n\t// #region IVectorConsumer\n\n\titemsChanged(start: number, removedCount: number, insertedCount: number): void {\n\t\t// If positions were inserted/removed, our current policy is to trim the array\n\t\t// at the beginning of the invalidate range and lazily repopulate the handles\n\t\t// on demand.\n\t\t//\n\t\t// Some alternatives to consider that preserve the previously cached handles\n\t\t// that are still valid:\n\t\t//\n\t\t// * Eagerly populate the 'handles[]' with the newly insert values (currently guaranteed\n\t\t// to be Handle.unallocated, so we don't even need to look them up.)\n\t\t//\n\t\t// * Use a sentinel value or other mechanism to allow \"holes\" in the cache.\n\n\t\tconst index = this.getIndex(start);\n\t\tif (index < this.handles.length) {\n\t\t\tthis.handles.length = index;\n\t\t}\n\t}\n\n\t// #endregion IVectorConsumer\n}\n"]}
@@ -7,7 +7,9 @@ export declare const enum Handle {
7
7
  * Sentinel representing the absence of a valid handle.
8
8
  */
9
9
  none = 0,
10
- /** Minimum valid handle. */
10
+ /**
11
+ * Minimum valid handle.
12
+ */
11
13
  valid = 1,
12
14
  /**
13
15
  * Sentinel representing an unallocated Handle. Used by PermutationVector
@@ -1 +1 @@
1
- {"version":3,"file":"handletable.d.ts","sourceRoot":"","sources":["../src/handletable.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,0BAAkB,MAAM;IACvB;;OAEG;IACH,IAAI,IAAI;IAER,4BAA4B;IAC5B,KAAK,IAAI;IAET;;;OAGG;IACH,WAAW,cAAc;CACzB;AAED,eAAO,MAAM,aAAa,WAAY,MAAM,YAA2B,CAAC;AAExE;;GAEG;AACH,qBAAa,WAAW,CAAC,CAAC;IAIN,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,GAAE,CAAC,MAAM,GAAG,CAAC,CAAC,EAAQ;IAE1D,KAAK;IAOZ;;OAEG;IACI,QAAQ,IAAI,MAAM;IAmBzB;;OAEG;IACI,YAAY,CAAC,KAAK,EAAE,MAAM;IAQjC;;OAEG;IACI,IAAI,CAAC,MAAM,EAAE,MAAM;IAK1B;;OAEG;IACI,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC;IAI7B;;OAEG;IACI,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IAMnC,OAAO,KAAK,IAAI,GAEf;IACD,OAAO,KAAK,IAAI,QAEf;IAEM,iBAAiB;WAIV,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE;CAG1C"}
1
+ {"version":3,"file":"handletable.d.ts","sourceRoot":"","sources":["../src/handletable.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,0BAAkB,MAAM;IACvB;;OAEG;IACH,IAAI,IAAI;IAER;;OAEG;IACH,KAAK,IAAI;IAET;;;OAGG;IACH,WAAW,cAAc;CACzB;AAED,eAAO,MAAM,aAAa,WAAY,MAAM,KAAG,OAAiC,CAAC;AAEjF;;GAEG;AACH,qBAAa,WAAW,CAAC,CAAC;IAIN,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,GAAE,CAAC,MAAM,GAAG,CAAC,CAAC,EAAQ;IAE1D,KAAK,IAAI,IAAI;IAOpB;;OAEG;IACI,QAAQ,IAAI,MAAM;IAmBzB;;OAEG;IACI,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW;IAQ/C;;OAEG;IACI,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAKjC;;OAEG;IACI,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC;IAI7B;;OAEG;IACI,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI;IAM1C,OAAO,KAAK,IAAI,GAEf;IACD,OAAO,KAAK,IAAI,QAEf;IAEM,iBAAiB,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE;WAI5B,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,GAAG,WAAW,CAAC,CAAC,CAAC;CAG3D"}
@@ -1 +1 @@
1
- {"version":3,"file":"handletable.js","sourceRoot":"","sources":["../src/handletable.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAkBI,MAAM,aAAa,GAAG,CAAC,MAAc,EAAE,EAAE,CAAC,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AAC;IAED;;OAEG;IACI,GAAG,CAAC,MAAc;QACxB,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAM,CAAC;IAClC,CAAC;IAED;;OAEG;IACI,GAAG,CAAC,MAAc,EAAE,KAAQ;QAClC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC;IAC9B,CAAC;IAED,wFAAwF;IACxF,uBAAuB;IACvB,IAAY,IAAI;QACf,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAW,CAAC;IAClC,CAAC;IACD,IAAY,IAAI,CAAC,MAAc;QAC9B,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC;IAC1B,CAAC;IAEM,iBAAiB;QACvB,OAAO,IAAI,CAAC,OAAO,CAAC;IACrB,CAAC;IAEM,MAAM,CAAC,IAAI,CAAI,IAAoB;QACzC,OAAO,IAAI,WAAW,CAAI,IAAI,CAAC,CAAC;IACjC,CAAC;CACD;AApFD,kCAoFC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport const enum Handle {\n\t/**\n\t * Sentinel representing the absence of a valid handle.\n\t */\n\tnone = 0,\n\n\t/** Minimum valid handle. */\n\tvalid = 1,\n\n\t/**\n\t * Sentinel representing an unallocated Handle. Used by PermutationVector\n\t * to delay allocate handles when previously empty row/cols become populated.\n\t */\n\tunallocated = -0x80000000,\n}\n\nexport const isHandleValid = (handle: Handle) => handle >= Handle.valid;\n\n/**\n * A handle table provides a fast mapping from an integer `handle` to a value `T`.\n */\nexport class HandleTable<T> {\n\t// Note: the first slot of the 'handles' array is reserved to store the pointer to the first\n\t// free handle. We initialize this slot with a pointer to slot '1', which will cause\n\t// us to delay allocate the following slot in the array on the first allocation.\n\tpublic constructor(private readonly handles: (Handle | T)[] = [1]) {}\n\n\tpublic clear() {\n\t\t// Restore the HandleTable's initial state by deleting all items in the handles array\n\t\t// and then re-inserting the value '1' in the 0th slot. (See comment at `handles` decl\n\t\t// for explanation.)\n\t\tthis.handles.splice(0, this.handles.length, 1);\n\t}\n\n\t/**\n\t * Allocates and returns the next available handle. Note that freed handles are recycled.\n\t */\n\tpublic allocate(): Handle {\n\t\t// Get the handle to the next free slot.\n\t\tconst free = this.next;\n\n\t\t// Update 'next' to point to the new head of the free list. We use the contents of\n\t\t// recycled slots to store the free list. The contents of the handles[free] will point\n\t\t// to the next available slot. If there are no free slots (i.e., 'handles' is full),\n\t\t// the slot will point to 'handles.length'. In this case, the handles array will grow\n\t\t// and we update 'next' to point to the new end of the array.\n\t\tthis.next = (this.handles[free] as Handle) ?? free + 1;\n\n\t\t// Out of paranoia, overwrite the contents of the newly allocated free slot with an\n\t\t// invalid handle value. This may help catch/diagnose bugs in the event the free list\n\t\t// becomes corrupted.\n\t\tthis.handles[free] = Handle.none;\n\n\t\treturn free;\n\t}\n\n\t/**\n\t * Allocates and returns the next available `count` handles.\n\t */\n\tpublic allocateMany(count: Handle) {\n\t\tconst handles = new Uint32Array(count);\n\t\tfor (let i = 0; i < count; i++) {\n\t\t\thandles[i] = this.allocate();\n\t\t}\n\t\treturn handles;\n\t}\n\n\t/**\n\t * Returns the given handle to the free list.\n\t */\n\tpublic free(handle: Handle) {\n\t\tthis.handles[handle] = this.next;\n\t\tthis.next = handle;\n\t}\n\n\t/**\n\t * Get the value `T` associated with the given handle, if any.\n\t */\n\tpublic get(handle: Handle): T {\n\t\treturn this.handles[handle] as T;\n\t}\n\n\t/**\n\t * Set the value `T` associated with the given handle.\n\t */\n\tpublic set(handle: Handle, value: T) {\n\t\tthis.handles[handle] = value;\n\t}\n\n\t// Private helpers to get/set the head of the free list, which is stored in the 0th slot\n\t// of the handle array.\n\tprivate get next() {\n\t\treturn this.handles[0] as Handle;\n\t}\n\tprivate set next(handle: Handle) {\n\t\tthis.handles[0] = handle;\n\t}\n\n\tpublic getSummaryContent() {\n\t\treturn this.handles;\n\t}\n\n\tpublic static load<T>(data: (Handle | T)[]) {\n\t\treturn new HandleTable<T>(data);\n\t}\n}\n"]}
1
+ {"version":3,"file":"handletable.js","sourceRoot":"","sources":["../src/handletable.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAoBI,MAAM,aAAa,GAAG,CAAC,MAAc,EAAW,EAAE,CAAC,MAAM,wBAAgB,CAAC;AAApE,QAAA,aAAa,iBAAuD;AAEjF;;GAEG;AACH,MAAa,WAAW;IACvB,4FAA4F;IAC5F,2FAA2F;IAC3F,sFAAsF;IACtF,YAAoC,UAA0B,CAAC,CAAC,CAAC;QAA7B,YAAO,GAAP,OAAO,CAAsB;IAAG,CAAC;IAE9D,KAAK;QACX,qFAAqF;QACrF,uFAAuF;QACvF,oBAAoB;QACpB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IAChD,CAAC;IAED;;OAEG;IACI,QAAQ;QACd,wCAAwC;QACxC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QAEvB,mFAAmF;QACnF,uFAAuF;QACvF,qFAAqF;QACrF,sFAAsF;QACtF,6DAA6D;QAC7D,IAAI,CAAC,IAAI,GAAI,IAAI,CAAC,OAAO,CAAC,IAAI,CAAY,IAAI,IAAI,GAAG,CAAC,CAAC;QAEvD,mFAAmF;QACnF,sFAAsF;QACtF,qBAAqB;QACrB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,sBAAc,CAAC;QAEjC,OAAO,IAAI,CAAC;IACb,CAAC;IAED;;OAEG;IACI,YAAY,CAAC,KAAa;QAChC,MAAM,OAAO,GAAG,IAAI,WAAW,CAAC,KAAK,CAAC,CAAC;QACvC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC;YAChC,OAAO,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;QAC9B,CAAC;QACD,OAAO,OAAO,CAAC;IAChB,CAAC;IAED;;OAEG;IACI,IAAI,CAAC,MAAc;QACzB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC;QACjC,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC;IACpB,CAAC;IAED;;OAEG;IACI,GAAG,CAAC,MAAc;QACxB,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAM,CAAC;IAClC,CAAC;IAED;;OAEG;IACI,GAAG,CAAC,MAAc,EAAE,KAAQ;QAClC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC;IAC9B,CAAC;IAED,wFAAwF;IACxF,uBAAuB;IACvB,IAAY,IAAI;QACf,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAW,CAAC;IAClC,CAAC;IACD,IAAY,IAAI,CAAC,MAAc;QAC9B,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC;IAC1B,CAAC;IAEM,iBAAiB;QACvB,OAAO,IAAI,CAAC,OAAO,CAAC;IACrB,CAAC;IAEM,MAAM,CAAC,IAAI,CAAI,IAAoB;QACzC,OAAO,IAAI,WAAW,CAAI,IAAI,CAAC,CAAC;IACjC,CAAC;CACD;AApFD,kCAoFC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport const enum Handle {\n\t/**\n\t * Sentinel representing the absence of a valid handle.\n\t */\n\tnone = 0,\n\n\t/**\n\t * Minimum valid handle.\n\t */\n\tvalid = 1,\n\n\t/**\n\t * Sentinel representing an unallocated Handle. Used by PermutationVector\n\t * to delay allocate handles when previously empty row/cols become populated.\n\t */\n\tunallocated = -0x80000000,\n}\n\nexport const isHandleValid = (handle: Handle): boolean => handle >= Handle.valid;\n\n/**\n * A handle table provides a fast mapping from an integer `handle` to a value `T`.\n */\nexport class HandleTable<T> {\n\t// Note: the first slot of the 'handles' array is reserved to store the pointer to the first\n\t// free handle. We initialize this slot with a pointer to slot '1', which will cause\n\t// us to delay allocate the following slot in the array on the first allocation.\n\tpublic constructor(private readonly handles: (Handle | T)[] = [1]) {}\n\n\tpublic clear(): void {\n\t\t// Restore the HandleTable's initial state by deleting all items in the handles array\n\t\t// and then re-inserting the value '1' in the 0th slot. (See comment at `handles` decl\n\t\t// for explanation.)\n\t\tthis.handles.splice(0, this.handles.length, 1);\n\t}\n\n\t/**\n\t * Allocates and returns the next available handle. Note that freed handles are recycled.\n\t */\n\tpublic allocate(): Handle {\n\t\t// Get the handle to the next free slot.\n\t\tconst free = this.next;\n\n\t\t// Update 'next' to point to the new head of the free list. We use the contents of\n\t\t// recycled slots to store the free list. The contents of the handles[free] will point\n\t\t// to the next available slot. If there are no free slots (i.e., 'handles' is full),\n\t\t// the slot will point to 'handles.length'. In this case, the handles array will grow\n\t\t// and we update 'next' to point to the new end of the array.\n\t\tthis.next = (this.handles[free] as Handle) ?? free + 1;\n\n\t\t// Out of paranoia, overwrite the contents of the newly allocated free slot with an\n\t\t// invalid handle value. This may help catch/diagnose bugs in the event the free list\n\t\t// becomes corrupted.\n\t\tthis.handles[free] = Handle.none;\n\n\t\treturn free;\n\t}\n\n\t/**\n\t * Allocates and returns the next available `count` handles.\n\t */\n\tpublic allocateMany(count: Handle): Uint32Array {\n\t\tconst handles = new Uint32Array(count);\n\t\tfor (let i = 0; i < count; i++) {\n\t\t\thandles[i] = this.allocate();\n\t\t}\n\t\treturn handles;\n\t}\n\n\t/**\n\t * Returns the given handle to the free list.\n\t */\n\tpublic free(handle: Handle): void {\n\t\tthis.handles[handle] = this.next;\n\t\tthis.next = handle;\n\t}\n\n\t/**\n\t * Get the value `T` associated with the given handle, if any.\n\t */\n\tpublic get(handle: Handle): T {\n\t\treturn this.handles[handle] as T;\n\t}\n\n\t/**\n\t * Set the value `T` associated with the given handle.\n\t */\n\tpublic set(handle: Handle, value: T): void {\n\t\tthis.handles[handle] = value;\n\t}\n\n\t// Private helpers to get/set the head of the free list, which is stored in the 0th slot\n\t// of the handle array.\n\tprivate get next(): Handle {\n\t\treturn this.handles[0] as Handle;\n\t}\n\tprivate set next(handle: Handle) {\n\t\tthis.handles[0] = handle;\n\t}\n\n\tpublic getSummaryContent(): (Handle | T)[] {\n\t\treturn this.handles;\n\t}\n\n\tpublic static load<T>(data: (Handle | T)[]): HandleTable<T> {\n\t\treturn new HandleTable<T>(data);\n\t}\n}\n"]}
package/dist/legacy.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  /*
7
7
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
8
- * Generated by "flub generate entrypoints" in @fluidframework/build-tools.
8
+ * Generated by "flub generate entrypoints" in @fluid-tools/build-cli.
9
9
  */
10
10
 
11
11
  export {
package/dist/matrix.d.ts CHANGED
@@ -135,6 +135,7 @@ export declare class SharedMatrix<T = any> extends SharedObject<ISharedMatrixEve
135
135
  * on the SharedMatrix op is 11.
136
136
  */
137
137
  private readonly inFlightRefSeqs;
138
+ readonly getMinInFlightRefSeq: () => number | undefined;
138
139
  private readonly rows;
139
140
  private readonly cols;
140
141
  private cells;
@@ -202,7 +203,7 @@ export declare class SharedMatrix<T = any> extends SharedObject<ISharedMatrixEve
202
203
  * automatically advance 'localSeq'.
203
204
  */
204
205
  private nextLocalSeq;
205
- protected submitLocalMessage(message: any, localOpMetadata?: any): void;
206
+ protected submitLocalMessage(message: unknown, localOpMetadata?: unknown): void;
206
207
  protected didAttach(): void;
207
208
  protected onConnect(): void;
208
209
  private rebasePosition;
@@ -1 +1 @@
1
- {"version":3,"file":"matrix.d.ts","sourceRoot":"","sources":["../src/matrix.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,MAAM,EACN,qBAAqB,EACrB,KAAK,cAAc,EACnB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EACN,kBAAkB,EAClB,sBAAsB,EACtB,KAAK,QAAQ,EACb,sBAAsB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;;OAEG;cACa,QAAQ,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;IAoCxE;;;OAGG;IACH,OAAO,CAAC,uBAAuB;IAuB/B,SAAS,CAAC,WAAW,CACpB,GAAG,EAAE,yBAAyB,EAC9B,KAAK,EAAE,OAAO,EACd,eAAe,EAAE,OAAO,GACtB,IAAI;IAmIP,OAAO,CAAC,QAAQ,CAAC,UAAU,CAQzB;IAGF,OAAO,CAAC,QAAQ,CAAC,UAAU,CAQzB;IAEF,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAMnC;IAEF,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAMnC;IAEK,mBAAmB,IAAI,IAAI;IAUlC;;;;;;;OAOG;IACH,OAAO,CAAC,oBAAoB;IAqBrB,QAAQ,IAAI,MAAM;IAoBzB;;OAEG;IACH,SAAS,CAAC,cAAc,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI;CAiBjD"}
package/dist/matrix.js CHANGED
@@ -35,6 +35,9 @@ const undoprovider_js_1 = require("./undoprovider.js");
35
35
  * @legacy
36
36
  * @alpha
37
37
  */
38
+ // Changing this to `unknown` would be a breaking change.
39
+ // TODO: if possible, transition SharedMatrix to not use `any`.
40
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
38
41
  class SharedMatrix extends internal_4.SharedObject {
39
42
  /**
40
43
  * Constructor for the Shared Matrix
@@ -58,6 +61,7 @@ class SharedMatrix extends internal_4.SharedObject {
58
61
  * on the SharedMatrix op is 11.
59
62
  */
60
63
  this.inFlightRefSeqs = new double_ended_queue_1.default();
64
+ this.getMinInFlightRefSeq = () => this.inFlightRefSeqs.get(0);
61
65
  this.cells = new sparsearray2d_js_1.SparseArray2D(); // Stores cell values.
62
66
  this.pending = new sparsearray2d_js_1.SparseArray2D(); // Tracks pending writes.
63
67
  this.cellLastWriteTracker = new sparsearray2d_js_1.SparseArray2D(); // Tracks last writes sequence number and clientId in a cell.
@@ -91,9 +95,8 @@ class SharedMatrix extends internal_4.SharedObject {
91
95
  }
92
96
  };
93
97
  this.setCellLwwToFwwPolicySwitchOpSeqNumber = -1;
94
- const getMinInFlightRefSeq = () => this.inFlightRefSeqs.get(0);
95
- this.rows = new permutationvector_js_1.PermutationVector(ops_js_1.SnapshotPath.rows, this.logger, runtime, this.onRowDelta, this.onRowHandlesRecycled, getMinInFlightRefSeq);
96
- this.cols = new permutationvector_js_1.PermutationVector(ops_js_1.SnapshotPath.cols, this.logger, runtime, this.onColDelta, this.onColHandlesRecycled, getMinInFlightRefSeq);
98
+ this.rows = new permutationvector_js_1.PermutationVector(ops_js_1.SnapshotPath.rows, this.logger, runtime, this.onRowDelta, this.onRowHandlesRecycled, this.getMinInFlightRefSeq);
99
+ this.cols = new permutationvector_js_1.PermutationVector(ops_js_1.SnapshotPath.cols, this.logger, runtime, this.onColDelta, this.onColHandlesRecycled, this.getMinInFlightRefSeq);
97
100
  }
98
101
  /**
99
102
  * Subscribes the given IUndoConsumer to the matrix.
@@ -322,6 +325,8 @@ class SharedMatrix extends internal_4.SharedObject {
322
325
  const rowCount = inserted.cachedLength;
323
326
  for (let row = rowStart; row < rowStart + rowCount; row++, rowHandle++) {
324
327
  for (let col = 0; col < this.colCount; col++) {
328
+ // TODO Non null asserting, why is this not null?
329
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
325
330
  const colHandle = this.colHandles.getHandle(col);
326
331
  const value = this.cells.getCell(rowHandle, colHandle);
327
332
  if (this.isAttached() && value !== undefined && value !== null) {
@@ -343,6 +348,8 @@ class SharedMatrix extends internal_4.SharedObject {
343
348
  const colCount = inserted.cachedLength;
344
349
  for (let col = colStart; col < colStart + colCount; col++, colHandle++) {
345
350
  for (let row = 0; row < this.rowCount; row++) {
351
+ // TODO Non null asserting, why is this not null?
352
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
346
353
  const rowHandle = this.rowHandles.getHandle(row);
347
354
  const value = this.cells.getCell(rowHandle, colHandle);
348
355
  if (this.isAttached() && value !== undefined && value !== null) {
@@ -465,16 +472,18 @@ class SharedMatrix extends internal_4.SharedObject {
465
472
  }
466
473
  else {
467
474
  switch (content.target) {
468
- case ops_js_1.SnapshotPath.cols:
475
+ case ops_js_1.SnapshotPath.cols: {
469
476
  this.submitColMessage(this.cols.regeneratePendingOp(content,
470
477
  // eslint-disable-next-line import/no-deprecated
471
478
  localOpMetadata));
472
479
  break;
473
- case ops_js_1.SnapshotPath.rows:
480
+ }
481
+ case ops_js_1.SnapshotPath.rows: {
474
482
  this.submitRowMessage(this.rows.regeneratePendingOp(content,
475
483
  // eslint-disable-next-line import/no-deprecated
476
484
  localOpMetadata));
477
485
  break;
486
+ }
478
487
  default: {
479
488
  (0, internal_1.unreachableCase)(content);
480
489
  }
@@ -489,7 +498,9 @@ class SharedMatrix extends internal_4.SharedObject {
489
498
  try {
490
499
  await this.rows.load(this.runtime, new internal_3.ObjectStoragePartition(storage, ops_js_1.SnapshotPath.rows), this.serializer);
491
500
  await this.cols.load(this.runtime, new internal_3.ObjectStoragePartition(storage, ops_js_1.SnapshotPath.cols), this.serializer);
492
- const [cellData, _pendingCliSeqData, setCellLwwToFwwPolicySwitchOpSeqNumber, cellLastWriteTracker,] = await (0, serialization_js_1.deserializeBlob)(storage, ops_js_1.SnapshotPath.cells, this.serializer);
501
+ const [cellData, _pendingCliSeqData, setCellLwwToFwwPolicySwitchOpSeqNumber, cellLastWriteTracker,
502
+ // Cast is needed since the (de)serializer returns content of type `any`.
503
+ ] = (await (0, serialization_js_1.deserializeBlob)(storage, ops_js_1.SnapshotPath.cells, this.serializer));
493
504
  this.cells = sparsearray2d_js_1.SparseArray2D.load(cellData);
494
505
  this.setCellLwwToFwwPolicySwitchOpSeqNumber =
495
506
  setCellLwwToFwwPolicySwitchOpSeqNumber ?? -1;
@@ -530,12 +541,14 @@ class SharedMatrix extends internal_4.SharedObject {
530
541
  const contents = msg.contents;
531
542
  const target = contents.target;
532
543
  switch (target) {
533
- case ops_js_1.SnapshotPath.cols:
544
+ case ops_js_1.SnapshotPath.cols: {
534
545
  this.cols.applyMsg(msg, local);
535
546
  break;
536
- case ops_js_1.SnapshotPath.rows:
547
+ }
548
+ case ops_js_1.SnapshotPath.rows: {
537
549
  this.rows.applyMsg(msg, local);
538
550
  break;
551
+ }
539
552
  case undefined: {
540
553
  (0, internal_1.assert)(contents.type === ops_js_1.MatrixOp.set, 0x021 /* "SharedMatrix message contents have unexpected type!" */);
541
554
  const { row, col, value, fwwMode } = contents;
@@ -615,8 +628,9 @@ class SharedMatrix extends internal_4.SharedObject {
615
628
  }
616
629
  break;
617
630
  }
618
- default:
631
+ default: {
619
632
  (0, internal_1.unreachableCase)(target, "unknown target");
633
+ }
620
634
  }
621
635
  }
622
636
  switchSetCellPolicy() {