@dxos/plugin-search 0.8.4-main.b97322e → 0.8.4-main.bc674ce

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