@carlonicora/nextjs-jsonapi 6.14.0 → 6.14.1
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/{BlockNoteEditor-QIVV2OB4.mjs → BlockNoteEditor-I3J6YYXK.mjs} +2 -2
- package/dist/{BlockNoteEditor-CUNH4LSQ.js → BlockNoteEditor-UIAX72XW.js} +9 -9
- package/dist/{BlockNoteEditor-CUNH4LSQ.js.map → BlockNoteEditor-UIAX72XW.js.map} +1 -1
- package/dist/billing/index.js +378 -378
- package/dist/billing/index.mjs +1 -1
- package/dist/{chunk-GSRTVIIK.js → chunk-RT7XFGIN.js} +222 -218
- package/dist/chunk-RT7XFGIN.js.map +1 -0
- package/dist/{chunk-YKNULEHB.mjs → chunk-RYY7USSW.mjs} +9 -5
- package/dist/chunk-RYY7USSW.mjs.map +1 -0
- package/dist/client/index.js +2 -2
- package/dist/client/index.mjs +1 -1
- package/dist/components/index.js +2 -2
- package/dist/components/index.mjs +1 -1
- package/dist/contexts/index.js +2 -2
- package/dist/contexts/index.mjs +1 -1
- package/dist/email-automations/index.js +58 -58
- package/dist/email-automations/index.mjs +1 -1
- package/dist/features/analytics/index.js +96 -96
- package/dist/features/analytics/index.mjs +1 -1
- package/dist/features/blog/index.js +93 -93
- package/dist/features/blog/index.mjs +1 -1
- package/dist/features/help/index.js +31 -31
- package/dist/features/help/index.mjs +1 -1
- package/dist/features/tokenusage/index.js +102 -102
- package/dist/features/tokenusage/index.mjs +1 -1
- package/package.json +1 -1
- package/src/hooks/__tests__/usePageTracker.spec.tsx +61 -0
- package/src/hooks/usePageTracker.ts +17 -7
- package/dist/chunk-GSRTVIIK.js.map +0 -1
- package/dist/chunk-YKNULEHB.mjs.map +0 -1
- /package/dist/{BlockNoteEditor-QIVV2OB4.mjs.map → BlockNoteEditor-I3J6YYXK.mjs.map} +0 -0
|
@@ -299,4 +299,65 @@ describe("usePageTracker", () => {
|
|
|
299
299
|
|
|
300
300
|
await waitFor(() => expect(pages(store)[0]?.title).toBe("Venezia Obscura"));
|
|
301
301
|
});
|
|
302
|
+
|
|
303
|
+
describe("most-specific-first titles (`Name · Type · Context | App`)", () => {
|
|
304
|
+
it("records the entity name on a hard load", async () => {
|
|
305
|
+
pathnameRef.current = "/npcs/npc-1";
|
|
306
|
+
document.title = "Charlie · NPC · Venezia Obscura | App";
|
|
307
|
+
const store = createStore();
|
|
308
|
+
store.set(recentPagesAtom, []);
|
|
309
|
+
|
|
310
|
+
mount(store);
|
|
311
|
+
|
|
312
|
+
await waitFor(() => expect(pages(store)).toHaveLength(1));
|
|
313
|
+
expect(pages(store)[0]).toMatchObject({ url: "/npcs/npc-1", title: "Charlie", moduleType: "npcs" });
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
it("records a single-part title such as a campaign's", async () => {
|
|
317
|
+
pathnameRef.current = "/campaigns/camp-1";
|
|
318
|
+
document.title = "Venezia Obscura | App";
|
|
319
|
+
const store = createStore();
|
|
320
|
+
store.set(recentPagesAtom, []);
|
|
321
|
+
|
|
322
|
+
mount(store);
|
|
323
|
+
|
|
324
|
+
await waitFor(() => expect(pages(store)[0]?.title).toBe("Venezia Obscura"));
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
it("never stamps an entity with the previous page's name, then upgrades when the title lands", async () => {
|
|
328
|
+
pathnameRef.current = "/campaigns/camp-1";
|
|
329
|
+
document.title = "Venezia Obscura | App";
|
|
330
|
+
const store = createStore();
|
|
331
|
+
store.set(recentPagesAtom, []);
|
|
332
|
+
const view = mount(store);
|
|
333
|
+
await waitFor(() => expect(pages(store)[0]?.title).toBe("Venezia Obscura"));
|
|
334
|
+
|
|
335
|
+
pathnameRef.current = "/npcs/npc-1";
|
|
336
|
+
view.rerender(
|
|
337
|
+
<Provider store={store}>
|
|
338
|
+
<Harness />
|
|
339
|
+
</Provider>,
|
|
340
|
+
);
|
|
341
|
+
|
|
342
|
+
await waitFor(() => expect(pages(store)[0]?.url).toBe("/npcs/npc-1"));
|
|
343
|
+
expect(pages(store)[0].title).toBe("npcs");
|
|
344
|
+
|
|
345
|
+
document.title = "Charlie · NPC · Venezia Obscura | App";
|
|
346
|
+
|
|
347
|
+
await waitFor(() => expect(pages(store)[0]?.title).toBe("Charlie"));
|
|
348
|
+
expect(pages(store).find((page) => page.url === "/campaigns/camp-1")?.title).toBe("Venezia Obscura");
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
it("keeps the module name when the title is only the app name", async () => {
|
|
352
|
+
pathnameRef.current = "/npcs/npc-1";
|
|
353
|
+
document.title = "App";
|
|
354
|
+
const store = createStore();
|
|
355
|
+
store.set(recentPagesAtom, []);
|
|
356
|
+
|
|
357
|
+
mount(store);
|
|
358
|
+
|
|
359
|
+
await waitFor(() => expect(pages(store)).toHaveLength(1));
|
|
360
|
+
expect(pages(store)[0].title).toBe("npcs");
|
|
361
|
+
});
|
|
362
|
+
});
|
|
302
363
|
});
|
|
@@ -10,18 +10,28 @@ import { getTrackablePages } from "../client/config";
|
|
|
10
10
|
const EXCLUDED_ROUTES = ["/", "/login", "/register", "/forgot-password", "/reset-password", "/activate"];
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
* Detail pages title themselves
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
13
|
+
* Detail pages title themselves in one of two shapes:
|
|
14
|
+
*
|
|
15
|
+
* `[Entity type] Entity name | App name` (bracketed)
|
|
16
|
+
* `Entity name · Entity type · Context | App name` (most-specific-first)
|
|
17
|
+
*
|
|
18
|
+
* Returns the entity name, or null when the document title carries no page
|
|
19
|
+
* name — just the bare app name. Whether the title belongs to THIS route (and
|
|
20
|
+
* not the page we left) is decided by the caller, not here.
|
|
17
21
|
*/
|
|
18
22
|
function readEntityTitle(): string | null {
|
|
19
23
|
if (typeof document === "undefined") return null;
|
|
20
24
|
|
|
21
|
-
const
|
|
22
|
-
if (!afterEntityType) return null;
|
|
25
|
+
const title = document.title;
|
|
23
26
|
|
|
24
|
-
|
|
27
|
+
if (title.includes("]")) {
|
|
28
|
+
const afterEntityType = title.split("]")[1];
|
|
29
|
+
return afterEntityType?.split("|")[0]?.trim() || null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (!title.includes("|")) return null;
|
|
33
|
+
|
|
34
|
+
return title.split("|")[0].split("·")[0]?.trim() || null;
|
|
25
35
|
}
|
|
26
36
|
|
|
27
37
|
export function usePageTracker() {
|