@mui/internal-docs-infra 0.10.1-canary.1 → 0.10.1-canary.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/internal-docs-infra",
3
- "version": "0.10.1-canary.1",
3
+ "version": "0.10.1-canary.3",
4
4
  "author": "MUI Team",
5
5
  "description": "MUI Infra - internal documentation creation tools.",
6
6
  "license": "MIT",
@@ -643,5 +643,5 @@
643
643
  "bin": {
644
644
  "docs-infra": "./cli/index.mjs"
645
645
  },
646
- "gitSha": "eb63c846936de0d8b339188c5191c2c524357cc7"
646
+ "gitSha": "cad4d117211040086fea5435a525d50f80a8cf34"
647
647
  }
@@ -587,7 +587,11 @@ function calculateEmphasizedLines(directives, lineElements) {
587
587
  lineHighlight: directive.lineHighlight,
588
588
  focus: directive.focus,
589
589
  paddingFrameMaxSize: directive.paddingFrameMaxSize,
590
- focusFramesMaxSize: directive.focusFramesMaxSize
590
+ focusFramesMaxSize: directive.focusFramesMaxSize,
591
+ // Treat a single `@highlight` as a containing highlight range of depth 1
592
+ // so that an outer multiline range wrapping this line is detected as
593
+ // nesting and promoted to `strong`.
594
+ containingRangeDepth: directive.lineHighlight ? 1 : undefined
591
595
  });
