@fluidframework/matrix 2.0.0-rc.1.0.4 → 2.0.0-rc.2.0.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 (167) hide show
  1. package/{.eslintrc.js → .eslintrc.cjs} +5 -5
  2. package/{.mocharc.js → .mocharc.cjs} +1 -1
  3. package/CHANGELOG.md +4 -0
  4. package/{api-extractor-esm.json → api-extractor-cjs.json} +5 -1
  5. package/api-extractor.json +1 -1
  6. package/api-report/matrix.api.md +22 -10
  7. package/dist/handlecache.d.ts +2 -2
  8. package/dist/handlecache.d.ts.map +1 -1
  9. package/dist/handlecache.js +5 -5
  10. package/dist/handlecache.js.map +1 -1
  11. package/dist/index.d.ts +4 -3
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +4 -4
  14. package/dist/index.js.map +1 -1
  15. package/dist/matrix-alpha.d.ts +29 -7
  16. package/dist/matrix-beta.d.ts +6 -0
  17. package/dist/matrix-public.d.ts +6 -0
  18. package/dist/matrix-untrimmed.d.ts +29 -7
  19. package/dist/matrix.d.ts +30 -16
  20. package/dist/matrix.d.ts.map +1 -1
  21. package/dist/matrix.js +202 -138
  22. package/dist/matrix.js.map +1 -1
  23. package/dist/ops.d.ts +22 -14
  24. package/dist/ops.d.ts.map +1 -1
  25. package/dist/ops.js +7 -2
  26. package/dist/ops.js.map +1 -1
  27. package/dist/package.json +3 -0
  28. package/dist/packageVersion.d.ts +1 -1
  29. package/dist/packageVersion.js +1 -1
  30. package/dist/packageVersion.js.map +1 -1
  31. package/dist/permutationvector.d.ts +5 -5
  32. package/dist/permutationvector.d.ts.map +1 -1
  33. package/dist/permutationvector.js +16 -16
  34. package/dist/permutationvector.js.map +1 -1
  35. package/dist/runtime.d.ts +2 -1
  36. package/dist/runtime.d.ts.map +1 -1
  37. package/dist/runtime.js +5 -5
  38. package/dist/runtime.js.map +1 -1
  39. package/dist/tsdoc-metadata.json +1 -1
  40. package/dist/undoprovider.d.ts +5 -4
  41. package/dist/undoprovider.d.ts.map +1 -1
  42. package/dist/undoprovider.js +2 -2
  43. package/dist/undoprovider.js.map +1 -1
  44. package/lib/{handlecache.d.mts → handlecache.d.ts} +3 -3
  45. package/lib/handlecache.d.ts.map +1 -0
  46. package/lib/{handlecache.mjs → handlecache.js} +4 -3
  47. package/lib/handlecache.js.map +1 -0
  48. package/lib/{handletable.d.mts → handletable.d.ts} +1 -1
  49. package/lib/handletable.d.ts.map +1 -0
  50. package/lib/{handletable.mjs → handletable.js} +1 -1
  51. package/lib/handletable.js.map +1 -0
  52. package/lib/index.d.ts +9 -0
  53. package/lib/index.d.ts.map +1 -0
  54. package/lib/index.js +7 -0
  55. package/lib/index.js.map +1 -0
  56. package/lib/{matrix-alpha.d.mts → matrix-alpha.d.ts} +29 -7
  57. package/lib/{matrix-beta.d.mts → matrix-beta.d.ts} +6 -0
  58. package/lib/{matrix-public.d.mts → matrix-public.d.ts} +6 -0
  59. package/lib/{matrix-untrimmed.d.mts → matrix-untrimmed.d.ts} +29 -7
  60. package/lib/{matrix.d.mts → matrix.d.ts} +31 -17
  61. package/lib/matrix.d.ts.map +1 -0
  62. package/lib/{matrix.mjs → matrix.js} +187 -126
  63. package/lib/matrix.js.map +1 -0
  64. package/lib/ops.d.ts +37 -0
  65. package/lib/ops.d.ts.map +1 -0
  66. package/lib/{ops.mjs → ops.js} +7 -2
  67. package/lib/ops.js.map +1 -0
  68. package/lib/{packageVersion.d.mts → packageVersion.d.ts} +2 -2
  69. package/lib/packageVersion.d.ts.map +1 -0
  70. package/lib/{packageVersion.mjs → packageVersion.js} +2 -2
  71. package/lib/packageVersion.js.map +1 -0
  72. package/lib/{permutationvector.d.mts → permutationvector.d.ts} +6 -6
  73. package/lib/permutationvector.d.ts.map +1 -0
  74. package/lib/{permutationvector.mjs → permutationvector.js} +7 -7
  75. package/lib/permutationvector.js.map +1 -0
  76. package/lib/{range.d.mts → range.d.ts} +1 -1
  77. package/lib/range.d.ts.map +1 -0
  78. package/lib/{range.mjs → range.js} +1 -1
  79. package/lib/range.js.map +1 -0
  80. package/lib/{runtime.d.mts → runtime.d.ts} +3 -2
  81. package/lib/runtime.d.ts.map +1 -0
  82. package/lib/{runtime.mjs → runtime.js} +3 -3
  83. package/lib/runtime.js.map +1 -0
  84. package/lib/{serialization.d.mts → serialization.d.ts} +1 -1
  85. package/lib/serialization.d.ts.map +1 -0
  86. package/lib/{serialization.mjs → serialization.js} +1 -1
  87. package/lib/serialization.js.map +1 -0
  88. package/lib/{sparsearray2d.d.mts → sparsearray2d.d.ts} +1 -1
  89. package/lib/sparsearray2d.d.ts.map +1 -0
  90. package/lib/{sparsearray2d.mjs → sparsearray2d.js} +1 -1
  91. package/lib/sparsearray2d.js.map +1 -0
  92. package/lib/test/dirname.cjs +16 -0
  93. package/lib/test/dirname.cjs.map +1 -0
  94. package/lib/test/matrix.applyStashedOp.spec.js +91 -0
  95. package/lib/test/matrix.applyStashedOp.spec.js.map +1 -0
  96. package/lib/test/matrix.big.spec.js +148 -0
  97. package/lib/test/matrix.big.spec.js.map +1 -0
  98. package/lib/test/matrix.fuzz.spec.js +188 -0
  99. package/lib/test/matrix.fuzz.spec.js.map +1 -0
  100. package/lib/test/matrix.reconnect.spec.js +192 -0
  101. package/lib/test/matrix.reconnect.spec.js.map +1 -0
  102. package/lib/test/matrix.spec.js +1234 -0
  103. package/lib/test/matrix.spec.js.map +1 -0
  104. package/lib/test/matrix.stress.spec.js +461 -0
  105. package/lib/test/matrix.stress.spec.js.map +1 -0
  106. package/lib/test/matrix.undo.spec.js +601 -0
  107. package/lib/test/matrix.undo.spec.js.map +1 -0
  108. package/lib/test/memory/matrix.spec.js +122 -0
  109. package/lib/test/memory/matrix.spec.js.map +1 -0
  110. package/lib/test/sparsearray2d.spec.js +142 -0
  111. package/lib/test/sparsearray2d.spec.js.map +1 -0
  112. package/lib/test/testconsumer.js +76 -0
  113. package/lib/test/testconsumer.js.map +1 -0
  114. package/lib/test/types/validateMatrixPrevious.generated.js +14 -0
  115. package/lib/test/types/validateMatrixPrevious.generated.js.map +1 -0
  116. package/lib/test/undoRedoStackManager.js +176 -0
  117. package/lib/test/undoRedoStackManager.js.map +1 -0
  118. package/lib/test/utils.js +132 -0
  119. package/lib/test/utils.js.map +1 -0
  120. package/lib/{types.d.mts → types.d.ts} +1 -1
  121. package/lib/types.d.ts.map +1 -0
  122. package/lib/{types.mjs → types.js} +1 -1
  123. package/lib/types.js.map +1 -0
  124. package/lib/{undoprovider.d.mts → undoprovider.d.ts} +6 -5
  125. package/lib/undoprovider.d.ts.map +1 -0
  126. package/lib/{undoprovider.mjs → undoprovider.js} +2 -2
  127. package/lib/undoprovider.js.map +1 -0
  128. package/package.json +49 -54
  129. package/src/handlecache.ts +3 -3
  130. package/src/index.ts +4 -3
  131. package/src/matrix.ts +236 -215
  132. package/src/ops.ts +26 -13
  133. package/src/packageVersion.ts +1 -1
  134. package/src/permutationvector.ts +12 -7
  135. package/src/runtime.ts +3 -3
  136. package/src/undoprovider.ts +5 -4
  137. package/tsconfig.cjs.json +7 -0
  138. package/tsconfig.json +2 -5
  139. package/lib/handlecache.d.mts.map +0 -1
  140. package/lib/handlecache.mjs.map +0 -1
  141. package/lib/handletable.d.mts.map +0 -1
  142. package/lib/handletable.mjs.map +0 -1
  143. package/lib/index.d.mts +0 -8
  144. package/lib/index.d.mts.map +0 -1
  145. package/lib/index.mjs +0 -7
  146. package/lib/index.mjs.map +0 -1
  147. package/lib/matrix.d.mts.map +0 -1
  148. package/lib/matrix.mjs.map +0 -1
  149. package/lib/ops.d.mts +0 -29
  150. package/lib/ops.d.mts.map +0 -1
  151. package/lib/ops.mjs.map +0 -1
  152. package/lib/packageVersion.d.mts.map +0 -1
  153. package/lib/packageVersion.mjs.map +0 -1
  154. package/lib/permutationvector.d.mts.map +0 -1
  155. package/lib/permutationvector.mjs.map +0 -1
  156. package/lib/range.d.mts.map +0 -1
  157. package/lib/range.mjs.map +0 -1
  158. package/lib/runtime.d.mts.map +0 -1
  159. package/lib/runtime.mjs.map +0 -1
  160. package/lib/serialization.d.mts.map +0 -1
  161. package/lib/serialization.mjs.map +0 -1
  162. package/lib/sparsearray2d.d.mts.map +0 -1
  163. package/lib/sparsearray2d.mjs.map +0 -1
  164. package/lib/types.d.mts.map +0 -1
  165. package/lib/types.mjs.map +0 -1
  166. package/lib/undoprovider.d.mts.map +0 -1
  167. package/lib/undoprovider.mjs.map +0 -1
