@dxos/plugin-search 0.7.4 → 0.7.5-labs.a279d8c
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/dist/lib/browser/app-graph-builder-4C2ZPCED.mjs +41 -0
- package/dist/lib/browser/app-graph-builder-4C2ZPCED.mjs.map +7 -0
- package/dist/lib/browser/{chunk-4L4PWJYC.mjs → chunk-B532NWHM.mjs} +3 -3
- package/dist/lib/browser/chunk-B532NWHM.mjs.map +7 -0
- package/dist/lib/browser/chunk-GGOOQO2C.mjs +133 -0
- package/dist/lib/browser/chunk-GGOOQO2C.mjs.map +7 -0
- package/dist/lib/browser/chunk-Z745WIBH.mjs +21 -0
- package/dist/lib/browser/chunk-Z745WIBH.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +67 -577
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/intent-resolver-XUWUYVFT.mjs +19 -0
- package/dist/lib/browser/intent-resolver-XUWUYVFT.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react-context-IIHWUFU6.mjs +18 -0
- package/dist/lib/browser/react-context-IIHWUFU6.mjs.map +7 -0
- package/dist/lib/browser/react-surface-242JU6MW.mjs +360 -0
- package/dist/lib/browser/react-surface-242JU6MW.mjs.map +7 -0
- package/dist/types/src/SearchPlugin.d.ts +1 -3
- package/dist/types/src/SearchPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts +181 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +185 -0
- package/dist/types/src/capabilities/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/intent-resolver.d.ts +4 -0
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-context.d.ts +8 -0
- package/dist/types/src/capabilities/react-context.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +4 -0
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
- package/dist/types/src/components/SearchDialog.d.ts +6 -8
- package/dist/types/src/components/SearchDialog.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +1 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +11 -4
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/package.json +20 -27
- package/src/SearchPlugin.tsx +40 -101
- package/src/capabilities/app-graph-builder.ts +36 -0
- package/src/capabilities/index.ts +10 -0
- package/src/capabilities/intent-resolver.ts +15 -0
- package/src/capabilities/react-context.tsx +16 -0
- package/src/capabilities/react-surface.tsx +30 -0
- package/src/components/SearchDialog.tsx +30 -33
- package/src/index.ts +1 -4
- package/src/meta.ts +1 -1
- package/src/search-sync.ts +1 -1
- package/src/search.ts +1 -1
- package/src/types.tsx +7 -16
- package/dist/lib/browser/chunk-4L4PWJYC.mjs.map +0 -7
- package/dist/lib/browser/meta.mjs +0 -11
- package/dist/lib/browser/meta.mjs.map +0 -7
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
|
|
7
|
+
import { Capabilities, contributes, createSurface, firstIdInPart, useCapability } from '@dxos/app-framework';
|
|
8
|
+
import { getActiveSpace } from '@dxos/plugin-space';
|
|
9
|
+
|
|
10
|
+
import { SEARCH_DIALOG, SearchDialog, type SearchDialogProps, SearchMain } from '../components';
|
|
11
|
+
|
|
12
|
+
export default () =>
|
|
13
|
+
contributes(Capabilities.ReactSurface, [
|
|
14
|
+
createSurface({
|
|
15
|
+
id: SEARCH_DIALOG,
|
|
16
|
+
role: 'dialog',
|
|
17
|
+
filter: (data): data is { subject: SearchDialogProps } => data.component === SEARCH_DIALOG,
|
|
18
|
+
component: ({ data }) => <SearchDialog {...data.subject} />,
|
|
19
|
+
}),
|
|
20
|
+
createSurface({
|
|
21
|
+
id: 'search-input',
|
|
22
|
+
role: 'search-input',
|
|
23
|
+
component: () => {
|
|
24
|
+
const location = useCapability(Capabilities.Location);
|
|
25
|
+
const { graph } = useCapability(Capabilities.AppGraph);
|
|
26
|
+
const space = graph && location ? getActiveSpace(graph, firstIdInPart(location.active, 'main')) : undefined;
|
|
27
|
+
return space ? <SearchMain space={space} /> : null;
|
|
28
|
+
},
|
|
29
|
+
}),
|
|
30
|
+
]);
|
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
import React, { forwardRef, useCallback, useState } from 'react';
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
|
-
useResolvePlugin,
|
|
9
|
-
parseNavigationPlugin,
|
|
10
|
-
parseGraphPlugin,
|
|
11
8
|
NavigationAction,
|
|
12
9
|
LayoutAction,
|
|
13
10
|
type LayoutCoordinate,
|
|
14
11
|
isLayoutParts,
|
|
15
12
|
useIntentDispatcher,
|
|
13
|
+
createIntent,
|
|
14
|
+
useCapability,
|
|
15
|
+
Capabilities,
|
|
16
16
|
} from '@dxos/app-framework';
|
|
17
17
|
import { type Node } from '@dxos/plugin-graph';
|
|
18
18
|
import { useClient } from '@dxos/react-client';
|
|
@@ -24,6 +24,8 @@ import { descriptionText, mx } from '@dxos/react-ui-theme';
|
|
|
24
24
|
import { SEARCH_PLUGIN } from '../meta';
|
|
25
25
|
import { useSearchResults } from '../search';
|
|
26
26
|
|
|
27
|
+
export const SEARCH_DIALOG = `${SEARCH_PLUGIN}/SearchDialog`;
|
|
28
|
+
|
|
27
29
|
type SearchListResultProps = {
|
|
28
30
|
node: Node;
|
|
29
31
|
} & Pick<SearchListItemProps, 'onSelect'>;
|
|
@@ -45,55 +47,50 @@ const SearchListResult = forwardRef<HTMLDivElement, SearchListResultProps>(({ no
|
|
|
45
47
|
);
|
|
46
48
|
});
|
|
47
49
|
|
|
48
|
-
export
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
}) => {
|
|
50
|
+
export type SearchDialogProps = {
|
|
51
|
+
layoutCoordinate: LayoutCoordinate;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export const SearchDialog = ({ layoutCoordinate }: SearchDialogProps) => {
|
|
53
55
|
const { t } = useTranslation(SEARCH_PLUGIN);
|
|
54
|
-
const
|
|
55
|
-
const graph =
|
|
56
|
-
const
|
|
57
|
-
const providedClosed = navigationPlugin?.provides.location.closed ?? [];
|
|
56
|
+
const location = useCapability(Capabilities.Location);
|
|
57
|
+
const { graph } = useCapability(Capabilities.AppGraph);
|
|
58
|
+
const providedClosed = location.closed ?? [];
|
|
58
59
|
const closed = (Array.isArray(providedClosed) ? providedClosed : [providedClosed])
|
|
59
60
|
.map((id) => graph?.findNode(id))
|
|
60
61
|
.filter(Boolean);
|
|
61
|
-
const active =
|
|
62
|
+
const active = location.active;
|
|
62
63
|
const [queryString, setQueryString] = useState('');
|
|
63
64
|
const client = useClient();
|
|
64
65
|
const dangerouslyLoadAllObjects = useQuery(client.spaces, Filter.all());
|
|
65
66
|
const [pending, results] = useSearchResults(queryString, dangerouslyLoadAllObjects);
|
|
66
67
|
const resultObjects = Array.from(results.keys());
|
|
67
|
-
const dispatch = useIntentDispatcher();
|
|
68
|
+
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
68
69
|
|
|
69
70
|
const handleSelect = useCallback(
|
|
70
|
-
(nodeId: string) => {
|
|
71
|
+
async (nodeId: string) => {
|
|
71
72
|
if (active && isLayoutParts(active)) {
|
|
72
73
|
// If node is already present in the active parts, scroll to it and close the dialog.
|
|
73
74
|
const index = active?.main?.findIndex((entry) => entry.id === nodeId);
|
|
74
75
|
if (index !== -1) {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
]);
|
|
76
|
+
await dispatch(createIntent(LayoutAction.SetLayout, { element: 'dialog', state: false }));
|
|
77
|
+
await dispatch(createIntent(LayoutAction.ScrollIntoView, { id: nodeId }));
|
|
78
|
+
return;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
|
|
82
|
-
{
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
{ action: LayoutAction.SET_LAYOUT, data: { element: 'dialog', state: false } },
|
|
92
|
-
{ action: LayoutAction.SCROLL_INTO_VIEW, data: { id: nodeId } },
|
|
93
|
-
]);
|
|
81
|
+
await dispatch(
|
|
82
|
+
createIntent(NavigationAction.AddToActive, {
|
|
83
|
+
part: layoutCoordinate.part,
|
|
84
|
+
id: nodeId,
|
|
85
|
+
pivotId: layoutCoordinate.entryId,
|
|
86
|
+
positioning: 'end',
|
|
87
|
+
}),
|
|
88
|
+
);
|
|
89
|
+
await dispatch(createIntent(LayoutAction.SetLayout, { element: 'dialog', state: false }));
|
|
90
|
+
await dispatch(createIntent(LayoutAction.ScrollIntoView, { id: nodeId }));
|
|
94
91
|
}
|
|
95
92
|
},
|
|
96
|
-
[
|
|
93
|
+
[layoutCoordinate, dispatch, active],
|
|
97
94
|
);
|
|
98
95
|
|
|
99
96
|
return (
|
package/src/index.ts
CHANGED
package/src/meta.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { type PluginMeta } from '@dxos/app-framework';
|
|
|
7
7
|
export const SEARCH_PLUGIN = 'dxos.org/plugin/search';
|
|
8
8
|
export const SEARCH_RESULT = `${SEARCH_PLUGIN}/result`;
|
|
9
9
|
|
|
10
|
-
export
|
|
10
|
+
export const meta = {
|
|
11
11
|
id: SEARCH_PLUGIN,
|
|
12
12
|
name: 'Search',
|
|
13
13
|
description: 'Search ECHO spaces for content.',
|
package/src/search-sync.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import { AST, type S } from '@dxos/echo-schema';
|
|
6
6
|
import { getSchema } from '@dxos/live-object';
|
|
7
|
-
import { TextType } from '@dxos/
|
|
7
|
+
import { TextType } from '@dxos/schema';
|
|
8
8
|
|
|
9
9
|
export const queryStringToMatch = (queryString?: string): RegExp | undefined => {
|
|
10
10
|
const trimmed = queryString?.trim();
|
package/src/search.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { yieldOrContinue } from 'main-thread-scheduling';
|
|
6
6
|
import { useEffect, useState } from 'react';
|
|
7
7
|
|
|
8
|
-
import { TextType } from '@dxos/
|
|
8
|
+
import { TextType } from '@dxos/schema';
|
|
9
9
|
|
|
10
10
|
// TODO(thure): Deprecate search-sync, move still-relevant utilities elsewhere (here, probably).
|
|
11
11
|
import { mapObjectToTextFields, queryStringToMatch } from './search-sync';
|
package/src/types.tsx
CHANGED
|
@@ -2,24 +2,15 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
6
|
-
GraphBuilderProvides,
|
|
7
|
-
IntentResolverProvides,
|
|
8
|
-
MetadataRecordsProvides,
|
|
9
|
-
SurfaceProvides,
|
|
10
|
-
TranslationsProvides,
|
|
11
|
-
} from '@dxos/app-framework';
|
|
5
|
+
import { S } from '@dxos/echo-schema';
|
|
12
6
|
|
|
13
7
|
import { SEARCH_PLUGIN } from './meta';
|
|
14
8
|
|
|
15
|
-
|
|
9
|
+
export namespace SearchAction {
|
|
10
|
+
const SEARCH_ACTION = `${SEARCH_PLUGIN}/action`;
|
|
16
11
|
|
|
17
|
-
export
|
|
18
|
-
|
|
12
|
+
export class OpenSearch extends S.TaggedClass<OpenSearch>()(`${SEARCH_ACTION}/open-search`, {
|
|
13
|
+
input: S.Void,
|
|
14
|
+
output: S.Void,
|
|
15
|
+
}) {}
|
|
19
16
|
}
|
|
20
|
-
|
|
21
|
-
export type SearchPluginProvides = SurfaceProvides &
|
|
22
|
-
IntentResolverProvides &
|
|
23
|
-
GraphBuilderProvides &
|
|
24
|
-
MetadataRecordsProvides &
|
|
25
|
-
TranslationsProvides;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/meta.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type PluginMeta } from '@dxos/app-framework';\n\nexport const SEARCH_PLUGIN = 'dxos.org/plugin/search';\nexport const SEARCH_RESULT = `${SEARCH_PLUGIN}/result`;\n\nexport default {\n id: SEARCH_PLUGIN,\n name: 'Search',\n description: 'Search ECHO spaces for content.',\n icon: 'ph--magnifying-glass--regular',\n source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/experimental/plugin-search',\n tags: ['experimental'],\n} satisfies PluginMeta;\n"],
|
|
5
|
-
"mappings": ";AAMO,IAAMA,gBAAgB;AACtB,IAAMC,gBAAgB,GAAGD,aAAAA;AAEhC,IAAA,eAAe;EACbE,IAAIF;EACJG,MAAM;EACNC,aAAa;EACbC,MAAM;EACNC,QAAQ;EACRC,MAAM;IAAC;;AACT;",
|
|
6
|
-
"names": ["SEARCH_PLUGIN", "SEARCH_RESULT", "id", "name", "description", "icon", "source", "tags"]
|
|
7
|
-
}
|