@unhingged/vizu-core 0.1.3 → 0.1.4

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/auto.cjs CHANGED
@@ -3169,6 +3169,23 @@ var Vizu = class {
3169
3169
  getUser() {
3170
3170
  return this.user;
3171
3171
  }
3172
+ /**
3173
+ * Cloud-mode write gate. Every entry point that creates or modifies a
3174
+ * comment first checks that we have a known user. Without one, the
3175
+ * write would land as Anonymous (or 401 on the backend) — neither is
3176
+ * the right UX. So we re-trigger the sign-in popup and refuse the
3177
+ * action. The user signs in, this.user gets set via onAuthChanged,
3178
+ * then they can retry the click themselves.
3179
+ *
3180
+ * Returns true when the caller may proceed.
3181
+ */
3182
+ requireUserOrAuth() {
3183
+ if (!(this.storage instanceof CloudStorageAdapter)) return true;
3184
+ if (this.user) return true;
3185
+ void this.storage.preflightAuth().catch(() => {
3186
+ });
3187
+ return false;
3188
+ }
3172
3189
  /* ===== Lifecycle ===== */
3173
3190
  enable() {
3174
3191
  if (this.enabled) return;
@@ -3337,6 +3354,7 @@ var Vizu = class {
3337
3354
  * patch for adapters that don't implement reply ops.
3338
3355
  */
3339
3356
  async addReply(commentId, text, mentions) {
3357
+ if (!this.requireUserOrAuth()) return null;
3340
3358
  const idx = this.comments.findIndex((c) => c.id === commentId);
3341
3359
  if (idx === -1) return null;
3342
3360
  const reply = {
@@ -3403,6 +3421,7 @@ var Vizu = class {
3403
3421
  /* ===== Multi-select API ===== */
3404
3422
  /** Toggle multi-select mode. When on, plain clicks accumulate into the selection. */
3405
3423
  toggleMultiSelectMode() {
3424
+ if (!this.requireUserOrAuth()) return;
3406
3425
  this.multiSelectMode = !this.multiSelectMode;
3407
3426
  if (!this.multiSelectMode) this.clearSelection();
3408
3427
  this.pill?.setMultiSelectState(this.multiSelectMode, this.pendingFingerprints.length);
@@ -3564,6 +3583,7 @@ var Vizu = class {
3564
3583
  p.onSelect(fp2);
3565
3584
  return;
3566
3585
  }
3586
+ if (!this.requireUserOrAuth()) return;
3567
3587
  const fp = fingerprint(el);
3568
3588
  if (this.popover?.isOpen() && e.shiftKey) {
3569
3589
  this.popover.addAnchor(fp, el);
@@ -3611,6 +3631,7 @@ var Vizu = class {
3611
3631
  );
3612
3632
  }
3613
3633
  async addCommentFromPopover(text, fps, references, mentions, attachments) {
3634
+ if (!this.requireUserOrAuth()) return;
3614
3635
  if (fps.length === 0) return;
3615
3636
  const pageUrl = typeof location !== "undefined" ? location.href : void 0;
3616
3637
  const c = {