@eifi1/ui-kit 0.42.0 → 0.43.0

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.
Files changed (130) hide show
  1. package/README.md +12 -6
  2. package/dist/admin/admin-area-labels.d.ts +4 -0
  3. package/dist/admin/admin-area-labels.js +3 -1
  4. package/dist/admin/admin-area-labels.js.map +1 -1
  5. package/dist/admin/admin-overview.d.ts +25 -8
  6. package/dist/admin/admin-overview.js +26 -3
  7. package/dist/admin/admin-overview.js.map +1 -1
  8. package/dist/admin/admin-sections.d.ts +36 -5
  9. package/dist/admin/admin-sections.js +35 -18
  10. package/dist/admin/admin-sections.js.map +1 -1
  11. package/dist/billing/billing-banner.d.ts +8 -0
  12. package/dist/billing/billing-banner.js +25 -2
  13. package/dist/billing/billing-banner.js.map +1 -1
  14. package/dist/billing/billing-labels.d.ts +4 -0
  15. package/dist/billing/billing-labels.js +1 -0
  16. package/dist/billing/billing-labels.js.map +1 -1
  17. package/dist/billing/cancel-request.d.ts +53 -0
  18. package/dist/billing/cancel-request.js +21 -0
  19. package/dist/billing/cancel-request.js.map +1 -0
  20. package/dist/billing/provider-page.d.ts +40 -0
  21. package/dist/billing/provider-page.js +33 -0
  22. package/dist/billing/provider-page.js.map +1 -0
  23. package/dist/billing/subscription-actions.d.ts +32 -1
  24. package/dist/billing/subscription-actions.js +57 -4
  25. package/dist/billing/subscription-actions.js.map +1 -1
  26. package/dist/components/account-chips.d.ts +8 -1
  27. package/dist/components/account-chips.js.map +1 -1
  28. package/dist/eslint/index.js +1 -1
  29. package/dist/feedback/feedback-menu.d.ts +7 -4
  30. package/dist/feedback/feedback-menu.js +4 -2
  31. package/dist/feedback/feedback-menu.js.map +1 -1
  32. package/dist/hooks/use-search-param-state.js +4 -1
  33. package/dist/hooks/use-search-param-state.js.map +1 -1
  34. package/dist/i18n/defaults.js +2 -0
  35. package/dist/i18n/defaults.js.map +1 -1
  36. package/dist/i18n/german.js +36 -2
  37. package/dist/i18n/german.js.map +1 -1
  38. package/dist/i18n/kit-labels.d.ts +3 -0
  39. package/dist/i18n/kit-labels.js.map +1 -1
  40. package/dist/i18n/locales/en.js +51 -2
  41. package/dist/i18n/locales/en.js.map +3 -3
  42. package/dist/i18n/locales/es.js +36 -2
  43. package/dist/i18n/locales/es.js.map +1 -1
  44. package/dist/i18n/locales/fr.js +36 -2
  45. package/dist/i18n/locales/fr.js.map +1 -1
  46. package/dist/i18n/locales/hu.js +36 -2
  47. package/dist/i18n/locales/hu.js.map +1 -1
  48. package/dist/i18n/locales/it.js +36 -2
  49. package/dist/i18n/locales/it.js.map +1 -1
  50. package/dist/i18n/locales/zh.js +36 -2
  51. package/dist/i18n/locales/zh.js.map +1 -1
  52. package/dist/i18n/review.js +15 -1
  53. package/dist/i18n/review.js.map +1 -1
  54. package/dist/index.d.ts +6 -0
  55. package/dist/index.js +6 -0
  56. package/dist/index.js.map +1 -1
  57. package/dist/search/global-search.d.ts +3 -0
  58. package/dist/search/global-search.js +3 -1
  59. package/dist/search/global-search.js.map +1 -1
  60. package/dist/settings/settings-catalogue.d.ts +9 -1
  61. package/dist/settings/settings-catalogue.js +1 -1
  62. package/dist/settings/settings-catalogue.js.map +1 -1
  63. package/dist/shell/admin-menu.d.ts +26 -3
  64. package/dist/shell/admin-menu.js +8 -4
  65. package/dist/shell/admin-menu.js.map +1 -1
  66. package/dist/shell/dev-switchers.js +5 -0
  67. package/dist/shell/dev-switchers.js.map +1 -1
  68. package/dist/shell/top-bar-parts-labels.d.ts +6 -0
  69. package/dist/shell/top-bar-parts-labels.js +4 -1
  70. package/dist/shell/top-bar-parts-labels.js.map +1 -1
  71. package/dist/shell/tour-menu.d.ts +19 -10
  72. package/dist/shell/tour-menu.js +20 -6
  73. package/dist/shell/tour-menu.js.map +1 -1
  74. package/dist/shell.d.ts +2 -0
  75. package/dist/shell.js +2 -0
  76. package/dist/shell.js.map +1 -1
  77. package/dist/tour/tour-catalogue-labels.d.ts +44 -0
  78. package/dist/tour/tour-catalogue-labels.js +32 -0
  79. package/dist/tour/tour-catalogue-labels.js.map +1 -0
  80. package/dist/tour/tour-catalogue.d.ts +68 -0
  81. package/dist/tour/tour-catalogue.js +189 -0
  82. package/dist/tour/tour-catalogue.js.map +1 -0
  83. package/dist/tour/tour-info.d.ts +112 -0
  84. package/dist/tour/tour-info.js +36 -0
  85. package/dist/tour/tour-info.js.map +1 -0
  86. package/dist/tour/use-tour-progress.d.ts +61 -0
  87. package/dist/tour/use-tour-progress.js +116 -0
  88. package/dist/tour/use-tour-progress.js.map +1 -0
  89. package/dist/tour/use-tour-url-sync.d.ts +58 -0
  90. package/dist/tour/use-tour-url-sync.js +110 -0
  91. package/dist/tour/use-tour-url-sync.js.map +1 -0
  92. package/dist/tour.d.ts +8 -0
  93. package/dist/tour.js +18 -0
  94. package/dist/tour.js.map +1 -1
  95. package/package.json +1 -1
  96. package/src/admin/admin-area-labels.ts +7 -1
  97. package/src/admin/admin-overview.tsx +61 -10
  98. package/src/admin/admin-sections.tsx +109 -48
  99. package/src/billing/billing-banner.tsx +25 -2
  100. package/src/billing/billing-labels.ts +6 -0
  101. package/src/billing/cancel-request.ts +75 -0
  102. package/src/billing/provider-page.ts +75 -0
  103. package/src/billing/subscription-actions.tsx +97 -11
  104. package/src/components/account-chips.tsx +8 -1
  105. package/src/feedback/feedback-menu.tsx +8 -3
  106. package/src/hooks/use-search-param-state.ts +6 -1
  107. package/src/i18n/defaults.ts +2 -0
  108. package/src/i18n/german.ts +36 -1
  109. package/src/i18n/kit-labels.tsx +3 -0
  110. package/src/i18n/locales/en.ts +13 -0
  111. package/src/i18n/locales/es.ts +36 -1
  112. package/src/i18n/locales/fr.ts +36 -1
  113. package/src/i18n/locales/hu.ts +36 -1
  114. package/src/i18n/locales/it.ts +36 -1
  115. package/src/i18n/locales/zh.ts +36 -1
  116. package/src/i18n/review.ts +14 -0
  117. package/src/index.ts +8 -0
  118. package/src/search/global-search.tsx +5 -0
  119. package/src/settings/settings-catalogue.ts +10 -2
  120. package/src/shell/admin-menu.tsx +34 -5
  121. package/src/shell/dev-switchers.tsx +8 -0
  122. package/src/shell/top-bar-parts-labels.ts +9 -0
  123. package/src/shell/tour-menu.tsx +50 -15
  124. package/src/shell.ts +3 -0
  125. package/src/tour/tour-catalogue-labels.ts +75 -0
  126. package/src/tour/tour-catalogue.tsx +316 -0
  127. package/src/tour/tour-info.ts +144 -0
  128. package/src/tour/use-tour-progress.ts +198 -0
  129. package/src/tour/use-tour-url-sync.ts +221 -0
  130. package/src/tour.ts +11 -0
