@dxos/plugin-search 0.8.4-main.7ace549 → 0.8.4-main.937b3ca

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-KZ3V2E5U.mjs +81 -0
  2. package/dist/lib/browser/app-graph-builder-KZ3V2E5U.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 +47 -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-6MBOKZQH.mjs +25 -0
  13. package/dist/lib/browser/operation-resolver-6MBOKZQH.mjs.map +7 -0
  14. package/dist/lib/browser/react-surface-CFRXSKDB.mjs +364 -0
  15. package/dist/lib/browser/react-surface-CFRXSKDB.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 +53 -46
  59. package/src/SearchPlugin.tsx +24 -42
  60. package/src/capabilities/app-graph-builder/app-graph-builder.ts +70 -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 +23 -0
  65. package/src/capabilities/react-surface/index.ts +7 -0
  66. package/src/capabilities/react-surface/react-surface.tsx +70 -0
  67. package/src/components/SearchDialog.tsx +65 -71
  68. package/src/components/SearchMain.stories.tsx +90 -0
  69. package/src/components/SearchMain.tsx +61 -37
  70. package/src/components/SpaceMain.tsx +166 -0
  71. package/src/components/index.ts +1 -1
  72. package/src/hooks/sync.test.ts +6 -4
  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-D7STUIQS.mjs +0 -306
  92. package/dist/lib/browser/react-surface-D7STUIQS.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 -62
  122. package/src/components/Searchbar/index.ts +0 -5
