@esportsplus/ui 0.57.0 → 0.58.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +123 -39
- package/build/components/accordion/group.d.ts +14 -0
- package/build/components/accordion/group.js +21 -0
- package/build/components/accordion/index.d.ts +9 -0
- package/build/components/accordion/index.js +20 -3
- package/build/components/accordion/scss/index.scss +1 -1
- package/build/components/announcement/scss/index.scss +1 -1
- package/build/components/breadcrumb/scss/index.scss +1 -1
- package/build/components/button/scss/index.scss +1 -1
- package/build/components/button/sidebar.d.ts +3 -0
- package/build/components/button/sidebar.js +40 -10
- package/build/components/capslock/index.js +1 -1
- package/build/components/capslock/scss/index.scss +1 -1
- package/build/components/card/scss/index.scss +1 -1
- package/build/components/cc/scss/index.scss +1 -1
- package/build/components/chat-minimap/scss/index.scss +1 -1
- package/build/components/checkbox/scss/index.scss +1 -1
- package/build/components/color-picker/index.d.ts +1 -0
- package/build/components/color-picker/index.js +166 -136
- package/build/components/color-picker/scss/index.scss +1 -1
- package/build/components/command/index.d.ts +0 -1
- package/build/components/command/index.js +3 -2
- package/build/components/command/scss/index.scss +1 -1
- package/build/components/copy/scss/index.scss +1 -1
- package/build/components/counter/scss/index.scss +1 -1
- package/build/components/datalist/index.js +3 -3
- package/build/components/datalist/scss/index.scss +1 -1
- package/build/components/dock/scss/index.scss +1 -1
- package/build/components/editor/code/index.d.ts +0 -1
- package/build/components/editor/code/index.js +0 -1
- package/build/components/editor/code/minimap.d.ts +2 -1
- package/build/components/editor/code/minimap.js +5 -2
- package/build/components/editor/code/view.d.ts +3 -1
- package/build/components/editor/code/view.js +37 -26
- package/build/components/editor/diffs/index.d.ts +0 -1
- package/build/components/editor/diffs/index.js +0 -1
- package/build/components/editor/diffs/merge.js +7 -3
- package/build/components/editor/diffs/view.js +3 -1
- package/build/components/editor/index.d.ts +4 -1
- package/build/components/editor/index.js +2 -1
- package/build/components/editor/markdown/editing.js +22 -3
- package/build/components/editor/markdown/erase.d.ts +9 -0
- package/build/components/editor/markdown/erase.js +78 -0
- package/build/components/editor/markdown/index.d.ts +0 -1
- package/build/components/editor/markdown/index.js +0 -1
- package/build/components/editor/markdown/layout.d.ts +2 -9
- package/build/components/editor/markdown/layout.js +2 -7
- package/build/components/editor/markdown/render.d.ts +0 -1
- package/build/components/editor/markdown/render.js +287 -235
- package/build/components/editor/markdown/view.js +566 -667
- package/build/components/editor/viewer/index.d.ts +27 -0
- package/build/components/editor/viewer/index.js +250 -0
- package/build/components/editor/viewer/model.d.ts +15 -0
- package/build/components/editor/viewer/model.js +73 -0
- package/build/components/editor/workspace/index.d.ts +6 -2
- package/build/components/editor/workspace/index.js +243 -137
- package/build/components/editor/workspace/keybindings.d.ts +37 -0
- package/build/components/editor/workspace/keybindings.js +288 -0
- package/build/components/editor/workspace/model.d.ts +55 -2
- package/build/components/editor/workspace/model.js +141 -3
- package/build/components/editor/workspace/navigate.d.ts +19 -0
- package/build/components/editor/workspace/navigate.js +118 -0
- package/build/components/editor/workspace/session.d.ts +29 -0
- package/build/components/editor/workspace/session.js +373 -0
- package/build/components/editor/workspace/shortcuts.d.ts +19 -0
- package/build/components/editor/workspace/shortcuts.js +185 -0
- package/build/components/editor/workspace/status.d.ts +34 -0
- package/build/components/editor/workspace/status.js +193 -0
- package/build/components/editor/workspace/statusbar.d.ts +15 -0
- package/build/components/editor/workspace/statusbar.js +190 -0
- package/build/components/editor/workspace/strip.d.ts +27 -0
- package/build/components/editor/workspace/strip.js +239 -0
- package/build/components/editor/workspace/tabs.d.ts +15 -0
- package/build/components/editor/workspace/tabs.js +63 -0
- package/build/components/error/index.js +1 -1
- package/build/components/error/scss/index.scss +1 -1
- package/build/components/filter/index.js +5 -3
- package/build/components/filter/scss/index.scss +1 -1
- package/build/components/frame/scss/index.scss +1 -1
- package/build/components/heatmap/index.js +3 -3
- package/build/components/heatmap/scss/index.scss +1 -1
- package/build/components/highlight/scss/index.scss +1 -1
- package/build/components/icon/scss/index.scss +1 -1
- package/build/components/image/scss/index.scss +1 -1
- package/build/components/index.d.ts +2 -0
- package/build/components/index.js +2 -0
- package/build/components/inline-edit/scss/index.scss +1 -1
- package/build/components/input/scss/index.scss +1 -1
- package/build/components/link/scss/index.scss +1 -1
- package/build/components/loading/scss/index.scss +1 -1
- package/build/components/marquee/scss/index.scss +1 -1
- package/build/components/metric/scss/index.scss +1 -1
- package/build/components/nav/index.d.ts +1 -1
- package/build/components/nav/scss/index.scss +1 -1
- package/build/components/nav/tree.d.ts +3 -1
- package/build/components/nav/tree.js +30 -60
- package/build/components/notification/scss/index.scss +1 -1
- package/build/components/overlay/scss/index.scss +1 -1
- package/build/components/page/scss/index.scss +1 -1
- package/build/components/pagination/arrows.d.ts +15 -0
- package/build/components/pagination/arrows.js +65 -0
- package/build/components/pagination/cards.d.ts +23 -0
- package/build/components/pagination/cards.js +66 -0
- package/build/components/pagination/index.d.ts +5 -0
- package/build/components/pagination/index.js +3 -1
- package/build/components/pagination/scss/index.scss +1 -1
- package/build/components/progress/scss/index.scss +1 -1
- package/build/components/pull-to-refresh/scss/index.scss +1 -1
- package/build/components/range/index.js +1 -1
- package/build/components/range/scss/index.scss +1 -1
- package/build/components/relative-time/scss/index.scss +1 -1
- package/build/components/root/scss/index.scss +1 -1
- package/build/components/section/scss/index.scss +2 -0
- package/build/components/select/index.d.ts +1 -0
- package/build/components/select/index.js +16 -11
- package/build/components/select/scss/index.scss +1 -1
- package/build/components/shortcut-recorder/scss/index.scss +1 -1
- package/build/components/sortable/scss/index.scss +1 -1
- package/build/components/sticky-header/index.js +3 -3
- package/build/components/sticky-header/scss/index.scss +1 -1
- package/build/components/story/scss/index.scss +1 -1
- package/build/components/surface-field/scss/index.scss +1 -1
- package/build/components/tasklist/scss/index.scss +1 -1
- package/build/components/text/scss/index.scss +1 -1
- package/build/components/textarea/scss/index.scss +1 -1
- package/build/{css-utilities → components}/theme/index.d.ts +1 -1
- package/build/{css-utilities → components}/theme/index.js +15 -5
- package/build/components/theme/scss/index.scss +2 -0
- package/build/components/theme-picker/index.d.ts +52 -0
- package/build/components/theme-picker/index.js +167 -0
- package/build/components/theme-picker/scss/index.scss +2 -0
- package/build/components/toast/index.js +3 -5
- package/build/components/toast/scss/index.scss +1 -1
- package/build/components/tooltip/menu.js +3 -1
- package/build/components/tooltip/scss/index.scss +1 -1
- package/build/components/typewriter/scss/index.scss +1 -1
- package/build/components/uptime/scss/index.scss +1 -1
- package/build/components/usage-meter/scss/index.scss +1 -1
- package/build/{css-utilities → modifiers}/glass/index.d.ts +2 -2
- package/build/modifiers/glass/index.js +28 -0
- package/build/modifiers/glass/scss/index.scss +2 -0
- package/build/{css-utilities → modifiers}/index.d.ts +0 -1
- package/build/{css-utilities → modifiers}/index.js +0 -1
- package/build/modifiers/scrollbar/index.d.ts +72 -0
- package/build/{css-utilities → modifiers}/scrollbar/index.js +52 -19
- package/build/modifiers/scrollbar/scss/index.scss +2 -0
- package/build/normalize/scss/index.scss +1 -2
- package/layer.scss +1 -1
- package/package.json +11 -18
- package/scripts/code-editor-markdown.test.mjs +45 -14
- package/scripts/code-viewer.test.mjs +69 -0
- package/scripts/workspace-keybindings.test.mjs +273 -0
- package/scripts/workspace-session.test.mjs +349 -0
- package/scripts/workspace-status.test.mjs +229 -0
- package/scripts/workspace-tabs.test.mjs +142 -0
- package/src/components/accordion/group.ts +39 -0
- package/src/components/accordion/index.ts +32 -6
- package/src/components/accordion/scss/index.scss +12 -21
- package/src/components/accordion/scss/variables.scss +18 -3
- package/src/components/announcement/scss/index.scss +4 -4
- package/src/components/announcement/scss/variables.scss +6 -6
- package/src/components/banner/scss/index.scss +1 -1
- package/src/components/breadcrumb/scss/index.scss +35 -50
- package/src/components/breadcrumb/scss/variables.scss +23 -31
- package/src/components/button/scss/_fan.scss +39 -43
- package/src/components/button/scss/_morph.scss +66 -78
- package/src/components/button/scss/_sidebar.scss +41 -30
- package/src/components/button/scss/_split.scss +9 -9
- package/src/components/button/scss/index.scss +23 -19
- package/src/components/button/scss/variables.scss +94 -90
- package/src/components/button/sidebar.ts +36 -24
- package/src/components/capslock/index.ts +2 -2
- package/src/components/capslock/scss/index.scss +11 -6
- package/src/components/capslock/scss/variables.scss +3 -5
- package/src/components/card/scss/_expand.scss +58 -64
- package/src/components/card/scss/index.scss +40 -21
- package/src/components/card/scss/variables.scss +40 -31
- package/src/components/cc/scss/index.scss +68 -68
- package/src/components/cc/scss/variables.scss +13 -14
- package/src/components/chat-minimap/scss/index.scss +24 -16
- package/src/components/chat-minimap/scss/variables.scss +37 -37
- package/src/components/checkbox/scss/index.scss +54 -52
- package/src/components/checkbox/scss/variables.scss +37 -39
- package/src/components/color-picker/index.ts +157 -120
- package/src/components/color-picker/scss/index.scss +159 -96
- package/src/components/color-picker/scss/variables.scss +33 -15
- package/src/components/command/index.ts +3 -2
- package/src/components/command/scss/index.scss +10 -14
- package/src/components/command/scss/variables.scss +12 -35
- package/src/components/copy/scss/index.scss +6 -6
- package/src/components/copy/scss/variables.scss +12 -15
- package/src/components/counter/scss/index.scss +14 -14
- package/src/components/counter/scss/variables.scss +1 -1
- package/src/components/datalist/index.ts +3 -3
- package/src/components/datalist/scss/index.scss +7 -6
- package/src/components/datalist/scss/variables.scss +7 -3
- package/src/components/dock/scss/index.scss +10 -15
- package/src/components/dock/scss/variables.scss +29 -25
- package/src/components/editor/code/index.ts +0 -1
- package/src/components/editor/code/minimap.ts +13 -5
- package/src/components/editor/code/scss/_editor.scss +83 -81
- package/src/components/editor/code/scss/_features.scss +106 -97
- package/src/components/editor/code/scss/_services.scss +27 -25
- package/src/components/editor/code/scss/index.scss +0 -1
- package/src/components/editor/code/scss/variables.scss +30 -26
- package/src/components/editor/code/view.ts +14 -5
- package/src/components/editor/diffs/index.ts +0 -1
- package/src/components/editor/diffs/merge.ts +2 -1
- package/src/components/editor/diffs/scss/_diffs.scss +67 -57
- package/src/components/editor/diffs/scss/_merge.scss +17 -14
- package/src/components/editor/diffs/scss/index.scss +0 -1
- package/src/components/editor/diffs/scss/variables.scss +25 -18
- package/src/components/editor/diffs/view.ts +2 -1
- package/src/components/editor/index.ts +7 -1
- package/src/components/editor/markdown/editing.ts +38 -3
- package/src/components/editor/markdown/erase.ts +124 -0
- package/src/components/editor/markdown/index.ts +0 -1
- package/src/components/editor/markdown/layout.ts +3 -12
- package/src/components/editor/markdown/render.ts +65 -37
- package/src/components/editor/markdown/scss/index.scss +92 -124
- package/src/components/editor/markdown/scss/variables.scss +39 -19
- package/src/components/editor/markdown/view.ts +737 -786
- package/src/components/editor/tree/scss/index.scss +121 -110
- package/src/components/editor/tree/scss/variables.scss +48 -54
- package/src/components/editor/viewer/index.ts +321 -0
- package/src/components/editor/viewer/model.ts +130 -0
- package/src/components/editor/viewer/scss/_viewer.scss +302 -0
- package/src/components/editor/viewer/scss/index.scss +2 -0
- package/src/components/editor/viewer/scss/variables.scss +69 -0
- package/src/components/editor/workspace/index.ts +159 -31
- package/src/components/editor/workspace/keybindings.ts +447 -0
- package/src/components/editor/workspace/model.ts +233 -3
- package/src/components/editor/workspace/navigate.ts +194 -0
- package/src/components/editor/workspace/scss/index.scss +72 -59
- package/src/components/editor/workspace/scss/keybindings.scss +190 -0
- package/src/components/editor/workspace/scss/status.scss +122 -0
- package/src/components/editor/workspace/scss/tabs.scss +56 -0
- package/src/components/editor/workspace/session.ts +551 -0
- package/src/components/editor/workspace/shortcuts.ts +255 -0
- package/src/components/editor/workspace/status.ts +259 -0
- package/src/components/editor/workspace/statusbar.ts +255 -0
- package/src/components/editor/workspace/strip.ts +273 -0
- package/src/components/editor/workspace/tabs.ts +106 -0
- package/src/components/error/index.ts +1 -1
- package/src/components/error/scss/index.scss +19 -19
- package/src/components/error/scss/variables.scss +2 -2
- package/src/components/filter/index.ts +7 -2
- package/src/components/filter/scss/index.scss +1 -1
- package/src/components/filter/scss/variables.scss +11 -10
- package/src/components/frame/scss/index.scss +12 -12
- package/src/components/frame/scss/variables.scss +8 -8
- package/src/components/heatmap/index.ts +3 -3
- package/src/components/heatmap/scss/index.scss +28 -26
- package/src/components/heatmap/scss/variables.scss +18 -17
- package/src/components/highlight/scss/index.scss +17 -13
- package/src/components/highlight/scss/variables.scss +8 -10
- package/src/components/icon/scss/index.scss +10 -0
- package/src/components/icon/scss/variables.scss +5 -0
- package/src/components/image/scss/index.scss +9 -9
- package/src/components/image/scss/variables.scss +7 -2
- package/src/components/index.ts +2 -0
- package/src/components/inline-edit/scss/index.scss +99 -104
- package/src/components/inline-edit/scss/variables.scss +40 -39
- package/src/components/input/scss/_field.scss +6 -20
- package/src/components/input/scss/_scrub.scss +10 -8
- package/src/components/input/scss/_tag.scss +35 -37
- package/src/components/input/scss/variables.scss +100 -99
- package/src/components/link/scss/index.scss +4 -1
- package/src/components/loading/scss/index.scss +1 -1
- package/src/components/loading/scss/variables.scss +1 -1
- package/src/components/marquee/scss/index.scss +9 -5
- package/src/components/marquee/scss/variables.scss +3 -1
- package/src/components/metric/scss/_flash.scss +3 -1
- package/src/components/metric/scss/index.scss +8 -6
- package/src/components/metric/scss/variables.scss +26 -20
- package/src/components/nav/index.ts +1 -1
- package/src/components/nav/scss/index.scss +12 -40
- package/src/components/nav/scss/variables.scss +30 -11
- package/src/components/nav/tree.ts +19 -62
- package/src/components/notification/scss/index.scss +7 -7
- package/src/components/notification/scss/variables.scss +7 -9
- package/src/components/overlay/scss/index.scss +181 -170
- package/src/components/overlay/scss/variables.scss +26 -57
- package/src/components/page/scss/index.scss +12 -11
- package/src/components/page/scss/variables.scss +5 -0
- package/src/components/pagination/arrows.ts +58 -0
- package/src/components/pagination/cards.ts +57 -0
- package/src/components/pagination/index.ts +4 -1
- package/src/components/pagination/scss/_arrows.scss +69 -0
- package/src/components/pagination/scss/_cards.scss +121 -0
- package/src/components/pagination/scss/_dots.scss +2 -5
- package/src/components/pagination/scss/index.scss +8 -6
- package/src/components/pagination/scss/variables.scss +87 -37
- package/src/components/progress/scss/_text.scss +21 -18
- package/src/components/progress/scss/index.scss +1 -1
- package/src/components/progress/scss/variables.scss +12 -12
- package/src/components/pull-to-refresh/scss/index.scss +2 -1
- package/src/components/pull-to-refresh/scss/variables.scss +11 -6
- package/src/components/range/index.ts +1 -1
- package/src/components/range/scss/_filter.scss +62 -51
- package/src/components/range/scss/_slider.scss +78 -75
- package/src/components/range/scss/_vertical.scss +6 -6
- package/src/components/range/scss/index.scss +3 -2
- package/src/components/range/scss/variables.scss +26 -23
- package/src/components/relative-time/scss/index.scss +27 -27
- package/src/components/relative-time/scss/variables.scss +10 -12
- package/src/components/root/scss/index.scss +71 -43
- package/src/components/root/scss/variables.scss +35 -31
- package/src/components/section/scss/index.scss +31 -0
- package/src/components/section/scss/variables.scss +21 -0
- package/src/components/select/index.ts +11 -6
- package/src/components/select/scss/index.scss +21 -32
- package/src/components/select/scss/variables.scss +25 -18
- package/src/components/shortcut-recorder/scss/index.scss +13 -12
- package/src/components/shortcut-recorder/scss/variables.scss +12 -13
- package/src/components/sortable/scss/index.scss +47 -44
- package/src/components/sortable/scss/variables.scss +4 -5
- package/src/components/sticky-header/index.ts +4 -4
- package/src/components/sticky-header/scss/index.scss +14 -13
- package/src/components/sticky-header/scss/variables.scss +9 -9
- package/src/components/story/scss/index.scss +26 -30
- package/src/components/story/scss/variables.scss +16 -9
- package/src/components/surface-field/scss/index.scss +45 -40
- package/src/components/surface-field/scss/variables.scss +5 -6
- package/src/components/tasklist/scss/index.scss +19 -19
- package/src/components/tasklist/scss/variables.scss +26 -29
- package/src/components/text/scss/index.scss +2 -1
- package/src/components/textarea/scss/variables.scss +1 -1
- package/src/{css-utilities → components}/theme/index.ts +17 -3
- package/src/components/theme/scss/index.scss +1 -0
- package/src/components/theme/scss/variables.scss +78 -0
- package/src/components/theme-picker/index.ts +231 -0
- package/src/components/theme-picker/scss/index.scss +264 -0
- package/src/components/toast/index.ts +28 -30
- package/src/components/toast/scss/index.scss +87 -87
- package/src/components/toast/scss/variables.scss +39 -39
- package/src/components/tooltip/menu.ts +4 -1
- package/src/components/tooltip/scss/_east.scss +10 -10
- package/src/components/tooltip/scss/_menu.scss +284 -269
- package/src/components/tooltip/scss/_north.scss +10 -10
- package/src/components/tooltip/scss/_shared.scss +7 -7
- package/src/components/tooltip/scss/_south.scss +10 -10
- package/src/components/tooltip/scss/_west.scss +10 -10
- package/src/components/tooltip/scss/index.scss +21 -20
- package/src/components/tooltip/scss/variables.scss +104 -96
- package/src/components/typewriter/scss/_retype.scss +12 -11
- package/src/components/typewriter/scss/_rotate.scss +2 -1
- package/src/components/typewriter/scss/variables.scss +41 -39
- package/src/components/uptime/scss/index.scss +15 -15
- package/src/components/uptime/scss/variables.scss +8 -8
- package/src/components/usage-meter/scss/index.scss +3 -1
- package/src/components/usage-meter/scss/variables.scss +5 -5
- package/src/css-utilities/absolute.scss +64 -0
- package/src/css-utilities/background.scss +43 -0
- package/src/css-utilities/border.scss +45 -0
- package/src/css-utilities/box-shadow.scss +29 -0
- package/src/css-utilities/color.scss +41 -0
- package/src/css-utilities/flex.scss +64 -0
- package/src/css-utilities/font/geist/{scss/index.scss → index.scss} +12 -4
- package/src/css-utilities/font/montserrat/Montserrat-Italic-Variable.woff2 +0 -0
- package/src/css-utilities/font/montserrat/Montserrat-Variable.woff2 +0 -0
- package/src/css-utilities/font/montserrat/OFL.txt +93 -0
- package/src/css-utilities/font/montserrat/index.scss +38 -0
- package/src/{shared/scss → css-utilities}/icon.scss +1 -1
- package/src/css-utilities/{inline/scss/index.scss → inline.scss} +1 -1
- package/src/css-utilities/{skeleton/scss/index.scss → skeleton.scss} +11 -11
- package/src/css-utilities/surface.scss +266 -0
- package/src/css-utilities/text.scss +191 -0
- package/src/modifiers/glass/index.ts +44 -0
- package/src/{css-utilities → modifiers}/glass/scss/index.scss +6 -6
- package/src/{css-utilities → modifiers}/glass/scss/variables.scss +1 -1
- package/src/{css-utilities → modifiers}/index.ts +0 -1
- package/src/{css-utilities → modifiers}/scrollbar/index.ts +92 -17
- package/src/{css-utilities → modifiers}/scrollbar/scss/index.scss +178 -177
- package/src/{css-utilities → modifiers}/scrollbar/scss/variables.scss +28 -21
- package/src/normalize/scss/index.scss +4 -2
- package/src/shared/scss/color-weights.scss +19 -0
- package/src/shared/scss/index.scss +1 -12
- package/src/tokens/scss/blur.scss +5 -0
- package/src/tokens/scss/color.scss +74 -50
- package/src/tokens/scss/index.scss +1 -2
- package/src/tokens/scss/size.scss +0 -2
- package/src/tokens/scss/state.scss +3 -2
- package/src/tokens/scss/transition.scss +19 -2
- package/storage/svg/monitor.svg +1 -0
- package/storage/svg/moon.svg +1 -0
- package/storage/svg/pin.svg +1 -0
- package/storage/svg/sun.svg +1 -0
- package/vite.config.ts +33 -8
- package/build/css-utilities/background/scss/index.scss +0 -2
- package/build/css-utilities/border/scss/index.scss +0 -2
- package/build/css-utilities/color/scss/index.scss +0 -2
- package/build/css-utilities/flex/scss/index.scss +0 -2
- package/build/css-utilities/font/geist/index.d.ts +0 -1
- package/build/css-utilities/font/geist/index.js +0 -1
- package/build/css-utilities/font/geist/scss/index.scss +0 -2
- package/build/css-utilities/font/montserrat/index.d.ts +0 -1
- package/build/css-utilities/font/montserrat/index.js +0 -1
- package/build/css-utilities/font/montserrat/scss/Montserrat-Bold.woff +0 -0
- package/build/css-utilities/font/montserrat/scss/Montserrat-Bold.woff2 +0 -0
- package/build/css-utilities/font/montserrat/scss/Montserrat-BoldItalic.woff +0 -0
- package/build/css-utilities/font/montserrat/scss/Montserrat-BoldItalic.woff2 +0 -0
- package/build/css-utilities/font/montserrat/scss/Montserrat-Italic.woff +0 -0
- package/build/css-utilities/font/montserrat/scss/Montserrat-Italic.woff2 +0 -0
- package/build/css-utilities/font/montserrat/scss/Montserrat-Medium.woff +0 -0
- package/build/css-utilities/font/montserrat/scss/Montserrat-Medium.woff2 +0 -0
- package/build/css-utilities/font/montserrat/scss/Montserrat-MediumItalic.woff +0 -0
- package/build/css-utilities/font/montserrat/scss/Montserrat-MediumItalic.woff2 +0 -0
- package/build/css-utilities/font/montserrat/scss/Montserrat-Regular.woff +0 -0
- package/build/css-utilities/font/montserrat/scss/Montserrat-Regular.woff2 +0 -0
- package/build/css-utilities/font/montserrat/scss/Montserrat-SemiBold.woff +0 -0
- package/build/css-utilities/font/montserrat/scss/Montserrat-SemiBold.woff2 +0 -0
- package/build/css-utilities/font/montserrat/scss/Montserrat-SemiBoldItalic.woff +0 -0
- package/build/css-utilities/font/montserrat/scss/Montserrat-SemiBoldItalic.woff2 +0 -0
- package/build/css-utilities/font/montserrat/scss/index.scss +0 -2
- package/build/css-utilities/glass/index.js +0 -26
- package/build/css-utilities/glass/scss/index.scss +0 -2
- package/build/css-utilities/index.scss +0 -2
- package/build/css-utilities/inline/scss/index.scss +0 -2
- package/build/css-utilities/scrollbar/index.d.ts +0 -42
- package/build/css-utilities/scrollbar/scss/index.scss +0 -2
- package/build/css-utilities/skeleton/scss/index.scss +0 -2
- package/build/css-utilities/text/scss/index.scss +0 -2
- package/build/themes/dark/index.d.ts +0 -3
- package/build/themes/dark/index.js +0 -3
- package/build/themes/dark/input.d.ts +0 -3
- package/build/themes/dark/input.js +0 -12
- package/build/themes/dark/select.d.ts +0 -3
- package/build/themes/dark/select.js +0 -23
- package/build/themes/dark/textarea.d.ts +0 -2186
- package/build/themes/dark/textarea.js +0 -11
- package/src/css-utilities/background/scss/index.scss +0 -1
- package/src/css-utilities/background/scss/variables.scss +0 -18
- package/src/css-utilities/border/scss/index.scss +0 -1
- package/src/css-utilities/border/scss/variables.scss +0 -23
- package/src/css-utilities/color/scss/index.scss +0 -1
- package/src/css-utilities/color/scss/variables.scss +0 -17
- package/src/css-utilities/flex/scss/index.scss +0 -57
- package/src/css-utilities/flex/scss/variables.scss +0 -16
- package/src/css-utilities/font/geist/index.ts +0 -1
- package/src/css-utilities/font/montserrat/index.ts +0 -1
- package/src/css-utilities/font/montserrat/scss/Montserrat-Bold.woff +0 -0
- package/src/css-utilities/font/montserrat/scss/Montserrat-Bold.woff2 +0 -0
- package/src/css-utilities/font/montserrat/scss/Montserrat-BoldItalic.woff +0 -0
- package/src/css-utilities/font/montserrat/scss/Montserrat-BoldItalic.woff2 +0 -0
- package/src/css-utilities/font/montserrat/scss/Montserrat-Italic.woff +0 -0
- package/src/css-utilities/font/montserrat/scss/Montserrat-Italic.woff2 +0 -0
- package/src/css-utilities/font/montserrat/scss/Montserrat-Medium.woff +0 -0
- package/src/css-utilities/font/montserrat/scss/Montserrat-Medium.woff2 +0 -0
- package/src/css-utilities/font/montserrat/scss/Montserrat-MediumItalic.woff +0 -0
- package/src/css-utilities/font/montserrat/scss/Montserrat-MediumItalic.woff2 +0 -0
- package/src/css-utilities/font/montserrat/scss/Montserrat-Regular.woff +0 -0
- package/src/css-utilities/font/montserrat/scss/Montserrat-Regular.woff2 +0 -0
- package/src/css-utilities/font/montserrat/scss/Montserrat-SemiBold.woff +0 -0
- package/src/css-utilities/font/montserrat/scss/Montserrat-SemiBold.woff2 +0 -0
- package/src/css-utilities/font/montserrat/scss/Montserrat-SemiBoldItalic.woff +0 -0
- package/src/css-utilities/font/montserrat/scss/Montserrat-SemiBoldItalic.woff2 +0 -0
- package/src/css-utilities/font/montserrat/scss/index.scss +0 -94
- package/src/css-utilities/glass/index.ts +0 -42
- package/src/css-utilities/index.scss +0 -13
- package/src/css-utilities/skeleton/scss/variables.scss +0 -3
- package/src/css-utilities/text/scss/index.scss +0 -152
- package/src/css-utilities/text/scss/variables.scss +0 -22
- package/src/shared/scss/absolute.scss +0 -28
- package/src/shared/scss/background.scss +0 -21
- package/src/shared/scss/border.scss +0 -21
- package/src/shared/scss/color.scss +0 -21
- package/src/shared/scss/position.scss +0 -55
- package/src/shared/scss/text.scss +0 -31
- package/src/themes/dark/index.ts +0 -3
- package/src/themes/dark/input.ts +0 -16
- package/src/themes/dark/select.ts +0 -28
- package/src/themes/dark/textarea.ts +0 -13
- package/src/tokens/scss/box-shadow.scss +0 -23
- package/src/tokens/scss/font-family.scss +0 -5
- package/storage/code.md +0 -180
- package/storage/editor-features.md +0 -227
- package/build/css-utilities/font/geist/{scss/Geist-Italic-Variable.woff2 → Geist-Italic-Variable.woff2} +0 -0
- package/build/css-utilities/font/geist/{scss/Geist-Variable.woff2 → Geist-Variable.woff2} +0 -0
- package/build/css-utilities/font/geist/{scss/GeistMono-Italic-Variable.woff2 → GeistMono-Italic-Variable.woff2} +0 -0
- package/build/css-utilities/font/geist/{scss/GeistMono-Variable.woff2 → GeistMono-Variable.woff2} +0 -0
- package/src/{shared/scss → css-utilities}/anchor.scss +6 -6
- package/src/{shared/scss → css-utilities}/drag.scss +0 -0
- package/src/css-utilities/font/geist/{scss/Geist-Italic-Variable.woff2 → Geist-Italic-Variable.woff2} +0 -0
- package/src/css-utilities/font/geist/{scss/Geist-Variable.woff2 → Geist-Variable.woff2} +0 -0
- package/src/css-utilities/font/geist/{scss/GeistMono-Italic-Variable.woff2 → GeistMono-Italic-Variable.woff2} +0 -0
- package/src/css-utilities/font/geist/{scss/GeistMono-Variable.woff2 → GeistMono-Variable.woff2} +0 -0
- package/src/{shared/scss → css-utilities}/hidden.scss +11 -11
- /package/src/{shared/scss → css-utilities}/layer.scss +0 -0
- /package/src/{shared/scss → css-utilities}/reset.scss +0 -0
|
@@ -0,0 +1,551 @@
|
|
|
1
|
+
import { effect, read, root, signal, untrack, write, type Signal } from '@esportsplus/reactivity';
|
|
2
|
+
import Decorations, { type Decoration } from '../tree/decorations';
|
|
3
|
+
import type { CodeController } from '../code/view';
|
|
4
|
+
import type { FileTreeElement, FileTreeImportEntry, FileTreeSnapshot } from '../tree';
|
|
5
|
+
import {
|
|
6
|
+
containsPath,
|
|
7
|
+
dirty,
|
|
8
|
+
workspacePath,
|
|
9
|
+
type EditorWorkspaceModel,
|
|
10
|
+
type WorkspaceChange,
|
|
11
|
+
type WorkspaceSession,
|
|
12
|
+
type WorkspaceSessionTab,
|
|
13
|
+
type WorkspaceTab
|
|
14
|
+
} from './model';
|
|
15
|
+
import type { WorkspaceEditorController } from './index';
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
type Baseline = {
|
|
19
|
+
// The latest fetch, settled once its text is in.
|
|
20
|
+
fetched: Promise<void>;
|
|
21
|
+
request: number;
|
|
22
|
+
// The tab's saved text when this was fetched: a save or an outside change fetches it again.
|
|
23
|
+
saved: string;
|
|
24
|
+
text: Signal<string | null>;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
type Shown = { controller: WorkspaceEditorController; tab: WorkspaceTab };
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
// Session writes wait this long after the last change.
|
|
31
|
+
const DELAY = 500;
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
function code(controller: WorkspaceEditorController): controller is CodeController {
|
|
35
|
+
return 'folds' in controller && 'nextChange' in controller;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function message(error: unknown) {
|
|
39
|
+
return (error instanceof Error ? error.message : String(error)).replace(/^Workspace: /, '');
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function numbers(value: unknown) {
|
|
43
|
+
return Array.isArray(value) ? value.filter((item): item is number => Number.isFinite(item)) : [];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function offset(value: unknown, length: number) {
|
|
47
|
+
return Number.isFinite(value) ? Math.max(0, Math.min(length, Math.trunc(value as number))) : 0;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Stored sessions outlive the code that wrote them and may be edited by hand, so each field is checked on the way in.
|
|
51
|
+
function parse(value: WorkspaceSession | null | undefined): WorkspaceSession | null {
|
|
52
|
+
if (!value || typeof value !== 'object' || !Array.isArray(value.tabs)) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
let tabs: WorkspaceSessionTab[] = [];
|
|
57
|
+
|
|
58
|
+
for (let i = 0, n = value.tabs.length; i < n; i++) {
|
|
59
|
+
let tab = value.tabs[i];
|
|
60
|
+
|
|
61
|
+
if (!tab || typeof tab.path !== 'string') {
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
tabs.push({
|
|
66
|
+
...(typeof tab.draft === 'string' ? { draft: tab.draft } : {}),
|
|
67
|
+
folds: numbers(tab.folds),
|
|
68
|
+
path: tab.path,
|
|
69
|
+
pinned: tab.pinned === true,
|
|
70
|
+
preview: tab.preview === true,
|
|
71
|
+
scroll: { left: Math.max(0, Number(tab.scroll?.left) || 0), top: Math.max(0, Number(tab.scroll?.top) || 0) },
|
|
72
|
+
selection: { anchor: Number(tab.selection?.anchor) || 0, head: Number(tab.selection?.head) || 0 }
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return {
|
|
77
|
+
active: typeof value.active === 'string' ? value.active : null,
|
|
78
|
+
explorer: {
|
|
79
|
+
expanded: Array.isArray(value.explorer?.expanded) ? value.explorer.expanded.filter((id) => typeof id === 'string') : [],
|
|
80
|
+
scroll: Math.max(0, Number(value.explorer?.scroll) || 0)
|
|
81
|
+
},
|
|
82
|
+
tabs
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function selection(tab: WorkspaceTab): WorkspaceSessionTab['selection'] {
|
|
87
|
+
let { direction, end, start } = tab.document.selection;
|
|
88
|
+
|
|
89
|
+
return direction === 'backward' ? { anchor: end, head: start } : { anchor: start, head: end };
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
// What the workspace takes from its host beyond files: the persisted session (hot exit included), each tab's git
|
|
94
|
+
// baseline, OS drag and drop, and the change and problem marks the explorer's next/previous step between.
|
|
95
|
+
const hosted = (model: EditorWorkspaceModel, current: () => Shown | undefined, delay = DELAY) => {
|
|
96
|
+
let baselines = new Map<string, Baseline>(),
|
|
97
|
+
disposed = false,
|
|
98
|
+
documents = new Map<WorkspaceTab, VoidFunction>(),
|
|
99
|
+
explorer: FileTreeSnapshot = {},
|
|
100
|
+
folded = new WeakMap<WorkspaceTab, number[]>(),
|
|
101
|
+
host = model.host,
|
|
102
|
+
last = '',
|
|
103
|
+
marks = new Decorations(),
|
|
104
|
+
// Folds a restored tab gets once its editor first shows it.
|
|
105
|
+
pending = new WeakMap<WorkspaceTab, number[]>(),
|
|
106
|
+
problems = new Map<WorkspaceTab, { errors: number; warnings: number }>(),
|
|
107
|
+
ready = signal(!host.session),
|
|
108
|
+
restored = !host.session,
|
|
109
|
+
restoring: Promise<void> | undefined,
|
|
110
|
+
stopProblems: VoidFunction | undefined,
|
|
111
|
+
timer: ReturnType<typeof setTimeout> | undefined,
|
|
112
|
+
waiters = new Map<WorkspaceTab, ((controller: WorkspaceEditorController | undefined) => void)[]>();
|
|
113
|
+
|
|
114
|
+
function capture(): WorkspaceSession {
|
|
115
|
+
let shown = current(),
|
|
116
|
+
state = model.state,
|
|
117
|
+
tabs: WorkspaceSessionTab[] = [];
|
|
118
|
+
|
|
119
|
+
for (let i = 0, n = state.tabs.length; i < n; i++) {
|
|
120
|
+
let tab = state.tabs[i];
|
|
121
|
+
|
|
122
|
+
// A compare tab is a snapshot of two files, not a file to reopen.
|
|
123
|
+
if (tab.compare) {
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
let live = shown?.tab === tab && shown.controller.host?.isConnected ? shown.controller : undefined,
|
|
128
|
+
item: WorkspaceSessionTab = {
|
|
129
|
+
folds: live && code(live) ? live.folds() : (folded.get(tab) ?? pending.get(tab) ?? []),
|
|
130
|
+
path: tab.path,
|
|
131
|
+
pinned: tab.pinned,
|
|
132
|
+
preview: tab.preview,
|
|
133
|
+
scroll: live ? { left: live.scroller.scrollLeft, top: live.scroller.scrollTop } : { ...tab.scroll },
|
|
134
|
+
selection: selection(tab)
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
if (dirty(tab) || tab.missing) {
|
|
138
|
+
item.draft = tab.document.value;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
tabs.push(item);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return {
|
|
145
|
+
active: state.active && !state.active.compare ? state.active.path : null,
|
|
146
|
+
explorer: { expanded: [...(explorer.expanded ?? [])], scroll: explorer.scroll ?? 0 },
|
|
147
|
+
tabs
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
async function fetch(path: string, entry: Baseline) {
|
|
152
|
+
let cwd = model.state.cwd,
|
|
153
|
+
request = ++entry.request,
|
|
154
|
+
text: string | null = null;
|
|
155
|
+
|
|
156
|
+
try {
|
|
157
|
+
text = await host.baseline!(cwd, path);
|
|
158
|
+
}
|
|
159
|
+
catch (error) {
|
|
160
|
+
if (baselines.get(path) === entry) {
|
|
161
|
+
model.status(`Could not read the baseline of ${path}: ${message(error)}`, true);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if (!disposed && baselines.get(path) === entry && entry.request === request && cwd === model.state.cwd) {
|
|
166
|
+
write(entry.text, typeof text === 'string' ? text : null);
|
|
167
|
+
mark();
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function flush() {
|
|
172
|
+
clearTimeout(timer);
|
|
173
|
+
timer = undefined;
|
|
174
|
+
mark();
|
|
175
|
+
|
|
176
|
+
if (!restored || !host.session) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
let session = capture(),
|
|
181
|
+
json = JSON.stringify(session);
|
|
182
|
+
|
|
183
|
+
if (json === last) {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
last = json;
|
|
188
|
+
host.session.set(session).catch((error) => {
|
|
189
|
+
last = '';
|
|
190
|
+
model.status(`Could not save the session: ${message(error)}`, true);
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function mark() {
|
|
195
|
+
let entries: [string, Decoration][] = [],
|
|
196
|
+
tabs = model.state.tabs;
|
|
197
|
+
|
|
198
|
+
for (let i = 0, n = tabs.length; i < n; i++) {
|
|
199
|
+
let tab = tabs[i],
|
|
200
|
+
baseline = baselines.get(tab.path),
|
|
201
|
+
counts = problems.get(tab),
|
|
202
|
+
decoration: Decoration = {},
|
|
203
|
+
text = baseline && untrack(() => read(baseline.text));
|
|
204
|
+
|
|
205
|
+
if (typeof text === 'string' && text !== tab.document.value) {
|
|
206
|
+
decoration.status = 'modified';
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
if (counts?.errors) {
|
|
210
|
+
decoration.errors = counts.errors;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
if (counts?.warnings) {
|
|
214
|
+
decoration.warnings = counts.warnings;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
if (decoration.errors || decoration.status || decoration.warnings) {
|
|
218
|
+
entries.push([tab.path, decoration]);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
marks.replace(entries);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
async function reopen(session: WorkspaceSession) {
|
|
226
|
+
let cwd = model.state.cwd;
|
|
227
|
+
|
|
228
|
+
for (let i = 0, n = session.tabs.length; i < n; i++) {
|
|
229
|
+
let item = session.tabs[i],
|
|
230
|
+
content: string | undefined,
|
|
231
|
+
path: string;
|
|
232
|
+
|
|
233
|
+
try {
|
|
234
|
+
path = workspacePath(item.path, cwd);
|
|
235
|
+
}
|
|
236
|
+
catch {
|
|
237
|
+
continue;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
try {
|
|
241
|
+
content = await host.read(cwd, path);
|
|
242
|
+
}
|
|
243
|
+
catch {
|
|
244
|
+
content = undefined;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
if (disposed || cwd !== model.state.cwd) {
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// A file gone from disk comes back only for the draft it held.
|
|
252
|
+
if (content === undefined && item.draft === undefined) {
|
|
253
|
+
continue;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
let tab = model.adopt(path, item.draft ?? content!, content ?? '', content === undefined);
|
|
257
|
+
|
|
258
|
+
if (!tab) {
|
|
259
|
+
continue;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
let length = tab.document.value.length,
|
|
263
|
+
anchor = offset(item.selection.anchor, length),
|
|
264
|
+
head = offset(item.selection.head, length);
|
|
265
|
+
|
|
266
|
+
if (item.pinned) {
|
|
267
|
+
model.pin(path);
|
|
268
|
+
}
|
|
269
|
+
else {
|
|
270
|
+
tab.preview = item.preview;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
tab.scroll = { ...item.scroll };
|
|
274
|
+
tab.document.select({ direction: head < anchor ? 'backward' : 'forward', end: Math.max(anchor, head), start: Math.min(anchor, head) });
|
|
275
|
+
|
|
276
|
+
if (item.folds.length) {
|
|
277
|
+
pending.set(tab, item.folds);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
// Whatever the user opened meanwhile stays in front.
|
|
282
|
+
if (session.active && !model.state.active && !model.state.opening.length) {
|
|
283
|
+
model.activate(session.active);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
function schedule() {
|
|
288
|
+
clearTimeout(timer);
|
|
289
|
+
timer = setTimeout(flush, delay);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
function settle(tab: WorkspaceTab, controller: WorkspaceEditorController | undefined) {
|
|
293
|
+
let list = waiters.get(tab);
|
|
294
|
+
|
|
295
|
+
waiters.delete(tab);
|
|
296
|
+
|
|
297
|
+
for (let i = 0, n = list?.length ?? 0; i < n; i++) {
|
|
298
|
+
list;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
function sync() {
|
|
303
|
+
let open = new Set<string>(),
|
|
304
|
+
tabs = model.state.tabs;
|
|
305
|
+
|
|
306
|
+
for (let i = 0, n = tabs.length; i < n; i++) {
|
|
307
|
+
let tab = tabs[i];
|
|
308
|
+
|
|
309
|
+
open.add(tab.path);
|
|
310
|
+
|
|
311
|
+
if (!documents.has(tab)) {
|
|
312
|
+
documents.set(tab, tab.document.subscribe((_, change) => {
|
|
313
|
+
if (change.selectionChanged || change.textChanged) {
|
|
314
|
+
schedule();
|
|
315
|
+
}
|
|
316
|
+
}));
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
if (!host.baseline) {
|
|
320
|
+
continue;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
let entry = baselines.get(tab.path);
|
|
324
|
+
|
|
325
|
+
if (!entry) {
|
|
326
|
+
track(tab);
|
|
327
|
+
}
|
|
328
|
+
else if (entry.saved !== tab.saved) {
|
|
329
|
+
entry.saved = tab.saved;
|
|
330
|
+
entry.fetched = fetch(tab.path, entry);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
for (let [tab, stop] of documents) {
|
|
335
|
+
if (!tabs.includes(tab)) {
|
|
336
|
+
stop();
|
|
337
|
+
documents.delete(tab);
|
|
338
|
+
problems.delete(tab);
|
|
339
|
+
settle(tab, undefined);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
for (let path of [...baselines.keys()]) {
|
|
344
|
+
if (!open.has(path)) {
|
|
345
|
+
baselines.delete(path);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
schedule();
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
function track(tab: WorkspaceTab) {
|
|
353
|
+
let entry: Baseline = { fetched: Promise.resolve(), request: 0, saved: tab.saved, text: signal<string | null>(null) };
|
|
354
|
+
|
|
355
|
+
baselines.set(tab.path, entry);
|
|
356
|
+
entry.fetched = fetch(tab.path, entry);
|
|
357
|
+
|
|
358
|
+
return entry;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
function watched(event: WorkspaceChange) {
|
|
362
|
+
for (let [path, entry] of baselines) {
|
|
363
|
+
if (!event.paths || event.paths.some((changed) => containsPath(changed, path))) {
|
|
364
|
+
entry.fetched = fetch(path, entry);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
return {
|
|
370
|
+
// The text the tab's git gutter diffs against; reactive, so the editor's options follow it once fetched.
|
|
371
|
+
baseline(path: string) {
|
|
372
|
+
if (!host.baseline) {
|
|
373
|
+
return undefined;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
// An editor can ask before the workspace has heard of the path, as it does mid-rename.
|
|
377
|
+
let entry = baselines.get(path) ?? untrack(() => {
|
|
378
|
+
let tab = model.state.tabs.find((item) => item.path === path);
|
|
379
|
+
|
|
380
|
+
return tab && track(tab);
|
|
381
|
+
});
|
|
382
|
+
|
|
383
|
+
return entry ? read(entry.text) : null;
|
|
384
|
+
},
|
|
385
|
+
connect(element: HTMLElement) {
|
|
386
|
+
let listening = new AbortController(),
|
|
387
|
+
unsubscribe = model.subscribe(sync),
|
|
388
|
+
unwatch = model.onWatch(watched);
|
|
389
|
+
|
|
390
|
+
// Scrolling, folding and opening folders tell nothing else, so any gesture in the workspace may be one.
|
|
391
|
+
element.addEventListener('keyup', schedule, { capture: true, passive: true, signal: listening.signal });
|
|
392
|
+
element.addEventListener('pointerup', schedule, { capture: true, passive: true, signal: listening.signal });
|
|
393
|
+
element.addEventListener('scroll', schedule, { capture: true, passive: true, signal: listening.signal });
|
|
394
|
+
// Hot exit: a closing page never disconnects the workspace.
|
|
395
|
+
element.ownerDocument.defaultView?.addEventListener('pagehide', flush, { signal: listening.signal });
|
|
396
|
+
sync();
|
|
397
|
+
|
|
398
|
+
return () => {
|
|
399
|
+
listening.abort();
|
|
400
|
+
unsubscribe();
|
|
401
|
+
unwatch();
|
|
402
|
+
flush();
|
|
403
|
+
stopProblems?.();
|
|
404
|
+
stopProblems = undefined;
|
|
405
|
+
|
|
406
|
+
for (let stop of documents.values()) {
|
|
407
|
+
stop();
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
documents.clear();
|
|
411
|
+
};
|
|
412
|
+
},
|
|
413
|
+
dispose() {
|
|
414
|
+
flush();
|
|
415
|
+
disposed = true;
|
|
416
|
+
},
|
|
417
|
+
explorer,
|
|
418
|
+
export: host.export && ((element: FileTreeElement) => host.export!(model.state.cwd, element.id)),
|
|
419
|
+
flush,
|
|
420
|
+
import: host.import && (async (target: FileTreeElement | null, entries: readonly FileTreeImportEntry[]) => {
|
|
421
|
+
let folder = !target ? '' : target.type === 'file' ? target.id.slice(0, Math.max(0, target.id.lastIndexOf('/'))) : target.id;
|
|
422
|
+
|
|
423
|
+
try {
|
|
424
|
+
await host.import!(model.state.cwd, folder, entries);
|
|
425
|
+
}
|
|
426
|
+
catch (error) {
|
|
427
|
+
model.status(`Import failed: ${message(error)}`, true);
|
|
428
|
+
return;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
model.status(`Imported ${entries.length === 1 ? entries[0].path : `${entries.length} items`}`);
|
|
432
|
+
await model.refresh();
|
|
433
|
+
}),
|
|
434
|
+
// The tab's baseline once its latest fetch is in; null for none.
|
|
435
|
+
async loaded(path: string) {
|
|
436
|
+
let entry = baselines.get(path);
|
|
437
|
+
|
|
438
|
+
while (entry && baselines.get(path) === entry) {
|
|
439
|
+
let fetched = entry.fetched;
|
|
440
|
+
|
|
441
|
+
await fetched;
|
|
442
|
+
|
|
443
|
+
if (fetched === entry.fetched) {
|
|
444
|
+
break;
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
return entry && baselines.get(path) === entry ? untrack(() => read(entry.text)) : null;
|
|
449
|
+
},
|
|
450
|
+
mark,
|
|
451
|
+
marks,
|
|
452
|
+
ready: () => read(ready),
|
|
453
|
+
// The shown tab is leaving its editor: its folds stay with it.
|
|
454
|
+
remember(tab: WorkspaceTab, controller: WorkspaceEditorController) {
|
|
455
|
+
if (code(controller)) {
|
|
456
|
+
folded.set(tab, controller.folds());
|
|
457
|
+
}
|
|
458
|
+
},
|
|
459
|
+
// Starts the model, then brings back the stored session once; nothing is written until it's back.
|
|
460
|
+
restore() {
|
|
461
|
+
if (!host.session || restored) {
|
|
462
|
+
return model.start();
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
return restoring ??= (async () => {
|
|
466
|
+
let loading = model.start(),
|
|
467
|
+
session: WorkspaceSession | null = null;
|
|
468
|
+
|
|
469
|
+
try {
|
|
470
|
+
session = parse(await host.session!.get());
|
|
471
|
+
}
|
|
472
|
+
catch (error) {
|
|
473
|
+
model.status(`Could not restore the session: ${message(error)}`, true);
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
await loading;
|
|
477
|
+
|
|
478
|
+
if (disposed) {
|
|
479
|
+
return;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
if (session) {
|
|
483
|
+
explorer.expanded = session.explorer.expanded;
|
|
484
|
+
explorer.scroll = session.explorer.scroll;
|
|
485
|
+
last = JSON.stringify(session);
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
write(ready, true);
|
|
489
|
+
|
|
490
|
+
try {
|
|
491
|
+
if (session) {
|
|
492
|
+
await reopen(session);
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
finally {
|
|
496
|
+
restored = true;
|
|
497
|
+
}
|
|
498
|
+
})();
|
|
499
|
+
},
|
|
500
|
+
// A tab's editor is showing it, scrolled where it was left; folds come first, since they change the height.
|
|
501
|
+
shown(tab: WorkspaceTab, controller: WorkspaceEditorController) {
|
|
502
|
+
let lines = pending.get(tab);
|
|
503
|
+
|
|
504
|
+
pending.delete(tab);
|
|
505
|
+
|
|
506
|
+
if (code(controller)) {
|
|
507
|
+
for (let i = 0, n = lines?.length ?? 0; i < n; i++) {
|
|
508
|
+
controller.fold(lines![i]);
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
stopProblems?.();
|
|
512
|
+
stopProblems = root((dispose) => {
|
|
513
|
+
effect(() => {
|
|
514
|
+
let { errors, warnings } = controller.state.problems;
|
|
515
|
+
|
|
516
|
+
untrack(() => {
|
|
517
|
+
if (current()?.tab === tab) {
|
|
518
|
+
problems.set(tab, { errors, warnings });
|
|
519
|
+
mark();
|
|
520
|
+
}
|
|
521
|
+
});
|
|
522
|
+
});
|
|
523
|
+
|
|
524
|
+
return dispose;
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
settle(tab, controller);
|
|
529
|
+
},
|
|
530
|
+
// Resolves once an editor shows the tab, or with undefined when the tab closes first.
|
|
531
|
+
whenShown(tab: WorkspaceTab) {
|
|
532
|
+
let shown = current();
|
|
533
|
+
|
|
534
|
+
if (shown?.tab === tab) {
|
|
535
|
+
return Promise.resolve(shown.controller);
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
return new Promise<WorkspaceEditorController | undefined>((resolve) => {
|
|
539
|
+
let list = waiters.get(tab) ?? [];
|
|
540
|
+
|
|
541
|
+
list.push(resolve);
|
|
542
|
+
waiters.set(tab, list);
|
|
543
|
+
});
|
|
544
|
+
}
|
|
545
|
+
};
|
|
546
|
+
};
|
|
547
|
+
|
|
548
|
+
|
|
549
|
+
export default hosted;
|
|
550
|
+
export { parse };
|
|
551
|
+
export type { Shown };
|