@@ -4,7 +4,10 @@
4
4
  */
5
5
 
6
6
  module.exports = {
7
- extends: [require.resolve("@fluidframework/eslint-config-fluid/minimal"), "prettier"],
7
+ extends: [
8
+ require.resolve("@fluidframework/eslint-config-fluid/minimal-deprecated"),
9
+ "prettier",
10
+ ],
8
11
 
9
12
  parserOptions: {
10
13
  project: ["./tsconfig.json", "./src/test/tsconfig.json"],
@@ -12,9 +15,6 @@ module.exports = {
12
15
  rules: {
13
16
  "@typescript-eslint/no-shadow": "off",
14
17
  "space-before-function-paren": "off", // Off because it conflicts with typescript-formatter
15
-
16
- // This library is used in the browser, so we don't want dependencies on most node libraries.
17
- "import/no-nodejs-modules": ["error", { allow: ["events"] }],
18
18
  },
19
19
  overrides: [
20
20
  {
@@ -22,7 +22,7 @@ module.exports = {
22
22
  files: ["*.spec.ts", "src/test/**"],
23
23
  rules: {
24
24
  // Test files are run in node only so additional node libraries can be used.
25
- "import/no-nodejs-modules": ["error", { allow: ["assert", "events"] }],
25
+ "import/no-nodejs-modules": ["error", { allow: ["assert", "path"] }],
26
26
  },
27
27
  },
28
28
  ],
@@ -5,7 +5,7 @@
5
5
 
6
6
  "use strict";
7
7
 
8
- const getFluidTestMochaConfig = require("@fluidframework/mocha-test-setup/mocharc-common");
8
+ const getFluidTestMochaConfig = require("@fluid-internal/mocha-test-setup/mocharc-common");
9
9
 
10
10
  const packageDir = __dirname;
11
11
  const config = getFluidTestMochaConfig(packageDir);
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # @fluidframework/matrix
2
2
 
3
+ ## 2.0.0-rc.2.0.0
4
+
5
+ Dependency updates only.
6
+
3
7
  ## 2.0.0-rc.1.0.0
4
8
 
5
9
  ### Minor Changes
@@ -1,4 +1,8 @@
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.json"
3
+ "extends": "../../../common/build/build-common/api-extractor-base.cjs.primary.json",
4
+ // CJS is actually secondary; so, no report.
5
+ "apiReport": {
6
+ "enabled": false
7
+ }
4
8
  }
@@ -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.json"
3
+ "extends": "../../../common/build/build-common/api-extractor-base.esm.primary.json"
4
4
  }
@@ -9,6 +9,8 @@ import { IChannelAttributes } from '@fluidframework/datastore-definitions';
9
9
  import { IChannelFactory } from '@fluidframework/datastore-definitions';
10
10
  import { IChannelServices } from '@fluidframework/datastore-definitions';
11
11
  import { IChannelStorageService } from '@fluidframework/datastore-definitions';
12
+ import { IEvent } from '@fluidframework/core-interfaces';
13
+ import { IEventProvider } from '@fluidframework/core-interfaces';
12
14
  import { IEventThisPlaceHolder } from '@fluidframework/core-interfaces';
13
15
  import { IFluidDataStoreRuntime } from '@fluidframework/datastore-definitions';
14
16
  import { IFluidSerializer } from '@fluidframework/shared-object-base';
@@ -31,8 +33,22 @@ export interface IRevertible {
31
33
  revert(): void;
32
34
  }
33
35
 
36
+ // @alpha (undocumented)
37
+ export interface ISharedMatrix<T = any> extends IEventProvider<ISharedMatrixEvents<T>>, IMatrixProducer<MatrixItem<T>>, IMatrixReader<MatrixItem<T>>, IMatrixWriter<MatrixItem<T>> {
38
+ // (undocumented)
39
+ insertCols(colStart: number, count: number): void;
40
+ // (undocumented)
41
+ insertRows(rowStart: number, count: number): void;
42
+ // (undocumented)
43
+ openUndo(consumer: IUndoConsumer): void;
44
+ // (undocumented)
45
+ removeCols(colStart: number, count: number): void;
46
+ // (undocumented)
47
+ removeRows(rowStart: number, count: number): void;
48
+ }
49
+
34
50
  // @alpha
35
- export interface ISharedMatrixEvents<T> extends ISharedObjectEvents {
51
+ export interface ISharedMatrixEvents<T> extends IEvent {
36
52
  (event: "conflict", listener: (row: number, col: number, currentValue: MatrixItem<T>, conflictingValue: MatrixItem<T>, target: IEventThisPlaceHolder) => void): void;
37
53
  }
38
54
 
@@ -46,15 +62,13 @@ export interface IUndoConsumer {
46
62
  export type MatrixItem<T> = Serializable<Exclude<T, null>> | undefined;
47
63
 
48
64
  // @alpha
49
- export class SharedMatrix<T = any> extends SharedObject<ISharedMatrixEvents<T>> implements IMatrixProducer<MatrixItem<T>>, IMatrixReader<MatrixItem<T>>, IMatrixWriter<MatrixItem<T>> {
65
+ export class SharedMatrix<T = any> extends SharedObject<ISharedMatrixEvents<T> & ISharedObjectEvents> implements ISharedMatrix<T> {
50
66
  constructor(runtime: IFluidDataStoreRuntime, id: string, attributes: IChannelAttributes, _isSetCellConflictResolutionPolicyFWW?: boolean);
51
- // (undocumented)
52
- protected applyStashedOp(content: any): unknown;
67
+ protected applyStashedOp(_content: unknown): void;
53
68
  // (undocumented)
54
69
  closeMatrix(consumer: IMatrixConsumer<MatrixItem<T>>): void;
55
70
  // (undocumented)
56
71
  get colCount(): number;
57
- // (undocumented)
58
72
  static create<T>(runtime: IFluidDataStoreRuntime, id?: string): SharedMatrix<T>;
59
73
  // (undocumented)
60
74
  protected didAttach(): void;
@@ -70,7 +84,6 @@ export class SharedMatrix<T = any> extends SharedObject<ISharedMatrixEvents<T>>
70
84
  insertRows(rowStart: number, count: number): void;
71
85
  // (undocumented)
72
86
  isSetCellConflictResolutionPolicyFWW(): boolean;
73
- // (undocumented)
74
87
  protected loadCore(storage: IChannelStorageService): Promise<void>;
75
88
  // (undocumented)
76
89
  get matrixProducer(): IMatrixProducer<MatrixItem<T>>;
@@ -82,14 +95,14 @@ export class SharedMatrix<T = any> extends SharedObject<ISharedMatrixEvents<T>>
82
95
  openMatrix(consumer: IMatrixConsumer<MatrixItem<T>>): IMatrixReader<MatrixItem<T>>;
83
96
  openUndo(consumer: IUndoConsumer): void;
84
97
  // (undocumented)
85
- protected processCore(rawMessage: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
98
+ protected processCore(msg: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
86
99
  protected processGCDataCore(serializer: IFluidSerializer): void;
87
100
  // (undocumented)
88
101
  removeCols(colStart: number, count: number): void;
89
102
  // (undocumented)
90
103
  removeRows(rowStart: number, count: number): void;
91
104
  // (undocumented)
92
- protected reSubmitCore(content: any, localOpMetadata: unknown): void;
105
+ protected reSubmitCore(incoming: unknown, localOpMetadata: unknown): void;
93
106
  // (undocumented)
94
107
  get rowCount(): number;
95
108
  // (undocumented)
@@ -116,8 +129,7 @@ export class SharedMatrixFactory implements IChannelFactory {
116
129
  // (undocumented)
117
130
  get attributes(): IChannelAttributes;
118
131
  // (undocumented)
119
- create(document: IFluidDataStoreRuntime, id: string): IChannel;
120
- // (undocumented)
132
+ create(document: IFluidDataStoreRuntime, id: string): SharedMatrix;
121
133
  load(runtime: IFluidDataStoreRuntime, id: string, services: IChannelServices, attributes: IChannelAttributes): Promise<IChannel>;
122
134
  // (undocumented)
123
135
  static Type: string;
@@ -3,8 +3,8 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { IVectorConsumer } from "@tiny-calc/nano";
6
- import { Handle } from "./handletable";
7
- import { PermutationVector } from "./permutationvector";
6
+ import { Handle } from "./handletable.js";
7
+ import { PermutationVector } from "./permutationvector.js";
8
8
  /**
9
9
  * Used by PermutationVector to cache position -\> handle lookups.
10
10
  *
@@ -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;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M;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"}
@@ -7,8 +7,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.HandleCache = void 0;
8
8
  /* eslint-disable no-bitwise */
9
9
  const core_utils_1 = require("@fluidframework/core-utils");
10
- const handletable_1 = require("./handletable");
11
- const range_1 = require("./range");
10
+ const handletable_js_1 = require("./handletable.js");
11
+ const range_js_1 = require("./range.js");
12
12
  /**
13
13
  * Used by PermutationVector to cache position -\> handle lookups.
14
14
  *
@@ -47,10 +47,10 @@ class HandleCache {
47
47
  }
48
48
  /** Update the cache when a handle has been allocated for a given position. */
49
49
  addHandle(position, handle) {
50
- (0, core_utils_1.assert)((0, handletable_1.isHandleValid)(handle), 0x017 /* "Trying to add invalid handle!" */);
50
+ (0, core_utils_1.assert)((0, handletable_js_1.isHandleValid)(handle), 0x017 /* "Trying to add invalid handle!" */);
51
51
  const index = this.getIndex(position);
52
52
  if (index < this.handles.length) {
53
- (0, core_utils_1.assert)(!(0, handletable_1.isHandleValid)(this.handles[index]), 0x018 /* "Trying to insert handle into position with already valid handle!" */);
53
+ (0, core_utils_1.assert)(!(0, handletable_js_1.isHandleValid)(this.handles[index]), 0x018 /* "Trying to insert handle into position with already valid handle!" */);
54
54
  this.handles[index] = handle;
55
55
  }
56
56
  }
@@ -83,7 +83,7 @@ class HandleCache {
83
83
  return this.handles[0];
84
84
  }
85
85
  else {
86
- (0, range_1.ensureRange)(_position, this.vector.getLength());
86
+ (0, range_js_1.ensureRange)(_position, this.vector.getLength());
87
87
  this.handles = this.handles.concat(this.getHandles(this.start + this.handles.length, _position + 1));
88
88
  return this.handles[this.handles.length - 1];
89
89
  }
@@ -1 +1 @@
1
- {"version":3,"file":"handlecache.js","sourceRoot":"","sources":["../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,EAAE,SAAS,GAAG,CAAC,CAAC,CAChE,CAAC;YACF,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;SAC7C;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;YAChC,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,KAAK,CAAC;SAC5B;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\";\nimport { IVectorConsumer } from \"@tiny-calc/nano\";\nimport { Handle, isHandleValid } from \"./handletable\";\nimport { PermutationVector, PermutationSegment } from \"./permutationvector\";\nimport { ensureRange } from \"./range\";\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,2DAAoD;AAEpD,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,Q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F,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;YAChC,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,KAAK,CAAC;SAC5B;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\";\nimport { IVectorConsumer } from \"@tiny-calc/nano\";\nimport { Handle, isHandleValid } from \"./handletable.js\";\nimport { PermutationVector, PermutationSegment } 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"]}
package/dist/index.d.ts CHANGED
@@ -2,7 +2,8 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- export { ISharedMatrixEvents, SharedMatrix, MatrixItem } from "./matrix";
6
- export { SharedMatrixFactory } from "./runtime";
7
- export { IUndoConsumer, IRevertible } from "./types";
5
+ export { ISharedMatrixEvents, SharedMatrix, ISharedMatrix } from "./matrix.js";
6
+ export { MatrixItem } from "./ops.js";
7
+ export { SharedMatrixFactory } from "./runtime.js";
8
+ export { IUndoConsumer, IRevertible } from "./types.js";
8
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACzE,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAIhD,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC/E,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAInD,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC"}
package/dist/index.js CHANGED
@@ -5,8 +5,8 @@
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.SharedMatrixFactory = exports.SharedMatrix = void 0;
8
- var matrix_1 = require("./matrix");
9
- Object.defineProperty(exports, "SharedMatrix", { enumerable: true, get: function () { return matrix_1.SharedMatrix; } });
10
- var runtime_1 = require("./runtime");
11
- Object.defineProperty(exports, "SharedMatrixFactory", { enumerable: true, get: function () { return runtime_1.SharedMatrixFactory; } });
8
+ var matrix_js_1 = require("./matrix.js");
9
+ Object.defineProperty(exports, "SharedMatrix", { enumerable: true, get: function () { return matrix_js_1.SharedMatrix; } });
10
+ var runtime_js_1 = require("./runtime.js");
11
+ Object.defineProperty(exports, "SharedMatrixFactory", { enumerable: true, get: function () { return runtime_js_1.SharedMatrixFactory; } });
12
12
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,mCAAyE;AAA3C,sGAAA,YAAY,OAAA;AAC1C,qCAAgD;AAAvC,8GAAA,mBAAmB,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { ISharedMatrixEvents, SharedMatrix, MatrixItem } from \"./matrix\";\nexport { SharedMatrixFactory } from \"./runtime\";\n\n// TODO: We temporarily duplicate these contracts from 'framework/undo-redo' to unblock development\n// of SharedMatrix undo while we decide on the correct layering for undo.\nexport { IUndoConsumer, IRevertible } from \"./types\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,yCAA+E;AAAjD,yGAAA,YAAY,OAAA;AAE1C,2CAAmD;AAA1C,iHAAA,mBAAmB,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { ISharedMatrixEvents, SharedMatrix, ISharedMatrix } from \"./matrix.js\";\nexport { MatrixItem } from \"./ops.js\";\nexport { SharedMatrixFactory } from \"./runtime.js\";\n\n// TODO: We temporarily duplicate these contracts from 'framework/undo-redo' to unblock development\n// of SharedMatrix undo while we decide on the correct layering for undo.\nexport { IUndoConsumer, IRevertible } from \"./types.js\";\n"]}
@@ -3,6 +3,8 @@ import { IChannelAttributes } from '@fluidframework/datastore-definitions';
3
3
  import { IChannelFactory } from '@fluidframework/datastore-definitions';
4
4
  import { IChannelServices } from '@fluidframework/datastore-definitions';
5
5
  import { IChannelStorageService } from '@fluidframework/datastore-definitions';
6
+ import { IEvent } from '@fluidframework/core-interfaces';
7
+ import { IEventProvider } from '@fluidframework/core-interfaces';
6
8
  import { IEventThisPlaceHolder } from '@fluidframework/core-interfaces';
7
9
  import { IFluidDataStoreRuntime } from '@fluidframework/datastore-definitions';
8
10
  import { IFluidSerializer } from '@fluidframework/shared-object-base';
@@ -25,11 +27,20 @@ export declare interface IRevertible {
25
27
  discard(): void;
26
28
  }
27
29
 
30
+ /** @alpha */
31
+ export declare interface ISharedMatrix<T = any> extends IEventProvider<ISharedMatrixEvents<T>>, IMatrixProducer<MatrixItem<T>>, IMatrixReader<MatrixItem<T>>, IMatrixWriter<MatrixItem<T>> {
32
+ insertCols(colStart: number, count: number): void;
33
+ removeCols(colStart: number, count: number): void;
34
+ insertRows(rowStart: number, count: number): void;
35
+ removeRows(rowStart: number, count: number): void;
36
+ openUndo(consumer: IUndoConsumer): void;
37
+ }
38
+
28
39
  /**
29
40
  * Events emitted by Shared Matrix.
30
41
  * @alpha
31
42
  */
32
- export declare interface ISharedMatrixEvents<T> extends ISharedObjectEvents {
43
+ export declare interface ISharedMatrixEvents<T> extends IEvent {
33
44
  /**
34
45
  * This event is only emitted when the SetCell Resolution Policy is First Write Win(FWW).
35
46
  * This is emitted when two clients race and send changes without observing each other changes,
@@ -79,10 +90,20 @@ export declare type MatrixItem<T> = Serializable<Exclude<T, null>> | undefined;
79
90
  * for more details.)
80
91
  * @alpha
81
92
  */
82
- export declare class SharedMatrix<T = any> extends SharedObject<ISharedMatrixEvents<T>> implements IMatrixProducer<MatrixItem<T>>, IMatrixReader<MatrixItem<T>>, IMatrixWriter<MatrixItem<T>> {
93
+ export declare class SharedMatrix<T = any> extends SharedObject<ISharedMatrixEvents<T> & ISharedObjectEvents> implements ISharedMatrix<T> {
83
94
  id: string;
84
95
  private readonly consumers;
85
96
  static getFactory(): SharedMatrixFactory;
97
+ /**
98
+ * Note: this field only provides a lower-bound on the reference sequence numbers for in-flight ops.
99
+ * The exact reason isn't understood, but some e2e tests suggest that the runtime may sometimes process
100
+ * incoming leave/join ops before putting an op that this DDS submits over the wire.
101
+ *
102
+ * E.g. SharedMatrix submits an op while deltaManager has lastSequenceNumber = 10, but before the runtime
103
+ * puts this op over the wire, it processes a client join/leave op with sequence number 11, so the referenceSequenceNumber
104
+ * on the SharedMatrix op is 11.
105
+ */
106
+ private readonly inFlightRefSeqs;
86
107
  private readonly rows;
87
108
  private readonly cols;
88
109
  private cells;
@@ -121,6 +142,7 @@ export declare class SharedMatrix<T = any> extends SharedObject<ISharedMatrixEve
121
142
  setCell(row: number, col: number, value: MatrixItem<T>): void;
122
143
  setCells(rowStart: number, colStart: number, colCount: number, values: readonly MatrixItem<T>[]): void;
123
144
  private setCellCore;
145
+ private createOpMetadataLocalRef;
124
146
  private sendSetCellOp;
125
147
  /**
126
148
  * This makes sure that the code inside the callback is not reentrant. We need to do that because we raise notifications
@@ -138,7 +160,7 @@ export declare class SharedMatrix<T = any> extends SharedObject<ISharedMatrixEve
138
160
  private submitRowMessage;
139
161
  insertRows(rowStart: number, count: number): void;
140
162
  removeRows(rowStart: number, count: number): void;
141
- /***/ _undoRemoveRows(rowStart: number, spec: IJSONSegment): void;
163
+ _undoRemoveRows(rowStart: number, spec: IJSONSegment): void;
142
164
  /***/ _undoRemoveCols(colStart: number, spec: IJSONSegment): void;
143
165
  protected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats;
144
166
  /**
@@ -157,7 +179,7 @@ export declare class SharedMatrix<T = any> extends SharedObject<ISharedMatrixEve
157
179
  protected didAttach(): void;
158
180
  protected onConnect(): void;
159
181
  private rebasePosition;
160
- protected reSubmitCore(content: any, localOpMetadata: unknown): void;
182
+ protected reSubmitCore(incoming: unknown, localOpMetadata: unknown): void;
161
183
  protected onDisconnect(): void;
162
184
  /**
163
185
  * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}
@@ -168,7 +190,7 @@ export declare class SharedMatrix<T = any> extends SharedObject<ISharedMatrixEve
168
190
  * we are in FWW mode.
169
191
  */
170
192
  private shouldSetCellBasedOnFWW;
171
- protected processCore(rawMessage: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
193
+ protected processCore(msg: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
172
194
  private readonly onRowDelta;
173
195
  private readonly onColDelta;
174
196
  private readonly onRowHandlesRecycled;
@@ -191,7 +213,7 @@ export declare class SharedMatrix<T = any> extends SharedObject<ISharedMatrixEve
191
213
  /**
192
214
  * {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}
193
215
  */
194
- protected applyStashedOp(content: any): unknown;
216
+ protected applyStashedOp(_content: unknown): void;
195
217
  }
196
218
 
197
219
  /**
@@ -207,7 +229,7 @@ export declare class SharedMatrixFactory implements IChannelFactory {
207
229
  * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}
208
230
  */
209
231
  load(runtime: IFluidDataStoreRuntime, id: string, services: IChannelServices, attributes: IChannelAttributes): Promise<IChannel>;
210
- create(document: IFluidDataStoreRuntime, id: string): IChannel;
232
+ create(document: IFluidDataStoreRuntime, id: string): SharedMatrix;
211
233
  }
212
234
 
213
235
  export { }
@@ -3,6 +3,8 @@ import { IChannelAttributes } from '@fluidframework/datastore-definitions';
3
3
  import { IChannelFactory } from '@fluidframework/datastore-definitions';
4
4
  import { IChannelServices } from '@fluidframework/datastore-definitions';
5
5
  import { IChannelStorageService } from '@fluidframework/datastore-definitions';
6
+ import { IEvent } from '@fluidframework/core-interfaces';
7
+ import { IEventProvider } from '@fluidframework/core-interfaces';
6
8
  import { IEventThisPlaceHolder } from '@fluidframework/core-interfaces';
7
9
  import { IFluidDataStoreRuntime } from '@fluidframework/datastore-definitions';
8
10
  import { IFluidSerializer } from '@fluidframework/shared-object-base';
@@ -21,6 +23,8 @@ import { SharedObject } from '@fluidframework/shared-object-base';
21
23
 
22
24
  /* Excluded from this release type: IRevertible */
23
25
 
26
+ /* Excluded from this release type: ISharedMatrix */
27
+
24
28
  /* Excluded from this release type: ISharedMatrixEvents */
25
29
 
26
30
  /* Excluded from this release type: IUndoConsumer */
@@ -33,4 +37,6 @@ import { SharedObject } from '@fluidframework/shared-object-base';
33
37
 
34
38
  /* Excluded from this release type: SharedMatrixFactory */
35
39
 
40
+ /* Excluded from this release type: SharedObject */
41
+
36
42
  export { }
@@ -3,6 +3,8 @@ import { IChannelAttributes } from '@fluidframework/datastore-definitions';
3
3
  import { IChannelFactory } from '@fluidframework/datastore-definitions';
4
4
  import { IChannelServices } from '@fluidframework/datastore-definitions';
5
5
  import { IChannelStorageService } from '@fluidframework/datastore-definitions';
6
+ import { IEvent } from '@fluidframework/core-interfaces';
7
+ import { IEventProvider } from '@fluidframework/core-interfaces';
6
8
  import { IEventThisPlaceHolder } from '@fluidframework/core-interfaces';
7
9
  import { IFluidDataStoreRuntime } from '@fluidframework/datastore-definitions';
8
10
  import { IFluidSerializer } from '@fluidframework/shared-object-base';
@@ -21,6 +23,8 @@ import { SharedObject } from '@fluidframework/shared-object-base';
21
23
 
22
24
  /* Excluded from this release type: IRevertible */
23
25
 
26
+ /* Excluded from this release type: ISharedMatrix */
27
+
24
28
  /* Excluded from this release type: ISharedMatrixEvents */
25
29
 
26
30
  /* Excluded from this release type: IUndoConsumer */
@@ -33,4 +37,6 @@ import { SharedObject } from '@fluidframework/shared-object-base';
33
37
 
34
38
  /* Excluded from this release type: SharedMatrixFactory */
35
39
 
40
+ /* Excluded from this release type: SharedObject */
41
+
36
42
  export { }
@@ -3,6 +3,8 @@ import { IChannelAttributes } from '@fluidframework/datastore-definitions';
3
3
  import { IChannelFactory } from '@fluidframework/datastore-definitions';
4
4
  import { IChannelServices } from '@fluidframework/datastore-definitions';
5
5
  import { IChannelStorageService } from '@fluidframework/datastore-definitions';
6
+ import { IEvent } from '@fluidframework/core-interfaces';
7
+ import { IEventProvider } from '@fluidframework/core-interfaces';
6
8
  import { IEventThisPlaceHolder } from '@fluidframework/core-interfaces';
7
9
  import { IFluidDataStoreRuntime } from '@fluidframework/datastore-definitions';
8
10
  import { IFluidSerializer } from '@fluidframework/shared-object-base';
@@ -25,11 +27,20 @@ export declare interface IRevertible {
25
27
  discard(): void;
26
28
  }
27
29
 
30
+ /** @alpha */
31
+ export declare interface ISharedMatrix<T = any> extends IEventProvider<ISharedMatrixEvents<T>>, IMatrixProducer<MatrixItem<T>>, IMatrixReader<MatrixItem<T>>, IMatrixWriter<MatrixItem<T>> {
32
+ insertCols(colStart: number, count: number): void;
33
+ removeCols(colStart: number, count: number): void;
34
+ insertRows(rowStart: number, count: number): void;
35
+ removeRows(rowStart: number, count: number): void;
36
+ openUndo(consumer: IUndoConsumer): void;
37
+ }
38
+
28
39
  /**
29
40
  * Events emitted by Shared Matrix.
30
41
  * @alpha
31
42
  */
32
- export declare interface ISharedMatrixEvents<T> extends ISharedObjectEvents {
43
+ export declare interface ISharedMatrixEvents<T> extends IEvent {
33
44
  /**
34
45
  * This event is only emitted when the SetCell Resolution Policy is First Write Win(FWW).
35
46
  * This is emitted when two clients race and send changes without observing each other changes,
@@ -79,10 +90,20 @@ export declare type MatrixItem<T> = Serializable<Exclude<T, null>> | undefined;
79
90
  * for more details.)
80
91
  * @alpha
81
92
  */
82
- export declare class SharedMatrix<T = any> extends SharedObject<ISharedMatrixEvents<T>> implements IMatrixProducer<MatrixItem<T>>, IMatrixReader<MatrixItem<T>>, IMatrixWriter<MatrixItem<T>> {
93
+ export declare class SharedMatrix<T = any> extends SharedObject<ISharedMatrixEvents<T> & ISharedObjectEvents> implements ISharedMatrix<T> {
83
94
  id: string;
84
95
  private readonly consumers;
85
96
  static getFactory(): SharedMatrixFactory;
97
+ /**
98
+ * Note: this field only provides a lower-bound on the reference sequence numbers for in-flight ops.
99
+ * The exact reason isn't understood, but some e2e tests suggest that the runtime may sometimes process
100
+ * incoming leave/join ops before putting an op that this DDS submits over the wire.
101
+ *
102
+ * E.g. SharedMatrix submits an op while deltaManager has lastSequenceNumber = 10, but before the runtime
103
+ * puts this op over the wire, it processes a client join/leave op with sequence number 11, so the referenceSequenceNumber
104
+ * on the SharedMatrix op is 11.
105
+ */
106
+ private readonly inFlightRefSeqs;
86
107
  private readonly rows;
87
108
  private readonly cols;
88
109
  private cells;
@@ -121,6 +142,7 @@ export declare class SharedMatrix<T = any> extends SharedObject<ISharedMatrixEve
121
142
  setCell(row: number, col: number, value: MatrixItem<T>): void;
122
143
  setCells(rowStart: number, colStart: number, colCount: number, values: readonly MatrixItem<T>[]): void;
123
144
  private setCellCore;
145
+ private createOpMetadataLocalRef;
124
146
  private sendSetCellOp;
125
147
  /**
126
148
  * This makes sure that the code inside the callback is not reentrant. We need to do that because we raise notifications
@@ -138,7 +160,7 @@ export declare class SharedMatrix<T = any> extends SharedObject<ISharedMatrixEve
138
160
  private submitRowMessage;
139
161
  insertRows(rowStart: number, count: number): void;
140
162
  removeRows(rowStart: number, count: number): void;
141
- /***/ _undoRemoveRows(rowStart: number, spec: IJSONSegment): void;
163
+ _undoRemoveRows(rowStart: number, spec: IJSONSegment): void;
142
164
  /***/ _undoRemoveCols(colStart: number, spec: IJSONSegment): void;
143
165
  protected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats;
144
166
  /**
@@ -157,7 +179,7 @@ export declare class SharedMatrix<T = any> extends SharedObject<ISharedMatrixEve
157
179
  protected didAttach(): void;
158
180
  protected onConnect(): void;
159
181
  private rebasePosition;
160
- protected reSubmitCore(content: any, localOpMetadata: unknown): void;
182
+ protected reSubmitCore(incoming: unknown, localOpMetadata: unknown): void;
161
183
  protected onDisconnect(): void;
162
184
  /**
163
185
  * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}
@@ -168,7 +190,7 @@ export declare class SharedMatrix<T = any> extends SharedObject<ISharedMatrixEve
168
190
  * we are in FWW mode.
169
191
  */
170
192
  private shouldSetCellBasedOnFWW;
171
- protected processCore(rawMessage: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
193
+ protected processCore(msg: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
172
194
  private readonly onRowDelta;
173
195
  private readonly onColDelta;
174
196
  private readonly onRowHandlesRecycled;
@@ -191,7 +213,7 @@ export declare class SharedMatrix<T = any> extends SharedObject<ISharedMatrixEve
191
213
  /**
192
214
  * {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}
193
215
  */
194
- protected applyStashedOp(content: any): unknown;
216
+ protected applyStashedOp(_content: unknown): void;
195
217
  }
196
218
 
197
219
  /**
@@ -207,7 +229,7 @@ export declare class SharedMatrixFactory implements IChannelFactory {
207
229
  * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}
208
230
  */
209
231
  load(runtime: IFluidDataStoreRuntime, id: string, services: IChannelServices, attributes: IChannelAttributes): Promise<IChannel>;
210
- create(document: IFluidDataStoreRuntime, id: string): IChannel;
232
+ create(document: IFluidDataStoreRuntime, id: string): SharedMatrix;
211
233
  }
212
234
 
213
235
  export { }