@astryxdesign/cli 0.7.7-canary.c0929c8 → 0.7.7-canary.c19ca12

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 (25) hide show
  1. package/api/integration/authoring-checks.mjs +31 -0
  2. package/api/integration/check/check.mjs +8 -3
  3. package/assets/discover/official-packages.json +0 -4
  4. package/assets/templates/blocks/components/Hooks/useGridFocusHookUsage.doc.mjs +14 -0
  5. package/assets/templates/blocks/components/Hooks/useGridFocusHookUsage.tsx +86 -0
  6. package/assets/templates/blocks/components/Hooks/useOverflowHookUsage.doc.mjs +14 -0
  7. package/assets/templates/blocks/components/Hooks/useOverflowHookUsage.tsx +89 -0
  8. package/assets/templates/blocks/components/Hooks/usePressFeedbackHookUsage.tsx +24 -21
  9. package/assets/templates/blocks/components/Outline/useOutlineFromMarkdownHookUsage.doc.mjs +14 -0
  10. package/assets/templates/blocks/components/Outline/useOutlineFromMarkdownHookUsage.tsx +69 -0
  11. package/assets/templates/blocks/components/createAnimator/AnimatorPlayingCardsVanilla.doc.mjs +14 -0
  12. package/assets/templates/blocks/components/createAnimator/AnimatorPlayingCardsVanilla.tsx +199 -0
  13. package/assets/templates/blocks/components/useAnimator/AnimatorPlayingCards.doc.mjs +21 -0
  14. package/assets/templates/blocks/components/useAnimator/AnimatorPlayingCards.tsx +210 -0
  15. package/foundation/discovery/component-discovery.mjs +26 -6
  16. package/foundation/discovery/doc-types.mjs +4 -2
  17. package/foundation/discovery/prop-drift.mjs +6 -0
  18. package/foundation/discovery/source-file-cache.d.mts +15 -0
  19. package/foundation/discovery/source-file-cache.mjs +140 -0
  20. package/foundation/discovery/template-adapter.d.mts +7 -3
  21. package/foundation/discovery/template-adapter.mjs +150 -10
  22. package/foundation/fs/listing-cache.d.mts +15 -0
  23. package/foundation/fs/listing-cache.mjs +50 -1
  24. package/foundation/fs/paths.mjs +50 -5
  25. package/package.json +9 -9
