@dxos/plugin-search 0.8.4-main.406dc2a → 0.8.4-main.52d7546f51

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 (128) 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-5N6LDSFF.mjs → chunk-HRIWTRJV.mjs} +6 -2
  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-ZRJJXRGF.mjs +282 -0
  8. package/dist/lib/browser/chunk-ZRJJXRGF.mjs.map +7 -0
  9. package/dist/lib/browser/index.mjs +52 -57
  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 +4 -5
  34. package/dist/types/src/components/SearchMain.d.ts.map +1 -1
  35. package/dist/types/src/components/SearchMain.stories.d.ts +31 -0
  36. package/dist/types/src/components/SearchMain.stories.d.ts.map +1 -0
  37. package/dist/types/src/components/SpaceMain.d.ts +9 -0
  38. package/dist/types/src/components/SpaceMain.d.ts.map +1 -0
  39. package/dist/types/src/components/index.d.ts +1 -1
  40. package/dist/types/src/components/index.d.ts.map +1 -1
  41. package/dist/types/src/hooks/index.d.ts +1 -0
  42. package/dist/types/src/hooks/index.d.ts.map +1 -1
  43. package/dist/types/src/hooks/sync.d.ts +3 -2
  44. package/dist/types/src/hooks/sync.d.ts.map +1 -1
  45. package/dist/types/src/hooks/useGlobalSearch.d.ts +7 -3
  46. package/dist/types/src/hooks/useGlobalSearch.d.ts.map +1 -1
  47. package/dist/types/src/hooks/useSearchResults.d.ts +3 -2
  48. package/dist/types/src/hooks/useSearchResults.d.ts.map +1 -1
  49. package/dist/types/src/hooks/useWebSearch.d.ts +6 -3
  50. package/dist/types/src/hooks/useWebSearch.d.ts.map +1 -1
  51. package/dist/types/src/meta.d.ts +2 -2
  52. package/dist/types/src/meta.d.ts.map +1 -1
  53. package/dist/types/src/search/exa.d.ts +3 -1
  54. package/dist/types/src/search/exa.d.ts.map +1 -1
  55. package/dist/types/src/translations.d.ts +1 -1
  56. package/dist/types/src/types/action.d.ts +13 -10
  57. package/dist/types/src/types/action.d.ts.map +1 -1
  58. package/dist/types/src/types/search.d.ts +3 -7
  59. package/dist/types/src/types/search.d.ts.map +1 -1
  60. package/dist/types/tsconfig.tsbuildinfo +1 -1
  61. package/package.json +54 -45
  62. package/src/SearchPlugin.tsx +25 -42
  63. package/src/capabilities/app-graph-builder/app-graph-builder.ts +71 -0
  64. package/src/capabilities/app-graph-builder/index.ts +7 -0
  65. package/src/capabilities/index.ts +3 -5
  66. package/src/capabilities/operation-resolver/index.ts +7 -0
  67. package/src/capabilities/operation-resolver/operation-resolver.ts +24 -0
  68. package/src/capabilities/react-surface/index.ts +7 -0
  69. package/src/capabilities/react-surface/react-surface.tsx +71 -0
  70. package/src/components/SearchDialog.tsx +56 -60
  71. package/src/components/SearchMain.stories.tsx +90 -0
  72. package/src/components/SearchMain.tsx +65 -48
  73. package/src/components/SpaceMain.tsx +172 -0
  74. package/src/components/index.ts +1 -1
  75. package/src/hooks/index.ts +2 -0
  76. package/src/hooks/sync.test.ts +6 -4
  77. package/src/hooks/sync.ts +25 -30
  78. package/src/hooks/useGlobalSearch.tsx +31 -12
  79. package/src/hooks/useSearchResults.ts +7 -4
  80. package/src/hooks/useWebSearch.ts +20 -9
  81. package/src/meta.ts +7 -3
  82. package/src/search/exa.test.ts +9 -11
  83. package/src/search/exa.ts +6 -5
  84. package/src/translations.ts +1 -1
  85. package/src/types/action.tsx +8 -6
  86. package/src/types/command-score.d.ts +16 -0
  87. package/src/types/search.ts +3 -9
  88. package/dist/lib/browser/app-graph-builder-YME7SN7O.mjs +0 -78
  89. package/dist/lib/browser/app-graph-builder-YME7SN7O.mjs.map +0 -7
  90. package/dist/lib/browser/chunk-5N6LDSFF.mjs.map +0 -7
  91. package/dist/lib/browser/chunk-WN3TVQLV.mjs +0 -190
  92. package/dist/lib/browser/chunk-WN3TVQLV.mjs.map +0 -7
  93. package/dist/lib/browser/chunk-YJGHPWUO.mjs +0 -21
  94. package/dist/lib/browser/chunk-YJGHPWUO.mjs.map +0 -7
  95. package/dist/lib/browser/intent-resolver-XNVR4XRX.mjs +0 -22
  96. package/dist/lib/browser/intent-resolver-XNVR4XRX.mjs.map +0 -7
  97. package/dist/lib/browser/react-surface-YOGLADC4.mjs +0 -470
  98. package/dist/lib/browser/react-surface-YOGLADC4.mjs.map +0 -7
  99. package/dist/types/src/capabilities/app-graph-builder.d.ts +0 -4
  100. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +0 -1
  101. package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
  102. package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
  103. package/dist/types/src/capabilities/react-surface.d.ts +0 -4
  104. package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
  105. package/dist/types/src/components/Search.stories.d.ts +0 -19
  106. package/dist/types/src/components/Search.stories.d.ts.map +0 -1
  107. package/dist/types/src/components/SearchResults/SearchResults.d.ts +0 -20
  108. package/dist/types/src/components/SearchResults/SearchResults.d.ts.map +0 -1
  109. package/dist/types/src/components/SearchResults/SearchResults.stories.d.ts +0 -16
  110. package/dist/types/src/components/SearchResults/SearchResults.stories.d.ts.map +0 -1
  111. package/dist/types/src/components/SearchResults/index.d.ts +0 -2
  112. package/dist/types/src/components/SearchResults/index.d.ts.map +0 -1
  113. package/dist/types/src/components/Searchbar/Searchbar.d.ts +0 -14
  114. package/dist/types/src/components/Searchbar/Searchbar.d.ts.map +0 -1
  115. package/dist/types/src/components/Searchbar/Searchbar.stories.d.ts +0 -13
  116. package/dist/types/src/components/Searchbar/Searchbar.stories.d.ts.map +0 -1
  117. package/dist/types/src/components/Searchbar/index.d.ts +0 -2
  118. package/dist/types/src/components/Searchbar/index.d.ts.map +0 -1
  119. package/src/capabilities/app-graph-builder.ts +0 -80
  120. package/src/capabilities/intent-resolver.ts +0 -18
  121. package/src/capabilities/react-surface.tsx +0 -59
  122. package/src/components/Search.stories.tsx +0 -67
  123. package/src/components/SearchResults/SearchResults.stories.tsx +0 -58
  124. package/src/components/SearchResults/SearchResults.tsx +0 -86
  125. package/src/components/SearchResults/index.ts +0 -5
  126. package/src/components/Searchbar/Searchbar.stories.tsx +0 -28
  127. package/src/components/Searchbar/Searchbar.tsx +0 -67
  128. 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.406dc2a",
