@firebase/util 1.8.0 → 1.9.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/CHANGELOG.md +10 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.esm2017.js +181 -151
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +181 -151
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +181 -150
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.d.ts +1 -0
- package/dist/node-esm/index.d.ts +1 -0
- package/dist/node-esm/index.node.d.ts +1 -0
- package/dist/node-esm/index.node.esm.js +181 -151
- package/dist/node-esm/index.node.esm.js.map +1 -1
- package/dist/node-esm/src/defaults.d.ts +13 -0
- package/dist/node-esm/src/environment.d.ts +1 -6
- package/dist/node-esm/src/global.d.ts +22 -0
- package/dist/node-esm/test/environments.test.d.ts +17 -0
- package/dist/src/defaults.d.ts +13 -0
- package/dist/src/environment.d.ts +1 -6
- package/dist/src/global.d.ts +22 -0
- package/dist/test/environments.test.d.ts +17 -0
- package/dist/util-public.d.ts +32 -1
- package/dist/util.d.ts +32 -1
- package/package.json +1 -1
package/dist/index.esm5.js
CHANGED
|
@@ -451,7 +451,7 @@ function isValidKey(key) {
|
|
|
451
451
|
|
|
452
452
|
/**
|
|
453
453
|
* @license
|
|
454
|
-
* Copyright
|
|
454
|
+
* Copyright 2022 Google LLC
|
|
455
455
|
*
|
|
456
456
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
457
457
|
* you may not use this file except in compliance with the License.
|
|
@@ -465,156 +465,10 @@ function isValidKey(key) {
|
|
|
465
465
|
* See the License for the specific language governing permissions and
|
|
466
466
|
* limitations under the License.
|
|
467
467
|
*/
|
|
468
|
-
/**
|
|
469
|
-
* Returns navigator.userAgent string or '' if it's not defined.
|
|
470
|
-
* @return user agent string
|
|
471
|
-
*/
|
|
472
|
-
function getUA() {
|
|
473
|
-
if (typeof navigator !== 'undefined' &&
|
|
474
|
-
typeof navigator['userAgent'] === 'string') {
|
|
475
|
-
return navigator['userAgent'];
|
|
476
|
-
}
|
|
477
|
-
else {
|
|
478
|
-
return '';
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
/**
|
|
482
|
-
* Detect Cordova / PhoneGap / Ionic frameworks on a mobile device.
|
|
483
|
-
*
|
|
484
|
-
* Deliberately does not rely on checking `file://` URLs (as this fails PhoneGap
|
|
485
|
-
* in the Ripple emulator) nor Cordova `onDeviceReady`, which would normally
|
|
486
|
-
* wait for a callback.
|
|
487
|
-
*/
|
|
488
|
-
function isMobileCordova() {
|
|
489
|
-
return (typeof window !== 'undefined' &&
|
|
490
|
-
// @ts-ignore Setting up an broadly applicable index signature for Window
|
|
491
|
-
// just to deal with this case would probably be a bad idea.
|
|
492
|
-
!!(window['cordova'] || window['phonegap'] || window['PhoneGap']) &&
|
|
493
|
-
/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(getUA()));
|
|
494
|
-
}
|
|
495
|
-
/**
|
|
496
|
-
* Detect Node.js.
|
|
497
|
-
*
|
|
498
|
-
* @return true if Node.js environment is detected.
|
|
499
|
-
*/
|
|
500
|
-
// Node detection logic from: https://github.com/iliakan/detect-node/
|
|
501
|
-
function isNode() {
|
|
502
|
-
try {
|
|
503
|
-
return (Object.prototype.toString.call(global.process) === '[object process]');
|
|
504
|
-
}
|
|
505
|
-
catch (e) {
|
|
506
|
-
return false;
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
/**
|
|
510
|
-
* Detect Browser Environment
|
|
511
|
-
*/
|
|
512
|
-
function isBrowser() {
|
|
513
|
-
return typeof self === 'object' && self.self === self;
|
|
514
|
-
}
|
|
515
|
-
function isBrowserExtension() {
|
|
516
|
-
var runtime = typeof chrome === 'object'
|
|
517
|
-
? chrome.runtime
|
|
518
|
-
: typeof browser === 'object'
|
|
519
|
-
? browser.runtime
|
|
520
|
-
: undefined;
|
|
521
|
-
return typeof runtime === 'object' && runtime.id !== undefined;
|
|
522
|
-
}
|
|
523
|
-
/**
|
|
524
|
-
* Detect React Native.
|
|
525
|
-
*
|
|
526
|
-
* @return true if ReactNative environment is detected.
|
|
527
|
-
*/
|
|
528
|
-
function isReactNative() {
|
|
529
|
-
return (typeof navigator === 'object' && navigator['product'] === 'ReactNative');
|
|
530
|
-
}
|
|
531
|
-
/** Detects Electron apps. */
|
|
532
|
-
function isElectron() {
|
|
533
|
-
return getUA().indexOf('Electron/') >= 0;
|
|
534
|
-
}
|
|
535
|
-
/** Detects Internet Explorer. */
|
|
536
|
-
function isIE() {
|
|
537
|
-
var ua = getUA();
|
|
538
|
-
return ua.indexOf('MSIE ') >= 0 || ua.indexOf('Trident/') >= 0;
|
|
539
|
-
}
|
|
540
|
-
/** Detects Universal Windows Platform apps. */
|
|
541
|
-
function isUWP() {
|
|
542
|
-
return getUA().indexOf('MSAppHost/') >= 0;
|
|
543
|
-
}
|
|
544
|
-
/**
|
|
545
|
-
* Detect whether the current SDK build is the Node version.
|
|
546
|
-
*
|
|
547
|
-
* @return true if it's the Node SDK build.
|
|
548
|
-
*/
|
|
549
|
-
function isNodeSdk() {
|
|
550
|
-
return CONSTANTS.NODE_CLIENT === true || CONSTANTS.NODE_ADMIN === true;
|
|
551
|
-
}
|
|
552
|
-
/** Returns true if we are running in Safari. */
|
|
553
|
-
function isSafari() {
|
|
554
|
-
return (!isNode() &&
|
|
555
|
-
navigator.userAgent.includes('Safari') &&
|
|
556
|
-
!navigator.userAgent.includes('Chrome'));
|
|
557
|
-
}
|
|
558
|
-
/**
|
|
559
|
-
* This method checks if indexedDB is supported by current browser/service worker context
|
|
560
|
-
* @return true if indexedDB is supported by current browser/service worker context
|
|
561
|
-
*/
|
|
562
|
-
function isIndexedDBAvailable() {
|
|
563
|
-
try {
|
|
564
|
-
return typeof indexedDB === 'object';
|
|
565
|
-
}
|
|
566
|
-
catch (e) {
|
|
567
|
-
return false;
|
|
568
|
-
}
|
|
569
|
-
}
|
|
570
|
-
/**
|
|
571
|
-
* This method validates browser/sw context for indexedDB by opening a dummy indexedDB database and reject
|
|
572
|
-
* if errors occur during the database open operation.
|
|
573
|
-
*
|
|
574
|
-
* @throws exception if current browser/sw context can't run idb.open (ex: Safari iframe, Firefox
|
|
575
|
-
* private browsing)
|
|
576
|
-
*/
|
|
577
|
-
function validateIndexedDBOpenable() {
|
|
578
|
-
return new Promise(function (resolve, reject) {
|
|
579
|
-
try {
|
|
580
|
-
var preExist_1 = true;
|
|
581
|
-
var DB_CHECK_NAME_1 = 'validate-browser-context-for-indexeddb-analytics-module';
|
|
582
|
-
var request_1 = self.indexedDB.open(DB_CHECK_NAME_1);
|
|
583
|
-
request_1.onsuccess = function () {
|
|
584
|
-
request_1.result.close();
|
|
585
|
-
// delete database only when it doesn't pre-exist
|
|
586
|
-
if (!preExist_1) {
|
|
587
|
-
self.indexedDB.deleteDatabase(DB_CHECK_NAME_1);
|
|
588
|
-
}
|
|
589
|
-
resolve(true);
|
|
590
|
-
};
|
|
591
|
-
request_1.onupgradeneeded = function () {
|
|
592
|
-
preExist_1 = false;
|
|
593
|
-
};
|
|
594
|
-
request_1.onerror = function () {
|
|
595
|
-
var _a;
|
|
596
|
-
reject(((_a = request_1.error) === null || _a === void 0 ? void 0 : _a.message) || '');
|
|
597
|
-
};
|
|
598
|
-
}
|
|
599
|
-
catch (error) {
|
|
600
|
-
reject(error);
|
|
601
|
-
}
|
|
602
|
-
});
|
|
603
|
-
}
|
|
604
|
-
/**
|
|
605
|
-
*
|
|
606
|
-
* This method checks whether cookie is enabled within current browser
|
|
607
|
-
* @return true if cookie is enabled within current browser
|
|
608
|
-
*/
|
|
609
|
-
function areCookiesEnabled() {
|
|
610
|
-
if (typeof navigator === 'undefined' || !navigator.cookieEnabled) {
|
|
611
|
-
return false;
|
|
612
|
-
}
|
|
613
|
-
return true;
|
|
614
|
-
}
|
|
615
468
|
/**
|
|
616
469
|
* Polyfill for `globalThis` object.
|
|
617
470
|
* @returns the `globalThis` object for the given environment.
|
|
471
|
+
* @public
|
|
618
472
|
*/
|
|
619
473
|
function getGlobal() {
|
|
620
474
|
if (typeof self !== 'undefined') {
|
|
@@ -650,8 +504,11 @@ var getDefaultsFromGlobal = function () {
|
|
|
650
504
|
};
|
|
651
505
|
/**
|
|
652
506
|
* Attempt to read defaults from a JSON string provided to
|
|
653
|
-
* process.env.__FIREBASE_DEFAULTS__ or a JSON file whose path is in
|
|
654
|
-
* process.env.__FIREBASE_DEFAULTS_PATH__
|
|
507
|
+
* process(.)env(.)__FIREBASE_DEFAULTS__ or a JSON file whose path is in
|
|
508
|
+
* process(.)env(.)__FIREBASE_DEFAULTS_PATH__
|
|
509
|
+
* The dots are in parens because certain compilers (Vite?) cannot
|
|
510
|
+
* handle seeing that variable in comments.
|
|
511
|
+
* See https://github.com/firebase/firebase-js-sdk/issues/6838
|
|
655
512
|
*/
|
|
656
513
|
var getDefaultsFromEnvVariable = function () {
|
|
657
514
|
if (typeof process === 'undefined' || typeof process.env === 'undefined') {
|
|
@@ -683,6 +540,7 @@ var getDefaultsFromCookie = function () {
|
|
|
683
540
|
* (1) if such an object exists as a property of `globalThis`
|
|
684
541
|
* (2) if such an object was provided on a shell environment variable
|
|
685
542
|
* (3) if such an object exists in a cookie
|
|
543
|
+
* @public
|
|
686
544
|
*/
|
|
687
545
|
var getDefaults = function () {
|
|
688
546
|
try {
|
|
@@ -849,6 +707,178 @@ function createMockUserToken(token, projectId) {
|
|
|
849
707
|
].join('.');
|
|
850
708
|
}
|
|
851
709
|
|
|
710
|
+
/**
|
|
711
|
+
* @license
|
|
712
|
+
* Copyright 2017 Google LLC
|
|
713
|
+
*
|
|
714
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
715
|
+
* you may not use this file except in compliance with the License.
|
|
716
|
+
* You may obtain a copy of the License at
|
|
717
|
+
*
|
|
718
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
719
|
+
*
|
|
720
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
721
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
722
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
723
|
+
* See the License for the specific language governing permissions and
|
|
724
|
+
* limitations under the License.
|
|
725
|
+
*/
|
|
726
|
+
/**
|
|
727
|
+
* Returns navigator.userAgent string or '' if it's not defined.
|
|
728
|
+
* @return user agent string
|
|
729
|
+
*/
|
|
730
|
+
function getUA() {
|
|
731
|
+
if (typeof navigator !== 'undefined' &&
|
|
732
|
+
typeof navigator['userAgent'] === 'string') {
|
|
733
|
+
return navigator['userAgent'];
|
|
734
|
+
}
|
|
735
|
+
else {
|
|
736
|
+
return '';
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
/**
|
|
740
|
+
* Detect Cordova / PhoneGap / Ionic frameworks on a mobile device.
|
|
741
|
+
*
|
|
742
|
+
* Deliberately does not rely on checking `file://` URLs (as this fails PhoneGap
|
|
743
|
+
* in the Ripple emulator) nor Cordova `onDeviceReady`, which would normally
|
|
744
|
+
* wait for a callback.
|
|
745
|
+
*/
|
|
746
|
+
function isMobileCordova() {
|
|
747
|
+
return (typeof window !== 'undefined' &&
|
|
748
|
+
// @ts-ignore Setting up an broadly applicable index signature for Window
|
|
749
|
+
// just to deal with this case would probably be a bad idea.
|
|
750
|
+
!!(window['cordova'] || window['phonegap'] || window['PhoneGap']) &&
|
|
751
|
+
/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(getUA()));
|
|
752
|
+
}
|
|
753
|
+
/**
|
|
754
|
+
* Detect Node.js.
|
|
755
|
+
*
|
|
756
|
+
* @return true if Node.js environment is detected or specified.
|
|
757
|
+
*/
|
|
758
|
+
// Node detection logic from: https://github.com/iliakan/detect-node/
|
|
759
|
+
function isNode() {
|
|
760
|
+
var _a;
|
|
761
|
+
var forceEnvironment = (_a = getDefaults()) === null || _a === void 0 ? void 0 : _a.forceEnvironment;
|
|
762
|
+
if (forceEnvironment === 'node') {
|
|
763
|
+
return true;
|
|
764
|
+
}
|
|
765
|
+
else if (forceEnvironment === 'browser') {
|
|
766
|
+
return false;
|
|
767
|
+
}
|
|
768
|
+
try {
|
|
769
|
+
return (Object.prototype.toString.call(global.process) === '[object process]');
|
|
770
|
+
}
|
|
771
|
+
catch (e) {
|
|
772
|
+
return false;
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
/**
|
|
776
|
+
* Detect Browser Environment
|
|
777
|
+
*/
|
|
778
|
+
function isBrowser() {
|
|
779
|
+
return typeof self === 'object' && self.self === self;
|
|
780
|
+
}
|
|
781
|
+
function isBrowserExtension() {
|
|
782
|
+
var runtime = typeof chrome === 'object'
|
|
783
|
+
? chrome.runtime
|
|
784
|
+
: typeof browser === 'object'
|
|
785
|
+
? browser.runtime
|
|
786
|
+
: undefined;
|
|
787
|
+
return typeof runtime === 'object' && runtime.id !== undefined;
|
|
788
|
+
}
|
|
789
|
+
/**
|
|
790
|
+
* Detect React Native.
|
|
791
|
+
*
|
|
792
|
+
* @return true if ReactNative environment is detected.
|
|
793
|
+
*/
|
|
794
|
+
function isReactNative() {
|
|
795
|
+
return (typeof navigator === 'object' && navigator['product'] === 'ReactNative');
|
|
796
|
+
}
|
|
797
|
+
/** Detects Electron apps. */
|
|
798
|
+
function isElectron() {
|
|
799
|
+
return getUA().indexOf('Electron/') >= 0;
|
|
800
|
+
}
|
|
801
|
+
/** Detects Internet Explorer. */
|
|
802
|
+
function isIE() {
|
|
803
|
+
var ua = getUA();
|
|
804
|
+
return ua.indexOf('MSIE ') >= 0 || ua.indexOf('Trident/') >= 0;
|
|
805
|
+
}
|
|
806
|
+
/** Detects Universal Windows Platform apps. */
|
|
807
|
+
function isUWP() {
|
|
808
|
+
return getUA().indexOf('MSAppHost/') >= 0;
|
|
809
|
+
}
|
|
810
|
+
/**
|
|
811
|
+
* Detect whether the current SDK build is the Node version.
|
|
812
|
+
*
|
|
813
|
+
* @return true if it's the Node SDK build.
|
|
814
|
+
*/
|
|
815
|
+
function isNodeSdk() {
|
|
816
|
+
return CONSTANTS.NODE_CLIENT === true || CONSTANTS.NODE_ADMIN === true;
|
|
817
|
+
}
|
|
818
|
+
/** Returns true if we are running in Safari. */
|
|
819
|
+
function isSafari() {
|
|
820
|
+
return (!isNode() &&
|
|
821
|
+
navigator.userAgent.includes('Safari') &&
|
|
822
|
+
!navigator.userAgent.includes('Chrome'));
|
|
823
|
+
}
|
|
824
|
+
/**
|
|
825
|
+
* This method checks if indexedDB is supported by current browser/service worker context
|
|
826
|
+
* @return true if indexedDB is supported by current browser/service worker context
|
|
827
|
+
*/
|
|
828
|
+
function isIndexedDBAvailable() {
|
|
829
|
+
try {
|
|
830
|
+
return typeof indexedDB === 'object';
|
|
831
|
+
}
|
|
832
|
+
catch (e) {
|
|
833
|
+
return false;
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
/**
|
|
837
|
+
* This method validates browser/sw context for indexedDB by opening a dummy indexedDB database and reject
|
|
838
|
+
* if errors occur during the database open operation.
|
|
839
|
+
*
|
|
840
|
+
* @throws exception if current browser/sw context can't run idb.open (ex: Safari iframe, Firefox
|
|
841
|
+
* private browsing)
|
|
842
|
+
*/
|
|
843
|
+
function validateIndexedDBOpenable() {
|
|
844
|
+
return new Promise(function (resolve, reject) {
|
|
845
|
+
try {
|
|
846
|
+
var preExist_1 = true;
|
|
847
|
+
var DB_CHECK_NAME_1 = 'validate-browser-context-for-indexeddb-analytics-module';
|
|
848
|
+
var request_1 = self.indexedDB.open(DB_CHECK_NAME_1);
|
|
849
|
+
request_1.onsuccess = function () {
|
|
850
|
+
request_1.result.close();
|
|
851
|
+
// delete database only when it doesn't pre-exist
|
|
852
|
+
if (!preExist_1) {
|
|
853
|
+
self.indexedDB.deleteDatabase(DB_CHECK_NAME_1);
|
|
854
|
+
}
|
|
855
|
+
resolve(true);
|
|
856
|
+
};
|
|
857
|
+
request_1.onupgradeneeded = function () {
|
|
858
|
+
preExist_1 = false;
|
|
859
|
+
};
|
|
860
|
+
request_1.onerror = function () {
|
|
861
|
+
var _a;
|
|
862
|
+
reject(((_a = request_1.error) === null || _a === void 0 ? void 0 : _a.message) || '');
|
|
863
|
+
};
|
|
864
|
+
}
|
|
865
|
+
catch (error) {
|
|
866
|
+
reject(error);
|
|
867
|
+
}
|
|
868
|
+
});
|
|
869
|
+
}
|
|
870
|
+
/**
|
|
871
|
+
*
|
|
872
|
+
* This method checks whether cookie is enabled within current browser
|
|
873
|
+
* @return true if cookie is enabled within current browser
|
|
874
|
+
*/
|
|
875
|
+
function areCookiesEnabled() {
|
|
876
|
+
if (typeof navigator === 'undefined' || !navigator.cookieEnabled) {
|
|
877
|
+
return false;
|
|
878
|
+
}
|
|
879
|
+
return true;
|
|
880
|
+
}
|
|
881
|
+
|
|
852
882
|
/**
|
|
853
883
|
* @license
|
|
854
884
|
* Copyright 2017 Google LLC
|
|
@@ -2064,5 +2094,5 @@ function getModularInstance(service) {
|
|
|
2064
2094
|
}
|
|
2065
2095
|
}
|
|
2066
2096
|
|
|
2067
|
-
export { CONSTANTS, Deferred, ErrorFactory, FirebaseError, MAX_VALUE_MILLIS, RANDOM_FACTOR, Sha1, areCookiesEnabled, assert, assertionError, async, base64, base64Decode, base64Encode, base64urlEncodeWithoutPadding, calculateBackoffMillis, contains, createMockUserToken, createSubscribe, decode, deepCopy, deepEqual, deepExtend, errorPrefix, extractQuerystring, getDefaultAppConfig, getDefaultEmulatorHost, getDefaultEmulatorHostnameAndPort, getExperimentalSetting, getGlobal, getModularInstance, getUA, isAdmin, isBrowser, isBrowserExtension, isElectron, isEmpty, isIE, isIndexedDBAvailable, isMobileCordova, isNode, isNodeSdk, isReactNative, isSafari, isUWP, isValidFormat, isValidTimestamp, issuedAtTime, jsonEval, map, ordinal, promiseWithTimeout, querystring, querystringDecode, safeGet, stringLength, stringToByteArray, stringify, uuidv4, validateArgCount, validateCallback, validateContextObject, validateIndexedDBOpenable, validateNamespace };
|
|
2097
|
+
export { CONSTANTS, Deferred, ErrorFactory, FirebaseError, MAX_VALUE_MILLIS, RANDOM_FACTOR, Sha1, areCookiesEnabled, assert, assertionError, async, base64, base64Decode, base64Encode, base64urlEncodeWithoutPadding, calculateBackoffMillis, contains, createMockUserToken, createSubscribe, decode, deepCopy, deepEqual, deepExtend, errorPrefix, extractQuerystring, getDefaultAppConfig, getDefaultEmulatorHost, getDefaultEmulatorHostnameAndPort, getDefaults, getExperimentalSetting, getGlobal, getModularInstance, getUA, isAdmin, isBrowser, isBrowserExtension, isElectron, isEmpty, isIE, isIndexedDBAvailable, isMobileCordova, isNode, isNodeSdk, isReactNative, isSafari, isUWP, isValidFormat, isValidTimestamp, issuedAtTime, jsonEval, map, ordinal, promiseWithTimeout, querystring, querystringDecode, safeGet, stringLength, stringToByteArray, stringify, uuidv4, validateArgCount, validateCallback, validateContextObject, validateIndexedDBOpenable, validateNamespace };
|
|
2068
2098
|
//# sourceMappingURL=index.esm5.js.map
|