@vuepress-plume/plugin-search 1.0.0-rc.163 → 1.0.0-rc.165

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.
@@ -30,14 +30,9 @@ const searchIndexData = shallowRef(searchIndex);
30
30
  function useSearchIndex() {
31
31
  return searchIndexData;
32
32
  }
33
- if (__VUEPRESS_DEV__ && (import.meta.webpackHot || import.meta.hot)) {
34
- __VUE_HMR_RUNTIME__.updateSearchIndex = (data) => {
35
- searchIndexData.value = data;
36
- };
37
- __VUE_HMR_RUNTIME__.updateSearchIndex = (data) => {
38
- searchIndexData.value = data;
39
- };
40
- }
33
+ if (__VUEPRESS_DEV__ && (import.meta.webpackHot || import.meta.hot)) __VUE_HMR_RUNTIME__.updateSearchIndex = (data) => {
34
+ searchIndexData.value = data;
35
+ };
41
36
 
42
37
  //#endregion
43
38
  export { useLocale, useSearchIndex };
@@ -2,18 +2,11 @@ import { SearchOptions, SearchPluginOptions } from "../shared/index.js";
2
2
  import { App, Plugin } from "vuepress/core";
3
3
  export * from "../shared/index.js";
4
4
 
5
- //#region src/node/searchPlugin.d.ts
6
- declare function searchPlugin({
7
- locales,
8
- isSearchable,
9
- ...searchOptions
10
- }?: SearchPluginOptions): Plugin;
11
- //#endregion
12
5
  //#region src/node/prepareSearchIndex.d.ts
13
6
  interface SearchIndexOptions {
14
7
  app: App;
15
8
  searchOptions: SearchOptions;
16
- isSearchable: SearchPluginOptions["isSearchable"];
9
+ isSearchable: SearchPluginOptions['isSearchable'];
17
10
  }
