@dxos/plugin-search 0.8.4-main.3c1ae3b → 0.8.4-main.3eb6e50203

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.
Files changed (122) hide show
  1. package/dist/lib/browser/app-graph-builder-NUJ2FOVQ.mjs +82 -0
  2. package/dist/lib/browser/app-graph-builder-NUJ2FOVQ.mjs.map +7 -0
  3. package/dist/lib/browser/{chunk-GN2FSWTM.mjs → chunk-HRIWTRJV.mjs} +1 -1
  4. package/dist/lib/browser/chunk-HRIWTRJV.mjs.map +7 -0
  5. package/dist/lib/browser/chunk-I7YWQSUZ.mjs +26 -0
  6. package/dist/lib/browser/chunk-I7YWQSUZ.mjs.map +7 -0
  7. package/dist/lib/browser/{chunk-MBISM5WN.mjs → chunk-ZRJJXRGF.mjs} +47 -56
  8. package/dist/lib/browser/chunk-ZRJJXRGF.mjs.map +7 -0
  9. package/dist/lib/browser/index.mjs +48 -55
  10. package/dist/lib/browser/index.mjs.map +4 -4
  11. package/dist/lib/browser/meta.json +1 -1
  12. package/dist/lib/browser/operation-resolver-QEGN4ZKN.mjs +26 -0
  13. package/dist/lib/browser/operation-resolver-QEGN4ZKN.mjs.map +7 -0
  14. package/dist/lib/browser/react-surface-QE45EVGF.mjs +369 -0
  15. package/dist/lib/browser/react-surface-QE45EVGF.mjs.map +7 -0
  16. package/dist/types/src/SearchPlugin.d.ts +2 -1
  17. package/dist/types/src/SearchPlugin.d.ts.map +1 -1
  18. package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts +6 -0
  19. package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts.map +1 -0
  20. package/dist/types/src/capabilities/app-graph-builder/index.d.ts +3 -0
  21. package/dist/types/src/capabilities/app-graph-builder/index.d.ts.map +1 -0
  22. package/dist/types/src/capabilities/index.d.ts +3 -3
  23. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  24. package/dist/types/src/capabilities/operation-resolver/index.d.ts +3 -0
  25. package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +1 -0
  26. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +5 -0
  27. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +1 -0
  28. package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
  29. package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
  30. package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
  31. package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
  32. package/dist/types/src/components/SearchDialog.d.ts.map +1 -1
  33. package/dist/types/src/components/SearchMain.d.ts.map +1 -1
  34. package/dist/types/src/components/SearchMain.stories.d.ts +31 -0
  35. package/dist/types/src/components/SearchMain.stories.d.ts.map +1 -0
  36. package/dist/types/src/components/SpaceMain.d.ts +9 -0
  37. package/dist/types/src/components/SpaceMain.d.ts.map +1 -0
  38. package/dist/types/src/components/index.d.ts +1 -1
  39. package/dist/types/src/components/index.d.ts.map +1 -1
  40. package/dist/types/src/hooks/sync.d.ts +3 -2
  41. package/dist/types/src/hooks/sync.d.ts.map +1 -1
  42. package/dist/types/src/hooks/useGlobalSearch.d.ts +7 -3
  43. package/dist/types/src/hooks/useGlobalSearch.d.ts.map +1 -1
  44. package/dist/types/src/hooks/useSearchResults.d.ts +3 -2
  45. package/dist/types/src/hooks/useSearchResults.d.ts.map +1 -1
  46. package/dist/types/src/hooks/useWebSearch.d.ts +6 -3
  47. package/dist/types/src/hooks/useWebSearch.d.ts.map +1 -1
  48. package/dist/types/src/meta.d.ts +2 -2
  49. package/dist/types/src/meta.d.ts.map +1 -1
  50. package/dist/types/src/search/exa.d.ts +3 -1
  51. package/dist/types/src/search/exa.d.ts.map +1 -1
  52. package/dist/types/src/translations.d.ts +1 -1
  53. package/dist/types/src/types/action.d.ts +13 -10
  54. package/dist/types/src/types/action.d.ts.map +1 -1
  55. package/dist/types/src/types/search.d.ts +3 -7
  56. package/dist/types/src/types/search.d.ts.map +1 -1
  57. package/dist/types/tsconfig.tsbuildinfo +1 -1
  58. package/package.json +54 -47
  59. package/src/SearchPlugin.tsx +25 -42
  60. package/src/capabilities/app-graph-builder/app-graph-builder.ts +71 -0
  61. package/src/capabilities/app-graph-builder/index.ts +7 -0
  62. package/src/capabilities/index.ts +3 -5
  63. package/src/capabilities/operation-resolver/index.ts +7 -0
  64. package/src/capabilities/operation-resolver/operation-resolver.ts +24 -0
  65. package/src/capabilities/react-surface/index.ts +7 -0
  66. package/src/capabilities/react-surface/react-surface.tsx +71 -0
  67. package/src/components/SearchDialog.tsx +54 -70
  68. package/src/components/SearchMain.stories.tsx +90 -0
  69. package/src/components/SearchMain.tsx +63 -37
  70. package/src/components/SpaceMain.tsx +172 -0
  71. package/src/components/index.ts +1 -1
  72. package/src/hooks/sync.test.ts +5 -3
  73. package/src/hooks/sync.ts +22 -27
  74. package/src/hooks/useGlobalSearch.tsx +31 -12
  75. package/src/hooks/useSearchResults.ts +5 -2
  76. package/src/hooks/useWebSearch.ts +19 -8
  77. package/src/meta.ts +2 -2
  78. package/src/search/exa.ts +4 -3
  79. package/src/translations.ts +1 -1
  80. package/src/types/action.tsx +8 -6
  81. package/src/types/command-score.d.ts +16 -0
  82. package/src/types/search.ts +3 -9
  83. package/dist/lib/browser/app-graph-builder-BFLYNCSJ.mjs +0 -79
  84. package/dist/lib/browser/app-graph-builder-BFLYNCSJ.mjs.map +0 -7
  85. package/dist/lib/browser/chunk-GN2FSWTM.mjs.map +0 -7
  86. package/dist/lib/browser/chunk-MBISM5WN.mjs.map +0 -7
  87. package/dist/lib/browser/chunk-TCVYYI44.mjs +0 -21
  88. package/dist/lib/browser/chunk-TCVYYI44.mjs.map +0 -7
  89. package/dist/lib/browser/intent-resolver-UYQA6UUQ.mjs +0 -22
  90. package/dist/lib/browser/intent-resolver-UYQA6UUQ.mjs.map +0 -7
  91. package/dist/lib/browser/react-surface-NNSCVH4Q.mjs +0 -301
  92. package/dist/lib/browser/react-surface-NNSCVH4Q.mjs.map +0 -7
  93. package/dist/types/src/capabilities/app-graph-builder.d.ts +0 -4
  94. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +0 -1
  95. package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
  96. package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
  97. package/dist/types/src/capabilities/react-surface.d.ts +0 -4
  98. package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
  99. package/dist/types/src/components/Search.stories.d.ts +0 -16
  100. package/dist/types/src/components/Search.stories.d.ts.map +0 -1
  101. package/dist/types/src/components/SearchResults/SearchResults.d.ts +0 -20
  102. package/dist/types/src/components/SearchResults/SearchResults.d.ts.map +0 -1
  103. package/dist/types/src/components/SearchResults/SearchResults.stories.d.ts +0 -16
  104. package/dist/types/src/components/SearchResults/SearchResults.stories.d.ts.map +0 -1
  105. package/dist/types/src/components/SearchResults/index.d.ts +0 -2
  106. package/dist/types/src/components/SearchResults/index.d.ts.map +0 -1
  107. package/dist/types/src/components/Searchbar/Searchbar.d.ts +0 -10
  108. package/dist/types/src/components/Searchbar/Searchbar.d.ts.map +0 -1
  109. package/dist/types/src/components/Searchbar/Searchbar.stories.d.ts +0 -13
  110. package/dist/types/src/components/Searchbar/Searchbar.stories.d.ts.map +0 -1
  111. package/dist/types/src/components/Searchbar/index.d.ts +0 -2
  112. package/dist/types/src/components/Searchbar/index.d.ts.map +0 -1
  113. package/src/capabilities/app-graph-builder.ts +0 -81
  114. package/src/capabilities/intent-resolver.ts +0 -18
  115. package/src/capabilities/react-surface.tsx +0 -56
  116. package/src/components/Search.stories.tsx +0 -64
  117. package/src/components/SearchResults/SearchResults.stories.tsx +0 -59
  118. package/src/components/SearchResults/SearchResults.tsx +0 -83
  119. package/src/components/SearchResults/index.ts +0 -5
  120. package/src/components/Searchbar/Searchbar.stories.tsx +0 -28
  121. package/src/components/Searchbar/Searchbar.tsx +0 -57
  122. package/src/components/Searchbar/index.ts +0 -5
