@jant/core 1.2.0 → 1.4.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 (150) hide show
  1. package/bin/commands/site/import.js +2 -1
  2. package/dist/{app-CbOZ2Irh.js → app-BuzORSgm.js} +1441 -686
  3. package/dist/client/.vite/manifest.json +72 -83
  4. package/dist/client/_assets/chunks/{confirm-CMe01lne.js → confirm-BQebcuNB.js} +1 -1
  5. package/dist/client/_assets/chunks/{create-editor-hWapNE40.js → create-editor-B8KuszlS.js} +38 -38
  6. package/dist/client/_assets/chunks/footnote-rail-DUrqz0Py.js +2 -0
  7. package/dist/client/_assets/chunks/{jant-locale-picker-2L4rkDaz.js → jant-locale-picker-CLq0iKDH.js} +1 -1
  8. package/dist/client/_assets/chunks/lit-BN4mrI3j.js +2 -0
  9. package/dist/client/_assets/chunks/{settings-paths-BBVT8zKj.js → settings-paths-_fry4yWW.js} +1 -1
  10. package/dist/client/_assets/chunks/{slug-format-BuCPjSrB.js → slug-format-bcJ2ozr4.js} +1 -1
  11. package/dist/client/_assets/chunks/{sortable-list-DJXwkaOv.js → sortable-list-Bz2Na2E9.js} +2 -2
  12. package/dist/client/_assets/chunks/{unsafe-html-CWos3v6N.js → unsafe-html-OJ9m154w.js} +1 -1
  13. package/dist/client/_assets/chunks/unsafe-svg-DVJ4NPcb.js +1 -0
  14. package/dist/client/_assets/client-CStDm2xD.js +354 -0
  15. package/dist/client/_assets/{client-D8Rrsd73.css → client-CoNHvipV.css} +1 -1
  16. package/dist/client/_assets/{client-auth-CsUGM718.js → client-auth-D53R-Wby.js} +99 -129
  17. package/dist/client/_assets/client-author-2WYBkgni.css +2 -0
  18. package/dist/client/_assets/{client-compose-BB4U7Wz0.js → client-compose-DYtDlYm-.js} +248 -244
  19. package/dist/client/_assets/{client-manage-CI9-eh-8.js → client-manage-BODyYP5Z.js} +157 -157
  20. package/dist/client/_assets/{client-settings-BnGPuqwc.js → client-settings-DDpe_tXJ.js} +166 -166
  21. package/dist/client/_assets/client-share-B9OsXx9p.js +149 -0
  22. package/dist/{constants-DEgyqWDl.js → constants-C2CdWAqt.js} +55 -5
  23. package/dist/index.js +1 -1
  24. package/dist/node.js +2 -2
  25. package/package.json +2 -1
  26. package/src/client/components/compose-types.ts +5 -1
  27. package/src/client/components/jant-compose-dialog.ts +25 -4
  28. package/src/client/components/jant-media-lightbox.ts +18 -3
  29. package/src/client/components/jant-nav-manager.ts +2 -0
  30. package/src/client/components/jant-post-menu.ts +42 -89
  31. package/src/client/components/nav-manager-types.ts +2 -0
  32. package/src/client/components/settings-types.ts +1 -1
  33. package/src/client/list-views.ts +382 -0
  34. package/src/client/media-lightbox-events.ts +12 -0
  35. package/src/client/runtime-paths.ts +12 -0
  36. package/src/client/share-capture.ts +63 -0
  37. package/src/client/share-launch.ts +36 -9
  38. package/src/client/tiptap/create-editor.ts +4 -0
  39. package/src/client/tiptap/embed-node.ts +3 -1
  40. package/src/client/tiptap/html-block-node.ts +3 -1
  41. package/src/client/tiptap/image-node.ts +3 -1
  42. package/src/client/view-confirm.ts +32 -4
  43. package/src/client.ts +1 -0
  44. package/src/db/migrations/0037_round_post.sql +16 -0
  45. package/src/db/migrations/0038_flashy_changeling.sql +15 -0
  46. package/src/db/migrations/0039_mixed_sister_grimm.sql +1 -0
  47. package/src/db/migrations/meta/0037_snapshot.json +2932 -0
  48. package/src/db/migrations/meta/0038_snapshot.json +2924 -0
  49. package/src/db/migrations/meta/0039_snapshot.json +2931 -0
  50. package/src/db/migrations/meta/_journal.json +21 -0
  51. package/src/db/migrations/pg/0035_flimsy_outlaw_kid.sql +3 -0
  52. package/src/db/migrations/pg/0036_milky_wolverine.sql +5 -0
  53. package/src/db/migrations/pg/0037_fuzzy_hammerhead.sql +1 -0
  54. package/src/db/migrations/pg/meta/0035_snapshot.json +3773 -0
  55. package/src/db/migrations/pg/meta/0036_snapshot.json +3766 -0
  56. package/src/db/migrations/pg/meta/0037_snapshot.json +3772 -0
  57. package/src/db/migrations/pg/meta/_journal.json +21 -0
  58. package/src/db/pg/schema.ts +1 -0
  59. package/src/db/post-visibility.ts +37 -6
  60. package/src/db/schema.ts +5 -2
  61. package/src/i18n/locales/glossary.zh-Hans.yml +4 -0
  62. package/src/i18n/locales/glossary.zh-Hant.yml +4 -0
  63. package/src/i18n/locales/public/en.po +21 -90
  64. package/src/i18n/locales/public/en.ts +1 -1
  65. package/src/i18n/locales/public/zh-Hans.po +20 -89
  66. package/src/i18n/locales/public/zh-Hans.ts +1 -1
  67. package/src/i18n/locales/public/zh-Hant.po +20 -89
  68. package/src/i18n/locales/public/zh-Hant.ts +1 -1
  69. package/src/i18n/locales/settings/en.po +84 -0
  70. package/src/i18n/locales/settings/en.ts +1 -1
  71. package/src/i18n/locales/settings/zh-Hans.po +130 -46
  72. package/src/i18n/locales/settings/zh-Hans.ts +1 -1
  73. package/src/i18n/locales/settings/zh-Hant.po +124 -40
  74. package/src/i18n/locales/settings/zh-Hant.ts +1 -1
  75. package/src/lib/api-public-posts.ts +10 -0
  76. package/src/lib/feed-policy.ts +2 -2
  77. package/src/lib/feed.ts +17 -1
  78. package/src/lib/filter-dimensions.ts +11 -4
  79. package/src/lib/hugo-markdown.ts +7 -0
  80. package/src/lib/icons.ts +2 -0
  81. package/src/lib/link-preview.ts +499 -0
  82. package/src/lib/list-views.ts +117 -0
  83. package/src/lib/markdown-manager.ts +40 -1
  84. package/src/lib/navigation.ts +1 -1
  85. package/src/lib/share-card.ts +4 -3
  86. package/src/lib/thread-query.ts +6 -2
  87. package/src/lib/timeline.ts +12 -11
  88. package/src/lib/url-fetch.ts +291 -74
  89. package/src/lib/view-buffer.ts +2 -2
  90. package/src/lib/view-counting.ts +7 -6
  91. package/src/lib/view-token.ts +29 -7
  92. package/src/lib/view.ts +17 -0
  93. package/src/middleware/view-counter.ts +10 -5
  94. package/src/preset.css +5 -3
  95. package/src/routes/api/search.ts +1 -1
  96. package/src/routes/dash/settings.tsx +1 -1
  97. package/src/routes/feed/sitemap.ts +1 -1
  98. package/src/routes/pages/archive.tsx +25 -19
  99. package/src/routes/pages/collection.tsx +3 -3
  100. package/src/routes/pages/page.tsx +16 -4
  101. package/src/routes/pages/search.tsx +3 -3
  102. package/src/routes/pages/subscribe.tsx +19 -3
  103. package/src/routes/view-confirm.ts +23 -15
  104. package/src/services/collection.ts +1 -1
  105. package/src/services/export-theme/assets/client-site.js +19 -19
  106. package/src/services/export-theme/layouts/archive/list.html +4 -2
  107. package/src/services/export-theme/layouts/partials/collection-members.html +4 -3
  108. package/src/services/export-theme/layouts/partials/featured-members.html +3 -3
  109. package/src/services/export-theme/layouts/partials/head.html +2 -0
  110. package/src/services/export-theme/layouts/partials/latest-members.html +4 -4
  111. package/src/services/export-theme/layouts/partials/post-card.html +1 -9
  112. package/src/services/export-theme/layouts/partials/reply.html +1 -9
  113. package/src/services/export-theme/layouts/partials/smart-collection-members.html +4 -3
  114. package/src/services/export-theme/layouts/post/list.html +1 -9
  115. package/src/services/export-theme/styles/main.css +2 -26
  116. package/src/services/export.ts +10 -3
  117. package/src/services/mcp.ts +5 -5
  118. package/src/services/navigation.ts +9 -4
  119. package/src/services/post.ts +102 -112
  120. package/src/services/search.ts +22 -7
  121. package/src/services/smart-collection.ts +3 -3
  122. package/src/services/stats.ts +12 -5
  123. package/src/services/thread.ts +6 -2
  124. package/src/styles/components-author.css +69 -7
  125. package/src/styles/tokens.css +28 -29
  126. package/src/styles/ui-author.css +140 -353
  127. package/src/styles/ui.css +34 -32
  128. package/src/types/constants.ts +68 -4
  129. package/src/types/entities.ts +1 -0
  130. package/src/types/views.ts +2 -0
  131. package/src/ui/compose/ComposeDialog.tsx +20 -1
  132. package/src/ui/dash/StatusBadge.tsx +11 -0
  133. package/src/ui/dash/appearance/FontThemeContent.tsx +1 -1
  134. package/src/ui/dash/appearance/NavigationContent.tsx +8 -0
  135. package/src/ui/dash/settings/StatsContent.tsx +29 -29
  136. package/src/ui/feed/LinkCard.tsx +19 -2
  137. package/src/ui/feed/PostStatusBadges.tsx +19 -3
  138. package/src/ui/feed/TimelineFeed.tsx +3 -0
  139. package/src/ui/font-themes.ts +32 -15
  140. package/src/ui/pages/ArchivePage.tsx +1 -0
  141. package/src/ui/pages/SubscribePage.tsx +9 -1
  142. package/src/ui/shared/PostFooter.tsx +1 -22
  143. package/src/ui/shared/custom-icons.ts +5 -5
  144. package/dist/client/_assets/chunks/footnote-rail-9zwl6jtV.js +0 -2
  145. package/dist/client/_assets/chunks/lit-Bw_voPoW.js +0 -2
  146. package/dist/client/_assets/chunks/runtime-paths-y0_gHowM.js +0 -1
  147. package/dist/client/_assets/chunks/unsafe-svg-CUrgo4Xg.js +0 -1
  148. package/dist/client/_assets/client-BO8GOFfT.js +0 -354
  149. package/dist/client/_assets/client-author-QPm1whbO.css +0 -2
  150. package/dist/client/_assets/client-share-C59mOLJ1.js +0 -149
