@flamingo-stack/openframe-frontend-core 0.0.797 → 0.0.799

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 (92) hide show
  1. package/dist/build/export-map.json +1 -1
  2. package/dist/{chunk-VFCPLZFY.cjs → chunk-247LDSQE.cjs} +61 -61
  3. package/dist/{chunk-UKLSEI7S.cjs → chunk-2KEBGXA4.cjs} +4 -4
  4. package/dist/{chunk-GAFNJDZV.cjs → chunk-3MRK7X6Z.cjs} +3 -3
  5. package/dist/{chunk-7GFKJGWH.cjs → chunk-4RK62AMV.cjs} +68 -68
  6. package/dist/{chunk-PBL66EVT.cjs → chunk-6CB3AXZM.cjs} +30 -30
  7. package/dist/{chunk-BUCCV72E.cjs → chunk-6EDOASF4.cjs} +11 -11
  8. package/dist/{chunk-NBUHCGGG.cjs → chunk-AVAE5B2A.cjs} +2 -2
  9. package/dist/{chunk-YHCC3BLP.cjs → chunk-B3X4J4HQ.cjs} +14 -14
  10. package/dist/{chunk-ZPTHTGHK.cjs → chunk-BSBCZIPQ.cjs} +39 -39
  11. package/dist/{chunk-CO6FB4DR.cjs → chunk-CS2KLF4O.cjs} +13 -13
  12. package/dist/{chunk-FFEE2ON2.cjs → chunk-DBRXZC2I.cjs} +139 -129
  13. package/dist/{chunk-5CEXT3V7.cjs → chunk-FDDM5Z52.cjs} +2 -2
  14. package/dist/{chunk-QKXXHOOD.cjs → chunk-FIKIPO4F.cjs} +13 -0
  15. package/dist/{chunk-3H3CQ7BQ.cjs → chunk-GRNTIKPD.cjs} +54 -44
  16. package/dist/{chunk-LAJNO2EW.cjs → chunk-HB7FVY46.cjs} +32 -32
  17. package/dist/{chunk-RD57WBJK.cjs → chunk-IJGIWG6G.cjs} +4 -4
  18. package/dist/{chunk-OZUUCVDZ.cjs → chunk-O6KQ64RI.cjs} +2 -2
  19. package/dist/{chunk-KWINW3FC.cjs → chunk-PO5IIN4S.cjs} +11 -11
  20. package/dist/{chunk-YMWK7GOC.cjs → chunk-PPORXZI7.cjs} +139 -119
  21. package/dist/{chunk-IS77JFF6.cjs → chunk-SDV335EO.cjs} +4 -4
  22. package/dist/{chunk-7MLK7BGF.cjs → chunk-T5OCU3EL.cjs} +4 -4
  23. package/dist/{chunk-4M5JIVAH.cjs → chunk-TETW5NR4.cjs} +3 -3
  24. package/dist/{chunk-CHF6PHOR.cjs → chunk-UFCKY7OL.cjs} +16 -16
  25. package/dist/{chunk-7AMU2ZD2.cjs → chunk-XJD7IZR2.cjs} +48 -48
  26. package/dist/{chunk-NX4QOEPJ.cjs → chunk-ZOK4OWMJ.cjs} +2 -2
  27. package/dist/{cloud-tenants-THCY3N2P.cjs → cloud-tenants-BQAVRN44.cjs} +6 -6
  28. package/dist/components/case-studies/index.cjs +20 -20
  29. package/dist/components/chat/entity-cards/roadmap-card.d.ts +5 -0
  30. package/dist/components/chat/entity-cards/roadmap-card.d.ts.map +1 -1
  31. package/dist/components/chat/entity-cards/roadmap-card.js +16 -1
  32. package/dist/components/chat/index.cjs +5 -5
  33. package/dist/components/chat/types/entities/roadmap-item.d.ts +8 -0
  34. package/dist/components/chat/types/entities/roadmap-item.d.ts.map +1 -1
  35. package/dist/components/contact/index.cjs +7 -7
  36. package/dist/components/docs/index.cjs +10 -10
  37. package/dist/components/embeds/index.cjs +7 -7
  38. package/dist/components/faq/index.cjs +8 -8
  39. package/dist/components/features/index.cjs +6 -6
  40. package/dist/components/help-center-pages/index.cjs +82 -82
  41. package/dist/components/index.cjs +52 -52
  42. package/dist/components/loading/loading-fallback.d.ts +27 -3
  43. package/dist/components/loading/loading-fallback.d.ts.map +1 -1
  44. package/dist/components/loading/loading-fallback.js +17 -9
  45. package/dist/components/meeting-scheduler/index.cjs +38 -38
  46. package/dist/components/navigation/index.cjs +9 -9
  47. package/dist/components/onboarding-guides/index.cjs +9 -9
  48. package/dist/components/product-demo/index.cjs +15 -15
  49. package/dist/components/related-content/index.cjs +5 -5
  50. package/dist/components/tickets/index.cjs +13 -13
  51. package/dist/components/ui/feature-card.d.ts +1 -1
  52. package/dist/components/ui/feature-card.d.ts.map +1 -1
  53. package/dist/components/ui/feature-card.js +1 -0
  54. package/dist/components/ui/index.cjs +6 -6
  55. package/dist/components/ui/index.d.ts +1 -1
  56. package/dist/components/ui/index.d.ts.map +1 -1
  57. package/dist/components/ui/index.js +9 -1
  58. package/dist/components/ui/markdown-editor.d.ts.map +1 -1
  59. package/dist/components/ui/trendline.d.ts +1 -1
  60. package/dist/components/ui/trendline.d.ts.map +1 -1
  61. package/dist/components/ui/trendline.js +11 -2
  62. package/dist/{devices-N4EF5QDS.cjs → devices-KDT5ZGSG.cjs} +7 -7
  63. package/dist/{embeddable-chat-7Z2OQK3X.cjs → embeddable-chat-ODKTSW3C.cjs} +62 -62
  64. package/dist/index.cjs +12 -10
  65. package/dist/{knowledge-TL4DSXYQ.cjs → knowledge-4NLP77HP.cjs} +7 -7
  66. package/dist/loading-standard/engine.d.mts +22 -4
  67. package/dist/loading-standard/engine.d.mts.map +1 -1
  68. package/dist/loading-standard/rule-examples.d.mts.map +1 -1
  69. package/dist/{logs-4VRUBGKE.cjs → logs-U6VMTY4N.cjs} +14 -14
  70. package/dist/{policies-TLNVCQGG.cjs → policies-TBLFBRFM.cjs} +10 -10
  71. package/dist/{scripts-4LFWHIMH.cjs → scripts-ZMNJWX7I.cjs} +11 -11
  72. package/dist/{software-update-J4ZXQABW.cjs → software-update-Q5AEQ4A4.cjs} +9 -9
  73. package/dist/utils/clickup-drop-down.cjs +22 -0
  74. package/dist/utils/clickup-drop-down.d.ts +26 -0
  75. package/dist/utils/clickup-drop-down.d.ts.map +1 -0
  76. package/dist/utils/clickup-drop-down.js +20 -0
  77. package/dist/utils/index.cjs +20 -0
  78. package/dist/utils/index.d.ts +1 -0
  79. package/dist/utils/index.d.ts.map +1 -1
  80. package/dist/utils/index.js +1 -0
  81. package/package.json +7 -1
  82. package/src/components/chat/entity-cards/roadmap-card.tsx +18 -1
  83. package/src/components/chat/types/entities/roadmap-item.ts +8 -0
  84. package/src/components/loading/loading-fallback.tsx +52 -12
  85. package/src/components/ui/feature-card.tsx +2 -1
  86. package/src/components/ui/index.ts +13 -1
  87. package/src/components/ui/markdown-editor.tsx +1 -0
  88. package/src/components/ui/trendline.tsx +27 -10
  89. package/src/loading-standard/engine.mjs +170 -14
  90. package/src/loading-standard/rule-examples.mjs +50 -0
  91. package/src/utils/clickup-drop-down.ts +41 -0
  92. package/src/utils/index.ts +1 -0
