@fluidframework/driver-utils 1.4.0-121020 → 2.0.0-dev-rc.1.0.0.224419
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 +17 -7
- package/.mocharc.js +12 -0
- package/CHANGELOG.md +141 -0
- package/README.md +68 -1
- package/api-extractor-lint.json +4 -0
- package/api-extractor.json +2 -2
- package/api-report/driver-utils.api.md +401 -0
- package/dist/adapters/compression/compressionTypes.cjs +20 -0
- package/dist/adapters/compression/compressionTypes.cjs.map +1 -0
- package/dist/adapters/compression/compressionTypes.d.ts +23 -0
- package/dist/adapters/compression/compressionTypes.d.ts.map +1 -0
- package/dist/adapters/compression/documentServiceCompressionAdapter.cjs +23 -0
- package/dist/adapters/compression/documentServiceCompressionAdapter.cjs.map +1 -0
- package/dist/adapters/compression/documentServiceCompressionAdapter.d.ts +13 -0
- package/dist/adapters/compression/documentServiceCompressionAdapter.d.ts.map +1 -0
- package/dist/adapters/compression/documentServiceFactoryCompressionAdapter.cjs +31 -0
- package/dist/adapters/compression/documentServiceFactoryCompressionAdapter.cjs.map +1 -0
- package/dist/adapters/compression/documentServiceFactoryCompressionAdapter.d.ts +16 -0
- package/dist/adapters/compression/documentServiceFactoryCompressionAdapter.d.ts.map +1 -0
- package/dist/adapters/compression/index.cjs +15 -0
- package/dist/adapters/compression/index.cjs.map +1 -0
- package/dist/adapters/compression/index.d.ts +8 -0
- package/dist/adapters/compression/index.d.ts.map +1 -0
- package/dist/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.cjs +370 -0
- package/dist/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.cjs.map +1 -0
- package/dist/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.d.ts +165 -0
- package/dist/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.d.ts.map +1 -0
- package/dist/adapters/compression/summaryblob/index.cjs +11 -0
- package/dist/adapters/compression/summaryblob/index.cjs.map +1 -0
- package/dist/adapters/compression/summaryblob/index.d.ts +6 -0
- package/dist/adapters/compression/summaryblob/index.d.ts.map +1 -0
- package/dist/adapters/index.cjs +14 -0
- package/dist/adapters/index.cjs.map +1 -0
- package/dist/adapters/index.d.ts +7 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/predefinedAdapters.cjs +52 -0
- package/dist/adapters/predefinedAdapters.cjs.map +1 -0
- package/dist/adapters/predefinedAdapters.d.ts +21 -0
- package/dist/adapters/predefinedAdapters.d.ts.map +1 -0
- package/dist/blob.cjs +65 -0
- package/dist/blob.cjs.map +1 -0
- package/dist/blob.d.ts +56 -0
- package/dist/blob.d.ts.map +1 -0
- package/dist/{buildSnapshotTree.js → buildSnapshotTree.cjs} +7 -5
- package/dist/buildSnapshotTree.cjs.map +1 -0
- package/dist/buildSnapshotTree.d.ts +1 -0
- package/dist/buildSnapshotTree.d.ts.map +1 -1
- package/dist/documentServiceFactoryProxy.cjs +27 -0
- package/dist/documentServiceFactoryProxy.cjs.map +1 -0
- package/dist/documentServiceFactoryProxy.d.ts +19 -0
- package/dist/documentServiceFactoryProxy.d.ts.map +1 -0
- package/dist/documentServiceProxy.cjs +36 -0
- package/dist/documentServiceProxy.cjs.map +1 -0
- package/dist/documentServiceProxy.d.ts +21 -0
- package/dist/documentServiceProxy.d.ts.map +1 -0
- package/dist/{documentStorageServiceProxy.js → documentStorageServiceProxy.cjs} +10 -8
- package/dist/documentStorageServiceProxy.cjs.map +1 -0
- package/dist/documentStorageServiceProxy.d.ts +5 -2
- package/dist/documentStorageServiceProxy.d.ts.map +1 -1
- package/dist/driver-utils-alpha.d.ts +163 -0
- package/dist/driver-utils-beta.d.ts +178 -0
- package/dist/driver-utils-public.d.ts +178 -0
- package/dist/driver-utils-untrimmed.d.ts +590 -0
- package/dist/{error.js → error.cjs} +10 -3
- package/dist/error.cjs.map +1 -0
- package/dist/error.d.ts +8 -3
- package/dist/error.d.ts.map +1 -1
- package/dist/index.cjs +69 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +16 -21
- package/dist/index.d.ts.map +1 -1
- package/dist/{insecureUrlResolver.js → insecureUrlResolver.cjs} +10 -11
- package/dist/insecureUrlResolver.cjs.map +1 -0
- package/dist/insecureUrlResolver.d.ts +1 -0
- package/dist/insecureUrlResolver.d.ts.map +1 -1
- package/dist/messageRecognition.cjs +38 -0
- package/dist/messageRecognition.cjs.map +1 -0
- package/dist/messageRecognition.d.ts +16 -26
- package/dist/messageRecognition.d.ts.map +1 -1
- package/dist/{network.js → network.cjs} +86 -24
- package/dist/network.cjs.map +1 -0
- package/dist/network.d.ts +69 -20
- package/dist/network.d.ts.map +1 -1
- package/dist/networkUtils.cjs +29 -0
- package/dist/networkUtils.cjs.map +1 -0
- package/dist/networkUtils.d.ts +4 -10
- package/dist/networkUtils.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/{parallelRequests.js → parallelRequests.cjs} +146 -74
- package/dist/parallelRequests.cjs.map +1 -0
- package/dist/parallelRequests.d.ts +19 -6
- package/dist/parallelRequests.d.ts.map +1 -1
- package/dist/{prefetchDocumentStorageService.js → prefetchDocumentStorageService.cjs} +7 -4
- package/dist/prefetchDocumentStorageService.cjs.map +1 -0
- package/dist/prefetchDocumentStorageService.d.ts +4 -2
- package/dist/prefetchDocumentStorageService.d.ts.map +1 -1
- package/dist/{rateLimiter.js → rateLimiter.cjs} +6 -3
- package/dist/rateLimiter.cjs.map +1 -0
- package/dist/rateLimiter.d.ts +3 -0
- package/dist/rateLimiter.d.ts.map +1 -1
- package/dist/readAndParse.cjs +28 -0
- package/dist/readAndParse.cjs.map +1 -0
- package/dist/readAndParse.d.ts +10 -4
- package/dist/readAndParse.d.ts.map +1 -1
- package/dist/runWithRetry.cjs +108 -0
- package/dist/runWithRetry.cjs.map +1 -0
- package/dist/runWithRetry.d.ts +26 -7
- package/dist/runWithRetry.d.ts.map +1 -1
- package/dist/{summaryForCreateNew.js → summaryForCreateNew.cjs} +20 -19
- package/dist/summaryForCreateNew.cjs.map +1 -0
- package/dist/summaryForCreateNew.d.ts +17 -4
- package/dist/summaryForCreateNew.d.ts.map +1 -1
- package/dist/{treeConversions.js → treeConversions.cjs} +16 -18
- package/dist/treeConversions.cjs.map +1 -0
- package/dist/treeConversions.d.ts +1 -0
- package/dist/treeConversions.d.ts.map +1 -1
- package/dist/tsdoc-metadata.json +11 -0
- package/lib/adapters/compression/compressionTypes.d.mts +23 -0
- package/lib/adapters/compression/compressionTypes.d.mts.map +1 -0
- package/lib/adapters/compression/compressionTypes.mjs +17 -0
- package/lib/adapters/compression/compressionTypes.mjs.map +1 -0
- package/lib/adapters/compression/documentServiceCompressionAdapter.d.mts +13 -0
- package/lib/adapters/compression/documentServiceCompressionAdapter.d.mts.map +1 -0
- package/lib/adapters/compression/documentServiceCompressionAdapter.mjs +19 -0
- package/lib/adapters/compression/documentServiceCompressionAdapter.mjs.map +1 -0
- package/lib/adapters/compression/documentServiceFactoryCompressionAdapter.d.mts +16 -0
- package/lib/adapters/compression/documentServiceFactoryCompressionAdapter.d.mts.map +1 -0
- package/lib/adapters/compression/documentServiceFactoryCompressionAdapter.mjs +27 -0
- package/lib/adapters/compression/documentServiceFactoryCompressionAdapter.mjs.map +1 -0
- package/lib/adapters/compression/index.d.mts +8 -0
- package/lib/adapters/compression/index.d.mts.map +1 -0
- package/lib/adapters/compression/index.mjs +8 -0
- package/lib/adapters/compression/index.mjs.map +1 -0
- package/lib/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.d.mts +165 -0
- package/lib/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.d.mts.map +1 -0
- package/lib/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.mjs +366 -0
- package/lib/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.mjs.map +1 -0
- package/lib/adapters/compression/summaryblob/index.d.mts +6 -0
- package/lib/adapters/compression/summaryblob/index.d.mts.map +1 -0
- package/lib/adapters/compression/summaryblob/index.mjs +6 -0
- package/lib/adapters/compression/summaryblob/index.mjs.map +1 -0
- package/lib/adapters/index.d.mts +7 -0
- package/lib/adapters/index.d.mts.map +1 -0
- package/lib/adapters/index.mjs +7 -0
- package/lib/adapters/index.mjs.map +1 -0
- package/lib/adapters/predefinedAdapters.d.mts +21 -0
- package/lib/adapters/predefinedAdapters.d.mts.map +1 -0
- package/lib/adapters/predefinedAdapters.mjs +47 -0
- package/lib/adapters/predefinedAdapters.mjs.map +1 -0
- package/lib/blob.d.mts +56 -0
- package/lib/blob.d.mts.map +1 -0
- package/lib/blob.mjs +59 -0
- package/lib/blob.mjs.map +1 -0
- package/lib/{buildSnapshotTree.d.ts → buildSnapshotTree.d.mts} +1 -0
- package/lib/buildSnapshotTree.d.mts.map +1 -0
- package/lib/{buildSnapshotTree.js → buildSnapshotTree.mjs} +6 -4
- package/lib/buildSnapshotTree.mjs.map +1 -0
- package/lib/documentServiceFactoryProxy.d.mts +19 -0
- package/lib/documentServiceFactoryProxy.d.mts.map +1 -0
- package/lib/documentServiceFactoryProxy.mjs +23 -0
- package/lib/documentServiceFactoryProxy.mjs.map +1 -0
- package/lib/documentServiceProxy.d.mts +21 -0
- package/lib/documentServiceProxy.d.mts.map +1 -0
- package/lib/documentServiceProxy.mjs +32 -0
- package/lib/documentServiceProxy.mjs.map +1 -0
- package/lib/{documentStorageServiceProxy.d.ts → documentStorageServiceProxy.d.mts} +5 -2
- package/lib/documentStorageServiceProxy.d.mts.map +1 -0
- package/lib/{documentStorageServiceProxy.js → documentStorageServiceProxy.mjs} +10 -8
- package/lib/documentStorageServiceProxy.mjs.map +1 -0
- package/lib/driver-utils-alpha.d.mts +163 -0
- package/lib/driver-utils-beta.d.mts +178 -0
- package/lib/driver-utils-public.d.mts +178 -0
- package/lib/driver-utils-untrimmed.d.mts +590 -0
- package/lib/error.d.mts +16 -0
- package/lib/error.d.mts.map +1 -0
- package/lib/error.mjs +19 -0
- package/lib/error.mjs.map +1 -0
- package/lib/index.d.mts +21 -0
- package/lib/index.d.mts.map +1 -0
- package/lib/index.mjs +21 -0
- package/lib/index.mjs.map +1 -0
- package/lib/{insecureUrlResolver.d.ts → insecureUrlResolver.d.mts} +1 -0
- package/lib/insecureUrlResolver.d.mts.map +1 -0
- package/lib/{insecureUrlResolver.js → insecureUrlResolver.mjs} +10 -11
- package/lib/insecureUrlResolver.mjs.map +1 -0
- package/lib/messageRecognition.d.mts +24 -0
- package/lib/messageRecognition.d.mts.map +1 -0
- package/lib/messageRecognition.mjs +29 -0
- package/lib/messageRecognition.mjs.map +1 -0
- package/lib/{network.d.ts → network.d.mts} +69 -20
- package/lib/network.d.mts.map +1 -0
- package/lib/{network.js → network.mjs} +85 -23
- package/lib/network.mjs.map +1 -0
- package/lib/networkUtils.d.mts +11 -0
- package/lib/networkUtils.d.mts.map +1 -0
- package/lib/networkUtils.mjs +25 -0
- package/lib/networkUtils.mjs.map +1 -0
- package/lib/{packageVersion.d.ts → packageVersion.d.mts} +1 -1
- package/lib/{packageVersion.d.ts.map → packageVersion.d.mts.map} +1 -1
- package/lib/{packageVersion.js → packageVersion.mjs} +2 -2
- package/lib/packageVersion.mjs.map +1 -0
- package/lib/{parallelRequests.d.ts → parallelRequests.d.mts} +19 -6
- package/lib/parallelRequests.d.mts.map +1 -0
- package/lib/{parallelRequests.js → parallelRequests.mjs} +119 -52
- package/lib/parallelRequests.mjs.map +1 -0
- package/lib/{prefetchDocumentStorageService.d.ts → prefetchDocumentStorageService.d.mts} +5 -7
- package/lib/prefetchDocumentStorageService.d.mts.map +1 -0
- package/lib/{prefetchDocumentStorageService.js → prefetchDocumentStorageService.mjs} +7 -8
- package/lib/prefetchDocumentStorageService.mjs.map +1 -0
- package/lib/{rateLimiter.d.ts → rateLimiter.d.mts} +3 -0
- package/lib/rateLimiter.d.mts.map +1 -0
- package/lib/{rateLimiter.js → rateLimiter.mjs} +5 -2
- package/lib/rateLimiter.mjs.map +1 -0
- package/lib/readAndParse.d.mts +20 -0
- package/lib/readAndParse.d.mts.map +1 -0
- package/lib/readAndParse.mjs +24 -0
- package/lib/readAndParse.mjs.map +1 -0
- package/lib/{runWithRetry.d.ts → runWithRetry.d.mts} +26 -7
- package/lib/runWithRetry.d.mts.map +1 -0
- package/lib/runWithRetry.mjs +103 -0
- package/lib/runWithRetry.mjs.map +1 -0
- package/lib/{summaryForCreateNew.d.ts → summaryForCreateNew.d.mts} +17 -4
- package/lib/summaryForCreateNew.d.mts.map +1 -0
- package/lib/{summaryForCreateNew.js → summaryForCreateNew.mjs} +18 -17
- package/lib/summaryForCreateNew.mjs.map +1 -0
- package/lib/{treeConversions.d.ts → treeConversions.d.mts} +1 -0
- package/lib/treeConversions.d.mts.map +1 -0
- package/lib/{treeConversions.js → treeConversions.mjs} +12 -14
- package/lib/treeConversions.mjs.map +1 -0
- package/package.json +88 -64
- package/prettier.config.cjs +8 -0
- package/src/adapters/compression/compressionTypes.ts +25 -0
- package/src/adapters/compression/documentServiceCompressionAdapter.ts +28 -0
- package/src/adapters/compression/documentServiceFactoryCompressionAdapter.ts +54 -0
- package/src/adapters/compression/index.ts +12 -0
- package/src/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.ts +451 -0
- package/src/adapters/compression/summaryblob/index.ts +9 -0
- package/src/adapters/index.ts +13 -0
- package/src/adapters/predefinedAdapters.ts +74 -0
- package/src/blob.ts +77 -0
- package/src/buildSnapshotTree.ts +58 -53
- package/src/documentServiceFactoryProxy.ts +47 -0
- package/src/documentServiceProxy.ts +46 -0
- package/src/documentStorageServiceProxy.ts +52 -37
- package/src/error.ts +13 -8
- package/src/index.ts +51 -21
- package/src/insecureUrlResolver.ts +125 -120
- package/src/messageRecognition.ts +24 -53
- package/src/network.ts +189 -111
- package/src/networkUtils.ts +24 -49
- package/src/packageVersion.ts +1 -1
- package/src/parallelRequests.ts +630 -519
- package/src/prefetchDocumentStorageService.ts +79 -74
- package/src/rateLimiter.ts +33 -30
- package/src/readAndParse.ts +18 -9
- package/src/runWithRetry.ts +145 -85
- package/src/summaryForCreateNew.ts +48 -29
- package/src/treeConversions.ts +49 -70
- package/tsc-multi.test.json +4 -0
- package/tsconfig.json +10 -12
- package/dist/blobAggregationStorage.d.ts +0 -43
- package/dist/blobAggregationStorage.d.ts.map +0 -1
- package/dist/blobAggregationStorage.js +0 -318
- package/dist/blobAggregationStorage.js.map +0 -1
- package/dist/blobCacheStorageService.d.ts +0 -16
- package/dist/blobCacheStorageService.d.ts.map +0 -1
- package/dist/blobCacheStorageService.js +0 -29
- package/dist/blobCacheStorageService.js.map +0 -1
- package/dist/buildSnapshotTree.js.map +0 -1
- package/dist/documentStorageServiceProxy.js.map +0 -1
- package/dist/emptyDocumentDeltaStorageService.d.ts +0 -13
- package/dist/emptyDocumentDeltaStorageService.d.ts.map +0 -1
- package/dist/emptyDocumentDeltaStorageService.js +0 -20
- package/dist/emptyDocumentDeltaStorageService.js.map +0 -1
- package/dist/error.js.map +0 -1
- package/dist/fluidResolvedUrl.d.ts +0 -8
- package/dist/fluidResolvedUrl.d.ts.map +0 -1
- package/dist/fluidResolvedUrl.js +0 -16
- package/dist/fluidResolvedUrl.js.map +0 -1
- package/dist/index.js +0 -38
- package/dist/index.js.map +0 -1
- package/dist/insecureUrlResolver.js.map +0 -1
- package/dist/messageRecognition.js +0 -73
- package/dist/messageRecognition.js.map +0 -1
- package/dist/multiDocumentServiceFactory.d.ts +0 -16
- package/dist/multiDocumentServiceFactory.d.ts.map +0 -1
- package/dist/multiDocumentServiceFactory.js +0 -63
- package/dist/multiDocumentServiceFactory.js.map +0 -1
- package/dist/multiUrlResolver.d.ts +0 -20
- package/dist/multiUrlResolver.d.ts.map +0 -1
- package/dist/multiUrlResolver.js +0 -45
- package/dist/multiUrlResolver.js.map +0 -1
- package/dist/network.js.map +0 -1
- package/dist/networkUtils.js +0 -59
- package/dist/networkUtils.js.map +0 -1
- package/dist/packageVersion.js.map +0 -1
- package/dist/parallelRequests.js.map +0 -1
- package/dist/prefetchDocumentStorageService.js.map +0 -1
- package/dist/rateLimiter.js.map +0 -1
- package/dist/readAndParse.js +0 -22
- package/dist/readAndParse.js.map +0 -1
- package/dist/runWithRetry.js +0 -69
- package/dist/runWithRetry.js.map +0 -1
- package/dist/summaryForCreateNew.js.map +0 -1
- package/dist/treeConversions.js.map +0 -1
- package/dist/treeUtils.d.ts +0 -51
- package/dist/treeUtils.d.ts.map +0 -1
- package/dist/treeUtils.js +0 -85
- package/dist/treeUtils.js.map +0 -1
- package/lib/blobAggregationStorage.d.ts +0 -43
- package/lib/blobAggregationStorage.d.ts.map +0 -1
- package/lib/blobAggregationStorage.js +0 -313
- package/lib/blobAggregationStorage.js.map +0 -1
- package/lib/blobCacheStorageService.d.ts +0 -16
- package/lib/blobCacheStorageService.d.ts.map +0 -1
- package/lib/blobCacheStorageService.js +0 -25
- package/lib/blobCacheStorageService.js.map +0 -1
- package/lib/buildSnapshotTree.d.ts.map +0 -1
- package/lib/buildSnapshotTree.js.map +0 -1
- package/lib/documentStorageServiceProxy.d.ts.map +0 -1
- package/lib/documentStorageServiceProxy.js.map +0 -1
- package/lib/emptyDocumentDeltaStorageService.d.ts +0 -13
- package/lib/emptyDocumentDeltaStorageService.d.ts.map +0 -1
- package/lib/emptyDocumentDeltaStorageService.js +0 -16
- package/lib/emptyDocumentDeltaStorageService.js.map +0 -1
- package/lib/error.d.ts +0 -11
- package/lib/error.d.ts.map +0 -1
- package/lib/error.js +0 -13
- package/lib/error.js.map +0 -1
- package/lib/fluidResolvedUrl.d.ts +0 -8
- package/lib/fluidResolvedUrl.d.ts.map +0 -1
- package/lib/fluidResolvedUrl.js +0 -11
- package/lib/fluidResolvedUrl.js.map +0 -1
- package/lib/index.d.ts +0 -26
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js +0 -26
- package/lib/index.js.map +0 -1
- package/lib/insecureUrlResolver.d.ts.map +0 -1
- package/lib/insecureUrlResolver.js.map +0 -1
- package/lib/messageRecognition.d.ts +0 -38
- package/lib/messageRecognition.d.ts.map +0 -1
- package/lib/messageRecognition.js +0 -67
- package/lib/messageRecognition.js.map +0 -1
- package/lib/multiDocumentServiceFactory.d.ts +0 -16
- package/lib/multiDocumentServiceFactory.d.ts.map +0 -1
- package/lib/multiDocumentServiceFactory.js +0 -59
- package/lib/multiDocumentServiceFactory.js.map +0 -1
- package/lib/multiUrlResolver.d.ts +0 -20
- package/lib/multiUrlResolver.d.ts.map +0 -1
- package/lib/multiUrlResolver.js +0 -40
- package/lib/multiUrlResolver.js.map +0 -1
- package/lib/network.d.ts.map +0 -1
- package/lib/network.js.map +0 -1
- package/lib/networkUtils.d.ts +0 -17
- package/lib/networkUtils.d.ts.map +0 -1
- package/lib/networkUtils.js +0 -54
- package/lib/networkUtils.js.map +0 -1
- package/lib/packageVersion.js.map +0 -1
- package/lib/parallelRequests.d.ts.map +0 -1
- package/lib/parallelRequests.js.map +0 -1
- package/lib/prefetchDocumentStorageService.d.ts.map +0 -1
- package/lib/prefetchDocumentStorageService.js.map +0 -1
- package/lib/rateLimiter.d.ts.map +0 -1
- package/lib/rateLimiter.js.map +0 -1
- package/lib/readAndParse.d.ts +0 -14
- package/lib/readAndParse.d.ts.map +0 -1
- package/lib/readAndParse.js +0 -18
- package/lib/readAndParse.js.map +0 -1
- package/lib/runWithRetry.d.ts.map +0 -1
- package/lib/runWithRetry.js +0 -65
- package/lib/runWithRetry.js.map +0 -1
- package/lib/summaryForCreateNew.d.ts.map +0 -1
- package/lib/summaryForCreateNew.js.map +0 -1
- package/lib/treeConversions.d.ts.map +0 -1
- package/lib/treeConversions.js.map +0 -1
- package/lib/treeUtils.d.ts +0 -51
- package/lib/treeUtils.d.ts.map +0 -1
- package/lib/treeUtils.js +0 -80
- package/lib/treeUtils.js.map +0 -1
- package/src/blobAggregationStorage.ts +0 -374
- package/src/blobCacheStorageService.ts +0 -32
- package/src/emptyDocumentDeltaStorageService.ts +0 -24
- package/src/fluidResolvedUrl.ts +0 -15
- package/src/multiDocumentServiceFactory.ts +0 -80
- package/src/multiUrlResolver.ts +0 -51
- package/src/treeUtils.ts +0 -111
- package/tsconfig.esnext.json +0 -7
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ITelemetryProperties } from "@fluidframework/core-interfaces";
|
|
2
|
+
import { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils";
|
|
2
3
|
import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
|
|
3
4
|
import { IDeltasFetchResult, IStream, IStreamResult } from "@fluidframework/driver-definitions";
|
|
4
5
|
/**
|
|
@@ -7,11 +8,12 @@ import { IDeltasFetchResult, IStream, IStreamResult } from "@fluidframework/driv
|
|
|
7
8
|
* data in the right order. Take a look at UT for examples.
|
|
8
9
|
* @param concurrency - level of concurrency
|
|
9
10
|
* @param from - starting point of fetching data (inclusive)
|
|
10
|
-
* @param to
|
|
11
|
+
* @param to - ending point of fetching data. exclusive, or undefined if unknown
|
|
11
12
|
* @param payloadSize - batch size
|
|
12
13
|
* @param logger - logger to use
|
|
13
14
|
* @param requestCallback - callback to request batches
|
|
14
|
-
* @returns
|
|
15
|
+
* @returns Queue that can be used to retrieve data
|
|
16
|
+
* @internal
|
|
15
17
|
*/
|
|
16
18
|
export declare class ParallelRequests<T> {
|
|
17
19
|
private to;
|
|
@@ -29,7 +31,7 @@ export declare class ParallelRequests<T> {
|
|
|
29
31
|
private readonly knewTo;
|
|
30
32
|
private get working();
|
|
31
33
|
get canceled(): boolean;
|
|
32
|
-
constructor(from: number, to: number | undefined, payloadSize: number, logger:
|
|
34
|
+
constructor(from: number, to: number | undefined, payloadSize: number, logger: ITelemetryLoggerExt, requestCallback: (request: number, from: number, to: number, strongTo: boolean, props: ITelemetryProperties) => Promise<{
|
|
33
35
|
partial: boolean;
|
|
34
36
|
cancel: boolean;
|
|
35
37
|
payload: T[];
|
|
@@ -46,6 +48,7 @@ export declare class ParallelRequests<T> {
|
|
|
46
48
|
/**
|
|
47
49
|
* Helper queue class to allow async push / pull
|
|
48
50
|
* It's essentially a pipe allowing multiple writers, and single reader
|
|
51
|
+
* @internal
|
|
49
52
|
*/
|
|
50
53
|
export declare class Queue<T> implements IStream<T> {
|
|
51
54
|
private readonly queue;
|
|
@@ -67,10 +70,20 @@ export declare class Queue<T> implements IStream<T> {
|
|
|
67
70
|
* @param logger - Logger to log progress and errors
|
|
68
71
|
* @param signal - Cancelation signal
|
|
69
72
|
* @param scenarioName - Reason for fetching ops
|
|
70
|
-
* @returns
|
|
73
|
+
* @returns Messages fetched
|
|
74
|
+
* @internal
|
|
75
|
+
*/
|
|
76
|
+
export declare function requestOps(get: (from: number, to: number, telemetryProps: ITelemetryProperties) => Promise<IDeltasFetchResult>, concurrency: number, fromTotal: number, toTotal: number | undefined, payloadSize: number, logger: ITelemetryLoggerExt, signal?: AbortSignal, scenarioName?: string): IStream<ISequencedDocumentMessage[]>;
|
|
77
|
+
/**
|
|
78
|
+
* @internal
|
|
71
79
|
*/
|
|
72
|
-
export declare function requestOps(get: (from: number, to: number, telemetryProps: ITelemetryProperties) => Promise<IDeltasFetchResult>, concurrency: number, fromTotal: number, toTotal: number | undefined, payloadSize: number, logger: ITelemetryLogger, signal?: AbortSignal, scenarioName?: string): IStream<ISequencedDocumentMessage[]>;
|
|
73
80
|
export declare const emptyMessageStream: IStream<ISequencedDocumentMessage[]>;
|
|
81
|
+
/**
|
|
82
|
+
* @internal
|
|
83
|
+
*/
|
|
74
84
|
export declare function streamFromMessages(messagesArg: Promise<ISequencedDocumentMessage[]>): IStream<ISequencedDocumentMessage[]>;
|
|
85
|
+
/**
|
|
86
|
+
* @internal
|
|
87
|
+
*/
|
|
75
88
|
export declare function streamObserver<T>(stream: IStream<T>, handler: (value: IStreamResult<T>) => void): IStream<T>;
|
|
76
89
|
//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AAE,CAInE,CAAC;AAEF;;GAEG;AACH,wBAAgB,kBAAkB,CACjC,WAAW,EAAE,OAAO,CAAC,yBAAyB,EAAE,CAAC,GAC/C,OAAO,CAAC,yBAAyB,EAAE,CAAC,CAYtC;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAC/B,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,EAClB,OAAO,EAAE,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,IAAI,GACxC,OAAO,CAAC,CAAC,CAAC,CAQZ"}
|
|
@@ -1,28 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
import { assert, Deferred, performance } from "@fluidframework/common-utils";
|
|
1
|
+
import { performance } from "@fluid-internal/client-utils";
|
|
2
|
+
import { assert, Deferred } from "@fluidframework/core-utils";
|
|
6
3
|
import { PerformanceEvent } from "@fluidframework/telemetry-utils";
|
|
7
|
-
import { getRetryDelayFromError, canRetryOnError, createGenericNetworkError } from "./network";
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
const MissingFetchDelayInMs =
|
|
4
|
+
import { getRetryDelayFromError, canRetryOnError, createGenericNetworkError } from "./network.mjs";
|
|
5
|
+
import { logNetworkFailure } from "./networkUtils.mjs";
|
|
6
|
+
import { pkgVersion as driverVersion } from "./packageVersion.mjs";
|
|
7
|
+
import { calculateMaxWaitTime } from "./runWithRetry.mjs";
|
|
8
|
+
// We double this value in first try in when we calculate time to wait for in "calculateMaxWaitTime" function.
|
|
9
|
+
const MissingFetchDelayInMs = 50;
|
|
13
10
|
/**
|
|
14
11
|
* Helper class to organize parallel fetching of data
|
|
15
12
|
* It can be used to concurrently do many requests, while consuming
|
|
16
13
|
* data in the right order. Take a look at UT for examples.
|
|
17
14
|
* @param concurrency - level of concurrency
|
|
18
15
|
* @param from - starting point of fetching data (inclusive)
|
|
19
|
-
* @param to
|
|
16
|
+
* @param to - ending point of fetching data. exclusive, or undefined if unknown
|
|
20
17
|
* @param payloadSize - batch size
|
|
21
18
|
* @param logger - logger to use
|
|
22
19
|
* @param requestCallback - callback to request batches
|
|
23
|
-
* @returns
|
|
20
|
+
* @returns Queue that can be used to retrieve data
|
|
21
|
+
* @internal
|
|
24
22
|
*/
|
|
25
23
|
export class ParallelRequests {
|
|
24
|
+
get working() {
|
|
25
|
+
return this.workingState === "working";
|
|
26
|
+
}
|
|
27
|
+
get canceled() {
|
|
28
|
+
return this.workingState === "canceled";
|
|
29
|
+
}
|
|
26
30
|
constructor(from, to, payloadSize, logger, requestCallback, responseCallback) {
|
|
27
31
|
this.to = to;
|
|
28
32
|
this.payloadSize = payloadSize;
|
|
@@ -36,10 +40,8 @@ export class ParallelRequests {
|
|
|
36
40
|
this.requests = 0;
|
|
37
41
|
this.latestRequested = from;
|
|
38
42
|
this.nextToDeliver = from;
|
|
39
|
-
this.knewTo =
|
|
43
|
+
this.knewTo = to !== undefined;
|
|
40
44
|
}
|
|
41
|
-
get working() { return this.workingState === "working"; }
|
|
42
|
-
get canceled() { return this.workingState === "canceled"; }
|
|
43
45
|
cancel() {
|
|
44
46
|
if (this.working) {
|
|
45
47
|
this.workingState = "canceled";
|
|
@@ -173,7 +175,7 @@ export class ParallelRequests {
|
|
|
173
175
|
if (this.working) {
|
|
174
176
|
const fromOrig = from;
|
|
175
177
|
const length = payload.length;
|
|
176
|
-
let fullChunk =
|
|
178
|
+
let fullChunk = requestedLength <= length; // we can possible get more than we asked.
|
|
177
179
|
if (length !== 0) {
|
|
178
180
|
// We can get more than we asked for!
|
|
179
181
|
// This can screw up logic in dispatch!
|
|
@@ -231,9 +233,10 @@ export class ParallelRequests {
|
|
|
231
233
|
if (to === this.latestRequested) {
|
|
232
234
|
// we can go after full chunk at the end if we received partial chunk, or more than asked
|
|
233
235
|
// Also if we got more than we asked to, we can actually use those ops!
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
from
|
|
236
|
+
while (payload.length !== 0) {
|
|
237
|
+
const data = payload.splice(0, requestedLength);
|
|
238
|
+
this.results.set(from, data);
|
|
239
|
+
from += data.length;
|
|
237
240
|
}
|
|
238
241
|
this.latestRequested = from;
|
|
239
242
|
fullChunk = true;
|
|
@@ -255,6 +258,7 @@ export class ParallelRequests {
|
|
|
255
258
|
/**
|
|
256
259
|
* Helper queue class to allow async push / pull
|
|
257
260
|
* It's essentially a pipe allowing multiple writers, and single reader
|
|
261
|
+
* @internal
|
|
258
262
|
*/
|
|
259
263
|
export class Queue {
|
|
260
264
|
constructor() {
|
|
@@ -294,6 +298,18 @@ export class Queue {
|
|
|
294
298
|
return this.deferred.promise;
|
|
295
299
|
}
|
|
296
300
|
}
|
|
301
|
+
const waitForOnline = async () => {
|
|
302
|
+
// Only wait if we have a strong signal that we're offline - otherwise assume we're online.
|
|
303
|
+
if (globalThis.navigator?.onLine === false && globalThis.addEventListener !== undefined) {
|
|
304
|
+
return new Promise((resolve) => {
|
|
305
|
+
const resolveAndRemoveListener = () => {
|
|
306
|
+
resolve();
|
|
307
|
+
globalThis.removeEventListener("online", resolveAndRemoveListener);
|
|
308
|
+
};
|
|
309
|
+
globalThis.addEventListener("online", resolveAndRemoveListener);
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
};
|
|
297
313
|
/**
|
|
298
314
|
* Retrieve single batch of ops
|
|
299
315
|
* @param request - request index
|
|
@@ -305,30 +321,38 @@ export class Queue {
|
|
|
305
321
|
* @param logger - logger object to use to log progress & errors
|
|
306
322
|
* @param signal - cancelation signal
|
|
307
323
|
* @param scenarioName - reason for fetching ops
|
|
308
|
-
* @returns
|
|
324
|
+
* @returns An object with resulting ops and cancellation / partial result flags
|
|
309
325
|
*/
|
|
310
326
|
async function getSingleOpBatch(get, props, strongTo, logger, signal, scenarioName) {
|
|
311
327
|
let lastSuccessTime;
|
|
328
|
+
let totalRetryAfterTime = 0;
|
|
329
|
+
let telemetryEvent;
|
|
312
330
|
let retry = 0;
|
|
313
|
-
const deltas = [];
|
|
314
331
|
const nothing = { partial: false, cancel: true, payload: [] };
|
|
315
|
-
|
|
332
|
+
let waitStartTime = 0;
|
|
333
|
+
let waitTime = MissingFetchDelayInMs;
|
|
334
|
+
while (signal?.aborted !== true) {
|
|
316
335
|
retry++;
|
|
317
|
-
let
|
|
336
|
+
let lastError;
|
|
318
337
|
const startTime = performance.now();
|
|
319
338
|
try {
|
|
320
|
-
// Issue async request for deltas
|
|
321
|
-
const
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
339
|
+
// Issue async request for deltas
|
|
340
|
+
const { messages, partialResult } = await get({ ...props, retry } /* telemetry props */);
|
|
341
|
+
// If we got messages back, return them. Return regardless of whether we got messages back if we didn't
|
|
342
|
+
// specify a "to", since we don't have an expectation of how many to receive.
|
|
343
|
+
if (messages.length !== 0 || !strongTo) {
|
|
344
|
+
// Report this event if we waited to fetch ops due to being offline or throttling.
|
|
345
|
+
telemetryEvent?.end({
|
|
346
|
+
duration: totalRetryAfterTime,
|
|
347
|
+
...props,
|
|
348
|
+
reason: scenarioName,
|
|
349
|
+
});
|
|
350
|
+
return { payload: messages, cancel: false, partial: partialResult };
|
|
327
351
|
}
|
|
328
|
-
//
|
|
329
|
-
// Attempt to fetch more deltas. If we didn't receive any in the previous call we up our retry
|
|
330
|
-
// count since something prevented us from seeing those deltas
|
|
352
|
+
// Otherwise, the storage gave us back an empty set of ops but we were expecting a non-empty set.
|
|
331
353
|
if (lastSuccessTime === undefined) {
|
|
354
|
+
// Take timestamp of the first time server responded successfully, even though it wasn't with the ops we asked for.
|
|
355
|
+
// If we keep getting empty responses we'll eventually fail out below.
|
|
332
356
|
lastSuccessTime = performance.now();
|
|
333
357
|
}
|
|
334
358
|
else if (performance.now() - lastSuccessTime > 30000) {
|
|
@@ -338,25 +362,48 @@ async function getSingleOpBatch(get, props, strongTo, logger, signal, scenarioNa
|
|
|
338
362
|
// current as it can't get ops.
|
|
339
363
|
throw createGenericNetworkError(
|
|
340
364
|
// pre-0.58 error message: failedToRetrieveOpsFromStorage:TooManyRetries
|
|
341
|
-
"Failed to retrieve ops from storage (Too Many Retries)", { canRetry: false },
|
|
342
|
-
|
|
365
|
+
"Failed to retrieve ops from storage (Too Many Retries)", { canRetry: false }, {
|
|
366
|
+
retry,
|
|
367
|
+
driverVersion,
|
|
368
|
+
...props,
|
|
369
|
+
});
|
|
343
370
|
}
|
|
344
371
|
}
|
|
345
372
|
catch (error) {
|
|
373
|
+
lastError = error;
|
|
346
374
|
const canRetry = canRetryOnError(error);
|
|
347
|
-
lastSuccessTime = undefined;
|
|
348
375
|
const retryAfter = getRetryDelayFromError(error);
|
|
349
376
|
// This will log to error table only if the error is non-retryable
|
|
350
|
-
logNetworkFailure(logger,
|
|
377
|
+
logNetworkFailure(logger, {
|
|
378
|
+
eventName: "GetDeltas_Error",
|
|
379
|
+
...props,
|
|
380
|
+
retry,
|
|
381
|
+
duration: performance.now() - startTime,
|
|
382
|
+
retryAfter,
|
|
383
|
+
reason: scenarioName,
|
|
384
|
+
}, error);
|
|
351
385
|
if (!canRetry) {
|
|
352
386
|
// It's game over scenario.
|
|
353
387
|
throw error;
|
|
354
388
|
}
|
|
355
|
-
if (retryAfter !== undefined && retryAfter >= 0) {
|
|
356
|
-
delay = retryAfter;
|
|
357
|
-
}
|
|
358
389
|
}
|
|
359
|
-
|
|
390
|
+
if (telemetryEvent === undefined) {
|
|
391
|
+
waitStartTime = performance.now();
|
|
392
|
+
telemetryEvent = PerformanceEvent.start(logger, {
|
|
393
|
+
eventName: "GetDeltasWaitTime",
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
waitTime = calculateMaxWaitTime(waitTime, lastError);
|
|
397
|
+
// If we get here something has gone wrong - either got an unexpected empty set of messages back or a real error.
|
|
398
|
+
// Either way we will wait a little bit before retrying.
|
|
399
|
+
await new Promise((resolve) => {
|
|
400
|
+
setTimeout(resolve, waitTime);
|
|
401
|
+
});
|
|
402
|
+
// If we believe we're offline, we assume there's no point in trying until we at least think we're online.
|
|
403
|
+
// NOTE: This isn't strictly true for drivers that don't require network (e.g. local driver). Really this logic
|
|
404
|
+
// should probably live in the driver.
|
|
405
|
+
await waitForOnline();
|
|
406
|
+
totalRetryAfterTime += performance.now() - waitStartTime;
|
|
360
407
|
}
|
|
361
408
|
return nothing;
|
|
362
409
|
}
|
|
@@ -370,7 +417,8 @@ async function getSingleOpBatch(get, props, strongTo, logger, signal, scenarioNa
|
|
|
370
417
|
* @param logger - Logger to log progress and errors
|
|
371
418
|
* @param signal - Cancelation signal
|
|
372
419
|
* @param scenarioName - Reason for fetching ops
|
|
373
|
-
* @returns
|
|
420
|
+
* @returns Messages fetched
|
|
421
|
+
* @internal
|
|
374
422
|
*/
|
|
375
423
|
export function requestOps(get, concurrency, fromTotal, toTotal, payloadSize, logger, signal, scenarioName) {
|
|
376
424
|
let requests = 0;
|
|
@@ -381,10 +429,14 @@ export function requestOps(get, concurrency, fromTotal, toTotal, payloadSize, lo
|
|
|
381
429
|
fromTotal,
|
|
382
430
|
toTotal,
|
|
383
431
|
};
|
|
384
|
-
const telemetryEvent = PerformanceEvent.start(logger,
|
|
432
|
+
const telemetryEvent = PerformanceEvent.start(logger, {
|
|
433
|
+
eventName: "GetDeltas",
|
|
434
|
+
...propsTotal,
|
|
435
|
+
reason: scenarioName,
|
|
436
|
+
});
|
|
385
437
|
const manager = new ParallelRequests(fromTotal, toTotal, payloadSize, logger, async (request, from, to, strongTo, propsPerRequest) => {
|
|
386
438
|
requests++;
|
|
387
|
-
return getSingleOpBatch(async (propsAll) => get(from, to, propsAll),
|
|
439
|
+
return getSingleOpBatch(async (propsAll) => get(from, to, propsAll), { request, from, to, ...propsTotal, ...propsPerRequest }, strongTo, logger, signal, scenarioName);
|
|
388
440
|
}, (deltas) => {
|
|
389
441
|
// Assert continuing and right start.
|
|
390
442
|
if (lastFetch === undefined) {
|
|
@@ -402,26 +454,30 @@ export function requestOps(get, concurrency, fromTotal, toTotal, payloadSize, lo
|
|
|
402
454
|
// waits (up to 10 seconds) and fetches (can take infinite amount of time).
|
|
403
455
|
// While every such case should be improved and take into account signal (and thus cancel immediately),
|
|
404
456
|
// it is beneficial to have catch-all
|
|
405
|
-
const listener = (event) => {
|
|
457
|
+
const listener = (event) => {
|
|
458
|
+
manager.cancel();
|
|
459
|
+
};
|
|
406
460
|
if (signal !== undefined) {
|
|
407
461
|
signal.addEventListener("abort", listener);
|
|
408
462
|
}
|
|
409
|
-
manager
|
|
463
|
+
manager
|
|
464
|
+
.run(concurrency)
|
|
410
465
|
.finally(() => {
|
|
411
466
|
if (signal !== undefined) {
|
|
412
467
|
signal.removeEventListener("abort", listener);
|
|
413
468
|
}
|
|
414
|
-
})
|
|
469
|
+
})
|
|
470
|
+
.then(() => {
|
|
415
471
|
const props = {
|
|
416
472
|
lastFetch,
|
|
417
473
|
length,
|
|
418
474
|
requests,
|
|
419
475
|
};
|
|
420
476
|
if (manager.canceled) {
|
|
421
|
-
telemetryEvent.cancel(
|
|
477
|
+
telemetryEvent.cancel({ ...props, error: "ops request cancelled by client" });
|
|
422
478
|
}
|
|
423
479
|
else {
|
|
424
|
-
assert(toTotal === undefined || lastFetch !== undefined && lastFetch >= toTotal - 1, 0x270 /* "All requested ops fetched" */);
|
|
480
|
+
assert(toTotal === undefined || (lastFetch !== undefined && lastFetch >= toTotal - 1), 0x270 /* "All requested ops fetched" */);
|
|
425
481
|
telemetryEvent.end(props);
|
|
426
482
|
}
|
|
427
483
|
queue.pushDone();
|
|
@@ -436,9 +492,17 @@ export function requestOps(get, concurrency, fromTotal, toTotal, payloadSize, lo
|
|
|
436
492
|
});
|
|
437
493
|
return queue;
|
|
438
494
|
}
|
|
495
|
+
/**
|
|
496
|
+
* @internal
|
|
497
|
+
*/
|
|
439
498
|
export const emptyMessageStream = {
|
|
440
|
-
read: async () => {
|
|
499
|
+
read: async () => {
|
|
500
|
+
return { done: true };
|
|
501
|
+
},
|
|
441
502
|
};
|
|
503
|
+
/**
|
|
504
|
+
* @internal
|
|
505
|
+
*/
|
|
442
506
|
export function streamFromMessages(messagesArg) {
|
|
443
507
|
let messages = messagesArg;
|
|
444
508
|
return {
|
|
@@ -452,6 +516,9 @@ export function streamFromMessages(messagesArg) {
|
|
|
452
516
|
},
|
|
453
517
|
};
|
|
454
518
|
}
|
|
519
|
+
/**
|
|
520
|
+
* @internal
|
|
521
|
+
*/
|
|
455
522
|
export function streamObserver(stream, handler) {
|
|
456
523
|
return {
|
|
457
524
|
read: async () => {
|
|
@@ -461,4 +528,4 @@ export function streamObserver(stream, handler) {
|
|
|
461
528
|
},
|
|
462
529
|
};
|
|
463
530
|
}
|
|
464
|
-
//# sourceMappingURL=parallelRequests.
|
|
531
|
+
//# sourceMappingURL=parallelRequests.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parallelRequests.mjs","sourceRoot":"","sources":["../src/parallelRequests.ts"],"names":[],"mappings":"OAIO,EAAE,WAAW,EAAE,MAAM,8BAA8B;OAEnD,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,4BAA4B;OACtD,EAAuB,gBAAgB,EAAE,MAAM,iCAAiC;OAGhF,EAAE,sBAAsB,EAAE,eAAe,EAAE,yBAAyB,EAAE;OACtE,EAAE,iBAAiB,EAAE;OAErB,EAAE,UAAU,IAAI,aAAa,EAAE;OAC/B,EAAE,oBAAoB,EAAE;AAE/B,8GAA8G;AAC9G,MAAM,qBAAqB,GAAG,EAAE,CAAC;AAIjC;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,gBAAgB;IAU5B,IAAY,OAAO;QAClB,OAAO,IAAI,CAAC,YAAY,KAAK,SAAS,CAAC;IACxC,CAAC;IACD,IAAW,QAAQ;QAClB,OAAO,IAAI,CAAC,YAAY,KAAK,UAAU,CAAC;IACzC,CAAC;IAED,YACC,IAAY,EACJ,EAAsB,EACb,WAAmB,EACnB,MAA2B,EAC3B,e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,QAAQ;SACR,EACD,KAAK,CACL,CAAC;QACF,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACxB,CAAC,CAAC,CAAC;IAEJ,OAAO,KAAK,CAAC;AACd,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAyC;IACvE,IAAI,EAAE,KAAK,IAAI,EAAE;QAChB,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IACvB,CAAC;CACD,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,kBAAkB,CACjC,WAAiD;IAEjD,IAAI,QAAQ,GAAqD,WAAW,CAAC;IAC7E,OAAO;QACN,IAAI,EAAE,KAAK,IAAI,EAAE;YAChB,IAAI,QAAQ,KAAK,SAAS,EAAE;gBAC3B,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;aACtB;YACD,MAAM,KAAK,GAAG,MAAM,QAAQ,CAAC;YAC7B,QAAQ,GAAG,SAAS,CAAC;YACrB,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;QACrE,CAAC;KACD,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAC7B,MAAkB,EAClB,OAA0C;IAE1C,OAAO;QACN,IAAI,EAAE,KAAK,IAAI,EAAE;YAChB,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;YAClC,OAAO,CAAC,KAAK,CAAC,CAAC;YACf,OAAO,KAAK,CAAC;QACd,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { performance } from \"@fluid-internal/client-utils\";\nimport { ITelemetryProperties } from \"@fluidframework/core-interfaces\";\nimport { assert, Deferred } from \"@fluidframework/core-utils\";\nimport { ITelemetryLoggerExt, PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { IDeltasFetchResult, IStream, IStreamResult } from \"@fluidframework/driver-definitions\";\nimport { getRetryDelayFromError, canRetryOnError, createGenericNetworkError } from \"./network\";\nimport { logNetworkFailure } from \"./networkUtils\";\n// For now, this package is versioned and released in unison with the specific drivers\nimport { pkgVersion as driverVersion } from \"./packageVersion\";\nimport { calculateMaxWaitTime } from \"./runWithRetry\";\n\n// We double this value in first try in when we calculate time to wait for in \"calculateMaxWaitTime\" function.\nconst MissingFetchDelayInMs = 50;\n\ntype WorkingState = \"working\" | \"done\" | \"canceled\";\n\n/**\n * Helper class to organize parallel fetching of data\n * It can be used to concurrently do many requests, while consuming\n * data in the right order. Take a look at UT for examples.\n * @param concurrency - level of concurrency\n * @param from - starting point of fetching data (inclusive)\n * @param to - ending point of fetching data. exclusive, or undefined if unknown\n * @param payloadSize - batch size\n * @param logger - logger to use\n * @param requestCallback - callback to request batches\n * @returns Queue that can be used to retrieve data\n * @internal\n */\nexport class ParallelRequests<T> {\n\tprivate latestRequested: number;\n\tprivate nextToDeliver: number;\n\tprivate readonly results = new Map<number, T[]>();\n\tprivate workingState: WorkingState = \"working\";\n\tprivate requestsInFlight = 0;\n\tprivate readonly endEvent = new Deferred<void>();\n\tprivate requests = 0;\n\tprivate readonly knewTo: boolean;\n\n\tprivate get working() {\n\t\treturn this.workingState === \"working\";\n\t}\n\tpublic get canceled() {\n\t\treturn this.workingState === \"canceled\";\n\t}\n\n\tconstructor(\n\t\tfrom: number,\n\t\tprivate to: number | undefined,\n\t\tprivate readonly payloadSize: number,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t\tprivate readonly requestCallback: (\n\t\t\trequest: number,\n\t\t\tfrom: number,\n\t\t\tto: number,\n\t\t\tstrongTo: boolean,\n\t\t\tprops: ITelemetryProperties,\n\t\t) => Promise<{ partial: boolean; cancel: boolean; payload: T[] }>,\n\t\tprivate readonly responseCallback: (payload: T[]) => void,\n\t) {\n\t\tthis.latestRequested = from;\n\t\tthis.nextToDeliver = from;\n\t\tthis.knewTo = to !== undefined;\n\t}\n\n\tpublic cancel() {\n\t\tif (this.working) {\n\t\t\tthis.workingState = \"canceled\";\n\t\t\tthis.endEvent.resolve();\n\t\t}\n\t}\n\n\tpublic async run(concurrency: number) {\n\t\tassert(concurrency > 0, 0x102 /* \"invalid level of concurrency\" */);\n\t\tassert(this.working, 0x103 /* \"trying to parallel run while not working\" */);\n\n\t\tlet c = concurrency;\n\t\twhile (c > 0) {\n\t\t\tc--;\n\t\t\tthis.addRequest();\n\t\t}\n\t\tthis.dispatch(); // will recalculate and trigger this.endEvent if needed\n\t\treturn this.endEvent.promise;\n\t}\n\n\tprivate done() {\n\t\t// We should satisfy request fully.\n\t\tassert(this.to !== undefined, 0x104 /* \"undefined end point for parallel fetch\" */);\n\t\tassert(\n\t\t\tthis.nextToDeliver >= this.to,\n\t\t\t0x105 /* \"unexpected end point for parallel fetch\" */,\n\t\t);\n\t\tif (this.working) {\n\t\t\tthis.workingState = \"done\";\n\t\t\tthis.endEvent.resolve();\n\t\t}\n\t}\n\n\tprivate fail(error) {\n\t\tif (this.working) {\n\t\t\tthis.workingState = \"done\";\n\t\t\tthis.endEvent.reject(error);\n\t\t}\n\t}\n\n\tprivate dispatch() {\n\t\twhile (this.working) {\n\t\t\tconst value = this.results.get(this.nextToDeliver);\n\t\t\tif (value === undefined) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tthis.results.delete(this.nextToDeliver);\n\t\t\tassert(\n\t\t\t\tvalue.length <= this.payloadSize,\n\t\t\t\t0x1d9 /* \"addRequestCore() should break into smaller chunks\" */,\n\t\t\t);\n\t\t\tthis.nextToDeliver += value.length;\n\t\t\tthis.responseCallback(value);\n\t\t}\n\n\t\t// Account for cancellation - state might be not in consistent state on cancelling operation\n\t\tif (this.working) {\n\t\t\tif (this.requestsInFlight === 0) {\n\t\t\t\t// we should have dispatched everything, no matter whether we knew about the end or not.\n\t\t\t\t// see comment in addRequestCore() around throwing away chunk if it's above this.to\n\t\t\t\tassert(\n\t\t\t\t\tthis.results.size === 0,\n\t\t\t\t\t0x107 /* \"ending dispatch with remaining results to be sent\" */,\n\t\t\t\t);\n\t\t\t\tthis.done();\n\t\t\t} else if (this.to !== undefined && this.nextToDeliver >= this.to) {\n\t\t\t\t// Learned about the end and dispatched all the ops up to it.\n\t\t\t\t// Ignore all the in-flight requests above boundary - unblock caller sooner.\n\t\t\t\tassert(\n\t\t\t\t\t!this.knewTo,\n\t\t\t\t\t0x108 /* \"ending results dispatch but knew in advance about more requests\" */,\n\t\t\t\t);\n\t\t\t\tthis.done();\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate getNextChunk() {\n\t\tif (!this.working) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst from = this.latestRequested;\n\t\tif (this.to !== undefined) {\n\t\t\tif (this.to <= from) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t}\n\n\t\t// this.latestRequested\n\t\t// inclusive on the right side! Exclusive on the left.\n\t\tthis.latestRequested += this.payloadSize;\n\n\t\tif (this.to !== undefined) {\n\t\t\tthis.latestRequested = Math.min(this.to, this.latestRequested);\n\t\t}\n\n\t\tassert(from < this.latestRequested, 0x109 /* \"unexpected next chunk position\" */);\n\n\t\treturn { from, to: this.latestRequested };\n\t}\n\n\tprivate addRequest() {\n\t\tconst chunk = this.getNextChunk();\n\t\tif (chunk === undefined) {\n\t\t\treturn;\n\t\t}\n\t\tthis.addRequestCore(chunk.from, chunk.to).catch(this.fail.bind(this));\n\t}\n\n\tprivate async addRequestCore(fromArg: number, toArg: number) {\n\t\tassert(this.working, 0x10a /* \"cannot add parallel request while not working\" */);\n\n\t\tlet from = fromArg;\n\t\tlet to = toArg;\n\n\t\t// to & from are exclusive\n\t\tthis.requestsInFlight++;\n\t\twhile (this.working) {\n\t\t\tconst requestedLength = to - from;\n\t\t\tassert(requestedLength > 0, 0x10b /* \"invalid parallel request range\" */);\n\n\t\t\t// We should not be wasting time asking for something useless.\n\t\t\tif (this.to !== undefined) {\n\t\t\t\tassert(from < this.to, 0x10c /* \"invalid parallel request start point\" */);\n\t\t\t\tassert(to <= this.to, 0x10d /* \"invalid parallel request end point\" */);\n\t\t\t}\n\n\t\t\tthis.requests++;\n\n\t\t\tconst promise = this.requestCallback(\n\t\t\t\tthis.requests,\n\t\t\t\tfrom,\n\t\t\t\tto,\n\t\t\t\tthis.to !== undefined,\n\t\t\t\t{},\n\t\t\t);\n\n\t\t\t// dispatch any prior received data\n\t\t\tthis.dispatch();\n\n\t\t\tconst { payload, cancel, partial } = await promise;\n\n\t\t\tif (cancel) {\n\t\t\t\tthis.cancel();\n\t\t\t}\n\n\t\t\tif (this.to !== undefined && from >= this.to) {\n\t\t\t\t// while we were waiting for response, we learned on what is the boundary\n\t\t\t\t// We can get here (with actual result!) if situation changed while this request was in\n\t\t\t\t// flight, i.e. the end was extended over what we learn in some other request\n\t\t\t\t// While it's useful not to throw this result, this is very corner cases and makes logic\n\t\t\t\t// (including consistency checks) much harder to write correctly.\n\t\t\t\t// So for now, we are throwing this result out the window.\n\t\t\t\tassert(\n\t\t\t\t\t!this.knewTo,\n\t\t\t\t\t0x10e /* \"should not throw result if we knew about boundary in advance\" */,\n\t\t\t\t);\n\t\t\t\t// Learn how often it happens and if it's too wasteful to throw these chunks.\n\t\t\t\t// If it pops into our view a lot, we would need to reconsider how we approach it.\n\t\t\t\t// Note that this is not visible to user other than potentially not hitting 100% of\n\t\t\t\t// what we can in perf domain.\n\t\t\t\tif (payload.length !== 0) {\n\t\t\t\t\tthis.logger.sendErrorEvent({\n\t\t\t\t\t\teventName: \"ParallelRequests_GotExtra\",\n\t\t\t\t\t\tfrom,\n\t\t\t\t\t\tto,\n\t\t\t\t\t\tend: this.to,\n\t\t\t\t\t\tlength: payload.length,\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tif (this.working) {\n\t\t\t\tconst fromOrig = from;\n\t\t\t\tconst length = payload.length;\n\t\t\t\tlet fullChunk = requestedLength <= length; // we can possible get more than we asked.\n\n\t\t\t\tif (length !== 0) {\n\t\t\t\t\t// We can get more than we asked for!\n\t\t\t\t\t// This can screw up logic in dispatch!\n\t\t\t\t\t// So push only batch size, and keep the rest for later - if conditions are favorable, we\n\t\t\t\t\t// will be able to use it. If not (parallel request overlapping these ops), it's easier to\n\t\t\t\t\t// discard them and wait for another (overlapping) request to come in later.\n\t\t\t\t\tif (requestedLength < length) {\n\t\t\t\t\t\t// This is error in a sense that it's not expected and likely points bug in other layer.\n\t\t\t\t\t\t// This layer copes with this situation just fine.\n\t\t\t\t\t\tthis.logger.sendTelemetryEvent({\n\t\t\t\t\t\t\teventName: \"ParallelRequests_Over\",\n\t\t\t\t\t\t\tfrom,\n\t\t\t\t\t\t\tto,\n\t\t\t\t\t\t\tlength,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\tconst data = payload.splice(0, requestedLength);\n\t\t\t\t\tthis.results.set(from, data);\n\t\t\t\t\tfrom += data.length;\n\t\t\t\t} else {\n\t\t\t\t\t// 1. empty (partial) chunks should not be returned by various caching / adapter layers -\n\t\t\t\t\t// they should fall back to next layer. This might be important invariant to hold to ensure\n\t\t\t\t\t// that we are less likely have bugs where such layer would keep returning empty partial\n\t\t\t\t\t// result on each call.\n\t\t\t\t\t// 2. Current invariant is that callback does retries until it gets something,\n\t\t\t\t\t// with the goal of failing if zero data is retrieved in given amount of time.\n\t\t\t\t\t// This is very specific property of storage / ops, so this logic is not here, but given only\n\t\t\t\t\t// one user of this class, we assert that to catch issues earlier.\n\t\t\t\t\t// These invariant can be relaxed if needed.\n\t\t\t\t\tassert(\n\t\t\t\t\t\t!partial,\n\t\t\t\t\t\t0x10f /* \"empty/partial chunks should not be returned by caching\" */,\n\t\t\t\t\t);\n\t\t\t\t\tassert(\n\t\t\t\t\t\t!this.knewTo,\n\t\t\t\t\t\t0x110 /* \"callback should retry until valid fetch before it learns new boundary\" */,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tif (!partial && !fullChunk) {\n\t\t\t\t\tif (!this.knewTo) {\n\t\t\t\t\t\tif (this.to === undefined || this.to > from) {\n\t\t\t\t\t\t\t// The END\n\t\t\t\t\t\t\tthis.to = from;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\t// We know that there are more items to be retrieved\n\t\t\t\t\t// Can we get partial chunk? Ideally storage indicates that's not a full chunk\n\t\t\t\t\t// Note that it's possible that not all ops hit storage yet.\n\t\t\t\t\t// We will come back to request more, and if we can't get any more ops soon, it's\n\t\t\t\t\t// catastrophic failure (see comment above on responsibility of callback to return something)\n\t\t\t\t\t// This layer will just keep trying until it gets full set.\n\t\t\t\t\tthis.logger.sendPerformanceEvent({\n\t\t\t\t\t\teventName: \"ParallelRequests_Partial\",\n\t\t\t\t\t\tfrom: fromOrig,\n\t\t\t\t\t\tto,\n\t\t\t\t\t\tlength,\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tif (to === this.latestRequested) {\n\t\t\t\t\t// we can go after full chunk at the end if we received partial chunk, or more than asked\n\t\t\t\t\t// Also if we got more than we asked to, we can actually use those ops!\n\t\t\t\t\twhile (payload.length !== 0) {\n\t\t\t\t\t\tconst data = payload.splice(0, requestedLength);\n\t\t\t\t\t\tthis.results.set(from, data);\n\t\t\t\t\t\tfrom += data.length;\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.latestRequested = from;\n\t\t\t\t\tfullChunk = true;\n\t\t\t\t}\n\n\t\t\t\tif (fullChunk) {\n\t\t\t\t\tconst chunk = this.getNextChunk();\n\t\t\t\t\tif (chunk === undefined) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tfrom = chunk.from;\n\t\t\t\t\tto = chunk.to;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthis.requestsInFlight--;\n\t\tthis.dispatch();\n\t}\n}\n\n/**\n * Helper queue class to allow async push / pull\n * It's essentially a pipe allowing multiple writers, and single reader\n * @internal\n */\nexport class Queue<T> implements IStream<T> {\n\tprivate readonly queue: Promise<IStreamResult<T>>[] = [];\n\tprivate deferred: Deferred<IStreamResult<T>> | undefined;\n\tprivate done = false;\n\n\tpublic pushValue(value: T) {\n\t\tthis.pushCore(Promise.resolve({ done: false, value }));\n\t}\n\n\tpublic pushError(error: any) {\n\t\tthis.pushCore(Promise.reject(error));\n\t\tthis.done = true;\n\t}\n\n\tpublic pushDone() {\n\t\tthis.pushCore(Promise.resolve({ done: true }));\n\t\tthis.done = true;\n\t}\n\n\tprotected pushCore(value: Promise<IStreamResult<T>>) {\n\t\tassert(!this.done, 0x112 /* \"cannot push onto queue if done\" */);\n\t\tif (this.deferred) {\n\t\t\tassert(this.queue.length === 0, 0x113 /* \"deferred queue should be empty\" */);\n\t\t\tthis.deferred.resolve(value);\n\t\t\tthis.deferred = undefined;\n\t\t} else {\n\t\t\tthis.queue.push(value);\n\t\t}\n\t}\n\n\tpublic async read(): Promise<IStreamResult<T>> {\n\t\tassert(this.deferred === undefined, 0x114 /* \"cannot pop if deferred\" */);\n\t\tconst value = this.queue.shift();\n\t\tif (value !== undefined) {\n\t\t\treturn value;\n\t\t}\n\t\tassert(!this.done, 0x115 /* \"queue should not be done during pop\" */);\n\t\tthis.deferred = new Deferred<IStreamResult<T>>();\n\t\treturn this.deferred.promise;\n\t}\n}\n\nconst waitForOnline = async (): Promise<void> => {\n\t// Only wait if we have a strong signal that we're offline - otherwise assume we're online.\n\tif (globalThis.navigator?.onLine === false && globalThis.addEventListener !== undefined) {\n\t\treturn new Promise<void>((resolve) => {\n\t\t\tconst resolveAndRemoveListener = () => {\n\t\t\t\tresolve();\n\t\t\t\tglobalThis.removeEventListener(\"online\", resolveAndRemoveListener);\n\t\t\t};\n\t\t\tglobalThis.addEventListener(\"online\", resolveAndRemoveListener);\n\t\t});\n\t}\n};\n\n/**\n * Retrieve single batch of ops\n * @param request - request index\n * @param from - inclusive boundary\n * @param to - exclusive boundary\n * @param telemetryEvent - telemetry event used to track consecutive batch of requests\n * @param strongTo - tells if ops in range from...to have to be there and have to be retrieved.\n * If false, returning less ops would mean we reached end of file.\n * @param logger - logger object to use to log progress & errors\n * @param signal - cancelation signal\n * @param scenarioName - reason for fetching ops\n * @returns An object with resulting ops and cancellation / partial result flags\n */\nasync function getSingleOpBatch(\n\tget: (telemetryProps: ITelemetryProperties) => Promise<IDeltasFetchResult>,\n\tprops: ITelemetryProperties,\n\tstrongTo: boolean,\n\tlogger: ITelemetryLoggerExt,\n\tsignal?: AbortSignal,\n\tscenarioName?: string,\n): Promise<{ partial: boolean; cancel: boolean; payload: ISequencedDocumentMessage[] }> {\n\tlet lastSuccessTime: number | undefined;\n\tlet totalRetryAfterTime = 0;\n\tlet telemetryEvent: PerformanceEvent | undefined;\n\tlet retry: number = 0;\n\tconst nothing = { partial: false, cancel: true, payload: [] };\n\tlet waitStartTime: number = 0;\n\tlet waitTime = MissingFetchDelayInMs;\n\n\twhile (signal?.aborted !== true) {\n\t\tretry++;\n\t\tlet lastError: unknown;\n\t\tconst startTime = performance.now();\n\n\t\ttry {\n\t\t\t// Issue async request for deltas\n\t\t\tconst { messages, partialResult } = await get(\n\t\t\t\t{ ...props, retry } /* telemetry props */,\n\t\t\t);\n\n\t\t\t// If we got messages back, return them. Return regardless of whether we got messages back if we didn't\n\t\t\t// specify a \"to\", since we don't have an expectation of how many to receive.\n\t\t\tif (messages.length !== 0 || !strongTo) {\n\t\t\t\t// Report this event if we waited to fetch ops due to being offline or throttling.\n\t\t\t\ttelemetryEvent?.end({\n\t\t\t\t\tduration: totalRetryAfterTime,\n\t\t\t\t\t...props,\n\t\t\t\t\treason: scenarioName,\n\t\t\t\t});\n\t\t\t\treturn { payload: messages, cancel: false, partial: partialResult };\n\t\t\t}\n\n\t\t\t// Otherwise, the storage gave us back an empty set of ops but we were expecting a non-empty set.\n\n\t\t\tif (lastSuccessTime === undefined) {\n\t\t\t\t// Take timestamp of the first time server responded successfully, even though it wasn't with the ops we asked for.\n\t\t\t\t// If we keep getting empty responses we'll eventually fail out below.\n\t\t\t\tlastSuccessTime = performance.now();\n\t\t\t} else if (performance.now() - lastSuccessTime > 30000) {\n\t\t\t\t// If we are connected and receiving proper responses from server, but can't get any ops back,\n\t\t\t\t// then give up after some time. This likely indicates the issue with ordering service not flushing\n\t\t\t\t// ops to storage quick enough, and possibly waiting for summaries, while summarizer can't get\n\t\t\t\t// current as it can't get ops.\n\t\t\t\tthrow createGenericNetworkError(\n\t\t\t\t\t// pre-0.58 error message: failedToRetrieveOpsFromStorage:TooManyRetries\n\t\t\t\t\t\"Failed to retrieve ops from storage (Too Many Retries)\",\n\t\t\t\t\t{ canRetry: false },\n\t\t\t\t\t{\n\t\t\t\t\t\tretry,\n\t\t\t\t\t\tdriverVersion,\n\t\t\t\t\t\t...props,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tlastError = error;\n\t\t\tconst canRetry = canRetryOnError(error);\n\n\t\t\tconst retryAfter = getRetryDelayFromError(error);\n\n\t\t\t// This will log to error table only if the error is non-retryable\n\t\t\tlogNetworkFailure(\n\t\t\t\tlogger,\n\t\t\t\t{\n\t\t\t\t\teventName: \"GetDeltas_Error\",\n\t\t\t\t\t...props,\n\t\t\t\t\tretry,\n\t\t\t\t\tduration: performance.now() - startTime,\n\t\t\t\t\tretryAfter,\n\t\t\t\t\treason: scenarioName,\n\t\t\t\t},\n\t\t\t\terror,\n\t\t\t);\n\n\t\t\tif (!canRetry) {\n\t\t\t\t// It's game over scenario.\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\n\t\tif (telemetryEvent === undefined) {\n\t\t\twaitStartTime = performance.now();\n\t\t\ttelemetryEvent = PerformanceEvent.start(logger, {\n\t\t\t\teventName: \"GetDeltasWaitTime\",\n\t\t\t});\n\t\t}\n\n\t\twaitTime = calculateMaxWaitTime(waitTime, lastError);\n\n\t\t// If we get here something has gone wrong - either got an unexpected empty set of messages back or a real error.\n\t\t// Either way we will wait a little bit before retrying.\n\t\tawait new Promise<void>((resolve) => {\n\t\t\tsetTimeout(resolve, waitTime);\n\t\t});\n\n\t\t// If we believe we're offline, we assume there's no point in trying until we at least think we're online.\n\t\t// NOTE: This isn't strictly true for drivers that don't require network (e.g. local driver). Really this logic\n\t\t// should probably live in the driver.\n\t\tawait waitForOnline();\n\t\ttotalRetryAfterTime += performance.now() - waitStartTime;\n\t}\n\n\treturn nothing;\n}\n\n/**\n * Request ops from storage\n * @param get - Getter callback to get individual batches\n * @param concurrency - Number of concurrent requests to make\n * @param fromTotal - starting sequence number to fetch (inclusive)\n * @param toTotal - max (exclusive) sequence number to fetch\n * @param payloadSize - Payload size\n * @param logger - Logger to log progress and errors\n * @param signal - Cancelation signal\n * @param scenarioName - Reason for fetching ops\n * @returns Messages fetched\n * @internal\n */\nexport function requestOps(\n\tget: (\n\t\tfrom: number,\n\t\tto: number,\n\t\ttelemetryProps: ITelemetryProperties,\n\t) => Promise<IDeltasFetchResult>,\n\tconcurrency: number,\n\tfromTotal: number,\n\ttoTotal: number | undefined,\n\tpayloadSize: number,\n\tlogger: ITelemetryLoggerExt,\n\tsignal?: AbortSignal,\n\tscenarioName?: string,\n): IStream<ISequencedDocumentMessage[]> {\n\tlet requests = 0;\n\tlet lastFetch: number | undefined;\n\tlet length = 0;\n\tconst queue = new Queue<ISequencedDocumentMessage[]>();\n\n\tconst propsTotal: ITelemetryProperties = {\n\t\tfromTotal,\n\t\ttoTotal,\n\t};\n\n\tconst telemetryEvent = PerformanceEvent.start(logger, {\n\t\teventName: \"GetDeltas\",\n\t\t...propsTotal,\n\t\treason: scenarioName,\n\t});\n\n\tconst manager = new ParallelRequests<ISequencedDocumentMessage>(\n\t\tfromTotal,\n\t\ttoTotal,\n\t\tpayloadSize,\n\t\tlogger,\n\t\tasync (\n\t\t\trequest: number,\n\t\t\tfrom: number,\n\t\t\tto: number,\n\t\t\tstrongTo: boolean,\n\t\t\tpropsPerRequest: ITelemetryProperties,\n\t\t) => {\n\t\t\trequests++;\n\t\t\treturn getSingleOpBatch(\n\t\t\t\tasync (propsAll) => get(from, to, propsAll),\n\t\t\t\t{ request, from, to, ...propsTotal, ...propsPerRequest },\n\t\t\t\tstrongTo,\n\t\t\t\tlogger,\n\t\t\t\tsignal,\n\t\t\t\tscenarioName,\n\t\t\t);\n\t\t},\n\t\t(deltas: ISequencedDocumentMessage[]) => {\n\t\t\t// Assert continuing and right start.\n\t\t\tif (lastFetch === undefined) {\n\t\t\t\tassert(deltas[0].sequenceNumber === fromTotal, 0x26d /* \"wrong start\" */);\n\t\t\t} else {\n\t\t\t\tassert(deltas[0].sequenceNumber === lastFetch + 1, 0x26e /* \"wrong start\" */);\n\t\t\t}\n\t\t\tlastFetch = deltas[deltas.length - 1].sequenceNumber;\n\t\t\tassert(\n\t\t\t\tlastFetch - deltas[0].sequenceNumber + 1 === deltas.length,\n\t\t\t\t0x26f /* \"continuous and no duplicates\" */,\n\t\t\t);\n\t\t\tlength += deltas.length;\n\t\t\tqueue.pushValue(deltas);\n\t\t},\n\t);\n\n\t// Implement faster cancellation. getSingleOpBatch() checks signal, but only in between\n\t// waits (up to 10 seconds) and fetches (can take infinite amount of time).\n\t// While every such case should be improved and take into account signal (and thus cancel immediately),\n\t// it is beneficial to have catch-all\n\tconst listener = (event: Event) => {\n\t\tmanager.cancel();\n\t};\n\tif (signal !== undefined) {\n\t\tsignal.addEventListener(\"abort\", listener);\n\t}\n\n\tmanager\n\t\t.run(concurrency)\n\t\t.finally(() => {\n\t\t\tif (signal !== undefined) {\n\t\t\t\tsignal.removeEventListener(\"abort\", listener);\n\t\t\t}\n\t\t})\n\t\t.then(() => {\n\t\t\tconst props = {\n\t\t\t\tlastFetch,\n\t\t\t\tlength,\n\t\t\t\trequests,\n\t\t\t};\n\t\t\tif (manager.canceled) {\n\t\t\t\ttelemetryEvent.cancel({ ...props, error: \"ops request cancelled by client\" });\n\t\t\t} else {\n\t\t\t\tassert(\n\t\t\t\t\ttoTotal === undefined || (lastFetch !== undefined && lastFetch >= toTotal - 1),\n\t\t\t\t\t0x270 /* \"All requested ops fetched\" */,\n\t\t\t\t);\n\t\t\t\ttelemetryEvent.end(props);\n\t\t\t}\n\t\t\tqueue.pushDone();\n\t\t})\n\t\t.catch((error) => {\n\t\t\ttelemetryEvent.cancel(\n\t\t\t\t{\n\t\t\t\t\tlastFetch,\n\t\t\t\t\tlength,\n\t\t\t\t\trequests,\n\t\t\t\t},\n\t\t\t\terror,\n\t\t\t);\n\t\t\tqueue.pushError(error);\n\t\t});\n\n\treturn queue;\n}\n\n/**\n * @internal\n */\nexport const emptyMessageStream: IStream<ISequencedDocumentMessage[]> = {\n\tread: async () => {\n\t\treturn { done: true };\n\t},\n};\n\n/**\n * @internal\n */\nexport function streamFromMessages(\n\tmessagesArg: Promise<ISequencedDocumentMessage[]>,\n): IStream<ISequencedDocumentMessage[]> {\n\tlet messages: Promise<ISequencedDocumentMessage[]> | undefined = messagesArg;\n\treturn {\n\t\tread: async () => {\n\t\t\tif (messages === undefined) {\n\t\t\t\treturn { done: true };\n\t\t\t}\n\t\t\tconst value = await messages;\n\t\t\tmessages = undefined;\n\t\t\treturn value.length === 0 ? { done: true } : { done: false, value };\n\t\t},\n\t};\n}\n\n/**\n * @internal\n */\nexport function streamObserver<T>(\n\tstream: IStream<T>,\n\thandler: (value: IStreamResult<T>) => void,\n): IStream<T> {\n\treturn {\n\t\tread: async () => {\n\t\t\tconst value = await stream.read();\n\t\t\thandler(value);\n\t\t\treturn value;\n\t\t},\n\t};\n}\n"]}
|
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
1
|
import { LoaderCachingPolicy } from "@fluidframework/driver-definitions";
|
|
6
2
|
import { ISnapshotTree, IVersion } from "@fluidframework/protocol-definitions";
|
|
7
|
-
import { DocumentStorageServiceProxy } from "./documentStorageServiceProxy";
|
|
3
|
+
import { DocumentStorageServiceProxy } from "./documentStorageServiceProxy.mjs";
|
|
4
|
+
/**
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
8
7
|
export declare class PrefetchDocumentStorageService extends DocumentStorageServiceProxy {
|
|
9
8
|
private readonly prefetchCache;
|
|
10
9
|
private prefetchEnabled;
|
|
11
10
|
get policies(): {
|
|
12
11
|
caching: LoaderCachingPolicy;
|
|
13
|
-
|
|
14
|
-
maximumCacheDurationMs?: number | undefined;
|
|
12
|
+
maximumCacheDurationMs?: 432000000 | undefined;
|
|
15
13
|
} | undefined;
|
|
16
14
|
getSnapshotTree(version?: IVersion): Promise<ISnapshotTree | null>;
|
|
17
15
|
readBlob(blobId: string): Promise<ArrayBufferLike>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prefetchDocumentStorageService.d.ts","sourceRoot":"","sources":["../src/prefetchDocumentStorageService.ts"],"names":[],"mappings":"OAIO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC;OACjE,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,sCAAsC;OACvE,EAAE,2BAA2B,EAAE;AAGtC;;GAEG;AACH,qBAAa,8BAA+B,SAAQ,2BAA2B;IAE9E,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA+C;IAC7E,OAAO,CAAC,eAAe,CAAQ;IAE/B,IAAW,QAAQ;;;kBAKlB;IAEY,eAAe,CAAC,OAAO,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAclE,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAGxD,YAAY;YAKL,UAAU;IAqBxB,OAAO,CAAC,YAAY;IAUpB,OAAO,CAAC,gBAAgB;CAmBxB"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
1
|
import { LoaderCachingPolicy } from "@fluidframework/driver-definitions";
|
|
6
|
-
import { DocumentStorageServiceProxy } from "./documentStorageServiceProxy";
|
|
7
|
-
import { canRetryOnError } from "./network";
|
|
2
|
+
import { DocumentStorageServiceProxy } from "./documentStorageServiceProxy.mjs";
|
|
3
|
+
import { canRetryOnError } from "./network.mjs";
|
|
4
|
+
/**
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
8
7
|
export class PrefetchDocumentStorageService extends DocumentStorageServiceProxy {
|
|
9
8
|
constructor() {
|
|
10
9
|
super(...arguments);
|
|
@@ -15,7 +14,7 @@ export class PrefetchDocumentStorageService extends DocumentStorageServiceProxy
|
|
|
15
14
|
get policies() {
|
|
16
15
|
const policies = this.internalStorageService.policies;
|
|
17
16
|
if (policies) {
|
|
18
|
-
return
|
|
17
|
+
return { ...policies, caching: LoaderCachingPolicy.NoCaching };
|
|
19
18
|
}
|
|
20
19
|
}
|
|
21
20
|
async getSnapshotTree(version) {
|
|
@@ -83,4 +82,4 @@ export class PrefetchDocumentStorageService extends DocumentStorageServiceProxy
|
|
|
83
82
|
}
|
|
84
83
|
}
|
|
85
84
|
}
|
|
86
|
-
//# sourceMappingURL=prefetchDocumentStorageService.
|
|
85
|
+
//# sourceMappingURL=prefetchDocumentStorageService.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prefetchDocumentStorageService.mjs","sourceRoot":"","sources":["../src/prefetchDocumentStorageService.ts"],"names":[],"mappings":"OAIO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC;OAEjE,EAAE,2BAA2B,EAAE;OAC/B,EAAE,eAAe,EAAE;AAE1B;;GAEG;AACH,MAAM,OAAO,8BAA+B,SAAQ,2BAA2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I,CAAC,IAAI,CAAC,CAAC;iBACrB;aACD;SACD;QAED,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;YAC9C,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC,CAAC;SACtD;IACF,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { LoaderCachingPolicy } from \"@fluidframework/driver-definitions\";\nimport { ISnapshotTree, IVersion } from \"@fluidframework/protocol-definitions\";\nimport { DocumentStorageServiceProxy } from \"./documentStorageServiceProxy\";\nimport { canRetryOnError } from \"./network\";\n\n/**\n * @internal\n */\nexport class PrefetchDocumentStorageService extends DocumentStorageServiceProxy {\n\t// BlobId -> blob prefetchCache cache\n\tprivate readonly prefetchCache = new Map<string, Promise<ArrayBufferLike>>();\n\tprivate prefetchEnabled = true;\n\n\tpublic get policies() {\n\t\tconst policies = this.internalStorageService.policies;\n\t\tif (policies) {\n\t\t\treturn { ...policies, caching: LoaderCachingPolicy.NoCaching };\n\t\t}\n\t}\n\n\tpublic async getSnapshotTree(version?: IVersion): Promise<ISnapshotTree | null> {\n\t\tconst p = this.internalStorageService.getSnapshotTree(version);\n\t\tif (this.prefetchEnabled) {\n\t\t\t// We don't care if the prefetch succeeds\n\t\t\tvoid p.then((tree: ISnapshotTree | null | undefined) => {\n\t\t\t\tif (tree === null || tree === undefined) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tthis.prefetchTree(tree);\n\t\t\t});\n\t\t}\n\t\treturn p;\n\t}\n\n\tpublic async readBlob(blobId: string): Promise<ArrayBufferLike> {\n\t\treturn this.cachedRead(blobId);\n\t}\n\tpublic stopPrefetch() {\n\t\tthis.prefetchEnabled = false;\n\t\tthis.prefetchCache.clear();\n\t}\n\n\tprivate async cachedRead(blobId: string): Promise<ArrayBufferLike> {\n\t\tif (this.prefetchEnabled) {\n\t\t\tconst prefetchedBlobP = this.prefetchCache.get(blobId);\n\t\t\tif (prefetchedBlobP !== undefined) {\n\t\t\t\treturn prefetchedBlobP;\n\t\t\t}\n\t\t\tconst prefetchedBlobPFromStorage = this.internalStorageService.readBlob(blobId);\n\t\t\tthis.prefetchCache.set(\n\t\t\t\tblobId,\n\t\t\t\tprefetchedBlobPFromStorage.catch((error) => {\n\t\t\t\t\tif (canRetryOnError(error)) {\n\t\t\t\t\t\tthis.prefetchCache.delete(blobId);\n\t\t\t\t\t}\n\t\t\t\t\tthrow error;\n\t\t\t\t}),\n\t\t\t);\n\t\t\treturn prefetchedBlobPFromStorage;\n\t\t}\n\t\treturn this.internalStorageService.readBlob(blobId);\n\t}\n\n\tprivate prefetchTree(tree: ISnapshotTree) {\n\t\tconst secondary: string[] = [];\n\t\tthis.prefetchTreeCore(tree, secondary);\n\n\t\tfor (const blob of secondary) {\n\t\t\t// We don't care if the prefetch succeeds\n\t\t\tvoid this.cachedRead(blob);\n\t\t}\n\t}\n\n\tprivate prefetchTreeCore(tree: ISnapshotTree, secondary: string[]) {\n\t\tfor (const blobKey of Object.keys(tree.blobs)) {\n\t\t\tconst blob = tree.blobs[blobKey];\n\t\t\tif (blobKey.startsWith(\".\") || blobKey === \"header\" || blobKey.startsWith(\"quorum\")) {\n\t\t\t\tif (blob !== null) {\n\t\t\t\t\t// We don't care if the prefetch succeeds\n\t\t\t\t\tvoid this.cachedRead(blob);\n\t\t\t\t}\n\t\t\t} else if (!blobKey.startsWith(\"deltas\")) {\n\t\t\t\tif (blob !== null) {\n\t\t\t\t\tsecondary.push(blob);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfor (const subTree of Object.keys(tree.trees)) {\n\t\t\tthis.prefetchTreeCore(tree.trees[subTree], secondary);\n\t\t}\n\t}\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rateLimiter.d.ts","sourceRoot":"","sources":["../src/rateLimiter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;GAEG;AACH,qBAAa,WAAW;IAEX,OAAO,CAAC,WAAW;IAD/B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAsB;gBACxB,WAAW,EAAE,MAAM;IAIvC,IAAW,eAAe,IAAI,MAAM,CAEnC;IAID,SAAS,CAAC,QAAQ,CAAC,OAAO,aAMxB;cAEc,OAAO;IAWV,QAAQ,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC;CAI/C"}
|
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { assert } from "@fluidframework/
|
|
5
|
+
import { assert } from "@fluidframework/core-utils";
|
|
6
|
+
/**
|
|
7
|
+
* @alpha
|
|
8
|
+
*/
|
|
6
9
|
export class RateLimiter {
|
|
7
10
|
constructor(maxRequests) {
|
|
8
11
|
this.maxRequests = maxRequests;
|
|
@@ -35,4 +38,4 @@ export class RateLimiter {
|
|
|
35
38
|
return work().finally(this.release);
|
|
36
39
|
}
|
|
37
40
|
}
|
|
38
|
-
//# sourceMappingURL=rateLimiter.
|
|
41
|
+
//# sourceMappingURL=rateLimiter.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rateLimiter.mjs","sourceRoot":"","sources":["../src/rateLimiter.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAEI,EAAE,MAAM,EAAE,MAAM,4BAA4B;AAEnD;;GAEG;AACH,MAAM,OAAO,WAAW;IAEvB,YAAoB,WAAmB;QAAnB,gBAAW,GAAX,WAAW,CAAQ;QADtB,UAAK,GAAmB,EAAE,CAAC;QAS5C,8CAA8C;QAC9C,0EAA0E;QACvD,YAAO,GAAG,GAAG,EAAE;YACjC,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;YAChC,IAAI,IAAI,KAAK,SAAS,EAAE;gBACvB,OAAO,IAAI,EAAE,CAAC;aACd;YACD,IAAI,CAAC,WAAW,EAAE,CAAC;QACpB,CAAC,CAAC;QAfD,MAAM,CAAC,WAAW,GAAG,CAAC,EAAE,KAAK,CAAC,yDAAyD,CAAC,CAAC;IAC1F,CAAC;IAED,IAAW,eAAe;QACzB,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;IAC1B,CAAC;IAYS,KAAK,CAAC,OAAO;QACtB,IAAI,IAAI,CAAC,WAAW,GAAG,CAAC,EAAE;YACzB,IAAI,CAAC,WAAW,EAAE,CAAC;YACnB,OAAO;SACP;QAED,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;YACpC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC1B,CAAC,CAAC,CAAC;IACJ,CAAC;IAEM,KAAK,CAAC,QAAQ,CAAI,IAAsB;QAC9C,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;QACrB,OAAO,IAAI,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils\";\n\n/**\n * @alpha\n */\nexport class RateLimiter {\n\tprivate readonly tasks: (() => void)[] = [];\n\tconstructor(private maxRequests: number) {\n\t\tassert(maxRequests > 0, 0x0ae /* \"Tried to create rate limiter with 0 max requests!\" */);\n\t}\n\n\tpublic get waitQueueLength(): number {\n\t\treturn this.tasks.length;\n\t}\n\n\t// Run when one of the tasks finished running.\n\t// Release next task if we have one, or allow more tasks to run in future.\n\tprotected readonly release = () => {\n\t\tconst task = this.tasks.shift();\n\t\tif (task !== undefined) {\n\t\t\treturn task();\n\t\t}\n\t\tthis.maxRequests++;\n\t};\n\n\tprotected async acquire() {\n\t\tif (this.maxRequests > 0) {\n\t\t\tthis.maxRequests--;\n\t\t\treturn;\n\t\t}\n\n\t\treturn new Promise<void>((resolve) => {\n\t\t\tthis.tasks.push(resolve);\n\t\t});\n\t}\n\n\tpublic async schedule<T>(work: () => Promise<T>) {\n\t\tawait this.acquire();\n\t\treturn work().finally(this.release);\n\t}\n}\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { IDocumentStorageService } from "@fluidframework/driver-definitions";
|
|
6
|
+
/**
|
|
7
|
+
* Read a blob from {@link @fluidframework/driver-definitions#IDocumentStorageService} and
|
|
8
|
+
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse | JSON.parse}
|
|
9
|
+
* it into object of type `T`.
|
|
10
|
+
*
|
|
11
|
+
* @param storage - The `DocumentStorageService` to read from.
|
|
12
|
+
* @param id - The ID of the blob to read and parse.
|
|
13
|
+
*
|
|
14
|
+
* @typeParam T - Output type matching JSON format of inpyt blob data.
|
|
15
|
+
*
|
|
16
|
+
* @returns The object that we decoded and parsed via `JSON.parse`.
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
export declare function readAndParse<T>(storage: Pick<IDocumentStorageService, "readBlob">, id: string): Promise<T>;
|
|
20
|
+
//# sourceMappingURL=readAndParse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readAndParse.d.ts","sourceRoot":"","sources":["../src/readAndParse.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAGI,EAAE,uBAAuB,EAAE,MAAM,oCAAoC;AAE5E;;;;;;;;;;;;GAYG;AACH,wBAAsB,YAAY,CAAC,CAAC,EACnC,OAAO,EAAE,IAAI,CAAC,uBAAuB,EAAE,UAAU,CAAC,EAClD,EAAE,EAAE,MAAM,GACR,OAAO,CAAC,CAAC,CAAC,CAIZ"}
|