@@ -1,56 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import React from 'react';
6
-
7
- import { Capabilities, contributes, createSurface } from '@dxos/app-framework';
8
- import { useActiveSpace } from '@dxos/plugin-space';
9
- import { type Space, isSpace } from '@dxos/react-client/echo';
10
-
11
- import { SEARCH_DIALOG, SearchDialog, type SearchDialogProps, SearchMain } from '../components';
12
- import { SearchContextProvider } from '../hooks';
13
-
14
- export default () =>
15
- contributes(Capabilities.ReactSurface, [
16
- createSurface({
17
- id: SEARCH_DIALOG,
18
- role: 'dialog',
19
- filter: (data): data is { props: SearchDialogProps } => data.component === SEARCH_DIALOG,
20
- component: ({ data }) => (
21
- <SearchContextProvider>
22
- <SearchDialog {...data.props} />
23
- </SearchContextProvider>
24
- ),
25
- }),
26
- createSurface({
27
- id: `${SEARCH_DIALOG}/search-input`,
28
- role: 'search-input',
29
- component: () => {
30
- const space = useActiveSpace();
31
-
32
- return (
33
- <SearchContextProvider>
34
- <SearchMain space={space} />
35
- </SearchContextProvider>
36
- );
37
- },
38
- }),
39
- createSurface({
40
- id: `${SEARCH_DIALOG}/search`,
41
- role: 'deck-companion--search',
42
- filter: (data): data is { subject: Space } => isSpace(data.subject),
43
- component: ({ data }) => {
44
- const space = data.subject;
45
- if (!space) {
46
- return null;
47
- }
48
-
49
- return (
50
- <SearchContextProvider>
51
- <SearchMain space={space} />
52
- </SearchContextProvider>
53
- );
54
- },
55
- }),
56
- ]);
@@ -1,64 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- import { type Decorator, type Meta, type StoryObj } from '@storybook/react-vite';
6
- import React, { useState } from 'react';
7
-
8
- import { faker } from '@dxos/random';
9
- import { withLayout, withTheme } from '@dxos/react-ui/testing';
10
-
11
- import { SearchContextProvider, useGlobalSearch, useGlobalSearchResults } from '../hooks';
12
-
13
- import { Searchbar, type SearchbarProps } from './Searchbar';
14
- import { SearchResults } from './SearchResults';
15
-
16
- faker.seed(1);
17
-
18
- type StoryProps = SearchbarProps & {
19
- objects?: any[];
20
- };
21
-
22
- const DefaultStory = ({ objects, ...props }: StoryProps) => {
23
- const [selected, setSelected] = useState<string>();
24
- const { setMatch } = useGlobalSearch();
25
- const filteredItems = useGlobalSearchResults(objects);
26
-
27
- return (
28
- <div className='flex grow justify-center overflow-hidden'>
29
- <div className='flex flex-col is-[300px] m-4 overflow-hidden'>
30
- <Searchbar variant='subdued' placeholder='Enter regular expression...' onChange={setMatch} {...props} />
31
- <SearchResults items={filteredItems} selected={selected} onSelect={setSelected} />
32
- </div>
33
- </div>
34
- );
35
- };
36
-
37
- const withSearchContext = (): Decorator => {
38
- return (Story) => (
39
- <SearchContextProvider>
40
- <Story />
41
- </SearchContextProvider>
42
- );
43
- };
44
-
45
- export const Default: Story = {
46
- args: {
47
- objects: Array.from({ length: 8 }).map(() => ({
48
- id: faker.string.uuid(),
49
- label: faker.lorem.sentence(4).replace(/\./g, ''),
50
- content: faker.lorem.sentences(3),
51
- })),
52
- },
53
- };
54
-
55
- const meta = {
56
- title: 'plugins/plugin-search/Search',
57
- component: Searchbar,
58
- render: DefaultStory,
59
- decorators: [withTheme, withLayout({ container: 'column' }), withSearchContext()],
60
- } satisfies Meta<typeof Searchbar>;
61
-
62
- export default meta;
63
-
64
- type Story = StoryObj<typeof meta>;
@@ -1,59 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- import { type Meta, type StoryObj } from '@storybook/react-vite';
6
- import React, { useState } from 'react';
7
-
8
- import { withPluginManager } from '@dxos/app-framework/testing';
9
- import { faker } from '@dxos/random';
10
- import { withTheme } from '@dxos/react-ui/testing';
11
-
12
- import { filterObjectsSync } from '../../hooks';
13
-
14
- import { SearchResults, type SearchResultsProps } from './SearchResults';
15
-
16
- faker.seed(1);
17
-
18
- const DefaultStory = (props: SearchResultsProps) => {
19
- const [selected, setSelected] = useState<string>();
20
-
21
- return (
22
- <div className='flex grow justify-center overflow-hidden'>
23
- <div className='flex is-[300px] m-4 overflow-hidden'>
24
- <SearchResults {...props} selected={selected} onSelect={setSelected} />
25
- </div>
26
- </div>
27
- );
28
- };
29
-
30
- const word = 'hello';
31
-
32
- const objects = Array.from({ length: 100 }).map((_, i) => ({
33
- id: faker.string.uuid(),
34
- name: faker.lorem.sentence(4),
35
- content: faker.lorem.sentence() + ` ${word} ` + faker.lorem.sentence(),
36
- }));
37
-
38
- const match = new RegExp(word, 'i');
39
-
40
- const meta = {
41
- title: 'plugins/plugin-search/SearchResults',
42
- component: SearchResults,
43
- render: DefaultStory,
44
- decorators: [withTheme, withPluginManager({ plugins: [] })],
45
- parameters: {
46
- layout: 'fullscreen',
47
- },
48
- } satisfies Meta<typeof SearchResults>;
49
-
50
- export default meta;
51
-
52
- type Story = StoryObj<typeof meta>;
53
-
54
- export const Default: Story = {
55
- args: {
56
- items: filterObjectsSync(objects, match),
57
- match,
58
- },
59
- };
@@ -1,83 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- import React, { type FC, forwardRef } from 'react';
6
-
7
- import { Surface } from '@dxos/app-framework/react';
8
- import { Obj } from '@dxos/echo';
9
- import { Card } from '@dxos/react-ui-stack';
10
- import { ghostHover } from '@dxos/react-ui-theme';
11
-
12
- import { type SearchResult } from '../../types';
13
-
14
- export type SearchResultsProps = {
15
- items: SearchResult[];
16
- match?: RegExp;
17
- selected?: string;
18
- onSelect?: (id: string) => void;
19
- };
20
-
21
- // TODO(burdon): Key cursor up/down.
22
- // TODO(burdon): Use stack (should be virtualized).
23
- export const SearchResults = ({ items }: SearchResultsProps) => {
24
- return (
25
- <div className='overflow-y-auto'>
26
- <div className='flex flex-col'>
27
- {items
28
- // TODO(burdon): Hack to reduce noise from system objects.
29
- .filter((item) => Obj.getLabel(item.object))
30
- .map((item) => (
31
- <div key={item.id} role='none' className='pli-2 first:pbs-2 pbe-2'>
32
- <Surface role='card' data={{ subject: item.object }} limit={1} />
33
- </div>
34
- ))}
35
- </div>
36
- </div>
37
- );
38
- };
39
-
40
- export type SearchItemProps = SearchResult & { selected: boolean } & Pick<SearchResultsProps, 'onSelect'>;
41
-
42
- export const SearchItem = forwardRef<HTMLDivElement, SearchItemProps>((item, forwardRef) => {
43
- const { id, objectType, label, snippet, match, selected, onSelect } = item;
44
-
45
- return (
46
- <Card.StaticRoot
47
- ref={forwardRef}
48
- classNames={['mx-2 mt-2 cursor-pointer', selected && '!bg-activeSurface', ghostHover]}
49
- onClick={() => onSelect?.(id)}
50
- >
51
- {objectType && <div className='text-xs text-neutral-400 ml-4'>{objectType}</div>}
52
- <Card.Heading>{label ?? 'Untitled'}</Card.Heading>
53
- {snippet && <Snippet text={snippet} match={match} />}
54
- </Card.StaticRoot>
55
- );
56
- });
57
-
58
- export const Snippet: FC<{ text: string; match?: RegExp }> = ({ text, match }) => {
59
- let content = <>{text}</>;
60
- if (match) {
61
- const result = text.match(match);
62
- if (result?.index !== undefined) {
63
- // Break near to match.
64
- const maxOffset = 16;
65
- let before = text.slice(0, result.index);
66
- if (before.length > maxOffset) {
67
- const idx = before.indexOf(' ', result.index - maxOffset);
68
- before = '… ' + before.slice(idx);
69
- }
70
-
71
- const after = text.slice(result.index + result[0].length);
72
- content = (
73
- <>
74
- {before}
75
- <span className='text-blue-500'>{result[0]}</span>
76
- {after}
77
- </>
78
- );
79
- }
80
- }
81
-
82
- return <span className='text-xs mb-1 line-clamp-3 text-neutral-300'>{content}</span>;
83
- };
@@ -1,5 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- export * from './SearchResults';
@@ -1,28 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- import { type Meta, type StoryObj } from '@storybook/react-vite';
6
-
7
- import { withTheme } from '@dxos/react-ui/testing';
8
-
9
- import { Searchbar } from './Searchbar';
10
-
11
- const meta = {
12
- title: 'plugins/plugin-search/Searchbar',
13
- component: Searchbar,
14
- decorators: [withTheme],
15
- parameters: {
16
- layout: 'centered',
17
- },
18
- } satisfies Meta<typeof Searchbar>;
19
-
20
- export default meta;
21
-
22
- type Story = StoryObj<typeof meta>;
23
-
24
- export const Default: Story = {
25
- args: {
26
- placeholder: 'Search...',
27
- },
28
- };
@@ -1,62 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- import React, { useCallback, useEffect, useRef } from 'react';
6
-
7
- import { Input, type TextInputProps, type ThemedClassName, Toolbar, useControlledState } from '@dxos/react-ui';
8
-
9
- export type SearchbarProps = ThemedClassName<
10
- Pick<TextInputProps, 'variant' | 'placeholder'> & {
11
- delay?: number;
12
- value?: string;
13
- onChange?: (text?: string) => void;
14
- onSubmit?: (text?: string) => void;
15
- }
16
- >;
17
-
18
- export const Searchbar = ({ classNames, variant, placeholder, value, onChange, onSubmit }: SearchbarProps) => {
19
- const [text, setText] = useControlledState(value, onChange);
20
- const inputRef = useRef<HTMLInputElement>(null);
21
-
22
- const handleWindowKeyDown = useCallback(
23
- (event: KeyboardEvent) => {
24
- if (event.key === 'f' && event.metaKey && event.shiftKey) {
25
- inputRef.current?.focus();
26
- }
27
- },
28
- [inputRef],
29
- );
30
-
31
- useEffect(() => {
32
- window.addEventListener('keydown', handleWindowKeyDown);
33
- return () => window.removeEventListener('keydown', handleWindowKeyDown);
34
- }, [handleWindowKeyDown]);
35
-
36
- const handleKeyDown = useCallback(
37
- (event: React.KeyboardEvent<HTMLInputElement>) => {
38
- switch (event.key) {
39
- case 'Enter':
40
- onSubmit?.(text);
41
- break;
42
- }
43
- },
44
- [text, onSubmit],
45
- );
46
-
47
- return (
48
- <Toolbar.Root classNames={classNames}>
49
- <Input.Root>
50
- <Input.TextInput
51
- ref={inputRef}
52
- placeholder={placeholder}
53
- autoFocus
54
- variant={variant}
55
- value={text ?? ''}
56
- onChange={({ target }) => setText(target.value)}
57
- onKeyDown={handleKeyDown}
58
- />
59
- </Input.Root>
60
- </Toolbar.Root>
61
- );
62
- };
@@ -1,5 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- export * from './Searchbar';