summaryrefslogtreecommitdiff
path: root/packages/frontend/src/utility
diff options
context:
space:
mode:
Diffstat (limited to 'packages/frontend/src/utility')
-rw-r--r--packages/frontend/src/utility/inapp-search.ts37
-rw-r--r--packages/frontend/src/utility/settings-search-index.ts36
-rw-r--r--packages/frontend/src/utility/virtual.d.ts29
3 files changed, 56 insertions, 46 deletions
diff --git a/packages/frontend/src/utility/inapp-search.ts b/packages/frontend/src/utility/inapp-search.ts
new file mode 100644
index 0000000000..cbc3d87ff8
--- /dev/null
+++ b/packages/frontend/src/utility/inapp-search.ts
@@ -0,0 +1,37 @@
+/*
+ * SPDX-FileCopyrightText: syuilo and misskey-project
+ * SPDX-License-Identifier: AGPL-3.0-only
+ */
+
+import type { GeneratedSearchIndexItem } from 'search-index';
+
+export type SearchIndexItem = {
+ id: string;
+ parentId?: string;
+ path?: string;
+ label: string;
+ keywords: string[];
+ texts: string[];
+ icon?: string;
+};
+
+export function genSearchIndexes(generated: GeneratedSearchIndexItem[]): SearchIndexItem[] {
+ const rootMods = new Map(generated.map(item => [item.id, item]));
+
+ // link inlining here
+ for (const item of generated) {
+ if (item.inlining) {
+ for (const id of item.inlining) {
+ const inline = rootMods.get(id);
+ if (inline) {
+ inline.parentId = item.id;
+ inline.path = item.path;
+ } else {
+ console.log('[Settings Search Index] Failed to inline', id);
+ }
+ }
+ }
+ }
+
+ return generated;
+}
diff --git a/packages/frontend/src/utility/settings-search-index.ts b/packages/frontend/src/utility/settings-search-index.ts
deleted file mode 100644
index 8506e4fe2f..0000000000
--- a/packages/frontend/src/utility/settings-search-index.ts
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * SPDX-FileCopyrightText: syuilo and misskey-project
- * SPDX-License-Identifier: AGPL-3.0-only
- */
-
-import { searchIndexes as generated } from 'search-index:settings';
-import type { GeneratedSearchIndexItem } from 'search-index:settings';
-
-export type SearchIndexItem = {
- id: string;
- parentId?: string;
- path?: string;
- label: string;
- keywords: string[];
- icon?: string;
-};
-
-const rootMods = new Map(generated.map(item => [item.id, item]));
-
-// link inlining here
-for (const item of generated) {
- if (item.inlining) {
- for (const id of item.inlining) {
- const inline = rootMods.get(id);
- if (inline) {
- inline.parentId = item.id;
- inline.path = item.path;
- } else {
- console.log('[Settings Search Index] Failed to inline', id);
- }
- }
- }
-}
-
-export const searchIndexes: SearchIndexItem[] = generated;
-
diff --git a/packages/frontend/src/utility/virtual.d.ts b/packages/frontend/src/utility/virtual.d.ts
index 63dc4372b7..00f01992aa 100644
--- a/packages/frontend/src/utility/virtual.d.ts
+++ b/packages/frontend/src/utility/virtual.d.ts
@@ -3,16 +3,25 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/
+type XGeneratedSearchIndexItem = {
+ id: string;
+ parentId?: string;
+ path?: string;
+ label: string;
+ keywords: string[];
+ texts: string[];
+ icon?: string;
+ inlining?: string[];
+};
+
+declare module 'search-index' {
+ export type GeneratedSearchIndexItem = XGeneratedSearchIndexItem;
+}
+
declare module 'search-index:settings' {
- export type GeneratedSearchIndexItem = {
- id: string;
- parentId?: string;
- path?: string;
- label: string;
- keywords: string[];
- icon?: string;
- inlining?: string[];
- };
+ export const searchIndexes: XGeneratedSearchIndexItem[];
+}
- export const searchIndexes: GeneratedSearchIndexItem[];
+declare module 'search-index:admin' {
+ export const searchIndexes: XGeneratedSearchIndexItem[];
}