4
- "description": "Braneframe sketch plugin",
3
+ "version": "0.8.4-main.52d7546f51",
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,64 +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.406dc2a",
31
- "@dxos/assistant": "0.8.4-main.406dc2a",
32
- "@dxos/debug": "0.8.4-main.406dc2a",
33
- "@dxos/app-framework": "0.8.4-main.406dc2a",
34
- "@dxos/echo": "0.8.4-main.406dc2a",
35
- "@dxos/blueprints": "0.8.4-main.406dc2a",
36
- "@dxos/echo-protocol": "0.8.4-main.406dc2a",
37
- "@dxos/live-object": "0.8.4-main.406dc2a",
38
- "@dxos/invariant": "0.8.4-main.406dc2a",
39
- "@dxos/log": "0.8.4-main.406dc2a",
40
- "@dxos/effect": "0.8.4-main.406dc2a",
41
- "@dxos/plugin-deck": "0.8.4-main.406dc2a",
42
- "@dxos/plugin-graph": "0.8.4-main.406dc2a",
43
- "@dxos/plugin-client": "0.8.4-main.406dc2a",
44
- "@dxos/plugin-space": "0.8.4-main.406dc2a",
45
- "@dxos/react-client": "0.8.4-main.406dc2a",
46
- "@dxos/schema": "0.8.4-main.406dc2a",
47
- "@dxos/react-ui-searchlist": "0.8.4-main.406dc2a",
48
- "@dxos/util": "0.8.4-main.406dc2a",
49
- "@dxos/react-ui-stack": "0.8.4-main.406dc2a"
31
+ "@dxos/app-toolkit": "0.8.4-main.52d7546f51",
32
+ "@dxos/ai": "0.8.4-main.52d7546f51",
33
+ "@dxos/app-framework": "0.8.4-main.52d7546f51",
34
+ "@dxos/assistant": "0.8.4-main.52d7546f51",
35
+ "@dxos/async": "0.8.4-main.52d7546f51",
36
+ "@dxos/blueprints": "0.8.4-main.52d7546f51",
37
+ "@dxos/debug": "0.8.4-main.52d7546f51",
38
+ "@dxos/echo": "0.8.4-main.52d7546f51",
39
+ "@dxos/echo-protocol": "0.8.4-main.52d7546f51",
40
+ "@dxos/echo-query": "0.8.4-main.52d7546f51",
41
+ "@dxos/invariant": "0.8.4-main.52d7546f51",
42
+ "@dxos/effect": "0.8.4-main.52d7546f51",
43
+ "@dxos/log": "0.8.4-main.52d7546f51",
44
+ "@dxos/plugin-deck": "0.8.4-main.52d7546f51",
45
+ "@dxos/plugin-graph": "0.8.4-main.52d7546f51",
46
+ "@dxos/plugin-client": "0.8.4-main.52d7546f51",
47
+ "@dxos/react-ui-components": "0.8.4-main.52d7546f51",
48
+ "@dxos/react-ui-mosaic": "0.8.4-main.52d7546f51",
49
+ "@dxos/plugin-space": "0.8.4-main.52d7546f51",
50
+ "@dxos/react-client": "0.8.4-main.52d7546f51",
51
+ "@dxos/react-ui-stack": "0.8.4-main.52d7546f51",
52
+ "@dxos/schema": "0.8.4-main.52d7546f51",
53
+ "@dxos/types": "0.8.4-main.52d7546f51",
54
+ "@dxos/react-ui-searchlist": "0.8.4-main.52d7546f51",
55
+ "@dxos/util": "0.8.4-main.52d7546f51",
56
+ "@dxos/operation": "0.8.4-main.52d7546f51"
50
57
  },