@@ -52,6 +52,7 @@ import { SEO_TITLE_MAX_LENGTH } from "./seo-title.js";
52
52
  import { SEO_DESCRIPTION_MAX_LENGTH } from "./seo-description.js";
53
53
  export * from "./brand-marks.js";
54
54
  export * from "./design-doc-readiness.js";
55
+ export * from "./clickup-drop-down.js";
55
56
  export * from "./platform-config.js";
56
57
  export * from "./os-platforms.js";
57
58
  export * from "./access-code-client.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flamingo-stack/openframe-frontend-core",
3
- "version": "0.0.797",
3
+ "version": "0.0.799",
4
4
  "description": "Shared design system and components for all Flamingo platforms",
5
5
  "type": "module",
6
6
  "sideEffects": [
@@ -290,6 +290,12 @@
290
290
  "require": "./dist/utils/csv.cjs",
291
291
  "default": "./dist/utils/csv.js"
292
292
  },
293
+ "./utils/clickup-drop-down": {
294
+ "types": "./dist/utils/clickup-drop-down.d.ts",
295
+ "import": "./dist/utils/clickup-drop-down.js",
296
+ "require": "./dist/utils/clickup-drop-down.cjs",
297
+ "default": "./dist/utils/clickup-drop-down.js"
298
+ },
293
299
  "./utils/common": {
294
300
  "types": "./dist/utils/common.d.ts",
295
301
  "import": "./dist/utils/common.js",
@@ -10,7 +10,7 @@
10
10
  * default branch.
11
11
  */
12
12
 
13
- import { ThumbsUp, ThumbsDown } from 'lucide-react';
13
+ import { Globe, Lock, ThumbsDown, ThumbsUp } from 'lucide-react';
14
14
  import { useState } from 'react';
15
15
  import Image from '../../../embed-shims/next-image';
16
16
  import Link from '../../../embed-shims/next-link';
@@ -24,6 +24,7 @@ import { Button } from '../../ui/button/button';
24
24
  import { ImageGalleryModal } from '../../ui/image-gallery-modal';
25
25
  import { useLoadingScope } from '../../ui/loading-scope';
26
26
  import { StatusBadge, generationTierFromLabel } from '../../ui/status-badge';
27
+ import { Tag } from '../../ui/tag';
27
28
  import { useProxiedImageUrl } from '../hooks/use-proxied-image-url';
28
29
  import type { RoadmapItem } from '../types/entities/roadmap-item';
29
30
  import { getStatusColorScheme } from '../utils/agent-status-message';
@@ -65,6 +66,21 @@ const ROADMAP_CARD_FOOTER = 'flex w-full items-center justify-between';
65
66
  const ROADMAP_CARD_VOTES = 'flex h-[48px] overflow-hidden rounded-[6px]';
66
67
  const ROADMAP_CARD_FOOTER_END = 'flex min-w-0 items-center gap-2';
67
68
 
69
+ /** What a card says about its visibility when its reader states it (`RoadmapItem.isPublic`). */
70
+ export const ROADMAP_VISIBILITY_LABEL = { public: 'Public', internal: 'Team only' } as const;
71
+
72
+ /** Public or team only, when the item states it: a team-only plan is never read as announced. */
73
+ function RoadmapVisibilityTag({ isPublic }: { isPublic: boolean }) {
74
+ return (
75
+ <Tag
76
+ data-loading-optional
77
+ variant="outline"
78
+ icon={isPublic ? <Globe className="h-4 w-4" aria-hidden /> : <Lock className="h-4 w-4" aria-hidden />}
79
+ label={isPublic ? ROADMAP_VISIBILITY_LABEL.public : ROADMAP_VISIBILITY_LABEL.internal}
80
+ />
81
+ );
82
+ }
83
+
68
84
  /**
69
85
  * A roadmap card while it is read. `default`, in the card's own boxes: the 64px icon box, the title as two `text-h3`
70
86
  * lines, the quarter and id as a `text-h5` line, the status badge's box (beside the heading from md, its own row
@@ -385,6 +401,7 @@ function LoadedRoadmapCard({
385
401
  )}
386
402
 
387
403
  <div className={ROADMAP_CARD_FOOTER_END}>
404
+ {typeof item.isPublic === 'boolean' ? <RoadmapVisibilityTag isPublic={item.isPublic} /> : null}
388
405
  {item.assignees && item.assignees.length > 0 ? (
389
406
  <AvatarStack size="xs" people={assigneePeople(item.assignees)} className="shrink-0" />
390
407
  ) : null}
@@ -32,6 +32,14 @@ export interface RoadmapItem {
32
32
  downvotes: number;
33
33
  quarter: string;
34
34
  clickupUrl: string;
35
+ /** The team the item belongs to (the ClickUp `Team` field), when the reader states it. */
36
+ team?: string | null;
37
+ /**
38
+ * Whether the item is on the public roadmap (the ClickUp `Public` checkbox). Stated only by a reader that also
39
+ * serves team-only items (an internal hub); the public roadmap serves public items only and leaves it out. When it
40
+ * is stated, the card says which it is, so a team-only plan is never read as announced.
41
+ */
42
+ isPublic?: boolean;
35
43
  /** ClickUp canonical task-type taxonomy ID (1008=Bug, 1009=Request,
36
44
  * 1010=Feature, …). Drives the type-specific icon rendered in the
37
45
  * chat's compact card for the internal-tasks variant — see
@@ -1,7 +1,7 @@
1
1
  'use client';
2
2
 
3
3
  import { type ElementType, type ReactNode, Suspense } from 'react';
4
- import { AnnouncedLoadingScope } from '../ui/loading-scope';
4
+ import { AnnouncedLoadingScope, LoadingStatus, LoadingWhen, useLoadingScope } from '../ui/loading-scope';
5
5
 
6
6
  /**
7
7
  * A Suspense fallback drawn by the components themselves: the SAME component the boundary waits on, rendered in a
@@ -39,12 +39,18 @@ export function LoadingFallback({
39
39
  }
40
40
 
41
41
  /**
42
- * The one Suspense boundary whose fallback is its own children in a loading scope: what every screen wrote out as
43
- * `<Suspense fallback={<LoadingFallback label={…}>{x}</LoadingFallback>}>{x}</Suspense>`, with the child twice.
42
+ * THE boundary (the loading standard's one Suspense: `src/loading-standard/engine.mjs`, rules RAW_SUSPENSE and
43
+ * PAGE_BOUNDARY). It wraps only the component that waits on a read; its fallback is that component (or `fallback`, its
44
+ * view with no data) drawn in a loading scope, where every part draws its own loading form, so nothing jumps when the
45
+ * content arrives. Sections that share one read, or would look broken arriving one by one, share one boundary. A page's
46
+ * static frame (heading, copy, back link, cached content) renders at once, outside every boundary; a component that reads
47
+ * in the browser keeps its own loading state (`LoadingWhen`, `useLoadingScope`) and needs none.
44
48
  *
45
49
  * <LoadingSuspense label="Loading the tenants"><TenantList /></LoadingSuspense>
46
50
  * <LoadingSuspense label="Loading the script" fallback={<ScriptView script={null} />}><ScriptReader /></LoadingSuspense>
47
51
  * <LoadingSuspense status={false} as="span"><MentionChip id={id} /></LoadingSuspense>
52
+ * <LoadingSuspense live label="Loading the run" fallback={<RunView run={null} />}><RunReader /></LoadingSuspense>
53
+ * <LoadingSuspense gated={!flagReady} label="Loading usage" fallback={<UsageScreen data={null} />}><UsageReader /></LoadingSuspense>
48
54
  */
49
55
  export function LoadingSuspense({
50
56
  label,
@@ -52,6 +58,9 @@ export function LoadingSuspense({
52
58
  as,
53
59
  className,
54
60
  fallback,
61
+ live = false,
62
+ gated = false,
63
+ bare = false,
55
64
  children,
56
65
  }: {
57
66
  label?: string;
@@ -65,17 +74,48 @@ export function LoadingSuspense({
65
74
  * children.
66
75
  */
67
76
  fallback?: ReactNode;
77
+ /**
78
+ * The wait leaves the view usable: it is drawn in a BARE loading scope (no inert region) with the same status, so
79
+ * every part still draws its own loading form and every control that reads the scope still locks itself, while one
80
+ * that does not (Back, a plain `Button`, a search field) stays live. A body whose controls act on the record keeps
81
+ * the default (inert).
82
+ */
83
+ live?: boolean;
84
+ /**
85
+ * A gate the read depends on (a feature flag, a role, a test mode) has not answered: draw the waiting view and send
86
+ * nothing (the children are not rendered). The same view stands in for both waits, so no page spells the two branches.
87
+ */
88
+ gated?: boolean;
89
+ /**
90
+ * The gate's window draws the scope only (no region element of its own), and the scope stays mounted across the gate,
91
+ * so the view is not remounted: for a view inside a surface that already announces its load, or whose layout an extra
92
+ * element would break.
93
+ */
94
+ bare?: boolean;
68
95
  children: ReactNode;
69
96
  }) {
97
+ const view = fallback ?? children;
98
+ const waiting = live ? (
99
+ <LiveWait label={label} status={status}>
100
+ {view}
101
+ </LiveWait>
102
+ ) : (
103
+ <LoadingFallback label={label} status={status} as={as} className={className}>
104
+ {view}
105
+ </LoadingFallback>
106
+ );
107
+ const boundary = <Suspense fallback={waiting}>{children}</Suspense>;
108
+ if (bare) return <LoadingWhen loading={gated}>{gated ? view : boundary}</LoadingWhen>;
109
+ return gated ? waiting : boundary;
110
+ }
111
+
112
+ /** A `live` wait: the view in a bare loading scope, announced once (silent inside an outer scope, which has said it). */
113
+ function LiveWait({ label, status = true, children }: { label?: string; status?: boolean; children: ReactNode }) {
114
+ const outer = useLoadingScope();
70
115
  return (
71
- <Suspense
72
- fallback={
73
- <LoadingFallback label={label} status={status} as={as} className={className}>
74
- {fallback ?? children}
75
- </LoadingFallback>
76
- }
77
- >
78
- {children}
79
- </Suspense>
116
+ <>
117
+ <LoadingWhen loading>{children}</LoadingWhen>
118
+ {status && !outer && <LoadingStatus label={label ?? 'Loading the page'} />}
119
+ </>
80
120
  );
81
121
  }
@@ -39,7 +39,7 @@ export interface FeatureCardItem {
39
39
  export interface FeatureCardGridProps {
40
40
  items: FeatureCardItem[];
41
41
  /** Items per row from the widest breakpoint (4 shows two per row at `md`). */
42
- columns?: 2 | 3 | 4;
42
+ columns?: 1 | 2 | 3 | 4;
43
43
  className?: string;
44
44
  cardClassName?: string;
45
45
  itemClassName?: string;
@@ -86,6 +86,7 @@ export interface FeatureCardGridSkeletonShape {
86
86
  const FEATURE_CARD_GRID_SKELETON_ITEMS = 3;
87
87
 
88
88
  const GRID_COLUMNS = {
89
+ 1: 'grid-cols-1',
89
90
  2: 'grid-cols-1 content-md:grid-cols-2',
90
91
  3: 'grid-cols-1 content-md:grid-cols-3',
91
92
  4: 'grid-cols-1 content-md:grid-cols-2 content-lg:grid-cols-4',
@@ -117,7 +117,19 @@ export * from './compliance-badge';
117
117
  export * from './feature-card';
118
118
  export * from './feature-list';
119
119
  export { FloatingTooltip } from './floating-tooltip';
120
- export { Trendline, TrendHistory, TREND_TONES, formatTrendChange, trendlinePoints, trendTone, trendToneClass, type TrendTone, type TrendlineProps, type TrendHistoryProps, type TrendHistoryColumn } from './trendline';
120
+ export {
121
+ Trendline,
122
+ TrendHistory,
123
+ TREND_TONES,
124
+ formatTrendChange,
125
+ trendlinePoints,
126
+ trendTone,
127
+ trendToneClass,
128
+ type TrendTone,
129
+ type TrendlineProps,
130
+ type TrendHistoryProps,
131
+ type TrendHistoryColumn,
132
+ } from './trendline';
121
133
  export { SourceTooltip, type SourceTooltipProps, type SourceRef } from './source-tooltip';
122
134
  export { TruncateText, type TruncateTextProps } from './truncate-text';
123
135
  export * from './highlight-card';
@@ -378,6 +378,7 @@ export function MarkdownEditor({
378
378
 
379
379
  {/* `next/dynamic` draws the loader's `loading`; a host on `React.lazy` reaches this boundary. Both are the skeleton. */}
380
380
  <MarkdownEditorHeightContext.Provider value={height}>
381
+ {/* loading-standard-ok(RAW_SUSPENSE): waits on the editor's CODE (React.lazy), like next/dynamic's loading: */}
381
382
  <Suspense fallback={<MarkdownEditorFieldSkeleton height={height} />}>
382
383
  <MDEditor
383
384
  value={value}
@@ -53,7 +53,11 @@ export function trendTone(change: number | null, higherIsBetter = false): TrendT
53
53
  }
54
54
 
55
55
  /** The text colour of a change: its tone's class, from `TREND_TONES` or the host's `tones`. */
56
- export function trendToneClass(change: number | null, higherIsBetter = false, tones: Partial<Record<TrendTone, string>> = {}): string {
56
+ export function trendToneClass(
57
+ change: number | null,
58
+ higherIsBetter = false,
59
+ tones: Partial<Record<TrendTone, string>> = {},
60
+ ): string {
57
61
  const tone = trendTone(change, higherIsBetter);
58
62
  return tones[tone] ?? TREND_TONES[tone];
59
63
  }
@@ -64,9 +68,7 @@ export function trendToneClass(change: number | null, higherIsBetter = false, to
64
68
  * still visible; a flat series sits mid-height, a single value in the middle.
65
69
  */
66
70
  export function trendlinePoints(values: ReadonlyArray<number | null>): Array<{ x: number; y: number }> {
67
- const known = values
68
- .map((v, i) => [i, v] as const)
69
- .filter((p): p is readonly [number, number] => p[1] !== null);
71
+ const known = values.map((v, i) => [i, v] as const).filter((p): p is readonly [number, number] => p[1] !== null);
70
72
  if (known.length === 0) return [];
71
73
  const min = Math.min(...known.map(([, v]) => v));
72
74
  const range = Math.max(...known.map(([, v]) => v)) - min;
@@ -83,7 +85,7 @@ function Spark({ values, toneClass }: { values: ReadonlyArray<number | null>; to
83
85
  <svg className={`${SPARK_CLASS} ${toneClass}`} viewBox={`0 0 ${SPARK_W} ${SPARK_H}`} aria-hidden="true">
84
86
  {points.length > 1 && (
85
87
  <polyline
86
- points={points.map((p) => `${p.x},${p.y}`).join(' ')}
88
+ points={points.map(p => `${p.x},${p.y}`).join(' ')}
87
89
  fill="none"
88
90
  stroke="currentColor"
89
91
  strokeWidth={1.5}
@@ -112,7 +114,15 @@ export interface TrendlineProps {
112
114
  side?: 'top' | 'right' | 'bottom' | 'left';
113
115
  }
114
116
 
115
- export function Trendline({ values, label, change, higherIsBetter = false, tones, details, side = 'top' }: TrendlineProps) {
117
+ export function Trendline({
118
+ values,
119
+ label,
120
+ change,
121
+ higherIsBetter = false,
122
+ tones,
123
+ details,
124
+ side = 'top',
125
+ }: TrendlineProps) {
116
126
  // The ONE switch: in a loading scope, the skeleton at the loaded size.
117
127
  if (useLoadingScope()) {
118
128
  return (
@@ -199,13 +209,15 @@ export function TrendHistory({ title, columns, rows, loadingRows, error, childre
199
209
  ) : (
200
210
  <LoadingWhen loading={rows === null}>
201
211
  <div className="grid gap-x-[var(--spacing-system-mf)] gap-y-[var(--spacing-system-xxs)]" style={grid}>
202
- {columns.map((c) => (
212
+ {columns.map(c => (
203
213
  <span key={c.label} className={`${alignClass(c)} text-ods-text-secondary`}>
204
214
  {c.label}
205
215
  </span>
206
216
  ))}
207
217
  {(rows ?? Array.from({ length: loadingRows }, () => null)).map((row, r) =>
208
- columns.map((c, i) => <TrendHistoryCell key={`${r}:${c.label}`} column={c} value={row ? row[i] : null} />),
218
+ columns.map((c, i) => (
219
+ <TrendHistoryCell key={`${r}:${c.label}`} column={c} value={row ? row[i] : null} />
220
+ )),
209
221
  )}
210
222
  </div>
211
223
  </LoadingWhen>
@@ -216,6 +228,11 @@ export function TrendHistory({ title, columns, rows, loadingRows, error, childre
216
228
  }
217
229
 
218
230
  function TrendHistoryCell({ column, value }: { column: TrendHistoryColumn; value: ReactNode }) {
219
- if (useLoadingScope()) return <TextLineSkeleton type="h6" className={column.align === 'right' ? 'ml-auto w-8' : 'w-12'} />;
220
- return <span className={`${column.align === 'right' ? 'text-right tabular-nums' : 'text-left'} text-ods-text-primary`}>{value}</span>;
231
+ if (useLoadingScope())
232
+ return <TextLineSkeleton type="h6" className={column.align === 'right' ? 'ml-auto w-8' : 'w-12'} />;
233
+ return (
234
+ <span className={`${column.align === 'right' ? 'text-right tabular-nums' : 'text-left'} text-ods-text-primary`}>
235
+ {value}
236
+ </span>
237
+ );
221
238
  }
@@ -58,6 +58,17 @@
58
58
  * `LoadingFallback` drawing nothing.
59
59
  * HAND_PAIR A hand-built `<Suspense fallback={<LoadingFallback>…}>` (use `LoadingSuspense`), or a hand
60
60
  * `<LoadingRegion>` around a `<LoadingScope>` / `<LoadingWhen>` (use `LoadingFallback`).
61
+ * RAW_SUSPENSE A `Suspense` / `React.Suspense` with a fallback of its own. The ONE boundary is `LoadingSuspense`
62
+ * (or a host's own boundary built on it, `config.boundaries`): its fallback is the component it
63
+ * waits on, drawn in a loading scope, so nothing jumps when the content arrives. A boundary that
64
+ * draws nothing on purpose (structured data, a crawler-only body) opts out with its reason.
65
+ * PAGE_BOUNDARY A page's or a layout's whole output inside one boundary (`Suspense`, `LoadingSuspense`, a
66
+ * configured host boundary): the root element a route file's default export returns, a fragment
67
+ * holding only it, or a slot of the object it hands a render helper. A boundary wraps only the
68
+ * component that waits on a read; sections that share one read, or would look broken arriving one
69
+ * by one, share one boundary; the page's static frame (heading, copy, back link, cached content)
70
+ * renders at once, outside every boundary. A component that reads in the browser keeps its own
71
+ * loading state (`LoadingWhen`, `useLoadingScope`) and needs no boundary.
61
72
  * WHOLE_VIEW_SKELETON A component declared or rendered as `*PageSkeleton`, `*ScreenSkeleton`, `*DetailSkeleton`,
62
73
  * `*ArticleSkeleton`, `*ViewSkeleton`, `*HomeSkeleton`, `*DeckSkeleton`, `*EditorSkeleton`,
63
74
  * `*CenterSkeleton`, `*CatalogSkeleton`, `*FormSkeleton`, `*LayoutSkeleton`,
@@ -132,16 +143,38 @@
132
143
  * `/* … *\/`), at the end of the finding's line or alone on the line directly above it. It lifts that one rule on
133
144
  * that one line, and an opt-out that lifts nothing is itself a finding (OPT_OUT).
134
145
  *
135
- * CONFIG: `CONFIGS.lib` and `CONFIGS.frontend` hold each repository's rule set, reported trees, page code and
136
- * exemptions, declared once here.
146
+ * CONFIG: `CONFIGS.lib`, `CONFIGS.frontend` and `CONFIGS.hub` hold each repository's rule set, reported trees, page
147
+ * code, boundaries and exemptions, declared once here. `boundaries` names a host's own boundary components (built on
148
+ * `LoadingSuspense`) and the attribute that makes one render directly, with no boundary (`{ StreamedSection: 'cached' }`):
149
+ * bare or with any value but the literal `false`.
137
150
  */
138
151
  import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';
139
152
  import { createRequire } from 'node:module';
140
153
  import { dirname, join, relative, resolve } from 'node:path';
141
154
 
142
- // The compiler is the HOST's (a dev dependency of every repository that runs the gate), resolved from where this
143
- // module is installed: the lib does not ship TypeScript to its consumers.
144
- const ts = createRequire(import.meta.url)('typescript');
155
+ // The compiler is the HOST's (a dev dependency of every repository that runs the gate): resolved from the directory the
156
+ // gate runs in (the host's root), and only then from where this module is installed. The lib does not ship TypeScript,
157
+ // but a host's install can still nest one inside the lib's folder for another package's peer range (a TypeScript 7
158
+ // there has no JavaScript compiler API), which resolving from this module's location would pick first.
159
+ const ts = loadTypeScript();
160
+
161
+ /**
162
+ * The first TypeScript with a compiler API, resolved from each place in order (a file or URL to resolve from).
163
+ * Exported for its test.
164
+ */
165
+ export function loadTypeScript(from = [join(process.cwd(), 'package.json'), import.meta.url]) {
166
+ const tried = [];
167
+ for (const place of from) {
168
+ try {
169
+ const candidate = createRequire(place)('typescript');
170
+ if (candidate?.SyntaxKind && typeof candidate.createSourceFile === 'function') return candidate;
171
+ tried.push(`${place}: typescript ${candidate?.version ?? '?'} has no compiler API`);
172
+ } catch (error) {
173
+ tried.push(`${place}: ${error instanceof Error ? error.message : String(error)}`);
174
+ }
175
+ }
176
+ throw new Error(`loading-standard engine: no TypeScript compiler API to read with (${tried.join('; ')})`);
177
+ }
145
178
 
146
179
  /** Every rule id, with the reason a finding of it prints. */
147
180
  export const RULES = {
@@ -156,6 +189,9 @@ export const RULES = {
156
189
  OWN_PULSE: 'a pulse or skeleton colour of its own (use the lib skeletons)',
157
190
  SUSPENSE_FALLBACK: 'a Suspense with no fallback (use LoadingSuspense / LoadingFallback)',
158
191
  HAND_PAIR: 'a hand-built loading pair (use the lib wrapper)',
192
+ RAW_SUSPENSE: 'a raw Suspense (use LoadingSuspense: its fallback is the component it waits on, in a loading scope)',
193
+ PAGE_BOUNDARY:
194
+ 'a boundary around a whole page (wrap only the component that waits on a read; the static frame renders at once)',
159
195
  WHOLE_VIEW_SKELETON: 'a whole-view skeleton (the view itself in a loading scope is its loading state)',
160
196
  FOLD_PROP: 'a `fold` prop (a skeleton draws its full count: skeletonCount)',
161
197
  DEPRECATED_SKELETON: 'deprecated in the lib (render the component in a loading scope)',
@@ -175,6 +211,8 @@ const ALL_RULES = Object.keys(RULES);
175
211
  /** The files a host's PAGE CODE is (its route files, every file of a route folder, its screens, its `lib/`). */
176
212
  const ROUTE_FILE = /(?:^|\/)(?:page|layout|loading|template|not-found|error)\.tsx$/;
177
213
  const SCREEN_FILE = /-page(?:-ssr|-client)?\.tsx$/;
214
+ /** A route file whose output is a whole page or layout (PAGE_BOUNDARY). */
215
+ const PAGE_OR_LAYOUT_FILE = /(?:^|\/)(?:page|layout)\.tsx$/;
178
216
 
179
217
  /**
180
218
  * Each repository's rule set and exemptions. `trees` are the folders reported (relative to the tree's root; all when
@@ -204,6 +242,17 @@ export const CONFIGS = {
204
242
  },
205
243
  exempt: [],
206
244
  },
245
+ /**
246
+ * The hub (multi-platform-hub) runs the BOUNDARY rules from this engine; its own gate (`check-page-skeletons.mjs`)
247
+ * still holds its older skeleton checks. Its server boundary is `StreamedSection` (a read, drawn from a placeholder in
248
+ * a loading scope until it answers), which renders directly when told `cached`.
249
+ */
250
+ hub: {
251
+ rules: ['SUSPENSE_FALLBACK', 'HAND_PAIR', 'RAW_SUSPENSE', 'PAGE_BOUNDARY'],
252
+ trees: ['app', 'components', 'lib'],
253
+ boundaries: { StreamedSection: 'cached' },
254
+ exempt: [],
255
+ },
207
256
  lib: {
208
257
  rules: ALL_RULES,
209
258
  exempt: [
@@ -211,7 +260,7 @@ export const CONFIGS = {
211
260
  why: "the lib's own loading primitives: the one pulse, the scope, the fallback and the Suspense wrapper are built here",
212
261
  files:
213
262
  /(?:^|\/)components\/(?:loading\/(?:loading-fallback|loading-region|unified-skeleton)|ui\/(?:loading-scope|skeleton[\w-]*|text-line-skeleton))\.tsx?$/,
214
- rules: ['OWN_PULSE', 'HAND_PAIR', 'SUSPENSE_FALLBACK', 'NOTHING_WHILE_LOADING'],
263
+ rules: ['OWN_PULSE', 'HAND_PAIR', 'SUSPENSE_FALLBACK', 'RAW_SUSPENSE', 'NOTHING_WHILE_LOADING'],
215
264
  },
216
265
  {
217
266
  why: "the loaders themselves (declared, never a screen state in the lib), the Button's own action progress, and the chat registry's card loader (a card read by id, drawn by the card's own skeleton)",
@@ -1698,9 +1747,12 @@ function loadedListBeside(listNode, model) {
1698
1747
  * `exempt` lifting rules from files, and `files` (absolute paths) narrowing the run.
1699
1748
  *
1700
1749
  * @param {Project} project
1701
- * @param {{ rules?: string[], trees?: string[], pageCode?: Function, exempt?: Array<{ why?: string, files: RegExp, rules: string[] }>, files?: string[] }} [config]
1750
+ * @param {{ rules?: string[], trees?: string[], pageCode?: Function, boundaries?: Record<string, string>, exempt?: Array<{ why?: string, files: RegExp, rules: string[] }>, files?: string[] }} [config]
1702
1751
  */
1703
- export function analyzeProject(project, { rules = ALL_RULES, trees, pageCode, exempt = [], files } = {}) {
1752
+ export function analyzeProject(
1753
+ project,
1754
+ { rules = ALL_RULES, trees, pageCode, boundaries = {}, exempt = [], files } = {},
1755
+ ) {
1704
1756
  const enabled = new Set(rules);
1705
1757
  const findings = [];
1706
1758
  const paths = files ?? [...project.text.keys()].filter(path => project.treeOf.get(path)?.report);
@@ -1712,13 +1764,16 @@ export function analyzeProject(project, { rules = ALL_RULES, trees, pageCode, ex
1712
1764
  const active = new Set([...enabled].filter(r => !lifted.has(r)));
1713
1765
  if (!active.size) continue;
1714
1766
  const isFile = other => project.text.has(join(tree?.dir ?? '', other)) || existsSync(join(tree?.dir ?? '', other));
1715
- findings.push(...analyzeFile(project, path, active, rel, pageCode?.(rel, isFile) ?? null));
1767
+ findings.push(...analyzeFile(project, path, active, rel, pageCode?.(rel, isFile) ?? null, boundaries));
1716
1768
  }
1717
1769
  return findings;
1718
1770
  }
1719
1771
 
1720
- /** Every finding in one file (see `analyzeProject`); `page` is the file's page-code setting, or null. */
1721
- function analyzeFile(project, path, active, rel, page) {
1772
+ /**
1773
+ * Every finding in one file (see `analyzeProject`); `page` is the file's page-code setting, or null; `boundaries` the
1774
+ * host's own boundary components.
1775
+ */
1776
+ function analyzeFile(project, path, active, rel, page, boundaries = {}) {
1722
1777
  const model = project.model(path);
1723
1778
  const findings = [];
1724
1779
  const seen = new Set();
@@ -2241,10 +2296,10 @@ function analyzeFile(project, path, active, rel, page) {
2241
2296
  const leaf = tag.split('.').pop();
2242
2297
  skeletonRender(opening, opening.tagName);
2243
2298
  if (LOADERS.has(leaf)) report('LOADER_COMPONENT', opening, RULES.LOADER_COMPONENT);
2244
- if (leaf === 'StreamedPage') {
2299
+ if (leaf === 'StreamedPage' || leaf === 'StreamedSection') {
2245
2300
  for (const a of opening.attributes.properties) {
2246
2301
  if (ts.isJsxAttribute(a) && /^(?:skeleton|memory|remember)$/.test(a.name.getText()))
2247
- report('RETIRED_API', a, `StreamedPage \`${a.name.getText()}\` (it takes a placeholder)`);
2302
+ report('RETIRED_API', a, `${leaf} \`${a.name.getText()}\` (it takes a placeholder)`);
2248
2303
  }
2249
2304
  }
2250
2305
  if (leaf === 'Suspense' || leaf === 'LoadingSuspense') checkFallback(opening, leaf);
@@ -2313,8 +2368,10 @@ function analyzeFile(project, path, active, rel, page) {
2313
2368
  }
2314
2369
  const root = rootElement(value);
2315
2370
  const rootOpening = root && openingOf(root);
2316
- if (leaf === 'Suspense' && rootOpening && model.resolveName(rootOpening.tagName) === 'LoadingFallback')
2371
+ if (leaf !== 'Suspense') return;
2372
+ if (rootOpening && model.resolveName(rootOpening.tagName) === 'LoadingFallback')
2317
2373
  report('HAND_PAIR', opening, 'a hand Suspense + LoadingFallback pair (use LoadingSuspense)');
2374
+ else report('RAW_SUSPENSE', opening, RULES.RAW_SUSPENSE);
2318
2375
  }
2319
2376
 
2320
2377
  /**
@@ -3065,6 +3122,77 @@ function analyzeFile(project, path, active, rel, page) {
3065
3122
  // ---- page code (a host's route files and screens; see `CONFIGS.frontend.pageCode`) ---------------------------------
3066
3123
  if (page) checkPageCode(page);
3067
3124
 
3125
+ // ---- a boundary around a whole page (a route file's page or layout) ------------------------------------------------
3126
+ if (isTsx && PAGE_OR_LAYOUT_FILE.test(rel)) checkPageBoundary();
3127
+
3128
+ /** The boundary a JSX root is, by name (`Suspense`, `LoadingSuspense`, a host boundary not told to render directly). */
3129
+ function boundaryOf(el) {
3130
+ const opening = el && openingOf(el);
3131
+ if (!opening) return null;
3132
+ const leaf = model.resolveName(opening.tagName).split('.').pop();
3133
+ if (leaf === 'Suspense' || leaf === 'LoadingSuspense') return { opening, leaf };
3134
+ const direct = boundaries[leaf];
3135
+ if (direct === undefined) return null;
3136
+ const flag = attribute(opening, direct);
3137
+ const value = flag && attributeExpression(flag);
3138
+ // Bare (`cached`) or any value but the literal `false` (`cached={isCached}` included) turns the boundary off.
3139
+ const off = flag && (!flag.initializer || !value || value.kind !== ts.SyntaxKind.FalseKeyword);
3140
+ return off ? null : { opening, leaf };
3141
+ }
3142
+
3143
+ /** The element a page's output is: its root, or the only element of a root fragment. */
3144
+ function pageRoot(expr) {
3145
+ let el = rootElement(expr);
3146
+ while (el && ts.isJsxFragment(el)) {
3147
+ const kids = el.children.filter(c => !(ts.isJsxText(c) && !c.text.trim()));
3148
+ if (kids.length !== 1) return null;
3149
+ el = ts.isJsxExpression(kids[0]) ? rootElement(kids[0].expression) : kids[0];
3150
+ }
3151
+ return el;
3152
+ }
3153
+
3154
+ function checkPageBoundary() {
3155
+ const fn = defaultExportFunction(model);
3156
+ if (!fn) return;
3157
+ const outputs = [];
3158
+ const collect = expr => {
3159
+ const n = strip(expr);
3160
+ if (!n) return;
3161
+ if (ts.isConditionalExpression(n)) {
3162
+ collect(n.whenTrue);
3163
+ collect(n.whenFalse);
3164
+ return;
3165
+ }
3166
+ // A render helper handed the page (`renderPlatformPage({ slots: { x: <Page /> } })`): each slot is the output.
3167
+ if (ts.isCallExpression(n)) {
3168
+ for (const arg of n.arguments)
3169
+ walk(arg, m => {
3170
+ if (isFunctionLike(m)) return false;
3171
+ if (ts.isPropertyAssignment(m) && isJsx(strip(m.initializer))) outputs.push(m.initializer);
3172
+ return undefined;
3173
+ });
3174
+ return;
3175
+ }
3176
+ outputs.push(n);
3177
+ };
3178
+ if (fn.body && !ts.isBlock(fn.body)) collect(fn.body);
3179
+ else if (fn.body)
3180
+ walk(fn.body, n => {
3181
+ if (isFunctionLike(n)) return false;
3182
+ if (ts.isReturnStatement(n) && n.expression) collect(n.expression);
3183
+ return undefined;
3184
+ });
3185
+ for (const out of outputs) {
3186
+ const hit = boundaryOf(pageRoot(out));
3187
+ if (hit)
3188
+ report(
3189
+ 'PAGE_BOUNDARY',
3190
+ hit.opening,
3191
+ `<${hit.leaf}> around the whole ${/layout\.tsx$/.test(rel) ? 'layout' : 'page'} (wrap only the component that waits on a read; the static frame renders at once)`,
3192
+ );
3193
+ }
3194
+ }
3195
+
3068
3196
  function checkPageCode({ components: componentSkeletons }) {
3069
3197
  if (/(?:^|\/)loading\.tsx$/.test(rel) && rel.startsWith('app/'))
3070
3198
  report('PAGE_CODE', model.sf, 'a route-level loading.tsx (the page draws itself in a loading scope)');
@@ -3108,6 +3236,34 @@ function analyzeFile(project, path, active, rel, page) {
3108
3236
  return findings;
3109
3237
  }
3110
3238
 
3239
+ /** The function a module exports as its default (`export default function`, or `export default Name`), or null. */
3240
+ function defaultExportFunction(model) {
3241
+ for (const st of model.sf.statements) {
3242
+ const mods = ts.canHaveModifiers?.(st) ? (ts.getModifiers(st) ?? []) : (st.modifiers ?? []);
3243
+ const isDefault = mods.some(m => m.kind === ts.SyntaxKind.DefaultKeyword);
3244
+ if (ts.isFunctionDeclaration(st) && isDefault) return st;
3245
+ if (ts.isExportAssignment(st) && !st.isExportEquals) {
3246
+ const e = strip(st.expression);
3247
+ if (isFunctionLike(e)) return e;
3248
+ if (ts.isIdentifier(e)) {
3249
+ for (const other of model.sf.statements) {
3250
+ if (ts.isFunctionDeclaration(other) && other.name?.text === e.text) return other;
3251
+ if (ts.isVariableStatement(other))
3252
+ for (const d of other.declarationList.declarations)
3253
+ if (
3254
+ ts.isIdentifier(d.name) &&
3255
+ d.name.text === e.text &&
3256
+ d.initializer &&
3257
+ isFunctionLike(strip(d.initializer))
3258
+ )
3259
+ return strip(d.initializer);
3260
+ }
3261
+ }
3262
+ }
3263
+ }
3264
+ return null;
3265
+ }
3266
+
3111
3267
  /** Whether `model`'s module renders `<component />` from a function that is not a skeleton. */
3112
3268
  function rendersOutsideSkeletons(model, component) {
3113
3269
  let hit = false;
@@ -234,6 +234,56 @@ export function L({ loading }: { loading: boolean }) { return loading ? <Wait />
234
234
  'export function Su() { return <LoadingSuspense label="Loading X" fallback={<XView x={null} />}><X /></LoadingSuspense>; }\n',
235
235
  },
236
236
  },
237
+ {
238
+ rule: 'RAW_SUSPENSE',
239
+ fail: {
240
+ 'components/raw.tsx':
241
+ 'export function Raw() { return <Suspense fallback={<XView x={null} />}><X /></Suspense>; }\n',
242
+ },
243
+ pass: {
244
+ 'components/raw.tsx': `export function Raw() {
245
+ return (
246
+ <>
247
+ <LoadingSuspense label="Loading X" fallback={<XView x={null} />}><X /></LoadingSuspense>
248
+ {/* loading-standard-ok(SUSPENSE_FALLBACK): structured data for crawlers, nothing is drawn */}
249
+ <Suspense fallback={null}><StructuredData /></Suspense>
250
+ </>
251
+ );
252
+ }
253
+ `,
254
+ },
255
+ },
256
+ {
257
+ rule: 'PAGE_BOUNDARY',
258
+ fail: {
259
+ 'app/devices/page.tsx': `export default function Page() {
260
+ return (
261
+ <LoadingSuspense label="Loading the devices">
262
+ <DevicesHeading />
263
+ <DevicesTable />
264
+ </LoadingSuspense>
265
+ );
266
+ }
267
+ `,
268
+ 'app/settings/layout.tsx':
269
+ 'export default function Layout({ children }: any) { return <><Suspense fallback={<X />}>{children}</Suspense></>; }\n',
270
+ 'app/pricing/page.tsx':
271
+ 'export default function Page() { return renderPage({ slots: { flamingo: <LoadingSuspense><Pricing /></LoadingSuspense> } }); }\n',
272
+ },
273
+ pass: {
274
+ 'app/devices/page.tsx': `export default function Page() {
275
+ return (
276
+ <>
277
+ <DevicesHeading />
278
+ <LoadingSuspense label="Loading the devices">
279
+ <DevicesTable />
280
+ </LoadingSuspense>
281
+ </>
282
+ );
283
+ }
284
+ `,
285
+ },
286
+ },
237
287
  {
238
288
  rule: 'HAND_PAIR',
239
289
  fail: {