@copilotkit/react-textarea 0.19.0-alpha.9 → 0.19.1
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/.turbo/turbo-build.log +298 -298
- package/CHANGELOG.md +35 -0
- package/dist/chunk-2NURR2DX.mjs +47 -0
- package/dist/chunk-2NURR2DX.mjs.map +1 -0
- package/dist/chunk-3TK2VELX.mjs +202 -0
- package/dist/chunk-3TK2VELX.mjs.map +1 -0
- package/dist/chunk-47JRPWI3.mjs +257 -0
- package/dist/chunk-47JRPWI3.mjs.map +1 -0
- package/dist/chunk-4S5ZJH3I.mjs +18 -0
- package/dist/chunk-4S5ZJH3I.mjs.map +1 -0
- package/dist/chunk-5EJ5XOGP.mjs +22 -0
- package/dist/chunk-5EJ5XOGP.mjs.map +1 -0
- package/dist/chunk-5FO6ISW4.mjs +3 -0
- package/dist/chunk-5FO6ISW4.mjs.map +1 -0
- package/dist/chunk-66BDXIX4.mjs +76 -0
- package/dist/chunk-66BDXIX4.mjs.map +1 -0
- package/dist/chunk-7QWJ3OV7.mjs +108 -0
- package/dist/chunk-7QWJ3OV7.mjs.map +1 -0
- package/dist/chunk-BBKDE7YT.mjs +19 -0
- package/dist/chunk-BBKDE7YT.mjs.map +1 -0
- package/dist/chunk-CSGFJU3L.mjs +65 -0
- package/dist/chunk-CSGFJU3L.mjs.map +1 -0
- package/dist/chunk-DE5K76I2.mjs +3 -0
- package/dist/chunk-DE5K76I2.mjs.map +1 -0
- package/dist/chunk-F3MHL6ZY.mjs +25 -0
- package/dist/chunk-F3MHL6ZY.mjs.map +1 -0
- package/dist/chunk-FN7GDKKG.mjs +29 -0
- package/dist/chunk-FN7GDKKG.mjs.map +1 -0
- package/dist/chunk-H4VKQGVU.mjs +3 -0
- package/dist/chunk-H4VKQGVU.mjs.map +1 -0
- package/dist/chunk-HRTFMM7P.mjs +82 -0
- package/dist/chunk-HRTFMM7P.mjs.map +1 -0
- package/dist/chunk-IU3WTXLQ.mjs +3 -0
- package/dist/chunk-IU3WTXLQ.mjs.map +1 -0
- package/dist/chunk-IXJ2HCOA.mjs +101 -0
- package/dist/chunk-IXJ2HCOA.mjs.map +1 -0
- package/dist/chunk-JAFCXEPU.mjs +10 -0
- package/dist/chunk-JAFCXEPU.mjs.map +1 -0
- package/dist/chunk-JHTAOLEW.mjs +63 -0
- package/dist/chunk-JHTAOLEW.mjs.map +1 -0
- package/dist/chunk-K2AVA67P.mjs +57 -0
- package/dist/chunk-K2AVA67P.mjs.map +1 -0
- package/dist/chunk-KCHYD3EB.mjs +107 -0
- package/dist/chunk-KCHYD3EB.mjs.map +1 -0
- package/dist/chunk-KGKLUWKW.mjs +47 -0
- package/dist/chunk-KGKLUWKW.mjs.map +1 -0
- package/dist/chunk-KIRROE2K.mjs +37 -0
- package/dist/chunk-KIRROE2K.mjs.map +1 -0
- package/dist/chunk-L6DZHWEL.mjs +76 -0
- package/dist/chunk-L6DZHWEL.mjs.map +1 -0
- package/dist/chunk-L7VVZH4Q.mjs +3 -0
- package/dist/chunk-L7VVZH4Q.mjs.map +1 -0
- package/dist/chunk-LNAIMEB2.mjs +34 -0
- package/dist/chunk-LNAIMEB2.mjs.map +1 -0
- package/dist/chunk-MMVDU6DF.mjs +3 -0
- package/dist/chunk-MMVDU6DF.mjs.map +1 -0
- package/dist/chunk-MPME5BW2.mjs +59 -0
- package/dist/chunk-MPME5BW2.mjs.map +1 -0
- package/dist/chunk-MRXNTQOX.mjs +55 -0
- package/dist/chunk-MRXNTQOX.mjs.map +1 -0
- package/dist/chunk-ND5PXTAW.mjs +17 -0
- package/dist/chunk-ND5PXTAW.mjs.map +1 -0
- package/dist/chunk-NKW5OU2S.mjs +33 -0
- package/dist/chunk-NKW5OU2S.mjs.map +1 -0
- package/dist/chunk-O5OWT5GE.mjs +114 -0
- package/dist/chunk-O5OWT5GE.mjs.map +1 -0
- package/dist/chunk-OD7ZMOVE.mjs +45 -0
- package/dist/chunk-OD7ZMOVE.mjs.map +1 -0
- package/dist/chunk-OELUUJZY.mjs +16 -0
- package/dist/chunk-OELUUJZY.mjs.map +1 -0
- package/dist/chunk-OXPXFYUG.mjs +111 -0
- package/dist/chunk-OXPXFYUG.mjs.map +1 -0
- package/dist/chunk-QNJ6MXJ2.mjs +21 -0
- package/dist/chunk-QNJ6MXJ2.mjs.map +1 -0
- package/dist/chunk-RDHPSSHJ.mjs +44 -0
- package/dist/chunk-RDHPSSHJ.mjs.map +1 -0
- package/dist/chunk-RQHOUUXQ.mjs +29 -0
- package/dist/chunk-RQHOUUXQ.mjs.map +1 -0
- package/dist/chunk-S6JUGJK2.mjs +13 -0
- package/dist/chunk-S6JUGJK2.mjs.map +1 -0
- package/dist/chunk-UHD44NC5.mjs +101 -0
- package/dist/chunk-UHD44NC5.mjs.map +1 -0
- package/dist/chunk-WADHCMPK.mjs +3 -0
- package/dist/chunk-WADHCMPK.mjs.map +1 -0
- package/dist/chunk-WJHSY5T6.mjs +3 -0
- package/dist/chunk-WJHSY5T6.mjs.map +1 -0
- package/dist/chunk-WJYQWL4I.mjs +27 -0
- package/dist/chunk-WJYQWL4I.mjs.map +1 -0
- package/dist/chunk-XA7M72ZO.mjs +106 -0
- package/dist/chunk-XA7M72ZO.mjs.map +1 -0
- package/dist/chunk-XHUMROEY.mjs +91 -0
- package/dist/chunk-XHUMROEY.mjs.map +1 -0
- package/dist/chunk-YQU7WG7T.mjs +83 -0
- package/dist/chunk-YQU7WG7T.mjs.map +1 -0
- package/dist/chunk-YTOPHPSG.mjs +45 -0
- package/dist/chunk-YTOPHPSG.mjs.map +1 -0
- package/dist/chunk-YW3REYX6.mjs +23 -0
- package/dist/chunk-YW3REYX6.mjs.map +1 -0
- package/dist/components/base-copilot-textarea/base-copilot-textarea.mjs +34 -1734
- package/dist/components/base-copilot-textarea/base-copilot-textarea.mjs.map +1 -1
- package/dist/components/base-copilot-textarea/render-element.mjs +3 -52
- package/dist/components/base-copilot-textarea/render-element.mjs.map +1 -1
- package/dist/components/base-copilot-textarea/render-placeholder.mjs +3 -46
- package/dist/components/base-copilot-textarea/render-placeholder.mjs.map +1 -1
- package/dist/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.mjs +4 -86
- package/dist/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.mjs.map +1 -1
- package/dist/components/base-copilot-textarea/use-add-branding-css.mjs +3 -57
- package/dist/components/base-copilot-textarea/use-add-branding-css.mjs.map +1 -1
- package/dist/components/copilot-textarea/copilot-textarea.mjs +46 -2202
- package/dist/components/copilot-textarea/copilot-textarea.mjs.map +1 -1
- package/dist/components/hovering-toolbar/hovering-editor-provider.mjs +3 -22
- package/dist/components/hovering-toolbar/hovering-editor-provider.mjs.map +1 -1
- package/dist/components/hovering-toolbar/hovering-toolbar-components.mjs +3 -125
- package/dist/components/hovering-toolbar/hovering-toolbar-components.mjs.map +1 -1
- package/dist/components/hovering-toolbar/hovering-toolbar.mjs +17 -877
- package/dist/components/hovering-toolbar/hovering-toolbar.mjs.map +1 -1
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.mjs +11 -577
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.mjs.map +1 -1
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.mjs +12 -592
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.mjs.map +1 -1
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.mjs +13 -592
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.mjs.map +1 -1
- package/dist/components/index.mjs +47 -2203
- package/dist/components/index.mjs.map +1 -1
- package/dist/components/manual-ui/chip-with-icon.mjs +6 -5
- package/dist/components/manual-ui/chip-with-icon.mjs.map +1 -1
- package/dist/components/source-search-box/source-search-box.mjs +6 -209
- package/dist/components/source-search-box/source-search-box.mjs.map +1 -1
- package/dist/components/ui/button.mjs +4 -88
- package/dist/components/ui/button.mjs.map +1 -1
- package/dist/components/ui/card.mjs +7 -53
- package/dist/components/ui/card.mjs.map +1 -1
- package/dist/components/ui/command.mjs +5 -266
- package/dist/components/ui/command.mjs.map +1 -1
- package/dist/components/ui/dialog.mjs +4 -164
- package/dist/components/ui/dialog.mjs.map +1 -1
- package/dist/components/ui/label.mjs +4 -63
- package/dist/components/ui/label.mjs.map +1 -1
- package/dist/components/ui/separator.mjs +8 -50
- package/dist/components/ui/separator.mjs.map +1 -1
- package/dist/components/ui/textarea.mjs +7 -48
- package/dist/components/ui/textarea.mjs.map +1 -1
- package/dist/context/index.mjs +2 -0
- package/dist/context/index.mjs.map +1 -1
- package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.mjs +6 -168
- package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.mjs.map +1 -1
- package/dist/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.mjs +4 -168
- package/dist/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.mjs.map +1 -1
- package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.mjs +5 -155
- package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.mjs.map +1 -1
- package/dist/hooks/index.mjs +2 -0
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.mjs +14 -145
- package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.mjs.map +1 -1
- package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.mjs +14 -199
- package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.mjs.map +1 -1
- package/dist/hooks/misc/use-autosize-textarea.mjs +3 -15
- package/dist/hooks/misc/use-autosize-textarea.mjs.map +1 -1
- package/dist/index.mjs +49 -2206
- package/dist/index.mjs.map +1 -1
- package/dist/lib/debouncer.mjs +3 -51
- package/dist/lib/debouncer.mjs.map +1 -1
- package/dist/lib/editor-to-text.mjs +3 -43
- package/dist/lib/editor-to-text.mjs.map +1 -1
- package/dist/lib/get-text-around-cursor.mjs +3 -109
- package/dist/lib/get-text-around-cursor.mjs.map +1 -1
- package/dist/lib/retry.mjs +3 -17
- package/dist/lib/retry.mjs.map +1 -1
- package/dist/lib/slatejs-edits/add-autocompletions.mjs +3 -25
- package/dist/lib/slatejs-edits/add-autocompletions.mjs.map +1 -1
- package/dist/lib/slatejs-edits/clear-autocompletions.mjs +3 -23
- package/dist/lib/slatejs-edits/clear-autocompletions.mjs.map +1 -1
- package/dist/lib/slatejs-edits/replace-text.mjs +3 -27
- package/dist/lib/slatejs-edits/replace-text.mjs.map +1 -1
- package/dist/lib/slatejs-edits/with-partial-history.mjs +3 -106
- package/dist/lib/slatejs-edits/with-partial-history.mjs.map +1 -1
- package/dist/lib/stream-promise-flatten.mjs +3 -47
- package/dist/lib/stream-promise-flatten.mjs.map +1 -1
- package/dist/lib/utils.mjs +3 -71
- package/dist/lib/utils.mjs.map +1 -1
- package/dist/lib/utils.test.mjs +1 -0
- package/dist/lib/utils.test.mjs.map +1 -1
- package/dist/types/autosuggestions-config/autosuggestions-config-user-specified.mjs +2 -0
- package/dist/types/autosuggestions-config/autosuggestions-config-user-specified.mjs.map +1 -1
- package/dist/types/autosuggestions-config/autosuggestions-config.mjs +8 -254
- package/dist/types/autosuggestions-config/autosuggestions-config.mjs.map +1 -1
- package/dist/types/autosuggestions-config/editing-api-config.mjs +3 -83
- package/dist/types/autosuggestions-config/editing-api-config.mjs.map +1 -1
- package/dist/types/autosuggestions-config/index.mjs +10 -310
- package/dist/types/autosuggestions-config/index.mjs.map +1 -1
- package/dist/types/autosuggestions-config/insertions-api-config.mjs +3 -77
- package/dist/types/autosuggestions-config/insertions-api-config.mjs.map +1 -1
- package/dist/types/autosuggestions-config/subtypes/chatlike-api-endpoint.mjs +3 -77
- package/dist/types/autosuggestions-config/subtypes/chatlike-api-endpoint.mjs.map +1 -1
- package/dist/types/autosuggestions-config/subtypes/make-system-prompt.mjs +2 -0
- package/dist/types/autosuggestions-config/subtypes/make-system-prompt.mjs.map +1 -1
- package/dist/types/autosuggestions-config/subtypes/minimal-chat-gpt-message.mjs +2 -0
- package/dist/types/autosuggestions-config/subtypes/minimal-chat-gpt-message.mjs.map +1 -1
- package/dist/types/autosuggestions-config/suggestions-api-config.mjs +3 -64
- package/dist/types/autosuggestions-config/suggestions-api-config.mjs.map +1 -1
- package/dist/types/base/autosuggestion-state.mjs +2 -0
- package/dist/types/base/autosuggestion-state.mjs.map +1 -1
- package/dist/types/base/autosuggestions-bare-function.mjs +2 -0
- package/dist/types/base/autosuggestions-bare-function.mjs.map +1 -1
- package/dist/types/base/base-autosuggestions-config.mjs +3 -12
- package/dist/types/base/base-autosuggestions-config.mjs.map +1 -1
- package/dist/types/base/base-copilot-textarea-props.mjs +2 -0
- package/dist/types/base/base-copilot-textarea-props.mjs.map +1 -1
- package/dist/types/base/custom-editor.mjs +2 -0
- package/dist/types/base/custom-editor.mjs.map +1 -1
- package/dist/types/base/editor-autocomplete-state.mjs +4 -17
- package/dist/types/base/editor-autocomplete-state.mjs.map +1 -1
- package/dist/types/base/index.mjs +4 -12
- package/dist/types/base/index.mjs.map +1 -1
- package/dist/types/html-copilot-textarea-element.mjs +2 -0
- package/dist/types/html-copilot-textarea-element.mjs.map +1 -1
- package/dist/types/index.mjs +12 -311
- package/dist/types/index.mjs.map +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/get-text-around-cursor.ts"],"names":[],"mappings":"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","sourcesContent":["import {\n Editor,\n Node,\n Path,\n Range,\n Text,\n Element,\n BasePoint,\n BaseRange,\n Point,\n} from \"slate\";\nimport { EditorAutocompleteState } from \"../types/base/editor-autocomplete-state\";\n\nexport interface EditorTextState {\n selection: BaseRange;\n\n textBeforeCursor: string;\n selectedText: string;\n textAfterCursor: string;\n}\n\nexport function getTextAroundCollapsedCursor(\n editor: Editor\n): EditorAutocompleteState | null {\n const { selection } = editor;\n if (!selection || !Range.isCollapsed(selection)) {\n return null;\n }\n\n const cursorPoint = selection.anchor;\n\n // Create two ranges: one before the anchor and one after\n const beforeRange: Range = {\n anchor: Editor.start(editor, []),\n focus: cursorPoint,\n };\n const afterRange: Range = {\n anchor: cursorPoint,\n focus: Editor.end(editor, []),\n };\n\n // Extract text for these ranges\n const before = extractTextWithNewlines(editor, beforeRange);\n const after = extractTextWithNewlines(editor, afterRange);\n\n return {\n cursorPoint: cursorPoint,\n textBeforeCursor: before,\n textAfterCursor: after,\n };\n}\n\nexport function getTextAroundSelection(editor: Editor): EditorTextState | null {\n const { selection } = editor;\n if (!selection) {\n return null;\n }\n\n const wellOrderedSelection = wellOrderedRange(selection);\n\n // Create two ranges: one before the anchor and one after\n const beforeRange: Range = {\n anchor: Editor.start(editor, []),\n focus: wellOrderedSelection.anchor,\n };\n const afterRange: Range = {\n anchor: wellOrderedSelection.focus,\n focus: Editor.end(editor, []),\n };\n\n // Extract text for these ranges\n const before = extractTextWithNewlines(editor, beforeRange);\n const after = extractTextWithNewlines(editor, afterRange);\n const selectedText = extractTextWithNewlines(editor, wellOrderedSelection);\n\n return {\n selection: wellOrderedSelection,\n textBeforeCursor: before,\n selectedText,\n textAfterCursor: after,\n };\n}\n\nexport function getFullEditorTextWithNewlines(editor: Editor): string {\n const fullDocumentRange: Range = {\n anchor: Editor.start(editor, []),\n focus: Editor.end(editor, []),\n };\n return extractTextWithNewlines(editor, fullDocumentRange);\n}\n\n// Helper function to extract text with newlines\nexport function extractTextWithNewlines(editor: Editor, range: Range): string {\n const voids = false;\n const [start, end] = Range.edges(range);\n let text = \"\";\n let lastBlock: Node | null = null;\n\n for (const [node, path] of Editor.nodes(editor, {\n at: range,\n match: Text.isText,\n voids,\n })) {\n let t = node.text;\n\n // Determine the parent block of the current text node\n const [block] = Editor.above(editor, {\n at: path,\n match: (n) => Element.isElement(n) && n.type === \"paragraph\",\n }) || [null];\n\n // If we encounter a new block, prepend a newline\n if (lastBlock !== block && block) {\n // check that lastBlock is not null to avoid adding a newline at the beginning\n if (lastBlock) {\n text += \"\\n\";\n }\n lastBlock = block;\n }\n\n if (Path.equals(path, end.path)) {\n t = t.slice(0, end.offset);\n }\n\n if (Path.equals(path, start.path)) {\n t = t.slice(start.offset);\n }\n\n text += t;\n }\n\n return text;\n}\n\nfunction wellOrderedRange(range: BaseRange): BaseRange {\n const { anchor, focus } = range;\n // if anchor is before focus, return range as is\n if (Point.isBefore(anchor, focus)) {\n return range;\n }\n\n // if focus is before anchor, return range with anchor and focus swapped\n return {\n anchor: focus,\n focus: anchor,\n };\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { arraysAreEqual } from './chunk-KGKLUWKW.mjs';
|
|
2
|
+
|
|
3
|
+
// src/types/base/editor-autocomplete-state.ts
|
|
4
|
+
function areEqual_autocompleteState(prev, next) {
|
|
5
|
+
return prev.cursorPoint.offset === next.cursorPoint.offset && arraysAreEqual(prev.cursorPoint.path, next.cursorPoint.path) && prev.textBeforeCursor === next.textBeforeCursor && prev.textAfterCursor === next.textAfterCursor;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export { areEqual_autocompleteState };
|
|
9
|
+
//# sourceMappingURL=out.js.map
|
|
10
|
+
//# sourceMappingURL=chunk-JAFCXEPU.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/types/base/editor-autocomplete-state.ts"],"names":[],"mappings":";;;;;AASO,SAAS,2BACd,MACA,MACA;AACA,SACE,KAAK,YAAY,WAAW,KAAK,YAAY,UAC7C,eAAe,KAAK,YAAY,MAAM,KAAK,YAAY,IAAI,KAC3D,KAAK,qBAAqB,KAAK,oBAC/B,KAAK,oBAAoB,KAAK;AAElC","sourcesContent":["import { BasePoint } from \"slate\";\nimport { arraysAreEqual } from \"../../lib/utils\";\n\nexport interface EditorAutocompleteState {\n cursorPoint: BasePoint;\n textBeforeCursor: string;\n textAfterCursor: string;\n}\n\nexport function areEqual_autocompleteState(\n prev: EditorAutocompleteState,\n next: EditorAutocompleteState\n) {\n return (\n prev.cursorPoint.offset === next.cursorPoint.offset &&\n arraysAreEqual(prev.cursorPoint.path, next.cursorPoint.path) &&\n prev.textBeforeCursor === next.textBeforeCursor &&\n prev.textAfterCursor === next.textAfterCursor\n );\n}\n"]}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// src/types/autosuggestions-config/suggestions-api-config.tsx
|
|
2
|
+
var defaultSuggestionsMakeSystemPrompt = (textareaPurpose, contextString) => {
|
|
3
|
+
return `You are a versatile writing assistant.
|
|
4
|
+
|
|
5
|
+
The user is writing some text.
|
|
6
|
+
The purpose is: "${textareaPurpose}"
|
|
7
|
+
|
|
8
|
+
Your job is to guess what the user will write next AS BEST YOU CAN.
|
|
9
|
+
Only guess a SHORT distance ahead. Usually 1 sentence, or at most 1 paragraph.
|
|
10
|
+
|
|
11
|
+
Adjust yourself to the user's style and implied intent.
|
|
12
|
+
|
|
13
|
+
The user will provide both the text before and after the cursor. You should use this to infer what the user is likely to write next.
|
|
14
|
+
<TextAfterCursor>
|
|
15
|
+
<TextBeforeCursor>
|
|
16
|
+
<YourSuggestion>
|
|
17
|
+
|
|
18
|
+
If we need to add a whitespace character to the suggested text, make sure to explicitly add it in.
|
|
19
|
+
|
|
20
|
+
The following external context is also provided. Use it to help you make better suggestions!!!
|
|
21
|
+
\`\`\`
|
|
22
|
+
${contextString}
|
|
23
|
+
\`\`\`
|
|
24
|
+
`;
|
|
25
|
+
};
|
|
26
|
+
var defaultSuggestionsFewShotMessages = [
|
|
27
|
+
{
|
|
28
|
+
role: "user",
|
|
29
|
+
name: "TextAfterCursor",
|
|
30
|
+
content: "While I was there I also picked up some apples, oranges, and bananas."
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
role: "user",
|
|
34
|
+
content: "This morning I woke up and went straight to the grocery store."
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
role: "assistant",
|
|
38
|
+
content: " When I arrived I went straight to the produce section and picked out a big watermelon. "
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
role: "user",
|
|
42
|
+
name: "TextAfterCursor",
|
|
43
|
+
content: "and (iii) to the appointment of the Equityholders' Representative pursuant to Section 10.7 of the Merger Agreement and to the provisions thereof."
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
role: "user",
|
|
47
|
+
name: "TextBeforeCursor",
|
|
48
|
+
content: `The Optionholder, in the Optionholder's capacity as a holder of vested Options, hereby irrevocably and unconditionally agrees: (i) that the Optionholder shall be deemed an "Equityholder" under the Merger Agreement and shall be entitled to the rights and benefits, and subject to the obligations, of an "Equityholder" thereunder;`
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
role: "assistant",
|
|
52
|
+
content: ` (ii) that, for purposes of this Agreement and the Merger Agreement, the applicable percentage set forth opposite the name of the Optionholder in the Distribution Waterfall shall be such the Optionholder's "Pro Rata Share"; `
|
|
53
|
+
}
|
|
54
|
+
];
|
|
55
|
+
var defaultSuggestionsApiConfig = {
|
|
56
|
+
makeSystemPrompt: defaultSuggestionsMakeSystemPrompt,
|
|
57
|
+
fewShotMessages: defaultSuggestionsFewShotMessages,
|
|
58
|
+
forwardedParams: void 0
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export { defaultSuggestionsApiConfig, defaultSuggestionsFewShotMessages, defaultSuggestionsMakeSystemPrompt };
|
|
62
|
+
//# sourceMappingURL=out.js.map
|
|
63
|
+
//# sourceMappingURL=chunk-JHTAOLEW.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/types/autosuggestions-config/suggestions-api-config.tsx"],"names":[],"mappings":";AASO,IAAM,qCAAuD,CAClE,iBACA,kBACG;AACH,SAAO;AAAA;AAAA;AAAA,mBAGW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAgBlB;AAAA;AAAA;AAGF;AAEO,IAAM,oCAA6D;AAAA,EACxE;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SACE;AAAA,EACJ;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,SAAS;AAAA,EACX;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,SACE;AAAA,EACJ;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SACE;AAAA,EACJ;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SACE;AAAA,EACJ;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,SACE;AAAA,EACJ;AACF;AAEO,IAAM,8BAAoD;AAAA,EAC/D,kBAAkB;AAAA,EAClB,iBAAiB;AAAA,EACjB,iBAAiB;AACnB","sourcesContent":["import { MinimalChatGPTMessage } from \"./subtypes/minimal-chat-gpt-message\";\nimport { MakeSystemPrompt } from \"./subtypes/make-system-prompt\";\n\nexport interface SuggestionsApiConfig {\n makeSystemPrompt: MakeSystemPrompt;\n fewShotMessages: MinimalChatGPTMessage[];\n forwardedParams: { [key: string]: any } | undefined;\n}\n\nexport const defaultSuggestionsMakeSystemPrompt: MakeSystemPrompt = (\n textareaPurpose,\n contextString\n) => {\n return `You are a versatile writing assistant.\n \nThe user is writing some text.\nThe purpose is: \\\"${textareaPurpose}\\\"\n\nYour job is to guess what the user will write next AS BEST YOU CAN.\nOnly guess a SHORT distance ahead. Usually 1 sentence, or at most 1 paragraph.\n\nAdjust yourself to the user's style and implied intent.\n\nThe user will provide both the text before and after the cursor. You should use this to infer what the user is likely to write next.\n<TextAfterCursor>\n<TextBeforeCursor>\n<YourSuggestion>\n\nIf we need to add a whitespace character to the suggested text, make sure to explicitly add it in.\n\nThe following external context is also provided. Use it to help you make better suggestions!!!\n\\`\\`\\`\n${contextString}\n\\`\\`\\`\n`;\n};\n\nexport const defaultSuggestionsFewShotMessages: MinimalChatGPTMessage[] = [\n {\n role: \"user\",\n name: \"TextAfterCursor\",\n content:\n \"While I was there I also picked up some apples, oranges, and bananas.\",\n },\n {\n role: \"user\",\n content: \"This morning I woke up and went straight to the grocery store.\",\n },\n {\n role: \"assistant\",\n content:\n \" When I arrived I went straight to the produce section and picked out a big watermelon. \",\n },\n {\n role: \"user\",\n name: \"TextAfterCursor\",\n content:\n \"and (iii) to the appointment of the Equityholders' Representative pursuant to Section 10.7 of the Merger Agreement and to the provisions thereof.\",\n },\n {\n role: \"user\",\n name: \"TextBeforeCursor\",\n content:\n 'The Optionholder, in the Optionholder\\'s capacity as a holder of vested Options, hereby irrevocably and unconditionally agrees: (i) that the Optionholder shall be deemed an \"Equityholder\" under the Merger Agreement and shall be entitled to the rights and benefits, and subject to the obligations, of an \"Equityholder\" thereunder;',\n },\n {\n role: \"assistant\",\n content:\n ' (ii) that, for purposes of this Agreement and the Merger Agreement, the applicable percentage set forth opposite the name of the Optionholder in the Distribution Waterfall shall be such the Optionholder\\'s \"Pro Rata Share\"; ',\n },\n];\n\nexport const defaultSuggestionsApiConfig: SuggestionsApiConfig = {\n makeSystemPrompt: defaultSuggestionsMakeSystemPrompt,\n fewShotMessages: defaultSuggestionsFewShotMessages,\n forwardedParams: undefined,\n};\n"]}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { ChatlikeApiEndpoint } from './chunk-KIRROE2K.mjs';
|
|
2
|
+
import { retry } from './chunk-4S5ZJH3I.mjs';
|
|
3
|
+
import { __async } from './chunk-MRXNTQOX.mjs';
|
|
4
|
+
import { CopilotContext } from '@copilotkit/react-core';
|
|
5
|
+
import { useContext, useCallback } from 'react';
|
|
6
|
+
|
|
7
|
+
function useMakeStandardAutosuggestionFunction(textareaPurpose, contextCategories, apiConfig) {
|
|
8
|
+
const { getContextString, copilotApiConfig } = useContext(CopilotContext);
|
|
9
|
+
return useCallback(
|
|
10
|
+
(editorState, abortSignal) => __async(this, null, function* () {
|
|
11
|
+
const res = yield retry(() => __async(this, null, function* () {
|
|
12
|
+
const messages = [
|
|
13
|
+
{
|
|
14
|
+
role: "system",
|
|
15
|
+
content: apiConfig.makeSystemPrompt(
|
|
16
|
+
textareaPurpose,
|
|
17
|
+
getContextString(contextCategories)
|
|
18
|
+
)
|
|
19
|
+
},
|
|
20
|
+
...apiConfig.fewShotMessages,
|
|
21
|
+
{
|
|
22
|
+
role: "user",
|
|
23
|
+
name: "TextAfterCursor",
|
|
24
|
+
content: editorState.textAfterCursor
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
role: "user",
|
|
28
|
+
name: "TextBeforeCursor",
|
|
29
|
+
content: editorState.textBeforeCursor
|
|
30
|
+
}
|
|
31
|
+
];
|
|
32
|
+
const apiEndpoint = ChatlikeApiEndpoint.fromCopilotApiConfig(copilotApiConfig);
|
|
33
|
+
const stream = yield apiEndpoint.run(
|
|
34
|
+
abortSignal,
|
|
35
|
+
messages,
|
|
36
|
+
apiConfig.forwardedParams
|
|
37
|
+
);
|
|
38
|
+
const reader = stream.getReader();
|
|
39
|
+
let result = "";
|
|
40
|
+
while (true) {
|
|
41
|
+
const { done, value } = yield reader.read();
|
|
42
|
+
if (done) {
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
result += value;
|
|
46
|
+
}
|
|
47
|
+
return result;
|
|
48
|
+
}));
|
|
49
|
+
return res;
|
|
50
|
+
}),
|
|
51
|
+
[apiConfig, getContextString, contextCategories, textareaPurpose]
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export { useMakeStandardAutosuggestionFunction };
|
|
56
|
+
//# sourceMappingURL=out.js.map
|
|
57
|
+
//# sourceMappingURL=chunk-K2AVA67P.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,SAAS,sBAAsB;AAC/B,SAAS,aAAa,kBAAkB;AAsBjC,SAAS,sCACd,iBACA,mBACA,WAC6B;AAC7B,QAAM,EAAE,kBAAkB,iBAAiB,IAAI,WAAW,cAAc;AAExE,SAAO;AAAA,IACL,CAAO,aAAmC,gBAA6B;AACrE,YAAM,MAAM,MAAM,MAAM,MAAY;AAClC,cAAM,WAAoC;AAAA,UACxC;AAAA,YACE,MAAM;AAAA,YACN,SAAS,UAAU;AAAA,cACjB;AAAA,cACA,iBAAiB,iBAAiB;AAAA,YACpC;AAAA,UACF;AAAA,UACA,GAAG,UAAU;AAAA,UACb;AAAA,YACE,MAAM;AAAA,YACN,MAAM;AAAA,YACN,SAAS,YAAY;AAAA,UACvB;AAAA,UACA;AAAA,YACE,MAAM;AAAA,YACN,MAAM;AAAA,YACN,SAAS,YAAY;AAAA,UACvB;AAAA,QACF;AAEA,cAAM,cACJ,oBAAoB,qBAAqB,gBAAgB;AAC3D,cAAM,SAAS,MAAM,YAAY;AAAA,UAC/B;AAAA,UACA;AAAA,UACA,UAAU;AAAA,QACZ;AAGA,cAAM,SAAS,OAAO,UAAU;AAChC,YAAI,SAAS;AAEb,eAAO,MAAM;AACX,gBAAM,EAAE,MAAM,MAAM,IAAI,MAAM,OAAO,KAAK;AAC1C,cAAI,MAAM;AACR;AAAA,UACF;AACA,oBAAU;AAAA,QACZ;AAEA,eAAO;AAAA,MACT,EAAC;AAED,aAAO;AAAA,IACT;AAAA,IACA,CAAC,WAAW,kBAAkB,mBAAmB,eAAe;AAAA,EAClE;AACF","sourcesContent":["import { CopilotContext } from \"@copilotkit/react-core\";\nimport { useCallback, useContext } from \"react\";\nimport {\n AutosuggestionsBareFunction,\n ChatlikeApiEndpoint,\n MinimalChatGPTMessage,\n} from \"../../types\";\nimport { retry } from \"../../lib/retry\";\nimport { InsertionEditorState } from \"../../types/base/autosuggestions-bare-function\";\nimport { SuggestionsApiConfig } from \"../../types/autosuggestions-config/suggestions-api-config\";\n/**\n * Returns a memoized function that sends a request to the specified API endpoint to get an autosuggestion for the user's input.\n * The function takes in the text before and after the cursor, and an abort signal.\n * It sends a POST request to the API endpoint with the messages array containing the system message, few shot messages, and user messages.\n * The function returns the suggestion from the API response.\n *\n * @param textareaPurpose - The purpose of the textarea. This is included in the system message.\n * @param apiEndpoint - The API endpoint to send the autosuggestion request to.\n * @param makeSystemMessage - A function that takes in a context string and returns a system message to include in the autosuggestion request.\n * @param fewShotMessages - An array of few shot messages to include in the autosuggestion request.\n * @param contextCategories - The categories of context strings we want to include. By default, we include the (default) \"global\" context category.\n * @returns A memoized function that sends a request to the specified API endpoint to get an autosuggestion for the user's input.\n */\nexport function useMakeStandardAutosuggestionFunction(\n textareaPurpose: string,\n contextCategories: string[] | undefined,\n apiConfig: SuggestionsApiConfig\n): AutosuggestionsBareFunction {\n const { getContextString, copilotApiConfig } = useContext(CopilotContext);\n\n return useCallback(\n async (editorState: InsertionEditorState, abortSignal: AbortSignal) => {\n const res = await retry(async () => {\n const messages: MinimalChatGPTMessage[] = [\n {\n role: \"system\",\n content: apiConfig.makeSystemPrompt(\n textareaPurpose,\n getContextString(contextCategories)\n ),\n },\n ...apiConfig.fewShotMessages,\n {\n role: \"user\",\n name: \"TextAfterCursor\",\n content: editorState.textAfterCursor,\n },\n {\n role: \"user\",\n name: \"TextBeforeCursor\",\n content: editorState.textBeforeCursor,\n },\n ];\n\n const apiEndpoint =\n ChatlikeApiEndpoint.fromCopilotApiConfig(copilotApiConfig);\n const stream = await apiEndpoint.run(\n abortSignal,\n messages,\n apiConfig.forwardedParams\n );\n\n // read the stream:\n const reader = stream.getReader();\n let result = \"\";\n\n while (true) {\n const { done, value } = await reader.read();\n if (done) {\n break;\n }\n result += value;\n }\n\n return result;\n });\n\n return res;\n },\n [apiConfig, getContextString, contextCategories, textareaPurpose]\n );\n}\n"]}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { Transforms, Editor, Operation, Path } from 'slate';
|
|
2
|
+
import { HistoryEditor } from 'slate-history';
|
|
3
|
+
|
|
4
|
+
// src/lib/slatejs-edits/with-partial-history.ts
|
|
5
|
+
var withPartialHistory = (editor, shouldSave) => {
|
|
6
|
+
const e = editor;
|
|
7
|
+
const { apply } = e;
|
|
8
|
+
e.history = { undos: [], redos: [] };
|
|
9
|
+
e.redo = () => {
|
|
10
|
+
const { history } = e;
|
|
11
|
+
const { redos } = history;
|
|
12
|
+
if (redos.length > 0) {
|
|
13
|
+
const batch = redos[redos.length - 1];
|
|
14
|
+
if (batch.selectionBefore) {
|
|
15
|
+
Transforms.setSelection(e, batch.selectionBefore);
|
|
16
|
+
}
|
|
17
|
+
HistoryEditor.withoutSaving(e, () => {
|
|
18
|
+
Editor.withoutNormalizing(e, () => {
|
|
19
|
+
for (const op of batch.operations) {
|
|
20
|
+
e.apply(op);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
history.redos.pop();
|
|
25
|
+
e.writeHistory("undos", batch);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
e.undo = () => {
|
|
29
|
+
const { history } = e;
|
|
30
|
+
const { undos } = history;
|
|
31
|
+
if (undos.length > 0) {
|
|
32
|
+
const batch = undos[undos.length - 1];
|
|
33
|
+
HistoryEditor.withoutSaving(e, () => {
|
|
34
|
+
Editor.withoutNormalizing(e, () => {
|
|
35
|
+
const inverseOps = batch.operations.map(Operation.inverse).reverse();
|
|
36
|
+
for (const op of inverseOps) {
|
|
37
|
+
e.apply(op);
|
|
38
|
+
}
|
|
39
|
+
if (batch.selectionBefore) {
|
|
40
|
+
Transforms.setSelection(e, batch.selectionBefore);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
e.writeHistory("redos", batch);
|
|
45
|
+
history.undos.pop();
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
e.apply = (op) => {
|
|
49
|
+
const { operations, history } = e;
|
|
50
|
+
const { undos } = history;
|
|
51
|
+
const lastBatch = undos[undos.length - 1];
|
|
52
|
+
const lastOp = lastBatch && lastBatch.operations[lastBatch.operations.length - 1];
|
|
53
|
+
let save = HistoryEditor.isSaving(e);
|
|
54
|
+
let merge = HistoryEditor.isMerging(e);
|
|
55
|
+
if (save == null) {
|
|
56
|
+
save = shouldSave(op, lastOp);
|
|
57
|
+
}
|
|
58
|
+
if (save) {
|
|
59
|
+
if (merge == null) {
|
|
60
|
+
if (lastBatch == null) {
|
|
61
|
+
merge = false;
|
|
62
|
+
} else if (operations.length !== 0) {
|
|
63
|
+
merge = true;
|
|
64
|
+
} else {
|
|
65
|
+
merge = shouldMerge(op, lastOp);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (lastBatch && merge) {
|
|
69
|
+
lastBatch.operations.push(op);
|
|
70
|
+
} else {
|
|
71
|
+
const batch = {
|
|
72
|
+
operations: [op],
|
|
73
|
+
selectionBefore: e.selection
|
|
74
|
+
};
|
|
75
|
+
e.writeHistory("undos", batch);
|
|
76
|
+
}
|
|
77
|
+
while (undos.length > 100) {
|
|
78
|
+
undos.shift();
|
|
79
|
+
}
|
|
80
|
+
history.redos = [];
|
|
81
|
+
}
|
|
82
|
+
apply(op);
|
|
83
|
+
};
|
|
84
|
+
e.writeHistory = (stack, batch) => {
|
|
85
|
+
e.history[stack].push(batch);
|
|
86
|
+
};
|
|
87
|
+
return e;
|
|
88
|
+
};
|
|
89
|
+
var shouldMerge = (op, prev) => {
|
|
90
|
+
if (prev && op.type === "insert_text" && prev.type === "insert_text" && op.offset === prev.offset + prev.text.length && Path.equals(op.path, prev.path)) {
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
if (prev && op.type === "remove_text" && prev.type === "remove_text" && op.offset + op.text.length === prev.offset && Path.equals(op.path, prev.path)) {
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
return false;
|
|
97
|
+
};
|
|
98
|
+
var defaultShouldSave = (op, prev) => {
|
|
99
|
+
if (op.type === "set_selection") {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
return true;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export { defaultShouldSave, withPartialHistory };
|
|
106
|
+
//# sourceMappingURL=out.js.map
|
|
107
|
+
//# sourceMappingURL=chunk-KCHYD3EB.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/slatejs-edits/with-partial-history.ts"],"names":[],"mappings":"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","sourcesContent":["import { Editor, Operation, Path, Range, Transforms } from \"slate\";\nimport { HistoryEditor } from \"slate-history\";\n\n// Copy-pasted from `https://github.com/ianstormtaylor/slate/blob/main/packages/slate-history/src/with-history.ts`\n// With one exception: the `shouldSave` function is passed in as an argument to `withPartialHistory` instead of being hardcoded\nexport type ShouldSaveToHistory = (\n op: Operation,\n prev: Operation | undefined\n) => boolean;\n\nexport const withPartialHistory = <T extends Editor>(\n editor: T,\n shouldSave: ShouldSaveToHistory\n) => {\n const e = editor as T & HistoryEditor;\n const { apply } = e;\n e.history = { undos: [], redos: [] };\n\n e.redo = () => {\n const { history } = e;\n const { redos } = history;\n\n if (redos.length > 0) {\n const batch = redos[redos.length - 1];\n\n if (batch.selectionBefore) {\n Transforms.setSelection(e, batch.selectionBefore);\n }\n\n HistoryEditor.withoutSaving(e, () => {\n Editor.withoutNormalizing(e, () => {\n for (const op of batch.operations) {\n e.apply(op);\n }\n });\n });\n\n history.redos.pop();\n e.writeHistory(\"undos\", batch);\n }\n };\n\n e.undo = () => {\n const { history } = e;\n const { undos } = history;\n\n if (undos.length > 0) {\n const batch = undos[undos.length - 1];\n\n HistoryEditor.withoutSaving(e, () => {\n Editor.withoutNormalizing(e, () => {\n const inverseOps = batch.operations.map(Operation.inverse).reverse();\n\n for (const op of inverseOps) {\n e.apply(op);\n }\n if (batch.selectionBefore) {\n Transforms.setSelection(e, batch.selectionBefore);\n }\n });\n });\n\n e.writeHistory(\"redos\", batch);\n history.undos.pop();\n }\n };\n\n e.apply = (op: Operation) => {\n const { operations, history } = e;\n const { undos } = history;\n const lastBatch = undos[undos.length - 1];\n const lastOp =\n lastBatch && lastBatch.operations[lastBatch.operations.length - 1];\n let save = HistoryEditor.isSaving(e);\n let merge = HistoryEditor.isMerging(e);\n\n if (save == null) {\n save = shouldSave(op, lastOp);\n }\n\n if (save) {\n if (merge == null) {\n if (lastBatch == null) {\n merge = false;\n } else if (operations.length !== 0) {\n merge = true;\n } else {\n merge = shouldMerge(op, lastOp);\n }\n }\n\n if (lastBatch && merge) {\n lastBatch.operations.push(op);\n } else {\n const batch = {\n operations: [op],\n selectionBefore: e.selection,\n };\n e.writeHistory(\"undos\", batch);\n }\n\n while (undos.length > 100) {\n undos.shift();\n }\n\n history.redos = [];\n }\n\n apply(op);\n };\n\n e.writeHistory = (stack: \"undos\" | \"redos\", batch: any) => {\n e.history[stack].push(batch);\n };\n\n return e;\n};\n\n/**\n * Check whether to merge an operation into the previous operation.\n */\n\nconst shouldMerge = (op: Operation, prev: Operation | undefined): boolean => {\n if (\n prev &&\n op.type === \"insert_text\" &&\n prev.type === \"insert_text\" &&\n op.offset === prev.offset + prev.text.length &&\n Path.equals(op.path, prev.path)\n ) {\n return true;\n }\n\n if (\n prev &&\n op.type === \"remove_text\" &&\n prev.type === \"remove_text\" &&\n op.offset + op.text.length === prev.offset &&\n Path.equals(op.path, prev.path)\n ) {\n return true;\n }\n\n return false;\n};\n\nexport const defaultShouldSave = (\n op: Operation,\n prev: Operation | undefined\n): boolean => {\n if (op.type === \"set_selection\") {\n return false;\n }\n\n return true;\n};\n"]}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { __async } from './chunk-MRXNTQOX.mjs';
|
|
2
|
+
import { clsx } from 'clsx';
|
|
3
|
+
import { customAlphabet } from 'nanoid';
|
|
4
|
+
import { twMerge } from 'tailwind-merge';
|
|
5
|
+
|
|
6
|
+
function cn(...inputs) {
|
|
7
|
+
return twMerge(clsx(inputs));
|
|
8
|
+
}
|
|
9
|
+
var nanoid = customAlphabet(
|
|
10
|
+
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
|
|
11
|
+
7
|
|
12
|
+
);
|
|
13
|
+
function fetcher(input, init) {
|
|
14
|
+
return __async(this, null, function* () {
|
|
15
|
+
const res = yield fetch(input, init);
|
|
16
|
+
if (!res.ok) {
|
|
17
|
+
const json = yield res.json();
|
|
18
|
+
if (json.error) {
|
|
19
|
+
const error = new Error(json.error);
|
|
20
|
+
error.status = res.status;
|
|
21
|
+
throw error;
|
|
22
|
+
} else {
|
|
23
|
+
throw new Error("An unexpected error occurred");
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return res.json();
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
function formatDate(input) {
|
|
30
|
+
const date = new Date(input);
|
|
31
|
+
return date.toLocaleDateString("en-US", {
|
|
32
|
+
month: "long",
|
|
33
|
+
day: "numeric",
|
|
34
|
+
year: "numeric"
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
var arraysAreEqual = (arr1, arr2) => arr1.length === arr2.length && arr1.every((value, index) => value === arr2[index]);
|
|
38
|
+
function nullableCompatibleEqualityCheck(naiveEqualityCheck, a, b) {
|
|
39
|
+
if (a === null || a === void 0 || b === null || b === void 0) {
|
|
40
|
+
return a === b;
|
|
41
|
+
}
|
|
42
|
+
return naiveEqualityCheck(a, b);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export { arraysAreEqual, cn, fetcher, formatDate, nanoid, nullableCompatibleEqualityCheck };
|
|
46
|
+
//# sourceMappingURL=out.js.map
|
|
47
|
+
//# sourceMappingURL=chunk-KGKLUWKW.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/utils.ts"],"names":[],"mappings":";;;;;AAAA,SAAS,YAA6B;AACtC,SAAS,sBAAsB;AAC/B,SAAS,eAAe;AAEjB,SAAS,MAAM,QAAsB;AAC1C,SAAO,QAAQ,KAAK,MAAM,CAAC;AAC7B;AAEO,IAAM,SAAS;AAAA,EACpB;AAAA,EACA;AACF;AAEA,SAAsB,QACpB,OACA,MACe;AAAA;AACf,UAAM,MAAM,MAAM,MAAM,OAAO,IAAI;AAEnC,QAAI,CAAC,IAAI,IAAI;AACX,YAAM,OAAO,MAAM,IAAI,KAAK;AAC5B,UAAI,KAAK,OAAO;AACd,cAAM,QAAQ,IAAI,MAAM,KAAK,KAAK;AAGlC,cAAM,SAAS,IAAI;AACnB,cAAM;AAAA,MACR,OAAO;AACL,cAAM,IAAI,MAAM,8BAA8B;AAAA,MAChD;AAAA,IACF;AAEA,WAAO,IAAI,KAAK;AAAA,EAClB;AAAA;AAEO,SAAS,WAAW,OAAuC;AAChE,QAAM,OAAO,IAAI,KAAK,KAAK;AAC3B,SAAO,KAAK,mBAAmB,SAAS;AAAA,IACtC,OAAO;AAAA,IACP,KAAK;AAAA,IACL,MAAM;AAAA,EACR,CAAC;AACH;AAEO,IAAM,iBAAiB,CAAC,MAAgB,SAC7C,KAAK,WAAW,KAAK,UACrB,KAAK,MAAM,CAAC,OAAO,UAAU,UAAU,KAAK,MAAM;AAE7C,SAAS,gCACd,oBACA,GACA,GACS;AACT,MAAI,MAAM,QAAQ,MAAM,UAAa,MAAM,QAAQ,MAAM,QAAW;AAClE,WAAO,MAAM;AAAA,EACf;AAEA,SAAO,mBAAmB,GAAG,CAAC;AAChC","sourcesContent":["import { clsx, type ClassValue } from \"clsx\";\nimport { customAlphabet } from \"nanoid\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n\nexport const nanoid = customAlphabet(\n \"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\",\n 7\n); // 7-character random string\n\nexport async function fetcher<JSON = any>(\n input: RequestInfo,\n init?: RequestInit\n): Promise<JSON> {\n const res = await fetch(input, init);\n\n if (!res.ok) {\n const json = await res.json();\n if (json.error) {\n const error = new Error(json.error) as Error & {\n status: number;\n };\n error.status = res.status;\n throw error;\n } else {\n throw new Error(\"An unexpected error occurred\");\n }\n }\n\n return res.json();\n}\n\nexport function formatDate(input: string | number | Date): string {\n const date = new Date(input);\n return date.toLocaleDateString(\"en-US\", {\n month: \"long\",\n day: \"numeric\",\n year: \"numeric\",\n });\n}\n\nexport const arraysAreEqual = (arr1: number[], arr2: number[]): boolean =>\n arr1.length === arr2.length &&\n arr1.every((value, index) => value === arr2[index]);\n\nexport function nullableCompatibleEqualityCheck<T>(\n naiveEqualityCheck: (a: T, b: T) => boolean,\n a: T | null | undefined,\n b: T | null | undefined\n): boolean {\n if (a === null || a === undefined || b === null || b === undefined) {\n return a === b;\n }\n\n return naiveEqualityCheck(a, b);\n}\n"]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { __async, __spreadProps, __spreadValues } from './chunk-MRXNTQOX.mjs';
|
|
2
|
+
import { copilotApiConfigExtrapolator } from '@copilotkit/react-core';
|
|
3
|
+
|
|
4
|
+
var ChatlikeApiEndpoint = class {
|
|
5
|
+
constructor(run) {
|
|
6
|
+
this.run = run;
|
|
7
|
+
}
|
|
8
|
+
static fromCopilotApiConfig(copilotApiConfig) {
|
|
9
|
+
return new ChatlikeApiEndpoint(
|
|
10
|
+
(abortSignal, messages, forwardedProps) => __async(this, null, function* () {
|
|
11
|
+
const res = yield fetch(
|
|
12
|
+
copilotApiConfigExtrapolator(copilotApiConfig).chatApiEndpoint,
|
|
13
|
+
{
|
|
14
|
+
method: "POST",
|
|
15
|
+
body: JSON.stringify(__spreadProps(__spreadValues({}, forwardedProps), {
|
|
16
|
+
messages
|
|
17
|
+
})),
|
|
18
|
+
signal: abortSignal
|
|
19
|
+
}
|
|
20
|
+
);
|
|
21
|
+
const bodySteram = res.body;
|
|
22
|
+
if (!bodySteram) {
|
|
23
|
+
throw new Error("The response body is empty.");
|
|
24
|
+
}
|
|
25
|
+
const stringStream = bodySteram.pipeThrough(new TextDecoderStream());
|
|
26
|
+
return stringStream;
|
|
27
|
+
})
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
static custom(run) {
|
|
31
|
+
return new ChatlikeApiEndpoint(run);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export { ChatlikeApiEndpoint };
|
|
36
|
+
//# sourceMappingURL=out.js.map
|
|
37
|
+
//# sourceMappingURL=chunk-KIRROE2K.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/types/autosuggestions-config/subtypes/chatlike-api-endpoint.tsx"],"names":[],"mappings":";;;;;;;AAAA;AAAA,EAEE;AAAA,OACK;AAeA,IAAM,sBAAN,MAA0B;AAAA,EAG/B,YAAY,KAAuC;AACjD,SAAK,MAAM;AAAA,EACb;AAAA,EAOA,OAAO,qBACL,kBACqB;AACrB,WAAO,IAAI;AAAA,MACT,CACE,aACA,UACA,mBACG;AACH,cAAM,MAAM,MAAM;AAAA,UAChB,6BAA6B,gBAAgB,EAAE;AAAA,UAC/C;AAAA,YACE,QAAQ;AAAA,YACR,MAAM,KAAK,UAAU,iCAChB,iBADgB;AAAA,cAEnB;AAAA,YACF,EAAC;AAAA,YACD,QAAQ;AAAA,UACV;AAAA,QACF;AAEA,cAAM,aAAgD,IAAI;AAC1D,YAAI,CAAC,YAAY;AACf,gBAAM,IAAI,MAAM,6BAA6B;AAAA,QAC/C;AAGA,cAAM,eAAe,WAAW,YAAY,IAAI,kBAAkB,CAAC;AAEnE,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AAAA,EAOA,OAAO,OAAO,KAA4D;AACxE,WAAO,IAAI,oBAAoB,GAAG;AAAA,EACpC;AACF","sourcesContent":["import {\n CopilotApiConfig,\n copilotApiConfigExtrapolator,\n} from \"@copilotkit/react-core\";\nimport { MinimalChatGPTMessage } from \"./minimal-chat-gpt-message\";\n\nexport type ChatlikeApiEndpointImpl = (\n abortSignal: AbortSignal,\n messages: MinimalChatGPTMessage[],\n forwardedProps?: { [key: string]: any }\n) => Promise<string>;\n\nexport type StreamingChatlikeApiEndpointImpl = (\n abortSignal: AbortSignal,\n messages: MinimalChatGPTMessage[],\n forwardedProps?: { [key: string]: any }\n) => Promise<ReadableStream<string>>;\n\nexport class ChatlikeApiEndpoint {\n public run: StreamingChatlikeApiEndpointImpl;\n\n constructor(run: StreamingChatlikeApiEndpointImpl) {\n this.run = run;\n }\n\n /**\n * Creates a new instance of ChatlikeApiEndpoint with the provided API endpoint.\n * @param apiEndpoint The URL of the OpenAI-compatible API endpoint.\n * @returns A new instance of ChatlikeApiEndpoint.\n */\n static fromCopilotApiConfig(\n copilotApiConfig: CopilotApiConfig\n ): ChatlikeApiEndpoint {\n return new ChatlikeApiEndpoint(\n async (\n abortSignal: AbortSignal,\n messages: MinimalChatGPTMessage[],\n forwardedProps?: { [key: string]: any }\n ) => {\n const res = await fetch(\n copilotApiConfigExtrapolator(copilotApiConfig).chatApiEndpoint,\n {\n method: \"POST\",\n body: JSON.stringify({\n ...forwardedProps,\n messages: messages,\n }),\n signal: abortSignal,\n }\n );\n\n const bodySteram: ReadableStream<Uint8Array> | null = res.body;\n if (!bodySteram) {\n throw new Error(\"The response body is empty.\");\n }\n\n // map the stream to a stream of strings\n const stringStream = bodySteram.pipeThrough(new TextDecoderStream());\n\n return stringStream;\n }\n );\n }\n\n /**\n * Creates a fully customized instance of ChatlikeApiEndpoint.\n * @param run - The implementation of the ChatlikeApiEndpointImpl interface.\n * @returns A new instance of ChatlikeApiEndpoint .\n */\n static custom(run: StreamingChatlikeApiEndpointImpl): ChatlikeApiEndpoint {\n return new ChatlikeApiEndpoint(run);\n }\n}\n"]}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { Command, CommandInput, CommandList, CommandEmpty, CommandGroup, CommandItem, CommandSeparator } from './chunk-XA7M72ZO.mjs';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
function SourceSearchBox(props) {
|
|
6
|
+
const [selectedValue, setSelectedValue] = useState("");
|
|
7
|
+
return /* @__PURE__ */ jsxs(Command, {
|
|
8
|
+
className: "rounded-lg border shadow-md",
|
|
9
|
+
value: selectedValue,
|
|
10
|
+
onValueChange: (value) => {
|
|
11
|
+
setSelectedValue(value);
|
|
12
|
+
},
|
|
13
|
+
filter: (value, search) => {
|
|
14
|
+
if (props.searchTerm === "")
|
|
15
|
+
return 1;
|
|
16
|
+
if (value.startsWith(props.searchTerm))
|
|
17
|
+
return 1;
|
|
18
|
+
return 0;
|
|
19
|
+
},
|
|
20
|
+
children: [
|
|
21
|
+
/* @__PURE__ */ jsx(CommandInput, {
|
|
22
|
+
value: props.searchTerm,
|
|
23
|
+
className: "rounded-t-lg hidden",
|
|
24
|
+
placeholder: "Search for a command..."
|
|
25
|
+
}),
|
|
26
|
+
/* @__PURE__ */ jsxs(CommandList, {
|
|
27
|
+
children: [
|
|
28
|
+
/* @__PURE__ */ jsx(CommandEmpty, {
|
|
29
|
+
children: "No results found."
|
|
30
|
+
}),
|
|
31
|
+
/* @__PURE__ */ jsx(CommandGroup, {
|
|
32
|
+
heading: "Available resources",
|
|
33
|
+
children: props.suggestedFiles.map((filePointer) => {
|
|
34
|
+
return /* @__PURE__ */ jsx(CommandItem, {
|
|
35
|
+
value: filePointer.name,
|
|
36
|
+
onSelect: (value) => {
|
|
37
|
+
props.onSelectedFile(filePointer);
|
|
38
|
+
},
|
|
39
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
40
|
+
className: "flex flex-row gap-3 items-center",
|
|
41
|
+
children: [
|
|
42
|
+
/* @__PURE__ */ jsx(Logo, {
|
|
43
|
+
size: "30px",
|
|
44
|
+
children: /* @__PURE__ */ jsx("img", {
|
|
45
|
+
src: filePointer.iconImageUri,
|
|
46
|
+
alt: filePointer.sourceApplication,
|
|
47
|
+
width: 30,
|
|
48
|
+
height: 30
|
|
49
|
+
})
|
|
50
|
+
}),
|
|
51
|
+
filePointer.name
|
|
52
|
+
]
|
|
53
|
+
})
|
|
54
|
+
}, `word-${filePointer.sourceApplication}.${filePointer.name}`);
|
|
55
|
+
})
|
|
56
|
+
}),
|
|
57
|
+
/* @__PURE__ */ jsx(CommandSeparator, {})
|
|
58
|
+
]
|
|
59
|
+
})
|
|
60
|
+
]
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
function Logo({
|
|
64
|
+
children,
|
|
65
|
+
size = "30px"
|
|
66
|
+
}) {
|
|
67
|
+
return /* @__PURE__ */ jsx("div", {
|
|
68
|
+
className: "flex items-center justify-center bg-black",
|
|
69
|
+
style: { width: size, height: size },
|
|
70
|
+
children
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export { Logo, SourceSearchBox };
|
|
75
|
+
//# sourceMappingURL=out.js.map
|
|
76
|
+
//# sourceMappingURL=chunk-L6DZHWEL.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/source-search-box/source-search-box.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,SAAS,gBAAgB;AAmDnB,cAkBU,YAlBV;AArBC,SAAS,gBAAgB,OAA6B;AAC3D,QAAM,CAAC,eAAe,gBAAgB,IAAI,SAAiB,EAAE;AAE7D,SACE,qBAAC;AAAA,IACC,WAAU;AAAA,IACV,OAAO;AAAA,IACP,eAAe,CAAC,UAAU;AACxB,uBAAiB,KAAK;AAAA,IACxB;AAAA,IACA,QAAQ,CAAC,OAAO,WAAW;AAEzB,UAAI,MAAM,eAAe;AAAI,eAAO;AAGpC,UAAI,MAAM,WAAW,MAAM,UAAU;AAAG,eAAO;AAG/C,aAAO;AAAA,IACT;AAAA,IAEA;AAAA,0BAAC;AAAA,QACC,OAAO,MAAM;AAAA,QACb,WAAU;AAAA,QACV,aAAY;AAAA,OACd;AAAA,MACA,qBAAC;AAAA,QACC;AAAA,8BAAC;AAAA,YAAa;AAAA,WAAiB;AAAA,UAE/B,oBAAC;AAAA,YAAa,SAAQ;AAAA,YACnB,gBAAM,eAAe,IAAI,CAAC,gBAAgB;AACzC,qBACE,oBAAC;AAAA,gBAEC,OAAO,YAAY;AAAA,gBACnB,UAAU,CAAC,UAAU;AACnB,wBAAM,eAAe,WAAW;AAAA,gBAClC;AAAA,gBAEA,+BAAC;AAAA,kBAAI,WAAU;AAAA,kBACb;AAAA,wCAAC;AAAA,sBAAK,MAAK;AAAA,sBACT,8BAAC;AAAA,wBACC,KAAK,YAAY;AAAA,wBACjB,KAAK,YAAY;AAAA,wBACjB,OAAO;AAAA,wBACP,QAAQ;AAAA,uBACV;AAAA,qBACF;AAAA,oBACC,YAAY;AAAA;AAAA,iBACf;AAAA,iBAhBK,QAAQ,YAAY,qBAAqB,YAAY,MAiB5D;AAAA,YAEJ,CAAC;AAAA,WACH;AAAA,UAqBA,oBAAC,oBAAiB;AAAA;AAAA,OACpB;AAAA;AAAA,GACF;AAEJ;AAEO,SAAS,KAAK;AAAA,EACnB;AAAA,EACA,OAAO;AACT,GAGG;AACD,SACE,oBAAC;AAAA,IACC,WAAU;AAAA,IACV,OAAO,EAAE,OAAO,MAAM,QAAQ,KAAK;AAAA,IAElC;AAAA,GACH;AAEJ","sourcesContent":["import { useState } from \"react\";\nimport {\n Command,\n CommandDialog,\n CommandEmpty,\n CommandGroup,\n CommandInput,\n CommandItem,\n CommandList,\n CommandSeparator,\n CommandShortcut,\n} from \"../ui/command\";\n\nimport {\n Calculator,\n Calendar,\n CreditCard,\n Settings,\n Smile,\n User,\n} from \"lucide-react\";\n\nimport { DocumentPointer } from \"@copilotkit/react-core\";\n\nexport interface SourceSearchBoxProps {\n searchTerm: string;\n suggestedFiles: DocumentPointer[];\n onSelectedFile: (filePointer: DocumentPointer) => void;\n}\n\nexport function SourceSearchBox(props: SourceSearchBoxProps) {\n const [selectedValue, setSelectedValue] = useState<string>(\"\");\n\n return (\n <Command\n className=\"rounded-lg border shadow-md\"\n value={selectedValue}\n onValueChange={(value) => {\n setSelectedValue(value);\n }}\n filter={(value, search) => {\n // if the search term is empty, show all commands\n if (props.searchTerm === \"\") return 1;\n\n // if the search term is a prefix of the command, show it\n if (value.startsWith(props.searchTerm)) return 1;\n\n // otherwise, don't show it\n return 0;\n }}\n >\n <CommandInput\n value={props.searchTerm}\n className=\"rounded-t-lg hidden\"\n placeholder=\"Search for a command...\"\n />\n <CommandList>\n <CommandEmpty>No results found.</CommandEmpty>\n\n <CommandGroup heading=\"Available resources\">\n {props.suggestedFiles.map((filePointer) => {\n return (\n <CommandItem\n key={`word-${filePointer.sourceApplication}.${filePointer.name}`}\n value={filePointer.name}\n onSelect={(value) => {\n props.onSelectedFile(filePointer);\n }}\n >\n <div className=\"flex flex-row gap-3 items-center\">\n <Logo size=\"30px\">\n <img\n src={filePointer.iconImageUri}\n alt={filePointer.sourceApplication}\n width={30}\n height={30}\n />\n </Logo>\n {filePointer.name}\n </div>\n </CommandItem>\n );\n })}\n </CommandGroup>\n\n {/* <CommandGroup heading=\"Suggestions\">\n <CommandItem\n onSelect={(value) => {\n console.log(value);\n console.log(value);\n }}\n >\n <Calendar className=\"mr-2 h-4 w-4\" />\n <span>Calendar</span>\n </CommandItem>\n <CommandItem>\n <Smile className=\"mr-2 h-4 w-4\" />\n <span>Search Emoji</span>\n </CommandItem>\n <CommandItem>\n <Calculator className=\"mr-2 h-4 w-4\" />\n <span>Calculator</span>\n </CommandItem>\n </CommandGroup> */}\n <CommandSeparator />\n </CommandList>\n </Command>\n );\n}\n\nexport function Logo({\n children,\n size = \"30px\",\n}: {\n children: React.ReactNode;\n size?: string;\n}) {\n return (\n <div\n className=\"flex items-center justify-center bg-black\"\n style={{ width: size, height: size }}\n >\n {children}\n </div>\n );\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { __spreadProps, __spreadValues } from './chunk-MRXNTQOX.mjs';
|
|
2
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
+
|
|
4
|
+
function makeRenderElementFunction(suggestionsStyle) {
|
|
5
|
+
return (props) => {
|
|
6
|
+
switch (props.element.type) {
|
|
7
|
+
case "paragraph":
|
|
8
|
+
return /* @__PURE__ */ jsx(DefaultElement, __spreadValues({}, props));
|
|
9
|
+
case "suggestion":
|
|
10
|
+
return /* @__PURE__ */ jsx(SuggestionElement, __spreadProps(__spreadValues({}, props), {
|
|
11
|
+
suggestionsStyle
|
|
12
|
+
}));
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
var DefaultElement = (props) => {
|
|
17
|
+
return /* @__PURE__ */ jsx("div", __spreadProps(__spreadValues({}, props.attributes), {
|
|
18
|
+
children: props.children
|
|
19
|
+
}));
|
|
20
|
+
};
|
|
21
|
+
var SuggestionElement = (props) => {
|
|
22
|
+
return /* @__PURE__ */ jsxs("span", __spreadProps(__spreadValues({}, props.attributes), {
|
|
23
|
+
style: __spreadValues({}, props.suggestionsStyle),
|
|
24
|
+
contentEditable: false,
|
|
25
|
+
children: [
|
|
26
|
+
props.children,
|
|
27
|
+
props.element.type === "suggestion" && props.element.content
|
|
28
|
+
]
|
|
29
|
+
}));
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export { makeRenderElementFunction };
|
|
33
|
+
//# sourceMappingURL=out.js.map
|
|
34
|
+
//# sourceMappingURL=chunk-LNAIMEB2.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/base-copilot-textarea/render-element.tsx"],"names":[],"mappings":";;;;;;AAUe,cAkBX,YAlBW;AANR,SAAS,0BACd,kBACuB;AACvB,SAAO,CAAC,UAA8B;AACpC,YAAQ,MAAM,QAAQ,MAAM;AAAA,MAC1B,KAAK;AACH,eAAO,oBAAC,mCAAmB,MAAO;AAAA,MACpC,KAAK;AACH,eACE,oBAAC,oDAAsB,QAAtB;AAAA,UAA6B;AAAA,UAAoC;AAAA,IAExE;AAAA,EACF;AACF;AAEA,IAAM,iBAAiB,CAAC,UAA8B;AACpD,SAAO,oBAAC,wCAAQ,MAAM,aAAd;AAAA,IAA2B,gBAAM;AAAA,IAAS;AACpD;AACA,IAAM,oBAAoB,CACxB,UAGG;AACH,SACE,qBAAC,yCACK,MAAM,aADX;AAAA,IAEC,OAAO,mBACF,MAAM;AAAA,IAEX,iBAAiB;AAAA,IAEhB;AAAA,YAAM;AAAA,MACN,MAAM,QAAQ,SAAS,gBAAgB,MAAM,QAAQ;AAAA;AAAA,IACxD;AAEJ","sourcesContent":["import { RenderElementProps } from \"slate-react\";\n\nexport type RenderElementFunction = (props: RenderElementProps) => JSX.Element;\n\nexport function makeRenderElementFunction(\n suggestionsStyle: React.CSSProperties\n): RenderElementFunction {\n return (props: RenderElementProps) => {\n switch (props.element.type) {\n case \"paragraph\":\n return <DefaultElement {...props} />;\n case \"suggestion\":\n return (\n <SuggestionElement {...props} suggestionsStyle={suggestionsStyle} />\n );\n }\n };\n}\n\nconst DefaultElement = (props: RenderElementProps) => {\n return <div {...props.attributes}>{props.children}</div>;\n};\nconst SuggestionElement = (\n props: RenderElementProps & {\n suggestionsStyle: React.CSSProperties;\n }\n) => {\n return (\n <span\n {...props.attributes}\n style={{\n ...props.suggestionsStyle,\n }}\n contentEditable={false}\n >\n {props.children /* https://github.com/ianstormtaylor/slate/issues/3930 */}\n {props.element.type === \"suggestion\" && props.element.content}\n </span>\n );\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
// src/components/base-copilot-textarea/use-add-branding-css.tsx
|
|
4
|
+
function useAddBrandingCss(suggestionStyleAugmented, disableBranding) {
|
|
5
|
+
const cssSelector = ".copilot-textarea.with-branding";
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
if (disableBranding) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
const styleEl = document.createElement("style");
|
|
11
|
+
styleEl.id = "dynamic-styles";
|
|
12
|
+
let dynamicStyles = Object.entries(suggestionStyleAugmented).map(([key, value]) => {
|
|
13
|
+
const kebabCaseKey = key.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
|
|
14
|
+
return `${kebabCaseKey}: ${value};`;
|
|
15
|
+
}).join(" ");
|
|
16
|
+
dynamicStyles += `font-style: normal; font-size: x-small;`;
|
|
17
|
+
dynamicStyles += `content: "CopilotKit";`;
|
|
18
|
+
dynamicStyles += `bottom: 6px;`;
|
|
19
|
+
dynamicStyles += `right: 6px;`;
|
|
20
|
+
dynamicStyles += `pointer-events: none;`;
|
|
21
|
+
dynamicStyles += `font-weight: 200;`;
|
|
22
|
+
dynamicStyles += `padding: 0;`;
|
|
23
|
+
dynamicStyles += `margin: 0;`;
|
|
24
|
+
dynamicStyles += `border: 0;`;
|
|
25
|
+
dynamicStyles += `line-height: 1;`;
|
|
26
|
+
dynamicStyles += `position: absolute;`;
|
|
27
|
+
styleEl.innerHTML = `
|
|
28
|
+
${cssSelector}::after {
|
|
29
|
+
${dynamicStyles}
|
|
30
|
+
}
|
|
31
|
+
`;
|
|
32
|
+
document.head.appendChild(styleEl);
|
|
33
|
+
const textarea = document.querySelector(cssSelector);
|
|
34
|
+
const handleScroll = () => {
|
|
35
|
+
const styleEl2 = document.getElementById("dynamic-styles");
|
|
36
|
+
if (styleEl2 && textarea) {
|
|
37
|
+
const offsetFromBottom = -textarea.scrollTop + 6;
|
|
38
|
+
const offsetFromRight = -textarea.scrollLeft + 6;
|
|
39
|
+
styleEl2.innerHTML = `
|
|
40
|
+
${cssSelector}::after {
|
|
41
|
+
${dynamicStyles}
|
|
42
|
+
bottom: ${offsetFromBottom}px;
|
|
43
|
+
right: ${offsetFromRight}px;
|
|
44
|
+
}
|
|
45
|
+
`;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
textarea == null ? void 0 : textarea.addEventListener("scroll", handleScroll);
|
|
49
|
+
return () => {
|
|
50
|
+
var _a;
|
|
51
|
+
(_a = document.getElementById("dynamic-styles")) == null ? void 0 : _a.remove();
|
|
52
|
+
textarea == null ? void 0 : textarea.removeEventListener("scroll", handleScroll);
|
|
53
|
+
};
|
|
54
|
+
}, [disableBranding, suggestionStyleAugmented]);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export { useAddBrandingCss };
|
|
58
|
+
//# sourceMappingURL=out.js.map
|
|
59
|
+
//# sourceMappingURL=chunk-MPME5BW2.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/base-copilot-textarea/use-add-branding-css.tsx"],"names":["styleEl"],"mappings":";AAAA,SAAS,iBAAiB;AAEnB,SAAS,kBACd,0BACA,iBACA;AACA,QAAM,cAAc;AACpB,YAAU,MAAM;AACd,QAAI,iBAAiB;AACnB;AAAA,IACF;AAIA,UAAM,UAAU,SAAS,cAAc,OAAO;AAC9C,YAAQ,KAAK;AAGb,QAAI,gBAAgB,OAAO,QAAQ,wBAAwB,EACxD,IAAI,CAAC,CAAC,KAAK,KAAK,MAAM;AACrB,YAAM,eAAe,IAClB,QAAQ,gCAAgC,OAAO,EAC/C,YAAY;AACf,aAAO,GAAG,iBAAiB;AAAA,IAC7B,CAAC,EACA,KAAK,GAAG;AAGX,qBAAiB;AACjB,qBAAiB;AACjB,qBAAiB;AACjB,qBAAiB;AACjB,qBAAiB;AACjB,qBAAiB;AACjB,qBAAiB;AACjB,qBAAiB;AACjB,qBAAiB;AACjB,qBAAiB;AACjB,qBAAiB;AAGjB,YAAQ,YAAY;AAAA,QAChB;AAAA,UACE;AAAA;AAAA;AAIN,aAAS,KAAK,YAAY,OAAO;AAIjC,UAAM,WAAW,SAAS,cAAc,WAAW;AACnD,UAAM,eAAe,MAAM;AACzB,YAAMA,WAAU,SAAS,eAAe,gBAAgB;AACxD,UAAIA,YAAW,UAAU;AACvB,cAAM,mBAAmB,CAAC,SAAS,YAAY;AAC/C,cAAM,kBAAkB,CAAC,SAAS,aAAa;AAC/C,QAAAA,SAAQ,YAAY;AAAA,YAChB;AAAA,cACE;AAAA,sBACQ;AAAA,qBACD;AAAA;AAAA;AAAA,MAGf;AAAA,IACF;AAEA,yCAAU,iBAAiB,UAAU;AAGrC,WAAO,MAAM;AAtEjB;AAuEM,qBAAS,eAAe,gBAAgB,MAAxC,mBAA2C;AAC3C,2CAAU,oBAAoB,UAAU;AAAA,IAC1C;AAAA,EACF,GAAG,CAAC,iBAAiB,wBAAwB,CAAC;AAChD","sourcesContent":["import { useEffect } from \"react\";\n\nexport function useAddBrandingCss(\n suggestionStyleAugmented: React.CSSProperties,\n disableBranding: boolean | undefined\n) {\n const cssSelector = \".copilot-textarea.with-branding\";\n useEffect(() => {\n if (disableBranding) {\n return;\n }\n\n // ---\n // 1: Add the CSS to the DOM\n const styleEl = document.createElement(\"style\");\n styleEl.id = \"dynamic-styles\";\n\n // Build the CSS string dynamically\n let dynamicStyles = Object.entries(suggestionStyleAugmented)\n .map(([key, value]) => {\n const kebabCaseKey = key\n .replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, \"$1-$2\")\n .toLowerCase();\n return `${kebabCaseKey}: ${value};`;\n })\n .join(\" \");\n\n // Append overrides for italics and font-size\n dynamicStyles += `font-style: normal; font-size: x-small;`;\n dynamicStyles += `content: \"CopilotKit\";`;\n dynamicStyles += `bottom: 6px;`;\n dynamicStyles += `right: 6px;`;\n dynamicStyles += `pointer-events: none;`;\n dynamicStyles += `font-weight: 200;`;\n dynamicStyles += `padding: 0;`;\n dynamicStyles += `margin: 0;`;\n dynamicStyles += `border: 0;`;\n dynamicStyles += `line-height: 1;`;\n dynamicStyles += `position: absolute;`;\n\n // Append it to the ::after class\n styleEl.innerHTML = `\n ${cssSelector}::after {\n ${dynamicStyles}\n }\n `;\n\n document.head.appendChild(styleEl);\n\n // ---\n // 2: Add the scroll listener (to keep the branding in the bottom right as the textarea scrolls)\n const textarea = document.querySelector(cssSelector);\n const handleScroll = () => {\n const styleEl = document.getElementById(\"dynamic-styles\");\n if (styleEl && textarea) {\n const offsetFromBottom = -textarea.scrollTop + 6;\n const offsetFromRight = -textarea.scrollLeft + 6;\n styleEl.innerHTML = `\n ${cssSelector}::after {\n ${dynamicStyles}\n bottom: ${offsetFromBottom}px;\n right: ${offsetFromRight}px;\n }\n `;\n }\n };\n\n textarea?.addEventListener(\"scroll\", handleScroll);\n\n // Cleanup\n return () => {\n document.getElementById(\"dynamic-styles\")?.remove();\n textarea?.removeEventListener(\"scroll\", handleScroll);\n };\n }, [disableBranding, suggestionStyleAugmented]);\n}\n"]}
|