@dxos/plugin-thread 0.7.4 → 0.7.5-labs.a279d8c

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 (197) hide show
  1. package/dist/lib/browser/ThreadContainer-4VLBSBI7.mjs +19 -0
  2. package/dist/lib/browser/ThreadContainer-4VLBSBI7.mjs.map +7 -0
  3. package/dist/lib/browser/app-graph-builder-Q7A2ZRUA.mjs +121 -0
  4. package/dist/lib/browser/app-graph-builder-Q7A2ZRUA.mjs.map +7 -0
  5. package/dist/lib/browser/chunk-2B3EXYZ7.mjs +18 -0
  6. package/dist/lib/browser/chunk-2B3EXYZ7.mjs.map +7 -0
  7. package/dist/lib/browser/{chunk-ENERBDYI.mjs → chunk-636QDHE3.mjs} +3 -3
  8. package/dist/lib/browser/chunk-636QDHE3.mjs.map +7 -0
  9. package/dist/lib/browser/chunk-BNEWNQBO.mjs +71 -0
  10. package/dist/lib/browser/chunk-BNEWNQBO.mjs.map +7 -0
  11. package/dist/lib/browser/{chunk-52HWDLBR.mjs → chunk-GQONSZ3J.mjs} +31 -117
  12. package/dist/lib/browser/chunk-GQONSZ3J.mjs.map +7 -0
  13. package/dist/lib/browser/chunk-NAO3LZMZ.mjs +16 -0
  14. package/dist/lib/browser/chunk-NAO3LZMZ.mjs.map +7 -0
  15. package/dist/lib/browser/chunk-NO5AZLUZ.mjs +81 -0
  16. package/dist/lib/browser/chunk-NO5AZLUZ.mjs.map +7 -0
  17. package/dist/lib/browser/index.mjs +147 -1094
  18. package/dist/lib/browser/index.mjs.map +4 -4
  19. package/dist/lib/browser/intent-resolver-PIEZ3LKQ.mjs +275 -0
  20. package/dist/lib/browser/intent-resolver-PIEZ3LKQ.mjs.map +7 -0
  21. package/dist/lib/browser/markdown-2NBXKXCY.mjs +112 -0
  22. package/dist/lib/browser/markdown-2NBXKXCY.mjs.map +7 -0
  23. package/dist/lib/browser/meta.json +1 -1
  24. package/dist/lib/browser/react-surface-CHCZO4TI.mjs +412 -0
  25. package/dist/lib/browser/react-surface-CHCZO4TI.mjs.map +7 -0
  26. package/dist/lib/browser/settings-TKOPRXSU.mjs +22 -0
  27. package/dist/lib/browser/settings-TKOPRXSU.mjs.map +7 -0
  28. package/dist/lib/browser/state-GNFUURIC.mjs +33 -0
  29. package/dist/lib/browser/state-GNFUURIC.mjs.map +7 -0
  30. package/dist/lib/browser/types.mjs +6 -4
  31. package/dist/lib/node/{ThreadArticle-I7ADXDW3.cjs → ThreadContainer-VOYLV4UL.cjs} +14 -13
  32. package/dist/lib/node/ThreadContainer-VOYLV4UL.cjs.map +7 -0
  33. package/dist/lib/node/app-graph-builder-ZXW5KUDK.cjs +135 -0
  34. package/dist/lib/node/app-graph-builder-ZXW5KUDK.cjs.map +7 -0
  35. package/dist/lib/node/{chunk-YCDM2SZM.cjs → chunk-6PUGKCPR.cjs} +76 -165
  36. package/dist/lib/node/chunk-6PUGKCPR.cjs.map +7 -0
  37. package/dist/lib/node/chunk-AUVKOX5Q.cjs +101 -0
  38. package/dist/lib/node/chunk-AUVKOX5Q.cjs.map +7 -0
  39. package/dist/lib/node/chunk-AWSTZ2KN.cjs +93 -0
  40. package/dist/lib/node/chunk-AWSTZ2KN.cjs.map +7 -0
  41. package/dist/lib/node/{chunk-IC2NICNC.cjs → chunk-F735VMTN.cjs} +7 -7
  42. package/dist/lib/node/chunk-F735VMTN.cjs.map +7 -0
  43. package/dist/lib/node/{meta.cjs → chunk-FPWNZ6TB.cjs} +13 -10
  44. package/dist/lib/node/chunk-FPWNZ6TB.cjs.map +7 -0
  45. package/dist/lib/node/{ThreadMain-MRNJC3TI.cjs → chunk-ZRN7B26W.cjs} +26 -23
  46. package/dist/lib/node/chunk-ZRN7B26W.cjs.map +7 -0
  47. package/dist/lib/node/index.cjs +142 -1083
  48. package/dist/lib/node/index.cjs.map +4 -4
  49. package/dist/lib/node/intent-resolver-X5O3SVLF.cjs +287 -0
  50. package/dist/lib/node/intent-resolver-X5O3SVLF.cjs.map +7 -0
  51. package/dist/lib/node/markdown-FWRKMSKV.cjs +122 -0
  52. package/dist/lib/node/markdown-FWRKMSKV.cjs.map +7 -0
  53. package/dist/lib/node/meta.json +1 -1
  54. package/dist/lib/node/react-surface-LO7S2HPR.cjs +414 -0
  55. package/dist/lib/node/react-surface-LO7S2HPR.cjs.map +7 -0
  56. package/dist/lib/node/settings-TH4YSUVU.cjs +36 -0
  57. package/dist/lib/node/settings-TH4YSUVU.cjs.map +7 -0
  58. package/dist/lib/node/state-TQWEZ6B3.cjs +49 -0
  59. package/dist/lib/node/state-TQWEZ6B3.cjs.map +7 -0
  60. package/dist/lib/node/types.cjs +6 -4
  61. package/dist/lib/node/types.cjs.map +2 -2
  62. package/dist/lib/node-esm/ThreadContainer-7DZY2MWA.mjs +20 -0
  63. package/dist/lib/node-esm/ThreadContainer-7DZY2MWA.mjs.map +7 -0
  64. package/dist/lib/node-esm/app-graph-builder-ATS6HGE6.mjs +122 -0
  65. package/dist/lib/node-esm/app-graph-builder-ATS6HGE6.mjs.map +7 -0
  66. package/dist/lib/node-esm/chunk-B3CF35MY.mjs +82 -0
  67. package/dist/lib/node-esm/chunk-B3CF35MY.mjs.map +7 -0
  68. package/dist/lib/node-esm/{chunk-JG7MXH6O.mjs → chunk-DYFIKKDT.mjs} +31 -117
  69. package/dist/lib/node-esm/chunk-DYFIKKDT.mjs.map +7 -0
  70. package/dist/lib/node-esm/{chunk-7QRGG25F.mjs → chunk-FXUATCLW.mjs} +3 -3
  71. package/dist/lib/node-esm/chunk-FXUATCLW.mjs.map +7 -0
  72. package/dist/lib/node-esm/chunk-GS2OILYF.mjs +20 -0
  73. package/dist/lib/node-esm/chunk-GS2OILYF.mjs.map +7 -0
  74. package/dist/lib/node-esm/chunk-HLWJTUWZ.mjs +73 -0
  75. package/dist/lib/node-esm/chunk-HLWJTUWZ.mjs.map +7 -0
  76. package/dist/lib/node-esm/chunk-ZJITX3TO.mjs +17 -0
  77. package/dist/lib/node-esm/chunk-ZJITX3TO.mjs.map +7 -0
  78. package/dist/lib/node-esm/index.mjs +147 -1094
  79. package/dist/lib/node-esm/index.mjs.map +4 -4
  80. package/dist/lib/node-esm/intent-resolver-XJWT5X6T.mjs +276 -0
  81. package/dist/lib/node-esm/intent-resolver-XJWT5X6T.mjs.map +7 -0
  82. package/dist/lib/node-esm/markdown-6AQFDAW3.mjs +113 -0
  83. package/dist/lib/node-esm/markdown-6AQFDAW3.mjs.map +7 -0
  84. package/dist/lib/node-esm/meta.json +1 -1
  85. package/dist/lib/node-esm/react-surface-LAF3QIPB.mjs +413 -0
  86. package/dist/lib/node-esm/react-surface-LAF3QIPB.mjs.map +7 -0
  87. package/dist/lib/node-esm/settings-KEDRR7RM.mjs +23 -0
  88. package/dist/lib/node-esm/settings-KEDRR7RM.mjs.map +7 -0
  89. package/dist/lib/node-esm/state-7MLR27YG.mjs +34 -0
  90. package/dist/lib/node-esm/state-7MLR27YG.mjs.map +7 -0
  91. package/dist/lib/node-esm/types.mjs +6 -4
  92. package/dist/types/src/ThreadPlugin.d.ts +1 -3
  93. package/dist/types/src/ThreadPlugin.d.ts.map +1 -1
  94. package/dist/types/src/capabilities/app-graph-builder.d.ts +180 -0
  95. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -0
  96. package/dist/types/src/capabilities/capabilities.d.ts +15 -0
  97. package/dist/types/src/capabilities/capabilities.d.ts.map +1 -0
  98. package/dist/types/src/capabilities/index.d.ts +187 -0
  99. package/dist/types/src/capabilities/index.d.ts.map +1 -0
  100. package/dist/types/src/capabilities/intent-resolver.d.ts +4 -0
  101. package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -0
  102. package/dist/types/src/capabilities/markdown.d.ts +4 -0
  103. package/dist/types/src/capabilities/markdown.d.ts.map +1 -0
  104. package/dist/types/src/capabilities/react-surface.d.ts +4 -0
  105. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
  106. package/dist/types/src/capabilities/settings.d.ts +4 -0
  107. package/dist/types/src/capabilities/settings.d.ts.map +1 -0
  108. package/dist/types/src/capabilities/state.d.ts +7 -0
  109. package/dist/types/src/capabilities/state.d.ts.map +1 -0
  110. package/dist/types/src/components/Chat.stories.d.ts.map +1 -1
  111. package/dist/types/src/components/ChatContainer.d.ts.map +1 -1
  112. package/dist/types/src/components/CommentContainer.d.ts +1 -1
  113. package/dist/types/src/components/CommentContainer.d.ts.map +1 -1
  114. package/dist/types/src/components/CommentsContainer.d.ts +2 -7
  115. package/dist/types/src/components/CommentsContainer.d.ts.map +1 -1
  116. package/dist/types/src/components/MessageContainer.d.ts.map +1 -1
  117. package/dist/types/src/components/ThreadComplementary.d.ts +1 -6
  118. package/dist/types/src/components/ThreadComplementary.d.ts.map +1 -1
  119. package/dist/types/src/components/ThreadContainer.d.ts +7 -0
  120. package/dist/types/src/components/ThreadContainer.d.ts.map +1 -0
  121. package/dist/types/src/components/index.d.ts +3 -15
  122. package/dist/types/src/components/index.d.ts.map +1 -1
  123. package/dist/types/src/components/testing.d.ts +50 -66
  124. package/dist/types/src/components/testing.d.ts.map +1 -1
  125. package/dist/types/src/components/types.d.ts +5 -5
  126. package/dist/types/src/components/types.d.ts.map +1 -1
  127. package/dist/types/src/extensions/threads.d.ts +2 -2
  128. package/dist/types/src/extensions/threads.d.ts.map +1 -1
  129. package/dist/types/src/hooks/analytics.d.ts.map +1 -1
  130. package/dist/types/src/index.d.ts +1 -3
  131. package/dist/types/src/index.d.ts.map +1 -1
  132. package/dist/types/src/meta.d.ts +1 -2
  133. package/dist/types/src/meta.d.ts.map +1 -1
  134. package/dist/types/src/translations.d.ts +3 -0
  135. package/dist/types/src/translations.d.ts.map +1 -1
  136. package/dist/types/src/types.d.ts +86 -22
  137. package/dist/types/src/types.d.ts.map +1 -1
  138. package/dist/types/tsconfig.tsbuildinfo +1 -0
  139. package/package.json +30 -38
  140. package/src/ThreadPlugin.tsx +109 -620
  141. package/src/capabilities/app-graph-builder.ts +120 -0
  142. package/src/capabilities/capabilities.ts +19 -0
  143. package/src/capabilities/index.ts +14 -0
  144. package/src/capabilities/intent-resolver.ts +223 -0
  145. package/src/capabilities/markdown.ts +18 -0
  146. package/src/capabilities/react-surface.tsx +61 -0
  147. package/src/capabilities/settings.ts +14 -0
  148. package/src/capabilities/state.ts +25 -0
  149. package/src/components/Chat.stories.tsx +26 -22
  150. package/src/components/ChatContainer.tsx +13 -11
  151. package/src/components/CommentContainer.tsx +21 -32
  152. package/src/components/CommentsContainer.tsx +1 -17
  153. package/src/components/MessageContainer.tsx +7 -5
  154. package/src/components/ThreadComplementary.tsx +88 -68
  155. package/src/components/ThreadContainer.tsx +22 -0
  156. package/src/components/index.ts +1 -2
  157. package/src/components/testing.ts +26 -22
  158. package/src/components/types.ts +5 -5
  159. package/src/extensions/threads.ts +16 -25
  160. package/src/hooks/analytics.ts +6 -10
  161. package/src/index.ts +1 -5
  162. package/src/meta.ts +1 -1
  163. package/src/translations.ts +1 -0
  164. package/src/types.ts +70 -38
  165. package/dist/lib/browser/ThreadArticle-6IXTL7CH.mjs +0 -18
  166. package/dist/lib/browser/ThreadArticle-6IXTL7CH.mjs.map +0 -7
  167. package/dist/lib/browser/ThreadMain-4IAS67KE.mjs +0 -26
  168. package/dist/lib/browser/ThreadMain-4IAS67KE.mjs.map +0 -7
  169. package/dist/lib/browser/chunk-52HWDLBR.mjs.map +0 -7
  170. package/dist/lib/browser/chunk-ENERBDYI.mjs.map +0 -7
  171. package/dist/lib/browser/chunk-XUHNZID5.mjs +0 -20
  172. package/dist/lib/browser/chunk-XUHNZID5.mjs.map +0 -7
  173. package/dist/lib/browser/meta.mjs +0 -11
  174. package/dist/lib/browser/meta.mjs.map +0 -7
  175. package/dist/lib/node/ThreadArticle-I7ADXDW3.cjs.map +0 -7
  176. package/dist/lib/node/ThreadMain-MRNJC3TI.cjs.map +0 -7
  177. package/dist/lib/node/chunk-IC2NICNC.cjs.map +0 -7
  178. package/dist/lib/node/chunk-XFO6D2LG.cjs +0 -39
  179. package/dist/lib/node/chunk-XFO6D2LG.cjs.map +0 -7
  180. package/dist/lib/node/chunk-YCDM2SZM.cjs.map +0 -7
  181. package/dist/lib/node/meta.cjs.map +0 -7
  182. package/dist/lib/node-esm/ThreadArticle-CJHYMF2W.mjs +0 -19
  183. package/dist/lib/node-esm/ThreadArticle-CJHYMF2W.mjs.map +0 -7
  184. package/dist/lib/node-esm/ThreadMain-VISGW4IF.mjs +0 -27
  185. package/dist/lib/node-esm/ThreadMain-VISGW4IF.mjs.map +0 -7
  186. package/dist/lib/node-esm/chunk-7QRGG25F.mjs.map +0 -7
  187. package/dist/lib/node-esm/chunk-I5MU54RT.mjs +0 -21
  188. package/dist/lib/node-esm/chunk-I5MU54RT.mjs.map +0 -7
  189. package/dist/lib/node-esm/chunk-JG7MXH6O.mjs.map +0 -7
  190. package/dist/lib/node-esm/meta.mjs +0 -12
  191. package/dist/lib/node-esm/meta.mjs.map +0 -7
  192. package/dist/types/src/components/ThreadArticle.d.ts +0 -5
  193. package/dist/types/src/components/ThreadArticle.d.ts.map +0 -1
  194. package/dist/types/src/components/ThreadMain.d.ts +0 -7
  195. package/dist/types/src/components/ThreadMain.d.ts.map +0 -1
  196. package/src/components/ThreadArticle.tsx +0 -18
  197. package/src/components/ThreadMain.tsx +0 -27