package/package.json CHANGED
@@ -1,9 +1,13 @@
1
1
  {
2
2
  "name": "@dxos/plugin-search",
3
- "version": "0.8.4-main.3c1ae3b",
4
- "description": "Braneframe sketch plugin",
3
+ "version": "0.8.4-main.3eb6e50203",
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,
@@ -12,66 +16,69 @@
12
16
  ".": {
13
17
  "source": "./src/index.ts",
14
18
  "types": "./dist/types/src/index.d.ts",
15
- "browser": "./dist/lib/browser/index.mjs"
19
+ "browser": "./dist/lib/browser/index.mjs",
20
+ "node": "./dist/lib/node-esm/index.mjs"
16
21
  }
17
22
  },
18
23
  "types": "dist/types/src/index.d.ts",
19
- "typesVersions": {
20
- "*": {}
21
- },
22
24
  "files": [
23
25
  "dist",
24
26
  "src"
25
27
  ],
26
28
  "dependencies": {
27
- "@preact-signals/safe-react": "^0.9.0",
28
29
  "exa-js": "^1.5.12",
29
30
  "main-thread-scheduling": "^14.1.1",
30
- "@dxos/ai": "0.8.4-main.3c1ae3b",
31
- "@dxos/app-framework": "0.8.4-main.3c1ae3b",
32
- "@dxos/assistant": "0.8.4-main.3c1ae3b",
33
- "@dxos/async": "0.8.4-main.3c1ae3b",
34
- "@dxos/blueprints": "0.8.4-main.3c1ae3b",
35
- "@dxos/debug": "0.8.4-main.3c1ae3b",
36
- "@dxos/effect": "0.8.4-main.3c1ae3b",
37
- "@dxos/invariant": "0.8.4-main.3c1ae3b",
38
- "@dxos/echo-protocol": "0.8.4-main.3c1ae3b",
39
- "@dxos/live-object": "0.8.4-main.3c1ae3b",
40
- "@dxos/log": "0.8.4-main.3c1ae3b",
41
- "@dxos/plugin-client": "0.8.4-main.3c1ae3b",
42
- "@dxos/plugin-deck": "0.8.4-main.3c1ae3b",
43
- "@dxos/plugin-graph": "0.8.4-main.3c1ae3b",
44
- "@dxos/plugin-space": "0.8.4-main.3c1ae3b",
45
- "@dxos/echo": "0.8.4-main.3c1ae3b",
46
- "@dxos/react-client": "0.8.4-main.3c1ae3b",
47
- "@dxos/schema": "0.8.4-main.3c1ae3b",
48
- "@dxos/react-ui-searchlist": "0.8.4-main.3c1ae3b",
49
- "@dxos/util": "0.8.4-main.3c1ae3b",
50
- "@dxos/react-ui-stack": "0.8.4-main.3c1ae3b",
51
- "@dxos/types": "0.8.4-main.3c1ae3b"
31
+ "@dxos/ai": "0.8.4-main.3eb6e50203",
32
+ "@dxos/app-toolkit": "0.8.4-main.3eb6e50203",
33
+ "@dxos/assistant": "0.8.4-main.3eb6e50203",
34
+ "@dxos/app-framework": "0.8.4-main.3eb6e50203",
35
+ "@dxos/blueprints": "0.8.4-main.3eb6e50203",
36
+ "@dxos/debug": "0.8.4-main.3eb6e50203",
37
+ "@dxos/async": "0.8.4-main.3eb6e50203",
38
+ "@dxos/echo-protocol": "0.8.4-main.3eb6e50203",
39
+ "@dxos/echo": "0.8.4-main.3eb6e50203",
40
+ "@dxos/echo-query": "0.8.4-main.3eb6e50203",
41
+ "@dxos/effect": "0.8.4-main.3eb6e50203",
42
+ "@dxos/invariant": "0.8.4-main.3eb6e50203",
43
+ "@dxos/log": "0.8.4-main.3eb6e50203",
44
+ "@dxos/operation": "0.8.4-main.3eb6e50203",
45
+ "@dxos/plugin-deck": "0.8.4-main.3eb6e50203",
46
+ "@dxos/plugin-client": "0.8.4-main.3eb6e50203",
47
+ "@dxos/plugin-graph": "0.8.4-main.3eb6e50203",
48
+ "@dxos/plugin-space": "0.8.4-main.3eb6e50203",
49
+ "@dxos/react-ui-components": "0.8.4-main.3eb6e50203",
50
+ "@dxos/react-client": "0.8.4-main.3eb6e50203",
51
+ "@dxos/react-ui-searchlist": "0.8.4-main.3eb6e50203",
52
+ "@dxos/react-ui-mosaic": "0.8.4-main.3eb6e50203",
53
+ "@dxos/react-ui-stack": "0.8.4-main.3eb6e50203",
54
+ "@dxos/types": "0.8.4-main.3eb6e50203",
55
+ "@dxos/schema": "0.8.4-main.3eb6e50203",
56
+ "@dxos/util": "0.8.4-main.3eb6e50203"
52
57
  },
