@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,255 @@
|
|
|
1
|
+
import { computed, effect, reactive, read, signal, untrack, write } from '@esportsplus/reactivity';
|
|
2
|
+
import { html } from '@esportsplus/template';
|
|
3
|
+
import type { Command as PaletteCommand } from '~/components/command';
|
|
4
|
+
import input from '~/components/input';
|
|
5
|
+
import overlay from '~/components/overlay';
|
|
6
|
+
import shortcutRecorder from '~/components/shortcut-recorder';
|
|
7
|
+
import scrollbar from '~/modifiers/scrollbar';
|
|
8
|
+
import type { Command } from '../code';
|
|
9
|
+
import {
|
|
10
|
+
bind,
|
|
11
|
+
conflict,
|
|
12
|
+
fromChord,
|
|
13
|
+
fromRecorder,
|
|
14
|
+
label,
|
|
15
|
+
matches,
|
|
16
|
+
reset,
|
|
17
|
+
rows,
|
|
18
|
+
unassign,
|
|
19
|
+
type KeybindingRow,
|
|
20
|
+
type Keybindings
|
|
21
|
+
} from './keybindings';
|
|
22
|
+
import keyboard from '@esportsplus/ui/svg/keyboard.svg';
|
|
23
|
+
import '~/components/button/scss/index.scss';
|
|
24
|
+
import './scss/keybindings.scss';
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
type A = {
|
|
28
|
+
apple: boolean;
|
|
29
|
+
// Element id prefix.
|
|
30
|
+
id: string;
|
|
31
|
+
keybindings: () => Keybindings;
|
|
32
|
+
onchange: (keybindings: Keybindings) => void;
|
|
33
|
+
state: { active: boolean };
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// A recorded chord another command holds, waiting for the user to take it or not.
|
|
37
|
+
type Pending = { command: Command; keys: string; owner: Command };
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
// The chords that open the keybinding editor, as 'combo' writes them; the code editor keymap has no sequences, so
|
|
41
|
+
// the workspace runs this one itself.
|
|
42
|
+
const OPEN = ['Mod+k', 'Mod+s'] as const;
|
|
43
|
+
|
|
44
|
+
const PALETTE: PaletteCommand = {
|
|
45
|
+
group: 'Preferences',
|
|
46
|
+
icon: keyboard,
|
|
47
|
+
id: 'workspace.keybindings',
|
|
48
|
+
label: 'Open Keyboard Shortcuts'
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
const shortcuts = ({ apple, id, keybindings, onchange, state }: A) => {
|
|
53
|
+
let current = computed(() => rows(keybindings(), apple)),
|
|
54
|
+
initial = untrack(() => read(current)),
|
|
55
|
+
names = new Map(initial.map((row) => [row.id, row.label])),
|
|
56
|
+
pending = signal<Pending | undefined>(undefined),
|
|
57
|
+
ui = reactive({ query: '' });
|
|
58
|
+
|
|
59
|
+
function apply(next: Keybindings) {
|
|
60
|
+
write(pending, undefined);
|
|
61
|
+
onchange(next);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function confirm() {
|
|
65
|
+
let held = read(pending);
|
|
66
|
+
|
|
67
|
+
if (held) {
|
|
68
|
+
onchange(bind(keybindings(), apple, held.command, held.keys));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
write(pending, undefined);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// A recorder's value as it ought to read for the row, so values written back from the table are told apart
|
|
75
|
+
// from ones the user recorded.
|
|
76
|
+
function shown(row: KeybindingRow) {
|
|
77
|
+
return row.chords.length ? fromChord(row.chords[0], apple) : '';
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function record(index: number, value: string) {
|
|
81
|
+
let row = read(current)[index];
|
|
82
|
+
|
|
83
|
+
if (value === shown(row)) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (!value) {
|
|
88
|
+
apply(unassign(keybindings(), apple, row.id));
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
let keys = fromRecorder(value, apple);
|
|
93
|
+
|
|
94
|
+
if (!keys) {
|
|
95
|
+
write(pending, undefined);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
let owner = conflict(keybindings(), apple, row.id, keys);
|
|
100
|
+
|
|
101
|
+
if (owner) {
|
|
102
|
+
write(pending, { command: row.id, keys, owner });
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
apply(bind(keybindings(), apple, row.id, keys));
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function row(info: KeybindingRow, index: number) {
|
|
110
|
+
let recorder = reactive({ error: '', value: shown(info) }),
|
|
111
|
+
entry = () => read(current)[index],
|
|
112
|
+
// Built-in keys alone: the recorder only adds a chord, so it shows none of its own.
|
|
113
|
+
adding = () => !entry().chords.length && entry().builtin.length > 0;
|
|
114
|
+
|
|
115
|
+
// A chord waiting on a conflict stays shown; anything else follows the table.
|
|
116
|
+
effect(() => {
|
|
117
|
+
let held = read(pending)?.command === info.id,
|
|
118
|
+
value = shown(entry());
|
|
119
|
+
|
|
120
|
+
if (!held) {
|
|
121
|
+
untrack(() => {
|
|
122
|
+
recorder.value = value;
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
effect(() => {
|
|
128
|
+
let value = recorder.value;
|
|
129
|
+
|
|
130
|
+
untrack(() => record(index, value));
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
return html`
|
|
134
|
+
<div class='code-workspace-keybindings-row' role='row' ${{ hidden: () => !matches(entry(), ui.query, apple) }}>
|
|
135
|
+
<div class='code-workspace-keybindings-command' role='cell'>
|
|
136
|
+
<span class='code-workspace-keybindings-label'>${info.label}</span>
|
|
137
|
+
<span class='code-workspace-keybindings-id'>${info.id}</span>
|
|
138
|
+
</div>
|
|
139
|
+
<div class='code-workspace-keybindings-keys' role='cell'>
|
|
140
|
+
${() => entry().builtin.map((keys) => html`
|
|
141
|
+
<kbd
|
|
142
|
+
class='button button--kbd code-workspace-keybindings-key code-workspace-keybindings-key--builtin'
|
|
143
|
+
title='Built into the editor and not removable here; a chord bound to another command takes it over'
|
|
144
|
+
>
|
|
145
|
+
${label(keys, apple)}
|
|
146
|
+
</kbd>
|
|
147
|
+
`)}
|
|
148
|
+
${shortcutRecorder({
|
|
149
|
+
'aria-label': `Keybinding for ${info.label}`,
|
|
150
|
+
class: ['code-workspace-keybindings-recorder', () => adding() && 'code-workspace-keybindings-recorder--add'],
|
|
151
|
+
state: recorder,
|
|
152
|
+
taken: (shortcut) => (fromRecorder(shortcut, apple) === OPEN[0] ? 'the keyboard shortcuts chord' : null),
|
|
153
|
+
title: () => (adding() ? `Add a keybinding for ${info.label}` : undefined)
|
|
154
|
+
})}
|
|
155
|
+
${() => entry().chords.slice(1).map((keys) => html`
|
|
156
|
+
<kbd class='button button--kbd code-workspace-keybindings-key'>${label(keys, apple)}</kbd>
|
|
157
|
+
`)}
|
|
158
|
+
${() => {
|
|
159
|
+
let held = read(pending);
|
|
160
|
+
|
|
161
|
+
if (held?.command !== info.id) {
|
|
162
|
+
return '';
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return html`
|
|
166
|
+
<div class='code-workspace-keybindings-conflict' role='alert'>
|
|
167
|
+
<span class='code-workspace-keybindings-conflict-text'>
|
|
168
|
+
${label(held.keys, apple)} is bound to ${names.get(held.owner)}.
|
|
169
|
+
</span>
|
|
170
|
+
<button class='button code-workspace-keybindings-button code-workspace-keybindings-button--primary' type='button' onclick='${confirm}'>
|
|
171
|
+
Replace
|
|
172
|
+
</button>
|
|
173
|
+
<button class='button code-workspace-keybindings-button' type='button' onclick='${() => write(pending, undefined)}'>
|
|
174
|
+
Cancel
|
|
175
|
+
</button>
|
|
176
|
+
</div>
|
|
177
|
+
`;
|
|
178
|
+
}}
|
|
179
|
+
</div>
|
|
180
|
+
<div class='code-workspace-keybindings-source' role='cell'>${() => (entry().user ? 'User' : 'Default')}</div>
|
|
181
|
+
<div class='code-workspace-keybindings-actions' role='cell'>
|
|
182
|
+
<button
|
|
183
|
+
class='button code-workspace-keybindings-button'
|
|
184
|
+
type='button'
|
|
185
|
+
${{
|
|
186
|
+
'aria-label': `Reset ${info.label}`,
|
|
187
|
+
disabled: () => !entry().user,
|
|
188
|
+
onclick: () => apply(reset(keybindings(), apple, info.id))
|
|
189
|
+
}}
|
|
190
|
+
>
|
|
191
|
+
Reset
|
|
192
|
+
</button>
|
|
193
|
+
</div>
|
|
194
|
+
</div>
|
|
195
|
+
`;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
effect(() => {
|
|
199
|
+
if (!state.active) {
|
|
200
|
+
untrack(() => write(pending, undefined));
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
return overlay(
|
|
205
|
+
{
|
|
206
|
+
'aria-labelledby': `${id}-keybindings`,
|
|
207
|
+
class: 'card code-workspace-keybindings',
|
|
208
|
+
state
|
|
209
|
+
},
|
|
210
|
+
html`
|
|
211
|
+
<div class='code-workspace-keybindings-header'>
|
|
212
|
+
<h2 class='code-workspace-keybindings-title' id='${id}-keybindings'>Keyboard Shortcuts</h2>
|
|
213
|
+
<button
|
|
214
|
+
class='button code-workspace-keybindings-button'
|
|
215
|
+
type='button'
|
|
216
|
+
${{
|
|
217
|
+
disabled: () => !Object.keys(keybindings()).length,
|
|
218
|
+
onclick: () => apply({})
|
|
219
|
+
}}
|
|
220
|
+
>
|
|
221
|
+
Reset all
|
|
222
|
+
</button>
|
|
223
|
+
</div>
|
|
224
|
+
${input({
|
|
225
|
+
'aria-label': 'Search keybindings',
|
|
226
|
+
autocomplete: 'off',
|
|
227
|
+
autofocus: true,
|
|
228
|
+
class: 'code-workspace-keybindings-search',
|
|
229
|
+
oninput: (event: Event) => {
|
|
230
|
+
ui.query = (event.target as HTMLInputElement).value;
|
|
231
|
+
},
|
|
232
|
+
placeholder: 'Search by command, id or key',
|
|
233
|
+
spellcheck: false,
|
|
234
|
+
type: 'search',
|
|
235
|
+
value: () => ui.query
|
|
236
|
+
})}
|
|
237
|
+
<div aria-label='Keybindings' class='code-workspace-keybindings-table' role='table' ${scrollbar()}>
|
|
238
|
+
<div class='code-workspace-keybindings-row code-workspace-keybindings-row--head' role='row'>
|
|
239
|
+
<span role='columnheader'>Command</span>
|
|
240
|
+
<span role='columnheader'>Keybinding</span>
|
|
241
|
+
<span role='columnheader'>Source</span>
|
|
242
|
+
<span role='columnheader'><span class='code-workspace-keybindings-hidden'>Reset</span></span>
|
|
243
|
+
</div>
|
|
244
|
+
${initial.map(row)}
|
|
245
|
+
${() => read(current).every((entry) => !matches(entry, ui.query, apple)) && html`
|
|
246
|
+
<div class='code-workspace-keybindings-empty' role='status'>No commands match</div>
|
|
247
|
+
`}
|
|
248
|
+
</div>
|
|
249
|
+
`
|
|
250
|
+
);
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
export default shortcuts;
|
|
255
|
+
export { OPEN, PALETTE };
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import { reactive } from '@esportsplus/reactivity';
|
|
2
|
+
import type { Edit, EditorDocument, Language, Options, Selection } from '../code';
|
|
3
|
+
import type { Status } from '~/components/inline-edit/status';
|
|
4
|
+
import { dirty, type EditorWorkspaceModel, type WorkspacePreferences, type WorkspaceTab } from './model';
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
type AutoSaveMode = WorkspacePreferences['autoSave'];
|
|
8
|
+
|
|
9
|
+
type Indentation = { size: number; tabs: boolean };
|
|
10
|
+
|
|
11
|
+
type LineEnding = 'crlf' | 'lf';
|
|
12
|
+
|
|
13
|
+
type Tracked = {
|
|
14
|
+
dirty: boolean;
|
|
15
|
+
saved: string;
|
|
16
|
+
timer?: ReturnType<typeof setTimeout>;
|
|
17
|
+
unsubscribe: VoidFunction;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
const AUTO_SAVE_MODES: Record<AutoSaveMode, string> = {
|
|
22
|
+
delay: 'After delay',
|
|
23
|
+
focus: 'On focus change',
|
|
24
|
+
off: 'Off'
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const INDENT_SIZES = [2, 4, 8];
|
|
28
|
+
|
|
29
|
+
const LANGUAGES: Record<Language, string> = {
|
|
30
|
+
css: 'CSS',
|
|
31
|
+
html: 'HTML',
|
|
32
|
+
javascript: 'JavaScript',
|
|
33
|
+
json: 'JSON',
|
|
34
|
+
jsonc: 'JSON with Comments',
|
|
35
|
+
jsx: 'JavaScript JSX',
|
|
36
|
+
markdown: 'Markdown',
|
|
37
|
+
plain: 'Plain Text',
|
|
38
|
+
python: 'Python',
|
|
39
|
+
scss: 'SCSS',
|
|
40
|
+
tsx: 'TypeScript JSX',
|
|
41
|
+
typescript: 'TypeScript'
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const LINE_BREAK = /\r\n|\r|\n/g;
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
function indentation({ size, tabs }: Indentation): Options {
|
|
48
|
+
return { indent: tabs ? '\t' : ' '.repeat(size), tabSize: size };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function indentLabel({ size, tabs }: Indentation) {
|
|
52
|
+
return `${tabs ? 'Tab Size' : 'Spaces'}: ${size}`;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Every break becomes 'eol' in one transaction, so a single undo restores the original endings; carets keep their
|
|
56
|
+
// place in the text, and one inside a CRLF lands before it.
|
|
57
|
+
function lineEndings(document: EditorDocument, eol: LineEnding) {
|
|
58
|
+
let edits: Edit[] = [],
|
|
59
|
+
insert = eol === 'crlf' ? '\r\n' : '\n',
|
|
60
|
+
shifts = [0],
|
|
61
|
+
text = document.value;
|
|
62
|
+
|
|
63
|
+
for (let match of text.matchAll(LINE_BREAK)) {
|
|
64
|
+
if (match[0] !== insert) {
|
|
65
|
+
edits.push({ from: match.index, insert, to: match.index + match[0].length });
|
|
66
|
+
shifts.push(shifts[shifts.length - 1] + insert.length - match[0].length);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (!edits.length) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
let map = (offset: number) => {
|
|
75
|
+
let hi = edits.length,
|
|
76
|
+
lo = 0;
|
|
77
|
+
|
|
78
|
+
while (lo < hi) {
|
|
79
|
+
let mid = (lo + hi) >>> 1;
|
|
80
|
+
|
|
81
|
+
if (edits[mid].to <= offset) {
|
|
82
|
+
lo = mid + 1;
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
hi = mid;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
let edit = edits[lo];
|
|
90
|
+
|
|
91
|
+
if (edit && edit.from < offset) {
|
|
92
|
+
return edit.from + shifts[lo];
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return offset + shifts[lo];
|
|
96
|
+
},
|
|
97
|
+
selections: Selection[] = document.selections.map((range) => ({ direction: range.direction, end: map(range.end), start: map(range.start) }));
|
|
98
|
+
|
|
99
|
+
return document.transact(edits, { selections }).changed;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
/** Saves dirty tabs by the 'autoSave' preference and reports the workspace's save status, as inline-edit's. */
|
|
104
|
+
class AutoSave {
|
|
105
|
+
readonly model: EditorWorkspaceModel;
|
|
106
|
+
readonly status: Status = reactive<Status>({ phase: 'saved', savedAt: null });
|
|
107
|
+
private active: WorkspaceTab | undefined;
|
|
108
|
+
private mode: AutoSaveMode = 'off';
|
|
109
|
+
private pending = 0;
|
|
110
|
+
private tabs = new Map<WorkspaceTab, Tracked>();
|
|
111
|
+
private unsubscribe: VoidFunction | undefined;
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
constructor(model: EditorWorkspaceModel) {
|
|
115
|
+
this.model = model;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
private edited(tab: WorkspaceTab) {
|
|
120
|
+
let tracked = this.tabs.get(tab);
|
|
121
|
+
|
|
122
|
+
if (!tracked || this.mode !== 'delay') {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
clearTimeout(tracked.timer);
|
|
127
|
+
tracked.timer = undefined;
|
|
128
|
+
|
|
129
|
+
if (dirty(tab)) {
|
|
130
|
+
tracked.timer = setTimeout(() => {
|
|
131
|
+
tracked.timer = undefined;
|
|
132
|
+
this.save(tab);
|
|
133
|
+
}, this.model.state.preferences.autoSaveDelay);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
private phase() {
|
|
138
|
+
this.status.phase = this.pending ? 'saving' : this.model.state.tabs.some(dirty) ? 'unsaved' : 'saved';
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// A file deleted from disk is never brought back without being asked.
|
|
142
|
+
private save(tab: WorkspaceTab) {
|
|
143
|
+
if (!dirty(tab) || tab.missing || !this.tabs.has(tab)) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
this.pending++;
|
|
148
|
+
this.phase();
|
|
149
|
+
|
|
150
|
+
void this.model.save(tab).finally(() => {
|
|
151
|
+
this.pending--;
|
|
152
|
+
this.phase();
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
private sync() {
|
|
157
|
+
let state = this.model.state,
|
|
158
|
+
open = new Set(state.tabs),
|
|
159
|
+
previous = this.active;
|
|
160
|
+
|
|
161
|
+
for (let [tab, tracked] of this.tabs) {
|
|
162
|
+
if (!open.has(tab)) {
|
|
163
|
+
clearTimeout(tracked.timer);
|
|
164
|
+
tracked.unsubscribe();
|
|
165
|
+
this.tabs.delete(tab);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
for (let i = 0, n = state.tabs.length; i < n; i++) {
|
|
170
|
+
let tab = state.tabs[i],
|
|
171
|
+
tracked = this.tabs.get(tab),
|
|
172
|
+
unsaved = dirty(tab);
|
|
173
|
+
|
|
174
|
+
if (!tracked) {
|
|
175
|
+
this.tabs.set(tab, {
|
|
176
|
+
dirty: unsaved,
|
|
177
|
+
saved: tab.saved,
|
|
178
|
+
unsubscribe: tab.document.subscribe((_, change) => {
|
|
179
|
+
if (change.textChanged) {
|
|
180
|
+
this.edited(tab);
|
|
181
|
+
}
|
|
182
|
+
})
|
|
183
|
+
});
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// Only saving turns a draft clean with new saved text; a reload from disk only touches clean tabs.
|
|
188
|
+
if (tracked.dirty && !unsaved && tracked.saved !== tab.saved) {
|
|
189
|
+
this.status.savedAt = Date.now();
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
tracked.dirty = unsaved;
|
|
193
|
+
tracked.saved = tab.saved;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if (state.preferences.autoSave !== this.mode) {
|
|
197
|
+
this.mode = state.preferences.autoSave;
|
|
198
|
+
|
|
199
|
+
for (let [tab, tracked] of this.tabs) {
|
|
200
|
+
clearTimeout(tracked.timer);
|
|
201
|
+
tracked.timer = undefined;
|
|
202
|
+
this.edited(tab);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
this.active = state.active;
|
|
207
|
+
|
|
208
|
+
if (this.mode === 'focus' && previous && previous !== state.active) {
|
|
209
|
+
this.save(previous);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
this.phase();
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
// The editor lost focus, or with 'all' the window did.
|
|
217
|
+
blur(all = false) {
|
|
218
|
+
if (this.mode !== 'focus') {
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
let tabs = all ? this.model.state.tabs : [this.model.state.active];
|
|
223
|
+
|
|
224
|
+
for (let i = 0, n = tabs.length; i < n; i++) {
|
|
225
|
+
let tab = tabs[i];
|
|
226
|
+
|
|
227
|
+
if (tab) {
|
|
228
|
+
this.save(tab);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
connect() {
|
|
234
|
+
this.disconnect();
|
|
235
|
+
this.unsubscribe = this.model.subscribe(() => this.sync());
|
|
236
|
+
this.sync();
|
|
237
|
+
|
|
238
|
+
return () => this.disconnect();
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// Pending saves are dropped with it.
|
|
242
|
+
disconnect() {
|
|
243
|
+
this.unsubscribe?.();
|
|
244
|
+
this.unsubscribe = undefined;
|
|
245
|
+
|
|
246
|
+
for (let tracked of this.tabs.values()) {
|
|
247
|
+
clearTimeout(tracked.timer);
|
|
248
|
+
tracked.unsubscribe();
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
this.active = undefined;
|
|
252
|
+
this.mode = 'off';
|
|
253
|
+
this.tabs.clear();
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
export { AUTO_SAVE_MODES, AutoSave, INDENT_SIZES, indentation, indentLabel, LANGUAGES, lineEndings };
|
|
259
|
+
export type { AutoSaveMode, Indentation, LineEnding };
|