@dxos/plugin-search 0.8.4-main.f9ba587 → 0.8.4-main.fcfe5033a5
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/README.md +0 -1
- package/dist/lib/browser/index.mjs +328 -82
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/types/src/SearchPlugin.d.ts +2 -1
- package/dist/types/src/SearchPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts +4 -2
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +5 -3
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
- package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +3 -2
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/components/SearchResultStack/SearchResultStack.d.ts +9 -0
- package/dist/types/src/components/SearchResultStack/SearchResultStack.d.ts.map +1 -0
- package/dist/types/src/components/SearchResultStack/index.d.ts +2 -0
- package/dist/types/src/components/SearchResultStack/index.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +1 -3
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/constants.d.ts +2 -0
- package/dist/types/src/constants.d.ts.map +1 -0
- package/dist/types/src/containers/SearchArticle/SearchArticle.d.ts +7 -0
- package/dist/types/src/containers/SearchArticle/SearchArticle.d.ts.map +1 -0
- package/dist/types/src/containers/SearchArticle/SearchArticle.stories.d.ts +15 -0
- package/dist/types/src/containers/SearchArticle/SearchArticle.stories.d.ts.map +1 -0
- package/dist/types/src/containers/SearchArticle/index.d.ts +2 -0
- package/dist/types/src/containers/SearchArticle/index.d.ts.map +1 -0
- package/dist/types/src/containers/SearchDialog/SearchDialog.d.ts +8 -0
- package/dist/types/src/containers/SearchDialog/SearchDialog.d.ts.map +1 -0
- package/dist/types/src/containers/SearchDialog/SearchDialog.stories.d.ts +17 -0
- package/dist/types/src/containers/SearchDialog/SearchDialog.stories.d.ts.map +1 -0
- package/dist/types/src/containers/SearchDialog/index.d.ts +3 -0
- package/dist/types/src/containers/SearchDialog/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +5 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +1 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/sync.d.ts +4 -3
- package/dist/types/src/hooks/sync.d.ts.map +1 -1
- package/dist/types/src/hooks/useGlobalSearch.d.ts +8 -4
- package/dist/types/src/hooks/useGlobalSearch.d.ts.map +1 -1
- package/dist/types/src/hooks/useSearchResults.d.ts +3 -2
- package/dist/types/src/hooks/useSearchResults.d.ts.map +1 -1
- package/dist/types/src/hooks/useWebSearch.d.ts +7 -4
- package/dist/types/src/hooks/useWebSearch.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +3 -4
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/operations/definitions.d.ts +3 -0
- package/dist/types/src/operations/definitions.d.ts.map +1 -0
- package/dist/types/src/operations/index.d.ts +4 -0
- package/dist/types/src/operations/index.d.ts.map +1 -0
- package/dist/types/src/operations/open-search.d.ts +5 -0
- package/dist/types/src/operations/open-search.d.ts.map +1 -0
- package/dist/types/src/search/exa.d.ts +4 -4
- package/dist/types/src/search/exa.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +15 -9
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/index.d.ts +1 -2
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/search.d.ts +1 -20
- package/dist/types/src/types/search.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +67 -49
- package/src/SearchPlugin.tsx +30 -47
- package/src/capabilities/app-graph-builder.ts +56 -69
- package/src/capabilities/index.ts +8 -4
- package/src/capabilities/operation-handler.ts +16 -0
- package/src/capabilities/react-surface.tsx +51 -48
- package/src/components/SearchResultStack/SearchResultStack.tsx +118 -0
- package/src/components/SearchResultStack/index.ts +5 -0
- package/src/components/index.ts +1 -3
- package/src/constants.ts +7 -0
- package/src/containers/SearchArticle/SearchArticle.stories.tsx +80 -0
- package/src/containers/SearchArticle/SearchArticle.tsx +63 -0
- package/src/containers/SearchArticle/index.ts +5 -0
- package/src/containers/SearchDialog/SearchDialog.stories.tsx +109 -0
- package/src/containers/SearchDialog/SearchDialog.tsx +96 -0
- package/src/containers/SearchDialog/index.ts +6 -0
- package/src/containers/index.ts +10 -0
- package/src/hooks/index.ts +2 -0
- package/src/hooks/sync.test.ts +9 -7
- package/src/hooks/sync.ts +28 -32
- package/src/hooks/useGlobalSearch.tsx +33 -13
- package/src/hooks/useSearchResults.ts +9 -6
- package/src/hooks/useWebSearch.ts +23 -17
- package/src/meta.ts +10 -7
- package/src/operations/definitions.ts +17 -0
- package/src/operations/index.ts +9 -0
- package/src/operations/open-search.ts +24 -0
- package/src/search/exa.test.ts +9 -32
- package/src/search/exa.ts +140 -168
- package/src/translations.ts +10 -9
- package/src/types/command-score.d.ts +16 -0
- package/src/types/index.ts +1 -2
- package/src/types/search.ts +1 -25
- package/dist/lib/browser/app-graph-builder-V667YGDS.mjs +0 -77
- package/dist/lib/browser/app-graph-builder-V667YGDS.mjs.map +0 -7
- package/dist/lib/browser/chunk-2QKDUXCH.mjs +0 -21
- package/dist/lib/browser/chunk-2QKDUXCH.mjs.map +0 -7
- package/dist/lib/browser/chunk-KNS62YL2.mjs +0 -20
- package/dist/lib/browser/chunk-KNS62YL2.mjs.map +0 -7
- package/dist/lib/browser/chunk-LPB2XRYL.mjs +0 -190
- package/dist/lib/browser/chunk-LPB2XRYL.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-SPX5JVY7.mjs +0 -22
- package/dist/lib/browser/intent-resolver-SPX5JVY7.mjs.map +0 -7
- package/dist/lib/browser/react-surface-HMXHJSLE.mjs +0 -642
- package/dist/lib/browser/react-surface-HMXHJSLE.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-IZHM72QQ.mjs +0 -78
- package/dist/lib/node-esm/app-graph-builder-IZHM72QQ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-L7BUHKLC.mjs +0 -192
- package/dist/lib/node-esm/chunk-L7BUHKLC.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-N5SNYFMK.mjs +0 -22
- package/dist/lib/node-esm/chunk-N5SNYFMK.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-Y7BGRQH5.mjs +0 -22
- package/dist/lib/node-esm/chunk-Y7BGRQH5.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -113
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-MFPFD3XC.mjs +0 -23
- package/dist/lib/node-esm/intent-resolver-MFPFD3XC.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/react-surface-WHU5EEAQ.mjs +0 -643
- package/dist/lib/node-esm/react-surface-WHU5EEAQ.mjs.map +0 -7
- package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/components/Search.stories.d.ts +0 -15
- package/dist/types/src/components/Search.stories.d.ts.map +0 -1
- package/dist/types/src/components/SearchDialog.d.ts +0 -7
- package/dist/types/src/components/SearchDialog.d.ts.map +0 -1
- package/dist/types/src/components/SearchMain.d.ts +0 -7
- package/dist/types/src/components/SearchMain.d.ts.map +0 -1
- package/dist/types/src/components/SearchResults/SearchResults.d.ts +0 -20
- package/dist/types/src/components/SearchResults/SearchResults.d.ts.map +0 -1
- package/dist/types/src/components/SearchResults/SearchResults.stories.d.ts +0 -12
- package/dist/types/src/components/SearchResults/SearchResults.stories.d.ts.map +0 -1
- package/dist/types/src/components/SearchResults/index.d.ts +0 -2
- package/dist/types/src/components/SearchResults/index.d.ts.map +0 -1
- package/dist/types/src/components/Searchbar/Searchbar.d.ts +0 -14
- package/dist/types/src/components/Searchbar/Searchbar.d.ts.map +0 -1
- package/dist/types/src/components/Searchbar/Searchbar.stories.d.ts +0 -11
- package/dist/types/src/components/Searchbar/Searchbar.stories.d.ts.map +0 -1
- package/dist/types/src/components/Searchbar/index.d.ts +0 -2
- package/dist/types/src/components/Searchbar/index.d.ts.map +0 -1
- package/dist/types/src/types/action.d.ts +0 -13
- package/dist/types/src/types/action.d.ts.map +0 -1
- package/src/capabilities/intent-resolver.ts +0 -18
- package/src/components/Search.stories.tsx +0 -66
- package/src/components/SearchDialog.tsx +0 -124
- package/src/components/SearchMain.tsx +0 -67
- package/src/components/SearchResults/SearchResults.stories.tsx +0 -57
- package/src/components/SearchResults/SearchResults.tsx +0 -86
- package/src/components/SearchResults/index.ts +0 -5
- package/src/components/Searchbar/Searchbar.stories.tsx +0 -28
- package/src/components/Searchbar/Searchbar.tsx +0 -69
- package/src/components/Searchbar/index.ts +0 -5
- package/src/types/action.tsx +0 -16
package/package.json
CHANGED
|
@@ -1,77 +1,95 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/plugin-search",
|
|
3
|
-
"version": "0.8.4-main.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.8.4-main.fcfe5033a5",
|
|
4
|
+
"description": "Search plugin",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/dxos/dxos"
|
|
10
|
+
},
|
|
7
11
|
"license": "MIT",
|
|
8
12
|
"author": "DXOS.org",
|
|
9
13
|
"sideEffects": true,
|
|
10
14
|
"type": "module",
|
|
15
|
+
"imports": {
|
|
16
|
+
"#capabilities": "./src/capabilities/index.ts",
|
|
17
|
+
"#components": "./src/components/index.ts",
|
|
18
|
+
"#containers": "./src/containers/index.ts",
|
|
19
|
+
"#hooks": "./src/hooks/index.ts",
|
|
20
|
+
"#meta": "./src/meta.ts",
|
|
21
|
+
"#operations": "./src/operations/index.ts",
|
|
22
|
+
"#types": "./src/types/index.ts"
|
|
23
|
+
},
|
|
11
24
|
"exports": {
|
|
12
25
|
".": {
|
|
26
|
+
"source": "./src/index.ts",
|
|
13
27
|
"types": "./dist/types/src/index.d.ts",
|
|
14
|
-
"browser": "./dist/lib/browser/index.mjs"
|
|
28
|
+
"browser": "./dist/lib/browser/index.mjs",
|
|
29
|
+
"node": "./dist/lib/node-esm/index.mjs"
|
|
15
30
|
}
|
|
16
31
|
},
|
|
17
32
|
"types": "dist/types/src/index.d.ts",
|
|
18
|
-
"typesVersions": {
|
|
19
|
-
"*": {}
|
|
20
|
-
},
|
|
21
33
|
"files": [
|
|
22
34
|
"dist",
|
|
23
35
|
"src"
|
|
24
36
|
],
|
|
25
37
|
"dependencies": {
|
|
26
|
-
"@preact-signals/safe-react": "^0.9.0",
|
|
27
38
|
"exa-js": "^1.5.12",
|
|
28
39
|
"main-thread-scheduling": "^14.1.1",
|
|
29
|
-
"@dxos/
|
|
30
|
-
"@dxos/
|
|
31
|
-
"@dxos/
|
|
32
|
-
"@dxos/
|
|
33
|
-
"@dxos/
|
|
34
|
-
"@dxos/
|
|
35
|
-
"@dxos/
|
|
36
|
-
"@dxos/echo
|
|
37
|
-
"@dxos/
|
|
38
|
-
"@dxos/
|
|
39
|
-
"@dxos/
|
|
40
|
-
"@dxos/log": "0.8.4-main.
|
|
41
|
-
"@dxos/
|
|
42
|
-
"@dxos/plugin-
|
|
43
|
-
"@dxos/plugin-
|
|
44
|
-
"@dxos/
|
|
45
|
-
"@dxos/react-
|
|
46
|
-
"@dxos/react-ui-
|
|
47
|
-
"@dxos/
|
|
48
|
-
"@dxos/react-ui-
|
|
49
|
-
"@dxos/
|
|
40
|
+
"@dxos/app-framework": "0.8.4-main.fcfe5033a5",
|
|
41
|
+
"@dxos/ai": "0.8.4-main.fcfe5033a5",
|
|
42
|
+
"@dxos/assistant": "0.8.4-main.fcfe5033a5",
|
|
43
|
+
"@dxos/app-toolkit": "0.8.4-main.fcfe5033a5",
|
|
44
|
+
"@dxos/blueprints": "0.8.4-main.fcfe5033a5",
|
|
45
|
+
"@dxos/async": "0.8.4-main.fcfe5033a5",
|
|
46
|
+
"@dxos/debug": "0.8.4-main.fcfe5033a5",
|
|
47
|
+
"@dxos/echo": "0.8.4-main.fcfe5033a5",
|
|
48
|
+
"@dxos/echo-query": "0.8.4-main.fcfe5033a5",
|
|
49
|
+
"@dxos/operation": "0.8.4-main.fcfe5033a5",
|
|
50
|
+
"@dxos/echo-protocol": "0.8.4-main.fcfe5033a5",
|
|
51
|
+
"@dxos/log": "0.8.4-main.fcfe5033a5",
|
|
52
|
+
"@dxos/effect": "0.8.4-main.fcfe5033a5",
|
|
53
|
+
"@dxos/plugin-deck": "0.8.4-main.fcfe5033a5",
|
|
54
|
+
"@dxos/plugin-client": "0.8.4-main.fcfe5033a5",
|
|
55
|
+
"@dxos/react-client": "0.8.4-main.fcfe5033a5",
|
|
56
|
+
"@dxos/react-ui-components": "0.8.4-main.fcfe5033a5",
|
|
57
|
+
"@dxos/react-ui-attention": "0.8.4-main.fcfe5033a5",
|
|
58
|
+
"@dxos/plugin-graph": "0.8.4-main.fcfe5033a5",
|
|
59
|
+
"@dxos/react-ui-mosaic": "0.8.4-main.fcfe5033a5",
|
|
60
|
+
"@dxos/react-ui-menu": "0.8.4-main.fcfe5033a5",
|
|
61
|
+
"@dxos/plugin-space": "0.8.4-main.fcfe5033a5",
|
|
62
|
+
"@dxos/invariant": "0.8.4-main.fcfe5033a5",
|
|
63
|
+
"@dxos/react-ui-search": "0.8.4-main.fcfe5033a5",
|
|
64
|
+
"@dxos/schema": "0.8.4-main.fcfe5033a5",
|
|
65
|
+
"@dxos/util": "0.8.4-main.fcfe5033a5",
|
|
66
|
+
"@dxos/types": "0.8.4-main.fcfe5033a5",
|
|
67
|
+
"@dxos/react-ui-stack": "0.8.4-main.fcfe5033a5"
|
|
50
68
|
},
|
|
51
69
|
"devDependencies": {
|
|
52
|
-
"@effect-
|
|
53
|
-
"@effect/platform": "0.
|
|
54
|
-
"@
|
|
55
|
-
"@types/react": "~
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"react": "~
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"@dxos/
|
|
62
|
-
"@dxos/
|
|
63
|
-
"@dxos/react-ui
|
|
64
|
-
"@dxos/storybook-utils": "0.8.4-main.
|
|
70
|
+
"@effect-atom/atom-react": "^0.5.0",
|
|
71
|
+
"@effect/platform": "0.94.4",
|
|
72
|
+
"@types/react": "~19.2.7",
|
|
73
|
+
"@types/react-dom": "~19.2.3",
|
|
74
|
+
"effect": "3.20.0",
|
|
75
|
+
"react": "~19.2.3",
|
|
76
|
+
"react-dom": "~19.2.3",
|
|
77
|
+
"vite": "^7.1.11",
|
|
78
|
+
"@dxos/plugin-preview": "0.8.4-main.fcfe5033a5",
|
|
79
|
+
"@dxos/plugin-testing": "0.8.4-main.fcfe5033a5",
|
|
80
|
+
"@dxos/random": "0.8.4-main.fcfe5033a5",
|
|
81
|
+
"@dxos/react-ui": "0.8.4-main.fcfe5033a5",
|
|
82
|
+
"@dxos/storybook-utils": "0.8.4-main.fcfe5033a5",
|
|
83
|
+
"@dxos/ui-theme": "0.8.4-main.fcfe5033a5"
|
|
65
84
|
},
|
|
66
85
|
"peerDependencies": {
|
|
67
|
-
"@effect-
|
|
68
|
-
"@effect/platform": "
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"react": "~
|
|
72
|
-
"react-
|
|
73
|
-
"@dxos/
|
|
74
|
-
"@dxos/react-ui-theme": "0.8.4-main.f9ba587"
|
|
86
|
+
"@effect-atom/atom-react": "^0.5.0",
|
|
87
|
+
"@effect/platform": "0.94.4",
|
|
88
|
+
"effect": "3.20.0",
|
|
89
|
+
"react": "~19.2.3",
|
|
90
|
+
"react-dom": "~19.2.3",
|
|
91
|
+
"@dxos/react-ui": "0.8.4-main.fcfe5033a5",
|
|
92
|
+
"@dxos/ui-theme": "0.8.4-main.fcfe5033a5"
|
|
75
93
|
},
|
|
76
94
|
"publishConfig": {
|
|
77
95
|
"access": "public"
|
package/src/SearchPlugin.tsx
CHANGED
|
@@ -2,53 +2,36 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { Plugin } from '@dxos/app-framework';
|
|
6
|
+
import { AppPlugin } from '@dxos/app-toolkit';
|
|
7
|
+
|
|
8
|
+
import { AppGraphBuilder, OperationHandler, ReactSurface } from '#capabilities';
|
|
9
|
+
import { SEARCH_RESULT, meta } from '#meta';
|
|
10
|
+
import { type SearchResult } from '#types';
|
|
6
11
|
|
|
7
|
-
import { AppGraphBuilder, IntentResolver, ReactSurface } from './capabilities';
|
|
8
|
-
import { meta, SEARCH_RESULT } from './meta';
|
|
9
12
|
import { translations } from './translations';
|
|
10
|
-
import { type SearchResult } from './types';
|
|
11
13
|
|
|
12
|
-
export const SearchPlugin = ()
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
},
|
|
37
|
-
}),
|
|
38
|
-
}),
|
|
39
|
-
defineModule({
|
|
40
|
-
id: `${meta.id}/module/app-graph-builder`,
|
|
41
|
-
activatesOn: Events.SetupAppGraph,
|
|
42
|
-
activate: AppGraphBuilder,
|
|
43
|
-
}),
|
|
44
|
-
defineModule({
|
|
45
|
-
id: `${meta.id}/module/intent-resolver`,
|
|
46
|
-
activatesOn: Events.SetupIntentResolver,
|
|
47
|
-
activate: IntentResolver,
|
|
48
|
-
}),
|
|
49
|
-
defineModule({
|
|
50
|
-
id: `${meta.id}/module/react-surface`,
|
|
51
|
-
activatesOn: Events.SetupReactSurface,
|
|
52
|
-
activate: ReactSurface,
|
|
53
|
-
}),
|
|
54
|
-
]);
|
|
14
|
+
export const SearchPlugin = Plugin.define(meta).pipe(
|
|
15
|
+
AppPlugin.addAppGraphModule({ activate: AppGraphBuilder }),
|
|
16
|
+
AppPlugin.addMetadataModule({
|
|
17
|
+
metadata: {
|
|
18
|
+
id: SEARCH_RESULT,
|
|
19
|
+
metadata: {
|
|
20
|
+
parse: (item: SearchResult, type: string) => {
|
|
21
|
+
switch (type) {
|
|
22
|
+
case 'node':
|
|
23
|
+
return { id: item.id, label: item.label, data: item.object };
|
|
24
|
+
case 'object':
|
|
25
|
+
return item.object;
|
|
26
|
+
case 'view-object':
|
|
27
|
+
return item;
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
}),
|
|
33
|
+
AppPlugin.addOperationHandlerModule({ activate: OperationHandler }),
|
|
34
|
+
AppPlugin.addSurfaceModule({ activate: ReactSurface }),
|
|
35
|
+
AppPlugin.addTranslationsModule({ translations }),
|
|
36
|
+
Plugin.make,
|
|
37
|
+
);
|
|
@@ -2,78 +2,65 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
6
|
-
import { Option, pipe } from 'effect';
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
7
6
|
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
7
|
+
import { Capability } from '@dxos/app-framework';
|
|
8
|
+
import { AppCapabilities, AppNode, getSpaceIdFromPath } from '@dxos/app-toolkit';
|
|
9
|
+
import { Operation } from '@dxos/operation';
|
|
10
|
+
import { ClientCapabilities } from '@dxos/plugin-client/types';
|
|
11
|
+
import { GraphBuilder, NodeMatcher } from '@dxos/plugin-graph';
|
|
12
|
+
import { linkedSegment } from '@dxos/react-ui-attention';
|
|
13
13
|
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
14
|
+
import { meta } from '#meta';
|
|
15
|
+
import { SearchOperation } from '#operations';
|
|
16
16
|
|
|
17
|
-
export default (
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const { spaceId } = parseId(workspace);
|
|
30
|
-
const space = spaceId ? client.spaces.get(spaceId) : null;
|
|
17
|
+
export default Capability.makeModule(
|
|
18
|
+
Effect.fnUntraced(function* () {
|
|
19
|
+
const extensions = yield* Effect.all([
|
|
20
|
+
GraphBuilder.createExtension({
|
|
21
|
+
id: 'space-search',
|
|
22
|
+
match: NodeMatcher.whenRoot,
|
|
23
|
+
connector: Effect.fnUntraced(function* (node, get) {
|
|
24
|
+
const client = yield* Capability.get(ClientCapabilities.Client);
|
|
25
|
+
const layoutAtom = get(yield* Capability.atom(AppCapabilities.Layout))[0];
|
|
26
|
+
const layout = layoutAtom ? get(layoutAtom) : undefined;
|
|
27
|
+
const spaceId = layout?.workspace ? getSpaceIdFromPath(layout.workspace) : undefined;
|
|
28
|
+
const space = spaceId ? client.spaces.get(spaceId) : null;
|
|
31
29
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
label: ['search label', { ns: SEARCH_PLUGIN }],
|
|
39
|
-
icon: 'ph--magnifying-glass--regular',
|
|
40
|
-
disposition: 'hidden',
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
];
|
|
30
|
+
return [
|
|
31
|
+
AppNode.makeDeckCompanion({
|
|
32
|
+
id: linkedSegment('search'),
|
|
33
|
+
label: ['search.label', { ns: meta.id }],
|
|
34
|
+
icon: 'ph--magnifying-glass--regular',
|
|
35
|
+
data: space,
|
|
44
36
|
}),
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
label: ['search action label', { ns: SEARCH_PLUGIN }],
|
|
66
|
-
icon: 'ph--magnifying-glass--regular',
|
|
67
|
-
keyBinding: {
|
|
68
|
-
macos: 'shift+meta+f',
|
|
69
|
-
windows: 'shift+alt+f',
|
|
70
|
-
},
|
|
71
|
-
},
|
|
37
|
+
];
|
|
38
|
+
}),
|
|
39
|
+
}),
|
|
40
|
+
GraphBuilder.createExtension({
|
|
41
|
+
id: 'root',
|
|
42
|
+
match: NodeMatcher.whenRoot,
|
|
43
|
+
actions: () =>
|
|
44
|
+
Effect.succeed([
|
|
45
|
+
{
|
|
46
|
+
id: SearchOperation.OpenSearch.meta.key,
|
|
47
|
+
data: Effect.fnUntraced(function* () {
|
|
48
|
+
yield* Operation.invoke(SearchOperation.OpenSearch);
|
|
49
|
+
return false;
|
|
50
|
+
}),
|
|
51
|
+
properties: {
|
|
52
|
+
label: ['search-action.label', { ns: meta.id }],
|
|
53
|
+
icon: 'ph--magnifying-glass--regular',
|
|
54
|
+
keyBinding: {
|
|
55
|
+
macos: 'shift+meta+f',
|
|
56
|
+
windows: 'shift+alt+f',
|
|
72
57
|
},
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
]),
|
|
61
|
+
}),
|
|
62
|
+
]);
|
|
63
|
+
|
|
64
|
+
return Capability.contributes(AppCapabilities.AppGraphBuilder, extensions);
|
|
65
|
+
}),
|
|
66
|
+
);
|
|
@@ -2,8 +2,12 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { Capability } from '@dxos/app-framework';
|
|
6
|
+
import { OperationHandlerSet } from '@dxos/operation';
|
|
6
7
|
|
|
7
|
-
export const AppGraphBuilder = lazy(() => import('./app-graph-builder'));
|
|
8
|
-
export const
|
|
9
|
-
|
|
8
|
+
export const AppGraphBuilder = Capability.lazy('AppGraphBuilder', () => import('./app-graph-builder'));
|
|
9
|
+
export const OperationHandler = Capability.lazy<OperationHandlerSet.OperationHandlerSet>(
|
|
10
|
+
'OperationHandler',
|
|
11
|
+
() => import('./operation-handler'),
|
|
12
|
+
);
|
|
13
|
+
export const ReactSurface = Capability.lazy('ReactSurface', () => import('./react-surface'));
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
|
|
7
|
+
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
8
|
+
import type { OperationHandlerSet } from '@dxos/operation';
|
|
9
|
+
|
|
10
|
+
import { SearchOperationHandlerSet } from '#operations';
|
|
11
|
+
|
|
12
|
+
export default Capability.makeModule<OperationHandlerSet.OperationHandlerSet>(
|
|
13
|
+
Effect.fnUntraced(function* () {
|
|
14
|
+
return Capability.contributes(Capabilities.OperationHandler, SearchOperationHandlerSet);
|
|
15
|
+
}),
|
|
16
|
+
);
|
|
@@ -2,58 +2,61 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
import React, { type ComponentProps } from 'react';
|
|
6
7
|
|
|
7
|
-
import { Capabilities,
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
9
|
+
import { Surface } from '@dxos/app-framework/ui';
|
|
10
|
+
import { AppSurface, useActiveSpace } from '@dxos/app-toolkit/ui';
|
|
11
|
+
import { type Space, isSpace } from '@dxos/react-client/echo';
|
|
10
12
|
|
|
11
|
-
import {
|
|
12
|
-
import { SearchContextProvider } from '
|
|
13
|
+
import { SearchArticle, SearchDialog } from '#containers';
|
|
14
|
+
import { SearchContextProvider } from '#hooks';
|
|
13
15
|
|
|
14
|
-
|
|
15
|
-
contributes(Capabilities.ReactSurface, [
|
|
16
|
-
createSurface({
|
|
17
|
-
id: SEARCH_DIALOG,
|
|
18
|
-
role: 'dialog',
|
|
19
|
-
filter: (data): data is { props: SearchDialogProps } => data.component === SEARCH_DIALOG,
|
|
20
|
-
component: ({ data }) => (
|
|
21
|
-
<SearchContextProvider>
|
|
22
|
-
<SearchDialog {...data.props} />
|
|
23
|
-
</SearchContextProvider>
|
|
24
|
-
),
|
|
25
|
-
}),
|
|
26
|
-
createSurface({
|
|
27
|
-
id: `${SEARCH_DIALOG}/search-input`,
|
|
28
|
-
role: 'search-input',
|
|
29
|
-
component: () => {
|
|
30
|
-
const space = useActiveSpace();
|
|
31
|
-
if (!space) {
|
|
32
|
-
return null;
|
|
33
|
-
}
|
|
16
|
+
import { SEARCH_DIALOG } from '../constants';
|
|
34
17
|
|
|
35
|
-
|
|
18
|
+
export default Capability.makeModule(() =>
|
|
19
|
+
Effect.succeed(
|
|
20
|
+
Capability.contributes(Capabilities.ReactSurface, [
|
|
21
|
+
Surface.create({
|
|
22
|
+
id: SEARCH_DIALOG,
|
|
23
|
+
filter: AppSurface.component<ComponentProps<typeof SearchDialog>>(AppSurface.Dialog, SEARCH_DIALOG),
|
|
24
|
+
component: ({ data }) => (
|
|
36
25
|
<SearchContextProvider>
|
|
37
|
-
<
|
|
26
|
+
<SearchDialog {...data.props} />
|
|
38
27
|
</SearchContextProvider>
|
|
39
|
-
)
|
|
40
|
-
},
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
component: ({ data }) => {
|
|
47
|
-
const space = data.subject;
|
|
48
|
-
if (!space) {
|
|
49
|
-
return null;
|
|
50
|
-
}
|
|
28
|
+
),
|
|
29
|
+
}),
|
|
30
|
+
Surface.create({
|
|
31
|
+
id: `${SEARCH_DIALOG}.search-input`,
|
|
32
|
+
role: 'search-input',
|
|
33
|
+
component: () => {
|
|
34
|
+
const space = useActiveSpace();
|
|
51
35
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
36
|
+
return (
|
|
37
|
+
<SearchContextProvider>
|
|
38
|
+
<SearchArticle space={space} />
|
|
39
|
+
</SearchContextProvider>
|
|
40
|
+
);
|
|
41
|
+
},
|
|
42
|
+
}),
|
|
43
|
+
Surface.create({
|
|
44
|
+
id: `${SEARCH_DIALOG}.search`,
|
|
45
|
+
role: 'deck-companion--search',
|
|
46
|
+
filter: (data): data is { subject: Space } => isSpace(data.subject),
|
|
47
|
+
component: ({ data }) => {
|
|
48
|
+
const space = data.subject;
|
|
49
|
+
if (!space) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<SearchContextProvider>
|
|
55
|
+
<SearchArticle space={space} />
|
|
56
|
+
</SearchContextProvider>
|
|
57
|
+
);
|
|
58
|
+
},
|
|
59
|
+
}),
|
|
60
|
+
]),
|
|
61
|
+
),
|
|
62
|
+
);
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { type KeyboardEvent, forwardRef, useCallback, useMemo, useState } from 'react';
|
|
6
|
+
|
|
7
|
+
import { Surface } from '@dxos/app-framework/ui';
|
|
8
|
+
import { AppSurface, useObjectMenuItems } from '@dxos/app-toolkit/ui';
|
|
9
|
+
import { Entity } from '@dxos/echo';
|
|
10
|
+
import { Card, Toolbar } from '@dxos/react-ui';
|
|
11
|
+
import { ScrollArea } from '@dxos/react-ui';
|
|
12
|
+
import { Menu } from '@dxos/react-ui-menu';
|
|
13
|
+
import { type MosaicTileProps, Mosaic, useMosaicContainer, Focus } from '@dxos/react-ui-mosaic';
|
|
14
|
+
import { type SearchResult } from '@dxos/react-ui-search';
|
|
15
|
+
import { composable, composableProps } from '@dxos/ui-theme';
|
|
16
|
+
|
|
17
|
+
//
|
|
18
|
+
// SearchResultStack
|
|
19
|
+
//
|
|
20
|
+
|
|
21
|
+
export type SearchResultStackProps = {
|
|
22
|
+
results: SearchResult[];
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const SearchResultStack = composable<HTMLDivElement, SearchResultStackProps>(
|
|
26
|
+
({ results, ...props }, forwardedRef) => {
|
|
27
|
+
const [viewport, setViewport] = useState<HTMLElement | null>(null);
|
|
28
|
+
const items = useMemo(() => results.map((result) => ({ result })), [results]);
|
|
29
|
+
|
|
30
|
+
const handleKeyDown = useCallback((event: KeyboardEvent<HTMLDivElement>) => {
|
|
31
|
+
if (event.key === 'Enter') {
|
|
32
|
+
event.preventDefault();
|
|
33
|
+
(document.activeElement as HTMLElement | null)?.click();
|
|
34
|
+
}
|
|
35
|
+
}, []);
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<Focus.Group asChild {...composableProps(props)} onKeyDown={handleKeyDown} ref={forwardedRef}>
|
|
39
|
+
<Mosaic.Container asChild>
|
|
40
|
+
<ScrollArea.Root orientation='vertical' padding centered>
|
|
41
|
+
<ScrollArea.Viewport ref={setViewport}>
|
|
42
|
+
<Mosaic.VirtualStack
|
|
43
|
+
Tile={SearchResultTile}
|
|
44
|
+
classNames='my-2'
|
|
45
|
+
gap={8}
|
|
46
|
+
items={items}
|
|
47
|
+
draggable={false}
|
|
48
|
+
getId={(item) => item.result.id}
|
|
49
|
+
getScrollElement={() => viewport}
|
|
50
|
+
estimateSize={() => 150}
|
|
51
|
+
/>
|
|
52
|
+
</ScrollArea.Viewport>
|
|
53
|
+
</ScrollArea.Root>
|
|
54
|
+
</Mosaic.Container>
|
|
55
|
+
</Focus.Group>
|
|
56
|
+
);
|
|
57
|
+
},
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
SearchResultStack.displayName = 'SearchResultStack';
|
|
61
|
+
|
|
62
|
+
//
|
|
63
|
+
// SearchResultTile
|
|
64
|
+
//
|
|
65
|
+
|
|
66
|
+
type SearchResultTileData = {
|
|
67
|
+
result: SearchResult;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
type SearchResultTileProps = Pick<MosaicTileProps<SearchResultTileData>, 'location' | 'data' | 'current'>;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Search result tile that uses Surface to render object content.
|
|
74
|
+
*/
|
|
75
|
+
const SearchResultTile = forwardRef<HTMLDivElement, SearchResultTileProps>(
|
|
76
|
+
({ data, location, current }, forwardedRef) => {
|
|
77
|
+
const { result } = data;
|
|
78
|
+
const menuItems = useObjectMenuItems(result.object);
|
|
79
|
+
const { setCurrentId } = useMosaicContainer('SearchResultTile');
|
|
80
|
+
|
|
81
|
+
const handleCurrentChange = useCallback(() => {
|
|
82
|
+
setCurrentId(result.id);
|
|
83
|
+
}, [result.id, setCurrentId]);
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
<Menu.Root>
|
|
87
|
+
<Mosaic.Tile
|
|
88
|
+
asChild
|
|
89
|
+
classNames='dx-hover dx-current dx-selected'
|
|
90
|
+
id={result.id}
|
|
91
|
+
data={data}
|
|
92
|
+
location={location}
|
|
93
|
+
>
|
|
94
|
+
<Focus.Item asChild current={current} onCurrentChange={handleCurrentChange}>
|
|
95
|
+
<Card.Root ref={forwardedRef} role='button' classNames='cursor-pointer'>
|
|
96
|
+
<Card.Toolbar>
|
|
97
|
+
<Card.IconBlock />
|
|
98
|
+
<Card.Title>{result.label ?? (result.object && Entity.getLabel(result.object))}</Card.Title>
|
|
99
|
+
<Menu.Trigger asChild disabled={!menuItems?.length}>
|
|
100
|
+
<Toolbar.IconButton
|
|
101
|
+
iconOnly
|
|
102
|
+
variant='ghost'
|
|
103
|
+
icon='ph--dots-three-vertical--regular'
|
|
104
|
+
label='Actions'
|
|
105
|
+
/>
|
|
106
|
+
</Menu.Trigger>
|
|
107
|
+
<Menu.Content items={menuItems} />
|
|
108
|
+
</Card.Toolbar>
|
|
109
|
+
<Surface.Surface type={AppSurface.Card} data={{ subject: result.object }} limit={1} />
|
|
110
|
+
</Card.Root>
|
|
111
|
+
</Focus.Item>
|
|
112
|
+
</Mosaic.Tile>
|
|
113
|
+
</Menu.Root>
|
|
114
|
+
);
|
|
115
|
+
},
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
SearchResultTile.displayName = 'SearchResultTile';
|
package/src/components/index.ts
CHANGED