@firebase/remote-config
Advanced tools
Comparing version 0.1.7-canary.638aba6 to 0.1.7-canary.9b8ef59
@@ -12,2 +12,3 @@ 'use strict'; | ||
var logger = require('@firebase/logger'); | ||
var component = require('@firebase/component'); | ||
@@ -549,46 +550,39 @@ /** | ||
return tslib.__awaiter(this, void 0, void 0, function () { | ||
var abortSignal, e_1, lastFetchStatus; | ||
var _this = this; | ||
return tslib.__generator(this, function (_a) { | ||
return [2 /*return*/, new Promise(function (resolve, reject) { return tslib.__awaiter(_this, void 0, void 0, function () { | ||
var abortSignal, e_1, lastFetchStatus; | ||
var _this = this; | ||
return tslib.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
abortSignal = new RemoteConfigAbortSignal(); | ||
setTimeout(function () { return tslib.__awaiter(_this, void 0, void 0, function () { | ||
return tslib.__generator(this, function (_a) { | ||
// Note a very low delay, eg < 10ms, can elapse before listeners are initialized. | ||
abortSignal.abort(); | ||
return [2 /*return*/]; | ||
}); | ||
}); }, this.settings.fetchTimeoutMillis); | ||
_a.label = 1; | ||
case 1: | ||
_a.trys.push([1, 4, , 6]); | ||
return [4 /*yield*/, this._client.fetch({ | ||
cacheMaxAgeMillis: this.settings.minimumFetchIntervalMillis, | ||
signal: abortSignal | ||
})]; | ||
case 2: | ||
_a.sent(); | ||
return [4 /*yield*/, this._storageCache.setLastFetchStatus('success')]; | ||
case 3: | ||
_a.sent(); | ||
resolve(); | ||
return [3 /*break*/, 6]; | ||
case 4: | ||
e_1 = _a.sent(); | ||
lastFetchStatus = hasErrorCode(e_1, "fetch-throttle" /* FETCH_THROTTLE */) | ||
? 'throttle' | ||
: 'failure'; | ||
return [4 /*yield*/, this._storageCache.setLastFetchStatus(lastFetchStatus)]; | ||
case 5: | ||
_a.sent(); | ||
reject(e_1); | ||
return [3 /*break*/, 6]; | ||
case 6: return [2 /*return*/]; | ||
} | ||
}); | ||
}); })]; | ||
switch (_a.label) { | ||
case 0: | ||
abortSignal = new RemoteConfigAbortSignal(); | ||
setTimeout(function () { return tslib.__awaiter(_this, void 0, void 0, function () { | ||
return tslib.__generator(this, function (_a) { | ||
// Note a very low delay, eg < 10ms, can elapse before listeners are initialized. | ||
abortSignal.abort(); | ||
return [2 /*return*/]; | ||
}); | ||
}); }, this.settings.fetchTimeoutMillis); | ||
_a.label = 1; | ||
case 1: | ||
_a.trys.push([1, 4, , 6]); | ||
return [4 /*yield*/, this._client.fetch({ | ||
cacheMaxAgeMillis: this.settings.minimumFetchIntervalMillis, | ||
signal: abortSignal | ||
})]; | ||
case 2: | ||
_a.sent(); | ||
return [4 /*yield*/, this._storageCache.setLastFetchStatus('success')]; | ||
case 3: | ||
_a.sent(); | ||
return [3 /*break*/, 6]; | ||
case 4: | ||
e_1 = _a.sent(); | ||
lastFetchStatus = hasErrorCode(e_1, "fetch-throttle" /* FETCH_THROTTLE */) | ||
? 'throttle' | ||
: 'failure'; | ||
return [4 /*yield*/, this._storageCache.setLastFetchStatus(lastFetchStatus)]; | ||
case 5: | ||
_a.sent(); | ||
throw e_1; | ||
case 6: return [2 /*return*/]; | ||
} | ||
}); | ||
@@ -1197,3 +1191,9 @@ }); | ||
function registerRemoteConfig(firebaseInstance) { | ||
firebaseInstance.INTERNAL.registerService('remoteConfig', function (app, _, namespace) { | ||
firebaseInstance.INTERNAL.registerComponent(new component.Component('remoteConfig', remoteConfigFactory, "PUBLIC" /* PUBLIC */).setMultipleInstances(true)); | ||
function remoteConfigFactory(container, namespace) { | ||
/* Dependencies */ | ||
// getImmediate for FirebaseApp will always succeed | ||
var app = container.getProvider('app').getImmediate(); | ||
// The following call will always succeed because rc has `import '@firebase/installations'` | ||
var installations = container.getProvider('installations').getImmediate(); | ||
// Guards against the SDK being used in non-browser environments. | ||
@@ -1221,3 +1221,3 @@ if (typeof window === 'undefined') { | ||
logger$1.logLevel = logger.LogLevel.ERROR; | ||
var restClient = new RestClient(app.installations(), | ||
var restClient = new RestClient(installations, | ||
// Uses the JS SDK version, by which the RC package version can be deduced, if necessary. | ||
@@ -1232,3 +1232,3 @@ firebaseInstance.SDK_VERSION, namespace, projectId, apiKey, appId); | ||
return remoteConfigInstance; | ||
}, undefined, undefined, true /* allowMultipleInstances */); | ||
} | ||
} | ||
@@ -1235,0 +1235,0 @@ registerRemoteConfig(firebase); |
@@ -17,4 +17,4 @@ /** | ||
*/ | ||
import '@firebase/installations'; | ||
import { _FirebaseNamespace } from '@firebase/app-types/private'; | ||
import '@firebase/installations'; | ||
import { RemoteConfig as RemoteConfigType } from '@firebase/remote-config-types'; | ||
@@ -21,0 +21,0 @@ declare global { |
@@ -6,2 +6,3 @@ import firebase from '@firebase/app'; | ||
import { LogLevel, Logger } from '@firebase/logger'; | ||
import { Component } from '@firebase/component'; | ||
@@ -543,46 +544,39 @@ /** | ||
return __awaiter(this, void 0, void 0, function () { | ||
var abortSignal, e_1, lastFetchStatus; | ||
var _this = this; | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () { | ||
var abortSignal, e_1, lastFetchStatus; | ||
var _this = this; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
abortSignal = new RemoteConfigAbortSignal(); | ||
setTimeout(function () { return __awaiter(_this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
// Note a very low delay, eg < 10ms, can elapse before listeners are initialized. | ||
abortSignal.abort(); | ||
return [2 /*return*/]; | ||
}); | ||
}); }, this.settings.fetchTimeoutMillis); | ||
_a.label = 1; | ||
case 1: | ||
_a.trys.push([1, 4, , 6]); | ||
return [4 /*yield*/, this._client.fetch({ | ||
cacheMaxAgeMillis: this.settings.minimumFetchIntervalMillis, | ||
signal: abortSignal | ||
})]; | ||
case 2: | ||
_a.sent(); | ||
return [4 /*yield*/, this._storageCache.setLastFetchStatus('success')]; | ||
case 3: | ||
_a.sent(); | ||
resolve(); | ||
return [3 /*break*/, 6]; | ||
case 4: | ||
e_1 = _a.sent(); | ||
lastFetchStatus = hasErrorCode(e_1, "fetch-throttle" /* FETCH_THROTTLE */) | ||
? 'throttle' | ||
: 'failure'; | ||
return [4 /*yield*/, this._storageCache.setLastFetchStatus(lastFetchStatus)]; | ||
case 5: | ||
_a.sent(); | ||
reject(e_1); | ||
return [3 /*break*/, 6]; | ||
case 6: return [2 /*return*/]; | ||
} | ||
}); | ||
}); })]; | ||
switch (_a.label) { | ||
case 0: | ||
abortSignal = new RemoteConfigAbortSignal(); | ||
setTimeout(function () { return __awaiter(_this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
// Note a very low delay, eg < 10ms, can elapse before listeners are initialized. | ||
abortSignal.abort(); | ||
return [2 /*return*/]; | ||
}); | ||
}); }, this.settings.fetchTimeoutMillis); | ||
_a.label = 1; | ||
case 1: | ||
_a.trys.push([1, 4, , 6]); | ||
return [4 /*yield*/, this._client.fetch({ | ||
cacheMaxAgeMillis: this.settings.minimumFetchIntervalMillis, | ||
signal: abortSignal | ||
})]; | ||
case 2: | ||
_a.sent(); | ||
return [4 /*yield*/, this._storageCache.setLastFetchStatus('success')]; | ||
case 3: | ||
_a.sent(); | ||
return [3 /*break*/, 6]; | ||
case 4: | ||
e_1 = _a.sent(); | ||
lastFetchStatus = hasErrorCode(e_1, "fetch-throttle" /* FETCH_THROTTLE */) | ||
? 'throttle' | ||
: 'failure'; | ||
return [4 /*yield*/, this._storageCache.setLastFetchStatus(lastFetchStatus)]; | ||
case 5: | ||
_a.sent(); | ||
throw e_1; | ||
case 6: return [2 /*return*/]; | ||
} | ||
}); | ||
@@ -1191,3 +1185,9 @@ }); | ||
function registerRemoteConfig(firebaseInstance) { | ||
firebaseInstance.INTERNAL.registerService('remoteConfig', function (app, _, namespace) { | ||
firebaseInstance.INTERNAL.registerComponent(new Component('remoteConfig', remoteConfigFactory, "PUBLIC" /* PUBLIC */).setMultipleInstances(true)); | ||
function remoteConfigFactory(container, namespace) { | ||
/* Dependencies */ | ||
// getImmediate for FirebaseApp will always succeed | ||
var app = container.getProvider('app').getImmediate(); | ||
// The following call will always succeed because rc has `import '@firebase/installations'` | ||
var installations = container.getProvider('installations').getImmediate(); | ||
// Guards against the SDK being used in non-browser environments. | ||
@@ -1215,3 +1215,3 @@ if (typeof window === 'undefined') { | ||
logger.logLevel = LogLevel.ERROR; | ||
var restClient = new RestClient(app.installations(), | ||
var restClient = new RestClient(installations, | ||
// Uses the JS SDK version, by which the RC package version can be deduced, if necessary. | ||
@@ -1226,3 +1226,3 @@ firebaseInstance.SDK_VERSION, namespace, projectId, apiKey, appId); | ||
return remoteConfigInstance; | ||
}, undefined, undefined, true /* allowMultipleInstances */); | ||
} | ||
} | ||
@@ -1229,0 +1229,0 @@ registerRemoteConfig(firebase); |
@@ -5,2 +5,3 @@ import firebase from '@firebase/app'; | ||
import { LogLevel, Logger } from '@firebase/logger'; | ||
import { Component } from '@firebase/component'; | ||
@@ -489,35 +490,32 @@ /** | ||
async fetch() { | ||
return new Promise(async (resolve, reject) => { | ||
// Aborts the request after the given timeout, causing the fetch call to | ||
// reject with an AbortError. | ||
// | ||
// <p>Aborting after the request completes is a no-op, so we don't need a | ||
// corresponding clearTimeout. | ||
// | ||
// Locating abort logic here because: | ||
// * it uses a developer setting (timeout) | ||
// * it applies to all retries (like curl's max-time arg) | ||
// * it is consistent with the Fetch API's signal input | ||
const abortSignal = new RemoteConfigAbortSignal(); | ||
setTimeout(async () => { | ||
// Note a very low delay, eg < 10ms, can elapse before listeners are initialized. | ||
abortSignal.abort(); | ||
}, this.settings.fetchTimeoutMillis); | ||
// Catches *all* errors thrown by client so status can be set consistently. | ||
try { | ||
await this._client.fetch({ | ||
cacheMaxAgeMillis: this.settings.minimumFetchIntervalMillis, | ||
signal: abortSignal | ||
}); | ||
await this._storageCache.setLastFetchStatus('success'); | ||
resolve(); | ||
} | ||
catch (e) { | ||
const lastFetchStatus = hasErrorCode(e, "fetch-throttle" /* FETCH_THROTTLE */) | ||
? 'throttle' | ||
: 'failure'; | ||
await this._storageCache.setLastFetchStatus(lastFetchStatus); | ||
reject(e); | ||
} | ||
}); | ||
// Aborts the request after the given timeout, causing the fetch call to | ||
// reject with an AbortError. | ||
// | ||
// <p>Aborting after the request completes is a no-op, so we don't need a | ||
// corresponding clearTimeout. | ||
// | ||
// Locating abort logic here because: | ||
// * it uses a developer setting (timeout) | ||
// * it applies to all retries (like curl's max-time arg) | ||
// * it is consistent with the Fetch API's signal input | ||
const abortSignal = new RemoteConfigAbortSignal(); | ||
setTimeout(async () => { | ||
// Note a very low delay, eg < 10ms, can elapse before listeners are initialized. | ||
abortSignal.abort(); | ||
}, this.settings.fetchTimeoutMillis); | ||
// Catches *all* errors thrown by client so status can be set consistently. | ||
try { | ||
await this._client.fetch({ | ||
cacheMaxAgeMillis: this.settings.minimumFetchIntervalMillis, | ||
signal: abortSignal | ||
}); | ||
await this._storageCache.setLastFetchStatus('success'); | ||
} | ||
catch (e) { | ||
const lastFetchStatus = hasErrorCode(e, "fetch-throttle" /* FETCH_THROTTLE */) | ||
? 'throttle' | ||
: 'failure'; | ||
await this._storageCache.setLastFetchStatus(lastFetchStatus); | ||
throw e; | ||
} | ||
} | ||
@@ -1036,3 +1034,9 @@ async fetchAndActivate() { | ||
function registerRemoteConfig(firebaseInstance) { | ||
firebaseInstance.INTERNAL.registerService('remoteConfig', (app, _, namespace) => { | ||
firebaseInstance.INTERNAL.registerComponent(new Component('remoteConfig', remoteConfigFactory, "PUBLIC" /* PUBLIC */).setMultipleInstances(true)); | ||
function remoteConfigFactory(container, namespace) { | ||
/* Dependencies */ | ||
// getImmediate for FirebaseApp will always succeed | ||
const app = container.getProvider('app').getImmediate(); | ||
// The following call will always succeed because rc has `import '@firebase/installations'` | ||
const installations = container.getProvider('installations').getImmediate(); | ||
// Guards against the SDK being used in non-browser environments. | ||
@@ -1060,3 +1064,3 @@ if (typeof window === 'undefined') { | ||
logger.logLevel = LogLevel.ERROR; | ||
const restClient = new RestClient(app.installations(), | ||
const restClient = new RestClient(installations, | ||
// Uses the JS SDK version, by which the RC package version can be deduced, if necessary. | ||
@@ -1071,3 +1075,3 @@ firebaseInstance.SDK_VERSION, namespace, projectId, apiKey, appId); | ||
return remoteConfigInstance; | ||
}, undefined, undefined, true /* allowMultipleInstances */); | ||
} | ||
} | ||
@@ -1074,0 +1078,0 @@ registerRemoteConfig(firebase); |
{ | ||
"name": "@firebase/remote-config", | ||
"version": "0.1.7-canary.638aba6", | ||
"version": "0.1.7-canary.9b8ef59", | ||
"description": "The Remote Config package of the Firebase JS SDK", | ||
@@ -25,10 +25,11 @@ "author": "Firebase <firebase-support@google.com> (https://firebase.google.com/)", | ||
"peerDependencies": { | ||
"@firebase/app": "0.4.25-canary.638aba6", | ||
"@firebase/app-types": "0.4.8-canary.638aba6" | ||
"@firebase/app": "0.4.25-canary.9b8ef59", | ||
"@firebase/app-types": "0.4.8-canary.9b8ef59" | ||
}, | ||
"dependencies": { | ||
"@firebase/installations": "0.3.6-canary.638aba6", | ||
"@firebase/logger": "0.1.31-canary.638aba6", | ||
"@firebase/remote-config-types": "0.1.3-canary.638aba6", | ||
"@firebase/util": "0.2.34-canary.638aba6", | ||
"@firebase/installations": "0.3.6-canary.9b8ef59", | ||
"@firebase/logger": "0.1.31-canary.9b8ef59", | ||
"@firebase/remote-config-types": "0.1.3-canary.9b8ef59", | ||
"@firebase/util": "0.2.34-canary.9b8ef59", | ||
"@firebase/component": "0.1.0-canary.9b8ef59", | ||
"tslib": "1.10.0" | ||
@@ -35,0 +36,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
415528
4304
8
+ Added@firebase/app@0.4.25-canary.9b8ef59(transitive)
+ Added@firebase/app-types@0.4.8-canary.9b8ef59(transitive)
+ Added@firebase/installations@0.3.6-canary.9b8ef59(transitive)
+ Added@firebase/installations-types@0.2.2-canary.9b8ef59(transitive)
+ Added@firebase/logger@0.1.31-canary.9b8ef59(transitive)
+ Added@firebase/remote-config-types@0.1.3-canary.9b8ef59(transitive)
+ Added@firebase/util@0.2.34-canary.9b8ef59(transitive)
- Removed@firebase/app@0.4.25-canary.638aba6(transitive)
- Removed@firebase/app-types@0.4.8-canary.638aba6(transitive)
- Removed@firebase/installations@0.3.6-canary.638aba6(transitive)
- Removed@firebase/installations-types@0.2.2-canary.638aba6(transitive)
- Removed@firebase/logger@0.1.31-canary.638aba6(transitive)
- Removed@firebase/remote-config-types@0.1.3-canary.638aba6(transitive)
- Removed@firebase/util@0.2.34-canary.638aba6(transitive)