@@ -1,455 +1,34 @@
1
1
  import {
2
- ThreadAction
3
- } from "./chunk-XUHNZID5.mjs";
2
+ AppGraphBuilder,
3
+ IntentResolver,
4
+ Markdown,
5
+ ReactSurface,
6
+ ThreadSettings,
7
+ ThreadState
8
+ } from "./chunk-2B3EXYZ7.mjs";
9
+ import "./chunk-NAO3LZMZ.mjs";
4
10
  import {
5
- ChatContainer,
6
- ChatHeading,
7
- MessageContainer,
8
- command,
9
- getMessageMetadata,
10
11
  useAnalyticsCallback,
11
12
  useOnEditAnalytics,
12
13
  useStatus
13
- } from "./chunk-52HWDLBR.mjs";
14
+ } from "./chunk-BNEWNQBO.mjs";
15
+ import {
16
+ ThreadAction
17
+ } from "./chunk-NO5AZLUZ.mjs";
14
18
  import {
15
19
  THREAD_ITEM,
16
20
  THREAD_PLUGIN,
17
- meta_default
18
- } from "./chunk-ENERBDYI.mjs";
21
+ meta
22
+ } from "./chunk-636QDHE3.mjs";
19
23
 
20
24
  // packages/plugins/plugin-thread/src/ThreadPlugin.tsx
