@fluidframework/odsp-driver 1.4.0-121020 → 2.0.0-dev-rc.1.0.0.225277
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 +12 -12
- package/.mocharc.js +12 -0
- package/CHANGELOG.md +162 -0
- package/README.md +56 -0
- package/api-extractor-esm.json +4 -0
- package/api-extractor-lint.json +4 -0
- package/api-extractor.json +2 -2
- package/api-report/odsp-driver.api.md +309 -0
- package/dist/{ReadBufferUtils.js → ReadBufferUtils.cjs} +16 -9
- package/dist/ReadBufferUtils.cjs.map +1 -0
- package/dist/ReadBufferUtils.d.ts.map +1 -1
- package/dist/{WriteBufferUtils.js → WriteBufferUtils.cjs} +73 -69
- package/dist/WriteBufferUtils.cjs.map +1 -0
- package/dist/WriteBufferUtils.d.ts +3 -5
- package/dist/WriteBufferUtils.d.ts.map +1 -1
- package/dist/{checkUrl.js → checkUrl.cjs} +7 -6
- package/dist/checkUrl.cjs.map +1 -0
- package/dist/checkUrl.d.ts +1 -0
- package/dist/checkUrl.d.ts.map +1 -1
- package/dist/compactSnapshotParser.cjs +207 -0
- package/dist/compactSnapshotParser.cjs.map +1 -0
- package/dist/compactSnapshotParser.d.ts +12 -3
- package/dist/compactSnapshotParser.d.ts.map +1 -1
- package/dist/{compactSnapshotWriter.js → compactSnapshotWriter.cjs} +43 -33
- package/dist/compactSnapshotWriter.cjs.map +1 -0
- package/dist/compactSnapshotWriter.d.ts +2 -3
- package/dist/compactSnapshotWriter.d.ts.map +1 -1
- package/dist/{constants.js → constants.cjs} +7 -1
- package/dist/constants.cjs.map +1 -0
- package/dist/constants.d.ts +6 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/{contracts.js → contracts.cjs} +1 -1
- package/dist/contracts.cjs.map +1 -0
- package/dist/contracts.d.ts +16 -53
- package/dist/contracts.d.ts.map +1 -1
- package/dist/{contractsPublic.js → contractsPublic.cjs} +9 -3
- package/dist/contractsPublic.cjs.map +1 -0
- package/dist/contractsPublic.d.ts +15 -0
- package/dist/contractsPublic.d.ts.map +1 -1
- package/dist/createFile.cjs +177 -0
- package/dist/createFile.cjs.map +1 -0
- package/dist/createFile.d.ts +6 -10
- package/dist/createFile.d.ts.map +1 -1
- package/dist/createNewContainerOnExistingFile.cjs +60 -0
- package/dist/createNewContainerOnExistingFile.cjs.map +1 -0
- package/dist/createNewContainerOnExistingFile.d.ts +22 -0
- package/dist/createNewContainerOnExistingFile.d.ts.map +1 -0
- package/dist/createNewModule.cjs +12 -0
- package/dist/createNewModule.cjs.map +1 -0
- package/dist/createNewModule.d.ts +7 -0
- package/dist/createNewModule.d.ts.map +1 -0
- package/dist/createNewUtils.cjs +203 -0
- package/dist/createNewUtils.cjs.map +1 -0
- package/dist/createNewUtils.d.ts +16 -0
- package/dist/createNewUtils.d.ts.map +1 -1
- package/dist/{createOdspCreateContainerRequest.js → createOdspCreateContainerRequest.cjs} +8 -4
- package/dist/createOdspCreateContainerRequest.cjs.map +1 -0
- package/dist/createOdspCreateContainerRequest.d.ts +5 -3
- package/dist/createOdspCreateContainerRequest.d.ts.map +1 -1
- package/dist/{createOdspUrl.js → createOdspUrl.cjs} +2 -1
- package/dist/createOdspUrl.cjs.map +1 -0
- package/dist/createOdspUrl.d.ts +1 -0
- package/dist/createOdspUrl.d.ts.map +1 -1
- package/dist/{epochTracker.js → epochTracker.cjs} +102 -48
- package/dist/epochTracker.cjs.map +1 -0
- package/dist/epochTracker.d.ts +32 -8
- package/dist/epochTracker.d.ts.map +1 -1
- package/dist/{fetch.js → fetch.cjs} +1 -1
- package/dist/fetch.cjs.map +1 -0
- package/dist/fetch.d.ts +1 -1
- package/dist/fetch.d.ts.map +1 -1
- package/dist/{fetchSnapshot.js → fetchSnapshot.cjs} +192 -176
- package/dist/fetchSnapshot.cjs.map +1 -0
- package/dist/fetchSnapshot.d.ts +10 -5
- package/dist/fetchSnapshot.d.ts.map +1 -1
- package/dist/{getFileLink.js → getFileLink.cjs} +52 -41
- package/dist/getFileLink.cjs.map +1 -0
- package/dist/getFileLink.d.ts +4 -7
- package/dist/getFileLink.d.ts.map +1 -1
- package/dist/{getQueryString.js → getQueryString.cjs} +1 -1
- package/dist/getQueryString.cjs.map +1 -0
- package/dist/getQueryString.d.ts.map +1 -1
- package/dist/{getUrlAndHeadersWithAuth.js → getUrlAndHeadersWithAuth.cjs} +4 -2
- package/dist/getUrlAndHeadersWithAuth.cjs.map +1 -0
- package/dist/getUrlAndHeadersWithAuth.d.ts.map +1 -1
- package/dist/index.cjs +59 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +19 -16
- package/dist/index.d.ts.map +1 -1
- package/dist/localOdspDriver/localOdspDeltaStorageService.cjs +35 -0
- package/dist/localOdspDriver/localOdspDeltaStorageService.cjs.map +1 -0
- package/dist/localOdspDriver/localOdspDeltaStorageService.d.ts +17 -0
- package/dist/localOdspDriver/localOdspDeltaStorageService.d.ts.map +1 -0
- package/dist/localOdspDriver/{localOdspDocumentService.js → localOdspDocumentService.cjs} +7 -5
- package/dist/localOdspDriver/localOdspDocumentService.cjs.map +1 -0
- package/dist/localOdspDriver/localOdspDocumentService.d.ts +3 -2
- package/dist/localOdspDriver/localOdspDocumentService.d.ts.map +1 -1
- package/dist/localOdspDriver/{localOdspDocumentServiceFactory.js → localOdspDocumentServiceFactory.cjs} +9 -10
- package/dist/localOdspDriver/localOdspDocumentServiceFactory.cjs.map +1 -0
- package/dist/localOdspDriver/localOdspDocumentServiceFactory.d.ts +2 -3
- package/dist/localOdspDriver/localOdspDocumentServiceFactory.d.ts.map +1 -1
- package/dist/localOdspDriver/{localOdspDocumentStorageManager.js → localOdspDocumentStorageManager.cjs} +13 -11
- package/dist/localOdspDriver/localOdspDocumentStorageManager.cjs.map +1 -0
- package/dist/localOdspDriver/localOdspDocumentStorageManager.d.ts +2 -2
- package/dist/localOdspDriver/localOdspDocumentStorageManager.d.ts.map +1 -1
- package/dist/odsp-driver-alpha.d.ts +496 -0
- package/dist/odsp-driver-beta.d.ts +160 -0
- package/dist/odsp-driver-public.d.ts +160 -0
- package/dist/odsp-driver-untrimmed.d.ts +565 -0
- package/dist/{odspCache.js → odspCache.cjs} +9 -10
- package/dist/odspCache.cjs.map +1 -0
- package/dist/odspCache.d.ts +19 -4
- package/dist/odspCache.d.ts.map +1 -1
- package/dist/odspDelayLoadedDeltaStream.cjs +291 -0
- package/dist/odspDelayLoadedDeltaStream.cjs.map +1 -0
- package/dist/odspDelayLoadedDeltaStream.d.ts +75 -0
- package/dist/odspDelayLoadedDeltaStream.d.ts.map +1 -0
- package/dist/{odspDeltaStorageService.js → odspDeltaStorageService.cjs} +70 -71
- package/dist/odspDeltaStorageService.cjs.map +1 -0
- package/dist/odspDeltaStorageService.d.ts +8 -6
- package/dist/odspDeltaStorageService.d.ts.map +1 -1
- package/dist/{odspDocumentDeltaConnection.js → odspDocumentDeltaConnection.cjs} +224 -113
- package/dist/odspDocumentDeltaConnection.cjs.map +1 -0
- package/dist/odspDocumentDeltaConnection.d.ts +32 -12
- package/dist/odspDocumentDeltaConnection.d.ts.map +1 -1
- package/dist/odspDocumentService.cjs +225 -0
- package/dist/odspDocumentService.cjs.map +1 -0
- package/dist/odspDocumentService.d.ts +11 -25
- package/dist/odspDocumentService.d.ts.map +1 -1
- package/dist/{odspDocumentServiceFactory.js → odspDocumentServiceFactory.cjs} +8 -5
- package/dist/odspDocumentServiceFactory.cjs.map +1 -0
- package/dist/odspDocumentServiceFactory.d.ts +4 -0
- package/dist/odspDocumentServiceFactory.d.ts.map +1 -1
- package/dist/odspDocumentServiceFactoryCore.cjs +196 -0
- package/dist/odspDocumentServiceFactoryCore.cjs.map +1 -0
- package/dist/odspDocumentServiceFactoryCore.d.ts +18 -11
- package/dist/odspDocumentServiceFactoryCore.d.ts.map +1 -1
- package/dist/odspDocumentServiceFactoryWithCodeSplit.cjs +20 -0
- package/dist/odspDocumentServiceFactoryWithCodeSplit.cjs.map +1 -0
- package/dist/odspDocumentServiceFactoryWithCodeSplit.d.ts +5 -0
- package/dist/odspDocumentServiceFactoryWithCodeSplit.d.ts.map +1 -1
- package/dist/odspDocumentStorageManager.cjs +490 -0
- package/dist/odspDocumentStorageManager.cjs.map +1 -0
- package/dist/odspDocumentStorageManager.d.ts +11 -5
- package/dist/odspDocumentStorageManager.d.ts.map +1 -1
- package/dist/{odspDocumentStorageServiceBase.js → odspDocumentStorageServiceBase.cjs} +32 -34
- package/dist/odspDocumentStorageServiceBase.cjs.map +1 -0
- package/dist/odspDocumentStorageServiceBase.d.ts +7 -9
- package/dist/odspDocumentStorageServiceBase.d.ts.map +1 -1
- package/dist/{odspDriverUrlResolver.js → odspDriverUrlResolver.cjs} +50 -36
- package/dist/odspDriverUrlResolver.cjs.map +1 -0
- package/dist/odspDriverUrlResolver.d.ts +12 -0
- package/dist/odspDriverUrlResolver.d.ts.map +1 -1
- package/dist/{odspDriverUrlResolverForShareLink.js → odspDriverUrlResolverForShareLink.cjs} +37 -26
- package/dist/odspDriverUrlResolverForShareLink.cjs.map +1 -0
- package/dist/odspDriverUrlResolverForShareLink.d.ts +5 -3
- package/dist/odspDriverUrlResolverForShareLink.d.ts.map +1 -1
- package/dist/{odspError.js → odspError.cjs} +7 -3
- package/dist/odspError.cjs.map +1 -0
- package/dist/odspError.d.ts.map +1 -1
- package/dist/{odspFluidFileLink.js → odspFluidFileLink.cjs} +25 -18
- package/dist/odspFluidFileLink.cjs.map +1 -0
- package/dist/odspFluidFileLink.d.ts +10 -1
- package/dist/odspFluidFileLink.d.ts.map +1 -1
- package/dist/odspLocationRedirection.cjs +24 -0
- package/dist/odspLocationRedirection.cjs.map +1 -0
- package/dist/odspLocationRedirection.d.ts +14 -0
- package/dist/odspLocationRedirection.d.ts.map +1 -0
- package/dist/{odspPublicUtils.js → odspPublicUtils.cjs} +7 -4
- package/dist/odspPublicUtils.cjs.map +1 -0
- package/dist/odspPublicUtils.d.ts +6 -0
- package/dist/odspPublicUtils.d.ts.map +1 -1
- package/dist/{odspSnapshotParser.js → odspSnapshotParser.cjs} +11 -12
- package/dist/odspSnapshotParser.cjs.map +1 -0
- package/dist/odspSnapshotParser.d.ts.map +1 -1
- package/dist/{odspSummaryUploadManager.js → odspSummaryUploadManager.cjs} +47 -34
- package/dist/odspSummaryUploadManager.cjs.map +1 -0
- package/dist/odspSummaryUploadManager.d.ts +7 -4
- package/dist/odspSummaryUploadManager.d.ts.map +1 -1
- package/dist/{odspUrlHelper.js → odspUrlHelper.cjs} +9 -3
- package/dist/odspUrlHelper.cjs.map +1 -0
- package/dist/odspUrlHelper.d.ts +5 -0
- package/dist/odspUrlHelper.d.ts.map +1 -1
- package/dist/{odspUtils.js → odspUtils.cjs} +118 -30
- package/dist/odspUtils.cjs.map +1 -0
- package/dist/odspUtils.d.ts +35 -6
- package/dist/odspUtils.d.ts.map +1 -1
- package/dist/{opsCaching.js → opsCaching.cjs} +25 -9
- package/dist/opsCaching.cjs.map +1 -0
- package/dist/opsCaching.d.ts +3 -3
- package/dist/opsCaching.d.ts.map +1 -1
- package/dist/{packageVersion.js → packageVersion.cjs} +2 -2
- package/dist/packageVersion.cjs.map +1 -0
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/prefetchLatestSnapshot.cjs +100 -0
- package/dist/prefetchLatestSnapshot.cjs.map +1 -0
- package/dist/prefetchLatestSnapshot.d.ts +12 -7
- package/dist/prefetchLatestSnapshot.d.ts.map +1 -1
- package/dist/{retryErrorsStorageAdapter.js → retryErrorsStorageAdapter.cjs} +13 -6
- package/dist/retryErrorsStorageAdapter.cjs.map +1 -0
- package/dist/retryErrorsStorageAdapter.d.ts +5 -4
- package/dist/retryErrorsStorageAdapter.d.ts.map +1 -1
- package/dist/{retryUtils.js → retryUtils.cjs} +30 -14
- package/dist/retryUtils.cjs.map +1 -0
- package/dist/retryUtils.d.ts +2 -2
- package/dist/retryUtils.d.ts.map +1 -1
- package/dist/socketModule.cjs +10 -0
- package/dist/socketModule.cjs.map +1 -0
- package/dist/socketModule.d.ts +7 -0
- package/dist/socketModule.d.ts.map +1 -0
- package/dist/tsdoc-metadata.json +11 -0
- package/dist/{vroom.js → vroom.cjs} +24 -9
- package/dist/vroom.cjs.map +1 -0
- package/dist/vroom.d.ts +4 -4
- package/dist/vroom.d.ts.map +1 -1
- package/dist/{zipItDataRepresentationUtils.js → zipItDataRepresentationUtils.cjs} +227 -118
- package/dist/zipItDataRepresentationUtils.cjs.map +1 -0
- package/dist/zipItDataRepresentationUtils.d.ts +47 -20
- package/dist/zipItDataRepresentationUtils.d.ts.map +1 -1
- package/lib/{ReadBufferUtils.d.ts → ReadBufferUtils.d.mts} +1 -1
- package/lib/ReadBufferUtils.d.mts.map +1 -0
- package/lib/{ReadBufferUtils.js → ReadBufferUtils.mjs} +14 -7
- package/lib/ReadBufferUtils.mjs.map +1 -0
- package/lib/{WriteBufferUtils.d.ts → WriteBufferUtils.d.mts} +4 -6
- package/lib/WriteBufferUtils.d.mts.map +1 -0
- package/lib/{WriteBufferUtils.js → WriteBufferUtils.mjs} +68 -64
- package/lib/WriteBufferUtils.mjs.map +1 -0
- package/lib/{checkUrl.d.ts → checkUrl.d.mts} +2 -1
- package/lib/checkUrl.d.mts.map +1 -0
- package/lib/{checkUrl.js → checkUrl.mjs} +7 -6
- package/lib/checkUrl.mjs.map +1 -0
- package/lib/compactSnapshotParser.d.mts +24 -0
- package/lib/compactSnapshotParser.d.mts.map +1 -0
- package/lib/compactSnapshotParser.mjs +203 -0
- package/lib/compactSnapshotParser.mjs.map +1 -0
- package/lib/{compactSnapshotWriter.d.ts → compactSnapshotWriter.d.mts} +4 -5
- package/lib/compactSnapshotWriter.d.mts.map +1 -0
- package/lib/{compactSnapshotWriter.js → compactSnapshotWriter.mjs} +41 -31
- package/lib/compactSnapshotWriter.mjs.map +1 -0
- package/lib/{constants.d.ts → constants.d.mts} +7 -1
- package/lib/constants.d.mts.map +1 -0
- package/lib/{constants.js → constants.mjs} +7 -1
- package/lib/constants.mjs.map +1 -0
- package/lib/{contracts.d.ts → contracts.d.mts} +18 -55
- package/lib/contracts.d.mts.map +1 -0
- package/lib/{contracts.js → contracts.mjs} +1 -1
- package/lib/contracts.mjs.map +1 -0
- package/lib/{contractsPublic.d.ts → contractsPublic.d.mts} +16 -1
- package/lib/contractsPublic.d.mts.map +1 -0
- package/lib/{contractsPublic.js → contractsPublic.mjs} +7 -1
- package/lib/contractsPublic.mjs.map +1 -0
- package/lib/createFile.d.mts +18 -0
- package/lib/createFile.d.mts.map +1 -0
- package/lib/createFile.mjs +171 -0
- package/lib/createFile.mjs.map +1 -0
- package/lib/createNewContainerOnExistingFile.d.mts +22 -0
- package/lib/createNewContainerOnExistingFile.d.mts.map +1 -0
- package/lib/createNewContainerOnExistingFile.mjs +56 -0
- package/lib/createNewContainerOnExistingFile.mjs.map +1 -0
- package/lib/createNewModule.d.mts +7 -0
- package/lib/createNewModule.d.mts.map +1 -0
- package/lib/createNewModule.mjs +7 -0
- package/lib/createNewModule.mjs.map +1 -0
- package/lib/createNewUtils.d.mts +27 -0
- package/lib/createNewUtils.d.mts.map +1 -0
- package/lib/createNewUtils.mjs +197 -0
- package/lib/createNewUtils.mjs.map +1 -0
- package/lib/{createOdspCreateContainerRequest.d.ts → createOdspCreateContainerRequest.d.mts} +6 -8
- package/lib/createOdspCreateContainerRequest.d.mts.map +1 -0
- package/lib/{createOdspCreateContainerRequest.js → createOdspCreateContainerRequest.mjs} +8 -4
- package/lib/createOdspCreateContainerRequest.mjs.map +1 -0
- package/lib/{createOdspUrl.d.ts → createOdspUrl.d.mts} +3 -2
- package/lib/createOdspUrl.d.mts.map +1 -0
- package/lib/{createOdspUrl.js → createOdspUrl.mjs} +2 -1
- package/lib/createOdspUrl.mjs.map +1 -0
- package/lib/{epochTracker.d.ts → epochTracker.d.mts} +35 -11
- package/lib/epochTracker.d.mts.map +1 -0
- package/lib/{epochTracker.js → epochTracker.mjs} +97 -43
- package/lib/epochTracker.mjs.map +1 -0
- package/lib/{fetch.d.ts → fetch.d.mts} +2 -2
- package/lib/fetch.d.mts.map +1 -0
- package/lib/{fetch.js → fetch.mjs} +1 -1
- package/lib/fetch.mjs.map +1 -0
- package/lib/{fetchSnapshot.d.ts → fetchSnapshot.d.mts} +15 -10
- package/lib/fetchSnapshot.d.mts.map +1 -0
- package/lib/{fetchSnapshot.js → fetchSnapshot.mjs} +185 -167
- package/lib/fetchSnapshot.mjs.map +1 -0
- package/lib/{getFileLink.d.ts → getFileLink.d.mts} +5 -8
- package/lib/getFileLink.d.mts.map +1 -0
- package/lib/{getFileLink.js → getFileLink.mjs} +49 -38
- package/lib/getFileLink.mjs.map +1 -0
- package/lib/{getQueryString.d.ts → getQueryString.d.mts} +1 -5
- package/lib/getQueryString.d.mts.map +1 -0
- package/lib/{getQueryString.js → getQueryString.mjs} +1 -1
- package/lib/getQueryString.mjs.map +1 -0
- package/lib/{getUrlAndHeadersWithAuth.d.ts → getUrlAndHeadersWithAuth.d.mts} +1 -1
- package/lib/getUrlAndHeadersWithAuth.d.mts.map +1 -0
- package/lib/{getUrlAndHeadersWithAuth.js → getUrlAndHeadersWithAuth.mjs} +4 -2
- package/lib/getUrlAndHeadersWithAuth.mjs.map +1 -0
- package/lib/index.d.mts +24 -0
- package/lib/index.d.mts.map +1 -0
- package/lib/index.mjs +22 -0
- package/lib/index.mjs.map +1 -0
- package/lib/localOdspDriver/localOdspDeltaStorageService.d.mts +17 -0
- package/lib/localOdspDriver/localOdspDeltaStorageService.d.mts.map +1 -0
- package/lib/localOdspDriver/localOdspDeltaStorageService.mjs +31 -0
- package/lib/localOdspDriver/localOdspDeltaStorageService.mjs.map +1 -0
- package/lib/localOdspDriver/{localOdspDocumentService.d.ts → localOdspDocumentService.d.mts} +4 -3
- package/lib/localOdspDriver/localOdspDocumentService.d.mts.map +1 -0
- package/lib/localOdspDriver/{localOdspDocumentService.js → localOdspDocumentService.mjs} +8 -6
- package/lib/localOdspDriver/localOdspDocumentService.mjs.map +1 -0
- package/lib/localOdspDriver/{localOdspDocumentServiceFactory.d.ts → localOdspDocumentServiceFactory.d.mts} +5 -6
- package/lib/localOdspDriver/localOdspDocumentServiceFactory.d.mts.map +1 -0
- package/lib/localOdspDriver/{localOdspDocumentServiceFactory.js → localOdspDocumentServiceFactory.mjs} +9 -10
- package/lib/localOdspDriver/localOdspDocumentServiceFactory.mjs.map +1 -0
- package/lib/localOdspDriver/{localOdspDocumentStorageManager.d.ts → localOdspDocumentStorageManager.d.mts} +4 -4
- package/lib/localOdspDriver/localOdspDocumentStorageManager.d.mts.map +1 -0
- package/lib/localOdspDriver/{localOdspDocumentStorageManager.js → localOdspDocumentStorageManager.mjs} +11 -9
- package/lib/localOdspDriver/localOdspDocumentStorageManager.mjs.map +1 -0
- package/lib/odsp-driver-alpha.d.mts +496 -0
- package/lib/odsp-driver-beta.d.mts +160 -0
- package/lib/odsp-driver-public.d.mts +160 -0
- package/lib/odsp-driver-untrimmed.d.mts +565 -0
- package/lib/{odspCache.d.ts → odspCache.d.mts} +20 -9
- package/lib/odspCache.d.mts.map +1 -0
- package/lib/{odspCache.js → odspCache.mjs} +6 -11
- package/lib/odspCache.mjs.map +1 -0
- package/lib/odspDelayLoadedDeltaStream.d.mts +75 -0
- package/lib/odspDelayLoadedDeltaStream.d.mts.map +1 -0
- package/lib/odspDelayLoadedDeltaStream.mjs +287 -0
- package/lib/odspDelayLoadedDeltaStream.mjs.map +1 -0
- package/lib/{odspDeltaStorageService.d.ts → odspDeltaStorageService.d.mts} +10 -8
- package/lib/odspDeltaStorageService.d.mts.map +1 -0
- package/lib/{odspDeltaStorageService.js → odspDeltaStorageService.mjs} +70 -68
- package/lib/odspDeltaStorageService.mjs.map +1 -0
- package/lib/{odspDocumentDeltaConnection.d.ts → odspDocumentDeltaConnection.d.mts} +34 -14
- package/lib/odspDocumentDeltaConnection.d.mts.map +1 -0
- package/lib/{odspDocumentDeltaConnection.js → odspDocumentDeltaConnection.mjs} +214 -103
- package/lib/odspDocumentDeltaConnection.mjs.map +1 -0
- package/lib/{odspDocumentService.d.ts → odspDocumentService.d.mts} +15 -29
- package/lib/odspDocumentService.d.mts.map +1 -0
- package/lib/odspDocumentService.mjs +221 -0
- package/lib/odspDocumentService.mjs.map +1 -0
- package/lib/{odspDocumentServiceFactory.d.ts → odspDocumentServiceFactory.d.mts} +6 -2
- package/lib/odspDocumentServiceFactory.d.mts.map +1 -0
- package/lib/{odspDocumentServiceFactory.js → odspDocumentServiceFactory.mjs} +8 -6
- package/lib/odspDocumentServiceFactory.mjs.map +1 -0
- package/lib/{odspDocumentServiceFactoryCore.d.ts → odspDocumentServiceFactoryCore.d.mts} +20 -13
- package/lib/odspDocumentServiceFactoryCore.d.mts.map +1 -0
- package/lib/odspDocumentServiceFactoryCore.mjs +192 -0
- package/lib/odspDocumentServiceFactoryCore.mjs.map +1 -0
- package/lib/{odspDocumentServiceFactoryWithCodeSplit.d.ts → odspDocumentServiceFactoryWithCodeSplit.d.mts} +7 -2
- package/lib/odspDocumentServiceFactoryWithCodeSplit.d.mts.map +1 -0
- package/lib/{odspDocumentServiceFactoryWithCodeSplit.js → odspDocumentServiceFactoryWithCodeSplit.mjs} +8 -3
- package/lib/odspDocumentServiceFactoryWithCodeSplit.mjs.map +1 -0
- package/lib/{odspDocumentStorageManager.d.ts → odspDocumentStorageManager.d.mts} +18 -12
- package/lib/odspDocumentStorageManager.d.mts.map +1 -0
- package/lib/odspDocumentStorageManager.mjs +486 -0
- package/lib/odspDocumentStorageManager.mjs.map +1 -0
- package/lib/{odspDocumentStorageServiceBase.d.ts → odspDocumentStorageServiceBase.d.mts} +9 -11
- package/lib/odspDocumentStorageServiceBase.d.mts.map +1 -0
- package/lib/{odspDocumentStorageServiceBase.js → odspDocumentStorageServiceBase.mjs} +31 -33
- package/lib/odspDocumentStorageServiceBase.mjs.map +1 -0
- package/lib/{odspDriverUrlResolver.d.ts → odspDriverUrlResolver.d.mts} +13 -1
- package/lib/odspDriverUrlResolver.d.mts.map +1 -0
- package/lib/{odspDriverUrlResolver.js → odspDriverUrlResolver.mjs} +50 -40
- package/lib/odspDriverUrlResolver.mjs.map +1 -0
- package/lib/{odspDriverUrlResolverForShareLink.d.ts → odspDriverUrlResolverForShareLink.d.mts} +7 -5
- package/lib/odspDriverUrlResolverForShareLink.d.mts.map +1 -0
- package/lib/{odspDriverUrlResolverForShareLink.js → odspDriverUrlResolverForShareLink.mjs} +36 -29
- package/lib/odspDriverUrlResolverForShareLink.mjs.map +1 -0
- package/lib/{odspError.d.ts → odspError.d.mts} +2 -2
- package/lib/odspError.d.mts.map +1 -0
- package/lib/{odspError.js → odspError.mjs} +7 -3
- package/lib/odspError.mjs.map +1 -0
- package/lib/{odspFluidFileLink.d.ts → odspFluidFileLink.d.mts} +12 -3
- package/lib/odspFluidFileLink.d.mts.map +1 -0
- package/lib/{odspFluidFileLink.js → odspFluidFileLink.mjs} +23 -16
- package/lib/odspFluidFileLink.mjs.map +1 -0
- package/lib/odspLocationRedirection.d.mts +14 -0
- package/lib/odspLocationRedirection.d.mts.map +1 -0
- package/lib/odspLocationRedirection.mjs +20 -0
- package/lib/odspLocationRedirection.mjs.map +1 -0
- package/lib/{odspPublicUtils.d.ts → odspPublicUtils.d.mts} +7 -1
- package/lib/odspPublicUtils.d.mts.map +1 -0
- package/lib/{odspPublicUtils.js → odspPublicUtils.mjs} +5 -2
- package/lib/odspPublicUtils.mjs.map +1 -0
- package/lib/{odspSnapshotParser.d.ts → odspSnapshotParser.d.mts} +3 -3
- package/lib/odspSnapshotParser.d.mts.map +1 -0
- package/lib/{odspSnapshotParser.js → odspSnapshotParser.mjs} +10 -11
- package/lib/odspSnapshotParser.mjs.map +1 -0
- package/lib/{odspSummaryUploadManager.d.ts → odspSummaryUploadManager.d.mts} +9 -6
- package/lib/odspSummaryUploadManager.d.mts.map +1 -0
- package/lib/{odspSummaryUploadManager.js → odspSummaryUploadManager.mjs} +41 -32
- package/lib/odspSummaryUploadManager.mjs.map +1 -0
- package/lib/{odspUrlHelper.d.ts → odspUrlHelper.d.mts} +6 -1
- package/lib/odspUrlHelper.d.mts.map +1 -0
- package/lib/{odspUrlHelper.js → odspUrlHelper.mjs} +9 -3
- package/lib/odspUrlHelper.mjs.map +1 -0
- package/lib/{odspUtils.d.ts → odspUtils.d.mts} +37 -8
- package/lib/odspUtils.d.mts.map +1 -0
- package/lib/{odspUtils.js → odspUtils.mjs} +109 -27
- package/lib/odspUtils.mjs.map +1 -0
- package/lib/{opsCaching.d.ts → opsCaching.d.mts} +4 -4
- package/lib/opsCaching.d.mts.map +1 -0
- package/lib/{opsCaching.js → opsCaching.mjs} +23 -7
- package/lib/opsCaching.mjs.map +1 -0
- package/lib/{packageVersion.d.ts → packageVersion.d.mts} +2 -2
- package/lib/packageVersion.d.mts.map +1 -0
- package/lib/{packageVersion.js → packageVersion.mjs} +2 -2
- package/lib/packageVersion.mjs.map +1 -0
- package/lib/{prefetchLatestSnapshot.d.ts → prefetchLatestSnapshot.d.mts} +14 -9
- package/lib/prefetchLatestSnapshot.d.mts.map +1 -0
- package/lib/prefetchLatestSnapshot.mjs +96 -0
- package/lib/prefetchLatestSnapshot.mjs.map +1 -0
- package/lib/{retryErrorsStorageAdapter.d.ts → retryErrorsStorageAdapter.d.mts} +6 -5
- package/lib/retryErrorsStorageAdapter.d.mts.map +1 -0
- package/lib/{retryErrorsStorageAdapter.js → retryErrorsStorageAdapter.mjs} +13 -6
- package/lib/retryErrorsStorageAdapter.mjs.map +1 -0
- package/lib/{retryUtils.d.ts → retryUtils.d.mts} +3 -3
- package/lib/retryUtils.d.mts.map +1 -0
- package/lib/{retryUtils.js → retryUtils.mjs} +27 -11
- package/lib/retryUtils.mjs.map +1 -0
- package/lib/socketModule.d.mts +7 -0
- package/lib/socketModule.d.mts.map +1 -0
- package/lib/socketModule.mjs +7 -0
- package/lib/socketModule.mjs.map +1 -0
- package/lib/{vroom.d.ts → vroom.d.mts} +7 -7
- package/lib/vroom.d.mts.map +1 -0
- package/lib/{vroom.js → vroom.mjs} +24 -9
- package/lib/vroom.mjs.map +1 -0
- package/lib/{zipItDataRepresentationUtils.d.ts → zipItDataRepresentationUtils.d.mts} +49 -22
- package/lib/zipItDataRepresentationUtils.d.mts.map +1 -0
- package/lib/{zipItDataRepresentationUtils.js → zipItDataRepresentationUtils.mjs} +213 -111
- package/lib/zipItDataRepresentationUtils.mjs.map +1 -0
- package/package.json +87 -69
- package/prettier.config.cjs +8 -0
- package/src/ReadBufferUtils.ts +51 -44
- package/src/WriteBufferUtils.ts +203 -181
- package/src/checkUrl.ts +16 -15
- package/src/compactSnapshotParser.ts +219 -103
- package/src/compactSnapshotWriter.ts +118 -97
- package/src/constants.ts +7 -0
- package/src/contracts.ts +96 -136
- package/src/contractsPublic.ts +31 -16
- package/src/createFile.ts +243 -305
- package/src/createNewContainerOnExistingFile.ts +93 -0
- package/src/createNewModule.ts +7 -0
- package/src/createNewUtils.ts +266 -56
- package/src/createOdspCreateContainerRequest.ts +22 -18
- package/src/createOdspUrl.ts +12 -13
- package/src/epochTracker.ts +596 -457
- package/src/fetch.ts +4 -4
- package/src/fetchSnapshot.ts +583 -508
- package/src/getFileLink.ts +194 -155
- package/src/getQueryString.ts +11 -9
- package/src/getUrlAndHeadersWithAuth.ts +34 -33
- package/src/index.ts +42 -18
- package/src/localOdspDriver/localOdspDeltaStorageService.ts +49 -0
- package/src/localOdspDriver/localOdspDocumentService.ts +40 -38
- package/src/localOdspDriver/localOdspDocumentServiceFactory.ts +46 -43
- package/src/localOdspDriver/localOdspDocumentStorageManager.ts +55 -50
- package/src/odspCache.ts +112 -90
- package/src/odspDelayLoadedDeltaStream.ts +459 -0
- package/src/odspDeltaStorageService.ts +232 -221
- package/src/odspDocumentDeltaConnection.ts +751 -563
- package/src/odspDocumentService.ts +324 -523
- package/src/odspDocumentServiceFactory.ts +20 -21
- package/src/odspDocumentServiceFactoryCore.ts +329 -200
- package/src/odspDocumentServiceFactoryWithCodeSplit.ts +20 -20
- package/src/odspDocumentStorageManager.ts +730 -534
- package/src/odspDocumentStorageServiceBase.ts +279 -254
- package/src/odspDriverUrlResolver.ts +230 -188
- package/src/odspDriverUrlResolverForShareLink.ts +223 -203
- package/src/odspError.ts +27 -19
- package/src/odspFluidFileLink.ts +106 -87
- package/src/odspLocationRedirection.ts +26 -0
- package/src/odspPublicUtils.ts +20 -14
- package/src/odspSnapshotParser.ts +53 -46
- package/src/odspSummaryUploadManager.ts +243 -218
- package/src/odspUrlHelper.ts +81 -71
- package/src/odspUtils.ts +401 -259
- package/src/opsCaching.ts +214 -193
- package/src/packageVersion.ts +1 -1
- package/src/prefetchLatestSnapshot.ts +142 -80
- package/src/retryErrorsStorageAdapter.ts +92 -77
- package/src/retryUtils.ts +80 -57
- package/src/socketModule.ts +8 -0
- package/src/vroom.ts +92 -83
- package/src/zipItDataRepresentationUtils.ts +534 -394
- package/tsc-multi.test.json +4 -0
- package/tsconfig.json +11 -13
- package/.editorconfig +0 -7
- package/dist/ReadBufferUtils.js.map +0 -1
- package/dist/WriteBufferUtils.js.map +0 -1
- package/dist/checkUrl.js.map +0 -1
- package/dist/compactSnapshotParser.js +0 -115
- package/dist/compactSnapshotParser.js.map +0 -1
- package/dist/compactSnapshotWriter.js.map +0 -1
- package/dist/constants.js.map +0 -1
- package/dist/contracts.js.map +0 -1
- package/dist/contractsPublic.js.map +0 -1
- package/dist/createFile.js +0 -242
- package/dist/createFile.js.map +0 -1
- package/dist/createNewUtils.js +0 -67
- package/dist/createNewUtils.js.map +0 -1
- package/dist/createOdspCreateContainerRequest.js.map +0 -1
- package/dist/createOdspUrl.js.map +0 -1
- package/dist/epochTracker.js.map +0 -1
- package/dist/fetch.js.map +0 -1
- package/dist/fetchSnapshot.js.map +0 -1
- package/dist/getFileLink.js.map +0 -1
- package/dist/getQueryString.js.map +0 -1
- package/dist/getSocketIo.d.ts +0 -11
- package/dist/getSocketIo.d.ts.map +0 -1
- package/dist/getSocketIo.js +0 -20
- package/dist/getSocketIo.js.map +0 -1
- package/dist/getUrlAndHeadersWithAuth.js.map +0 -1
- package/dist/index.js +0 -41
- package/dist/index.js.map +0 -1
- package/dist/localOdspDriver/localOdspDocumentService.js.map +0 -1
- package/dist/localOdspDriver/localOdspDocumentServiceFactory.js.map +0 -1
- package/dist/localOdspDriver/localOdspDocumentStorageManager.js.map +0 -1
- package/dist/odspCache.js.map +0 -1
- package/dist/odspDeltaStorageService.js.map +0 -1
- package/dist/odspDocumentDeltaConnection.js.map +0 -1
- package/dist/odspDocumentService.js +0 -364
- package/dist/odspDocumentService.js.map +0 -1
- package/dist/odspDocumentServiceFactory.js.map +0 -1
- package/dist/odspDocumentServiceFactoryCore.js +0 -118
- package/dist/odspDocumentServiceFactoryCore.js.map +0 -1
- package/dist/odspDocumentServiceFactoryWithCodeSplit.js +0 -34
- package/dist/odspDocumentServiceFactoryWithCodeSplit.js.map +0 -1
- package/dist/odspDocumentStorageManager.js +0 -356
- package/dist/odspDocumentStorageManager.js.map +0 -1
- package/dist/odspDocumentStorageServiceBase.js.map +0 -1
- package/dist/odspDriverUrlResolver.js.map +0 -1
- package/dist/odspDriverUrlResolverForShareLink.js.map +0 -1
- package/dist/odspError.js.map +0 -1
- package/dist/odspFluidFileLink.js.map +0 -1
- package/dist/odspPublicUtils.js.map +0 -1
- package/dist/odspSnapshotParser.js.map +0 -1
- package/dist/odspSummaryUploadManager.js.map +0 -1
- package/dist/odspUrlHelper.js.map +0 -1
- package/dist/odspUtils.js.map +0 -1
- package/dist/opsCaching.js.map +0 -1
- package/dist/packageVersion.js.map +0 -1
- package/dist/prefetchLatestSnapshot.js +0 -57
- package/dist/prefetchLatestSnapshot.js.map +0 -1
- package/dist/retryErrorsStorageAdapter.js.map +0 -1
- package/dist/retryUtils.js.map +0 -1
- package/dist/vroom.js.map +0 -1
- package/dist/zipItDataRepresentationUtils.js.map +0 -1
- package/lib/ReadBufferUtils.d.ts.map +0 -1
- package/lib/ReadBufferUtils.js.map +0 -1
- package/lib/WriteBufferUtils.d.ts.map +0 -1
- package/lib/WriteBufferUtils.js.map +0 -1
- package/lib/checkUrl.d.ts.map +0 -1
- package/lib/checkUrl.js.map +0 -1
- package/lib/compactSnapshotParser.d.ts +0 -15
- package/lib/compactSnapshotParser.d.ts.map +0 -1
- package/lib/compactSnapshotParser.js +0 -111
- package/lib/compactSnapshotParser.js.map +0 -1
- package/lib/compactSnapshotWriter.d.ts.map +0 -1
- package/lib/compactSnapshotWriter.js.map +0 -1
- package/lib/constants.d.ts.map +0 -1
- package/lib/constants.js.map +0 -1
- package/lib/contracts.d.ts.map +0 -1
- package/lib/contracts.js.map +0 -1
- package/lib/contractsPublic.d.ts.map +0 -1
- package/lib/contractsPublic.js.map +0 -1
- package/lib/createFile.d.ts +0 -22
- package/lib/createFile.d.ts.map +0 -1
- package/lib/createFile.js +0 -235
- package/lib/createFile.js.map +0 -1
- package/lib/createNewUtils.d.ts +0 -11
- package/lib/createNewUtils.d.ts.map +0 -1
- package/lib/createNewUtils.js +0 -63
- package/lib/createNewUtils.js.map +0 -1
- package/lib/createOdspCreateContainerRequest.d.ts.map +0 -1
- package/lib/createOdspCreateContainerRequest.js.map +0 -1
- package/lib/createOdspUrl.d.ts.map +0 -1
- package/lib/createOdspUrl.js.map +0 -1
- package/lib/epochTracker.d.ts.map +0 -1
- package/lib/epochTracker.js.map +0 -1
- package/lib/fetch.d.ts.map +0 -1
- package/lib/fetch.js.map +0 -1
- package/lib/fetchSnapshot.d.ts.map +0 -1
- package/lib/fetchSnapshot.js.map +0 -1
- package/lib/getFileLink.d.ts.map +0 -1
- package/lib/getFileLink.js.map +0 -1
- package/lib/getQueryString.d.ts.map +0 -1
- package/lib/getQueryString.js.map +0 -1
- package/lib/getSocketIo.d.ts +0 -11
- package/lib/getSocketIo.d.ts.map +0 -1
- package/lib/getSocketIo.js +0 -13
- package/lib/getSocketIo.js.map +0 -1
- package/lib/getUrlAndHeadersWithAuth.d.ts.map +0 -1
- package/lib/getUrlAndHeadersWithAuth.js.map +0 -1
- package/lib/index.d.ts +0 -21
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js +0 -29
- package/lib/index.js.map +0 -1
- package/lib/localOdspDriver/localOdspDocumentService.d.ts.map +0 -1
- package/lib/localOdspDriver/localOdspDocumentService.js.map +0 -1
- package/lib/localOdspDriver/localOdspDocumentServiceFactory.d.ts.map +0 -1
- package/lib/localOdspDriver/localOdspDocumentServiceFactory.js.map +0 -1
- package/lib/localOdspDriver/localOdspDocumentStorageManager.d.ts.map +0 -1
- package/lib/localOdspDriver/localOdspDocumentStorageManager.js.map +0 -1
- package/lib/odspCache.d.ts.map +0 -1
- package/lib/odspCache.js.map +0 -1
- package/lib/odspDeltaStorageService.d.ts.map +0 -1
- package/lib/odspDeltaStorageService.js.map +0 -1
- package/lib/odspDocumentDeltaConnection.d.ts.map +0 -1
- package/lib/odspDocumentDeltaConnection.js.map +0 -1
- package/lib/odspDocumentService.d.ts.map +0 -1
- package/lib/odspDocumentService.js +0 -360
- package/lib/odspDocumentService.js.map +0 -1
- package/lib/odspDocumentServiceFactory.d.ts.map +0 -1
- package/lib/odspDocumentServiceFactory.js.map +0 -1
- package/lib/odspDocumentServiceFactoryCore.d.ts.map +0 -1
- package/lib/odspDocumentServiceFactoryCore.js +0 -114
- package/lib/odspDocumentServiceFactoryCore.js.map +0 -1
- package/lib/odspDocumentServiceFactoryWithCodeSplit.d.ts.map +0 -1
- package/lib/odspDocumentServiceFactoryWithCodeSplit.js.map +0 -1
- package/lib/odspDocumentStorageManager.d.ts.map +0 -1
- package/lib/odspDocumentStorageManager.js +0 -352
- package/lib/odspDocumentStorageManager.js.map +0 -1
- package/lib/odspDocumentStorageServiceBase.d.ts.map +0 -1
- package/lib/odspDocumentStorageServiceBase.js.map +0 -1
- package/lib/odspDriverUrlResolver.d.ts.map +0 -1
- package/lib/odspDriverUrlResolver.js.map +0 -1
- package/lib/odspDriverUrlResolverForShareLink.d.ts.map +0 -1
- package/lib/odspDriverUrlResolverForShareLink.js.map +0 -1
- package/lib/odspError.d.ts.map +0 -1
- package/lib/odspError.js.map +0 -1
- package/lib/odspFluidFileLink.d.ts.map +0 -1
- package/lib/odspFluidFileLink.js.map +0 -1
- package/lib/odspPublicUtils.d.ts.map +0 -1
- package/lib/odspPublicUtils.js.map +0 -1
- package/lib/odspSnapshotParser.d.ts.map +0 -1
- package/lib/odspSnapshotParser.js.map +0 -1
- package/lib/odspSummaryUploadManager.d.ts.map +0 -1
- package/lib/odspSummaryUploadManager.js.map +0 -1
- package/lib/odspUrlHelper.d.ts.map +0 -1
- package/lib/odspUrlHelper.js.map +0 -1
- package/lib/odspUtils.d.ts.map +0 -1
- package/lib/odspUtils.js.map +0 -1
- package/lib/opsCaching.d.ts.map +0 -1
- package/lib/opsCaching.js.map +0 -1
- package/lib/packageVersion.d.ts.map +0 -1
- package/lib/packageVersion.js.map +0 -1
- package/lib/prefetchLatestSnapshot.d.ts.map +0 -1
- package/lib/prefetchLatestSnapshot.js +0 -53
- package/lib/prefetchLatestSnapshot.js.map +0 -1
- package/lib/retryErrorsStorageAdapter.d.ts.map +0 -1
- package/lib/retryErrorsStorageAdapter.js.map +0 -1
- package/lib/retryUtils.d.ts.map +0 -1
- package/lib/retryUtils.js.map +0 -1
- package/lib/vroom.d.ts.map +0 -1
- package/lib/vroom.js.map +0 -1
- package/lib/zipItDataRepresentationUtils.d.ts.map +0 -1
- package/lib/zipItDataRepresentationUtils.js.map +0 -1
- package/src/getSocketIo.ts +0 -14
- package/tsconfig.esnext.json +0 -7
|
@@ -3,597 +3,785 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { IEvent } from "@fluidframework/core-interfaces";
|
|
7
|
+
import {
|
|
8
|
+
ITelemetryLoggerExt,
|
|
9
|
+
IFluidErrorBase,
|
|
10
|
+
loggerToMonitoringContext,
|
|
11
|
+
} from "@fluidframework/telemetry-utils";
|
|
12
|
+
import { performance, TypedEventEmitter } from "@fluid-internal/client-utils";
|
|
13
|
+
import { assert, Deferred } from "@fluidframework/core-utils";
|
|
8
14
|
import { DocumentDeltaConnection } from "@fluidframework/driver-base";
|
|
15
|
+
import { IAnyDriverError } from "@fluidframework/driver-definitions";
|
|
9
16
|
import { OdspError } from "@fluidframework/odsp-driver-definitions";
|
|
10
|
-
import { IAnyDriverError } from "@fluidframework/driver-utils";
|
|
11
|
-
import { IFluidErrorBase, loggerToMonitoringContext } from "@fluidframework/telemetry-utils";
|
|
12
17
|
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
IClient,
|
|
19
|
+
IConnect,
|
|
20
|
+
IDocumentMessage,
|
|
21
|
+
INack,
|
|
22
|
+
ISentSignalMessage,
|
|
23
|
+
ISequencedDocumentMessage,
|
|
24
|
+
ISignalMessage,
|
|
18
25
|
} from "@fluidframework/protocol-definitions";
|
|
19
|
-
import
|
|
26
|
+
import { Socket } from "socket.io-client";
|
|
20
27
|
import { v4 as uuid } from "uuid";
|
|
28
|
+
import { createGenericNetworkError } from "@fluidframework/driver-utils";
|
|
21
29
|
import { IOdspSocketError, IGetOpsResponse, IFlushOpsResponse } from "./contracts";
|
|
22
30
|
import { EpochTracker } from "./epochTracker";
|
|
23
31
|
import { errorObjectFromSocketError } from "./odspError";
|
|
32
|
+
import { SocketIOClientStatic } from "./socketModule";
|
|
24
33
|
import { pkgVersion } from "./packageVersion";
|
|
25
34
|
|
|
26
35
|
const protocolVersions = ["^0.4.0", "^0.3.0", "^0.2.0", "^0.1.0"];
|
|
27
36
|
const feature_get_ops = "api_get_ops";
|
|
28
37
|
const feature_flush_ops = "api_flush_ops";
|
|
38
|
+
const feature_submit_signals_v2 = "submit_signals_v2";
|
|
29
39
|
|
|
30
40
|
export interface FlushResult {
|
|
31
|
-
|
|
32
|
-
|
|
41
|
+
lastPersistedSequenceNumber?: number;
|
|
42
|
+
retryAfter?: number;
|
|
33
43
|
}
|
|
34
44
|
|
|
35
45
|
// How long to wait before disconnecting the socket after the last reference is removed
|
|
36
46
|
// This allows reconnection after receiving a nack to be smooth
|
|
37
47
|
const socketReferenceBufferTime = 2000;
|
|
38
48
|
|
|
39
|
-
|
|
40
|
-
|
|
49
|
+
interface ISocketEvents extends IEvent {
|
|
50
|
+
(
|
|
51
|
+
event: "disconnect",
|
|
52
|
+
listener: (error: IFluidErrorBase & OdspError, clientId?: string) => void,
|
|
53
|
+
);
|
|
41
54
|
}
|
|
42
55
|
|
|
43
56
|
class SocketReference extends TypedEventEmitter<ISocketEvents> {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
57
|
+
private references: number = 1;
|
|
58
|
+
private delayDeleteTimeout: ReturnType<typeof setTimeout> | undefined;
|
|
59
|
+
private _socket: Socket | undefined;
|
|
60
|
+
|
|
61
|
+
// When making decisions about socket reuse, we do not reuse disconnected socket.
|
|
62
|
+
// But we want to differentiate the following case from disconnected case:
|
|
63
|
+
// Socket that never connected and never failed, it's in "attempting to connect" mode
|
|
64
|
+
// such sockets should be reused, despite socket.disconnected === true
|
|
65
|
+
private isPendingInitialConnection = true;
|
|
66
|
+
|
|
67
|
+
// Map of all existing socket io sockets. [url, tenantId, documentId] -> socket
|
|
68
|
+
private static readonly socketIoSockets: Map<string, SocketReference> = new Map();
|
|
69
|
+
|
|
70
|
+
public static find(key: string, logger: ITelemetryLoggerExt) {
|
|
71
|
+
const socketReference = SocketReference.socketIoSockets.get(key);
|
|
72
|
+
|
|
73
|
+
// Verify the socket is healthy before reusing it
|
|
74
|
+
if (socketReference?.disconnected) {
|
|
75
|
+
// The socket is in a bad state. fully remove the reference
|
|
76
|
+
socketReference.closeSocket();
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (socketReference) {
|
|
81
|
+
// Clear the pending deletion if there is one
|
|
82
|
+
socketReference.clearTimer();
|
|
83
|
+
socketReference.references++;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return socketReference;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Removes a reference for the given key
|
|
91
|
+
* Once the ref count hits 0, the socket is disconnected and removed
|
|
92
|
+
*/
|
|
93
|
+
public removeSocketIoReference() {
|
|
94
|
+
assert(this.references > 0, 0x09f /* "No more socketIO refs to remove!" */);
|
|
95
|
+
this.references--;
|
|
96
|
+
|
|
97
|
+
// see comment in disconnected() getter
|
|
98
|
+
this.isPendingInitialConnection = false;
|
|
99
|
+
|
|
100
|
+
if (this.disconnected) {
|
|
101
|
+
this.closeSocket();
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (this.references === 0 && this.delayDeleteTimeout === undefined) {
|
|
106
|
+
this.delayDeleteTimeout = setTimeout(() => {
|
|
107
|
+
// We should not get here with active users.
|
|
108
|
+
assert(
|
|
109
|
+
this.references === 0,
|
|
110
|
+
0x0a0 /* "Unexpected socketIO references on timeout" */,
|
|
111
|
+
);
|
|
112
|
+
this.closeSocket();
|
|
113
|
+
}, socketReferenceBufferTime);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
public get socket() {
|
|
118
|
+
if (!this._socket) {
|
|
119
|
+
throw new Error(`Invalid socket for key "${this.key}`);
|
|
120
|
+
}
|
|
121
|
+
return this._socket;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
public constructor(
|
|
125
|
+
public readonly key: string,
|
|
126
|
+
socket: Socket,
|
|
127
|
+
) {
|
|
128
|
+
super();
|
|
129
|
+
|
|
130
|
+
this._socket = socket;
|
|
131
|
+
assert(!SocketReference.socketIoSockets.has(key), 0x220 /* "socket key collision" */);
|
|
132
|
+
SocketReference.socketIoSockets.set(key, this);
|
|
133
|
+
|
|
134
|
+
// Server sends this event when it wants to disconnect a particular client in which case the client id would
|
|
135
|
+
// be present or if it wants to disconnect all the clients. The server always closes the socket in case all
|
|
136
|
+
// clients needs to be disconnected. So fully remove the socket reference in this case.
|
|
137
|
+
socket.on("server_disconnect", this.serverDisconnectEventHandler);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
private readonly serverDisconnectEventHandler = (
|
|
141
|
+
socketError: IOdspSocketError,
|
|
142
|
+
clientId?: string,
|
|
143
|
+
) => {
|
|
144
|
+
// Treat all errors as recoverable, and rely on joinSession / reconnection flow to
|
|
145
|
+
// filter out retryable vs. non-retryable cases.
|
|
146
|
+
const error = errorObjectFromSocketError(socketError, "server_disconnect");
|
|
147
|
+
error.addTelemetryProperties({ disconnectClientId: clientId });
|
|
148
|
+
error.canRetry = true;
|
|
149
|
+
|
|
150
|
+
// see comment in disconnected() getter
|
|
151
|
+
// Setting it here to ensure socket reuse does not happen if new request to connect
|
|
152
|
+
// comes in from "disconnect" listener below, before we close socket.
|
|
153
|
+
this.isPendingInitialConnection = false;
|
|
154
|
+
|
|
155
|
+
if (clientId === undefined) {
|
|
156
|
+
// We could first raise "disconnect" event, but that may result in socket reuse due to
|
|
157
|
+
// new connection comming in. So, it's better to have more explicit flow to make it impossible.
|
|
158
|
+
this.closeSocket(error);
|
|
159
|
+
} else {
|
|
160
|
+
this.emit("disconnect", error, clientId);
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
private clearTimer() {
|
|
165
|
+
if (this.delayDeleteTimeout !== undefined) {
|
|
166
|
+
clearTimeout(this.delayDeleteTimeout);
|
|
167
|
+
this.delayDeleteTimeout = undefined;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
public closeSocket(error?: IAnyDriverError) {
|
|
172
|
+
if (!this._socket) {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
this._socket.off("server_disconnect", this.serverDisconnectEventHandler);
|
|
177
|
+
this.clearTimer();
|
|
178
|
+
|
|
179
|
+
assert(
|
|
180
|
+
SocketReference.socketIoSockets.get(this.key) === this,
|
|
181
|
+
0x0a1 /* "Socket reference set unexpectedly does not point to this socket!" */,
|
|
182
|
+
);
|
|
183
|
+
|
|
184
|
+
// First, remove socket to ensure no socket reuse is possible.
|
|
185
|
+
SocketReference.socketIoSockets.delete(this.key);
|
|
186
|
+
|
|
187
|
+
// Block access to socket. From now on, calls like flush() or requestOps()
|
|
188
|
+
// Disconnect flow should be synchronous and result in system fully forgetting about this connection / socket.
|
|
189
|
+
const socket = this._socket;
|
|
190
|
+
this._socket = undefined;
|
|
191
|
+
|
|
192
|
+
// Let all connections know they need to go through disconnect flow.
|
|
193
|
+
this.emit(
|
|
194
|
+
"disconnect",
|
|
195
|
+
error ??
|
|
196
|
+
createGenericNetworkError(
|
|
197
|
+
"Socket closed without error",
|
|
198
|
+
{ canRetry: true },
|
|
199
|
+
{ driverVersion: pkgVersion },
|
|
200
|
+
),
|
|
201
|
+
undefined /* clientId */,
|
|
202
|
+
);
|
|
203
|
+
|
|
204
|
+
// We should not have any users now, assuming synchronous disconnect flow in response to
|
|
205
|
+
// "disconnect" event
|
|
206
|
+
assert(
|
|
207
|
+
this.references === 0,
|
|
208
|
+
0x412 /* Nobody should be connected to this socket at this point! */,
|
|
209
|
+
);
|
|
210
|
+
|
|
211
|
+
socket.disconnect();
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
public get disconnected() {
|
|
215
|
+
if (this._socket === undefined) {
|
|
216
|
+
return true;
|
|
217
|
+
}
|
|
218
|
+
if (this.socket.connected) {
|
|
219
|
+
return false;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// We have a socket that is not connected. Possible cases:
|
|
223
|
+
// 1) It was connected some time ago and lost connection. We do not want to reuse it.
|
|
224
|
+
// 2) It failed to connect (was never connected).
|
|
225
|
+
// 3) It was just created and never had a chance to connect - connection is in process.
|
|
226
|
+
// We have to differentiate 1 from 2-3 (specifically 1 & 3) in order to be able to reuse socket in #3.
|
|
227
|
+
// We will use the fact that socket had some activity. I.e. if socket disconnected, or client stopped using
|
|
228
|
+
// socket, then removeSocketIoReference() will be called for it, and it will be the indiction that it's not #3.
|
|
229
|
+
return !this.isPendingInitialConnection;
|
|
230
|
+
}
|
|
176
231
|
}
|
|
177
232
|
|
|
178
233
|
/**
|
|
179
234
|
* Represents a connection to a stream of delta updates
|
|
180
235
|
*/
|
|
181
236
|
export class OdspDocumentDeltaConnection extends DocumentDeltaConnection {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
237
|
+
/**
|
|
238
|
+
* Create a OdspDocumentDeltaConnection
|
|
239
|
+
* If url #1 fails to connect, will try url #2 if applicable.
|
|
240
|
+
*
|
|
241
|
+
* @param tenantId - the ID of the tenant
|
|
242
|
+
* @param documentId - document ID
|
|
243
|
+
* @param token - authorization token for storage service
|
|
244
|
+
* @param client - information about the client
|
|
245
|
+
* @param mode - mode of the client
|
|
246
|
+
* @param url - websocket URL
|
|
247
|
+
* @param telemetryLogger - optional telemetry logger
|
|
248
|
+
* @param timeoutMs - time limit on making the connection
|
|
249
|
+
* @param epochTracker - track epoch changes
|
|
250
|
+
* @param socketReferenceKeyPrefix - (optional) prefix to isolate socket reuse cache
|
|
251
|
+
*/
|
|
252
|
+
public static async create(
|
|
253
|
+
tenantId: string,
|
|
254
|
+
documentId: string,
|
|
255
|
+
// eslint-disable-next-line @rushstack/no-new-null
|
|
256
|
+
token: string | null,
|
|
257
|
+
client: IClient,
|
|
258
|
+
url: string,
|
|
259
|
+
telemetryLogger: ITelemetryLoggerExt,
|
|
260
|
+
timeoutMs: number,
|
|
261
|
+
epochTracker: EpochTracker,
|
|
262
|
+
socketReferenceKeyPrefix: string | undefined,
|
|
263
|
+
): Promise<OdspDocumentDeltaConnection> {
|
|
264
|
+
const mc = loggerToMonitoringContext(telemetryLogger);
|
|
265
|
+
|
|
266
|
+
// enable multiplexing when the websocket url does not include the tenant/document id
|
|
267
|
+
const parsedUrl = new URL(url);
|
|
268
|
+
const enableMultiplexing =
|
|
269
|
+
!parsedUrl.searchParams.has("documentId") && !parsedUrl.searchParams.has("tenantId");
|
|
270
|
+
|
|
271
|
+
// do not include the specific tenant/doc id in the ref key when multiplexing
|
|
272
|
+
// this will allow multiple documents to share the same websocket connection
|
|
273
|
+
const key = socketReferenceKeyPrefix ? `${socketReferenceKeyPrefix},${url}` : url;
|
|
274
|
+
const socketReferenceKey = enableMultiplexing ? key : `${key},${tenantId},${documentId}`;
|
|
275
|
+
|
|
276
|
+
const socketReference = OdspDocumentDeltaConnection.getOrCreateSocketIoReference(
|
|
277
|
+
timeoutMs,
|
|
278
|
+
socketReferenceKey,
|
|
279
|
+
url,
|
|
280
|
+
enableMultiplexing,
|
|
281
|
+
tenantId,
|
|
282
|
+
documentId,
|
|
283
|
+
telemetryLogger,
|
|
284
|
+
);
|
|
285
|
+
|
|
286
|
+
const socket = socketReference.socket;
|
|
287
|
+
const connectionId = uuid();
|
|
288
|
+
const connectMessage: IConnect = {
|
|
289
|
+
client,
|
|
290
|
+
id: documentId,
|
|
291
|
+
mode: client.mode,
|
|
292
|
+
tenantId,
|
|
293
|
+
token, // Token is going to indicate tenant level information, etc...
|
|
294
|
+
versions: protocolVersions,
|
|
295
|
+
driverVersion: pkgVersion,
|
|
296
|
+
nonce: connectionId,
|
|
297
|
+
epoch: epochTracker.fluidEpoch,
|
|
298
|
+
relayUserAgent: [client.details.environment, ` driverVersion:${pkgVersion}`].join(";"),
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
connectMessage.supportedFeatures = {
|
|
302
|
+
[feature_submit_signals_v2]: true,
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
// Reference to this client supporting get_ops flow.
|
|
306
|
+
if (mc.config.getBoolean("Fluid.Driver.Odsp.GetOpsEnabled") !== false) {
|
|
307
|
+
connectMessage.supportedFeatures[feature_get_ops] = true;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
const deltaConnection = new OdspDocumentDeltaConnection(
|
|
311
|
+
socket,
|
|
312
|
+
documentId,
|
|
313
|
+
socketReference,
|
|
314
|
+
telemetryLogger,
|
|
315
|
+
enableMultiplexing,
|
|
316
|
+
connectionId,
|
|
317
|
+
);
|
|
318
|
+
|
|
319
|
+
try {
|
|
320
|
+
await deltaConnection.initialize(connectMessage, timeoutMs);
|
|
321
|
+
await epochTracker.validateEpoch(deltaConnection.details.epoch, "push");
|
|
322
|
+
} catch (errorObject: any) {
|
|
323
|
+
if (errorObject !== null && typeof errorObject === "object") {
|
|
324
|
+
// We have to special-case error types here in terms of what is re-triable.
|
|
325
|
+
// These errors have to re-retried, we just need new joinSession result to connect to right server:
|
|
326
|
+
// 400: Invalid tenant or document id. The WebSocket is connected to a different document
|
|
327
|
+
// Document is full (with retryAfter)
|
|
328
|
+
// 404: Invalid document. The document \"local/w1-...\" does not exist
|
|
329
|
+
// But this has to stay not-retriable:
|
|
330
|
+
// 406: Unsupported client protocol. This path is the only gatekeeper, have to fail!
|
|
331
|
+
// 409: Epoch Version Mismatch. Client epoch and server epoch does not match, so app needs
|
|
332
|
+
// to be refreshed.
|
|
333
|
+
// This one is fine either way
|
|
334
|
+
// 401/403: Code will retry once with new token either way, then it becomes fatal - on this path
|
|
335
|
+
// and on join Session path.
|
|
336
|
+
// 501: (Fluid not enabled): this is fine either way, as joinSession is gatekeeper
|
|
337
|
+
if (errorObject.statusCode === 400 || errorObject.statusCode === 404) {
|
|
338
|
+
errorObject.canRetry = true;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
throw errorObject;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
return deltaConnection;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
private socketReference: SocketReference | undefined;
|
|
348
|
+
|
|
349
|
+
private readonly requestOpsNoncePrefix: string;
|
|
350
|
+
private pushCallCounter = 0;
|
|
351
|
+
private readonly getOpsMap: Map<string, { start: number; from: number; to: number }> =
|
|
352
|
+
new Map();
|
|
353
|
+
private flushOpNonce: string | undefined;
|
|
354
|
+
private flushDeferred: Deferred<FlushResult> | undefined;
|
|
355
|
+
private connectionNotYetDisposedTimeout: ReturnType<typeof setTimeout> | undefined;
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* Error raising for socket.io issues
|
|
359
|
+
*/
|
|
360
|
+
protected createErrorObject(handler: string, error?: any, canRetry = true): IAnyDriverError {
|
|
361
|
+
// Note: we suspect the incoming error object is either:
|
|
362
|
+
// - a socketError: add it to the OdspError object for driver to be able to parse it and reason over it.
|
|
363
|
+
// - anything else: let base class handle it
|
|
364
|
+
return canRetry && Number.isInteger(error?.code) && typeof error?.message === "string"
|
|
365
|
+
? errorObjectFromSocketError(error as IOdspSocketError, handler)
|
|
366
|
+
: super.createErrorObject(handler, error, canRetry);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* Gets or create a socket io connection for the given key
|
|
371
|
+
*/
|
|
372
|
+
private static getOrCreateSocketIoReference(
|
|
373
|
+
timeoutMs: number,
|
|
374
|
+
key: string,
|
|
375
|
+
url: string,
|
|
376
|
+
enableMultiplexing: boolean,
|
|
377
|
+
tenantId: string,
|
|
378
|
+
documentId: string,
|
|
379
|
+
logger: ITelemetryLoggerExt,
|
|
380
|
+
): SocketReference {
|
|
381
|
+
const existingSocketReference = SocketReference.find(key, logger);
|
|
382
|
+
if (existingSocketReference) {
|
|
383
|
+
return existingSocketReference;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
const query = enableMultiplexing ? undefined : { documentId, tenantId };
|
|
387
|
+
|
|
388
|
+
const socket = SocketIOClientStatic(url, {
|
|
389
|
+
multiplex: false, // Don't rely on socket.io built-in multiplexing
|
|
390
|
+
query,
|
|
391
|
+
reconnection: false,
|
|
392
|
+
transports: ["websocket"],
|
|
393
|
+
timeout: timeoutMs,
|
|
394
|
+
});
|
|
395
|
+
|
|
396
|
+
return new SocketReference(key, socket);
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* @param socket - websocket to be used
|
|
401
|
+
* @param documentId - ID of the document
|
|
402
|
+
* @param details - details of the websocket connection
|
|
403
|
+
* @param socketReferenceKey - socket reference key
|
|
404
|
+
* @param enableMultiplexing - If the websocket is multiplexing multiple documents
|
|
405
|
+
*/
|
|
406
|
+
private constructor(
|
|
407
|
+
socket: Socket,
|
|
408
|
+
documentId: string,
|
|
409
|
+
socketReference: SocketReference,
|
|
410
|
+
logger: ITelemetryLoggerExt,
|
|
411
|
+
private readonly enableMultiplexing?: boolean,
|
|
412
|
+
connectionId?: string,
|
|
413
|
+
) {
|
|
414
|
+
super(socket, documentId, logger, false, connectionId);
|
|
415
|
+
this.socketReference = socketReference;
|
|
416
|
+
this.requestOpsNoncePrefix = `${uuid()}-`;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
/**
|
|
420
|
+
* Retrieves ops from PUSH
|
|
421
|
+
* @param from - inclusive
|
|
422
|
+
* @param to - exclusive
|
|
423
|
+
* @returns ops retrieved
|
|
424
|
+
*/
|
|
425
|
+
public requestOps(from: number, to: number) {
|
|
426
|
+
assert(!this.socketReference?.disconnected, 0x413 /* non-active socket */);
|
|
427
|
+
|
|
428
|
+
// Given that to is exclusive, we should be asking for at least something!
|
|
429
|
+
assert(to > from, 0x272 /* "empty request" */);
|
|
430
|
+
|
|
431
|
+
// PUSH may disable this functionality
|
|
432
|
+
// back-compat: remove cast to any once latest version of IConnected is consumed
|
|
433
|
+
if ((this.details as any).supportedFeatures?.[feature_get_ops] !== true) {
|
|
434
|
+
return;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
this.pushCallCounter++;
|
|
438
|
+
const nonce = `${this.requestOpsNoncePrefix}${this.pushCallCounter}`;
|
|
439
|
+
const start = performance.now();
|
|
440
|
+
|
|
441
|
+
// We may keep keep accumulating memory for nothing, if we are not getting responses.
|
|
442
|
+
// Note that we should not have overlapping requests, as DeltaManager allows only one
|
|
443
|
+
// outstanding request to storage, and that's the only way to get here.
|
|
444
|
+
// But requests could be cancelled, and thus overlapping requests might be in the picture
|
|
445
|
+
// If it happens, we do not care about stale requests.
|
|
446
|
+
// So track some number of requests, but log if we get too many in flight - that likely
|
|
447
|
+
// indicates an error somewhere.
|
|
448
|
+
if (this.getOpsMap.size >= 5) {
|
|
449
|
+
let time = start;
|
|
450
|
+
let key: string | undefined;
|
|
451
|
+
for (const [keyCandidate, value] of this.getOpsMap.entries()) {
|
|
452
|
+
if (value.start <= time || key === undefined) {
|
|
453
|
+
time = value.start;
|
|
454
|
+
key = keyCandidate;
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
const payloadToDelete = this.getOpsMap.get(key!)!;
|
|
458
|
+
this.logger.sendErrorEvent({
|
|
459
|
+
eventName: "GetOpsTooMany",
|
|
460
|
+
nonce,
|
|
461
|
+
from: payloadToDelete.from,
|
|
462
|
+
to: payloadToDelete.to,
|
|
463
|
+
length: payloadToDelete.to - payloadToDelete.from,
|
|
464
|
+
duration: performance.now() - payloadToDelete.start,
|
|
465
|
+
});
|
|
466
|
+
this.getOpsMap.delete(key!);
|
|
467
|
+
}
|
|
468
|
+
this.getOpsMap.set(nonce, {
|
|
469
|
+
start,
|
|
470
|
+
from,
|
|
471
|
+
to,
|
|
472
|
+
});
|
|
473
|
+
this.socket.emit("get_ops", this.clientId, {
|
|
474
|
+
nonce,
|
|
475
|
+
from,
|
|
476
|
+
to: to - 1,
|
|
477
|
+
});
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
public async flush(): Promise<FlushResult> {
|
|
481
|
+
assert(!this.socketReference?.disconnected, 0x414 /* non-active socket */);
|
|
482
|
+
|
|
483
|
+
// back-compat: remove cast to any once latest version of IConnected is consumed
|
|
484
|
+
if ((this.details as any).supportedFeatures?.[feature_flush_ops] !== true) {
|
|
485
|
+
// Once single-commit summary is enabled end-to-end, flush support is a must!
|
|
486
|
+
// The only alternative is change in design where SPO fetches ops from PUSH OR
|
|
487
|
+
// summary includes required ops and SPO has some validation mechanism to ensure
|
|
488
|
+
// they are not forged by client.
|
|
489
|
+
// If design changes, we can reconsider it, but right now it's non-recoverable failure.
|
|
490
|
+
this.logger.sendErrorEvent({ eventName: "FlushOpsNotSupported" });
|
|
491
|
+
throw new Error(
|
|
492
|
+
"flush() API is not supported by PUSH, required for single-commit summaries",
|
|
493
|
+
);
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
this.pushCallCounter++;
|
|
497
|
+
const nonce = `${this.requestOpsNoncePrefix}${this.pushCallCounter}`;
|
|
498
|
+
// There should be only one flush ops in flight, kicked out by upload summary workflow
|
|
499
|
+
// That said, it could timeout and request could be repeated, so theoretically we can
|
|
500
|
+
// get overlapping requests, but it should be very rare
|
|
501
|
+
if (this.flushDeferred !== undefined) {
|
|
502
|
+
this.logger.sendErrorEvent({ eventName: "FlushOpsTooMany" });
|
|
503
|
+
this.flushDeferred.reject(
|
|
504
|
+
"process involving flush() was cancelled OR unsupported concurrency",
|
|
505
|
+
);
|
|
506
|
+
}
|
|
507
|
+
this.socket.emit("flush_ops", this.clientId, { nonce });
|
|
508
|
+
|
|
509
|
+
this.flushOpNonce = nonce;
|
|
510
|
+
this.flushDeferred = new Deferred<FlushResult>();
|
|
511
|
+
return this.flushDeferred.promise;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
protected disconnectHandler = (error: IFluidErrorBase & OdspError, clientId?: string) => {
|
|
515
|
+
if (clientId === undefined || clientId === this.clientId) {
|
|
516
|
+
this.logger.sendTelemetryEvent(
|
|
517
|
+
{
|
|
518
|
+
eventName: "ServerDisconnect",
|
|
519
|
+
driverVersion: pkgVersion,
|
|
520
|
+
details: JSON.stringify({
|
|
521
|
+
...this.getConnectionDetailsProps(),
|
|
522
|
+
}),
|
|
523
|
+
},
|
|
524
|
+
error,
|
|
525
|
+
);
|
|
526
|
+
this.disconnect(error);
|
|
527
|
+
}
|
|
528
|
+
};
|
|
529
|
+
|
|
530
|
+
protected async initialize(connectMessage: IConnect, timeout: number) {
|
|
531
|
+
assert(!this.socketReference?.disconnected, 0x415 /* non-active socket */);
|
|
532
|
+
|
|
533
|
+
if (this.enableMultiplexing) {
|
|
534
|
+
// multiplex compatible early handlers
|
|
535
|
+
this.earlyOpHandler = (
|
|
536
|
+
messageDocumentId: string,
|
|
537
|
+
msgs: ISequencedDocumentMessage[],
|
|
538
|
+
) => {
|
|
539
|
+
if (this.documentId === messageDocumentId) {
|
|
540
|
+
this.queuedMessages.push(...msgs);
|
|
541
|
+
}
|
|
542
|
+
};
|
|
543
|
+
|
|
544
|
+
this.earlySignalHandler = (
|
|
545
|
+
msg: ISignalMessage | ISignalMessage[],
|
|
546
|
+
messageDocumentId?: string,
|
|
547
|
+
) => {
|
|
548
|
+
if (messageDocumentId === undefined || messageDocumentId === this.documentId) {
|
|
549
|
+
if (Array.isArray(msg)) {
|
|
550
|
+
this.queuedSignals.push(...msg);
|
|
551
|
+
} else {
|
|
552
|
+
this.queuedSignals.push(msg);
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
};
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
this.socketReference!.on("disconnect", this.disconnectHandler);
|
|
559
|
+
|
|
560
|
+
this.addTrackedListener("get_ops_response", (result: IGetOpsResponse) => {
|
|
561
|
+
const messages = result.messages;
|
|
562
|
+
const data = this.getOpsMap.get(result.nonce);
|
|
563
|
+
// Due to socket multiplexing, this client may not have asked for any data
|
|
564
|
+
// If so, there it most likely does not need these ops (otherwise it already asked for them)
|
|
565
|
+
// Also we may have deleted entry in this.getOpsMap due to too many requests and too slow response.
|
|
566
|
+
// But not processing such result may push us into infinite loop of fast requests and dropping all responses
|
|
567
|
+
if (data !== undefined || result.nonce.startsWith(this.requestOpsNoncePrefix)) {
|
|
568
|
+
this.getOpsMap.delete(result.nonce);
|
|
569
|
+
const common = {
|
|
570
|
+
eventName: "GetOps",
|
|
571
|
+
// We need nonce only to pair with GetOpsTooMany events, i.e. when record was deleted
|
|
572
|
+
nonce: data === undefined ? result.nonce : undefined,
|
|
573
|
+
code: result.code,
|
|
574
|
+
from: data?.from,
|
|
575
|
+
to: data?.to,
|
|
576
|
+
duration: data === undefined ? undefined : performance.now() - data.start,
|
|
577
|
+
};
|
|
578
|
+
if (messages !== undefined && messages.length > 0) {
|
|
579
|
+
this.logger.sendPerformanceEvent({
|
|
580
|
+
...common,
|
|
581
|
+
first: messages[0].sequenceNumber,
|
|
582
|
+
last: messages[messages.length - 1].sequenceNumber,
|
|
583
|
+
length: messages.length,
|
|
584
|
+
});
|
|
585
|
+
this.emit("op", this.documentId, messages);
|
|
586
|
+
} else {
|
|
587
|
+
this.logger.sendPerformanceEvent({
|
|
588
|
+
...common,
|
|
589
|
+
length: 0,
|
|
590
|
+
});
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
});
|
|
594
|
+
|
|
595
|
+
this.addTrackedListener("flush_ops_response", (result: IFlushOpsResponse) => {
|
|
596
|
+
if (this.flushOpNonce === result.nonce) {
|
|
597
|
+
const seq = result.lastPersistedSequenceNumber;
|
|
598
|
+
let category: "generic" | "error" = "generic";
|
|
599
|
+
if (result.lastPersistedSequenceNumber === undefined || result.code !== 200) {
|
|
600
|
+
switch (result.code) {
|
|
601
|
+
case 409:
|
|
602
|
+
case 429:
|
|
603
|
+
category = "error";
|
|
604
|
+
break;
|
|
605
|
+
case 204:
|
|
606
|
+
break;
|
|
607
|
+
default:
|
|
608
|
+
category = "error";
|
|
609
|
+
break;
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
this.logger.sendTelemetryEvent({
|
|
613
|
+
eventName: "FlushResult",
|
|
614
|
+
code: result.code,
|
|
615
|
+
sequenceNumber: seq,
|
|
616
|
+
category,
|
|
617
|
+
});
|
|
618
|
+
this.flushDeferred!.resolve(result);
|
|
619
|
+
this.flushDeferred = undefined;
|
|
620
|
+
this.flushOpNonce = undefined;
|
|
621
|
+
}
|
|
622
|
+
});
|
|
623
|
+
|
|
624
|
+
await super.initialize(connectMessage, timeout).finally(() => {
|
|
625
|
+
this.logger.sendTelemetryEvent({
|
|
626
|
+
eventName: "ConnectionAttemptInfo",
|
|
627
|
+
...this.getConnectionDetailsProps(),
|
|
628
|
+
});
|
|
629
|
+
});
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
protected addTrackedListener(event: string, listener: (...args: any[]) => void) {
|
|
633
|
+
// override some event listeners in order to support multiple documents/clients over the same websocket
|
|
634
|
+
switch (event) {
|
|
635
|
+
case "op":
|
|
636
|
+
// per document op handling
|
|
637
|
+
super.addTrackedListener(
|
|
638
|
+
event,
|
|
639
|
+
(documentId: string, msgs: ISequencedDocumentMessage[]) => {
|
|
640
|
+
if (!this.enableMultiplexing || this.documentId === documentId) {
|
|
641
|
+
listener(documentId, msgs);
|
|
642
|
+
}
|
|
643
|
+
},
|
|
644
|
+
);
|
|
645
|
+
break;
|
|
646
|
+
|
|
647
|
+
case "signal":
|
|
648
|
+
// per document signal handling
|
|
649
|
+
super.addTrackedListener(
|
|
650
|
+
event,
|
|
651
|
+
(msg: ISignalMessage | ISignalMessage[], documentId?: string) => {
|
|
652
|
+
if (
|
|
653
|
+
!this.enableMultiplexing ||
|
|
654
|
+
!documentId ||
|
|
655
|
+
documentId === this.documentId
|
|
656
|
+
) {
|
|
657
|
+
listener(msg, documentId);
|
|
658
|
+
}
|
|
659
|
+
},
|
|
660
|
+
);
|
|
661
|
+
break;
|
|
662
|
+
|
|
663
|
+
case "nack":
|
|
664
|
+
// per client / document nack handling
|
|
665
|
+
super.addTrackedListener(event, (clientIdOrDocumentId: string, nacks: INack[]) => {
|
|
666
|
+
const handle =
|
|
667
|
+
clientIdOrDocumentId.length === 0 ||
|
|
668
|
+
clientIdOrDocumentId === this.documentId ||
|
|
669
|
+
clientIdOrDocumentId === this.clientId;
|
|
670
|
+
const { code, type, message, retryAfter } = nacks[0]?.content ?? {};
|
|
671
|
+
const { clientSequenceNumber, referenceSequenceNumber } =
|
|
672
|
+
nacks[0]?.operation ?? {};
|
|
673
|
+
this.logger.sendTelemetryEvent({
|
|
674
|
+
eventName: "ServerNack",
|
|
675
|
+
code,
|
|
676
|
+
type,
|
|
677
|
+
message,
|
|
678
|
+
retryAfterSeconds: retryAfter,
|
|
679
|
+
clientId: this.clientId,
|
|
680
|
+
handle,
|
|
681
|
+
clientSequenceNumber,
|
|
682
|
+
referenceSequenceNumber,
|
|
683
|
+
opType: nacks[0]?.operation?.type,
|
|
684
|
+
});
|
|
685
|
+
if (handle) {
|
|
686
|
+
this.emit("nack", clientIdOrDocumentId, nacks);
|
|
687
|
+
}
|
|
688
|
+
});
|
|
689
|
+
break;
|
|
690
|
+
|
|
691
|
+
default:
|
|
692
|
+
super.addTrackedListener(event, listener);
|
|
693
|
+
break;
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
public get disposed() {
|
|
698
|
+
if (!(this._disposed || this.socket.connected)) {
|
|
699
|
+
// Send error event if this connection is not yet disposed after socket is disconnected for 15s.
|
|
700
|
+
if (this.connectionNotYetDisposedTimeout === undefined) {
|
|
701
|
+
this.connectionNotYetDisposedTimeout = setTimeout(() => {
|
|
702
|
+
if (!this._disposed) {
|
|
703
|
+
this.logger.sendErrorEvent({
|
|
704
|
+
eventName: "ConnectionNotYetDisposed",
|
|
705
|
+
driverVersion: pkgVersion,
|
|
706
|
+
details: JSON.stringify({
|
|
707
|
+
...this.getConnectionDetailsProps(),
|
|
708
|
+
}),
|
|
709
|
+
});
|
|
710
|
+
}
|
|
711
|
+
}, 15000);
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
return this._disposed;
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
/**
|
|
718
|
+
* Returns true in case the connection is not yet disposed and the socket is also connected. The expectation is
|
|
719
|
+
* that it will be called only after connection is fully established. i.e. there should no way to submit an op
|
|
720
|
+
* while we are connecting, as connection object is not exposed to Loader layer until connection is established.
|
|
721
|
+
*/
|
|
722
|
+
private get connected(): boolean {
|
|
723
|
+
return !this.disposed && this.socket.connected;
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
protected emitMessages(type: string, messages: IDocumentMessage[][]) {
|
|
727
|
+
// Only submit the op/signals if we are connected.
|
|
728
|
+
if (this.connected) {
|
|
729
|
+
this.socket.emit(type, this.clientId, messages);
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
/**
|
|
734
|
+
* Submits a new delta operation to the server
|
|
735
|
+
* @param message - delta operation to submit
|
|
736
|
+
*/
|
|
737
|
+
public submit(messages: IDocumentMessage[]): void {
|
|
738
|
+
this.emitMessages("submitOp", [messages]);
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
/**
|
|
742
|
+
* Submits a new signal to the server
|
|
743
|
+
*
|
|
744
|
+
* @param content - Content of the signal.
|
|
745
|
+
* @param targetClientId - When specified, the signal is only sent to the provided client id.
|
|
746
|
+
*/
|
|
747
|
+
public submitSignal(content: IDocumentMessage, targetClientId?: string): void {
|
|
748
|
+
const signal: ISentSignalMessage = {
|
|
749
|
+
content,
|
|
750
|
+
targetClientId,
|
|
751
|
+
};
|
|
752
|
+
|
|
753
|
+
// back-compat: the typing for this method and emitMessages is incorrect, will be fixed in a future PR
|
|
754
|
+
this.emitMessages("submitSignal", [signal] as any);
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
/**
|
|
758
|
+
* Critical path where we need to also close the socket for an error.
|
|
759
|
+
* @param error - Error causing the socket to close.
|
|
760
|
+
*/
|
|
761
|
+
protected closeSocketCore(error: IAnyDriverError) {
|
|
762
|
+
const socket = this.socketReference;
|
|
763
|
+
assert(socket !== undefined, 0x416 /* reentrancy not supported in close socket */);
|
|
764
|
+
socket.closeSocket(error);
|
|
765
|
+
assert(
|
|
766
|
+
this.socketReference === undefined,
|
|
767
|
+
0x417 /* disconnect flow did not work correctly */,
|
|
768
|
+
);
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
/**
|
|
772
|
+
* Disconnect from the websocket
|
|
773
|
+
*/
|
|
774
|
+
protected disconnectCore() {
|
|
775
|
+
const socket = this.socketReference;
|
|
776
|
+
assert(socket !== undefined, 0x0a2 /* "reentrancy not supported!" */);
|
|
777
|
+
this.socketReference = undefined;
|
|
778
|
+
|
|
779
|
+
socket.off("disconnect", this.disconnectHandler);
|
|
780
|
+
if (this.hasDetails) {
|
|
781
|
+
// tell the server we are disconnecting this client from the document
|
|
782
|
+
this.socket.emit("disconnect_document", this.clientId, this.documentId);
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
socket.removeSocketIoReference();
|
|
786
|
+
}
|
|
599
787
|
}
|