@dxos/plugin-search 0.8.4-main.67995b8 → 0.8.4-main.a4bbb77

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 (66) hide show
  1. package/dist/lib/browser/{app-graph-builder-FLW7KDC5.mjs → app-graph-builder-GWNVDUTC.mjs} +11 -11
  2. package/dist/lib/browser/app-graph-builder-GWNVDUTC.mjs.map +7 -0
  3. package/dist/lib/browser/{chunk-KNS62YL2.mjs → chunk-5N6LDSFF.mjs} +5 -7
  4. package/dist/lib/browser/chunk-5N6LDSFF.mjs.map +7 -0
  5. package/dist/lib/browser/{chunk-JVMYGOKS.mjs → chunk-NDOA4O75.mjs} +4 -4
  6. package/dist/lib/browser/chunk-NDOA4O75.mjs.map +7 -0
  7. package/dist/lib/browser/{chunk-BXSF7IAU.mjs → chunk-YJGLEPHU.mjs} +3 -3
  8. package/dist/lib/browser/{chunk-BXSF7IAU.mjs.map → chunk-YJGLEPHU.mjs.map} +3 -3
  9. package/dist/lib/browser/index.mjs +8 -10
  10. package/dist/lib/browser/index.mjs.map +3 -3
  11. package/dist/lib/browser/intent-resolver-2JXJD6Q3.mjs +22 -0
  12. package/dist/lib/browser/{intent-resolver-JPBGEKFT.mjs.map → intent-resolver-2JXJD6Q3.mjs.map} +3 -3
  13. package/dist/lib/browser/meta.json +1 -1
  14. package/dist/lib/browser/{react-surface-ETKK5YS3.mjs → react-surface-GWNMYPYS.mjs} +95 -275
  15. package/dist/lib/browser/react-surface-GWNMYPYS.mjs.map +7 -0
  16. package/dist/types/src/SearchPlugin.d.ts +1 -1
  17. package/dist/types/src/SearchPlugin.d.ts.map +1 -1
  18. package/dist/types/src/capabilities/app-graph-builder.d.ts +1 -1
  19. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
  20. package/dist/types/src/capabilities/index.d.ts +3 -3
  21. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  22. package/dist/types/src/capabilities/intent-resolver.d.ts +1 -1
  23. package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
  24. package/dist/types/src/capabilities/react-surface.d.ts +1 -1
  25. package/dist/types/src/components/Search.stories.d.ts +15 -11
  26. package/dist/types/src/components/Search.stories.d.ts.map +1 -1
  27. package/dist/types/src/components/SearchDialog.d.ts +1 -1
  28. package/dist/types/src/components/SearchDialog.d.ts.map +1 -1
  29. package/dist/types/src/components/SearchMain.d.ts.map +1 -1
  30. package/dist/types/src/components/SearchResults/SearchResults.stories.d.ts +12 -8
  31. package/dist/types/src/components/SearchResults/SearchResults.stories.d.ts.map +1 -1
  32. package/dist/types/src/components/Searchbar/Searchbar.d.ts.map +1 -1
  33. package/dist/types/src/components/Searchbar/Searchbar.stories.d.ts +10 -8
  34. package/dist/types/src/components/Searchbar/Searchbar.stories.d.ts.map +1 -1
  35. package/dist/types/src/hooks/useGlobalSearch.d.ts.map +1 -1
  36. package/dist/types/src/hooks/useWebSearch.d.ts.map +1 -1
  37. package/dist/types/src/meta.d.ts +1 -2
  38. package/dist/types/src/meta.d.ts.map +1 -1
  39. package/dist/types/src/search/exa.d.ts +0 -2
  40. package/dist/types/src/search/exa.d.ts.map +1 -1
  41. package/dist/types/src/types/action.d.ts +2 -2
  42. package/dist/types/tsconfig.tsbuildinfo +1 -1
  43. package/package.json +40 -40
  44. package/src/SearchPlugin.tsx +43 -44
  45. package/src/capabilities/app-graph-builder.ts +7 -7
  46. package/src/capabilities/intent-resolver.ts +1 -1
  47. package/src/capabilities/react-surface.tsx +1 -1
  48. package/src/components/Search.stories.tsx +14 -13
  49. package/src/components/SearchDialog.tsx +4 -4
  50. package/src/components/SearchMain.tsx +6 -5
  51. package/src/components/SearchResults/SearchResults.stories.tsx +18 -17
  52. package/src/components/Searchbar/Searchbar.stories.tsx +8 -8
  53. package/src/components/Searchbar/Searchbar.tsx +1 -1
  54. package/src/hooks/sync.test.ts +1 -1
  55. package/src/hooks/useGlobalSearch.tsx +3 -2
  56. package/src/hooks/useSearchResults.ts +2 -2
  57. package/src/hooks/useWebSearch.ts +1 -2
  58. package/src/meta.ts +3 -4
  59. package/src/search/exa.test.ts +2 -11
  60. package/src/search/exa.ts +127 -149
  61. package/src/types/action.tsx +2 -2
  62. package/dist/lib/browser/app-graph-builder-FLW7KDC5.mjs.map +0 -7
  63. package/dist/lib/browser/chunk-JVMYGOKS.mjs.map +0 -7
  64. package/dist/lib/browser/chunk-KNS62YL2.mjs.map +0 -7
  65. package/dist/lib/browser/intent-resolver-JPBGEKFT.mjs +0 -22
  66. package/dist/lib/browser/react-surface-ETKK5YS3.mjs.map +0 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/plugin-search",