21
- import React5 from "react";
22
- import { isLayoutParts, LayoutAction as LayoutAction2, NavigationAction, parseIntentPlugin, parseMetadataResolverPlugin, parseNavigationPlugin, resolvePlugin } from "@dxos/app-framework";
23
- import { LocalStorageStore } from "@dxos/local-storage";
24
- import { log } from "@dxos/log";
25
- import { parseClientPlugin } from "@dxos/plugin-client";
26
- import { createExtension, isActionGroup, toSignal } from "@dxos/plugin-graph";
27
- import { ObservabilityAction } from "@dxos/plugin-observability/meta";
28
- import { memoizeQuery, SpaceAction } from "@dxos/plugin-space";
29
- import { ChannelType as ChannelType2, MessageType as MessageType2, ThreadType as ThreadType2 } from "@dxos/plugin-space/types";
30
- import { create as create2, fullyQualifiedId as fullyQualifiedId5, getSpace as getSpace3, getTypename, loadObjectReferences, parseId, SpaceState } from "@dxos/react-client/echo";
25
+ import { allOf, Capabilities, contributes, createIntent, defineModule, definePlugin, Events, oneOf } from "@dxos/app-framework";
26
+ import { ClientCapabilities, ClientEvents } from "@dxos/plugin-client";
27
+ import { DeckCapabilities } from "@dxos/plugin-deck";
28
+ import { ChannelType as ChannelType2, MessageType, ThreadType } from "@dxos/plugin-space/types";
29
+ import { RefArray } from "@dxos/react-client/echo";
31
30
  import { translations as threadTranslations } from "@dxos/react-ui-thread";
32
31
 
