@unhingged/vizu-core 0.1.21 → 0.1.23

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 CHANGED
@@ -3724,14 +3724,7 @@ var Vizu = class {
3724
3724
  e.preventDefault();
3725
3725
  const wasEnabled = this.enabled;
3726
3726
  this.toggle();
3727
- if (!wasEnabled && this.enabled && this.storage instanceof CloudStorageAdapter) {
3728
- void this.storage.preflightAuth().catch((err) => {
3729
- if (err?.code === "auth_canceled" || err?.code === "popup_blocked") return;
3730
- if (typeof console !== "undefined") {
3731
- console.warn("[vizu] preflight auth failed:", err);
3732
- }
3733
- });
3734
- }
3727
+ if (!wasEnabled && this.enabled) this.requestAuth();
3735
3728
  }
3736
3729
  };
3737
3730
  /* ===== Reposition on scroll/resize ===== */
@@ -3885,6 +3878,25 @@ var Vizu = class {
3885
3878
  isEnabled() {
3886
3879
  return this.enabled;
3887
3880
  }
3881
+ /**
3882
+ * Kick the cloud sign-in flow. Call this alongside `enable()` from an
3883
+ * explicit user gesture — a host-rendered launcher button, a menu item —
3884
+ * so cloud-mode users get the sign-in popup immediately instead of only
3885
+ * after clicking an element. The keyboard shortcut goes through this
3886
+ * same path. No-op outside cloud mode, when already signed in, or when
3887
+ * the workspace has already denied access this session.
3888
+ */
3889
+ requestAuth() {
3890
+ if (!(this.storage instanceof CloudStorageAdapter)) return;
3891
+ if (this.user) return;
3892
+ if (this.storage.isAccessDenied()) return;
3893
+ void this.storage.preflightAuth().catch((err) => {
3894
+ if (err?.code === "auth_canceled" || err?.code === "popup_blocked") return;
3895
+ if (typeof console !== "undefined") {
3896
+ console.warn("[vizu] preflight auth failed:", err);
3897
+ }
3898
+ });
3899
+ }
3888
3900
  destroy() {
3889
3901
  this.disable();
3890
3902
  if (typeof window !== "undefined") window.removeEventListener("keydown", this.onKeyDown);