@igstack/app-catalog-frontend-core 6.12.0 → 6.12.2

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 (63) hide show
  1. package/dist/esm/api/infra/trpc.d.ts +27 -0
  2. package/dist/esm/internal.d.ts +1 -0
  3. package/dist/esm/modules/appCatalog/ui/catalog/AppDetailPanel.js +0 -1
  4. package/dist/esm/modules/appCatalog/ui/catalog/AppDetailPanel.js.map +1 -1
  5. package/dist/esm/modules/appCatalog/ui/detail/AppDetails.js +0 -1
  6. package/dist/esm/modules/appCatalog/ui/detail/AppDetails.js.map +1 -1
  7. package/dist/esm/modules/communityTools/communityToolsConfigLoader.d.ts +11 -0
  8. package/dist/esm/modules/communityTools/communityToolsConfigLoader.js +38 -0
  9. package/dist/esm/modules/communityTools/communityToolsConfigLoader.js.map +1 -0
  10. package/dist/esm/modules/communityTools/siteOpen.d.ts +10 -0
  11. package/dist/esm/modules/communityTools/siteOpen.js +18 -0
  12. package/dist/esm/modules/communityTools/siteOpen.js.map +1 -0
  13. package/dist/esm/modules/communityTools/timeAgo.d.ts +2 -0
  14. package/dist/esm/modules/communityTools/timeAgo.js +11 -0
  15. package/dist/esm/modules/communityTools/timeAgo.js.map +1 -1
  16. package/dist/esm/modules/communityTools/ui/CardScreenshot.js +10 -12
  17. package/dist/esm/modules/communityTools/ui/CardScreenshot.js.map +1 -1
  18. package/dist/esm/modules/communityTools/ui/CardTitleBlock.d.ts +1 -1
  19. package/dist/esm/modules/communityTools/ui/CardTitleBlock.js +5 -13
  20. package/dist/esm/modules/communityTools/ui/CardTitleBlock.js.map +1 -1
  21. package/dist/esm/modules/communityTools/ui/CommunityPage.js +2 -4
  22. package/dist/esm/modules/communityTools/ui/CommunityPage.js.map +1 -1
  23. package/dist/esm/modules/communityTools/ui/FeedRow.d.ts +6 -3
  24. package/dist/esm/modules/communityTools/ui/FeedRow.js +14 -8
  25. package/dist/esm/modules/communityTools/ui/FeedRow.js.map +1 -1
  26. package/dist/esm/modules/communityTools/ui/ShelfTile.js +4 -7
  27. package/dist/esm/modules/communityTools/ui/ShelfTile.js.map +1 -1
  28. package/dist/esm/modules/communityTools/ui/ToolCard.js +15 -3
  29. package/dist/esm/modules/communityTools/ui/ToolCard.js.map +1 -1
  30. package/dist/esm/modules/communityTools/ui/ToolFormDialog.js +0 -1
  31. package/dist/esm/modules/communityTools/ui/ToolFormDialog.js.map +1 -1
  32. package/dist/esm/modules/communityTools/useCommunityTools.d.ts +2 -0
  33. package/dist/esm/modules/communityTools/useCommunityTools.js +0 -1
  34. package/dist/esm/modules/communityTools/useCommunityTools.js.map +1 -1
  35. package/dist/esm/routeTree.gen.d.ts +13 -13
  36. package/dist/esm/routes/_layout/app.$slug.d.ts +1 -1
  37. package/dist/esm/routes/_layout/app.$slug_.sub.$subSlug.d.ts +1 -1
  38. package/dist/esm/routes/_layout/catalog.apps.index.d.ts +2 -2
  39. package/dist/esm/routes/_layout/community.$slug.d.ts +1 -1
  40. package/dist/esm/routes/_layout/community.d.ts +1 -1
  41. package/dist/esm/routes/_layout/index.d.ts +1 -1
  42. package/dist/esm/routes/_layout/login.d.ts +1 -1
  43. package/dist/esm/routes/_layout/mcp.d.ts +1 -1
  44. package/dist/esm/routes/_layout/service-desks.d.ts +1 -1
  45. package/dist/esm/routes/_layout.d.ts +2 -1
  46. package/dist/esm/routes/_layout.js +3 -1
  47. package/dist/esm/routes/_layout.js.map +1 -1
  48. package/dist/esm/userDb/AcDb.d.ts +6 -2
  49. package/dist/esm/userDb/AcDb.js +6 -0
  50. package/dist/esm/userDb/AcDb.js.map +1 -1
  51. package/package.json +4 -4
  52. package/src/internal.ts +1 -0
  53. package/src/modules/communityTools/communityToolsConfigLoader.ts +56 -0
  54. package/src/modules/communityTools/siteOpen.ts +20 -0
  55. package/src/modules/communityTools/timeAgo.ts +12 -0
  56. package/src/modules/communityTools/ui/CardScreenshot.tsx +21 -9
  57. package/src/modules/communityTools/ui/CardTitleBlock.tsx +4 -9
  58. package/src/modules/communityTools/ui/CommunityPage.tsx +2 -5
  59. package/src/modules/communityTools/ui/FeedRow.tsx +19 -15
  60. package/src/modules/communityTools/ui/ShelfTile.tsx +4 -5
  61. package/src/modules/communityTools/ui/ToolCard.tsx +11 -1
  62. package/src/routes/_layout.tsx +2 -0
  63. package/src/userDb/AcDb.ts +15 -1
