@firebase/util 1.14.0 → 1.15.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.
@@ -667,53 +667,6 @@ class Deferred {
667
667
  }
668
668
  }
669
669
 
670
- /**
671
- * @license
672
- * Copyright 2025 Google LLC
673
- *
674
- * Licensed under the Apache License, Version 2.0 (the "License");
675
- * you may not use this file except in compliance with the License.
676
- * You may obtain a copy of the License at
677
- *
678
- * http://www.apache.org/licenses/LICENSE-2.0
679
- *
680
- * Unless required by applicable law or agreed to in writing, software
681
- * distributed under the License is distributed on an "AS IS" BASIS,
682
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
683
- * See the License for the specific language governing permissions and
684
- * limitations under the License.
685
- */
686
- /**
687
- * Checks whether host is a cloud workstation or not.
688
- * @public
689
- */
690
- function isCloudWorkstation(url) {
691
- // `isCloudWorkstation` is called without protocol in certain connect*Emulator functions
692
- // In HTTP request builders, it's called with the protocol.
693
- // If called with protocol prefix, it's a valid URL, so we extract the hostname
694
- // If called without, we assume the string is the hostname.
695
- try {
696
- const host = url.startsWith('http://') || url.startsWith('https://')
697
- ? new URL(url).hostname
698
- : url;
699
- return host.endsWith('.cloudworkstations.dev');
700
- }
701
- catch {
702
- return false;
703
- }
704
- }
705
- /**
706
- * Makes a fetch request to the given server.
707
- * Mostly used for forwarding cookies in Firebase Studio.
708
- * @public
709
- */
710
- async function pingServer(endpoint) {
711
- const result = await fetch(endpoint, {
712
- credentials: 'include'
713
- });
714
- return result.ok;
715
- }
716
-
717
670
  /**
718
671
  * @license
719
672
  * Copyright 2021 Google LLC
@@ -769,152 +722,6 @@ function createMockUserToken(token, projectId) {
769
722
  signature
770
723
  ].join('.');
771
724
  }
772
- const emulatorStatus = {};
773
- // Checks whether any products are running on an emulator
774
- function getEmulatorSummary() {
775
- const summary = {
776
- prod: [],
777
- emulator: []
778
- };
779
- for (const key of Object.keys(emulatorStatus)) {
780
- if (emulatorStatus[key]) {
781
- summary.emulator.push(key);
782
- }
783
- else {
784
- summary.prod.push(key);
785
- }
786
- }
787
- return summary;
788
- }
789
- function getOrCreateEl(id) {
790
- let parentDiv = document.getElementById(id);
791
- let created = false;
792
- if (!parentDiv) {
793
- parentDiv = document.createElement('div');
794
- parentDiv.setAttribute('id', id);
795
- created = true;
796
- }
797
- return { created, element: parentDiv };
798
- }
799
- let previouslyDismissed = false;
800
- /**
801
- * Updates Emulator Banner. Primarily used for Firebase Studio
802
- * @param name
803
- * @param isRunningEmulator
804
- * @public
805
- */
806
- function updateEmulatorBanner(name, isRunningEmulator) {
807
- if (typeof window === 'undefined' ||
808
- typeof document === 'undefined' ||
809
- !isCloudWorkstation(window.location.host) ||
810
- emulatorStatus[name] === isRunningEmulator ||
811
- emulatorStatus[name] || // If already set to use emulator, can't go back to prod.
812
- previouslyDismissed) {
813
- return;
814
- }
815
- emulatorStatus[name] = isRunningEmulator;
816
- function prefixedId(id) {
817
- return `__firebase__banner__${id}`;
818
- }
819
- const bannerId = '__firebase__banner';
820
- const summary = getEmulatorSummary();
821
- const showError = summary.prod.length > 0;
822
- function tearDown() {
823
- const element = document.getElementById(bannerId);
824
- if (element) {
825
- element.remove();
826
- }
827
- }
828
- function setupBannerStyles(bannerEl) {
829
- bannerEl.style.display = 'flex';
830
- bannerEl.style.background = '#7faaf0';
831
- bannerEl.style.position = 'fixed';
832
- bannerEl.style.bottom = '5px';
833
- bannerEl.style.left = '5px';
834
- bannerEl.style.padding = '.5em';
835
- bannerEl.style.borderRadius = '5px';
836
- bannerEl.style.alignItems = 'center';
837
- }
838
- function setupIconStyles(prependIcon, iconId) {
839
- prependIcon.setAttribute('width', '24');
840
- prependIcon.setAttribute('id', iconId);
841
- prependIcon.setAttribute('height', '24');
842
- prependIcon.setAttribute('viewBox', '0 0 24 24');
843
- prependIcon.setAttribute('fill', 'none');
844
- prependIcon.style.marginLeft = '-6px';
845
- }
846
- function setupCloseBtn() {
847
- const closeBtn = document.createElement('span');
848
- closeBtn.style.cursor = 'pointer';
849
- closeBtn.style.marginLeft = '16px';
850
- closeBtn.style.fontSize = '24px';
851
- closeBtn.innerHTML = ' ×';
852
- closeBtn.onclick = () => {
853
- previouslyDismissed = true;
854
- tearDown();
855
- };
856
- return closeBtn;
857
- }
858
- function setupLinkStyles(learnMoreLink, learnMoreId) {
859
- learnMoreLink.setAttribute('id', learnMoreId);
860
- learnMoreLink.innerText = 'Learn more';
861
- learnMoreLink.href =
862
- 'https://firebase.google.com/docs/studio/preview-apps#preview-backend';
863
- learnMoreLink.setAttribute('target', '__blank');
864
- learnMoreLink.style.paddingLeft = '5px';
865
- learnMoreLink.style.textDecoration = 'underline';
866
- }
867
- function setupDom() {
868
- const banner = getOrCreateEl(bannerId);
869
- const firebaseTextId = prefixedId('text');
870
- const firebaseText = document.getElementById(firebaseTextId) || document.createElement('span');
871
- const learnMoreId = prefixedId('learnmore');
872
- const learnMoreLink = document.getElementById(learnMoreId) ||
873
- document.createElement('a');
874
- const prependIconId = prefixedId('preprendIcon');
875
- const prependIcon = document.getElementById(prependIconId) ||
876
- document.createElementNS('http://www.w3.org/2000/svg', 'svg');
877
- if (banner.created) {
878
- // update styles
879
- const bannerEl = banner.element;
880
- setupBannerStyles(bannerEl);
881
- setupLinkStyles(learnMoreLink, learnMoreId);
882
- const closeBtn = setupCloseBtn();
883
- setupIconStyles(prependIcon, prependIconId);
884
- bannerEl.append(prependIcon, firebaseText, learnMoreLink, closeBtn);
885
- document.body.appendChild(bannerEl);
886
- }
887
- if (showError) {
888
- firebaseText.innerText = `Preview backend disconnected.`;
889
- prependIcon.innerHTML = `<g clip-path="url(#clip0_6013_33858)">
890
- <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"/>
891
- </g>
892
- <defs>
893
- <clipPath id="clip0_6013_33858">
894
- <rect width="24" height="24" fill="white"/>
895
- </clipPath>
896
- </defs>`;
897
- }
898
- else {
899
- prependIcon.innerHTML = `<g clip-path="url(#clip0_6083_34804)">
900
- <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"/>
901
- </g>
902
- <defs>
903
- <clipPath id="clip0_6083_34804">
904
- <rect width="24" height="24" fill="white"/>
905
- </clipPath>
906
- </defs>`;
907
- firebaseText.innerText = 'Preview backend running in this workspace.';
908
- }
909
- firebaseText.setAttribute('id', firebaseTextId);
910
- }
911
- if (document.readyState === 'loading') {
912
- window.addEventListener('DOMContentLoaded', setupDom);
913
- }
914
- else {
915
- setupDom();
916
- }
917
- }
918
725
 