3
- "version": "0.8.4-main.67995b8",
3
+ "version": "0.8.4-main.a4bbb77",
4
4
  "description": "Braneframe sketch plugin",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -10,9 +10,9 @@
10
10
  "type": "module",
11
11
  "exports": {
12
12
  ".": {
13
+ "source": "./src/index.ts",
13
14
  "types": "./dist/types/src/index.d.ts",
14
- "browser": "./dist/lib/browser/index.mjs",
15
- "source": "./src/index.ts"
15
+ "browser": "./dist/lib/browser/index.mjs"
16
16
  }
17
17
  },
18
18
  "types": "dist/types/src/index.d.ts",
@@ -27,50 +27,50 @@
27
27
  "@preact-signals/safe-react": "^0.9.0",
28
28
  "exa-js": "^1.5.12",
29
29
  "main-thread-scheduling": "^14.1.1",
30
- "@dxos/ai": "0.8.4-main.67995b8",
31
- "@dxos/app-framework": "0.8.4-main.67995b8",
32
- "@dxos/assistant": "0.8.4-main.67995b8",
33
- "@dxos/blueprints": "0.8.4-main.67995b8",
34
- "@dxos/debug": "0.8.4-main.67995b8",
35
- "@dxos/echo": "0.8.4-main.67995b8",
36
- "@dxos/echo-schema": "0.8.4-main.67995b8",
37
- "@dxos/echo-protocol": "0.8.4-main.67995b8",
38
- "@dxos/effect": "0.8.4-main.67995b8",
39
- "@dxos/invariant": "0.8.4-main.67995b8",
40
- "@dxos/log": "0.8.4-main.67995b8",
41
- "@dxos/plugin-client": "0.8.4-main.67995b8",
42
- "@dxos/live-object": "0.8.4-main.67995b8",
43
- "@dxos/plugin-graph": "0.8.4-main.67995b8",
44
- "@dxos/plugin-deck": "0.8.4-main.67995b8",
45
- "@dxos/plugin-space": "0.8.4-main.67995b8",
46
- "@dxos/react-client": "0.8.4-main.67995b8",
47
- "@dxos/react-ui-searchlist": "0.8.4-main.67995b8",
48
- "@dxos/react-ui-stack": "0.8.4-main.67995b8",
49
- "@dxos/schema": "0.8.4-main.67995b8",
50
- "@dxos/util": "0.8.4-main.67995b8"
30
+ "@dxos/ai": "0.8.4-main.a4bbb77",
31
+ "@dxos/app-framework": "0.8.4-main.a4bbb77",
32
+ "@dxos/assistant": "0.8.4-main.a4bbb77",
33
+ "@dxos/debug": "0.8.4-main.a4bbb77",
34
+ "@dxos/blueprints": "0.8.4-main.a4bbb77",
35
+ "@dxos/echo": "0.8.4-main.a4bbb77",
36
+ "@dxos/echo-protocol": "0.8.4-main.a4bbb77",
37
+ "@dxos/echo-schema": "0.8.4-main.a4bbb77",
38
+ "@dxos/effect": "0.8.4-main.a4bbb77",
39
+ "@dxos/invariant": "0.8.4-main.a4bbb77",
40
+ "@dxos/live-object": "0.8.4-main.a4bbb77",
41
+ "@dxos/log": "0.8.4-main.a4bbb77",
42
+ "@dxos/plugin-client": "0.8.4-main.a4bbb77",
43
+ "@dxos/plugin-deck": "0.8.4-main.a4bbb77",
44
+ "@dxos/plugin-graph": "0.8.4-main.a4bbb77",
45
+ "@dxos/plugin-space": "0.8.4-main.a4bbb77",
46
+ "@dxos/react-client": "0.8.4-main.a4bbb77",
47
+ "@dxos/react-ui-searchlist": "0.8.4-main.a4bbb77",
48
+ "@dxos/schema": "0.8.4-main.a4bbb77",
49
+ "@dxos/react-ui-stack": "0.8.4-main.a4bbb77",
50
+ "@dxos/util": "0.8.4-main.a4bbb77"
51
51
  },
