@dxos/plugin-thread 0.7.4-staging.f7e8224 → 0.7.5-labs.071a3e2

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