18
11
  declare function prepareSearchIndex({
19
12
  app,
@@ -21,4 +14,11 @@ declare function prepareSearchIndex({
21
14
  searchOptions
22
15
  }: SearchIndexOptions): Promise<void>;
23
16
  //#endregion
17
+ //#region src/node/searchPlugin.d.ts
18
+ declare function searchPlugin({
19
+ locales,
20
+ isSearchable,
21
+ ...searchOptions
22
+ }?: SearchPluginOptions): Plugin;
23
+ //#endregion
24
24
  export { prepareSearchIndex, searchPlugin };
package/lib/node/index.js CHANGED
@@ -1,154 +1,11 @@
1
- import { addViteOptimizeDepsInclude, getFullLocaleConfig } from "@vuepress/helper";
2
- import chokidar from "chokidar";
3
- import { colors, getDirname, logger, path } from "vuepress/utils";
4
1
  import MiniSearch from "minisearch";
5
2
  import pMap from "p-map";
3
+ import { colors, getDirname, logger, path } from "vuepress/utils";
4
+ import { addViteOptimizeDepsInclude, getFullLocaleConfig } from "@vuepress/helper";
5
+ import chokidar from "chokidar";
6
6
 
7
7
  export * from "../shared/index.js"
8
8
 
9
- //#region src/node/locales/de.ts
10
- const deSearchLocale = {
11
- placeholder: "Dokumente durchsuchen",
12
- resetButtonTitle: "Suche zurücksetzen",
13
- backButtonTitle: "Schließen",
14
- noResultsText: "Keine Suchergebnisse:",
15
- footer: {
16
- selectText: "Auswählen",
17
- selectKeyAriaLabel: "Eingabe",
18
- navigateText: "Wechseln",
19
- navigateUpKeyAriaLabel: "Nach oben",
20
- navigateDownKeyAriaLabel: "Nach unten",
21
- closeText: "Schließen",
22
- closeKeyAriaLabel: "Beenden"
23
- }
24
- };
25
-
26
- //#endregion
27
- //#region src/node/locales/en.ts
28
- const enSearchLocale = {
29
- placeholder: "Search",
30
- resetButtonTitle: "Reset search",
31
- backButtonTitle: "Close search",
32
- noResultsText: "No results for",
33
- footer: {
34
- selectText: "to select",
35
- selectKeyAriaLabel: "enter",
36
- navigateText: "to navigate",
37
- navigateUpKeyAriaLabel: "up arrow",
38
- navigateDownKeyAriaLabel: "down arrow",
39
- closeText: "to close",
40
- closeKeyAriaLabel: "escape"
41
- }
42
- };
43
-
44
- //#endregion
45
- //#region src/node/locales/fr.ts
46
- const frSearchLocale = {
47
- placeholder: "Rechercher dans la documentation",
48
- resetButtonTitle: "Réinitialiser la recherche",
49
- backButtonTitle: "Fermer",
50
- noResultsText: "Aucun résultat trouvé :",
51
- footer: {
52
- selectText: "sélectionner",
53
- selectKeyAriaLabel: "Entrée",
54
- navigateText: "naviguer",
55
- navigateUpKeyAriaLabel: "haut",
56
- navigateDownKeyAriaLabel: "bas",
57
- closeText: "fermer",
58
- closeKeyAriaLabel: "sortie"
59
- }
60
- };
61
-
62
- //#endregion
63
- //#region src/node/locales/ja.ts
64
- const jaSearchLocale = {
65
- placeholder: "ドキュメントを検索",
66
- resetButtonTitle: "検索をリセット",
67
- backButtonTitle: "閉じる",
68
- noResultsText: "検索結果がありません:",
69
- footer: {
70
- selectText: "選択",
71
- selectKeyAriaLabel: "入力",
72
- navigateText: "切り替え",
73
- navigateUpKeyAriaLabel: "上へ",
74
- navigateDownKeyAriaLabel: "下へ",
75
- closeText: "閉じる",
76
- closeKeyAriaLabel: "終了"
77
- }
78
- };
79
-
80
- //#endregion
81
- //#region src/node/locales/ru.ts
82
- const ruSearchLocale = {
83
- placeholder: "Поиск по документации",
84
- resetButtonTitle: "Сбросить поиск",
85
- backButtonTitle: "Закрыть",
86
- noResultsText: "Нет результатов поиска:",
87
- footer: {
88
- selectText: "Выбрать",
89
- selectKeyAriaLabel: "Ввод",
90
- navigateText: "Переключить",
91
- navigateUpKeyAriaLabel: "Вверх",
92
- navigateDownKeyAriaLabel: "Вниз",
93
- closeText: "Закрыть",
94
- closeKeyAriaLabel: "Выход"
95
- }
96
- };
97
-
98
- //#endregion
99
- //#region src/node/locales/zh-tw.ts
100
- const zhTwSearchLocale = {
101
- placeholder: "搜索文檔",
102
- resetButtonTitle: "重置搜索",
103
- backButtonTitle: "關閉",
104
- noResultsText: "無搜索結果:",
105
- footer: {
106
- selectText: "選擇",
107
- selectKeyAriaLabel: "輸入",
108
- navigateText: "切換",
109
- navigateUpKeyAriaLabel: "向上",
110
- navigateDownKeyAriaLabel: "向下",
111
- closeText: "關閉",
112
- closeKeyAriaLabel: "退出"
113
- }
114
- };
115
-
116
- //#endregion
117
- //#region src/node/locales/zh.ts
118
- const zhSearchLocale = {
119
- placeholder: "搜索文档",
120
- resetButtonTitle: "重置搜索",
121
- backButtonTitle: "关闭",
122
- noResultsText: "无搜索结果:",
123
- footer: {
124
- selectText: "选择",
125
- selectKeyAriaLabel: "输入",
126
- navigateText: "切换",
127
- navigateUpKeyAriaLabel: "向上",
128
- navigateDownKeyAriaLabel: "向下",
129
- closeText: "关闭",
130
- closeKeyAriaLabel: "退出"
131
- }
132
- };
133
-
134
- //#endregion
135
- //#region src/node/locales/index.ts
136
- const SEARCH_LOCALES = [
137
- [["en", "en-US"], enSearchLocale],
138
- [[
139
- "zh",
140
- "zh-CN",
141
- "zh-Hans",
142
- "zh-Hant"
143
- ], zhSearchLocale],
144
- [["zh-TW"], zhTwSearchLocale],
145
- [["de", "de-DE"], deSearchLocale],
146
- [["fr", "fr-FR"], frSearchLocale],
147
- [["ru", "ru-RU"], ruSearchLocale],
148
- [["ja", "ja-JP"], jaSearchLocale]
149
- ];
150
-
151
- //#endregion
152
9
  //#region src/node/prepareSearchIndex.ts
153
10
  const SEARCH_INDEX_DIR = "internal/minisearchIndex/";
154
11
  const indexByLocales = /* @__PURE__ */ new Map();
@@ -181,8 +38,7 @@ async function prepareSearchIndex({ app, isSearchable, searchOptions }) {
181
38
  const start = performance.now();
182
39
  indexByLocales.clear();
183
40
  indexCache.clear();
184
- const pages = isSearchable ? app.pages.filter(isSearchable) : app.pages;
185
- await pMap(pages, (p) => indexFile(p, searchOptions), { concurrency: 64 });
41
+ await pMap(isSearchable ? app.pages.filter(isSearchable) : app.pages, (p) => indexFile(p, searchOptions), { concurrency: 64 });
186
42
  await writeTemp(app);
187
43
  if (app.env.isDebug) logger.info(`\n[${colors.green("@vuepress-plume/plugin-search")}] prepare search time spent: ${(performance.now() - start).toFixed(2)}ms`);
188
44
  }
@@ -220,9 +76,8 @@ async function indexFile(page, options) {
220
76
  const locale = page.pathLocale;
221
77
  const index = getIndexByLocale(locale, options);
222
78
  const cache = getIndexCache(fileId);
223
- const html = `<h1><a href="#"><span>${page.frontmatter.title || page.title}</span></a></h1>
224
- ${page.contentRendered}`;
225
- const sections = splitPageIntoSections(html);
79
+ const sections = splitPageIntoSections(`<h1><a href="#"><span>${page.frontmatter.title || page.title}</span></a></h1>
80
+ ${page.contentRendered}`);
226
81
  if (cache && cache.length) index.removeAll(cache);
227
82
  for await (const section of sections) {
228
83
  if (!section || !(section.text || section.titles)) break;
@@ -298,6 +153,149 @@ if (import.meta.hot) {
298
153
  `;
299
154
  }
300
155
 
156
+ //#endregion
157
+ //#region src/node/locales/de.ts
158
+ const deSearchLocale = {
159
+ placeholder: "Dokumente durchsuchen",
160
+ resetButtonTitle: "Suche zurücksetzen",
161
+ backButtonTitle: "Schließen",
162
+ noResultsText: "Keine Suchergebnisse:",
163
+ footer: {
164
+ selectText: "Auswählen",
165
+ selectKeyAriaLabel: "Eingabe",
166
+ navigateText: "Wechseln",
167
+ navigateUpKeyAriaLabel: "Nach oben",
168
+ navigateDownKeyAriaLabel: "Nach unten",
169
+ closeText: "Schließen",
170
+ closeKeyAriaLabel: "Beenden"
171
+ }
172
+ };
173
+
174
+ //#endregion
175
+ //#region src/node/locales/en.ts
176
+ const enSearchLocale = {
177
+ placeholder: "Search",
178
+ resetButtonTitle: "Reset search",
179
+ backButtonTitle: "Close search",
180
+ noResultsText: "No results for",
181
+ footer: {
182
+ selectText: "to select",
183
+ selectKeyAriaLabel: "enter",
184
+ navigateText: "to navigate",
185
+ navigateUpKeyAriaLabel: "up arrow",
186
+ navigateDownKeyAriaLabel: "down arrow",
187
+ closeText: "to close",
188
+ closeKeyAriaLabel: "escape"
189
+ }
190
+ };
191
+
192
+ //#endregion
193
+ //#region src/node/locales/fr.ts
194
+ const frSearchLocale = {
195
+ placeholder: "Rechercher dans la documentation",
196
+ resetButtonTitle: "Réinitialiser la recherche",
197
+ backButtonTitle: "Fermer",
198
+ noResultsText: "Aucun résultat trouvé :",
199
+ footer: {
200
+ selectText: "sélectionner",
201
+ selectKeyAriaLabel: "Entrée",
202
+ navigateText: "naviguer",
203
+ navigateUpKeyAriaLabel: "haut",
204
+ navigateDownKeyAriaLabel: "bas",
205
+ closeText: "fermer",
206
+ closeKeyAriaLabel: "sortie"
207
+ }
208
+ };
209
+
210
+ //#endregion
211
+ //#region src/node/locales/ja.ts
212
+ const jaSearchLocale = {
213
+ placeholder: "ドキュメントを検索",
214
+ resetButtonTitle: "検索をリセット",
215
+ backButtonTitle: "閉じる",
216
+ noResultsText: "検索結果がありません:",
217
+ footer: {
218
+ selectText: "選択",
219
+ selectKeyAriaLabel: "入力",
220
+ navigateText: "切り替え",
221
+ navigateUpKeyAriaLabel: "上へ",
222
+ navigateDownKeyAriaLabel: "下へ",
223
+ closeText: "閉じる",
224
+ closeKeyAriaLabel: "終了"
225
+ }
226
+ };
227
+
228
+ //#endregion
229
+ //#region src/node/locales/ru.ts
230
+ const ruSearchLocale = {
231
+ placeholder: "Поиск по документации",
232
+ resetButtonTitle: "Сбросить поиск",
233
+ backButtonTitle: "Закрыть",
234
+ noResultsText: "Нет результатов поиска:",
235
+ footer: {
236
+ selectText: "Выбрать",
237
+ selectKeyAriaLabel: "Ввод",
238
+ navigateText: "Переключить",
239
+ navigateUpKeyAriaLabel: "Вверх",
240
+ navigateDownKeyAriaLabel: "Вниз",
241
+ closeText: "Закрыть",
242
+ closeKeyAriaLabel: "Выход"
243
+ }
244
+ };
245
+
246
+ //#endregion
247
+ //#region src/node/locales/zh-tw.ts
248
+ const zhTwSearchLocale = {
249
+ placeholder: "搜索文檔",
250
+ resetButtonTitle: "重置搜索",
251
+ backButtonTitle: "關閉",
252
+ noResultsText: "無搜索結果:",
253
+ footer: {
254
+ selectText: "選擇",
255
+ selectKeyAriaLabel: "輸入",
256
+ navigateText: "切換",
257
+ navigateUpKeyAriaLabel: "向上",
258
+ navigateDownKeyAriaLabel: "向下",
259
+ closeText: "關閉",
260
+ closeKeyAriaLabel: "退出"
261
+ }
262
+ };
263
+
264
+ //#endregion
265
+ //#region src/node/locales/zh.ts
266
+ const zhSearchLocale = {
267
+ placeholder: "搜索文档",
268
+ resetButtonTitle: "重置搜索",
269
+ backButtonTitle: "关闭",
270
+ noResultsText: "无搜索结果:",
271
+ footer: {
272
+ selectText: "选择",
273
+ selectKeyAriaLabel: "输入",
274
+ navigateText: "切换",
275
+ navigateUpKeyAriaLabel: "向上",
276
+ navigateDownKeyAriaLabel: "向下",
277
+ closeText: "关闭",
278
+ closeKeyAriaLabel: "退出"
279
+ }
280
+ };
281
+
282
+ //#endregion
283
+ //#region src/node/locales/index.ts
284
+ const SEARCH_LOCALES = [
285
+ [["en", "en-US"], enSearchLocale],
286
+ [[
287
+ "zh",
288
+ "zh-CN",
289
+ "zh-Hans",
290
+ "zh-Hant"
291
+ ], zhSearchLocale],
292
+ [["zh-TW"], zhTwSearchLocale],
293
+ [["de", "de-DE"], deSearchLocale],
294
+ [["fr", "fr-FR"], frSearchLocale],
295
+ [["ru", "ru-RU"], ruSearchLocale],
296
+ [["ja", "ja-JP"], jaSearchLocale]
297
+ ];
298
+
301
299
  //#endregion
302
300
  //#region src/node/searchPlugin.ts
303
301
  const __dirname = getDirname(import.meta.url);
@@ -25,18 +25,18 @@ interface SearchPluginOptions extends SearchOptions {
25
25
  }
26
26
  interface SearchOptions {
27
27
  /**
28
- * @default false
29
- */
28
+ * @default false
29
+ */
30
30
  disableQueryPersistence?: boolean;
31
31
  miniSearch?: {
32
32
  /**
33
- * @see https://lucaong.github.io/minisearch/modules/_minisearch_.html#options
34
- */
35
- options?: Pick<Options, "extractField" | "tokenize" | "processTerm">;
33
+ * @see https://lucaong.github.io/minisearch/modules/_minisearch_.html#options
34
+ */
35
+ options?: Pick<Options, 'extractField' | 'tokenize' | 'processTerm'>;
36
36
  /**
37
- * @see https://lucaong.github.io/minisearch/modules/_minisearch_.html#searchoptions-1
38
- */
39
- searchOptions?: Options["searchOptions"];
37
+ * @see https://lucaong.github.io/minisearch/modules/_minisearch_.html#searchoptions-1
38
+ */
39
+ searchOptions?: Options['searchOptions'];
40
40
  };
41
41
  }
42
42
  //#endregion
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vuepress-plume/plugin-search",
3
3
  "type": "module",
4
- "version": "1.0.0-rc.163",
4
+ "version": "1.0.0-rc.165",
5
5
  "description": "The Plugin for VuePress 2 - local search",
6
6
  "author": "pengzhanbo <volodymyr@foxmail.com>",
7
7
  "license": "MIT",
@@ -40,9 +40,9 @@
40
40
  "chokidar": "4.0.3",
41
41
  "focus-trap": "^7.6.5",
42
42
  "mark.js": "^8.11.1",
43
- "minisearch": "^7.1.2",
43
+ "minisearch": "^7.2.0",
44
44
  "p-map": "^7.0.3",
45
- "vue": "^3.5.21"
45
+ "vue": "^3.5.22"
46
46
  },
47
47
  "publishConfig": {
48
48
  "access": "public"