@dxos/plugin-thread 0.7.5-main.9d2a38b → 0.7.5-main.ff8607b
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.
- package/dist/lib/browser/{ThreadContainer-4VLBSBI7.mjs → ThreadContainer-OI5M262D.mjs} +2 -2
- package/dist/lib/browser/{chunk-2B3EXYZ7.mjs → chunk-BD3J6HEY.mjs} +3 -3
- package/dist/lib/browser/{chunk-GQONSZ3J.mjs → chunk-GQVZK3BQ.mjs} +3 -5
- package/dist/lib/browser/{chunk-GQONSZ3J.mjs.map → chunk-GQVZK3BQ.mjs.map} +3 -3
- package/dist/lib/browser/index.mjs +5 -5
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/intent-resolver-QFP6L3AF.mjs +287 -0
- package/dist/lib/browser/intent-resolver-QFP6L3AF.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-CHCZO4TI.mjs → react-surface-PXYCYPWA.mjs} +30 -32
- package/dist/lib/browser/react-surface-PXYCYPWA.mjs.map +7 -0
- package/dist/lib/node/{ThreadContainer-VOYLV4UL.cjs → ThreadContainer-L6TPQJWA.cjs} +6 -6
- package/dist/lib/node/{chunk-6PUGKCPR.cjs → chunk-2TK6J6BN.cjs} +5 -7
- package/dist/lib/node/{chunk-6PUGKCPR.cjs.map → chunk-2TK6J6BN.cjs.map} +3 -3
- package/dist/lib/node/{chunk-ZRN7B26W.cjs → chunk-S5LH7AIT.cjs} +6 -6
- package/dist/lib/node/index.cjs +10 -10
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/intent-resolver-ZSOQILPJ.cjs +299 -0
- package/dist/lib/node/intent-resolver-ZSOQILPJ.cjs.map +7 -0
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/{react-surface-LO7S2HPR.cjs → react-surface-CPDCOLUZ.cjs} +33 -35
- package/dist/lib/node/react-surface-CPDCOLUZ.cjs.map +7 -0
- package/dist/lib/node-esm/{ThreadContainer-7DZY2MWA.mjs → ThreadContainer-HE46AQJH.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-GS2OILYF.mjs → chunk-7YYL6QVU.mjs} +3 -3
- package/dist/lib/node-esm/{chunk-DYFIKKDT.mjs → chunk-AZCU7SHI.mjs} +3 -5
- package/dist/lib/node-esm/{chunk-DYFIKKDT.mjs.map → chunk-AZCU7SHI.mjs.map} +3 -3
- package/dist/lib/node-esm/index.mjs +5 -5
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/intent-resolver-MHP4C2NZ.mjs +288 -0
- package/dist/lib/node-esm/intent-resolver-MHP4C2NZ.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-LAF3QIPB.mjs → react-surface-RD4F2LRT.mjs} +30 -32
- package/dist/lib/node-esm/react-surface-RD4F2LRT.mjs.map +7 -0
- package/dist/types/src/ThreadPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts +22 -22
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +30 -30
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/components/ThreadComplementary.d.ts.map +1 -1
- package/dist/types/src/components/command-extension.d.ts.map +1 -1
- package/package.json +30 -30
- package/src/ThreadPlugin.tsx +3 -4
- package/src/capabilities/intent-resolver.ts +180 -164
- package/src/capabilities/react-surface.tsx +12 -17
- package/src/components/ThreadComplementary.tsx +7 -4
- package/src/components/ThreadSettings.tsx +3 -3
- package/src/components/command-extension.ts +2 -5
- package/dist/lib/browser/intent-resolver-PIEZ3LKQ.mjs +0 -275
- package/dist/lib/browser/intent-resolver-PIEZ3LKQ.mjs.map +0 -7
- package/dist/lib/browser/react-surface-CHCZO4TI.mjs.map +0 -7
- package/dist/lib/node/intent-resolver-X5O3SVLF.cjs +0 -287
- package/dist/lib/node/intent-resolver-X5O3SVLF.cjs.map +0 -7
- package/dist/lib/node/react-surface-LO7S2HPR.cjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-XJWT5X6T.mjs +0 -276
- package/dist/lib/node-esm/intent-resolver-XJWT5X6T.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-LAF3QIPB.mjs.map +0 -7
- /package/dist/lib/browser/{ThreadContainer-4VLBSBI7.mjs.map → ThreadContainer-OI5M262D.mjs.map} +0 -0
- /package/dist/lib/browser/{chunk-2B3EXYZ7.mjs.map → chunk-BD3J6HEY.mjs.map} +0 -0
- /package/dist/lib/node/{ThreadContainer-VOYLV4UL.cjs.map → ThreadContainer-L6TPQJWA.cjs.map} +0 -0
- /package/dist/lib/node/{chunk-ZRN7B26W.cjs.map → chunk-S5LH7AIT.cjs.map} +0 -0
- /package/dist/lib/node-esm/{ThreadContainer-7DZY2MWA.mjs.map → ThreadContainer-HE46AQJH.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-GS2OILYF.mjs.map → chunk-7YYL6QVU.mjs.map} +0 -0
|
@@ -26,14 +26,14 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var
|
|
30
|
-
__export(
|
|
29
|
+
var chunk_2TK6J6BN_exports = {};
|
|
30
|
+
__export(chunk_2TK6J6BN_exports, {
|
|
31
31
|
ChatContainer: () => ChatContainer,
|
|
32
32
|
MessageContainer: () => MessageContainer,
|
|
33
33
|
command: () => command,
|
|
34
34
|
getMessageMetadata: () => getMessageMetadata
|
|
35
35
|
});
|
|
36
|
-
module.exports = __toCommonJS(
|
|
36
|
+
module.exports = __toCommonJS(chunk_2TK6J6BN_exports);
|
|
37
37
|
var import_chunk_AWSTZ2KN = require("./chunk-AWSTZ2KN.cjs");
|
|
38
38
|
var import_chunk_F735VMTN = require("./chunk-F735VMTN.cjs");
|
|
39
39
|
var import_react = __toESM(require("react"));
|
|
@@ -83,9 +83,7 @@ var parser = import_language.StreamLanguage.define({
|
|
|
83
83
|
var styles = import_language.HighlightStyle.define([
|
|
84
84
|
{
|
|
85
85
|
tag: import_react_ui_editor3.tags.tagName,
|
|
86
|
-
class: (0, import_react_ui_theme3.mx)(
|
|
87
|
-
palette: "cyan"
|
|
88
|
-
}), "text-baseText font-medium")
|
|
86
|
+
class: (0, import_react_ui_theme3.mx)("dx-tag dx-tag--indigo text-baseText font-medium")
|
|
89
87
|
}
|
|
90
88
|
]);
|
|
91
89
|
var command = [
|
|
@@ -339,4 +337,4 @@ var ChatContainer = ({ thread, context, current, autoFocusTextbox }) => {
|
|
|
339
337
|
command,
|
|
340
338
|
getMessageMetadata
|
|
341
339
|
});
|
|
342
|
-
//# sourceMappingURL=chunk-
|
|
340
|
+
//# sourceMappingURL=chunk-2TK6J6BN.cjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/ChatContainer.tsx", "../../../src/components/MessageContainer.tsx", "../../../src/components/command-extension.ts", "../../../src/util.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport React, { useLayoutEffect, useMemo, useRef, useState } from 'react';\n\nimport { Ref } from '@dxos/echo-schema';\nimport { create, makeRef, RefArray } from '@dxos/live-object';\nimport { MessageType } from '@dxos/plugin-space/types';\nimport { fullyQualifiedId, getSpace, useMembers, type Expando } from '@dxos/react-client/echo';\nimport { useIdentity } from '@dxos/react-client/halo';\nimport { Icon, ScrollArea, useThemeContext, useTranslation } from '@dxos/react-ui';\nimport { createBasicExtensions, createThemeExtensions, listener } from '@dxos/react-ui-editor';\nimport { StackItem } from '@dxos/react-ui-stack';\nimport { mx } from '@dxos/react-ui-theme';\nimport { MessageTextbox, type MessageTextboxProps, Thread, ThreadFooter, threadLayout } from '@dxos/react-ui-thread';\n\nimport { MessageContainer } from './MessageContainer';\nimport { command } from './command-extension';\nimport { type ThreadContainerProps } from './types';\nimport { useStatus } from '../hooks';\nimport { THREAD_PLUGIN } from '../meta';\nimport { getMessageMetadata } from '../util';\n\nexport const ChatHeading = ({ attendableId }: { attendableId?: string }) => {\n const { t } = useTranslation(THREAD_PLUGIN);\n return (\n <div role='none' className='flex items-center'>\n <StackItem.SigilButton attendableId={attendableId}>\n <Icon icon='ph--chat--regular' size={5} />\n </StackItem.SigilButton>\n <StackItem.HeadingLabel attendableId={attendableId}>{t('chat heading')}</StackItem.HeadingLabel>\n </div>\n );\n};\n\nexport const ChatContainer = ({ thread, context, current, autoFocusTextbox }: ThreadContainerProps) => {\n const identity = useIdentity()!;\n const space = getSpace(thread);\n const members = useMembers(space?.key);\n const activity = useStatus(space, fullyQualifiedId(thread));\n const { t } = useTranslation(THREAD_PLUGIN);\n // TODO(wittjosiah): This is a hack to reset the editor after a message is sent.\n const [_count, _setCount] = useState(0);\n const rerenderEditor = () => _setCount((count) => count + 1);\n const [autoFocus, setAutoFocus] = useState(autoFocusTextbox);\n const threadScrollRef = useRef<HTMLDivElement | null>(null);\n const { themeMode } = useThemeContext();\n\n const textboxMetadata = getMessageMetadata(fullyQualifiedId(thread), identity);\n const messageRef = useRef('');\n const extensions = useMemo(\n () => [\n createBasicExtensions({ placeholder: t('message placeholder') }),\n createThemeExtensions({ themeMode }),\n listener({ onChange: (text) => (messageRef.current = text) }),\n command,\n ],\n [themeMode, _count],\n );\n\n // TODO(thure): Factor out.\n // TODO(thure): `flex-col-reverse` does not work to start the container scrolled to the end while also using\n // `ScrollArea`. This is the least-bad way I found to scroll to the end on mount. Note that 0ms was insufficient\n // for the desired effect; this is likely hardware-dependent and should be reevaluated.\n const scrollToEnd = (behavior: ScrollBehavior) =>\n setTimeout(() => threadScrollRef.current?.scrollIntoView({ behavior, block: 'end' }), 10);\n\n useLayoutEffect(() => {\n scrollToEnd('instant');\n }, []);\n\n // TODO(burdon): Change to model.\n const handleCreate: MessageTextboxProps['onSend'] = () => {\n if (!messageRef.current?.length) {\n return false;\n }\n\n thread.messages.push(\n makeRef(\n create(MessageType, {\n sender: { identityKey: identity.identityKey.toHex() },\n timestamp: new Date().toISOString(),\n text: messageRef.current,\n context: makeRef(context as Expando),\n }),\n ),\n );\n\n messageRef.current = '';\n setAutoFocus(true);\n scrollToEnd('smooth');\n rerenderEditor();\n return true;\n };\n\n const handleDelete = (id: string) => {\n const messageIndex = thread.messages.findIndex(Ref.hasObjectId(id));\n if (messageIndex !== -1) {\n thread.messages.splice(messageIndex, 1);\n }\n };\n\n return (\n <Thread\n current={current}\n id={fullyQualifiedId(thread)}\n classNames='bs-full grid-rows-[1fr_min-content_min-content] overflow-hidden transition-[padding-block-end] [[data-sidebar-inline-start-state=open]_&]:lg:pbe-0'\n >\n <ScrollArea.Root classNames='col-span-2'>\n <ScrollArea.Viewport classNames='overflow-anchored after:overflow-anchor after:block after:bs-px after:-mbs-px [&>div]:min-bs-full [&>div]:!grid [&>div]:grid-rows-[1fr_0]'>\n <div role='none' className={mx(threadLayout, 'place-self-end')}>\n {RefArray.allResolvedTargets(thread.messages ?? []).map((message) => (\n <MessageContainer key={message.id} message={message} members={members} onDelete={handleDelete} />\n ))}\n </div>\n {/* NOTE(thure): This can’t also be the `overflow-anchor` because `ScrollArea` injects an interceding node that contains this necessary ref’d element. */}\n <div role='none' className='bs-px -mbs-px' ref={threadScrollRef} />\n <ScrollArea.Scrollbar>\n <ScrollArea.Thumb />\n </ScrollArea.Scrollbar>\n </ScrollArea.Viewport>\n </ScrollArea.Root>\n <MessageTextbox extensions={extensions} autoFocus={autoFocus} onSend={handleCreate} {...textboxMetadata} />\n <ThreadFooter activity={activity}>{t('activity message')}</ThreadFooter>\n </Thread>\n );\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { EditorView } from '@codemirror/view';\nimport { Check, PencilSimple, X } from '@phosphor-icons/react';\nimport React, { forwardRef, useCallback, useEffect, useRef, useState } from 'react';\n\nimport { Surface } from '@dxos/app-framework';\nimport { RefArray } from '@dxos/live-object';\nimport { type MessageType } from '@dxos/plugin-space/types';\nimport { PublicKey } from '@dxos/react-client';\nimport { type ReactiveEchoObject, type Expando, type SpaceMember } from '@dxos/react-client/echo';\nimport { useIdentity, type Identity } from '@dxos/react-client/halo';\nimport { Button, ButtonGroup, Tooltip, useOnTransition, useThemeContext, useTranslation } from '@dxos/react-ui';\nimport { createBasicExtensions, createThemeExtensions, useTextEditor } from '@dxos/react-ui-editor';\nimport { Mosaic, type MosaicTileComponent } from '@dxos/react-ui-mosaic';\nimport {\n getSize,\n hoverableControlItem,\n hoverableControls,\n hoverableFocusedWithinControls,\n mx,\n} from '@dxos/react-ui-theme';\nimport { MessageHeading, MessageRoot } from '@dxos/react-ui-thread';\n\nimport { command } from './command-extension';\nimport { useOnEditAnalytics } from '../hooks';\nimport { THREAD_ITEM, THREAD_PLUGIN } from '../meta';\nimport { getMessageMetadata } from '../util';\n\n// TODO(thure): #8149\nconst messageControlClassNames = ['!p-1 !min-bs-0 transition-opacity', hoverableControlItem];\n\nexport const MessageContainer = ({\n message,\n members,\n onDelete,\n}: {\n message: MessageType;\n members: SpaceMember[];\n onDelete?: (id: string) => void;\n}) => {\n const senderIdentity = members.find(\n (member) => message.sender.identityKey && PublicKey.equals(member.identity.identityKey, message.sender.identityKey),\n )?.identity;\n const messageMetadata = getMessageMetadata(message.id, senderIdentity);\n const userIsAuthor = useIdentity()?.identityKey.toHex() === messageMetadata.authorId;\n const [editing, setEditing] = useState(false);\n const handleDelete = useCallback(() => onDelete?.(message.id), [message, onDelete]);\n const { t } = useTranslation(THREAD_PLUGIN);\n const editLabel = t(editing ? 'save message label' : 'edit message label');\n const deleteLabel = t('delete message label');\n\n return (\n <MessageRoot {...messageMetadata} classNames={[hoverableControls, hoverableFocusedWithinControls]}>\n <MessageHeading authorName={messageMetadata.authorName} timestamp={messageMetadata.timestamp}>\n <ButtonGroup classNames='mie-1'>\n {userIsAuthor && (\n <Tooltip.Root>\n <Tooltip.Trigger asChild>\n <Button\n variant='ghost'\n data-testid={editing ? 'thread.message.save' : 'thread.message.edit'}\n classNames={messageControlClassNames}\n onClick={() => setEditing((editing) => !editing)}\n >\n <span className='sr-only'>{editLabel}</span>\n {editing ? <Check className={getSize(4)} /> : <PencilSimple className={getSize(4)} />}\n </Button>\n </Tooltip.Trigger>\n <Tooltip.Portal>\n <Tooltip.Content>\n {editLabel}\n <Tooltip.Arrow />\n </Tooltip.Content>\n </Tooltip.Portal>\n </Tooltip.Root>\n )}\n {onDelete && (\n <Tooltip.Root>\n <Tooltip.Trigger asChild>\n <Button\n variant='ghost'\n data-testid='thread.message.delete'\n classNames={messageControlClassNames}\n onClick={() => handleDelete()}\n >\n <span className='sr-only'>{deleteLabel}</span>\n <X className={getSize(4)} />\n </Button>\n </Tooltip.Trigger>\n <Tooltip.Portal>\n <Tooltip.Content>\n {deleteLabel}\n <Tooltip.Arrow />\n </Tooltip.Content>\n </Tooltip.Portal>\n </Tooltip.Root>\n )}\n </ButtonGroup>\n </MessageHeading>\n <TextboxBlock message={message} isAuthor={userIsAuthor} editing={editing} />\n {RefArray.allResolvedTargets(message.parts ?? []).map((part, index) => (\n <MessagePart key={index} part={part} />\n ))}\n </MessageRoot>\n );\n};\n\nconst MessagePart = ({ part }: { part: Expando }) => {\n return (\n <Mosaic.Container id={part.id}>\n <Mosaic.DraggableTile type={THREAD_ITEM} path={part.id} item={part} Component={MessageBlockObjectTile} />\n </Mosaic.Container>\n );\n};\n\nconst TextboxBlock = ({\n message,\n isAuthor,\n editing,\n}: {\n message: MessageType;\n editing?: boolean;\n isAuthor?: boolean;\n identity?: Identity;\n}) => {\n const { themeMode } = useThemeContext();\n const inMemoryContentRef = useRef(message.text);\n\n const handleDocumentChange = useCallback((newState: string) => {\n inMemoryContentRef.current = newState;\n }, []);\n\n const saveDocumentChange = useCallback(() => {\n message.text = inMemoryContentRef.current;\n }, [message]);\n\n useOnTransition(editing, true, false, saveDocumentChange);\n\n const { parentRef, focusAttributes, view } = useTextEditor(\n () => ({\n initialValue: message.text,\n extensions: [\n createBasicExtensions({ readonly: !isAuthor || !editing }),\n createThemeExtensions({ themeMode }),\n command,\n EditorView.updateListener.of((update) => {\n if (update.docChanged) {\n handleDocumentChange(update.state.doc.toString());\n }\n }),\n ],\n }),\n [message.text, editing, isAuthor, themeMode, handleDocumentChange],\n );\n\n useEffect(() => {\n editing && view?.focus();\n }, [editing, view]);\n\n useOnEditAnalytics(message, !!editing);\n\n return <div role='none' ref={parentRef} className='mie-4' {...focusAttributes} />;\n};\n\nconst MessageBlockObjectTile: MosaicTileComponent<ReactiveEchoObject<any>> = forwardRef(\n ({ draggableStyle, draggableProps, item, active, ref: _ref, ...props }, forwardedRef) => {\n let title = item.name ?? item.title ?? item.type ?? 'Object';\n if (typeof title !== 'string') {\n title = title?.content ?? '';\n }\n\n return (\n <div\n role='group'\n className={mx('grid col-span-3 py-1 pr-4', hoverableControls, hoverableFocusedWithinControls)}\n style={draggableStyle}\n ref={forwardedRef}\n >\n <Surface\n role='card'\n limit={1}\n data={{ subject: item }}\n draggableProps={draggableProps}\n fallback={title}\n {...props}\n />\n </div>\n );\n },\n);\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { StreamLanguage, HighlightStyle, syntaxHighlighting } from '@codemirror/language';\nimport { type Extension } from '@codemirror/state';\n\nimport { tags } from '@dxos/react-ui-editor';\nimport { mx, tagRoot } from '@dxos/react-ui-theme';\n\n/**\n * https://github.com/codemirror/stream-parser/blob/main/test/test-stream-parser.ts\n */\nconst parser = StreamLanguage.define<{ count: number }>({\n startState: () => ({ count: 0 }),\n token: (stream, state) => {\n state.count++;\n if (stream.eatSpace()) {\n return null;\n }\n if (state.count === 1 && stream.match(/^(\\/\\w+)/)) {\n return 'tagName';\n }\n stream.next();\n return null;\n },\n});\n\nconst styles = HighlightStyle.define([\n {\n tag: tags.tagName,\n class: mx(tagRoot({ palette: 'cyan' }), 'text-baseText font-medium'),\n },\n]);\n\nexport const command: Extension = [parser, syntaxHighlighting(styles)];\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { generateName } from '@dxos/display-name';\nimport { type PublicKey } from '@dxos/react-client';\nimport { type Identity } from '@dxos/react-client/halo';\nimport { type MessageMetadata } from '@dxos/react-ui-thread';\nimport { hexToFallback } from '@dxos/util';\n\nexport type MessagePropertiesProvider = (identityKey: PublicKey | undefined) => MessageMetadata;\n\nexport const getMessageMetadata = (id: string, identity?: Identity): MessageMetadata => {\n const fallback = hexToFallback(identity?.identityKey.toHex() ?? '0');\n return {\n id,\n authorId: identity?.identityKey.toHex(),\n authorName:\n identity?.profile?.displayName ??\n (identity?.identityKey ? generateName(identity.identityKey.toHex()) : undefined),\n authorAvatarProps: {\n hue: identity?.profile?.data?.hue ?? fallback.hue,\n emoji: identity?.profile?.data?.emoji ?? fallback.emoji,\n },\n };\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,mBAAkE;AAElE,yBAAoB;AACpB,yBAA0C;AAC1C,mBAA4B;AAC5B,kBAAqE;AACrE,kBAA4B;AAC5B,sBAAkE;AAClE,6BAAuE;AACvE,4BAA0B;AAC1B,4BAAmB;AACnB,6BAA6F;ACX7F,kBAA2B;AAC3B,IAAAA,gBAAuC;AACvC,IAAAA,gBAA4E;AAE5E,2BAAwB;AACxB,IAAAC,sBAAyB;AAEzB,0BAA0B;AAE1B,IAAAC,eAA2C;AAC3C,IAAAC,mBAA+F;AAC/F,IAAAC,0BAA4E;AAC5E,6BAAiD;AACjD,IAAAC,yBAMO;AACP,IAAAC,0BAA4C;ACpB5C,sBAAmE;AAGnE,IAAAF,0BAAqB;AACrB,IAAAC,
|
|
6
|
-
"names": ["import_react", "import_live_object", "import_halo", "import_react_ui", "import_react_ui_editor", "import_react_ui_theme", "import_react_ui_thread", "parser", "StreamLanguage", "define", "startState", "count", "token", "stream", "state", "eatSpace", "match", "next", "styles", "HighlightStyle", "tag", "tags", "tagName", "class", "mx", "
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport React, { useLayoutEffect, useMemo, useRef, useState } from 'react';\n\nimport { Ref } from '@dxos/echo-schema';\nimport { create, makeRef, RefArray } from '@dxos/live-object';\nimport { MessageType } from '@dxos/plugin-space/types';\nimport { fullyQualifiedId, getSpace, useMembers, type Expando } from '@dxos/react-client/echo';\nimport { useIdentity } from '@dxos/react-client/halo';\nimport { Icon, ScrollArea, useThemeContext, useTranslation } from '@dxos/react-ui';\nimport { createBasicExtensions, createThemeExtensions, listener } from '@dxos/react-ui-editor';\nimport { StackItem } from '@dxos/react-ui-stack';\nimport { mx } from '@dxos/react-ui-theme';\nimport { MessageTextbox, type MessageTextboxProps, Thread, ThreadFooter, threadLayout } from '@dxos/react-ui-thread';\n\nimport { MessageContainer } from './MessageContainer';\nimport { command } from './command-extension';\nimport { type ThreadContainerProps } from './types';\nimport { useStatus } from '../hooks';\nimport { THREAD_PLUGIN } from '../meta';\nimport { getMessageMetadata } from '../util';\n\nexport const ChatHeading = ({ attendableId }: { attendableId?: string }) => {\n const { t } = useTranslation(THREAD_PLUGIN);\n return (\n <div role='none' className='flex items-center'>\n <StackItem.SigilButton attendableId={attendableId}>\n <Icon icon='ph--chat--regular' size={5} />\n </StackItem.SigilButton>\n <StackItem.HeadingLabel attendableId={attendableId}>{t('chat heading')}</StackItem.HeadingLabel>\n </div>\n );\n};\n\nexport const ChatContainer = ({ thread, context, current, autoFocusTextbox }: ThreadContainerProps) => {\n const identity = useIdentity()!;\n const space = getSpace(thread);\n const members = useMembers(space?.key);\n const activity = useStatus(space, fullyQualifiedId(thread));\n const { t } = useTranslation(THREAD_PLUGIN);\n // TODO(wittjosiah): This is a hack to reset the editor after a message is sent.\n const [_count, _setCount] = useState(0);\n const rerenderEditor = () => _setCount((count) => count + 1);\n const [autoFocus, setAutoFocus] = useState(autoFocusTextbox);\n const threadScrollRef = useRef<HTMLDivElement | null>(null);\n const { themeMode } = useThemeContext();\n\n const textboxMetadata = getMessageMetadata(fullyQualifiedId(thread), identity);\n const messageRef = useRef('');\n const extensions = useMemo(\n () => [\n createBasicExtensions({ placeholder: t('message placeholder') }),\n createThemeExtensions({ themeMode }),\n listener({ onChange: (text) => (messageRef.current = text) }),\n command,\n ],\n [themeMode, _count],\n );\n\n // TODO(thure): Factor out.\n // TODO(thure): `flex-col-reverse` does not work to start the container scrolled to the end while also using\n // `ScrollArea`. This is the least-bad way I found to scroll to the end on mount. Note that 0ms was insufficient\n // for the desired effect; this is likely hardware-dependent and should be reevaluated.\n const scrollToEnd = (behavior: ScrollBehavior) =>\n setTimeout(() => threadScrollRef.current?.scrollIntoView({ behavior, block: 'end' }), 10);\n\n useLayoutEffect(() => {\n scrollToEnd('instant');\n }, []);\n\n // TODO(burdon): Change to model.\n const handleCreate: MessageTextboxProps['onSend'] = () => {\n if (!messageRef.current?.length) {\n return false;\n }\n\n thread.messages.push(\n makeRef(\n create(MessageType, {\n sender: { identityKey: identity.identityKey.toHex() },\n timestamp: new Date().toISOString(),\n text: messageRef.current,\n context: makeRef(context as Expando),\n }),\n ),\n );\n\n messageRef.current = '';\n setAutoFocus(true);\n scrollToEnd('smooth');\n rerenderEditor();\n return true;\n };\n\n const handleDelete = (id: string) => {\n const messageIndex = thread.messages.findIndex(Ref.hasObjectId(id));\n if (messageIndex !== -1) {\n thread.messages.splice(messageIndex, 1);\n }\n };\n\n return (\n <Thread\n current={current}\n id={fullyQualifiedId(thread)}\n classNames='bs-full grid-rows-[1fr_min-content_min-content] overflow-hidden transition-[padding-block-end] [[data-sidebar-inline-start-state=open]_&]:lg:pbe-0'\n >\n <ScrollArea.Root classNames='col-span-2'>\n <ScrollArea.Viewport classNames='overflow-anchored after:overflow-anchor after:block after:bs-px after:-mbs-px [&>div]:min-bs-full [&>div]:!grid [&>div]:grid-rows-[1fr_0]'>\n <div role='none' className={mx(threadLayout, 'place-self-end')}>\n {RefArray.allResolvedTargets(thread.messages ?? []).map((message) => (\n <MessageContainer key={message.id} message={message} members={members} onDelete={handleDelete} />\n ))}\n </div>\n {/* NOTE(thure): This can’t also be the `overflow-anchor` because `ScrollArea` injects an interceding node that contains this necessary ref’d element. */}\n <div role='none' className='bs-px -mbs-px' ref={threadScrollRef} />\n <ScrollArea.Scrollbar>\n <ScrollArea.Thumb />\n </ScrollArea.Scrollbar>\n </ScrollArea.Viewport>\n </ScrollArea.Root>\n <MessageTextbox extensions={extensions} autoFocus={autoFocus} onSend={handleCreate} {...textboxMetadata} />\n <ThreadFooter activity={activity}>{t('activity message')}</ThreadFooter>\n </Thread>\n );\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { EditorView } from '@codemirror/view';\nimport { Check, PencilSimple, X } from '@phosphor-icons/react';\nimport React, { forwardRef, useCallback, useEffect, useRef, useState } from 'react';\n\nimport { Surface } from '@dxos/app-framework';\nimport { RefArray } from '@dxos/live-object';\nimport { type MessageType } from '@dxos/plugin-space/types';\nimport { PublicKey } from '@dxos/react-client';\nimport { type ReactiveEchoObject, type Expando, type SpaceMember } from '@dxos/react-client/echo';\nimport { useIdentity, type Identity } from '@dxos/react-client/halo';\nimport { Button, ButtonGroup, Tooltip, useOnTransition, useThemeContext, useTranslation } from '@dxos/react-ui';\nimport { createBasicExtensions, createThemeExtensions, useTextEditor } from '@dxos/react-ui-editor';\nimport { Mosaic, type MosaicTileComponent } from '@dxos/react-ui-mosaic';\nimport {\n getSize,\n hoverableControlItem,\n hoverableControls,\n hoverableFocusedWithinControls,\n mx,\n} from '@dxos/react-ui-theme';\nimport { MessageHeading, MessageRoot } from '@dxos/react-ui-thread';\n\nimport { command } from './command-extension';\nimport { useOnEditAnalytics } from '../hooks';\nimport { THREAD_ITEM, THREAD_PLUGIN } from '../meta';\nimport { getMessageMetadata } from '../util';\n\n// TODO(thure): #8149\nconst messageControlClassNames = ['!p-1 !min-bs-0 transition-opacity', hoverableControlItem];\n\nexport const MessageContainer = ({\n message,\n members,\n onDelete,\n}: {\n message: MessageType;\n members: SpaceMember[];\n onDelete?: (id: string) => void;\n}) => {\n const senderIdentity = members.find(\n (member) => message.sender.identityKey && PublicKey.equals(member.identity.identityKey, message.sender.identityKey),\n )?.identity;\n const messageMetadata = getMessageMetadata(message.id, senderIdentity);\n const userIsAuthor = useIdentity()?.identityKey.toHex() === messageMetadata.authorId;\n const [editing, setEditing] = useState(false);\n const handleDelete = useCallback(() => onDelete?.(message.id), [message, onDelete]);\n const { t } = useTranslation(THREAD_PLUGIN);\n const editLabel = t(editing ? 'save message label' : 'edit message label');\n const deleteLabel = t('delete message label');\n\n return (\n <MessageRoot {...messageMetadata} classNames={[hoverableControls, hoverableFocusedWithinControls]}>\n <MessageHeading authorName={messageMetadata.authorName} timestamp={messageMetadata.timestamp}>\n <ButtonGroup classNames='mie-1'>\n {userIsAuthor && (\n <Tooltip.Root>\n <Tooltip.Trigger asChild>\n <Button\n variant='ghost'\n data-testid={editing ? 'thread.message.save' : 'thread.message.edit'}\n classNames={messageControlClassNames}\n onClick={() => setEditing((editing) => !editing)}\n >\n <span className='sr-only'>{editLabel}</span>\n {editing ? <Check className={getSize(4)} /> : <PencilSimple className={getSize(4)} />}\n </Button>\n </Tooltip.Trigger>\n <Tooltip.Portal>\n <Tooltip.Content>\n {editLabel}\n <Tooltip.Arrow />\n </Tooltip.Content>\n </Tooltip.Portal>\n </Tooltip.Root>\n )}\n {onDelete && (\n <Tooltip.Root>\n <Tooltip.Trigger asChild>\n <Button\n variant='ghost'\n data-testid='thread.message.delete'\n classNames={messageControlClassNames}\n onClick={() => handleDelete()}\n >\n <span className='sr-only'>{deleteLabel}</span>\n <X className={getSize(4)} />\n </Button>\n </Tooltip.Trigger>\n <Tooltip.Portal>\n <Tooltip.Content>\n {deleteLabel}\n <Tooltip.Arrow />\n </Tooltip.Content>\n </Tooltip.Portal>\n </Tooltip.Root>\n )}\n </ButtonGroup>\n </MessageHeading>\n <TextboxBlock message={message} isAuthor={userIsAuthor} editing={editing} />\n {RefArray.allResolvedTargets(message.parts ?? []).map((part, index) => (\n <MessagePart key={index} part={part} />\n ))}\n </MessageRoot>\n );\n};\n\nconst MessagePart = ({ part }: { part: Expando }) => {\n return (\n <Mosaic.Container id={part.id}>\n <Mosaic.DraggableTile type={THREAD_ITEM} path={part.id} item={part} Component={MessageBlockObjectTile} />\n </Mosaic.Container>\n );\n};\n\nconst TextboxBlock = ({\n message,\n isAuthor,\n editing,\n}: {\n message: MessageType;\n editing?: boolean;\n isAuthor?: boolean;\n identity?: Identity;\n}) => {\n const { themeMode } = useThemeContext();\n const inMemoryContentRef = useRef(message.text);\n\n const handleDocumentChange = useCallback((newState: string) => {\n inMemoryContentRef.current = newState;\n }, []);\n\n const saveDocumentChange = useCallback(() => {\n message.text = inMemoryContentRef.current;\n }, [message]);\n\n useOnTransition(editing, true, false, saveDocumentChange);\n\n const { parentRef, focusAttributes, view } = useTextEditor(\n () => ({\n initialValue: message.text,\n extensions: [\n createBasicExtensions({ readonly: !isAuthor || !editing }),\n createThemeExtensions({ themeMode }),\n command,\n EditorView.updateListener.of((update) => {\n if (update.docChanged) {\n handleDocumentChange(update.state.doc.toString());\n }\n }),\n ],\n }),\n [message.text, editing, isAuthor, themeMode, handleDocumentChange],\n );\n\n useEffect(() => {\n editing && view?.focus();\n }, [editing, view]);\n\n useOnEditAnalytics(message, !!editing);\n\n return <div role='none' ref={parentRef} className='mie-4' {...focusAttributes} />;\n};\n\nconst MessageBlockObjectTile: MosaicTileComponent<ReactiveEchoObject<any>> = forwardRef(\n ({ draggableStyle, draggableProps, item, active, ref: _ref, ...props }, forwardedRef) => {\n let title = item.name ?? item.title ?? item.type ?? 'Object';\n if (typeof title !== 'string') {\n title = title?.content ?? '';\n }\n\n return (\n <div\n role='group'\n className={mx('grid col-span-3 py-1 pr-4', hoverableControls, hoverableFocusedWithinControls)}\n style={draggableStyle}\n ref={forwardedRef}\n >\n <Surface\n role='card'\n limit={1}\n data={{ subject: item }}\n draggableProps={draggableProps}\n fallback={title}\n {...props}\n />\n </div>\n );\n },\n);\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { StreamLanguage, HighlightStyle, syntaxHighlighting } from '@codemirror/language';\nimport { type Extension } from '@codemirror/state';\n\nimport { tags } from '@dxos/react-ui-editor';\nimport { mx } from '@dxos/react-ui-theme';\n\n/**\n * https://github.com/codemirror/stream-parser/blob/main/test/test-stream-parser.ts\n */\nconst parser = StreamLanguage.define<{ count: number }>({\n startState: () => ({ count: 0 }),\n token: (stream, state) => {\n state.count++;\n if (stream.eatSpace()) {\n return null;\n }\n if (state.count === 1 && stream.match(/^(\\/\\w+)/)) {\n return 'tagName';\n }\n stream.next();\n return null;\n },\n});\n\nconst styles = HighlightStyle.define([\n { tag: tags.tagName, class: mx('dx-tag dx-tag--indigo text-baseText font-medium') },\n]);\n\nexport const command: Extension = [parser, syntaxHighlighting(styles)];\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { generateName } from '@dxos/display-name';\nimport { type PublicKey } from '@dxos/react-client';\nimport { type Identity } from '@dxos/react-client/halo';\nimport { type MessageMetadata } from '@dxos/react-ui-thread';\nimport { hexToFallback } from '@dxos/util';\n\nexport type MessagePropertiesProvider = (identityKey: PublicKey | undefined) => MessageMetadata;\n\nexport const getMessageMetadata = (id: string, identity?: Identity): MessageMetadata => {\n const fallback = hexToFallback(identity?.identityKey.toHex() ?? '0');\n return {\n id,\n authorId: identity?.identityKey.toHex(),\n authorName:\n identity?.profile?.displayName ??\n (identity?.identityKey ? generateName(identity.identityKey.toHex()) : undefined),\n authorAvatarProps: {\n hue: identity?.profile?.data?.hue ?? fallback.hue,\n emoji: identity?.profile?.data?.emoji ?? fallback.emoji,\n },\n };\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;A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K;IAAOzD,eAAW9D,sBAAAA,IAAGoL,qCAAc,gBAAA;KAC1C5G,mBAAAA,SAASC,mBAAmB+D,OAAO6B,YAAY,CAAA,CAAE,EAAE1F,IAAI,CAACpD,YACvDsB,6BAAAA,QAAA,cAACvB,kBAAAA;IAAiByD,KAAKxD,QAAQnB;IAAImB;IAAkBC;IAAkBC,UAAUa;QAIrFO,6BAAAA,QAAA,cAACyE,OAAAA;IAAIC,MAAK;IAAOzD,WAAU;IAAgB0D,KAAK8B;MAChDzG,6BAAAA,QAAA,cAACqI,2BAAWG,WAAS,MACnBxI,6BAAAA,QAAA,cAACqI,2BAAWI,OAAK,IAAA,CAAA,CAAA,CAAA,GAIvBzI,6BAAAA,QAAA,cAAC0I,uCAAAA;IAAe/E;IAAwB4C;IAAsBoC,QAAQrB;IAAe,GAAGZ;MACxF1G,6BAAAA,QAAA,cAAC4I,qCAAAA;IAAa3C;KAAqBtG,EAAE,kBAAA,CAAA,CAAA;AAG3C;",
|
|
6
|
+
"names": ["import_react", "import_live_object", "import_halo", "import_react_ui", "import_react_ui_editor", "import_react_ui_theme", "import_react_ui_thread", "parser", "StreamLanguage", "define", "startState", "count", "token", "stream", "state", "eatSpace", "match", "next", "styles", "HighlightStyle", "tag", "tags", "tagName", "class", "mx", "command", "syntaxHighlighting", "getMessageMetadata", "id", "identity", "fallback", "hexToFallback", "identityKey", "toHex", "authorId", "authorName", "profile", "displayName", "generateName", "undefined", "authorAvatarProps", "hue", "data", "emoji", "messageControlClassNames", "hoverableControlItem", "MessageContainer", "message", "members", "onDelete", "senderIdentity", "find", "member", "sender", "PublicKey", "equals", "messageMetadata", "userIsAuthor", "useIdentity", "editing", "setEditing", "useState", "handleDelete", "useCallback", "t", "useTranslation", "THREAD_PLUGIN", "editLabel", "deleteLabel", "React", "MessageRoot", "classNames", "hoverableControls", "hoverableFocusedWithinControls", "MessageHeading", "timestamp", "ButtonGroup", "Tooltip", "Root", "Trigger", "asChild", "Button", "variant", "data-testid", "onClick", "span", "className", "Check", "getSize", "PencilSimple", "Portal", "Content", "Arrow", "X", "TextboxBlock", "isAuthor", "RefArray", "allResolvedTargets", "parts", "map", "part", "index", "MessagePart", "key", "Mosaic", "Container", "DraggableTile", "type", "THREAD_ITEM", "path", "item", "Component", "MessageBlockObjectTile", "themeMode", "useThemeContext", "inMemoryContentRef", "useRef", "text", "handleDocumentChange", "newState", "current", "saveDocumentChange", "useOnTransition", "parentRef", "focusAttributes", "view", "useTextEditor", "initialValue", "extensions", "createBasicExtensions", "readonly", "createThemeExtensions", "EditorView", "updateListener", "of", "update", "docChanged", "doc", "toString", "useEffect", "focus", "useOnEditAnalytics", "div", "role", "ref", "forwardRef", "draggableStyle", "draggableProps", "active", "_ref", "props", "forwardedRef", "title", "name", "content", "style", "Surface", "limit", "subject", "ChatContainer", "thread", "context", "autoFocusTextbox", "space", "getSpace", "useMembers", "activity", "useStatus", "fullyQualifiedId", "_count", "_setCount", "rerenderEditor", "autoFocus", "setAutoFocus", "threadScrollRef", "textboxMetadata", "messageRef", "useMemo", "placeholder", "listener", "onChange", "scrollToEnd", "behavior", "setTimeout", "scrollIntoView", "block", "useLayoutEffect", "handleCreate", "length", "messages", "push", "makeRef", "create", "MessageType", "Date", "toISOString", "messageIndex", "findIndex", "Ref", "hasObjectId", "splice", "Thread", "ScrollArea", "Viewport", "threadLayout", "Scrollbar", "Thumb", "MessageTextbox", "onSend", "ThreadFooter"]
|
|
7
7
|
}
|
|
@@ -26,8 +26,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var
|
|
30
|
-
__export(
|
|
29
|
+
var chunk_S5LH7AIT_exports = {};
|
|
30
|
+
__export(chunk_S5LH7AIT_exports, {
|
|
31
31
|
AppGraphBuilder: () => AppGraphBuilder,
|
|
32
32
|
IntentResolver: () => IntentResolver,
|
|
33
33
|
Markdown: () => Markdown,
|
|
@@ -35,12 +35,12 @@ __export(chunk_ZRN7B26W_exports, {
|
|
|
35
35
|
ThreadSettings: () => ThreadSettings,
|
|
36
36
|
ThreadState: () => ThreadState
|
|
37
37
|
});
|
|
38
|
-
module.exports = __toCommonJS(
|
|
38
|
+
module.exports = __toCommonJS(chunk_S5LH7AIT_exports);
|
|
39
39
|
var import_app_framework = require("@dxos/app-framework");
|
|
40
40
|
var AppGraphBuilder = (0, import_app_framework.lazy)(() => import("./app-graph-builder-ZXW5KUDK.cjs"));
|
|
41
|
-
var IntentResolver = (0, import_app_framework.lazy)(() => import("./intent-resolver-
|
|
41
|
+
var IntentResolver = (0, import_app_framework.lazy)(() => import("./intent-resolver-ZSOQILPJ.cjs"));
|
|
42
42
|
var Markdown = (0, import_app_framework.lazy)(() => import("./markdown-FWRKMSKV.cjs"));
|
|
43
|
-
var ReactSurface = (0, import_app_framework.lazy)(() => import("./react-surface-
|
|
43
|
+
var ReactSurface = (0, import_app_framework.lazy)(() => import("./react-surface-CPDCOLUZ.cjs"));
|
|
44
44
|
var ThreadSettings = (0, import_app_framework.lazy)(() => import("./settings-TH4YSUVU.cjs"));
|
|
45
45
|
var ThreadState = (0, import_app_framework.lazy)(() => import("./state-TQWEZ6B3.cjs"));
|
|
46
46
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -52,4 +52,4 @@ var ThreadState = (0, import_app_framework.lazy)(() => import("./state-TQWEZ6B3.
|
|
|
52
52
|
ThreadSettings,
|
|
53
53
|
ThreadState
|
|
54
54
|
});
|
|
55
|
-
//# sourceMappingURL=chunk-
|
|
55
|
+
//# sourceMappingURL=chunk-S5LH7AIT.cjs.map
|
package/dist/lib/node/index.cjs
CHANGED
|
@@ -27,7 +27,7 @@ __export(node_exports, {
|
|
|
27
27
|
useStatus: () => import_chunk_AWSTZ2KN.useStatus
|
|
28
28
|
});
|
|
29
29
|
module.exports = __toCommonJS(node_exports);
|
|
30
|
-
var
|
|
30
|
+
var import_chunk_S5LH7AIT = require("./chunk-S5LH7AIT.cjs");
|
|
31
31
|
var import_chunk_FPWNZ6TB = require("./chunk-FPWNZ6TB.cjs");
|
|
32
32
|
var import_chunk_AWSTZ2KN = require("./chunk-AWSTZ2KN.cjs");
|
|
33
33
|
var import_chunk_AUVKOX5Q = require("./chunk-AUVKOX5Q.cjs");
|
|
@@ -82,12 +82,12 @@ var ThreadPlugin = () => (0, import_app_framework.definePlugin)(import_chunk_F73
|
|
|
82
82
|
(0, import_app_framework.defineModule)({
|
|
83
83
|
id: `${import_chunk_F735VMTN.meta.id}/module/settings`,
|
|
84
84
|
activatesOn: import_app_framework.Events.SetupSettings,
|
|
85
|
-
activate:
|
|
85
|
+
activate: import_chunk_S5LH7AIT.ThreadSettings
|
|
86
86
|
}),
|
|
87
87
|
(0, import_app_framework.defineModule)({
|
|
88
88
|
id: `${import_chunk_F735VMTN.meta.id}/module/state`,
|
|
89
89
|
activatesOn: import_app_framework.Events.Startup,
|
|
90
|
-
activate:
|
|
90
|
+
activate: import_chunk_S5LH7AIT.ThreadState
|
|
91
91
|
}),
|
|
92
92
|
(0, import_app_framework.defineModule)({
|
|
93
93
|
id: `${import_chunk_F735VMTN.meta.id}/module/translations`,
|
|
@@ -99,7 +99,7 @@ var ThreadPlugin = () => (0, import_app_framework.definePlugin)(import_chunk_F73
|
|
|
99
99
|
}),
|
|
100
100
|
(0, import_app_framework.defineModule)({
|
|
101
101
|
id: `${import_chunk_F735VMTN.meta.id}/module/metadata`,
|
|
102
|
-
activatesOn:
|
|
102
|
+
activatesOn: import_app_framework.Events.SetupMetadata,
|
|
103
103
|
activate: () => [
|
|
104
104
|
(0, import_app_framework.contributes)(import_app_framework.Capabilities.Metadata, {
|
|
105
105
|
id: import_types.ChannelType.typename,
|
|
@@ -156,7 +156,7 @@ var ThreadPlugin = () => (0, import_app_framework.definePlugin)(import_chunk_F73
|
|
|
156
156
|
}),
|
|
157
157
|
(0, import_app_framework.defineModule)({
|
|
158
158
|
id: `${import_chunk_F735VMTN.meta.id}/module/schema`,
|
|
159
|
-
activatesOn: import_plugin_client.ClientEvents.
|
|
159
|
+
activatesOn: import_plugin_client.ClientEvents.SetupSchema,
|
|
160
160
|
activate: () => (0, import_app_framework.contributes)(import_plugin_client.ClientCapabilities.SystemSchema, [
|
|
161
161
|
import_types.ThreadType,
|
|
162
162
|
import_types.MessageType
|
|
@@ -196,22 +196,22 @@ var ThreadPlugin = () => (0, import_app_framework.definePlugin)(import_chunk_F73
|
|
|
196
196
|
(0, import_app_framework.defineModule)({
|
|
197
197
|
id: `${import_chunk_F735VMTN.meta.id}/module/markdown`,
|
|
198
198
|
activatesOn: import_app_framework.Events.Startup,
|
|
199
|
-
activate:
|
|
199
|
+
activate: import_chunk_S5LH7AIT.Markdown
|
|
200
200
|
}),
|
|
201
201
|
(0, import_app_framework.defineModule)({
|
|
202
202
|
id: `${import_chunk_F735VMTN.meta.id}/module/react-surface`,
|
|
203
|
-
activatesOn: import_app_framework.Events.
|
|
204
|
-
activate:
|
|
203
|
+
activatesOn: import_app_framework.Events.SetupSurfaces,
|
|
204
|
+
activate: import_chunk_S5LH7AIT.ReactSurface
|
|
205
205
|
}),
|
|
206
206
|
(0, import_app_framework.defineModule)({
|
|
207
207
|
id: `${import_chunk_F735VMTN.meta.id}/module/intent-resolver`,
|
|
208
208
|
activatesOn: import_app_framework.Events.SetupIntents,
|
|
209
|
-
activate:
|
|
209
|
+
activate: import_chunk_S5LH7AIT.IntentResolver
|
|
210
210
|
}),
|
|
211
211
|
(0, import_app_framework.defineModule)({
|
|
212
212
|
id: `${import_chunk_F735VMTN.meta.id}/module/app-graph-builder`,
|
|
213
213
|
activatesOn: import_app_framework.Events.SetupAppGraph,
|
|
214
|
-
activate:
|
|
214
|
+
activate: import_chunk_S5LH7AIT.AppGraphBuilder
|
|
215
215
|
})
|
|
216
216
|
]);
|
|
217
217
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/ThreadPlugin.tsx", "../../../src/translations.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport {\n allOf,\n Capabilities,\n contributes,\n createIntent,\n defineModule,\n definePlugin,\n Events,\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,
|
|
6
|
-
"names": ["import_types", "ChannelType", "typename", "THREAD_PLUGIN", "ThreadPlugin", "definePlugin", "meta", "defineModule", "id", "activatesOn", "Events", "SetupSettings", "activate", "ThreadSettings", "Startup", "ThreadState", "SetupTranslations", "contributes", "Capabilities", "Translations", "translations", "threadTranslations", "
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport {\n allOf,\n Capabilities,\n contributes,\n createIntent,\n defineModule,\n definePlugin,\n Events,\n type PluginsContext,\n} from '@dxos/app-framework';\nimport { ClientCapabilities, ClientEvents } from '@dxos/plugin-client';\nimport { DeckCapabilities } from '@dxos/plugin-deck';\nimport { ChannelType, MessageType, ThreadType } from '@dxos/plugin-space/types';\nimport { type ReactiveEchoObject, RefArray } from '@dxos/react-client/echo';\nimport { translations as threadTranslations } from '@dxos/react-ui-thread';\n\nimport { AppGraphBuilder, IntentResolver, Markdown, ReactSurface, ThreadSettings, ThreadState } from './capabilities';\nimport { meta, THREAD_ITEM, THREAD_PLUGIN } from './meta';\nimport translations from './translations';\nimport { ThreadAction, type ThreadSettingsProps } from './types';\n\n// TODO(Zan): Every instance of `cursor` should be replaced with `anchor`.\n// NOTE(burdon): Review/discuss CursorConverter semantics.\nexport const ThreadPlugin = () =>\n definePlugin(meta, [\n defineModule({\n id: `${meta.id}/module/settings`,\n activatesOn: Events.SetupSettings,\n activate: ThreadSettings,\n }),\n defineModule({\n id: `${meta.id}/module/state`,\n activatesOn: Events.Startup,\n activate: ThreadState,\n }),\n defineModule({\n id: `${meta.id}/module/translations`,\n activatesOn: Events.SetupTranslations,\n activate: () => contributes(Capabilities.Translations, [...translations, ...threadTranslations]),\n }),\n defineModule({\n id: `${meta.id}/module/metadata`,\n activatesOn: Events.SetupMetadata,\n activate: () => [\n contributes(Capabilities.Metadata, {\n id: ChannelType.typename,\n metadata: {\n createObject: (props: { name?: string }) => createIntent(ThreadAction.Create, props),\n placeholder: ['channel name placeholder', { ns: THREAD_PLUGIN }],\n icon: 'ph--chat--regular',\n // TODO(wittjosiah): Move out of metadata.\n loadReferences: async (channel: ChannelType) => await RefArray.loadAll(channel.threads ?? []),\n },\n }),\n contributes(Capabilities.Metadata, {\n id: ThreadType.typename,\n metadata: {\n // TODO(wittjosiah): Move out of metadata.\n loadReferences: async (thread: ThreadType) => await RefArray.loadAll(thread.messages ?? []),\n },\n }),\n contributes(Capabilities.Metadata, {\n id: MessageType.typename,\n metadata: {\n // TODO(wittjosiah): Move out of metadata.\n loadReferences: (message: MessageType) => [], // loadObjectReferences(message, (message) => [...message.parts, message.context]),\n },\n }),\n contributes(Capabilities.Metadata, {\n id: THREAD_ITEM,\n metadata: {\n parse: (item: ReactiveEchoObject<any>, type: string) => {\n switch (type) {\n case 'node':\n return { id: item.id, label: item.title, data: item };\n case 'object':\n return item;\n case 'view-object':\n return { id: `${item.id}-view`, object: item };\n }\n },\n },\n }),\n ],\n }),\n defineModule({\n id: `${meta.id}/module/schema`,\n activatesOn: ClientEvents.SetupSchema,\n activate: () => contributes(ClientCapabilities.SystemSchema, [ThreadType, MessageType]),\n }),\n defineModule({\n id: `${meta.id}/module/channel-schema`,\n activatesOn: allOf(Events.SettingsReady, ClientEvents.ClientReady),\n activate: (context: PluginsContext) => {\n const client = context.requestCapability(ClientCapabilities.Client);\n const settings = context\n .requestCapability(Capabilities.SettingsStore)\n .getStore<ThreadSettingsProps>(THREAD_PLUGIN)!.value;\n if (settings.standalone) {\n // TODO(wittjosiah): Requires reload to disable.\n client.addTypes([ChannelType]);\n return contributes(ClientCapabilities.Schema, [ChannelType]);\n }\n\n return [];\n },\n }),\n defineModule({\n id: `${meta.id}/module/complementary-panel`,\n activatesOn: Events.Startup,\n activate: () =>\n contributes(DeckCapabilities.ComplementaryPanel, {\n id: 'comments',\n label: ['comments panel label', { ns: THREAD_PLUGIN }],\n icon: 'ph--chat-text--regular',\n }),\n }),\n defineModule({\n id: `${meta.id}/module/markdown`,\n activatesOn: Events.Startup,\n activate: Markdown,\n }),\n defineModule({\n id: `${meta.id}/module/react-surface`,\n activatesOn: Events.SetupSurfaces,\n activate: ReactSurface,\n }),\n defineModule({\n id: `${meta.id}/module/intent-resolver`,\n activatesOn: Events.SetupIntents,\n activate: IntentResolver,\n }),\n defineModule({\n id: `${meta.id}/module/app-graph-builder`,\n activatesOn: Events.SetupAppGraph,\n activate: AppGraphBuilder,\n }),\n ]);\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { ChannelType } from '@dxos/plugin-space/types';\n\nimport { THREAD_PLUGIN } from './meta';\n\nexport default [\n {\n 'en-US': {\n [ChannelType.typename]: {\n 'typename label': 'Channel',\n },\n [THREAD_PLUGIN]: {\n 'plugin name': 'Threads',\n 'channel name placeholder': 'New channel',\n 'channel title label': 'Title',\n 'delete channel label': 'Delete channel',\n 'create channel label': 'Create channel',\n 'message placeholder': 'Reply…',\n 'settings standalone label': 'Enable channel creation (experimental)',\n 'activity message': 'Processing…',\n 'anonymous label': 'Anonymous',\n 'delete message block label': 'Delete message block',\n 'detached thread label': 'Referenced content was removed',\n 'delete thread label': 'Delete thread',\n 'thread deleted label': 'You deleted a thread.',\n 'message deleted label': 'You deleted a message.',\n 'comments heading': 'Comments',\n 'chat heading': 'Chat',\n 'draft button': 'DRAFT',\n 'no comments title': 'No comments (yet)',\n 'no comments message':\n 'To start a comment thread, select a range of text in a document and click the <commentIcon></commentIcon> Create comment button in the toolbar.',\n 'toggle show resolved': 'Show resolved',\n 'unnamed object threads label': 'Threads',\n 'mark as resolved label': 'Mark as resolved',\n 'mark as unresolved label': 'Mark as unresolved',\n 'save message label': 'Save',\n 'edit message label': 'Edit',\n 'delete message label': 'Delete message',\n 'open comments panel label': 'Show Comments',\n 'comments panel label': 'Comments',\n },\n },\n },\n];\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,2BASO;AACP,2BAAiD;AACjD,yBAAiC;AACjC,mBAAqD;AACrD,kBAAkD;AAClD,6BAAmD;ACdnD,IAAAA,gBAA4B;AAI5B,IAAA,uBAAe;EACb;IACE,SAAS;MACP,CAACC,0BAAYC,QAAQ,GAAG;QACtB,kBAAkB;MACpB;MACA,CAACC,mCAAAA,GAAgB;QACf,eAAe;QACf,4BAA4B;QAC5B,uBAAuB;QACvB,wBAAwB;QACxB,wBAAwB;QACxB,uBAAuB;QACvB,6BAA6B;QAC7B,oBAAoB;QACpB,mBAAmB;QACnB,8BAA8B;QAC9B,yBAAyB;QACzB,uBAAuB;QACvB,wBAAwB;QACxB,yBAAyB;QACzB,oBAAoB;QACpB,gBAAgB;QAChB,gBAAgB;QAChB,qBAAqB;QACrB,uBACE;QACF,wBAAwB;QACxB,gCAAgC;QAChC,0BAA0B;QAC1B,4BAA4B;QAC5B,sBAAsB;QACtB,sBAAsB;QACtB,wBAAwB;QACxB,6BAA6B;QAC7B,wBAAwB;MAC1B;IACF;EACF;;ADnBK,IAAMC,eAAe,UAC1BC,mCAAaC,4BAAM;MACjBC,mCAAa;IACXC,IAAI,GAAGF,2BAAKE,EAAE;IACdC,aAAaC,4BAAOC;IACpBC,UAAUC;EACZ,CAAA;MACAN,mCAAa;IACXC,IAAI,GAAGF,2BAAKE,EAAE;IACdC,aAAaC,4BAAOI;IACpBF,UAAUG;EACZ,CAAA;MACAR,mCAAa;IACXC,IAAI,GAAGF,2BAAKE,EAAE;IACdC,aAAaC,4BAAOM;IACpBJ,UAAU,UAAMK,kCAAYC,kCAAaC,cAAc;SAAIC;SAAiBC,uBAAAA;KAAmB;EACjG,CAAA;MAC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BAAa8C,4BAAM7C,4BAAO8C,eAAeL,kCAAaM,WAAW;IACjE7C,UAAU,CAAC8C,YAAAA;AACT,YAAMC,SAASD,QAAQE,kBAAkBP,wCAAmBQ,MAAM;AAClE,YAAMC,WAAWJ,QACdE,kBAAkB1C,kCAAa6C,aAAa,EAC5CC,SAA8B7D,mCAAAA,EAAgB8D;AACjD,UAAIH,SAASI,YAAY;AAEvBP,eAAOQ,SAAS;UAAClE,aAAAA;SAAY;AAC7B,mBAAOgB,kCAAYoC,wCAAmBe,QAAQ;UAACnE,aAAAA;SAAY;MAC7D;AAEA,aAAO,CAAA;IACT;EACF,CAAA;MACAM,mCAAa;IACXC,IAAI,GAAGF,2BAAKE,EAAE;IACdC,aAAaC,4BAAOI;IACpBF,UAAU,UACRK,kCAAYoD,oCAAiBC,oBAAoB;MAC/C9D,IAAI;MACJuC,OAAO;QAAC;QAAwB;UAAEhB,IAAI5B;QAAc;;MACpD6B,MAAM;IACR,CAAA;EACJ,CAAA;MACAzB,mCAAa;IACXC,IAAI,GAAGF,2BAAKE,EAAE;IACdC,aAAaC,4BAAOI;IACpBF,UAAU2D;EACZ,CAAA;MACAhE,mCAAa;IACXC,IAAI,GAAGF,2BAAKE,EAAE;IACdC,aAAaC,4BAAO8D;IACpB5D,UAAU6D;EACZ,CAAA;MACAlE,mCAAa;IACXC,IAAI,GAAGF,2BAAKE,EAAE;IACdC,aAAaC,4BAAOgE;IACpB9D,UAAU+D;EACZ,CAAA;MACApE,mCAAa;IACXC,IAAI,GAAGF,2BAAKE,EAAE;IACdC,aAAaC,4BAAOkE;IACpBhE,UAAUiE;EACZ,CAAA;CACD;",
|
|
6
|
+
"names": ["import_types", "ChannelType", "typename", "THREAD_PLUGIN", "ThreadPlugin", "definePlugin", "meta", "defineModule", "id", "activatesOn", "Events", "SetupSettings", "activate", "ThreadSettings", "Startup", "ThreadState", "SetupTranslations", "contributes", "Capabilities", "Translations", "translations", "threadTranslations", "SetupMetadata", "Metadata", "metadata", "createObject", "props", "createIntent", "ThreadAction", "Create", "placeholder", "ns", "icon", "loadReferences", "channel", "RefArray", "loadAll", "threads", "ThreadType", "thread", "messages", "MessageType", "message", "THREAD_ITEM", "parse", "item", "type", "label", "title", "data", "object", "ClientEvents", "SetupSchema", "ClientCapabilities", "SystemSchema", "allOf", "SettingsReady", "ClientReady", "context", "client", "requestCapability", "Client", "settings", "SettingsStore", "getStore", "value", "standalone", "addTypes", "Schema", "DeckCapabilities", "ComplementaryPanel", "Markdown", "SetupSurfaces", "ReactSurface", "SetupIntents", "IntentResolver", "SetupAppGraph", "AppGraphBuilder"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var intent_resolver_ZSOQILPJ_exports = {};
|
|
20
|
+
__export(intent_resolver_ZSOQILPJ_exports, {
|
|
21
|
+
default: () => intent_resolver_default
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(intent_resolver_ZSOQILPJ_exports);
|
|
24
|
+
var import_chunk_FPWNZ6TB = require("./chunk-FPWNZ6TB.cjs");
|
|
25
|
+
var import_chunk_AUVKOX5Q = require("./chunk-AUVKOX5Q.cjs");
|
|
26
|
+
var import_chunk_F735VMTN = require("./chunk-F735VMTN.cjs");
|
|
27
|
+
var import_app_framework = require("@dxos/app-framework");
|
|
28
|
+
var import_echo_schema = require("@dxos/echo-schema");
|
|
29
|
+
var import_log = require("@dxos/log");
|
|
30
|
+
var import_types = require("@dxos/plugin-observability/types");
|
|
31
|
+
var import_types2 = require("@dxos/plugin-space/types");
|
|
32
|
+
var import_echo = require("@dxos/react-client/echo");
|
|
33
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-thread/src/capabilities/intent-resolver.ts";
|
|
34
|
+
var intent_resolver_default = (context) => (0, import_app_framework.contributes)(import_app_framework.Capabilities.IntentResolver, [
|
|
35
|
+
(0, import_app_framework.createResolver)({
|
|
36
|
+
intent: import_chunk_AUVKOX5Q.ThreadAction.Create,
|
|
37
|
+
resolve: ({ name, cursor, subject }) => {
|
|
38
|
+
if (cursor && subject) {
|
|
39
|
+
if (subject?.threads === void 0) {
|
|
40
|
+
try {
|
|
41
|
+
subject.threads = [];
|
|
42
|
+
} catch (err) {
|
|
43
|
+
import_log.log.error("Subject does not support threads array", {
|
|
44
|
+
typename: subject?.typename
|
|
45
|
+
}, {
|
|
46
|
+
F: __dxlog_file,
|
|
47
|
+
L: 35,
|
|
48
|
+
S: void 0,
|
|
49
|
+
C: (f, a) => f(...a)
|
|
50
|
+
});
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
const { state } = context.requestCapability(import_chunk_FPWNZ6TB.ThreadCapabilities.MutableState);
|
|
55
|
+
const subjectId = (0, import_echo.fullyQualifiedId)(subject);
|
|
56
|
+
const thread = (0, import_echo.create)(import_types2.ThreadType, {
|
|
57
|
+
name,
|
|
58
|
+
anchor: cursor,
|
|
59
|
+
messages: [],
|
|
60
|
+
status: "staged"
|
|
61
|
+
});
|
|
62
|
+
const draft = state.drafts[subjectId];
|
|
63
|
+
if (draft) {
|
|
64
|
+
draft.push(thread);
|
|
65
|
+
} else {
|
|
66
|
+
state.drafts[subjectId] = [
|
|
67
|
+
thread
|
|
68
|
+
];
|
|
69
|
+
}
|
|
70
|
+
return {
|
|
71
|
+
data: {
|
|
72
|
+
object: thread
|
|
73
|
+
},
|
|
74
|
+
intents: [
|
|
75
|
+
(0, import_app_framework.createIntent)(import_chunk_AUVKOX5Q.ThreadAction.Select, {
|
|
76
|
+
current: (0, import_echo.fullyQualifiedId)(thread)
|
|
77
|
+
}),
|
|
78
|
+
(0, import_app_framework.createIntent)(import_app_framework.LayoutAction.UpdateComplementary, {
|
|
79
|
+
part: "complementary",
|
|
80
|
+
subject: "comments"
|
|
81
|
+
})
|
|
82
|
+
]
|
|
83
|
+
};
|
|
84
|
+
} else {
|
|
85
|
+
return {
|
|
86
|
+
data: {
|
|
87
|
+
object: (0, import_echo.create)(import_types2.ChannelType, {
|
|
88
|
+
threads: [
|
|
89
|
+
(0, import_echo.makeRef)((0, import_echo.create)(import_types2.ThreadType, {
|
|
90
|
+
messages: []
|
|
91
|
+
}))
|
|
92
|
+
]
|
|
93
|
+
})
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}),
|
|
99
|
+
(0, import_app_framework.createResolver)({
|
|
100
|
+
intent: import_chunk_AUVKOX5Q.ThreadAction.Select,
|
|
101
|
+
resolve: ({ current, skipOpen }) => {
|
|
102
|
+
const { state } = context.requestCapability(import_chunk_FPWNZ6TB.ThreadCapabilities.MutableState);
|
|
103
|
+
state.current = current;
|
|
104
|
+
return {
|
|
105
|
+
intents: !skipOpen ? [
|
|
106
|
+
(0, import_app_framework.createIntent)(import_app_framework.LayoutAction.UpdateComplementary, {
|
|
107
|
+
part: "complementary",
|
|
108
|
+
subject: "comments"
|
|
109
|
+
})
|
|
110
|
+
] : void 0
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
}),
|
|
114
|
+
(0, import_app_framework.createResolver)({
|
|
115
|
+
intent: import_chunk_AUVKOX5Q.ThreadAction.ToggleResolved,
|
|
116
|
+
resolve: ({ thread }) => {
|
|
117
|
+
if (thread.status === "active" || thread.status === void 0) {
|
|
118
|
+
thread.status = "resolved";
|
|
119
|
+
} else if (thread.status === "resolved") {
|
|
120
|
+
thread.status = "active";
|
|
121
|
+
}
|
|
122
|
+
const space = (0, import_echo.getSpace)(thread);
|
|
123
|
+
const spaceId = space?.id;
|
|
124
|
+
return {
|
|
125
|
+
intents: [
|
|
126
|
+
(0, import_app_framework.createIntent)(import_types.ObservabilityAction.SendEvent, {
|
|
127
|
+
name: "threads.toggle-resolved",
|
|
128
|
+
properties: {
|
|
129
|
+
threadId: thread.id,
|
|
130
|
+
spaceId
|
|
131
|
+
}
|
|
132
|
+
})
|
|
133
|
+
]
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
}),
|
|
137
|
+
(0, import_app_framework.createResolver)({
|
|
138
|
+
intent: import_chunk_AUVKOX5Q.ThreadAction.Delete,
|
|
139
|
+
resolve: ({ subject, thread }, undo) => {
|
|
140
|
+
const { state } = context.requestCapability(import_chunk_FPWNZ6TB.ThreadCapabilities.MutableState);
|
|
141
|
+
const subjectId = (0, import_echo.fullyQualifiedId)(subject);
|
|
142
|
+
const draft = state.drafts[subjectId];
|
|
143
|
+
if (draft) {
|
|
144
|
+
const index = draft.findIndex((t) => t.id === thread.id);
|
|
145
|
+
if (index !== -1) {
|
|
146
|
+
draft.splice(index, 1);
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
const space = (0, import_echo.getSpace)(thread);
|
|
151
|
+
if (!space || !subject.threads) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
if (!undo) {
|
|
155
|
+
const index = subject.threads.findIndex((t) => t?.id === thread.id);
|
|
156
|
+
const cursor = subject.threads[index]?.anchor;
|
|
157
|
+
if (index !== -1) {
|
|
158
|
+
subject.threads?.splice(index, 1);
|
|
159
|
+
}
|
|
160
|
+
space.db.remove(thread);
|
|
161
|
+
return {
|
|
162
|
+
undoable: {
|
|
163
|
+
message: [
|
|
164
|
+
"thread deleted label",
|
|
165
|
+
{
|
|
166
|
+
ns: import_chunk_F735VMTN.THREAD_PLUGIN
|
|
167
|
+
}
|
|
168
|
+
],
|
|
169
|
+
data: {
|
|
170
|
+
cursor
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
intents: [
|
|
174
|
+
(0, import_app_framework.createIntent)(import_types.ObservabilityAction.SendEvent, {
|
|
175
|
+
name: "threads.delete",
|
|
176
|
+
properties: {
|
|
177
|
+
threadId: thread.id,
|
|
178
|
+
spaceId: space.id
|
|
179
|
+
}
|
|
180
|
+
})
|
|
181
|
+
]
|
|
182
|
+
};
|
|
183
|
+
} else {
|
|
184
|
+
const savedThread = space.db.add(thread);
|
|
185
|
+
subject.threads.push(savedThread);
|
|
186
|
+
return {
|
|
187
|
+
intents: [
|
|
188
|
+
(0, import_app_framework.createIntent)(import_types.ObservabilityAction.SendEvent, {
|
|
189
|
+
name: "threads.undo-delete",
|
|
190
|
+
properties: {
|
|
191
|
+
threadId: thread.id,
|
|
192
|
+
spaceId: space.id
|
|
193
|
+
}
|
|
194
|
+
})
|
|
195
|
+
]
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}),
|
|
200
|
+
(0, import_app_framework.createResolver)({
|
|
201
|
+
intent: import_chunk_AUVKOX5Q.ThreadAction.OnMessageAdd,
|
|
202
|
+
resolve: ({ thread, subject }) => {
|
|
203
|
+
const { state } = context.requestCapability(import_chunk_FPWNZ6TB.ThreadCapabilities.MutableState);
|
|
204
|
+
const subjectId = (0, import_echo.fullyQualifiedId)(subject);
|
|
205
|
+
const space = (0, import_echo.getSpace)(subject);
|
|
206
|
+
const intents = [];
|
|
207
|
+
const analyticsProperties = {
|
|
208
|
+
threadId: thread.id,
|
|
209
|
+
spaceId: space?.id
|
|
210
|
+
};
|
|
211
|
+
if (state.drafts[subjectId]?.find((t) => t === thread)) {
|
|
212
|
+
thread.status = "active";
|
|
213
|
+
subject.threads ? subject.threads.push((0, import_echo.makeRef)(thread)) : subject.threads = [
|
|
214
|
+
(0, import_echo.makeRef)(thread)
|
|
215
|
+
];
|
|
216
|
+
state.drafts[subjectId] = state.drafts[subjectId]?.filter(({ id }) => id !== thread.id);
|
|
217
|
+
intents.push((0, import_app_framework.createIntent)(import_types.ObservabilityAction.SendEvent, {
|
|
218
|
+
name: "threads.thread-created",
|
|
219
|
+
properties: analyticsProperties
|
|
220
|
+
}));
|
|
221
|
+
}
|
|
222
|
+
intents.push((0, import_app_framework.createIntent)(import_types.ObservabilityAction.SendEvent, {
|
|
223
|
+
name: "threads.message-added",
|
|
224
|
+
properties: {
|
|
225
|
+
...analyticsProperties,
|
|
226
|
+
threadLength: thread.messages.length
|
|
227
|
+
}
|
|
228
|
+
}));
|
|
229
|
+
return {
|
|
230
|
+
intents
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
}),
|
|
234
|
+
(0, import_app_framework.createResolver)({
|
|
235
|
+
intent: import_chunk_AUVKOX5Q.ThreadAction.DeleteMessage,
|
|
236
|
+
resolve: ({ subject, thread, messageId, message, messageIndex }, undo) => {
|
|
237
|
+
const space = (0, import_echo.getSpace)(subject);
|
|
238
|
+
if (!undo) {
|
|
239
|
+
const messageIndex2 = thread.messages.findIndex(import_echo_schema.Ref.hasObjectId(messageId));
|
|
240
|
+
const message2 = thread.messages[messageIndex2]?.target;
|
|
241
|
+
if (!message2) {
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
if (messageIndex2 === 0 && thread.messages.length === 1) {
|
|
245
|
+
return {
|
|
246
|
+
intents: [
|
|
247
|
+
(0, import_app_framework.createIntent)(import_chunk_AUVKOX5Q.ThreadAction.Delete, {
|
|
248
|
+
subject,
|
|
249
|
+
thread
|
|
250
|
+
})
|
|
251
|
+
]
|
|
252
|
+
};
|
|
253
|
+
} else {
|
|
254
|
+
thread.messages.splice(messageIndex2, 1);
|
|
255
|
+
}
|
|
256
|
+
return {
|
|
257
|
+
undoable: {
|
|
258
|
+
message: [
|
|
259
|
+
"message deleted label",
|
|
260
|
+
{
|
|
261
|
+
ns: import_chunk_F735VMTN.THREAD_PLUGIN
|
|
262
|
+
}
|
|
263
|
+
],
|
|
264
|
+
data: {
|
|
265
|
+
message: message2,
|
|
266
|
+
messageIndex: messageIndex2
|
|
267
|
+
}
|
|
268
|
+
},
|
|
269
|
+
intents: [
|
|
270
|
+
(0, import_app_framework.createIntent)(import_types.ObservabilityAction.SendEvent, {
|
|
271
|
+
name: "threads.message.delete",
|
|
272
|
+
properties: {
|
|
273
|
+
threadId: thread.id,
|
|
274
|
+
spaceId: space?.id
|
|
275
|
+
}
|
|
276
|
+
})
|
|
277
|
+
]
|
|
278
|
+
};
|
|
279
|
+
} else {
|
|
280
|
+
if (!messageIndex || !message) {
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
thread.messages.splice(messageIndex, 0, (0, import_echo.makeRef)(message));
|
|
284
|
+
return {
|
|
285
|
+
intents: [
|
|
286
|
+
(0, import_app_framework.createIntent)(import_types.ObservabilityAction.SendEvent, {
|
|
287
|
+
name: "threads.message.undo-delete",
|
|
288
|
+
properties: {
|
|
289
|
+
threadId: thread.id,
|
|
290
|
+
spaceId: space?.id
|
|
291
|
+
}
|
|
292
|
+
})
|
|
293
|
+
]
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
})
|
|
298
|
+
]);
|
|
299
|
+
//# sourceMappingURL=intent-resolver-ZSOQILPJ.cjs.map
|