@unhingged/vizu-core 0.1.7 → 0.1.9
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 +25 -3
- package/dist/auto.cjs.map +1 -1
- package/dist/auto.js +25 -3
- package/dist/auto.js.map +1 -1
- package/dist/index.cjs +25 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +25 -3
- package/dist/index.js.map +1 -1
- package/dist/vizu.min.js +3 -3
- package/dist/vizu.min.js.map +1 -1
- package/package.json +1 -1
package/dist/auto.js
CHANGED
|
@@ -380,7 +380,9 @@ var CloudStorageAdapter = class {
|
|
|
380
380
|
const payload = params.get("vizu_auth");
|
|
381
381
|
if (!payload) return null;
|
|
382
382
|
try {
|
|
383
|
-
const
|
|
383
|
+
const bytes = Uint8Array.from(atob(payload), (c) => c.charCodeAt(0));
|
|
384
|
+
const decoded = new TextDecoder("utf-8").decode(bytes);
|
|
385
|
+
const json = JSON.parse(decoded);
|
|
384
386
|
if (!json.t || !json.e || !json.u || !json.w) return null;
|
|
385
387
|
if (json.w !== this.workspace) return null;
|
|
386
388
|
const stored = {
|
|
@@ -434,6 +436,11 @@ var CloudStorageAdapter = class {
|
|
|
434
436
|
}
|
|
435
437
|
/* ─── StorageAdapter v2 ───────────────────────────────────────────── */
|
|
436
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
|
+
}
|
|
437
444
|
const out = [];
|
|
438
445
|
let cursor = null;
|
|
439
446
|
do {
|
|
@@ -3151,6 +3158,14 @@ var Vizu = class {
|
|
|
3151
3158
|
this.selfHealedThisSession = /* @__PURE__ */ new Set();
|
|
3152
3159
|
this.actions = [];
|
|
3153
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;
|
|
3154
3169
|
this.enabled = false;
|
|
3155
3170
|
this.rafScheduled = false;
|
|
3156
3171
|
this.bus = new EventBus();
|
|
@@ -3219,21 +3234,28 @@ var Vizu = class {
|
|
|
3219
3234
|
this.opts.namespace = options.namespace ?? DEFAULTS.namespace;
|
|
3220
3235
|
this.opts.accent = options.accent ?? DEFAULTS.accent;
|
|
3221
3236
|
this.parsedShortcut = parseShortcut(this.opts.shortcut);
|
|
3237
|
+
this.user = options.user ?? null;
|
|
3222
3238
|
this.storage = resolveStorage(
|
|
3223
3239
|
options.storage,
|
|
3224
3240
|
options.cloud,
|
|
3225
3241
|
_defaultStorage,
|
|
3226
3242
|
(info) => {
|
|
3227
3243
|
if (info.user) this.setUser(info.user);
|
|
3244
|
+
if (this.hasLoadedComments) {
|
|
3245
|
+
void this.loadComments();
|
|
3246
|
+
}
|
|
3228
3247
|
}
|
|
3229
3248
|
);
|
|
3230
|
-
this.user = options.user ?? null;
|
|
3231
3249
|
if (options.actions) this.actions = [...options.actions];
|
|
3232
3250
|
if (options.onCommentAdded) this.bus.on("comment:added", (p) => options.onCommentAdded(p.comment));
|
|
3233
3251
|
if (options.onCommentRemoved) this.bus.on("comment:removed", (p) => options.onCommentRemoved(p.id));
|
|
3234
3252
|
if (typeof window !== "undefined") {
|
|
3235
3253
|
window.addEventListener("keydown", this.onKeyDown);
|
|
3236
|
-
void this.loadComments().
|
|
3254
|
+
void this.loadComments().catch(() => {
|
|
3255
|
+
}).finally(() => {
|
|
3256
|
+
this.hasLoadedComments = true;
|
|
3257
|
+
this.subscribeStorage();
|
|
3258
|
+
});
|
|
3237
3259
|
if (options.startEnabled) this.deferred(() => this.enable());
|
|
3238
3260
|
}
|
|
3239
3261
|
}
|