@jant/core 0.6.12 → 0.6.14

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 (120) hide show
  1. package/bin/commands/import-site.js +2 -10
  2. package/bin/commands/migrate-text-attachments.js +1 -3
  3. package/bin/commands/site/export.js +1 -3
  4. package/bin/commands/telegram/register-webhooks.js +9 -3
  5. package/bin/lib/site-snapshot.js +1 -5
  6. package/dist/{app-D-zAhayc.js → app-2i7-WQHg.js} +426 -450
  7. package/dist/app-DZDlmh7C.js +6 -0
  8. package/dist/client/.vite/manifest.json +3 -3
  9. package/dist/client/_assets/{client-S1cdvulk.js → client-BvID5ucz.js} +1 -1
  10. package/dist/client/_assets/client-Cevfpm8H.css +2 -0
  11. package/dist/client/_assets/{client-auth-YW92ZH7u.js → client-auth-v3yvhbgZ.js} +596 -590
  12. package/dist/{export-Ckwh4BiE.js → export-DWn149b7.js} +24 -19
  13. package/dist/{github-sync-BMmK3JZ0.js → github-sync-C0zyF6XS.js} +2 -2
  14. package/dist/{github-sync-Dl9wQMar.js → github-sync-Ckk0sJxK.js} +1 -1
  15. package/dist/index.js +3 -3
  16. package/dist/node.js +4 -4
  17. package/package.json +1 -1
  18. package/src/__tests__/export-service.test.ts +1 -2
  19. package/src/__tests__/helpers/app.ts +3 -0
  20. package/src/__tests__/helpers/export-fixtures.ts +0 -1
  21. package/src/__tests__/import-site-command.test.ts +1 -2
  22. package/src/client/__tests__/site-header-nav.test.ts +36 -2
  23. package/src/client/components/__tests__/compose-title-from-heading.test.ts +57 -0
  24. package/src/client/components/__tests__/jant-command-palette.test.ts +137 -10
  25. package/src/client/components/__tests__/jant-compose-dialog.test.ts +3 -0
  26. package/src/client/components/__tests__/jant-compose-editor.test.ts +94 -2
  27. package/src/client/components/__tests__/jant-nav-manager.test.ts +107 -22
  28. package/src/client/components/__tests__/jant-settings-general.test.ts +1 -0
  29. package/src/client/components/compose-title-from-heading.ts +66 -0
  30. package/src/client/components/compose-types.ts +8 -0
  31. package/src/client/components/inline-image-issues.ts +17 -0
  32. package/src/client/components/jant-command-palette.ts +100 -70
  33. package/src/client/components/jant-compose-dialog.ts +3 -1
  34. package/src/client/components/jant-compose-editor.ts +78 -1
  35. package/src/client/components/jant-compose-fullscreen.ts +2 -0
  36. package/src/client/components/jant-nav-manager.ts +245 -155
  37. package/src/client/components/nav-manager-types.ts +0 -10
  38. package/src/client/site-header-nav.d.ts +1 -0
  39. package/src/client/site-header-nav.js +105 -47
  40. package/src/client/tiptap/__tests__/block-insertion.test.ts +35 -0
  41. package/src/client/tiptap/__tests__/footnotes.test.ts +284 -0
  42. package/src/client/tiptap/__tests__/image-input-rules.test.ts +117 -0
  43. package/src/client/tiptap/__tests__/markdown-clipboard.test.ts +148 -1
  44. package/src/client/tiptap/bubble-menu.ts +3 -3
  45. package/src/client/tiptap/create-editor.ts +7 -0
  46. package/src/client/tiptap/extensions.ts +7 -2
  47. package/src/client/tiptap/footnotes.ts +156 -0
  48. package/src/client/tiptap/image-input-rules.ts +48 -0
  49. package/src/client/tiptap/image-node.ts +189 -7
  50. package/src/client/tiptap/markdown-clipboard.ts +7 -2
  51. package/src/client-auth.ts +0 -1
  52. package/src/i18n/locales/public/en.po +20 -4
  53. package/src/i18n/locales/public/en.ts +1 -1
  54. package/src/i18n/locales/public/zh-Hans.po +20 -4
  55. package/src/i18n/locales/public/zh-Hans.ts +1 -1
  56. package/src/i18n/locales/public/zh-Hant.po +20 -4
  57. package/src/i18n/locales/public/zh-Hant.ts +1 -1
  58. package/src/i18n/locales/settings/en.po +23 -20
  59. package/src/i18n/locales/settings/en.ts +1 -1
  60. package/src/i18n/locales/settings/zh-Hans.po +23 -20
  61. package/src/i18n/locales/settings/zh-Hans.ts +1 -1
  62. package/src/i18n/locales/settings/zh-Hant.po +23 -20
  63. package/src/i18n/locales/settings/zh-Hant.ts +1 -1
  64. package/src/lib/__tests__/markdown-to-tiptap.test.ts +4 -0
  65. package/src/lib/__tests__/navigation.test.ts +4 -37
  66. package/src/lib/__tests__/resolve-config.test.ts +6 -1
  67. package/src/lib/__tests__/view.test.ts +6 -30
  68. package/src/lib/github-sync-site-config.ts +0 -2
  69. package/src/lib/hugo-markdown.ts +1 -1
  70. package/src/lib/markdown-manager.ts +14 -5
  71. package/src/lib/navigation.ts +5 -22
  72. package/src/lib/resolve-config.ts +9 -2
  73. package/src/lib/site-header-fragment.tsx +37 -0
  74. package/src/lib/view.ts +2 -7
  75. package/src/node/__tests__/cli-site-snapshot.test.ts +45 -45
  76. package/src/routes/api/__tests__/nav-items.test.ts +26 -0
  77. package/src/routes/api/export.ts +0 -2
  78. package/src/routes/api/internal/__tests__/uploads.test.ts +9 -13
  79. package/src/routes/api/internal/sites.ts +5 -5
  80. package/src/routes/api/nav-items.ts +25 -4
  81. package/src/routes/dash/settings.tsx +8 -2
  82. package/src/routes/feed/__tests__/feed.test.ts +42 -0
  83. package/src/routes/feed/__tests__/sitemap.test.ts +2 -13
  84. package/src/routes/feed/feed.ts +1 -0
  85. package/src/routes/feed/sitemap.ts +2 -6
  86. package/src/routes/pages/archive.tsx +1 -0
  87. package/src/routes/pages/collection.tsx +1 -0
  88. package/src/routes/pages/featured.tsx +0 -4
  89. package/src/routes/pages/home.tsx +4 -51
  90. package/src/routes/pages/latest.tsx +2 -51
  91. package/src/services/__tests__/github-app-installations.test.ts +10 -10
  92. package/src/services/__tests__/navigation.test.ts +41 -0
  93. package/src/services/__tests__/post-timeline.test.ts +56 -0
  94. package/src/services/__tests__/post.test.ts +33 -0
  95. package/src/services/__tests__/settings.test.ts +5 -20
  96. package/src/services/export-theme/assets/client-site.js +10 -10
  97. package/src/services/export-theme/layouts/_default/rss.xml +5 -15
  98. package/src/services/export-theme/layouts/index.html +26 -39
  99. package/src/services/export.ts +5 -10
  100. package/src/services/github-app-installations.ts +1 -3
  101. package/src/services/navigation.ts +44 -13
  102. package/src/services/post.ts +80 -57
  103. package/src/services/settings.ts +0 -10
  104. package/src/services/site-admin.ts +0 -2
  105. package/src/services/upload-session.ts +4 -18
  106. package/src/styles/tokens.css +2 -2
  107. package/src/styles/ui.css +316 -34
  108. package/src/types/bindings.ts +0 -1
  109. package/src/types/config.ts +3 -7
  110. package/src/ui/compose/ComposeDialog.tsx +28 -0
  111. package/src/ui/dash/appearance/NavigationContent.tsx +1 -1
  112. package/src/ui/dash/settings/AccountMenuContent.tsx +2 -2
  113. package/src/ui/dash/settings/SettingsRootContent.tsx +3 -3
  114. package/src/ui/feed/__tests__/timeline-cards.test.ts +8 -3
  115. package/src/ui/layouts/BaseLayout.tsx +1 -1
  116. package/src/ui/layouts/SiteLayout.tsx +266 -227
  117. package/src/ui/layouts/__tests__/SiteLayout.test.tsx +48 -0
  118. package/dist/app-B5P1b4TF.js +0 -6
  119. package/dist/client/_assets/client-BUxR-E8O.css +0 -2
  120. package/src/client/nav-manager-bridge.ts +0 -54
