@dxos/plugin-registry 0.8.4-main.fffef41 → 0.8.4-staging.60fe92afc8

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 (233) hide show
  1. package/LICENSE +102 -5
  2. package/dist/lib/neutral/RegistryPlugin.mjs +27 -0
  3. package/dist/lib/neutral/RegistryPlugin.mjs.map +7 -0
  4. package/dist/lib/neutral/RegistryPlugin.node.mjs +153 -0
  5. package/dist/lib/neutral/RegistryPlugin.node.mjs.map +7 -0
  6. package/dist/lib/neutral/RegistryPlugin.workerd.mjs +10 -0
  7. package/dist/lib/neutral/RegistryPlugin.workerd.mjs.map +7 -0
  8. package/dist/lib/neutral/chunk-GRQI6MLI.mjs +36 -0
  9. package/dist/lib/neutral/chunk-GRQI6MLI.mjs.map +7 -0
  10. package/dist/lib/neutral/chunk-XK2JMH3H.mjs +33 -0
  11. package/dist/lib/neutral/chunk-XK2JMH3H.mjs.map +7 -0
  12. package/dist/lib/neutral/index.mjs +25 -0
  13. package/dist/lib/neutral/index.mjs.map +7 -0
  14. package/dist/lib/neutral/meta.json +1 -0
  15. package/dist/lib/neutral/open-plugin-registry-II735N76.mjs +15 -0
  16. package/dist/lib/neutral/open-plugin-registry-II735N76.mjs.map +7 -0
  17. package/dist/lib/neutral/plugin.mjs +18 -0
  18. package/dist/lib/neutral/plugin.mjs.map +7 -0
  19. package/dist/lib/neutral/translations.mjs +72 -0
  20. package/dist/lib/neutral/translations.mjs.map +7 -0
  21. package/dist/types/src/RegistryPlugin.d.ts +3 -1
  22. package/dist/types/src/RegistryPlugin.d.ts.map +1 -1
  23. package/dist/types/src/RegistryPlugin.node.d.ts +4 -0
  24. package/dist/types/src/RegistryPlugin.node.d.ts.map +1 -0
  25. package/dist/types/src/RegistryPlugin.test.d.ts +2 -0
  26. package/dist/types/src/RegistryPlugin.test.d.ts.map +1 -0
  27. package/dist/types/src/RegistryPlugin.workerd.d.ts +4 -0
  28. package/dist/types/src/RegistryPlugin.workerd.d.ts.map +1 -0
  29. package/dist/types/src/capabilities/app-graph-builder.d.ts +4 -2
  30. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
  31. package/dist/types/src/capabilities/dev-plugin-loader.d.ts +11 -0
  32. package/dist/types/src/capabilities/dev-plugin-loader.d.ts.map +1 -0
  33. package/dist/types/src/capabilities/index.d.ts +15 -3
  34. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  35. package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
  36. package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
  37. package/dist/types/src/capabilities/react-surface.d.ts +3 -2
  38. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
  39. package/dist/types/src/capabilities/settings.d.ts +14 -0
  40. package/dist/types/src/capabilities/settings.d.ts.map +1 -0
  41. package/dist/types/src/categories.d.ts +18 -0
  42. package/dist/types/src/categories.d.ts.map +1 -0
  43. package/dist/types/src/commands/disable.d.ts +11 -0
  44. package/dist/types/src/commands/disable.d.ts.map +1 -0
  45. package/dist/types/src/commands/enable.d.ts +11 -0
  46. package/dist/types/src/commands/enable.d.ts.map +1 -0
  47. package/dist/types/src/commands/index.d.ts +3 -0
  48. package/dist/types/src/commands/index.d.ts.map +1 -0
  49. package/dist/types/src/commands/list.d.ts +7 -0
  50. package/dist/types/src/commands/list.d.ts.map +1 -0
  51. package/dist/types/src/commands/util.d.ts +11 -0
  52. package/dist/types/src/commands/util.d.ts.map +1 -0
  53. package/dist/types/src/components/DisableDependentsAlert/DisableDependentsAlert.d.ts +24 -0
  54. package/dist/types/src/components/DisableDependentsAlert/DisableDependentsAlert.d.ts.map +1 -0
  55. package/dist/types/src/components/DisableDependentsAlert/index.d.ts +2 -0
  56. package/dist/types/src/components/DisableDependentsAlert/index.d.ts.map +1 -0
  57. package/dist/types/src/components/PluginDetail/PluginDetail.d.ts +82 -0
  58. package/dist/types/src/components/PluginDetail/PluginDetail.d.ts.map +1 -0
  59. package/dist/types/src/components/PluginDetail/PluginDetail.stories.d.ts +79 -0
  60. package/dist/types/src/components/PluginDetail/PluginDetail.stories.d.ts.map +1 -0
  61. package/dist/types/src/components/PluginDetail/index.d.ts +2 -0
  62. package/dist/types/src/components/PluginDetail/index.d.ts.map +1 -0
  63. package/dist/types/src/components/PluginFailureBadge/PluginFailureBadge.d.ts +20 -0
  64. package/dist/types/src/components/PluginFailureBadge/PluginFailureBadge.d.ts.map +1 -0
  65. package/dist/types/src/components/PluginFailureBadge/index.d.ts +2 -0
  66. package/dist/types/src/components/PluginFailureBadge/index.d.ts.map +1 -0
  67. package/dist/types/src/components/PluginList/PluginItem.d.ts +40 -0
  68. package/dist/types/src/components/PluginList/PluginItem.d.ts.map +1 -0
  69. package/dist/types/src/components/PluginList/PluginList.d.ts +23 -0
  70. package/dist/types/src/components/PluginList/PluginList.d.ts.map +1 -0
  71. package/dist/types/src/components/PluginList/PluginList.stories.d.ts +78 -0
  72. package/dist/types/src/components/PluginList/PluginList.stories.d.ts.map +1 -0
  73. package/dist/types/src/components/PluginList/index.d.ts +2 -0
  74. package/dist/types/src/components/PluginList/index.d.ts.map +1 -0
  75. package/dist/types/src/components/RegistrySettings/RegistrySettings.d.ts +18 -0
  76. package/dist/types/src/components/RegistrySettings/RegistrySettings.d.ts.map +1 -0
  77. package/dist/types/src/components/RegistrySettings/index.d.ts +2 -0
  78. package/dist/types/src/components/RegistrySettings/index.d.ts.map +1 -0
  79. package/dist/types/src/components/index.d.ts +3 -1
  80. package/dist/types/src/components/index.d.ts.map +1 -1
  81. package/dist/types/src/containers/BaseRegistryArticle/BaseRegistryArticle.d.ts +20 -0
  82. package/dist/types/src/containers/BaseRegistryArticle/BaseRegistryArticle.d.ts.map +1 -0
  83. package/dist/types/src/containers/BaseRegistryArticle/index.d.ts +2 -0
  84. package/dist/types/src/containers/BaseRegistryArticle/index.d.ts.map +1 -0
  85. package/dist/types/src/containers/LoadPluginDialog/LoadPluginDialog.d.ts +5 -0
  86. package/dist/types/src/containers/LoadPluginDialog/LoadPluginDialog.d.ts.map +1 -0
  87. package/dist/types/src/containers/LoadPluginDialog/index.d.ts +2 -0
  88. package/dist/types/src/containers/LoadPluginDialog/index.d.ts.map +1 -0
  89. package/dist/types/src/containers/PluginArticle/PluginArticle.d.ts +7 -0
  90. package/dist/types/src/containers/PluginArticle/PluginArticle.d.ts.map +1 -0
  91. package/dist/types/src/containers/PluginArticle/index.d.ts +2 -0
  92. package/dist/types/src/containers/PluginArticle/index.d.ts.map +1 -0
  93. package/dist/types/src/containers/PublicRegistryArticle/PublicRegistryArticle.d.ts +8 -0
  94. package/dist/types/src/containers/PublicRegistryArticle/PublicRegistryArticle.d.ts.map +1 -0
  95. package/dist/types/src/containers/PublicRegistryArticle/index.d.ts +2 -0
  96. package/dist/types/src/containers/PublicRegistryArticle/index.d.ts.map +1 -0
  97. package/dist/types/src/containers/RegistryArticle/RegistryArticle.d.ts +14 -0
  98. package/dist/types/src/containers/RegistryArticle/RegistryArticle.d.ts.map +1 -0
  99. package/dist/types/src/containers/RegistryArticle/index.d.ts +2 -0
  100. package/dist/types/src/containers/RegistryArticle/index.d.ts.map +1 -0
  101. package/dist/types/src/containers/RegistrySettingsContainer/RegistrySettingsContainer.d.ts +13 -0
  102. package/dist/types/src/containers/RegistrySettingsContainer/RegistrySettingsContainer.d.ts.map +1 -0
  103. package/dist/types/src/containers/RegistrySettingsContainer/index.d.ts +2 -0
  104. package/dist/types/src/containers/RegistrySettingsContainer/index.d.ts.map +1 -0
  105. package/dist/types/src/containers/index.d.ts +8 -0
  106. package/dist/types/src/containers/index.d.ts.map +1 -0
  107. package/dist/types/src/hooks/index.d.ts +9 -0
  108. package/dist/types/src/hooks/index.d.ts.map +1 -0
  109. package/dist/types/src/hooks/useAutoTags.d.ts +20 -0
  110. package/dist/types/src/hooks/useAutoTags.d.ts.map +1 -0
  111. package/dist/types/src/hooks/useCatalogEntry.d.ts +11 -0
  112. package/dist/types/src/hooks/useCatalogEntry.d.ts.map +1 -0
  113. package/dist/types/src/hooks/useDisableConfirmation.d.ts +19 -0
  114. package/dist/types/src/hooks/useDisableConfirmation.d.ts.map +1 -0
  115. package/dist/types/src/hooks/useInstalledVersionTag.d.ts +18 -0
  116. package/dist/types/src/hooks/useInstalledVersionTag.d.ts.map +1 -0
  117. package/dist/types/src/hooks/usePluginActions.d.ts +36 -0
  118. package/dist/types/src/hooks/usePluginActions.d.ts.map +1 -0
  119. package/dist/types/src/hooks/useRegistryPlugins.d.ts +15 -0
  120. package/dist/types/src/hooks/useRegistryPlugins.d.ts.map +1 -0
  121. package/dist/types/src/hooks/useUpdateAvailable.d.ts +18 -0
  122. package/dist/types/src/hooks/useUpdateAvailable.d.ts.map +1 -0
  123. package/dist/types/src/hooks/useVersionPicker.d.ts +21 -0
  124. package/dist/types/src/hooks/useVersionPicker.d.ts.map +1 -0
  125. package/dist/types/src/index.d.ts +1 -1
  126. package/dist/types/src/index.d.ts.map +1 -1
  127. package/dist/types/src/meta.d.ts +21 -3
  128. package/dist/types/src/meta.d.ts.map +1 -1
  129. package/dist/types/src/operations/index.d.ts +3 -0
  130. package/dist/types/src/operations/index.d.ts.map +1 -0
  131. package/dist/types/src/operations/open-plugin-registry.d.ts +5 -0
  132. package/dist/types/src/operations/open-plugin-registry.d.ts.map +1 -0
  133. package/dist/types/src/plugin.d.ts +4 -0
  134. package/dist/types/src/plugin.d.ts.map +1 -0
  135. package/dist/types/src/storage.d.ts +18 -0
  136. package/dist/types/src/storage.d.ts.map +1 -0
  137. package/dist/types/src/translations.d.ts +59 -16
  138. package/dist/types/src/translations.d.ts.map +1 -1
  139. package/dist/types/src/types.d.ts +30 -1
  140. package/dist/types/src/types.d.ts.map +1 -1
  141. package/dist/types/tsconfig.tsbuildinfo +1 -1
  142. package/package.json +76 -35
  143. package/src/RegistryPlugin.node.ts +19 -0
  144. package/src/RegistryPlugin.test.ts +24 -0
  145. package/src/RegistryPlugin.tsx +19 -25
  146. package/src/RegistryPlugin.workerd.ts +11 -0
  147. package/src/capabilities/app-graph-builder.ts +199 -136
  148. package/src/capabilities/dev-plugin-loader.ts +39 -0
  149. package/src/capabilities/index.ts +10 -4
  150. package/src/capabilities/operation-handler.ts +16 -0
  151. package/src/capabilities/react-surface.tsx +115 -75
  152. package/src/capabilities/settings.ts +34 -0
  153. package/src/categories.ts +44 -0
  154. package/src/commands/disable.ts +47 -0
  155. package/src/commands/enable.ts +44 -0
  156. package/src/commands/index.ts +14 -0
  157. package/src/commands/list.ts +41 -0
  158. package/src/commands/util.ts +24 -0
  159. package/src/components/DisableDependentsAlert/DisableDependentsAlert.tsx +69 -0
  160. package/src/components/DisableDependentsAlert/index.ts +5 -0
  161. package/src/components/{PluginDetail.stories.tsx → PluginDetail/PluginDetail.stories.tsx} +14 -11
  162. package/src/components/PluginDetail/PluginDetail.tsx +345 -0
  163. package/src/components/PluginDetail/index.ts +5 -0
  164. package/src/components/PluginFailureBadge/PluginFailureBadge.tsx +68 -0
  165. package/src/components/PluginFailureBadge/index.ts +5 -0
  166. package/src/components/PluginList/PluginItem.tsx +223 -0
  167. package/src/components/PluginList/PluginList.stories.tsx +90 -0
  168. package/src/components/PluginList/PluginList.tsx +52 -0
  169. package/src/components/PluginList/index.ts +5 -0
  170. package/src/components/RegistrySettings/RegistrySettings.tsx +120 -0
  171. package/src/components/RegistrySettings/index.ts +5 -0
  172. package/src/components/index.ts +3 -1
  173. package/src/containers/BaseRegistryArticle/BaseRegistryArticle.tsx +178 -0
  174. package/src/containers/BaseRegistryArticle/index.ts +5 -0
  175. package/src/containers/LoadPluginDialog/LoadPluginDialog.tsx +88 -0
  176. package/src/containers/LoadPluginDialog/index.ts +5 -0
  177. package/src/containers/PluginArticle/PluginArticle.tsx +117 -0
  178. package/src/containers/PluginArticle/index.ts +5 -0
  179. package/src/containers/PublicRegistryArticle/PublicRegistryArticle.tsx +193 -0
  180. package/src/containers/PublicRegistryArticle/index.ts +5 -0
  181. package/src/containers/RegistryArticle/RegistryArticle.tsx +53 -0
  182. package/src/containers/RegistryArticle/index.ts +5 -0
  183. package/src/containers/RegistrySettingsContainer/RegistrySettingsContainer.tsx +59 -0
  184. package/src/containers/RegistrySettingsContainer/index.ts +5 -0
  185. package/src/containers/index.ts +12 -0
  186. package/src/hooks/index.ts +12 -0
  187. package/src/hooks/useAutoTags.ts +52 -0
  188. package/src/hooks/useCatalogEntry.ts +25 -0
  189. package/src/hooks/useDisableConfirmation.ts +58 -0
  190. package/src/hooks/useInstalledVersionTag.ts +41 -0
  191. package/src/hooks/usePluginActions.ts +177 -0
  192. package/src/hooks/useRegistryPlugins.ts +29 -0
  193. package/src/hooks/useUpdateAvailable.ts +31 -0
  194. package/src/hooks/useVersionPicker.ts +112 -0
  195. package/src/index.ts +1 -1
  196. package/src/meta.ts +34 -8
  197. package/src/operations/index.ts +7 -0
  198. package/src/operations/open-plugin-registry.ts +21 -0
  199. package/src/plugin.ts +11 -0
  200. package/src/storage.ts +50 -0
  201. package/src/translations.ts +64 -15
  202. package/src/types.ts +33 -1
  203. package/dist/lib/browser/app-graph-builder-6CNBP3A4.mjs +0 -162
  204. package/dist/lib/browser/app-graph-builder-6CNBP3A4.mjs.map +0 -7
  205. package/dist/lib/browser/chunk-XPEFEID2.mjs +0 -19
  206. package/dist/lib/browser/chunk-XPEFEID2.mjs.map +0 -7
  207. package/dist/lib/browser/index.mjs +0 -69
  208. package/dist/lib/browser/index.mjs.map +0 -7
  209. package/dist/lib/browser/intent-resolver-LKNUYBTN.mjs +0 -23
  210. package/dist/lib/browser/intent-resolver-LKNUYBTN.mjs.map +0 -7
  211. package/dist/lib/browser/meta.json +0 -1
  212. package/dist/lib/browser/react-surface-IGCXOVE2.mjs +0 -359
  213. package/dist/lib/browser/react-surface-IGCXOVE2.mjs.map +0 -7
  214. package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
  215. package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
  216. package/dist/types/src/components/PluginDetail.d.ts +0 -9
  217. package/dist/types/src/components/PluginDetail.d.ts.map +0 -1
  218. package/dist/types/src/components/PluginDetail.stories.d.ts +0 -32
  219. package/dist/types/src/components/PluginDetail.stories.d.ts.map +0 -1
  220. package/dist/types/src/components/PluginItem.d.ts +0 -13
  221. package/dist/types/src/components/PluginItem.d.ts.map +0 -1
  222. package/dist/types/src/components/PluginList.d.ts +0 -8
  223. package/dist/types/src/components/PluginList.d.ts.map +0 -1
  224. package/dist/types/src/components/PluginList.stories.d.ts +0 -34
  225. package/dist/types/src/components/PluginList.stories.d.ts.map +0 -1
  226. package/dist/types/src/components/RegistryContainer.d.ts +0 -7
  227. package/dist/types/src/components/RegistryContainer.d.ts.map +0 -1
  228. package/src/capabilities/intent-resolver.ts +0 -27
  229. package/src/components/PluginDetail.tsx +0 -82
  230. package/src/components/PluginItem.tsx +0 -120
  231. package/src/components/PluginList.stories.tsx +0 -80
  232. package/src/components/PluginList.tsx +0 -24
  233. package/src/components/RegistryContainer.tsx +0 -76