51
58
  "devDependencies": {
52
- "@effect-rx/rx-react": "0.42.4",
53
- "@effect/platform": "0.92.1",
54
- "@types/react": "~19.2.2",
55
- "@types/react-dom": "~19.2.1",
56
- "effect": "3.18.3",
57
- "react": "~19.2.0",
58
- "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",
59
66
  "vite": "7.1.9",
60
- "@dxos/react-ui": "0.8.4-main.406dc2a",
61
- "@dxos/storybook-utils": "0.8.4-main.406dc2a",
62
- "@dxos/random": "0.8.4-main.406dc2a",
63
- "@dxos/react-ui-theme": "0.8.4-main.406dc2a"
67
+ "@dxos/plugin-preview": "0.8.4-main.52d7546f51",
68
+ "@dxos/plugin-testing": "0.8.4-main.52d7546f51",
69
+ "@dxos/random": "0.8.4-main.52d7546f51",
70
+ "@dxos/react-ui": "0.8.4-main.52d7546f51",
71
+ "@dxos/storybook-utils": "0.8.4-main.52d7546f51",
72
+ "@dxos/ui-theme": "0.8.4-main.52d7546f51"
64
73
  },
65
74
  "peerDependencies": {
66
- "@effect-rx/rx-react": "^0.34.1",
67
- "@effect/platform": "^0.80.12",
68
- "effect": "^3.13.3",
69
- "react": "^19.0.0",
70
- "react-dom": "^19.0.0",
71
- "@dxos/react-ui": "0.8.4-main.406dc2a",
72
- "@dxos/react-ui-theme": "0.8.4-main.406dc2a"
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.52d7546f51",
81
+ "@dxos/ui-theme": "0.8.4-main.52d7546f51"
73
82
  },
