@mui/internal-docs-infra 0.13.1-canary.1 → 0.13.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/CodeHighlighter/buildStringFallback.mjs +1 -1
- package/package.json +2 -2
- package/pipeline/parseSource/createPlainTextRoot.d.mts +18 -0
- package/pipeline/parseSource/createPlainTextRoot.mjs +38 -0
- package/pipeline/parseSource/parseSource.d.mts +2 -18
- package/pipeline/parseSource/parseSource.mjs +2 -33
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { buildRootFallback } from "./fallbackFormat.mjs";
|
|
2
|
-
import { parsePlainText } from "../pipeline/parseSource/
|
|
2
|
+
import { parsePlainText } from "../pipeline/parseSource/createPlainTextRoot.mjs";
|
|
3
3
|
function isPromiseLike(value) {
|
|
4
4
|
return typeof value === 'object' && value !== null && typeof value.then === 'function';
|
|
5
5
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/internal-docs-infra",
|
|
3
|
-
"version": "0.13.1-canary.
|
|
3
|
+
"version": "0.13.1-canary.3",
|
|
4
4
|
"author": "MUI Team",
|
|
5
5
|
"description": "MUI Infra - internal documentation creation tools.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -814,5 +814,5 @@
|
|
|
814
814
|
"bin": {
|
|
815
815
|
"docs-infra": "./cli/index.mjs"
|
|
816
816
|
},
|
|
817
|
-
"gitSha": "
|
|
817
|
+
"gitSha": "d81524e8f3c59df916d9e262bdad83961cb98512"
|
|
818
818
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ParseSource } from "../../CodeHighlighter/types.mjs";
|
|
2
|
+
export declare function createPlainTextRoot(source: string): ReturnType<ParseSource>;
|
|
3
|
+
/**
|
|
4
|
+
* Parses source into a line-guttered HAST **without** syntax highlighting — the
|
|
5
|
+
* raw text wrapped in the same `.line`/`.frame` structure `parseSource` produces,
|
|
6
|
+
* just no starry-night tokenization. It is a `ParseSource` so it can be dropped
|
|
7
|
+
* into the loader in place of the highlighting parser.
|
|
8
|
+
*
|
|
9
|
+
* Used for the deferred (un-highlighted) fallback: the enhancer pipeline needs the
|
|
10
|
+
* line/frame structure to compute focus windows and truncation, but the syntax
|
|
11
|
+
* colors are exactly the part being deferred — so we skip them. Cheap (no grammar,
|
|
12
|
+
* no `getInstance`); the frames it produces collapse back to text via `buildRootFallback`.
|
|
13
|
+
*
|
|
14
|
+
* Takes only `source` (it ignores file name / language since it never highlights) but
|
|
15
|
+
* stays structurally assignable to `ParseSource`, so it drops into the loader in place
|
|
16
|
+
* of the highlighting parser.
|
|
17
|
+
*/
|
|
18
|
+
export declare const parsePlainText: (source: string) => ReturnType<ParseSource>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { starryNightGutter } from "./addLineGutters.mjs";
|
|
2
|
+
|
|
3
|
+
// Lives apart from `parseSource.ts` so callers that only need plain text (the
|
|
4
|
+
// server fallback in `buildStringFallback`) don't statically pull the Starry
|
|
5
|
+
// Night engine (vscode-textmate + oniguruma + grammars) into the page bundle.
|
|
6
|
+
//
|
|
7
|
+
// Builds the plain-text HAST fallback used for unsupported file types and for a
|
|
8
|
+
// mapped-but-not-yet-registered scope. Line gutters are still added so the
|
|
9
|
+
// enhancer pipeline (e.g. auto-focus frames) can operate on the result.
|
|
10
|
+
export function createPlainTextRoot(source) {
|
|
11
|
+
const root = {
|
|
12
|
+
type: 'root',
|
|
13
|
+
children: [{
|
|
14
|
+
type: 'text',
|
|
15
|
+
value: source
|
|
16
|
+
}]
|
|
17
|
+
};
|
|
18
|
+
const sourceLines = source.split(/\r?\n|\r/);
|
|
19
|
+
starryNightGutter(root, sourceLines);
|
|
20
|
+
return root;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Parses source into a line-guttered HAST **without** syntax highlighting — the
|
|
25
|
+
* raw text wrapped in the same `.line`/`.frame` structure `parseSource` produces,
|
|
26
|
+
* just no starry-night tokenization. It is a `ParseSource` so it can be dropped
|
|
27
|
+
* into the loader in place of the highlighting parser.
|
|
28
|
+
*
|
|
29
|
+
* Used for the deferred (un-highlighted) fallback: the enhancer pipeline needs the
|
|
30
|
+
* line/frame structure to compute focus windows and truncation, but the syntax
|
|
31
|
+
* colors are exactly the part being deferred — so we skip them. Cheap (no grammar,
|
|
32
|
+
* no `getInstance`); the frames it produces collapse back to text via `buildRootFallback`.
|
|
33
|
+
*
|
|
34
|
+
* Takes only `source` (it ignores file name / language since it never highlights) but
|
|
35
|
+
* stays structurally assignable to `ParseSource`, so it drops into the loader in place
|
|
36
|
+
* of the highlighting parser.
|
|
37
|
+
*/
|
|
38
|
+
export const parsePlainText = source => createPlainTextRoot(source);
|
|
@@ -1,22 +1,7 @@
|
|
|
1
1
|
import { createStarryNight } from '@wooorm/starry-night';
|
|
2
2
|
import type { ParseSource } from "../../CodeHighlighter/types.mjs";
|
|
3
3
|
type StarryNight = Awaited<ReturnType<typeof createStarryNight>>;
|
|
4
|
-
|
|
5
|
-
* Parses source into a line-guttered HAST **without** syntax highlighting — the
|
|
6
|
-
* raw text wrapped in the same `.line`/`.frame` structure `parseSource` produces,
|
|
7
|
-
* just no starry-night tokenization. It is a `ParseSource` so it can be dropped
|
|
8
|
-
* into the loader in place of the highlighting parser.
|
|
9
|
-
*
|
|
10
|
-
* Used for the deferred (un-highlighted) fallback: the enhancer pipeline needs the
|
|
11
|
-
* line/frame structure to compute focus windows and truncation, but the syntax
|
|
12
|
-
* colors are exactly the part being deferred — so we skip them. Cheap (no grammar,
|
|
13
|
-
* no `getInstance`); the frames it produces collapse back to text via `buildRootFallback`.
|
|
14
|
-
*
|
|
15
|
-
* Takes only `source` (it ignores file name / language since it never highlights) but
|
|
16
|
-
* stays structurally assignable to `ParseSource`, so it drops into the loader in place
|
|
17
|
-
* of the highlighting parser.
|
|
18
|
-
*/
|
|
19
|
-
export declare const parsePlainText: (source: string) => ReturnType<ParseSource>;
|
|
4
|
+
export { parsePlainText } from "./createPlainTextRoot.mjs";
|
|
20
5
|
/**
|
|
21
6
|
* Parses source code into a HAST tree with syntax highlighting.
|
|
22
7
|
*
|
|
@@ -64,5 +49,4 @@ export declare function getStarryNightInstance(): Promise<StarryNight>;
|
|
|
64
49
|
* Clears the global Starry Night singleton and registration state. Intended for
|
|
65
50
|
* tests exercising lazy registration from a known-empty registry.
|
|
66
51
|
*/
|
|
67
|
-
export declare function resetStarryNight(): void;
|
|
68
|
-
export {};
|
|
52
|
+
export declare function resetStarryNight(): void;
|
|
@@ -2,6 +2,7 @@ import { createStarryNight } from '@wooorm/starry-night';
|
|
|
2
2
|
import { resolveGrammarScope } from "./grammarMaps.mjs";
|
|
3
3
|
import { grammarLoaders } from "./grammarLoaders.mjs";
|
|
4
4
|
import { starryNightGutter } from "./addLineGutters.mjs";
|
|
5
|
+
import { createPlainTextRoot } from "./createPlainTextRoot.mjs";
|
|
5
6
|
import { extendSyntaxTokens } from "./extendSyntaxTokens.mjs";
|
|
6
7
|
const STARRY_NIGHT_KEY = '__docs_infra_starry_night_instance__';
|
|
7
8
|
const STARRY_NIGHT_STATE_KEY = '__docs_infra_starry_night_state__';
|
|
@@ -24,39 +25,7 @@ function getState() {
|
|
|
24
25
|
}
|
|
25
26
|
return state;
|
|
26
27
|
}
|
|
27
|
-
|
|
28
|
-
// Builds the plain-text HAST fallback used for unsupported file types and for a
|
|
29
|
-
// mapped-but-not-yet-registered scope. Line gutters are still added so the
|
|
30
|
-
// enhancer pipeline (e.g. auto-focus frames) can operate on the result.
|
|
31
|
-
function createPlainTextRoot(source) {
|
|
32
|
-
const root = {
|
|
33
|
-
type: 'root',
|
|
34
|
-
children: [{
|
|
35
|
-
type: 'text',
|
|
36
|
-
value: source
|
|
37
|
-
}]
|
|
38
|
-
};
|
|
39
|
-
const sourceLines = source.split(/\r?\n|\r/);
|
|
40
|
-
starryNightGutter(root, sourceLines);
|
|
41
|
-
return root;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Parses source into a line-guttered HAST **without** syntax highlighting — the
|
|
46
|
-
* raw text wrapped in the same `.line`/`.frame` structure `parseSource` produces,
|
|
47
|
-
* just no starry-night tokenization. It is a `ParseSource` so it can be dropped
|
|
48
|
-
* into the loader in place of the highlighting parser.
|
|
49
|
-
*
|
|
50
|
-
* Used for the deferred (un-highlighted) fallback: the enhancer pipeline needs the
|
|
51
|
-
* line/frame structure to compute focus windows and truncation, but the syntax
|
|
52
|
-
* colors are exactly the part being deferred — so we skip them. Cheap (no grammar,
|
|
53
|
-
* no `getInstance`); the frames it produces collapse back to text via `buildRootFallback`.
|
|
54
|
-
*
|
|
55
|
-
* Takes only `source` (it ignores file name / language since it never highlights) but
|
|
56
|
-
* stays structurally assignable to `ParseSource`, so it drops into the loader in place
|
|
57
|
-
* of the highlighting parser.
|
|
58
|
-
*/
|
|
59
|
-
export const parsePlainText = source => createPlainTextRoot(source);
|
|
28
|
+
export { parsePlainText } from "./createPlainTextRoot.mjs";
|
|
60
29
|
|
|
61
30
|
/**
|
|
62
31
|
* Parses source code into a HAST tree with syntax highlighting.
|