@flamingo-stack/openframe-frontend-core 0.0.798 → 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.
- package/dist/{chunk-PTQVGWJE.cjs → chunk-247LDSQE.cjs} +53 -53
- package/dist/{chunk-NK2FSEWD.cjs → chunk-2KEBGXA4.cjs} +4 -4
- package/dist/{chunk-6F2UHDCB.cjs → chunk-3MRK7X6Z.cjs} +3 -3
- package/dist/{chunk-WUBTAN27.cjs → chunk-4RK62AMV.cjs} +48 -48
- package/dist/{chunk-2M6HS23A.cjs → chunk-6CB3AXZM.cjs} +19 -19
- package/dist/{chunk-EYE5FLHZ.cjs → chunk-6EDOASF4.cjs} +6 -6
- package/dist/{chunk-6YCUP6JJ.cjs → chunk-B3X4J4HQ.cjs} +11 -11
- package/dist/{chunk-5IU64YEA.cjs → chunk-BSBCZIPQ.cjs} +39 -39
- package/dist/{chunk-FO3N6HDS.cjs → chunk-CS2KLF4O.cjs} +7 -7
- package/dist/{chunk-W5ZQDEDT.cjs → chunk-DBRXZC2I.cjs} +116 -107
- package/dist/{chunk-KFDAL6NA.cjs → chunk-FDDM5Z52.cjs} +2 -2
- package/dist/{chunk-ND7ECICK.cjs → chunk-GRNTIKPD.cjs} +17 -7
- package/dist/{chunk-TJQGKIXB.cjs → chunk-HB7FVY46.cjs} +32 -32
- package/dist/{chunk-BWTCULUN.cjs → chunk-IJGIWG6G.cjs} +4 -4
- package/dist/{chunk-W25OB2R6.cjs → chunk-PO5IIN4S.cjs} +9 -9
- package/dist/{chunk-VUHPWSAE.cjs → chunk-PPORXZI7.cjs} +18 -18
- package/dist/{chunk-ZXRAYCNB.cjs → chunk-TETW5NR4.cjs} +3 -3
- package/dist/{chunk-C2UZWRU5.cjs → chunk-UFCKY7OL.cjs} +10 -10
- package/dist/{cloud-tenants-XGL3DYSG.cjs → cloud-tenants-BQAVRN44.cjs} +4 -4
- package/dist/components/case-studies/index.cjs +16 -16
- package/dist/components/chat/index.cjs +3 -3
- package/dist/components/contact/index.cjs +5 -5
- package/dist/components/docs/index.cjs +8 -8
- package/dist/components/embeds/index.cjs +5 -5
- package/dist/components/faq/index.cjs +6 -6
- package/dist/components/features/index.cjs +4 -4
- package/dist/components/help-center-pages/index.cjs +61 -61
- package/dist/components/index.cjs +38 -38
- package/dist/components/loading/loading-fallback.d.ts +27 -3
- package/dist/components/loading/loading-fallback.d.ts.map +1 -1
- package/dist/components/loading/loading-fallback.js +17 -9
- package/dist/components/meeting-scheduler/index.cjs +29 -29
- package/dist/components/navigation/index.cjs +7 -7
- package/dist/components/onboarding-guides/index.cjs +6 -6
- package/dist/components/product-demo/index.cjs +13 -13
- package/dist/components/tickets/index.cjs +9 -9
- package/dist/components/ui/index.cjs +4 -4
- package/dist/components/ui/index.d.ts +1 -1
- package/dist/components/ui/index.d.ts.map +1 -1
- package/dist/components/ui/index.js +9 -1
- package/dist/components/ui/markdown-editor.d.ts.map +1 -1
- package/dist/components/ui/trendline.d.ts +1 -1
- package/dist/components/ui/trendline.d.ts.map +1 -1
- package/dist/components/ui/trendline.js +11 -2
- package/dist/{devices-U2NQYDI7.cjs → devices-KDT5ZGSG.cjs} +5 -5
- package/dist/{embeddable-chat-MPJLN4C6.cjs → embeddable-chat-ODKTSW3C.cjs} +59 -59
- package/dist/index.cjs +8 -8
- package/dist/{knowledge-BUY6TSK6.cjs → knowledge-4NLP77HP.cjs} +5 -5
- package/dist/loading-standard/engine.d.mts +22 -4
- package/dist/loading-standard/engine.d.mts.map +1 -1
- package/dist/loading-standard/rule-examples.d.mts.map +1 -1
- package/dist/{logs-FUPQ7XYE.cjs → logs-U6VMTY4N.cjs} +12 -12
- package/dist/{policies-NASADYBK.cjs → policies-TBLFBRFM.cjs} +8 -8
- package/dist/{scripts-BGLTDQKV.cjs → scripts-ZMNJWX7I.cjs} +9 -9
- package/dist/{software-update-QDIZ32KU.cjs → software-update-Q5AEQ4A4.cjs} +7 -7
- package/package.json +1 -1
- package/src/components/loading/loading-fallback.tsx +52 -12
- package/src/components/ui/index.ts +13 -1
- package/src/components/ui/markdown-editor.tsx +1 -0
- package/src/components/ui/trendline.tsx +27 -10
- package/src/loading-standard/engine.mjs +170 -14
- package/src/loading-standard/rule-examples.mjs +50 -0
|
@@ -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.
|
|
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)
|
|
143
|
-
// module is installed
|
|
144
|
-
|
|
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(
|
|
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
|
-
/**
|
|
1721
|
-
|
|
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,
|
|
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
|
|
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: {
|