@@ -119,6 +119,8 @@ export interface PostFilters {
119
119
  hasReplies?: boolean;
120
120
  /** Explicit result sort order */
121
121
  sortOrder?: SortOrder;
122
+ /** Ignore global pinned ordering when sorting subscription/feed results. */
123
+ ignorePinnedSort?: boolean;
122
124
  limit?: number;
123
125
  cursor?: string;
124
126
  offset?: number; // offset for page-based pagination
@@ -137,6 +139,11 @@ interface ThreadRootPageOptions {
137
139
  offset?: number;
138
140
  }
139
141
 
142
+ interface CollectionFeedEntryOptions extends ThreadRootPageOptions {
143
+ /** Ignore per-collection pinned ordering when sorting collection feeds. */
144
+ ignoreCollectionPinnedSort?: boolean;
145
+ }
146
+
140
147
  interface CollectionThreadRootPageOptions extends ThreadRootPageOptions {
141
148
  sortOrder?: CollectionSortOrder;
142
149
  }
@@ -314,12 +321,12 @@ export interface PostService {
314
321
  /** List collection feed entries ordered by latest added-at timestamp */
315
322
  listCollectionFeedEntries(
316
323
  collectionId: string,
317
- options?: ThreadRootPageOptions,
324
+ options?: CollectionFeedEntryOptions,
318
325
  ): Promise<CollectionFeedEntry[]>;
319
326
  /** List collection feed entries for a union of collections */
320
327
  listCollectionFeedEntriesForCollections(
321
328
  collectionIds: string[],
322
- options?: ThreadRootPageOptions,
329
+ options?: CollectionFeedEntryOptions,
323
330
  ): Promise<CollectionFeedEntry[]>;
324
331
  /** Fetch all published, non-deleted posts for each requested thread root */
325
332
  getPublishedThreads(rootIds: string[]): Promise<Map<string, Post[]>>;
@@ -902,76 +909,90 @@ export function createPostService(
902
909
  const cursorSortTimestamp = getCursorSortTimestamp(cursorPost);
903
910
  const cursorRatingPresence = cursorPost.rating === null ? 0 : 1;
904
911
  const cursorRating = cursorPost.rating ?? -1;
912
+ const withPinnedSortKey = (
913
+ keys: [CursorSortKey, ...CursorSortKey[]],
914
+ ): [CursorSortKey, ...CursorSortKey[]] =>
915
+ filters.ignorePinnedSort
916
+ ? keys
917
+ : [
918
+ { direction: "desc", expr: pinnedSortExpr, value: cursorPinnedAt },
919
+ ...keys,
920
+ ];
905
921
 
906
922
  if (filters.featured || filters.sortOrder === undefined) {
907
923
  if (filters.featured) {
908
- return buildLexicographicCursorCondition([
909
- { direction: "desc", expr: pinnedSortExpr, value: cursorPinnedAt },
924
+ return buildLexicographicCursorCondition(
925
+ withPinnedSortKey([
926
+ {
927
+ direction: "desc",
928
+ expr: featuredSortExpr,
929
+ value: cursorFeaturedAt,
930
+ },
931
+ { direction: "desc", expr: posts.id, value: cursorPost.id },
932
+ ]),
933
+ );
934
+ }
935
+
936
+ return buildLexicographicCursorCondition(
937
+ withPinnedSortKey([
910
938
  {
911
939
  direction: "desc",
912
- expr: featuredSortExpr,
913
- value: cursorFeaturedAt,
940
+ expr: sortTimestampSortExpr,
941
+ value: cursorSortTimestamp,
914
942
  },
915
943
  { direction: "desc", expr: posts.id, value: cursorPost.id },
916
- ]);
917
- }
918
-
919
- return buildLexicographicCursorCondition([
920
- { direction: "desc", expr: pinnedSortExpr, value: cursorPinnedAt },
921
- {
922
- direction: "desc",
923
- expr: sortTimestampSortExpr,
924
- value: cursorSortTimestamp,
925
- },
926
- { direction: "desc", expr: posts.id, value: cursorPost.id },
927
- ]);
944
+ ]),
945
+ );
928
946
  }
929
947
 
930
948
  if (filters.sortOrder === "oldest") {
931
- return buildLexicographicCursorCondition([
932
- { direction: "desc", expr: pinnedSortExpr, value: cursorPinnedAt },
933
- {
934
- direction: "asc",
935
- expr: sortTimestampSortExpr,
936
- value: cursorSortTimestamp,
937
- },
938
- { direction: "asc", expr: posts.id, value: cursorPost.id },
939
- ]);
949
+ return buildLexicographicCursorCondition(
950
+ withPinnedSortKey([
951
+ {
952
+ direction: "asc",
953
+ expr: sortTimestampSortExpr,
954
+ value: cursorSortTimestamp,
955
+ },
956
+ { direction: "asc", expr: posts.id, value: cursorPost.id },
957
+ ]),
958
+ );
940
959
  }
941
960
 
942
961
  if (filters.sortOrder === "rating_desc") {
943
- return buildLexicographicCursorCondition([
944
- { direction: "desc", expr: pinnedSortExpr, value: cursorPinnedAt },
962
+ return buildLexicographicCursorCondition(
963
+ withPinnedSortKey([
964
+ {
965
+ direction: "desc",
966
+ expr: ratingPresenceExpr,
967
+ value: cursorRatingPresence,
968
+ },
969
+ { direction: "desc", expr: ratingSortExpr, value: cursorRating },
970
+ {
971
+ direction: "desc",
972
+ expr: sortTimestampSortExpr,
973
+ value: cursorSortTimestamp,
974
+ },
975
+ { direction: "desc", expr: posts.id, value: cursorPost.id },
976
+ ]),
977
+ );
978
+ }
979
+
980
+ return buildLexicographicCursorCondition(
981
+ withPinnedSortKey([
945
982
  {
946
983
  direction: "desc",
947
984
  expr: ratingPresenceExpr,
948
985
  value: cursorRatingPresence,
949
986
  },
950
- { direction: "desc", expr: ratingSortExpr, value: cursorRating },
987
+ { direction: "asc", expr: ratingSortExpr, value: cursorRating },
951
988
  {
952
989
  direction: "desc",
953
990
  expr: sortTimestampSortExpr,
954
991
  value: cursorSortTimestamp,
955
992
  },
956
993
  { direction: "desc", expr: posts.id, value: cursorPost.id },
957
- ]);
958
- }
959
-
960
- return buildLexicographicCursorCondition([
961
- { direction: "desc", expr: pinnedSortExpr, value: cursorPinnedAt },
962
- {
963
- direction: "desc",
964
- expr: ratingPresenceExpr,
965
- value: cursorRatingPresence,
966
- },
967
- { direction: "asc", expr: ratingSortExpr, value: cursorRating },
968
- {
969
- direction: "desc",
970
- expr: sortTimestampSortExpr,
971
- value: cursorSortTimestamp,
972
- },
973
- { direction: "desc", expr: posts.id, value: cursorPost.id },
974
- ]);
994
+ ]),
995
+ );
975
996
  }
