@flamingo-stack/openframe-frontend-core 0.0.798 → 0.0.800

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 (79) hide show
  1. package/dist/{chunk-TJQGKIXB.cjs → chunk-3C6JR5Z5.cjs} +32 -32
  2. package/dist/{chunk-C2UZWRU5.cjs → chunk-5LTKE6D3.cjs} +16 -16
  3. package/dist/{chunk-FO3N6HDS.cjs → chunk-5PDOKPBF.cjs} +13 -13
  4. package/dist/{chunk-BWTCULUN.cjs → chunk-CDLOQCJC.cjs} +4 -4
  5. package/dist/{chunk-2M6HS23A.cjs → chunk-CM2UGR4I.cjs} +30 -30
  6. package/dist/{chunk-NK2FSEWD.cjs → chunk-DUSCG2EO.cjs} +4 -4
  7. package/dist/{chunk-FIKIPO4F.cjs → chunk-FAUVDMH4.cjs} +1 -1
  8. package/dist/{chunk-VUHPWSAE.cjs → chunk-FCT7VKWG.cjs} +25 -25
  9. package/dist/{chunk-SDV335EO.cjs → chunk-FFRFKWTZ.cjs} +4 -4
  10. package/dist/{chunk-XJD7IZR2.cjs → chunk-FS4TVAE7.cjs} +48 -48
  11. package/dist/{chunk-5IU64YEA.cjs → chunk-IX2D26OR.cjs} +39 -39
  12. package/dist/{chunk-ZXRAYCNB.cjs → chunk-KH5DRO4V.cjs} +3 -3
  13. package/dist/{chunk-AVAE5B2A.cjs → chunk-KVGWOJCX.cjs} +2 -2
  14. package/dist/{chunk-6YCUP6JJ.cjs → chunk-LTOSJI6B.cjs} +14 -14
  15. package/dist/{chunk-ND7ECICK.cjs → chunk-OEEFUB25.cjs} +70 -45
  16. package/dist/{chunk-EYE5FLHZ.cjs → chunk-OGUBSDU5.cjs} +11 -11
  17. package/dist/{chunk-6F2UHDCB.cjs → chunk-OUKKLSME.cjs} +3 -3
  18. package/dist/{chunk-W25OB2R6.cjs → chunk-PQNRSUQ6.cjs} +11 -11
  19. package/dist/{chunk-W5ZQDEDT.cjs → chunk-PZVBTLLQ.cjs} +147 -131
  20. package/dist/{chunk-PTQVGWJE.cjs → chunk-S7CBD6KF.cjs} +61 -61
  21. package/dist/{chunk-O6KQ64RI.cjs → chunk-UYGXJ5SQ.cjs} +2 -2
  22. package/dist/{chunk-WUBTAN27.cjs → chunk-WWWCFNKI.cjs} +68 -68
  23. package/dist/{chunk-KFDAL6NA.cjs → chunk-XAJPXPQ6.cjs} +2 -2
  24. package/dist/{chunk-ZOK4OWMJ.cjs → chunk-Y5XHMEBB.cjs} +2 -2
  25. package/dist/{chunk-T5OCU3EL.cjs → chunk-ZPVFFPQM.cjs} +4 -4
  26. package/dist/{cloud-tenants-XGL3DYSG.cjs → cloud-tenants-S3BDIJHM.cjs} +6 -6
  27. package/dist/components/case-studies/index.cjs +20 -20
  28. package/dist/components/chat/index.cjs +5 -5
  29. package/dist/components/contact/index.cjs +7 -7
  30. package/dist/components/docs/index.cjs +10 -10
  31. package/dist/components/embeds/index.cjs +7 -7
  32. package/dist/components/faq/index.cjs +8 -8
  33. package/dist/components/features/index.cjs +6 -6
  34. package/dist/components/help-center-pages/index.cjs +82 -82
  35. package/dist/components/index.cjs +52 -52
  36. package/dist/components/layout/page-heading.js +1 -1
  37. package/dist/components/loading/loading-fallback.d.ts +27 -3
  38. package/dist/components/loading/loading-fallback.d.ts.map +1 -1
  39. package/dist/components/loading/loading-fallback.js +17 -9
  40. package/dist/components/meeting-scheduler/index.cjs +38 -38
  41. package/dist/components/navigation/index.cjs +9 -9
  42. package/dist/components/onboarding-guides/index.cjs +9 -9
  43. package/dist/components/product-demo/index.cjs +15 -15
  44. package/dist/components/related-content/index.cjs +5 -5
  45. package/dist/components/tickets/index.cjs +13 -13
  46. package/dist/components/ui/fade-preview.d.ts.map +1 -1
  47. package/dist/components/ui/fade-preview.js +9 -2
  48. package/dist/components/ui/index.cjs +6 -6
  49. package/dist/components/ui/index.d.ts +1 -1
  50. package/dist/components/ui/index.d.ts.map +1 -1
  51. package/dist/components/ui/index.js +9 -1
  52. package/dist/components/ui/markdown-editor.d.ts.map +1 -1
  53. package/dist/components/ui/trendline.d.ts +1 -1
  54. package/dist/components/ui/trendline.d.ts.map +1 -1
  55. package/dist/components/ui/trendline.js +11 -2
  56. package/dist/{devices-U2NQYDI7.cjs → devices-C6OOVBJK.cjs} +7 -7
  57. package/dist/{embeddable-chat-MPJLN4C6.cjs → embeddable-chat-2EBDLEVA.cjs} +62 -62
  58. package/dist/index.cjs +10 -10
  59. package/dist/{knowledge-BUY6TSK6.cjs → knowledge-YA5SFLQP.cjs} +7 -7
  60. package/dist/loading-standard/engine.d.mts +22 -4
  61. package/dist/loading-standard/engine.d.mts.map +1 -1
  62. package/dist/loading-standard/rule-examples.d.mts.map +1 -1
  63. package/dist/{logs-FUPQ7XYE.cjs → logs-LQX2CNVB.cjs} +14 -14
  64. package/dist/{policies-NASADYBK.cjs → policies-LWAUO6NR.cjs} +10 -10
  65. package/dist/{scripts-BGLTDQKV.cjs → scripts-W46RQ64X.cjs} +11 -11
  66. package/dist/{software-update-QDIZ32KU.cjs → software-update-OVR26DUF.cjs} +9 -9
  67. package/dist/utils/index.cjs +16 -1
  68. package/dist/utils/markdown-to-plain.d.ts.map +1 -1
  69. package/dist/utils/markdown-to-plain.js +16 -1
  70. package/package.json +1 -1
  71. package/src/components/layout/page-heading.tsx +3 -1
  72. package/src/components/loading/loading-fallback.tsx +52 -12
  73. package/src/components/ui/fade-preview.tsx +13 -2
  74. package/src/components/ui/index.ts +13 -1
  75. package/src/components/ui/markdown-editor.tsx +1 -0
  76. package/src/components/ui/trendline.tsx +27 -10
  77. package/src/loading-standard/engine.mjs +170 -14
  78. package/src/loading-standard/rule-examples.mjs +50 -0
  79. package/src/utils/markdown-to-plain.ts +23 -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: {
@@ -61,6 +61,25 @@ const NOT_PROSE = new Set(['pre', 'img']);
61
61
 
62
62
  const TABLE_SECTIONS = new Set(['thead', 'tbody', 'tfoot']);
63
63
 
64
+ const element = (tagName: string, children: Element['children']): Element => ({
65
+ type: 'element',
66
+ tagName,
67
+ properties: {},
68
+ children,
69
+ });
70
+
71
+ /** Whether `toText` already breaks between a table's sections (current `hast-util-to-text` does; an older one ran
72
+ * the header row into the first body row). Asked once, of a one-cell header over a one-cell body. */
73
+ let sectionsBreak: boolean | undefined;
74
+ function toTextBreaksBetweenSections(): boolean {
75
+ if (sectionsBreak === undefined) {
76
+ const row = (text: string) => element('tr', [element('td', [{ type: 'text', value: text }])]);
77
+ const table = element('table', [element('thead', [row('a')]), element('tbody', [row('b')])]);
78
+ sectionsBreak = toText({ type: 'root', children: [table] }).includes('\n');
79
+ }
80
+ return sectionsBreak;
81
+ }
82
+
64
83
  /** The renderer's steps, as functions: markdown (GFM) → line breaks → HTML tree with raw HTML parsed. */
65
84
  function htmlTree(markdown: string): Root {
66
85
  const mdast = fromMarkdown(markdown, { extensions: [gfm()], mdastExtensions: [gfmFromMarkdown()] });
@@ -75,10 +94,10 @@ function proseTree(markdown: string): Root {
75
94
  parent.children.splice(index, 1);
76
95
  return [SKIP, index];
77
96
  }
78
- // `innerText` breaks between rows of the same `thead` / `tbody` only, so the last header row
79
- // ran into the first body row ("What it buysEnthusiast"). A section followed by another ends
80
- // its last row with a line break.
81
- if (TABLE_SECTIONS.has(node.tagName) && parent && index !== undefined) {
97
+ // An older `innerText` broke between rows of the same `thead` / `tbody` only, so the last header
98
+ // row ran into the first body row ("What it buysEnthusiast"). There, a section followed by
99
+ // another ends its last row with a line break; a current one breaks there itself.
100
+ if (TABLE_SECTIONS.has(node.tagName) && parent && index !== undefined && !toTextBreaksBetweenSections()) {
82
101
  const followedBySection = parent.children
83
102
  .slice(index + 1)
84
103
  .some(sibling => sibling.type === 'element' && TABLE_SECTIONS.has(sibling.tagName));