74
83
  "publishConfig": {
75
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,13 +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, useAppGraph, useIntentDispatcher, useLayout } from '@dxos/app-framework';
9
- import { type Node } from '@dxos/plugin-graph';
8
+ import { useOperationInvoker } from '@dxos/app-framework/ui';
9
+ import { LayoutOperation } from '@dxos/app-toolkit';
10
+ import { useAppGraph, useLayout } from '@dxos/app-toolkit/ui';
11
+ import { Obj } from '@dxos/echo';
12
+ import { Graph, type Node } from '@dxos/plugin-graph';
10
13
  import { useClient } from '@dxos/react-client';
11
- import { Filter, fullyQualifiedId, useQuery } from '@dxos/react-client/echo';
12
- import { Button, Dialog, Icon, toLocalizedString, useTranslation } from '@dxos/react-ui';
13
- import { SearchList, type SearchListItemProps } from '@dxos/react-ui-searchlist';
14
- import { descriptionText, mx } from '@dxos/react-ui-theme';
14
+ import { Filter, useQuery } from '@dxos/react-client/echo';
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';
15
18
 
16
19
  import { useSearchResults } from '../hooks';
17
20
  import { meta } from '../meta';
@@ -19,23 +22,25 @@ import { meta } from '../meta';
19
22
  export const SEARCH_DIALOG = `${meta.id}/SearchDialog`;
20
23
 
21
24
  type SearchListResultProps = {
22
- node: Node;
23
- } & Pick<SearchListItemProps, 'onSelect'>;
25
+ node: Node.Node;
26
+ onSelect?: (nodeId: string) => void;
27
+ };
24
28
 
25
29
  const SearchListResult = forwardRef<HTMLDivElement, SearchListResultProps>(({ node, onSelect }, forwardedRef) => {
26
30
  const { t } = useTranslation(meta.id);
27
31
  const label = toLocalizedString(node?.properties.label ?? 'never', t);
32
+ const handleSelect = useCallback(() => {
33
+ onSelect?.(node!.id);
34
+ }, [node, onSelect]);
28
35
  return (
29
36
  <SearchList.Item
30
- value={label}
31
- key={node!.id}
37
+ value={node!.id}
38
+ label={label}
39
+ icon={node?.properties.icon}
32
40
  classNames='flex gap-2 items-center pli-2'
33
- onSelect={() => onSelect?.(node!.id)}
41
+ onSelect={handleSelect}
34
42
  ref={forwardedRef}
35
- >
36
- <Icon size={5} icon={node?.properties.icon} />
37
- <span className='is-0 grow truncate'>{label}</span>
38
- </SearchList.Item>
43
+ />
39
44
  );
40
45
  });
41
46
 