33
- // packages/plugins/plugin-thread/src/components/index.ts
34
- import { lazy } from "react";
35
-
36
- // packages/plugins/plugin-thread/src/components/CommentContainer.tsx
37
- import { CheckCircle, X } from "@phosphor-icons/react";
38
- import React, { useCallback, useMemo, useRef, useState } from "react";
39
- import { create } from "@dxos/live-object";
40
- import { MessageType } from "@dxos/plugin-space/types";
41
- import { fullyQualifiedId, getSpace, useMembers } from "@dxos/react-client/echo";
42
- import { useIdentity } from "@dxos/react-client/halo";
43
- import { Button, Tag, Tooltip, useThemeContext, useTranslation } from "@dxos/react-ui";
44
- import { createBasicExtensions, createThemeExtensions, listener } from "@dxos/react-ui-editor";
45
- import { getSize, hoverableControlItem, hoverableControls, hoverableFocusedWithinControls, mx } from "@dxos/react-ui-theme";
46
- import { MessageTextbox, Thread, ThreadFooter, ThreadHeading } from "@dxos/react-ui-thread";
47
- import { nonNullable } from "@dxos/util";
48
- var sizeClass = getSize(4);
49
- var commentControlClassNames = "!p-1 !min-bs-0 transition-opacity";
50
- var ToggleResolvedButton = ({ isResolved, onResolve }) => {
51
- const { t } = useTranslation(THREAD_PLUGIN);
52
- const label = t(isResolved ? "mark as unresolved label" : "mark as resolved label");
53
- return /* @__PURE__ */ React.createElement(Tooltip.Root, null, /* @__PURE__ */ React.createElement(Tooltip.Trigger, {
54
- asChild: true
55
- }, /* @__PURE__ */ React.createElement(Button, {
56
- variant: "ghost",
57
- "data-testid": "thread.toggle-resolved",
58
- onClick: onResolve,
59
- classNames: [
60
- commentControlClassNames,
61
- !isResolved && hoverableControlItem
62
- ]
63
- }, /* @__PURE__ */ React.createElement("span", {
64
- className: "sr-only"
65
- }, label), isResolved ? /* @__PURE__ */ React.createElement(CheckCircle, {
66
- className: sizeClass,
67
- weight: "fill"
68
- }) : /* @__PURE__ */ React.createElement(CheckCircle, {
69
- className: sizeClass
70
- }))), /* @__PURE__ */ React.createElement(Tooltip.Portal, null, /* @__PURE__ */ React.createElement(Tooltip.Content, {
71
- classNames: "z-[21]"
72
- }, label, /* @__PURE__ */ React.createElement(Tooltip.Arrow, null))));
73
- };
74
- var DeleteThreadButton = ({ onDelete }) => {
75
- const { t } = useTranslation(THREAD_PLUGIN);
76
- const label = t("delete thread label");
77
- return /* @__PURE__ */ React.createElement(Tooltip.Root, null, /* @__PURE__ */ React.createElement(Tooltip.Trigger, {
78
- asChild: true
79
- }, /* @__PURE__ */ React.createElement(Button, {
80
- variant: "ghost",
81
- "data-testid": "thread.delete",
82
- onClick: onDelete,
83
- classNames: [
84
- commentControlClassNames,
85
- hoverableControlItem
86
- ]
87
- }, /* @__PURE__ */ React.createElement("span", {
88
- className: "sr-only"
89
- }, label), /* @__PURE__ */ React.createElement(X, {
90
- className: sizeClass
91
- }))), /* @__PURE__ */ React.createElement(Tooltip.Portal, null, /* @__PURE__ */ React.createElement(Tooltip.Content, {
92
- classNames: "z-[21]"
93
- }, label, /* @__PURE__ */ React.createElement(Tooltip.Arrow, null))));
94
- };
95
- var CommentContainer = ({ thread, detached, context, current, onAttend, onThreadDelete, onMessageDelete, onResolve, onComment }) => {
96
- const identity = useIdentity();
97
- const space = getSpace(thread);
98
- const members = useMembers(space?.key);
99
- const activity = useStatus(space, fullyQualifiedId(thread));
100
- const { t } = useTranslation(THREAD_PLUGIN);
101
- const threadScrollRef = useRef(null);
102
- const { themeMode } = useThemeContext();
103
- const textboxMetadata = getMessageMetadata(fullyQualifiedId(thread), identity);
104
- const [_count, _setCount] = useState(0);
105
- const rerenderEditor = () => _setCount((count) => count + 1);
106
- const messageRef = useRef("");
107
- const extensions = useMemo(() => [
108
- createBasicExtensions({
109
- placeholder: t("message placeholder")
110
- }),
111
- createThemeExtensions({
112
- themeMode
113
- }),
114
- listener({
115
- onChange: (text) => messageRef.current = text
116
- }),
117
- command
118
- ], [
119
- _count
120
- ]);
121
- const scrollToEnd = (behavior) => setTimeout(() => threadScrollRef.current?.scrollIntoView({
122
- behavior,
123
- block: "end"
124
- }), 10);
125
- const handleCreate = useCallback(() => {
126
- if (!messageRef.current) {
127
- return false;
128
- }
129
- thread.messages.push(create(MessageType, {
130
- sender: {
131
- identityKey: identity.identityKey.toHex()
132
- },
133
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
134
- text: messageRef.current,
135
- context
136
- }));
137
- onComment?.(thread);
138
- messageRef.current = "";
139
- scrollToEnd("instant");
140
- rerenderEditor();
141
- return true;
142
- }, [
143
- thread,
144
- identity
145
- ]);
146
- return /* @__PURE__ */ React.createElement(Thread, {
147
- onClickCapture: onAttend,
148
- onFocusCapture: onAttend,
149
- current,
150
- id: fullyQualifiedId(thread)
151
- }, /* @__PURE__ */ React.createElement("div", {
152
- role: "none",
153
- className: mx("col-span-2 grid grid-cols-[var(--rail-size)_1fr_min-content]", hoverableControls, hoverableFocusedWithinControls)
154
- }, detached ? /* @__PURE__ */ React.createElement(Tooltip.Root, null, /* @__PURE__ */ React.createElement(Tooltip.Trigger, {
155
- asChild: true
156
- }, /* @__PURE__ */ React.createElement(ThreadHeading, {
157
- detached: true
158
- }, thread.name)), /* @__PURE__ */ React.createElement(Tooltip.Portal, null, /* @__PURE__ */ React.createElement(Tooltip.Content, {
159
- classNames: "z-[21]",
160
- side: "top"
161
- }, t("detached thread label"), /* @__PURE__ */ React.createElement(Tooltip.Arrow, null)))) : /* @__PURE__ */ React.createElement(ThreadHeading, null, thread.name), /* @__PURE__ */ React.createElement("div", {
162
- className: "flex flex-row items-center pli-1"
163
- }, thread.status === "staged" && /* @__PURE__ */ React.createElement(Tag, {
164
- palette: "neutral"
165
- }, t("draft button")), onResolve && !(thread?.status === "staged") && /* @__PURE__ */ React.createElement(ToggleResolvedButton, {
166
- isResolved: thread?.status === "resolved",
167
- onResolve
168
- }), onThreadDelete && /* @__PURE__ */ React.createElement(DeleteThreadButton, {
169
- onDelete: onThreadDelete
170
- }))), thread.messages.filter(nonNullable).map((message) => /* @__PURE__ */ React.createElement(MessageContainer, {
171
- key: message.id,
172
- message,
173
- members,
174
- onDelete: (id) => onMessageDelete?.(id)
175
- })), /* @__PURE__ */ React.createElement(MessageTextbox, {
176
- extensions,
177
- onSend: handleCreate,
178
- ...textboxMetadata
179
- }), /* @__PURE__ */ React.createElement(ThreadFooter, {
180
- activity
181
- }, t("activity message")), /* @__PURE__ */ React.createElement("div", {
182
- role: "none",
183
- className: "bs-px -mbs-px",
184
- ref: threadScrollRef
185
- }));
186
- };
187
-
188
- // packages/plugins/plugin-thread/src/components/CommentsContainer.tsx
189
- import { ChatText } from "@phosphor-icons/react";
190
- import React2, { useEffect } from "react";
191
- import { fullyQualifiedId as fullyQualifiedId2 } from "@dxos/react-client/echo";
192
- import { useTranslation as useTranslation2, Trans } from "@dxos/react-ui";
193
- import { descriptionText, mx as mx2 } from "@dxos/react-ui-theme";
194
- var CommentsContainer = ({ threads: threads2, detached = [], currentId, showResolvedThreads, onThreadAttend, onThreadDelete, onMessageDelete, onThreadToggleResolved, ...props }) => {
195
- const { t } = useTranslation2(THREAD_PLUGIN);
196
- const filteredThreads = showResolvedThreads ? threads2 : threads2.filter((thread) => !(thread?.status === "resolved"));
197
- useEffect(() => {
198
- if (currentId) {
199
- document.getElementById(currentId)?.scrollIntoView({
200
- behavior: "smooth",
201
- block: "end"
202
- });
203
- }
204
- }, [
205
- currentId
206
- ]);
207
- return /* @__PURE__ */ React2.createElement(React2.Fragment, null, filteredThreads.length > 0 ? filteredThreads.map((thread) => {
208
- const threadId = fullyQualifiedId2(thread);
209
- return /* @__PURE__ */ React2.createElement(CommentContainer, {
210
- key: threadId,
211
- thread,
212
- current: currentId === threadId,
213
- detached: detached.includes(threadId),
214
- ...onThreadAttend && {
215
- onAttend: () => onThreadAttend(thread)
216
- },
217
- ...onThreadDelete && {
218
- onThreadDelete: () => onThreadDelete(thread)
219
- },
220
- ...onMessageDelete && {
221
- onMessageDelete: (messageId) => onMessageDelete(thread, messageId)
222
- },
223
- ...onThreadToggleResolved && {
224
- onResolve: () => onThreadToggleResolved(thread)
225
- },
226
- ...props
227
- });
228
- }) : /* @__PURE__ */ React2.createElement("div", {
229
- role: "alert",
230
- className: mx2(descriptionText, "place-self-center border border-dashed border-unAccent rounded-lg text-center p-4 m-4")
231
- }, /* @__PURE__ */ React2.createElement("h2", {
232
- className: "mbe-2 font-medium text-baseText"
233
- }, t("no comments title")), /* @__PURE__ */ React2.createElement("p", null, /* @__PURE__ */ React2.createElement(Trans, {
234
- t,
235
- i18nKey: "no comments message",
236
- components: {
237
- commentIcon: /* @__PURE__ */ React2.createElement(ChatText, {
238
- className: "inline-block"
239
- })
240
- }
241
- }))));
242
- };
243
-
244
- // packages/plugins/plugin-thread/src/components/ThreadComplementary.tsx
245
- import React3, { useEffect as useEffect2, useMemo as useMemo2 } from "react";
246
- import { LayoutAction, useIntentDispatcher, useResolvePlugins } from "@dxos/app-framework";
247
- import { fullyQualifiedId as fullyQualifiedId3 } from "@dxos/react-client/echo";
248
- import { useAttended } from "@dxos/react-ui-attention";
249
- import { nonNullable as nonNullable2 } from "@dxos/util";
250
- var providesThreadsConfig = (plugin) => "thread" in plugin.provides ? plugin : void 0;
251
- var ThreadComplementary = ({ role, subject, drafts, current, showResolvedThreads }) => {
252
- const dispatch = useIntentDispatcher();
253
- const threadsIntegrators = useResolvePlugins(providesThreadsConfig);
254
- const threadProvides = useMemo2(() => threadsIntegrators.map((p) => p.provides.thread), [
255
- threadsIntegrators
256
- ]);
257
- const createSort = useMemo2(() => threadProvides.find((p) => p.predicate(subject))?.createSort, [
258
- threadProvides,
259
- subject
260
- ]);
261
- const sort = useMemo2(() => createSort?.(subject), [
262
- createSort,
263
- subject
264
- ]);
265
- const threads2 = useMemo2(() => {
266
- return subject.threads.concat(drafts ?? []).filter(nonNullable2);
267
- }, [
268
- JSON.stringify(subject.threads),
269
- JSON.stringify(drafts)
270
- ]);
271
- const detachedIds = useMemo2(() => {
272
- return threads2.filter(({ anchor }) => !anchor).map((thread) => fullyQualifiedId3(thread));
273
- }, [
274
- threads2
275
- ]);
276
- useEffect2(() => {
277
- if (!sort) {
278
- return;
279
- }
280
- threads2.sort((a, b) => sort(a?.anchor, b?.anchor));
281
- }, [
282
- sort,
283
- threads2
284
- ]);
285
- const attended = useAttended();
286
- const qualifiedSubjectId = fullyQualifiedId3(subject);
287
- return /* @__PURE__ */ React3.createElement(CommentsContainer, {
288
- threads: threads2,
289
- detached: detachedIds,
290
- currentId: attended.includes(qualifiedSubjectId) ? current : void 0,
291
- showResolvedThreads,
292
- onThreadAttend: (thread) => {
293
- const threadId = fullyQualifiedId3(thread);
294
- if (current !== threadId) {
295
- current = threadId;
296
- void dispatch?.([
297
- {
298
- action: LayoutAction.SCROLL_INTO_VIEW,
299
- data: {
300
- id: fullyQualifiedId3(subject),
301
- thread: threadId,
302
- cursor: thread.anchor
303
- }
304
- }
305
- ]);
306
- }
307
- },
308
- onThreadDelete: (thread) => {
309
- return dispatch({
310
- plugin: THREAD_PLUGIN,
311
- action: ThreadAction.DELETE,
312
- data: {
313
- subject,
314
- thread
315
- }
316
- });
317
- },
318
- onMessageDelete: (thread, messageId) => dispatch({
319
- plugin: THREAD_PLUGIN,
320
- action: ThreadAction.DELETE_MESSAGE,
321
- data: {
322
- subject,
323
- thread,
324
- messageId
325
- }
326
- }),
327
- onThreadToggleResolved: (thread) => dispatch({
328
- plugin: THREAD_PLUGIN,
329
- action: ThreadAction.TOGGLE_RESOLVED,
330
- data: {
331
- thread
332
- }
333
- }),
334
- onComment: (thread) => {
335
- void dispatch({
336
- action: ThreadAction.ON_MESSAGE_ADD,
337
- data: {
338
- thread,
339
- subject
340
- }
341
- });
342
- }
343
- });
344
- };
345
-
346
- // packages/plugins/plugin-thread/src/components/ThreadSettings.tsx
347
- import React4 from "react";
348
- import { Input, useTranslation as useTranslation3 } from "@dxos/react-ui";
349
- import { DeprecatedFormInput } from "@dxos/react-ui-form";
350
- var ThreadSettings = ({ settings }) => {
351
- const { t } = useTranslation3(THREAD_PLUGIN);
352
- return /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement(DeprecatedFormInput, {
353
- label: t("settings standalone label")
354
- }, /* @__PURE__ */ React4.createElement(Input.Switch, {
355
- checked: settings.standalone,
356
- onCheckedChange: (checked) => settings.standalone = !!checked
357
- })));
358
- };
359
-
360
- // packages/plugins/plugin-thread/src/components/index.ts
361
- var ThreadMain = lazy(() => import("./ThreadMain-4IAS67KE.mjs"));
362
- var ThreadArticle = lazy(() => import("./ThreadArticle-6IXTL7CH.mjs"));
363
-
364
- // packages/plugins/plugin-thread/src/extensions/threads.ts
365
- import { EditorView } from "@codemirror/view";
366
- import { computed, effect } from "@preact/signals-core";
367
- import { ThreadType } from "@dxos/plugin-space/types";
368
- import { getSpace as getSpace2, getTextInRange, createDocAccessor, fullyQualifiedId as fullyQualifiedId4 } from "@dxos/react-client/echo";
369
- import { comments, createExternalCommentSync } from "@dxos/react-ui-editor";
370
- import { nonNullable as nonNullable3 } from "@dxos/util";
371
- var getName = (doc, anchor) => {
372
- if (doc.content) {
373
- const [start, end] = anchor.split(":");
374
- return getTextInRange(createDocAccessor(doc.content, [
375
- "content"
376
- ]), start, end);
377
- }
378
- };
379
- var threads = (state, doc, dispatch) => {
380
- const space = doc && getSpace2(doc);
381
- if (!doc || !space || !dispatch) {
382
- return [
383
- comments()
384
- ];
385
- }
386
- const threads2 = computed(() => [
387
- ...doc.threads.filter(nonNullable3),
388
- ...state.drafts[fullyQualifiedId4(doc)] ?? []
389
- ].filter((thread) => !(thread?.status === "resolved")));
390
- return [
391
- EditorView.updateListener.of((update) => {
392
- if (update.docChanged) {
393
- doc.threads.forEach((thread) => {
394
- if (thread?.anchor) {
395
- const name = getName(doc, thread.anchor);
396
- if (name && name !== thread.name) {
397
- thread.name = name;
398
- }
399
- }
400
- });
401
- }
402
- }),
403
- createExternalCommentSync(fullyQualifiedId4(doc), (sink) => effect(() => sink()), () => threads2.value.filter((thread) => thread?.anchor).map((thread) => ({
404
- id: fullyQualifiedId4(thread),
405
- cursor: thread.anchor
406
- }))),
407
- comments({
408
- id: fullyQualifiedId4(doc),
409
- onCreate: ({ cursor }) => {
410
- const name = getName(doc, cursor);
411
- void dispatch({
412
- action: ThreadAction.CREATE,
413
- data: {
414
- cursor,
415
- name,
416
- subject: doc
417
- }
418
- });
419
- },
420
- onDelete: ({ id }) => {
421
- const draft = state.drafts[fullyQualifiedId4(doc)];
422
- if (draft) {
423
- const index = draft.findIndex((thread2) => fullyQualifiedId4(thread2) === id);
424
- if (index !== -1) {
425
- draft.splice(index, 1);
426
- }
427
- }
428
- const thread = doc.threads.find((thread2) => thread2?.id === id);
429
- if (thread) {
430
- thread.anchor = void 0;
431
- }
432
- },
433
- onUpdate: ({ id, cursor }) => {
434
- const thread = state.drafts[fullyQualifiedId4(doc)]?.find((thread2) => fullyQualifiedId4(thread2) === id) ?? doc.threads.find((thread2) => thread2?.id === id);
435
- if (thread instanceof ThreadType && thread.anchor) {
436
- thread.name = getName(doc, thread.anchor);
437
- thread.anchor = cursor;
438
- }
439
- },
440
- onSelect: ({ selection: { current, closest } }) => {
441
- void dispatch({
442
- action: ThreadAction.SELECT,
443
- data: {
444
- current: current ?? closest,
445
- skipOpen: true
446
- }
447
- });
448
- }
449
- })
450
- ];
451
- };
452
-
453
32
  // packages/plugins/plugin-thread/src/translations.ts
