@rspress/core 2.0.10 → 2.0.12
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/0~execa.js +1 -1
- package/dist/3323.js +8 -0
- package/dist/{2240.js → 6162.js} +1 -4
- package/dist/8006.js +1 -1
- package/dist/8857.js +1 -1
- package/dist/common-Qw-RoVFD.js +25 -0
- package/dist/eject-theme/components/Llms/LlmsContainer.tsx +1 -2
- package/dist/eject-theme/components/Llms/LlmsCopyButton.tsx +1 -2
- package/dist/eject-theme/components/Llms/LlmsViewOptions.tsx +1 -2
- package/dist/eject-theme/components/PackageManagerTabs/index.tsx +16 -17
- package/dist/eject-theme/components/Prompt/icons.tsx +1 -1
- package/dist/eject-theme/components/Prompt/index.scss +325 -380
- package/dist/eject-theme/components/Search/SearchPanel.tsx +1 -6
- package/dist/eject-theme/components/Search/logic/search.ts +10 -5
- package/dist/eject-theme/components/Search/logic/util.test.ts +20 -1
- package/dist/eject-theme/components/Search/logic/util.ts +4 -1
- package/dist/eject-theme/components/Sidebar/SidebarItem.tsx +1 -1
- package/dist/eject-theme/components/Tabs/index.tsx +48 -41
- package/dist/entry/process.d.ts +1 -0
- package/dist/entry/process.js +65 -0
- package/dist/entry/utils.d.ts +7 -0
- package/dist/entry/utils.js +2 -0
- package/dist/entry/worker.d.ts +1 -0
- package/dist/entry/worker.js +74 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -0
- package/dist/node/PluginDriver.js +1 -1
- package/dist/node/auto-nav-sidebar/index.js +1 -1
- package/dist/node/auto-nav-sidebar/locales.js +1 -1
- package/dist/node/auto-nav-sidebar/normalize.d.ts +1 -1
- package/dist/node/auto-nav-sidebar/normalize.js +1 -1
- package/dist/node/auto-nav-sidebar/utils.js +1 -1
- package/dist/node/auto-nav-sidebar/walk.js +1 -1
- package/dist/node/index.d.ts +1 -0
- package/dist/node/initRsbuild.js +1 -1
- package/dist/node/mdx/options.js +2 -1
- package/dist/node/mdx/processor.js +1 -1
- package/dist/node/mdx/rehypePlugins/codeMeta.js +1 -1
- package/dist/node/mdx/rehypePlugins/headerAnchor.js +1 -1
- package/dist/node/mdx/rehypePlugins/shiki.js +1 -1
- package/dist/node/mdx/rehypePlugins/transformers/add-title.js +3 -6
- package/dist/node/mdx/rehypePlugins/transformers/index.d.ts +1 -1
- package/dist/node/mdx/remarkPlugins/builtin.js +1 -1
- package/dist/node/mdx/remarkPlugins/containerSyntax.d.ts +1 -1
- package/dist/node/mdx/remarkPlugins/fileCodeBlock.d.ts +1 -0
- package/dist/node/mdx/remarkPlugins/fileCodeBlock.js +9 -4
- package/dist/node/mdx/remarkPlugins/image.d.ts +1 -1
- package/dist/node/mdx/remarkPlugins/image.js +2 -1
- package/dist/node/mdx/remarkPlugins/link.d.ts +1 -1
- package/dist/node/mdx/remarkPlugins/link.js +1 -1
- package/dist/node/route/RoutePage.js +1 -1
- package/dist/node/route/RouteService.js +1 -1
- package/dist/node/route/extractPageData.js +1 -1
- package/dist/node/route/normalizeRoutePath.js +1 -1
- package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.d.ts +140 -140
- package/dist/node/runtimeModule/i18n.js +1 -1
- package/dist/node/runtimeModule/pageData/createPageData.js +1 -1
- package/dist/node/runtimeModule/pageData/rsbuildPlugin.d.ts +1 -1
- package/dist/node/runtimeModule/pageData/rsbuildPlugin.js +1 -1
- package/dist/node/runtimeModule/searchHooks.js +1 -1
- package/dist/node/runtimeModule/siteData/createSiteData.js +1 -1
- package/dist/node/runtimeModule/siteData/normalizeThemeConfig.js +1 -1
- package/dist/node/runtimeModule/siteData/rsbuildPlugin.js +1 -1
- package/dist/node/serve.js +1 -1
- package/dist/node/ssg/renderPages.js +2 -2
- package/dist/node/ssg/rsbuildPluginSSG.js +1 -1
- package/dist/node/ssg/ssgEnv.js +1 -1
- package/dist/node/ssg-md/llms/emitLlmsTxt.js +1 -1
- package/dist/node/ssg-md/llms/llmsTxt.js +1 -1
- package/dist/node/ssg-md/remarkSplitMdx.js +1 -1
- package/dist/node/ssg-md/renderPage.js +1 -1
- package/dist/node/ssg-md/renderPages.js +1 -1
- package/dist/node/ssg-md/rsbuildPluginSSGMD.js +1 -1
- package/dist/node/utils/checkLanguageParity.js +1 -1
- package/dist/node/utils/createHash.js +1 -1
- package/dist/node/utils/flattenMdxContent.js +1 -1
- package/dist/node/utils/getPageKey.js +1 -1
- package/dist/node/utils/reactAlias.js +1 -1
- package/dist/runtime/BrowserOnly.d.ts +7 -0
- package/dist/runtime/BrowserOnly.js +40 -0
- package/dist/runtime/BrowserOnly.test.d.ts +1 -0
- package/dist/runtime/index.d.ts +1 -0
- package/dist/runtime/index.js +1 -0
- package/dist/theme/components/DocContent/docComponents/a.d.ts +1 -1
- package/dist/theme/components/DocContent/docComponents/hr.d.ts +1 -1
- package/dist/theme/components/DocContent/docComponents/img.d.ts +1 -1
- package/dist/theme/components/DocContent/docComponents/index.d.ts +18 -18
- package/dist/theme/components/DocContent/docComponents/list.d.ts +3 -3
- package/dist/theme/components/DocContent/docComponents/paragraph.d.ts +3 -3
- package/dist/theme/components/DocContent/docComponents/table.d.ts +3 -3
- package/dist/theme/components/DocContent/docComponents/title.d.ts +6 -6
- package/dist/theme/components/Nav/hooks.d.ts +1 -1
- package/dist/theme/components/PackageManagerTabs/index.js +17 -17
- package/dist/theme/components/Prompt/icons.js +1 -1
- package/dist/theme/components/Prompt/index.css +11 -37
- package/dist/theme/components/Search/SearchPanel.js +1 -2
- package/dist/theme/components/Search/logic/search.js +5 -3
- package/dist/theme/components/Search/logic/util.js +2 -1
- package/dist/theme/components/Sidebar/SidebarItem.js +1 -0
- package/dist/theme/components/Tabs/index.d.ts +8 -4
- package/dist/theme/components/Tabs/index.js +19 -19
- package/dist/theme/layout/DocLayout/index.css +4 -0
- package/dist/theme/layout/DocLayout/index.js +3 -2
- package/dist/theme/logic/useThemeState.d.ts +5 -10
- package/dist/theme/logic/useThemeState.js +15 -20
- package/dist/utils-B--2TaWv.js +34 -0
- package/dist/utils-De75vAgL.js +7 -0
- package/package.json +13 -13
- package/dist/3425.js +0 -6
- package/dist/runtime/getSidebarDataGroup.test.js +0 -68
- package/dist/runtime/hooks/useWindowSize.test.js +0 -36
- package/dist/runtime/route.test.js +0 -154
- package/dist/runtime/utils.test.js +0 -34
- package/dist/theme/components/Search/logic/util.test.js +0 -51
- /package/dist/{2287.js → 2235.js} +0 -0
|
@@ -388,15 +388,10 @@ export function SearchPanel({ focused, setFocused }: SearchPanelProps) {
|
|
|
388
388
|
);
|
|
389
389
|
}
|
|
390
390
|
|
|
391
|
-
const tabValues = result.map(item => {
|
|
392
|
-
return item.group;
|
|
393
|
-
});
|
|
394
|
-
|
|
395
391
|
const renderKey = 'render' as const;
|
|
396
392
|
|
|
397
393
|
return (
|
|
398
394
|
<Tabs
|
|
399
|
-
values={tabValues}
|
|
400
395
|
className="rp-search-panel__tabs"
|
|
401
396
|
onChange={index => {
|
|
402
397
|
setResultTabIndex(index);
|
|
@@ -406,7 +401,7 @@ export function SearchPanel({ focused, setFocused }: SearchPanelProps) {
|
|
|
406
401
|
ref={searchResultTabRef}
|
|
407
402
|
>
|
|
408
403
|
{result.map(item => (
|
|
409
|
-
<Tab key={item.group}>
|
|
404
|
+
<Tab key={item.group} label={item.group}>
|
|
410
405
|
{item.renderType === RenderType.Default &&
|
|
411
406
|
renderSearchResultItem(item.result, query, isSearching)}
|
|
412
407
|
{item.renderType === RenderType.Custom &&
|
|
@@ -248,15 +248,17 @@ export class PageSearcher {
|
|
|
248
248
|
let statementStartIndex = content.slice(0, queryIndex).lastIndexOf('\n');
|
|
249
249
|
statementStartIndex =
|
|
250
250
|
statementStartIndex === -1 ? 0 : statementStartIndex;
|
|
251
|
-
|
|
251
|
+
let statementEndIndex = content.indexOf(
|
|
252
252
|
'\n\n',
|
|
253
253
|
queryIndex + query.length,
|
|
254
254
|
);
|
|
255
|
+
statementEndIndex =
|
|
256
|
+
statementEndIndex === -1 ? content.length : statementEndIndex;
|
|
255
257
|
let statement = content.slice(statementStartIndex, statementEndIndex);
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
258
|
+
statement = this.#normalizeStatement(statement, query);
|
|
259
|
+
const highlightIndex = normalizeTextCase(statement).indexOf(
|
|
260
|
+
normalizeTextCase(query),
|
|
261
|
+
);
|
|
260
262
|
const highlightInfoList = [
|
|
261
263
|
{
|
|
262
264
|
start: highlightIndex,
|
|
@@ -286,6 +288,9 @@ export class PageSearcher {
|
|
|
286
288
|
}
|
|
287
289
|
|
|
288
290
|
#normalizeStatement(statement: string, query: string) {
|
|
291
|
+
if (statement.length <= THRESHOLD_CONTENT_LENGTH) {
|
|
292
|
+
return statement;
|
|
293
|
+
}
|
|
289
294
|
// If statement is too long, we will only show 120 characters
|
|
290
295
|
const queryIndex = normalizeTextCase(statement).indexOf(
|
|
291
296
|
normalizeTextCase(query),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Header } from '@rspress/core';
|
|
2
2
|
import { describe, expect, test } from '@rstest/core';
|
|
3
|
-
import { backTrackHeaders } from './util';
|
|
3
|
+
import { backTrackHeaders, normalizeTextCase } from './util';
|
|
4
4
|
|
|
5
5
|
describe('utils logic', () => {
|
|
6
6
|
test('back track the headers', () => {
|
|
@@ -19,3 +19,22 @@ describe('utils logic', () => {
|
|
|
19
19
|
]);
|
|
20
20
|
});
|
|
21
21
|
});
|
|
22
|
+
|
|
23
|
+
describe('normalizeTextCase', () => {
|
|
24
|
+
test('normalize latin text without accents for search', () => {
|
|
25
|
+
expect(normalizeTextCase('CAFÉ')).toBe('cafe');
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
test('normalize japanese text without accents for search', () => {
|
|
29
|
+
expect(normalizeTextCase('ご')).toBe('ご');
|
|
30
|
+
expect(normalizeTextCase('ガ')).toBe('ガ');
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test('normalize cyrillic text without accents for search', () => {
|
|
34
|
+
expect(normalizeTextCase('ПРИВЕТ')).toBe('привет');
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
test('normalize korean text without accents for search', () => {
|
|
38
|
+
expect(normalizeTextCase('안녕하세요')).toBe('안녕하세요');
|
|
39
|
+
});
|
|
40
|
+
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Header } from '@rspress/core';
|
|
2
2
|
|
|
3
3
|
const MAX_TITLE_LENGTH = 20;
|
|
4
|
+
const jRegex = /[\u3040-\u309f\u30a0-\u30ff\u31f0-\u31ff]/u;
|
|
4
5
|
const kRegex = /[\u3131-\u314e|\u314f-\u3163|\uac00-\ud7a3]/u;
|
|
5
6
|
const cyrillicRegex = /[\u0400-\u04FF]/u;
|
|
6
7
|
|
|
@@ -46,9 +47,11 @@ export function normalizeTextCase(text: string | number) {
|
|
|
46
47
|
}
|
|
47
48
|
|
|
48
49
|
const resultWithoutAccents = textNormalized.replace(/[\u0300-\u036f]/g, '');
|
|
49
|
-
|
|
50
|
+
|
|
51
|
+
if (jRegex.test(String(text)) || kRegex.test(String(text))) {
|
|
50
52
|
return resultWithoutAccents.normalize('NFC');
|
|
51
53
|
}
|
|
54
|
+
|
|
52
55
|
return resultWithoutAccents;
|
|
53
56
|
}
|
|
54
57
|
|
|
@@ -56,7 +56,7 @@ export function SidebarItemRaw({
|
|
|
56
56
|
const innerContent = (
|
|
57
57
|
<>
|
|
58
58
|
<div className="rp-sidebar-item__left" ref={ref}>
|
|
59
|
-
<span {...renderInlineMarkdown(text)}></span>
|
|
59
|
+
<span className="rp-doc" {...renderInlineMarkdown(text)}></span>
|
|
60
60
|
{left}
|
|
61
61
|
</div>
|
|
62
62
|
<div className="rp-sidebar-item__right">
|
|
@@ -13,17 +13,25 @@ import {
|
|
|
13
13
|
import './index.scss';
|
|
14
14
|
|
|
15
15
|
type TabItem = {
|
|
16
|
-
label
|
|
16
|
+
label: ReactNode;
|
|
17
|
+
value: string;
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
type ResolvedTabItem = {
|
|
22
|
+
label?: ReactNode;
|
|
23
|
+
value?: string;
|
|
17
24
|
disabled?: boolean;
|
|
18
25
|
content?: ReactNode;
|
|
19
26
|
};
|
|
20
27
|
|
|
21
28
|
export interface TabsProps {
|
|
22
|
-
values?:
|
|
29
|
+
values?: ReadonlyArray<TabItem>;
|
|
23
30
|
/**
|
|
24
31
|
* @default 0
|
|
25
32
|
*/
|
|
26
33
|
defaultIndex?: number;
|
|
34
|
+
defaultValue?: string;
|
|
27
35
|
onChange?: (index: number) => void;
|
|
28
36
|
children: ReactNode;
|
|
29
37
|
/**
|
|
@@ -45,56 +53,41 @@ export interface TabsProps {
|
|
|
45
53
|
|
|
46
54
|
function getTabValuesFromChildren(
|
|
47
55
|
children: ReactElement<TabProps>[],
|
|
48
|
-
|
|
49
|
-
):
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
// 1. values only contain label
|
|
57
|
-
// <Tabs values={['Tab1', 'Tab2']}><Tab label="Tab1"/></Tab><Tab label="Tab2"/></Tab></Tabs>
|
|
58
|
-
if (defaultValues && defaultValues.length > 0) {
|
|
59
|
-
return defaultValues.map((item, index) => {
|
|
60
|
-
if (isTabItem(item)) {
|
|
61
|
-
return item;
|
|
62
|
-
}
|
|
56
|
+
values: ReadonlyArray<TabItem> | undefined,
|
|
57
|
+
): ResolvedTabItem[] {
|
|
58
|
+
if (values && values.length > 0) {
|
|
59
|
+
return values.map((item, index) => {
|
|
60
|
+
const content =
|
|
61
|
+
children.find(child => child.props?.value === item.value) ??
|
|
62
|
+
children[index];
|
|
63
63
|
|
|
64
64
|
return {
|
|
65
|
-
|
|
66
|
-
content
|
|
67
|
-
} satisfies
|
|
65
|
+
...item,
|
|
66
|
+
content,
|
|
67
|
+
} satisfies ResolvedTabItem;
|
|
68
68
|
});
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
|
|
72
|
-
// <Tabs><Tab label="Tab1"/></Tab><Tab label="Tab2"/></Tab></Tabs>
|
|
73
|
-
return Children.map<TabItem, ReactElement<TabProps>>(
|
|
71
|
+
return Children.map<ResolvedTabItem, ReactElement<TabProps>>(
|
|
74
72
|
children,
|
|
75
73
|
(child, index) => {
|
|
76
74
|
if (isValidElement(child)) {
|
|
77
75
|
return {
|
|
78
76
|
label: child.props?.label || undefined,
|
|
77
|
+
value: child.props?.value,
|
|
78
|
+
disabled: child.props?.disabled,
|
|
79
79
|
content: children[index],
|
|
80
|
-
} satisfies
|
|
80
|
+
} satisfies ResolvedTabItem;
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
return {
|
|
84
84
|
label: index,
|
|
85
85
|
content: children[index],
|
|
86
|
-
} satisfies
|
|
86
|
+
} satisfies ResolvedTabItem;
|
|
87
87
|
},
|
|
88
88
|
);
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
function isTabItem(item: unknown): item is TabItem {
|
|
92
|
-
if (item && typeof item === 'object' && 'label' in item) {
|
|
93
|
-
return true;
|
|
94
|
-
}
|
|
95
|
-
return false;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
91
|
const groupIdPrefix = 'rspress.tabs.';
|
|
99
92
|
|
|
100
93
|
export const Tabs = forwardRef(
|
|
@@ -102,6 +95,7 @@ export const Tabs = forwardRef(
|
|
|
102
95
|
const {
|
|
103
96
|
values,
|
|
104
97
|
defaultIndex,
|
|
98
|
+
defaultValue,
|
|
105
99
|
onChange,
|
|
106
100
|
children: rawChildren,
|
|
107
101
|
groupId,
|
|
@@ -118,9 +112,9 @@ export const Tabs = forwardRef(
|
|
|
118
112
|
isValidElement(child),
|
|
119
113
|
) as unknown as ReactElement<TabProps>[];
|
|
120
114
|
|
|
121
|
-
const tabValues:
|
|
115
|
+
const tabValues: ResolvedTabItem[] = useMemo(() => {
|
|
122
116
|
return getTabValuesFromChildren(children, values);
|
|
123
|
-
}, [
|
|
117
|
+
}, [children, values]);
|
|
124
118
|
|
|
125
119
|
if (process.env.__SSR_MD__) {
|
|
126
120
|
return (
|
|
@@ -138,11 +132,18 @@ export const Tabs = forwardRef(
|
|
|
138
132
|
);
|
|
139
133
|
}
|
|
140
134
|
|
|
141
|
-
const
|
|
135
|
+
const defaultValueIndex =
|
|
136
|
+
defaultValue !== undefined
|
|
137
|
+
? tabValues.findIndex(item => item.value === defaultValue)
|
|
138
|
+
: -1;
|
|
139
|
+
const initialActiveIndex =
|
|
140
|
+
defaultValueIndex === -1 ? (defaultIndex ?? 0) : defaultValueIndex;
|
|
141
|
+
|
|
142
|
+
const [activeIndex, setActiveIndex] = useState(initialActiveIndex);
|
|
142
143
|
|
|
143
144
|
const [storageIndex, setStorageIndex] = useStorageValue<string>(
|
|
144
145
|
`${groupIdPrefix}${groupId}`,
|
|
145
|
-
|
|
146
|
+
initialActiveIndex.toString(),
|
|
146
147
|
);
|
|
147
148
|
|
|
148
149
|
const currentIndex: number = groupId ? Number(storageIndex) : activeIndex;
|
|
@@ -157,11 +158,11 @@ export const Tabs = forwardRef(
|
|
|
157
158
|
tabPosition === 'center' ? 'center' : 'flex-start',
|
|
158
159
|
}}
|
|
159
160
|
>
|
|
160
|
-
{tabValues.map(({ label }, index) => {
|
|
161
|
+
{tabValues.map(({ label, value, disabled }, index) => {
|
|
161
162
|
const isActive = index === currentIndex;
|
|
162
163
|
return (
|
|
163
164
|
<div
|
|
164
|
-
key={
|
|
165
|
+
key={value ?? index}
|
|
165
166
|
className={clsx(
|
|
166
167
|
'rp-tabs__label__item',
|
|
167
168
|
isActive
|
|
@@ -171,6 +172,9 @@ export const Tabs = forwardRef(
|
|
|
171
172
|
)}
|
|
172
173
|
data-index={index}
|
|
173
174
|
onClick={() => {
|
|
175
|
+
if (disabled) {
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
174
178
|
onChange?.(index);
|
|
175
179
|
if (groupId) {
|
|
176
180
|
setStorageIndex(index.toString());
|
|
@@ -186,7 +190,7 @@ export const Tabs = forwardRef(
|
|
|
186
190
|
</div>
|
|
187
191
|
) : null}
|
|
188
192
|
<div className="rp-tabs__content">
|
|
189
|
-
{tabValues.map(({
|
|
193
|
+
{tabValues.map(({ value, content }, index) => {
|
|
190
194
|
const isActive = index === currentIndex;
|
|
191
195
|
if (!keepDOM && !isActive) {
|
|
192
196
|
return null;
|
|
@@ -194,7 +198,7 @@ export const Tabs = forwardRef(
|
|
|
194
198
|
|
|
195
199
|
return (
|
|
196
200
|
<div
|
|
197
|
-
key={
|
|
201
|
+
key={value ?? index}
|
|
198
202
|
className={clsx(
|
|
199
203
|
'rp-tabs__content__item',
|
|
200
204
|
isActive
|
|
@@ -217,7 +221,10 @@ export const Tabs = forwardRef(
|
|
|
217
221
|
|
|
218
222
|
Tabs.displayName = 'Tabs';
|
|
219
223
|
|
|
220
|
-
export type TabProps =
|
|
224
|
+
export type TabProps = {
|
|
225
|
+
label?: ReactNode;
|
|
226
|
+
value?: string;
|
|
227
|
+
disabled?: boolean;
|
|
221
228
|
children: ReactNode;
|
|
222
229
|
};
|
|
223
230
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { stderr, stdout } from "../utils-De75vAgL.js";
|
|
2
|
+
import { getHandler, throwInNextTick } from "../utils-B--2TaWv.js";
|
|
3
|
+
process.__tinypool_state__ = {
|
|
4
|
+
isChildProcess: true,
|
|
5
|
+
isTinypoolWorker: true,
|
|
6
|
+
workerData: null,
|
|
7
|
+
workerId: Number(process.env.TINYPOOL_WORKER_ID)
|
|
8
|
+
};
|
|
9
|
+
const memoryUsage = process.memoryUsage.bind(process);
|
|
10
|
+
const send = process.send.bind(process);
|
|
11
|
+
process.on("message", (message)=>{
|
|
12
|
+
if (!message || !message.__tinypool_worker_message__) return;
|
|
13
|
+
if ("pool" === message.source) {
|
|
14
|
+
const { filename, name } = message;
|
|
15
|
+
(async function() {
|
|
16
|
+
if (null !== filename) await getHandler(filename, name);
|
|
17
|
+
send({
|
|
18
|
+
ready: true,
|
|
19
|
+
source: "pool",
|
|
20
|
+
__tinypool_worker_message__: true
|
|
21
|
+
}, ()=>{});
|
|
22
|
+
})().catch(throwInNextTick);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if ("port" === message.source) return void onMessage(message).catch(throwInNextTick);
|
|
26
|
+
throw new Error(`Unexpected TinypoolWorkerMessage ${JSON.stringify(message)}`);
|
|
27
|
+
});
|
|
28
|
+
async function onMessage(message) {
|
|
29
|
+
const { taskId, task, filename, name } = message;
|
|
30
|
+
let response;
|
|
31
|
+
try {
|
|
32
|
+
const handler = await getHandler(filename, name);
|
|
33
|
+
if (null === handler) throw new Error(`No handler function "${name}" exported from "${filename}"`);
|
|
34
|
+
const result = await handler(task);
|
|
35
|
+
response = {
|
|
36
|
+
source: "port",
|
|
37
|
+
__tinypool_worker_message__: true,
|
|
38
|
+
taskId,
|
|
39
|
+
result,
|
|
40
|
+
error: null,
|
|
41
|
+
usedMemory: memoryUsage().heapUsed
|
|
42
|
+
};
|
|
43
|
+
if (stdout()?.writableLength > 0) await new Promise((resolve)=>process.stdout.write("", resolve));
|
|
44
|
+
if (stderr()?.writableLength > 0) await new Promise((resolve)=>process.stderr.write("", resolve));
|
|
45
|
+
} catch (error) {
|
|
46
|
+
response = {
|
|
47
|
+
source: "port",
|
|
48
|
+
__tinypool_worker_message__: true,
|
|
49
|
+
taskId,
|
|
50
|
+
result: null,
|
|
51
|
+
error: serializeError(error),
|
|
52
|
+
usedMemory: memoryUsage().heapUsed
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
send(response);
|
|
56
|
+
}
|
|
57
|
+
function serializeError(error) {
|
|
58
|
+
if (error instanceof Error) return {
|
|
59
|
+
...error,
|
|
60
|
+
name: error.name,
|
|
61
|
+
stack: error.stack,
|
|
62
|
+
message: error.message
|
|
63
|
+
};
|
|
64
|
+
return String(error);
|
|
65
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { isMovable, kRequestCountField, kResponseCountField, kTransferable, kValue } from "../common-Qw-RoVFD.js";
|
|
2
|
+
import { stderr, stdout } from "../utils-De75vAgL.js";
|
|
3
|
+
import { getHandler, throwInNextTick } from "../utils-B--2TaWv.js";
|
|
4
|
+
import { parentPort, receiveMessageOnPort, workerData } from "node:worker_threads";
|
|
5
|
+
const [tinypoolPrivateData, workerData$1] = workerData;
|
|
6
|
+
process.__tinypool_state__ = {
|
|
7
|
+
isWorkerThread: true,
|
|
8
|
+
isTinypoolWorker: true,
|
|
9
|
+
workerData: workerData$1,
|
|
10
|
+
workerId: tinypoolPrivateData.workerId
|
|
11
|
+
};
|
|
12
|
+
const memoryUsage = process.memoryUsage.bind(process);
|
|
13
|
+
let useAtomics = "1" !== process.env.PISCINA_DISABLE_ATOMICS;
|
|
14
|
+
parentPort.on("message", (message)=>{
|
|
15
|
+
useAtomics = "1" === process.env.PISCINA_DISABLE_ATOMICS ? false : message.useAtomics;
|
|
16
|
+
const { port, sharedBuffer, filename, name } = message;
|
|
17
|
+
(async function() {
|
|
18
|
+
if (null !== filename) await getHandler(filename, name);
|
|
19
|
+
const readyMessage = {
|
|
20
|
+
ready: true
|
|
21
|
+
};
|
|
22
|
+
parentPort.postMessage(readyMessage);
|
|
23
|
+
port.start();
|
|
24
|
+
port.on("message", onMessage.bind(null, port, sharedBuffer));
|
|
25
|
+
atomicsWaitLoop(port, sharedBuffer);
|
|
26
|
+
})().catch(throwInNextTick);
|
|
27
|
+
});
|
|
28
|
+
let currentTasks = 0;
|
|
29
|
+
let lastSeenRequestCount = 0;
|
|
30
|
+
function atomicsWaitLoop(port, sharedBuffer) {
|
|
31
|
+
if (!useAtomics) return;
|
|
32
|
+
while(0 === currentTasks){
|
|
33
|
+
Atomics.wait(sharedBuffer, kRequestCountField, lastSeenRequestCount);
|
|
34
|
+
lastSeenRequestCount = Atomics.load(sharedBuffer, kRequestCountField);
|
|
35
|
+
let entry;
|
|
36
|
+
while(void 0 !== (entry = receiveMessageOnPort(port)))onMessage(port, sharedBuffer, entry.message);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function onMessage(port, sharedBuffer, message) {
|
|
40
|
+
currentTasks++;
|
|
41
|
+
const { taskId, task, filename, name } = message;
|
|
42
|
+
(async function() {
|
|
43
|
+
let response;
|
|
44
|
+
let transferList = [];
|
|
45
|
+
try {
|
|
46
|
+
const handler = await getHandler(filename, name);
|
|
47
|
+
if (null === handler) throw new Error(`No handler function "${name}" exported from "${filename}"`);
|
|
48
|
+
let result = await handler(task);
|
|
49
|
+
if (isMovable(result)) {
|
|
50
|
+
transferList = transferList.concat(result[kTransferable]);
|
|
51
|
+
result = result[kValue];
|
|
52
|
+
}
|
|
53
|
+
response = {
|
|
54
|
+
taskId,
|
|
55
|
+
result,
|
|
56
|
+
error: null,
|
|
57
|
+
usedMemory: memoryUsage().heapUsed
|
|
58
|
+
};
|
|
59
|
+
if (stdout()?.writableLength > 0) await new Promise((resolve)=>process.stdout.write("", resolve));
|
|
60
|
+
if (stderr()?.writableLength > 0) await new Promise((resolve)=>process.stderr.write("", resolve));
|
|
61
|
+
} catch (error) {
|
|
62
|
+
response = {
|
|
63
|
+
taskId,
|
|
64
|
+
result: null,
|
|
65
|
+
error,
|
|
66
|
+
usedMemory: memoryUsage().heapUsed
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
currentTasks--;
|
|
70
|
+
port.postMessage(response, transferList);
|
|
71
|
+
Atomics.add(sharedBuffer, kResponseCountField, 1);
|
|
72
|
+
atomicsWaitLoop(port, sharedBuffer);
|
|
73
|
+
})().catch(throwInNextTick);
|
|
74
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export { getIconUrlPath, getNodeAttribute, mergeDocConfig, } from '@rspress/shar
|
|
|
5
5
|
export { matchPath } from 'react-router-dom';
|
|
6
6
|
export type { UserConfigAsyncFn } from './config/defineConfig.js';
|
|
7
7
|
export { defineConfig } from './config/defineConfig.js';
|
|
8
|
-
export { build, dev, remarkFileCodeBlock, remarkLink, serve } from './node/index.js';
|
|
8
|
+
export { build, dev, remarkFileCodeBlock, remarkImage, remarkLink, serve, } from './node/index.js';
|
|
9
9
|
export type { CustomLinkMeta, DirSectionHeaderSideMeta, DirSideMeta, DividerSideMeta, FileSideMeta, MetaJson, NavJson, SectionHeaderMeta, SideMeta, SideMetaItem, } from './node/auto-nav-sidebar/type.js';
|
|
10
10
|
export { PluginDriver } from './node/PluginDriver.js';
|
|
11
11
|
export { RouteService } from './node/route/RouteService.js';
|
package/dist/index.js
CHANGED
|
@@ -5,5 +5,6 @@ export { build } from "./node/build.js";
|
|
|
5
5
|
export { defineConfig } from "./config/defineConfig.js";
|
|
6
6
|
export { dev } from "./node/dev.js";
|
|
7
7
|
export { remarkFileCodeBlock } from "./node/mdx/remarkPlugins/fileCodeBlock.js";
|
|
8
|
+
export { remarkImage } from "./node/mdx/remarkPlugins/image.js";
|
|
8
9
|
export { remarkLink } from "./node/mdx/remarkPlugins/link.js";
|
|
9
10
|
export { serve } from "./node/serve.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { addTrailingSlash, node_path, addLeadingSlash } from "../
|
|
1
|
+
import { addTrailingSlash, node_path, addLeadingSlash } from "../2235.js";
|
|
2
2
|
import { createError } from "./utils/error.js";
|
|
3
3
|
import { haveNavSidebarConfig as auto_nav_sidebar_haveNavSidebarConfig } from "./auto-nav-sidebar/index.js";
|
|
4
4
|
class PluginDriver {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DEFAULT_PAGE_EXTENSIONS, node_path } from "../../
|
|
1
|
+
import { DEFAULT_PAGE_EXTENSIONS, node_path } from "../../2235.js";
|
|
2
2
|
import { processLocales, combineWalkResult } from "./locales.js";
|
|
3
3
|
import { walk } from "./walk.js";
|
|
4
4
|
async function runAutoNavSide(config, metaFileSet, mdFileSet) {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { type SidebarDivider, type SidebarGroup, type SidebarItem, type SidebarSectionHeader } from '@rspress/shared';
|
|
2
|
-
declare function scanSideMeta(workDir: string, docsDir: string, extensions: string[], metaFileSet: Set<string>, mdFileSet: Set<string>): Promise<(
|
|
2
|
+
declare function scanSideMeta(workDir: string, docsDir: string, extensions: string[], metaFileSet: Set<string>, mdFileSet: Set<string>): Promise<(SidebarDivider | SidebarGroup | SidebarItem | SidebarSectionHeader)[]>;
|
|
3
3
|
export { scanSideMeta };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __webpack_require__ } from "../../0~rslib-runtime.js";
|
|
2
2
|
import "../../8006.js";
|
|
3
|
-
import { extname, logger, promises_readdir, external_node_path_relative, isExternalUrl, slash, promises_stat, join } from "../../
|
|
3
|
+
import { extname, logger, promises_readdir, external_node_path_relative, isExternalUrl, slash, promises_stat, join } from "../../2235.js";
|
|
4
4
|
import { createError } from "../utils/error.js";
|
|
5
5
|
import { PUBLIC_DIR } from "../constants.js";
|
|
6
6
|
import { pathExists, extractInfoFromFrontmatterWithAbsolutePath, readJson } from "./utils.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { node_path, extractTextAndId, promises, loadFrontMatter } from "../../
|
|
1
|
+
import { node_path, extractTextAndId, promises, loadFrontMatter } from "../../2235.js";
|
|
2
2
|
import { createError } from "../utils/error.js";
|
|
3
3
|
async function pathExists(path) {
|
|
4
4
|
try {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isExternalUrl, node_path, promises } from "../../
|
|
1
|
+
import { isExternalUrl, node_path, promises } from "../../2235.js";
|
|
2
2
|
import { pathExists } from "../utils/fs.js";
|
|
3
3
|
import { readJson } from "./utils.js";
|
|
4
4
|
import { addRoutePrefix } from "../route/RoutePage.js";
|
package/dist/node/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { build } from './build.js';
|
|
2
2
|
export { dev } from './dev.js';
|
|
3
3
|
export { remarkFileCodeBlock } from './mdx/remarkPlugins/fileCodeBlock.js';
|
|
4
|
+
export { remarkImage } from './mdx/remarkPlugins/image.js';
|
|
4
5
|
export { remarkLink } from './mdx/remarkPlugins/link.js';
|
|
5
6
|
export { serve } from './serve.js';
|
package/dist/node/initRsbuild.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { external_node_process_cwd, node_path, external_node_url_fileURLToPath, addTrailingSlash, PLUGIN_REACT_NAME, external_node_module_createRequire, removeTrailingSlash, pluginVirtualModule, pluginReact, MDX_OR_MD_REGEXP } from "../
|
|
1
|
+
import { external_node_process_cwd, node_path, external_node_url_fileURLToPath, addTrailingSlash, PLUGIN_REACT_NAME, external_node_module_createRequire, removeTrailingSlash, pluginVirtualModule, pluginReact, MDX_OR_MD_REGEXP } from "../2235.js";
|
|
2
2
|
import { createError } from "./utils/error.js";
|
|
3
3
|
import { PUBLIC_DIR, CSR_CLIENT_ENTRY, SSR_CLIENT_ENTRY, OUTPUT_DIR, SSG_MD_SERVER_ENTRY, inlineThemeScript, NODE_SSG_BUNDLE_FOLDER, isProduction, PACKAGE_ROOT, SSR_SERVER_ENTRY, TEMPLATE_PATH, NODE_SSG_MD_BUNDLE_FOLDER, DEFAULT_THEME, NODE_SSG_MD_BUNDLE_NAME, DEFAULT_TITLE, NODE_SSG_BUNDLE_NAME } from "./constants.js";
|
|
4
4
|
import { hintBuilderPluginsBreakingChange, hintThemeBreakingChange } from "./logger/hint.js";
|
package/dist/node/mdx/options.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { node_path, rehype_external_links, rehype_raw, remark_cjk_friendly, nodeTypes, remark_gfm, rehype, remark_cjk_friendly_gfm_strikethrough } from "../../
|
|
1
|
+
import { node_path, rehype_external_links, rehype_raw, remark_cjk_friendly, nodeTypes, remark_gfm, rehype, remark_cjk_friendly_gfm_strikethrough } from "../../6162.js";
|
|
2
2
|
import { remarkToc } from "./remarkPlugins/toc.js";
|
|
3
3
|
import { remarkContainerSyntax } from "./remarkPlugins/containerSyntax.js";
|
|
4
4
|
import { remarkFileCodeBlock } from "./remarkPlugins/fileCodeBlock.js";
|
|
@@ -34,6 +34,7 @@ async function createMDXOptions(options) {
|
|
|
34
34
|
remarkFileCodeBlock,
|
|
35
35
|
{
|
|
36
36
|
filepath,
|
|
37
|
+
docDirectory,
|
|
37
38
|
addDependency
|
|
38
39
|
}
|
|
39
40
|
],
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { node_path, extractTextAndId, createProcessor, loadFrontMatter } from "../../
|
|
1
|
+
import { node_path, extractTextAndId, createProcessor, loadFrontMatter } from "../../6162.js";
|
|
2
2
|
import { createMDXOptions } from "./options.js";
|
|
3
3
|
import { applyReplaceRules } from "../utils/applyReplaceRules.js";
|
|
4
4
|
import { escapeMarkdownHeadingIds } from "../utils/escapeHeadingIds.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { visit, extractTextAndId, github_slugger, headingRank } from "../../../
|
|
1
|
+
import { visit, extractTextAndId, github_slugger, headingRank } from "../../../6162.js";
|
|
2
2
|
const rehypeHeaderAnchor = ()=>{
|
|
3
3
|
const slugger = new github_slugger();
|
|
4
4
|
return (tree)=>{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { transformerAddLang, transformerAddLineNumbers, transformerAddTitle, transformerAddFold, createCssVariablesTheme, transformerAddWrapCode } from "../../../
|
|
1
|
+
import { transformerAddLang, transformerAddLineNumbers, transformerAddTitle, transformerAddFold, createCssVariablesTheme, transformerAddWrapCode } from "../../../6162.js";
|
|
2
2
|
const cssVariablesTheme = createCssVariablesTheme({
|
|
3
3
|
name: 'css-variables',
|
|
4
4
|
variablePrefix: '--shiki-',
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
const SHIKI_TRANSFORMER_ADD_TITLE = 'shiki-transformer:add-title';
|
|
2
|
+
const TITLE_META_REGEX = /(?:^|\s)title=(?:"([^"]*)"|'([^']*)'|`([^`]*)`|([^\s]+))(?=\s|$)/;
|
|
2
3
|
function parseTitleFromMeta(meta) {
|
|
3
4
|
if (!meta) return '';
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
const [k, v = ''] = item.split('=').filter(Boolean);
|
|
7
|
-
if ('title' === k && v.length > 0) return v.replace(/["'`]/g, '');
|
|
8
|
-
}
|
|
9
|
-
return '';
|
|
5
|
+
const matched = meta.match(TITLE_META_REGEX);
|
|
6
|
+
return matched?.slice(1).find(Boolean) ?? '';
|
|
10
7
|
}
|
|
11
8
|
function transformerAddTitle() {
|
|
12
9
|
return {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { SHIKI_TRANSFORMER_ADD_FOLD, transformerAddFold
|
|
1
|
+
export { SHIKI_TRANSFORMER_ADD_FOLD, transformerAddFold } from './add-fold.js';
|
|
2
2
|
export { SHIKI_TRANSFORMER_ADD_LANG, transformerAddLang } from './add-lang.js';
|
|
3
3
|
export { SHIKI_TRANSFORMER_ADD_LINE_NUMBERS, transformerAddLineNumbers, } from './add-line-numbers.js';
|
|
4
4
|
export { SHIKI_TRANSFORMER_ADD_TITLE, transformerAddTitle } from './add-title.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { node_path } from "../../../
|
|
1
|
+
import { node_path } from "../../../6162.js";
|
|
2
2
|
import { getDefaultImportAstNode } from "../../utils/getImportAstNode.js";
|
|
3
3
|
const remarkBuiltin = ({ globalComponents })=>(tree)=>{
|
|
4
4
|
const demos = globalComponents.map((componentPath)=>{
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
*/
|
|
14
14
|
import type { Root } from 'mdast';
|
|
15
15
|
import type { Plugin } from 'unified';
|
|
16
|
-
export declare const DIRECTIVE_TYPES: readonly [
|
|
16
|
+
export declare const DIRECTIVE_TYPES: readonly ['tip', 'note', 'warning', 'caution', 'danger', 'info', 'details'];
|
|
17
17
|
export declare const REGEX_BEGIN: RegExp;
|
|
18
18
|
export declare const REGEX_END: RegExp;
|
|
19
19
|
export declare const REGEX_GH_BEGIN: RegExp;
|