@@ -12,6 +12,8 @@
12
12
  * The token names the page and where the reader came from, decided on the
13
13
  * server from the request; nothing about the reader is read here or sent.
14
14
  * No cookie, no storage, one request, and nothing waits for its answer.
15
+ * The Threads read in full in a list page's feed go out the same way, once
16
+ * the page is confirmed (`list-views.ts`).
15
17
  */
16
18
 
17
19
  import { publicPath } from "./runtime-paths.js";
@@ -20,7 +22,7 @@ import { publicPath } from "./runtime-paths.js";
20
22
  export const VIEW_CONFIRM_DWELL_MS = 5_000;
21
23
 
22
24
  /** Where the token goes; the same path `lib/view-token.ts` names. */
23
- const CONFIRM_PATH = "/_/seen";
25
+ export const CONFIRM_PATH = "/_/seen";
24
26
 
25
27
  /** Anything a reader does that a crawler fetching a page does not. */
26
28
  const INTERACTION_EVENTS = [
@@ -32,19 +34,44 @@ const INTERACTION_EVENTS = [
32
34
  "scroll",
33
35
  ] as const;
34
36
 
35
- function deliver(url: string, token: string): void {
37
+ /** Documents whose view has been confirmed. */
38
+ const confirmed = new WeakSet<globalThis.Document>();
39
+
40
+ /**
41
+ * Post a body to the site, surviving the page being closed: a beacon, or a
42
+ * `keepalive` fetch when the browser will not queue one.
43
+ *
44
+ * @param url - Where to post
45
+ * @param body - The plain-text body
46
+ * @returns Nothing; nothing waits for the answer
47
+ * @example
48
+ * deliver(publicPath(CONFIRM_PATH), token);
49
+ */
50
+ export function deliver(url: string, body: string): void {
36
51
  const sent =
37
52
  typeof navigator.sendBeacon === "function" &&
38
- navigator.sendBeacon(url, new Blob([token], { type: "text/plain" }));
53
+ navigator.sendBeacon(url, new Blob([body], { type: "text/plain" }));
39
54
  if (sent) return;
40
55
  void fetch(url, {
41
56
  method: "POST",
42
- body: token,
57
+ body,
43
58
  keepalive: true,
44
59
  headers: { "content-type": "text/plain" },
45
60
  }).catch(() => {});
46
61
  }
47
62
 
63
+ /**
64
+ * Whether this document has confirmed its view.
65
+ *
66
+ * @param doc - The document, the current one unless a test passes another
67
+ * @returns `true` once the confirmation went out
68
+ * @example
69
+ * if (isViewConfirmed()) report();
70
+ */
71
+ export function isViewConfirmed(doc: globalThis.Document = document): boolean {
72
+ return confirmed.has(doc);
73
+ }
74
+
48
75
  /**
49
76
  * Arm the page's confirmation, if the page carries a token.
50
77
  *
@@ -89,6 +116,7 @@ export function confirmView(doc: globalThis.Document = document): void {
89
116
  doc.removeEventListener(event, send);
90
117
  }
91
118
  doc.removeEventListener("visibilitychange", onVisibility);
119
+ confirmed.add(doc);
92
120
  deliver(url, token);
93
121
  };
94
122
 
package/src/client.ts CHANGED
@@ -10,6 +10,7 @@ import { installPrefixedFetch } from "./client/runtime-paths.js";
10
10
  import "./client/audio-player.js";
11
11
  import "./client/feed-video-player.js";
12
12
  import "./client/view-confirm.js";
13
+ import "./client/list-views.js";
13
14
  import "./client/media-scroll-hint.js";
14
15
  import "./client/form-enter-submit.js";
15
16
  import "./client/copy-field.js";
@@ -0,0 +1,16 @@
1
+ PRAGMA foreign_keys=OFF;--> statement-breakpoint
2
+ CREATE TABLE `__new_view_count` (
3
+ `site_id` text NOT NULL,
4
+ `day` text NOT NULL,
5
+ `page` text NOT NULL,
6
+ `referrer` text NOT NULL,
7
+ `via` text DEFAULT 'page' NOT NULL,
8
+ `count` integer DEFAULT 0 NOT NULL,
9
+ PRIMARY KEY(`site_id`, `day`, `page`, `referrer`, `via`),
10
+ FOREIGN KEY (`site_id`) REFERENCES `site`(`id`) ON UPDATE no action ON DELETE cascade
11
+ );
12
+ --> statement-breakpoint
13
+ INSERT INTO `__new_view_count`("site_id", "day", "page", "referrer", "count") SELECT "site_id", "day", "page", "referrer", "count" FROM `view_count`;--> statement-breakpoint
14
+ DROP TABLE `view_count`;--> statement-breakpoint
15
+ ALTER TABLE `__new_view_count` RENAME TO `view_count`;--> statement-breakpoint
16
+ PRAGMA foreign_keys=ON;
@@ -0,0 +1,15 @@
1
+ PRAGMA foreign_keys=OFF;--> statement-breakpoint
2
+ CREATE TABLE `__new_view_count` (
3
+ `site_id` text NOT NULL,
4
+ `day` text NOT NULL,
5
+ `page` text NOT NULL,
6
+ `referrer` text NOT NULL,
7
+ `count` integer DEFAULT 0 NOT NULL,
8
+ PRIMARY KEY(`site_id`, `day`, `page`, `referrer`),
9
+ FOREIGN KEY (`site_id`) REFERENCES `site`(`id`) ON UPDATE no action ON DELETE cascade
10
+ );
11
+ --> statement-breakpoint
12
+ INSERT INTO `__new_view_count`("site_id", "day", "page", "referrer", "count") SELECT "site_id", "day", "page", "referrer", SUM("count") FROM `view_count` GROUP BY "site_id", "day", "page", "referrer";--> statement-breakpoint
13
+ DROP TABLE `view_count`;--> statement-breakpoint
14
+ ALTER TABLE `__new_view_count` RENAME TO `view_count`;--> statement-breakpoint
15
+ PRAGMA foreign_keys=ON;
@@ -0,0 +1 @@
1
+ ALTER TABLE `post` ADD `preview_icon_key` text;