@@ -1,8 +1,9 @@
1
1
  import type { CommunityTool } from '@igstack/app-catalog-shared-core'
2
- import { Camera, ExternalLink, ImageOff, Maximize2 } from 'lucide-react'
2
+ import { Camera, ImageOff, Maximize2 } from 'lucide-react'
3
3
  import { useState } from 'react'
4
4
  import { ScreenshotGallery } from '~/modules/appCatalog/ui/components/ScreenshotGallery'
5
5
  import { cn } from '~/lib/utils'
6
+ import { recordSiteOpen } from '../siteOpen'
6
7
  import { screenshotUrl } from './FeedRow'
7
8
 
8
9
  /**
@@ -13,6 +14,10 @@ import { screenshotUrl } from './FeedRow'
13
14
  const BOX =
14
15
  'relative flex aspect-[16/10] max-h-[320px] w-full items-center justify-center overflow-hidden rounded-[14px] border border-border bg-muted shadow-sm'
15
16
 
17
+ /** The server's checks get no answer, so there is no fresh screenshot to show. */
18
+ const UNREACHABLE =
19
+ "Screenshot unavailable: the catalog's server can't reach this site."
20
+
16
21
  export function formatCardDate(iso: string): string {
17
22
  return new Date(iso).toLocaleDateString('en-GB', {
18
23
  day: 'numeric',
@@ -58,7 +63,11 @@ export function CardScreenshot({
58
63
  ) : (
59
64
  <>
60
65
  <ImageOff aria-hidden="true" className="size-7" />
61
- No screenshot. The site may need a login, or it did not load.
66
+ {tool.serverUnreachable ? (
67
+ <span data-testid="card-server-unreachable">{UNREACHABLE}</span>
68
+ ) : (
69
+ 'No screenshot. The site may need a login, or it did not load.'
70
+ )}
62
71
  </>
63
72
  )}
64
73
  </div>
@@ -78,9 +87,8 @@ export function CardScreenshot({
78
87
  >
79
88
  <a
80
89
  href={tool.url}
81
- target="_blank"
82
- rel="noopener noreferrer"
83
- aria-label={`Open ${tool.name} in a new tab`}
90
+ onClick={() => recordSiteOpen(tool.slug)}
91
+ aria-label={`Open ${tool.name}`}
84
92
  data-testid="card-screenshot-link"
85
93
  className="group/shot block size-full rounded-[14px] focus-visible:outline-2 focus-visible:-outline-offset-4 focus-visible:outline-ring"
86
94
  >
@@ -90,9 +98,8 @@ export function CardScreenshot({
90
98
  className="size-full object-cover object-left-top"
91
99
  />
92
100
  <span className="absolute inset-0 flex items-center justify-center bg-black/0 transition-colors group-focus-visible/shot:bg-black/20 group-hover/shot:bg-black/20">
93
- <span className="inline-flex items-center gap-1.5 rounded-lg bg-primary px-3.5 py-2 text-sm font-extrabold text-primary-foreground opacity-0 shadow-sm transition-opacity group-focus-visible/shot:opacity-100 group-hover/shot:opacity-100">
101
+ <span className="rounded-lg bg-primary px-3.5 py-2 text-sm font-extrabold text-primary-foreground opacity-0 shadow-sm transition-opacity group-focus-visible/shot:opacity-100 group-hover/shot:opacity-100">
94
102
  Open site
95
- <ExternalLink aria-hidden="true" className="size-4" />
96
103
  </span>
97
104
  </span>
98
105
  </a>
@@ -107,9 +114,14 @@ export function CardScreenshot({
107
114
  <Maximize2 aria-hidden="true" className="size-4" />
108
115
  </button>
109
116
  </div>
110
- {capturedAt && (
117
+ {(capturedAt || tool.serverUnreachable) && (
111
118
  <figcaption className="mt-2 text-[12.5px] font-semibold text-muted-foreground">
112
- Screenshot captured {formatCardDate(capturedAt)}
119
+ {capturedAt && `Screenshot captured ${formatCardDate(capturedAt)}`}
120
+ {tool.serverUnreachable && (
121
+ <span data-testid="card-server-unreachable" className="block">
122
+ {UNREACHABLE}
123
+ </span>
124
+ )}
113
125
  </figcaption>
114
126
  )}
115
127
  <ScreenshotGallery
@@ -1,20 +1,20 @@
1
1
  import type { CommunityTool } from '@igstack/app-catalog-shared-core'
2
- import { ExternalLink, Globe } from 'lucide-react'
2
+ import { Globe } from 'lucide-react'
3
3
  import { cn } from '~/lib/utils'
4
+ import { recordSiteOpen } from '../siteOpen'
4
5
  import { screenshotUrl } from './FeedRow'
5
6
  import { LifecycleBadge, UnreviewedBadge } from './LifecycleBadge'
6
7
 
7
8
  /**
8
9
  * The card's door: favicon (a globe when the site has none), name, badges and
9
- * address, all one link that opens the site in a new tab.
10
+ * address, all one link that opens the site.
10
11
  */
11
12
  export function CardTitleBlock({ tool }: { tool: CommunityTool }) {
12
13
  const archived = tool.lifecycle.state === 'archived'
13
14
  return (
14
15
  <a
15
16
  href={tool.url}
16
- target="_blank"
17
- rel="noopener noreferrer"
17
+ onClick={() => recordSiteOpen(tool.slug)}
18
18
  data-testid="card-title-block"
19
19
  className={cn(
20
20
  'group/door inline-flex min-w-0 items-center gap-[15px] rounded-[14px] border border-border bg-primary/[0.025] px-[17px] py-[11px] transition-colors',
@@ -47,12 +47,7 @@ export function CardTitleBlock({ tool }: { tool: CommunityTool }) {
47
47
  <span className="truncate font-mono text-[13px] text-muted-foreground">
48
48
  {tool.host}
49
49
  </span>
50
- <span className="sr-only">(opens in a new tab)</span>
51
50
  </span>
52
- <ExternalLink
53
- aria-hidden="true"
54
- className="size-[18px] shrink-0 self-start text-muted-foreground group-hover/door:text-primary"
55
- />
56
51
  </a>
57
52
  )
58
53
  }
@@ -29,6 +29,7 @@ import type { ToastMessage } from './Toast'
29
29
  import { ToolCard } from './ToolCard'
30
30
  import { ToolFormDialog } from './ToolFormDialog'
31
31
  import { ToolSearch } from './ToolSearch'
32
+ import { openSite } from '../siteOpen'
32
33
 
33
34
  const KBD =
34
35
  'rounded-[5px] border border-b-2 border-border bg-card px-1.5 py-px text-[11px] font-semibold text-muted-foreground'
@@ -56,10 +57,6 @@ function optionIdOf(slug: string): string {
56
57
  return `community-option-${slug}`
57
58
  }
58
59
 
59
- function openSite(url: string) {
60
- window.open(url, '_blank', 'noopener,noreferrer')
61
- }
62
-
63
60
  export function CommunityPage({
64
61
  tag,
65
62
  sort,
@@ -311,7 +308,7 @@ export function CommunityPage({
311
308
  )
312
309
  } else if (e.key === 'Enter' && current) {
313
310
  e.preventDefault()
314
- openSite(current.tool.url)
311
+ openSite(current.tool)
315
312
  } else if (
316
313
  e.key === 'ArrowRight' &&
317
314
  current &&
@@ -13,7 +13,8 @@ import {
13
13
  } from 'lucide-react'
14
14
  import { cn } from '~/lib/utils'
15
15
  import { highlightTokens } from '~/util/highlightMatches'
16
- import { timeAgo } from '../timeAgo'
16
+ import { recordSiteOpen } from '../siteOpen'
17
+ import { exactDate, timeAgo } from '../timeAgo'
17
18
  import { LifecycleBadge, UnreviewedBadge } from './LifecycleBadge'
18
19
  import { LikeButton } from './LikeButton'
19
20
  import { PinButton } from './PinButton'
@@ -96,7 +97,10 @@ export interface FeedRowProps {
96
97
  tool: CommunityTool
97
98
  /** Shown in the ranked feed; search results have no rank. */
98
99
  rank?: number
99
- /** Recently updated shows when the site changed; every other sort, when it was added. */
100
+ /**
101
+ * Newest shows when it was added, Recently updated when the site changed;
102
+ * every other sort the site's date, or when it was added if that is unknown.
103
+ */
100
104
  sort: FeedSort
101
105
  tokens: string[]
102
106
  /** Set while searching: which fields the query hit. */
@@ -122,8 +126,8 @@ const PANEL = 'w-[120px]'
122
126
 
123
127
  /**
124
128
  * One tool in the feed or the search results. Everything left of the end
125
- * panel (rank, picture, name, summary, meta) is one link that opens the site
126
- * in a new tab; the 120 px panel opens the card. The star sits in the meta
129
+ * panel (rank, picture, name, summary, meta) is one link that opens the
130
+ * site; the 120 px panel opens the card. The star sits in the meta
127
131
  * line as its own target, above that link.
128
132
  */
129
133
  export function FeedRow({
@@ -142,12 +146,12 @@ export function FeedRow({
142
146
  const archived = tool.lifecycle.state === 'archived'
143
147
  const cell = optionId ? 'gridcell' : undefined
144
148
  const owners = tool.owners.map((o) => o.name).join(', ')
145
- const dated =
146
- sort !== 'updated'
147
- ? `Added ${timeAgo(tool.createdAt)}`
148
- : tool.siteUpdatedAt
149
- ? `Updated ${timeAgo(tool.siteUpdatedAt)}`
150
- : null
149
+ const siteUpdatedAt = sort !== 'newest' ? tool.siteUpdatedAt : null
150
+ const dated = siteUpdatedAt
151
+ ? { label: 'Updated', at: siteUpdatedAt }
152
+ : sort !== 'updated'
153
+ ? { label: 'Added', at: tool.createdAt }
154
+ : null
151
155
 
152
156
  return (
153
157
  <div
@@ -182,11 +186,10 @@ export function FeedRow({
182
186
  <div className="flex items-center gap-2.5 text-[15.5px] font-extrabold">
183
187
  <a
184
188
  href={tool.url}
185
- target="_blank"
186
- rel="noopener noreferrer"
189
+ onClick={() => recordSiteOpen(tool.slug)}
187
190
  data-site
188
191
  data-testid="feed-row-name"
189
- aria-label={`${tool.name}, opens ${tool.host} in a new tab`}
192
+ aria-label={`${tool.name}, opens ${tool.host}`}
190
193
  className={cn(
191
194
  'truncate decoration-1 underline-offset-[3px] after:absolute after:inset-y-0 after:left-0 after:right-[120px] after:z-[1] after:rounded-l-[13px] focus-visible:outline-none focus-visible:after:outline-2 focus-visible:after:-outline-offset-[3px] focus-visible:after:outline-ring',
192
195
  'group-hover/row:underline group-has-[[data-details]:hover]/row:no-underline',
@@ -269,9 +272,10 @@ export function FeedRow({
269
272
  {dated && (
270
273
  <span
271
274
  data-testid="feed-row-date"
272
- className="ml-auto shrink-0 pr-4 text-[13px] font-semibold whitespace-nowrap text-muted-foreground"
275
+ title={exactDate(dated.at)}
276
+ className="pointer-events-auto ml-auto shrink-0 pr-4 text-[13px] font-semibold whitespace-nowrap text-muted-foreground"
273
277
  >
274
- {dated}
278
+ {dated.label} {timeAgo(dated.at)}
275
279
  </span>
276
280
  )}
277
281
  </div>
@@ -1,7 +1,8 @@
1
1
  import type { CommunityTool } from '@igstack/app-catalog-shared-core'
2
- import { ExternalLink, GripVertical } from 'lucide-react'
2
+ import { GripVertical } from 'lucide-react'
3
3
  import { cn } from '~/lib/utils'
4
4
  import { PersonAvatar, ToolThumb } from './FeedRow'
5
+ import { recordSiteOpen } from '../siteOpen'
5
6
  import { PinButton } from './PinButton'
6
7
 
7
8
  /**
@@ -35,8 +36,7 @@ export function ShelfTile({
35
36
  >
36
37
  <a
37
38
  href={tool.url}
38
- target="_blank"
39
- rel="noopener noreferrer"
39
+ onClick={() => recordSiteOpen(tool.slug)}
40
40
  aria-keyshortcuts="Alt+ArrowUp Alt+ArrowDown"
41
41
  onKeyDown={(e) => {
42
42
  if (!e.altKey) return
@@ -49,8 +49,7 @@ export function ShelfTile({
49
49
  >
50
50
  <span className="relative block aspect-[16/9.5] border-b border-border">
51
51
  <ToolThumb tool={tool} size={512} className="size-full border-0" />
52
- <span className="absolute right-2.5 bottom-2.5 inline-flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-sm font-extrabold text-primary-foreground opacity-0 shadow-sm transition-opacity group-hover:opacity-100 group-focus-within:opacity-100">
53
- <ExternalLink aria-hidden="true" className="size-4" />
52
+ <span className="absolute right-2.5 bottom-2.5 rounded-lg bg-primary px-3 py-1.5 text-sm font-extrabold text-primary-foreground opacity-0 shadow-sm transition-opacity group-hover:opacity-100 group-focus-within:opacity-100">
54
53
  Open site
55
54
  </span>
56
55
  </span>
@@ -26,6 +26,8 @@ import { Skeleton } from '~/ui/skeleton'
26
26
  import { CardScreenshot, formatCardDate } from './CardScreenshot'
27
27
  import { CardTitleBlock } from './CardTitleBlock'
28
28
  import { PersonAvatar } from './FeedRow'
29
+ import { openSite } from '../siteOpen'
30
+ import { exactDate, timeAgo } from '../timeAgo'
29
31
  import { useTimeUp } from '../useTimeUp'
30
32
  import { PinButton } from './PinButton'
31
33
  import { TagChip, tagKey, tagLabel } from './TagRow'
@@ -184,7 +186,7 @@ export function ToolCard({
184
186
  // that opens the site.
185
187
  if (target.closest('a, button')) return
186
188
  e.preventDefault()
187
- window.open(tool.url, '_blank', 'noopener,noreferrer')
189
+ openSite(tool)
188
190
  }
189
191
  }
190
192
 
@@ -296,6 +298,14 @@ export function ToolCard({
296
298
  </b>{' '}
297
299
  all time
298
300
  </span>
301
+ {tool.siteUpdatedAt && (
302
+ <span
303
+ data-testid="card-site-updated"
304
+ title={exactDate(tool.siteUpdatedAt)}
305
+ >
306
+ Site updated {timeAgo(tool.siteUpdatedAt)}
307
+ </span>
308
+ )}
299
309
  </p>
300
310
  )}
301
311
  {/* Who to ask, up here with the facts: below the screenshot
@@ -1,6 +1,7 @@
1
1
  import { Outlet, createFileRoute, useRouterState } from '@tanstack/react-router'
2
2
  import { AppCatalogLayout } from '~/modules/appCatalog/ui/layout/AppCatalogLayout'
3
3
  import { AppCatalogPage } from '~/modules/appCatalog/ui/pages/AppCatalogPage'
4
+ import { communityToolsConfigLoader } from '~/modules/communityTools/communityToolsConfigLoader'
4
5
  // Route ids are read off the route objects instead of being spelled out as
5
6
  // string literals: renaming/moving either file is then a compile error here
6
7
  // rather than a silently non-matching id at runtime. `Route.id` is only
@@ -42,6 +43,7 @@ function hasSlug(params: unknown): params is { slug: string } {
42
43
 
43
44
  export const Route = createFileRoute('/_layout')({
44
45
  component: LayoutComponent,
46
+ loader: communityToolsConfigLoader,
45
47
  })
46
48
 
47
49
  function LayoutComponent() {
@@ -1,7 +1,14 @@
1
1
  import Dexie from 'dexie'
2
- import type { AppCatalogData } from '@igstack/app-catalog-backend-core'
2
+ import type {
3
+ AppCatalogData,
4
+ TRPCRouter,
5
+ } from '@igstack/app-catalog-backend-core'
6
+ import type { inferRouterOutputs } from '@trpc/server'
3
7
  import type { Table } from 'dexie'
4
8
 
9
+ export type CommunityToolsConfig =
10
+ inferRouterOutputs<TRPCRouter>['communityTools']['config']
11
+
5
12
  export interface AppClickHistoryItem {
6
13
  id?: number
7
14
  appSlug: string
@@ -11,6 +18,7 @@ export interface AppClickHistoryItem {
11
18
  export class AcDb extends Dexie {
12
19
  appCatalog!: Table<AppCatalogData>
13
20
  appClickHistory!: Table<AppClickHistoryItem>
21
+ communityToolsConfig!: Table<CommunityToolsConfig>
14
22
 
15
23
  constructor() {
16
24
  super('app-catalog')
@@ -21,6 +29,11 @@ export class AcDb extends Dexie {
21
29
  appCatalog: '',
22
30
  appClickHistory: '++id, appSlug, timestamp',
23
31
  })
32
+ this.version(3).stores({
33
+ appCatalog: '',
34
+ appClickHistory: '++id, appSlug, timestamp',
35
+ communityToolsConfig: '',
36
+ })
24
37
  }
25
38
 
26
39
  /**
@@ -37,4 +50,5 @@ export class AcDb extends Dexie {
37
50
 
38
51
  export enum dbCacheDbKeys {
39
52
  AppCatalog = 'appCatalog',
53
+ CommunityToolsConfig = 'communityToolsConfig',
40
54
  }