@dxos/plugin-preview 0.8.4-main.dedc0f3 → 0.8.4-main.e8ec1fe

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 (86) hide show
  1. package/dist/lib/browser/chunk-CEWM5LJG.mjs +17 -0
  2. package/dist/lib/browser/chunk-CEWM5LJG.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +11 -10
  4. package/dist/lib/browser/index.mjs.map +3 -3
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/{preview-popover-HC6LHWXZ.mjs → preview-popover-IAPAEKZL.mjs} +7 -6
  7. package/dist/lib/browser/preview-popover-IAPAEKZL.mjs.map +7 -0
  8. package/dist/lib/browser/react-surface-LRMZKOJS.mjs +498 -0
  9. package/dist/lib/browser/react-surface-LRMZKOJS.mjs.map +7 -0
  10. package/dist/lib/node-esm/chunk-Q5MUNELK.mjs +19 -0
  11. package/dist/lib/node-esm/chunk-Q5MUNELK.mjs.map +7 -0
  12. package/dist/lib/node-esm/index.mjs +11 -10
  13. package/dist/lib/node-esm/index.mjs.map +3 -3
  14. package/dist/lib/node-esm/meta.json +1 -1
  15. package/dist/lib/node-esm/{preview-popover-ROGTBCTT.mjs → preview-popover-CH2LDYWM.mjs} +7 -6
  16. package/dist/lib/node-esm/preview-popover-CH2LDYWM.mjs.map +7 -0
  17. package/dist/lib/node-esm/react-surface-65UVGBIZ.mjs +499 -0
  18. package/dist/lib/node-esm/react-surface-65UVGBIZ.mjs.map +7 -0
  19. package/dist/types/src/PreviewPlugin.d.ts +1 -1
  20. package/dist/types/src/PreviewPlugin.d.ts.map +1 -1
  21. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
  22. package/dist/types/src/cards/OrganizationCard.d.ts +5 -0
  23. package/dist/types/src/cards/OrganizationCard.d.ts.map +1 -0
  24. package/dist/types/src/cards/PersonCard.d.ts +5 -0
  25. package/dist/types/src/cards/PersonCard.d.ts.map +1 -0
  26. package/dist/types/src/cards/ProjectCard.d.ts +5 -0
  27. package/dist/types/src/cards/ProjectCard.d.ts.map +1 -0
  28. package/dist/types/src/cards/TaskCard.d.ts +5 -0
  29. package/dist/types/src/cards/TaskCard.d.ts.map +1 -0
  30. package/dist/types/src/cards/index.d.ts +5 -0
  31. package/dist/types/src/cards/index.d.ts.map +1 -0
  32. package/dist/types/src/components/CardComponents.d.ts +16 -0
  33. package/dist/types/src/components/CardComponents.d.ts.map +1 -0
  34. package/dist/types/src/components/CardSubjectMenu.d.ts +3 -5
  35. package/dist/types/src/components/CardSubjectMenu.d.ts.map +1 -1
  36. package/dist/types/src/components/index.d.ts +2 -3
  37. package/dist/types/src/components/index.d.ts.map +1 -1
  38. package/dist/types/src/meta.d.ts +0 -1
  39. package/dist/types/src/meta.d.ts.map +1 -1
  40. package/dist/types/src/stories/Card.stories.d.ts +3 -1
  41. package/dist/types/src/stories/Card.stories.d.ts.map +1 -1
  42. package/dist/types/src/stories/testing.d.ts +4 -3
  43. package/dist/types/src/stories/testing.d.ts.map +1 -1
  44. package/dist/types/src/translations.d.ts +3 -0
  45. package/dist/types/src/translations.d.ts.map +1 -1
  46. package/dist/types/src/types.d.ts +10 -5
  47. package/dist/types/src/types.d.ts.map +1 -1
  48. package/dist/types/tsconfig.tsbuildinfo +1 -1
  49. package/package.json +33 -32
  50. package/src/PreviewPlugin.tsx +23 -24
  51. package/src/capabilities/preview-popover.ts +5 -5
  52. package/src/capabilities/react-surface.tsx +89 -96
  53. package/src/cards/OrganizationCard.tsx +34 -0
  54. package/src/cards/PersonCard.tsx +63 -0
  55. package/src/cards/ProjectCard.tsx +24 -0
  56. package/src/{components → cards}/TaskCard.tsx +10 -10
  57. package/src/cards/index.ts +8 -0
  58. package/src/components/CardComponents.tsx +67 -0
  59. package/src/components/CardSubjectMenu.tsx +73 -26
  60. package/src/components/index.ts +2 -3
  61. package/src/meta.ts +6 -3
  62. package/src/stories/Card.stories.tsx +11 -8
  63. package/src/stories/testing.tsx +21 -21
  64. package/src/translations.ts +3 -0
  65. package/src/types.ts +23 -5
  66. package/dist/lib/browser/chunk-Z73ENKLE.mjs +0 -14
  67. package/dist/lib/browser/chunk-Z73ENKLE.mjs.map +0 -7
  68. package/dist/lib/browser/preview-popover-HC6LHWXZ.mjs.map +0 -7
  69. package/dist/lib/browser/react-surface-JGO43GLE.mjs +0 -381
  70. package/dist/lib/browser/react-surface-JGO43GLE.mjs.map +0 -7
  71. package/dist/lib/node-esm/chunk-2ORSL4GJ.mjs +0 -16
  72. package/dist/lib/node-esm/chunk-2ORSL4GJ.mjs.map +0 -7
  73. package/dist/lib/node-esm/preview-popover-ROGTBCTT.mjs.map +0 -7
  74. package/dist/lib/node-esm/react-surface-Q7F36L3Z.mjs +0 -382
  75. package/dist/lib/node-esm/react-surface-Q7F36L3Z.mjs.map +0 -7
  76. package/dist/types/src/components/ContactCard.d.ts +0 -7
  77. package/dist/types/src/components/ContactCard.d.ts.map +0 -1
  78. package/dist/types/src/components/OrganizationCard.d.ts +0 -5
  79. package/dist/types/src/components/OrganizationCard.d.ts.map +0 -1
  80. package/dist/types/src/components/ProjectCard.d.ts +0 -5
  81. package/dist/types/src/components/ProjectCard.d.ts.map +0 -1
  82. package/dist/types/src/components/TaskCard.d.ts +0 -5
  83. package/dist/types/src/components/TaskCard.d.ts.map +0 -1
  84. package/src/components/ContactCard.tsx +0 -76
  85. package/src/components/OrganizationCard.tsx +0 -44
  86. package/src/components/ProjectCard.tsx +0 -28