53
58
  "devDependencies": {
54
- "@effect-atom/atom-react": "^0.3.4",
55
- "@effect/platform": "0.92.1",
56
- "@types/react": "~19.2.2",
57
- "@types/react-dom": "~19.2.2",
58
- "effect": "3.18.3",
59
- "react": "~19.2.0",
60
- "react-dom": "~19.2.0",
59
+ "@effect-atom/atom-react": "^0.5.0",
60
+ "@effect/platform": "0.94.4",
61
+ "@types/react": "~19.2.7",
62
+ "@types/react-dom": "~19.2.3",
63
+ "effect": "3.19.16",
64
+ "react": "~19.2.3",
65
+ "react-dom": "~19.2.3",
61
66
  "vite": "7.1.9",
62
- "@dxos/random": "0.8.4-main.3c1ae3b",
63
- "@dxos/react-ui": "0.8.4-main.3c1ae3b",
64
- "@dxos/storybook-utils": "0.8.4-main.3c1ae3b",
65
- "@dxos/react-ui-theme": "0.8.4-main.3c1ae3b"
67
+ "@dxos/plugin-testing": "0.8.4-main.3eb6e50203",
68
+ "@dxos/random": "0.8.4-main.3eb6e50203",
69
+ "@dxos/plugin-preview": "0.8.4-main.3eb6e50203",
70
+ "@dxos/react-ui": "0.8.4-main.3eb6e50203",
71
+ "@dxos/storybook-utils": "0.8.4-main.3eb6e50203",
72
+ "@dxos/ui-theme": "0.8.4-main.3eb6e50203"
66
73
  },
