@firebase/util 1.7.0 → 1.7.1-20221010203322
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/index.esm2017.js +28 -19
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +28 -19
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +28 -18
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/node-esm/index.node.esm.js +28 -19
- package/dist/node-esm/index.node.esm.js.map +1 -1
- package/dist/node-esm/src/defaults.d.ts +8 -0
- package/dist/node-esm/test/defaults.test.d.ts +1 -0
- package/dist/src/defaults.d.ts +8 -0
- package/dist/test/defaults.test.d.ts +1 -0
- package/dist/util-public.d.ts +9 -0
- package/dist/util.d.ts +9 -0
- package/package.json +1 -1
package/dist/index.node.cjs.js
CHANGED
|
@@ -653,30 +653,13 @@ var getDefaultsFromGlobal = function () {
|
|
|
653
653
|
* process.env.__FIREBASE_DEFAULTS_PATH__
|
|
654
654
|
*/
|
|
655
655
|
var getDefaultsFromEnvVariable = function () {
|
|
656
|
-
if (typeof process === 'undefined') {
|
|
656
|
+
if (typeof process === 'undefined' || typeof process.env === 'undefined') {
|
|
657
657
|
return;
|
|
658
658
|
}
|
|
659
659
|
var defaultsJsonString = process.env.__FIREBASE_DEFAULTS__;
|
|
660
|
-
var defaultsJsonPath = process.env.__FIREBASE_DEFAULTS_PATH__;
|
|
661
660
|
if (defaultsJsonString) {
|
|
662
|
-
if (defaultsJsonPath) {
|
|
663
|
-
console.warn("Values were provided for both __FIREBASE_DEFAULTS__ " +
|
|
664
|
-
"and __FIREBASE_DEFAULTS_PATH__. __FIREBASE_DEFAULTS_PATH__ " +
|
|
665
|
-
"will be ignored.");
|
|
666
|
-
}
|
|
667
661
|
return JSON.parse(defaultsJsonString);
|
|
668
662
|
}
|
|
669
|
-
if (defaultsJsonPath && typeof require !== 'undefined') {
|
|
670
|
-
try {
|
|
671
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
672
|
-
var json = require(defaultsJsonPath);
|
|
673
|
-
return json;
|
|
674
|
-
}
|
|
675
|
-
catch (e) {
|
|
676
|
-
console.warn("Unable to read defaults from file provided to " +
|
|
677
|
-
("__FIREBASE_DEFAULTS_PATH__: " + defaultsJsonPath));
|
|
678
|
-
}
|
|
679
|
-
}
|
|
680
663
|
};
|
|
681
664
|
var getDefaultsFromCookie = function () {
|
|
682
665
|
if (typeof document === 'undefined') {
|
|
@@ -700,9 +683,35 @@ var getDefaults = function () {
|
|
|
700
683
|
/**
|
|
701
684
|
* Returns emulator host stored in the __FIREBASE_DEFAULTS__ object
|
|
702
685
|
* for the given product.
|
|
686
|
+
* @returns a URL host formatted like `127.0.0.1:9999` or `[::1]:4000` if available
|
|
703
687
|
* @public
|
|
704
688
|
*/
|
|
705
689
|
var getDefaultEmulatorHost = function (productName) { var _a, _b; return (_b = (_a = getDefaults()) === null || _a === void 0 ? void 0 : _a.emulatorHosts) === null || _b === void 0 ? void 0 : _b[productName]; };
|
|
690
|
+
/**
|
|
691
|
+
* Returns emulator hostname and port stored in the __FIREBASE_DEFAULTS__ object
|
|
692
|
+
* for the given product.
|
|
693
|
+
* @returns a pair of hostname and port like `["::1", 4000]` if available
|
|
694
|
+
* @public
|
|
695
|
+
*/
|
|
696
|
+
var getDefaultEmulatorHostnameAndPort = function (productName) {
|
|
697
|
+
var host = getDefaultEmulatorHost(productName);
|
|
698
|
+
if (!host) {
|
|
699
|
+
return undefined;
|
|
700
|
+
}
|
|
701
|
+
var separatorIndex = host.lastIndexOf(':'); // Finding the last since IPv6 addr also has colons.
|
|
702
|
+
if (separatorIndex <= 0 || separatorIndex + 1 === host.length) {
|
|
703
|
+
throw new Error("Invalid host " + host + " with no separate hostname and port!");
|
|
704
|
+
}
|
|
705
|
+
// eslint-disable-next-line no-restricted-globals
|
|
706
|
+
var port = parseInt(host.substring(separatorIndex + 1), 10);
|
|
707
|
+
if (host[0] === '[') {
|
|
708
|
+
// Bracket-quoted `[ipv6addr]:port` => return "ipv6addr" (without brackets).
|
|
709
|
+
return [host.substring(1, separatorIndex - 1), port];
|
|
710
|
+
}
|
|
711
|
+
else {
|
|
712
|
+
return [host.substring(0, separatorIndex), port];
|
|
713
|
+
}
|
|
714
|
+
};
|
|
706
715
|
/**
|
|
707
716
|
* Returns Firebase app config stored in the __FIREBASE_DEFAULTS__ object.
|
|
708
717
|
* @public
|
|
@@ -2080,6 +2089,7 @@ exports.errorPrefix = errorPrefix;
|
|
|
2080
2089
|
exports.extractQuerystring = extractQuerystring;
|
|
2081
2090
|
exports.getDefaultAppConfig = getDefaultAppConfig;
|
|
2082
2091
|
exports.getDefaultEmulatorHost = getDefaultEmulatorHost;
|
|
2092
|
+
exports.getDefaultEmulatorHostnameAndPort = getDefaultEmulatorHostnameAndPort;
|
|
2083
2093
|
exports.getExperimentalSetting = getExperimentalSetting;
|
|
2084
2094
|
exports.getGlobal = getGlobal;
|
|
2085
2095
|
exports.getModularInstance = getModularInstance;
|