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