@timpel/forumkit-sdk-web 0.2.6 → 0.2.8
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/{chunk-46QQNTQZ.js → chunk-G3BQUVWC.js} +30 -12
- package/dist/chunk-G3BQUVWC.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +1 -1
- package/dist/wrappers/react.d.ts +1 -1
- package/dist/wrappers/react.js +4 -3
- package/dist/wrappers/react.js.map +1 -1
- package/dist/wrappers/vue.d.ts +9 -0
- package/dist/wrappers/vue.js +3 -1
- package/dist/wrappers/vue.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-46QQNTQZ.js.map +0 -1
|
@@ -392,11 +392,12 @@ function SessionProvider({ config, children }) {
|
|
|
392
392
|
if (cancelled) return;
|
|
393
393
|
expiresAtRef.current = Date.now() + expiresIn * 1e3;
|
|
394
394
|
refreshTimer = setTimeout(() => {
|
|
395
|
-
void refresh();
|
|
395
|
+
void refresh(true);
|
|
396
396
|
}, expiresIn * 1e3 * 0.8);
|
|
397
397
|
}
|
|
398
|
-
function refresh() {
|
|
399
|
-
|
|
398
|
+
function refresh(isRenewal = false) {
|
|
399
|
+
const tokenPromise = isRenewal && config.getToken ? config.getToken() : Promise.resolve(config.token);
|
|
400
|
+
return tokenPromise.then((hostToken) => createSession2(apiUrl, hostToken)).then((result) => {
|
|
400
401
|
if (cancelled) return;
|
|
401
402
|
setState({ status: "ready", forumId: config.forumId, apiUrl, sessionToken: result.sessionToken, error: null, onLogout: config.onLogout, platform });
|
|
402
403
|
scheduleRefresh(result.expiresIn);
|
|
@@ -405,7 +406,7 @@ function SessionProvider({ config, children }) {
|
|
|
405
406
|
const message = err instanceof Error ? err.message : "Failed to create session";
|
|
406
407
|
setState({ status: "error", forumId: config.forumId, apiUrl, sessionToken: null, error: message, onLogout: config.onLogout, platform });
|
|
407
408
|
retryTimer = setTimeout(() => {
|
|
408
|
-
void refresh();
|
|
409
|
+
void refresh(true);
|
|
409
410
|
}, RETRY_DELAY_MS);
|
|
410
411
|
});
|
|
411
412
|
}
|
|
@@ -413,7 +414,7 @@ function SessionProvider({ config, children }) {
|
|
|
413
414
|
if (document.visibilityState !== "visible") return;
|
|
414
415
|
const msRemaining = expiresAtRef.current - Date.now();
|
|
415
416
|
if (msRemaining <= 0) {
|
|
416
|
-
void refresh();
|
|
417
|
+
void refresh(true);
|
|
417
418
|
} else {
|
|
418
419
|
if (refreshTimer) clearTimeout(refreshTimer);
|
|
419
420
|
scheduleRefresh(msRemaining / 1e3);
|
|
@@ -5389,13 +5390,12 @@ function ProfileTabs({ active, onSelect, showSaved = true }) {
|
|
|
5389
5390
|
|
|
5390
5391
|
// src/views/components/profile/profile-empty-state.tsx
|
|
5391
5392
|
import { jsx as jsx34, jsxs as jsxs28 } from "react/jsx-runtime";
|
|
5392
|
-
function ProfileEmptyState({ tab
|
|
5393
|
+
function ProfileEmptyState({ tab }) {
|
|
5393
5394
|
const copy = profileEmptyCopy(tab);
|
|
5394
5395
|
return /* @__PURE__ */ jsxs28("div", { className: "fk-profile-empty", children: [
|
|
5395
5396
|
/* @__PURE__ */ jsx34("div", { className: "fk-profile-empty-mascot", children: /* @__PURE__ */ jsx34(MascotIcon, { size: 120, variant: "empty" }) }),
|
|
5396
5397
|
/* @__PURE__ */ jsx34("h2", { className: "fk-profile-empty-title", children: copy.title }),
|
|
5397
|
-
/* @__PURE__ */ jsx34("p", { className: "fk-profile-empty-desc", children: copy.description })
|
|
5398
|
-
/* @__PURE__ */ jsx34(PillButton, { variant: "ghost", onClick: onUpdateSettings, style: { background: "var(--text)", color: "var(--bg)" }, children: "Update Settings" })
|
|
5398
|
+
/* @__PURE__ */ jsx34("p", { className: "fk-profile-empty-desc", children: copy.description })
|
|
5399
5399
|
] });
|
|
5400
5400
|
}
|
|
5401
5401
|
|
|
@@ -5558,7 +5558,6 @@ function Profile() {
|
|
|
5558
5558
|
loadMoreViewedProfileActivity,
|
|
5559
5559
|
openComposer,
|
|
5560
5560
|
openThread,
|
|
5561
|
-
openSettings,
|
|
5562
5561
|
votePost,
|
|
5563
5562
|
toggleSavePost,
|
|
5564
5563
|
setPostMenu,
|
|
@@ -5657,7 +5656,7 @@ function Profile() {
|
|
|
5657
5656
|
] })
|
|
5658
5657
|
] }),
|
|
5659
5658
|
/* @__PURE__ */ jsx37("div", { className: "fk-profile-divider" }),
|
|
5660
|
-
profile.activityItems.length === 0 && !profile.activityLoading ? /* @__PURE__ */ jsx37(ProfileEmptyState, { tab: profile.activeTab
|
|
5659
|
+
profile.activityItems.length === 0 && !profile.activityLoading ? /* @__PURE__ */ jsx37(ProfileEmptyState, { tab: profile.activeTab }) : /* @__PURE__ */ jsxs31(Fragment14, { children: [
|
|
5661
5660
|
profile.activityItems.map((item) => item.kind === "thread" ? /* @__PURE__ */ jsx37(
|
|
5662
5661
|
PostCard,
|
|
5663
5662
|
{
|
|
@@ -13375,6 +13374,24 @@ var ForumKitElement = class extends HTMLElement {
|
|
|
13375
13374
|
this._render();
|
|
13376
13375
|
}
|
|
13377
13376
|
}
|
|
13377
|
+
// Same reasoning as onLogout above - getToken is a function, so it's a JS
|
|
13378
|
+
// property (el.getToken = fn) rather than an observed attribute. Called by
|
|
13379
|
+
// SessionProvider to fetch a fresh host JWT on every renewal past the
|
|
13380
|
+
// first exchange, since a properly short-lived host token (the security
|
|
13381
|
+
// property it's meant to have) will already be expired by the time a
|
|
13382
|
+
// renewal is due - without this, the SDK has no way to get a new one and
|
|
13383
|
+
// renewal just fails once the original token expires.
|
|
13384
|
+
_getToken;
|
|
13385
|
+
get getToken() {
|
|
13386
|
+
return this._getToken;
|
|
13387
|
+
}
|
|
13388
|
+
set getToken(fn) {
|
|
13389
|
+
this._getToken = fn;
|
|
13390
|
+
if (this._config) {
|
|
13391
|
+
this._config = this._readConfig();
|
|
13392
|
+
this._render();
|
|
13393
|
+
}
|
|
13394
|
+
}
|
|
13378
13395
|
static get observedAttributes() {
|
|
13379
13396
|
return ["forum-id", "token", "theme", "api-url", "platform"];
|
|
13380
13397
|
}
|
|
@@ -13424,7 +13441,8 @@ var ForumKitElement = class extends HTMLElement {
|
|
|
13424
13441
|
theme,
|
|
13425
13442
|
apiUrl,
|
|
13426
13443
|
platform,
|
|
13427
|
-
...this._onLogout ? { onLogout: this._onLogout } : {}
|
|
13444
|
+
...this._onLogout ? { onLogout: this._onLogout } : {},
|
|
13445
|
+
...this._getToken ? { getToken: this._getToken } : {}
|
|
13428
13446
|
};
|
|
13429
13447
|
}
|
|
13430
13448
|
/**
|
|
@@ -13477,4 +13495,4 @@ if (!customElements.get("forum-kit")) {
|
|
|
13477
13495
|
export {
|
|
13478
13496
|
ForumKitElement
|
|
13479
13497
|
};
|
|
13480
|
-
//# sourceMappingURL=chunk-
|
|
13498
|
+
//# sourceMappingURL=chunk-G3BQUVWC.js.map
|