@firebase/util 1.11.1-canary.f92069a21 → 1.11.1

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/dist/index.cjs.js CHANGED
@@ -671,41 +671,6 @@ class Deferred {
671
671
  }
672
672
  }
673
673
 
674
- /**
675
- * @license
676
- * Copyright 2025 Google LLC
677
- *
678
- * Licensed under the Apache License, Version 2.0 (the "License");
679
- * you may not use this file except in compliance with the License.
680
- * You may obtain a copy of the License at
681
- *
682
- * http://www.apache.org/licenses/LICENSE-2.0
683
- *
684
- * Unless required by applicable law or agreed to in writing, software
685
- * distributed under the License is distributed on an "AS IS" BASIS,
686
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
687
- * See the License for the specific language governing permissions and
688
- * limitations under the License.
689
- */
690
- /**
691
- * Checks whether host is a cloud workstation or not.
692
- * @public
693
- */
694
- function isCloudWorkstation(host) {
695
- return host.endsWith('.cloudworkstations.dev');
696
- }
697
- /**
698
- * Makes a fetch request to the given server.
699
- * Mostly used for forwarding cookies in Firebase Studio.
700
- * @public
701
- */
702
- async function pingServer(endpoint) {
703
- const result = await fetch(endpoint, {
704
- credentials: 'include'
705
- });
706
- return result.ok;
707
- }
708
-
709
674
  /**
710
675
  * @license
711
676
  * Copyright 2021 Google LLC
@@ -751,152 +716,6 @@ function createMockUserToken(token, projectId) {
751
716
  signature
752
717
  ].join('.');
753
718
  }
754
- const emulatorStatus = {};
755
- // Checks whether any products are running on an emulator
756
- function getEmulatorSummary() {
757
- const summary = {
758
- prod: [],
759
- emulator: []
760
- };
761
- for (const key of Object.keys(emulatorStatus)) {
762
- if (emulatorStatus[key]) {
763
- summary.emulator.push(key);
764
- }
765
- else {
766
- summary.prod.push(key);
767
- }
768
- }
769
- return summary;
770
- }
771
- function getOrCreateEl(id) {
772
- let parentDiv = document.getElementById(id);
773
- let created = false;
774
- if (!parentDiv) {
775
- parentDiv = document.createElement('div');
776
- parentDiv.setAttribute('id', id);
777
- created = true;
778
- }
779
- return { created, element: parentDiv };
780
- }
781
- let previouslyDismissed = false;
782
- /**
783
- * Updates Emulator Banner. Primarily used for Firebase Studio
784
- * @param name
785
- * @param isRunningEmulator
786
- * @public
787
- */
788
- function updateEmulatorBanner(name, isRunningEmulator) {
789
- if (typeof window === 'undefined' ||
790
- typeof document === 'undefined' ||
791
- !isCloudWorkstation(window.location.host) ||
792
- emulatorStatus[name] === isRunningEmulator ||
793
- emulatorStatus[name] || // If already set to use emulator, can't go back to prod.
794
- previouslyDismissed) {
795
- return;
796
- }
797
- emulatorStatus[name] = isRunningEmulator;
798
- function prefixedId(id) {
799
- return `__firebase__banner__${id}`;
800
- }
801
- const bannerId = '__firebase__banner';
802
- const summary = getEmulatorSummary();
803
- const showError = summary.prod.length > 0;
804
- function tearDown() {
805
- const element = document.getElementById(bannerId);
806
- if (element) {
807
- element.remove();
808
- }
809
- }
810
- function setupBannerStyles(bannerEl) {
811
- bannerEl.style.display = 'flex';
812
- bannerEl.style.background = '#7faaf0';
813
- bannerEl.style.position = 'absolute';
814
- bannerEl.style.bottom = '5px';
815
- bannerEl.style.left = '5px';
816
- bannerEl.style.padding = '.5em';
817
- bannerEl.style.borderRadius = '5px';
818
- bannerEl.style.alignItems = 'center';
819
- }
820
- function setupIconStyles(prependIcon, iconId) {
821
- prependIcon.setAttribute('width', '24');
822
- prependIcon.setAttribute('id', iconId);
823
- prependIcon.setAttribute('height', '24');
824
- prependIcon.setAttribute('viewBox', '0 0 24 24');
825
- prependIcon.setAttribute('fill', 'none');
826
- prependIcon.style.marginLeft = '-6px';
827
- }
828
- function setupCloseBtn() {
829
- const closeBtn = document.createElement('span');
830
- closeBtn.style.cursor = 'pointer';
831
- closeBtn.style.marginLeft = '16px';
832
- closeBtn.style.fontSize = '24px';
833
- closeBtn.innerHTML = ' ×';
834
- closeBtn.onclick = () => {
835
- previouslyDismissed = true;
836
- tearDown();
837
- };
838
- return closeBtn;
839
- }
840
- function setupLinkStyles(learnMoreLink, learnMoreId) {
841
- learnMoreLink.setAttribute('id', learnMoreId);
842
- learnMoreLink.innerText = 'Learn more';
843
- learnMoreLink.href =
844
- 'https://firebase.google.com/docs/studio/preview-apps#preview-backend';
845
- learnMoreLink.setAttribute('target', '__blank');
846
- learnMoreLink.style.paddingLeft = '5px';
847
- learnMoreLink.style.textDecoration = 'underline';
848
- }
849
- function setupDom() {
850
- const banner = getOrCreateEl(bannerId);
851
- const firebaseTextId = prefixedId('text');
852
- const firebaseText = document.getElementById(firebaseTextId) || document.createElement('span');
853
- const learnMoreId = prefixedId('learnmore');
854
- const learnMoreLink = document.getElementById(learnMoreId) ||
855
- document.createElement('a');
856
- const prependIconId = prefixedId('preprendIcon');
857
- const prependIcon = document.getElementById(prependIconId) ||
858
- document.createElementNS('http://www.w3.org/2000/svg', 'svg');
859
- if (banner.created) {
860
- // update styles
861
- const bannerEl = banner.element;
862
- setupBannerStyles(bannerEl);
863
- setupLinkStyles(learnMoreLink, learnMoreId);
864
- const closeBtn = setupCloseBtn();
865
- setupIconStyles(prependIcon, prependIconId);
866
- bannerEl.append(prependIcon, firebaseText, learnMoreLink, closeBtn);
867
- document.body.appendChild(bannerEl);
868
- }
869
- if (showError) {
870
- firebaseText.innerText = `Preview backend disconnected.`;
871
- prependIcon.innerHTML = `<g clip-path="url(#clip0_6013_33858)">
872
- <path d="M4.8 17.6L12 5.6L19.2 17.6H4.8ZM6.91667 16.4H17.0833L12 7.93333L6.91667 16.4ZM12 15.6C12.1667 15.6 12.3056 15.5444 12.4167 15.4333C12.5389 15.3111 12.6 15.1667 12.6 15C12.6 14.8333 12.5389 14.6944 12.4167 14.5833C12.3056 14.4611 12.1667 14.4 12 14.4C11.8333 14.4 11.6889 14.4611 11.5667 14.5833C11.4556 14.6944 11.4 14.8333 11.4 15C11.4 15.1667 11.4556 15.3111 11.5667 15.4333C11.6889 15.5444 11.8333 15.6 12 15.6ZM11.4 13.6H12.6V10.4H11.4V13.6Z" fill="#212121"/>
873
- </g>
874
- <defs>
875
- <clipPath id="clip0_6013_33858">
876
- <rect width="24" height="24" fill="white"/>
877
- </clipPath>
878
- </defs>`;
879
- }
880
- else {
881
- prependIcon.innerHTML = `<g clip-path="url(#clip0_6083_34804)">
882
- <path d="M11.4 15.2H12.6V11.2H11.4V15.2ZM12 10C12.1667 10 12.3056 9.94444 12.4167 9.83333C12.5389 9.71111 12.6 9.56667 12.6 9.4C12.6 9.23333 12.5389 9.09444 12.4167 8.98333C12.3056 8.86111 12.1667 8.8 12 8.8C11.8333 8.8 11.6889 8.86111 11.5667 8.98333C11.4556 9.09444 11.4 9.23333 11.4 9.4C11.4 9.56667 11.4556 9.71111 11.5667 9.83333C11.6889 9.94444 11.8333 10 12 10ZM12 18.4C11.1222 18.4 10.2944 18.2333 9.51667 17.9C8.73889 17.5667 8.05556 17.1111 7.46667 16.5333C6.88889 15.9444 6.43333 15.2611 6.1 14.4833C5.76667 13.7056 5.6 12.8778 5.6 12C5.6 11.1111 5.76667 10.2833 6.1 9.51667C6.43333 8.73889 6.88889 8.06111 7.46667 7.48333C8.05556 6.89444 8.73889 6.43333 9.51667 6.1C10.2944 5.76667 11.1222 5.6 12 5.6C12.8889 5.6 13.7167 5.76667 14.4833 6.1C15.2611 6.43333 15.9389 6.89444 16.5167 7.48333C17.1056 8.06111 17.5667 8.73889 17.9 9.51667C18.2333 10.2833 18.4 11.1111 18.4 12C18.4 12.8778 18.2333 13.7056 17.9 14.4833C17.5667 15.2611 17.1056 15.9444 16.5167 16.5333C15.9389 17.1111 15.2611 17.5667 14.4833 17.9C13.7167 18.2333 12.8889 18.4 12 18.4ZM12 17.2C13.4444 17.2 14.6722 16.6944 15.6833 15.6833C16.6944 14.6722 17.2 13.4444 17.2 12C17.2 10.5556 16.6944 9.32778 15.6833 8.31667C14.6722 7.30555 13.4444 6.8 12 6.8C10.5556 6.8 9.32778 7.30555 8.31667 8.31667C7.30556 9.32778 6.8 10.5556 6.8 12C6.8 13.4444 7.30556 14.6722 8.31667 15.6833C9.32778 16.6944 10.5556 17.2 12 17.2Z" fill="#212121"/>
883
- </g>
884
- <defs>
885
- <clipPath id="clip0_6083_34804">
886
- <rect width="24" height="24" fill="white"/>
887
- </clipPath>
888
- </defs>`;
889
- firebaseText.innerText = 'Preview backend running in this workspace.';
890
- }
891
- firebaseText.setAttribute('id', firebaseTextId);
892
- }
893
- if (document.readyState === 'loading') {
894
- window.addEventListener('DOMContentLoaded', setupDom);
895
- }
896
- else {
897
- setupDom();
898
- }
899
- }
900
719
 