@@ -0,0 +1,210 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ 'use client';
4
+
5
+ import {useRef, useState} from 'react';
6
+ import type {PointerEvent} from 'react';
7
+ import {Button} from '@astryxdesign/core/Button';
8
+ import {Card} from '@astryxdesign/core/Card';
9
+ import {useAnimator} from '@astryxdesign/core/hooks';
10
+ import {HStack, VStack} from '@astryxdesign/core/Layout';
11
+ import {Text} from '@astryxdesign/core/Text';
12
+ import {VisuallyHidden} from '@astryxdesign/core/VisuallyHidden';
13
+
14
+ const DECK = [
15
+ {rank: 'A', suit: '\u2660', name: 'Ace of spades'},
16
+ {rank: 'K', suit: '\u2665', name: 'King of hearts'},
17
+ {rank: 'Q', suit: '\u2663', name: 'Queen of clubs'},
18
+ {rank: 'J', suit: '\u2666', name: 'Jack of diamonds'},
19
+ ];
20
+
21
+ /** A release faster than this (px/s) throws the card away. */
22
+ const THROW_SPEED = 1000;
23
+ /** The slowest throw, so a thrown card always leaves the table. */
24
+ const MIN_THROW = 1600;
25
+
26
+ interface Sample {
27
+ t: number;
28
+ x: number;
29
+ y: number;
30
+ }
31
+
32
+ /**
33
+ * The release velocity in px/s, over the 80 ms before the release: a finger
34
+ * that held still before letting go releases at rest.
35
+ */
36
+ function releaseVelocity(
37
+ samples: Sample[],
38
+ releasedAt: number,
39
+ ): {x: number; y: number} {
40
+ const recent = samples.filter(s => releasedAt - s.t <= 80);
41
+ const first = recent[0];
42
+ const last = recent.at(-1);
43
+ if (last == null || first == null || last.t === first.t) {
44
+ return {x: 0, y: 0};
45
+ }
46
+ const seconds = (last.t - first.t) / 1000;
47
+ return {x: (last.x - first.x) / seconds, y: (last.y - first.y) / seconds};
48
+ }
49
+
50
+ export default function AnimatorPlayingCards() {
51
+ const ref = useRef<HTMLDivElement>(null);
52
+ const animator = useAnimator(ref);
53
+ const [top, setTop] = useState(0);
54
+ const [status, setStatus] = useState('');
55
+ const drag = useRef<{start: Sample; samples: Sample[]} | null>(null);
56
+ // One discard at a time: a press while a card leaves deals no second card.
57
+ const discarding = useRef(false);
58
+ const card = DECK[top % DECK.length];
59
+
60
+ // Announces the discard and deals the next card in place of the old one.
61
+ const dealNext = async () => {
62
+ setStatus(`${card.name} discarded`);
63
+ setTop(index => index + 1);
64
+ animator.set({x: 0, y: 0, rotate: 0, scale: 0.9, opacity: 0});
65
+ discarding.current = false;
66
+ await animator.animate({scale: 1, opacity: 1});
67
+ };
68
+
69
+ // Starts a discard unless one runs. It also ends a drag in progress: the
70
+ // drag's next move would take the discard's motion over and drag the dealt
71
+ // card.
72
+ const startDiscard = () => {
73
+ if (discarding.current) {
74
+ return false;
75
+ }
76
+ discarding.current = true;
77
+ drag.current = null;
78
+ return true;
79
+ };
80
+
81
+ // Throws the card away on its release velocity, then deals the next one.
82
+ const discard = async (velocity: {x: number; y: number}) => {
83
+ if (!startDiscard()) {
84
+ return;
85
+ }
86
+ const speed = Math.hypot(velocity.x, velocity.y);
87
+ const boost = speed < MIN_THROW ? MIN_THROW / Math.max(speed, 1) : 1;
88
+ const throwX = speed < 1 ? MIN_THROW : velocity.x * boost;
89
+ // The card coasts on while it fades; once it is gone, the next card is
90
+ // dealt in place, which ends the coast. A coast continues the person's
91
+ // throw, so Reduce Motion keeps it.
92
+ void animator.decay({x: throwX, y: velocity.y * boost});
93
+ await animator.animate({opacity: 0});
94
+ await dealNext();
95
+ };
96
+
97
+ // The button moves the card off on the state-change motion: a planned
98
+ // move, which Reduce Motion turns into a fade where the card is.
99
+ const discardWithButton = async () => {
100
+ if (!startDiscard()) {
101
+ return;
102
+ }
103
+ await animator.animate({x: 400, opacity: 0});
104
+ await dealNext();
105
+ };
106
+
107
+ const onPointerDown = (event: PointerEvent<HTMLDivElement>) => {
108
+ // A leaving card takes no press. Pinning it would end its discard and deal
109
+ // the next card under the finger.
110
+ if (discarding.current) {
111
+ return;
112
+ }
113
+ event.currentTarget.setPointerCapture(event.pointerId);
114
+ // Pins the card where it shows, so the drag starts there. Only the
115
+ // position stops, so a card fading in keeps fading in.
116
+ const {x, y, rotate} = animator.get();
117
+ animator.set({x, y, rotate});
118
+ const start = {
119
+ t: event.timeStamp,
120
+ x: event.clientX - x,
121
+ y: event.clientY - y,
122
+ };
123
+ drag.current = {start, samples: []};
124
+ };
125
+
126
+ const onPointerMove = (event: PointerEvent<HTMLDivElement>) => {
127
+ const current = drag.current;
128
+ if (current == null) {
129
+ return;
130
+ }
131
+ const x = event.clientX - current.start.x;
132
+ const y = event.clientY - current.start.y;
133
+ current.samples.push({t: event.timeStamp, x, y});
134
+ // The card follows the finger, turning a little with the drag.
135
+ animator.set({x, y, rotate: x / 18});
136
+ };
137
+
138
+ // A cancelled pointer was not let go, so the card springs back.
139
+ const onPointerCancel = () => {
140
+ if (drag.current == null) {
141
+ return;
142
+ }
143
+ drag.current = null;
144
+ void animator.animate({x: 0, y: 0, rotate: 0});
145
+ };
146
+
147
+ const onPointerUp = (event: PointerEvent<HTMLDivElement>) => {
148
+ const current = drag.current;
149
+ drag.current = null;
150
+ if (current == null) {
151
+ return;
152
+ }
153
+ const velocity = releaseVelocity(current.samples, event.timeStamp);
154
+ if (Math.abs(velocity.x) > THROW_SPEED) {
155
+ void discard(velocity);
156
+ } else {
157
+ // A gentle release springs back, carrying on as it was let go.
158
+ void animator.animate({x: 0, y: 0, rotate: 0}, {velocity});
159
+ }
160
+ };
161
+
162
+ return (
163
+ <VStack gap={4} style={{maxWidth: 360, padding: 16}}>
164
+ <Text type="body">
165
+ Drag the card and let go. A gentle release springs it back; a quick
166
+ flick throws it away.
167
+ </Text>
168
+ <div style={{height: 200, display: 'grid', placeItems: 'center'}}>
169
+ <Card
170
+ ref={ref}
171
+ width={120}
172
+ minHeight={170}
173
+ onPointerDown={onPointerDown}
174
+ onPointerMove={onPointerMove}
175
+ onPointerUp={onPointerUp}
176
+ onPointerCancel={onPointerCancel}
177
+ style={{touchAction: 'none', cursor: 'grab', userSelect: 'none'}}
178
+ role="img"
179
+ aria-label={card.name}>
180
+ <VStack gap={1} hAlign="center" style={{paddingBlock: 40}}>
181
+ <Text type="display-2" weight="bold">
182
+ {card.rank}
183
+ </Text>
184
+ <Text type="display-3">{card.suit}</Text>
185
+ </VStack>
186
+ </Card>
187
+ </div>
188
+ <HStack gap={2}>
189
+ <Button
190
+ label={`Discard ${card.name}`}
191
+ variant="secondary"
192
+ onClick={() => void discardWithButton()}
193
+ />
194
+ <Button
195
+ label="Shake"
196
+ variant="ghost"
197
+ onClick={() =>
198
+ void animator.animate(
199
+ {x: 0, rotate: 0},
200
+ {velocity: {x: 900, rotate: 300}},
201
+ )
202
+ }
203
+ />
204
+ </HStack>
205
+ <VisuallyHidden as="div" aria-live="polite">
206
+ {status}
207
+ </VisuallyHidden>
208
+ </VStack>
209
+ );
210
+ }
@@ -8,7 +8,12 @@ import * as fs from 'node:fs';
8
8
  import {createRequire} from 'node:module';
