Skip to content

Commit dfcad1d

Browse files
authored
fix(plugin-slimsearch): correct worker file position (#658)
1 parent afe6a11 commit dfcad1d

19 files changed

Lines changed: 28 additions & 30 deletions

File tree

plugins/search/plugin-slimsearch/src/client/components/SearchResult.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ import type { PropType, VNode } from 'vue'
55
import { computed, defineComponent, h, reactive, ref, toRef, watch } from 'vue'
66
import { RouteLink, useRouteLocale, useRouter } from 'vuepress/client'
77

8+
import type { MatchedItem, Word } from '../../shared/index.js'
89
import {
910
useQueryHistory,
1011
useResultHistory,
1112
useResults,
1213
} from '../composables/index.js'
1314
import { customFieldConfig, locales } from '../define.js'
1415
import { CLOSE_ICON } from '../icons/index.js'
15-
import type { MatchedItem, Word } from '../typings/index.js'
1616
import { getResultPath } from '../utils/index.js'
1717
import { HeadingIcon, HeartIcon, HistoryIcon, TitleIcon } from './icons.js'
1818
import { SearchLoading } from './SearchLoading.js'

plugins/search/plugin-slimsearch/src/client/composables/useResultHistory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { useLocalStorage } from '@vueuse/core'
22
import type { Ref } from 'vue'
33

4+
import type { MatchedItem, Word } from '../../shared/index.js'
45
import { options } from '../define.js'
5-
import type { MatchedItem, Word } from '../typings/index.js'
66
import { getResultPath } from '../utils/index.js'
77

88
const SLIMSEARCH_RESULT_HISTORY_STORAGE = 'SLIMSEARCH_RESULT_HISTORY'

plugins/search/plugin-slimsearch/src/client/composables/useResults.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import type { Ref } from 'vue'
33
import { computed, onMounted, onUnmounted, ref, shallowRef } from 'vue'
44
import { useData } from 'vuepress/client'
55

6+
import type { SearchResult } from '../../shared/index.js'
67
import { options } from '../define.js'
78
import { useSearchOptions } from '../helpers/index.js'
8-
import type { SearchResult } from '../typings/index.js'
99
import { createSearchWorker } from '../utils/index.js'
1010

1111
export interface Results {

plugins/search/plugin-slimsearch/src/client/helpers/search.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type { PageData } from 'vuepress/client'
55
import { useRouteLocale } from 'vuepress/client'
66
import { isFunction } from 'vuepress/shared'
77

8-
import type { SearchResult, WorkerSearchOptions } from '../typings/index.js'
8+
import type { SearchResult, WorkerSearchOptions } from '../../shared/index.js'
99

1010
declare const __VUEPRESS_DEV__: boolean
1111

plugins/search/plugin-slimsearch/src/client/typings/index.ts

Lines changed: 0 additions & 2 deletions
This file was deleted.

plugins/search/plugin-slimsearch/src/client/utils/createSearchWorker.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import { values } from '@vuepress/helper/client'
22
import type { SearchOptions } from 'slimsearch'
33

4-
import type { IndexItem } from '../../shared/index.js'
4+
import type {
5+
IndexItem,
6+
QueryResult,
7+
SearchResult,
8+
} from '../../shared/index.js'
59
import { options } from '../define.js'
6-
import type { QueryResult, SearchResult } from '../typings/index.js'
710

811
declare const __VUEPRESS_BASE__: string
912
declare const __VUEPRESS_DEV__: boolean
@@ -73,8 +76,9 @@ const ERR_MSG = 'Canceled because of new search request.'
7376

7477
export const createSearchWorker = (): SearchWorker => {
7578
const worker = new Worker(
79+
// FIXME: Currently rolldown does not respect `import.meta.url` here. Might need another fix in the future.
7680
__VUEPRESS_DEV__
77-
? new URL('worker.js', import.meta.url)
81+
? new URL('worker/dev.js', import.meta.url)
7882
: `${__VUEPRESS_BASE__}${options.worker}`,
7983
__VUEPRESS_DEV__ ? { type: 'module' } : {},
8084
)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { store } from '@temp/slimsearch/store.js'
22

3-
import type { MatchedItem } from '../typings/index.js'
3+
import type { MatchedItem } from '../../shared/index.js'
44

55
export const getResultPath = (item: MatchedItem): string =>
66
store[item.id] + ('anchor' in item ? `#${item.anchor}` : '')

plugins/search/plugin-slimsearch/src/node/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const CLIENT_FOLDER = ensureEndingSlash(
1111
path.resolve(__dirname, '../client/'),
1212
)
1313

14-
export const WORKER_FILE = path.resolve(__dirname, '../worker/index.js')
14+
export const WORKER_FILE = path.resolve(__dirname, '../worker/build.js')
1515

1616
export const getLocaleChunkName = (locale: string): string =>
1717
locale.replaceAll('/', '') || 'root'
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
export type SlimSearchSortStrategy = 'max' | 'total'
2+
13
export * from './data.js'
24
export type * from './formatter.js'
35
export type * from './locales.js'
4-
export type SlimSearchSortStrategy = 'max' | 'total'
6+
export type * from './result.js'
7+
export type * from './worker.js'

plugins/search/plugin-slimsearch/src/client/typings/result.ts renamed to plugins/search/plugin-slimsearch/src/shared/result.ts

File renamed without changes.

0 commit comments

Comments
 (0)