@fluidframework/replay-driver 2.3.0-288113 → 2.4.0-294316
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/CHANGELOG.md +4 -0
- package/dist/replayDocumentDeltaConnection.d.ts.map +1 -1
- package/dist/replayDocumentDeltaConnection.js +0 -8
- package/dist/replayDocumentDeltaConnection.js.map +1 -1
- package/lib/replayDocumentDeltaConnection.d.ts.map +1 -1
- package/lib/replayDocumentDeltaConnection.js +0 -8
- package/lib/replayDocumentDeltaConnection.js.map +1 -1
- package/lib/tsdoc-metadata.json +1 -1
- package/package.json +19 -13
- package/src/replayDocumentDeltaConnection.ts +4 -12
- package/tsconfig.json +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"replayDocumentDeltaConnection.d.ts","sourceRoot":"","sources":["../src/replayDocumentDeltaConnection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAE9D,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EACN,wBAAwB,EACxB,8BAA8B,EAC9B,4BAA4B,EAC5B,gBAAgB,EAChB,oBAAoB,EACpB,UAAU,EACV,gBAAgB,EAChB,aAAa,EACb,YAAY,EACZ,QAAQ,EAER,yBAAyB,EACzB,cAAc,EACd,MAAM,6CAA6C,CAAC;AAErD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAIzD,qBAAa,sBAAuB,SAAQ,gBAAgB;aAgB1C,UAAU,EAAE,MAAM;aAClB,QAAQ,EAAE,MAAM;aAChB,UAAU,CAAC;IAjB5B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAM;IAC3C,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,C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D,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAU5B;IAEF,IAAW,QAAQ,IAAI,MAAM,CAE5B;IAED,IAAW,IAAI,IAAI,cAAc,CAEhC;IAED,IAAW,MAAM,IAAI,YAAY,CAEhC;IAED,IAAW,QAAQ,IAAI,OAAO,CAE7B;IAED,IAAW,OAAO,IAAI,MAAM,CAE3B;IAED,IAAW,eAAe,IAAI,yBAAyB,EAAE,CAExD;IAED,IAAW,cAAc,IAAI,cAAc,EAAE,CAE5C;IAED,IAAW,cAAc,IAAI,aAAa,EAAE,CAE3C;IAED,IAAW,oBAAoB,IAAI,oBAAoB,CAEtD;IAED,SAAgB,cAAc,SAAsD;gBAEjE,OAAO,EAAE,UAAU;IAI/B,MAAM,CAAC,eAAe,EAAE,gBAAgB,EAAE,GAAG,IAAI;IAM3C,YAAY,CAAC,OAAO,EAAE,GAAG;IAEtC,OAAO,CAAC,SAAS,CAAS;IAC1B,IAAW,QAAQ,YAElB;IACM,OAAO;IAId;;OAEG;YACW,eAAe;CA2C7B"}
|
|
@@ -68,8 +68,6 @@ class ReplayControllerStatic extends replayController_js_1.ReplayController {
|
|
|
68
68
|
}
|
|
69
69
|
if (this.unitIsTime === true) {
|
|
70
70
|
for (let i = 0; i < fetchedOps.length; i += 1) {
|
|
71
|
-
// Non null asserting here because we are iterating over fetchedOps
|
|
72
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
73
71
|
const timeStamp = fetchedOps[i].timestamp;
|
|
74
72
|
if (timeStamp !== undefined) {
|
|
75
73
|
if (this.firstTimeStamp === undefined) {
|
|
@@ -92,8 +90,6 @@ class ReplayControllerStatic extends replayController_js_1.ReplayController {
|
|
|
92
90
|
const replayNextOps = () => {
|
|
93
91
|
// Emit the ops from replay to the end every "deltainterval" milliseconds
|
|
94
92
|
// to simulate the socket stream
|
|
95
|
-
// TODO Why are we non null asserting here
|
|
96
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
97
93
|
const currentOp = fetchedOps[current];
|
|
98
94
|
const playbackOps = [currentOp];
|
|
99
95
|
let nextInterval = ReplayControllerStatic.DelayInterval;
|
|
@@ -103,8 +99,6 @@ class ReplayControllerStatic extends replayController_js_1.ReplayController {
|
|
|
103
99
|
if (currentTimeStamp !== undefined) {
|
|
104
100
|
// Emit more ops that is in the ReplayResolution window
|
|
105
101
|
while (current < fetchedOps.length) {
|
|
106
|
-
// TODO Why are we non null asserting here
|
|
107
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
108
102
|
const op = fetchedOps[current];
|
|
109
103
|
if (op.timestamp === undefined) {
|
|
110
104
|
// Missing timestamp, just delay the standard amount of time
|
|
@@ -248,8 +242,6 @@ class ReplayDocumentDeltaConnection extends client_utils_1.TypedEventEmitter {
|
|
|
248
242
|
replayPromiseChain = replayPromiseChain.then(async () => controller.replay((ops) => this.emit("op", ReplayDocumentId, ops), messages));
|
|
249
243
|
const messages = result.value;
|
|
250
244
|
currentOp += messages.length;
|
|
251
|
-
// TODO Why are we non null asserting here
|
|
252
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
253
245
|
done = controller.isDoneFetch(currentOp, messages[messages.length - 1].timestamp);
|
|
254
246
|
} while (!done);
|
|
255
247
|
abortController.abort();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"replayDocumentDeltaConnection.js","sourceRoot":"","sources":["../src/replayDocumentDeltaConnection.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAiE;AAEjE,kEAA4D;AAE5D,0EAcqD;AAErD,+DAAyD;AAEzD,MAAM,gBAAgB,GAAG,YAAY,CAAC;AAEtC,MAAa,sBAAuB,SAAQ,sCAAgB;IAM3D,gDAAgD;IAEhD;;;;;;OAMG;IACH,YACiB,UAAkB,EAClB,QAAgB,EAChB,UAAoB;QAEpC,KAAK,EAAE,CAAC;QAJQ,eAAU,GAAV,UAAU,CAAQ;QAClB,aAAQ,GAAR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AAI,GAAG,UAAU,CAAC,WAAW,CAAC,SAAS,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAE,CAAC,SAAS,CAAC,CAAC;YACpF,CAAC,QAAQ,CAAC,IAAI,EAAE;YAEhB,eAAe,CAAC,KAAK,EAAE,CAAC;QACzB,CAAC,QAAQ,CAAC,IAAI,EAAE;QAChB,OAAO,kBAAkB,CAAC;IAC3B,CAAC;;AA5JF,sEA6JC;AA1HwB,mDAAqB,GAAG,QAAQ,AAAX,CAAY;AACzD,qFAAqF;AAC7D,kDAAoB,GAAG,EAAE,GAAG,IAAI,AAAZ,CAAa;AAEjC,oCAAM,GAAiB;IAC9C,UAAU,EAAE,gBAAgB;IAC5B,MAAM,EAAE,CAAC,oBAAS,CAAC,OAAO,CAAC;IAC3B,QAAQ,EAAE,EAAE;IACZ,IAAI,EAAE;QACL,EAAE,EAAE,EAAE;KACN;IACD,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC;IAC5C,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,oBAAoB;IAC5E,GAAG,EAAE,KAAK;CACV,AAV6B,CAU5B","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport { IDisposable } from \"@fluidframework/core-interfaces\";\nimport { delay } from \"@fluidframework/core-utils/internal\";\nimport { ConnectionMode } from \"@fluidframework/driver-definitions\";\nimport {\n\tIDocumentDeltaConnection,\n\tIDocumentDeltaConnectionEvents,\n\tIDocumentDeltaStorageService,\n\tIDocumentService,\n\tIClientConfiguration,\n\tIConnected,\n\tIDocumentMessage,\n\tISignalClient,\n\tITokenClaims,\n\tIVersion,\n\tScopeType,\n\tISequencedDocumentMessage,\n\tISignalMessage,\n} from \"@fluidframework/driver-definitions/internal\";\n\nimport { ReplayController } from \"./replayController.js\";\n\nconst ReplayDocumentId = \"documentId\";\n\nexport class ReplayControllerStatic extends ReplayController {\n\tprivate static readonly DelayInterval = 50;\n\tprivate static readonly ReplayResolution = 15;\n\n\tprivate firstTimeStamp: number | undefined;\n\tprivate replayCurrent = 0;\n\t// Simulated delay interval for emitting the ops\n\n\t/**\n\t * Helper class\n\t *\n\t * @param replayFrom - First op to be played on socket.\n\t * @param replayTo - Last op number to be played on socket.\n\t * @param unitIsTime - True is user want to play ops that are within a replay resolution window.\n\t */\n\tpublic constructor(\n\t\tpublic readonly replayFrom: number,\n\t\tpublic readonly replayTo: number,\n\t\tpublic readonly unitIsTime?: boolean,\n\t) {\n\t\tsuper();\n\t\tif (unitIsTime !== true) {\n\t\t\t// There is no code in here to start with snapshot, thus we have to start with op #0.\n\t\t\tthis.replayTo = 0;\n\t\t}\n\t}\n\n\tpublic async initStorage(documentService: IDocumentService) {\n\t\treturn true;\n\t}\n\n\tpublic async getVersions(versionId: string | null, count: number): Promise<IVersion[]> {\n\t\treturn [];\n\t}\n\n\tpublic async getSnapshotTree(version?: IVersion) {\n\t\treturn version ? Promise.reject(new Error(\"Invalid operation\")) : null;\n\t}\n\n\tpublic async readBlob(blobId: string): Promise<ArrayBufferLike> {\n\t\tthrow new Error(\"Invalid operation\");\n\t}\n\n\tpublic async getStartingOpSequence(): Promise<number> {\n\t\treturn 0;\n\t}\n\n\tpublic fetchTo(currentOp: number) {\n\t\tif (!(this.unitIsTime !== true && this.replayTo >= 0)) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn this.replayTo;\n\t}\n\n\tpublic isDoneFetch(currentOp: number, lastTimeStamp?: number) {\n\t\tif (this.replayTo >= 0) {\n\t\t\tif (this.unitIsTime === true) {\n\t\t\t\treturn (\n\t\t\t\t\tlastTimeStamp !== undefined &&\n\t\t\t\t\tthis.firstTimeStamp !== undefined &&\n\t\t\t\t\tlastTimeStamp - this.firstTimeStamp >= this.replayTo\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn currentOp >= this.replayTo;\n\t\t}\n\t\treturn lastTimeStamp === undefined; // No more ops\n\t}\n\n\tpublic skipToIndex(fetchedOps: ISequencedDocumentMessage[]) {\n\t\tif (this.replayFrom <= 0) {\n\t\t\treturn 0;\n\t\t}\n\t\tif (this.unitIsTime === true) {\n\t\t\tfor (let i = 0; i < fetchedOps.length; i += 1) {\n\t\t\t\t// Non null asserting here because we are iterating over fetchedOps\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tconst timeStamp = fetchedOps[i]!.timestamp;\n\t\t\t\tif (timeStamp !== undefined) {\n\t\t\t\t\tif (this.firstTimeStamp === undefined) {\n\t\t\t\t\t\tthis.firstTimeStamp = timeStamp;\n\t\t\t\t\t}\n\t\t\t\t\tif (timeStamp - this.firstTimeStamp >= this.replayFrom) {\n\t\t\t\t\t\treturn i;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (this.replayFrom > this.replayCurrent) {\n\t\t\treturn this.replayFrom - this.replayCurrent;\n\t\t}\n\t\treturn 0;\n\t}\n\n\tpublic async replay(\n\t\temitter: (op: ISequencedDocumentMessage[]) => void,\n\t\tfetchedOps: ISequencedDocumentMessage[],\n\t): Promise<void> {\n\t\tlet current = this.skipToIndex(fetchedOps);\n\n\t\treturn new Promise((resolve) => {\n\t\t\tconst replayNextOps = () => {\n\t\t\t\t// Emit the ops from replay to the end every \"deltainterval\" milliseconds\n\t\t\t\t// to simulate the socket stream\n\t\t\t\t// TODO Why are we non null asserting here\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tconst currentOp = fetchedOps[current]!;\n\t\t\t\tconst playbackOps = [currentOp];\n\t\t\t\tlet nextInterval = ReplayControllerStatic.DelayInterval;\n\t\t\t\tcurrent += 1;\n\n\t\t\t\tif (this.unitIsTime === true) {\n\t\t\t\t\tconst currentTimeStamp = currentOp.timestamp;\n\t\t\t\t\tif (currentTimeStamp !== undefined) {\n\t\t\t\t\t\t// Emit more ops that is in the ReplayResolution window\n\n\t\t\t\t\t\twhile (current < fetchedOps.length) {\n\t\t\t\t\t\t\t// TODO Why are we non null asserting here\n\t\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t\t\t\tconst op = fetchedOps[current]!;\n\t\t\t\t\t\t\tif (op.timestamp === undefined) {\n\t\t\t\t\t\t\t\t// Missing timestamp, just delay the standard amount of time\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tconst timeDiff = op.timestamp - currentTimeStamp;\n\t\t\t\t\t\t\tif (timeDiff >= ReplayControllerStatic.ReplayResolution) {\n\t\t\t\t\t\t\t\t// Time exceeded the resolution window, break out the loop\n\t\t\t\t\t\t\t\t// and delay for the time difference.\n\t\t\t\t\t\t\t\tnextInterval = timeDiff;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (timeDiff < 0) {\n\t\t\t\t\t\t\t\t// Time have regressed, just delay the standard amount of time\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// The op is within the ReplayResolution emit it now\n\t\t\t\t\t\t\tplaybackOps.push(op);\n\t\t\t\t\t\t\tcurrent += 1;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tthis.firstTimeStamp !== undefined &&\n\t\t\t\t\t\t\tthis.replayTo >= 0 &&\n\t\t\t\t\t\t\tcurrentTimeStamp + nextInterval - this.firstTimeStamp > this.replayTo\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tnextInterval = -1;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tscheduleNext(nextInterval);\n\t\t\t\temitter(playbackOps);\n\t\t\t};\n\t\t\tconst scheduleNext = (nextInterval: number) => {\n\t\t\t\tif (nextInterval >= 0 && current < fetchedOps.length) {\n\t\t\t\t\tsetTimeout(replayNextOps, nextInterval);\n\t\t\t\t} else {\n\t\t\t\t\tthis.replayCurrent += current;\n\t\t\t\t\tresolve();\n\t\t\t\t}\n\t\t\t};\n\t\t\tscheduleNext(ReplayControllerStatic.DelayInterval);\n\t\t});\n\t}\n}\n\nexport class ReplayDocumentDeltaConnection\n\textends TypedEventEmitter<IDocumentDeltaConnectionEvents>\n\timplements IDocumentDeltaConnection, IDisposable\n{\n\t/**\n\t * Creates a new delta connection and mimics the delta connection to replay ops on it.\n\t * @param documentService - The document service to be used to get underlying endpoints.\n\t */\n\tpublic static create(\n\t\tdocumentStorageService: IDocumentDeltaStorageService,\n\t\tcontroller: ReplayController,\n\t): IDocumentDeltaConnection {\n\t\tconst connection: IConnected = {\n\t\t\tclaims: ReplayDocumentDeltaConnection.claims,\n\t\t\tclientId: \"PseudoClientId\",\n\t\t\texisting: true,\n\t\t\tinitialMessages: [],\n\t\t\tinitialSignals: [],\n\t\t\tinitialClients: [],\n\t\t\tmaxMessageSize: ReplayDocumentDeltaConnection.ReplayMaxMessageSize,\n\t\t\tmode: \"read\",\n\t\t\tserviceConfiguration: {\n\t\t\t\tblockSize: 64436,\n\t\t\t\tmaxMessageSize: ReplayDocumentDeltaConnection.ReplayMaxMessageSize,\n\t\t\t},\n\t\t\tsupportedVersions: [ReplayDocumentDeltaConnection.replayProtocolVersion],\n\t\t\tversion: ReplayDocumentDeltaConnection.replayProtocolVersion,\n\t\t};\n\t\tconst deltaConnection = new ReplayDocumentDeltaConnection(connection);\n\t\t// eslint-disable-next-line @typescript-eslint/no-floating-promises\n\t\tdeltaConnection.fetchAndEmitOps(documentStorageService, controller);\n\n\t\treturn deltaConnection;\n\t}\n\n\tprivate static readonly replayProtocolVersion = \"^0.1.0\";\n\t// Since the replay service never actually sends messages the size below is arbitrary\n\tprivate static readonly ReplayMaxMessageSize = 16 * 1024;\n\n\tprivate static readonly claims: ITokenClaims = {\n\t\tdocumentId: ReplayDocumentId,\n\t\tscopes: [ScopeType.DocRead],\n\t\ttenantId: \"\",\n\t\tuser: {\n\t\t\tid: \"\",\n\t\t},\n\t\tiat: Math.round(new Date().getTime() / 1000),\n\t\texp: Math.round(new Date().getTime() / 1000) + 60 * 60, // 1 hour expiration\n\t\tver: \"1.0\",\n\t};\n\n\tpublic get clientId(): string {\n\t\treturn this.details.clientId;\n\t}\n\n\tpublic get mode(): ConnectionMode {\n\t\treturn this.details.mode;\n\t}\n\n\tpublic get claims(): ITokenClaims {\n\t\treturn this.details.claims;\n\t}\n\n\tpublic get existing(): boolean {\n\t\treturn this.details.existing;\n\t}\n\n\tpublic get version(): string {\n\t\treturn this.details.version;\n\t}\n\n\tpublic get initialMessages(): ISequencedDocumentMessage[] {\n\t\treturn this.details.initialMessages;\n\t}\n\n\tpublic get initialSignals(): ISignalMessage[] {\n\t\treturn this.details.initialSignals;\n\t}\n\n\tpublic get initialClients(): ISignalClient[] {\n\t\treturn this.details.initialClients;\n\t}\n\n\tpublic get serviceConfiguration(): IClientConfiguration {\n\t\treturn this.details.serviceConfiguration;\n\t}\n\n\tpublic readonly maxMessageSize = ReplayDocumentDeltaConnection.ReplayMaxMessageSize;\n\n\tconstructor(public details: IConnected) {\n\t\tsuper();\n\t}\n\n\tpublic submit(documentMessage: IDocumentMessage[]): void {\n\t\t// ReplayDocumentDeltaConnection.submit() can't be called - client never sees its own join on,\n\t\t// and thus can never move to sending ops.\n\t\tthrow new Error(\"ReplayDocumentDeltaConnection.submit() can't be called\");\n\t}\n\n\tpublic async submitSignal(message: any) {}\n\n\tprivate _disposed = false;\n\tpublic get disposed() {\n\t\treturn this._disposed;\n\t}\n\tpublic dispose() {\n\t\tthis._disposed = true;\n\t}\n\n\t/**\n\t * This gets the specified ops from the delta storage endpoint and replays them in the replayer.\n\t */\n\tprivate async fetchAndEmitOps(\n\t\tdocumentStorageService: IDocumentDeltaStorageService,\n\t\tcontroller: ReplayController,\n\t): Promise<void> {\n\t\tlet done;\n\t\tlet replayPromiseChain = Promise.resolve();\n\n\t\tlet currentOp = await controller.getStartingOpSequence();\n\n\t\tdo {\n\t\t\tconst fetchTo = controller.fetchTo(currentOp);\n\n\t\t\tconst abortController = new AbortController();\n\t\t\tconst stream = documentStorageService.fetchMessages(\n\t\t\t\tcurrentOp + 1,\n\t\t\t\tfetchTo,\n\t\t\t\tabortController.signal,\n\t\t\t);\n\t\t\tdo {\n\t\t\t\tconst result = await stream.read();\n\n\t\t\t\tif (result.done) {\n\t\t\t\t\t// No more ops. But, they can show up later, either because document was just created,\n\t\t\t\t\t// or because another client keeps submitting new ops.\n\t\t\t\t\tdone = controller.isDoneFetch(currentOp, undefined);\n\t\t\t\t\tif (!done) {\n\t\t\t\t\t\tawait delay(2000);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\treplayPromiseChain = replayPromiseChain.then(async () =>\n\t\t\t\t\tcontroller.replay((ops) => this.emit(\"op\", ReplayDocumentId, ops), messages),\n\t\t\t\t);\n\n\t\t\t\tconst messages = result.value;\n\t\t\t\tcurrentOp += messages.length;\n\t\t\t\t// TODO Why are we non null asserting here\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tdone = controller.isDoneFetch(currentOp, messages[messages.length - 1]!.timestamp);\n\t\t\t} while (!done);\n\n\t\t\tabortController.abort();\n\t\t} while (!done);\n\t\treturn replayPromiseChain;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"replayDocumentDeltaConnection.js","sourceRoot":"","sources":["../src/replayDocumentDeltaConnection.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAiE;AAEjE,kEAA4D;AAE5D,0EAcqD;AAErD,+DAAyD;AAEzD,MAAM,gBAAgB,GAAG,YAAY,CAAC;AAEtC,MAAa,sBAAuB,SAAQ,sCAAgB;IAM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C,MAAM,CAAC;gBAC7B,IAAI,GAAG,UAAU,CAAC,WAAW,CAAC,SAAS,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;YACnF,CAAC,QAAQ,CAAC,IAAI,EAAE;YAEhB,eAAe,CAAC,KAAK,EAAE,CAAC;QACzB,CAAC,QAAQ,CAAC,IAAI,EAAE;QAChB,OAAO,kBAAkB,CAAC;IAC3B,CAAC;;AA1JF,sEA2JC;AAxHwB,mDAAqB,GAAG,QAAQ,AAAX,CAAY;AACzD,qFAAqF;AAC7D,kDAAoB,GAAG,EAAE,GAAG,IAAI,AAAZ,CAAa;AAEjC,oCAAM,GAAiB;IAC9C,UAAU,EAAE,gBAAgB;IAC5B,MAAM,EAAE,CAAC,oBAAS,CAAC,OAAO,CAAC;IAC3B,QAAQ,EAAE,EAAE;IACZ,IAAI,EAAE;QACL,EAAE,EAAE,EAAE;KACN;IACD,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC;IAC5C,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,oBAAoB;IAC5E,GAAG,EAAE,KAAK;CACV,AAV6B,CAU5B","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport { IDisposable } from \"@fluidframework/core-interfaces\";\nimport { delay } from \"@fluidframework/core-utils/internal\";\nimport { ConnectionMode } from \"@fluidframework/driver-definitions\";\nimport {\n\tIDocumentDeltaConnection,\n\tIDocumentDeltaConnectionEvents,\n\tIDocumentDeltaStorageService,\n\tIDocumentService,\n\tIClientConfiguration,\n\tIConnected,\n\tIDocumentMessage,\n\tISignalClient,\n\tITokenClaims,\n\tIVersion,\n\tScopeType,\n\tISequencedDocumentMessage,\n\tISignalMessage,\n} from \"@fluidframework/driver-definitions/internal\";\n\nimport { ReplayController } from \"./replayController.js\";\n\nconst ReplayDocumentId = \"documentId\";\n\nexport class ReplayControllerStatic extends ReplayController {\n\tprivate static readonly DelayInterval = 50;\n\tprivate static readonly ReplayResolution = 15;\n\n\tprivate firstTimeStamp: number | undefined;\n\tprivate replayCurrent = 0;\n\t// Simulated delay interval for emitting the ops\n\n\t/**\n\t * Helper class\n\t *\n\t * @param replayFrom - First op to be played on socket.\n\t * @param replayTo - Last op number to be played on socket.\n\t * @param unitIsTime - True is user want to play ops that are within a replay resolution window.\n\t */\n\tpublic constructor(\n\t\tpublic readonly replayFrom: number,\n\t\tpublic readonly replayTo: number,\n\t\tpublic readonly unitIsTime?: boolean,\n\t) {\n\t\tsuper();\n\t\tif (unitIsTime !== true) {\n\t\t\t// There is no code in here to start with snapshot, thus we have to start with op #0.\n\t\t\tthis.replayTo = 0;\n\t\t}\n\t}\n\n\tpublic async initStorage(documentService: IDocumentService) {\n\t\treturn true;\n\t}\n\n\tpublic async getVersions(versionId: string | null, count: number): Promise<IVersion[]> {\n\t\treturn [];\n\t}\n\n\tpublic async getSnapshotTree(version?: IVersion) {\n\t\treturn version ? Promise.reject(new Error(\"Invalid operation\")) : null;\n\t}\n\n\tpublic async readBlob(blobId: string): Promise<ArrayBufferLike> {\n\t\tthrow new Error(\"Invalid operation\");\n\t}\n\n\tpublic async getStartingOpSequence(): Promise<number> {\n\t\treturn 0;\n\t}\n\n\tpublic fetchTo(currentOp: number) {\n\t\tif (!(this.unitIsTime !== true && this.replayTo >= 0)) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn this.replayTo;\n\t}\n\n\tpublic isDoneFetch(currentOp: number, lastTimeStamp?: number) {\n\t\tif (this.replayTo >= 0) {\n\t\t\tif (this.unitIsTime === true) {\n\t\t\t\treturn (\n\t\t\t\t\tlastTimeStamp !== undefined &&\n\t\t\t\t\tthis.firstTimeStamp !== undefined &&\n\t\t\t\t\tlastTimeStamp - this.firstTimeStamp >= this.replayTo\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn currentOp >= this.replayTo;\n\t\t}\n\t\treturn lastTimeStamp === undefined; // No more ops\n\t}\n\n\tpublic skipToIndex(fetchedOps: ISequencedDocumentMessage[]) {\n\t\tif (this.replayFrom <= 0) {\n\t\t\treturn 0;\n\t\t}\n\t\tif (this.unitIsTime === true) {\n\t\t\tfor (let i = 0; i < fetchedOps.length; i += 1) {\n\t\t\t\tconst timeStamp = fetchedOps[i].timestamp;\n\t\t\t\tif (timeStamp !== undefined) {\n\t\t\t\t\tif (this.firstTimeStamp === undefined) {\n\t\t\t\t\t\tthis.firstTimeStamp = timeStamp;\n\t\t\t\t\t}\n\t\t\t\t\tif (timeStamp - this.firstTimeStamp >= this.replayFrom) {\n\t\t\t\t\t\treturn i;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (this.replayFrom > this.replayCurrent) {\n\t\t\treturn this.replayFrom - this.replayCurrent;\n\t\t}\n\t\treturn 0;\n\t}\n\n\tpublic async replay(\n\t\temitter: (op: ISequencedDocumentMessage[]) => void,\n\t\tfetchedOps: ISequencedDocumentMessage[],\n\t): Promise<void> {\n\t\tlet current = this.skipToIndex(fetchedOps);\n\n\t\treturn new Promise((resolve) => {\n\t\t\tconst replayNextOps = () => {\n\t\t\t\t// Emit the ops from replay to the end every \"deltainterval\" milliseconds\n\t\t\t\t// to simulate the socket stream\n\t\t\t\tconst currentOp = fetchedOps[current];\n\t\t\t\tconst playbackOps = [currentOp];\n\t\t\t\tlet nextInterval = ReplayControllerStatic.DelayInterval;\n\t\t\t\tcurrent += 1;\n\n\t\t\t\tif (this.unitIsTime === true) {\n\t\t\t\t\tconst currentTimeStamp = currentOp.timestamp;\n\t\t\t\t\tif (currentTimeStamp !== undefined) {\n\t\t\t\t\t\t// Emit more ops that is in the ReplayResolution window\n\n\t\t\t\t\t\twhile (current < fetchedOps.length) {\n\t\t\t\t\t\t\tconst op = fetchedOps[current];\n\t\t\t\t\t\t\tif (op.timestamp === undefined) {\n\t\t\t\t\t\t\t\t// Missing timestamp, just delay the standard amount of time\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tconst timeDiff = op.timestamp - currentTimeStamp;\n\t\t\t\t\t\t\tif (timeDiff >= ReplayControllerStatic.ReplayResolution) {\n\t\t\t\t\t\t\t\t// Time exceeded the resolution window, break out the loop\n\t\t\t\t\t\t\t\t// and delay for the time difference.\n\t\t\t\t\t\t\t\tnextInterval = timeDiff;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (timeDiff < 0) {\n\t\t\t\t\t\t\t\t// Time have regressed, just delay the standard amount of time\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// The op is within the ReplayResolution emit it now\n\t\t\t\t\t\t\tplaybackOps.push(op);\n\t\t\t\t\t\t\tcurrent += 1;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tthis.firstTimeStamp !== undefined &&\n\t\t\t\t\t\t\tthis.replayTo >= 0 &&\n\t\t\t\t\t\t\tcurrentTimeStamp + nextInterval - this.firstTimeStamp > this.replayTo\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tnextInterval = -1;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tscheduleNext(nextInterval);\n\t\t\t\temitter(playbackOps);\n\t\t\t};\n\t\t\tconst scheduleNext = (nextInterval: number) => {\n\t\t\t\tif (nextInterval >= 0 && current < fetchedOps.length) {\n\t\t\t\t\tsetTimeout(replayNextOps, nextInterval);\n\t\t\t\t} else {\n\t\t\t\t\tthis.replayCurrent += current;\n\t\t\t\t\tresolve();\n\t\t\t\t}\n\t\t\t};\n\t\t\tscheduleNext(ReplayControllerStatic.DelayInterval);\n\t\t});\n\t}\n}\n\nexport class ReplayDocumentDeltaConnection\n\textends TypedEventEmitter<IDocumentDeltaConnectionEvents>\n\timplements IDocumentDeltaConnection, IDisposable\n{\n\t/**\n\t * Creates a new delta connection and mimics the delta connection to replay ops on it.\n\t * @param documentService - The document service to be used to get underlying endpoints.\n\t */\n\tpublic static create(\n\t\tdocumentStorageService: IDocumentDeltaStorageService,\n\t\tcontroller: ReplayController,\n\t): IDocumentDeltaConnection {\n\t\tconst connection: IConnected = {\n\t\t\tclaims: ReplayDocumentDeltaConnection.claims,\n\t\t\tclientId: \"PseudoClientId\",\n\t\t\texisting: true,\n\t\t\tinitialMessages: [],\n\t\t\tinitialSignals: [],\n\t\t\tinitialClients: [],\n\t\t\tmaxMessageSize: ReplayDocumentDeltaConnection.ReplayMaxMessageSize,\n\t\t\tmode: \"read\",\n\t\t\tserviceConfiguration: {\n\t\t\t\tblockSize: 64436,\n\t\t\t\tmaxMessageSize: ReplayDocumentDeltaConnection.ReplayMaxMessageSize,\n\t\t\t},\n\t\t\tsupportedVersions: [ReplayDocumentDeltaConnection.replayProtocolVersion],\n\t\t\tversion: ReplayDocumentDeltaConnection.replayProtocolVersion,\n\t\t};\n\t\tconst deltaConnection = new ReplayDocumentDeltaConnection(connection);\n\t\t// eslint-disable-next-line @typescript-eslint/no-floating-promises\n\t\tdeltaConnection.fetchAndEmitOps(documentStorageService, controller);\n\n\t\treturn deltaConnection;\n\t}\n\n\tprivate static readonly replayProtocolVersion = \"^0.1.0\";\n\t// Since the replay service never actually sends messages the size below is arbitrary\n\tprivate static readonly ReplayMaxMessageSize = 16 * 1024;\n\n\tprivate static readonly claims: ITokenClaims = {\n\t\tdocumentId: ReplayDocumentId,\n\t\tscopes: [ScopeType.DocRead],\n\t\ttenantId: \"\",\n\t\tuser: {\n\t\t\tid: \"\",\n\t\t},\n\t\tiat: Math.round(new Date().getTime() / 1000),\n\t\texp: Math.round(new Date().getTime() / 1000) + 60 * 60, // 1 hour expiration\n\t\tver: \"1.0\",\n\t};\n\n\tpublic get clientId(): string {\n\t\treturn this.details.clientId;\n\t}\n\n\tpublic get mode(): ConnectionMode {\n\t\treturn this.details.mode;\n\t}\n\n\tpublic get claims(): ITokenClaims {\n\t\treturn this.details.claims;\n\t}\n\n\tpublic get existing(): boolean {\n\t\treturn this.details.existing;\n\t}\n\n\tpublic get version(): string {\n\t\treturn this.details.version;\n\t}\n\n\tpublic get initialMessages(): ISequencedDocumentMessage[] {\n\t\treturn this.details.initialMessages;\n\t}\n\n\tpublic get initialSignals(): ISignalMessage[] {\n\t\treturn this.details.initialSignals;\n\t}\n\n\tpublic get initialClients(): ISignalClient[] {\n\t\treturn this.details.initialClients;\n\t}\n\n\tpublic get serviceConfiguration(): IClientConfiguration {\n\t\treturn this.details.serviceConfiguration;\n\t}\n\n\tpublic readonly maxMessageSize = ReplayDocumentDeltaConnection.ReplayMaxMessageSize;\n\n\tconstructor(public details: IConnected) {\n\t\tsuper();\n\t}\n\n\tpublic submit(documentMessage: IDocumentMessage[]): void {\n\t\t// ReplayDocumentDeltaConnection.submit() can't be called - client never sees its own join on,\n\t\t// and thus can never move to sending ops.\n\t\tthrow new Error(\"ReplayDocumentDeltaConnection.submit() can't be called\");\n\t}\n\n\tpublic async submitSignal(message: any) {}\n\n\tprivate _disposed = false;\n\tpublic get disposed() {\n\t\treturn this._disposed;\n\t}\n\tpublic dispose() {\n\t\tthis._disposed = true;\n\t}\n\n\t/**\n\t * This gets the specified ops from the delta storage endpoint and replays them in the replayer.\n\t */\n\tprivate async fetchAndEmitOps(\n\t\tdocumentStorageService: IDocumentDeltaStorageService,\n\t\tcontroller: ReplayController,\n\t): Promise<void> {\n\t\tlet done;\n\t\tlet replayPromiseChain = Promise.resolve();\n\n\t\tlet currentOp = await controller.getStartingOpSequence();\n\n\t\tdo {\n\t\t\tconst fetchTo = controller.fetchTo(currentOp);\n\n\t\t\tconst abortController = new AbortController();\n\t\t\tconst stream = documentStorageService.fetchMessages(\n\t\t\t\tcurrentOp + 1,\n\t\t\t\tfetchTo,\n\t\t\t\tabortController.signal,\n\t\t\t);\n\t\t\tdo {\n\t\t\t\tconst result = await stream.read();\n\n\t\t\t\tif (result.done) {\n\t\t\t\t\t// No more ops. But, they can show up later, either because document was just created,\n\t\t\t\t\t// or because another client keeps submitting new ops.\n\t\t\t\t\tdone = controller.isDoneFetch(currentOp, undefined);\n\t\t\t\t\tif (!done) {\n\t\t\t\t\t\tawait delay(2000);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\treplayPromiseChain = replayPromiseChain.then(async () =>\n\t\t\t\t\tcontroller.replay((ops) => this.emit(\"op\", ReplayDocumentId, ops), messages),\n\t\t\t\t);\n\n\t\t\t\tconst messages = result.value;\n\t\t\t\tcurrentOp += messages.length;\n\t\t\t\tdone = controller.isDoneFetch(currentOp, messages[messages.length - 1].timestamp);\n\t\t\t} while (!done);\n\n\t\t\tabortController.abort();\n\t\t} while (!done);\n\t\treturn replayPromiseChain;\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"replayDocumentDeltaConnection.d.ts","sourceRoot":"","sources":["../src/replayDocumentDeltaConnection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAE9D,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EACN,wBAAwB,EACxB,8BAA8B,EAC9B,4BAA4B,EAC5B,gBAAgB,EAChB,oBAAoB,EACpB,UAAU,EACV,gBAAgB,EAChB,aAAa,EACb,YAAY,EACZ,QAAQ,EAER,yBAAyB,EACzB,cAAc,EACd,MAAM,6CAA6C,CAAC;AAErD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAIzD,qBAAa,sBAAuB,S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,CACnB,sBAAsB,EAAE,4BAA4B,EACpD,UAAU,EAAE,gBAAgB,GAC1B,wBAAwB;IAwB3B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,qBAAqB,CAAY;IAEzD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,oBAAoB,CAAa;IAEzD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAU5B;IAEF,IAAW,QAAQ,IAAI,MAAM,CAE5B;IAED,IAAW,IAAI,IAAI,cAAc,CAEhC;IAED,IAAW,MAAM,IAAI,YAAY,CAEhC;IAED,IAAW,QAAQ,IAAI,OAAO,CAE7B;IAED,IAAW,OAAO,IAAI,MAAM,CAE3B;IAED,IAAW,eAAe,IAAI,yBAAyB,EAAE,CAExD;IAED,IAAW,cAAc,IAAI,cAAc,EAAE,CAE5C;IAED,IAAW,cAAc,IAAI,aAAa,EAAE,CAE3C;IAED,IAAW,oBAAoB,IAAI,oBAAoB,CAEtD;IAED,SAAgB,cAAc,SAAsD;gBAEjE,OAAO,EAAE,UAAU;IAI/B,MAAM,CAAC,eAAe,EAAE,gBAAgB,EAAE,GAAG,IAAI;IAM3C,YAAY,CAAC,OAAO,EAAE,GAAG;IAEtC,OAAO,CAAC,SAAS,CAAS;IAC1B,IAAW,QAAQ,YAElB;IACM,OAAO;IAId;;OAEG;YACW,eAAe;CA2C7B"}
|
|
@@ -65,8 +65,6 @@ export class ReplayControllerStatic extends ReplayController {
|
|
|
65
65
|
}
|
|
66
66
|
if (this.unitIsTime === true) {
|
|
67
67
|
for (let i = 0; i < fetchedOps.length; i += 1) {
|
|
68
|
-
// Non null asserting here because we are iterating over fetchedOps
|
|
69
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
70
68
|
const timeStamp = fetchedOps[i].timestamp;
|
|
71
69
|
if (timeStamp !== undefined) {
|
|
72
70
|
if (this.firstTimeStamp === undefined) {
|
|
@@ -89,8 +87,6 @@ export class ReplayControllerStatic extends ReplayController {
|
|
|
89
87
|
const replayNextOps = () => {
|
|
90
88
|
// Emit the ops from replay to the end every "deltainterval" milliseconds
|
|
91
89
|
// to simulate the socket stream
|
|
92
|
-
// TODO Why are we non null asserting here
|
|
93
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
94
90
|
const currentOp = fetchedOps[current];
|
|
95
91
|
const playbackOps = [currentOp];
|
|
96
92
|
let nextInterval = ReplayControllerStatic.DelayInterval;
|
|
@@ -100,8 +96,6 @@ export class ReplayControllerStatic extends ReplayController {
|
|
|
100
96
|
if (currentTimeStamp !== undefined) {
|
|
101
97
|
// Emit more ops that is in the ReplayResolution window
|
|
102
98
|
while (current < fetchedOps.length) {
|
|
103
|
-
// TODO Why are we non null asserting here
|
|
104
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
105
99
|
const op = fetchedOps[current];
|
|
106
100
|
if (op.timestamp === undefined) {
|
|
107
101
|
// Missing timestamp, just delay the standard amount of time
|
|
@@ -244,8 +238,6 @@ export class ReplayDocumentDeltaConnection extends TypedEventEmitter {
|
|
|
244
238
|
replayPromiseChain = replayPromiseChain.then(async () => controller.replay((ops) => this.emit("op", ReplayDocumentId, ops), messages));
|
|
245
239
|
const messages = result.value;
|
|
246
240
|
currentOp += messages.length;
|
|
247
|
-
// TODO Why are we non null asserting here
|
|
248
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
249
241
|
done = controller.isDoneFetch(currentOp, messages[messages.length - 1].timestamp);
|
|
250
242
|
} while (!done);
|
|
251
243
|
abortController.abort();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"replayDocumentDeltaConnection.js","sourceRoot":"","sources":["../src/replayDocumentDeltaConnection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEjE,OAAO,EAAE,KAAK,EAAE,MAAM,qCAAqC,CAAC;AAE5D,OAAO,EAWN,SAAS,G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EAAE,CACvD,UAAU,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,gBAAgB,EAAE,GAAG,CAAC,EAAE,QAAQ,CAAC,CAC5E,CAAC;gBAEF,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC;gBAC9B,SAAS,IAAI,QAAQ,CAAC,MAAM,CAAC;gBAC7B,0CAA0C;gBAC1C,oEAAoE;gBACpE,IAAI,GAAG,UAAU,CAAC,WAAW,CAAC,SAAS,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAE,CAAC,SAAS,CAAC,CAAC;YACpF,CAAC,QAAQ,CAAC,IAAI,EAAE;YAEhB,eAAe,CAAC,KAAK,EAAE,CAAC;QACzB,CAAC,QAAQ,CAAC,IAAI,EAAE;QAChB,OAAO,kBAAkB,CAAC;IAC3B,CAAC;;AAzHuB,mDAAqB,GAAG,QAAQ,AAAX,CAAY;AACzD,qFAAqF;AAC7D,kDAAoB,GAAG,EAAE,GAAG,IAAI,AAAZ,CAAa;AAEjC,oCAAM,GAAiB;IAC9C,UAAU,EAAE,gBAAgB;IAC5B,MAAM,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC;IAC3B,QAAQ,EAAE,EAAE;IACZ,IAAI,EAAE;QACL,EAAE,EAAE,EAAE;KACN;IACD,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC;IAC5C,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,oBAAoB;IAC5E,GAAG,EAAE,KAAK;CACV,AAV6B,CAU5B","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport { IDisposable } from \"@fluidframework/core-interfaces\";\nimport { delay } from \"@fluidframework/core-utils/internal\";\nimport { ConnectionMode } from \"@fluidframework/driver-definitions\";\nimport {\n\tIDocumentDeltaConnection,\n\tIDocumentDeltaConnectionEvents,\n\tIDocumentDeltaStorageService,\n\tIDocumentService,\n\tIClientConfiguration,\n\tIConnected,\n\tIDocumentMessage,\n\tISignalClient,\n\tITokenClaims,\n\tIVersion,\n\tScopeType,\n\tISequencedDocumentMessage,\n\tISignalMessage,\n} from \"@fluidframework/driver-definitions/internal\";\n\nimport { ReplayController } from \"./replayController.js\";\n\nconst ReplayDocumentId = \"documentId\";\n\nexport class ReplayControllerStatic extends ReplayController {\n\tprivate static readonly DelayInterval = 50;\n\tprivate static readonly ReplayResolution = 15;\n\n\tprivate firstTimeStamp: number | undefined;\n\tprivate replayCurrent = 0;\n\t// Simulated delay interval for emitting the ops\n\n\t/**\n\t * Helper class\n\t *\n\t * @param replayFrom - First op to be played on socket.\n\t * @param replayTo - Last op number to be played on socket.\n\t * @param unitIsTime - True is user want to play ops that are within a replay resolution window.\n\t */\n\tpublic constructor(\n\t\tpublic readonly replayFrom: number,\n\t\tpublic readonly replayTo: number,\n\t\tpublic readonly unitIsTime?: boolean,\n\t) {\n\t\tsuper();\n\t\tif (unitIsTime !== true) {\n\t\t\t// There is no code in here to start with snapshot, thus we have to start with op #0.\n\t\t\tthis.replayTo = 0;\n\t\t}\n\t}\n\n\tpublic async initStorage(documentService: IDocumentService) {\n\t\treturn true;\n\t}\n\n\tpublic async getVersions(versionId: string | null, count: number): Promise<IVersion[]> {\n\t\treturn [];\n\t}\n\n\tpublic async getSnapshotTree(version?: IVersion) {\n\t\treturn version ? Promise.reject(new Error(\"Invalid operation\")) : null;\n\t}\n\n\tpublic async readBlob(blobId: string): Promise<ArrayBufferLike> {\n\t\tthrow new Error(\"Invalid operation\");\n\t}\n\n\tpublic async getStartingOpSequence(): Promise<number> {\n\t\treturn 0;\n\t}\n\n\tpublic fetchTo(currentOp: number) {\n\t\tif (!(this.unitIsTime !== true && this.replayTo >= 0)) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn this.replayTo;\n\t}\n\n\tpublic isDoneFetch(currentOp: number, lastTimeStamp?: number) {\n\t\tif (this.replayTo >= 0) {\n\t\t\tif (this.unitIsTime === true) {\n\t\t\t\treturn (\n\t\t\t\t\tlastTimeStamp !== undefined &&\n\t\t\t\t\tthis.firstTimeStamp !== undefined &&\n\t\t\t\t\tlastTimeStamp - this.firstTimeStamp >= this.replayTo\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn currentOp >= this.replayTo;\n\t\t}\n\t\treturn lastTimeStamp === undefined; // No more ops\n\t}\n\n\tpublic skipToIndex(fetchedOps: ISequencedDocumentMessage[]) {\n\t\tif (this.replayFrom <= 0) {\n\t\t\treturn 0;\n\t\t}\n\t\tif (this.unitIsTime === true) {\n\t\t\tfor (let i = 0; i < fetchedOps.length; i += 1) {\n\t\t\t\t// Non null asserting here because we are iterating over fetchedOps\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tconst timeStamp = fetchedOps[i]!.timestamp;\n\t\t\t\tif (timeStamp !== undefined) {\n\t\t\t\t\tif (this.firstTimeStamp === undefined) {\n\t\t\t\t\t\tthis.firstTimeStamp = timeStamp;\n\t\t\t\t\t}\n\t\t\t\t\tif (timeStamp - this.firstTimeStamp >= this.replayFrom) {\n\t\t\t\t\t\treturn i;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (this.replayFrom > this.replayCurrent) {\n\t\t\treturn this.replayFrom - this.replayCurrent;\n\t\t}\n\t\treturn 0;\n\t}\n\n\tpublic async replay(\n\t\temitter: (op: ISequencedDocumentMessage[]) => void,\n\t\tfetchedOps: ISequencedDocumentMessage[],\n\t): Promise<void> {\n\t\tlet current = this.skipToIndex(fetchedOps);\n\n\t\treturn new Promise((resolve) => {\n\t\t\tconst replayNextOps = () => {\n\t\t\t\t// Emit the ops from replay to the end every \"deltainterval\" milliseconds\n\t\t\t\t// to simulate the socket stream\n\t\t\t\t// TODO Why are we non null asserting here\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tconst currentOp = fetchedOps[current]!;\n\t\t\t\tconst playbackOps = [currentOp];\n\t\t\t\tlet nextInterval = ReplayControllerStatic.DelayInterval;\n\t\t\t\tcurrent += 1;\n\n\t\t\t\tif (this.unitIsTime === true) {\n\t\t\t\t\tconst currentTimeStamp = currentOp.timestamp;\n\t\t\t\t\tif (currentTimeStamp !== undefined) {\n\t\t\t\t\t\t// Emit more ops that is in the ReplayResolution window\n\n\t\t\t\t\t\twhile (current < fetchedOps.length) {\n\t\t\t\t\t\t\t// TODO Why are we non null asserting here\n\t\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t\t\t\tconst op = fetchedOps[current]!;\n\t\t\t\t\t\t\tif (op.timestamp === undefined) {\n\t\t\t\t\t\t\t\t// Missing timestamp, just delay the standard amount of time\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tconst timeDiff = op.timestamp - currentTimeStamp;\n\t\t\t\t\t\t\tif (timeDiff >= ReplayControllerStatic.ReplayResolution) {\n\t\t\t\t\t\t\t\t// Time exceeded the resolution window, break out the loop\n\t\t\t\t\t\t\t\t// and delay for the time difference.\n\t\t\t\t\t\t\t\tnextInterval = timeDiff;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (timeDiff < 0) {\n\t\t\t\t\t\t\t\t// Time have regressed, just delay the standard amount of time\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// The op is within the ReplayResolution emit it now\n\t\t\t\t\t\t\tplaybackOps.push(op);\n\t\t\t\t\t\t\tcurrent += 1;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tthis.firstTimeStamp !== undefined &&\n\t\t\t\t\t\t\tthis.replayTo >= 0 &&\n\t\t\t\t\t\t\tcurrentTimeStamp + nextInterval - this.firstTimeStamp > this.replayTo\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tnextInterval = -1;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tscheduleNext(nextInterval);\n\t\t\t\temitter(playbackOps);\n\t\t\t};\n\t\t\tconst scheduleNext = (nextInterval: number) => {\n\t\t\t\tif (nextInterval >= 0 && current < fetchedOps.length) {\n\t\t\t\t\tsetTimeout(replayNextOps, nextInterval);\n\t\t\t\t} else {\n\t\t\t\t\tthis.replayCurrent += current;\n\t\t\t\t\tresolve();\n\t\t\t\t}\n\t\t\t};\n\t\t\tscheduleNext(ReplayControllerStatic.DelayInterval);\n\t\t});\n\t}\n}\n\nexport class ReplayDocumentDeltaConnection\n\textends TypedEventEmitter<IDocumentDeltaConnectionEvents>\n\timplements IDocumentDeltaConnection, IDisposable\n{\n\t/**\n\t * Creates a new delta connection and mimics the delta connection to replay ops on it.\n\t * @param documentService - The document service to be used to get underlying endpoints.\n\t */\n\tpublic static create(\n\t\tdocumentStorageService: IDocumentDeltaStorageService,\n\t\tcontroller: ReplayController,\n\t): IDocumentDeltaConnection {\n\t\tconst connection: IConnected = {\n\t\t\tclaims: ReplayDocumentDeltaConnection.claims,\n\t\t\tclientId: \"PseudoClientId\",\n\t\t\texisting: true,\n\t\t\tinitialMessages: [],\n\t\t\tinitialSignals: [],\n\t\t\tinitialClients: [],\n\t\t\tmaxMessageSize: ReplayDocumentDeltaConnection.ReplayMaxMessageSize,\n\t\t\tmode: \"read\",\n\t\t\tserviceConfiguration: {\n\t\t\t\tblockSize: 64436,\n\t\t\t\tmaxMessageSize: ReplayDocumentDeltaConnection.ReplayMaxMessageSize,\n\t\t\t},\n\t\t\tsupportedVersions: [ReplayDocumentDeltaConnection.replayProtocolVersion],\n\t\t\tversion: ReplayDocumentDeltaConnection.replayProtocolVersion,\n\t\t};\n\t\tconst deltaConnection = new ReplayDocumentDeltaConnection(connection);\n\t\t// eslint-disable-next-line @typescript-eslint/no-floating-promises\n\t\tdeltaConnection.fetchAndEmitOps(documentStorageService, controller);\n\n\t\treturn deltaConnection;\n\t}\n\n\tprivate static readonly replayProtocolVersion = \"^0.1.0\";\n\t// Since the replay service never actually sends messages the size below is arbitrary\n\tprivate static readonly ReplayMaxMessageSize = 16 * 1024;\n\n\tprivate static readonly claims: ITokenClaims = {\n\t\tdocumentId: ReplayDocumentId,\n\t\tscopes: [ScopeType.DocRead],\n\t\ttenantId: \"\",\n\t\tuser: {\n\t\t\tid: \"\",\n\t\t},\n\t\tiat: Math.round(new Date().getTime() / 1000),\n\t\texp: Math.round(new Date().getTime() / 1000) + 60 * 60, // 1 hour expiration\n\t\tver: \"1.0\",\n\t};\n\n\tpublic get clientId(): string {\n\t\treturn this.details.clientId;\n\t}\n\n\tpublic get mode(): ConnectionMode {\n\t\treturn this.details.mode;\n\t}\n\n\tpublic get claims(): ITokenClaims {\n\t\treturn this.details.claims;\n\t}\n\n\tpublic get existing(): boolean {\n\t\treturn this.details.existing;\n\t}\n\n\tpublic get version(): string {\n\t\treturn this.details.version;\n\t}\n\n\tpublic get initialMessages(): ISequencedDocumentMessage[] {\n\t\treturn this.details.initialMessages;\n\t}\n\n\tpublic get initialSignals(): ISignalMessage[] {\n\t\treturn this.details.initialSignals;\n\t}\n\n\tpublic get initialClients(): ISignalClient[] {\n\t\treturn this.details.initialClients;\n\t}\n\n\tpublic get serviceConfiguration(): IClientConfiguration {\n\t\treturn this.details.serviceConfiguration;\n\t}\n\n\tpublic readonly maxMessageSize = ReplayDocumentDeltaConnection.ReplayMaxMessageSize;\n\n\tconstructor(public details: IConnected) {\n\t\tsuper();\n\t}\n\n\tpublic submit(documentMessage: IDocumentMessage[]): void {\n\t\t// ReplayDocumentDeltaConnection.submit() can't be called - client never sees its own join on,\n\t\t// and thus can never move to sending ops.\n\t\tthrow new Error(\"ReplayDocumentDeltaConnection.submit() can't be called\");\n\t}\n\n\tpublic async submitSignal(message: any) {}\n\n\tprivate _disposed = false;\n\tpublic get disposed() {\n\t\treturn this._disposed;\n\t}\n\tpublic dispose() {\n\t\tthis._disposed = true;\n\t}\n\n\t/**\n\t * This gets the specified ops from the delta storage endpoint and replays them in the replayer.\n\t */\n\tprivate async fetchAndEmitOps(\n\t\tdocumentStorageService: IDocumentDeltaStorageService,\n\t\tcontroller: ReplayController,\n\t): Promise<void> {\n\t\tlet done;\n\t\tlet replayPromiseChain = Promise.resolve();\n\n\t\tlet currentOp = await controller.getStartingOpSequence();\n\n\t\tdo {\n\t\t\tconst fetchTo = controller.fetchTo(currentOp);\n\n\t\t\tconst abortController = new AbortController();\n\t\t\tconst stream = documentStorageService.fetchMessages(\n\t\t\t\tcurrentOp + 1,\n\t\t\t\tfetchTo,\n\t\t\t\tabortController.signal,\n\t\t\t);\n\t\t\tdo {\n\t\t\t\tconst result = await stream.read();\n\n\t\t\t\tif (result.done) {\n\t\t\t\t\t// No more ops. But, they can show up later, either because document was just created,\n\t\t\t\t\t// or because another client keeps submitting new ops.\n\t\t\t\t\tdone = controller.isDoneFetch(currentOp, undefined);\n\t\t\t\t\tif (!done) {\n\t\t\t\t\t\tawait delay(2000);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\treplayPromiseChain = replayPromiseChain.then(async () =>\n\t\t\t\t\tcontroller.replay((ops) => this.emit(\"op\", ReplayDocumentId, ops), messages),\n\t\t\t\t);\n\n\t\t\t\tconst messages = result.value;\n\t\t\t\tcurrentOp += messages.length;\n\t\t\t\t// TODO Why are we non null asserting here\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tdone = controller.isDoneFetch(currentOp, messages[messages.length - 1]!.timestamp);\n\t\t\t} while (!done);\n\n\t\t\tabortController.abort();\n\t\t} while (!done);\n\t\treturn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5E,GAAG,EAAE,KAAK;CACV,AAV6B,CAU5B","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport { IDisposable } from \"@fluidframework/core-interfaces\";\nimport { delay } from \"@fluidframework/core-utils/internal\";\nimport { ConnectionMode } from \"@fluidframework/driver-definitions\";\nimport {\n\tIDocumentDeltaConnection,\n\tIDocumentDeltaConnectionEvents,\n\tIDocumentDeltaStorageService,\n\tIDocumentService,\n\tIClientConfiguration,\n\tIConnected,\n\tIDocumentMessage,\n\tISignalClient,\n\tITokenClaims,\n\tIVersion,\n\tScopeType,\n\tISequencedDocumentMessage,\n\tISignalMessage,\n} from \"@fluidframework/driver-definitions/internal\";\n\nimport { ReplayController } from \"./replayController.js\";\n\nconst ReplayDocumentId = \"documentId\";\n\nexport class ReplayControllerStatic extends ReplayController {\n\tprivate static readonly DelayInterval = 50;\n\tprivate static readonly ReplayResolution = 15;\n\n\tprivate firstTimeStamp: number | undefined;\n\tprivate replayCurrent = 0;\n\t// Simulated delay interval for emitting the ops\n\n\t/**\n\t * Helper class\n\t *\n\t * @param replayFrom - First op to be played on socket.\n\t * @param replayTo - Last op number to be played on socket.\n\t * @param unitIsTime - True is user want to play ops that are within a replay resolution window.\n\t */\n\tpublic constructor(\n\t\tpublic readonly replayFrom: number,\n\t\tpublic readonly replayTo: number,\n\t\tpublic readonly unitIsTime?: boolean,\n\t) {\n\t\tsuper();\n\t\tif (unitIsTime !== true) {\n\t\t\t// There is no code in here to start with snapshot, thus we have to start with op #0.\n\t\t\tthis.replayTo = 0;\n\t\t}\n\t}\n\n\tpublic async initStorage(documentService: IDocumentService) {\n\t\treturn true;\n\t}\n\n\tpublic async getVersions(versionId: string | null, count: number): Promise<IVersion[]> {\n\t\treturn [];\n\t}\n\n\tpublic async getSnapshotTree(version?: IVersion) {\n\t\treturn version ? Promise.reject(new Error(\"Invalid operation\")) : null;\n\t}\n\n\tpublic async readBlob(blobId: string): Promise<ArrayBufferLike> {\n\t\tthrow new Error(\"Invalid operation\");\n\t}\n\n\tpublic async getStartingOpSequence(): Promise<number> {\n\t\treturn 0;\n\t}\n\n\tpublic fetchTo(currentOp: number) {\n\t\tif (!(this.unitIsTime !== true && this.replayTo >= 0)) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn this.replayTo;\n\t}\n\n\tpublic isDoneFetch(currentOp: number, lastTimeStamp?: number) {\n\t\tif (this.replayTo >= 0) {\n\t\t\tif (this.unitIsTime === true) {\n\t\t\t\treturn (\n\t\t\t\t\tlastTimeStamp !== undefined &&\n\t\t\t\t\tthis.firstTimeStamp !== undefined &&\n\t\t\t\t\tlastTimeStamp - this.firstTimeStamp >= this.replayTo\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn currentOp >= this.replayTo;\n\t\t}\n\t\treturn lastTimeStamp === undefined; // No more ops\n\t}\n\n\tpublic skipToIndex(fetchedOps: ISequencedDocumentMessage[]) {\n\t\tif (this.replayFrom <= 0) {\n\t\t\treturn 0;\n\t\t}\n\t\tif (this.unitIsTime === true) {\n\t\t\tfor (let i = 0; i < fetchedOps.length; i += 1) {\n\t\t\t\tconst timeStamp = fetchedOps[i].timestamp;\n\t\t\t\tif (timeStamp !== undefined) {\n\t\t\t\t\tif (this.firstTimeStamp === undefined) {\n\t\t\t\t\t\tthis.firstTimeStamp = timeStamp;\n\t\t\t\t\t}\n\t\t\t\t\tif (timeStamp - this.firstTimeStamp >= this.replayFrom) {\n\t\t\t\t\t\treturn i;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (this.replayFrom > this.replayCurrent) {\n\t\t\treturn this.replayFrom - this.replayCurrent;\n\t\t}\n\t\treturn 0;\n\t}\n\n\tpublic async replay(\n\t\temitter: (op: ISequencedDocumentMessage[]) => void,\n\t\tfetchedOps: ISequencedDocumentMessage[],\n\t): Promise<void> {\n\t\tlet current = this.skipToIndex(fetchedOps);\n\n\t\treturn new Promise((resolve) => {\n\t\t\tconst replayNextOps = () => {\n\t\t\t\t// Emit the ops from replay to the end every \"deltainterval\" milliseconds\n\t\t\t\t// to simulate the socket stream\n\t\t\t\tconst currentOp = fetchedOps[current];\n\t\t\t\tconst playbackOps = [currentOp];\n\t\t\t\tlet nextInterval = ReplayControllerStatic.DelayInterval;\n\t\t\t\tcurrent += 1;\n\n\t\t\t\tif (this.unitIsTime === true) {\n\t\t\t\t\tconst currentTimeStamp = currentOp.timestamp;\n\t\t\t\t\tif (currentTimeStamp !== undefined) {\n\t\t\t\t\t\t// Emit more ops that is in the ReplayResolution window\n\n\t\t\t\t\t\twhile (current < fetchedOps.length) {\n\t\t\t\t\t\t\tconst op = fetchedOps[current];\n\t\t\t\t\t\t\tif (op.timestamp === undefined) {\n\t\t\t\t\t\t\t\t// Missing timestamp, just delay the standard amount of time\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tconst timeDiff = op.timestamp - currentTimeStamp;\n\t\t\t\t\t\t\tif (timeDiff >= ReplayControllerStatic.ReplayResolution) {\n\t\t\t\t\t\t\t\t// Time exceeded the resolution window, break out the loop\n\t\t\t\t\t\t\t\t// and delay for the time difference.\n\t\t\t\t\t\t\t\tnextInterval = timeDiff;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (timeDiff < 0) {\n\t\t\t\t\t\t\t\t// Time have regressed, just delay the standard amount of time\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// The op is within the ReplayResolution emit it now\n\t\t\t\t\t\t\tplaybackOps.push(op);\n\t\t\t\t\t\t\tcurrent += 1;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tthis.firstTimeStamp !== undefined &&\n\t\t\t\t\t\t\tthis.replayTo >= 0 &&\n\t\t\t\t\t\t\tcurrentTimeStamp + nextInterval - this.firstTimeStamp > this.replayTo\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tnextInterval = -1;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tscheduleNext(nextInterval);\n\t\t\t\temitter(playbackOps);\n\t\t\t};\n\t\t\tconst scheduleNext = (nextInterval: number) => {\n\t\t\t\tif (nextInterval >= 0 && current < fetchedOps.length) {\n\t\t\t\t\tsetTimeout(replayNextOps, nextInterval);\n\t\t\t\t} else {\n\t\t\t\t\tthis.replayCurrent += current;\n\t\t\t\t\tresolve();\n\t\t\t\t}\n\t\t\t};\n\t\t\tscheduleNext(ReplayControllerStatic.DelayInterval);\n\t\t});\n\t}\n}\n\nexport class ReplayDocumentDeltaConnection\n\textends TypedEventEmitter<IDocumentDeltaConnectionEvents>\n\timplements IDocumentDeltaConnection, IDisposable\n{\n\t/**\n\t * Creates a new delta connection and mimics the delta connection to replay ops on it.\n\t * @param documentService - The document service to be used to get underlying endpoints.\n\t */\n\tpublic static create(\n\t\tdocumentStorageService: IDocumentDeltaStorageService,\n\t\tcontroller: ReplayController,\n\t): IDocumentDeltaConnection {\n\t\tconst connection: IConnected = {\n\t\t\tclaims: ReplayDocumentDeltaConnection.claims,\n\t\t\tclientId: \"PseudoClientId\",\n\t\t\texisting: true,\n\t\t\tinitialMessages: [],\n\t\t\tinitialSignals: [],\n\t\t\tinitialClients: [],\n\t\t\tmaxMessageSize: ReplayDocumentDeltaConnection.ReplayMaxMessageSize,\n\t\t\tmode: \"read\",\n\t\t\tserviceConfiguration: {\n\t\t\t\tblockSize: 64436,\n\t\t\t\tmaxMessageSize: ReplayDocumentDeltaConnection.ReplayMaxMessageSize,\n\t\t\t},\n\t\t\tsupportedVersions: [ReplayDocumentDeltaConnection.replayProtocolVersion],\n\t\t\tversion: ReplayDocumentDeltaConnection.replayProtocolVersion,\n\t\t};\n\t\tconst deltaConnection = new ReplayDocumentDeltaConnection(connection);\n\t\t// eslint-disable-next-line @typescript-eslint/no-floating-promises\n\t\tdeltaConnection.fetchAndEmitOps(documentStorageService, controller);\n\n\t\treturn deltaConnection;\n\t}\n\n\tprivate static readonly replayProtocolVersion = \"^0.1.0\";\n\t// Since the replay service never actually sends messages the size below is arbitrary\n\tprivate static readonly ReplayMaxMessageSize = 16 * 1024;\n\n\tprivate static readonly claims: ITokenClaims = {\n\t\tdocumentId: ReplayDocumentId,\n\t\tscopes: [ScopeType.DocRead],\n\t\ttenantId: \"\",\n\t\tuser: {\n\t\t\tid: \"\",\n\t\t},\n\t\tiat: Math.round(new Date().getTime() / 1000),\n\t\texp: Math.round(new Date().getTime() / 1000) + 60 * 60, // 1 hour expiration\n\t\tver: \"1.0\",\n\t};\n\n\tpublic get clientId(): string {\n\t\treturn this.details.clientId;\n\t}\n\n\tpublic get mode(): ConnectionMode {\n\t\treturn this.details.mode;\n\t}\n\n\tpublic get claims(): ITokenClaims {\n\t\treturn this.details.claims;\n\t}\n\n\tpublic get existing(): boolean {\n\t\treturn this.details.existing;\n\t}\n\n\tpublic get version(): string {\n\t\treturn this.details.version;\n\t}\n\n\tpublic get initialMessages(): ISequencedDocumentMessage[] {\n\t\treturn this.details.initialMessages;\n\t}\n\n\tpublic get initialSignals(): ISignalMessage[] {\n\t\treturn this.details.initialSignals;\n\t}\n\n\tpublic get initialClients(): ISignalClient[] {\n\t\treturn this.details.initialClients;\n\t}\n\n\tpublic get serviceConfiguration(): IClientConfiguration {\n\t\treturn this.details.serviceConfiguration;\n\t}\n\n\tpublic readonly maxMessageSize = ReplayDocumentDeltaConnection.ReplayMaxMessageSize;\n\n\tconstructor(public details: IConnected) {\n\t\tsuper();\n\t}\n\n\tpublic submit(documentMessage: IDocumentMessage[]): void {\n\t\t// ReplayDocumentDeltaConnection.submit() can't be called - client never sees its own join on,\n\t\t// and thus can never move to sending ops.\n\t\tthrow new Error(\"ReplayDocumentDeltaConnection.submit() can't be called\");\n\t}\n\n\tpublic async submitSignal(message: any) {}\n\n\tprivate _disposed = false;\n\tpublic get disposed() {\n\t\treturn this._disposed;\n\t}\n\tpublic dispose() {\n\t\tthis._disposed = true;\n\t}\n\n\t/**\n\t * This gets the specified ops from the delta storage endpoint and replays them in the replayer.\n\t */\n\tprivate async fetchAndEmitOps(\n\t\tdocumentStorageService: IDocumentDeltaStorageService,\n\t\tcontroller: ReplayController,\n\t): Promise<void> {\n\t\tlet done;\n\t\tlet replayPromiseChain = Promise.resolve();\n\n\t\tlet currentOp = await controller.getStartingOpSequence();\n\n\t\tdo {\n\t\t\tconst fetchTo = controller.fetchTo(currentOp);\n\n\t\t\tconst abortController = new AbortController();\n\t\t\tconst stream = documentStorageService.fetchMessages(\n\t\t\t\tcurrentOp + 1,\n\t\t\t\tfetchTo,\n\t\t\t\tabortController.signal,\n\t\t\t);\n\t\t\tdo {\n\t\t\t\tconst result = await stream.read();\n\n\t\t\t\tif (result.done) {\n\t\t\t\t\t// No more ops. But, they can show up later, either because document was just created,\n\t\t\t\t\t// or because another client keeps submitting new ops.\n\t\t\t\t\tdone = controller.isDoneFetch(currentOp, undefined);\n\t\t\t\t\tif (!done) {\n\t\t\t\t\t\tawait delay(2000);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\treplayPromiseChain = replayPromiseChain.then(async () =>\n\t\t\t\t\tcontroller.replay((ops) => this.emit(\"op\", ReplayDocumentId, ops), messages),\n\t\t\t\t);\n\n\t\t\t\tconst messages = result.value;\n\t\t\t\tcurrentOp += messages.length;\n\t\t\t\tdone = controller.isDoneFetch(currentOp, messages[messages.length - 1].timestamp);\n\t\t\t} while (!done);\n\n\t\t\tabortController.abort();\n\t\t} while (!done);\n\t\treturn replayPromiseChain;\n\t}\n}\n"]}
|
package/lib/tsdoc-metadata.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/replay-driver",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0-294316",
|
|
4
4
|
"description": "Document replay version of Socket.IO implementation",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -37,22 +37,22 @@
|
|
|
37
37
|
"main": "lib/index.js",
|
|
38
38
|
"types": "lib/public.d.ts",
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@fluid-internal/client-utils": "2.
|
|
41
|
-
"@fluidframework/core-interfaces": "2.
|
|
42
|
-
"@fluidframework/core-utils": "2.
|
|
43
|
-
"@fluidframework/driver-definitions": "2.
|
|
44
|
-
"@fluidframework/driver-utils": "2.
|
|
45
|
-
"@fluidframework/telemetry-utils": "2.
|
|
40
|
+
"@fluid-internal/client-utils": "2.4.0-294316",
|
|
41
|
+
"@fluidframework/core-interfaces": "2.4.0-294316",
|
|
42
|
+
"@fluidframework/core-utils": "2.4.0-294316",
|
|
43
|
+
"@fluidframework/driver-definitions": "2.4.0-294316",
|
|
44
|
+
"@fluidframework/driver-utils": "2.4.0-294316",
|
|
45
|
+
"@fluidframework/telemetry-utils": "2.4.0-294316"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@arethetypeswrong/cli": "^0.15.2",
|
|
49
49
|
"@biomejs/biome": "~1.8.3",
|
|
50
|
-
"@fluid-tools/build-cli": "^0.
|
|
50
|
+
"@fluid-tools/build-cli": "^0.46.0",
|
|
51
51
|
"@fluidframework/build-common": "^2.0.3",
|
|
52
|
-
"@fluidframework/build-tools": "^0.
|
|
53
|
-
"@fluidframework/eslint-config-fluid": "^5.
|
|
54
|
-
"@fluidframework/replay-driver-previous": "npm:@fluidframework/replay-driver@2.
|
|
55
|
-
"@microsoft/api-extractor": "
|
|
52
|
+
"@fluidframework/build-tools": "^0.46.0",
|
|
53
|
+
"@fluidframework/eslint-config-fluid": "^5.4.0",
|
|
54
|
+
"@fluidframework/replay-driver-previous": "npm:@fluidframework/replay-driver@2.3.0",
|
|
55
|
+
"@microsoft/api-extractor": "7.47.8",
|
|
56
56
|
"@types/nock": "^9.3.0",
|
|
57
57
|
"@types/node": "^18.19.0",
|
|
58
58
|
"concurrently": "^8.2.1",
|
|
@@ -65,13 +65,19 @@
|
|
|
65
65
|
},
|
|
66
66
|
"fluidBuild": {
|
|
67
67
|
"tasks": {
|
|
68
|
+
"build:esnext": [
|
|
69
|
+
"...",
|
|
70
|
+
"typetests:gen"
|
|
71
|
+
],
|
|
68
72
|
"tsc": [
|
|
73
|
+
"...",
|
|
69
74
|
"typetests:gen"
|
|
70
75
|
]
|
|
71
76
|
}
|
|
72
77
|
},
|
|
73
78
|
"typeValidation": {
|
|
74
|
-
"broken": {}
|
|
79
|
+
"broken": {},
|
|
80
|
+
"entrypoint": "internal"
|
|
75
81
|
},
|
|
76
82
|
"scripts": {
|
|
77
83
|
"api": "fluid-build . --task api",
|
|
@@ -101,9 +101,7 @@ export class ReplayControllerStatic extends ReplayController {
|
|
|
101
101
|
}
|
|
102
102
|
if (this.unitIsTime === true) {
|
|
103
103
|
for (let i = 0; i < fetchedOps.length; i += 1) {
|
|
104
|
-
|
|
105
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
106
|
-
const timeStamp = fetchedOps[i]!.timestamp;
|
|
104
|
+
const timeStamp = fetchedOps[i].timestamp;
|
|
107
105
|
if (timeStamp !== undefined) {
|
|
108
106
|
if (this.firstTimeStamp === undefined) {
|
|
109
107
|
this.firstTimeStamp = timeStamp;
|
|
@@ -129,9 +127,7 @@ export class ReplayControllerStatic extends ReplayController {
|
|
|
129
127
|
const replayNextOps = () => {
|
|
130
128
|
// Emit the ops from replay to the end every "deltainterval" milliseconds
|
|
131
129
|
// to simulate the socket stream
|
|
132
|
-
|
|
133
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
134
|
-
const currentOp = fetchedOps[current]!;
|
|
130
|
+
const currentOp = fetchedOps[current];
|
|
135
131
|
const playbackOps = [currentOp];
|
|
136
132
|
let nextInterval = ReplayControllerStatic.DelayInterval;
|
|
137
133
|
current += 1;
|
|
@@ -142,9 +138,7 @@ export class ReplayControllerStatic extends ReplayController {
|
|
|
142
138
|
// Emit more ops that is in the ReplayResolution window
|
|
143
139
|
|
|
144
140
|
while (current < fetchedOps.length) {
|
|
145
|
-
|
|
146
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
147
|
-
const op = fetchedOps[current]!;
|
|
141
|
+
const op = fetchedOps[current];
|
|
148
142
|
if (op.timestamp === undefined) {
|
|
149
143
|
// Missing timestamp, just delay the standard amount of time
|
|
150
144
|
break;
|
|
@@ -339,9 +333,7 @@ export class ReplayDocumentDeltaConnection
|
|
|
339
333
|
|
|
340
334
|
const messages = result.value;
|
|
341
335
|
currentOp += messages.length;
|
|
342
|
-
|
|
343
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
344
|
-
done = controller.isDoneFetch(currentOp, messages[messages.length - 1]!.timestamp);
|
|
336
|
+
done = controller.isDoneFetch(currentOp, messages[messages.length - 1].timestamp);
|
|
345
337
|
} while (!done);
|
|
346
338
|
|
|
347
339
|
abortController.abort();
|