919
726
  /**
920
727
  * @license
@@ -2314,6 +2121,53 @@ function getModularInstance(service) {
2314
2121
  }
2315
2122
  }
2316
2123
 
2124
+ /**
2125
+ * @license
2126
+ * Copyright 2025 Google LLC
2127
+ *
2128
+ * Licensed under the Apache License, Version 2.0 (the "License");
2129
+ * you may not use this file except in compliance with the License.
2130
+ * You may obtain a copy of the License at
2131
+ *
2132
+ * http://www.apache.org/licenses/LICENSE-2.0
2133
+ *
2134
+ * Unless required by applicable law or agreed to in writing, software
2135
+ * distributed under the License is distributed on an "AS IS" BASIS,
2136
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2137
+ * See the License for the specific language governing permissions and
2138
+ * limitations under the License.
2139
+ */
2140
+ /**
2141
+ * Checks whether host is a cloud workstation or not.
2142
+ * @public
2143
+ */
2144
+ function isCloudWorkstation(url) {
2145
+ // `isCloudWorkstation` is called without protocol in certain connect*Emulator functions
2146
+ // In HTTP request builders, it's called with the protocol.
2147
+ // If called with protocol prefix, it's a valid URL, so we extract the hostname
2148
+ // If called without, we assume the string is the hostname.
2149
+ try {
2150
+ const host = url.startsWith('http://') || url.startsWith('https://')
2151
+ ? new URL(url).hostname
2152
+ : url;
2153
+ return host.endsWith('.cloudworkstations.dev');
2154
+ }
2155
+ catch {
2156
+ return false;
2157
+ }
2158
+ }
2159
+ /**
2160
+ * Makes a fetch request to the given server.
2161
+ * Mostly used for forwarding cookies in Firebase Studio.
2162
+ * @public
2163
+ */
2164
+ async function pingServer(endpoint) {
2165
+ const result = await fetch(endpoint, {
2166
+ credentials: 'include'
2167
+ });
2168
+ return result.ok;
2169
+ }
2170
+
2317
2171
  /**
2318
2172
  * @license
2319
2173
  * Copyright 2025 Google LLC
@@ -2366,5 +2220,5 @@ async function generateSHA256Hash(input) {
2366
2220
  // Overriding the constant (we should be the only ones doing this)
2367
2221
  CONSTANTS.NODE_CLIENT = true;
2368
2222
 
2369
- export { CONSTANTS, DecodeBase64StringError, 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, generateSHA256Hash, getDefaultAppConfig, getDefaultEmulatorHost, getDefaultEmulatorHostnameAndPort, getDefaults, getExperimentalSetting, getGlobal, getModularInstance, getUA, isAdmin, isBrowser, isBrowserExtension, isCloudWorkstation, isCloudflareWorker, isElectron, isEmpty, isIE, isIndexedDBAvailable, isMobileCordova, isNode, isNodeSdk, isReactNative, isSafari, isSafariOrWebkit, isUWP, isValidFormat, isValidTimestamp, isWebWorker, issuedAtTime, jsonEval, map, ordinal, pingServer, promiseWithTimeout, querystring, querystringDecode, safeGet, stringLength, stringToByteArray, stringify, updateEmulatorBanner, validateArgCount, validateCallback, validateContextObject, validateIndexedDBOpenable, validateNamespace };
2223
+ export { CONSTANTS, DecodeBase64StringError, 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, generateSHA256Hash, getDefaultAppConfig, getDefaultEmulatorHost, getDefaultEmulatorHostnameAndPort, getDefaults, getExperimentalSetting, getGlobal, getModularInstance, getUA, isAdmin, isBrowser, isBrowserExtension, isCloudWorkstation, isCloudflareWorker, isElectron, isEmpty, isIE, isIndexedDBAvailable, isMobileCordova, isNode, isNodeSdk, isReactNative, isSafari, isSafariOrWebkit, isUWP, isValidFormat, isValidTimestamp, isWebWorker, issuedAtTime, jsonEval, map, ordinal, pingServer, promiseWithTimeout, querystring, querystringDecode, safeGet, stringLength, stringToByteArray, stringify, validateArgCount, validateCallback, validateContextObject, validateIndexedDBOpenable, validateNamespace };
2370
2224
  //# sourceMappingURL=index.node.esm.js.map