@@ -0,0 +1,67 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import React from 'react';
6
+
7
+ import { Button, Icon } from '@dxos/react-ui';
8
+ import { Card, cardNoSpacing, cardSpacing } from '@dxos/react-ui-stack';
9
+ import { mx } from '@dxos/react-ui-theme';
10
+
11
+ import { type CardPreviewProps } from '../types';
12
+
13
+ import { CardSubjectMenu } from './CardSubjectMenu';
14
+
15
+ export const gridRow = 'is-full grid grid-cols-[1.5rem_1fr_min-content] gap-2 items-center';
16
+
17
+ // TODO(burdon): Standardize card grid for common rows.
18
+
19
+ export const CardHeader = ({ label, subject, activeSpace }: { label?: string } & CardPreviewProps) => {
20
+ return (
21
+ <div role='none' className={mx('flex items-center gap-2', cardSpacing)}>
22
+ <Card.Heading classNames={cardNoSpacing}>{label}</Card.Heading>
23
+ <CardSubjectMenu subject={subject} activeSpace={activeSpace} />
24
+ </div>
25
+ );
26
+ };
27
+
28
+ export const CardRow = ({ icon, label, onClick }: { icon: string; label: string; onClick?: () => void }) => {
29
+ if (!onClick) {
30
+ return (
31
+ <Card.Chrome>
32
+ <p data-variant='ghost' className={mx(gridRow, 'dx-button')}>
33
+ <Icon icon={icon} size={5} classNames='text-subdued' />
34
+ <span className='min-is-0 flex-1 truncate col-span-2'>{label}</span>
35
+ </p>
36
+ </Card.Chrome>
37
+ );
38
+ }
39
+
40
+ return (
41
+ <Card.Chrome>
42
+ <Button variant='ghost' classNames={mx(gridRow, 'text-start')} onClick={onClick}>
43
+ <Icon icon={icon} size={5} classNames='text-subdued' />
44
+ <span className='min-is-0 flex-1 truncate'>{label}</span>
45
+ <Icon icon='ph--arrow-right--regular' />
46
+ </Button>
47
+ </Card.Chrome>
48
+ );
49
+ };
50
+
51
+ export const CardLink = ({ label, href }: { label: string; href: string }) => {
52
+ return (
53
+ <Card.Chrome>
54
+ <a
55
+ className={mx(gridRow, 'dx-button dx-focus-ring')}
56
+ data-variant='ghost'
57
+ href={href}
58
+ target='_blank'
59
+ rel='noreferrer'
60
+ >
61
+ <Icon icon='ph--link--regular' size={5} classNames='text-subdued' />
62
+ <span className='min-is-0 flex-1 truncate'>{label}</span>
63
+ <Icon icon='ph--arrow-square-out--regular' />
64
+ </a>
65
+ </Card.Chrome>
66
+ );
67
+ };
@@ -2,50 +2,50 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { Rx } from '@effect-rx/rx-react';
5
+ import { Atom } from '@effect-atom/atom-react';
6
6
  import React from 'react';