454
33
  import { ChannelType } from "@dxos/plugin-space/types";
455
34
  var translations_default = [
@@ -485,681 +64,155 @@ var translations_default = [
485
64
  "save message label": "Save",
486
65
  "edit message label": "Edit",
487
66
  "delete message label": "Delete message",
488
- "open comments panel label": "Show Comments"
67
+ "open comments panel label": "Show Comments",
68
+ "comments panel label": "Comments"
489
69
  }
490
70
  }
491
71
  }
492
72
  ];
493
73
 
494
74
  // packages/plugins/plugin-thread/src/ThreadPlugin.tsx
495
- var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-thread/src/ThreadPlugin.tsx";
496
- var initialViewState = {
497
- showResolvedThreads: false
498
- };
499
- var ThreadPlugin = () => {
500
- const settings = new LocalStorageStore(THREAD_PLUGIN);
501
- const state = create2({
502
- drafts: {}
503
- });
504
- const viewStore = create2({});
505
- const getViewState = (subjectId) => {
506
- if (!viewStore[subjectId]) {
507
- viewStore[subjectId] = {
508
- ...initialViewState
509
- };
510
- }
511
- return viewStore[subjectId];
512
- };
513
- let navigationPlugin;
514
- let intentPlugin;
515
- const unsubscribeCallbacks = [];
516
- return {
517
- meta: meta_default,
518
- initialize: async () => {
519
- settings.prop({
520
- key: "standalone",
521
- type: LocalStorageStore.bool({
522
- allowUndefined: true
523
- })
524
- });
525
- return {
526
- echo: {
527
- system: [
528
- ThreadType2,
529
- MessageType2
530
- ],
531
- // TODO(wittjosiah): Requires reload.
532
- ...settings.values.standalone ? {
533
- schema: [
534
- ChannelType2
535
- ]
536
- } : {}
537
- }
538
- };
539
- },
540
- ready: async (plugins) => {
541
- navigationPlugin = resolvePlugin(plugins, parseNavigationPlugin);
542
- intentPlugin = resolvePlugin(plugins, parseIntentPlugin);
543
- },
544
- unload: async () => {
545
- unsubscribeCallbacks.forEach((unsubscribe) => unsubscribe());
546
- },
547
- provides: {
548
- settings: settings.values,
549
- metadata: {
550
- records: {
551
- [ChannelType2.typename]: {
552
- createObject: ThreadAction.CREATE,
553
- placeholder: [
554
- "channel name placeholder",
555
- {
556
- ns: THREAD_PLUGIN
557
- }
558
- ],
559
- icon: "ph--chat--regular",
560
- // TODO(wittjosiah): Move out of metadata.
561
- loadReferences: (channel) => loadObjectReferences(channel, (channel2) => channel2.threads)
562
- },
563
- [ThreadType2.typename]: {
564
- // TODO(wittjosiah): Move out of metadata.
565
- loadReferences: (thread) => loadObjectReferences(thread, (thread2) => thread2.messages)
566
- },
567
- [MessageType2.typename]: {
568
- // TODO(wittjosiah): Move out of metadata.
569
- loadReferences: (message) => []
570
- },
571
- [THREAD_ITEM]: {
572
- parse: (item, type) => {
573
- switch (type) {
574
- case "node":
575
- return {
576
- id: item.id,
577
- label: item.title,
578
- data: item
579
- };
580
- case "object":
581
- return item;
582
- case "view-object":
583
- return {
584
- id: `${item.id}-view`,
585
- object: item
586
- };
587
- }
75
+ var ThreadPlugin = () => definePlugin(meta, [
76
+ defineModule({
77
+ id: `${meta.id}/module/settings`,
78
+ activatesOn: Events.SetupSettings,
79
+ activate: ThreadSettings
80
+ }),
81
+ defineModule({
82
+ id: `${meta.id}/module/state`,
83
+ activatesOn: Events.Startup,
84
+ activate: ThreadState
85
+ }),
86
+ defineModule({
87
+ id: `${meta.id}/module/translations`,
88
+ activatesOn: Events.SetupTranslations,
89
+ activate: () => contributes(Capabilities.Translations, [
90
+ ...translations_default,
91
+ ...threadTranslations
92
+ ])
93
+ }),
94
+ defineModule({
95
+ id: `${meta.id}/module/metadata`,
96
+ activatesOn: oneOf(Events.Startup, Events.SetupAppGraph),
97
+ activate: () => [
98
+ contributes(Capabilities.Metadata, {
99
+ id: ChannelType2.typename,
100
+ metadata: {
101
+ createObject: (props) => createIntent(ThreadAction.Create, props),
102
+ placeholder: [
103
+ "channel name placeholder",
104
+ {
105
+ ns: THREAD_PLUGIN
588
106
  }
589
- }
107
+ ],
108
+ icon: "ph--chat--regular",
109
+ // TODO(wittjosiah): Move out of metadata.
110
+ loadReferences: async (channel) => await RefArray.loadAll(channel.threads ?? [])
590
111
  }
591
- },
592
- translations: [
593
- ...translations_default,
594
- ...threadTranslations
595
- ],
596
- complementary: {
597
- panels: [
598
- {
599
- id: "comments",
600
- label: [
601
- "open comments panel label",
602
- {
603
- ns: THREAD_PLUGIN
604
- }
605
- ],
606
- icon: "ph--chat-text--regular"
607
- }
608
- ]
609
- },
610
- graph: {
611
- builder: (plugins) => {
612
- const client = resolvePlugin(plugins, parseClientPlugin)?.provides.client;
613
- const dispatch = resolvePlugin(plugins, parseIntentPlugin)?.provides.intent.dispatch;
614
- const metadataResolver = resolvePlugin(plugins, parseMetadataResolverPlugin)?.provides.metadata.resolver;
615
- if (!client || !dispatch || !metadataResolver) {
616
- return [];
617
- }
618
- const type = "orphan-comments-for-subject";
619
- const icon = "ph--chat-text--regular";
620
- return [
621
- createExtension({
622
- id: `${THREAD_PLUGIN}/comments-for-subject`,
623
- resolver: ({ id }) => {
624
- if (!id.endsWith("~comments")) {
625
- return;
626
- }
627
- const [subjectId] = id.split("~");
628
- const { spaceId, objectId } = parseId(subjectId);
629
- const spaces = toSignal((onChange) => client.spaces.subscribe(() => onChange()).unsubscribe, () => client.spaces.get());
630
- const space = spaces?.find((space2) => space2.id === spaceId && space2.state.get() === SpaceState.SPACE_READY);
631
- if (!objectId) {
632
- return {
633
- id,
634
- type,
635
- data: null,
636
- properties: {
637
- icon,
638
- label: [
639
- "unnamed object threads label",
640
- {
641
- ns: THREAD_PLUGIN
642
- }
643
- ],
644
- showResolvedThreads: false,
645
- object: null,
646
- space
647
- }
648
- };
649
- }
650
- const [object] = memoizeQuery(space, {
651
- id: objectId
652
- });
653
- if (!object || !subjectId) {
654
- return;
655
- }
656
- const meta = metadataResolver(getTypename(object) ?? "");
657
- const label = meta.label?.(object) || object.name || meta.placeholder || [
658
- "unnamed object threads label",
659
- {
660
- ns: THREAD_PLUGIN
661
- }
662
- ];
663
- const viewState = getViewState(subjectId);
664
- return {
665
- id,
666
- type,
667
- data: null,
668
- properties: {
669
- icon,
670
- label,
671
- showResolvedThreads: viewState.showResolvedThreads,
672
- object
673
- }
674
- };
675
- },
676
- actions: ({ node }) => {
677
- const dataId = node.id.split("~").at(0);
678
- if (!node.id.endsWith("~comments") || !dataId) {
679
- return;
680
- }
681
- const [spaceId, objectId] = dataId.split(":");
682
- const viewState = getViewState(dataId);
683
- const toggle = () => {
684
- const newToggleState = !viewState.showResolvedThreads;
685
- viewState.showResolvedThreads = newToggleState;
686
- void dispatch({
687
- action: ObservabilityAction.SEND_EVENT,
688
- data: {
689
- name: "threads.toggle-show-resolved",
690
- properties: {
691
- spaceId,
692
- threadId: objectId,
693
- showResolved: newToggleState
694
- }
695
- }
696
- });
697
- };
698
- return [
699
- {
700
- id: `${THREAD_PLUGIN}/toggle-show-resolved/${node.id}`,
701
- data: toggle,
702
- properties: {
703
- label: [
704
- "toggle show resolved",
705
- {
706
- ns: THREAD_PLUGIN
707
- }
708
- ],
709
- menuItemType: "toggle",
710
- isChecked: viewState.showResolvedThreads,
711
- testId: "threadPlugin.toggleShowResolved",
712
- icon: viewState.showResolvedThreads ? "ph--eye-slash--regular" : "ph--eye--regular"
713
- }
714
- }
715
- ];
716
- }
717
- }),
718
- createExtension({
719
- id: ThreadAction.CREATE,
720
- filter: (node) => !!settings.values.standalone && isActionGroup(node) && node.id.startsWith(SpaceAction.ADD_OBJECT),
721
- actions: ({ node }) => {
722
- const id = node.id.split("/").at(-1);
723
- const [spaceId, objectId] = id?.split(":") ?? [];
724
- const space = client.spaces.get().find((space2) => space2.id === spaceId);
725
- const object = objectId && space?.db.getObjectById(objectId);
726
- const target = objectId ? object : space;
727
- if (!target) {
728
- return;
729
- }
730
- return [
731
- {
732
- id: `${THREAD_PLUGIN}/create/${node.id}`,
733
- data: async () => {
734
- await dispatch([
735
- {
736
- plugin: THREAD_PLUGIN,
737
- action: ThreadAction.CREATE
738
- },
739
- {
740
- action: SpaceAction.ADD_OBJECT,
741
- data: {
742
- target
743
- }
744
- },
745
- {
746
- action: NavigationAction.OPEN
747
- }
748
- ]);
749
- },
750
- properties: {
751
- label: [
752
- "create channel label",
753
- {
754
- ns: THREAD_PLUGIN
755
- }
756
- ],
757
- icon: "ph--chat--regular",
758
- testId: "threadPlugin.createObject"
759
- }
760
- }
761
- ];
762
- }
763
- })
764
- ];
112
+ }),
113
+ contributes(Capabilities.Metadata, {
114
+ id: ThreadType.typename,
115
+ metadata: {
116
+ // TODO(wittjosiah): Move out of metadata.
117
+ loadReferences: async (thread) => await RefArray.loadAll(thread.messages ?? [])
765
118
  }
766
- },
767
- surface: {
768
- component: ({ data, role }) => {
769
- switch (role) {
770
- case "main": {
771
- return data.active instanceof ChannelType2 && data.active.threads[0] ? /* @__PURE__ */ React5.createElement(ThreadMain, {
772
- thread: data.active.threads[0]
773
- }) : null;
774
- }
775
- case "settings": {
776
- return data.plugin === meta_default.id ? /* @__PURE__ */ React5.createElement(ThreadSettings, {
777
- settings: settings.values
778
- }) : null;
779
- }
780
- case "article": {
781
- const location = navigationPlugin?.provides.location;
782
- if (data.object instanceof ChannelType2 && data.object.threads[0]) {
783
- const channel = data.object;
784
- if (isLayoutParts(location?.active) && location.active.main) {
785
- const layoutEntries = location.active.main;
786
- const currentPosition = layoutEntries.findIndex((entry) => channel.id === entry.id);
787
- if (currentPosition > 0) {
788
- const objectToTheLeft = layoutEntries[currentPosition - 1];
789
- const context = getSpace3(data.object)?.db.getObjectById(objectToTheLeft.id);
790
- return /* @__PURE__ */ React5.createElement(ThreadArticle, {
791
- thread: data.object.threads[0],
792
- context
793
- });
794
- }
795
- }
796
- return /* @__PURE__ */ React5.createElement(ThreadArticle, {
797
- thread: data.object.threads[0]
798
- });
799
- }
800
- if (data.subject instanceof ThreadType2) {
801
- return /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement(ChatHeading, {
802
- attendableId: data.subject.id
803
- }), /* @__PURE__ */ React5.createElement(ChatContainer, {
804
- thread: data.subject
805
- }));
806
- }
807
- break;
808
- }
809
- case "complementary--comments": {
810
- if (data.subject && typeof data.subject === "object" && "threads" in data.subject && Array.isArray(data.subject.threads) && !(data.subject instanceof ChannelType2)) {
811
- const { showResolvedThreads } = getViewState(fullyQualifiedId5(data.subject));
812
- return /* @__PURE__ */ React5.createElement(ThreadComplementary, {
813
- role,
814
- subject: data.subject,
815
- drafts: state.drafts[fullyQualifiedId5(data.subject)],
816
- current: state.current,
817
- showResolvedThreads
818
- });
819
- }
820
- break;
821
- }
822
- }
823
- return null;
119
+ }),
120
+ contributes(Capabilities.Metadata, {
121
+ id: MessageType.typename,
122
+ metadata: {
123
+ // TODO(wittjosiah): Move out of metadata.
124
+ loadReferences: (message) => []
824
125
  }
825
- },
826
- intent: {
827
- resolver: async (intent) => {
828
- switch (intent.action) {
829
- case ThreadAction.CREATE: {
830
- if (intent.data && intent.data.cursor !== void 0) {
831
- const { cursor, name, subject } = intent.data;
832
- if (subject?.threads === void 0) {
833
- try {
834
- subject.threads = [];
835
- } catch (err) {
836
- log.error("Subject does not support threads array", subject?.typename, {
837
- F: __dxlog_file,
838
- L: 371,
839
- S: void 0,
840
- C: (f, a) => f(...a)
841
- });
842
- return;
843
- }
844
- }
845
- const subjectId = fullyQualifiedId5(subject);
846
- const thread = create2(ThreadType2, {
847
- name,
848
- anchor: cursor,
849
- messages: [],
850
- status: "staged"
851
- });
852
- const draft = state.drafts[subjectId];
853
- if (draft) {
854
- draft.push(thread);
855
- } else {
856
- state.drafts[subjectId] = [
857
- thread
858
- ];
859
- }
126
+ }),
127
+ contributes(Capabilities.Metadata, {
128
+ id: THREAD_ITEM,
129
+ metadata: {
130
+ parse: (item, type) => {
131
+ switch (type) {
132
+ case "node":
860
133
  return {
861
- data: thread,
862
- intents: [
863
- [
864
- {
865
- action: ThreadAction.SELECT,
866
- data: {
867
- current: fullyQualifiedId5(thread)
868
- }
869
- }
870
- ],
871
- [
872
- {
873
- action: NavigationAction.OPEN,
874
- data: {
875
- activeParts: {
876
- complementary: "comments"
877
- }
878
- }
879
- }
880
- ],
881
- [
882
- {
883
- action: LayoutAction2.SET_LAYOUT,
884
- data: {
885
- element: "complementary",
886
- state: true
887
- }
888
- }
889
- ]
890
- ]
134
+ id: item.id,
135
+ label: item.title,
136
+ data: item
891
137
  };
892
- } else {
138
+ case "object":
139
+ return item;
140
+ case "view-object":
893
141
  return {
894
- data: create2(ChannelType2, {
895
- threads: [
896
- create2(ThreadType2, {
897
- messages: []
898
- })
899
- ]
900
- })
142
+ id: `${item.id}-view`,
143
+ object: item
901
144
  };
902
- }
903
- }
904
- case ThreadAction.SELECT: {
905
- state.current = intent.data?.current;
906
- return {
907
- data: true,
908
- intents: !intent.data?.skipOpen ? [
909
- [
910
- {
911
- action: NavigationAction.OPEN,
912
- data: {
913
- activeParts: {
914
- complementary: "comments"
915
- }
916
- }
917
- }
918
- ]
919
- ] : []
920
- };
921
- }
922
- case ThreadAction.TOGGLE_RESOLVED: {
923
- const { thread } = intent.data ?? {};
924
- if (!(thread instanceof ThreadType2)) {
925
- return;
926
- }
927
- if (thread.status === "active" || thread.status === void 0) {
928
- thread.status = "resolved";
929
- } else if (thread.status === "resolved") {
930
- thread.status = "active";
931
- }
932
- const space = getSpace3(thread);
933
- const spaceId = space?.id;
934
- return {
935
- data: true,
936
- intents: [
937
- [
938
- {
939
- action: ObservabilityAction.SEND_EVENT,
940
- data: {
941
- name: "threads.toggle-resolved",
942
- properties: {
943
- threadId: thread.id,
944
- spaceId
945
- }
946
- }
947
- }
948
- ]
949
- ]
950
- };
951
- }
952
- case ThreadAction.DELETE: {
953
- const { subject, thread } = intent.data ?? {};
954
- if (!(thread instanceof ThreadType2) || !(subject && typeof subject === "object" && "threads" in subject)) {
955
- return;
956
- }
957
- const subjectId = fullyQualifiedId5(subject);
958
- const draft = state.drafts[subjectId];
959
- if (draft) {
960
- const index = draft.findIndex((t) => t.id === thread.id);
961
- if (index !== -1) {
962
- draft.splice(index, 1);
963
- return {
964
- data: true
965
- };
966
- }
967
- }
968
- const space = getSpace3(thread);
969
- if (!space || !subject.threads) {
970
- return;
971
- }
972
- if (!intent.undo) {
973
- const index = subject.threads.findIndex((t) => t?.id === thread.id);
974
- const cursor = subject.threads[index]?.anchor;
975
- if (index !== -1) {
976
- subject.threads?.splice(index, 1);
977
- }
978
- space.db.remove(thread);
979
- return {
980
- undoable: {
981
- message: translations_default[0]["en-US"][THREAD_PLUGIN]["thread deleted label"],
982
- data: {
983
- cursor
984
- }
985
- },
986
- intents: [
987
- [
988
- {
989
- action: ObservabilityAction.SEND_EVENT,
990
- data: {
991
- name: "threads.delete",
992
- properties: {
993
- threadId: thread.id,
994
- spaceId: space.id
995
- }
996
- }
997
- }
998
- ]
999
- ]
1000
- };
1001
- } else if (intent.undo) {
1002
- const savedThread = space.db.add(thread);
1003
- subject.threads.push(savedThread);
1004
- return {
1005
- data: true,
1006
- intents: [
1007
- [
1008
- {
1009
- action: ObservabilityAction.SEND_EVENT,
1010
- data: {
1011
- name: "threads.undo-delete",
1012
- properties: {
1013
- threadId: thread.id,
1014
- spaceId: space.id
1015
- }
1016
- }
1017
- }
1018
- ]
1019
- ]
1020
- };
1021
- }
1022
- break;
1023
- }
1024
- case ThreadAction.ON_MESSAGE_ADD: {
1025
- const { thread, subject } = intent.data ?? {};
1026
- if (!(thread instanceof ThreadType2) || !(subject && typeof subject === "object" && "threads" in subject && Array.isArray(subject.threads))) {
1027
- return;
1028
- }
1029
- const subjectId = fullyQualifiedId5(subject);
1030
- const space = getSpace3(subject);
1031
- const intents = [];
1032
- const analyticsProperties = {
1033
- threadId: thread.id,
1034
- spaceId: space?.id
1035
- };
1036
- if (state.drafts[subjectId]?.find((t) => t === thread)) {
1037
- thread.status = "active";
1038
- subject.threads ? subject.threads.push(thread) : subject.threads = [
1039
- thread
1040
- ];
1041
- state.drafts[subjectId] = state.drafts[subjectId]?.filter(({ id }) => id !== thread.id);
1042
- intents.push({
1043
- action: ObservabilityAction.SEND_EVENT,
1044
- data: {
1045
- name: "threads.thread-created",
1046
- properties: analyticsProperties
1047
- }
1048
- });
1049
- }
1050
- intents.push({
1051
- action: ObservabilityAction.SEND_EVENT,
1052
- data: {
1053
- name: "threads.message-added",
1054
- properties: {
1055
- ...analyticsProperties,
1056
- threadLength: thread.messages.length
1057
- }
1058
- }
1059
- });
1060
- return {
1061
- data: thread,
1062
- intents: [
1063
- intents
1064
- ]
1065
- };
1066
- }
1067
- case ThreadAction.DELETE_MESSAGE: {
1068
- const { subject, thread, messageId } = intent.data ?? {};
1069
- const space = getSpace3(subject);
1070
- if (!(thread instanceof ThreadType2) || !(subject && typeof subject === "object" && "threads" in subject)) {
1071
- return;
1072
- }
1073
- if (!intent.undo) {
1074
- const message = thread.messages.find((m) => m?.id === messageId);
1075
- const messageIndex = thread.messages.findIndex((m) => m?.id === messageId);
1076
- if (messageIndex === -1 || !message) {
1077
- return void 0;
1078
- }
1079
- if (messageIndex === 0 && thread.messages.length === 1) {
1080
- return {
1081
- intents: [
1082
- [
1083
- {
1084
- action: ThreadAction.DELETE,
1085
- data: {
1086
- subject,
1087
- thread
1088
- }
1089
- }
1090
- ]
1091
- ]
1092
- };
1093
- } else {
1094
- thread.messages.splice(messageIndex, 1);
1095
- }
1096
- return {
1097
- undoable: {
1098
- message: translations_default[0]["en-US"][THREAD_PLUGIN]["message deleted label"],
1099
- data: {
1100
- message,
1101
- messageIndex
1102
- }
1103
- },
1104
- intents: [
1105
- [
1106
- {
1107
- action: ObservabilityAction.SEND_EVENT,
1108
- data: {
1109
- name: "threads.message.delete",
1110
- properties: {
1111
- threadId: thread.id,
1112
- spaceId: space?.id
1113
- }
1114
- }
1115
- }
1116
- ]
1117
- ]
1118
- };
1119
- } else if (intent.undo) {
1120
- const message = intent.data?.message;
1121
- const messageIndex = intent.data?.messageIndex;
1122
- if (!(message instanceof MessageType2) || !(typeof messageIndex === "number")) {
1123
- return;
1124
- }
1125
- thread.messages.splice(messageIndex, 0, message);
1126
- return {
1127
- data: true,
1128
- intents: [
1129
- [
1130
- {
1131
- action: ObservabilityAction.SEND_EVENT,
1132
- data: {
1133
- name: "threads.message.undo-delete",
1134
- properties: {
1135
- threadId: thread.id,
1136
- spaceId: space?.id
1137
- }
1138
- }
1139
- }
1140
- ]
1141
- ]
1142
- };
1143
- }
1144
145
  }
1145
146
  }
1146
147
  }
1147
- },
1148
- markdown: {
1149
- extensions: ({ document: doc }) => {
1150
- return threads(state, doc, intentPlugin?.provides.intent.dispatch);
1151
- }
148
+ })
149
+ ]
150
+ }),
151
+ defineModule({
152
+ id: `${meta.id}/module/schema`,
153
+ activatesOn: ClientEvents.SetupClient,
154
+ activate: () => contributes(ClientCapabilities.SystemSchema, [
155
+ ThreadType,
156
+ MessageType
157
+ ])
158
+ }),
159
+ defineModule({
160
+ id: `${meta.id}/module/channel-schema`,
161
+ activatesOn: allOf(Events.SettingsReady, ClientEvents.ClientReady),
162
+ activate: (context) => {
163
+ const client = context.requestCapability(ClientCapabilities.Client);
164
+ const settings = context.requestCapability(Capabilities.SettingsStore).getStore(THREAD_PLUGIN).value;
165
+ if (settings.standalone) {
166
+ client.addTypes([
167
+ ChannelType2
168
+ ]);
169
+ return contributes(ClientCapabilities.Schema, [
170
+ ChannelType2
171
+ ]);
1152
172
  }
173
+ return [];
1153
174
  }
1154
- };
1155
- };
1156
-
1157
- // packages/plugins/plugin-thread/src/index.ts
1158
- var src_default = ThreadPlugin;
175
+ }),
176
+ defineModule({
177
+ id: `${meta.id}/module/complementary-panel`,
178
+ activatesOn: Events.Startup,
179
+ activate: () => contributes(DeckCapabilities.ComplementaryPanel, {
180
+ id: "comments",
181
+ label: [
182
+ "comments panel label",
183
+ {
184
+ ns: THREAD_PLUGIN
185
+ }
186
+ ],
187
+ icon: "ph--chat-text--regular"
188
+ })
189
+ }),
190
+ defineModule({
191
+ id: `${meta.id}/module/markdown`,
192
+ activatesOn: Events.Startup,
193
+ activate: Markdown
194
+ }),
195
+ defineModule({
196
+ id: `${meta.id}/module/react-surface`,
197
+ activatesOn: Events.Startup,
198
+ activate: ReactSurface
199
+ }),
200
+ defineModule({
201
+ id: `${meta.id}/module/intent-resolver`,
202
+ activatesOn: Events.SetupIntents,
203
+ activate: IntentResolver
204
+ }),
205
+ defineModule({
206
+ id: `${meta.id}/module/app-graph-builder`,
207
+ activatesOn: Events.SetupAppGraph,
208
+ activate: AppGraphBuilder
209
+ })
210
+ ]);
1159
211
  export {
1160
- ThreadAction,
212
+ THREAD_ITEM,
213
+ THREAD_PLUGIN,
1161
214
  ThreadPlugin,
1162
- src_default as default,
215
+ meta,
1163
216
  useAnalyticsCallback,
1164
217
  useOnEditAnalytics,
1165
218
  useStatus