@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/auto.js
CHANGED
|
@@ -436,6 +436,11 @@ var CloudStorageAdapter = class {
|
|
|
436
436
|
}
|
|
437
437
|
/* ─── StorageAdapter v2 ───────────────────────────────────────────── */
|
|
438
438
|
async load(_namespace) {
|
|
439
|
+
if (!this.cachedToken || this.isExpired(this.cachedToken)) {
|
|
440
|
+
const fresh = this.readStoredToken();
|
|
441
|
+
if (!fresh || this.isExpired(fresh)) return [];
|
|
442
|
+
this.cachedToken = fresh;
|
|
443
|
+
}
|
|
439
444
|
const out = [];
|
|
440
445
|
let cursor = null;
|
|
441
446
|
do {
|
|
@@ -3153,6 +3158,14 @@ var Vizu = class {
|
|
|
3153
3158
|
this.selfHealedThisSession = /* @__PURE__ */ new Set();
|
|
3154
3159
|
this.actions = [];
|
|
3155
3160
|
this.user = null;
|
|
3161
|
+
/**
|
|
3162
|
+
* Flipped true once the initial loadComments() at construction has
|
|
3163
|
+
* settled (success or failure). The cloud onAuthChanged callback uses
|
|
3164
|
+
* this to decide whether a subsequent auth change should trigger a
|
|
3165
|
+
* re-load: skipped for the initial fire (the explicit loadComments
|
|
3166
|
+
* below handles it), fired for every later token acquisition.
|
|
3167
|
+
*/
|
|
3168
|
+
this.hasLoadedComments = false;
|
|
3156
3169
|
this.enabled = false;
|
|
3157
3170
|
this.rafScheduled = false;
|
|
3158
3171
|
this.bus = new EventBus();
|
|
@@ -3228,6 +3241,9 @@ var Vizu = class {
|
|
|
3228
3241
|
_defaultStorage,
|
|
3229
3242
|
(info) => {
|
|
3230
3243
|
if (info.user) this.setUser(info.user);
|
|
3244
|
+
if (this.hasLoadedComments) {
|
|
3245
|
+
void this.loadComments();
|
|
3246
|
+
}
|
|
3231
3247
|
}
|
|
3232
3248
|
);
|
|
3233
3249
|
if (options.actions) this.actions = [...options.actions];
|
|
@@ -3235,7 +3251,11 @@ var Vizu = class {
|
|
|
3235
3251
|
if (options.onCommentRemoved) this.bus.on("comment:removed", (p) => options.onCommentRemoved(p.id));
|
|
3236
3252
|
if (typeof window !== "undefined") {
|
|
3237
3253
|
window.addEventListener("keydown", this.onKeyDown);
|
|
3238
|
-
void this.loadComments().
|
|
3254
|
+
void this.loadComments().catch(() => {
|
|
3255
|
+
}).finally(() => {
|
|
3256
|
+
this.hasLoadedComments = true;
|
|
3257
|
+
this.subscribeStorage();
|
|
3258
|
+
});
|
|
3239
3259
|
if (options.startEnabled) this.deferred(() => this.enable());
|
|
3240
3260
|
}
|
|
3241
3261
|
}
|
|
@@ -3251,11 +3271,25 @@ var Vizu = class {
|
|
|
3251
3271
|
this.user = user;
|
|
3252
3272
|
this.popover?.setUser(user);
|
|
3253
3273
|
this.pill?.setUser(user);
|
|
3274
|
+
if (this.pill) {
|
|
3275
|
+
if (this.shouldShowPill()) this.pill.show();
|
|
3276
|
+
else this.pill.hide();
|
|
3277
|
+
}
|
|
3254
3278
|
this.bus.emit("user:changed", { user });
|
|
3255
3279
|
}
|
|
3256
3280
|
getUser() {
|
|
3257
3281
|
return this.user;
|
|
3258
3282
|
}
|
|
3283
|
+
/**
|
|
3284
|
+
* Whether the pill belongs on-screen right now. Cloud-mode workspaces
|
|
3285
|
+
* keep it hidden until the user is signed in; non-cloud usage (local /
|
|
3286
|
+
* memory storage) has no auth and always shows it. Recomputed on every
|
|
3287
|
+
* setUser and on mount.
|
|
3288
|
+
*/
|
|
3289
|
+
shouldShowPill() {
|
|
3290
|
+
if (!(this.storage instanceof CloudStorageAdapter)) return true;
|
|
3291
|
+
return this.user !== null;
|
|
3292
|
+
}
|
|
3259
3293
|
/**
|
|
3260
3294
|
* Cloud-mode write gate. Every entry point that creates or modifies a
|
|
3261
3295
|
* comment first checks that we have a known user. Without one, the
|
|
@@ -3619,7 +3653,7 @@ var Vizu = class {
|
|
|
3619
3653
|
this.pill.setUser(this.user);
|
|
3620
3654
|
this.pill.setComments(this.comments);
|
|
3621
3655
|
this.pill.setMultiSelectState(this.multiSelectMode, this.pendingFingerprints.length);
|
|
3622
|
-
this.pill.show();
|
|
3656
|
+
if (this.shouldShowPill()) this.pill.show();
|
|
3623
3657
|
this.highlighter = new Highlighter(
|
|
3624
3658
|
this.root,
|
|
3625
3659
|
this.opts.ignoreSelectors ?? [],
|