7
7
 
8
- // import { useIntentDispatcher } from '@dxos/app-framework';
8
+ import { LayoutAction, createIntent } from '@dxos/app-framework';
9
+ import { useIntentDispatcher } from '@dxos/app-framework/react';
9
10
  import { ACTION_TYPE } from '@dxos/app-graph';
10
- import { type AnyEchoObject } from '@dxos/echo-schema';
11
+ import { Obj } from '@dxos/echo';
12
+ import { SpaceAction } from '@dxos/plugin-space/types';
11
13
  import { IconButton, type IconButtonProps, useTranslation } from '@dxos/react-ui';
12
- import { type ActionGraphProps, DropdownMenu, MenuProvider, useMenuActions } from '@dxos/react-ui-menu';
14
+ import {
15
+ type ActionGraphProps,
16
+ DropdownMenu,
17
+ type MenuActions,
18
+ MenuProvider,
19
+ useMenuActions,
20
+ } from '@dxos/react-ui-menu';
13
21
 
14
- const useSubjectMenuGroupItems = (subject: AnyEchoObject) => {
15
- // const { dispatchPromise: dispatch } = useIntentDispatcher();
16
- const result: ActionGraphProps = { edges: [], nodes: [] };
17
- result.nodes.push({
18
- type: ACTION_TYPE,
19
- id: `${subject.id}/add-to-space`,
20
- data: () => console.log('[TO DO]', 'add object to space', subject),
21
- properties: {
22
- label: ['add object to space label', { ns: 'os' }],
23
- icon: 'ph--file-plus--regular',
24
- },
25
- });
26
- result.nodes.forEach(({ id: target }) => {
27
- result.edges.push({ source: 'root', target });
28
- });
29
- return useMenuActions(Rx.make(result));
30
- };
22
+ import { meta } from '../meta';
23
+ import { type CardPreviewProps } from '../types';
31
24
 
32
25
  /**
33
- * This is a generic menu for objects that tries to infer common actions.
26
+ * Generic menu for objects; builds menu with common actions.
34
27
  */
