|
6 | 6 |
|
7 | 7 |
|
8 | 8 | (function() { |
| 9 | + let rawSearchIndex; |
| 10 | + let docSearch; |
9 | 11 | const longItemTypes = [ |
10 | 12 | "keyword", |
11 | 13 | "primitive type", |
|
143 | 145 |
|
144 | 146 | for (const item of array) { |
145 | 147 | const name = item.name; |
146 | | - const type = itemTypes[item.ty]; |
| 148 | + const type = window.DocSearch.getItemType(item.ty); |
147 | 149 | const longType = longItemTypes[item.ty]; |
148 | 150 | const typeName = longType.length !== 0 ? `${longType}` : "?"; |
149 | 151 |
|
@@ -247,7 +249,7 @@ ${item.displayPath}<span class="${type}">${name}</span>\ |
247 | 249 | return; |
248 | 250 | } |
249 | 251 | if (results.query === undefined) { |
250 | | - results.query = DocSearch.parseQuery(searchState.input.value); |
| 252 | + results.query = window.DocSearch.parseQuery(searchState.input.value); |
251 | 253 | } |
252 | 254 |
|
253 | 255 | currentResults = results.query.userQuery; |
@@ -378,7 +380,7 @@ ${item.displayPath}<span class="${type}">${name}</span>\ |
378 | 380 | * @param {boolean} [forced] |
379 | 381 | */ |
380 | 382 | async function search(forced) { |
381 | | - const query = DocSearch.parseQuery(searchState.input.value.trim()); |
| 383 | + const query = window.DocSearch.parseQuery(searchState.input.value.trim()); |
382 | 384 | let filterCrates = getFilterCrates(); |
383 | 385 |
|
384 | 386 | if (!forced && query.userQuery === currentResults) { |
@@ -595,8 +597,9 @@ ${item.displayPath}<span class="${type}">${name}</span>\ |
595 | 597 | } |
596 | 598 |
|
597 | 599 | function initSearch(rawSearchIndex) { |
| 600 | + rawSearchIndex = rawSearchIndex; |
598 | 601 | if (typeof window !== "undefined") { |
599 | | - window.docSearch = new window.DocSearch(rawSearchIndex); |
| 602 | + docSearch = new window.DocSearch(rawSearchIndex); |
600 | 603 | } else if (typeof exports !== "undefined") { |
601 | 604 | exports.docSearch = new exports.DocSearch(rawSearchIndex); |
602 | 605 | } |
|
0 commit comments