@unhingged/vizu-core 0.1.1 → 0.1.2
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 +268 -176
- package/dist/auto.cjs.map +1 -1
- package/dist/auto.js +32 -7
- package/dist/auto.js.map +1 -1
- package/dist/index.cjs +268 -176
- 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 +32 -7
- package/dist/index.js.map +1 -1
- package/dist/{live-collab-IRUNFAPE.js → live-collab-BVLNJ5QI.js} +237 -172
- package/dist/live-collab-BVLNJ5QI.js.map +1 -0
- package/dist/vizu.min.js +107 -109
- package/dist/vizu.min.js.map +1 -1
- package/package.json +24 -27
- package/dist/live-collab-IRUNFAPE.js.map +0 -1
package/dist/auto.js
CHANGED
|
@@ -365,6 +365,18 @@ var CloudStorageAdapter = class {
|
|
|
365
365
|
async preflightAuth() {
|
|
366
366
|
await this.resolveToken();
|
|
367
367
|
}
|
|
368
|
+
/**
|
|
369
|
+
* Synchronous accessor for the currently cached bearer token, used
|
|
370
|
+
* by sibling modules that need to authenticate against the same
|
|
371
|
+
* backend (live-collab cross-origin polling). Returns null when no
|
|
372
|
+
* valid token is cached — callers fall back to credentials:'include'
|
|
373
|
+
* for same-origin or just disable themselves.
|
|
374
|
+
*/
|
|
375
|
+
getCachedAuthToken() {
|
|
376
|
+
if (!this.cachedToken) return null;
|
|
377
|
+
if (this.isExpired(this.cachedToken)) return null;
|
|
378
|
+
return this.cachedToken.token;
|
|
379
|
+
}
|
|
368
380
|
/* ─── StorageAdapter v2 ───────────────────────────────────────────── */
|
|
369
381
|
async load(_namespace) {
|
|
370
382
|
const out = [];
|
|
@@ -537,7 +549,7 @@ var CloudStorageAdapter = class {
|
|
|
537
549
|
}
|
|
538
550
|
}
|
|
539
551
|
sessionKey() {
|
|
540
|
-
return `vizu:cloud-token:${this.workspace}`;
|
|
552
|
+
return `vizu:cloud-token:v2:${this.workspace}`;
|
|
541
553
|
}
|
|
542
554
|
/**
|
|
543
555
|
* Resolve a valid token, opening the popup if needed.
|
|
@@ -2845,14 +2857,27 @@ var Vizu = class {
|
|
|
2845
2857
|
if (options.actions) this.actions = [...options.actions];
|
|
2846
2858
|
if (options.onCommentAdded) this.bus.on("comment:added", (p) => options.onCommentAdded(p.comment));
|
|
2847
2859
|
if (options.onCommentRemoved) this.bus.on("comment:removed", (p) => options.onCommentRemoved(p.id));
|
|
2848
|
-
if (options.
|
|
2849
|
-
const live = options.liveblocks;
|
|
2860
|
+
if (options.cloud) {
|
|
2850
2861
|
const cloud = options.cloud;
|
|
2851
|
-
|
|
2862
|
+
const apiUrl = (cloud.apiUrl ?? "https://vizu.unhingged.com").replace(/\/$/, "");
|
|
2863
|
+
void import("./live-collab-BVLNJ5QI.js").then(({ LiveCollab }) => {
|
|
2852
2864
|
this.liveCollab = new LiveCollab({
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2865
|
+
workspaceSlug: cloud.workspace,
|
|
2866
|
+
apiUrl,
|
|
2867
|
+
getAuthHeader: async () => {
|
|
2868
|
+
if (typeof window === "undefined") return null;
|
|
2869
|
+
try {
|
|
2870
|
+
if (new URL(apiUrl).origin === window.location.origin) return null;
|
|
2871
|
+
} catch {
|
|
2872
|
+
return null;
|
|
2873
|
+
}
|
|
2874
|
+
const adapter = this.storage;
|
|
2875
|
+
if (adapter instanceof CloudStorageAdapter) {
|
|
2876
|
+
const token = adapter.getCachedAuthToken();
|
|
2877
|
+
if (token) return { Authorization: `Bearer ${token}` };
|
|
2878
|
+
}
|
|
2879
|
+
return null;
|
|
2880
|
+
}
|
|
2856
2881
|
});
|
|
2857
2882
|
void this.liveCollab.start();
|
|
2858
2883
|
});
|