28
+ // TODO(burdon): Reconcile title and menu with main Card header.
35
29
  export const CardSubjectMenu = ({
36
30
  subject,
31
+ activeSpace,
37
32
  ...props
38
- }: Omit<IconButtonProps, 'icon' | 'label'> & { subject: AnyEchoObject }) => {
39
- const { t } = useTranslation('os');
40
- const menuProps = useSubjectMenuGroupItems(subject);
33
+ }: CardPreviewProps & Omit<IconButtonProps, 'icon' | 'label'>) => {
34
+ const { t } = useTranslation(meta.id);
35
+ const menuProps = useSubjectMenuGroupItems({ subject, activeSpace });
36
+
37
+ if (!activeSpace) {
38
+ return null;
39
+ }
40
+
41
41
  return (
42
42
  <MenuProvider {...menuProps}>
43
43
  <DropdownMenu.Root>
44
44
  <DropdownMenu.Trigger asChild>
45
45
  <IconButton
46
- iconOnly
47
46
  variant='ghost'
48
47
  icon='ph--dots-three-vertical--bold'
48
+ iconOnly
49
49
  label={t('more options label')}
50
50
  {...props}
51
51
  />
@@ -54,3 +54,50 @@ export const CardSubjectMenu = ({
54
54
  </MenuProvider>
55
55
  );
56
56
  };
57
+
58
+ const useSubjectMenuGroupItems = ({ subject, activeSpace }: CardPreviewProps): MenuActions => {
59
+ const { dispatchPromise: dispatch } = useIntentDispatcher();
60
+ const result: ActionGraphProps = { edges: [], nodes: [] };
61
+
62
+ result.nodes.push({
63
+ type: ACTION_TYPE,
64
+ id: `${subject.id}/open`,
65
+ data: () =>
66
+ dispatch(
67
+ createIntent(LayoutAction.Open, {
68
+ part: 'main',
69
+ subject: [Obj.getDXN(subject).toString()],
70
+ }),
71
+ ),
72
+ properties: {
73
+ label: ['open object label', { ns: meta.id }],
74
+ icon: 'ph--arrow-right--regular',
75
+ },
76
+ });
77
+
78
+ if (activeSpace && Obj.getDXN(subject).asQueueDXN()) {
79
+ result.nodes.push({
80
+ type: ACTION_TYPE,
81
+ id: `${subject.id}/add-to-space`,
82
+ // TODO(wittjosiah): Update reference to point to db object when adding?
83
+ data: () =>
84
+ dispatch(
85
+ createIntent(SpaceAction.AddObject, {
86
+ object: subject,
87
+ target: activeSpace,
88
+ hidden: true,
89
+ }),
90
+ ),
91
+ properties: {
92
+ label: ['add object to space label', { ns: meta.id }],
93
+ icon: 'ph--file-plus--regular',
94
+ },
95
+ });
96
+ }
97
+
98
+ result.nodes.forEach(({ id: target }) => {
99
+ result.edges.push({ source: 'root', target });
100
+ });
101
+
102
+ return useMenuActions(Atom.make(result));
103
+ };
@@ -2,6 +2,5 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- export * from './ContactCard';
6
- export * from './OrganizationCard';
7
- export * from './ProjectCard';
5
+ export * from './CardComponents';
6
+ export * from './CardSubjectMenu';
package/src/meta.ts CHANGED
@@ -3,12 +3,15 @@
3
3
  //
4
4
 
5
5
  import { type PluginMeta } from '@dxos/app-framework';
6
-
7
- export const PREVIEW_PLUGIN = 'dxos.org/plugin/preview';
6
+ import { trim } from '@dxos/util';
8
7
 
9
8
  export const meta: PluginMeta = {
10
- id: PREVIEW_PLUGIN,
9
+ id: 'dxos.org/plugin/preview',
11
10
  name: 'Preview',
11
+ description: trim`
12
+ Rich preview panel for viewing object content without opening full editors.
13
+ Quick peek at documents, images, and data with inline rendering.
14
+ `,
12
15
  icon: 'ph--eye--regular',
13
16
  source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-preview',
14
17
  };
@@ -2,27 +2,30 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import '@dxos-theme';
6
-
7
5
  import { type Meta, type StoryObj } from '@storybook/react-vite';
8
6
 
9
- import { withLayout, withTheme } from '@dxos/storybook-utils';
7
+ import { IntentPlugin } from '@dxos/app-framework';
8
+ import { withPluginManager } from '@dxos/app-framework/testing';
9
+ import { faker } from '@dxos/random';
10
+ import { withTheme } from '@dxos/react-ui/testing';
10
11
 
11
12
  import { translations } from '../translations';
12
13
 
13
14
  import { Defaultstory, createCards } from './testing';
14
15
 
16
+ faker.seed(999);
17
+
15
18
  const meta = {
16
19
  title: 'plugins/plugin-preview/Card',
17
20
  render: Defaultstory,
18
21
  decorators: [
19
22
  withTheme,
20
- withLayout({
21
- fullscreen: true,
22
- classNames: 'flex flex-col justify-center',
23
- }),
23
+ // TODO(wittjosiah): Try to write story which does not depend on plugin manager.
24
+ withPluginManager({ plugins: [IntentPlugin()] }),
24
25
  ],
25
- parameters: { translations },
26
+ parameters: {
27
+ translations,
28
+ },
26
29
  tags: ['cards'],
27
30
  } satisfies Meta<typeof Defaultstory>;
28
31
 
@@ -7,16 +7,14 @@ import React, { type FC } from 'react';
7
7
  import { Obj, Ref } from '@dxos/echo';
8
8
  import { faker } from '@dxos/random';
9
9
  import { CardContainer } from '@dxos/react-ui-stack/testing';
10
- import { DataType } from '@dxos/schema';
10
+ import { Organization, Person, Task } from '@dxos/types';
11
+ import { Project } from '@dxos/types';
11
12
 
12
- import { ContactCard, OrganizationCard, ProjectCard } from '../components';
13
- import { TaskCard } from '../components/TaskCard';
14
- import { type PreviewProps } from '../types';
13
+ import { OrganizationCard, PersonCard, ProjectCard, TaskCard } from '../cards';
14
+ import { type CardPreviewProps } from '../types';
15
15
 
16
- faker.seed(1234);
17
-
18
- type CardProps<T extends object> = {
19
- Component: FC<PreviewProps<T>>;
16
+ type CardProps<T extends Obj.Any> = {
17
+ Component: FC<CardPreviewProps<T>>;
20
18
  subject: T;
21
19
  icon?: string;
22
20
  image?: boolean;
@@ -29,14 +27,16 @@ export type DefaultstoryProps = {
29
27
 
30
28
  export const Defaultstory = ({ role, cards }: DefaultstoryProps) => {
31
29
  return (
32
- <div className='grid grid-cols-4'>
33
- {cards.map(({ Component, icon, image, subject }, i) => (
34
- <div key={i} className='flex justify-center'>
35
- <CardContainer icon={icon} role={role}>
36
- <Component role={role} subject={image ? subject : omitImage(subject)} />
37
- </CardContainer>
38
- </div>
39
- ))}
30
+ <div className='flex bs-full'>
31
+ <div className='flex shrink-0 gap-8 overflow-x-auto pbe-4'>
32
+ {cards.map(({ Component, icon, image, subject }, i) => (
33
+ <div key={i} className='flex is-[24rem] justify-center'>
34
+ <CardContainer icon={icon} role={role}>
35
+ <Component role={role} subject={image ? subject : omitImage(subject)} />
36
+ </CardContainer>
37
+ </div>
38
+ ))}
39
+ </div>
40
40
  </div>
41
41
  );
42
42
  };
@@ -45,7 +45,7 @@ export const omitImage = ({ image: _, ...rest }: any) => rest;
45
45
 
46
46
  // TODO(burdon): Test data should exercise the standard data generators.
47
47
  export const createCards = (image = true): CardProps<any>[] => {
48
- const organization = Obj.make(DataType.Organization, {
48
+ const organization = Obj.make(Organization.Organization, {
49
49
  name: faker.company.name(),
50
50
  image:
51
51
  'https://plus.unsplash.com/premium_photo-1672116452571-896980a801c8?q=80&w=2671&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
@@ -53,7 +53,7 @@ export const createCards = (image = true): CardProps<any>[] => {
53
53
  description: faker.lorem.paragraph(),
54
54
  });
55
55
 
56
- const contact = Obj.make(DataType.Person, {
56
+ const contact = Obj.make(Person.Person, {
57
57
  fullName: faker.person.fullName(),
58
58
  image:
59
59
  'https://plus.unsplash.com/premium_photo-1664536392779-049ba8fde933?q=80&w=2574&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
@@ -74,13 +74,13 @@ export const createCards = (image = true): CardProps<any>[] => {
74
74
  ],
75
75
  });
76
76
 
77
- const project = DataType.makeProject({
77
+ const project = Project.make({
78
78
  name: faker.person.fullName(),
79
79
  image: 'https://dxos.network/dxos-logotype-blue.png',
80
80
  description: faker.lorem.paragraph(),
81
81
  });
82
82
 
83
- const task = Obj.make(DataType.Task, {
83
+ const task = Obj.make(Task.Task, {
84
84
  title: faker.lorem.sentence(),
85
85
  status: faker.helpers.arrayElement(['todo', 'in-progress', 'done']),
86
86
  });
@@ -93,7 +93,7 @@ export const createCards = (image = true): CardProps<any>[] => {
93
93
  image,
94
94
  },
95
95
  {
96
- Component: ContactCard,
96
+ Component: PersonCard,
97
97
  subject: contact,
98
98
  icon: 'ph--user--regular',
99
99
  image,
@@ -14,6 +14,9 @@ export const translations = [
14
14
  'todo label': 'To do',
15
15
  'in-progress label': 'In progress',
16
16
  'done label': 'Done',
17
+ 'open object label': 'Open',
18
+ 'add object to space label': 'Add to space',
19
+ 'more options label': 'More options',
17
20
  },
18
21
  },
19
22
  },
package/src/types.ts CHANGED
@@ -2,10 +2,28 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { type Schema } from 'effect';
6
5
  import { type PropsWithChildren } from 'react';
7
6
 
8
- export type PreviewProps<T extends Schema.Schema.Type<any>> = PropsWithChildren<{
9
- subject: T;
10
- role?: string;
11
- }>;
7
+ import { type SurfaceCardRole, type SurfaceComponentProps } from '@dxos/app-framework/react';
8
+ import { type Obj } from '@dxos/echo';
9
+ import { type Space } from '@dxos/react-client/echo';
10
+
11
+ /**
12
+ * @deprecated Use {@link SurfaceComponentProps} instead.
13
+ */
14
+ // TODO(burdon): Remove?
15
+ export type CardPreviewProps<
16
+ Subject extends Obj.Any = Obj.Any,
17
+ Role extends SurfaceCardRole = SurfaceCardRole,
18
+ > = PropsWithChildren<
19
+ SurfaceComponentProps<
20
+ Subject,
21
+ {
22
+ // TODO(burdon): Why is this required (why active?)
23
+ activeSpace?: Space;
24
+ // TODO(burdon): Remove in favor of intents?
25
+ onSelect?: (obj: Obj.Any) => void;
26
+ },
27
+ Role
28
+ >
29
+ >;
@@ -1,14 +0,0 @@
1
- // src/meta.ts
2
- var PREVIEW_PLUGIN = "dxos.org/plugin/preview";
3
- var meta = {
4
- id: PREVIEW_PLUGIN,
5
- name: "Preview",
6
- icon: "ph--eye--regular",
7
- source: "https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-preview"
8
- };
9
-
10
- export {
11
- PREVIEW_PLUGIN,
12
- meta
13
- };
14
- //# sourceMappingURL=chunk-Z73ENKLE.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/meta.ts"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type PluginMeta } from '@dxos/app-framework';\n\nexport const PREVIEW_PLUGIN = 'dxos.org/plugin/preview';\n\nexport const meta: PluginMeta = {\n id: PREVIEW_PLUGIN,\n name: 'Preview',\n icon: 'ph--eye--regular',\n source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-preview',\n};\n"],
5
- "mappings": ";AAMO,IAAMA,iBAAiB;AAEvB,IAAMC,OAAmB;EAC9BC,IAAIF;EACJG,MAAM;EACNC,MAAM;EACNC,QAAQ;AACV;",
6
- "names": ["PREVIEW_PLUGIN", "meta", "id", "name", "icon", "source"]
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/capabilities/preview-popover.ts"],
4
- "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Capabilities, LayoutAction, type PluginContext, contributes, createIntent } from '@dxos/app-framework';\nimport { addEventListener } from '@dxos/async';\nimport { type Client } from '@dxos/client';\nimport { type Space, parseId } from '@dxos/client/echo';\nimport { DXN } from '@dxos/keys';\nimport { type DxAnchorActivate } from '@dxos/lit-ui';\nimport { log } from '@dxos/log';\nimport { ClientCapabilities } from '@dxos/plugin-client';\nimport { type PreviewLinkRef, type PreviewLinkTarget } from '@dxos/react-ui-editor';\n\nconst customEventOptions = { capture: true, passive: false };\n\nconst handlePreviewLookup = async (\n client: Client,\n defaultSpace: Space,\n { ref, label }: PreviewLinkRef,\n): Promise<PreviewLinkTarget | null> => {\n try {\n const object = await defaultSpace.db.ref(DXN.parse(ref)).load();\n return { label, object };\n } catch (err) {\n return null;\n }\n};\n\nexport default (context: PluginContext) => {\n // TODO(wittjosiah): Factor out lookup handlers to other plugins to make not ECHO-specific.\n const handleDxAnchorActivate = async ({ refId, label, trigger }: DxAnchorActivate) => {\n const { dispatchPromise: dispatch } = context.getCapability(Capabilities.IntentDispatcher);\n const client = context.getCapability(ClientCapabilities.Client);\n const [layout] = context.getCapabilities(Capabilities.Layout);\n const { spaceId } = parseId(layout.workspace);\n const space = (spaceId && client.spaces.get(spaceId)) ?? client.spaces.default;\n const result = await handlePreviewLookup(client, space, { ref: refId, label });\n if (!result) {\n return;\n }\n\n await dispatch(\n createIntent(LayoutAction.UpdatePopover, {\n part: 'popover',\n subject: result.object,\n options: {\n state: true,\n variant: 'virtual',\n anchor: trigger,\n },\n }),\n );\n };\n\n let cleanup: () => void;\n if (document.defaultView) {\n cleanup = addEventListener(\n document.defaultView,\n 'dx-anchor-activate' as any,\n handleDxAnchorActivate,\n customEventOptions,\n );\n } else {\n log.warn('No default view found');\n }\n\n return contributes(Capabilities.Null, null, () => cleanup());\n};\n"],
5
- "mappings": ";AAIA,SAASA,cAAcC,cAAkCC,aAAaC,oBAAoB;AAC1F,SAASC,wBAAwB;AAEjC,SAAqBC,eAAe;AACpC,SAASC,WAAW;AAEpB,SAASC,WAAW;AACpB,SAASC,0BAA0B;;AAGnC,IAAMC,qBAAqB;EAAEC,SAAS;EAAMC,SAAS;AAAM;AAE3D,IAAMC,sBAAsB,OAC1BC,QACAC,cACA,EAAEC,KAAKC,MAAK,MAAkB;AAE9B,MAAI;AACF,UAAMC,SAAS,MAAMH,aAAaI,GAAGH,IAAIT,IAAIa,MAAMJ,GAAAA,CAAAA,EAAMK,KAAI;AAC7D,WAAO;MAAEJ;MAAOC;IAAO;EACzB,SAASI,KAAK;AACZ,WAAO;EACT;AACF;AAEA,IAAA,0BAAe,CAACC,YAAAA;AAEd,QAAMC,yBAAyB,OAAO,EAAEC,OAAOR,OAAOS,QAAO,MAAoB;AAC/E,UAAM,EAAEC,iBAAiBC,SAAQ,IAAKL,QAAQM,cAAc5B,aAAa6B,gBAAgB;AACzF,UAAMhB,SAASS,QAAQM,cAAcpB,mBAAmBsB,MAAM;AAC9D,UAAM,CAACC,MAAAA,IAAUT,QAAQU,gBAAgBhC,aAAaiC,MAAM;AAC5D,UAAM,EAAEC,QAAO,IAAK7B,QAAQ0B,OAAOI,SAAS;AAC5C,UAAMC,SAASF,WAAWrB,OAAOwB,OAAOC,IAAIJ,OAAAA,MAAarB,OAAOwB,OAAOE;AACvE,UAAMC,SAAS,MAAM5B,oBAAoBC,QAAQuB,OAAO;MAAErB,KAAKS;MAAOR;IAAM,CAAA;AAC5E,QAAI,CAACwB,QAAQ;AACX;IACF;AAEA,UAAMb,SACJxB,aAAaF,aAAawC,eAAe;MACvCC,MAAM;MACNC,SAASH,OAAOvB;MAChB2B,SAAS;QACPC,OAAO;QACPC,SAAS;QACTC,QAAQtB;MACV;IACF,CAAA,CAAA;EAEJ;AAEA,MAAIuB;AACJ,MAAIC,SAASC,aAAa;AACxBF,cAAU5C,iBACR6C,SAASC,aACT,sBACA3B,wBACAd,kBAAAA;EAEJ,OAAO;AACLF,QAAI4C,KAAK,yBAAA,QAAA;;;;;;EACX;AAEA,SAAOjD,YAAYF,aAAaoD,MAAM,MAAM,MAAMJ,QAAAA,CAAAA;AACpD;",
6
- "names": ["Capabilities", "LayoutAction", "contributes", "createIntent", "addEventListener", "parseId", "DXN", "log", "ClientCapabilities", "customEventOptions", "capture", "passive", "handlePreviewLookup", "client", "defaultSpace", "ref", "label", "object", "db", "parse", "load", "err", "context", "handleDxAnchorActivate", "refId", "trigger", "dispatchPromise", "dispatch", "getCapability", "IntentDispatcher", "Client", "layout", "getCapabilities", "Layout", "spaceId", "workspace", "space", "spaces", "get", "default", "result", "UpdatePopover", "part", "subject", "options", "state", "variant", "anchor", "cleanup", "document", "defaultView", "warn", "Null"]
7
- }