67
74
  "peerDependencies": {
68
- "@effect-atom/atom-react": "^0.3.4",
69
- "@effect/platform": "^0.80.12",
70
- "effect": "^3.13.3",
71
- "react": "^19.0.0",
72
- "react-dom": "^19.0.0",
73
- "@dxos/react-ui": "0.8.4-main.3c1ae3b",
74
- "@dxos/react-ui-theme": "0.8.4-main.3c1ae3b"
75
+ "@effect-atom/atom-react": "^0.5.0",
76
+ "@effect/platform": "0.94.4",
77
+ "effect": "3.19.16",
78
+ "react": "~19.2.3",
79
+ "react-dom": "~19.2.3",
80
+ "@dxos/react-ui": "0.8.4-main.3eb6e50203",
81
+ "@dxos/ui-theme": "0.8.4-main.3eb6e50203"
75
82
  },
76
83
  "publishConfig": {
77
84
  "access": "public"
@@ -2,52 +2,35 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { Capabilities, Events, contributes, defineModule, definePlugin } from '@dxos/app-framework';
5
+ import { Plugin } from '@dxos/app-framework';
6
+ import { AppPlugin } from '@dxos/app-toolkit';
6
7
 
7
- import { AppGraphBuilder, IntentResolver, ReactSurface } from './capabilities';
8
+ import { AppGraphBuilder, OperationResolver, ReactSurface } from './capabilities';
8
9
  import { SEARCH_RESULT, meta } from './meta';
9
10
  import { translations } from './translations';
10
11
  import { type SearchResult } from './types';
11
12
 
12
- export const SearchPlugin = definePlugin(meta, () => [
13
- defineModule({
14
- id: `${meta.id}/module/translations`,
15
- activatesOn: Events.SetupTranslations,
16
- activate: () => contributes(Capabilities.Translations, translations),
17
- }),
18
- defineModule({
19
- id: `${meta.id}/module/metadata`,
20
- activatesOn: Events.SetupMetadata,
21
- activate: () =>
22
- contributes(Capabilities.Metadata, {
23
- id: SEARCH_RESULT,
24
- metadata: {
25
- parse: (item: SearchResult, type: string) => {
26
- switch (type) {
27
- case 'node':
28
- return { id: item.id, label: item.label, data: item.object };
29
- case 'object':
30
- return item.object;
31
- case 'view-object':
32
- return item;
33
- }
34
- },
13
+ export const SearchPlugin = Plugin.define(meta).pipe(
14
+ AppPlugin.addAppGraphModule({ activate: AppGraphBuilder }),
15
+ AppPlugin.addMetadataModule({
16
+ metadata: {
17
+ id: SEARCH_RESULT,
18
+ metadata: {
19
+ parse: (item: SearchResult, type: string) => {
20
+ switch (type) {
21
+ case 'node':
22
+ return { id: item.id, label: item.label, data: item.object };
23
+ case 'object':
24
+ return item.object;
25
+ case 'view-object':
26
+ return item;
27
+ }
35
28
  },
36
- }),
37
- }),
38
- defineModule({
39
- id: `${meta.id}/module/app-graph-builder`,
40
- activatesOn: Events.SetupAppGraph,
41
- activate: AppGraphBuilder,
42
- }),
43
- defineModule({
44
- id: `${meta.id}/module/intent-resolver`,
45
- activatesOn: Events.SetupIntentResolver,
46
- activate: IntentResolver,
47
- }),
48
- defineModule({
49
- id: `${meta.id}/module/react-surface`,
50
- activatesOn: Events.SetupReactSurface,
51
- activate: ReactSurface,
29
+ },
30
+ },
52
31
  }),
53
- ]);
32
+ AppPlugin.addOperationResolverModule({ activate: OperationResolver }),
33
+ AppPlugin.addSurfaceModule({ activate: ReactSurface }),
34
+ AppPlugin.addTranslationsModule({ translations }),
35
+ Plugin.make,
36
+ );
@@ -0,0 +1,71 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import * as Effect from 'effect/Effect';
6
+
7
+ import { Capability } from '@dxos/app-framework';
8
+ import { AppCapabilities } from '@dxos/app-toolkit';
9
+ import { Operation } from '@dxos/operation';
10
+ import { ClientCapabilities } from '@dxos/plugin-client';
11
+ import { ATTENDABLE_PATH_SEPARATOR, DECK_COMPANION_TYPE } from '@dxos/plugin-deck/types';
12
+ import { GraphBuilder, NodeMatcher } from '@dxos/plugin-graph';
13
+ import { parseId } from '@dxos/react-client/echo';
14
+
15
+ import { meta } from '../../meta';
16
+ import { SearchOperation } from '../../types';
17
+
18
+ export default Capability.makeModule(
19
+ Effect.fnUntraced(function* () {
20
+ const extensions = yield* Effect.all([
21
+ GraphBuilder.createExtension({
22
+ id: `${meta.id}/space-search`,
23
+ match: NodeMatcher.whenRoot,
24
+ connector: Effect.fnUntraced(function* (node, get) {
25
+ const client = yield* Capability.get(ClientCapabilities.Client);
26
+ const layoutAtom = get(yield* Capability.atom(AppCapabilities.Layout))[0];
27
+ const layout = layoutAtom ? get(layoutAtom) : undefined;
28
+ const { spaceId } = parseId(layout?.workspace);
29
+ const space = spaceId ? client.spaces.get(spaceId) : null;
30
+
31
+ return [
32
+ {
33
+ id: [node.id, 'search'].join(ATTENDABLE_PATH_SEPARATOR),
34
+ type: DECK_COMPANION_TYPE,
35
+ data: space,
36
+ properties: {
37
+ label: ['search label', { ns: meta.id }],
38
+ icon: 'ph--magnifying-glass--regular',
39
+ disposition: 'hidden',
40
+ },
41
+ },
42
+ ];
43
+ }),
44
+ }),
45
+ GraphBuilder.createExtension({
46
+ id: meta.id,
47
+ match: NodeMatcher.whenRoot,
48
+ actions: () =>
49
+ Effect.succeed([
50
+ {
51
+ id: SearchOperation.OpenSearch.meta.key,
52
+ data: Effect.fnUntraced(function* () {
53
+ yield* Operation.invoke(SearchOperation.OpenSearch);
54
+ return false;
55
+ }),
56
+ properties: {
57
+ label: ['search action label', { ns: meta.id }],
58
+ icon: 'ph--magnifying-glass--regular',
59
+ keyBinding: {
60
+ macos: 'shift+meta+f',
61
+ windows: 'shift+alt+f',
62
+ },
63
+ },
64
+ },
65
+ ]),
66
+ }),
67
+ ]);
68
+
69
+ return Capability.contributes(AppCapabilities.AppGraphBuilder, extensions);
70
+ }),
71
+ );
@@ -0,0 +1,7 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { Capability } from '@dxos/app-framework';
6
+
7
+ export const AppGraphBuilder = Capability.lazy('AppGraphBuilder', () => import('./app-graph-builder'));
@@ -2,8 +2,6 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { lazy } from '@dxos/app-framework';
6
-
7
- export const AppGraphBuilder = lazy(() => import('./app-graph-builder'));
8
- export const IntentResolver = lazy(() => import('./intent-resolver'));
9
- export const ReactSurface = lazy(() => import('./react-surface'));
5
+ export * from './app-graph-builder';
6
+ export * from './operation-resolver';
7
+ export * from './react-surface';
@@ -0,0 +1,7 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { Capability } from '@dxos/app-framework';
6
+
7
+ export const OperationResolver = Capability.lazy('OperationResolver', () => import('./operation-resolver'));
@@ -0,0 +1,24 @@
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 { LayoutOperation } from '@dxos/app-toolkit';
9
+ import { Operation, OperationResolver } from '@dxos/operation';
10
+
11
+ import { SearchOperation } from '../../types';
12
+
13
+ export default Capability.makeModule(
14
+ Effect.fnUntraced(function* () {
15
+ return Capability.contributes(Capabilities.OperationResolver, [
16
+ OperationResolver.make({
17
+ operation: SearchOperation.OpenSearch,
18
+ handler: Effect.fnUntraced(function* () {
19
+ yield* Operation.invoke(LayoutOperation.UpdateComplementary, { subject: 'search' });
20
+ }),
21
+ }),
22
+ ]);
23
+ }),
24
+ );
@@ -0,0 +1,7 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { Capability } from '@dxos/app-framework';
6
+
7
+ export const ReactSurface = Capability.lazy('ReactSurface', () => import('./react-surface'));
@@ -0,0 +1,71 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import * as Effect from 'effect/Effect';
6
+ import React from 'react';
7
+
8
+ import { Capabilities, Capability } from '@dxos/app-framework';
9
+ import { Surface } from '@dxos/app-framework/ui';
10
+ import { useActiveSpace } from '@dxos/plugin-space';
11
+ import { type Space, SpaceState, isSpace } from '@dxos/react-client/echo';
12
+
13
+ import { SEARCH_DIALOG, SearchDialog, type SearchDialogProps, SearchMain, SpaceMain } from '../../components';
14
+ import { SearchContextProvider } from '../../hooks';
15
+ import { meta } from '../../meta';
16
+
17
+ export default Capability.makeModule(() =>
18
+ Effect.succeed(
19
+ Capability.contributes(Capabilities.ReactSurface, [
20
+ Surface.create({
21
+ id: SEARCH_DIALOG,
22
+ role: 'dialog',
23
+ filter: (data): data is { props: SearchDialogProps } => data.component === SEARCH_DIALOG,
24
+ component: ({ data }) => (
25
+ <SearchContextProvider>
26
+ <SearchDialog {...data.props} />
27
+ </SearchContextProvider>
28
+ ),
29
+ }),
30
+ Surface.create({
31
+ id: `${SEARCH_DIALOG}/search-input`,
32
+ role: 'search-input',
33
+ component: () => {
34
+ const space = useActiveSpace();
35
+
36
+ return (
37
+ <SearchContextProvider>
38
+ <SearchMain 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
+ <SearchMain space={space} />
56
+ </SearchContextProvider>
57
+ );
58
+ },
59
+ }),
60
+ Surface.create({
61
+ id: `${meta.id}/space-article`,
62
+ role: 'article',
63
+ position: 'hoist',
64
+ filter: (data): data is { subject: Space } =>
65
+ // TODO(wittjosiah): Need to avoid shotgun parsing space state everywhere.
66
+ isSpace(data.subject) && data.subject.state.get() === SpaceState.SPACE_READY,
67
+ component: ({ data }) => <SpaceMain space={data.subject} />,
68
+ }),
69
+ ]),
70
+ ),
71
+ );
@@ -5,15 +5,16 @@
5
5
  import * as Option from 'effect/Option';
6
6
  import React, { forwardRef, useCallback, useState } from 'react';
7
7
 
8
- import { LayoutAction, createIntent } from '@dxos/app-framework';
9
- import { useAppGraph, useIntentDispatcher, useLayout } from '@dxos/app-framework/react';
8
+ import { useOperationInvoker } from '@dxos/app-framework/ui';
9
+ import { LayoutOperation } from '@dxos/app-toolkit';
10
+ import { useAppGraph, useLayout } from '@dxos/app-toolkit/ui';
10
11
  import { Obj } from '@dxos/echo';
11
- import { type Node } from '@dxos/plugin-graph';
12
+ import { Graph, type Node } from '@dxos/plugin-graph';
12
13
  import { useClient } from '@dxos/react-client';
13
14
  import { Filter, useQuery } from '@dxos/react-client/echo';
14
- import { Button, Dialog, Icon, toLocalizedString, useTranslation } from '@dxos/react-ui';
15
- import { SearchList, type SearchListItemProps } from '@dxos/react-ui-searchlist';
16
- import { descriptionText, mx } from '@dxos/react-ui-theme';
15
+ import { Button, Dialog, toLocalizedString, useTranslation } from '@dxos/react-ui';
16
+ import { SearchList } from '@dxos/react-ui-searchlist';
17
+ import { descriptionText, mx, osTranslations } from '@dxos/ui-theme';
17
18
 
18
19
  import { useSearchResults } from '../hooks';
19
20
  import { meta } from '../meta';
@@ -21,23 +22,25 @@ import { meta } from '../meta';
21
22
  export const SEARCH_DIALOG = `${meta.id}/SearchDialog`;
22
23
 
23
24
  type SearchListResultProps = {
24
- node: Node;
25
- } & Pick<SearchListItemProps, 'onSelect'>;
25
+ node: Node.Node;
26
+ onSelect?: (nodeId: string) => void;
27
+ };
26
28
 
27
29
  const SearchListResult = forwardRef<HTMLDivElement, SearchListResultProps>(({ node, onSelect }, forwardedRef) => {
28
30
  const { t } = useTranslation(meta.id);
29
31
  const label = toLocalizedString(node?.properties.label ?? 'never', t);
32
+ const handleSelect = useCallback(() => {
33
+ onSelect?.(node!.id);
34
+ }, [node, onSelect]);
30
35
  return (
31
36
  <SearchList.Item
32
- value={label}
33
- key={node!.id}
37
+ value={node!.id}
38
+ label={label}
39
+ icon={node?.properties.icon}
34
40
  classNames='flex gap-2 items-center pli-2'
35
- onSelect={() => onSelect?.(node!.id)}
41
+ onSelect={handleSelect}
36
42
  ref={forwardedRef}
37
- >
38
- <Icon size={5} icon={node?.properties.icon} />
39
- <span className='is-0 grow truncate'>{label}</span>
40
- </SearchList.Item>
43
+ />
41
44
  );
42
45
  });
43
46
 
@@ -50,86 +53,67 @@ export const SearchDialog = ({ pivotId }: SearchDialogProps) => {
50
53
  const { graph } = useAppGraph();
51
54
  const layout = useLayout();
52
55
  const closed = (Array.isArray(layout.inactive) ? layout.inactive : [layout.inactive])
53
- .map((id) => graph?.getNode(id))
56
+ .map((id) => (graph ? Graph.getNode(graph, id) : Option.none()))
54
57
  .filter(Boolean);
55
58
  const [queryString, setQueryString] = useState('');
56
59
  const client = useClient();
57
60
  const dangerouslyLoadAllObjects = useQuery(client.spaces, Filter.everything());
58
61
  const [pending, results] = useSearchResults(queryString, dangerouslyLoadAllObjects);
59
62
  const resultObjects = Array.from(results.keys());
60
- const { dispatchPromise: dispatch } = useIntentDispatcher();
63
+ const { invokePromise } = useOperationInvoker();
61
64
 
62
65
  const handleSelect = useCallback(
63
66
  async (nodeId: string) => {
64
- await dispatch(
65
- createIntent(LayoutAction.UpdateDialog, {
66
- part: 'dialog',
67
- options: { state: false },
68
- }),
69
- );
67
+ await invokePromise(LayoutOperation.UpdateDialog, { state: false });
70
68
 
71
69
  // If node is already present in the active parts, scroll to it and close the dialog.
72
70
  const index = layout.active.findIndex((id) => id === nodeId);
73
71
  if (index !== -1) {
74
- await dispatch(
75
- createIntent(LayoutAction.ScrollIntoView, {
76
- part: 'current',
77
- subject: nodeId,
78
- }),
79
- );
72
+ await invokePromise(LayoutOperation.ScrollIntoView, { subject: nodeId });
80
73
  } else {
81
- await dispatch(
82
- createIntent(LayoutAction.Open, {
83
- part: 'main',
84
- subject: [nodeId],
85
- options: {
86
- pivotId,
87
- positioning: 'end',
88
- },
89
- }),
90
- );
74
+ await invokePromise(LayoutOperation.Open, {
75
+ subject: [nodeId],
76
+ pivotId,
77
+ positioning: 'end',
78
+ });
91
79
  }
92
80
  },
93
- [pivotId, dispatch, layout],
81
+ [pivotId, invokePromise, layout],
94
82
  );
95
83
 
84
+ const handleSearch = useCallback((query: string) => {
85
+ setQueryString(query);
86
+ }, []);
87
+
96
88
  return (
97
- <Dialog.Content classNames={['md:max-is-[24rem] overflow-hidden mbs-12']}>
89
+ <Dialog.Content>
98
90
  <Dialog.Title>{t('search dialog title')}</Dialog.Title>
99
- <SearchList.Root label={t('search placeholder')} classNames='flex flex-col grow overflow-hidden my-2'>
100
- <SearchList.Input
101
- value={queryString}
102
- onValueChange={(nextValue) => {
103
- setQueryString(nextValue);
104
- }}
105
- placeholder={t('search placeholder')}
106
- classNames='pli-1 my-2'
107
- />
91
+ <SearchList.Root onSearch={handleSearch}>
108
92
  <SearchList.Content classNames='max-bs-[24rem] overflow-auto'>
109
- {queryString.length > 0 ? (
110
- resultObjects.length > 0 ? (
111
- resultObjects
112
- .map((object) => graph.getNode(Obj.getDXN(object).toString()))
113
- .filter(Option.isSome)
114
- .map((node) => <SearchListResult key={node.value.id} node={node.value} onSelect={handleSelect} />)
93
+ <SearchList.Input placeholder={t('search placeholder')} />
94
+ <SearchList.Viewport>
95
+ {queryString.length > 0 ? (
96
+ resultObjects.length > 0 ? (
97
+ resultObjects
98
+ .map((object) => Graph.getNode(graph, Obj.getDXN(object).toString()))
99
+ .filter(Option.isSome)
100
+ .map((node) => <SearchListResult key={node.value.id} node={node.value} onSelect={handleSelect} />)
101
+ ) : (
102
+ <p className='pli-1'>{t(pending ? 'pending results message' : 'empty results message')}</p>
103
+ )
115
104
  ) : (
116
- <p className='pli-1'>{t(pending ? 'pending results message' : 'empty results message')}</p>
117
- )
118
- ) : (
119
- <>
120
- {closed.length > 0 && <h2 className={mx('mlb-1', descriptionText)}>{t('recently closed heading')}</h2>}
121
- {closed.filter(Option.isSome).map((node) => (
122
- <SearchListResult key={node.value.id} node={node.value} onSelect={handleSelect} />
123
- ))}
124
- </>
125
- )}
105
+ <>
106
+ {closed.length > 0 && <h2 className={mx('mlb-1', descriptionText)}>{t('recently closed heading')}</h2>}
107
+ {closed.filter(Option.isSome).map((node) => (
108
+ <SearchListResult key={node.value.id} node={node.value} onSelect={handleSelect} />
109
+ ))}
110
+ </>
111
+ )}
112
+ </SearchList.Viewport>
126
113
  </SearchList.Content>
127
114
  </SearchList.Root>
128
-
129
115
  <Dialog.Close asChild>
130
- <Button variant='primary' classNames='mbs-2'>
131
- {t('close label', { ns: 'os' })}
132
- </Button>
116
+ <Button variant='primary'>{t('close label', { ns: osTranslations })}</Button>
133
117
  </Dialog.Close>
134
118
  </Dialog.Content>
135
119
  );