@@ -48,76 +53,67 @@ export const SearchDialog = ({ pivotId }: SearchDialogProps) => {
48
53
  const { graph } = useAppGraph();
49
54
  const layout = useLayout();
50
55
  const closed = (Array.isArray(layout.inactive) ? layout.inactive : [layout.inactive])
51
- .map((id) => graph?.getNode(id))
56
+ .map((id) => (graph ? Graph.getNode(graph, id) : Option.none()))
52
57
  .filter(Boolean);
53
58
  const [queryString, setQueryString] = useState('');
54
59
  const client = useClient();
55
60
  const dangerouslyLoadAllObjects = useQuery(client.spaces, Filter.everything());
56
61
  const [pending, results] = useSearchResults(queryString, dangerouslyLoadAllObjects);
57
62
  const resultObjects = Array.from(results.keys());
58
- const { dispatchPromise: dispatch } = useIntentDispatcher();
63
+ const { invokePromise } = useOperationInvoker();
59
64
 
60
65
  const handleSelect = useCallback(
61
66
  async (nodeId: string) => {
62
- await dispatch(createIntent(LayoutAction.UpdateDialog, { part: 'dialog', options: { state: false } }));
67
+ await invokePromise(LayoutOperation.UpdateDialog, { state: false });
63
68
 
64
69
  // If node is already present in the active parts, scroll to it and close the dialog.
65
70
  const index = layout.active.findIndex((id) => id === nodeId);
66
71
  if (index !== -1) {
67
- await dispatch(createIntent(LayoutAction.ScrollIntoView, { part: 'current', subject: nodeId }));
72
+ await invokePromise(LayoutOperation.ScrollIntoView, { subject: nodeId });
68
73
  } else {
69
- await dispatch(
70
- createIntent(LayoutAction.Open, {
71
- part: 'main',
72
- subject: [nodeId],
73
- options: {
74
- pivotId,
75
- positioning: 'end',
76
- },
77
- }),
78
- );
74
+ await invokePromise(LayoutOperation.Open, {
75
+ subject: [nodeId],
76
+ pivotId,
77
+ positioning: 'end',
78
+ });
79
79
  }
80
80
  },
81
- [pivotId, dispatch, layout],
81
+ [pivotId, invokePromise, layout],
82
82
  );
83
83
 
84
+ const handleSearch = useCallback((query: string) => {
85
+ setQueryString(query);
86
+ }, []);
87
+
84
88
  return (
85
- <Dialog.Content classNames={['md:max-is-[24rem] overflow-hidden mbs-12']}>
89
+ <Dialog.Content>
86
90
  <Dialog.Title>{t('search dialog title')}</Dialog.Title>
87
- <SearchList.Root label={t('search placeholder')} classNames='flex flex-col grow overflow-hidden my-2'>
88
- <SearchList.Input
89
- value={queryString}
90
- onValueChange={(nextValue) => {
91
- setQueryString(nextValue);
92
- }}
93
- placeholder={t('search placeholder')}
94
- classNames='px-1 my-2'
95
- />
91
+ <SearchList.Root onSearch={handleSearch}>
96
92
  <SearchList.Content classNames='max-bs-[24rem] overflow-auto'>
97
- {queryString.length > 0 ? (
98
- resultObjects.length > 0 ? (
99
- resultObjects
100
- .map((object) => graph.getNode(fullyQualifiedId(object)))
101
- .filter(Option.isSome)
102
- .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
+ )
103
104
  ) : (
104
- <p className='pli-1'>{t(pending ? 'pending results message' : 'empty results message')}</p>
105
- )
106
- ) : (
107
- <>
108
- {closed.length > 0 && <h2 className={mx('mlb-1', descriptionText)}>{t('recently closed heading')}</h2>}
109
- {closed.filter(Option.isSome).map((node) => (
110
- <SearchListResult key={node.value.id} node={node.value} onSelect={handleSelect} />
111
- ))}
112
- </>
113
- )}
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>
114
113
  </SearchList.Content>
115
114
  </SearchList.Root>
116
-
117
115
  <Dialog.Close asChild>
118
- <Button variant='primary' classNames='mbs-2'>
119
- {t('close label', { ns: 'os' })}
120
- </Button>
116
+ <Button variant='primary'>{t('close label', { ns: osTranslations })}</Button>
121
117
  </Dialog.Close>
122
118
  </Dialog.Content>
123
119
  );