@mui/internal-docs-infra 0.2.3-canary.8 → 0.3.1-canary.0
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/README.md +3 -2
- package/esm/CodeHighlighter/CodeHighlighter.js +16 -16
- package/esm/CodeHighlighter/CodeHighlighterClient.js +33 -33
- package/esm/CodeHighlighter/errors.js +3 -3
- package/esm/CodeHighlighter/types.d.ts +1 -1
- package/esm/CodeProvider/CodeContext.d.ts +4 -4
- package/esm/CodeProvider/CodeProvider.js +7 -7
- package/esm/cli/index.d.ts +1 -0
- package/esm/cli/index.js +6 -0
- package/esm/cli/runValidate.d.ts +8 -0
- package/esm/cli/runValidate.js +297 -0
- package/esm/createSitemap/createSitemap.d.ts +23 -0
- package/esm/createSitemap/createSitemap.js +45 -0
- package/esm/createSitemap/index.d.ts +1 -0
- package/esm/createSitemap/index.js +1 -0
- package/esm/createSitemap/types.d.ts +68 -0
- package/esm/createSitemap/types.js +1 -0
- package/esm/pipeline/getFileConventions/fileConventions.d.ts +4 -0
- package/esm/pipeline/getFileConventions/fileConventions.js +4 -0
- package/esm/pipeline/getFileConventions/getFileConventions.d.ts +4 -0
- package/esm/pipeline/getFileConventions/getFileConventions.js +17 -0
- package/esm/pipeline/getFileConventions/index.d.ts +1 -0
- package/esm/pipeline/getFileConventions/index.js +1 -0
- package/esm/{CodeHighlighter/addPathsToVariant.d.ts → pipeline/loadCodeVariant/addCodeVariantPaths.d.ts} +1 -1
- package/esm/{CodeHighlighter/applyTransform.d.ts → pipeline/loadCodeVariant/applyCodeTransform.d.ts} +3 -3
- package/esm/{CodeHighlighter/applyTransform.js → pipeline/loadCodeVariant/applyCodeTransform.js} +4 -4
- package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/calculateMainFilePath.js +1 -1
- package/esm/{CodeHighlighter/transformCode.d.ts → pipeline/loadCodeVariant/computeHastDeltas.d.ts} +9 -5
- package/esm/{CodeHighlighter/transformCode.js → pipeline/loadCodeVariant/computeHastDeltas.js} +20 -16
- package/esm/pipeline/loadCodeVariant/diffHast.d.ts +3 -0
- package/esm/{CodeHighlighter/transformParsedSource.js → pipeline/loadCodeVariant/diffHast.js} +5 -5
- package/esm/{CodeHighlighter/examineVariant.d.ts → pipeline/loadCodeVariant/examineCodeVariant.d.ts} +2 -2
- package/esm/{CodeHighlighter/examineVariant.js → pipeline/loadCodeVariant/examineCodeVariant.js} +1 -1
- package/esm/{useDemo/flattenVariant.d.ts → pipeline/loadCodeVariant/flattenCodeVariant.d.ts} +2 -2
- package/esm/{useDemo/flattenVariant.js → pipeline/loadCodeVariant/flattenCodeVariant.js} +3 -3
- package/esm/{CodeHighlighter/hasAllVariants.d.ts → pipeline/loadCodeVariant/hasAllCodeVariants.d.ts} +1 -1
- package/esm/pipeline/loadCodeVariant/index.d.ts +10 -0
- package/esm/pipeline/loadCodeVariant/index.js +17 -0
- package/esm/{CodeHighlighter/loadFallbackCode.d.ts → pipeline/loadCodeVariant/loadCodeFallback.d.ts} +2 -2
- package/esm/{CodeHighlighter/loadFallbackCode.js → pipeline/loadCodeVariant/loadCodeFallback.js} +180 -106
- package/esm/{CodeHighlighter/loadVariant.d.ts → pipeline/loadCodeVariant/loadCodeVariant.d.ts} +2 -2
- package/esm/{CodeHighlighter/loadVariant.js → pipeline/loadCodeVariant/loadCodeVariant.js} +122 -49
- package/esm/{CodeHighlighter/maybeInitialData.d.ts → pipeline/loadCodeVariant/maybeCodeInitialData.d.ts} +6 -6
- package/esm/{CodeHighlighter/maybeInitialData.js → pipeline/loadCodeVariant/maybeCodeInitialData.js} +6 -6
- package/esm/{CodeHighlighter/mergeMetadata.d.ts → pipeline/loadCodeVariant/mergeCodeMetadata.d.ts} +3 -3
- package/esm/{CodeHighlighter/mergeMetadata.js → pipeline/loadCodeVariant/mergeCodeMetadata.js} +3 -3
- package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/parseCode.d.ts +1 -1
- package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/transformSource.d.ts +1 -1
- package/esm/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.d.ts +5 -0
- package/esm/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.js +86 -13
- package/esm/pipeline/loadPrecomputedCodeHighlighter/performanceLogger.d.ts +30 -0
- package/esm/pipeline/loadPrecomputedCodeHighlighter/performanceLogger.js +77 -0
- package/esm/pipeline/loadPrecomputedCodeHighlighterClient/loadPrecomputedCodeHighlighterClient.js +7 -7
- package/esm/pipeline/loadPrecomputedSitemap/index.d.ts +2 -0
- package/esm/pipeline/loadPrecomputedSitemap/index.js +4 -0
- package/esm/pipeline/loadPrecomputedSitemap/loadPrecomputedSitemap.d.ts +10 -0
- package/esm/pipeline/loadPrecomputedSitemap/loadPrecomputedSitemap.js +213 -0
- package/esm/pipeline/loadServerCodeMeta/index.d.ts +2 -1
- package/esm/pipeline/loadServerCodeMeta/index.js +2 -1
- package/esm/pipeline/loadServerCodeMeta/loadServerCodeMeta.d.ts +1 -1
- package/esm/pipeline/loadServerCodeMeta/loadServerCodeMeta.js +2 -2
- package/esm/pipeline/{loaderUtils → loadServerCodeMeta}/resolveModulePathWithFs.d.ts +1 -1
- package/esm/pipeline/{loaderUtils → loadServerCodeMeta}/resolveModulePathWithFs.js +1 -1
- package/esm/pipeline/loadServerPageIndex/index.d.ts +2 -0
- package/esm/pipeline/loadServerPageIndex/index.js +1 -0
- package/esm/pipeline/loadServerPageIndex/loadServerPageIndex.d.ts +51 -0
- package/esm/pipeline/loadServerPageIndex/loadServerPageIndex.js +174 -0
- package/esm/pipeline/loadServerSitemap/index.d.ts +2 -0
- package/esm/pipeline/loadServerSitemap/index.js +1 -0
- package/esm/pipeline/loadServerSitemap/loadServerSitemap.d.ts +39 -0
- package/esm/pipeline/loadServerSitemap/loadServerSitemap.js +168 -0
- package/esm/pipeline/loadServerSource/loadServerSource.js +1 -1
- package/esm/pipeline/loaderUtils/externalsToPackages.js +1 -1
- package/esm/pipeline/loaderUtils/processRelativeImports.js +16 -3
- package/esm/pipeline/loaderUtils/rewriteImports.d.ts +36 -0
- package/esm/pipeline/loaderUtils/rewriteImports.js +139 -8
- package/esm/pipeline/syncPageIndex/createMarkdownNodes.d.ts +76 -0
- package/esm/pipeline/syncPageIndex/createMarkdownNodes.js +305 -0
- package/esm/pipeline/syncPageIndex/index.d.ts +1 -0
- package/esm/pipeline/syncPageIndex/index.js +1 -0
- package/esm/pipeline/syncPageIndex/mergeMetadataMarkdown.d.ts +58 -0
- package/esm/pipeline/syncPageIndex/mergeMetadataMarkdown.js +214 -0
- package/esm/pipeline/syncPageIndex/metadataToMarkdown.d.ts +67 -0
- package/esm/pipeline/syncPageIndex/metadataToMarkdown.js +1486 -0
- package/esm/pipeline/syncPageIndex/syncPageIndex.d.ts +108 -0
- package/esm/pipeline/syncPageIndex/syncPageIndex.js +540 -0
- package/esm/pipeline/transformHtmlCodePrecomputed/transformHtmlCodePrecomputed.d.ts +2 -2
- package/esm/pipeline/transformHtmlCodePrecomputed/transformHtmlCodePrecomputed.js +5 -5
- package/esm/pipeline/transformMarkdownBlockquoteCallouts/index.d.ts +2 -0
- package/esm/pipeline/transformMarkdownBlockquoteCallouts/index.js +4 -0
- package/esm/pipeline/transformMarkdownBlockquoteCallouts/transformMarkdownBlockquoteCallouts.d.ts +16 -0
- package/esm/pipeline/transformMarkdownBlockquoteCallouts/transformMarkdownBlockquoteCallouts.js +58 -0
- package/esm/pipeline/transformMarkdownDemoLinks/index.d.ts +2 -0
- package/esm/pipeline/transformMarkdownDemoLinks/index.js +4 -0
- package/esm/pipeline/transformMarkdownDemoLinks/transformMarkdownDemoLinks.d.ts +26 -0
- package/esm/pipeline/transformMarkdownDemoLinks/transformMarkdownDemoLinks.js +107 -0
- package/esm/pipeline/transformMarkdownMetadata/index.d.ts +2 -0
- package/esm/pipeline/transformMarkdownMetadata/index.js +4 -0
- package/esm/pipeline/transformMarkdownMetadata/transformMarkdownMetadata.d.ts +3 -0
- package/esm/pipeline/transformMarkdownMetadata/transformMarkdownMetadata.js +1010 -0
- package/esm/pipeline/transformMarkdownMetadata/types.d.ts +110 -0
- package/esm/pipeline/transformMarkdownMetadata/types.js +1 -0
- package/esm/pipeline/transformMarkdownRelativePaths/index.d.ts +2 -0
- package/esm/pipeline/transformMarkdownRelativePaths/index.js +4 -0
- package/esm/pipeline/transformMarkdownRelativePaths/transformMarkdownRelativePaths.d.ts +15 -0
- package/esm/pipeline/transformMarkdownRelativePaths/transformMarkdownRelativePaths.js +40 -0
- package/esm/useCode/Pre.js +15 -2
- package/esm/useCode/useCode.d.ts +15 -2
- package/esm/useCode/useCode.js +15 -6
- package/esm/useCode/useCodeUtils.js +3 -3
- package/esm/useCode/useFileNavigation.d.ts +9 -3
- package/esm/useCode/useFileNavigation.js +124 -81
- package/esm/useCode/useUIState.d.ts +4 -1
- package/esm/useCode/useUIState.js +17 -2
- package/esm/useCode/useVariantSelection.d.ts +8 -3
- package/esm/useCode/useVariantSelection.js +144 -52
- package/esm/useCopier/index.js +5 -4
- package/esm/useDemo/createCodeSandbox.d.ts +1 -1
- package/esm/useDemo/createStackBlitz.d.ts +1 -1
- package/esm/useDemo/exportVariant.js +13 -11
- package/esm/useDemo/index.d.ts +1 -1
- package/esm/useDemo/index.js +1 -1
- package/esm/useDemo/useDemo.d.ts +5 -5
- package/esm/useDemo/useDemo.js +6 -6
- package/esm/useErrors/useErrors.d.ts +1 -1
- package/esm/useErrors/useErrors.js +6 -2
- package/esm/useSearch/index.d.ts +1 -0
- package/esm/useSearch/index.js +1 -0
- package/esm/useSearch/types.d.ts +165 -0
- package/esm/useSearch/types.js +1 -0
- package/esm/useSearch/useSearch.d.ts +56 -0
- package/esm/useSearch/useSearch.js +647 -0
- package/esm/withDocsInfra/withDeploymentConfig.js +4 -2
- package/esm/withDocsInfra/withDocsInfra.d.ts +39 -0
- package/esm/withDocsInfra/withDocsInfra.js +79 -7
- package/package.json +106 -6
- package/esm/CodeHighlighter/transformParsedSource.d.ts +0 -3
- /package/esm/{CodeHighlighter/addPathsToVariant.js → pipeline/loadCodeVariant/addCodeVariantPaths.js} +0 -0
- /package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/calculateMainFilePath.d.ts +0 -0
- /package/esm/{CodeHighlighter/hasAllVariants.js → pipeline/loadCodeVariant/hasAllCodeVariants.js} +0 -0
- /package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/parseCode.js +0 -0
- /package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/pathUtils.d.ts +0 -0
- /package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/pathUtils.js +0 -0
- /package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/transformSource.js +0 -0
|
@@ -0,0 +1,647 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import _regenerator from "@babel/runtime/helpers/esm/regenerator";
|
|
4
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
5
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
6
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
7
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
8
|
+
import * as React from 'react';
|
|
9
|
+
import { create, insertMultiple, search as oramaSearch } from '@orama/orama';
|
|
10
|
+
import { pluginQPS } from '@orama/plugin-qps';
|
|
11
|
+
import { stemmer, language } from '@orama/stemmers/english';
|
|
12
|
+
import { stopwords as englishStopwords } from '@orama/stopwords/english';
|
|
13
|
+
// https://github.com/oramasearch/orama/blob/main/packages/stopwords/lib/en.js
|
|
14
|
+
// Removed words that might be meaningful in a software documentation context
|
|
15
|
+
var stopWords = englishStopwords.filter(function (word) {
|
|
16
|
+
return word !== 'about' && word !== 'but' &&
|
|
17
|
+
// start of button
|
|
18
|
+
word !== 'for' &&
|
|
19
|
+
// part of form
|
|
20
|
+
word !== 'between' && word !== 'before' && word !== 'after' && word !== 'above' && word !== 'below' && word !== 'once' && word !== 'then' && word !== 'where' && word !== 'to' && word !== 'from' && word !== 'up' && word !== 'down' && word !== 'in' && word !== 'out' && word !== 'on' && word !== 'off' && word !== 'over' && word !== 'under';
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Type for our search document structure
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Orama schema definition for our search document
|
|
29
|
+
*/
|
|
30
|
+
var searchSchema = {
|
|
31
|
+
type: 'string',
|
|
32
|
+
group: 'string',
|
|
33
|
+
title: 'string',
|
|
34
|
+
description: 'string',
|
|
35
|
+
slug: 'string',
|
|
36
|
+
sectionTitle: 'string',
|
|
37
|
+
prefix: 'string',
|
|
38
|
+
path: 'string',
|
|
39
|
+
keywords: 'string',
|
|
40
|
+
page: 'string',
|
|
41
|
+
pageKeywords: 'string',
|
|
42
|
+
sections: 'string',
|
|
43
|
+
subsections: 'string',
|
|
44
|
+
part: 'string',
|
|
45
|
+
"export": 'string',
|
|
46
|
+
props: 'string',
|
|
47
|
+
dataAttributes: 'string',
|
|
48
|
+
cssVariables: 'string',
|
|
49
|
+
section: 'string',
|
|
50
|
+
subsection: 'string'
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Type for Orama search hit results
|
|
55
|
+
*/
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Default function to flatten a sitemap page into search results
|
|
59
|
+
*/
|
|
60
|
+
function defaultFlattenPage(page, sectionData, includeCategoryInGroup, excludeSections, generateSlug) {
|
|
61
|
+
var _page$keywords;
|
|
62
|
+
var results = [];
|
|
63
|
+
|
|
64
|
+
// Extract top-level sections and all subsections with their slugs
|
|
65
|
+
// Re-slugify from titles using the provided slugify function to match actual page IDs
|
|
66
|
+
var sections = [];
|
|
67
|
+
var subsections = [];
|
|
68
|
+
if (page.sections) {
|
|
69
|
+
var _loop = function _loop() {
|
|
70
|
+
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
|
|
71
|
+
originalSlug = _Object$entries$_i[0],
|
|
72
|
+
sectionInfo = _Object$entries$_i[1];
|
|
73
|
+
// Use generateSlug if provided, otherwise use the original slug from sitemap
|
|
74
|
+
var slug = generateSlug ? generateSlug(sectionInfo.title, []) : originalSlug;
|
|
75
|
+
sections.push({
|
|
76
|
+
title: sectionInfo.title,
|
|
77
|
+
slug: slug
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
// Subsections are all nested children (recursively)
|
|
81
|
+
if (sectionInfo.children && Object.keys(sectionInfo.children).length > 0) {
|
|
82
|
+
var _extractWithSlugs = function extractWithSlugs(hierarchy, parentSlugs, parentTitles) {
|
|
83
|
+
var items = [];
|
|
84
|
+
for (var _i2 = 0, _Object$entries2 = Object.entries(hierarchy); _i2 < _Object$entries2.length; _i2++) {
|
|
85
|
+
var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i2], 2),
|
|
86
|
+
childOriginalSlug = _Object$entries2$_i[0],
|
|
87
|
+
childData = _Object$entries2$_i[1];
|
|
88
|
+
// Use generateSlug if provided, otherwise use the original slug from sitemap
|
|
89
|
+
// When generateSlug is provided, pass parent titles for context
|
|
90
|
+
// (e.g., for Releases pages: v1.0.0-rc.0-autocomplete)
|
|
91
|
+
var childSlug = generateSlug ? generateSlug(childData.title, parentTitles) : childOriginalSlug;
|
|
92
|
+
var currentSlugs = [].concat(_toConsumableArray(parentSlugs), [childSlug]);
|
|
93
|
+
var currentTitles = [].concat(_toConsumableArray(parentTitles), [childData.title]);
|
|
94
|
+
items.push({
|
|
95
|
+
title: childData.title,
|
|
96
|
+
slug: childSlug,
|
|
97
|
+
parentSlugs: currentSlugs,
|
|
98
|
+
parentTitles: currentTitles
|
|
99
|
+
});
|
|
100
|
+
if (childData.children && Object.keys(childData.children).length > 0) {
|
|
101
|
+
items.push.apply(items, _toConsumableArray(_extractWithSlugs(childData.children, currentSlugs, currentTitles)));
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return items;
|
|
105
|
+
};
|
|
106
|
+
subsections.push.apply(subsections, _toConsumableArray(_extractWithSlugs(sectionInfo.children, [slug], [sectionInfo.title])));
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
// Top-level sections are the direct children
|
|
110
|
+
for (var _i = 0, _Object$entries = Object.entries(page.sections); _i < _Object$entries.length; _i++) {
|
|
111
|
+
_loop();
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
var flattened = {};
|
|
115
|
+
if ((_page$keywords = page.keywords) != null && _page$keywords.length) {
|
|
116
|
+
flattened.keywords = page.keywords.join(' ');
|
|
117
|
+
}
|
|
118
|
+
if (sections.length > 0) {
|
|
119
|
+
flattened.sections = sections.map(function (s) {
|
|
120
|
+
return s.title;
|
|
121
|
+
}).join(' ');
|
|
122
|
+
}
|
|
123
|
+
if (subsections.length > 0) {
|
|
124
|
+
flattened.subsections = subsections.map(function (s) {
|
|
125
|
+
return s.title;
|
|
126
|
+
}).join(' ');
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Add base page result
|
|
130
|
+
results.push(_extends(_extends({
|
|
131
|
+
type: 'page',
|
|
132
|
+
group: includeCategoryInGroup ? "".concat(sectionData.title, " Pages") : 'Pages',
|
|
133
|
+
page: page.title,
|
|
134
|
+
title: page.title,
|
|
135
|
+
slug: page.slug,
|
|
136
|
+
path: page.path,
|
|
137
|
+
description: page.description,
|
|
138
|
+
sectionTitle: sectionData.title,
|
|
139
|
+
prefix: sectionData.prefix
|
|
140
|
+
}, flattened.keywords ? {
|
|
141
|
+
keywords: flattened.keywords
|
|
142
|
+
} : {}), excludeSections ? {} : {
|
|
143
|
+
sections: flattened.sections,
|
|
144
|
+
subsections: flattened.subsections
|
|
145
|
+
}));
|
|
146
|
+
|
|
147
|
+
// Add entries for each part
|
|
148
|
+
if (page.parts && Object.keys(page.parts).length > 0) {
|
|
149
|
+
for (var _i3 = 0, _Object$entries3 = Object.entries(page.parts); _i3 < _Object$entries3.length; _i3++) {
|
|
150
|
+
var _Object$entries3$_i = _slicedToArray(_Object$entries3[_i3], 2),
|
|
151
|
+
partName = _Object$entries3$_i[0],
|
|
152
|
+
partData = _Object$entries3$_i[1];
|
|
153
|
+
results.push({
|
|
154
|
+
type: 'part',
|
|
155
|
+
group: 'API Reference',
|
|
156
|
+
part: partName,
|
|
157
|
+
"export": "".concat(page.slug, ".").concat(partName),
|
|
158
|
+
slug: partName.toLowerCase(),
|
|
159
|
+
path: page.path,
|
|
160
|
+
title: page.title ? "".concat(page.title, " \u2023 ").concat(partName) : partName,
|
|
161
|
+
description: page.description,
|
|
162
|
+
sectionTitle: sectionData.title,
|
|
163
|
+
prefix: sectionData.prefix,
|
|
164
|
+
props: partData.props ? partData.props.join(' ') : '',
|
|
165
|
+
dataAttributes: partData.dataAttributes ? partData.dataAttributes.join(' ') : '',
|
|
166
|
+
cssVariables: partData.cssVariables ? partData.cssVariables.join(' ') : '',
|
|
167
|
+
keywords: flattened.keywords
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// Add entries for each export
|
|
173
|
+
if (page.exports && Object.keys(page.exports).length > 0) {
|
|
174
|
+
for (var _i4 = 0, _Object$entries4 = Object.entries(page.exports); _i4 < _Object$entries4.length; _i4++) {
|
|
175
|
+
var _Object$entries4$_i = _slicedToArray(_Object$entries4[_i4], 2),
|
|
176
|
+
exportName = _Object$entries4$_i[0],
|
|
177
|
+
exportData = _Object$entries4$_i[1];
|
|
178
|
+
// If export name matches page slug (case-insensitive), use #api-reference
|
|
179
|
+
var exportSlug = exportName.toLowerCase() === page.slug.toLowerCase() ? 'api-reference' : exportName.toLowerCase();
|
|
180
|
+
results.push({
|
|
181
|
+
type: 'export',
|
|
182
|
+
group: 'API Reference',
|
|
183
|
+
"export": exportSlug,
|
|
184
|
+
slug: page.slug,
|
|
185
|
+
path: page.path,
|
|
186
|
+
title: exportName,
|
|
187
|
+
description: page.description,
|
|
188
|
+
sectionTitle: sectionData.title,
|
|
189
|
+
prefix: sectionData.prefix,
|
|
190
|
+
props: exportData.props ? exportData.props.join(' ') : '',
|
|
191
|
+
dataAttributes: exportData.dataAttributes ? exportData.dataAttributes.join(' ') : '',
|
|
192
|
+
cssVariables: exportData.cssVariables ? exportData.cssVariables.join(' ') : '',
|
|
193
|
+
keywords: flattened.keywords
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// Add entries for each section
|
|
199
|
+
for (var _i5 = 0, _sections = sections; _i5 < _sections.length; _i5++) {
|
|
200
|
+
var sectionItem = _sections[_i5];
|
|
201
|
+
results.push({
|
|
202
|
+
type: 'section',
|
|
203
|
+
group: 'Sections',
|
|
204
|
+
section: sectionItem.title,
|
|
205
|
+
slug: "".concat(page.slug, "#").concat(sectionItem.slug),
|
|
206
|
+
path: page.path,
|
|
207
|
+
title: page.title ? "".concat(page.title, " \u2023 ").concat(sectionItem.title) : sectionItem.title,
|
|
208
|
+
description: page.description,
|
|
209
|
+
sectionTitle: sectionData.title,
|
|
210
|
+
prefix: sectionData.prefix,
|
|
211
|
+
keywords: flattened.keywords
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// Add entries for each subsection
|
|
216
|
+
for (var _i6 = 0, _subsections = subsections; _i6 < _subsections.length; _i6++) {
|
|
217
|
+
var subsectionItem = _subsections[_i6];
|
|
218
|
+
var fullTitle = subsectionItem.parentTitles.join(' ‣ ');
|
|
219
|
+
results.push({
|
|
220
|
+
type: 'subsection',
|
|
221
|
+
group: 'Sections',
|
|
222
|
+
subsection: fullTitle,
|
|
223
|
+
slug: "".concat(page.slug, "#").concat(subsectionItem.slug.toLowerCase()),
|
|
224
|
+
path: page.path,
|
|
225
|
+
title: page.title ? "".concat(page.title, " \u2023 ").concat(fullTitle) : fullTitle,
|
|
226
|
+
description: page.description,
|
|
227
|
+
sectionTitle: sectionData.title,
|
|
228
|
+
prefix: sectionData.prefix,
|
|
229
|
+
keywords: flattened.keywords
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
return results;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Default function to format search results
|
|
237
|
+
*/
|
|
238
|
+
function defaultFormatResult(hit) {
|
|
239
|
+
var base = {
|
|
240
|
+
id: hit.id,
|
|
241
|
+
title: hit.document.title,
|
|
242
|
+
description: hit.document.description,
|
|
243
|
+
slug: hit.document.slug,
|
|
244
|
+
sectionTitle: hit.document.sectionTitle,
|
|
245
|
+
prefix: hit.document.prefix,
|
|
246
|
+
path: hit.document.path,
|
|
247
|
+
score: hit.score,
|
|
248
|
+
keywords: hit.document.keywords
|
|
249
|
+
};
|
|
250
|
+
var type = hit.document.type;
|
|
251
|
+
if (type === 'part') {
|
|
252
|
+
return _extends(_extends({}, base), {}, {
|
|
253
|
+
type: 'part',
|
|
254
|
+
part: hit.document.part,
|
|
255
|
+
"export": hit.document["export"],
|
|
256
|
+
props: hit.document.props,
|
|
257
|
+
dataAttributes: hit.document.dataAttributes,
|
|
258
|
+
cssVariables: hit.document.cssVariables
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
if (type === 'export') {
|
|
262
|
+
return _extends(_extends({}, base), {}, {
|
|
263
|
+
type: 'export',
|
|
264
|
+
"export": hit.document["export"],
|
|
265
|
+
props: hit.document.props,
|
|
266
|
+
dataAttributes: hit.document.dataAttributes,
|
|
267
|
+
cssVariables: hit.document.cssVariables
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
if (type === 'section') {
|
|
271
|
+
return _extends(_extends({}, base), {}, {
|
|
272
|
+
type: 'section',
|
|
273
|
+
section: hit.document.section
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
if (type === 'subsection') {
|
|
277
|
+
return _extends(_extends({}, base), {}, {
|
|
278
|
+
type: 'subsection',
|
|
279
|
+
subsection: hit.document.subsection
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
// Default to page type
|
|
284
|
+
return _extends(_extends(_extends({}, base), {}, {
|
|
285
|
+
type: 'page',
|
|
286
|
+
page: hit.document.title
|
|
287
|
+
}, hit.document.sections ? {
|
|
288
|
+
sections: hit.document.sections
|
|
289
|
+
} : {}), hit.document.subsections ? {
|
|
290
|
+
subsections: hit.document.subsections
|
|
291
|
+
} : {});
|
|
292
|
+
}
|
|
293
|
+
export var defaultSearchBoost = {
|
|
294
|
+
type: 100,
|
|
295
|
+
group: 100,
|
|
296
|
+
slug: 2,
|
|
297
|
+
path: 2,
|
|
298
|
+
title: 2,
|
|
299
|
+
page: 10,
|
|
300
|
+
pageKeywords: 15,
|
|
301
|
+
description: 1.5,
|
|
302
|
+
part: 1.5,
|
|
303
|
+
"export": 1.3,
|
|
304
|
+
sectionTitle: 50,
|
|
305
|
+
section: 3,
|
|
306
|
+
subsection: 2.5,
|
|
307
|
+
props: 1.5,
|
|
308
|
+
dataAttributes: 1.5,
|
|
309
|
+
cssVariables: 1.5,
|
|
310
|
+
sections: 0.7,
|
|
311
|
+
subsections: 0.3,
|
|
312
|
+
keywords: 1.5
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* Hook for managing search functionality with Orama
|
|
317
|
+
*
|
|
318
|
+
* @param options Configuration options for search behavior
|
|
319
|
+
* @returns Search state and functions
|
|
320
|
+
*/
|
|
321
|
+
export function useSearch(options) {
|
|
322
|
+
var sitemapImport = options.sitemap,
|
|
323
|
+
maxDefaultResults = options.maxDefaultResults,
|
|
324
|
+
_options$tolerance = options.tolerance,
|
|
325
|
+
tolerance = _options$tolerance === void 0 ? 1 : _options$tolerance,
|
|
326
|
+
_options$limit = options.limit,
|
|
327
|
+
defaultLimit = _options$limit === void 0 ? 20 : _options$limit,
|
|
328
|
+
_options$boost = options.boost,
|
|
329
|
+
boost = _options$boost === void 0 ? defaultSearchBoost : _options$boost,
|
|
330
|
+
_options$enableStemmi = options.enableStemming,
|
|
331
|
+
enableStemming = _options$enableStemmi === void 0 ? true : _options$enableStemmi,
|
|
332
|
+
generateSlug = options.generateSlug,
|
|
333
|
+
_options$flattenPage = options.flattenPage,
|
|
334
|
+
flattenPage = _options$flattenPage === void 0 ? defaultFlattenPage : _options$flattenPage,
|
|
335
|
+
_options$formatResult = options.formatResult,
|
|
336
|
+
formatResult = _options$formatResult === void 0 ? defaultFormatResult : _options$formatResult;
|
|
337
|
+
var _React$useState = React.useState(null),
|
|
338
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
339
|
+
index = _React$useState2[0],
|
|
340
|
+
setIndex = _React$useState2[1];
|
|
341
|
+
var _React$useState3 = React.useState({
|
|
342
|
+
results: [],
|
|
343
|
+
count: 0,
|
|
344
|
+
elapsed: {
|
|
345
|
+
raw: 0,
|
|
346
|
+
formatted: '0ms'
|
|
347
|
+
}
|
|
348
|
+
}),
|
|
349
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
350
|
+
defaultResults = _React$useState4[0],
|
|
351
|
+
setDefaultResults = _React$useState4[1];
|
|
352
|
+
var _React$useState5 = React.useState({
|
|
353
|
+
results: [],
|
|
354
|
+
count: 0,
|
|
355
|
+
elapsed: {
|
|
356
|
+
raw: 0,
|
|
357
|
+
formatted: '0ms'
|
|
358
|
+
}
|
|
359
|
+
}),
|
|
360
|
+
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
361
|
+
results = _React$useState6[0],
|
|
362
|
+
setResults = _React$useState6[1];
|
|
363
|
+
React.useEffect(function () {
|
|
364
|
+
_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
365
|
+
var _yield$sitemapImport, sitemap, searchIndex, pages, pageResultsByGroup, pageResultsCount, dummyDoc, pageResultsGrouped, defaultResultsValue;
|
|
366
|
+
return _regenerator().w(function (_context) {
|
|
367
|
+
while (1) switch (_context.n) {
|
|
368
|
+
case 0:
|
|
369
|
+
_context.n = 1;
|
|
370
|
+
return sitemapImport();
|
|
371
|
+
case 1:
|
|
372
|
+
_yield$sitemapImport = _context.v;
|
|
373
|
+
sitemap = _yield$sitemapImport.sitemap;
|
|
374
|
+
if (sitemap) {
|
|
375
|
+
_context.n = 2;
|
|
376
|
+
break;
|
|
377
|
+
}
|
|
378
|
+
console.error('Sitemap is undefined');
|
|
379
|
+
return _context.a(2);
|
|
380
|
+
case 2:
|
|
381
|
+
_context.n = 3;
|
|
382
|
+
return create({
|
|
383
|
+
schema: searchSchema,
|
|
384
|
+
components: enableStemming ? {
|
|
385
|
+
tokenizer: {
|
|
386
|
+
stemming: true,
|
|
387
|
+
language: language,
|
|
388
|
+
stemmer: stemmer,
|
|
389
|
+
stemmerSkipProperties: ['type', 'group', 'slug', 'sectionTitle', 'page', 'part', 'export', 'dataAttributes', 'cssVariables', 'props'],
|
|
390
|
+
stopWords: stopWords
|
|
391
|
+
}
|
|
392
|
+
} : undefined,
|
|
393
|
+
plugins: [pluginQPS()]
|
|
394
|
+
});
|
|
395
|
+
case 3:
|
|
396
|
+
searchIndex = _context.v;
|
|
397
|
+
// Flatten the sitemap data structure to a single array of pages
|
|
398
|
+
pages = [];
|
|
399
|
+
pageResultsByGroup = {};
|
|
400
|
+
pageResultsCount = 0;
|
|
401
|
+
Object.entries(sitemap.data).forEach(function (_ref2) {
|
|
402
|
+
var _ref3 = _slicedToArray(_ref2, 2),
|
|
403
|
+
_sectionKey = _ref3[0],
|
|
404
|
+
sectionData = _ref3[1];
|
|
405
|
+
(sectionData.pages || []).forEach(function (page) {
|
|
406
|
+
var flattened = flattenPage(page, sectionData, options.includeCategoryInGroup || false, options.excludeSections, generateSlug);
|
|
407
|
+
pages.push.apply(pages, _toConsumableArray(flattened));
|
|
408
|
+
|
|
409
|
+
// Add the first result (page type) to default results, grouped by their group
|
|
410
|
+
if ((maxDefaultResults === undefined || pageResultsCount < maxDefaultResults) && flattened.length > 0) {
|
|
411
|
+
var pageResult = flattened[0];
|
|
412
|
+
var group = pageResult.group || 'Pages';
|
|
413
|
+
if (!pageResultsByGroup[group]) {
|
|
414
|
+
pageResultsByGroup[group] = [];
|
|
415
|
+
}
|
|
416
|
+
pageResultsByGroup[group].push(pageResult);
|
|
417
|
+
pageResultsCount += 1;
|
|
418
|
+
}
|
|
419
|
+
});
|
|
420
|
+
});
|
|
421
|
+
|
|
422
|
+
// Insert a dummy document with all fields to ensure QPS plugin initializes stats for all properties.
|
|
423
|
+
// This is needed because QPS only creates stats for properties that have data inserted.
|
|
424
|
+
// Using empty strings ensures no false matches while still initializing the stats.
|
|
425
|
+
dummyDoc = {
|
|
426
|
+
type: '',
|
|
427
|
+
group: '',
|
|
428
|
+
title: '',
|
|
429
|
+
description: '',
|
|
430
|
+
slug: '',
|
|
431
|
+
sectionTitle: '',
|
|
432
|
+
prefix: '',
|
|
433
|
+
path: '',
|
|
434
|
+
keywords: '',
|
|
435
|
+
page: '',
|
|
436
|
+
pageKeywords: '',
|
|
437
|
+
sections: '',
|
|
438
|
+
subsections: '',
|
|
439
|
+
part: '',
|
|
440
|
+
"export": '',
|
|
441
|
+
props: '',
|
|
442
|
+
dataAttributes: '',
|
|
443
|
+
cssVariables: '',
|
|
444
|
+
section: '',
|
|
445
|
+
subsection: ''
|
|
446
|
+
};
|
|
447
|
+
_context.n = 4;
|
|
448
|
+
return insertMultiple(searchIndex, [dummyDoc].concat(pages));
|
|
449
|
+
case 4:
|
|
450
|
+
pageResultsGrouped = Object.entries(pageResultsByGroup).map(function (_ref4) {
|
|
451
|
+
var _ref5 = _slicedToArray(_ref4, 2),
|
|
452
|
+
group = _ref5[0],
|
|
453
|
+
items = _ref5[1];
|
|
454
|
+
return {
|
|
455
|
+
group: group,
|
|
456
|
+
items: items
|
|
457
|
+
};
|
|
458
|
+
});
|
|
459
|
+
defaultResultsValue = {
|
|
460
|
+
results: pageResultsGrouped,
|
|
461
|
+
count: pageResultsCount,
|
|
462
|
+
elapsed: {
|
|
463
|
+
raw: 0,
|
|
464
|
+
formatted: '0ms'
|
|
465
|
+
}
|
|
466
|
+
};
|
|
467
|
+
setIndex(searchIndex);
|
|
468
|
+
setDefaultResults(defaultResultsValue);
|
|
469
|
+
setResults(defaultResultsValue);
|
|
470
|
+
case 5:
|
|
471
|
+
return _context.a(2);
|
|
472
|
+
}
|
|
473
|
+
}, _callee);
|
|
474
|
+
}))();
|
|
475
|
+
}, [sitemapImport, maxDefaultResults, flattenPage, generateSlug, enableStemming, options.includeCategoryInGroup, options.excludeSections]);
|
|
476
|
+
var search = React.useCallback(/*#__PURE__*/function () {
|
|
477
|
+
var _ref6 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(value) {
|
|
478
|
+
var _ref7,
|
|
479
|
+
facets,
|
|
480
|
+
groupBy,
|
|
481
|
+
_ref7$limit,
|
|
482
|
+
limit,
|
|
483
|
+
where,
|
|
484
|
+
valueLower,
|
|
485
|
+
valueNormalized,
|
|
486
|
+
useCustomSort,
|
|
487
|
+
cache,
|
|
488
|
+
getDocProps,
|
|
489
|
+
searchResults,
|
|
490
|
+
count,
|
|
491
|
+
elapsed,
|
|
492
|
+
groupedResults,
|
|
493
|
+
formattedResults,
|
|
494
|
+
_args2 = arguments;
|
|
495
|
+
return _regenerator().w(function (_context2) {
|
|
496
|
+
while (1) switch (_context2.n) {
|
|
497
|
+
case 0:
|
|
498
|
+
_ref7 = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : {}, facets = _ref7.facets, groupBy = _ref7.groupBy, _ref7$limit = _ref7.limit, limit = _ref7$limit === void 0 ? defaultLimit : _ref7$limit, where = _ref7.where;
|
|
499
|
+
if (!(!index || !value.trim())) {
|
|
500
|
+
_context2.n = 1;
|
|
501
|
+
break;
|
|
502
|
+
}
|
|
503
|
+
setResults(defaultResults);
|
|
504
|
+
return _context2.a(2);
|
|
505
|
+
case 1:
|
|
506
|
+
valueLower = value.toLowerCase(); // Normalize for comparison: convert spaces/hyphens to a common format
|
|
507
|
+
valueNormalized = valueLower.replace(/[-\s]+/g, ' ').trim(); // For longer search terms, skip custom sorting and rely on Orama's scoring
|
|
508
|
+
// The overhead of checking exact/startsWith/contains isn't worth it
|
|
509
|
+
useCustomSort = valueLower.length <= 20; // Cache for computed document properties to avoid repeated string operations
|
|
510
|
+
cache = new Map();
|
|
511
|
+
getDocProps = function getDocProps(doc) {
|
|
512
|
+
var key = doc.slug; // Use slug as cache key since it's unique per document
|
|
513
|
+
var props = cache.get(key);
|
|
514
|
+
if (!props) {
|
|
515
|
+
var titleLower = doc.title.toLowerCase();
|
|
516
|
+
var slugLower = doc.slug.toLowerCase();
|
|
517
|
+
props = {
|
|
518
|
+
titleLower: titleLower,
|
|
519
|
+
slugLower: slugLower,
|
|
520
|
+
slugNormalized: slugLower.replace(/-/g, ' ')
|
|
521
|
+
};
|
|
522
|
+
cache.set(key, props);
|
|
523
|
+
}
|
|
524
|
+
return props;
|
|
525
|
+
};
|
|
526
|
+
_context2.n = 2;
|
|
527
|
+
return oramaSearch(index, {
|
|
528
|
+
term: value,
|
|
529
|
+
facets: facets,
|
|
530
|
+
groupBy: groupBy,
|
|
531
|
+
where: where,
|
|
532
|
+
limit: limit,
|
|
533
|
+
tolerance: tolerance,
|
|
534
|
+
boost: boost,
|
|
535
|
+
sortBy: useCustomSort ? function (_ref8, _ref9) {
|
|
536
|
+
var _ref0 = _slicedToArray(_ref8, 3),
|
|
537
|
+
_ = _ref0[0],
|
|
538
|
+
aScore = _ref0[1],
|
|
539
|
+
aDocument = _ref0[2];
|
|
540
|
+
var _ref1 = _slicedToArray(_ref9, 3),
|
|
541
|
+
__ = _ref1[0],
|
|
542
|
+
bScore = _ref1[1],
|
|
543
|
+
bDocument = _ref1[2];
|
|
544
|
+
var a = getDocProps(aDocument);
|
|
545
|
+
var b = getDocProps(bDocument);
|
|
546
|
+
|
|
547
|
+
// Prioritize exact matches (short-circuit on first match)
|
|
548
|
+
var aExact = a.titleLower === valueLower || a.slugLower === valueLower || a.slugNormalized === valueNormalized;
|
|
549
|
+
var bExact = b.titleLower === valueLower || b.slugLower === valueLower || b.slugNormalized === valueNormalized;
|
|
550
|
+
if (aExact !== bExact) {
|
|
551
|
+
return aExact ? -1 : 1;
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
// Then prioritize startsWith matches
|
|
555
|
+
var aStartsWith = a.titleLower.startsWith(valueLower) || a.slugNormalized.startsWith(valueNormalized);
|
|
556
|
+
var bStartsWith = b.titleLower.startsWith(valueLower) || b.slugNormalized.startsWith(valueNormalized);
|
|
557
|
+
if (aStartsWith !== bStartsWith) {
|
|
558
|
+
return aStartsWith ? -1 : 1;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
// Then prioritize contains matches
|
|
562
|
+
var aContains = a.titleLower.includes(valueLower) || a.slugNormalized.includes(valueNormalized);
|
|
563
|
+
var bContains = b.titleLower.includes(valueLower) || b.slugNormalized.includes(valueNormalized);
|
|
564
|
+
if (aContains !== bContains) {
|
|
565
|
+
return aContains ? -1 : 1;
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
// Then sort by score descending
|
|
569
|
+
return bScore - aScore;
|
|
570
|
+
} : undefined
|
|
571
|
+
});
|
|
572
|
+
case 2:
|
|
573
|
+
searchResults = _context2.v;
|
|
574
|
+
count = searchResults.count;
|
|
575
|
+
elapsed = searchResults.elapsed;
|
|
576
|
+
if (!searchResults.groups) {
|
|
577
|
+
_context2.n = 3;
|
|
578
|
+
break;
|
|
579
|
+
}
|
|
580
|
+
groupedResults = searchResults.groups.map(function (group) {
|
|
581
|
+
return {
|
|
582
|
+
group: group.values.join(' '),
|
|
583
|
+
items: group.result.map(formatResult)
|
|
584
|
+
};
|
|
585
|
+
});
|
|
586
|
+
setResults({
|
|
587
|
+
results: groupedResults,
|
|
588
|
+
count: count,
|
|
589
|
+
elapsed: elapsed
|
|
590
|
+
});
|
|
591
|
+
return _context2.a(2);
|
|
592
|
+
case 3:
|
|
593
|
+
formattedResults = searchResults.hits.map(formatResult);
|
|
594
|
+
setResults({
|
|
595
|
+
results: [{
|
|
596
|
+
group: 'Default',
|
|
597
|
+
items: formattedResults
|
|
598
|
+
}],
|
|
599
|
+
count: count,
|
|
600
|
+
elapsed: elapsed
|
|
601
|
+
});
|
|
602
|
+
case 4:
|
|
603
|
+
return _context2.a(2);
|
|
604
|
+
}
|
|
605
|
+
}, _callee2);
|
|
606
|
+
}));
|
|
607
|
+
return function (_x) {
|
|
608
|
+
return _ref6.apply(this, arguments);
|
|
609
|
+
};
|
|
610
|
+
}(), [index, defaultLimit, defaultResults, tolerance, boost, formatResult]);
|
|
611
|
+
|
|
612
|
+
/**
|
|
613
|
+
* Build a URL from a search result
|
|
614
|
+
* Handles path normalization and hash fragments for different result types
|
|
615
|
+
*/
|
|
616
|
+
var buildResultUrl = React.useCallback(function (result) {
|
|
617
|
+
var url = result.path.startsWith('./') ? "".concat(result.prefix).concat(result.path.replace(/^\.\//, '').replace(/\/page\.mdx$/, '')) : result.path;
|
|
618
|
+
|
|
619
|
+
// Add hash for non-page types
|
|
620
|
+
if ('type' in result && result.type !== 'page') {
|
|
621
|
+
var hash;
|
|
622
|
+
if (result.type === 'section' || result.type === 'subsection') {
|
|
623
|
+
// For sections and subsections, extract hash from the slug field
|
|
624
|
+
// which already contains the page slug + hash (e.g., "button#api-reference")
|
|
625
|
+
var hashIndex = result.slug.indexOf('#');
|
|
626
|
+
hash = hashIndex !== -1 ? result.slug.substring(hashIndex + 1) : '';
|
|
627
|
+
} else if (result.type === 'part') {
|
|
628
|
+
hash = result.part.toLowerCase();
|
|
629
|
+
} else if (result.type === 'export') {
|
|
630
|
+
hash = result["export"]; // already lowercase or api-reference
|
|
631
|
+
} else {
|
|
632
|
+
hash = '';
|
|
633
|
+
}
|
|
634
|
+
if (hash) {
|
|
635
|
+
url += "#".concat(hash);
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
return url;
|
|
639
|
+
}, []);
|
|
640
|
+
return {
|
|
641
|
+
results: results,
|
|
642
|
+
isReady: index !== null,
|
|
643
|
+
search: search,
|
|
644
|
+
defaultResults: defaultResults,
|
|
645
|
+
buildResultUrl: buildResultUrl
|
|
646
|
+
};
|
|
647
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import * as os from 'node:os';
|
|
2
3
|
/**
|
|
3
4
|
* See the docs of the Netlify environment variables:
|
|
4
5
|
* https://docs.netlify.com/configure-builds/environment-variables/#build-metadata.
|
|
@@ -32,7 +33,8 @@ process.env.DEPLOY_ENV = DEPLOY_ENV;
|
|
|
32
33
|
export function withDeploymentConfig(nextConfig) {
|
|
33
34
|
return _extends(_extends({
|
|
34
35
|
trailingSlash: true,
|
|
35
|
-
reactStrictMode: true
|
|
36
|
+
reactStrictMode: true,
|
|
37
|
+
productionBrowserSourceMaps: true
|
|
36
38
|
}, nextConfig), {}, {
|
|
37
39
|
env: _extends(_extends({
|
|
38
40
|
// production | staging | pull-request | development
|
|
@@ -57,7 +59,7 @@ export function withDeploymentConfig(nextConfig) {
|
|
|
57
59
|
scrollRestoration: true,
|
|
58
60
|
workerThreads: false
|
|
59
61
|
}, process.env.CI ? {
|
|
60
|
-
cpus:
|
|
62
|
+
cpus: process.env.NEXT_PARALLELISM ? parseInt(process.env.NEXT_PARALLELISM, 10) : os.availableParallelism()
|
|
61
63
|
} : {}), nextConfig.experimental),
|
|
62
64
|
eslint: _extends({
|
|
63
65
|
ignoreDuringBuilds: true
|