901
720
  /**
902
721
  * @license
@@ -1031,14 +850,6 @@ function isSafari() {
1031
850
  navigator.userAgent.includes('Safari') &&
1032
851
  !navigator.userAgent.includes('Chrome'));
1033
852
  }
1034
- /** Returns true if we are running in Safari or WebKit */
1035
- function isSafariOrWebkit() {
1036
- return (!isNode() &&
1037
- !!navigator.userAgent &&
1038
- (navigator.userAgent.includes('Safari') ||
1039
- navigator.userAgent.includes('WebKit')) &&
1040
- !navigator.userAgent.includes('Chrome'));
1041
- }
1042
853
  /**
1043
854
  * This method checks if indexedDB is supported by current browser/service worker context
1044
855
  * @return true if indexedDB is supported by current browser/service worker context
@@ -2298,6 +2109,41 @@ function getModularInstance(service) {
2298
2109
  }
2299
2110
  }
2300
2111
 
2112
+ /**
2113
+ * @license
2114
+ * Copyright 2025 Google LLC
2115
+ *
2116
+ * Licensed under the Apache License, Version 2.0 (the "License");
2117
+ * you may not use this file except in compliance with the License.
2118
+ * You may obtain a copy of the License at
2119
+ *
2120
+ * http://www.apache.org/licenses/LICENSE-2.0
2121
+ *
2122
+ * Unless required by applicable law or agreed to in writing, software
2123
+ * distributed under the License is distributed on an "AS IS" BASIS,
2124
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2125
+ * See the License for the specific language governing permissions and
2126
+ * limitations under the License.
2127
+ */
2128
+ /**
2129
+ * Checks whether host is a cloud workstation or not.
2130
+ * @public
2131
+ */
2132
+ function isCloudWorkstation(host) {
2133
+ return host.endsWith('.cloudworkstations.dev');
2134
+ }
2135
+ /**
2136
+ * Makes a fetch request to the given server.
2137
+ * Mostly used for forwarding cookies in Firebase Studio.
2138
+ * @public
2139
+ */
2140
+ async function pingServer(endpoint) {
2141
+ const result = await fetch(endpoint, {
2142
+ credentials: 'include'
2143
+ });
2144
+ return result.ok;
2145
+ }
2146
+
2301
2147
  exports.CONSTANTS = CONSTANTS;
2302
2148
  exports.DecodeBase64StringError = DecodeBase64StringError;
2303
2149
  exports.Deferred = Deferred;
@@ -2346,7 +2192,6 @@ exports.isNode = isNode;
2346
2192
  exports.isNodeSdk = isNodeSdk;
2347
2193
  exports.isReactNative = isReactNative;
2348
2194
  exports.isSafari = isSafari;
2349
- exports.isSafariOrWebkit = isSafariOrWebkit;
2350
2195
  exports.isUWP = isUWP;
2351
2196
  exports.isValidFormat = isValidFormat;
2352
2197
  exports.isValidTimestamp = isValidTimestamp;
@@ -2363,7 +2208,6 @@ exports.safeGet = safeGet;
2363
2208
  exports.stringLength = stringLength;
2364
2209
  exports.stringToByteArray = stringToByteArray;
2365
2210
  exports.stringify = stringify;
2366
- exports.updateEmulatorBanner = updateEmulatorBanner;
2367
2211
  exports.validateArgCount = validateArgCount;
2368
2212
  exports.validateCallback = validateCallback;
2369
2213
  exports.validateContextObject = validateContextObject;