@thatopen/services 0.34.4 → 0.34.5

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/cli.js CHANGED
@@ -8849,6 +8849,7 @@ class RequestError extends Error {
8849
8849
  }
8850
8850
  const FOLDER_PATH = "item/folder";
8851
8851
  const ITEM_PATH = "item";
8852
+ const LOADED_AT_THE_LATEST_MS = 12e3;
8852
8853
  const PROCESS_PATH = "processor";
8853
8854
  const NPM_REGISTRY_PATH = "npm-registry";
8854
8855
  const HIDDEN_PATH = "hidden";
@@ -9643,9 +9644,64 @@ return main;`);
9643
9644
  this.setBuiltInGlobals(globals);
9644
9645
  await this.initBuiltInComponents(components, ...builtIns);
9645
9646
  components.init();
9646
- this.context.appEventOrchestrator?.appLoaded?.();
9647
+ if (globalThis.__thatOpenShellSaysLoaded && !this.#shellRelease) {
9648
+ this.#shellRelease = this.holdAppLoaded();
9649
+ }
9650
+ this.#setupDone = true;
9651
+ this.#reportLoaded();
9652
+ if (!this.#loadedReported) {
9653
+ const since = typeof performance !== "undefined" ? performance.now() : Date.now() - this.#bornAt;
9654
+ setTimeout(() => {
9655
+ this.#loadedHolds = 0;
9656
+ this.#reportLoaded();
9657
+ }, Math.max(0, LOADED_AT_THE_LATEST_MS - since));
9658
+ }
9647
9659
  return { components };
9648
9660
  }
9661
+ /**
9662
+ * 🔴 ONE LOADING SCREEN (Jesús 4-11: opening an app showed three, one after
9663
+ * the other). The platform keeps its own until the app says it is loaded,
9664
+ * and `setup` said so as soon as the components were made: the app's own
9665
+ * screens (its configuration, its viewer) then showed behind. Whatever is
9666
+ * still getting the app ready holds the word back with this, and lets it go
9667
+ * once it is: the platform's screen, the only one, stays until then.
9668
+ *
9669
+ * Returns the release; each is let go once. Held or not, the word goes 12 s
9670
+ * after this client was made at the latest, before the platform's own
9671
+ * deadline (15 s) calls the app dead.
9672
+ */
9673
+ holdAppLoaded(maxMs = LOADED_AT_THE_LATEST_MS) {
9674
+ if (this.#loadedReported) return () => {
9675
+ };
9676
+ this.#loadedHolds++;
9677
+ let released = false;
9678
+ const release = () => {
9679
+ if (released) return;
9680
+ released = true;
9681
+ clearTimeout(timer);
9682
+ this.#loadedHolds--;
9683
+ this.#reportLoaded();
9684
+ };
9685
+ const timer = setTimeout(release, maxMs);
9686
+ return release;
9687
+ }
9688
+ /**
9689
+ * The app's shell saying it is ready to be looked at: the hold `setup` took
9690
+ * for it, let go. Nothing if it took none.
9691
+ */
9692
+ appReady() {
9693
+ this.#shellRelease?.();
9694
+ }
9695
+ #shellRelease;
9696
+ #bornAt = Date.now();
9697
+ #setupDone = false;
9698
+ #loadedHolds = 0;
9699
+ #loadedReported = false;
9700
+ #reportLoaded() {
9701
+ if (this.#loadedReported || !this.#setupDone || this.#loadedHolds > 0) return;
9702
+ this.#loadedReported = true;
9703
+ this.context.appEventOrchestrator?.appLoaded?.();
9704
+ }
9649
9705
  /**
9650
9706
  * Reports an error to the platform via the {@link AppEventOrchestrator.appError} callback.
9651
9707
  * @param code - Numeric error code.