@fluidframework/register-collection 2.0.0-rc.1.0.6 → 2.0.0-rc.2.0.1
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.
- package/{.eslintrc.js → .eslintrc.cjs} +4 -1
- package/{.mocharc.js → .mocharc.cjs} +1 -1
- package/CHANGELOG.md +4 -0
- package/README.md +1 -1
- package/{api-extractor-esm.json → api-extractor-cjs.json} +5 -1
- package/api-extractor-lint.json +1 -1
- package/api-extractor.json +1 -1
- package/api-report/register-collection.api.md +1 -4
- package/dist/consensusRegisterCollection.d.ts +4 -4
- package/dist/consensusRegisterCollection.d.ts.map +1 -1
- package/dist/consensusRegisterCollection.js +16 -15
- package/dist/consensusRegisterCollection.js.map +1 -1
- package/dist/consensusRegisterCollectionFactory.d.ts +1 -1
- package/dist/consensusRegisterCollectionFactory.d.ts.map +1 -1
- package/dist/consensusRegisterCollectionFactory.js +5 -5
- package/dist/consensusRegisterCollectionFactory.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/dist/package.json +3 -0
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/register-collection-alpha.d.ts +1 -1
- package/dist/register-collection-beta.d.ts +2 -0
- package/dist/register-collection-public.d.ts +2 -0
- package/dist/register-collection-untrimmed.d.ts +1 -1
- package/dist/tsdoc-metadata.json +1 -1
- package/lib/{consensusRegisterCollection.d.mts → consensusRegisterCollection.d.ts} +5 -5
- package/lib/consensusRegisterCollection.d.ts.map +1 -0
- package/lib/{consensusRegisterCollection.mjs → consensusRegisterCollection.js} +14 -13
- package/lib/consensusRegisterCollection.js.map +1 -0
- package/lib/{consensusRegisterCollectionFactory.d.mts → consensusRegisterCollectionFactory.d.ts} +2 -2
- package/lib/consensusRegisterCollectionFactory.d.ts.map +1 -0
- package/lib/{consensusRegisterCollectionFactory.mjs → consensusRegisterCollectionFactory.js} +3 -3
- package/lib/consensusRegisterCollectionFactory.js.map +1 -0
- package/lib/{index.d.mts → index.d.ts} +4 -4
- package/lib/index.d.ts.map +1 -0
- package/lib/{index.mjs → index.js} +4 -4
- package/lib/index.js.map +1 -0
- package/lib/{interfaces.d.mts → interfaces.d.ts} +1 -1
- package/lib/interfaces.d.ts.map +1 -0
- package/lib/{interfaces.mjs → interfaces.js} +1 -1
- package/lib/interfaces.js.map +1 -0
- package/lib/{packageVersion.d.mts → packageVersion.d.ts} +2 -2
- package/lib/packageVersion.d.ts.map +1 -0
- package/lib/{packageVersion.mjs → packageVersion.js} +2 -2
- package/lib/packageVersion.js.map +1 -0
- package/lib/{register-collection-alpha.d.mts → register-collection-alpha.d.ts} +1 -1
- package/lib/{register-collection-beta.d.mts → register-collection-beta.d.ts} +2 -0
- package/lib/{register-collection-public.d.mts → register-collection-public.d.ts} +2 -0
- package/lib/{register-collection-untrimmed.d.mts → register-collection-untrimmed.d.ts} +1 -1
- package/lib/test/consensusRegisterCollection.spec.js +281 -0
- package/lib/test/consensusRegisterCollection.spec.js.map +1 -0
- package/lib/test/types/validateRegisterCollectionPrevious.generated.js +14 -0
- package/lib/test/types/validateRegisterCollectionPrevious.generated.js.map +1 -0
- package/package.json +40 -47
- package/src/consensusRegisterCollection.ts +35 -23
- package/src/consensusRegisterCollectionFactory.ts +3 -3
- package/src/index.ts +3 -3
- package/src/packageVersion.ts +1 -1
- package/tsconfig.cjs.json +7 -0
- package/tsconfig.json +2 -5
- package/lib/consensusRegisterCollection.d.mts.map +0 -1
- package/lib/consensusRegisterCollection.mjs.map +0 -1
- package/lib/consensusRegisterCollectionFactory.d.mts.map +0 -1
- package/lib/consensusRegisterCollectionFactory.mjs.map +0 -1
- package/lib/index.d.mts.map +0 -1
- package/lib/index.mjs.map +0 -1
- package/lib/interfaces.d.mts.map +0 -1
- package/lib/interfaces.mjs.map +0 -1
- package/lib/packageVersion.d.mts.map +0 -1
- package/lib/packageVersion.mjs.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/register-collection",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.2.0.1",
|
|
4
4
|
"description": "Consensus Register",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -11,60 +11,50 @@
|
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"author": "Microsoft and contributors",
|
|
13
13
|
"sideEffects": false,
|
|
14
|
+
"type": "module",
|
|
14
15
|
"exports": {
|
|
15
16
|
".": {
|
|
16
17
|
"import": {
|
|
17
|
-
"types": "./lib/index.d.
|
|
18
|
-
"default": "./lib/index.
|
|
18
|
+
"types": "./lib/index.d.ts",
|
|
19
|
+
"default": "./lib/index.js"
|
|
19
20
|
},
|
|
20
21
|
"require": {
|
|
21
22
|
"types": "./dist/index.d.ts",
|
|
22
23
|
"default": "./dist/index.js"
|
|
23
24
|
}
|
|
24
25
|
},
|
|
25
|
-
"./
|
|
26
|
+
"./public": {
|
|
26
27
|
"import": {
|
|
27
|
-
"types": "./lib/register-collection-
|
|
28
|
-
"default": "./lib/index.
|
|
28
|
+
"types": "./lib/register-collection-public.d.ts",
|
|
29
|
+
"default": "./lib/index.js"
|
|
29
30
|
},
|
|
30
31
|
"require": {
|
|
31
|
-
"types": "./dist/register-collection-
|
|
32
|
+
"types": "./dist/register-collection-public.d.ts",
|
|
32
33
|
"default": "./dist/index.js"
|
|
33
34
|
}
|
|
34
35
|
},
|
|
35
|
-
"./
|
|
36
|
+
"./alpha": {
|
|
36
37
|
"import": {
|
|
37
|
-
"types": "./lib/register-collection-
|
|
38
|
-
"default": "./lib/index.
|
|
38
|
+
"types": "./lib/register-collection-alpha.d.ts",
|
|
39
|
+
"default": "./lib/index.js"
|
|
39
40
|
},
|
|
40
41
|
"require": {
|
|
41
|
-
"types": "./dist/register-collection-
|
|
42
|
+
"types": "./dist/register-collection-alpha.d.ts",
|
|
42
43
|
"default": "./dist/index.js"
|
|
43
44
|
}
|
|
44
45
|
},
|
|
45
46
|
"./internal": {
|
|
46
47
|
"import": {
|
|
47
|
-
"types": "./lib/index.d.
|
|
48
|
-
"default": "./lib/index.
|
|
48
|
+
"types": "./lib/index.d.ts",
|
|
49
|
+
"default": "./lib/index.js"
|
|
49
50
|
},
|
|
50
51
|
"require": {
|
|
51
52
|
"types": "./dist/index.d.ts",
|
|
52
53
|
"default": "./dist/index.js"
|
|
53
54
|
}
|
|
54
|
-
},
|
|
55
|
-
"./public": {
|
|
56
|
-
"import": {
|
|
57
|
-
"types": "./lib/register-collection-public.d.mts",
|
|
58
|
-
"default": "./lib/index.mjs"
|
|
59
|
-
},
|
|
60
|
-
"require": {
|
|
61
|
-
"types": "./dist/register-collection-public.d.ts",
|
|
62
|
-
"default": "./dist/index.js"
|
|
63
|
-
}
|
|
64
55
|
}
|
|
65
56
|
},
|
|
66
57
|
"main": "dist/index.js",
|
|
67
|
-
"module": "lib/index.mjs",
|
|
68
58
|
"types": "dist/index.d.ts",
|
|
69
59
|
"c8": {
|
|
70
60
|
"all": true,
|
|
@@ -87,32 +77,32 @@
|
|
|
87
77
|
"temp-directory": "nyc/.nyc_output"
|
|
88
78
|
},
|
|
89
79
|
"dependencies": {
|
|
90
|
-
"@fluid-internal/client-utils": ">=2.0.0-rc.
|
|
91
|
-
"@fluidframework/core-interfaces": ">=2.0.0-rc.
|
|
92
|
-
"@fluidframework/core-utils": ">=2.0.0-rc.
|
|
93
|
-
"@fluidframework/datastore-definitions": ">=2.0.0-rc.
|
|
94
|
-
"@fluidframework/driver-utils": ">=2.0.0-rc.
|
|
95
|
-
"@fluidframework/protocol-definitions": "^3.
|
|
96
|
-
"@fluidframework/runtime-definitions": ">=2.0.0-rc.
|
|
97
|
-
"@fluidframework/shared-object-base": ">=2.0.0-rc.
|
|
80
|
+
"@fluid-internal/client-utils": ">=2.0.0-rc.2.0.1 <2.0.0-rc.2.1.0",
|
|
81
|
+
"@fluidframework/core-interfaces": ">=2.0.0-rc.2.0.1 <2.0.0-rc.2.1.0",
|
|
82
|
+
"@fluidframework/core-utils": ">=2.0.0-rc.2.0.1 <2.0.0-rc.2.1.0",
|
|
83
|
+
"@fluidframework/datastore-definitions": ">=2.0.0-rc.2.0.1 <2.0.0-rc.2.1.0",
|
|
84
|
+
"@fluidframework/driver-utils": ">=2.0.0-rc.2.0.1 <2.0.0-rc.2.1.0",
|
|
85
|
+
"@fluidframework/protocol-definitions": "^3.2.0",
|
|
86
|
+
"@fluidframework/runtime-definitions": ">=2.0.0-rc.2.0.1 <2.0.0-rc.2.1.0",
|
|
87
|
+
"@fluidframework/shared-object-base": ">=2.0.0-rc.2.0.1 <2.0.0-rc.2.1.0"
|
|
98
88
|
},
|
|
99
89
|
"devDependencies": {
|
|
100
90
|
"@arethetypeswrong/cli": "^0.13.3",
|
|
101
|
-
"@fluid-
|
|
102
|
-
"@fluid-
|
|
91
|
+
"@fluid-internal/mocha-test-setup": ">=2.0.0-rc.2.0.1 <2.0.0-rc.2.1.0",
|
|
92
|
+
"@fluid-private/test-dds-utils": ">=2.0.0-rc.2.0.1 <2.0.0-rc.2.1.0",
|
|
93
|
+
"@fluid-tools/build-cli": "^0.34.0",
|
|
103
94
|
"@fluidframework/build-common": "^2.0.3",
|
|
104
|
-
"@fluidframework/build-tools": "^0.
|
|
105
|
-
"@fluidframework/eslint-config-fluid": "^
|
|
106
|
-
"@fluidframework/mocha-test-setup": ">=2.0.0-rc.1.0.6 <2.0.0-rc.1.1.0",
|
|
95
|
+
"@fluidframework/build-tools": "^0.34.0",
|
|
96
|
+
"@fluidframework/eslint-config-fluid": "^4.0.0",
|
|
107
97
|
"@fluidframework/register-collection-previous": "npm:@fluidframework/register-collection@2.0.0-internal.8.0.0",
|
|
108
|
-
"@fluidframework/test-runtime-utils": ">=2.0.0-rc.
|
|
109
|
-
"@microsoft/api-extractor": "^7.
|
|
98
|
+
"@fluidframework/test-runtime-utils": ">=2.0.0-rc.2.0.1 <2.0.0-rc.2.1.0",
|
|
99
|
+
"@microsoft/api-extractor": "^7.42.3",
|
|
110
100
|
"@types/mocha": "^9.1.1",
|
|
111
101
|
"@types/node": "^18.19.0",
|
|
112
102
|
"c8": "^8.0.1",
|
|
113
103
|
"copyfiles": "^2.4.1",
|
|
114
104
|
"cross-env": "^7.0.3",
|
|
115
|
-
"eslint": "~8.
|
|
105
|
+
"eslint": "~8.55.0",
|
|
116
106
|
"mocha": "^10.2.0",
|
|
117
107
|
"mocha-json-output-reporter": "^2.0.1",
|
|
118
108
|
"mocha-multi-reporters": "^1.5.1",
|
|
@@ -120,7 +110,6 @@
|
|
|
120
110
|
"prettier": "~3.0.3",
|
|
121
111
|
"replace-in-file": "^6.3.5",
|
|
122
112
|
"rimraf": "^4.4.0",
|
|
123
|
-
"tsc-multi": "^1.1.0",
|
|
124
113
|
"typescript": "~5.1.6"
|
|
125
114
|
},
|
|
126
115
|
"fluidBuild": {
|
|
@@ -140,15 +129,17 @@
|
|
|
140
129
|
},
|
|
141
130
|
"scripts": {
|
|
142
131
|
"api": "fluid-build . --task api",
|
|
143
|
-
"api-extractor:commonjs": "api-extractor run --
|
|
144
|
-
"api-extractor:esnext": "api-extractor run --
|
|
132
|
+
"api-extractor:commonjs": "api-extractor run --config ./api-extractor-cjs.json",
|
|
133
|
+
"api-extractor:esnext": "api-extractor run --local",
|
|
145
134
|
"build": "fluid-build . --task build",
|
|
146
135
|
"build:commonjs": "fluid-build . --task commonjs",
|
|
147
136
|
"build:compile": "fluid-build . --task compile",
|
|
148
137
|
"build:docs": "fluid-build . --task api",
|
|
149
|
-
"build:esnext": "tsc
|
|
138
|
+
"build:esnext": "tsc --project ./tsconfig.json",
|
|
150
139
|
"build:genver": "gen-version",
|
|
151
|
-
"build:test": "
|
|
140
|
+
"build:test": "npm run build:test:esm && npm run build:test:cjs",
|
|
141
|
+
"build:test:cjs": "fluid-tsc commonjs --project ./src/test/tsconfig.cjs.json",
|
|
142
|
+
"build:test:esm": "tsc --project ./src/test/tsconfig.json",
|
|
152
143
|
"check:are-the-types-wrong": "attw --pack . --entrypoints .",
|
|
153
144
|
"check:release-tags": "api-extractor run --local --config ./api-extractor-lint.json",
|
|
154
145
|
"ci:build:docs": "api-extractor run",
|
|
@@ -162,9 +153,11 @@
|
|
|
162
153
|
"prettier:fix": "prettier --write . --cache --ignore-path ../../../.prettierignore",
|
|
163
154
|
"test": "npm run test:mocha",
|
|
164
155
|
"test:coverage": "c8 npm test",
|
|
165
|
-
"test:mocha": "
|
|
156
|
+
"test:mocha": "npm run test:mocha:esm && echo skipping cjs to avoid overhead - npm run test:mocha:cjs",
|
|
157
|
+
"test:mocha:cjs": "mocha --recursive \"dist/test/**/*.spec.*js\" --exit",
|
|
158
|
+
"test:mocha:esm": "mocha --recursive \"lib/test/**/*.spec.*js\" --exit",
|
|
166
159
|
"test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
|
|
167
|
-
"tsc": "tsc",
|
|
160
|
+
"tsc": "fluid-tsc commonjs --project ./tsconfig.cjs.json && copyfiles -f ../../../common/build/build-common/src/cjs/package.json ./dist",
|
|
168
161
|
"typetests:gen": "fluid-type-test-generator",
|
|
169
162
|
"typetests:prepare": "flub typetests --dir . --reset --previous --normalize"
|
|
170
163
|
}
|
|
@@ -5,24 +5,24 @@
|
|
|
5
5
|
|
|
6
6
|
import { bufferToString } from "@fluid-internal/client-utils";
|
|
7
7
|
import { assert, unreachableCase } from "@fluidframework/core-utils";
|
|
8
|
-
import { ISequencedDocumentMessage, MessageType } from "@fluidframework/protocol-definitions";
|
|
9
8
|
import {
|
|
10
9
|
IChannelAttributes,
|
|
11
|
-
IFluidDataStoreRuntime,
|
|
12
10
|
IChannelStorageService,
|
|
11
|
+
IFluidDataStoreRuntime,
|
|
13
12
|
} from "@fluidframework/datastore-definitions";
|
|
13
|
+
import { ISequencedDocumentMessage, MessageType } from "@fluidframework/protocol-definitions";
|
|
14
14
|
import { ISummaryTreeWithStats } from "@fluidframework/runtime-definitions";
|
|
15
15
|
import {
|
|
16
|
-
createSingleBlobSummary,
|
|
17
16
|
IFluidSerializer,
|
|
18
17
|
SharedObject,
|
|
18
|
+
createSingleBlobSummary,
|
|
19
19
|
} from "@fluidframework/shared-object-base";
|
|
20
|
-
import { ConsensusRegisterCollectionFactory } from "./consensusRegisterCollectionFactory";
|
|
20
|
+
import { ConsensusRegisterCollectionFactory } from "./consensusRegisterCollectionFactory.js";
|
|
21
21
|
import {
|
|
22
22
|
IConsensusRegisterCollection,
|
|
23
|
-
ReadPolicy,
|
|
24
23
|
IConsensusRegisterCollectionEvents,
|
|
25
|
-
|
|
24
|
+
ReadPolicy,
|
|
25
|
+
} from "./interfaces.js";
|
|
26
26
|
|
|
27
27
|
interface ILocalData<T> {
|
|
28
28
|
// Atomic version
|
|
@@ -53,8 +53,10 @@ const newLocalRegister = <T>(sequenceNumber: number, value: T): ILocalRegister<T
|
|
|
53
53
|
|
|
54
54
|
/**
|
|
55
55
|
* An operation for consensus register collection
|
|
56
|
+
*
|
|
57
|
+
* The value stored in this op is serialized as a string and must be deserialized
|
|
56
58
|
*/
|
|
57
|
-
interface
|
|
59
|
+
interface IRegisterOperationSerialized {
|
|
58
60
|
key: string;
|
|
59
61
|
type: "write";
|
|
60
62
|
serializedValue: string;
|
|
@@ -67,23 +69,33 @@ interface IRegisterOperation {
|
|
|
67
69
|
}
|
|
68
70
|
|
|
69
71
|
/**
|
|
70
|
-
* IRegisterOperation format in versions \< 0.17
|
|
72
|
+
* IRegisterOperation format in versions \< 0.17 and \>=2.0.0-rc.2.0.0
|
|
73
|
+
*
|
|
74
|
+
* The value stored in this op is _not_ serialized and is stored literally as `T`
|
|
71
75
|
*/
|
|
72
|
-
interface
|
|
76
|
+
interface IRegisterOperationPlain<T> {
|
|
73
77
|
key: string;
|
|
74
78
|
type: "write";
|
|
79
|
+
|
|
75
80
|
value: {
|
|
76
81
|
type: "Plain";
|
|
77
82
|
value: T;
|
|
78
83
|
};
|
|
79
|
-
|
|
84
|
+
|
|
85
|
+
// back-compat: for clients prior to 2.0.0-rc.2.0.0, we must also pass in
|
|
86
|
+
// the serialized value for them to parse handles correctly. we do not have
|
|
87
|
+
// to pay the cost of deserializing this value in newer clients
|
|
88
|
+
serializedValue: string;
|
|
89
|
+
|
|
90
|
+
// back-compat: files at rest written with runtime <= 0.13 do not have refSeq
|
|
91
|
+
refSeq: number | undefined;
|
|
80
92
|
}
|
|
81
93
|
|
|
82
94
|
/** Incoming ops could match any of these types */
|
|
83
|
-
type IIncomingRegisterOperation<T> =
|
|
95
|
+
type IIncomingRegisterOperation<T> = IRegisterOperationSerialized | IRegisterOperationPlain<T>;
|
|
84
96
|
|
|
85
97
|
/** Distinguish between incoming op formats so we know which type it is */
|
|
86
|
-
const
|
|
98
|
+
const incomingOpMatchesPlainFormat = <T>(op): op is IRegisterOperationPlain<T> => "value" in op;
|
|
87
99
|
|
|
88
100
|
/** The type of the resolve function to call after the local operation is ack'd */
|
|
89
101
|
type PendingResolve = (winner: boolean) => void;
|
|
@@ -142,18 +154,19 @@ export class ConsensusRegisterCollection<T>
|
|
|
142
154
|
* @returns Promise<true> if write was non-concurrent
|
|
143
155
|
*/
|
|
144
156
|
public async write(key: string, value: T): Promise<boolean> {
|
|
145
|
-
const serializedValue = this.stringify(value, this.serializer);
|
|
146
|
-
|
|
147
157
|
if (!this.isAttached()) {
|
|
148
|
-
|
|
149
|
-
this.processInboundWrite(key, this.parse(serializedValue, this.serializer), 0, 0, true);
|
|
158
|
+
this.processInboundWrite(key, value, 0, 0, true);
|
|
150
159
|
return true;
|
|
151
160
|
}
|
|
152
161
|
|
|
153
|
-
const message:
|
|
162
|
+
const message: IRegisterOperationPlain<T> = {
|
|
154
163
|
key,
|
|
155
164
|
type: "write",
|
|
156
|
-
serializedValue,
|
|
165
|
+
serializedValue: this.stringify(value, this.serializer),
|
|
166
|
+
value: {
|
|
167
|
+
type: "Plain",
|
|
168
|
+
value,
|
|
169
|
+
},
|
|
157
170
|
refSeq: this.runtime.deltaManager.lastSequenceNumber,
|
|
158
171
|
};
|
|
159
172
|
|
|
@@ -245,9 +258,9 @@ export class ConsensusRegisterCollection<T>
|
|
|
245
258
|
0x06e /* "Message's reference sequence number < op's reference sequence number!" */,
|
|
246
259
|
);
|
|
247
260
|
|
|
248
|
-
const value =
|
|
249
|
-
?
|
|
250
|
-
: op.
|
|
261
|
+
const value = incomingOpMatchesPlainFormat<T>(op)
|
|
262
|
+
? op.value.value
|
|
263
|
+
: (this.parse(op.serializedValue, this.serializer) as T);
|
|
251
264
|
const winner = this.processInboundWrite(
|
|
252
265
|
op.key,
|
|
253
266
|
value,
|
|
@@ -348,8 +361,7 @@ export class ConsensusRegisterCollection<T>
|
|
|
348
361
|
return serializer.parse(content);
|
|
349
362
|
}
|
|
350
363
|
|
|
351
|
-
protected applyStashedOp() {
|
|
364
|
+
protected applyStashedOp(): void {
|
|
352
365
|
// empty implementation
|
|
353
|
-
return () => {};
|
|
354
366
|
}
|
|
355
367
|
}
|
|
@@ -8,9 +8,9 @@ import {
|
|
|
8
8
|
IFluidDataStoreRuntime,
|
|
9
9
|
IChannelServices,
|
|
10
10
|
} from "@fluidframework/datastore-definitions";
|
|
11
|
-
import { ConsensusRegisterCollection } from "./consensusRegisterCollection";
|
|
12
|
-
import { IConsensusRegisterCollection, IConsensusRegisterCollectionFactory } from "./interfaces";
|
|
13
|
-
import { pkgVersion } from "./packageVersion";
|
|
11
|
+
import { ConsensusRegisterCollection } from "./consensusRegisterCollection.js";
|
|
12
|
+
import { IConsensusRegisterCollection, IConsensusRegisterCollectionFactory } from "./interfaces.js";
|
|
13
|
+
import { pkgVersion } from "./packageVersion.js";
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* The factory that defines the consensus queue.
|
package/src/index.ts
CHANGED
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
export { ConsensusRegisterCollection } from "./consensusRegisterCollection";
|
|
7
|
-
export { ConsensusRegisterCollectionFactory } from "./consensusRegisterCollectionFactory";
|
|
6
|
+
export { ConsensusRegisterCollection } from "./consensusRegisterCollection.js";
|
|
7
|
+
export { ConsensusRegisterCollectionFactory } from "./consensusRegisterCollectionFactory.js";
|
|
8
8
|
export {
|
|
9
9
|
IConsensusRegisterCollection,
|
|
10
10
|
IConsensusRegisterCollectionEvents,
|
|
11
11
|
IConsensusRegisterCollectionFactory,
|
|
12
12
|
ReadPolicy,
|
|
13
|
-
} from "./interfaces";
|
|
13
|
+
} from "./interfaces.js";
|
package/src/packageVersion.ts
CHANGED
package/tsconfig.json
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
{
|
|
2
|
-
"extends":
|
|
3
|
-
"../../../common/build/build-common/tsconfig.base.json",
|
|
4
|
-
"../../../common/build/build-common/tsconfig.cjs.json",
|
|
5
|
-
],
|
|
2
|
+
"extends": "../../../common/build/build-common/tsconfig.node16.json",
|
|
6
3
|
"include": ["src/**/*"],
|
|
7
4
|
"exclude": ["src/test/**/*"],
|
|
8
5
|
"compilerOptions": {
|
|
9
6
|
"rootDir": "./src",
|
|
10
|
-
"outDir": "./
|
|
7
|
+
"outDir": "./lib",
|
|
11
8
|
},
|
|
12
9
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"consensusRegisterCollection.d.mts","sourceRoot":"","sources":["../src/consensusRegisterCollection.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAII,EAAE,yBAAyB,EAAe,MAAM,sCAAsC;OACtF,EACN,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,MAAM,uCAAuC;OACvC,EAAE,qBAAqB,EAAE,MAAM,qCAAqC;OACpE,EAEN,gBAAgB,EAChB,YAAY,EACZ,MAAM,oCAAoC;OACpC,EAAE,kCAAkC,EAAE;OACtC,EACN,4BAA4B,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AC,EAAE;YACpC,MAAM;YACL,uGAAuG;YACvG,cAAc,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,cAAc,EACxE,KAAK,CAAC,8DAA8D,CACpE,CAAC;SACF;QAED,wBAAwB;QACxB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAElC,sDAAsD;QACtD,IAAI,MAAM,EAAE;YACX,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;SAC9C;QACD,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;QAE/C,OAAO,MAAM,CAAC;IACf,CAAC;IAEO,SAAS,CAAC,KAAU,EAAE,UAA4B;QACzD,OAAO,UAAU,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACjD,CAAC;IAEO,KAAK,CAAC,OAAe,EAAE,UAA4B;QAC1D,OAAO,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAClC,CAAC;IAES,cAAc;QACvB,uBAAuB;QACvB,OAAO,GAAG,EAAE,GAAE,CAAC,CAAC;IACjB,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { bufferToString } from \"@fluid-internal/client-utils\";\nimport { assert, unreachableCase } from \"@fluidframework/core-utils\";\nimport { ISequencedDocumentMessage, MessageType } from \"@fluidframework/protocol-definitions\";\nimport {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n} from \"@fluidframework/datastore-definitions\";\nimport { ISummaryTreeWithStats } from \"@fluidframework/runtime-definitions\";\nimport {\n\tcreateSingleBlobSummary,\n\tIFluidSerializer,\n\tSharedObject,\n} from \"@fluidframework/shared-object-base\";\nimport { ConsensusRegisterCollectionFactory } from \"./consensusRegisterCollectionFactory\";\nimport {\n\tIConsensusRegisterCollection,\n\tReadPolicy,\n\tIConsensusRegisterCollectionEvents,\n} from \"./interfaces\";\n\ninterface ILocalData<T> {\n\t// Atomic version\n\tatomic: ILocalRegister<T>;\n\n\t// All concurrent versions awaiting consensus\n\tversions: ILocalRegister<T>[];\n}\n\ninterface ILocalRegister<T> {\n\t// Register value, wrapped for backwards compatibility with < 0.17\n\tvalue: {\n\t\ttype: \"Plain\";\n\t\tvalue: T;\n\t};\n\n\t// The sequence number when last consensus was reached\n\tsequenceNumber: number;\n}\n\nconst newLocalRegister = <T>(sequenceNumber: number, value: T): ILocalRegister<T> => ({\n\tsequenceNumber,\n\tvalue: {\n\t\ttype: \"Plain\",\n\t\tvalue,\n\t},\n});\n\n/**\n * An operation for consensus register collection\n */\ninterface IRegisterOperation {\n\tkey: string;\n\ttype: \"write\";\n\tserializedValue: string;\n\n\t// Message can be delivered with delay - resubmitted on reconnect.\n\t// As such, refSeq needs to reference seq # at the time op was created,\n\t// not when op was actually sent over wire (ISequencedDocumentMessage.referenceSequenceNumber),\n\t// as client can ingest ops in between.\n\trefSeq: number | undefined;\n}\n\n/**\n * IRegisterOperation format in versions \\< 0.17\n */\ninterface IRegisterOperationOld<T> {\n\tkey: string;\n\ttype: \"write\";\n\tvalue: {\n\t\ttype: \"Plain\";\n\t\tvalue: T;\n\t};\n\trefSeq: number;\n}\n\n/** Incoming ops could match any of these types */\ntype IIncomingRegisterOperation<T> = IRegisterOperation | IRegisterOperationOld<T>;\n\n/** Distinguish between incoming op formats so we know which type it is */\nconst incomingOpMatchesCurrentFormat = (op): op is IRegisterOperation => \"serializedValue\" in op;\n\n/** The type of the resolve function to call after the local operation is ack'd */\ntype PendingResolve = (winner: boolean) => void;\n\nconst snapshotFileName = \"header\";\n\n/**\n * {@inheritDoc IConsensusRegisterCollection}\n * @alpha\n */\nexport class ConsensusRegisterCollection<T>\n\textends SharedObject<IConsensusRegisterCollectionEvents>\n\timplements IConsensusRegisterCollection<T>\n{\n\t/**\n\t * Create a new consensus register collection\n\t *\n\t * @param runtime - data store runtime the new consensus register collection belongs to\n\t * @param id - optional name of the consensus register collection\n\t * @returns newly create consensus register collection (but not attached yet)\n\t */\n\tpublic static create<T>(runtime: IFluidDataStoreRuntime, id?: string) {\n\t\treturn runtime.createChannel(\n\t\t\tid,\n\t\t\tConsensusRegisterCollectionFactory.Type,\n\t\t) as ConsensusRegisterCollection<T>;\n\t}\n\n\t/**\n\t * Get a factory for ConsensusRegisterCollection to register with the data store.\n\t *\n\t * @returns a factory that creates and load ConsensusRegisterCollection\n\t */\n\tpublic static getFactory() {\n\t\treturn new ConsensusRegisterCollectionFactory();\n\t}\n\n\tprivate readonly data = new Map<string, ILocalData<T>>();\n\n\t/**\n\t * Constructs a new consensus register collection. If the object is non-local an id and service interfaces will\n\t * be provided\n\t */\n\tpublic constructor(\n\t\tid: string,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tattributes: IChannelAttributes,\n\t) {\n\t\tsuper(id, runtime, attributes, \"fluid_consensusRegisterCollection_\");\n\t}\n\n\t/**\n\t * Creates a new register or writes a new value.\n\t * Returns a promise that will resolve when the write is acked.\n\t *\n\t * @returns Promise<true> if write was non-concurrent\n\t */\n\tpublic async write(key: string, value: T): Promise<boolean> {\n\t\tconst serializedValue = this.stringify(value, this.serializer);\n\n\t\tif (!this.isAttached()) {\n\t\t\t// JSON-roundtrip value for local writes to match the behavior of going through the wire\n\t\t\tthis.processInboundWrite(key, this.parse(serializedValue, this.serializer), 0, 0, true);\n\t\t\treturn true;\n\t\t}\n\n\t\tconst message: IRegisterOperation = {\n\t\t\tkey,\n\t\t\ttype: \"write\",\n\t\t\tserializedValue,\n\t\t\trefSeq: this.runtime.deltaManager.lastSequenceNumber,\n\t\t};\n\n\t\treturn this.newAckBasedPromise<boolean>((resolve) => {\n\t\t\t// Send the resolve function as the localOpMetadata. This will be provided back to us when the\n\t\t\t// op is ack'd.\n\t\t\tthis.submitLocalMessage(message, resolve);\n\t\t\t// If we fail due to runtime being disposed, it's better to return false then unhandled exception.\n\t\t}).catch((error) => false);\n\t}\n\n\t/**\n\t * Returns the most recent local value of a register.\n\t * @param key - The key to read\n\t * @param readPolicy - The ReadPolicy to apply. Defaults to Atomic.\n\t */\n\tpublic read(key: string, readPolicy: ReadPolicy = ReadPolicy.Atomic): T | undefined {\n\t\tif (readPolicy === ReadPolicy.Atomic) {\n\t\t\treturn this.readAtomic(key);\n\t\t}\n\n\t\tconst versions = this.readVersions(key);\n\n\t\tif (versions !== undefined) {\n\t\t\t// We don't support deletion. So there should be at least one value.\n\t\t\tassert(versions.length > 0, 0x06c /* \"Value should be undefined or non-empty\" */);\n\n\t\t\treturn versions[versions.length - 1];\n\t\t}\n\t}\n\n\tpublic readVersions(key: string): T[] | undefined {\n\t\tconst data = this.data.get(key);\n\t\treturn data?.versions.map((element: ILocalRegister<T>) => element.value.value);\n\t}\n\n\tpublic keys(): string[] {\n\t\treturn [...this.data.keys()];\n\t}\n\n\tprotected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats {\n\t\tconst dataObj: { [key: string]: ILocalData<T> } = {};\n\t\tthis.data.forEach((v, k) => {\n\t\t\tdataObj[k] = v;\n\t\t});\n\n\t\treturn createSingleBlobSummary(snapshotFileName, this.stringify(dataObj, serializer));\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}\n\t */\n\tprotected async loadCore(storage: IChannelStorageService): Promise<void> {\n\t\tconst blob = await storage.readBlob(snapshotFileName);\n\t\tconst header = bufferToString(blob, \"utf8\");\n\t\tconst dataObj = this.parse(header, this.serializer);\n\n\t\tfor (const key of Object.keys(dataObj)) {\n\t\t\tassert(\n\t\t\t\tdataObj[key].atomic?.value.type !== \"Shared\",\n\t\t\t\t0x06d /* \"SharedObjects contained in ConsensusRegisterCollection can no longer be deserialized as of 0.17\" */,\n\t\t\t);\n\n\t\t\tthis.data.set(key, dataObj[key]);\n\t\t}\n\t}\n\n\tprotected onDisconnect() {}\n\n\tprotected processCore(\n\t\tmessage: ISequencedDocumentMessage,\n\t\tlocal: boolean,\n\t\tlocalOpMetadata: unknown,\n\t) {\n\t\tif (message.type === MessageType.Operation) {\n\t\t\tconst op = message.contents as IIncomingRegisterOperation<T>;\n\t\t\tswitch (op.type) {\n\t\t\t\tcase \"write\": {\n\t\t\t\t\t// backward compatibility: File at rest written with runtime <= 0.13 do not have refSeq\n\t\t\t\t\t// when the refSeq property didn't exist\n\t\t\t\t\tif (op.refSeq === undefined) {\n\t\t\t\t\t\top.refSeq = message.referenceSequenceNumber;\n\t\t\t\t\t}\n\t\t\t\t\t// Message can be delivered with delay - e.g. resubmitted on reconnect.\n\t\t\t\t\t// Use the refSeq from when the op was created, not when it was transmitted\n\t\t\t\t\tconst refSeqWhenCreated = op.refSeq;\n\t\t\t\t\tassert(\n\t\t\t\t\t\trefSeqWhenCreated <= message.referenceSequenceNumber,\n\t\t\t\t\t\t0x06e /* \"Message's reference sequence number < op's reference sequence number!\" */,\n\t\t\t\t\t);\n\n\t\t\t\t\tconst value = incomingOpMatchesCurrentFormat(op)\n\t\t\t\t\t\t? (this.parse(op.serializedValue, this.serializer) as T)\n\t\t\t\t\t\t: op.value.value;\n\t\t\t\t\tconst winner = this.processInboundWrite(\n\t\t\t\t\t\top.key,\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\trefSeqWhenCreated,\n\t\t\t\t\t\tmessage.sequenceNumber,\n\t\t\t\t\t\tlocal,\n\t\t\t\t\t);\n\t\t\t\t\tif (local) {\n\t\t\t\t\t\t// Resolve the pending promise for this operation now that we have received an ack for it.\n\t\t\t\t\t\tconst resolve = localOpMetadata as PendingResolve;\n\t\t\t\t\t\tresolve(winner);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\tunreachableCase(op.type);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate readAtomic(key: string): T | undefined {\n\t\tconst data = this.data.get(key);\n\t\treturn data?.atomic.value.value;\n\t}\n\n\t/**\n\t * Process an inbound write op\n\t * @param key - Key that was written to\n\t * @param value - Incoming value\n\t * @param refSeq - RefSeq at the time of write on the remote client\n\t * @param sequenceNumber - Sequence Number of this write op\n\t * @param local - Did this write originate on this client\n\t */\n\tprivate processInboundWrite(\n\t\tkey: string,\n\t\tvalue: T,\n\t\trefSeq: number,\n\t\tsequenceNumber: number,\n\t\tlocal: boolean,\n\t): boolean {\n\t\tlet data = this.data.get(key);\n\t\t// Atomic update if it's a new register or the write was not concurrent,\n\t\t// meaning our state was known to the remote client at the time of write\n\t\tconst winner = data === undefined || refSeq >= data.atomic.sequenceNumber;\n\t\tif (winner) {\n\t\t\tconst atomicUpdate = newLocalRegister<T>(sequenceNumber, value);\n\t\t\tif (data === undefined) {\n\t\t\t\tdata = {\n\t\t\t\t\tatomic: atomicUpdate,\n\t\t\t\t\tversions: [], // we'll update versions next, leave it empty for now\n\t\t\t\t};\n\t\t\t\tthis.data.set(key, data);\n\t\t\t} else {\n\t\t\t\tdata.atomic = atomicUpdate;\n\t\t\t}\n\t\t} else {\n\t\t\tassert(!!data, 0x06f /* \"data missing for non-atomic inbound update!\" */);\n\t\t}\n\n\t\t// Remove versions that were known to the remote client at the time of write\n\t\twhile (data.versions.length > 0 && refSeq >= data.versions[0].sequenceNumber) {\n\t\t\tdata.versions.shift();\n\t\t}\n\n\t\tconst versionUpdate = newLocalRegister<T>(sequenceNumber, value);\n\n\t\t// Asserts for data integrity\n\t\tif (!this.isAttached()) {\n\t\t\tassert(\n\t\t\t\trefSeq === 0 && sequenceNumber === 0,\n\t\t\t\t0x070 /* \"sequence numbers are expected to be 0 when unattached\" */,\n\t\t\t);\n\t\t} else if (data.versions.length > 0) {\n\t\t\tassert(\n\t\t\t\t// seqNum should always be increasing, except for the case of grouped batches (seqNum will be the same)\n\t\t\t\tsequenceNumber >= data.versions[data.versions.length - 1].sequenceNumber,\n\t\t\t\t0x071 /* \"Versions should naturally be ordered by sequenceNumber\" */,\n\t\t\t);\n\t\t}\n\n\t\t// Push the new element.\n\t\tdata.versions.push(versionUpdate);\n\n\t\t// Raise events at the end, to avoid reentrancy issues\n\t\tif (winner) {\n\t\t\tthis.emit(\"atomicChanged\", key, value, local);\n\t\t}\n\t\tthis.emit(\"versionChanged\", key, value, local);\n\n\t\treturn winner;\n\t}\n\n\tprivate stringify(value: any, serializer: IFluidSerializer): string {\n\t\treturn serializer.stringify(value, this.handle);\n\t}\n\n\tprivate parse(content: string, serializer: IFluidSerializer): any {\n\t\treturn serializer.parse(content);\n\t}\n\n\tprotected applyStashedOp() {\n\t\t// empty implementation\n\t\treturn () => {};\n\t}\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"consensusRegisterCollectionFactory.d.mts","sourceRoot":"","sources":["../src/consensusRegisterCollectionFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAEI,EACN,kBAAkB,EAClB,sBAAsB,EACtB,gBAAgB,EAChB,MAAM,uCAAuC;OAEvC,EAAE,4BAA4B,EAAE,mCAAmC,EAAE;AAG5E;;;GAGG;AACH,qBAAa,kCAAmC,YAAW,mCAAmC;IAC7F,OAAc,IAAI,SAAqE;IAEvF,gBAAuB,UAAU,EAAE,kBAAkB,CAInD;IAEF,IAAW,IAAI,WAEd;IAED,IAAW,UAAU,uBAEpB;IAED;;OAEG;IACU,IAAI,CAChB,OAAO,EAAE,sBAAsB,EAC/B,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,gBAAgB,EAC1B,UAAU,EAAE,kBAAkB,GAC5B,OAAO,CAAC,4BAA4B,CAAC;IAMjC,MAAM,CAAC,QAAQ,EAAE,sBAAsB,EAAE,EAAE,EAAE,MAAM,GAAG,4BAA4B;CASzF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"consensusRegisterCollectionFactory.mjs","sourceRoot":"","sources":["../src/consensusRegisterCollectionFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAOI,EAAE,2BAA2B,EAAE;OAE/B,EAAE,UAAU,EAAE;AAErB;;;GAGG;AACH,MAAM,OAAO,kCAAkC;IAS9C,IAAW,IAAI;QACd,OAAO,kCAAkC,CAAC,IAAI,CAAC;IAChD,CAAC;IAED,IAAW,UAAU;QACpB,OAAO,kCAAkC,CAAC,UAAU,CAAC;IACtD,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,IAAI,CAChB,OAA+B,EAC/B,EAAU,EACV,QAA0B,EAC1B,UAA8B;QAE9B,MAAM,UAAU,GAAG,IAAI,2BAA2B,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;QAC5E,MAAM,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAChC,OAAO,UAAU,CAAC;IACnB,CAAC;IAEM,MAAM,CAAC,QAAgC,EAAE,EAAU;QACzD,MAAM,UAAU,GAAG,IAAI,2BAA2B,CACjD,EAAE,EACF,QAAQ,EACR,kCAAkC,CAAC,UAAU,CAC7C,CAAC;QACF,UAAU,CAAC,eAAe,EAAE,CAAC;QAC7B,OAAO,UAAU,CAAC;IACnB,CAAC;;AAtCa,uCAAI,GAAG,iEAAiE,CAAC;AAEhE,6CAAU,GAAuB;IACvD,IAAI,EAAE,kCAAkC,CAAC,IAAI;IAC7C,qBAAqB,EAAE,KAAK;IAC5B,cAAc,EAAE,UAAU;CAC1B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannelServices,\n} from \"@fluidframework/datastore-definitions\";\nimport { ConsensusRegisterCollection } from \"./consensusRegisterCollection\";\nimport { IConsensusRegisterCollection, IConsensusRegisterCollectionFactory } from \"./interfaces\";\nimport { pkgVersion } from \"./packageVersion\";\n\n/**\n * The factory that defines the consensus queue.\n * @alpha\n */\nexport class ConsensusRegisterCollectionFactory implements IConsensusRegisterCollectionFactory {\n\tpublic static Type = \"https://graph.microsoft.com/types/consensus-register-collection\";\n\n\tpublic static readonly Attributes: IChannelAttributes = {\n\t\ttype: ConsensusRegisterCollectionFactory.Type,\n\t\tsnapshotFormatVersion: \"0.1\",\n\t\tpackageVersion: pkgVersion,\n\t};\n\n\tpublic get type() {\n\t\treturn ConsensusRegisterCollectionFactory.Type;\n\t}\n\n\tpublic get attributes() {\n\t\treturn ConsensusRegisterCollectionFactory.Attributes;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}\n\t */\n\tpublic async load(\n\t\truntime: IFluidDataStoreRuntime,\n\t\tid: string,\n\t\tservices: IChannelServices,\n\t\tattributes: IChannelAttributes,\n\t): Promise<IConsensusRegisterCollection> {\n\t\tconst collection = new ConsensusRegisterCollection(id, runtime, attributes);\n\t\tawait collection.load(services);\n\t\treturn collection;\n\t}\n\n\tpublic create(document: IFluidDataStoreRuntime, id: string): IConsensusRegisterCollection {\n\t\tconst collection = new ConsensusRegisterCollection(\n\t\t\tid,\n\t\t\tdocument,\n\t\t\tConsensusRegisterCollectionFactory.Attributes,\n\t\t);\n\t\tcollection.initializeLocal();\n\t\treturn collection;\n\t}\n}\n"]}
|
package/lib/index.d.mts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAEI,EAAE,2BAA2B,EAAE;OAC/B,EAAE,kCAAkC,EAAE;OACtC,EACN,4BAA4B,EAC5B,kCAAkC,EAClC,mCAAmC,EACnC,UAAU,GACV"}
|
package/lib/index.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAEI,EAAE,2BAA2B,EAAE;OAC/B,EAAE,kCAAkC,EAAE;OACtC,EAIN,UAAU,GACV","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { ConsensusRegisterCollection } from \"./consensusRegisterCollection\";\nexport { ConsensusRegisterCollectionFactory } from \"./consensusRegisterCollectionFactory\";\nexport {\n\tIConsensusRegisterCollection,\n\tIConsensusRegisterCollectionEvents,\n\tIConsensusRegisterCollectionFactory,\n\tReadPolicy,\n} from \"./interfaces\";\n"]}
|
package/lib/interfaces.d.mts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.mts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAEI,EACN,sBAAsB,EACtB,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EACf,MAAM,uCAAuC;OACvC,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,oCAAoC;AAEvF;;;;;;GAMG;AACH,MAAM,WAAW,mCAAoC,SAAQ,eAAe;IAC3E;;OAEG;IACH,IAAI,CACH,QAAQ,EAAE,sBAAsB,EAChC,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,gBAAgB,EAC1B,UAAU,EAAE,kBAAkB,GAC5B,OAAO,CAAC,4BAA4B,CAAC,CAAC;IAEzC,MAAM,CAAC,QAAQ,EAAE,sBAAsB,EAAE,EAAE,EAAE,MAAM,GAAG,4BAA4B,CAAC;CACnF;AAED;;;GAGG;AACH,MAAM,WAAW,kCAAmC,SAAQ,mBAAmB;IAC9E,CACC,KAAK,EAAE,eAAe,GAAG,gBAAgB,EACzC,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,OAC1D;CACF;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,4BAA4B,CAAC,CAAC,GAAG,GAAG,CACpD,SAAQ,aAAa,CAAC,kCAAkC,CAAC;IACzD;;;;;OAKG;IACH,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAE/C;;OAEG;IACH,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,UAAU,GAAG,CAAC,GAAG,SAAS,CAAC;IAEtD;;OAEG;IACH,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,EAAE,GAAG,SAAS,CAAC;IAE3C;;OAEG;IACH,IAAI,IAAI,MAAM,EAAE,CAAC;CACjB;AAED;;;GAGG;AACH,oBAAY,UAAU;IAErB,MAAM,IAAA;IAGN,GAAG,IAAA;CACH"}
|
package/lib/interfaces.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.mjs","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAsFH;;;GAGG;AACH,MAAM,CAAN,IAAY,UAMX;AAND,WAAY,UAAU;IACrB,mFAAmF;IACnF,+CAAM,CAAA;IAEN,2DAA2D;IAC3D,yCAAG,CAAA;AACJ,CAAC,EANW,UAAU,KAAV,UAAU,QAMrB","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tIFluidDataStoreRuntime,\n\tIChannelServices,\n\tIChannelAttributes,\n\tIChannelFactory,\n} from \"@fluidframework/datastore-definitions\";\nimport { ISharedObject, ISharedObjectEvents } from \"@fluidframework/shared-object-base\";\n\n/**\n * Consensus Register Collection channel factory interface\n *\n * Extends the base IChannelFactory to return a more definite type of IConsensusRegisterCollection\n * Use for the runtime to create and load distributed data structure by type name of each channel.\n * @alpha\n */\nexport interface IConsensusRegisterCollectionFactory extends IChannelFactory {\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}\n\t */\n\tload(\n\t\tdocument: IFluidDataStoreRuntime,\n\t\tid: string,\n\t\tservices: IChannelServices,\n\t\tattributes: IChannelAttributes,\n\t): Promise<IConsensusRegisterCollection>;\n\n\tcreate(document: IFluidDataStoreRuntime, id: string): IConsensusRegisterCollection;\n}\n\n/**\n * Events emitted by {@link IConsensusRegisterCollection}.\n * @alpha\n */\nexport interface IConsensusRegisterCollectionEvents extends ISharedObjectEvents {\n\t(\n\t\tevent: \"atomicChanged\" | \"versionChanged\",\n\t\tlistener: (key: string, value: any, local: boolean) => void,\n\t);\n}\n\n/**\n * A distributed data structure that holds a set of registers with update\n * versions. On concurrent updates, a register internally stores all possible versions of a value by using reference\n * sequence number of the incoming update.\n *\n * Using all the stored versions, we can then distinguish amongst different read policies. Below are the policies\n * we support:\n *\n * Atomic: Atomicity requires a linearizable register. A linearizable register behaves as if there is only a single\n * copy of the data, and that every operation appears to take effect atomically at one point in time. This definition\n * implies that operations are executed in an well-defined order. On a concurrent update, we perform a compare-and-set\n * operation, where we compare a register sequence number with the incoming reference sequence number.\n * The earliest operation overwriting prior sequence numbers wins since every client reaches to an agreement on\n * the value. So we can safely return the first value.\n *\n * LWW: The last write to a key always wins.\n * @alpha\n */\nexport interface IConsensusRegisterCollection<T = any>\n\textends ISharedObject<IConsensusRegisterCollectionEvents> {\n\t/**\n\t * Attempts to write a register with a value. Returns a promise to indicate the roundtrip completion.\n\t * For a non existent register, it will attempt to create a new register with the specified value.\n\t *\n\t * @returns Promise<true> if write was non-concurrent\n\t */\n\twrite(key: string, value: T): Promise<boolean>;\n\n\t/**\n\t * Retrieves the agreed upon value for the register based on policy. Returns undefined if not present.\n\t */\n\tread(key: string, policy?: ReadPolicy): T | undefined;\n\n\t/**\n\t * Retrives all concurrent versions. Undefined if not present.\n\t */\n\treadVersions(key: string): T[] | undefined;\n\n\t/**\n\t * Returns the keys.\n\t */\n\tkeys(): string[];\n}\n\n/**\n * Read policies used when reading the map value.\n * @alpha\n */\nexport enum ReadPolicy {\n\t// On a concurrent update, returns the first agreed upon value amongst all clients.\n\tAtomic,\n\n\t// Last writer wins. Simply returns the last written value.\n\tLWW,\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.d.mts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,wCAAwC,CAAC;AAC7D,eAAO,MAAM,UAAU,mBAAmB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.mjs","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,qCAAqC,CAAC;AAC7D,MAAM,CAAC,MAAM,UAAU,GAAG,gBAAgB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/register-collection\";\nexport const pkgVersion = \"2.0.0-rc.1.0.6\";\n"]}
|