@fluidframework/driver-utils 2.0.0-internal.3.0.2 → 2.0.0-internal.3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +17 -19
- package/.mocharc.js +2 -2
- package/api-extractor.json +2 -2
- package/dist/blobAggregationStorage.d.ts +15 -2
- package/dist/blobAggregationStorage.d.ts.map +1 -1
- package/dist/blobAggregationStorage.js +22 -13
- package/dist/blobAggregationStorage.js.map +1 -1
- package/dist/blobCacheStorageService.d.ts.map +1 -1
- package/dist/blobCacheStorageService.js.map +1 -1
- package/dist/buildSnapshotTree.d.ts.map +1 -1
- package/dist/buildSnapshotTree.js.map +1 -1
- package/dist/documentStorageServiceProxy.d.ts.map +1 -1
- package/dist/documentStorageServiceProxy.js.map +1 -1
- package/dist/emptyDocumentDeltaStorageService.d.ts.map +1 -1
- package/dist/emptyDocumentDeltaStorageService.js.map +1 -1
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js.map +1 -1
- package/dist/fluidResolvedUrl.d.ts.map +1 -1
- package/dist/fluidResolvedUrl.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/insecureUrlResolver.d.ts.map +1 -1
- package/dist/insecureUrlResolver.js +2 -1
- package/dist/insecureUrlResolver.js.map +1 -1
- package/dist/mapWithExpiration.d.ts.map +1 -1
- package/dist/mapWithExpiration.js +5 -3
- package/dist/mapWithExpiration.js.map +1 -1
- package/dist/messageRecognition.d.ts.map +1 -1
- package/dist/messageRecognition.js.map +1 -1
- package/dist/multiDocumentServiceFactory.d.ts.map +1 -1
- package/dist/multiDocumentServiceFactory.js.map +1 -1
- package/dist/multiUrlResolver.d.ts.map +1 -1
- package/dist/multiUrlResolver.js.map +1 -1
- package/dist/network.d.ts +1 -1
- package/dist/network.d.ts.map +1 -1
- package/dist/network.js +4 -3
- package/dist/network.js.map +1 -1
- package/dist/networkUtils.d.ts.map +1 -1
- package/dist/networkUtils.js +2 -3
- package/dist/networkUtils.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/parallelRequests.d.ts.map +1 -1
- package/dist/parallelRequests.js +19 -9
- package/dist/parallelRequests.js.map +1 -1
- package/dist/prefetchDocumentStorageService.d.ts.map +1 -1
- package/dist/prefetchDocumentStorageService.js.map +1 -1
- package/dist/rateLimiter.d.ts.map +1 -1
- package/dist/rateLimiter.js.map +1 -1
- package/dist/readAndParse.d.ts.map +1 -1
- package/dist/readAndParse.js.map +1 -1
- package/dist/runWithRetry.d.ts.map +1 -1
- package/dist/runWithRetry.js.map +1 -1
- package/dist/summaryForCreateNew.d.ts.map +1 -1
- package/dist/summaryForCreateNew.js.map +1 -1
- package/dist/treeConversions.d.ts.map +1 -1
- package/dist/treeConversions.js +1 -4
- package/dist/treeConversions.js.map +1 -1
- package/dist/treeUtils.d.ts +10 -10
- package/dist/treeUtils.d.ts.map +1 -1
- package/dist/treeUtils.js +10 -10
- package/dist/treeUtils.js.map +1 -1
- package/lib/blobAggregationStorage.d.ts +15 -2
- package/lib/blobAggregationStorage.d.ts.map +1 -1
- package/lib/blobAggregationStorage.js +22 -13
- package/lib/blobAggregationStorage.js.map +1 -1
- package/lib/blobCacheStorageService.d.ts.map +1 -1
- package/lib/blobCacheStorageService.js.map +1 -1
- package/lib/buildSnapshotTree.d.ts.map +1 -1
- package/lib/buildSnapshotTree.js.map +1 -1
- package/lib/documentStorageServiceProxy.d.ts.map +1 -1
- package/lib/documentStorageServiceProxy.js.map +1 -1
- package/lib/emptyDocumentDeltaStorageService.d.ts.map +1 -1
- package/lib/emptyDocumentDeltaStorageService.js.map +1 -1
- package/lib/error.d.ts.map +1 -1
- package/lib/error.js.map +1 -1
- package/lib/fluidResolvedUrl.d.ts.map +1 -1
- package/lib/fluidResolvedUrl.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/insecureUrlResolver.d.ts.map +1 -1
- package/lib/insecureUrlResolver.js +2 -1
- package/lib/insecureUrlResolver.js.map +1 -1
- package/lib/mapWithExpiration.d.ts.map +1 -1
- package/lib/mapWithExpiration.js +5 -3
- package/lib/mapWithExpiration.js.map +1 -1
- package/lib/messageRecognition.d.ts.map +1 -1
- package/lib/messageRecognition.js +1 -1
- package/lib/messageRecognition.js.map +1 -1
- package/lib/multiDocumentServiceFactory.d.ts.map +1 -1
- package/lib/multiDocumentServiceFactory.js.map +1 -1
- package/lib/multiUrlResolver.d.ts.map +1 -1
- package/lib/multiUrlResolver.js.map +1 -1
- package/lib/network.d.ts +1 -1
- package/lib/network.d.ts.map +1 -1
- package/lib/network.js +4 -3
- package/lib/network.js.map +1 -1
- package/lib/networkUtils.d.ts.map +1 -1
- package/lib/networkUtils.js +2 -3
- package/lib/networkUtils.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/parallelRequests.d.ts.map +1 -1
- package/lib/parallelRequests.js +19 -9
- package/lib/parallelRequests.js.map +1 -1
- package/lib/prefetchDocumentStorageService.d.ts.map +1 -1
- package/lib/prefetchDocumentStorageService.js.map +1 -1
- package/lib/rateLimiter.d.ts.map +1 -1
- package/lib/rateLimiter.js.map +1 -1
- package/lib/readAndParse.d.ts.map +1 -1
- package/lib/readAndParse.js.map +1 -1
- package/lib/runWithRetry.d.ts.map +1 -1
- package/lib/runWithRetry.js.map +1 -1
- package/lib/summaryForCreateNew.d.ts.map +1 -1
- package/lib/summaryForCreateNew.js.map +1 -1
- package/lib/treeConversions.d.ts.map +1 -1
- package/lib/treeConversions.js +4 -7
- package/lib/treeConversions.js.map +1 -1
- package/lib/treeUtils.d.ts +10 -10
- package/lib/treeUtils.d.ts.map +1 -1
- package/lib/treeUtils.js +11 -11
- package/lib/treeUtils.js.map +1 -1
- package/package.json +43 -64
- package/prettier.config.cjs +1 -1
- package/src/blobAggregationStorage.ts +380 -324
- package/src/blobCacheStorageService.ts +20 -17
- package/src/buildSnapshotTree.ts +54 -51
- package/src/documentStorageServiceProxy.ts +49 -43
- package/src/emptyDocumentDeltaStorageService.ts +11 -10
- package/src/error.ts +5 -7
- package/src/fluidResolvedUrl.ts +9 -6
- package/src/index.ts +5 -1
- package/src/insecureUrlResolver.ts +127 -116
- package/src/mapWithExpiration.ts +111 -104
- package/src/messageRecognition.ts +25 -19
- package/src/multiDocumentServiceFactory.ts +73 -62
- package/src/multiUrlResolver.ts +26 -29
- package/src/network.ts +114 -112
- package/src/networkUtils.ts +37 -34
- package/src/packageVersion.ts +1 -1
- package/src/parallelRequests.ts +571 -509
- package/src/prefetchDocumentStorageService.ts +76 -74
- package/src/rateLimiter.ts +29 -29
- package/src/readAndParse.ts +7 -4
- package/src/runWithRetry.ts +105 -94
- package/src/summaryForCreateNew.ts +27 -24
- package/src/treeConversions.ts +48 -70
- package/src/treeUtils.ts +70 -74
- package/tsconfig.esnext.json +6 -6
- package/tsconfig.json +8 -12
package/src/network.ts
CHANGED
|
@@ -4,30 +4,34 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
IThrottlingWarning,
|
|
8
|
+
IDriverErrorBase,
|
|
9
|
+
IAuthorizationError,
|
|
10
|
+
DriverErrorType,
|
|
11
|
+
ILocationRedirectionError,
|
|
12
|
+
IResolvedUrl,
|
|
13
13
|
} from "@fluidframework/driver-definitions";
|
|
14
14
|
import { ITelemetryProperties } from "@fluidframework/common-definitions";
|
|
15
15
|
import { IFluidErrorBase, LoggingError } from "@fluidframework/telemetry-utils";
|
|
16
16
|
|
|
17
17
|
export enum OnlineStatus {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
Offline,
|
|
19
|
+
Online,
|
|
20
|
+
Unknown,
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
// It tells if we have local connection only - we might not have connection to web.
|
|
24
24
|
// No solution for node.js (other than resolve dns names / ping specific sites)
|
|
25
25
|
// Can also use window.addEventListener("online" / "offline")
|
|
26
26
|
export function isOnline(): OnlineStatus {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
if (
|
|
28
|
+
typeof navigator === "object" &&
|
|
29
|
+
navigator !== null &&
|
|
30
|
+
typeof navigator.onLine === "boolean"
|
|
31
|
+
) {
|
|
32
|
+
return navigator.onLine ? OnlineStatus.Online : OnlineStatus.Offline;
|
|
33
|
+
}
|
|
34
|
+
return OnlineStatus.Unknown;
|
|
31
35
|
}
|
|
32
36
|
|
|
33
37
|
/**
|
|
@@ -41,143 +45,141 @@ export function isOnline(): OnlineStatus {
|
|
|
41
45
|
*
|
|
42
46
|
* @deprecated - In favour of {@link @fluidframework/driver-definitions#IAnyDriverError} so that
|
|
43
47
|
* it can used from the base to upper layers.
|
|
44
|
-
*/
|
|
48
|
+
*/
|
|
45
49
|
export interface IAnyDriverError extends Omit<IDriverErrorBase, "errorType"> {
|
|
46
|
-
|
|
50
|
+
readonly errorType: string;
|
|
47
51
|
}
|
|
48
52
|
|
|
49
53
|
/** Telemetry props with driver-specific required properties */
|
|
50
|
-
export type DriverErrorTelemetryProps = ITelemetryProperties & {
|
|
54
|
+
export type DriverErrorTelemetryProps = ITelemetryProperties & {
|
|
55
|
+
driverVersion: string | undefined;
|
|
56
|
+
};
|
|
51
57
|
|
|
52
58
|
/**
|
|
53
59
|
* Generic network error class.
|
|
54
60
|
*/
|
|
55
61
|
export class GenericNetworkError extends LoggingError implements IDriverErrorBase, IFluidErrorBase {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
props: DriverErrorTelemetryProps,
|
|
62
|
-
) {
|
|
63
|
-
super(message, props);
|
|
64
|
-
}
|
|
62
|
+
readonly errorType = DriverErrorType.genericNetworkError;
|
|
63
|
+
|
|
64
|
+
constructor(message: string, readonly canRetry: boolean, props: DriverErrorTelemetryProps) {
|
|
65
|
+
super(message, props);
|
|
66
|
+
}
|
|
65
67
|
}
|
|
66
68
|
|
|
67
69
|
/**
|
|
68
70
|
* FluidInvalidSchema error class.
|
|
69
71
|
*/
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
72
|
+
export class FluidInvalidSchemaError
|
|
73
|
+
extends LoggingError
|
|
74
|
+
implements IDriverErrorBase, IFluidErrorBase
|
|
75
|
+
{
|
|
76
|
+
readonly errorType = DriverErrorType.fluidInvalidSchema;
|
|
77
|
+
readonly canRetry = false;
|
|
78
|
+
|
|
79
|
+
constructor(message: string, props: DriverErrorTelemetryProps) {
|
|
80
|
+
super(message, props);
|
|
81
|
+
}
|
|
80
82
|
}
|
|
81
83
|
|
|
82
|
-
export class DeltaStreamConnectionForbiddenError
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
84
|
+
export class DeltaStreamConnectionForbiddenError
|
|
85
|
+
extends LoggingError
|
|
86
|
+
implements IDriverErrorBase, IFluidErrorBase
|
|
87
|
+
{
|
|
88
|
+
static readonly errorType = DriverErrorType.deltaStreamConnectionForbidden;
|
|
89
|
+
readonly errorType = DeltaStreamConnectionForbiddenError.errorType;
|
|
90
|
+
readonly canRetry = false;
|
|
91
|
+
|
|
92
|
+
constructor(message: string, props: DriverErrorTelemetryProps) {
|
|
93
|
+
super(message, { ...props, statusCode: 400 });
|
|
94
|
+
}
|
|
90
95
|
}
|
|
91
96
|
|
|
92
|
-
export class AuthorizationError
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
97
|
+
export class AuthorizationError
|
|
98
|
+
extends LoggingError
|
|
99
|
+
implements IAuthorizationError, IFluidErrorBase
|
|
100
|
+
{
|
|
101
|
+
readonly errorType = DriverErrorType.authorizationError;
|
|
102
|
+
readonly canRetry = false;
|
|
103
|
+
|
|
104
|
+
constructor(
|
|
105
|
+
message: string,
|
|
106
|
+
readonly claims: string | undefined,
|
|
107
|
+
readonly tenantId: string | undefined,
|
|
108
|
+
props: DriverErrorTelemetryProps,
|
|
109
|
+
) {
|
|
110
|
+
// don't log claims or tenantId
|
|
111
|
+
super(message, props, new Set(["claims", "tenantId"]));
|
|
112
|
+
}
|
|
105
113
|
}
|
|
106
114
|
|
|
107
|
-
export class LocationRedirectionError
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
115
|
+
export class LocationRedirectionError
|
|
116
|
+
extends LoggingError
|
|
117
|
+
implements ILocationRedirectionError, IFluidErrorBase
|
|
118
|
+
{
|
|
119
|
+
readonly errorType = DriverErrorType.locationRedirection;
|
|
120
|
+
readonly canRetry = false;
|
|
121
|
+
|
|
122
|
+
constructor(
|
|
123
|
+
message: string,
|
|
124
|
+
readonly redirectUrl: IResolvedUrl,
|
|
125
|
+
props: DriverErrorTelemetryProps,
|
|
126
|
+
) {
|
|
127
|
+
// do not log redirectURL
|
|
128
|
+
super(message, props, new Set(["redirectUrl"]));
|
|
129
|
+
}
|
|
119
130
|
}
|
|
120
131
|
|
|
121
132
|
export class NetworkErrorBasic<T extends string> extends LoggingError implements IFluidErrorBase {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
133
|
+
constructor(
|
|
134
|
+
message: string,
|
|
135
|
+
readonly errorType: T,
|
|
136
|
+
readonly canRetry: boolean,
|
|
137
|
+
props: DriverErrorTelemetryProps,
|
|
138
|
+
) {
|
|
139
|
+
super(message, props);
|
|
140
|
+
}
|
|
130
141
|
}
|
|
131
142
|
|
|
132
143
|
export class NonRetryableError<T extends string> extends NetworkErrorBasic<T> {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
props: DriverErrorTelemetryProps,
|
|
137
|
-
) {
|
|
138
|
-
super(message, errorType, false, props);
|
|
139
|
-
}
|
|
144
|
+
constructor(message: string, readonly errorType: T, props: DriverErrorTelemetryProps) {
|
|
145
|
+
super(message, errorType, false, props);
|
|
146
|
+
}
|
|
140
147
|
}
|
|
141
148
|
|
|
142
149
|
export class RetryableError<T extends string> extends NetworkErrorBasic<T> {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
props: DriverErrorTelemetryProps,
|
|
147
|
-
) {
|
|
148
|
-
super(message, errorType, true, props);
|
|
149
|
-
}
|
|
150
|
+
constructor(message: string, readonly errorType: T, props: DriverErrorTelemetryProps) {
|
|
151
|
+
super(message, errorType, true, props);
|
|
152
|
+
}
|
|
150
153
|
}
|
|
151
154
|
|
|
152
155
|
/**
|
|
153
156
|
* Throttling error class - used to communicate all throttling errors
|
|
154
157
|
*/
|
|
155
158
|
export class ThrottlingError extends LoggingError implements IThrottlingWarning, IFluidErrorBase {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
159
|
+
readonly errorType = DriverErrorType.throttlingError;
|
|
160
|
+
readonly canRetry = true;
|
|
161
|
+
|
|
162
|
+
constructor(
|
|
163
|
+
message: string,
|
|
164
|
+
readonly retryAfterSeconds: number,
|
|
165
|
+
props: DriverErrorTelemetryProps,
|
|
166
|
+
) {
|
|
167
|
+
super(message, props);
|
|
168
|
+
}
|
|
166
169
|
}
|
|
167
170
|
|
|
168
171
|
export const createWriteError = (message: string, props: DriverErrorTelemetryProps) =>
|
|
169
|
-
|
|
172
|
+
new NonRetryableError(message, DriverErrorType.writeError, props);
|
|
170
173
|
|
|
171
174
|
export function createGenericNetworkError(
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
+
message: string,
|
|
176
|
+
retryInfo: { canRetry: boolean; retryAfterMs?: number },
|
|
177
|
+
props: DriverErrorTelemetryProps,
|
|
175
178
|
): ThrottlingError | GenericNetworkError {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
return new GenericNetworkError(message, retryInfo.canRetry, props);
|
|
179
|
+
if (retryInfo.retryAfterMs !== undefined && retryInfo.canRetry) {
|
|
180
|
+
return new ThrottlingError(message, retryInfo.retryAfterMs / 1000, props);
|
|
181
|
+
}
|
|
182
|
+
return new GenericNetworkError(message, retryInfo.canRetry, props);
|
|
181
183
|
}
|
|
182
184
|
|
|
183
185
|
/**
|
|
@@ -189,8 +191,8 @@ export const canRetryOnError = (error: any): boolean => error?.canRetry === true
|
|
|
189
191
|
|
|
190
192
|
/** Check retryAfterSeconds property on error */
|
|
191
193
|
export const getRetryDelaySecondsFromError = (error: any): number | undefined =>
|
|
192
|
-
|
|
194
|
+
error?.retryAfterSeconds as number | undefined;
|
|
193
195
|
|
|
194
196
|
/** Check retryAfterSeconds property on error and convert to ms */
|
|
195
|
-
export const getRetryDelayFromError = (error: any): number | undefined =>
|
|
196
|
-
|
|
197
|
+
export const getRetryDelayFromError = (error: any): number | undefined =>
|
|
198
|
+
error?.retryAfterSeconds !== undefined ? error.retryAfterSeconds * 1000 : undefined;
|
package/src/networkUtils.ts
CHANGED
|
@@ -6,25 +6,28 @@
|
|
|
6
6
|
import { ITelemetryErrorEvent, ITelemetryLogger } from "@fluidframework/common-definitions";
|
|
7
7
|
import { isOnline, OnlineStatus, canRetryOnError } from "./network";
|
|
8
8
|
|
|
9
|
-
export function logNetworkFailure(
|
|
10
|
-
|
|
9
|
+
export function logNetworkFailure(
|
|
10
|
+
logger: ITelemetryLogger,
|
|
11
|
+
event: ITelemetryErrorEvent,
|
|
12
|
+
error?: any,
|
|
13
|
+
) {
|
|
14
|
+
const newEvent = { ...event };
|
|
11
15
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
: OnlineStatus[isOnline()];
|
|
16
|
+
const errorOnlineProp = error.online;
|
|
17
|
+
newEvent.online =
|
|
18
|
+
typeof errorOnlineProp === "string" ? errorOnlineProp : OnlineStatus[isOnline()];
|
|
16
19
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
if (typeof navigator === "object" && navigator !== null) {
|
|
21
|
+
const nav = navigator as any;
|
|
22
|
+
const connection = nav.connection ?? nav.mozConnection ?? nav.webkitConnection;
|
|
23
|
+
if (connection !== null && typeof connection === "object") {
|
|
24
|
+
newEvent.connectionType = connection.type;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
24
27
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
+
// non-retryable errors are fatal and should be logged as errors
|
|
29
|
+
newEvent.category = canRetryOnError(error) ? "generic" : "error";
|
|
30
|
+
logger.sendTelemetryEvent(newEvent, error);
|
|
28
31
|
}
|
|
29
32
|
|
|
30
33
|
/**
|
|
@@ -38,23 +41,23 @@ export function logNetworkFailure(logger: ITelemetryLogger, event: ITelemetryErr
|
|
|
38
41
|
*/
|
|
39
42
|
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
|
40
43
|
export function waitForConnectedState(minDelay: number): Promise<void> {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
+
// Use this frequency to poll even when we are offline and able to setup online/offline listener
|
|
45
|
+
// This is mostly safety net
|
|
46
|
+
const offlinePollFrequency = 30000;
|
|
44
47
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
48
|
+
return new Promise((resolve) => {
|
|
49
|
+
let listener: () => void = resolve;
|
|
50
|
+
let delay = minDelay;
|
|
51
|
+
if (isOnline() === OnlineStatus.Offline) {
|
|
52
|
+
if (window?.addEventListener !== undefined) {
|
|
53
|
+
listener = () => {
|
|
54
|
+
resolve();
|
|
55
|
+
window.removeEventListener("online", listener);
|
|
56
|
+
};
|
|
57
|
+
window.addEventListener("online", listener, false);
|
|
58
|
+
delay = Math.max(minDelay, offlinePollFrequency);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
setTimeout(listener, delay);
|
|
62
|
+
});
|
|
60
63
|
}
|
package/src/packageVersion.ts
CHANGED