52
52
  "devDependencies": {
53
- "@effect-rx/rx-react": "0.38.0",
54
- "@effect/platform": "0.89.0",
55
- "@types/react": "~18.2.0",
56
- "@types/react-dom": "~18.2.0",
57
- "effect": "3.17.0",
58
- "react": "~18.2.0",
59
- "react-dom": "~18.2.0",
60
- "vite": "5.4.7",
61
- "@dxos/react-ui": "0.8.4-main.67995b8",
62
- "@dxos/react-ui-theme": "0.8.4-main.67995b8",
63
- "@dxos/random": "0.8.4-main.67995b8",
64
- "@dxos/storybook-utils": "0.8.4-main.67995b8"
53
+ "@effect-rx/rx-react": "0.42.4",
54
+ "@effect/platform": "0.92.1",
55
+ "@types/react": "~19.2.0",
56
+ "@types/react-dom": "~19.2.0",
57
+ "effect": "3.18.3",
58
+ "react": "~19.2.0",
59
+ "react-dom": "~19.2.0",
60
+ "vite": "7.1.9",
61
+ "@dxos/random": "0.8.4-main.a4bbb77",
62
+ "@dxos/react-ui": "0.8.4-main.a4bbb77",
63
+ "@dxos/react-ui-theme": "0.8.4-main.a4bbb77",
64
+ "@dxos/storybook-utils": "0.8.4-main.a4bbb77"
65
65
  },
66
66
  "peerDependencies": {
67
67
  "@effect-rx/rx-react": "^0.34.1",
68
68
  "@effect/platform": "^0.80.12",
69
69
  "effect": "^3.13.3",
70
- "react": "~18.2.0",
71
- "react-dom": "~18.2.0",
72
- "@dxos/react-ui": "0.8.4-main.67995b8",
73
- "@dxos/react-ui-theme": "0.8.4-main.67995b8"
70
+ "react": "^19.0.0",
71
+ "react-dom": "^19.0.0",
72
+ "@dxos/react-ui": "0.8.4-main.a4bbb77",
73
+ "@dxos/react-ui-theme": "0.8.4-main.a4bbb77"
74
74
  },
75
75
  "publishConfig": {
76
76
  "access": "public"
@@ -2,53 +2,52 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { contributes, Events, defineModule, definePlugin, Capabilities } from '@dxos/app-framework';
5
+ import { Capabilities, Events, contributes, defineModule, definePlugin } from '@dxos/app-framework';
6
6
 
7
7
  import { AppGraphBuilder, IntentResolver, ReactSurface } from './capabilities';
8
- import { meta, SEARCH_RESULT } from './meta';
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
- },
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
+ }
36
34
  },
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
- ]);
35
+ },
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,
52
+ }),
53
+ ]);
@@ -5,19 +5,19 @@
5
5
  import { Rx } from '@effect-rx/rx-react';
6
6
  import { Option, pipe } from 'effect';
7
7
 