976
997
 
977
998
  function toPost(
@@ -1328,6 +1349,9 @@ export function createPostService(
1328
1349
  const pinnedSortExpr = sql<number>`coalesce(${posts.pinnedAt}, -1)`;
1329
1350
  const featuredSortExpr = sql<number>`coalesce(${posts.featuredAt}, -1)`;
1330
1351
  const sortTimestampSortExpr = sql<number>`coalesce(${sortTimestamp}, -1)`;
1352
+ const pinnedOrder = filters.ignorePinnedSort
1353
+ ? []
1354
+ : [desc(pinnedSortExpr)];
1331
1355
 
1332
1356
  const baseQuery = db
1333
1357
  .select()
@@ -1338,7 +1362,7 @@ export function createPostService(
1338
1362
  let query =
1339
1363
  filters.featured || filters.sortOrder === undefined
1340
1364
  ? baseQuery.orderBy(
1341
- desc(pinnedSortExpr),
1365
+ ...pinnedOrder,
1342
1366
  filters.featured
1343
1367
  ? desc(featuredSortExpr)
1344
1368
  : desc(sortTimestampSortExpr),
@@ -1346,20 +1370,20 @@ export function createPostService(
1346
1370
  )
1347
1371
  : filters.sortOrder === "oldest"
1348
1372
  ? baseQuery.orderBy(
1349
- desc(pinnedSortExpr),
1373
+ ...pinnedOrder,
1350
1374
  asc(sortTimestampSortExpr),
1351
1375
  asc(posts.id),
1352
1376
  )
1353
1377
  : filters.sortOrder === "rating_desc"
1354
1378
  ? baseQuery.orderBy(
1355
- desc(pinnedSortExpr),
1379
+ ...pinnedOrder,
1356
1380
  desc(ratingPresence),
1357
1381
  desc(posts.rating),
1358
1382
  desc(sortTimestampSortExpr),
1359
1383
  desc(posts.id),
1360
1384
  )
1361
1385
  : baseQuery.orderBy(
1362
- desc(pinnedSortExpr),
1386
+ ...pinnedOrder,
1363
1387
  desc(ratingPresence),
1364
1388
  asc(posts.rating),
1365
1389
  desc(sortTimestampSortExpr),
@@ -2950,6 +2974,9 @@ export function createPostService(
2950
2974
  sql<number>`MAX(coalesce(${postCollections.pinnedAt}, -1))`.as(
2951
2975
  "collection_pinned_at",
2952
2976
  );
2977
+ const pinnedOrder = options.ignoreCollectionPinnedSort
2978
+ ? []
2979
+ : [desc(collectionPinnedAt)];
2953
2980
 
2954
2981
  let query = db
2955
2982
  .select({
@@ -2968,11 +2995,7 @@ export function createPostService(
2968
2995
  )
2969
2996
  .where(and(...conditions))
2970
2997
  .groupBy(posts.threadId)
2971
- .orderBy(
2972
- desc(collectionPinnedAt),
2973
- desc(threadActivityAt),
2974
- desc(posts.threadId),
2975
- );
2998
+ .orderBy(...pinnedOrder, desc(threadActivityAt), desc(posts.threadId));
2976
2999
 
2977
3000
  if (options.limit !== undefined) {
2978
3001
  query = query.limit(options.limit) as typeof query;
@@ -46,7 +46,6 @@ export interface GeneralSettingsData {
46
46
  dashboardLanguage?: string;
47
47
  cjkSerifFont: string;
48
48
  showJantBrandingOnHome: boolean;
49
- homeDefaultView?: FeedKind;
50
49
  mainRssFeed?: FeedKind;
51
50
  timeZone: string;
52
51
  }
@@ -404,15 +403,6 @@ export function createSettingsService(
404
403
  oldCjkSerifFont: opts.oldCjkSerifFont,
405
404
  });
406
405
 
407
- // Homepage default view: only update if provided (may be managed separately)
408
- if (data.homeDefaultView !== undefined) {
409
- if (data.homeDefaultView === "featured") {
410
- await this.set("HOME_DEFAULT_VIEW", data.homeDefaultView);
411
- } else {
412
- await this.remove("HOME_DEFAULT_VIEW");
413
- }
414
- }
415
-
416
406
  await this.updateFeedSettings({ mainRssFeed: data.mainRssFeed });
417
407
 
418
408
  return {
@@ -15,7 +15,6 @@ import { SETTINGS_KEYS } from "../lib/constants.js";
15
15
  import { ConflictError, NotFoundError } from "../lib/errors.js";
16
16
  import { createEntityId } from "../lib/ids.js";
17
17
  import { getConfiguredSingleSiteUrl } from "../lib/env.js";
18
- import { getHomeDefaultViewFromNavItems } from "../lib/navigation.js";
19
18
  import { resolveConfig } from "../lib/resolve-config.js";
20
19
  import { buildThemeStyle } from "../lib/theme.js";
21
20
  import { now } from "../lib/time.js";
@@ -793,7 +792,6 @@ export function createSiteAdminService(
793
792
  siteDescription: appConfig.siteDescription,
794
793
  siteLanguage: appConfig.siteLanguage,
795
794
  showJantBrandingOnHome: appConfig.showJantBrandingOnHome,
796
- homeDefaultView: getHomeDefaultViewFromNavItems(navItemList),
797
795
  mainRssFeed: appConfig.mainRssFeed,
798
796
  siteFooter: appConfig.siteFooter,
799
797
  showHeaderAvatar: appConfig.showHeaderAvatar,
@@ -52,10 +52,6 @@ const RELAY_MULTIPART_THRESHOLD = 95 * 1024 * 1024;
52
52
  const RELAY_MULTIPART_PART_SIZE = 50 * 1024 * 1024;
53
53
  const IMMUTABLE_CACHE_CONTROL = "public, max-age=31536000, immutable";
54
54
  const DEFAULT_EXPIRED_UPLOAD_CLEANUP_LIMIT = 20;
55
- // Grace window before a finalized-but-unattached media row (uploaded during
56
- // compose, `postId IS NULL`) is reaped. Generous enough that an in-progress
57
- // compose/edit is never affected; based on `createdAt`, no heartbeat needed.
58
- const ORPHAN_MEDIA_GRACE_SECONDS = 7 * 24 * 60 * 60;
59
55
  type CleanupableUploadSessionState = "pending" | "uploaded" | "failed";
60
56
  const CLEANUPABLE_UPLOAD_SESSION_STATES = [
61
57
  "pending",
@@ -766,19 +762,6 @@ export function createUploadSessionService(
766
762
  deletedSessions += 1;
767
763
  }
768
764
 
769
- // Reap finalized media that was uploaded during compose but never
770
- // attached to a post (`postId IS NULL`) past the grace window. This now
771
- // soft-deletes via the media service: the DB row is removed and the
772
- // storage object is enqueued for deferred deletion. Bounded by the same
773
- // per-run `limit`; any backlog drains over subsequent runs.
774
- const orphanIds = await media.listOrphanedMediaIds({
775
- before: now() - ORPHAN_MEDIA_GRACE_SECONDS,
776
- limit,
777
- });
778
- if (orphanIds.length > 0) {
779
- await media.deleteByIds(orphanIds, deps.storage);
780
- }
781
-
782
765
  // Physically delete storage objects whose recycle window has elapsed.
783
766
  // Skips any object a live media row still references (re-uploads).
784
767
  const purgedStorageObjects = await media.purgeDueStorageObjects(
@@ -789,7 +772,10 @@ export function createUploadSessionService(
789
772
  return {
790
773
  abortedMultipartUploads,
791
774
  deletedSessions,
792
- deletedOrphanMedia: orphanIds.length,
775
+ // Retained for response compatibility. Finalized media may be referenced
776
+ // from post bodies without a `media.post_id`, so upload cleanup must not
777
+ // infer liveness from attachment state.
778
+ deletedOrphanMedia: 0,
793
779
  purgedStorageObjects,
794
780
  };
795
781
  },
@@ -114,9 +114,9 @@
114
114
  --type-body-leading: 1.7;
115
115
  --type-display-leading: 1.15;
116
116
  --type-heading-leading: 1.15;
117
- --type-heading-weight: var(--fw-regular);
117
+ --type-heading-weight: var(--fw-medium);
118
118
  --type-heading-tracking: 0;
119
- --type-display-weight: var(--fw-regular);
119
+ --type-display-weight: var(--fw-medium);
120
120
  --type-display-tracking: 0;
121
121
  --type-label-weight: var(--fw-medium);
122
122
  --type-label-tracking: 0.08em;