@unhingged/vizu-core 0.1.8 → 0.1.10
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 +36 -2
- package/dist/auto.cjs.map +1 -1
- package/dist/auto.js +36 -2
- package/dist/auto.js.map +1 -1
- package/dist/index.cjs +36 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +15 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +36 -2
- package/dist/index.js.map +1 -1
- package/dist/vizu.min.js +12 -12
- package/dist/vizu.min.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -472,6 +472,11 @@ var CloudStorageAdapter = class {
|
|
|
472
472
|
}
|
|
473
473
|
/* ─── StorageAdapter v2 ───────────────────────────────────────────── */
|
|
474
474
|
async load(_namespace) {
|
|
475
|
+
if (!this.cachedToken || this.isExpired(this.cachedToken)) {
|
|
476
|
+
const fresh = this.readStoredToken();
|
|
477
|
+
if (!fresh || this.isExpired(fresh)) return [];
|
|
478
|
+
this.cachedToken = fresh;
|
|
479
|
+
}
|
|
475
480
|
const out = [];
|
|
476
481
|
let cursor = null;
|
|
477
482
|
do {
|
|
@@ -3189,6 +3194,14 @@ var Vizu = class {
|
|
|
3189
3194
|
this.selfHealedThisSession = /* @__PURE__ */ new Set();
|
|
3190
3195
|
this.actions = [];
|
|
3191
3196
|
this.user = null;
|
|
3197
|
+
/**
|
|
3198
|
+
* Flipped true once the initial loadComments() at construction has
|
|
3199
|
+
* settled (success or failure). The cloud onAuthChanged callback uses
|
|
3200
|
+
* this to decide whether a subsequent auth change should trigger a
|
|
3201
|
+
* re-load: skipped for the initial fire (the explicit loadComments
|
|
3202
|
+
* below handles it), fired for every later token acquisition.
|
|
3203
|
+
*/
|
|
3204
|
+
this.hasLoadedComments = false;
|
|
3192
3205
|
this.enabled = false;
|
|
3193
3206
|
this.rafScheduled = false;
|
|
3194
3207
|
this.bus = new EventBus();
|
|
@@ -3264,6 +3277,9 @@ var Vizu = class {
|
|
|
3264
3277
|
_defaultStorage,
|
|
3265
3278
|
(info) => {
|
|
3266
3279
|
if (info.user) this.setUser(info.user);
|
|
3280
|
+
if (this.hasLoadedComments) {
|
|
3281
|
+
void this.loadComments();
|
|
3282
|
+
}
|
|
3267
3283
|
}
|
|
3268
3284
|
);
|
|
3269
3285
|
if (options.actions) this.actions = [...options.actions];
|
|
@@ -3271,7 +3287,11 @@ var Vizu = class {
|
|
|
3271
3287
|
if (options.onCommentRemoved) this.bus.on("comment:removed", (p) => options.onCommentRemoved(p.id));
|
|
3272
3288
|
if (typeof window !== "undefined") {
|
|
3273
3289
|
window.addEventListener("keydown", this.onKeyDown);
|
|
3274
|
-
void this.loadComments().
|
|
3290
|
+
void this.loadComments().catch(() => {
|
|
3291
|
+
}).finally(() => {
|
|
3292
|
+
this.hasLoadedComments = true;
|
|
3293
|
+
this.subscribeStorage();
|
|
3294
|
+
});
|
|
3275
3295
|
if (options.startEnabled) this.deferred(() => this.enable());
|
|
3276
3296
|
}
|
|
3277
3297
|
}
|
|
@@ -3287,11 +3307,25 @@ var Vizu = class {
|
|
|
3287
3307
|
this.user = user;
|
|
3288
3308
|
this.popover?.setUser(user);
|
|
3289
3309
|
this.pill?.setUser(user);
|
|
3310
|
+
if (this.pill) {
|
|
3311
|
+
if (this.shouldShowPill()) this.pill.show();
|
|
3312
|
+
else this.pill.hide();
|
|
3313
|
+
}
|
|
3290
3314
|
this.bus.emit("user:changed", { user });
|
|
3291
3315
|
}
|
|
3292
3316
|
getUser() {
|
|
3293
3317
|
return this.user;
|
|
3294
3318
|
}
|
|
3319
|
+
/**
|
|
3320
|
+
* Whether the pill belongs on-screen right now. Cloud-mode workspaces
|
|
3321
|
+
* keep it hidden until the user is signed in; non-cloud usage (local /
|
|
3322
|
+
* memory storage) has no auth and always shows it. Recomputed on every
|
|
3323
|
+
* setUser and on mount.
|
|
3324
|
+
*/
|
|
3325
|
+
shouldShowPill() {
|
|
3326
|
+
if (!(this.storage instanceof CloudStorageAdapter)) return true;
|
|
3327
|
+
return this.user !== null;
|
|
3328
|
+
}
|
|
3295
3329
|
/**
|
|
3296
3330
|
* Cloud-mode write gate. Every entry point that creates or modifies a
|
|
3297
3331
|
* comment first checks that we have a known user. Without one, the
|
|
@@ -3655,7 +3689,7 @@ var Vizu = class {
|
|
|
3655
3689
|
this.pill.setUser(this.user);
|
|
3656
3690
|
this.pill.setComments(this.comments);
|
|
3657
3691
|
this.pill.setMultiSelectState(this.multiSelectMode, this.pendingFingerprints.length);
|
|
3658
|
-
this.pill.show();
|
|
3692
|
+
if (this.shouldShowPill()) this.pill.show();
|
|
3659
3693
|
this.highlighter = new Highlighter(
|
|
3660
3694
|
this.root,
|
|
3661
3695
|
this.opts.ignoreSelectors ?? [],
|