8
- import { Capabilities, contributes, createIntent, type PluginContext } from '@dxos/app-framework';
8
+ import { Capabilities, type PluginContext, contributes, createIntent } from '@dxos/app-framework';
9
9
  import { ClientCapabilities } from '@dxos/plugin-client';
10
10
  import { ATTENDABLE_PATH_SEPARATOR, DECK_COMPANION_TYPE } from '@dxos/plugin-deck/types';
11
- import { createExtension, ROOT_ID, rxFromSignal } from '@dxos/plugin-graph';
11
+ import { ROOT_ID, createExtension, rxFromSignal } from '@dxos/plugin-graph';
12
12
  import { parseId } from '@dxos/react-client/echo';
13
13
 
14
- import { SEARCH_PLUGIN } from '../meta';
14
+ import { meta } from '../meta';
15
15
  import { SearchAction } from '../types';
16
16
 
17
17
  export default (context: PluginContext) =>
18
18
  contributes(Capabilities.AppGraphBuilder, [
19
19
  createExtension({
20
- id: `${SEARCH_PLUGIN}/space-search`,
20
+ id: `${meta.id}/space-search`,
21
21
  connector: (node) =>
22
22
  Rx.make((get) =>
23
23
  pipe(
@@ -35,7 +35,7 @@ export default (context: PluginContext) =>
35
35
  type: DECK_COMPANION_TYPE,
36
36
  data: space,
37
37
  properties: {
38
- label: ['search label', { ns: SEARCH_PLUGIN }],
38
+ label: ['search label', { ns: meta.id }],
39
39
  icon: 'ph--magnifying-glass--regular',
40
40
  disposition: 'hidden',
41
41
  },
@@ -47,7 +47,7 @@ export default (context: PluginContext) =>
47
47
  ),
48
48
  }),
49
49
  createExtension({
50
- id: SEARCH_PLUGIN,
50
+ id: meta.id,
51
51
  actions: (node) =>
52
52
  Rx.make((get) =>
53
53
  pipe(
@@ -62,7 +62,7 @@ export default (context: PluginContext) =>
62
62
  await dispatch(createIntent(SearchAction.OpenSearch));
63
63
  },
64
64
  properties: {
65
- label: ['search action label', { ns: SEARCH_PLUGIN }],
65
+ label: ['search action label', { ns: meta.id }],
66
66
  icon: 'ph--magnifying-glass--regular',
67
67
  keyBinding: {
68
68
  macos: 'shift+meta+f',
@@ -2,7 +2,7 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { contributes, Capabilities, createResolver, LayoutAction, createIntent } from '@dxos/app-framework';
5
+ import { Capabilities, LayoutAction, contributes, createIntent, createResolver } from '@dxos/app-framework';
6
6
 
7
7
  import { SearchAction } from '../types';
8
8
 
@@ -6,7 +6,7 @@ import React from 'react';
6
6
 
7
7
  import { Capabilities, contributes, createSurface } from '@dxos/app-framework';
8
8
  import { useActiveSpace } from '@dxos/plugin-space';
9
- import { isSpace, type Space } from '@dxos/react-client/echo';
9
+ import { type Space, isSpace } from '@dxos/react-client/echo';
10
10
 
11
11
  import { SEARCH_DIALOG, SearchDialog, type SearchDialogProps, SearchMain } from '../components';
12
12
  import { SearchContextProvider } from '../hooks';
@@ -2,18 +2,17 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import '@dxos-theme';
6
-
7
- import { type Meta, type Decorator, type StoryFn } from '@storybook/react-vite';
5
+ import { type Decorator, type Meta, type StoryObj } from '@storybook/react-vite';
8
6
  import React, { useState } from 'react';
9
7
 
10
8
  import { faker } from '@dxos/random';
11
- import { withLayout, withTheme } from '@dxos/storybook-utils';
9
+ import { withTheme } from '@dxos/react-ui/testing';
12
10
 
13
- import { SearchResults } from './SearchResults';
14
- import { Searchbar, type SearchbarProps } from './Searchbar';
15
11
  import { SearchContextProvider, useGlobalSearch, useGlobalSearchResults } from '../hooks';
16
12
 
13
+ import { Searchbar, type SearchbarProps } from './Searchbar';
14
+ import { SearchResults } from './SearchResults';
15
+
17
16
  faker.seed(1);
18
17
 
19
18
  type StoryProps = SearchbarProps & {
@@ -35,15 +34,15 @@ const DefaultStory = ({ objects, ...props }: StoryProps) => {
35
34
  );
36
35
  };
37
36
 
38
- const SearchContextDecorator = (): Decorator => {
39
- return (Story: StoryFn) => (
37
+ const withSearchContext = (): Decorator => {
38
+ return (Story) => (
40
39
  <SearchContextProvider>
41
40
  <Story />
42
41
  </SearchContextProvider>
43
42
  );
44
43
  };
45
44
 
46
- export const Default = {
45
+ export const Default: Story = {
47
46
  args: {
48
47
  objects: Array.from({ length: 8 }).map(() => ({
49
48
  id: faker.string.uuid(),
@@ -53,14 +52,16 @@ export const Default = {
53
52
  },
54
53
  };
55
54
 
56
- const meta: Meta<typeof Searchbar> = {
55
+ const meta = {
57
56
  title: 'plugins/plugin-search/Search',
58
57
  component: Searchbar,
59
58
  render: DefaultStory,
60
- decorators: [withTheme, withLayout({ fullscreen: true }), SearchContextDecorator()],
59
+ decorators: [withTheme, withSearchContext()],
61
60
  parameters: {
62
- layout: 'fullscreen',
61
+ layout: 'column',
63
62
  },
64
- };
63
+ } satisfies Meta<typeof Searchbar>;
65
64
 
66
65
  export default meta;
66
+
67
+ type Story = StoryObj<typeof meta>;
@@ -14,16 +14,16 @@ import { SearchList, type SearchListItemProps } from '@dxos/react-ui-searchlist'
14
14
  import { descriptionText, mx } from '@dxos/react-ui-theme';
15
15
 
16
16
  import { useSearchResults } from '../hooks';
17
- import { SEARCH_PLUGIN } from '../meta';
17
+ import { meta } from '../meta';
18
18
 
19
- export const SEARCH_DIALOG = `${SEARCH_PLUGIN}/SearchDialog`;
19
+ export const SEARCH_DIALOG = `${meta.id}/SearchDialog`;
20
20
 
21
21
  type SearchListResultProps = {
22
22
  node: Node;
23
23
  } & Pick<SearchListItemProps, 'onSelect'>;
24
24
 
25
25
  const SearchListResult = forwardRef<HTMLDivElement, SearchListResultProps>(({ node, onSelect }, forwardedRef) => {
26
- const { t } = useTranslation(SEARCH_PLUGIN);
26
+ const { t } = useTranslation(meta.id);
27
27
  const label = toLocalizedString(node?.properties.label ?? 'never', t);
28
28
  return (
29
29
  <SearchList.Item
@@ -44,7 +44,7 @@ export type SearchDialogProps = {
44
44
  };
45
45
 
46
46
  export const SearchDialog = ({ pivotId }: SearchDialogProps) => {
47
- const { t } = useTranslation(SEARCH_PLUGIN);
47
+ const { t } = useTranslation(meta.id);
48
48
  const { graph } = useAppGraph();
49
49
  const layout = useLayout();
50
50
  const closed = (Array.isArray(layout.inactive) ? layout.inactive : [layout.inactive])
@@ -6,18 +6,19 @@ import React, { type FC, useState } from 'react';
6
6
 
7
7
  import { log } from '@dxos/log';
8
8
  import { useClient } from '@dxos/react-client';
9
- import { Filter, useQuery, type Space } from '@dxos/react-client/echo';
9
+ import { Filter, type Space, useQuery } from '@dxos/react-client/echo';
10
10
  import { type ThemedClassName, useTranslation } from '@dxos/react-ui';
11
11
  import { activeSurface, mx } from '@dxos/react-ui-theme';
12
12
 
13
- import { SearchResults } from './SearchResults';
14
- import { Searchbar } from './Searchbar';
15
13
  import { useGlobalSearch, useGlobalSearchResults } from '../hooks';
16
14
  import { useWebSearch } from '../hooks/useWebSearch';
17
- import { SEARCH_PLUGIN } from '../meta';
15
+ import { meta } from '../meta';
16
+
17
+ import { Searchbar } from './Searchbar';
18
+ import { SearchResults } from './SearchResults';
18
19
 
19
20
  export const SearchMain: FC<ThemedClassName<{ space: Space }>> = ({ classNames, space }) => {
20
- const { t } = useTranslation(SEARCH_PLUGIN);
21
+ const { t } = useTranslation(meta.id);
21
22
  const client = useClient();
22
23
  const { setMatch } = useGlobalSearch();
23
24
  const [query, setQuery] = useState<string>();
@@ -2,26 +2,25 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import '@dxos-theme';
6
-
7
- import { type Meta } from '@storybook/react-vite';
5
+ import { type Meta, type StoryObj } from '@storybook/react-vite';
8
6
  import React, { useState } from 'react';
9
7
 
10
8
  import { faker } from '@dxos/random';
11
- import { withLayout, withTheme } from '@dxos/storybook-utils';
9
+ import { withTheme } from '@dxos/react-ui/testing';
12
10
 
13
- import { SearchResults, type SearchResultsProps } from './SearchResults';
14
11
  import { filterObjectsSync } from '../../hooks';
15
12
 
13
+ import { SearchResults, type SearchResultsProps } from './SearchResults';
14
+
16
15
  faker.seed(1);
17
16
 
18
- const DefaultStory = (args: SearchResultsProps) => {
17
+ const DefaultStory = (props: SearchResultsProps) => {
19
18
  const [selected, setSelected] = useState<string>();
20
19
 
21
20
  return (
22
21
  <div className='flex grow justify-center overflow-hidden'>
23
22
  <div className='flex w-[300px] m-4 overflow-hidden'>
24
- <SearchResults {...args} selected={selected} onSelect={setSelected} />
23
+ <SearchResults {...props} selected={selected} onSelect={setSelected} />
25
24
  </div>
26
25
  </div>
27
26
  );
@@ -37,21 +36,23 @@ const objects = Array.from({ length: 100 }).map((_, i) => ({
37
36
 
38
37
  const match = new RegExp(word, 'i');
39
38
 
40
- export const Default = {
41
- args: {
42
- items: filterObjectsSync(objects, match),
43
- match,
44
- },
45
- };
46
-
47
- const meta: Meta<typeof SearchResults> = {
39
+ const meta = {
48
40
  title: 'plugins/plugin-search/SearchResults',
49
41
  component: SearchResults,
50
42
  render: DefaultStory,
51
- decorators: [withTheme, withLayout({ fullscreen: true })],
43
+ decorators: [withTheme],
52
44
  parameters: {
53
45
  layout: 'fullscreen',
54
46
  },
55
- };
47
+ } satisfies Meta<typeof SearchResults>;
56
48
 
57
49
  export default meta;
50
+
51
+ type Story = StoryObj<typeof meta>;
52
+
53
+ export const Default: Story = {
54
+ args: {
55
+ items: filterObjectsSync(objects, match),
56
+ match,
57
+ },
58
+ };
@@ -2,26 +2,26 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import '@dxos-theme';
5
+ import { type Meta, type StoryObj } from '@storybook/react-vite';
6
6
 
7
- import { type Meta } from '@storybook/react-vite';
7
+ import { withTheme } from '@dxos/react-ui/testing';
8
8
 
9
- import { withTheme } from '@dxos/storybook-utils';
9
+ import { Searchbar } from './Searchbar';
10
10
 
11
- import { Searchbar, type SearchbarProps } from './Searchbar';
12
-
13
- const meta: Meta<SearchbarProps> = {
11
+ const meta = {
14
12
  title: 'plugins/plugin-search/Searchbar',
15
13
  component: Searchbar,
16
14
  decorators: [withTheme],
17
15
  parameters: {
18
16
  layout: 'centered',
19
17
  },
20
- };
18
+ } satisfies Meta<typeof Searchbar>;
21
19
 
22
20
  export default meta;
23
21
 
24
- export const Default = {
22
+ type Story = StoryObj<typeof meta>;
23
+
24
+ export const Default: Story = {
25
25
  args: {
26
26
  placeholder: 'Search...',
27
27
  },
@@ -4,7 +4,7 @@
4
4
 
5
5
  import React, { type KeyboardEvent, useEffect, useRef, useState } from 'react';
6
6
 
7
- import { Input, type TextInputProps, Icon } from '@dxos/react-ui';
7
+ import { Icon, Input, type TextInputProps } from '@dxos/react-ui';
8
8
 
9
9
  export type SearchbarProps = Pick<TextInputProps, 'variant' | 'placeholder'> & {
10
10
  classes?: {
@@ -5,7 +5,7 @@
5
5
  import { describe, expect, test } from 'vitest';
6
6
 
7
7
  import { Client } from '@dxos/client';
8
- import { Obj, Filter, Type } from '@dxos/echo';
8
+ import { Filter, Obj, Type } from '@dxos/echo';
9
9
  import { faker } from '@dxos/random';
10
10
 
11
11
  import { filterObjectsSync } from './sync';
@@ -2,13 +2,14 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import React, { createContext, type PropsWithChildren, useContext, useMemo, useState } from 'react';
5
+ import React, { type PropsWithChildren, createContext, useContext, useMemo, useState } from 'react';
6
6
 
7
7
  import { raise } from '@dxos/debug';
8
8
 
9
- import { filterObjectsSync, queryStringToMatch } from './sync';
10
9
  import { type SearchResult } from '../types';
11
10
 
11
+ import { filterObjectsSync, queryStringToMatch } from './sync';
12
+
12
13
  type SearchContextType = {
13
14
  match?: RegExp;
14
15
  setMatch?: (text?: string) => void;
@@ -47,14 +47,14 @@ export const useSearchResults = <T extends Record<string, any>>(
47
47
 
48
48
  useEffect(() => {
49
49
  setPending(!!(objects && queryString));
50
- const timeoutId = setTimeout(async () => {
50
+ const timeout = setTimeout(async () => {
51
51
  const nextResults =
52
52
  objects && queryString ? await filterObjects(objects, queryStringToMatch(queryString)) : new Map();
53
53
  setResults(nextResults);
54
54
  setPending(false);
55
55
  }, delay);
56
56
 
57
- return () => clearTimeout(timeoutId);
57
+ return () => clearTimeout(timeout);
58
58
  }, [queryString, objects]);
59
59
 
60
60
  return [pending, results];
@@ -5,7 +5,6 @@
5
5
  import { useState } from 'react';
6
6
 
7
7
  import { EXA_API_KEY } from '@dxos/ai/testing';
8
- import { todo } from '@dxos/debug';
9
8
  import { Obj } from '@dxos/echo';
10
9
  import { type DXN } from '@dxos/keys';
11
10
  import { log } from '@dxos/log';
@@ -14,6 +13,7 @@ import { Testing } from '@dxos/schema/testing';
14
13
 
15
14
  import { search } from '../search';
16
15
  import { type SearchResult } from '../types';
16
+
17
17
  import { getStringProperty } from './sync';
18
18
 
19
19
  export const useWebSearch = ({ query, context }: { query?: string; context?: string }) => {
@@ -28,7 +28,6 @@ export const useWebSearch = ({ query, context }: { query?: string; context?: str
28
28
  query,
29
29
  context,
30
30
  schema: [Testing.Project, Testing.Organization, Testing.Contact],
31
- AiService: todo(),
32
31
  exaApiKey: EXA_API_KEY,
33
32
  });
34
33
 
package/src/meta.ts CHANGED
@@ -4,14 +4,13 @@
4
4
 
5
5
  import { type PluginMeta } from '@dxos/app-framework';
6
6
 
7
- export const SEARCH_PLUGIN = 'dxos.org/plugin/search';
8
- export const SEARCH_RESULT = `${SEARCH_PLUGIN}/result`;
9
-
10
7
  export const meta: PluginMeta = {
11
- id: SEARCH_PLUGIN,
8
+ id: 'dxos.org/plugin/search',
12
9
  name: 'Search',
13
10
  description: 'Search ECHO spaces for content.',
14
11
  icon: 'ph--magnifying-glass--regular',
15
12
  source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-search',
16
13
  tags: ['labs'],
17
14
  };
15
+
16
+ export const SEARCH_RESULT = `${meta.id}/result`;