@firebase/util 1.11.0-firebase-studio-sdk-integration.dbac496fa → 1.11.0-firebase-studio-sdk-integration.12759bc2e

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
@@ -694,16 +694,37 @@ class Deferred {
694
694
  function isCloudWorkstation(host) {
695
695
  return host.endsWith('.cloudworkstations.dev');
696
696
  }
697
+ const pingQueue = {};
698
+ const MAX_PING_RETRIES = 10;
697
699
  /**
698
700
  * Makes a fetch request to the given server.
699
701
  * Mostly used for forwarding cookies in Firebase Studio.
700
702
  * @public
701
703
  */
702
704
  async function pingServer(endpoint) {
703
- const result = await fetch(endpoint, {
704
- credentials: 'include'
705
- });
706
- return result.ok;
705
+ if (pingQueue[endpoint]) {
706
+ return Promise.resolve(false);
707
+ }
708
+ pingQueue[endpoint] = true;
709
+ function waitFor(ms) {
710
+ return new Promise((resolve, reject) => {
711
+ setTimeout(resolve);
712
+ });
713
+ }
714
+ for (let i = 0; i < MAX_PING_RETRIES; i++) {
715
+ try {
716
+ await waitFor(i * 1000);
717
+ const result = await fetch(endpoint, {
718
+ credentials: 'include'
719
+ });
720
+ if (result.ok) {
721
+ return result.ok;
722
+ }
723
+ }
724
+ catch (_a) { }
725
+ }
726
+ delete pingQueue[endpoint];
727
+ return false;
707
728
  }
708
729
 
709
730
  /**
@@ -815,7 +836,7 @@ function updateEmulatorBanner(name, isRunningEmulator) {
815
836
  bannerEl.style.left = '5px';
816
837
  bannerEl.style.padding = '.5em';
817
838
  bannerEl.style.borderRadius = '5px';
818
- bannerEl.style.alignContent = 'center';
839
+ bannerEl.style.alignItems = 'center';
819
840
  }
820
841
  function setupIconStyles(prependIcon, iconId) {
821
842
  prependIcon.setAttribute('width', '24');
@@ -828,8 +849,8 @@ function updateEmulatorBanner(name, isRunningEmulator) {
828
849
  function setupCloseBtn() {
829
850
  const closeBtn = document.createElement('span');
830
851
  closeBtn.style.cursor = 'pointer';
831
- closeBtn.style.paddingLeft = '5px';
832
- closeBtn.style.width = '10px';
852
+ closeBtn.style.marginLeft = '16px';
853
+ closeBtn.style.fontSize = '24px';
833
854
  closeBtn.innerHTML = ' &times;';
834
855
  closeBtn.onclick = () => {
835
856
  previouslyDismissed = true;
@@ -837,23 +858,14 @@ function updateEmulatorBanner(name, isRunningEmulator) {
837
858
  };
838
859
  return closeBtn;
839
860
  }
840
- function setupLinkStyles(learnMoreLink, learnMoreId, svgElement) {
861
+ function setupLinkStyles(learnMoreLink, learnMoreId) {
841
862
  learnMoreLink.setAttribute('id', learnMoreId);
842
863
  learnMoreLink.innerText = 'Learn more';
843
864
  learnMoreLink.href =
844
- 'http://firebase.google.com/docs/studio/deploy-app#emulator ';
865
+ 'https://firebase.google.com/docs/studio/preview-apps#preview-backend';
845
866
  learnMoreLink.setAttribute('target', '__blank');
846
867
  learnMoreLink.style.paddingLeft = '5px';
847
868
  learnMoreLink.style.textDecoration = 'underline';
848
- learnMoreLink.appendChild(svgElement);
849
- }
850
- function setupOpenExternal(svgElement, id) {
851
- svgElement.setAttribute('viewBox', '0 0 16 16');
852
- svgElement.setAttribute('fill', 'none');
853
- svgElement.setAttribute('id', id);
854
- svgElement.style.width = '16px';
855
- svgElement.style.marginLeft = '4px';
856
- svgElement.innerHTML = `<path fill-rule="evenodd" clip-rule="evenodd" d="M12.6667 12.6667H3.33333V3.33333H8V2H3.33333C2.59333 2 2 2.6 2 3.33333V12.6667C2 13.4 2.59333 14 3.33333 14H12.6667C13.4 14 14 13.4 14 12.6667V8H12.6667V12.6667ZM9.33333 2V3.33333H11.7267L5.17333 9.88667L6.11333 10.8267L12.6667 4.27333V6.66667H14V2H9.33333Z" fill="#212121"/>`;
857
869
  }
858
870
  function setupDom() {
859
871
  const banner = getOrCreateEl(bannerId);
@@ -865,22 +877,18 @@ function updateEmulatorBanner(name, isRunningEmulator) {
865
877
  const prependIconId = prefixedId('preprendIcon');
866
878
  const prependIcon = document.getElementById(prependIconId) ||
867
879
  document.createElementNS('http://www.w3.org/2000/svg', 'svg');
868
- const openExternalIconId = prefixedId('openexternal');
869
- const openExternalIcon = document.getElementById(openExternalIconId) ||
870
- document.createElementNS('http://www.w3.org/2000/svg', 'svg');
871
880
  if (banner.created) {
872
881
  // update styles
873
882
  const bannerEl = banner.element;
874
883
  setupBannerStyles(bannerEl);
875
- setupOpenExternal(openExternalIcon, openExternalIconId);
876
- setupLinkStyles(learnMoreLink, learnMoreId, openExternalIcon);
884
+ setupLinkStyles(learnMoreLink, learnMoreId);
877
885
  const closeBtn = setupCloseBtn();
878
886
  setupIconStyles(prependIcon, prependIconId);
879
- bannerEl.append(prependIcon, firebaseText, learnMoreLink, openExternalIcon, closeBtn);
887
+ bannerEl.append(prependIcon, firebaseText, learnMoreLink, closeBtn);
880
888
  document.body.appendChild(bannerEl);
881
889
  }
882
890
  if (showError) {
883
- firebaseText.innerText = `Not using emulated backend.`;
891
+ firebaseText.innerText = `Preview backend disconnected.`;
884
892
  prependIcon.innerHTML = `<g clip-path="url(#clip0_6013_33858)">
885
893
  <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"/>
886
894
  </g>
@@ -899,7 +907,7 @@ function updateEmulatorBanner(name, isRunningEmulator) {
899
907
  <rect width="24" height="24" fill="white"/>
900
908
  </clipPath>
901
909
  </defs>`;
902
- firebaseText.innerText = 'Using emulated backend';
910
+ firebaseText.innerText = 'Preview backend running in this workspace.';
903
911
  }
904
912
  firebaseText.setAttribute('id', firebaseTextId);
905
913
  }