@copilotkit/react-textarea 0.28.0-alpha.8 → 0.28.0
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 +429 -467
- package/CHANGELOG.md +45 -0
- package/dist/chunk-224UKA7C.mjs +9 -4
- package/dist/chunk-224UKA7C.mjs.map +1 -1
- package/dist/chunk-2C7O2EVM.mjs +4 -4
- package/dist/chunk-2C7O2EVM.mjs.map +1 -1
- package/dist/chunk-2QDCE7PD.mjs +6 -3
- package/dist/chunk-2QDCE7PD.mjs.map +1 -1
- package/dist/chunk-3PQ7GSFE.mjs +4 -4
- package/dist/chunk-3PQ7GSFE.mjs.map +1 -1
- package/dist/chunk-4NHVQZ67.mjs +6 -5
- package/dist/chunk-4NHVQZ67.mjs.map +1 -1
- package/dist/chunk-4OJ3H65F.mjs +5 -2
- package/dist/chunk-4OJ3H65F.mjs.map +1 -1
- package/dist/chunk-5J3UZV77.mjs +23 -11
- package/dist/chunk-5J3UZV77.mjs.map +1 -1
- package/dist/chunk-5UNJXFUO.mjs +4 -4
- package/dist/chunk-5UNJXFUO.mjs.map +1 -1
- package/dist/chunk-72P3KOHZ.mjs +17 -7
- package/dist/chunk-72P3KOHZ.mjs.map +1 -1
- package/dist/chunk-7LSRNPNI.mjs +4 -4
- package/dist/chunk-7LSRNPNI.mjs.map +1 -1
- package/dist/chunk-7SUZ6CXM.mjs +15 -6
- package/dist/chunk-7SUZ6CXM.mjs.map +1 -1
- package/dist/chunk-AZHILHKM.mjs +21 -8
- package/dist/chunk-AZHILHKM.mjs.map +1 -1
- package/dist/chunk-B6TKVDDY.mjs +58 -22
- package/dist/chunk-B6TKVDDY.mjs.map +1 -1
- package/dist/chunk-BBZ7AWOB.mjs +8 -4
- package/dist/chunk-BBZ7AWOB.mjs.map +1 -1
- package/dist/chunk-DE5K76I2.mjs +0 -2
- package/dist/chunk-DE5K76I2.mjs.map +1 -1
- package/dist/chunk-DRV2FOHZ.mjs +11 -6
- package/dist/chunk-DRV2FOHZ.mjs.map +1 -1
- package/dist/chunk-ECR45NSD.mjs +7 -4
- package/dist/chunk-ECR45NSD.mjs.map +1 -1
- package/dist/chunk-FJNUPSQK.mjs +16 -5
- package/dist/chunk-FJNUPSQK.mjs.map +1 -1
- package/dist/chunk-FP2EKU3L.mjs +4 -4
- package/dist/chunk-FP2EKU3L.mjs.map +1 -1
- package/dist/chunk-GQN2HYFJ.mjs +4 -4
- package/dist/chunk-GQN2HYFJ.mjs.map +1 -1
- package/dist/chunk-H4VKQGVU.mjs +0 -2
- package/dist/chunk-H4VKQGVU.mjs.map +1 -1
- package/dist/chunk-IU3WTXLQ.mjs +0 -2
- package/dist/chunk-IU3WTXLQ.mjs.map +1 -1
- package/dist/chunk-JJLQVT7S.mjs +6 -3
- package/dist/chunk-JJLQVT7S.mjs.map +1 -1
- package/dist/chunk-KDVMG3XF.mjs +5 -2
- package/dist/chunk-KDVMG3XF.mjs.map +1 -1
- package/dist/chunk-KFQZHRPJ.mjs +15 -8
- package/dist/chunk-KFQZHRPJ.mjs.map +1 -1
- package/dist/chunk-KNQIEOFP.mjs +3 -2
- package/dist/chunk-KNQIEOFP.mjs.map +1 -1
- package/dist/chunk-L7VVZH4Q.mjs +0 -2
- package/dist/chunk-L7VVZH4Q.mjs.map +1 -1
- package/dist/chunk-LQ2OWQU7.mjs +11 -7
- package/dist/chunk-LQ2OWQU7.mjs.map +1 -1
- package/dist/chunk-LYB4B6MK.mjs +6 -5
- package/dist/chunk-LYB4B6MK.mjs.map +1 -1
- package/dist/chunk-M2DR4KVB.mjs +6 -3
- package/dist/chunk-M2DR4KVB.mjs.map +1 -1
- package/dist/chunk-MMVDU6DF.mjs +0 -2
- package/dist/chunk-MMVDU6DF.mjs.map +1 -1
- package/dist/chunk-MRXNTQOX.mjs +6 -2
- package/dist/chunk-MRXNTQOX.mjs.map +1 -1
- package/dist/chunk-P4QVFRLY.mjs +17 -7
- package/dist/chunk-P4QVFRLY.mjs.map +1 -1
- package/dist/chunk-PTZVE6NC.mjs +22 -8
- package/dist/chunk-PTZVE6NC.mjs.map +1 -1
- package/dist/chunk-QCPS6IYI.mjs +15 -6
- package/dist/chunk-QCPS6IYI.mjs.map +1 -1
- package/dist/chunk-RKQ6RTZM.mjs +5 -2
- package/dist/chunk-RKQ6RTZM.mjs.map +1 -1
- package/dist/chunk-RT4UTBH3.mjs +15 -6
- package/dist/chunk-RT4UTBH3.mjs.map +1 -1
- package/dist/chunk-RUV6NBIF.mjs +0 -2
- package/dist/chunk-RUV6NBIF.mjs.map +1 -1
- package/dist/chunk-SNQEBH5I.mjs +24 -10
- package/dist/chunk-SNQEBH5I.mjs.map +1 -1
- package/dist/chunk-SX6NY5FW.mjs +11 -6
- package/dist/chunk-SX6NY5FW.mjs.map +1 -1
- package/dist/chunk-T6MTDQZ7.mjs +4 -4
- package/dist/chunk-T6MTDQZ7.mjs.map +1 -1
- package/dist/chunk-VB4VNCIQ.mjs +28 -12
- package/dist/chunk-VB4VNCIQ.mjs.map +1 -1
- package/dist/chunk-VPEH6V7T.mjs +12 -6
- package/dist/chunk-VPEH6V7T.mjs.map +1 -1
- package/dist/chunk-WADHCMPK.mjs +0 -2
- package/dist/chunk-WADHCMPK.mjs.map +1 -1
- package/dist/chunk-WFTAAA7R.mjs +16 -8
- package/dist/chunk-WFTAAA7R.mjs.map +1 -1
- package/dist/chunk-WJHSY5T6.mjs +0 -2
- package/dist/chunk-WJHSY5T6.mjs.map +1 -1
- package/dist/chunk-WTASPE2W.mjs +41 -22
- package/dist/chunk-WTASPE2W.mjs.map +1 -1
- package/dist/chunk-XW3ICO4S.mjs +10 -4
- package/dist/chunk-XW3ICO4S.mjs.map +1 -1
- package/dist/components/base-copilot-textarea/base-copilot-textarea.js +379 -257
- package/dist/components/base-copilot-textarea/base-copilot-textarea.js.map +1 -1
- package/dist/components/base-copilot-textarea/base-copilot-textarea.mjs +39 -35
- package/dist/components/base-copilot-textarea/base-copilot-textarea.mjs.map +1 -1
- package/dist/components/base-copilot-textarea/render-element.js +32 -11
- package/dist/components/base-copilot-textarea/render-element.js.map +1 -1
- package/dist/components/base-copilot-textarea/render-element.mjs +7 -3
- package/dist/components/base-copilot-textarea/render-element.mjs.map +1 -1
- package/dist/components/base-copilot-textarea/render-placeholder.js +29 -8
- package/dist/components/base-copilot-textarea/render-placeholder.js.map +1 -1
- package/dist/components/base-copilot-textarea/render-placeholder.mjs +7 -3
- 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.js +44 -17
- package/dist/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.js.map +1 -1
- package/dist/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.mjs +8 -4
- 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.js +29 -7
- package/dist/components/base-copilot-textarea/use-add-branding-css.js.map +1 -1
- package/dist/components/base-copilot-textarea/use-add-branding-css.mjs +7 -3
- package/dist/components/base-copilot-textarea/use-add-branding-css.mjs.map +1 -1
- package/dist/components/copilot-textarea/copilot-textarea.js +414 -272
- package/dist/components/copilot-textarea/copilot-textarea.js.map +1 -1
- package/dist/components/copilot-textarea/copilot-textarea.mjs +48 -44
- package/dist/components/copilot-textarea/copilot-textarea.mjs.map +1 -1
- package/dist/components/hovering-toolbar/hovering-editor-provider.js +35 -12
- package/dist/components/hovering-toolbar/hovering-editor-provider.js.map +1 -1
- package/dist/components/hovering-toolbar/hovering-editor-provider.mjs +9 -3
- package/dist/components/hovering-toolbar/hovering-editor-provider.mjs.map +1 -1
- package/dist/components/hovering-toolbar/hovering-toolbar-components.js +66 -36
- package/dist/components/hovering-toolbar/hovering-toolbar-components.js.map +1 -1
- package/dist/components/hovering-toolbar/hovering-toolbar-components.mjs +15 -3
- package/dist/components/hovering-toolbar/hovering-toolbar-components.mjs.map +1 -1
- package/dist/components/hovering-toolbar/hovering-toolbar.js +247 -179
- package/dist/components/hovering-toolbar/hovering-toolbar.js.map +1 -1
- package/dist/components/hovering-toolbar/hovering-toolbar.mjs +22 -18
- 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.js +180 -129
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.js.map +1 -1
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.mjs +16 -12
- 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.js +185 -131
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.js.map +1 -1
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.mjs +17 -13
- 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/included-files-preview.js +71 -55
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.js.map +1 -1
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.mjs +11 -5
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.mjs.map +1 -1
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.js +185 -131
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.js.map +1 -1
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.mjs +18 -14
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.mjs.map +1 -1
- package/dist/components/index.js +418 -273
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +52 -45
- package/dist/components/index.mjs.map +1 -1
- package/dist/components/manual-ui/chip-with-icon.js +31 -9
- package/dist/components/manual-ui/chip-with-icon.js.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.js +104 -72
- package/dist/components/source-search-box/source-search-box.js.map +1 -1
- package/dist/components/source-search-box/source-search-box.mjs +12 -6
- package/dist/components/source-search-box/source-search-box.mjs.map +1 -1
- package/dist/components/ui/button.js +56 -40
- package/dist/components/ui/button.js.map +1 -1
- package/dist/components/ui/button.mjs +10 -4
- package/dist/components/ui/button.mjs.map +1 -1
- package/dist/components/ui/card.js +70 -50
- package/dist/components/ui/card.js.map +1 -1
- package/dist/components/ui/card.mjs +18 -7
- package/dist/components/ui/card.mjs.map +1 -1
- package/dist/components/ui/command.js +139 -97
- package/dist/components/ui/command.js.map +1 -1
- package/dist/components/ui/command.mjs +26 -5
- package/dist/components/ui/command.mjs.map +1 -1
- package/dist/components/ui/dialog.js +90 -69
- package/dist/components/ui/dialog.js.map +1 -1
- package/dist/components/ui/dialog.mjs +21 -4
- package/dist/components/ui/dialog.mjs.map +1 -1
- package/dist/components/ui/label.js +55 -40
- package/dist/components/ui/label.js.map +1 -1
- package/dist/components/ui/label.mjs +9 -4
- package/dist/components/ui/label.mjs.map +1 -1
- package/dist/components/ui/separator.js +54 -39
- package/dist/components/ui/separator.js.map +1 -1
- package/dist/components/ui/separator.mjs +15 -8
- package/dist/components/ui/separator.mjs.map +1 -1
- package/dist/components/ui/textarea.js +50 -35
- package/dist/components/ui/textarea.js.map +1 -1
- package/dist/components/ui/textarea.mjs +13 -7
- package/dist/components/ui/textarea.mjs.map +1 -1
- package/dist/context/index.js +17 -2
- package/dist/context/index.js.map +1 -1
- package/dist/context/index.mjs +1 -2
- package/dist/context/index.mjs.map +1 -1
- package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.js +43 -18
- package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.js.map +1 -1
- package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.mjs +10 -6
- package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.mjs.map +1 -1
- package/dist/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.js +50 -25
- package/dist/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.js.map +1 -1
- package/dist/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.mjs +8 -4
- 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.js +62 -29
- package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.js.map +1 -1
- package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.mjs +9 -5
- package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.mjs.map +1 -1
- package/dist/hooks/index.js +17 -2
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +1 -2
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.js +35 -11
- package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.js.map +1 -1
- package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.mjs +8 -4
- 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.js +38 -14
- package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.js.map +1 -1
- package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.mjs +8 -4
- package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.mjs.map +1 -1
- package/dist/hooks/misc/use-autosize-textarea.js +25 -7
- package/dist/hooks/misc/use-autosize-textarea.js.map +1 -1
- package/dist/hooks/misc/use-autosize-textarea.mjs +7 -3
- package/dist/hooks/misc/use-autosize-textarea.mjs.map +1 -1
- package/dist/index.js +422 -275
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +62 -49
- package/dist/index.mjs.map +1 -1
- package/dist/lib/debouncer.js +27 -5
- package/dist/lib/debouncer.js.map +1 -1
- package/dist/lib/debouncer.mjs +7 -3
- package/dist/lib/debouncer.mjs.map +1 -1
- package/dist/lib/editor-to-text.js +30 -8
- package/dist/lib/editor-to-text.js.map +1 -1
- package/dist/lib/editor-to-text.mjs +7 -3
- package/dist/lib/editor-to-text.mjs.map +1 -1
- package/dist/lib/get-text-around-cursor.js +49 -24
- package/dist/lib/get-text-around-cursor.js.map +1 -1
- package/dist/lib/get-text-around-cursor.mjs +13 -3
- package/dist/lib/get-text-around-cursor.mjs.map +1 -1
- package/dist/lib/retry.js +27 -4
- package/dist/lib/retry.js.map +1 -1
- package/dist/lib/retry.mjs +7 -3
- package/dist/lib/retry.mjs.map +1 -1
- package/dist/lib/slatejs-edits/add-autocompletions.js +29 -7
- package/dist/lib/slatejs-edits/add-autocompletions.js.map +1 -1
- package/dist/lib/slatejs-edits/add-autocompletions.mjs +7 -3
- package/dist/lib/slatejs-edits/add-autocompletions.mjs.map +1 -1
- package/dist/lib/slatejs-edits/clear-autocompletions.js +31 -9
- package/dist/lib/slatejs-edits/clear-autocompletions.js.map +1 -1
- package/dist/lib/slatejs-edits/clear-autocompletions.mjs +7 -3
- package/dist/lib/slatejs-edits/clear-autocompletions.mjs.map +1 -1
- package/dist/lib/slatejs-edits/replace-text.js +32 -10
- package/dist/lib/slatejs-edits/replace-text.js.map +1 -1
- package/dist/lib/slatejs-edits/replace-text.mjs +7 -3
- package/dist/lib/slatejs-edits/replace-text.mjs.map +1 -1
- package/dist/lib/slatejs-edits/with-partial-history.js +42 -19
- package/dist/lib/slatejs-edits/with-partial-history.js.map +1 -1
- package/dist/lib/slatejs-edits/with-partial-history.mjs +9 -3
- package/dist/lib/slatejs-edits/with-partial-history.mjs.map +1 -1
- package/dist/lib/stream-promise-flatten.js +27 -5
- package/dist/lib/stream-promise-flatten.js.map +1 -1
- package/dist/lib/stream-promise-flatten.mjs +7 -3
- package/dist/lib/stream-promise-flatten.mjs.map +1 -1
- package/dist/lib/utils.js +44 -16
- package/dist/lib/utils.js.map +1 -1
- package/dist/lib/utils.mjs +17 -3
- package/dist/lib/utils.mjs.map +1 -1
- package/dist/lib/utils.test.js +1 -2
- package/dist/lib/utils.test.js.map +1 -1
- package/dist/lib/utils.test.mjs +0 -1
- package/dist/lib/utils.test.mjs.map +1 -1
- package/dist/types/autosuggestions-config/autosuggestions-config-user-specified.js +17 -2
- package/dist/types/autosuggestions-config/autosuggestions-config-user-specified.js.map +1 -1
- package/dist/types/autosuggestions-config/autosuggestions-config-user-specified.mjs +0 -2
- package/dist/types/autosuggestions-config/autosuggestions-config-user-specified.mjs.map +1 -1
- package/dist/types/autosuggestions-config/autosuggestions-config.js +35 -9
- package/dist/types/autosuggestions-config/autosuggestions-config.js.map +1 -1
- package/dist/types/autosuggestions-config/autosuggestions-config.mjs +12 -8
- package/dist/types/autosuggestions-config/autosuggestions-config.mjs.map +1 -1
- package/dist/types/autosuggestions-config/editing-api-config.js +31 -6
- package/dist/types/autosuggestions-config/editing-api-config.js.map +1 -1
- package/dist/types/autosuggestions-config/editing-api-config.mjs +11 -3
- package/dist/types/autosuggestions-config/editing-api-config.mjs.map +1 -1
- package/dist/types/autosuggestions-config/index.js +35 -9
- package/dist/types/autosuggestions-config/index.js.map +1 -1
- package/dist/types/autosuggestions-config/index.mjs +13 -9
- package/dist/types/autosuggestions-config/index.mjs.map +1 -1
- package/dist/types/autosuggestions-config/insertions-api-config.js +31 -6
- package/dist/types/autosuggestions-config/insertions-api-config.js.map +1 -1
- package/dist/types/autosuggestions-config/insertions-api-config.mjs +11 -3
- package/dist/types/autosuggestions-config/insertions-api-config.mjs.map +1 -1
- package/dist/types/autosuggestions-config/subtypes/make-system-prompt.js +17 -2
- package/dist/types/autosuggestions-config/subtypes/make-system-prompt.js.map +1 -1
- package/dist/types/autosuggestions-config/subtypes/make-system-prompt.mjs +0 -2
- package/dist/types/autosuggestions-config/subtypes/make-system-prompt.mjs.map +1 -1
- package/dist/types/autosuggestions-config/subtypes/minimal-chat-gpt-message.js +17 -2
- package/dist/types/autosuggestions-config/subtypes/minimal-chat-gpt-message.js.map +1 -1
- package/dist/types/autosuggestions-config/subtypes/minimal-chat-gpt-message.mjs +0 -2
- package/dist/types/autosuggestions-config/subtypes/minimal-chat-gpt-message.mjs.map +1 -1
- package/dist/types/autosuggestions-config/suggestions-api-config.js +31 -6
- package/dist/types/autosuggestions-config/suggestions-api-config.js.map +1 -1
- package/dist/types/autosuggestions-config/suggestions-api-config.mjs +11 -3
- package/dist/types/autosuggestions-config/suggestions-api-config.mjs.map +1 -1
- package/dist/types/base/autosuggestion-state.js +17 -2
- package/dist/types/base/autosuggestion-state.js.map +1 -1
- package/dist/types/base/autosuggestion-state.mjs +0 -2
- package/dist/types/base/autosuggestion-state.mjs.map +1 -1
- package/dist/types/base/autosuggestions-bare-function.js +17 -2
- package/dist/types/base/autosuggestions-bare-function.js.map +1 -1
- package/dist/types/base/autosuggestions-bare-function.mjs +0 -2
- package/dist/types/base/autosuggestions-bare-function.mjs.map +1 -1
- package/dist/types/base/base-autosuggestions-config.js +29 -7
- package/dist/types/base/base-autosuggestions-config.js.map +1 -1
- package/dist/types/base/base-autosuggestions-config.mjs +7 -3
- package/dist/types/base/base-autosuggestions-config.mjs.map +1 -1
- package/dist/types/base/base-copilot-textarea-props.js +17 -2
- package/dist/types/base/base-copilot-textarea-props.js.map +1 -1
- package/dist/types/base/base-copilot-textarea-props.mjs +0 -2
- package/dist/types/base/base-copilot-textarea-props.mjs.map +1 -1
- package/dist/types/base/custom-editor.js +17 -2
- package/dist/types/base/custom-editor.js.map +1 -1
- package/dist/types/base/custom-editor.mjs +0 -2
- package/dist/types/base/custom-editor.mjs.map +1 -1
- package/dist/types/base/editor-autocomplete-state.js +32 -8
- package/dist/types/base/editor-autocomplete-state.js.map +1 -1
- package/dist/types/base/editor-autocomplete-state.mjs +8 -4
- package/dist/types/base/editor-autocomplete-state.mjs.map +1 -1
- package/dist/types/base/index.js +30 -6
- package/dist/types/base/index.js.map +1 -1
- package/dist/types/base/index.mjs +8 -4
- package/dist/types/base/index.mjs.map +1 -1
- package/dist/types/html-copilot-textarea-element.js +17 -2
- package/dist/types/html-copilot-textarea-element.js.map +1 -1
- package/dist/types/html-copilot-textarea-element.mjs +1 -2
- package/dist/types/html-copilot-textarea-element.mjs.map +1 -1
- package/dist/types/index.js +37 -10
- package/dist/types/index.js.map +1 -1
- package/dist/types/index.mjs +18 -11
- package/dist/types/index.mjs.map +1 -1
- package/package.json +8 -8
package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.js
CHANGED
|
@@ -1,35 +1,64 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
10
29
|
|
|
11
30
|
// src/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.ts
|
|
31
|
+
var use_populate_copilot_textarea_ref_exports = {};
|
|
32
|
+
__export(use_populate_copilot_textarea_ref_exports, {
|
|
33
|
+
usePopulateCopilotTextareaRef: () => usePopulateCopilotTextareaRef
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(use_populate_copilot_textarea_ref_exports);
|
|
36
|
+
var import_react = __toESM(require("react"));
|
|
37
|
+
var import_slate_react = require("slate-react");
|
|
38
|
+
|
|
39
|
+
// src/lib/get-text-around-cursor.ts
|
|
40
|
+
var import_slate = require("slate");
|
|
12
41
|
function getFullEditorTextWithNewlines(editor) {
|
|
13
42
|
const fullDocumentRange = {
|
|
14
|
-
anchor:
|
|
15
|
-
focus:
|
|
43
|
+
anchor: import_slate.Editor.start(editor, []),
|
|
44
|
+
focus: import_slate.Editor.end(editor, [])
|
|
16
45
|
};
|
|
17
46
|
return extractTextWithNewlines(editor, fullDocumentRange);
|
|
18
47
|
}
|
|
19
48
|
function extractTextWithNewlines(editor, range) {
|
|
20
49
|
const voids = false;
|
|
21
|
-
const [start, end] =
|
|
50
|
+
const [start, end] = import_slate.Range.edges(range);
|
|
22
51
|
let text = "";
|
|
23
52
|
let lastBlock = null;
|
|
24
|
-
for (const [node, path] of
|
|
53
|
+
for (const [node, path] of import_slate.Editor.nodes(editor, {
|
|
25
54
|
at: range,
|
|
26
|
-
match:
|
|
55
|
+
match: import_slate.Text.isText,
|
|
27
56
|
voids
|
|
28
57
|
})) {
|
|
29
58
|
let t = node.text;
|
|
30
|
-
const [block] =
|
|
59
|
+
const [block] = import_slate.Editor.above(editor, {
|
|
31
60
|
at: path,
|
|
32
|
-
match: (n) =>
|
|
61
|
+
match: (n) => import_slate.Element.isElement(n) && n.type === "paragraph"
|
|
33
62
|
}) || [null];
|
|
34
63
|
if (lastBlock !== block && block) {
|
|
35
64
|
if (lastBlock) {
|
|
@@ -37,25 +66,28 @@ function extractTextWithNewlines(editor, range) {
|
|
|
37
66
|
}
|
|
38
67
|
lastBlock = block;
|
|
39
68
|
}
|
|
40
|
-
if (
|
|
69
|
+
if (import_slate.Path.equals(path, end.path)) {
|
|
41
70
|
t = t.slice(0, end.offset);
|
|
42
71
|
}
|
|
43
|
-
if (
|
|
72
|
+
if (import_slate.Path.equals(path, start.path)) {
|
|
44
73
|
t = t.slice(start.offset);
|
|
45
74
|
}
|
|
46
75
|
text += t;
|
|
47
76
|
}
|
|
48
77
|
return text;
|
|
49
78
|
}
|
|
79
|
+
|
|
80
|
+
// src/lib/slatejs-edits/replace-text.ts
|
|
81
|
+
var import_slate2 = require("slate");
|
|
50
82
|
function replaceEditorText(editor, newText) {
|
|
51
|
-
|
|
83
|
+
import_slate2.Transforms.delete(editor, {
|
|
52
84
|
at: {
|
|
53
|
-
anchor:
|
|
54
|
-
focus:
|
|
85
|
+
anchor: import_slate2.Editor.start(editor, []),
|
|
86
|
+
focus: import_slate2.Editor.end(editor, [])
|
|
55
87
|
}
|
|
56
88
|
});
|
|
57
89
|
if (newText && newText !== "") {
|
|
58
|
-
|
|
90
|
+
import_slate2.Transforms.insertNodes(
|
|
59
91
|
editor,
|
|
60
92
|
[
|
|
61
93
|
{
|
|
@@ -72,7 +104,7 @@ function replaceEditorText(editor, newText) {
|
|
|
72
104
|
|
|
73
105
|
// src/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.ts
|
|
74
106
|
function usePopulateCopilotTextareaRef(editor, ref) {
|
|
75
|
-
|
|
107
|
+
import_react.default.useImperativeHandle(
|
|
76
108
|
ref,
|
|
77
109
|
() => {
|
|
78
110
|
class Combined {
|
|
@@ -125,10 +157,10 @@ function usePopulateCopilotTextareaRef(editor, ref) {
|
|
|
125
157
|
this.editor = editor2;
|
|
126
158
|
}
|
|
127
159
|
focus() {
|
|
128
|
-
|
|
160
|
+
import_slate_react.ReactEditor.focus(this.editor);
|
|
129
161
|
}
|
|
130
162
|
blur() {
|
|
131
|
-
|
|
163
|
+
import_slate_react.ReactEditor.blur(this.editor);
|
|
132
164
|
}
|
|
133
165
|
get value() {
|
|
134
166
|
return getFullEditorTextWithNewlines(this.editor);
|
|
@@ -137,7 +169,7 @@ function usePopulateCopilotTextareaRef(editor, ref) {
|
|
|
137
169
|
replaceEditorText(this.editor, value);
|
|
138
170
|
}
|
|
139
171
|
}
|
|
140
|
-
const editorHtmlElement =
|
|
172
|
+
const editorHtmlElement = import_slate_react.ReactEditor.toDOMNode(editor, editor);
|
|
141
173
|
const customMethods = new CustomMethods(editor);
|
|
142
174
|
const combined = new Combined(customMethods, editorHtmlElement);
|
|
143
175
|
return new Proxy(combined, handler);
|
|
@@ -145,7 +177,8 @@ function usePopulateCopilotTextareaRef(editor, ref) {
|
|
|
145
177
|
[editor]
|
|
146
178
|
);
|
|
147
179
|
}
|
|
148
|
-
|
|
149
|
-
exports
|
|
150
|
-
|
|
180
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
181
|
+
0 && (module.exports = {
|
|
182
|
+
usePopulateCopilotTextareaRef
|
|
183
|
+
});
|
|
151
184
|
//# sourceMappingURL=use-populate-copilot-textarea-ref.js.map
|
package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.ts","../../../src/lib/get-text-around-cursor.ts","../../../src/lib/slatejs-edits/replace-text.ts"],"names":["Editor","customMethods","editorHtmlElement","editor"],"mappings":";AAAA,OAAO,WAAW;AAElB,SAAS,mBAAmB;;;ACF5B,SAAS,QAAc,MAAM,OAAO,MAAM,SAA+B,aAAa;AAuE/E,SAAS,8BAA8B,QAAwB;AACpE,QAAM,oBAA2B;AAAA,IAC/B,QAAQ,OAAO,MAAM,QAAQ,CAAC,CAAC;AAAA,IAC/B,OAAO,OAAO,IAAI,QAAQ,CAAC,CAAC;AAAA,EAC9B;AACA,SAAO,wBAAwB,QAAQ,iBAAiB;AAC1D;AAGO,SAAS,wBAAwB,QAAgB,OAAsB;AAC5E,QAAM,QAAQ;AACd,QAAM,CAAC,OAAO,GAAG,IAAI,MAAM,MAAM,KAAK;AACtC,MAAI,OAAO;AACX,MAAI,YAAyB;AAE7B,aAAW,CAAC,MAAM,IAAI,KAAK,OAAO,MAAM,QAAQ;AAAA,IAC9C,IAAI;AAAA,IACJ,OAAO,KAAK;AAAA,IACZ;AAAA,EACF,CAAC,GAAG;AACF,QAAI,IAAI,KAAK;AAGb,UAAM,CAAC,KAAK,IAAI,OAAO,MAAM,QAAQ;AAAA,MACnC,IAAI;AAAA,MACJ,OAAO,CAAC,MAAM,QAAQ,UAAU,CAAC,KAAK,EAAE,SAAS;AAAA,IACnD,CAAC,KAAK,CAAC,IAAI;AAGX,QAAI,cAAc,SAAS,OAAO;AAEhC,UAAI,WAAW;AACb,gBAAQ;AAAA,MACV;AACA,kBAAY;AAAA,IACd;AAEA,QAAI,KAAK,OAAO,MAAM,IAAI,IAAI,GAAG;AAC/B,UAAI,EAAE,MAAM,GAAG,IAAI,MAAM;AAAA,IAC3B;AAEA,QAAI,KAAK,OAAO,MAAM,MAAM,IAAI,GAAG;AACjC,UAAI,EAAE,MAAM,MAAM,MAAM;AAAA,IAC1B;AAEA,YAAQ;AAAA,EACV;AAEA,SAAO;AACT;;;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C,YAAC,KAAK,kBAA0B,OAAO,IAAI;AAAA,UAC7C,OAAO;AAEL,mBAAO,OAAO,IAAI;AAAA,UACpB;AACA,iBAAO;AAAA,QACT;AAAA,QAEQ,qBAAqB,KAAyC;AACpE,iBAAO,OAAO,KAAK;AAAA,QACrB;AAAA,QAEQ,mBAAmB,KAAuC;AAChE,iBAAO,OAAO,KAAK;AAAA,QACrB;AAAA,MACF;AAEA,YAAM,UAAU;AAAA,QACd,IAAI,QAAa,SAAkD;AACjE,iBAAO,OAAO,IAAI,QAAQ,OAAO;AAAA,QACnC;AAAA,QACA,IAAI,QAAa,SAAkD,OAAY;AAC7E,iBAAO,OAAO,IAAI,QAAQ,SAAS,KAAK;AAAA,QAC1C;AAAA,MACF;AAEA,YAAM,cAAc;AAAA,QAClB,YAAoBC,SAAsB;AAAtB,wBAAAA;AAAA,QAAuB;AAAA,QAE3C,QAAQ;AACN,sBAAY,MAAM,KAAK,MAAM;AAAA,QAC/B;AAAA,QAEA,OAAO;AACL,sBAAY,KAAK,KAAK,MAAM;AAAA,QAC9B;AAAA,QAEA,IAAI,QAAQ;AACV,iBAAO,8BAA8B,KAAK,MAAM;AAAA,QAClD;AAAA,QACA,IAAI,MAAM,OAAe;AACvB,4BAAkB,KAAK,QAAQ,KAAK;AAAA,QACtC;AAAA,MACF;AAEA,YAAM,oBAAoB,YAAY,UAAU,QAAQ,MAAM;AAC9D,YAAM,gBAAgB,IAAI,cAAc,MAAM;AAE9C,YAAM,WAAW,IAAI,SAAS,eAAe,iBAAiB;AAC9D,aAAO,IAAI,MAAM,UAAU,OAAO;AAAA,IACpC;AAAA,IACA,CAAC,MAAM;AAAA,EACT;AACF","sourcesContent":["import React from \"react\";\nimport { Editor } from \"slate\";\nimport { ReactEditor } from \"slate-react\";\nimport { getFullEditorTextWithNewlines } from \"../../lib/get-text-around-cursor\";\nimport { replaceEditorText } from \"../../lib/slatejs-edits/replace-text\";\nimport { HTMLCopilotTextAreaElement } from \"../../types\";\nimport { CustomEditor } from \"../../types/base/custom-editor\";\n\nexport function usePopulateCopilotTextareaRef(\n editor: Editor,\n ref: React.Ref<HTMLCopilotTextAreaElement>,\n) {\n React.useImperativeHandle(\n ref,\n () => {\n class Combined {\n constructor(private customMethods: CustomMethods, private editorHtmlElement: HTMLElement) {}\n\n [key: string]: any;\n\n get(target: any, propKey: string): any {\n if (this.isKeyOfCustomMethods(propKey)) {\n const value = this.customMethods[propKey];\n if (typeof value === \"function\") {\n return value.bind(this.customMethods);\n }\n return value;\n } else if (this.isKeyOfHTMLElement(propKey)) {\n const value = this.editorHtmlElement[propKey];\n if (typeof value === \"function\") {\n return value.bind(this.editorHtmlElement);\n }\n return value;\n }\n }\n\n set(target: any, propKey: string, value: any): boolean {\n if (this.isKeyOfCustomMethods(propKey)) {\n (this.customMethods as any)[propKey] = value;\n } else if (this.isKeyOfHTMLElement(propKey)) {\n (this.editorHtmlElement as any)[propKey] = value;\n } else {\n // Default behavior (optional)\n target[propKey] = value;\n }\n return true;\n }\n\n private isKeyOfCustomMethods(key: string): key is keyof CustomMethods {\n return key in this.customMethods;\n }\n\n private isKeyOfHTMLElement(key: string): key is keyof HTMLElement {\n return key in this.editorHtmlElement;\n }\n }\n\n const handler = {\n get(target: any, propKey: keyof CustomMethods | keyof HTMLElement) {\n return target.get(target, propKey);\n },\n set(target: any, propKey: keyof CustomMethods | keyof HTMLElement, value: any) {\n return target.set(target, propKey, value);\n },\n };\n\n class CustomMethods {\n constructor(private editor: CustomEditor) {}\n\n focus() {\n ReactEditor.focus(this.editor);\n }\n\n blur() {\n ReactEditor.blur(this.editor);\n }\n\n get value() {\n return getFullEditorTextWithNewlines(this.editor);\n }\n set value(value: string) {\n replaceEditorText(this.editor, value);\n }\n }\n\n const editorHtmlElement = ReactEditor.toDOMNode(editor, editor);\n const customMethods = new CustomMethods(editor);\n\n const combined = new Combined(customMethods, editorHtmlElement);\n return new Proxy(combined, handler);\n },\n [editor],\n );\n}\n","import { Editor, Node, Path, Range, Text, Element, BasePoint, BaseRange, Point } 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(editor: Editor): 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","import { Editor, Transforms } from \"slate\";\n\nexport function replaceEditorText(editor: Editor, newText: string) {\n // clear all previous text\n Transforms.delete(editor, {\n at: {\n anchor: Editor.start(editor, []),\n focus: Editor.end(editor, []),\n },\n });\n\n // insert new text\n if (newText && newText !== \"\") {\n // don't insert empty text - results in strange visual behavior\n Transforms.insertNodes(\n editor,\n [\n {\n type: \"paragraph\",\n children: [{ text: newText }],\n },\n ],\n {\n at: [0],\n },\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.ts","../../../src/lib/get-text-around-cursor.ts","../../../src/lib/slatejs-edits/replace-text.ts"],"sourcesContent":["import React from \"react\";\nimport { Editor } from \"slate\";\nimport { ReactEditor } from \"slate-react\";\nimport { getFullEditorTextWithNewlines } from \"../../lib/get-text-around-cursor\";\nimport { replaceEditorText } from \"../../lib/slatejs-edits/replace-text\";\nimport { HTMLCopilotTextAreaElement } from \"../../types\";\nimport { CustomEditor } from \"../../types/base/custom-editor\";\n\nexport function usePopulateCopilotTextareaRef(\n editor: Editor,\n ref: React.Ref<HTMLCopilotTextAreaElement>,\n) {\n React.useImperativeHandle(\n ref,\n () => {\n class Combined {\n constructor(private customMethods: CustomMethods, private editorHtmlElement: HTMLElement) {}\n\n [key: string]: any;\n\n get(target: any, propKey: string): any {\n if (this.isKeyOfCustomMethods(propKey)) {\n const value = this.customMethods[propKey];\n if (typeof value === \"function\") {\n return value.bind(this.customMethods);\n }\n return value;\n } else if (this.isKeyOfHTMLElement(propKey)) {\n const value = this.editorHtmlElement[propKey];\n if (typeof value === \"function\") {\n return value.bind(this.editorHtmlElement);\n }\n return value;\n }\n }\n\n set(target: any, propKey: string, value: any): boolean {\n if (this.isKeyOfCustomMethods(propKey)) {\n (this.customMethods as any)[propKey] = value;\n } else if (this.isKeyOfHTMLElement(propKey)) {\n (this.editorHtmlElement as any)[propKey] = value;\n } else {\n // Default behavior (optional)\n target[propKey] = value;\n }\n return true;\n }\n\n private isKeyOfCustomMethods(key: string): key is keyof CustomMethods {\n return key in this.customMethods;\n }\n\n private isKeyOfHTMLElement(key: string): key is keyof HTMLElement {\n return key in this.editorHtmlElement;\n }\n }\n\n const handler = {\n get(target: any, propKey: keyof CustomMethods | keyof HTMLElement) {\n return target.get(target, propKey);\n },\n set(target: any, propKey: keyof CustomMethods | keyof HTMLElement, value: any) {\n return target.set(target, propKey, value);\n },\n };\n\n class CustomMethods {\n constructor(private editor: CustomEditor) {}\n\n focus() {\n ReactEditor.focus(this.editor);\n }\n\n blur() {\n ReactEditor.blur(this.editor);\n }\n\n get value() {\n return getFullEditorTextWithNewlines(this.editor);\n }\n set value(value: string) {\n replaceEditorText(this.editor, value);\n }\n }\n\n const editorHtmlElement = ReactEditor.toDOMNode(editor, editor);\n const customMethods = new CustomMethods(editor);\n\n const combined = new Combined(customMethods, editorHtmlElement);\n return new Proxy(combined, handler);\n },\n [editor],\n );\n}\n","import { Editor, Node, Path, Range, Text, Element, BasePoint, BaseRange, Point } 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(editor: Editor): 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","import { Editor, Transforms } from \"slate\";\n\nexport function replaceEditorText(editor: Editor, newText: string) {\n // clear all previous text\n Transforms.delete(editor, {\n at: {\n anchor: Editor.start(editor, []),\n focus: Editor.end(editor, []),\n },\n });\n\n // insert new text\n if (newText && newText !== \"\") {\n // don't insert empty text - results in strange visual behavior\n Transforms.insertNodes(\n editor,\n [\n {\n type: \"paragraph\",\n children: [{ text: newText }],\n },\n ],\n {\n at: [0],\n },\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAElB,yBAA4B;;;ACF5B,mBAAsF;AAuE/E,SAAS,8BAA8B,QAAwB;AACpE,QAAM,oBAA2B;AAAA,IAC/B,QAAQ,oBAAO,MAAM,QAAQ,CAAC,CAAC;AAAA,IAC/B,OAAO,oBAAO,IAAI,QAAQ,CAAC,CAAC;AAAA,EAC9B;AACA,SAAO,wBAAwB,QAAQ,iBAAiB;AAC1D;AAGO,SAAS,wBAAwB,QAAgB,OAAsB;AAC5E,QAAM,QAAQ;A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,YAAM,cAAc;AAAA,QAClB,YAAoBC,SAAsB;AAAtB,wBAAAA;AAAA,QAAuB;AAAA,QAE3C,QAAQ;AACN,yCAAY,MAAM,KAAK,MAAM;AAAA,QAC/B;AAAA,QAEA,OAAO;AACL,yCAAY,KAAK,KAAK,MAAM;AAAA,QAC9B;AAAA,QAEA,IAAI,QAAQ;AACV,iBAAO,8BAA8B,KAAK,MAAM;AAAA,QAClD;AAAA,QACA,IAAI,MAAM,OAAe;AACvB,4BAAkB,KAAK,QAAQ,KAAK;AAAA,QACtC;AAAA,MACF;AAEA,YAAM,oBAAoB,+BAAY,UAAU,QAAQ,MAAM;AAC9D,YAAM,gBAAgB,IAAI,cAAc,MAAM;AAE9C,YAAM,WAAW,IAAI,SAAS,eAAe,iBAAiB;AAC9D,aAAO,IAAI,MAAM,UAAU,OAAO;AAAA,IACpC;AAAA,IACA,CAAC,MAAM;AAAA,EACT;AACF;","names":["import_slate","React","customMethods","editorHtmlElement","editor"]}
|
package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.mjs
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
|
|
1
|
+
import {
|
|
2
|
+
usePopulateCopilotTextareaRef
|
|
3
|
+
} from "../../chunk-VPEH6V7T.mjs";
|
|
4
|
+
import "../../chunk-5UNJXFUO.mjs";
|
|
5
|
+
import "../../chunk-ECR45NSD.mjs";
|
|
6
|
+
import "../../chunk-MRXNTQOX.mjs";
|
|
7
|
+
export {
|
|
8
|
+
usePopulateCopilotTextareaRef
|
|
9
|
+
};
|
|
6
10
|
//# sourceMappingURL=use-populate-copilot-textarea-ref.mjs.map
|
package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/hooks/index.js
CHANGED
|
@@ -1,4 +1,19 @@
|
|
|
1
|
-
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
2
15
|
|
|
3
|
-
|
|
16
|
+
// src/hooks/index.ts
|
|
17
|
+
var hooks_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(hooks_exports);
|
|
4
19
|
//# sourceMappingURL=index.js.map
|
package/dist/hooks/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/index.ts"],"sourcesContent":["export {};\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
package/dist/hooks/index.mjs
CHANGED
package/dist/hooks/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var reactCore = require('@copilotkit/react-core');
|
|
4
|
-
var react = require('react');
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
6
2
|
var __defProp = Object.defineProperty;
|
|
7
3
|
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
8
5
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
9
7
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
10
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
9
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
@@ -22,6 +20,19 @@ var __spreadValues = (a, b) => {
|
|
|
22
20
|
return a;
|
|
23
21
|
};
|
|
24
22
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
23
|
+
var __export = (target, all) => {
|
|
24
|
+
for (var name in all)
|
|
25
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
26
|
+
};
|
|
27
|
+
var __copyProps = (to, from, except, desc) => {
|
|
28
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
29
|
+
for (let key of __getOwnPropNames(from))
|
|
30
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
31
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
32
|
+
}
|
|
33
|
+
return to;
|
|
34
|
+
};
|
|
35
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
36
|
var __async = (__this, __arguments, generator) => {
|
|
26
37
|
return new Promise((resolve, reject) => {
|
|
27
38
|
var fulfilled = (value) => {
|
|
@@ -43,6 +54,15 @@ var __async = (__this, __arguments, generator) => {
|
|
|
43
54
|
});
|
|
44
55
|
};
|
|
45
56
|
|
|
57
|
+
// src/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.tsx
|
|
58
|
+
var use_make_standard_autosuggestions_function_exports = {};
|
|
59
|
+
__export(use_make_standard_autosuggestions_function_exports, {
|
|
60
|
+
useMakeStandardAutosuggestionFunction: () => useMakeStandardAutosuggestionFunction
|
|
61
|
+
});
|
|
62
|
+
module.exports = __toCommonJS(use_make_standard_autosuggestions_function_exports);
|
|
63
|
+
var import_react_core = require("@copilotkit/react-core");
|
|
64
|
+
var import_react = require("react");
|
|
65
|
+
|
|
46
66
|
// src/lib/retry.tsx
|
|
47
67
|
function retry(fn, retriesLeft = 2, interval = 200, backoff = 1.5) {
|
|
48
68
|
return new Promise((resolve, reject) => {
|
|
@@ -57,9 +77,12 @@ function retry(fn, retriesLeft = 2, interval = 200, backoff = 1.5) {
|
|
|
57
77
|
});
|
|
58
78
|
});
|
|
59
79
|
}
|
|
80
|
+
|
|
81
|
+
// src/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.tsx
|
|
82
|
+
var import_react_core2 = require("@copilotkit/react-core");
|
|
60
83
|
function useMakeStandardAutosuggestionFunction(textareaPurpose, contextCategories, apiConfig) {
|
|
61
|
-
const { getContextString, copilotApiConfig } =
|
|
62
|
-
return
|
|
84
|
+
const { getContextString, copilotApiConfig } = (0, import_react.useContext)(import_react_core.CopilotContext);
|
|
85
|
+
return (0, import_react.useCallback)(
|
|
63
86
|
(editorState, abortSignal) => __async(this, null, function* () {
|
|
64
87
|
const res = yield retry(() => __async(this, null, function* () {
|
|
65
88
|
const messages = [
|
|
@@ -82,7 +105,7 @@ function useMakeStandardAutosuggestionFunction(textareaPurpose, contextCategorie
|
|
|
82
105
|
content: editorState.textBeforeCursor
|
|
83
106
|
}
|
|
84
107
|
];
|
|
85
|
-
const response = yield
|
|
108
|
+
const response = yield (0, import_react_core2.fetchAndDecodeChatCompletionAsText)(__spreadProps(__spreadValues({
|
|
86
109
|
messages
|
|
87
110
|
}, apiConfig.forwardedParams), {
|
|
88
111
|
copilotConfig: copilotApiConfig,
|
|
@@ -107,7 +130,8 @@ function useMakeStandardAutosuggestionFunction(textareaPurpose, contextCategorie
|
|
|
107
130
|
[apiConfig, getContextString, contextCategories, textareaPurpose]
|
|
108
131
|
);
|
|
109
132
|
}
|
|
110
|
-
|
|
111
|
-
exports
|
|
112
|
-
|
|
133
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
134
|
+
0 && (module.exports = {
|
|
135
|
+
useMakeStandardAutosuggestionFunction
|
|
136
|
+
});
|
|
113
137
|
//# sourceMappingURL=use-make-standard-autosuggestions-function.js.map
|
package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.tsx","../../../src/lib/retry.tsx"],"
|
|
1
|
+
{"version":3,"sources":["../../../src/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.tsx","../../../src/lib/retry.tsx"],"sourcesContent":["import { Message } from \"@copilotkit/shared\";\nimport { CopilotContext } from \"@copilotkit/react-core\";\nimport { useCallback, useContext } from \"react\";\nimport { AutosuggestionsBareFunction, MinimalChatGPTMessage } from \"../../types\";\nimport { retry } from \"../../lib/retry\";\nimport { InsertionEditorState } from \"../../types/base/autosuggestions-bare-function\";\nimport { SuggestionsApiConfig } from \"../../types/autosuggestions-config/suggestions-api-config\";\nimport { fetchAndDecodeChatCompletionAsText } from \"@copilotkit/react-core\";\n\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[],\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 response = await fetchAndDecodeChatCompletionAsText({\n messages: messages as Message[],\n ...apiConfig.forwardedParams,\n copilotConfig: copilotApiConfig,\n signal: abortSignal,\n });\n\n if (!response.events) {\n throw new Error(\"Failed to fetch chat completion\");\n }\n\n const reader = response.events.getReader();\n\n let result = \"\";\n while (!abortSignal.aborted) {\n const { done, value } = await reader.read();\n if (done) {\n break;\n }\n result += value;\n }\n return result;\n });\n\n return res;\n },\n [apiConfig, getContextString, contextCategories, textareaPurpose],\n );\n}\n","export function retry<T>(\n fn: () => Promise<T>,\n retriesLeft: number = 2,\n interval: number = 200,\n backoff: number = 1.5,\n): Promise<T> {\n return new Promise((resolve, reject) => {\n fn()\n .then(resolve)\n .catch((error) => {\n if (retriesLeft === 1) {\n reject(error);\n return;\n }\n\n setTimeout(() => {\n retry(fn, retriesLeft - 1, interval * backoff, backoff)\n .then(resolve)\n .catch(reject);\n }, interval);\n });\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,wBAA+B;AAC/B,mBAAwC;;;ACFjC,SAAS,MACd,IACA,cAAsB,GACtB,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C,cAAI,MAAM;AACR;AAAA,UACF;AACA,oBAAU;AAAA,QACZ;AACA,eAAO;AAAA,MACT,EAAC;AAED,aAAO;AAAA,IACT;AAAA,IACA,CAAC,WAAW,kBAAkB,mBAAmB,eAAe;AAAA,EAClE;AACF;","names":["import_react_core"]}
|
package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.mjs
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import {
|
|
2
|
+
useMakeStandardAutosuggestionFunction
|
|
3
|
+
} from "../../chunk-RT4UTBH3.mjs";
|
|
4
|
+
import "../../chunk-KNQIEOFP.mjs";
|
|
5
|
+
import "../../chunk-MRXNTQOX.mjs";
|
|
6
|
+
export {
|
|
7
|
+
useMakeStandardAutosuggestionFunction
|
|
8
|
+
};
|
|
5
9
|
//# sourceMappingURL=use-make-standard-autosuggestions-function.mjs.map
|
package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var reactCore = require('@copilotkit/react-core');
|
|
4
|
-
var react = require('react');
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
6
2
|
var __defProp = Object.defineProperty;
|
|
7
3
|
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
8
5
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
9
7
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
10
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
9
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
@@ -22,6 +20,19 @@ var __spreadValues = (a, b) => {
|
|
|
22
20
|
return a;
|
|
23
21
|
};
|
|
24
22
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
23
|
+
var __export = (target, all) => {
|
|
24
|
+
for (var name in all)
|
|
25
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
26
|
+
};
|
|
27
|
+
var __copyProps = (to, from, except, desc) => {
|
|
28
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
29
|
+
for (let key of __getOwnPropNames(from))
|
|
30
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
31
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
32
|
+
}
|
|
33
|
+
return to;
|
|
34
|
+
};
|
|
35
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
36
|
var __async = (__this, __arguments, generator) => {
|
|
26
37
|
return new Promise((resolve, reject) => {
|
|
27
38
|
var fulfilled = (value) => {
|
|
@@ -43,6 +54,15 @@ var __async = (__this, __arguments, generator) => {
|
|
|
43
54
|
});
|
|
44
55
|
};
|
|
45
56
|
|
|
57
|
+
// src/hooks/make-autosuggestions-function/use-make-standard-insertion-function.tsx
|
|
58
|
+
var use_make_standard_insertion_function_exports = {};
|
|
59
|
+
__export(use_make_standard_insertion_function_exports, {
|
|
60
|
+
useMakeStandardInsertionOrEditingFunction: () => useMakeStandardInsertionOrEditingFunction
|
|
61
|
+
});
|
|
62
|
+
module.exports = __toCommonJS(use_make_standard_insertion_function_exports);
|
|
63
|
+
var import_react_core = require("@copilotkit/react-core");
|
|
64
|
+
var import_react = require("react");
|
|
65
|
+
|
|
46
66
|
// src/lib/retry.tsx
|
|
47
67
|
function retry(fn, retriesLeft = 2, interval = 200, backoff = 1.5) {
|
|
48
68
|
return new Promise((resolve, reject) => {
|
|
@@ -57,9 +77,12 @@ function retry(fn, retriesLeft = 2, interval = 200, backoff = 1.5) {
|
|
|
57
77
|
});
|
|
58
78
|
});
|
|
59
79
|
}
|
|
80
|
+
|
|
81
|
+
// src/hooks/make-autosuggestions-function/use-make-standard-insertion-function.tsx
|
|
82
|
+
var import_react_core2 = require("@copilotkit/react-core");
|
|
60
83
|
function useMakeStandardInsertionOrEditingFunction(textareaPurpose, contextCategories, insertionApiConfig, editingApiConfig) {
|
|
61
|
-
const { getContextString, copilotApiConfig } =
|
|
62
|
-
const insertionFunction =
|
|
84
|
+
const { getContextString, copilotApiConfig } = (0, import_react.useContext)(import_react_core.CopilotContext);
|
|
85
|
+
const insertionFunction = (0, import_react.useCallback)(
|
|
63
86
|
(editorState, insertionPrompt, documents, abortSignal) => __async(this, null, function* () {
|
|
64
87
|
const res = yield retry(() => __async(this, null, function* () {
|
|
65
88
|
const messages = [
|
|
@@ -87,7 +110,7 @@ function useMakeStandardInsertionOrEditingFunction(textareaPurpose, contextCateg
|
|
|
87
110
|
content: insertionPrompt
|
|
88
111
|
}
|
|
89
112
|
];
|
|
90
|
-
const stream = yield
|
|
113
|
+
const stream = yield (0, import_react_core2.fetchAndDecodeChatCompletionAsText)(__spreadProps(__spreadValues({
|
|
91
114
|
messages
|
|
92
115
|
}, insertionApiConfig.forwardedParams), {
|
|
93
116
|
copilotConfig: copilotApiConfig,
|
|
@@ -99,7 +122,7 @@ function useMakeStandardInsertionOrEditingFunction(textareaPurpose, contextCateg
|
|
|
99
122
|
}),
|
|
100
123
|
[insertionApiConfig, getContextString, contextCategories, textareaPurpose]
|
|
101
124
|
);
|
|
102
|
-
const editingFunction =
|
|
125
|
+
const editingFunction = (0, import_react.useCallback)(
|
|
103
126
|
(editorState, editingPrompt, documents, abortSignal) => __async(this, null, function* () {
|
|
104
127
|
const res = yield retry(() => __async(this, null, function* () {
|
|
105
128
|
const messages = [
|
|
@@ -132,7 +155,7 @@ function useMakeStandardInsertionOrEditingFunction(textareaPurpose, contextCateg
|
|
|
132
155
|
content: editingPrompt
|
|
133
156
|
}
|
|
134
157
|
];
|
|
135
|
-
const stream = yield
|
|
158
|
+
const stream = yield (0, import_react_core2.fetchAndDecodeChatCompletionAsText)(__spreadProps(__spreadValues({
|
|
136
159
|
messages
|
|
137
160
|
}, editingApiConfig.forwardedParams), {
|
|
138
161
|
copilotConfig: copilotApiConfig,
|
|
@@ -144,7 +167,7 @@ function useMakeStandardInsertionOrEditingFunction(textareaPurpose, contextCateg
|
|
|
144
167
|
}),
|
|
145
168
|
[editingApiConfig, getContextString, contextCategories, textareaPurpose]
|
|
146
169
|
);
|
|
147
|
-
const insertionOrEditingFunction =
|
|
170
|
+
const insertionOrEditingFunction = (0, import_react.useCallback)(
|
|
148
171
|
(editorState, insertionPrompt, documents, abortSignal) => __async(this, null, function* () {
|
|
149
172
|
if (editorState.selectedText === "") {
|
|
150
173
|
return yield insertionFunction(editorState, insertionPrompt, documents, abortSignal);
|
|
@@ -156,7 +179,8 @@ function useMakeStandardInsertionOrEditingFunction(textareaPurpose, contextCateg
|
|
|
156
179
|
);
|
|
157
180
|
return insertionOrEditingFunction;
|
|
158
181
|
}
|
|
159
|
-
|
|
160
|
-
exports
|
|
161
|
-
|
|
182
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
183
|
+
0 && (module.exports = {
|
|
184
|
+
useMakeStandardInsertionOrEditingFunction
|
|
185
|
+
});
|
|
162
186
|
//# sourceMappingURL=use-make-standard-insertion-function.js.map
|
package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/hooks/make-autosuggestions-function/use-make-standard-insertion-function.tsx","../../../src/lib/retry.tsx"],"
|
|
1
|
+
{"version":3,"sources":["../../../src/hooks/make-autosuggestions-function/use-make-standard-insertion-function.tsx","../../../src/lib/retry.tsx"],"sourcesContent":["import { Message } from \"@copilotkit/shared\";\nimport { CopilotContext } from \"@copilotkit/react-core\";\nimport { useCallback, useContext } from \"react\";\nimport { MinimalChatGPTMessage } from \"../../types\";\nimport { retry } from \"../../lib/retry\";\nimport {\n EditingEditorState,\n Generator_InsertionOrEditingSuggestion,\n InsertionEditorApiConfig,\n InsertionEditorState,\n} from \"../../types/base/autosuggestions-bare-function\";\nimport { InsertionsApiConfig } from \"../../types/autosuggestions-config/insertions-api-config\";\nimport { EditingApiConfig } from \"../../types/autosuggestions-config/editing-api-config\";\nimport { DocumentPointer } from \"@copilotkit/react-core\";\nimport { fetchAndDecodeChatCompletionAsText } from \"@copilotkit/react-core\";\n\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 useMakeStandardInsertionOrEditingFunction(\n textareaPurpose: string,\n contextCategories: string[],\n insertionApiConfig: InsertionsApiConfig,\n editingApiConfig: EditingApiConfig,\n): Generator_InsertionOrEditingSuggestion {\n const { getContextString, copilotApiConfig } = useContext(CopilotContext);\n\n const insertionFunction = useCallback(\n async (\n editorState: EditingEditorState,\n insertionPrompt: string,\n documents: DocumentPointer[],\n abortSignal: AbortSignal,\n ) => {\n const res = await retry(async () => {\n const messages: MinimalChatGPTMessage[] = [\n {\n role: \"system\",\n content: insertionApiConfig.makeSystemPrompt(\n textareaPurpose,\n getContextString(documents, contextCategories),\n ),\n },\n ...insertionApiConfig.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 role: \"user\",\n name: \"InsertionPrompt\",\n content: insertionPrompt,\n },\n ];\n\n const stream = await fetchAndDecodeChatCompletionAsText({\n messages: messages as Message[],\n ...insertionApiConfig.forwardedParams,\n copilotConfig: copilotApiConfig,\n signal: abortSignal,\n });\n return stream.events!;\n });\n\n return res;\n },\n [insertionApiConfig, getContextString, contextCategories, textareaPurpose],\n );\n\n const editingFunction = useCallback(\n async (\n editorState: EditingEditorState,\n editingPrompt: string,\n documents: DocumentPointer[],\n abortSignal: AbortSignal,\n ) => {\n const res = await retry(async () => {\n const messages: MinimalChatGPTMessage[] = [\n {\n role: \"system\",\n content: editingApiConfig.makeSystemPrompt(\n textareaPurpose,\n getContextString(documents, contextCategories),\n ),\n },\n ...editingApiConfig.fewShotMessages,\n {\n role: \"user\",\n name: \"TextBeforeCursor\",\n content: editorState.textBeforeCursor,\n },\n {\n role: \"user\",\n name: \"TextToEdit\",\n content: editorState.selectedText,\n },\n {\n role: \"user\",\n name: \"TextAfterCursor\",\n content: editorState.textAfterCursor,\n },\n {\n role: \"user\",\n name: \"EditingPrompt\",\n content: editingPrompt,\n },\n ];\n\n const stream = await fetchAndDecodeChatCompletionAsText({\n messages: messages as Message[],\n ...editingApiConfig.forwardedParams,\n copilotConfig: copilotApiConfig,\n signal: abortSignal,\n });\n return stream.events!;\n });\n\n return res;\n },\n [editingApiConfig, getContextString, contextCategories, textareaPurpose],\n );\n\n const insertionOrEditingFunction = useCallback(\n async (\n editorState: EditingEditorState,\n insertionPrompt: string,\n documents: DocumentPointer[],\n abortSignal: AbortSignal,\n ) => {\n if (editorState.selectedText === \"\") {\n return await insertionFunction(editorState, insertionPrompt, documents, abortSignal);\n } else {\n return await editingFunction(editorState, insertionPrompt, documents, abortSignal);\n }\n },\n [insertionFunction, editingFunction],\n );\n\n return insertionOrEditingFunction;\n}\n","export function retry<T>(\n fn: () => Promise<T>,\n retriesLeft: number = 2,\n interval: number = 200,\n backoff: number = 1.5,\n): Promise<T> {\n return new Promise((resolve, reject) => {\n fn()\n .then(resolve)\n .catch((error) => {\n if (retriesLeft === 1) {\n reject(error);\n return;\n }\n\n setTimeout(() => {\n retry(fn, retriesLeft - 1, interval * backoff, backoff)\n .then(resolve)\n .catch(reject);\n }, interval);\n });\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,wBAA+B;AAC/B,mBAAwC;;;ACFjC,SAAS,MACd,IACA,cAAsB,GACtB,WAAmB,KACnB,UAAkB,KACN;AACZ,SAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtC,OAAG,EACA,KAAK,OAAO,EACZ,MAAM,CAAC,UAAU;AAChB,UAAI,gBAAgB,GAAG;AACrB,eAAO,KAAK;AACZ;AAAA,MACF;AAEA,iBAAW,MAAM;AACf,cAAM,IAAI,cAAc,GAAG,WAAW,SAAS,OAAO,EACnD,KAAK,OAAO,EACZ,MAAM,MAAM;AAAA,MACjB,GAAG,QAAQ;AAAA,IACb,CAAC;AAAA,EACL,CAAC;AACH;;;ADRA,IAAAA,qBAAmD;AAe5C,SAAS,0CACd,iBACA,mBACA,oBACA,kBACwC;AACxC,QAAM,EAAE,kBAAkB,iBAAiB,QAAI,yBAAW,gCAAc;AAExE,QAAM,wBAAoB;AAAA,IACxB,CACE,aACA,iBACA,WACA,gBACG;AACH,YAAM,MAAM,MAAM,MAAM,MAAY;AAClC,cAAM,WAAoC;AAAA,UACxC;AAAA,YACE,MAAM;AAAA,YACN,SAAS,mBAAmB;AAAA,cAC1B;AAAA,cACA,iBAAiB,WAAW,iBAAiB;AAAA,YAC/C;AAAA,UACF;AAAA,UACA,GAAG,mBAAmB;AAAA,UACtB;AAAA,YACE,MAAM;AAAA,YACN,MAAM;AAAA,YACN,SAAS,YAAY;AAAA,UACvB;AAAA,UACA;AA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iCAA6B;AAAA,IACjC,CACE,aACA,iBACA,WACA,gBACG;AACH,UAAI,YAAY,iBAAiB,IAAI;AACnC,eAAO,MAAM,kBAAkB,aAAa,iBAAiB,WAAW,WAAW;AAAA,MACrF,OAAO;AACL,eAAO,MAAM,gBAAgB,aAAa,iBAAiB,WAAW,WAAW;AAAA,MACnF;AAAA,IACF;AAAA,IACA,CAAC,mBAAmB,eAAe;AAAA,EACrC;AAEA,SAAO;AACT;","names":["import_react_core"]}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import {
|
|
2
|
+
useMakeStandardInsertionOrEditingFunction
|
|
3
|
+
} from "../../chunk-QCPS6IYI.mjs";
|
|
4
|
+
import "../../chunk-KNQIEOFP.mjs";
|
|
5
|
+
import "../../chunk-MRXNTQOX.mjs";
|
|
6
|
+
export {
|
|
7
|
+
useMakeStandardInsertionOrEditingFunction
|
|
8
|
+
};
|
|
5
9
|
//# sourceMappingURL=use-make-standard-insertion-function.mjs.map
|
package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,10 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
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);
|
|
4
19
|
|
|
5
20
|
// src/hooks/misc/use-autosize-textarea.tsx
|
|
21
|
+
var use_autosize_textarea_exports = {};
|
|
22
|
+
__export(use_autosize_textarea_exports, {
|
|
23
|
+
default: () => use_autosize_textarea_default
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(use_autosize_textarea_exports);
|
|
26
|
+
var import_react = require("react");
|
|
6
27
|
var useAutosizeTextArea = (textAreaRef, value) => {
|
|
7
|
-
|
|
28
|
+
(0, import_react.useEffect)(() => {
|
|
8
29
|
if (textAreaRef.current !== null) {
|
|
9
30
|
textAreaRef.current.style.height = "0px";
|
|
10
31
|
const scrollHeight = textAreaRef.current.scrollHeight;
|
|
@@ -13,7 +34,4 @@ var useAutosizeTextArea = (textAreaRef, value) => {
|
|
|
13
34
|
}, [textAreaRef, value]);
|
|
14
35
|
};
|
|
15
36
|
var use_autosize_textarea_default = useAutosizeTextArea;
|
|
16
|
-
|
|
17
|
-
module.exports = use_autosize_textarea_default;
|
|
18
|
-
//# sourceMappingURL=out.js.map
|
|
19
37
|
//# sourceMappingURL=use-autosize-textarea.js.map
|