@@ -1,82 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import React from 'react';
6
-
7
- import { type Plugin } from '@dxos/app-framework';
8
- import { Icon, Input, Link, useTranslation } from '@dxos/react-ui';
9
- import { StackItem } from '@dxos/react-ui-stack';
10
- import { getStyles, mx } from '@dxos/react-ui-theme';
11
-
12
- import { meta } from '../meta';
13
-
14
- export type PluginDetailProps = {
15
- plugin: Plugin;
16
- enabled?: boolean;
17
- onEnable?: () => void;
18
- };
19
-
20
- export const PluginDetail = ({ plugin, enabled, onEnable }: PluginDetailProps) => {
21
- const { t } = useTranslation(meta.id);
22
- const {
23
- id,
24
- name,
25
- description,
26
- homePage,
27
- source,
28
- screenshots,
29
- icon = 'ph--circle--regular',
30
- iconHue = 'neutral',
31
- } = plugin.meta;
32
- const styles = getStyles(iconHue);
33
-
34
- return (
35
- <StackItem.Content scrollable>
36
- <div role='none' className='grid grid-cols-[min-content_1fr] gap-4 container-max-width p-4'>
37
- <div role='none'>
38
- <Icon classNames={mx('p-1 rounded', styles.bg, styles.icon)} icon={icon} size={14} />
39
- </div>
40
- <div role='none' className='flex flex-col gap-6'>
41
- <div role='none' className='grid grid-cols-[1fr_min-content] gap-x-3 is-full pbs-1'>
42
- <h2 className='text-xl'>{name}</h2>
43
- <Input.Root>
44
- <Input.Switch classNames='self-center' checked={enabled} onClick={onEnable} />
45
- </Input.Root>
46
- <p className='pbs-0.5 text-sm text-description'>{id}</p>
47
- </div>
48
-
49
- <div role='none'>
50
- <p className='text-description'>{description}</p>
51
- </div>
52
-
53
- {screenshots && screenshots.length > 0 && (
54
- <div role='none' className='flex flex-col gap-2'>
55
- <h2>Preview</h2>
56
- <img src={screenshots[0]} alt={name} className='aspect-video object-fit' />
57
- </div>
58
- )}
59
-
60
- <div role='none' className='flex flex-col gap-2'>
61
- <h2>Resources</h2>
62
- <div className='flex gap-2'>
63
- {homePage && (
64
- <Link href={homePage} target='_blank' rel='noreferrer' classNames='text-sm text-description'>
65
- {t('home page label')}
66
- <Icon icon='ph--arrow-square-out--bold' size={3} classNames='inline-block leading-none mli-1' />
67
- </Link>
68
- )}
69
-
70
- {source && (
71
- <Link href={source} target='_blank' rel='noreferrer' classNames='text-sm text-description'>
72
- {t('source label')}
73
- <Icon icon='ph--arrow-square-out--bold' size={3} classNames='inline-block leading-none mli-1' />
74
- </Link>
75
- )}
76
- </div>
77
- </div>
78
- </div>
79
- </div>
80
- </StackItem.Content>
81
- );
82
- };
@@ -1,120 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import React, { type MouseEvent, useCallback } from 'react';
6
-
7
- import { type Plugin } from '@dxos/app-framework';
8
- import { type ChromaticPalette, Icon, IconButton, Input, Link, ListItem, Tag, useTranslation } from '@dxos/react-ui';
9
- import { descriptionText, mx } from '@dxos/react-ui-theme';
10
- import { getStyles } from '@dxos/react-ui-theme';
11
-
12
- import { meta } from '../meta';
13
- import { type RegistryTagType } from '../types';
14
-
15
- export type PluginItemProps = {
16
- plugin: Plugin;
17
- installed?: readonly string[];
18
- enabled?: readonly string[];
19
- onClick?: (id: string) => void;
20
- onChange?: (id: string, enabled: boolean) => void;
21
- hasSettings?: (id: string) => boolean;
22
- onSettings?: (id: string) => void;
23
- };
24
-
25
- export const PluginItem = ({
26
- plugin,
27
- enabled = [],
28
- onClick,
29
- onChange,
30
- hasSettings: hasSettingsParam,
31
- onSettings,
32
- }: PluginItemProps) => {
33
- const { t } = useTranslation(meta.id);
34
- const { id, name, description, tags, icon = 'ph--circle--regular', iconHue = 'neutral' } = plugin.meta;
35
- const isEnabled = enabled.includes(id);
36
- const inputId = `${id}-input`;
37
- const labelId = `${id}-label`;
38
- const descriptionId = `${id}-description`;
39
- const handleClick = useCallback(() => onClick?.(id), [id, onClick]);
40
-
41
- const handleChange = useCallback(
42
- (event: MouseEvent) => {
43
- event.stopPropagation();
44
- onChange?.(id, !isEnabled);
45
- },
46
- [id, isEnabled, onChange],
47
- );
48
-
49
- const hasSettings = hasSettingsParam?.(id) ?? false;
50
- const handleSettings = useCallback(() => onSettings?.(id), [id, onSettings]);
51
- const styles = getStyles(iconHue);
52
- const gridCols = 'grid grid-cols-[5rem_1fr]';
53
- const gridRows = 'grid grid-rows-[40px_1fr_min-content_40px]';
54
-
55
- return (
56
- <ListItem.Root
57
- key={id}
58
- labelId={labelId}
59
- data-testid={`pluginList.${id}`}
60
- aria-describedby={descriptionId}
61
- classNames={mx(gridCols, 'bs-[12rem] is-full gap-3 pie-2 border border-separator rounded-md overflow-hidden')}
62
- >
63
- <div className={mx(gridRows, 'justify-center rounded-l-md', styles.bg)}>
64
- <div />
65
- <Icon classNames={mx('cursor-pointer', styles.icon)} icon={icon} size={14} onClick={handleClick} />
66
- </div>
67
-
68
- <div className={mx(gridRows)}>
69
- <div className='flex items-center overflow-hidden cursor-pointer' onClick={handleClick}>
70
- <span className='text-lg truncate'>{name ?? id}</span>
71
- </div>
72
-
73
- <div>
74
- <p className={mx(descriptionText, 'line-clamp-4 min-is-0')}>{description}</p>
75
- </div>
76
-
77
- <div className='flex -mis-0.5 overflow-x-auto scrollbar-none'>
78
- {tags?.map((tag) => (
79
- <Tag key={tag} palette={tagColors[tag as RegistryTagType]} classNames='text-xs uppercase font-thin'>
80
- {tag}
81
- </Tag>
82
- ))}
83
- </div>
84
-
85
- <div className='flex gap-2 items-center text-sm'>
86
- <IconButton
87
- aria-describedby={descriptionId}
88
- classNames='cursor-pointer'
89
- icon='ph--gear--regular'
90
- label={t('settings label')}
91
- iconOnly
92
- size={4}
93
- onClick={handleSettings}
94
- disabled={!hasSettings}
95
- />
96
-
97
- <Link aria-describedby={descriptionId} classNames='text-description cursor-pointer' onClick={handleClick}>
98
- {t('details label')}
99
- </Link>
100
-
101
- <div className='grow' />
102
- <div className='pie-1'>
103
- <Input.Root id={inputId}>
104
- <Input.Switch classNames='self-center' checked={isEnabled} onClick={handleChange} />
105
- </Input.Root>
106
- </div>
107
- </div>
108
- </div>
109
- </ListItem.Root>
110
- );
111
- };
112
-
113
- const tagColors: Record<RegistryTagType, ChromaticPalette> = {
114
- new: 'rose',
115
- beta: 'teal',
116
- labs: 'blue',
117
- popular: 'green',
118
- featured: 'pink',
119
- experimental: 'amber',
120
- };
@@ -1,80 +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 { type Plugin, definePlugin } from '@dxos/app-framework';
9
- import { faker } from '@dxos/random';
10
- import { withLayout, withTheme } from '@dxos/react-ui/testing';
11
- import { getHashHue } from '@dxos/react-ui-theme';
12
-
13
- import { translations } from '../translations';
14
- import { RegistryTagType } from '../types';
15
-
16
- import { PluginList } from './PluginList';
17
-
18
- faker.seed(1);
19
-
20
- const icons = [
21
- 'ph--bug--regular',
22
- 'ph--compass--regular',
23
- 'ph--kanban--regular',
24
- 'ph--table--regular',
25
- 'ph--gear--regular',
26
- 'ph--github-logo--regular',
27
- ];
28
-
29
- const DefaultStory = () => {
30
- const [plugins] = useState<Plugin[]>(
31
- faker.helpers.multiple(
32
- () =>
33
- definePlugin(
34
- {
35
- id: `dxos.org/plugin/plugin-${faker.string.uuid()}`,
36
- name: `${faker.commerce.productName()}`,
37
- description: faker.lorem.sentences(Math.ceil(Math.random() * 3)),
38
- tags: faker.helpers.uniqueArray(RegistryTagType.literals as any, Math.floor(Math.random() * 3)),
39
- icon: faker.helpers.arrayElement(icons),
40
- iconHue: getHashHue(faker.string.uuid()),
41
- homePage: faker.datatype.boolean({ probability: 0.5 }) ? faker.internet.url() : undefined,
42
- source: faker.internet.url(),
43
- },
44
- () => [],
45
- )(),
46
- { count: 32 },
47
- ),
48
- );
49
- const [enabled, setEnabled] = useState<string[]>([]);
50
-
51
- const handleChange = (id: string, enabled: boolean) => {
52
- setEnabled((plugins) => (enabled ? [...plugins, id] : plugins.filter((plugin) => plugin === id)));
53
- };
54
-
55
- return <PluginList plugins={plugins} enabled={enabled} onChange={handleChange} hasSettings={() => true} />;
56
- };
57
-
58
- const meta = {
59
- title: 'plugins/plugin-registry/PluginList',
60
- component: PluginList,
61
- render: DefaultStory,
62
- parameters: {
63
- translations,
64
- },
65
- } satisfies Meta<typeof PluginList>;
66
-
67
- export default meta;
68
-
69
- type Story = StoryObj<typeof meta>;
70
-
71
- export const Default: Story = {
72
- decorators: [withTheme, withLayout({ container: 'column', scroll: true })],
73
- };
74
-
75
- export const FullScreen: Story = {
76
- decorators: [withTheme, withLayout({ scroll: true })],
77
- parameters: {
78
- layout: 'fullscreen',
79
- },
80
- };
@@ -1,24 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- import React from 'react';
6
-
7
- import { type Plugin } from '@dxos/app-framework';
8
- import { List } from '@dxos/react-ui';
9
-
10
- import { PluginItem, type PluginItemProps } from './PluginItem';
11
-
12
- export type PluginListProps = Omit<PluginItemProps, 'plugin'> & {
13
- plugins?: readonly Plugin[];
14
- };
15
-
16
- export const PluginList = ({ plugins = [], ...props }: PluginListProps) => {
17
- return (
18
- <List classNames='grid grid-cols-[repeat(auto-fill,minmax(18rem,1fr))] gap-4 p-4'>
19
- {plugins.map((plugin) => (
20
- <PluginItem key={plugin.meta.id} plugin={plugin} {...props} />
21
- ))}
22
- </List>
23
- );
24
- };
@@ -1,76 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- import React, { useCallback, useMemo } from 'react';
6
-
7
- import { Capabilities, LayoutAction, type Plugin, SettingsAction, createIntent } from '@dxos/app-framework';
8
- import { useCapability, useIntentDispatcher, usePluginManager } from '@dxos/app-framework/react';
9
- import { ObservabilityAction } from '@dxos/plugin-observability/types';
10
- import { StackItem } from '@dxos/react-ui-stack';
11
-
12
- import { PluginList } from './PluginList';
13
-
14
- const sortByPluginMeta = ({ meta: { name: a = '' } }: Plugin, { meta: { name: b = '' } }: Plugin) => a.localeCompare(b);
15
-
16
- export const RegistryContainer = ({ id, plugins: _plugins }: { id: string; plugins: Plugin[] }) => {
17
- const manager = usePluginManager();
18
- const { dispatchPromise: dispatch } = useIntentDispatcher();
19
- const plugins = useMemo(() => _plugins.sort(sortByPluginMeta), [_plugins]);
20
- const settingsStore = useCapability(Capabilities.SettingsStore);
21
-
22
- // TODO(wittjosiah): Factor out to an intent?
23
- const handleChange = useCallback(
24
- async (id: string, enabled: boolean) => {
25
- if (enabled) {
26
- await manager.enable(id);
27
- } else {
28
- await manager.disable(id);
29
- }
30
-
31
- await dispatch(
32
- createIntent(ObservabilityAction.SendEvent, {
33
- name: 'plugins.toggle',
34
- properties: {
35
- plugin: id,
36
- enabled,
37
- },
38
- }),
39
- );
40
- },
41
- [dispatch, manager],
42
- );
43
-
44
- const handleClick = useCallback(
45
- (pluginId: string) =>
46
- dispatch(
47
- createIntent(LayoutAction.Open, {
48
- part: 'main',
49
- // TODO(wittjosiah): `/` currently is not supported in ids.
50
- subject: [pluginId.replaceAll('/', ':')],
51
- options: { pivotId: id, positioning: 'end' },
52
- }),
53
- ),
54
- [dispatch, id],
55
- );
56
-
57
- const hasSettings = useCallback((pluginId: string) => !!settingsStore.getStore(pluginId), [settingsStore]);
58
-
59
- const handleSettings = useCallback(
60
- (pluginId: string) => dispatch(createIntent(SettingsAction.Open, { plugin: pluginId })),
61
- [dispatch],
62
- );
63
-
64
- return (
65
- <StackItem.Content scrollable>
66
- <PluginList
67
- plugins={plugins}
68
- enabled={manager.enabled}
69
- onClick={handleClick}
70
- onChange={handleChange}
71
- hasSettings={hasSettings}
72
- onSettings={handleSettings}
73
- />
74
- </StackItem.Content>
75
- );
76
- };