@@ -0,0 +1,112 @@
1
+ import type { ReactNode } from "react";
2
+ /**
3
+ * The tours an app offers, as data (docs/tours-harmonization.md §2.2, §6) — one list for
4
+ * the tours page (`TourCatalogue`) and the top bar's `TourMenu`. The step lists stay the
5
+ * app's own: the kit's engine runs them (`useTour().start`), and this describes them.
6
+ *
7
+ * The kit takes finished strings, never i18n keys (§6.3, kk K-1). Role- and data-gated
8
+ * tours are filtered by the app before they come in; every count counts what it is given
9
+ * (§6.3, kk K-2, ka F6).
10
+ */
11
+ export interface TourInfo {
12
+ /** Stable id: what `onLaunch` gets, the progress key, `?tour=`. */
13
+ id: string;
14
+ title: string;
15
+ /** The one-liner under the title (and what the menu could carry). */
16
+ description?: string;
17
+ /** The longer account: which screens it visits, what it explains. Shown from `sm`. */
18
+ about?: string;
19
+ /** The tour's icon, drawn at 16px in the brand colour. */
20
+ icon?: ReactNode;
21
+ /** The id of its `TourGroup`: the section it is listed under. */
22
+ group: string;
23
+ /** The page the tour starts on — `TourMenu`'s "On this page". */
24
+ route?: string;
25
+ /** The day it shipped (ISO `YYYY-MM-DD`): what makes it NEW (§6.4). Without it, never NEW. */
26
+ since?: string;
27
+ /** The last update or fix (§8): a completion from before `updated.date` no longer counts. */
28
+ updated?: TourUpdate;
29
+ /** How many steps it has. Left out, the card shows no step count. */
30
+ steps?: number;
31
+ /** The points it awards (§6.1). Left out, the card draws no chip (never "0 points"). */
32
+ points?: number;
33
+ /** About how long it takes, in minutes — worded by the kit ("About 3 min", §6.5). */
34
+ duration?: number;
35
+ /** A chip beside NEW in the app's words — kastlan's practice mode (§6.5, ka F1). */
36
+ badge?: ReactNode;
37
+ }
38
+ /** A tour's last update or fix (§8). One at a time: a later update replaces it. */
39
+ export interface TourUpdate {
40
+ /** The day it shipped (ISO `YYYY-MM-DD`). */
41
+ date: string;
42
+ /** Why, in a short sentence in the app's words: "The import screen moved; the tour follows it now."
43
+ * Only shown (the card's reset line); the reset itself reads `date` alone, so an app that
44
+ * keeps a reason KEY on its tour definitions passes those to `complete(tour)` as they are. */
45
+ reason?: string;
46
+ }
47
+ /** A section of the tours page, in the app's words and order (§2.3). An empty one is hidden. */
48
+ export interface TourGroup {
49
+ id: string;
50
+ title: string;
51
+ /** The help line under the heading. */
52
+ help?: string;
53
+ /** The heading's icon, drawn at 16px. */
54
+ icon?: ReactNode;
55
+ }
56
+ /**
57
+ * Which tours are completed and when: tour id → the ISO timestamp of the completion, or
58
+ * `null` for one recorded without a date (kastlan's old id list, §6.2). A tour that is
59
+ * not a key is untaken.
60
+ */
61
+ export type TourCompletions = Readonly<Record<string, string | null>>;
62
+ /** What a reset reads of a tour (§8): the update's day, nothing else. */
63
+ type TourUpdated = {
64
+ updated?: {
65
+ date: string;
66
+ } | null;
67
+ };
68
+ /**
69
+ * Is this tour NEW for the person looking at it (§2.4, §6.4)? It shipped AFTER the
70
+ * account was opened — compared by calendar day, so a tour shipped on the joining day was
71
+ * already there to be found — and it is not taken yet. No `since`, or no `joined` date,
72
+ * is never NEW: a pill that appears late is better than one that flickers, and a first
73
+ * tour shipped with a feature should not flash NEW at every older account (KS, ka F7).
74
+ *
75
+ * `completed` is whether the tour was EVER completed — a tour reset by an update (§8) is
76
+ * not NEW again; it carries the "Updated" pill instead, and `since` stays its first ship
77
+ * date.
78
+ */
79
+ export declare function isTourNew({ since, joined, completed, }: {
80
+ since?: string | null;
81
+ /** The account's `created_at` (a date or a timestamp); unknown → never NEW. */
82
+ joined?: string | null;
83
+ completed?: boolean;
84
+ }): boolean;
85
+ /**
86
+ * Was this completion reset by an update (§8)? True when the tour carries `updated` and
87
+ * the completion happened BEFORE the update day began on this device — instants compared:
88
+ * the completion's timestamp against the start of `updated.date` in local time, so one
89
+ * taken at 00:30 in Zurich on the update day counts (its UTC day is the day before) — or
90
+ * has no date at all, which predates any update. A tour never completed (`completedAt`
91
+ * undefined) is never reset: for that person there is nothing to reset. The check itself
92
+ * deletes nothing; a new `complete(tour)` replaces the old date.
93
+ */
94
+ export declare function isTourReset(tour: TourUpdated, completedAt: string | null | undefined): boolean;
95
+ /** Does this completion count — completed, and not reset by a later update (§8)? */
96
+ export declare function isTourDone(tour: TourUpdated, completedAt: string | null | undefined): boolean;
97
+ /**
98
+ * How many of `tours` count as done (§8): the header's "x of y". A tour reset by an update
99
+ * does not count until it is taken again, as on its card.
100
+ */
101
+ export declare function doneCount(tours: readonly ({
102
+ id: string;
103
+ } & TourUpdated)[], completed: TourCompletions): number;
104
+ /**
105
+ * The points earned on `tours` (§6.1, §8): the sum of each done tour's `points`. A reset
106
+ * tour's points are not earned until it is taken again; a tour without points adds none.
107
+ */
108
+ export declare function earnedPoints(tours: readonly ({
109
+ id: string;
110
+ points?: number | null;
111
+ } & TourUpdated)[], completed: TourCompletions): number;
112
+ export {};
@@ -0,0 +1,36 @@
1
+ "use client";
2
+ const dayOf = (iso) => iso.slice(0, 10);
3
+ const BARE_DAY = /^\d{4}-\d{2}-\d{2}$/;
4
+ function startOfLocalDay(day) {
5
+ const [y, m, d] = dayOf(day).split("-").map(Number);
6
+ return new Date(y, m - 1, d).getTime();
7
+ }
8
+ const instantOf = (iso) => BARE_DAY.test(iso) ? startOfLocalDay(iso) : Date.parse(iso);
9
+ function isTourNew({
10
+ since,
11
+ joined,
12
+ completed
13
+ }) {
14
+ return !!since && !!joined && dayOf(since) > dayOf(joined) && !completed;
15
+ }
16
+ function isTourReset(tour, completedAt) {
17
+ if (completedAt === void 0 || !tour.updated) return false;
18
+ return completedAt === null || instantOf(completedAt) < startOfLocalDay(tour.updated.date);
19
+ }
20
+ function isTourDone(tour, completedAt) {
21
+ return completedAt !== void 0 && !isTourReset(tour, completedAt);
22
+ }
23
+ function doneCount(tours, completed) {
24
+ return tours.filter((tour) => isTourDone(tour, completed[tour.id])).length;
25
+ }
26
+ function earnedPoints(tours, completed) {
27
+ return tours.reduce((sum, tour) => sum + (isTourDone(tour, completed[tour.id]) ? tour.points ?? 0 : 0), 0);
28
+ }
29
+ export {
30
+ doneCount,
31
+ earnedPoints,
32
+ isTourDone,
33
+ isTourNew,
34
+ isTourReset
35
+ };
36
+ //# sourceMappingURL=tour-info.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/tour/tour-info.ts"],"sourcesContent":["import type { ReactNode } from \"react\";\n\n/**\n * The tours an app offers, as data (docs/tours-harmonization.md §2.2, §6) — one list for\n * the tours page (`TourCatalogue`) and the top bar's `TourMenu`. The step lists stay the\n * app's own: the kit's engine runs them (`useTour().start`), and this describes them.\n *\n * The kit takes finished strings, never i18n keys (§6.3, kk K-1). Role- and data-gated\n * tours are filtered by the app before they come in; every count counts what it is given\n * (§6.3, kk K-2, ka F6).\n */\nexport interface TourInfo {\n /** Stable id: what `onLaunch` gets, the progress key, `?tour=`. */\n id: string;\n title: string;\n /** The one-liner under the title (and what the menu could carry). */\n description?: string;\n /** The longer account: which screens it visits, what it explains. Shown from `sm`. */\n about?: string;\n /** The tour's icon, drawn at 16px in the brand colour. */\n icon?: ReactNode;\n /** The id of its `TourGroup`: the section it is listed under. */\n group: string;\n /** The page the tour starts on — `TourMenu`'s \"On this page\". */\n route?: string;\n /** The day it shipped (ISO `YYYY-MM-DD`): what makes it NEW (§6.4). Without it, never NEW. */\n since?: string;\n /** The last update or fix (§8): a completion from before `updated.date` no longer counts. */\n updated?: TourUpdate;\n /** How many steps it has. Left out, the card shows no step count. */\n steps?: number;\n /** The points it awards (§6.1). Left out, the card draws no chip (never \"0 points\"). */\n points?: number;\n /** About how long it takes, in minutes — worded by the kit (\"About 3 min\", §6.5). */\n duration?: number;\n /** A chip beside NEW in the app's words — kastlan's practice mode (§6.5, ka F1). */\n badge?: ReactNode;\n}\n\n/** A tour's last update or fix (§8). One at a time: a later update replaces it. */\nexport interface TourUpdate {\n /** The day it shipped (ISO `YYYY-MM-DD`). */\n date: string;\n /** Why, in a short sentence in the app's words: \"The import screen moved; the tour follows it now.\"\n * Only shown (the card's reset line); the reset itself reads `date` alone, so an app that\n * keeps a reason KEY on its tour definitions passes those to `complete(tour)` as they are. */\n reason?: string;\n}\n\n/** A section of the tours page, in the app's words and order (§2.3). An empty one is hidden. */\nexport interface TourGroup {\n id: string;\n title: string;\n /** The help line under the heading. */\n help?: string;\n /** The heading's icon, drawn at 16px. */\n icon?: ReactNode;\n}\n\n/**\n * Which tours are completed and when: tour id → the ISO timestamp of the completion, or\n * `null` for one recorded without a date (kastlan's old id list, §6.2). A tour that is\n * not a key is untaken.\n */\nexport type TourCompletions = Readonly<Record<string, string | null>>;\n\n/** The calendar day of an ISO date or timestamp — `\"2026-10-17T08:00:00Z\"` → `\"2026-10-17\"`. */\nconst dayOf = (iso: string) => iso.slice(0, 10);\n\n/** What a reset reads of a tour (§8): the update's day, nothing else. */\ntype TourUpdated = { updated?: { date: string } | null };\n\nconst BARE_DAY = /^\\d{4}-\\d{2}-\\d{2}$/;\n\n/** The start of an ISO day (`YYYY-MM-DD`) in THIS device's time zone, as an instant. */\nfunction startOfLocalDay(day: string): number {\n const [y, m, d] = dayOf(day).split(\"-\").map(Number);\n return new Date(y, m - 1, d).getTime();\n}\n\n/** A completion as an instant: a timestamp as written, a bare day from its local start. */\nconst instantOf = (iso: string) => (BARE_DAY.test(iso) ? startOfLocalDay(iso) : Date.parse(iso));\n\n/**\n * Is this tour NEW for the person looking at it (§2.4, §6.4)? It shipped AFTER the\n * account was opened — compared by calendar day, so a tour shipped on the joining day was\n * already there to be found — and it is not taken yet. No `since`, or no `joined` date,\n * is never NEW: a pill that appears late is better than one that flickers, and a first\n * tour shipped with a feature should not flash NEW at every older account (KS, ka F7).\n *\n * `completed` is whether the tour was EVER completed — a tour reset by an update (§8) is\n * not NEW again; it carries the \"Updated\" pill instead, and `since` stays its first ship\n * date.\n */\nexport function isTourNew({\n since,\n joined,\n completed,\n}: {\n since?: string | null;\n /** The account's `created_at` (a date or a timestamp); unknown → never NEW. */\n joined?: string | null;\n completed?: boolean;\n}): boolean {\n return !!since && !!joined && dayOf(since) > dayOf(joined) && !completed;\n}\n\n/**\n * Was this completion reset by an update (§8)? True when the tour carries `updated` and\n * the completion happened BEFORE the update day began on this device — instants compared:\n * the completion's timestamp against the start of `updated.date` in local time, so one\n * taken at 00:30 in Zurich on the update day counts (its UTC day is the day before) — or\n * has no date at all, which predates any update. A tour never completed (`completedAt`\n * undefined) is never reset: for that person there is nothing to reset. The check itself\n * deletes nothing; a new `complete(tour)` replaces the old date.\n */\nexport function isTourReset(tour: TourUpdated, completedAt: string | null | undefined): boolean {\n if (completedAt === undefined || !tour.updated) return false;\n return completedAt === null || instantOf(completedAt) < startOfLocalDay(tour.updated.date);\n}\n\n/** Does this completion count — completed, and not reset by a later update (§8)? */\nexport function isTourDone(tour: TourUpdated, completedAt: string | null | undefined): boolean {\n return completedAt !== undefined && !isTourReset(tour, completedAt);\n}\n\n/**\n * How many of `tours` count as done (§8): the header's \"x of y\". A tour reset by an update\n * does not count until it is taken again, as on its card.\n */\nexport function doneCount(tours: readonly ({ id: string } & TourUpdated)[], completed: TourCompletions): number {\n return tours.filter((tour) => isTourDone(tour, completed[tour.id])).length;\n}\n\n/**\n * The points earned on `tours` (§6.1, §8): the sum of each done tour's `points`. A reset\n * tour's points are not earned until it is taken again; a tour without points adds none.\n */\nexport function earnedPoints(\n tours: readonly ({ id: string; points?: number | null } & TourUpdated)[],\n completed: TourCompletions,\n): number {\n return tours.reduce((sum, tour) => sum + (isTourDone(tour, completed[tour.id]) ? (tour.points ?? 0) : 0), 0);\n}\n"],"mappings":";AAmEA,MAAM,QAAQ,CAAC,QAAgB,IAAI,MAAM,GAAG,EAAE;AAK9C,MAAM,WAAW;AAGjB,SAAS,gBAAgB,KAAqB;AAC5C,QAAM,CAAC,GAAG,GAAG,CAAC,IAAI,MAAM,GAAG,EAAE,MAAM,GAAG,EAAE,IAAI,MAAM;AAClD,SAAO,IAAI,KAAK,GAAG,IAAI,GAAG,CAAC,EAAE,QAAQ;AACvC;AAGA,MAAM,YAAY,CAAC,QAAiB,SAAS,KAAK,GAAG,IAAI,gBAAgB,GAAG,IAAI,KAAK,MAAM,GAAG;AAavF,SAAS,UAAU;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AACF,GAKY;AACV,SAAO,CAAC,CAAC,SAAS,CAAC,CAAC,UAAU,MAAM,KAAK,IAAI,MAAM,MAAM,KAAK,CAAC;AACjE;AAWO,SAAS,YAAY,MAAmB,aAAiD;AAC9F,MAAI,gBAAgB,UAAa,CAAC,KAAK,QAAS,QAAO;AACvD,SAAO,gBAAgB,QAAQ,UAAU,WAAW,IAAI,gBAAgB,KAAK,QAAQ,IAAI;AAC3F;AAGO,SAAS,WAAW,MAAmB,aAAiD;AAC7F,SAAO,gBAAgB,UAAa,CAAC,YAAY,MAAM,WAAW;AACpE;AAMO,SAAS,UAAU,OAAkD,WAAoC;AAC9G,SAAO,MAAM,OAAO,CAAC,SAAS,WAAW,MAAM,UAAU,KAAK,EAAE,CAAC,CAAC,EAAE;AACtE;AAMO,SAAS,aACd,OACA,WACQ;AACR,SAAO,MAAM,OAAO,CAAC,KAAK,SAAS,OAAO,WAAW,MAAM,UAAU,KAAK,EAAE,CAAC,IAAK,KAAK,UAAU,IAAK,IAAI,CAAC;AAC7G;","names":[]}
@@ -0,0 +1,61 @@
1
+ import { type TourCompletions } from "./tour-info.js";
2
+ /**
3
+ * Which tours this device has completed (docs/tours-harmonization.md §2.6, §6.2) —
4
+ * keksdose's `tour-progress-store` and kastlan's `completions.ts`, as one hook.
5
+ *
6
+ * - **Device storage, the app's key.** `storageKey` is always the app's: an app on shared
7
+ * devices scopes it per account (KS, bench PCs), and an app that lists its keys
8
+ * (KS `storage-keys.ts`) spells it there. Every access is guarded: a blocked or full
9
+ * storage keeps the marks for this page's life instead of throwing.
10
+ * - **One store, every reader.** A change notifies every hook on the same key in this tab
11
+ * (an in-tab emitter) and in other tabs (the `storage` event), so the tours page and
12
+ * `TourMenu` agree without a reload (ka F3).
13
+ * - **`migrate(raw)`** reads an older shape, so nobody loses their done marks at adoption:
14
+ * it gets the stored JSON (or the raw text, if it is no JSON) and returns the record for
15
+ * a shape it recognises, `undefined` for any other — the kit's own shape included,
16
+ * which it then reads itself. keksdose: zustand's `{state: {completed}, version: 1}`;
17
+ * kastlan: an array of ids, completed without a date (`null`). It runs only on a stored
18
+ * text that is not the kit's shape already, once per text and key, whichever reader
19
+ * reads it first; its identity is ignored. **Define `migrate` once, at module level**,
20
+ * and hand every reader of the key the same one: readers of one key share one snapshot.
21
+ * - **Resetting the device** (settings §11): register the key with `reset: () =>
22
+ * resetTourProgress(storageKey)`, which clears storage and the page's memory and tells
23
+ * every reader in this tab.
24
+ *
25
+ * The kit's own shape is the record itself, `{ [id]: ISO | null }`; an empty string reads
26
+ * as `null` (kastlan's record of 0.42).
27
+ */
28
+ export interface UseTourProgressOptions {
29
+ storageKey: string;
30
+ migrate?: (raw: unknown) => Record<string, string | null> | undefined;
31
+ }
32
+ export interface TourProgress {
33
+ /** Tour id → the completion's ISO timestamp, or `null` when recorded without a date. */
34
+ completed: TourCompletions;
35
+ /**
36
+ * Record a completion. Keeps the FIRST completion's date, so a replay changes nothing —
37
+ * unless the tour was reset by an update since (§8): pass the tour (`{id, updated}`) and
38
+ * a completion from before `updated.date` is replaced by today's.
39
+ *
40
+ * Returns `true` when this counts as a new completion — the moment to award the tour's
41
+ * points and show the app's toast (§6.1) — and `false` for a replay.
42
+ */
43
+ complete: (tour: string | {
44
+ id: string;
45
+ updated?: {
46
+ date: string;
47
+ } | null;
48
+ }) => boolean;
49
+ /** "Mark as not done": forget the completion. */
50
+ reset: (id: string) => void;
51
+ }
52
+ /**
53
+ * Forget every tour completion under `storageKey` on this device: the stored key, what the
54
+ * page kept in memory where storage refused it, and every reader in this tab moves at
55
+ * once. For "Reset this device's settings" (settings §11):
56
+ *
57
+ * registerDeviceSetting({ key: TOUR_KEY, kind: "view", reset: () => resetTourProgress(TOUR_KEY) });
58
+ */
59
+ export declare function resetTourProgress(storageKey: string): void;
60
+ /** The device's tour completions under `storageKey`; see {@link UseTourProgressOptions}. */
61
+ export declare function useTourProgress({ storageKey, migrate }: UseTourProgressOptions): TourProgress;
@@ -0,0 +1,116 @@
1
+ "use client";
2
+ import { useCallback, useEffect, useMemo, useRef, useSyncExternalStore } from "react";
3
+ import { readStored, removeStored, writeStored } from "../lib/safe-storage.js";
4
+ import { isTourDone } from "./tour-info.js";
5
+ const EMPTY = Object.freeze({});
6
+ const listeners = /* @__PURE__ */ new Map();
7
+ const memory = /* @__PURE__ */ new Map();
8
+ const cache = /* @__PURE__ */ new Map();
9
+ function emit(key) {
10
+ listeners.get(key)?.forEach((listener) => listener());
11
+ }
12
+ function rawOf(key) {
13
+ return memory.get(key) ?? readStored(key);
14
+ }
15
+ function isKitShape(value) {
16
+ if (!value || typeof value !== "object" || Array.isArray(value)) return false;
17
+ return Object.values(value).every((at) => at === null || typeof at === "string");
18
+ }
19
+ function fromRecord(value) {
20
+ if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
21
+ const out = {};
22
+ for (const [id, at] of Object.entries(value)) {
23
+ if (at === null || at === "") out[id] = null;
24
+ else if (typeof at === "string") out[id] = at;
25
+ }
26
+ return out;
27
+ }
28
+ function parse(raw, migrate) {
29
+ if (raw === null) return EMPTY;
30
+ let value = raw;
31
+ try {
32
+ value = JSON.parse(raw);
33
+ } catch {
34
+ }
35
+ if (migrate && !isKitShape(value)) {
36
+ try {
37
+ const migrated = migrate(value);
38
+ if (migrated !== void 0) return fromRecord(migrated) ?? EMPTY;
39
+ } catch {
40
+ }
41
+ }
42
+ return fromRecord(value) ?? EMPTY;
43
+ }
44
+ function snapshot(key, migrate) {
45
+ const raw = rawOf(key);
46
+ const hit = cache.get(key);
47
+ if (hit && hit.raw === raw) return hit.value;
48
+ const value = parse(raw, migrate);
49
+ cache.set(key, { raw, value });
50
+ return value;
51
+ }
52
+ function write(key, record) {
53
+ const raw = JSON.stringify(record);
54
+ writeStored(key, raw);
55
+ if (readStored(key) === raw) memory.delete(key);
56
+ else memory.set(key, raw);
57
+ emit(key);
58
+ }
59
+ function subscribe(key, listener) {
60
+ let set = listeners.get(key);
61
+ if (!set) listeners.set(key, set = /* @__PURE__ */ new Set());
62
+ set.add(listener);
63
+ const onStorage = (event) => {
64
+ if (event.key !== null && event.key !== key) return;
65
+ memory.delete(key);
66
+ listener();
67
+ };
68
+ if (typeof window !== "undefined") window.addEventListener("storage", onStorage);
69
+ return () => {
70
+ set.delete(listener);
71
+ if (typeof window !== "undefined") window.removeEventListener("storage", onStorage);
72
+ };
73
+ }
74
+ function resetTourProgress(storageKey) {
75
+ removeStored(storageKey);
76
+ memory.delete(storageKey);
77
+ cache.delete(storageKey);
78
+ emit(storageKey);
79
+ }
80
+ function useTourProgress({ storageKey, migrate }) {
81
+ const migrateRef = useRef(migrate);
82
+ useEffect(() => {
83
+ migrateRef.current = migrate;
84
+ });
85
+ const completed = useSyncExternalStore(
86
+ useCallback((listener) => subscribe(storageKey, listener), [storageKey]),
87
+ () => snapshot(storageKey, migrateRef.current),
88
+ () => EMPTY
89
+ );
90
+ const complete = useCallback(
91
+ (tour) => {
92
+ const subject = typeof tour === "string" ? { id: tour } : tour;
93
+ const current = snapshot(storageKey, migrateRef.current);
94
+ if (isTourDone(subject, current[subject.id])) return false;
95
+ write(storageKey, { ...current, [subject.id]: (/* @__PURE__ */ new Date()).toISOString() });
96
+ return true;
97
+ },
98
+ [storageKey]
99
+ );
100
+ const reset = useCallback(
101
+ (id) => {
102
+ const current = snapshot(storageKey, migrateRef.current);
103
+ if (current[id] === void 0) return;
104
+ const next = { ...current };
105
+ delete next[id];
106
+ write(storageKey, next);
107
+ },
108
+ [storageKey]
109
+ );
110
+ return useMemo(() => ({ completed, complete, reset }), [completed, complete, reset]);
111
+ }
112
+ export {
113
+ resetTourProgress,
114
+ useTourProgress
115
+ };
116
+ //# sourceMappingURL=use-tour-progress.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/tour/use-tour-progress.ts"],"sourcesContent":["import { useCallback, useEffect, useMemo, useRef, useSyncExternalStore } from \"react\";\nimport { readStored, removeStored, writeStored } from \"../lib/safe-storage\";\nimport { isTourDone, type TourCompletions } from \"./tour-info\";\n\n/**\n * Which tours this device has completed (docs/tours-harmonization.md §2.6, §6.2) —\n * keksdose's `tour-progress-store` and kastlan's `completions.ts`, as one hook.\n *\n * - **Device storage, the app's key.** `storageKey` is always the app's: an app on shared\n * devices scopes it per account (KS, bench PCs), and an app that lists its keys\n * (KS `storage-keys.ts`) spells it there. Every access is guarded: a blocked or full\n * storage keeps the marks for this page's life instead of throwing.\n * - **One store, every reader.** A change notifies every hook on the same key in this tab\n * (an in-tab emitter) and in other tabs (the `storage` event), so the tours page and\n * `TourMenu` agree without a reload (ka F3).\n * - **`migrate(raw)`** reads an older shape, so nobody loses their done marks at adoption:\n * it gets the stored JSON (or the raw text, if it is no JSON) and returns the record for\n * a shape it recognises, `undefined` for any other — the kit's own shape included,\n * which it then reads itself. keksdose: zustand's `{state: {completed}, version: 1}`;\n * kastlan: an array of ids, completed without a date (`null`). It runs only on a stored\n * text that is not the kit's shape already, once per text and key, whichever reader\n * reads it first; its identity is ignored. **Define `migrate` once, at module level**,\n * and hand every reader of the key the same one: readers of one key share one snapshot.\n * - **Resetting the device** (settings §11): register the key with `reset: () =>\n * resetTourProgress(storageKey)`, which clears storage and the page's memory and tells\n * every reader in this tab.\n *\n * The kit's own shape is the record itself, `{ [id]: ISO | null }`; an empty string reads\n * as `null` (kastlan's record of 0.42).\n */\nexport interface UseTourProgressOptions {\n storageKey: string;\n migrate?: (raw: unknown) => Record<string, string | null> | undefined;\n}\n\nexport interface TourProgress {\n /** Tour id → the completion's ISO timestamp, or `null` when recorded without a date. */\n completed: TourCompletions;\n /**\n * Record a completion. Keeps the FIRST completion's date, so a replay changes nothing —\n * unless the tour was reset by an update since (§8): pass the tour (`{id, updated}`) and\n * a completion from before `updated.date` is replaced by today's.\n *\n * Returns `true` when this counts as a new completion — the moment to award the tour's\n * points and show the app's toast (§6.1) — and `false` for a replay.\n */\n complete: (tour: string | { id: string; updated?: { date: string } | null }) => boolean;\n /** \"Mark as not done\": forget the completion. */\n reset: (id: string) => void;\n}\n\n/* ── The store: one per key, shared by every hook ───────────────────────────── */\n\nconst EMPTY: TourCompletions = Object.freeze({});\n/** In-tab listeners per key. */\nconst listeners = new Map<string, Set<() => void>>();\n/** What this page wrote where storage refused to keep it (blocked, full): per key. */\nconst memory = new Map<string, string>();\n/**\n * The last raw text read per key and what it parsed to, so a snapshot keeps its identity:\n * the same text gives the same object, whichever reader asks and whatever `migrate` it\n * holds. Several readers of one key with inline `migrate` arrows used to evict each other\n * here and loop (kastlan B1, 0.43).\n */\nconst cache = new Map<string, { raw: string | null; value: TourCompletions }>();\n\nfunction emit(key: string) {\n listeners.get(key)?.forEach((listener) => listener());\n}\n\nfunction rawOf(key: string): string | null {\n return memory.get(key) ?? readStored(key);\n}\n\n/** Is this the kit's own shape already: a record whose every value is a string or null? */\nfunction isKitShape(value: unknown): boolean {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return false;\n return Object.values(value as Record<string, unknown>).every((at) => at === null || typeof at === \"string\");\n}\n\n/** The kit's own shape: a record of string or null; anything else is dropped. */\nfunction fromRecord(value: unknown): TourCompletions | undefined {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return undefined;\n const out: Record<string, string | null> = {};\n for (const [id, at] of Object.entries(value as Record<string, unknown>)) {\n if (at === null || at === \"\") out[id] = null;\n else if (typeof at === \"string\") out[id] = at;\n }\n return out;\n}\n\nfunction parse(raw: string | null, migrate: UseTourProgressOptions[\"migrate\"]): TourCompletions {\n if (raw === null) return EMPTY;\n let value: unknown = raw;\n try {\n value = JSON.parse(raw);\n } catch {\n // Not JSON: `migrate` still sees the text.\n }\n if (migrate && !isKitShape(value)) {\n try {\n const migrated = migrate(value);\n if (migrated !== undefined) return fromRecord(migrated) ?? EMPTY;\n } catch {\n // A migrate that throws reads as \"not a shape it knows\".\n }\n }\n return fromRecord(value) ?? EMPTY;\n}\n\nfunction snapshot(key: string, migrate: UseTourProgressOptions[\"migrate\"]): TourCompletions {\n const raw = rawOf(key);\n const hit = cache.get(key);\n if (hit && hit.raw === raw) return hit.value;\n const value = parse(raw, migrate);\n cache.set(key, { raw, value });\n return value;\n}\n\nfunction write(key: string, record: TourCompletions) {\n const raw = JSON.stringify(record);\n writeStored(key, raw);\n // Storage refused it (blocked, full): keep it for this page's life instead.\n if (readStored(key) === raw) memory.delete(key);\n else memory.set(key, raw);\n emit(key);\n}\n\nfunction subscribe(key: string, listener: () => void): () => void {\n let set = listeners.get(key);\n if (!set) listeners.set(key, (set = new Set()));\n set.add(listener);\n // Another tab wrote (or cleared all storage: `key` null).\n const onStorage = (event: StorageEvent) => {\n if (event.key !== null && event.key !== key) return;\n memory.delete(key);\n listener();\n };\n if (typeof window !== \"undefined\") window.addEventListener(\"storage\", onStorage);\n return () => {\n set.delete(listener);\n if (typeof window !== \"undefined\") window.removeEventListener(\"storage\", onStorage);\n };\n}\n\n/**\n * Forget every tour completion under `storageKey` on this device: the stored key, what the\n * page kept in memory where storage refused it, and every reader in this tab moves at\n * once. For \"Reset this device's settings\" (settings §11):\n *\n * registerDeviceSetting({ key: TOUR_KEY, kind: \"view\", reset: () => resetTourProgress(TOUR_KEY) });\n */\nexport function resetTourProgress(storageKey: string): void {\n removeStored(storageKey);\n memory.delete(storageKey);\n cache.delete(storageKey);\n emit(storageKey);\n}\n\n/** The device's tour completions under `storageKey`; see {@link UseTourProgressOptions}. */\nexport function useTourProgress({ storageKey, migrate }: UseTourProgressOptions): TourProgress {\n // Held, not depended on: an inline arrow is a new function every render, and neither the\n // snapshot nor the callbacks may change with it.\n const migrateRef = useRef(migrate);\n useEffect(() => {\n migrateRef.current = migrate;\n });\n const completed = useSyncExternalStore(\n useCallback((listener: () => void) => subscribe(storageKey, listener), [storageKey]),\n () => snapshot(storageKey, migrateRef.current),\n () => EMPTY,\n );\n\n const complete = useCallback(\n (tour: string | { id: string; updated?: { date: string } | null }) => {\n const subject = typeof tour === \"string\" ? { id: tour } : tour;\n // Read now rather than from the render: two completions in one handler both count.\n const current = snapshot(storageKey, migrateRef.current);\n if (isTourDone(subject, current[subject.id])) return false;\n write(storageKey, { ...current, [subject.id]: new Date().toISOString() });\n return true;\n },\n [storageKey],\n );\n\n const reset = useCallback(\n (id: string) => {\n const current = snapshot(storageKey, migrateRef.current);\n if (current[id] === undefined) return;\n const next = { ...current };\n delete next[id];\n write(storageKey, next);\n },\n [storageKey],\n );\n\n return useMemo(() => ({ completed, complete, reset }), [completed, complete, reset]);\n}\n"],"mappings":";AAAA,SAAS,aAAa,WAAW,SAAS,QAAQ,4BAA4B;AAC9E,SAAS,YAAY,cAAc,mBAAmB;AACtD,SAAS,kBAAwC;AAmDjD,MAAM,QAAyB,OAAO,OAAO,CAAC,CAAC;AAE/C,MAAM,YAAY,oBAAI,IAA6B;AAEnD,MAAM,SAAS,oBAAI,IAAoB;AAOvC,MAAM,QAAQ,oBAAI,IAA4D;AAE9E,SAAS,KAAK,KAAa;AACzB,YAAU,IAAI,GAAG,GAAG,QAAQ,CAAC,aAAa,SAAS,CAAC;AACtD;AAEA,SAAS,MAAM,KAA4B;AACzC,SAAO,OAAO,IAAI,GAAG,KAAK,WAAW,GAAG;AAC1C;AAGA,SAAS,WAAW,OAAyB;AAC3C,MAAI,CAAC,SAAS,OAAO,UAAU,YAAY,MAAM,QAAQ,KAAK,EAAG,QAAO;AACxE,SAAO,OAAO,OAAO,KAAgC,EAAE,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Q;AAAA,IACZ,CAAC,OAAe;AACd,YAAM,UAAU,SAAS,YAAY,WAAW,OAAO;AACvD,UAAI,QAAQ,EAAE,MAAM,OAAW;AAC/B,YAAM,OAAO,EAAE,GAAG,QAAQ;AAC1B,aAAO,KAAK,EAAE;AACd,YAAM,YAAY,IAAI;AAAA,IACxB;AAAA,IACA,CAAC,UAAU;AAAA,EACb;AAEA,SAAO,QAAQ,OAAO,EAAE,WAAW,UAAU,MAAM,IAAI,CAAC,WAAW,UAAU,KAAK,CAAC;AACrF;","names":[]}
@@ -0,0 +1,58 @@
1
+ export interface UseTourUrlSyncOptions {
2
+ /**
3
+ * Start the tour `id` at `startIndex` (0-based) — the app's launcher, which builds the
4
+ * steps, awaits its own `prepare()` and passes `onFinish` (the completion, the points
5
+ * toast) to `useTour().start`. An unknown id should do nothing. May return a promise:
6
+ * the parameters are kept until it settles.
7
+ */
8
+ launch: (id: string, options: {
9
+ startIndex: number;
10
+ }) => void | Promise<unknown>;
11
+ /**
12
+ * Are the facts a tour's steps are built from loaded yet (keksdose's `ready`: the
13
+ * caches a branching tour reads)? A deep link waits for it, keeping its parameters, so
14
+ * an F5 mid-tour resumes the right variant at the right step. Default `true`.
15
+ */
16
+ ready?: boolean;
17
+ /**
18
+ * Older names of `tourStep`, read when it is absent and removed with it — kastlan's
19
+ * `ts` (§2.7, for one minor). Their value is a 0-based step index, as kastlan wrote it.
20
+ */
21
+ stepAliases?: readonly string[];
22
+ }
23
+ /**
24
+ * Tours and the URL (docs/tours-harmonization.md §2.7, §6.4) — keksdose's `TourUrlSync`,
25
+ * on the kit's engine (`useTourOptional`):
26
+ *
27
+ * - **`?tour=<id>` starts that tour whenever it APPEARS** — on load, and on in-app
28
+ * navigation too (kastlan's assistant links to `/help/tours?tour=<id>`, ka F4) —
29
+ * resuming at `&tourStep=<n>` (1-based). It waits for `ready`.
30
+ * - **While a tour runs, `?tour=&tourStep=` mirror where it is**, so a reload or a copied
31
+ * link pins the step (kk K-3). A step that navigates drops them; this puts them back.
32
+ * - **At the end it strips only its own parameters**; `?q=`, `?state=` and the hash stay.
33
+ *
34
+ * Mount it once inside the router and the `TourProvider`. Without a provider it still
35
+ * launches through `launch` and never mirrors.
36
+ */
37
+ export declare function useTourUrlSync({ launch, ready, stepAliases }: UseTourUrlSyncOptions): void;
38
+ /** The catalogue's state filter. */
39
+ export type TourStateFilter = "all" | "todo" | "done";
40
+ /** The catalogue's filters: the search, the group (`null`: every group), the state. */
41
+ export interface TourCatalogueFilter {
42
+ query: string;
43
+ group: string | null;
44
+ state: TourStateFilter;
45
+ }
46
+ /**
47
+ * The catalogue's filters in the URL (§2.8) — keksdose's `?q`, `?topic`, `?state`, each
48
+ * written with `replace` (typing does not bury the Back button), the defaults as the
49
+ * clean URL. Spread it onto the catalogue: `<TourCatalogue {...useTourCatalogueUrlState()} … />`.
50
+ * `params` renames them (kastlan's `?group`). Requires a react-router Router.
51
+ */
52
+ export declare function useTourCatalogueUrlState(params?: {
53
+ query?: string;
54
+ group?: string;
55
+ state?: string;
56
+ }): TourCatalogueFilter & {
57
+ onChange: (patch: Partial<TourCatalogueFilter>) => void;
58
+ };
@@ -0,0 +1,110 @@
1
+ "use client";
2
+ import { createContext, useContext, useEffect, useLayoutEffect, useRef, useState } from "react";
3
+ import * as ReactRouter from "react-router";
4
+ import { useLocation, useNavigate } from "react-router";
5
+ import { useSearchParamsState } from "../hooks/use-search-param-state.js";
6
+ import { useTourOptional } from "./tour.js";
7
+ function navigationInFlight(history, dataRouter, rendered) {
8
+ const state = dataRouter?.router?.state;
9
+ if (state && (state.navigation?.state ?? "idle") !== "idle") return true;
10
+ const live = state?.location ?? history?.location;
11
+ if (!live) return false;
12
+ return live.pathname !== rendered.pathname || (live.search ?? "") !== rendered.search || (live.hash ?? "") !== rendered.hash;
13
+ }
14
+ const NO_NAVIGATION = createContext(null);
15
+ const NO_DATA_ROUTER = createContext(null);
16
+ const DataRouterContext = (() => {
17
+ try {
18
+ return ReactRouter.UNSAFE_DataRouterContext ?? NO_DATA_ROUTER;
19
+ } catch {
20
+ return NO_DATA_ROUTER;
21
+ }
22
+ })();
23
+ const NavigationContext = (() => {
24
+ try {
25
+ return ReactRouter.UNSAFE_NavigationContext ?? NO_NAVIGATION;
26
+ } catch {
27
+ return NO_NAVIGATION;
28
+ }
29
+ })();
30
+ function stepOf(params, aliases) {
31
+ const step = Number(params.get("tourStep"));
32
+ if (params.has("tourStep")) return Number.isFinite(step) && step > 0 ? step - 1 : 0;
33
+ for (const alias of aliases) {
34
+ const value = Number(params.get(alias));
35
+ if (params.has(alias)) return Number.isFinite(value) && value > 0 ? Math.floor(value) : 0;
36
+ }
37
+ return 0;
38
+ }
39
+ function useTourUrlSync({ launch, ready = true, stepAliases = [] }) {
40
+ const navigate = useNavigate();
41
+ const location = useLocation();
42
+ const { pathname, search, hash } = location;
43
+ const history = useContext(NavigationContext)?.navigator;
44
+ const dataRouter = useContext(DataRouterContext);
45
+ const engine = useTourOptional();
46
+ const active = engine?.active ?? false;
47
+ const activeId = engine?.activeId ?? null;
48
+ const index = engine?.index ?? 0;
49
+ const urlTour = new URLSearchParams(search).get("tour");
50
+ const aliases = stepAliases.join("\n");
51
+ const launchRef = useRef(launch);
52
+ const activeIdRef = useRef(activeId);
53
+ useLayoutEffect(() => {
54
+ launchRef.current = launch;
55
+ activeIdRef.current = active ? activeId : null;
56
+ });
57
+ const seenRef = useRef(null);
58
+ const pendingRef = useRef(null);
59
+ const launchingRef = useRef(false);
60
+ const [settled, setSettled] = useState(0);
61
+ useEffect(() => {
62
+ if (urlTour !== seenRef.current) {
63
+ seenRef.current = urlTour;
64
+ pendingRef.current = urlTour && urlTour !== activeIdRef.current ? { id: urlTour, startIndex: stepOf(new URLSearchParams(search), aliases ? aliases.split("\n") : []) } : null;
65
+ }
66
+ const pending = pendingRef.current;
67
+ if (!pending || !ready) return;
68
+ pendingRef.current = null;
69
+ launchingRef.current = true;
70
+ void Promise.resolve().then(() => launchRef.current(pending.id, { startIndex: pending.startIndex })).catch(() => void 0).finally(() => {
71
+ launchingRef.current = false;
72
+ setSettled((n) => n + 1);
73
+ });
74
+ }, [urlTour, ready]);
75
+ useEffect(() => {
76
+ if (navigationInFlight(history, dataRouter, { pathname, search, hash })) return;
77
+ if (pendingRef.current || launchingRef.current) return;
78
+ const tourId = active && activeId ? activeId : null;
79
+ const own = ["tour", "tourStep", ...aliases ? aliases.split("\n") : []];
80
+ const current = new URLSearchParams(search);
81
+ if (!tourId && !own.some((key) => current.has(key))) return;
82
+ const next = new URLSearchParams(search);
83
+ for (const key of tourId ? own.slice(2) : own) next.delete(key);
84
+ if (tourId) {
85
+ next.set("tour", tourId);
86
+ next.set("tourStep", String(index + 1));
87
+ }
88
+ if (next.toString() === current.toString()) return;
89
+ void navigate({ pathname, search: next.toString(), hash }, { replace: true, state: location.state });
90
+ }, [active, activeId, index, pathname, search, hash, settled, aliases]);
91
+ }
92
+ const STATES = ["all", "todo", "done"];
93
+ function useTourCatalogueUrlState(params = {}) {
94
+ const [filter, setFilter] = useSearchParamsState({
95
+ query: { param: params.query ?? "q", default: "", history: "replace" },
96
+ group: { param: params.group ?? "topic", default: null, history: "replace", parse: (raw) => raw || void 0 },
97
+ state: {
98
+ param: params.state ?? "state",
99
+ default: "all",
100
+ history: "replace",
101
+ parse: (raw) => STATES.find((x) => x === raw)
102
+ }
103
+ });
104
+ return { ...filter, onChange: setFilter };
105
+ }
106
+ export {
107
+ useTourCatalogueUrlState,
108
+ useTourUrlSync
109
+ };
110
+ //# sourceMappingURL=use-tour-url-sync.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/tour/use-tour-url-sync.ts"],"sourcesContent":["import { createContext, useContext, useEffect, useLayoutEffect, useRef, useState, type Context } from \"react\";\nimport * as ReactRouter from \"react-router\";\nimport { useLocation, useNavigate, type Navigator } from \"react-router\";\nimport { useSearchParamsState } from \"../hooks/use-search-param-state\";\nimport { useTourOptional } from \"./tour\";\n\n/* ── useTourUrlSync ─────────────────────────────────────────────────────────── */\n\nexport interface UseTourUrlSyncOptions {\n /**\n * Start the tour `id` at `startIndex` (0-based) — the app's launcher, which builds the\n * steps, awaits its own `prepare()` and passes `onFinish` (the completion, the points\n * toast) to `useTour().start`. An unknown id should do nothing. May return a promise:\n * the parameters are kept until it settles.\n */\n launch: (id: string, options: { startIndex: number }) => void | Promise<unknown>;\n /**\n * Are the facts a tour's steps are built from loaded yet (keksdose's `ready`: the\n * caches a branching tour reads)? A deep link waits for it, keeping its parameters, so\n * an F5 mid-tour resumes the right variant at the right step. Default `true`.\n */\n ready?: boolean;\n /**\n * Older names of `tourStep`, read when it is absent and removed with it — kastlan's\n * `ts` (§2.7, for one minor). Their value is a 0-based step index, as kastlan wrote it.\n */\n stepAliases?: readonly string[];\n}\n\ntype Place = { pathname: string; search: string; hash: string };\n\n/**\n * Has the router already moved on from the location React is still rendering?\n * keksdose's check (tour-url-sync.tsx, tours audit 2026-10-02): a mirror write built\n * from the page being LEFT is a replace back onto it, which cancels a step's `go()`.\n *\n * - A data router (`createBrowserRouter`, kastlan): its navigator has no location (build\n * review 0.43, kastlan A2), so the router's own state answers — a navigation still\n * loading, or a location it has committed that React has not rendered yet.\n * - A declarative router (`BrowserRouter`, keksdose): its navigator is its history and\n * carries where it is.\n * - Anything else answers \"not in flight\".\n */\nfunction navigationInFlight(history: Navigator | undefined, dataRouter: DataRouterProbe, rendered: Place) {\n const state = dataRouter?.router?.state;\n if (state && (state.navigation?.state ?? \"idle\") !== \"idle\") return true;\n const live = state?.location ?? (history as (Navigator & { location?: Partial<Place> }) | undefined)?.location;\n if (!live) return false;\n return (\n live.pathname !== rendered.pathname || (live.search ?? \"\") !== rendered.search || (live.hash ?? \"\") !== rendered.hash\n );\n}\n\ntype NavigationProbe = { navigator?: Navigator } | null;\nconst NO_NAVIGATION = createContext<NavigationProbe>(null);\n/** The data router's state, as `useSearchParamState` reads it. */\ntype DataRouterProbe = {\n router?: { state?: { navigation?: { state?: string }; location?: Partial<Place> } };\n} | null;\nconst NO_DATA_ROUTER = createContext<DataRouterProbe>(null);\nconst DataRouterContext: Context<DataRouterProbe> = (() => {\n try {\n return (\n (ReactRouter as unknown as { UNSAFE_DataRouterContext?: Context<DataRouterProbe> }).UNSAFE_DataRouterContext ??\n NO_DATA_ROUTER\n );\n } catch {\n return NO_DATA_ROUTER;\n }\n})();\n/** Read off the namespace inside a `try`, as `useSearchParamState` reads the data router:\n * a test's partial `vi.mock(\"react-router\")` throws on an export it does not define. */\nconst NavigationContext: Context<NavigationProbe> = (() => {\n try {\n return (\n (ReactRouter as unknown as { UNSAFE_NavigationContext?: Context<NavigationProbe> }).UNSAFE_NavigationContext ??\n NO_NAVIGATION\n );\n } catch {\n return NO_NAVIGATION;\n }\n})();\n\n/** The step a link asks for, 0-based: `tourStep` is 1-based (keksdose), an alias 0-based. */\nfunction stepOf(params: URLSearchParams, aliases: readonly string[]): number {\n const step = Number(params.get(\"tourStep\"));\n if (params.has(\"tourStep\")) return Number.isFinite(step) && step > 0 ? step - 1 : 0;\n for (const alias of aliases) {\n const value = Number(params.get(alias));\n if (params.has(alias)) return Number.isFinite(value) && value > 0 ? Math.floor(value) : 0;\n }\n return 0;\n}\n\n/**\n * Tours and the URL (docs/tours-harmonization.md §2.7, §6.4) — keksdose's `TourUrlSync`,\n * on the kit's engine (`useTourOptional`):\n *\n * - **`?tour=<id>` starts that tour whenever it APPEARS** — on load, and on in-app\n * navigation too (kastlan's assistant links to `/help/tours?tour=<id>`, ka F4) —\n * resuming at `&tourStep=<n>` (1-based). It waits for `ready`.\n * - **While a tour runs, `?tour=&tourStep=` mirror where it is**, so a reload or a copied\n * link pins the step (kk K-3). A step that navigates drops them; this puts them back.\n * - **At the end it strips only its own parameters**; `?q=`, `?state=` and the hash stay.\n *\n * Mount it once inside the router and the `TourProvider`. Without a provider it still\n * launches through `launch` and never mirrors.\n */\nexport function useTourUrlSync({ launch, ready = true, stepAliases = [] }: UseTourUrlSyncOptions): void {\n const navigate = useNavigate();\n const location = useLocation();\n const { pathname, search, hash } = location;\n const history = useContext(NavigationContext)?.navigator;\n const dataRouter = useContext(DataRouterContext);\n const engine = useTourOptional();\n const active = engine?.active ?? false;\n const activeId = engine?.activeId ?? null;\n const index = engine?.index ?? 0;\n const urlTour = new URLSearchParams(search).get(\"tour\");\n const aliases = stepAliases.join(\"\\n\");\n\n const launchRef = useRef(launch);\n const activeIdRef = useRef(activeId);\n useLayoutEffect(() => {\n launchRef.current = launch;\n activeIdRef.current = active ? activeId : null;\n });\n /** The `tour` value last seen in the URL: a tour starts when it CHANGES to an id. */\n const seenRef = useRef<string | null>(null);\n /** A deep link waiting for `ready`. */\n const pendingRef = useRef<{ id: string; startIndex: number } | null>(null);\n /** A launch under way (an app's `prepare()`). */\n const launchingRef = useRef(false);\n /** Bumped when a launch settles, so the mirror looks again. */\n const [settled, setSettled] = useState(0);\n\n useEffect(() => {\n if (urlTour !== seenRef.current) {\n seenRef.current = urlTour;\n // Its own mirror writing the running tour back is no new link.\n pendingRef.current =\n urlTour && urlTour !== activeIdRef.current\n ? { id: urlTour, startIndex: stepOf(new URLSearchParams(search), aliases ? aliases.split(\"\\n\") : []) }\n : null;\n }\n const pending = pendingRef.current;\n if (!pending || !ready) return;\n pendingRef.current = null;\n launchingRef.current = true;\n void Promise.resolve()\n .then(() => launchRef.current(pending.id, { startIndex: pending.startIndex }))\n .catch(() => undefined)\n .finally(() => {\n launchingRef.current = false;\n setSettled((n) => n + 1);\n });\n // Only a change of the parameter, or readiness, starts a tour.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [urlTour, ready]);\n\n useEffect(() => {\n if (navigationInFlight(history, dataRouter, { pathname, search, hash })) return;\n // A link not yet used keeps its parameters: a reload in that window resumes.\n if (pendingRef.current || launchingRef.current) return;\n const tourId = active && activeId ? activeId : null;\n const own = [\"tour\", \"tourStep\", ...(aliases ? aliases.split(\"\\n\") : [])];\n const current = new URLSearchParams(search);\n // Nothing to mirror and nothing to strip: never touch the URL (a no-op replace\n // clobbers a page's own just-issued navigation, keksdose feedback #4).\n if (!tourId && !own.some((key) => current.has(key))) return;\n const next = new URLSearchParams(search);\n // `set` keeps a parameter where it stands; only the aliases (and, at the end, the\n // tour's own) go.\n for (const key of tourId ? own.slice(2) : own) next.delete(key);\n if (tourId) {\n next.set(\"tour\", tourId);\n next.set(\"tourStep\", String(index + 1));\n }\n if (next.toString() === current.toString()) return;\n // Spelled out, not `setSearchParams` (\"?…\" drops the hash, keksdose dev#495).\n void navigate({ pathname, search: next.toString(), hash }, { replace: true, state: location.state });\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [active, activeId, index, pathname, search, hash, settled, aliases]);\n}\n\n/* ── useTourCatalogueUrlState ───────────────────────────────────────────────── */\n\n/** The catalogue's state filter. */\nexport type TourStateFilter = \"all\" | \"todo\" | \"done\";\n\n/** The catalogue's filters: the search, the group (`null`: every group), the state. */\nexport interface TourCatalogueFilter {\n query: string;\n group: string | null;\n state: TourStateFilter;\n}\n\nconst STATES: readonly TourStateFilter[] = [\"all\", \"todo\", \"done\"];\n\n/**\n * The catalogue's filters in the URL (§2.8) — keksdose's `?q`, `?topic`, `?state`, each\n * written with `replace` (typing does not bury the Back button), the defaults as the\n * clean URL. Spread it onto the catalogue: `<TourCatalogue {...useTourCatalogueUrlState()} … />`.\n * `params` renames them (kastlan's `?group`). Requires a react-router Router.\n */\nexport function useTourCatalogueUrlState(\n params: { query?: string; group?: string; state?: string } = {},\n): TourCatalogueFilter & { onChange: (patch: Partial<TourCatalogueFilter>) => void } {\n const [filter, setFilter] = useSearchParamsState<TourCatalogueFilter>({\n query: { param: params.query ?? \"q\", default: \"\", history: \"replace\" },\n group: { param: params.group ?? \"topic\", default: null, history: \"replace\", parse: (raw) => raw || undefined },\n state: {\n param: params.state ?? \"state\",\n default: \"all\",\n history: \"replace\",\n parse: (raw) => STATES.find((x) => x === raw),\n },\n });\n // `group: null` is a value to the setter (it clears `?topic`); `undefined` leaves it.\n return { ...filter, onChange: setFilter };\n}\n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;AAAA,MACT,SAAS;AAAA,MACT,OAAO,CAAC,QAAQ,OAAO,KAAK,CAAC,MAAM,MAAM,GAAG;AAAA,IAC9C;AAAA,EACF,CAAC;AAED,SAAO,EAAE,GAAG,QAAQ,UAAU,UAAU;AAC1C;","names":[]}
package/dist/tour.d.ts CHANGED
@@ -1 +1,9 @@
1
1
  export * from "./tour/tour.js";
