@mieweb/ui 0.9.0 → 0.10.0-dev.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/MIGRATION.md +112 -0
- package/agent/mieweb-ui.instructions.md +2 -1
- package/dist/{Animated-Cs-naa2g.d.cts → Animated-XmH6k8pZ.d.cts} +16 -3
- package/dist/{Animated-Cs-naa2g.d.ts → Animated-XmH6k8pZ.d.ts} +16 -3
- package/dist/{CsvBlock-QXXZ7ZUM.cjs → CsvBlock-CVYA3HYS.cjs} +3 -2
- package/dist/{CsvBlock-QXXZ7ZUM.cjs.map → CsvBlock-CVYA3HYS.cjs.map} +1 -1
- package/dist/{CsvBlock-D7Z6ZCRP.js → CsvBlock-SM4NKSHA.js} +3 -2
- package/dist/{CsvBlock-D7Z6ZCRP.js.map → CsvBlock-SM4NKSHA.js.map} +1 -1
- package/dist/{HtmlPreviewBlock-F5VDM2EN.js → HtmlPreviewBlock-FAMF4W24.js} +3 -2
- package/dist/{HtmlPreviewBlock-F5VDM2EN.js.map → HtmlPreviewBlock-FAMF4W24.js.map} +1 -1
- package/dist/{HtmlPreviewBlock-AADG7MVB.cjs → HtmlPreviewBlock-JF454L2L.cjs} +3 -2
- package/dist/{HtmlPreviewBlock-AADG7MVB.cjs.map → HtmlPreviewBlock-JF454L2L.cjs.map} +1 -1
- package/dist/{MermaidBlock-6PLITRBZ.js → MermaidBlock-7V5G4K5A.js} +3 -2
- package/dist/{MermaidBlock-6PLITRBZ.js.map → MermaidBlock-7V5G4K5A.js.map} +1 -1
- package/dist/{MermaidBlock-TQ2O5CLV.cjs → MermaidBlock-FR5SQX4Q.cjs} +3 -2
- package/dist/{MermaidBlock-TQ2O5CLV.cjs.map → MermaidBlock-FR5SQX4Q.cjs.map} +1 -1
- package/dist/{SurveyBlock-W5PSQ62F.js → SurveyBlock-6K2POV7S.js} +3 -2
- package/dist/{SurveyBlock-W5PSQ62F.js.map → SurveyBlock-6K2POV7S.js.map} +1 -1
- package/dist/{SurveyBlock-OYL3VNU5.cjs → SurveyBlock-MCJVWR7H.cjs} +3 -2
- package/dist/{SurveyBlock-OYL3VNU5.cjs.map → SurveyBlock-MCJVWR7H.cjs.map} +1 -1
- package/dist/ag-grid.cjs +1 -0
- package/dist/ag-grid.cjs.map +1 -1
- package/dist/ag-grid.js +1 -0
- package/dist/ag-grid.js.map +1 -1
- package/dist/brands/bluehive.cjs +1 -0
- package/dist/brands/bluehive.js +1 -0
- package/dist/brands/ccme.cjs +1 -0
- package/dist/brands/ccme.js +1 -0
- package/dist/brands/index.cjs +3 -2
- package/dist/brands/index.js +2 -1
- package/dist/brands/ozwell.cjs +1 -0
- package/dist/brands/ozwell.js +1 -0
- package/dist/brands/types.cjs +1 -0
- package/dist/brands/types.js +1 -0
- package/dist/{chunk-XUVEF2RQ.js → chunk-24SEAAOH.js} +2 -2
- package/dist/{chunk-XUVEF2RQ.js.map → chunk-24SEAAOH.js.map} +1 -1
- package/dist/{chunk-IUDY6S7I.cjs → chunk-37UZHCLM.cjs} +35 -14
- package/dist/chunk-37UZHCLM.cjs.map +1 -0
- package/dist/{chunk-ODYQYLO2.js → chunk-7KWNY3HG.js} +9 -5
- package/dist/chunk-7KWNY3HG.js.map +1 -0
- package/dist/{chunk-L52N6BEN.cjs → chunk-AUOTJQGO.cjs} +7 -7
- package/dist/{chunk-L52N6BEN.cjs.map → chunk-AUOTJQGO.cjs.map} +1 -1
- package/dist/{chunk-O7XHHTTP.cjs → chunk-AZP3DDBT.cjs} +6 -6
- package/dist/{chunk-O7XHHTTP.cjs.map → chunk-AZP3DDBT.cjs.map} +1 -1
- package/dist/chunk-C6CTTLH2.js +44645 -0
- package/dist/chunk-C6CTTLH2.js.map +1 -0
- package/dist/{chunk-6XDPJWSC.cjs → chunk-E3KC2XLN.cjs} +34 -30
- package/dist/chunk-E3KC2XLN.cjs.map +1 -0
- package/dist/chunk-EUAMEVVI.cjs +41 -0
- package/dist/chunk-EUAMEVVI.cjs.map +1 -0
- package/dist/{chunk-DFYMIRMW.js → chunk-IGNWT6RP.js} +7 -2
- package/dist/chunk-IGNWT6RP.js.map +1 -0
- package/dist/{chunk-XEEVDZDK.cjs → chunk-IGSIWNX3.cjs} +7 -2
- package/dist/chunk-IGSIWNX3.cjs.map +1 -0
- package/dist/chunk-IIFQ6BSJ.js +1888 -0
- package/dist/chunk-IIFQ6BSJ.js.map +1 -0
- package/dist/{chunk-FUFBRKOG.cjs → chunk-KLJGJJHN.cjs} +24 -24
- package/dist/{chunk-FUFBRKOG.cjs.map → chunk-KLJGJJHN.cjs.map} +1 -1
- package/dist/chunk-LECJMLNE.js +15 -0
- package/dist/{chunk-CYMZ2QS5.js.map → chunk-LECJMLNE.js.map} +1 -1
- package/dist/{chunk-BJKAVWED.js → chunk-MBWF36DJ.js} +35 -14
- package/dist/chunk-MBWF36DJ.js.map +1 -0
- package/dist/chunk-NV2CWBI2.cjs +290 -0
- package/dist/chunk-NV2CWBI2.cjs.map +1 -0
- package/dist/{chunk-FQBTGS3E.cjs → chunk-OFUKTVBN.cjs} +363 -285
- package/dist/chunk-OFUKTVBN.cjs.map +1 -0
- package/dist/{chunk-7KN6J7XV.cjs → chunk-OMAACCFW.cjs} +7 -7
- package/dist/{chunk-7KN6J7XV.cjs.map → chunk-OMAACCFW.cjs.map} +1 -1
- package/dist/chunk-OYQ7GYAA.cjs +1921 -0
- package/dist/chunk-OYQ7GYAA.cjs.map +1 -0
- package/dist/{chunk-YJP6DUFO.cjs → chunk-PKD3JLS2.cjs} +6 -6
- package/dist/{chunk-YJP6DUFO.cjs.map → chunk-PKD3JLS2.cjs.map} +1 -1
- package/dist/chunk-PN2PIE2L.cjs +44670 -0
- package/dist/chunk-PN2PIE2L.cjs.map +1 -0
- package/dist/chunk-PX6F3LHL.js +37 -0
- package/dist/chunk-PX6F3LHL.js.map +1 -0
- package/dist/{chunk-CXDMZT45.cjs → chunk-PY7XAG4D.cjs} +27 -4
- package/dist/chunk-PY7XAG4D.cjs.map +1 -0
- package/dist/{chunk-5H7SAEQO.js → chunk-QKFJDQEK.js} +3 -3
- package/dist/{chunk-5H7SAEQO.js.map → chunk-QKFJDQEK.js.map} +1 -1
- package/dist/{chunk-XJTFZLWH.cjs → chunk-QO6PRHDX.cjs} +2 -2
- package/dist/{chunk-XJTFZLWH.cjs.map → chunk-QO6PRHDX.cjs.map} +1 -1
- package/dist/{chunk-ONNY7UO4.js → chunk-QSVQABXD.js} +4 -4
- package/dist/{chunk-ONNY7UO4.js.map → chunk-QSVQABXD.js.map} +1 -1
- package/dist/{chunk-OHDIJOGG.js → chunk-RD3JDFYJ.js} +3 -3
- package/dist/{chunk-OHDIJOGG.js.map → chunk-RD3JDFYJ.js.map} +1 -1
- package/dist/{chunk-4SM3I7WE.cjs → chunk-RXPEZXAB.cjs} +67 -38
- package/dist/chunk-RXPEZXAB.cjs.map +1 -0
- package/dist/{chunk-VTR2KGLY.cjs → chunk-S3BCHPXT.cjs} +9 -9
- package/dist/{chunk-VTR2KGLY.cjs.map → chunk-S3BCHPXT.cjs.map} +1 -1
- package/dist/{chunk-KU3XRHWA.js → chunk-TZX76ZNZ.js} +67 -38
- package/dist/chunk-TZX76ZNZ.js.map +1 -0
- package/dist/chunk-VNAREBLV.cjs +17 -0
- package/dist/{chunk-SNEQXSC5.cjs.map → chunk-VNAREBLV.cjs.map} +1 -1
- package/dist/{chunk-MXQ7J4BB.js → chunk-VSVGMMNO.js} +361 -284
- package/dist/chunk-VSVGMMNO.js.map +1 -0
- package/dist/{chunk-Q7G56ZIO.js → chunk-WUBMDOTG.js} +3 -3
- package/dist/{chunk-Q7G56ZIO.js.map → chunk-WUBMDOTG.js.map} +1 -1
- package/dist/{chunk-DGRXAIWK.js → chunk-X5YM3KXY.js} +27 -4
- package/dist/chunk-X5YM3KXY.js.map +1 -0
- package/dist/chunk-XCP454Q6.js +263 -0
- package/dist/chunk-XCP454Q6.js.map +1 -0
- package/dist/{chunk-I3DQXUSC.js → chunk-Y6DFMDMH.js} +3 -3
- package/dist/{chunk-I3DQXUSC.js.map → chunk-Y6DFMDMH.js.map} +1 -1
- package/dist/{chunk-D25WH7MH.js → chunk-ZX2XRFE5.js} +6 -6
- package/dist/{chunk-D25WH7MH.js.map → chunk-ZX2XRFE5.js.map} +1 -1
- package/dist/{collabKit-Q4A36LDA.cjs → collabKit-GCRHP25F.cjs} +3 -3
- package/dist/{collabKit-Q4A36LDA.cjs.map → collabKit-GCRHP25F.cjs.map} +1 -1
- package/dist/{collabKit-A643VH2I.js → collabKit-SJPDPXU4.js} +3 -3
- package/dist/{collabKit-A643VH2I.js.map → collabKit-SJPDPXU4.js.map} +1 -1
- package/dist/components/Accordion/index.cjs +1 -0
- package/dist/components/Accordion/index.js +1 -0
- package/dist/components/Alert/index.cjs +1 -0
- package/dist/components/Alert/index.js +1 -0
- package/dist/components/AlertDialog/index.cjs +5 -4
- package/dist/components/AlertDialog/index.js +4 -3
- package/dist/components/AudioPlayer/index.cjs +1 -0
- package/dist/components/AudioPlayer/index.js +1 -0
- package/dist/components/AudioRecorder/index.cjs +1 -0
- package/dist/components/AudioRecorder/index.js +1 -0
- package/dist/components/Autocomplete/index.cjs +1 -0
- package/dist/components/Autocomplete/index.js +1 -0
- package/dist/components/Avatar/index.cjs +1 -0
- package/dist/components/Avatar/index.js +1 -0
- package/dist/components/Badge/index.cjs +1 -0
- package/dist/components/Badge/index.js +1 -0
- package/dist/components/Breadcrumb/index.cjs +1 -0
- package/dist/components/Breadcrumb/index.js +1 -0
- package/dist/components/Button/index.cjs +1 -0
- package/dist/components/Button/index.js +1 -0
- package/dist/components/Card/index.cjs +1 -0
- package/dist/components/Card/index.js +1 -0
- package/dist/components/Checkbox/index.cjs +1 -0
- package/dist/components/Checkbox/index.js +1 -0
- package/dist/components/ClampedText/index.cjs +1 -0
- package/dist/components/ClampedText/index.js +1 -0
- package/dist/components/CollabStatus/index.cjs +1 -0
- package/dist/components/CollabStatus/index.js +1 -0
- package/dist/components/Collapsible/index.cjs +7 -4
- package/dist/components/Collapsible/index.js +4 -1
- package/dist/components/CopyButton/index.cjs +1 -0
- package/dist/components/CopyButton/index.js +1 -0
- package/dist/components/CountryCodeDropdown/index.cjs +1 -0
- package/dist/components/CountryCodeDropdown/index.js +1 -0
- package/dist/components/CustomizableDashboard/index.cjs +1 -0
- package/dist/components/CustomizableDashboard/index.js +1 -0
- package/dist/components/DateInput/index.cjs +1 -0
- package/dist/components/DateInput/index.js +1 -0
- package/dist/components/Dropdown/index.cjs +10 -8
- package/dist/components/Dropdown/index.js +3 -1
- package/dist/components/FilterSummaryBar/index.cjs +1 -0
- package/dist/components/FilterSummaryBar/index.js +1 -0
- package/dist/components/FloatingWindow/index.cjs +1 -0
- package/dist/components/FloatingWindow/index.js +1 -0
- package/dist/components/FreshnessBadge/index.cjs +1 -0
- package/dist/components/FreshnessBadge/index.js +1 -0
- package/dist/components/GlossaryTooltip/index.cjs +1 -0
- package/dist/components/GlossaryTooltip/index.js +1 -0
- package/dist/components/Input/index.cjs +1 -0
- package/dist/components/Input/index.js +1 -0
- package/dist/components/KeyboardShortcutsOverlay/index.cjs +6 -5
- package/dist/components/KeyboardShortcutsOverlay/index.js +4 -3
- package/dist/components/Label/index.cjs +1 -0
- package/dist/components/Label/index.js +1 -0
- package/dist/components/Markdown/index.cjs +6 -5
- package/dist/components/Markdown/index.js +2 -1
- package/dist/components/MediaEditor/index.cjs +10 -9
- package/dist/components/MediaEditor/index.js +5 -4
- package/dist/components/MediaPlayer/index.cjs +1 -0
- package/dist/components/MediaPlayer/index.js +1 -0
- package/dist/components/Modal/index.cjs +11 -10
- package/dist/components/Modal/index.js +3 -2
- package/dist/components/Pagination/index.cjs +1 -0
- package/dist/components/Pagination/index.js +1 -0
- package/dist/components/PhoneInput/index.cjs +1 -0
- package/dist/components/PhoneInput/index.js +1 -0
- package/dist/components/Progress/index.cjs +1 -0
- package/dist/components/Progress/index.js +1 -0
- package/dist/components/Q/index.cjs +1 -0
- package/dist/components/Q/index.js +1 -0
- package/dist/components/QuickAction/index.cjs +1 -0
- package/dist/components/QuickAction/index.js +1 -0
- package/dist/components/Radio/index.cjs +1 -0
- package/dist/components/Radio/index.js +1 -0
- package/dist/components/ReadingProgressBar/index.cjs +1 -0
- package/dist/components/ReadingProgressBar/index.js +1 -0
- package/dist/components/RecordButton/index.cjs +1 -0
- package/dist/components/RecordButton/index.js +1 -0
- package/dist/components/RichTextEditor/index.cjs +7 -5
- package/dist/components/RichTextEditor/index.js +4 -2
- package/dist/components/SchedulePicker/index.cjs +1 -0
- package/dist/components/SchedulePicker/index.js +1 -0
- package/dist/components/ScrollArea/index.cjs +1 -0
- package/dist/components/ScrollArea/index.js +1 -0
- package/dist/components/SectionSpyNav/index.cjs +1 -0
- package/dist/components/SectionSpyNav/index.js +1 -0
- package/dist/components/Select/index.cjs +4 -3
- package/dist/components/Select/index.js +2 -1
- package/dist/components/Separator/index.cjs +1 -0
- package/dist/components/Separator/index.js +1 -0
- package/dist/components/Sheet/index.cjs +1 -0
- package/dist/components/Sheet/index.js +1 -0
- package/dist/components/Skeleton/index.cjs +1 -0
- package/dist/components/Skeleton/index.js +1 -0
- package/dist/components/Slider/index.cjs +1 -0
- package/dist/components/Slider/index.js +1 -0
- package/dist/components/SourceTip/index.cjs +1 -0
- package/dist/components/SourceTip/index.js +1 -0
- package/dist/components/Sparkline/index.cjs +1 -0
- package/dist/components/Sparkline/index.js +1 -0
- package/dist/components/Spinner/index.cjs +1 -0
- package/dist/components/Spinner/index.js +1 -0
- package/dist/components/SuperChat/index.cjs +41 -17
- package/dist/components/SuperChat/index.cjs.map +1 -1
- package/dist/components/SuperChat/index.d.cts +20 -7
- package/dist/components/SuperChat/index.d.ts +20 -7
- package/dist/components/SuperChat/index.js +36 -12
- package/dist/components/SuperChat/index.js.map +1 -1
- package/dist/components/SuperChat/plugins/index.cjs +12 -4
- package/dist/components/SuperChat/plugins/index.cjs.map +1 -1
- package/dist/components/SuperChat/plugins/index.d.cts +3 -3
- package/dist/components/SuperChat/plugins/index.d.ts +3 -3
- package/dist/components/SuperChat/plugins/index.js +11 -3
- package/dist/components/SuperChat/plugins/index.js.map +1 -1
- package/dist/components/Switch/index.cjs +1 -0
- package/dist/components/Switch/index.js +1 -0
- package/dist/components/Table/index.cjs +1 -0
- package/dist/components/Table/index.js +1 -0
- package/dist/components/Tabs/index.cjs +1 -0
- package/dist/components/Tabs/index.js +1 -0
- package/dist/components/Text/index.cjs +1 -0
- package/dist/components/Text/index.js +1 -0
- package/dist/components/Textarea/index.cjs +1 -0
- package/dist/components/Textarea/index.js +1 -0
- package/dist/components/ThemeProvider/index.cjs +1 -0
- package/dist/components/ThemeProvider/index.js +1 -0
- package/dist/components/Toggle/index.cjs +1 -0
- package/dist/components/Toggle/index.js +1 -0
- package/dist/components/Tooltip/index.cjs +1 -0
- package/dist/components/Tooltip/index.js +1 -0
- package/dist/components/TranscriptView/index.cjs +1 -0
- package/dist/components/TranscriptView/index.js +1 -0
- package/dist/components/VisuallyHidden/index.cjs +1 -0
- package/dist/components/VisuallyHidden/index.js +1 -0
- package/dist/datavis.cjs +13 -8
- package/dist/datavis.cjs.map +1 -1
- package/dist/datavis.d.cts +647 -22
- package/dist/datavis.d.ts +647 -22
- package/dist/datavis.js +6 -5
- package/dist/datavis.js.map +1 -1
- package/dist/{default-BTEIFIZJ.cjs → default-CCMUBXP6.cjs} +3 -2
- package/dist/{default-BTEIFIZJ.cjs.map → default-CCMUBXP6.cjs.map} +1 -1
- package/dist/default-N2LW7ZFU.js +4 -0
- package/dist/{default-ORBRVZRZ.js.map → default-N2LW7ZFU.js.map} +1 -1
- package/dist/{enterprise-health-UDI25OCV.cjs → enterprise-health-75VYWAVG.cjs} +3 -2
- package/dist/{enterprise-health-UDI25OCV.cjs.map → enterprise-health-75VYWAVG.cjs.map} +1 -1
- package/dist/enterprise-health-CWLUB77O.js +4 -0
- package/dist/{enterprise-health-ORQQOLM3.js.map → enterprise-health-CWLUB77O.js.map} +1 -1
- package/dist/esheet.cjs +8 -7
- package/dist/esheet.cjs.map +1 -1
- package/dist/esheet.js +5 -4
- package/dist/esheet.js.map +1 -1
- package/dist/{hey-buddy-CLUVAY2X.cjs → hey-buddy-INNUFFJJ.cjs} +3 -2
- package/dist/hey-buddy-INNUFFJJ.cjs.map +1 -0
- package/dist/{hey-buddy-NMSWZ4TN.js → hey-buddy-V6FC5UKB.js} +3 -2
- package/dist/hey-buddy-V6FC5UKB.js.map +1 -0
- package/dist/hooks/index.cjs +14 -13
- package/dist/hooks/index.js +2 -1
- package/dist/index.cjs +753 -1703
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +347 -347
- package/dist/index.d.ts +347 -347
- package/dist/index.js +465 -1410
- package/dist/index.js.map +1 -1
- package/dist/kerebron.cjs +2 -1
- package/dist/kerebron.cjs.map +1 -1
- package/dist/kerebron.js +2 -1
- package/dist/kerebron.js.map +1 -1
- package/dist/{mieweb-6JCRWKSO.cjs → mieweb-72YOL44I.cjs} +3 -2
- package/dist/{mieweb-6JCRWKSO.cjs.map → mieweb-72YOL44I.cjs.map} +1 -1
- package/dist/mieweb-EZDLSSA6.js +4 -0
- package/dist/{mieweb-GIKY6EMN.js.map → mieweb-EZDLSSA6.js.map} +1 -1
- package/dist/motion.cjs +8 -7
- package/dist/motion.cjs.map +1 -1
- package/dist/motion.d.cts +1 -1
- package/dist/motion.d.ts +1 -1
- package/dist/motion.js +3 -2
- package/dist/motion.js.map +1 -1
- package/dist/{nitroTableGrid-SIMT7635.js → nitroTableGrid-LVYKKCGF.js} +5 -4
- package/dist/nitroTableGrid-LVYKKCGF.js.map +1 -0
- package/dist/{nitroTableGrid-3J2GY6CK.cjs → nitroTableGrid-SQADULEY.cjs} +5 -4
- package/dist/nitroTableGrid-SQADULEY.cjs.map +1 -0
- package/dist/q.cjs +1 -0
- package/dist/q.js +1 -0
- package/dist/styles.css +1 -1
- package/dist/tailwind-preset.cjs +5 -4
- package/dist/tailwind-preset.js +2 -1
- package/dist/{types-DZDroUW8.d.cts → types-B97JNRNQ.d.cts} +1 -1
- package/dist/{types-B2RLmdVd.d.ts → types-CnPEwzlp.d.cts} +6 -2
- package/dist/{types-B2RLmdVd.d.cts → types-CnPEwzlp.d.ts} +6 -2
- package/dist/{types-9vK_YdEb.d.ts → types-gZXrfLj6.d.ts} +1 -1
- package/dist/utils/index.cjs +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/{waggleline-I7QWD3YX.cjs → waggleline-5CBT4MNN.cjs} +3 -2
- package/dist/{waggleline-I7QWD3YX.cjs.map → waggleline-5CBT4MNN.cjs.map} +1 -1
- package/dist/waggleline-JMPCNV3J.js +4 -0
- package/dist/{waggleline-2MLRNVCV.js.map → waggleline-JMPCNV3J.js.map} +1 -1
- package/dist/webchart-2CVQ2TT3.js +4 -0
- package/dist/{webchart-72YMJ45P.js.map → webchart-2CVQ2TT3.js.map} +1 -1
- package/dist/{webchart-37OYZ42V.cjs → webchart-AXXOQHU6.cjs} +3 -2
- package/dist/{webchart-37OYZ42V.cjs.map → webchart-AXXOQHU6.cjs.map} +1 -1
- package/package.json +9 -14
- package/dist/chunk-4SM3I7WE.cjs.map +0 -1
- package/dist/chunk-5BVFVXHN.cjs +0 -1244
- package/dist/chunk-5BVFVXHN.cjs.map +0 -1
- package/dist/chunk-6XDPJWSC.cjs.map +0 -1
- package/dist/chunk-BJKAVWED.js.map +0 -1
- package/dist/chunk-BN75TLUN.cjs +0 -163
- package/dist/chunk-BN75TLUN.cjs.map +0 -1
- package/dist/chunk-CXDMZT45.cjs.map +0 -1
- package/dist/chunk-CYMZ2QS5.js +0 -15
- package/dist/chunk-DFYMIRMW.js.map +0 -1
- package/dist/chunk-DGRXAIWK.js.map +0 -1
- package/dist/chunk-FQBTGS3E.cjs.map +0 -1
- package/dist/chunk-IUDY6S7I.cjs.map +0 -1
- package/dist/chunk-KU3XRHWA.js.map +0 -1
- package/dist/chunk-MXQ7J4BB.js.map +0 -1
- package/dist/chunk-O6GJ4IYS.js +0 -1210
- package/dist/chunk-O6GJ4IYS.js.map +0 -1
- package/dist/chunk-ODYQYLO2.js.map +0 -1
- package/dist/chunk-SNEQXSC5.cjs +0 -17
- package/dist/chunk-VJOVJTFP.cjs +0 -370
- package/dist/chunk-VJOVJTFP.cjs.map +0 -1
- package/dist/chunk-WYMO3IIK.js +0 -136
- package/dist/chunk-WYMO3IIK.js.map +0 -1
- package/dist/chunk-XEEVDZDK.cjs.map +0 -1
- package/dist/chunk-YBLIDESO.js +0 -365
- package/dist/chunk-YBLIDESO.js.map +0 -1
- package/dist/default-ORBRVZRZ.js +0 -3
- package/dist/enterprise-health-ORQQOLM3.js +0 -3
- package/dist/hey-buddy-CLUVAY2X.cjs.map +0 -1
- package/dist/hey-buddy-NMSWZ4TN.js.map +0 -1
- package/dist/mieweb-GIKY6EMN.js +0 -3
- package/dist/nitroTableGrid-3J2GY6CK.cjs.map +0 -1
- package/dist/nitroTableGrid-SIMT7635.js.map +0 -1
- package/dist/waggleline-2MLRNVCV.js +0 -3
- package/dist/webchart-72YMJ45P.js +0 -3
package/dist/kerebron.cjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunkNMBYU7D7_cjs = require('./chunk-NMBYU7D7.cjs');
|
|
4
|
+
require('./chunk-EUAMEVVI.cjs');
|
|
4
5
|
var react = require('react');
|
|
5
6
|
var editor = require('@kerebron/editor');
|
|
6
7
|
var web = require('@kerebron/wasm/web');
|
|
@@ -25,7 +26,7 @@ var SafeAdvancedEditorKit = class {
|
|
|
25
26
|
};
|
|
26
27
|
async function createEditorKits(config) {
|
|
27
28
|
if (!config) return [new SafeAdvancedEditorKit(false)];
|
|
28
|
-
const { HuddleYjsKit, defaultWsUrl } = await import('./collabKit-
|
|
29
|
+
const { HuddleYjsKit, defaultWsUrl } = await import('./collabKit-GCRHP25F.cjs');
|
|
29
30
|
const url = config.wsUrl ?? defaultWsUrl();
|
|
30
31
|
return [
|
|
31
32
|
new SafeAdvancedEditorKit(true),
|
package/dist/kerebron.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/RichEditor/editorKits.ts","../src/components/RichEditor/RichEditor.tsx","../src/components/RichEditor/CodeEditor.tsx"],"names":["AdvancedEditorKit","forwardRef","RichEditor","useIsDarkMode","useRef","useState","useEffect","editor","CoreEditor","createAssetLoad","useImperativeHandle","jsx","jsxs","CodeEditorKit"],"mappings":";;;;;;;;;;AA4DA,IAAM,gBAAA,GAAmB,CAAC,cAAA,EAAgB,OAAO,CAAA;AAIjD,IAAM,wBAAN,MAAiD;AAAA,EAE/C,YAA6B,SAAA,EAAoB;AAApB,IAAA,IAAA,CAAA,SAAA,GAAA,SAAA;AAAA,EAAqB;AAAA,EAArB,SAAA;AAAA,EAD7B,IAAA,GAAO,iBAAA;AAAA,EAGP,aAAA,GAAgB;AACd,IAAA,MAAM,OAAA,GAAoB,CAAC,GAAG,gBAAgB,CAAA;AAC9C,IAAA,IAAI,IAAA,CAAK,SAAA,EAAW,OAAA,CAAQ,IAAA,CAAK,SAAS,CAAA;AAE1C,IAAA,OAAO,IAAIA,mCAAA,EAAkB,CAC1B,aAAA,EAAc,CACd,MAAA;AAAA,MACC,CAAC,cACC,EAAE,MAAA,IAAU,aAAa,OAAA,CAAQ,QAAA,CAAS,UAAU,IAAI,CAAA;AAAA,KAC5D;AAAA,EACJ;AACF,CAAA;AAWA,eAAsB,iBACpB,MAAA,EACsB;AACtB,EAAA,IAAI,CAAC,MAAA,EAAQ,OAAO,CAAC,IAAI,qBAAA,CAAsB,KAAK,CAAC,CAAA;AAErD,EAAA,MAAM,EAAE,YAAA,EAAc,YAAA,EAAa,GAAI,MAAM,OAAO,0BAAa,CAAA;AACjE,EAAA,MAAM,GAAA,GAAM,MAAA,CAAO,KAAA,IAAS,YAAA,EAAa;AACzC,EAAA,OAAO;AAAA,IACL,IAAI,sBAAsB,IAAI,CAAA;AAAA,IAC9B,IAAI,YAAA;AAAA,MACF,G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W,SAAA,EAAU,cAAA,EAAe,GAChD,CAAA,EACF,CAAA;AAEJ;AAEA,UAAA,CAAW,WAAA,GAAc,YAAA","file":"kerebron.cjs","sourcesContent":["/**\n * Editor kit assembly for {@link RichEditor}, for both plain and collaborative\n * (Yjs) mode.\n *\n * Both modes start from {@link AdvancedEditorKit} and drop the extensions that\n * are unsafe for our usage — see {@link unsafeExtensions} — then collaborative\n * mode adds the Yjs pieces on top.\n *\n * The Yjs pieces live in `collabKit.ts` behind a dynamic `import()`, so\n * `@kerebron/extension-yjs`, `yjs` and `y-protocols` remain truly optional\n * peers — plain-mode consumers never load them.\n */\nimport type { EditorKit } from '@kerebron/editor';\nimport { AdvancedEditorKit } from '@kerebron/editor-kits/AdvancedEditorKit';\n\nexport interface CollabConfig {\n /** Room id — one shared document per room (e.g. a post id). */\n room: string;\n /**\n * WebSocket base URL for the Yjs relay. Defaults to\n * `<ws|wss>://<location.host>/yjs`. The room id is appended by the provider.\n */\n wsUrl?: string;\n /** Extra query params for the socket (e.g. `{ token }` for auth). */\n params?: Record<string, string>;\n /**\n * Who this editor is, published on awareness (`kerebron:user`) so peers see\n * a named, coloured cursor. Without it remote cursors do not render — the\n * position plugin skips awareness states that carry no user — and the\n * `id` is what the cursor colour is derived from (kerebron's `User` shape).\n */\n user?: { id: string; name: string; color?: string };\n /**\n * Custom WebSocket implementation handed to the Yjs provider — e.g. a\n * loopback socket for demos/tests, or a polyfill outside the browser.\n * Defaults to `globalThis.WebSocket`.\n */\n WebSocketPolyfill?: typeof globalThis.WebSocket;\n}\n\n/**\n * Extensions dropped from {@link AdvancedEditorKit}, and why.\n *\n * `autocomplete` and `hover` debounce their DOM handlers (200ms) and then call\n * `dispatchMeta`, which reads `this.editor.state` with no guard that the editor\n * is still alive. Any teardown or document swap inside that debounce window\n * lands the deferred call on a dead view and throws\n * `null.matchesNode()` inside ProseMirror's `EditorView.updateStateInner`,\n * leaving the view permanently broken. Two ways to hit it:\n * - remount (e.g. a `key` change) while the pointer is over the editor, which\n * fires the debounced `onMouseLeave` after the view is destroyed;\n * - a Yjs remote update replacing the document tree under a pending callback.\n * The first applies to *every* editor, so both extensions come out in both\n * modes. No functional cost — autocomplete popups and node-hover tooltips are\n * compositor conveniences, not required for editing.\n *\n * `history` is collab-only: ExtensionYjs supplies its own CRDT-aware undo/redo\n * and the editor throws `Extension conflict: yjs vs history` if both are\n * present. Plain mode keeps it, so undo/redo still works there.\n */\nconst unsafeExtensions = ['autocomplete', 'hover'] as const;\n\n/** {@link AdvancedEditorKit} minus {@link unsafeExtensions} (and, for collab\n * mode, minus `history`). */\nclass SafeAdvancedEditorKit implements EditorKit {\n name = 'advanced-editor';\n constructor(private readonly forCollab: boolean) {}\n\n getExtensions() {\n const dropped: string[] = [...unsafeExtensions];\n if (this.forCollab) dropped.push('history');\n\n return new AdvancedEditorKit()\n .getExtensions()\n .filter(\n (extension) =>\n !('name' in extension && dropped.includes(extension.name))\n );\n }\n}\n\n/** MarkYChange + ExtensionYjs live in `collabKit.ts` (lazy-loaded). */\n\n/**\n * Build the editor kits for a session. Pass `config` to join a collaborative\n * room; omit it for a plain local editor.\n *\n * Async because collaborative mode lazy-loads the Yjs kit (and its optional\n * peer deps) on first use; plain mode resolves immediately.\n */\nexport async function createEditorKits(\n config?: CollabConfig\n): Promise<EditorKit[]> {\n if (!config) return [new SafeAdvancedEditorKit(false)];\n\n const { HuddleYjsKit, defaultWsUrl } = await import('./collabKit');\n const url = config.wsUrl ?? defaultWsUrl();\n return [\n new SafeAdvancedEditorKit(true),\n new HuddleYjsKit(\n url,\n config.params ?? {},\n config.WebSocketPolyfill,\n config.user\n ),\n ];\n}\n","'use client';\n\nimport {\n forwardRef,\n useEffect,\n useImperativeHandle,\n useRef,\n useState,\n} from 'react';\n\nimport { CoreEditor, type AssetLoad } from '@kerebron/editor';\nimport { createAssetLoad } from '@kerebron/wasm/web';\n\nimport { useIsDarkMode } from '../../hooks/useIsDarkMode';\nimport { createEditorKits, type CollabConfig } from './editorKits';\n\nexport type { CollabConfig } from './editorKits';\n\nconst MARKDOWN_TYPE = 'text/x-markdown';\n\n/**\n * The markdown converter's tree-sitter WASM init is not concurrency-safe, so\n * every editor's *first* load queues behind the previous one. Later loads (a\n * `value` change) are free — by then the grammars are warm.\n */\nlet initialLoadQueue: Promise<unknown> = Promise.resolve();\n\nfunction queueInitialLoad(load: () => Promise<void>): Promise<void> {\n const queued = initialLoadQueue.catch(() => undefined).then(load);\n initialLoadQueue = queued.catch(() => undefined);\n return queued;\n}\n\nexport interface RichEditorProps {\n /** Markdown to load. Changing it reloads the editor unless `collab` is set. */\n value?: string;\n /** Called with the editor's markdown content whenever it changes. */\n onChange?: (value: string) => void;\n /** Whether to render the live markdown output preview. Defaults to `false`. */\n showPreview?: boolean;\n /**\n * Enable live collaborative editing (Yjs) for the given room. When set, the\n * editor connects to the `/yjs` websocket relay and every peer in the same\n * `room` co-edits one shared document. Uncontrolled like `value` — remount via\n * `key` to switch rooms.\n */\n collab?: CollabConfig;\n /** Read-only surface: no typing, and the content dims. */\n disabled?: boolean;\n /**\n * Id for the editor host element — an `aria-labelledby`/`aria-describedby`\n * anchor. The host is a `div`, not a labelable control, so a\n * `<label htmlFor>` will not associate; name the editor with `aria-label`\n * or `aria-labelledby` instead.\n */\n id?: string;\n /** Extra classes on the editor surface, beside `kb-component`. */\n className?: string;\n 'aria-label'?: string;\n 'aria-labelledby'?: string;\n /**\n * Where the tree-sitter WASM grammars load from. Defaults to\n * `createAssetLoad('/kerebron-wasm')`; supply your own when the host serves\n * `@kerebron/wasm`'s `assets/` somewhere else.\n */\n assetLoad?: AssetLoad;\n}\n\nexport interface RichEditorHandle {\n /**\n * The editor's markdown, awaiting the initial load. `onChange` can lag the\n * last keystroke, so read this on submit rather than trusting mirrored state.\n */\n getContent: () => Promise<string>;\n /** Focus the editor, restoring the caret where the writer left it. */\n focus: () => void;\n}\n\n/**\n * Markdown editor over Kerebron's `CoreEditor`.\n *\n * The editor mounts into a **disposable child div**: `CoreEditor.destroy()`\n * replaces its host element with a clone, which would strand React's ref (and,\n * under StrictMode's double-mount, leave the live editor detached behind a\n * dead clone).\n */\nconst RichEditor = forwardRef<RichEditorHandle, RichEditorProps>(\n function RichEditor(\n {\n value = '',\n onChange,\n showPreview = false,\n collab,\n disabled = false,\n id,\n className,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n assetLoad,\n },\n ref\n ) {\n const isDark = useIsDarkMode();\n const hostRef = useRef<HTMLDivElement>(null);\n const editorInstance = useRef<CoreEditor | null>(null);\n const onChangeRef = useRef(onChange);\n onChangeRef.current = onChange;\n // Mirrors what the editor last held, so an echo of our own `onChange`\n // doesn't reload the document out from under the caret.\n const valueRef = useRef(value);\n const readyRef = useRef<Promise<void> | null>(null);\n const loadingRef = useRef(false);\n const disabledRef = useRef(disabled);\n\n const [md, setMd] = useState<string>('');\n\n useEffect(() => {\n disabledRef.current = disabled;\n editorInstance.current?.view.setProps({\n editable: () => !disabledRef.current,\n });\n }, [disabled]);\n\n useEffect(() => {\n // In collab mode the CRDT owns the content; reloading would fight it.\n if (collab || value === valueRef.current) return;\n valueRef.current = value;\n const editor = editorInstance.current;\n if (!editor) return;\n\n loadingRef.current = true;\n void editor\n .loadDocumentText(MARKDOWN_TYPE, value)\n .catch(() => undefined)\n .finally(() => {\n if (editorInstance.current === editor) loadingRef.current = false;\n });\n // `collab` is fixed for the lifetime of the instance.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [value]);\n\n useEffect(() => {\n if (!hostRef.current) return;\n const host = hostRef.current;\n\n // Set on cleanup so async continuations (kit loading and the\n // `loadDocumentText` chain) don't touch the editor after `destroy()`.\n let disposed = false;\n let editor: CoreEditor | null = null;\n\n const mount = document.createElement('div');\n host.appendChild(mount);\n\n // Listen to transactions and update markdown preview\n const onTransaction = async () => {\n // Programmatic loads are not edits — reporting them would echo the\n // caller's own `value` back through `onChange`.\n if (loadingRef.current || !editorInstance.current) return;\n\n try {\n const buffer =\n await editorInstance.current.saveDocument(MARKDOWN_TYPE);\n const markdown = new globalThis.TextDecoder().decode(buffer);\n if (disposed) return;\n valueRef.current = markdown;\n setMd(markdown);\n onChangeRef.current?.(markdown);\n } catch (err) {\n console.error('Failed to save markdown:', err);\n }\n };\n\n // Initialize the editor. Both modes drop the teardown-unsafe extensions;\n // collaborative mode additionally swaps `history` for the Yjs CRDT sync\n // and lazy-loads the Yjs kit (see `editorKits.ts` for why).\n const setup = async () => {\n const editorKits = await createEditorKits(collab);\n if (disposed) return;\n\n editor = CoreEditor.create({\n element: mount,\n uri: 'file:///untitled.md',\n assetLoad: assetLoad ?? createAssetLoad('/kerebron-wasm'),\n editorKits,\n readOnly: disabledRef.current,\n });\n\n editorInstance.current = editor;\n // The contenteditable surface has no implicit ARIA role, so labeling\n // attributes are only permitted alongside an explicit textbox role.\n const surfaceAttributes =\n ariaLabel || ariaLabelledBy\n ? {\n role: 'textbox',\n 'aria-multiline': 'true',\n ...(ariaLabel ? { 'aria-label': ariaLabel } : {}),\n ...(ariaLabelledBy\n ? { 'aria-labelledby': ariaLabelledBy }\n : {}),\n }\n : null;\n editor.view.setProps({\n editable: () => !disabledRef.current,\n ...(surfaceAttributes ? { attributes: surfaceAttributes } : {}),\n });\n editor.addEventListener('transaction', onTransaction);\n\n // Seed initial content, then populate the preview once on mount.\n //\n // In collaborative mode we still load the local markdown first, then\n // join the room: the Yjs binding seeds an *empty* shared document from\n // this content on the first join, and overwrites the editor with the\n // shared content when the room already has edits — so the stored\n // markdown is the starting point without ever double-inserting.\n const joinRoom = () => {\n if (collab && editor && !disposed) {\n (\n editor.run as Record<string, (...args: unknown[]) => boolean>\n ).changeRoom?.(collab.room);\n reseedWhenRoomStaysEmpty();\n }\n };\n\n // The Yjs binding is supposed to seed an empty room from the local\n // content, but the sync import can land as an overwrite that blanks\n // the just-loaded seed (observed with extension-yjs 0.8.x). Heal it:\n // once the join settles, an empty document with a non-empty seed\n // means nobody's content won — reload the seed, which the binding\n // then pushes into the room. Joiners pass no value, so exactly one\n // participant ever does this.\n const seed = valueRef.current;\n const reseedWhenRoomStaysEmpty = () => {\n if (!seed) return;\n const check = async (attempt: number) => {\n if (disposed || !editorInstance.current) return;\n try {\n const buffer =\n await editorInstance.current.saveDocument(MARKDOWN_TYPE);\n const current = new globalThis.TextDecoder()\n .decode(buffer)\n .trim();\n if (disposed || !editorInstance.current) return;\n if (current) return; // somebody's content arrived — done\n if (attempt >= 2) {\n await editorInstance.current.loadDocumentText(\n MARKDOWN_TYPE,\n seed\n );\n return;\n }\n setTimeout(() => void check(attempt + 1), 300);\n } catch {\n // A failed probe must not break the editor; the room stays as-is.\n }\n };\n setTimeout(() => void check(0), 300);\n };\n\n if (valueRef.current) {\n await queueInitialLoad(() =>\n editor!.loadDocumentText(MARKDOWN_TYPE, valueRef.current)\n );\n await onTransaction();\n joinRoom();\n } else {\n void onTransaction();\n joinRoom();\n }\n };\n\n readyRef.current = setup().catch((err) =>\n console.error('Failed to set up editor:', err)\n );\n\n // Cleanup on unmount\n return () => {\n disposed = true;\n editorInstance.current = null; // makes onTransaction's guard effective\n editor?.removeEventListener('transaction', onTransaction);\n editor?.destroy();\n readyRef.current = null;\n host.replaceChildren();\n };\n // Initial `value`/`collab` are intentionally only applied on mount\n // (uncontrolled). Remount via `key` to switch rooms.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n useImperativeHandle(\n ref,\n () => ({\n getContent: async (): Promise<string> => {\n await readyRef.current;\n const editor = editorInstance.current;\n if (!editor) return valueRef.current;\n const buffer = await editor.saveDocument(MARKDOWN_TYPE);\n const markdown = new globalThis.TextDecoder().decode(buffer);\n valueRef.current = markdown;\n return markdown;\n },\n focus: (): void => {\n const apply = (): void => {\n const view = editorInstance.current?.view as\n | { focus?: () => void }\n | undefined;\n if (view?.focus) {\n view.focus();\n return;\n }\n hostRef.current\n ?.querySelector<HTMLElement>('[contenteditable=\"true\"], textarea')\n ?.focus();\n };\n // Callers focus on mount; the editor may still be loading its kits.\n if (editorInstance.current) apply();\n else void readyRef.current?.then(apply);\n },\n }),\n []\n );\n\n return (\n <div>\n <div>\n <div\n ref={hostRef}\n id={id}\n className={[\n 'kb-component',\n isDark ? 'kb-component--dark' : '',\n className ?? '',\n ]\n .filter(Boolean)\n .join(' ')}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-disabled={disabled || undefined}\n style={{\n isolation: 'isolate',\n opacity: disabled ? 0.65 : undefined,\n pointerEvents: disabled ? 'none' : undefined,\n }}\n />\n </div>\n\n {showPreview && (\n <div>\n <div>\n <h5>Markdown Output</h5>\n <pre>{md}</pre>\n </div>\n </div>\n )}\n </div>\n );\n }\n);\n\nRichEditor.displayName = 'RichEditor';\n\nexport { RichEditor };\n","import React, { useEffect, useRef } from 'react';\n\nimport { CoreEditor } from '@kerebron/editor';\nimport { CodeEditorKit } from '@kerebron/editor-kits/CodeEditorKit';\nimport { createAssetLoad } from '@kerebron/wasm/web';\n\nexport interface CodeEditorProps {\n /** Initial source code to load into the editor. */\n value?: string;\n /** Called with the editor's contents whenever they change. */\n onChange?: (value: string) => void;\n /** Language/grammar to use for syntax highlighting. Defaults to `typescript`. */\n lang?: string;\n}\n\nconst CodeEditor: React.FC<CodeEditorProps> = ({\n value = '',\n onChange,\n lang = 'typescript',\n}) => {\n const editorRef = useRef<HTMLDivElement>(null);\n const editorInstance = useRef<CoreEditor | null>(null);\n const onChangeRef = useRef(onChange);\n onChangeRef.current = onChange;\n\n useEffect(() => {\n const root = editorRef.current;\n if (!root) return;\n\n const applySelectLabel = () => {\n root.querySelectorAll('select.codejar-select').forEach((element) => {\n if (!element.getAttribute('aria-label')) {\n element.setAttribute('aria-label', 'Code editor language');\n }\n });\n };\n\n applySelectLabel();\n const observer = new MutationObserver(() => applySelectLabel());\n observer.observe(root, { childList: true, subtree: true });\n return () => observer.disconnect();\n }, []);\n\n useEffect(() => {\n if (!editorRef.current) return;\n\n // Initialize the editor\n const editor = CoreEditor.create({\n element: editorRef.current,\n uri: 'file:///untitled.ts',\n assetLoad: createAssetLoad('/kerebron-wasm'),\n editorKits: [new CodeEditorKit(lang)],\n });\n\n editorInstance.current = editor;\n\n // Surface edits to callers.\n const onTransaction = async () => {\n if (!editorInstance.current) return;\n\n try {\n const buffer = await editorInstance.current.saveDocument('text/plain');\n onChangeRef.current?.(new globalThis.TextDecoder().decode(buffer));\n } catch (err) {\n console.error('Failed to read code:', err);\n }\n };\n\n editor.addEventListener('transaction', onTransaction);\n\n // Seed initial content on mount.\n if (value) {\n editor\n .loadDocumentText('text/plain', value)\n .catch((err) => console.error('Failed to load code:', err));\n }\n\n // Cleanup on unmount\n return () => {\n editor.removeEventListener('transaction', onTransaction);\n editor.destroy();\n };\n // Initial `value`/`lang` are intentionally only applied on mount.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n return (\n <div>\n <div>\n <div ref={editorRef} className=\"kb-component\" />\n </div>\n </div>\n );\n};\n\nCodeEditor.displayName = 'CodeEditor';\n\nexport { CodeEditor };\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/components/RichEditor/editorKits.ts","../src/components/RichEditor/RichEditor.tsx","../src/components/RichEditor/CodeEditor.tsx"],"names":["AdvancedEditorKit","forwardRef","RichEditor","useIsDarkMode","useRef","useState","useEffect","editor","CoreEditor","createAssetLoad","useImperativeHandle","jsx","jsxs","CodeEditorKit"],"mappings":";;;;;;;;;;;AA4DA,IAAM,gBAAA,GAAmB,CAAC,cAAA,EAAgB,OAAO,CAAA;AAIjD,IAAM,wBAAN,MAAiD;AAAA,EAE/C,YAA6B,SAAA,EAAoB;AAApB,IAAA,IAAA,CAAA,SAAA,GAAA,SAAA;AAAA,EAAqB;AAAA,EAArB,SAAA;AAAA,EAD7B,IAAA,GAAO,iBAAA;AAAA,EAGP,aAAA,GAAgB;AACd,IAAA,MAAM,OAAA,GAAoB,CAAC,GAAG,gBAAgB,CAAA;AAC9C,IAAA,IAAI,IAAA,CAAK,SAAA,EAAW,OAAA,CAAQ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IAAAA,QAAA,CAAO,gBAAA,CAAiB,eAAe,aAAa,CAAA;AAGpD,IAAA,IAAI,KAAA,EAAO;AACT,MAAAA,QAAA,CACG,gBAAA,CAAiB,YAAA,EAAc,KAAK,CAAA,CACpC,KAAA,CAAM,CAAC,GAAA,KAAQ,OAAA,CAAQ,KAAA,CAAM,sBAAA,EAAwB,GAAG,CAAC,CAAA;AAAA,IAC9D;AAGA,IAAA,OAAO,MAAM;AACX,MAAAA,QAAA,CAAO,mBAAA,CAAoB,eAAe,aAAa,CAAA;AACvD,MAAAA,QAAA,CAAO,OAAA,EAAQ;AAAA,IACjB,CAAA;AAAA,EAGF,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,uBACEI,cAAAA,CAAC,KAAA,EAAA,EACC,QAAA,kBAAAA,eAAC,KAAA,EAAA,EACC,QAAA,kBAAAA,cAAAA,CAAC,KAAA,EAAA,EAAI,GAAA,EAAK,SAAA,EAAW,SAAA,EAAU,cAAA,EAAe,GAChD,CAAA,EACF,CAAA;AAEJ;AAEA,UAAA,CAAW,WAAA,GAAc,YAAA","file":"kerebron.cjs","sourcesContent":["/**\n * Editor kit assembly for {@link RichEditor}, for both plain and collaborative\n * (Yjs) mode.\n *\n * Both modes start from {@link AdvancedEditorKit} and drop the extensions that\n * are unsafe for our usage — see {@link unsafeExtensions} — then collaborative\n * mode adds the Yjs pieces on top.\n *\n * The Yjs pieces live in `collabKit.ts` behind a dynamic `import()`, so\n * `@kerebron/extension-yjs`, `yjs` and `y-protocols` remain truly optional\n * peers — plain-mode consumers never load them.\n */\nimport type { EditorKit } from '@kerebron/editor';\nimport { AdvancedEditorKit } from '@kerebron/editor-kits/AdvancedEditorKit';\n\nexport interface CollabConfig {\n /** Room id — one shared document per room (e.g. a post id). */\n room: string;\n /**\n * WebSocket base URL for the Yjs relay. Defaults to\n * `<ws|wss>://<location.host>/yjs`. The room id is appended by the provider.\n */\n wsUrl?: string;\n /** Extra query params for the socket (e.g. `{ token }` for auth). */\n params?: Record<string, string>;\n /**\n * Who this editor is, published on awareness (`kerebron:user`) so peers see\n * a named, coloured cursor. Without it remote cursors do not render — the\n * position plugin skips awareness states that carry no user — and the\n * `id` is what the cursor colour is derived from (kerebron's `User` shape).\n */\n user?: { id: string; name: string; color?: string };\n /**\n * Custom WebSocket implementation handed to the Yjs provider — e.g. a\n * loopback socket for demos/tests, or a polyfill outside the browser.\n * Defaults to `globalThis.WebSocket`.\n */\n WebSocketPolyfill?: typeof globalThis.WebSocket;\n}\n\n/**\n * Extensions dropped from {@link AdvancedEditorKit}, and why.\n *\n * `autocomplete` and `hover` debounce their DOM handlers (200ms) and then call\n * `dispatchMeta`, which reads `this.editor.state` with no guard that the editor\n * is still alive. Any teardown or document swap inside that debounce window\n * lands the deferred call on a dead view and throws\n * `null.matchesNode()` inside ProseMirror's `EditorView.updateStateInner`,\n * leaving the view permanently broken. Two ways to hit it:\n * - remount (e.g. a `key` change) while the pointer is over the editor, which\n * fires the debounced `onMouseLeave` after the view is destroyed;\n * - a Yjs remote update replacing the document tree under a pending callback.\n * The first applies to *every* editor, so both extensions come out in both\n * modes. No functional cost — autocomplete popups and node-hover tooltips are\n * compositor conveniences, not required for editing.\n *\n * `history` is collab-only: ExtensionYjs supplies its own CRDT-aware undo/redo\n * and the editor throws `Extension conflict: yjs vs history` if both are\n * present. Plain mode keeps it, so undo/redo still works there.\n */\nconst unsafeExtensions = ['autocomplete', 'hover'] as const;\n\n/** {@link AdvancedEditorKit} minus {@link unsafeExtensions} (and, for collab\n * mode, minus `history`). */\nclass SafeAdvancedEditorKit implements EditorKit {\n name = 'advanced-editor';\n constructor(private readonly forCollab: boolean) {}\n\n getExtensions() {\n const dropped: string[] = [...unsafeExtensions];\n if (this.forCollab) dropped.push('history');\n\n return new AdvancedEditorKit()\n .getExtensions()\n .filter(\n (extension) =>\n !('name' in extension && dropped.includes(extension.name))\n );\n }\n}\n\n/** MarkYChange + ExtensionYjs live in `collabKit.ts` (lazy-loaded). */\n\n/**\n * Build the editor kits for a session. Pass `config` to join a collaborative\n * room; omit it for a plain local editor.\n *\n * Async because collaborative mode lazy-loads the Yjs kit (and its optional\n * peer deps) on first use; plain mode resolves immediately.\n */\nexport async function createEditorKits(\n config?: CollabConfig\n): Promise<EditorKit[]> {\n if (!config) return [new SafeAdvancedEditorKit(false)];\n\n const { HuddleYjsKit, defaultWsUrl } = await import('./collabKit');\n const url = config.wsUrl ?? defaultWsUrl();\n return [\n new SafeAdvancedEditorKit(true),\n new HuddleYjsKit(\n url,\n config.params ?? {},\n config.WebSocketPolyfill,\n config.user\n ),\n ];\n}\n","'use client';\n\nimport {\n forwardRef,\n useEffect,\n useImperativeHandle,\n useRef,\n useState,\n} from 'react';\n\nimport { CoreEditor, type AssetLoad } from '@kerebron/editor';\nimport { createAssetLoad } from '@kerebron/wasm/web';\n\nimport { useIsDarkMode } from '../../hooks/useIsDarkMode';\nimport { createEditorKits, type CollabConfig } from './editorKits';\n\nexport type { CollabConfig } from './editorKits';\n\nconst MARKDOWN_TYPE = 'text/x-markdown';\n\n/**\n * The markdown converter's tree-sitter WASM init is not concurrency-safe, so\n * every editor's *first* load queues behind the previous one. Later loads (a\n * `value` change) are free — by then the grammars are warm.\n */\nlet initialLoadQueue: Promise<unknown> = Promise.resolve();\n\nfunction queueInitialLoad(load: () => Promise<void>): Promise<void> {\n const queued = initialLoadQueue.catch(() => undefined).then(load);\n initialLoadQueue = queued.catch(() => undefined);\n return queued;\n}\n\nexport interface RichEditorProps {\n /** Markdown to load. Changing it reloads the editor unless `collab` is set. */\n value?: string;\n /** Called with the editor's markdown content whenever it changes. */\n onChange?: (value: string) => void;\n /** Whether to render the live markdown output preview. Defaults to `false`. */\n showPreview?: boolean;\n /**\n * Enable live collaborative editing (Yjs) for the given room. When set, the\n * editor connects to the `/yjs` websocket relay and every peer in the same\n * `room` co-edits one shared document. Uncontrolled like `value` — remount via\n * `key` to switch rooms.\n */\n collab?: CollabConfig;\n /** Read-only surface: no typing, and the content dims. */\n disabled?: boolean;\n /**\n * Id for the editor host element — an `aria-labelledby`/`aria-describedby`\n * anchor. The host is a `div`, not a labelable control, so a\n * `<label htmlFor>` will not associate; name the editor with `aria-label`\n * or `aria-labelledby` instead.\n */\n id?: string;\n /** Extra classes on the editor surface, beside `kb-component`. */\n className?: string;\n 'aria-label'?: string;\n 'aria-labelledby'?: string;\n /**\n * Where the tree-sitter WASM grammars load from. Defaults to\n * `createAssetLoad('/kerebron-wasm')`; supply your own when the host serves\n * `@kerebron/wasm`'s `assets/` somewhere else.\n */\n assetLoad?: AssetLoad;\n}\n\nexport interface RichEditorHandle {\n /**\n * The editor's markdown, awaiting the initial load. `onChange` can lag the\n * last keystroke, so read this on submit rather than trusting mirrored state.\n */\n getContent: () => Promise<string>;\n /** Focus the editor, restoring the caret where the writer left it. */\n focus: () => void;\n}\n\n/**\n * Markdown editor over Kerebron's `CoreEditor`.\n *\n * The editor mounts into a **disposable child div**: `CoreEditor.destroy()`\n * replaces its host element with a clone, which would strand React's ref (and,\n * under StrictMode's double-mount, leave the live editor detached behind a\n * dead clone).\n */\nconst RichEditor = forwardRef<RichEditorHandle, RichEditorProps>(\n function RichEditor(\n {\n value = '',\n onChange,\n showPreview = false,\n collab,\n disabled = false,\n id,\n className,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n assetLoad,\n },\n ref\n ) {\n const isDark = useIsDarkMode();\n const hostRef = useRef<HTMLDivElement>(null);\n const editorInstance = useRef<CoreEditor | null>(null);\n const onChangeRef = useRef(onChange);\n onChangeRef.current = onChange;\n // Mirrors what the editor last held, so an echo of our own `onChange`\n // doesn't reload the document out from under the caret.\n const valueRef = useRef(value);\n const readyRef = useRef<Promise<void> | null>(null);\n const loadingRef = useRef(false);\n const disabledRef = useRef(disabled);\n\n const [md, setMd] = useState<string>('');\n\n useEffect(() => {\n disabledRef.current = disabled;\n editorInstance.current?.view.setProps({\n editable: () => !disabledRef.current,\n });\n }, [disabled]);\n\n useEffect(() => {\n // In collab mode the CRDT owns the content; reloading would fight it.\n if (collab || value === valueRef.current) return;\n valueRef.current = value;\n const editor = editorInstance.current;\n if (!editor) return;\n\n loadingRef.current = true;\n void editor\n .loadDocumentText(MARKDOWN_TYPE, value)\n .catch(() => undefined)\n .finally(() => {\n if (editorInstance.current === editor) loadingRef.current = false;\n });\n // `collab` is fixed for the lifetime of the instance.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [value]);\n\n useEffect(() => {\n if (!hostRef.current) return;\n const host = hostRef.current;\n\n // Set on cleanup so async continuations (kit loading and the\n // `loadDocumentText` chain) don't touch the editor after `destroy()`.\n let disposed = false;\n let editor: CoreEditor | null = null;\n\n const mount = document.createElement('div');\n host.appendChild(mount);\n\n // Listen to transactions and update markdown preview\n const onTransaction = async () => {\n // Programmatic loads are not edits — reporting them would echo the\n // caller's own `value` back through `onChange`.\n if (loadingRef.current || !editorInstance.current) return;\n\n try {\n const buffer =\n await editorInstance.current.saveDocument(MARKDOWN_TYPE);\n const markdown = new globalThis.TextDecoder().decode(buffer);\n if (disposed) return;\n valueRef.current = markdown;\n setMd(markdown);\n onChangeRef.current?.(markdown);\n } catch (err) {\n console.error('Failed to save markdown:', err);\n }\n };\n\n // Initialize the editor. Both modes drop the teardown-unsafe extensions;\n // collaborative mode additionally swaps `history` for the Yjs CRDT sync\n // and lazy-loads the Yjs kit (see `editorKits.ts` for why).\n const setup = async () => {\n const editorKits = await createEditorKits(collab);\n if (disposed) return;\n\n editor = CoreEditor.create({\n element: mount,\n uri: 'file:///untitled.md',\n assetLoad: assetLoad ?? createAssetLoad('/kerebron-wasm'),\n editorKits,\n readOnly: disabledRef.current,\n });\n\n editorInstance.current = editor;\n // The contenteditable surface has no implicit ARIA role, so labeling\n // attributes are only permitted alongside an explicit textbox role.\n const surfaceAttributes =\n ariaLabel || ariaLabelledBy\n ? {\n role: 'textbox',\n 'aria-multiline': 'true',\n ...(ariaLabel ? { 'aria-label': ariaLabel } : {}),\n ...(ariaLabelledBy\n ? { 'aria-labelledby': ariaLabelledBy }\n : {}),\n }\n : null;\n editor.view.setProps({\n editable: () => !disabledRef.current,\n ...(surfaceAttributes ? { attributes: surfaceAttributes } : {}),\n });\n editor.addEventListener('transaction', onTransaction);\n\n // Seed initial content, then populate the preview once on mount.\n //\n // In collaborative mode we still load the local markdown first, then\n // join the room: the Yjs binding seeds an *empty* shared document from\n // this content on the first join, and overwrites the editor with the\n // shared content when the room already has edits — so the stored\n // markdown is the starting point without ever double-inserting.\n const joinRoom = () => {\n if (collab && editor && !disposed) {\n (\n editor.run as Record<string, (...args: unknown[]) => boolean>\n ).changeRoom?.(collab.room);\n reseedWhenRoomStaysEmpty();\n }\n };\n\n // The Yjs binding is supposed to seed an empty room from the local\n // content, but the sync import can land as an overwrite that blanks\n // the just-loaded seed (observed with extension-yjs 0.8.x). Heal it:\n // once the join settles, an empty document with a non-empty seed\n // means nobody's content won — reload the seed, which the binding\n // then pushes into the room. Joiners pass no value, so exactly one\n // participant ever does this.\n const seed = valueRef.current;\n const reseedWhenRoomStaysEmpty = () => {\n if (!seed) return;\n const check = async (attempt: number) => {\n if (disposed || !editorInstance.current) return;\n try {\n const buffer =\n await editorInstance.current.saveDocument(MARKDOWN_TYPE);\n const current = new globalThis.TextDecoder()\n .decode(buffer)\n .trim();\n if (disposed || !editorInstance.current) return;\n if (current) return; // somebody's content arrived — done\n if (attempt >= 2) {\n await editorInstance.current.loadDocumentText(\n MARKDOWN_TYPE,\n seed\n );\n return;\n }\n setTimeout(() => void check(attempt + 1), 300);\n } catch {\n // A failed probe must not break the editor; the room stays as-is.\n }\n };\n setTimeout(() => void check(0), 300);\n };\n\n if (valueRef.current) {\n await queueInitialLoad(() =>\n editor!.loadDocumentText(MARKDOWN_TYPE, valueRef.current)\n );\n await onTransaction();\n joinRoom();\n } else {\n void onTransaction();\n joinRoom();\n }\n };\n\n readyRef.current = setup().catch((err) =>\n console.error('Failed to set up editor:', err)\n );\n\n // Cleanup on unmount\n return () => {\n disposed = true;\n editorInstance.current = null; // makes onTransaction's guard effective\n editor?.removeEventListener('transaction', onTransaction);\n editor?.destroy();\n readyRef.current = null;\n host.replaceChildren();\n };\n // Initial `value`/`collab` are intentionally only applied on mount\n // (uncontrolled). Remount via `key` to switch rooms.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n useImperativeHandle(\n ref,\n () => ({\n getContent: async (): Promise<string> => {\n await readyRef.current;\n const editor = editorInstance.current;\n if (!editor) return valueRef.current;\n const buffer = await editor.saveDocument(MARKDOWN_TYPE);\n const markdown = new globalThis.TextDecoder().decode(buffer);\n valueRef.current = markdown;\n return markdown;\n },\n focus: (): void => {\n const apply = (): void => {\n const view = editorInstance.current?.view as\n | { focus?: () => void }\n | undefined;\n if (view?.focus) {\n view.focus();\n return;\n }\n hostRef.current\n ?.querySelector<HTMLElement>('[contenteditable=\"true\"], textarea')\n ?.focus();\n };\n // Callers focus on mount; the editor may still be loading its kits.\n if (editorInstance.current) apply();\n else void readyRef.current?.then(apply);\n },\n }),\n []\n );\n\n return (\n <div>\n <div>\n <div\n ref={hostRef}\n id={id}\n className={[\n 'kb-component',\n isDark ? 'kb-component--dark' : '',\n className ?? '',\n ]\n .filter(Boolean)\n .join(' ')}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-disabled={disabled || undefined}\n style={{\n isolation: 'isolate',\n opacity: disabled ? 0.65 : undefined,\n pointerEvents: disabled ? 'none' : undefined,\n }}\n />\n </div>\n\n {showPreview && (\n <div>\n <div>\n <h5>Markdown Output</h5>\n <pre>{md}</pre>\n </div>\n </div>\n )}\n </div>\n );\n }\n);\n\nRichEditor.displayName = 'RichEditor';\n\nexport { RichEditor };\n","import React, { useEffect, useRef } from 'react';\n\nimport { CoreEditor } from '@kerebron/editor';\nimport { CodeEditorKit } from '@kerebron/editor-kits/CodeEditorKit';\nimport { createAssetLoad } from '@kerebron/wasm/web';\n\nexport interface CodeEditorProps {\n /** Initial source code to load into the editor. */\n value?: string;\n /** Called with the editor's contents whenever they change. */\n onChange?: (value: string) => void;\n /** Language/grammar to use for syntax highlighting. Defaults to `typescript`. */\n lang?: string;\n}\n\nconst CodeEditor: React.FC<CodeEditorProps> = ({\n value = '',\n onChange,\n lang = 'typescript',\n}) => {\n const editorRef = useRef<HTMLDivElement>(null);\n const editorInstance = useRef<CoreEditor | null>(null);\n const onChangeRef = useRef(onChange);\n onChangeRef.current = onChange;\n\n useEffect(() => {\n const root = editorRef.current;\n if (!root) return;\n\n const applySelectLabel = () => {\n root.querySelectorAll('select.codejar-select').forEach((element) => {\n if (!element.getAttribute('aria-label')) {\n element.setAttribute('aria-label', 'Code editor language');\n }\n });\n };\n\n applySelectLabel();\n const observer = new MutationObserver(() => applySelectLabel());\n observer.observe(root, { childList: true, subtree: true });\n return () => observer.disconnect();\n }, []);\n\n useEffect(() => {\n if (!editorRef.current) return;\n\n // Initialize the editor\n const editor = CoreEditor.create({\n element: editorRef.current,\n uri: 'file:///untitled.ts',\n assetLoad: createAssetLoad('/kerebron-wasm'),\n editorKits: [new CodeEditorKit(lang)],\n });\n\n editorInstance.current = editor;\n\n // Surface edits to callers.\n const onTransaction = async () => {\n if (!editorInstance.current) return;\n\n try {\n const buffer = await editorInstance.current.saveDocument('text/plain');\n onChangeRef.current?.(new globalThis.TextDecoder().decode(buffer));\n } catch (err) {\n console.error('Failed to read code:', err);\n }\n };\n\n editor.addEventListener('transaction', onTransaction);\n\n // Seed initial content on mount.\n if (value) {\n editor\n .loadDocumentText('text/plain', value)\n .catch((err) => console.error('Failed to load code:', err));\n }\n\n // Cleanup on unmount\n return () => {\n editor.removeEventListener('transaction', onTransaction);\n editor.destroy();\n };\n // Initial `value`/`lang` are intentionally only applied on mount.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n return (\n <div>\n <div>\n <div ref={editorRef} className=\"kb-component\" />\n </div>\n </div>\n );\n};\n\nCodeEditor.displayName = 'CodeEditor';\n\nexport { CodeEditor };\n"]}
|
package/dist/kerebron.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useIsDarkMode } from './chunk-RUGHNFQG.js';
|
|
2
|
+
import './chunk-PX6F3LHL.js';
|
|
2
3
|
import { forwardRef, useRef, useState, useEffect, useImperativeHandle } from 'react';
|
|
3
4
|
import { CoreEditor } from '@kerebron/editor';
|
|
4
5
|
import { createAssetLoad } from '@kerebron/wasm/web';
|
|
@@ -23,7 +24,7 @@ var SafeAdvancedEditorKit = class {
|
|
|
23
24
|
};
|
|
24
25
|
async function createEditorKits(config) {
|
|
25
26
|
if (!config) return [new SafeAdvancedEditorKit(false)];
|
|
26
|
-
const { HuddleYjsKit, defaultWsUrl } = await import('./collabKit-
|
|
27
|
+
const { HuddleYjsKit, defaultWsUrl } = await import('./collabKit-SJPDPXU4.js');
|
|
27
28
|
const url = config.wsUrl ?? defaultWsUrl();
|
|
28
29
|
return [
|
|
29
30
|
new SafeAdvancedEditorKit(true),
|
package/dist/kerebron.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/RichEditor/editorKits.ts","../src/components/RichEditor/RichEditor.tsx","../src/components/RichEditor/CodeEditor.tsx"],"names":["RichEditor","useRef","useEffect","CoreEditor","createAssetLoad","jsx"],"mappings":";;;;;;;;AA4DA,IAAM,gBAAA,GAAmB,CAAC,cAAA,EAAgB,OAAO,CAAA;AAIjD,IAAM,wBAAN,MAAiD;AAAA,EAE/C,YAA6B,SAAA,EAAoB;AAApB,IAAA,IAAA,CAAA,SAAA,GAAA,SAAA;AAAA,EAAqB;AAAA,EAArB,SAAA;AAAA,EAD7B,IAAA,GAAO,iBAAA;AAAA,EAGP,aAAA,GAAgB;AACd,IAAA,MAAM,OAAA,GAAoB,CAAC,GAAG,gBAAgB,CAAA;AAC9C,IAAA,IAAI,IAAA,CAAK,SAAA,EAAW,OAAA,CAAQ,IAAA,CAAK,SAAS,CAAA;AAE1C,IAAA,OAAO,IAAI,iBAAA,EAAkB,CAC1B,aAAA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Ac,KAAK,CAAA,CACpC,KAAA,CAAM,CAAC,GAAA,KAAQ,OAAA,CAAQ,KAAA,CAAM,sBAAA,EAAwB,GAAG,CAAC,CAAA;AAAA,IAC9D;AAGA,IAAA,OAAO,MAAM;AACX,MAAA,MAAA,CAAO,mBAAA,CAAoB,eAAe,aAAa,CAAA;AACvD,MAAA,MAAA,CAAO,OAAA,EAAQ;AAAA,IACjB,CAAA;AAAA,EAGF,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,uBACEC,GAAAA,CAAC,KAAA,EAAA,EACC,QAAA,kBAAAA,IAAC,KAAA,EAAA,EACC,QAAA,kBAAAA,GAAAA,CAAC,KAAA,EAAA,EAAI,GAAA,EAAK,SAAA,EAAW,SAAA,EAAU,cAAA,EAAe,GAChD,CAAA,EACF,CAAA;AAEJ;AAEA,UAAA,CAAW,WAAA,GAAc,YAAA","file":"kerebron.js","sourcesContent":["/**\n * Editor kit assembly for {@link RichEditor}, for both plain and collaborative\n * (Yjs) mode.\n *\n * Both modes start from {@link AdvancedEditorKit} and drop the extensions that\n * are unsafe for our usage — see {@link unsafeExtensions} — then collaborative\n * mode adds the Yjs pieces on top.\n *\n * The Yjs pieces live in `collabKit.ts` behind a dynamic `import()`, so\n * `@kerebron/extension-yjs`, `yjs` and `y-protocols` remain truly optional\n * peers — plain-mode consumers never load them.\n */\nimport type { EditorKit } from '@kerebron/editor';\nimport { AdvancedEditorKit } from '@kerebron/editor-kits/AdvancedEditorKit';\n\nexport interface CollabConfig {\n /** Room id — one shared document per room (e.g. a post id). */\n room: string;\n /**\n * WebSocket base URL for the Yjs relay. Defaults to\n * `<ws|wss>://<location.host>/yjs`. The room id is appended by the provider.\n */\n wsUrl?: string;\n /** Extra query params for the socket (e.g. `{ token }` for auth). */\n params?: Record<string, string>;\n /**\n * Who this editor is, published on awareness (`kerebron:user`) so peers see\n * a named, coloured cursor. Without it remote cursors do not render — the\n * position plugin skips awareness states that carry no user — and the\n * `id` is what the cursor colour is derived from (kerebron's `User` shape).\n */\n user?: { id: string; name: string; color?: string };\n /**\n * Custom WebSocket implementation handed to the Yjs provider — e.g. a\n * loopback socket for demos/tests, or a polyfill outside the browser.\n * Defaults to `globalThis.WebSocket`.\n */\n WebSocketPolyfill?: typeof globalThis.WebSocket;\n}\n\n/**\n * Extensions dropped from {@link AdvancedEditorKit}, and why.\n *\n * `autocomplete` and `hover` debounce their DOM handlers (200ms) and then call\n * `dispatchMeta`, which reads `this.editor.state` with no guard that the editor\n * is still alive. Any teardown or document swap inside that debounce window\n * lands the deferred call on a dead view and throws\n * `null.matchesNode()` inside ProseMirror's `EditorView.updateStateInner`,\n * leaving the view permanently broken. Two ways to hit it:\n * - remount (e.g. a `key` change) while the pointer is over the editor, which\n * fires the debounced `onMouseLeave` after the view is destroyed;\n * - a Yjs remote update replacing the document tree under a pending callback.\n * The first applies to *every* editor, so both extensions come out in both\n * modes. No functional cost — autocomplete popups and node-hover tooltips are\n * compositor conveniences, not required for editing.\n *\n * `history` is collab-only: ExtensionYjs supplies its own CRDT-aware undo/redo\n * and the editor throws `Extension conflict: yjs vs history` if both are\n * present. Plain mode keeps it, so undo/redo still works there.\n */\nconst unsafeExtensions = ['autocomplete', 'hover'] as const;\n\n/** {@link AdvancedEditorKit} minus {@link unsafeExtensions} (and, for collab\n * mode, minus `history`). */\nclass SafeAdvancedEditorKit implements EditorKit {\n name = 'advanced-editor';\n constructor(private readonly forCollab: boolean) {}\n\n getExtensions() {\n const dropped: string[] = [...unsafeExtensions];\n if (this.forCollab) dropped.push('history');\n\n return new AdvancedEditorKit()\n .getExtensions()\n .filter(\n (extension) =>\n !('name' in extension && dropped.includes(extension.name))\n );\n }\n}\n\n/** MarkYChange + ExtensionYjs live in `collabKit.ts` (lazy-loaded). */\n\n/**\n * Build the editor kits for a session. Pass `config` to join a collaborative\n * room; omit it for a plain local editor.\n *\n * Async because collaborative mode lazy-loads the Yjs kit (and its optional\n * peer deps) on first use; plain mode resolves immediately.\n */\nexport async function createEditorKits(\n config?: CollabConfig\n): Promise<EditorKit[]> {\n if (!config) return [new SafeAdvancedEditorKit(false)];\n\n const { HuddleYjsKit, defaultWsUrl } = await import('./collabKit');\n const url = config.wsUrl ?? defaultWsUrl();\n return [\n new SafeAdvancedEditorKit(true),\n new HuddleYjsKit(\n url,\n config.params ?? {},\n config.WebSocketPolyfill,\n config.user\n ),\n ];\n}\n","'use client';\n\nimport {\n forwardRef,\n useEffect,\n useImperativeHandle,\n useRef,\n useState,\n} from 'react';\n\nimport { CoreEditor, type AssetLoad } from '@kerebron/editor';\nimport { createAssetLoad } from '@kerebron/wasm/web';\n\nimport { useIsDarkMode } from '../../hooks/useIsDarkMode';\nimport { createEditorKits, type CollabConfig } from './editorKits';\n\nexport type { CollabConfig } from './editorKits';\n\nconst MARKDOWN_TYPE = 'text/x-markdown';\n\n/**\n * The markdown converter's tree-sitter WASM init is not concurrency-safe, so\n * every editor's *first* load queues behind the previous one. Later loads (a\n * `value` change) are free — by then the grammars are warm.\n */\nlet initialLoadQueue: Promise<unknown> = Promise.resolve();\n\nfunction queueInitialLoad(load: () => Promise<void>): Promise<void> {\n const queued = initialLoadQueue.catch(() => undefined).then(load);\n initialLoadQueue = queued.catch(() => undefined);\n return queued;\n}\n\nexport interface RichEditorProps {\n /** Markdown to load. Changing it reloads the editor unless `collab` is set. */\n value?: string;\n /** Called with the editor's markdown content whenever it changes. */\n onChange?: (value: string) => void;\n /** Whether to render the live markdown output preview. Defaults to `false`. */\n showPreview?: boolean;\n /**\n * Enable live collaborative editing (Yjs) for the given room. When set, the\n * editor connects to the `/yjs` websocket relay and every peer in the same\n * `room` co-edits one shared document. Uncontrolled like `value` — remount via\n * `key` to switch rooms.\n */\n collab?: CollabConfig;\n /** Read-only surface: no typing, and the content dims. */\n disabled?: boolean;\n /**\n * Id for the editor host element — an `aria-labelledby`/`aria-describedby`\n * anchor. The host is a `div`, not a labelable control, so a\n * `<label htmlFor>` will not associate; name the editor with `aria-label`\n * or `aria-labelledby` instead.\n */\n id?: string;\n /** Extra classes on the editor surface, beside `kb-component`. */\n className?: string;\n 'aria-label'?: string;\n 'aria-labelledby'?: string;\n /**\n * Where the tree-sitter WASM grammars load from. Defaults to\n * `createAssetLoad('/kerebron-wasm')`; supply your own when the host serves\n * `@kerebron/wasm`'s `assets/` somewhere else.\n */\n assetLoad?: AssetLoad;\n}\n\nexport interface RichEditorHandle {\n /**\n * The editor's markdown, awaiting the initial load. `onChange` can lag the\n * last keystroke, so read this on submit rather than trusting mirrored state.\n */\n getContent: () => Promise<string>;\n /** Focus the editor, restoring the caret where the writer left it. */\n focus: () => void;\n}\n\n/**\n * Markdown editor over Kerebron's `CoreEditor`.\n *\n * The editor mounts into a **disposable child div**: `CoreEditor.destroy()`\n * replaces its host element with a clone, which would strand React's ref (and,\n * under StrictMode's double-mount, leave the live editor detached behind a\n * dead clone).\n */\nconst RichEditor = forwardRef<RichEditorHandle, RichEditorProps>(\n function RichEditor(\n {\n value = '',\n onChange,\n showPreview = false,\n collab,\n disabled = false,\n id,\n className,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n assetLoad,\n },\n ref\n ) {\n const isDark = useIsDarkMode();\n const hostRef = useRef<HTMLDivElement>(null);\n const editorInstance = useRef<CoreEditor | null>(null);\n const onChangeRef = useRef(onChange);\n onChangeRef.current = onChange;\n // Mirrors what the editor last held, so an echo of our own `onChange`\n // doesn't reload the document out from under the caret.\n const valueRef = useRef(value);\n const readyRef = useRef<Promise<void> | null>(null);\n const loadingRef = useRef(false);\n const disabledRef = useRef(disabled);\n\n const [md, setMd] = useState<string>('');\n\n useEffect(() => {\n disabledRef.current = disabled;\n editorInstance.current?.view.setProps({\n editable: () => !disabledRef.current,\n });\n }, [disabled]);\n\n useEffect(() => {\n // In collab mode the CRDT owns the content; reloading would fight it.\n if (collab || value === valueRef.current) return;\n valueRef.current = value;\n const editor = editorInstance.current;\n if (!editor) return;\n\n loadingRef.current = true;\n void editor\n .loadDocumentText(MARKDOWN_TYPE, value)\n .catch(() => undefined)\n .finally(() => {\n if (editorInstance.current === editor) loadingRef.current = false;\n });\n // `collab` is fixed for the lifetime of the instance.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [value]);\n\n useEffect(() => {\n if (!hostRef.current) return;\n const host = hostRef.current;\n\n // Set on cleanup so async continuations (kit loading and the\n // `loadDocumentText` chain) don't touch the editor after `destroy()`.\n let disposed = false;\n let editor: CoreEditor | null = null;\n\n const mount = document.createElement('div');\n host.appendChild(mount);\n\n // Listen to transactions and update markdown preview\n const onTransaction = async () => {\n // Programmatic loads are not edits — reporting them would echo the\n // caller's own `value` back through `onChange`.\n if (loadingRef.current || !editorInstance.current) return;\n\n try {\n const buffer =\n await editorInstance.current.saveDocument(MARKDOWN_TYPE);\n const markdown = new globalThis.TextDecoder().decode(buffer);\n if (disposed) return;\n valueRef.current = markdown;\n setMd(markdown);\n onChangeRef.current?.(markdown);\n } catch (err) {\n console.error('Failed to save markdown:', err);\n }\n };\n\n // Initialize the editor. Both modes drop the teardown-unsafe extensions;\n // collaborative mode additionally swaps `history` for the Yjs CRDT sync\n // and lazy-loads the Yjs kit (see `editorKits.ts` for why).\n const setup = async () => {\n const editorKits = await createEditorKits(collab);\n if (disposed) return;\n\n editor = CoreEditor.create({\n element: mount,\n uri: 'file:///untitled.md',\n assetLoad: assetLoad ?? createAssetLoad('/kerebron-wasm'),\n editorKits,\n readOnly: disabledRef.current,\n });\n\n editorInstance.current = editor;\n // The contenteditable surface has no implicit ARIA role, so labeling\n // attributes are only permitted alongside an explicit textbox role.\n const surfaceAttributes =\n ariaLabel || ariaLabelledBy\n ? {\n role: 'textbox',\n 'aria-multiline': 'true',\n ...(ariaLabel ? { 'aria-label': ariaLabel } : {}),\n ...(ariaLabelledBy\n ? { 'aria-labelledby': ariaLabelledBy }\n : {}),\n }\n : null;\n editor.view.setProps({\n editable: () => !disabledRef.current,\n ...(surfaceAttributes ? { attributes: surfaceAttributes } : {}),\n });\n editor.addEventListener('transaction', onTransaction);\n\n // Seed initial content, then populate the preview once on mount.\n //\n // In collaborative mode we still load the local markdown first, then\n // join the room: the Yjs binding seeds an *empty* shared document from\n // this content on the first join, and overwrites the editor with the\n // shared content when the room already has edits — so the stored\n // markdown is the starting point without ever double-inserting.\n const joinRoom = () => {\n if (collab && editor && !disposed) {\n (\n editor.run as Record<string, (...args: unknown[]) => boolean>\n ).changeRoom?.(collab.room);\n reseedWhenRoomStaysEmpty();\n }\n };\n\n // The Yjs binding is supposed to seed an empty room from the local\n // content, but the sync import can land as an overwrite that blanks\n // the just-loaded seed (observed with extension-yjs 0.8.x). Heal it:\n // once the join settles, an empty document with a non-empty seed\n // means nobody's content won — reload the seed, which the binding\n // then pushes into the room. Joiners pass no value, so exactly one\n // participant ever does this.\n const seed = valueRef.current;\n const reseedWhenRoomStaysEmpty = () => {\n if (!seed) return;\n const check = async (attempt: number) => {\n if (disposed || !editorInstance.current) return;\n try {\n const buffer =\n await editorInstance.current.saveDocument(MARKDOWN_TYPE);\n const current = new globalThis.TextDecoder()\n .decode(buffer)\n .trim();\n if (disposed || !editorInstance.current) return;\n if (current) return; // somebody's content arrived — done\n if (attempt >= 2) {\n await editorInstance.current.loadDocumentText(\n MARKDOWN_TYPE,\n seed\n );\n return;\n }\n setTimeout(() => void check(attempt + 1), 300);\n } catch {\n // A failed probe must not break the editor; the room stays as-is.\n }\n };\n setTimeout(() => void check(0), 300);\n };\n\n if (valueRef.current) {\n await queueInitialLoad(() =>\n editor!.loadDocumentText(MARKDOWN_TYPE, valueRef.current)\n );\n await onTransaction();\n joinRoom();\n } else {\n void onTransaction();\n joinRoom();\n }\n };\n\n readyRef.current = setup().catch((err) =>\n console.error('Failed to set up editor:', err)\n );\n\n // Cleanup on unmount\n return () => {\n disposed = true;\n editorInstance.current = null; // makes onTransaction's guard effective\n editor?.removeEventListener('transaction', onTransaction);\n editor?.destroy();\n readyRef.current = null;\n host.replaceChildren();\n };\n // Initial `value`/`collab` are intentionally only applied on mount\n // (uncontrolled). Remount via `key` to switch rooms.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n useImperativeHandle(\n ref,\n () => ({\n getContent: async (): Promise<string> => {\n await readyRef.current;\n const editor = editorInstance.current;\n if (!editor) return valueRef.current;\n const buffer = await editor.saveDocument(MARKDOWN_TYPE);\n const markdown = new globalThis.TextDecoder().decode(buffer);\n valueRef.current = markdown;\n return markdown;\n },\n focus: (): void => {\n const apply = (): void => {\n const view = editorInstance.current?.view as\n | { focus?: () => void }\n | undefined;\n if (view?.focus) {\n view.focus();\n return;\n }\n hostRef.current\n ?.querySelector<HTMLElement>('[contenteditable=\"true\"], textarea')\n ?.focus();\n };\n // Callers focus on mount; the editor may still be loading its kits.\n if (editorInstance.current) apply();\n else void readyRef.current?.then(apply);\n },\n }),\n []\n );\n\n return (\n <div>\n <div>\n <div\n ref={hostRef}\n id={id}\n className={[\n 'kb-component',\n isDark ? 'kb-component--dark' : '',\n className ?? '',\n ]\n .filter(Boolean)\n .join(' ')}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-disabled={disabled || undefined}\n style={{\n isolation: 'isolate',\n opacity: disabled ? 0.65 : undefined,\n pointerEvents: disabled ? 'none' : undefined,\n }}\n />\n </div>\n\n {showPreview && (\n <div>\n <div>\n <h5>Markdown Output</h5>\n <pre>{md}</pre>\n </div>\n </div>\n )}\n </div>\n );\n }\n);\n\nRichEditor.displayName = 'RichEditor';\n\nexport { RichEditor };\n","import React, { useEffect, useRef } from 'react';\n\nimport { CoreEditor } from '@kerebron/editor';\nimport { CodeEditorKit } from '@kerebron/editor-kits/CodeEditorKit';\nimport { createAssetLoad } from '@kerebron/wasm/web';\n\nexport interface CodeEditorProps {\n /** Initial source code to load into the editor. */\n value?: string;\n /** Called with the editor's contents whenever they change. */\n onChange?: (value: string) => void;\n /** Language/grammar to use for syntax highlighting. Defaults to `typescript`. */\n lang?: string;\n}\n\nconst CodeEditor: React.FC<CodeEditorProps> = ({\n value = '',\n onChange,\n lang = 'typescript',\n}) => {\n const editorRef = useRef<HTMLDivElement>(null);\n const editorInstance = useRef<CoreEditor | null>(null);\n const onChangeRef = useRef(onChange);\n onChangeRef.current = onChange;\n\n useEffect(() => {\n const root = editorRef.current;\n if (!root) return;\n\n const applySelectLabel = () => {\n root.querySelectorAll('select.codejar-select').forEach((element) => {\n if (!element.getAttribute('aria-label')) {\n element.setAttribute('aria-label', 'Code editor language');\n }\n });\n };\n\n applySelectLabel();\n const observer = new MutationObserver(() => applySelectLabel());\n observer.observe(root, { childList: true, subtree: true });\n return () => observer.disconnect();\n }, []);\n\n useEffect(() => {\n if (!editorRef.current) return;\n\n // Initialize the editor\n const editor = CoreEditor.create({\n element: editorRef.current,\n uri: 'file:///untitled.ts',\n assetLoad: createAssetLoad('/kerebron-wasm'),\n editorKits: [new CodeEditorKit(lang)],\n });\n\n editorInstance.current = editor;\n\n // Surface edits to callers.\n const onTransaction = async () => {\n if (!editorInstance.current) return;\n\n try {\n const buffer = await editorInstance.current.saveDocument('text/plain');\n onChangeRef.current?.(new globalThis.TextDecoder().decode(buffer));\n } catch (err) {\n console.error('Failed to read code:', err);\n }\n };\n\n editor.addEventListener('transaction', onTransaction);\n\n // Seed initial content on mount.\n if (value) {\n editor\n .loadDocumentText('text/plain', value)\n .catch((err) => console.error('Failed to load code:', err));\n }\n\n // Cleanup on unmount\n return () => {\n editor.removeEventListener('transaction', onTransaction);\n editor.destroy();\n };\n // Initial `value`/`lang` are intentionally only applied on mount.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n return (\n <div>\n <div>\n <div ref={editorRef} className=\"kb-component\" />\n </div>\n </div>\n );\n};\n\nCodeEditor.displayName = 'CodeEditor';\n\nexport { CodeEditor };\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/components/RichEditor/editorKits.ts","../src/components/RichEditor/RichEditor.tsx","../src/components/RichEditor/CodeEditor.tsx"],"names":["RichEditor","useRef","useEffect","CoreEditor","createAssetLoad","jsx"],"m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AAe,OAAA,EAAS;AAE7B,MAAA,IAAI;AACF,QAAA,MAAM,MAAA,GAAS,MAAM,cAAA,CAAe,OAAA,CAAQ,aAAa,YAAY,CAAA;AACrE,QAAA,WAAA,CAAY,UAAU,IAAI,UAAA,CAAW,aAAY,CAAE,MAAA,CAAO,MAAM,CAAC,CAAA;AAAA,MACnE,SAAS,GAAA,EAAK;AACZ,QAAA,OAAA,CAAQ,KAAA,CAAM,wBAAwB,GAAG,CAAA;AAAA,MAC3C;AAAA,IACF,CAAA;AAEA,IAAA,MAAA,CAAO,gBAAA,CAAiB,eAAe,aAAa,CAAA;AAGpD,IAAA,IAAI,KAAA,EAAO;AACT,MAAA,MAAA,CACG,gBAAA,CAAiB,YAAA,EAAc,KAAK,CAAA,CACpC,KAAA,CAAM,CAAC,GAAA,KAAQ,OAAA,CAAQ,KAAA,CAAM,sBAAA,EAAwB,GAAG,CAAC,CAAA;AAAA,IAC9D;AAGA,IAAA,OAAO,MAAM;AACX,MAAA,MAAA,CAAO,mBAAA,CAAoB,eAAe,aAAa,CAAA;AACvD,MAAA,MAAA,CAAO,OAAA,EAAQ;AAAA,IACjB,CAAA;AAAA,EAGF,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,uBACEC,GAAAA,CAAC,KAAA,EAAA,EACC,QAAA,kBAAAA,IAAC,KAAA,EAAA,EACC,QAAA,kBAAAA,GAAAA,CAAC,KAAA,EAAA,EAAI,GAAA,EAAK,SAAA,EAAW,SAAA,EAAU,cAAA,EAAe,GAChD,CAAA,EACF,CAAA;AAEJ;AAEA,UAAA,CAAW,WAAA,GAAc,YAAA","file":"kerebron.js","sourcesContent":["/**\n * Editor kit assembly for {@link RichEditor}, for both plain and collaborative\n * (Yjs) mode.\n *\n * Both modes start from {@link AdvancedEditorKit} and drop the extensions that\n * are unsafe for our usage — see {@link unsafeExtensions} — then collaborative\n * mode adds the Yjs pieces on top.\n *\n * The Yjs pieces live in `collabKit.ts` behind a dynamic `import()`, so\n * `@kerebron/extension-yjs`, `yjs` and `y-protocols` remain truly optional\n * peers — plain-mode consumers never load them.\n */\nimport type { EditorKit } from '@kerebron/editor';\nimport { AdvancedEditorKit } from '@kerebron/editor-kits/AdvancedEditorKit';\n\nexport interface CollabConfig {\n /** Room id — one shared document per room (e.g. a post id). */\n room: string;\n /**\n * WebSocket base URL for the Yjs relay. Defaults to\n * `<ws|wss>://<location.host>/yjs`. The room id is appended by the provider.\n */\n wsUrl?: string;\n /** Extra query params for the socket (e.g. `{ token }` for auth). */\n params?: Record<string, string>;\n /**\n * Who this editor is, published on awareness (`kerebron:user`) so peers see\n * a named, coloured cursor. Without it remote cursors do not render — the\n * position plugin skips awareness states that carry no user — and the\n * `id` is what the cursor colour is derived from (kerebron's `User` shape).\n */\n user?: { id: string; name: string; color?: string };\n /**\n * Custom WebSocket implementation handed to the Yjs provider — e.g. a\n * loopback socket for demos/tests, or a polyfill outside the browser.\n * Defaults to `globalThis.WebSocket`.\n */\n WebSocketPolyfill?: typeof globalThis.WebSocket;\n}\n\n/**\n * Extensions dropped from {@link AdvancedEditorKit}, and why.\n *\n * `autocomplete` and `hover` debounce their DOM handlers (200ms) and then call\n * `dispatchMeta`, which reads `this.editor.state` with no guard that the editor\n * is still alive. Any teardown or document swap inside that debounce window\n * lands the deferred call on a dead view and throws\n * `null.matchesNode()` inside ProseMirror's `EditorView.updateStateInner`,\n * leaving the view permanently broken. Two ways to hit it:\n * - remount (e.g. a `key` change) while the pointer is over the editor, which\n * fires the debounced `onMouseLeave` after the view is destroyed;\n * - a Yjs remote update replacing the document tree under a pending callback.\n * The first applies to *every* editor, so both extensions come out in both\n * modes. No functional cost — autocomplete popups and node-hover tooltips are\n * compositor conveniences, not required for editing.\n *\n * `history` is collab-only: ExtensionYjs supplies its own CRDT-aware undo/redo\n * and the editor throws `Extension conflict: yjs vs history` if both are\n * present. Plain mode keeps it, so undo/redo still works there.\n */\nconst unsafeExtensions = ['autocomplete', 'hover'] as const;\n\n/** {@link AdvancedEditorKit} minus {@link unsafeExtensions} (and, for collab\n * mode, minus `history`). */\nclass SafeAdvancedEditorKit implements EditorKit {\n name = 'advanced-editor';\n constructor(private readonly forCollab: boolean) {}\n\n getExtensions() {\n const dropped: string[] = [...unsafeExtensions];\n if (this.forCollab) dropped.push('history');\n\n return new AdvancedEditorKit()\n .getExtensions()\n .filter(\n (extension) =>\n !('name' in extension && dropped.includes(extension.name))\n );\n }\n}\n\n/** MarkYChange + ExtensionYjs live in `collabKit.ts` (lazy-loaded). */\n\n/**\n * Build the editor kits for a session. Pass `config` to join a collaborative\n * room; omit it for a plain local editor.\n *\n * Async because collaborative mode lazy-loads the Yjs kit (and its optional\n * peer deps) on first use; plain mode resolves immediately.\n */\nexport async function createEditorKits(\n config?: CollabConfig\n): Promise<EditorKit[]> {\n if (!config) return [new SafeAdvancedEditorKit(false)];\n\n const { HuddleYjsKit, defaultWsUrl } = await import('./collabKit');\n const url = config.wsUrl ?? defaultWsUrl();\n return [\n new SafeAdvancedEditorKit(true),\n new HuddleYjsKit(\n url,\n config.params ?? {},\n config.WebSocketPolyfill,\n config.user\n ),\n ];\n}\n","'use client';\n\nimport {\n forwardRef,\n useEffect,\n useImperativeHandle,\n useRef,\n useState,\n} from 'react';\n\nimport { CoreEditor, type AssetLoad } from '@kerebron/editor';\nimport { createAssetLoad } from '@kerebron/wasm/web';\n\nimport { useIsDarkMode } from '../../hooks/useIsDarkMode';\nimport { createEditorKits, type CollabConfig } from './editorKits';\n\nexport type { CollabConfig } from './editorKits';\n\nconst MARKDOWN_TYPE = 'text/x-markdown';\n\n/**\n * The markdown converter's tree-sitter WASM init is not concurrency-safe, so\n * every editor's *first* load queues behind the previous one. Later loads (a\n * `value` change) are free — by then the grammars are warm.\n */\nlet initialLoadQueue: Promise<unknown> = Promise.resolve();\n\nfunction queueInitialLoad(load: () => Promise<void>): Promise<void> {\n const queued = initialLoadQueue.catch(() => undefined).then(load);\n initialLoadQueue = queued.catch(() => undefined);\n return queued;\n}\n\nexport interface RichEditorProps {\n /** Markdown to load. Changing it reloads the editor unless `collab` is set. */\n value?: string;\n /** Called with the editor's markdown content whenever it changes. */\n onChange?: (value: string) => void;\n /** Whether to render the live markdown output preview. Defaults to `false`. */\n showPreview?: boolean;\n /**\n * Enable live collaborative editing (Yjs) for the given room. When set, the\n * editor connects to the `/yjs` websocket relay and every peer in the same\n * `room` co-edits one shared document. Uncontrolled like `value` — remount via\n * `key` to switch rooms.\n */\n collab?: CollabConfig;\n /** Read-only surface: no typing, and the content dims. */\n disabled?: boolean;\n /**\n * Id for the editor host element — an `aria-labelledby`/`aria-describedby`\n * anchor. The host is a `div`, not a labelable control, so a\n * `<label htmlFor>` will not associate; name the editor with `aria-label`\n * or `aria-labelledby` instead.\n */\n id?: string;\n /** Extra classes on the editor surface, beside `kb-component`. */\n className?: string;\n 'aria-label'?: string;\n 'aria-labelledby'?: string;\n /**\n * Where the tree-sitter WASM grammars load from. Defaults to\n * `createAssetLoad('/kerebron-wasm')`; supply your own when the host serves\n * `@kerebron/wasm`'s `assets/` somewhere else.\n */\n assetLoad?: AssetLoad;\n}\n\nexport interface RichEditorHandle {\n /**\n * The editor's markdown, awaiting the initial load. `onChange` can lag the\n * last keystroke, so read this on submit rather than trusting mirrored state.\n */\n getContent: () => Promise<string>;\n /** Focus the editor, restoring the caret where the writer left it. */\n focus: () => void;\n}\n\n/**\n * Markdown editor over Kerebron's `CoreEditor`.\n *\n * The editor mounts into a **disposable child div**: `CoreEditor.destroy()`\n * replaces its host element with a clone, which would strand React's ref (and,\n * under StrictMode's double-mount, leave the live editor detached behind a\n * dead clone).\n */\nconst RichEditor = forwardRef<RichEditorHandle, RichEditorProps>(\n function RichEditor(\n {\n value = '',\n onChange,\n showPreview = false,\n collab,\n disabled = false,\n id,\n className,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n assetLoad,\n },\n ref\n ) {\n const isDark = useIsDarkMode();\n const hostRef = useRef<HTMLDivElement>(null);\n const editorInstance = useRef<CoreEditor | null>(null);\n const onChangeRef = useRef(onChange);\n onChangeRef.current = onChange;\n // Mirrors what the editor last held, so an echo of our own `onChange`\n // doesn't reload the document out from under the caret.\n const valueRef = useRef(value);\n const readyRef = useRef<Promise<void> | null>(null);\n const loadingRef = useRef(false);\n const disabledRef = useRef(disabled);\n\n const [md, setMd] = useState<string>('');\n\n useEffect(() => {\n disabledRef.current = disabled;\n editorInstance.current?.view.setProps({\n editable: () => !disabledRef.current,\n });\n }, [disabled]);\n\n useEffect(() => {\n // In collab mode the CRDT owns the content; reloading would fight it.\n if (collab || value === valueRef.current) return;\n valueRef.current = value;\n const editor = editorInstance.current;\n if (!editor) return;\n\n loadingRef.current = true;\n void editor\n .loadDocumentText(MARKDOWN_TYPE, value)\n .catch(() => undefined)\n .finally(() => {\n if (editorInstance.current === editor) loadingRef.current = false;\n });\n // `collab` is fixed for the lifetime of the instance.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [value]);\n\n useEffect(() => {\n if (!hostRef.current) return;\n const host = hostRef.current;\n\n // Set on cleanup so async continuations (kit loading and the\n // `loadDocumentText` chain) don't touch the editor after `destroy()`.\n let disposed = false;\n let editor: CoreEditor | null = null;\n\n const mount = document.createElement('div');\n host.appendChild(mount);\n\n // Listen to transactions and update markdown preview\n const onTransaction = async () => {\n // Programmatic loads are not edits — reporting them would echo the\n // caller's own `value` back through `onChange`.\n if (loadingRef.current || !editorInstance.current) return;\n\n try {\n const buffer =\n await editorInstance.current.saveDocument(MARKDOWN_TYPE);\n const markdown = new globalThis.TextDecoder().decode(buffer);\n if (disposed) return;\n valueRef.current = markdown;\n setMd(markdown);\n onChangeRef.current?.(markdown);\n } catch (err) {\n console.error('Failed to save markdown:', err);\n }\n };\n\n // Initialize the editor. Both modes drop the teardown-unsafe extensions;\n // collaborative mode additionally swaps `history` for the Yjs CRDT sync\n // and lazy-loads the Yjs kit (see `editorKits.ts` for why).\n const setup = async () => {\n const editorKits = await createEditorKits(collab);\n if (disposed) return;\n\n editor = CoreEditor.create({\n element: mount,\n uri: 'file:///untitled.md',\n assetLoad: assetLoad ?? createAssetLoad('/kerebron-wasm'),\n editorKits,\n readOnly: disabledRef.current,\n });\n\n editorInstance.current = editor;\n // The contenteditable surface has no implicit ARIA role, so labeling\n // attributes are only permitted alongside an explicit textbox role.\n const surfaceAttributes =\n ariaLabel || ariaLabelledBy\n ? {\n role: 'textbox',\n 'aria-multiline': 'true',\n ...(ariaLabel ? { 'aria-label': ariaLabel } : {}),\n ...(ariaLabelledBy\n ? { 'aria-labelledby': ariaLabelledBy }\n : {}),\n }\n : null;\n editor.view.setProps({\n editable: () => !disabledRef.current,\n ...(surfaceAttributes ? { attributes: surfaceAttributes } : {}),\n });\n editor.addEventListener('transaction', onTransaction);\n\n // Seed initial content, then populate the preview once on mount.\n //\n // In collaborative mode we still load the local markdown first, then\n // join the room: the Yjs binding seeds an *empty* shared document from\n // this content on the first join, and overwrites the editor with the\n // shared content when the room already has edits — so the stored\n // markdown is the starting point without ever double-inserting.\n const joinRoom = () => {\n if (collab && editor && !disposed) {\n (\n editor.run as Record<string, (...args: unknown[]) => boolean>\n ).changeRoom?.(collab.room);\n reseedWhenRoomStaysEmpty();\n }\n };\n\n // The Yjs binding is supposed to seed an empty room from the local\n // content, but the sync import can land as an overwrite that blanks\n // the just-loaded seed (observed with extension-yjs 0.8.x). Heal it:\n // once the join settles, an empty document with a non-empty seed\n // means nobody's content won — reload the seed, which the binding\n // then pushes into the room. Joiners pass no value, so exactly one\n // participant ever does this.\n const seed = valueRef.current;\n const reseedWhenRoomStaysEmpty = () => {\n if (!seed) return;\n const check = async (attempt: number) => {\n if (disposed || !editorInstance.current) return;\n try {\n const buffer =\n await editorInstance.current.saveDocument(MARKDOWN_TYPE);\n const current = new globalThis.TextDecoder()\n .decode(buffer)\n .trim();\n if (disposed || !editorInstance.current) return;\n if (current) return; // somebody's content arrived — done\n if (attempt >= 2) {\n await editorInstance.current.loadDocumentText(\n MARKDOWN_TYPE,\n seed\n );\n return;\n }\n setTimeout(() => void check(attempt + 1), 300);\n } catch {\n // A failed probe must not break the editor; the room stays as-is.\n }\n };\n setTimeout(() => void check(0), 300);\n };\n\n if (valueRef.current) {\n await queueInitialLoad(() =>\n editor!.loadDocumentText(MARKDOWN_TYPE, valueRef.current)\n );\n await onTransaction();\n joinRoom();\n } else {\n void onTransaction();\n joinRoom();\n }\n };\n\n readyRef.current = setup().catch((err) =>\n console.error('Failed to set up editor:', err)\n );\n\n // Cleanup on unmount\n return () => {\n disposed = true;\n editorInstance.current = null; // makes onTransaction's guard effective\n editor?.removeEventListener('transaction', onTransaction);\n editor?.destroy();\n readyRef.current = null;\n host.replaceChildren();\n };\n // Initial `value`/`collab` are intentionally only applied on mount\n // (uncontrolled). Remount via `key` to switch rooms.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n useImperativeHandle(\n ref,\n () => ({\n getContent: async (): Promise<string> => {\n await readyRef.current;\n const editor = editorInstance.current;\n if (!editor) return valueRef.current;\n const buffer = await editor.saveDocument(MARKDOWN_TYPE);\n const markdown = new globalThis.TextDecoder().decode(buffer);\n valueRef.current = markdown;\n return markdown;\n },\n focus: (): void => {\n const apply = (): void => {\n const view = editorInstance.current?.view as\n | { focus?: () => void }\n | undefined;\n if (view?.focus) {\n view.focus();\n return;\n }\n hostRef.current\n ?.querySelector<HTMLElement>('[contenteditable=\"true\"], textarea')\n ?.focus();\n };\n // Callers focus on mount; the editor may still be loading its kits.\n if (editorInstance.current) apply();\n else void readyRef.current?.then(apply);\n },\n }),\n []\n );\n\n return (\n <div>\n <div>\n <div\n ref={hostRef}\n id={id}\n className={[\n 'kb-component',\n isDark ? 'kb-component--dark' : '',\n className ?? '',\n ]\n .filter(Boolean)\n .join(' ')}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-disabled={disabled || undefined}\n style={{\n isolation: 'isolate',\n opacity: disabled ? 0.65 : undefined,\n pointerEvents: disabled ? 'none' : undefined,\n }}\n />\n </div>\n\n {showPreview && (\n <div>\n <div>\n <h5>Markdown Output</h5>\n <pre>{md}</pre>\n </div>\n </div>\n )}\n </div>\n );\n }\n);\n\nRichEditor.displayName = 'RichEditor';\n\nexport { RichEditor };\n","import React, { useEffect, useRef } from 'react';\n\nimport { CoreEditor } from '@kerebron/editor';\nimport { CodeEditorKit } from '@kerebron/editor-kits/CodeEditorKit';\nimport { createAssetLoad } from '@kerebron/wasm/web';\n\nexport interface CodeEditorProps {\n /** Initial source code to load into the editor. */\n value?: string;\n /** Called with the editor's contents whenever they change. */\n onChange?: (value: string) => void;\n /** Language/grammar to use for syntax highlighting. Defaults to `typescript`. */\n lang?: string;\n}\n\nconst CodeEditor: React.FC<CodeEditorProps> = ({\n value = '',\n onChange,\n lang = 'typescript',\n}) => {\n const editorRef = useRef<HTMLDivElement>(null);\n const editorInstance = useRef<CoreEditor | null>(null);\n const onChangeRef = useRef(onChange);\n onChangeRef.current = onChange;\n\n useEffect(() => {\n const root = editorRef.current;\n if (!root) return;\n\n const applySelectLabel = () => {\n root.querySelectorAll('select.codejar-select').forEach((element) => {\n if (!element.getAttribute('aria-label')) {\n element.setAttribute('aria-label', 'Code editor language');\n }\n });\n };\n\n applySelectLabel();\n const observer = new MutationObserver(() => applySelectLabel());\n observer.observe(root, { childList: true, subtree: true });\n return () => observer.disconnect();\n }, []);\n\n useEffect(() => {\n if (!editorRef.current) return;\n\n // Initialize the editor\n const editor = CoreEditor.create({\n element: editorRef.current,\n uri: 'file:///untitled.ts',\n assetLoad: createAssetLoad('/kerebron-wasm'),\n editorKits: [new CodeEditorKit(lang)],\n });\n\n editorInstance.current = editor;\n\n // Surface edits to callers.\n const onTransaction = async () => {\n if (!editorInstance.current) return;\n\n try {\n const buffer = await editorInstance.current.saveDocument('text/plain');\n onChangeRef.current?.(new globalThis.TextDecoder().decode(buffer));\n } catch (err) {\n console.error('Failed to read code:', err);\n }\n };\n\n editor.addEventListener('transaction', onTransaction);\n\n // Seed initial content on mount.\n if (value) {\n editor\n .loadDocumentText('text/plain', value)\n .catch((err) => console.error('Failed to load code:', err));\n }\n\n // Cleanup on unmount\n return () => {\n editor.removeEventListener('transaction', onTransaction);\n editor.destroy();\n };\n // Initial `value`/`lang` are intentionally only applied on mount.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n return (\n <div>\n <div>\n <div ref={editorRef} className=\"kb-component\" />\n </div>\n </div>\n );\n};\n\nCodeEditor.displayName = 'CodeEditor';\n\nexport { CodeEditor };\n"]}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var chunkLCQGAOAZ_cjs = require('./chunk-LCQGAOAZ.cjs');
|
|
6
|
+
require('./chunk-EUAMEVVI.cjs');
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
|
|
@@ -14,5 +15,5 @@ Object.defineProperty(exports, "miewebBrand", {
|
|
|
14
15
|
enumerable: true,
|
|
15
16
|
get: function () { return chunkLCQGAOAZ_cjs.miewebBrand; }
|
|
16
17
|
});
|
|
17
|
-
//# sourceMappingURL=mieweb-
|
|
18
|
-
//# sourceMappingURL=mieweb-
|
|
18
|
+
//# sourceMappingURL=mieweb-72YOL44I.cjs.map
|
|
19
|
+
//# sourceMappingURL=mieweb-72YOL44I.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"mieweb-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"mieweb-72YOL44I.cjs"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"mieweb-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"mieweb-EZDLSSA6.js"}
|
package/dist/motion.cjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkNV2CWBI2_cjs = require('./chunk-NV2CWBI2.cjs');
|
|
4
4
|
require('./chunk-S5RVSXDV.cjs');
|
|
5
|
+
require('./chunk-EUAMEVVI.cjs');
|
|
5
6
|
var React = require('react');
|
|
6
7
|
var react = require('motion/react');
|
|
7
8
|
var jsxRuntime = require('react/jsx-runtime');
|
|
@@ -45,7 +46,7 @@ function MotionProvider({
|
|
|
45
46
|
Nav: react.m.nav,
|
|
46
47
|
Span: react.m.span,
|
|
47
48
|
Presence,
|
|
48
|
-
...
|
|
49
|
+
...chunkNV2CWBI2_cjs.createPresetPropBuilders()
|
|
49
50
|
}),
|
|
50
51
|
[disabled]
|
|
51
52
|
);
|
|
@@ -61,26 +62,26 @@ function MotionProvider({
|
|
|
61
62
|
// A disabled provider still supplies the runtime (with `enabled: false`)
|
|
62
63
|
// rather than `null`, so consumers can distinguish "disabled" from "never
|
|
63
64
|
// opted in" — see the `enabled` contract in `runtime.ts`.
|
|
64
|
-
/* @__PURE__ */ jsxRuntime.jsx(react.LazyMotion, { features: react.domAnimation, children: /* @__PURE__ */ jsxRuntime.jsx(react.MotionConfig, { reducedMotion, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
65
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.LazyMotion, { features: react.domAnimation, children: /* @__PURE__ */ jsxRuntime.jsx(react.MotionConfig, { reducedMotion, children: /* @__PURE__ */ jsxRuntime.jsx(chunkNV2CWBI2_cjs.MotionRuntimeContext.Provider, { value: runtime, children }) }) })
|
|
65
66
|
);
|
|
66
67
|
}
|
|
67
68
|
MotionProvider.displayName = "MotionProvider";
|
|
68
69
|
|
|
69
70
|
Object.defineProperty(exports, "Animated", {
|
|
70
71
|
enumerable: true,
|
|
71
|
-
get: function () { return
|
|
72
|
+
get: function () { return chunkNV2CWBI2_cjs.Animated; }
|
|
72
73
|
});
|
|
73
74
|
Object.defineProperty(exports, "AnimatedPresence", {
|
|
74
75
|
enumerable: true,
|
|
75
|
-
get: function () { return
|
|
76
|
+
get: function () { return chunkNV2CWBI2_cjs.AnimatedPresence; }
|
|
76
77
|
});
|
|
77
78
|
Object.defineProperty(exports, "motionPresets", {
|
|
78
79
|
enumerable: true,
|
|
79
|
-
get: function () { return
|
|
80
|
+
get: function () { return chunkNV2CWBI2_cjs.motionPresets; }
|
|
80
81
|
});
|
|
81
82
|
Object.defineProperty(exports, "useMotionRuntime", {
|
|
82
83
|
enumerable: true,
|
|
83
|
-
get: function () { return
|
|
84
|
+
get: function () { return chunkNV2CWBI2_cjs.useMotionRuntime; }
|
|
84
85
|
});
|
|
85
86
|
exports.MotionProvider = MotionProvider;
|
|
86
87
|
//# sourceMappingURL=motion.cjs.map
|
package/dist/motion.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/motion/MotionProvider.tsx"],"names":["jsx","AnimatePresence","React","m","createPresetPropBuilders","LazyMotion","domAnimation","MotionConfig","MotionRuntimeContext"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/motion/MotionProvider.tsx"],"names":["jsx","AnimatePresence","React","m","createPresetPropBuilders","LazyMotion","domAnimation","MotionConfig","MotionRuntimeContext"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,SAAS,QAAA,CAAS;AAAA,EAChB,QAAA;AAAA,EACA,OAAA,GAAU,IAAA;AAAA,EACV;AACF,CAAA,EAA2C;AACzC,EAAA,uBACEA,cAAA,CAACC,qBAAA,EAAA,EAAgB,OAAA,EAAkB,cAAA,EAChC,QAAA,EACH,CAAA;AAEJ;AA8BO,SAAS,cAAA,CAAe;AAAA,EAC7B,QAAA;AAAA,EACA,QAAA,GAAW,KAAA;AAAA,EACX,aAAA,GAAgB;AAClB,CAAA,EAA2C;AACzC,EAAA,MAAM,OAAA,GAAgBC,gBAAA,CAAA,OAAA;AAAA,IACpB,OAAO;AAAA,MACL,SAAS,CAAC,QAAA;AAAA,MACV,KAAKC,OAAA,CAAE,GAAA;AAAA,MACP,KAAKA,OAAA,CAAE,GAAA;AAAA,MACP,MAAMA,OAAA,CAAE,IAAA;AAAA,MACR,QAAA;AAAA,MACA,GAAGC,0CAAA;AAAyB,KAC9B,CAAA;AAAA,IACA,CAAC,QAAQ;AAAA,GACX;AAEA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAYEJ,cAAA,CAACK,gBAAA,EAAA,EAAW,QAAA,EAAUC,kBAAA,EACpB,yCAACC,kBAAA,EAAA,EAAa,aAAA,EACZ,QAAA,kBAAAP,cAAA,CAACQ,sCAAA,CAAqB,UAArB,EAA8B,KAAA,EAAO,OAAA,EACnC,QAAA,EACH,GACF,CAAA,EACF;AAAA;AAEJ;AAEA,cAAA,CAAe,WAAA,GAAc,gBAAA","file":"motion.cjs","sourcesContent":["/**\n * `<MotionProvider>` — the opt-in switch.\n *\n * This is the **only** file in the package that imports `motion`, and it is\n * reachable solely through the `@mieweb/ui/motion` entry point. An app that\n * never imports that entry never pulls the library into its bundle, which is\n * what makes this additive for existing consumers.\n *\n * ```tsx\n * import { MotionProvider } from '@mieweb/ui/motion';\n *\n * <MotionProvider>\n * <App />\n * </MotionProvider>\n * ```\n *\n * Components opted into motion upgrade automatically underneath it. Everything\n * else is untouched.\n */\n\nimport * as React from 'react';\nimport {\n AnimatePresence,\n LazyMotion,\n MotionConfig,\n domAnimation,\n m,\n} from 'motion/react';\nimport {\n MotionRuntimeContext,\n createPresetPropBuilders,\n type MotionPresenceProps,\n type MotionRuntime,\n} from './runtime';\n\n// =============================================================================\n// Presence adapter\n// =============================================================================\n\n/**\n * Narrows `AnimatePresence` to the surface `MotionRuntime` promises, so the\n * component-facing contract does not grow every time the library's API does.\n */\nfunction Presence({\n children,\n initial = true,\n onExitComplete,\n}: MotionPresenceProps): React.JSX.Element {\n return (\n <AnimatePresence initial={initial} onExitComplete={onExitComplete}>\n {children}\n </AnimatePresence>\n );\n}\n\n// =============================================================================\n// Provider\n// =============================================================================\n\nexport interface MotionProviderProps {\n children: React.ReactNode;\n /**\n * Stop animations running, putting every component on its CSS path.\n *\n * Intended for test runs: real spring animations make screenshot and\n * interaction assertions timing-dependent, and this keeps a suite\n * deterministic without having to unmount the provider.\n *\n * Flipping it at runtime swaps `Animated` elements between motion components\n * and plain tags, which remounts them and resets their local state — set it\n * once per suite rather than toggling it mid-interaction.\n */\n disabled?: boolean;\n /**\n * How to honor the OS \"reduce motion\" setting.\n *\n * Defaults to `'user'`, which drops transform and layout animations while\n * keeping opacity — the accessible default, and the reason motion should be\n * configured once at the root rather than per component.\n */\n reducedMotion?: 'user' | 'always' | 'never';\n}\n\nexport function MotionProvider({\n children,\n disabled = false,\n reducedMotion = 'user',\n}: MotionProviderProps): React.JSX.Element {\n const runtime = React.useMemo<MotionRuntime>(\n () => ({\n enabled: !disabled,\n Div: m.div,\n Nav: m.nav,\n Span: m.span,\n Presence,\n ...createPresetPropBuilders(),\n }),\n [disabled]\n );\n\n return (\n // `domAnimation` covers transforms, opacity and exit animations — the whole\n // preset vocabulary — at roughly a fifth of the full bundle.\n //\n // Deliberately not `strict`: this provider is documented to wrap the whole\n // app, and `strict` throws on any `motion.*` component anywhere beneath it.\n // That would make an application's own unrelated animations fail the moment\n // it opts in — a root-level provider has no business imposing that.\n //\n // A disabled provider still supplies the runtime (with `enabled: false`)\n // rather than `null`, so consumers can distinguish \"disabled\" from \"never\n // opted in\" — see the `enabled` contract in `runtime.ts`.\n <LazyMotion features={domAnimation}>\n <MotionConfig reducedMotion={reducedMotion}>\n <MotionRuntimeContext.Provider value={runtime}>\n {children}\n </MotionRuntimeContext.Provider>\n </MotionConfig>\n </LazyMotion>\n );\n}\n\nMotionProvider.displayName = 'MotionProvider';\n"]}
|
package/dist/motion.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
export { A as Animated, a as AnimatedPresence, b as AnimatedProps, M as
|
|
2
|
+
export { A as Animated, a as AnimatedPresence, b as AnimatedProps, M as MotionEdge, c as MotionPreset, d as MotionRuntime, m as motionPresets, u as useMotionRuntime } from './Animated-XmH6k8pZ.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* `<MotionProvider>` — the opt-in switch.
|
package/dist/motion.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
export { A as Animated, a as AnimatedPresence, b as AnimatedProps, M as
|
|
2
|
+
export { A as Animated, a as AnimatedPresence, b as AnimatedProps, M as MotionEdge, c as MotionPreset, d as MotionRuntime, m as motionPresets, u as useMotionRuntime } from './Animated-XmH6k8pZ.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* `<MotionProvider>` — the opt-in switch.
|
package/dist/motion.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { createPresetPropBuilders, MotionRuntimeContext } from './chunk-
|
|
2
|
-
export { Animated, AnimatedPresence, motionPresets, useMotionRuntime } from './chunk-
|
|
1
|
+
import { createPresetPropBuilders, MotionRuntimeContext } from './chunk-XCP454Q6.js';
|
|
2
|
+
export { Animated, AnimatedPresence, motionPresets, useMotionRuntime } from './chunk-XCP454Q6.js';
|
|
3
3
|
import './chunk-TQONQSJO.js';
|
|
4
|
+
import './chunk-PX6F3LHL.js';
|
|
4
5
|
import * as React from 'react';
|
|
5
6
|
import { m, LazyMotion, domAnimation, MotionConfig, AnimatePresence } from 'motion/react';
|
|
6
7
|
import { jsx } from 'react/jsx-runtime';
|
package/dist/motion.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/motion/MotionProvider.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/motion/MotionProvider.tsx"],"names":[],"mappings":";;;;;;;;AA2CA,SAAS,QAAA,CAAS;AAAA,EAChB,QAAA;AAAA,EACA,OAAA,GAAU,IAAA;AAAA,EACV;AACF,CAAA,EAA2C;AACzC,EAAA,uBACE,GAAA,CAAC,eAAA,EAAA,EAAgB,OAAA,EAAkB,cAAA,EAChC,QAAA,EACH,CAAA;AAEJ;AA8BO,SAAS,cAAA,CAAe;AAAA,EAC7B,QAAA;AAAA,EACA,QAAA,GAAW,KAAA;AAAA,EACX,aAAA,GAAgB;AAClB,CAAA,EAA2C;AACzC,EAAA,MAAM,OAAA,GAAgB,KAAA,CAAA,OAAA;AAAA,IACpB,OAAO;AAAA,MACL,SAAS,CAAC,QAAA;AAAA,MACV,KAAK,CAAA,CAAE,GAAA;AAAA,MACP,KAAK,CAAA,CAAE,GAAA;AAAA,MACP,MAAM,CAAA,CAAE,IAAA;AAAA,MACR,QAAA;AAAA,MACA,GAAG,wBAAA;AAAyB,KAC9B,CAAA;AAAA,IACA,CAAC,QAAQ;AAAA,GACX;AAEA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAYE,GAAA,CAAC,UAAA,EAAA,EAAW,QAAA,EAAU,YAAA,EACpB,8BAAC,YAAA,EAAA,EAAa,aAAA,EACZ,QAAA,kBAAA,GAAA,CAAC,oBAAA,CAAqB,UAArB,EAA8B,KAAA,EAAO,OAAA,EACnC,QAAA,EACH,GACF,CAAA,EACF;AAAA;AAEJ;AAEA,cAAA,CAAe,WAAA,GAAc,gBAAA","file":"motion.js","sourcesContent":["/**\n * `<MotionProvider>` — the opt-in switch.\n *\n * This is the **only** file in the package that imports `motion`, and it is\n * reachable solely through the `@mieweb/ui/motion` entry point. An app that\n * never imports that entry never pulls the library into its bundle, which is\n * what makes this additive for existing consumers.\n *\n * ```tsx\n * import { MotionProvider } from '@mieweb/ui/motion';\n *\n * <MotionProvider>\n * <App />\n * </MotionProvider>\n * ```\n *\n * Components opted into motion upgrade automatically underneath it. Everything\n * else is untouched.\n */\n\nimport * as React from 'react';\nimport {\n AnimatePresence,\n LazyMotion,\n MotionConfig,\n domAnimation,\n m,\n} from 'motion/react';\nimport {\n MotionRuntimeContext,\n createPresetPropBuilders,\n type MotionPresenceProps,\n type MotionRuntime,\n} from './runtime';\n\n// =============================================================================\n// Presence adapter\n// =============================================================================\n\n/**\n * Narrows `AnimatePresence` to the surface `MotionRuntime` promises, so the\n * component-facing contract does not grow every time the library's API does.\n */\nfunction Presence({\n children,\n initial = true,\n onExitComplete,\n}: MotionPresenceProps): React.JSX.Element {\n return (\n <AnimatePresence initial={initial} onExitComplete={onExitComplete}>\n {children}\n </AnimatePresence>\n );\n}\n\n// =============================================================================\n// Provider\n// =============================================================================\n\nexport interface MotionProviderProps {\n children: React.ReactNode;\n /**\n * Stop animations running, putting every component on its CSS path.\n *\n * Intended for test runs: real spring animations make screenshot and\n * interaction assertions timing-dependent, and this keeps a suite\n * deterministic without having to unmount the provider.\n *\n * Flipping it at runtime swaps `Animated` elements between motion components\n * and plain tags, which remounts them and resets their local state — set it\n * once per suite rather than toggling it mid-interaction.\n */\n disabled?: boolean;\n /**\n * How to honor the OS \"reduce motion\" setting.\n *\n * Defaults to `'user'`, which drops transform and layout animations while\n * keeping opacity — the accessible default, and the reason motion should be\n * configured once at the root rather than per component.\n */\n reducedMotion?: 'user' | 'always' | 'never';\n}\n\nexport function MotionProvider({\n children,\n disabled = false,\n reducedMotion = 'user',\n}: MotionProviderProps): React.JSX.Element {\n const runtime = React.useMemo<MotionRuntime>(\n () => ({\n enabled: !disabled,\n Div: m.div,\n Nav: m.nav,\n Span: m.span,\n Presence,\n ...createPresetPropBuilders(),\n }),\n [disabled]\n );\n\n return (\n // `domAnimation` covers transforms, opacity and exit animations — the whole\n // preset vocabulary — at roughly a fifth of the full bundle.\n //\n // Deliberately not `strict`: this provider is documented to wrap the whole\n // app, and `strict` throws on any `motion.*` component anywhere beneath it.\n // That would make an application's own unrelated animations fail the moment\n // it opts in — a root-level provider has no business imposing that.\n //\n // A disabled provider still supplies the runtime (with `enabled: false`)\n // rather than `null`, so consumers can distinguish \"disabled\" from \"never\n // opted in\" — see the `enabled` contract in `runtime.ts`.\n <LazyMotion features={domAnimation}>\n <MotionConfig reducedMotion={reducedMotion}>\n <MotionRuntimeContext.Provider value={runtime}>\n {children}\n </MotionRuntimeContext.Provider>\n </MotionConfig>\n </LazyMotion>\n );\n}\n\nMotionProvider.displayName = 'MotionProvider';\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ml, gl } from './chunk-C6CTTLH2.js';
|
|
2
|
+
import './chunk-PX6F3LHL.js';
|
|
2
3
|
import * as React from 'react';
|
|
3
4
|
import { jsx } from 'react/jsx-runtime';
|
|
4
5
|
|
|
@@ -17,9 +18,9 @@ function NitroTableGrid({ headers, rows }) {
|
|
|
17
18
|
},
|
|
18
19
|
[varName]
|
|
19
20
|
);
|
|
20
|
-
return /* @__PURE__ */ jsx("div", { "data-slot": "superchat-nitro-table", className: "my-2", children: /* @__PURE__ */ jsx(
|
|
21
|
+
return /* @__PURE__ */ jsx("div", { "data-slot": "superchat-nitro-table", className: "my-2", children: /* @__PURE__ */ jsx(ml, { type: "local", varName, children: /* @__PURE__ */ jsx(gl, { columns: headers, className: "max-h-80" }) }) });
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
export { NitroTableGrid as default };
|
|
24
|
-
//# sourceMappingURL=nitroTableGrid-
|
|
25
|
-
//# sourceMappingURL=nitroTableGrid-
|
|
25
|
+
//# sourceMappingURL=nitroTableGrid-LVYKKCGF.js.map
|
|
26
|
+
//# sourceMappingURL=nitroTableGrid-LVYKKCGF.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/SuperChat/plugins/nitroTableGrid.tsx"],"names":[],"mappings":";;;;;AAqBe,SAAR,cAAA,CAAgC,EAAE,OAAA,EAAS,IAAA,EAAK,EAAwB;AAC7E,EAAA,MAAM,OAAA,GAAgB,cAAQ,MAAM;AAClC,IAAA,MAAM,WAAA,GAAc,CAAA,wBAAA,EAA2B,IAAA,CAAK,MAAA,EAAO,CAAE,SAAS,EAAE,CAAA,CAAE,KAAA,CAAM,CAAC,CAAC,CAAA,CAAA;AAClF,IAAC,MAAA,CAA8C,WAAW,CAAA,GAAI;AAAA,MAC5D,QAAA,EAAU,QAAQ,GAAA,CAAI,CAAC,WAAW,EAAE,KAAA,EAAO,IAAA,EAAM,QAAA,EAAS,CAAE,CAAA;AAAA,MAC5D,IAAA,EAAM;AAAA,KACR;AACA,IAAA,OAAO,WAAA;AAAA,EACT,CAAA,EAAG,CAAC,OAAA,EAAS,IAAI,CAAC,CAAA;AAElB,EAAM,KAAA,CAAA,SAAA;AAAA,IACJ,MAAM,MAAM;AACV,MAAA,OAAQ,OAA8C,OAAO,CAAA;AAAA,IAC/D,CAAA;AAAA,IACA,CAAC,OAAO;AAAA,GACV;AAEA,EAAA,2BACG,KAAA,EAAA,EAAI,WAAA,EAAU,yBAAwB,SAAA,EAAU,MAAA,EAC/C,8BAAC,EAAA,EAAA,EAAmB,IAAA,EAAK,OAAA,EAAQ,OAAA,EAC/B,8BAAC,EAAA,EAAA,EAAiB,OAAA,EAAS,SAAS,SAAA,EAAU,UAAA,EAAW,GAC3D,CAAA,EACF,CAAA;AAEJ","file":"nitroTableGrid-LVYKKCGF.js","sourcesContent":["/**\n * SuperChat NITRO table grid (lazy chunk).\n *\n * Default-exported so it can be pulled in with `React.lazy` only when a GFM\n * table actually renders — this keeps the heavy `datavis` / `datavis-ace`\n * dependencies out of the SuperChat (and Markdown core) bundle.\n *\n * Data is handed to {@link DataVisNitroSource} through a short-lived local\n * source so Storybook never pauses in the intermediate \"Waiting…\" state.\n */\n\nimport * as React from 'react';\nimport { DataVisNitroGrid, DataVisNitroSource } from '../../DataVisNITRO';\n\nexport interface NitroTableGridProps {\n /** Column headers, in order. */\n headers: string[];\n /** Row objects keyed by header. */\n rows: Array<Record<string, string>>;\n}\n\nexport default function NitroTableGrid({ headers, rows }: NitroTableGridProps) {\n const varName = React.useMemo(() => {\n const nextVarName = `__superchat_nitro_table_${Math.random().toString(36).slice(2)}`;\n (window as unknown as Record<string, unknown>)[nextVarName] = {\n typeInfo: headers.map((field) => ({ field, type: 'string' })),\n data: rows,\n };\n return nextVarName;\n }, [headers, rows]);\n\n React.useEffect(\n () => () => {\n delete (window as unknown as Record<string, unknown>)[varName];\n },\n [varName]\n );\n\n return (\n <div data-slot=\"superchat-nitro-table\" className=\"my-2\">\n <DataVisNitroSource type=\"local\" varName={varName}>\n <DataVisNitroGrid columns={headers} className=\"max-h-80\" />\n </DataVisNitroSource>\n </div>\n );\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkPN2PIE2L_cjs = require('./chunk-PN2PIE2L.cjs');
|
|
4
|
+
require('./chunk-EUAMEVVI.cjs');
|
|
4
5
|
var React = require('react');
|
|
5
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
7
|
|
|
@@ -39,9 +40,9 @@ function NitroTableGrid({ headers, rows }) {
|
|
|
39
40
|
},
|
|
40
41
|
[varName]
|
|
41
42
|
);
|
|
42
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { "data-slot": "superchat-nitro-table", className: "my-2", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
43
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { "data-slot": "superchat-nitro-table", className: "my-2", children: /* @__PURE__ */ jsxRuntime.jsx(chunkPN2PIE2L_cjs.ml, { type: "local", varName, children: /* @__PURE__ */ jsxRuntime.jsx(chunkPN2PIE2L_cjs.gl, { columns: headers, className: "max-h-80" }) }) });
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
module.exports = NitroTableGrid;
|
|
46
|
-
//# sourceMappingURL=nitroTableGrid-
|
|
47
|
-
//# sourceMappingURL=nitroTableGrid-
|
|
47
|
+
//# sourceMappingURL=nitroTableGrid-SQADULEY.cjs.map
|
|
48
|
+
//# sourceMappingURL=nitroTableGrid-SQADULEY.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/SuperChat/plugins/nitroTableGrid.tsx"],"names":["React","ml","gl"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBe,SAAR,cAAA,CAAgC,EAAE,OAAA,EAAS,IAAA,EAAK,EAAwB;AAC7E,EAAA,MAAM,OAAA,GAAgBA,yBAAQ,MAAM;AAClC,IAAA,MAAM,WAAA,GAAc,CAAA,wBAAA,EAA2B,IAAA,CAAK,MAAA,EAAO,CAAE,SAAS,EAAE,CAAA,CAAE,KAAA,CAAM,CAAC,CAAC,CAAA,CAAA;AAClF,IAAC,MAAA,CAA8C,WAAW,CAAA,GAAI;AAAA,MAC5D,QAAA,EAAU,QAAQ,GAAA,CAAI,CAAC,WAAW,EAAE,KAAA,EAAO,IAAA,EAAM,QAAA,EAAS,CAAE,CAAA;AAAA,MAC5D,IAAA,EAAM;AAAA,KACR;AACA,IAAA,OAAO,WAAA;AAAA,EACT,CAAA,EAAG,CAAC,OAAA,EAAS,IAAI,CAAC,CAAA;AAElB,EAAMA,gBAAA,CAAA,SAAA;AAAA,IACJ,MAAM,MAAM;AACV,MAAA,OAAQ,OAA8C,OAAO,CAAA;AAAA,IAC/D,CAAA;AAAA,IACA,CAAC,OAAO;AAAA,GACV;AAEA,EAAA,sCACG,KAAA,EAAA,EAAI,WAAA,EAAU,yBAAwB,SAAA,EAAU,MAAA,EAC/C,yCAACC,oBAAA,EAAA,EAAmB,IAAA,EAAK,OAAA,EAAQ,OAAA,EAC/B,yCAACC,oBAAA,EAAA,EAAiB,OAAA,EAAS,SAAS,SAAA,EAAU,UAAA,EAAW,GAC3D,CAAA,EACF,CAAA;AAEJ","file":"nitroTableGrid-SQADULEY.cjs","sourcesContent":["/**\n * SuperChat NITRO table grid (lazy chunk).\n *\n * Default-exported so it can be pulled in with `React.lazy` only when a GFM\n * table actually renders — this keeps the heavy `datavis` / `datavis-ace`\n * dependencies out of the SuperChat (and Markdown core) bundle.\n *\n * Data is handed to {@link DataVisNitroSource} through a short-lived local\n * source so Storybook never pauses in the intermediate \"Waiting…\" state.\n */\n\nimport * as React from 'react';\nimport { DataVisNitroGrid, DataVisNitroSource } from '../../DataVisNITRO';\n\nexport interface NitroTableGridProps {\n /** Column headers, in order. */\n headers: string[];\n /** Row objects keyed by header. */\n rows: Array<Record<string, string>>;\n}\n\nexport default function NitroTableGrid({ headers, rows }: NitroTableGridProps) {\n const varName = React.useMemo(() => {\n const nextVarName = `__superchat_nitro_table_${Math.random().toString(36).slice(2)}`;\n (window as unknown as Record<string, unknown>)[nextVarName] = {\n typeInfo: headers.map((field) => ({ field, type: 'string' })),\n data: rows,\n };\n return nextVarName;\n }, [headers, rows]);\n\n React.useEffect(\n () => () => {\n delete (window as unknown as Record<string, unknown>)[varName];\n },\n [varName]\n );\n\n return (\n <div data-slot=\"superchat-nitro-table\" className=\"my-2\">\n <DataVisNitroSource type=\"local\" varName={varName}>\n <DataVisNitroGrid columns={headers} className=\"max-h-80\" />\n </DataVisNitroSource>\n </div>\n );\n}\n"]}
|
package/dist/q.cjs
CHANGED
package/dist/q.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { AgentConfigGenerator, ConfigEditor, FormBuilder, GENERIC_TOOLS, Header, Q, TIMEZONES, ToolBuilder, UniversalAgentConfigGenerator, brands, configToQuestionnaire, configToYaml, copyToClipboard, createQAgentConfig, createQTwilioAgentConfig, defaultSchema, deriveDefaultConfig, downloadConfig, generateBrandCSS, qAgentSchema, qLandingPageAgentConfig, qTwilioAgentSchema, questionnaireToConfig, validateConfig, yamlToConfig } from './chunk-7C226TQI.js';
|
|
2
2
|
import './chunk-TQONQSJO.js';
|
|
3
|
+
import './chunk-PX6F3LHL.js';
|
|
3
4
|
//# sourceMappingURL=q.js.map
|
|
4
5
|
//# sourceMappingURL=q.js.map
|