592
596
  } else if (directive.type === 'text') {
593
597
  // Text highlight - emphasize specific text(s) within the line.
@@ -640,7 +644,12 @@ function calculateEmphasizedLines(directives, lineElements) {
640
644
 
641
645
  // Determine position for this line in the current range
642
646
  let position;
643
- if (line === startLine && line !== endLine) {
647
+ if (line === startLine && line === endLine) {
648
+ // A multiline range that resolves to a single content line (e.g.
649
+ // when comment-only lines are stripped) should be treated as a
650
+ // standalone single-line highlight.
651
+ position = 'single';
652
+ } else if (line === startLine && line !== endLine) {
644
653
  position = 'start';
645
654
  } else if (line === endLine && line !== startLine) {
646
655
  position = 'end';
@@ -651,13 +660,20 @@ function calculateEmphasizedLines(directives, lineElements) {
651
660
  // A focus range overlapping with a highlight is not nesting — it just
652
661
  // merges focus into the existing entry.
653
662
  const meta = existing ? {
654
- // Nested highlight ranges are strong; focus+highlight overlap is not
655
- strong: existing.lineHighlight && startDirective.lineHighlight && !existing.highlightTexts || existing.strong || strong,
663
+ // Nested highlight ranges are strong; focus+highlight overlap is not.
664
+ // Detect true nesting via `containingRangeDepth` rather than
665
+ // `existing.lineHighlight`. This works when the existing entry
666
+ // came from a `@highlight-text` directive on a line that's also
667
+ // wrapped in a highlight range — `existing.lineHighlight` is true
668
+ // after the first range merge, so a second wrapping range needs to
669
+ // see the depth to know nesting occurred.
670
+ strong: (existing.containingRangeDepth ?? 0) >= 1 && startDirective.lineHighlight || existing.strong || strong,
656
671
  description: existing.description ?? (line === startLine ? description : undefined),
657
672
  // Inner range position takes precedence, but 'single' from a standalone
658
673
  // @highlight-text should be replaced by the multiline range's position.
659
- // Keep 'single' from regular @highlight (no highlightTexts).
660
- position: existing.position && !(existing.position === 'single' && existing.highlightTexts) ? existing.position : position,
674
+ // Keep 'single' from a real @highlight (lineHighlight is set), even when
675
+ // the line also carries @highlight-text.
676
+ position: existing.position && !(existing.position === 'single' && existing.highlightTexts && !existing.lineHighlight) ? existing.position : position,
661
677
  highlightTexts: existing.highlightTexts,
662
678
  // Preserve text highlights from @highlight-text
663
679
  lineHighlight: existing.lineHighlight || startDirective.lineHighlight,
@@ -682,7 +698,10 @@ function calculateEmphasizedLines(directives, lineElements) {
682
698
  focus: startDirective.focus,
683
699
  paddingFrameMaxSize: startDirective.paddingFrameMaxSize,
684
700
  focusFramesMaxSize: startDirective.focusFramesMaxSize,
685
- propagatedOverride: true
701
+ propagatedOverride: true,
702
+ // Track depth so a wrapping outer range can detect nesting
703
+ // (used by the `strong` calculation above).
704
+ containingRangeDepth: startDirective.lineHighlight ? 1 : undefined
686
705
  };
687
706
  emphasizedLines.set(line, meta);
688
707
  }
@@ -25,7 +25,9 @@ export declare function getLockPath(socketDir?: string): string;
25
25
  export declare function ensureSocketDir(socketDir?: string): Promise<void>;
26
26
  /**
27
27
  * Wait for the IPC endpoint to become available.
28
- * On Unix: Watches for the socket file to appear.
28
+ * On Unix: Polls the filesystem for the socket file to appear. We avoid
29
+ * `fs.watch` here because on macOS it does not reliably fire events when a
30
+ * unix domain socket file is created.
29
31
  * On Windows: Polls by attempting to connect to the named pipe.
30
32
  * @param socketDir - Optional custom directory for socket files (Unix only)
31
33
  * @param timeoutMs - Timeout in milliseconds (default: 5000)
@@ -9,7 +9,6 @@
9
9
  */
10
10
 
11
11
  import { connect } from 'node:net';
12
- import { watch } from 'node:fs';
13
12
  import { mkdir, stat } from 'node:fs/promises';
14
13
  import { createHash } from 'node:crypto';
15
14
  import { tmpdir } from 'node:os';
@@ -128,57 +127,42 @@ function sleep(ms) {
128
127
 
129
128
  /**
130
129
  * Wait for the IPC endpoint to become available.
131
- * On Unix: Watches for the socket file to appear.
130
+ * On Unix: Polls the filesystem for the socket file to appear. We avoid
131
+ * `fs.watch` here because on macOS it does not reliably fire events when a
132
+ * unix domain socket file is created.
132
133
  * On Windows: Polls by attempting to connect to the named pipe.
133
134
  * @param socketDir - Optional custom directory for socket files (Unix only)
134
135
  * @param timeoutMs - Timeout in milliseconds (default: 5000)
135
136
  */
136
137
  export async function waitForSocketFile(socketDir, timeoutMs = 5000) {
137
138
  const socketPath = getSocketPath(socketDir);
139
+ const pollInterval = 50;
140
+ const startTime = Date.now();
138
141
  if (isWindows) {
139
- // On Windows, named pipes don't create files - poll by trying to connect
140
- const startTime = Date.now();
141
- const pollInterval = 100; // ms
142
-
143
142
  while (Date.now() - startTime < timeoutMs) {
144
143
  // eslint-disable-next-line no-await-in-loop
145
144
  if (await tryConnectToPipe(socketPath)) {
146
145
  return;
147
146
  }
148
-
149
- // Wait before next poll
150
147
  // eslint-disable-next-line no-await-in-loop
151
148
  await sleep(pollInterval);
152
149
  }
153
150
  throw new Error(`Named pipe did not become available within ${timeoutMs}ms`);
154
151
  }
155
152
 
156
- // Unix: Check if socket file already exists
157
- if (await fileExists(socketPath)) {
158
- return;
159
- }
160
-
161
- // Ensure the directory exists before watching
162
- const dir = getEffectiveSocketDir(socketDir);
163
- await mkdir(dir, {
153
+ // Ensure the directory exists so the first stat doesn't fail spuriously
154
+ await mkdir(getEffectiveSocketDir(socketDir), {
164
155
  recursive: true
165
156
  });
166
- await new Promise((resolve, reject) => {
167
- let timer;
168
-
169
- // Watch the directory for the socket file to appear
170
- const watcher = watch(dir, (eventType, filename) => {
171
- if (filename && (filename.includes('types.sock') || isWindows && filename.includes('types'))) {
172
- clearTimeout(timer);
173
- watcher.close();
174
- resolve();
175
- }
176
- });
177
- timer = setTimeout(() => {
178
- watcher.close();
179
- reject(new Error(`Socket file did not appear within ${timeoutMs}ms`));
180
- }, timeoutMs);
181
- });
157
+ while (Date.now() - startTime < timeoutMs) {
158
+ // eslint-disable-next-line no-await-in-loop
159
+ if (await fileExists(socketPath)) {
160
+ return;
161
+ }
162
+ // eslint-disable-next-line no-await-in-loop
163
+ await sleep(pollInterval);
164
+ }
165
+ throw new Error(`Socket file did not appear within ${timeoutMs}ms`);
182
166
  }
183
167
 
184
168
  // Store the release function globally so we can call it when needed