2
+ export { TourCatalogue, TourCatalogueCard, DEFAULT_TOUR_CATALOGUE_LABELS } from "./tour/tour-catalogue.js";
3
+ export type { TourCatalogueProps, TourCatalogueCardProps, TourCatalogueLabels } from "./tour/tour-catalogue.js";
4
+ export { isTourNew, isTourReset, isTourDone, doneCount, earnedPoints } from "./tour/tour-info.js";
5
+ export type { TourInfo, TourGroup, TourUpdate, TourCompletions } from "./tour/tour-info.js";
6
+ export { useTourProgress, resetTourProgress } from "./tour/use-tour-progress.js";
7
+ export type { UseTourProgressOptions, TourProgress } from "./tour/use-tour-progress.js";
8
+ export { useTourUrlSync, useTourCatalogueUrlState } from "./tour/use-tour-url-sync.js";
9
+ export type { UseTourUrlSyncOptions, TourCatalogueFilter, TourStateFilter } from "./tour/use-tour-url-sync.js";
package/dist/tour.js CHANGED
@@ -1,3 +1,21 @@
1
1
  "use client";
2
2
  export * from "./tour/tour.js";
3
+ import { TourCatalogue, TourCatalogueCard, DEFAULT_TOUR_CATALOGUE_LABELS } from "./tour/tour-catalogue.js";
4
+ import { isTourNew, isTourReset, isTourDone, doneCount, earnedPoints } from "./tour/tour-info.js";
5
+ import { useTourProgress, resetTourProgress } from "./tour/use-tour-progress.js";
6
+ import { useTourUrlSync, useTourCatalogueUrlState } from "./tour/use-tour-url-sync.js";
7
+ export {
8
+ DEFAULT_TOUR_CATALOGUE_LABELS,
9
+ TourCatalogue,
10
+ TourCatalogueCard,
11
+ doneCount,
12
+ earnedPoints,
13
+ isTourDone,
14
+ isTourNew,
15
+ isTourReset,
16
+ resetTourProgress,
17
+ useTourCatalogueUrlState,
18
+ useTourProgress,
19
+ useTourUrlSync
20
+ };
3
21
  //# sourceMappingURL=tour.js.map