9
9
  import * as path from 'node:path';
10
10
  import {DOC_EXPORTS} from '../doc-compiler/read.mjs';
11
- import {listDir, listDirEntries, pathExists} from '../fs/listing-cache.mjs';
11
+ import {
12
+ listDir,
13
+ listDirEntries,
14
+ pathExists,
15
+ withListingCache,
16
+ } from '../fs/listing-cache.mjs';
12
17
  import {existsCaseExact} from '../fs/paths.mjs';
13
18
  import {CORE_PROVIDER_ID} from '../identity/providers.mjs';
14
19
  import {loadComponentDoc} from './component-loader.mjs';
@@ -595,20 +600,25 @@ export function findComponentSource(coreDir, name) {
595
600
  * @param {string} dirPath
596
601
  * @returns {string | null}
597
602
  */
598
- function searchDir(dirPath) {
599
- if (!pathExists(dirPath)) return null;
603
+ function searchDir(dirPath, listed = false) {
604
+ // A folder from its parent's listing exists; only a starting folder
605
+ // needs the check.
606
+ if (!listed && !pathExists(dirPath)) return null;
600
607
  const entries = listDirEntries(dirPath);
601
608
 
602
- // Check for an exact match (prefixed or bare) first
609
+ // Check for an exact match (prefixed or bare) first. The listing in hand
610
+ // holds every name in the folder, so no name is probed on disk.
603
611
  for (const candidate of candidateFiles) {
612
+ const entry = entries.find(e => e.name === candidate);
613
+ if (!entry) continue;
604
614
  const exact = path.join(dirPath, candidate);
605
- if (existsCaseExact(exact, dirPath)) return exact;
615
+ if (!entry.isSymbolicLink() || pathExists(exact)) return exact;
606
616
  }
607
617
 
608
618
  // Recurse into subdirectories
609
619
  for (const entry of entries) {
610
620
  if (entry.isDirectory()) {
611
- const found = searchDir(path.join(dirPath, entry.name));
621
+ const found = searchDir(path.join(dirPath, entry.name), true);
612
622
  if (found) return found;
613
623
  }
614
624
  }
@@ -1703,6 +1713,16 @@ export function unscopedComponentOwners(owners) {
1703
1713
  * @returns {Array<{name: string, package: string, group: string|null, docPath: string|null, sourcePath: string|null, issuesUrl: string|undefined}>}
1704
1714
  */
1705
1715
  export function discoverOwnedComponents(coreDir, loadedIntegrations = []) {
1716
+ // Read-only: one listing of each folder serves the whole discovery.
1717
+ return withListingCache(() => ownedComponents(coreDir, loadedIntegrations));
1718
+ }
1719
+
1720
+ /**
1721
+ * @param {string} coreDir
1722
+ * @param {Array<{name: string, components?: string, issuesUrl?: string}>} loadedIntegrations
1723
+ * @returns {Array<{name: string, package: string, group: string|null, docPath: string|null, sourcePath: string|null, issuesUrl: string|undefined}>}
1724
+ */
1725
+ function ownedComponents(coreDir, loadedIntegrations) {
1706
1726
  /** @type {Array<{name: string, package: string, group: string|null, docPath: string|null, sourcePath: string|null, issuesUrl: string|undefined}>} */
1707
1727
  const records = [];
1708
1728
 
@@ -45,6 +45,7 @@ import {
45
45
  TYPESCRIPT_FIX,
46
46
  unusableTypeScriptReason,
47
47
  } from './project-typescript.mjs';
48
+ import {keepSourceFiles} from './source-file-cache.mjs';
48
49
 
49
50
  /**
50
51
  * @typedef {'components' | 'hooks' | 'templates' | 'docs' | 'docs-overlay' | 'themes' | 'icon-sets'} DocRoot
@@ -1035,8 +1036,9 @@ export async function checkDocTypes(files, options) {
1035
1036
  paths: {[AUTHORING]: [AUTHORING_TYPES]},
1036
1037
  };
1037
1038
  const host = ts.createCompilerHost(options_);
1038
- const getSourceFile = host.getSourceFile.bind(host);
1039
- // Every other file is parsed once, so a later pass reuses it.
1039
+ // Every other file is parsed once, so a later pass reuses it; and once per
1040
+ // process for these options, so a later check does too.
1041
+ const getSourceFile = keepSourceFiles(ts, host, options_);
1040
1042
  /** @type {Map<string, any>} */
1041
1043
  const parsed = new Map();
1042
1044
  host.getSourceFile = (
@@ -54,6 +54,7 @@ import {
54
54
  TYPESCRIPT_FIX,
55
55
  unusableTypeScriptReason,
56
56
  } from './project-typescript.mjs';
57
+ import {keepSourceFiles} from './source-file-cache.mjs';
57
58
  import {judgeType} from './type-match.mjs';
58
59
  import {typeTextTooOld} from './type-text.mjs';
59
60
  import {
@@ -1802,6 +1803,10 @@ export function comparePropTables(tables, options) {
1802
1803
  typesNotCompared: [],
1803
1804
  };
1804
1805
  }
1806
+ // Parsed once per process for these options: every check reads the same
1807
+ // library and package declarations.
1808
+ const host = ts.createCompilerHost(project.options);
1809
+ host.getSourceFile = keepSourceFiles(ts, host, project.options);
1805
1810
  const program = ts.createProgram({
1806
1811
  rootNames: [
1807
1812
  ...new Set([
@@ -1810,6 +1815,7 @@ export function comparePropTables(tables, options) {
1810
1815
  ]),
1811
1816
  ],
1812
1817
  options: project.options,
1818
+ host,
1813
1819
  });
1814
1820
  const checker = program.getTypeChecker();
1815
1821
  const isOwnFile = ownFileTest(root);
@@ -0,0 +1,15 @@
1
+ // @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
2
+ // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
+
4
+ /**
5
+ * `host.getSourceFile`, keeping each file it parses while the file's stamp is
6
+ * the same, for every program whose options parse and bind a file as
7
+ * `options` do. A kept file still counts as read by the running operation
8
+ * (`recordContentRead`), as a parse would. On a TypeScript older than 5.3 the
9
+ * host's own `getSourceFile` is returned.
10
+ * @param {any} ts the project's own `typescript`
11
+ * @param {any} host
12
+ * @param {any} options the compiler options of the programs that use it
13
+ * @returns {(fileName: string, languageVersionOrOptions: any, onError?: any, shouldCreate?: boolean) => any}
14
+ */
15
+ export function keepSourceFiles(ts: any, host: any, options: any): (fileName: string, languageVersionOrOptions: any, onError?: any, shouldCreate?: boolean) => any;
@@ -0,0 +1,140 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file source-file-cache.mjs
5
+ * @input A TypeScript compiler host, the project's own `typescript`, and the
6
+ * compiler options its programs use
7
+ * @output `keepSourceFiles`: the host's `getSourceFile`, keeping each parsed
8
+ * file while its stamp (`fileStamp`) is the same, for every program in this
9
+ * process whose options parse and bind a file alike.
10
+ * @position The props comparison (./prop-drift.mjs) and the doc types check
11
+ * (./doc-types.mjs) build a program for every check, and each parsed the
12
+ * same declarations again: the TypeScript library's, React's, the
13
+ * authoring types. A process that checks more than once (a test run, a
14
+ * long-running caller, a check over several roots) now parses each once.
15
+ * TypeScript's language service shares parsed files between programs the
16
+ * same way; from 5.3 a program keeps what it resolved for a file itself, not
17
+ * on the file, which is what makes sharing them safe across programs.
18
+ */
19
+
20
+ import path from 'node:path';
21
+ import {fileStamp, recordContentRead} from '../fs/read-record.mjs';
22
+
23
+ /**
24
+ * The files kept, per TypeScript and per how the options parse and bind a
25
+ * file (`settingsKey`), the most recently used options last.
26
+ * @type {WeakMap<object, Map<string, Map<string, {stamp: string, sourceFile: any}>>>}
27
+ */
28
+ const kept = new WeakMap();
29
+
30
+ /** The most files kept for one key; the oldest go first. */
31
+ const MAX_FILES = 5000;
32
+
33
+ /**
34
+ * The most keys kept per TypeScript; the least recently used go first. Each
35
+ * holds its own parse of the TypeScript library's declarations, the largest
36
+ * files a program reads.
37
+ */
38
+ const MAX_KEYS = 8;
39
+
40
+ /** @type {WeakMap<object, any>} one document registry per TypeScript */
41
+ const registries = new WeakMap();
42
+
43
+ /**
44
+ * What in `options` decides how a file parses and binds: the key TypeScript's
45
+ * language service shares parsed files by (its document registry's), and
46
+ * whether a script binds in strict mode, which that key reads only from an
47
+ * explicit `alwaysStrict`. Options that only resolve or check (`paths`,
48
+ * `types`, `lib`, the strict checks) do not change it.
49
+ * @param {any} ts
50
+ * @param {any} options
51
+ * @returns {string}
52
+ */
53
+ function settingsKey(ts, options) {
54
+ let registry = registries.get(ts);
55
+ if (registry == null) {
56
+ registry = ts.createDocumentRegistry();
57
+ registries.set(ts, registry);
58
+ }
59
+ const strict =
60
+ typeof ts.getStrictOptionValue === 'function'
61
+ ? ts.getStrictOptionValue(options, 'alwaysStrict')
62
+ : (options.alwaysStrict ?? options.strict ?? false);
63
+ return `${registry.getKeyForCompilationSettings(options)}|${strict ? 1 : 0}`;
64
+ }
65
+
66
+ /**
67
+ * Whether this TypeScript keeps a program's module resolutions on the program
68
+ * (5.3 and later) rather than on the parsed files it shares.
69
+ * @param {any} ts
70
+ */
71
+ function sharesSafely(ts) {
72
+ const [major, minor] = String(ts.versionMajorMinor ?? '0.0')
73
+ .split('.')
74
+ .map(Number);
75
+ return major > 5 || (major === 5 && minor >= 3);
76
+ }
77
+
78
+ /**
79
+ * `host.getSourceFile`, keeping each file it parses while the file's stamp is
80
+ * the same, for every program whose options parse and bind a file as
81
+ * `options` do. A kept file still counts as read by the running operation
82
+ * (`recordContentRead`), as a parse would. On a TypeScript older than 5.3 the
83
+ * host's own `getSourceFile` is returned.
84
+ * @param {any} ts the project's own `typescript`
85
+ * @param {any} host
86
+ * @param {any} options the compiler options of the programs that use it
87
+ * @returns {(fileName: string, languageVersionOrOptions: any, onError?: any, shouldCreate?: boolean) => any}
88
+ */
89
+ export function keepSourceFiles(ts, host, options) {
90
+ const getSourceFile = host.getSourceFile.bind(host);
91
+ if (!sharesSafely(ts)) return getSourceFile;
92
+ let bySettings = kept.get(ts);
93
+ if (bySettings == null) {
94
+ bySettings = new Map();
95
+ kept.set(ts, bySettings);
96
+ }
97
+ const settings = settingsKey(ts, options);
98
+ const byFile = bySettings.get(settings) ?? new Map();
99
+ // Most recently used last; past MAX_KEYS, the least recently used go.
100
+ bySettings.delete(settings);
101
+ bySettings.set(settings, byFile);
102
+ if (bySettings.size > MAX_KEYS) {
103
+ bySettings.delete(/** @type {string} */ (bySettings.keys().next().value));
104
+ }
105
+ return (fileName, languageVersionOrOptions, onError, shouldCreate) => {
106
+ // How the file parses: its language version and, from TypeScript 5.0,
107
+ // its module format and JSDoc parsing (the module detection the options
108
+ // give is in `settings`).
109
+ const parse =
110
+ languageVersionOrOptions != null &&
111
+ typeof languageVersionOrOptions === 'object'
112
+ ? [
113
+ languageVersionOrOptions.languageVersion,
114
+ languageVersionOrOptions.impliedNodeFormat,
115
+ languageVersionOrOptions.jsDocParsingMode,
116
+ ]
117
+ : [languageVersionOrOptions];
118
+ const key = `${path.resolve(fileName)}\0${JSON.stringify(parse)}`;
119
+ const stamp = fileStamp(fileName);
120
+ const seen = byFile.get(key);
121
+ if (seen != null && stamp !== '-' && seen.stamp === stamp) {
122
+ recordContentRead(fileName);
123
+ return seen.sourceFile;
124
+ }
125
+ const sourceFile = getSourceFile(
126
+ fileName,
127
+ languageVersionOrOptions,
128
+ onError,
129
+ shouldCreate,
130
+ );
131
+ byFile.delete(key);
132
+ if (sourceFile != null && stamp !== '-') {
133
+ byFile.set(key, {stamp, sourceFile});
134
+ if (byFile.size > MAX_FILES) {
135
+ byFile.delete(/** @type {string} */ (byFile.keys().next().value));
136
+ }
137
+ }
138
+ return sourceFile;
139
+ };
140
+ }
@@ -69,7 +69,11 @@ export function replaceDemoMedia(source: string, { videoPlaceholder }?: {
69
69
  /**
70
70
  * Replace each JSX element imported from {@link DEMO_CONTENT_MODULE} with a
71
71
  * generic `<Text>` placeholder and remove that import, so emitted source never
72
- * depends on content only Astryx's previews provide.
72
+ * depends on content only Astryx's previews provide. An element that wraps one
73
+ * element, such as a hint shown under a demo, is removed instead: its child
74
+ * takes its place, with the indentation the child would have had without it.
75
+ * `demoContentReplaced` counts the placeholders, because only they need the
76
+ * consumer's own content.
73
77
  *
74
78
  * Every check resolves a name to its binding through the module's scope, so a
75
79
  * local declaration or parameter with the same name never counts as the same
@@ -79,12 +83,12 @@ export function replaceDemoMedia(source: string, { videoPlaceholder }?: {
79
83
  * writes the name `Text`.
80
84
  *
81
85
  * Only a plain static use is replaced: a named import used only as a JSX tag
82
- * whose children, if any, are whitespace, and whose props are literal values or
86
+ * whose children are whitespace or one element, and whose props are literal values or
83
87
  * read only bindings that code outside the replaced elements still reads. So
84
88
  * `faceDown={!isOpen}` is safe when the same `isOpen` is also read elsewhere.
85
89
  * Anything else (a namespace or type import, a re-export, a dynamic import, the
86
90
  * element used as a value or a type, a spread or computed prop, a prop whose
87
- * binding nothing else reads, children) throws, naming the element, rather than
91
+ * binding nothing else reads, other children) throws, naming the element, rather than
88
92
  * leaving a reference behind, leaving a binding unused, or dropping code the
89
93
  * rest of the file relies on. Source that never names the module is returned
90
94
  * as is.