package/dist/tour.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/tour.ts"],"sourcesContent":["// `@eifi1/ui-kit/tour` — guided tours.\n// A re-slicing of the main barrel, not a new API.\nexport * from \"./tour/tour\";\n"],"mappings":";AAEA,cAAc;","names":[]}
1
+ {"version":3,"sources":["../src/tour.ts"],"sourcesContent":["// `@eifi1/ui-kit/tour` — guided tours.\n// A re-slicing of the main barrel, not a new API.\nexport * from \"./tour/tour\";\n// 0.43.0: the tours page (docs/tours-harmonization.md §3, §8) — keksdose's catalogue, its\n// card, the NEW and reset rules, device progress and the URL. `useTourUrlSync` and\n// `useTourCatalogueUrlState` need react-router (a peer already, for /shell).\nexport { TourCatalogue, TourCatalogueCard, DEFAULT_TOUR_CATALOGUE_LABELS } from \"./tour/tour-catalogue\";\nexport type { TourCatalogueProps, TourCatalogueCardProps, TourCatalogueLabels } from \"./tour/tour-catalogue\";\nexport { isTourNew, isTourReset, isTourDone, doneCount, earnedPoints } from \"./tour/tour-info\";\nexport type { TourInfo, TourGroup, TourUpdate, TourCompletions } from \"./tour/tour-info\";\nexport { useTourProgress, resetTourProgress } from \"./tour/use-tour-progress\";\nexport type { UseTourProgressOptions, TourProgress } from \"./tour/use-tour-progress\";\nexport { useTourUrlSync, useTourCatalogueUrlState } from \"./tour/use-tour-url-sync\";\nexport type { UseTourUrlSyncOptions, TourCatalogueFilter, TourStateFilter } from \"./tour/use-tour-url-sync\";\n"],"mappings":";AAEA,cAAc;AAId,SAAS,eAAe,mBAAmB,qCAAqC;AAEhF,SAAS,WAAW,aAAa,YAAY,WAAW,oBAAoB;AAE5E,SAAS,iBAAiB,yBAAyB;AAEnD,SAAS,gBAAgB,gCAAgC;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eifi1/ui-kit",
3
- "version": "0.42.0",
3
+ "version": "0.43.0",
4
4
  "type": "module",
5
5
  "description": "App-agnostic shared design system: domain-free React components, theme and tokens.",
6
6
  "_sideEffects": "The barrel (src/index.ts) re-exports EVERY component, including components/chart, which statically imports recharts. Without this field a bundler must assume each of those modules has side effects, so it cannot drop the unused ones: importing a Button from '@eifi1/ui-kit' dragged all 433KB of recharts into the consumer's ENTRY chunk, and Keksdose was preloading it on every page load, login included. Nothing in src/ imports for side effects (no bare imports, no CSS imports from JS, no module-level global writes) — the token stylesheet is its own './tokens.css' export — so this is safe. CSS is still listed so any future stylesheet survives. Re-checked when `flag-icons` left `dependencies` and tsup started emitting a `\"use client\"` banner: neither touches this. The flag stylesheet was never imported from JS in the first place (that was the finding), and a directive prologue is a string literal every bundler lifts out before it decides whether a module is inert.",