@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,349 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import test from 'node:test';
|
|
3
|
+
import './resolve.mjs';
|
|
4
|
+
const { EditorWorkspaceModel, dirty } = await import('../src/components/editor/workspace/model.ts');
|
|
5
|
+
const { default: hosted, parse } = await import('../src/components/editor/workspace/session.ts');
|
|
6
|
+
const { default: navigate, step } = await import('../src/components/editor/workspace/navigate.ts');
|
|
7
|
+
const { createMemoryWorkspaceHost } = await import('../docs/src/examples/code-editor/fixtures/workspace.ts');
|
|
8
|
+
|
|
9
|
+
const FILES = { 'src/a.ts': 'alpha\nbeta\ngamma\n', 'src/b.ts': 'one\ntwo\n', 'c.md': '# C\n' };
|
|
10
|
+
|
|
11
|
+
async function fixture({ files = FILES, head, session, delay = 1 } = {}) {
|
|
12
|
+
const host = createMemoryWorkspaceHost(files, {}, [], { head }),
|
|
13
|
+
model = new EditorWorkspaceModel(host, '/project'),
|
|
14
|
+
view = { shown: undefined },
|
|
15
|
+
hosting = hosted(model, () => view.shown, delay);
|
|
16
|
+
const writes = [];
|
|
17
|
+
if (session !== undefined) await host.session.set(session);
|
|
18
|
+
const set = host.session.set;
|
|
19
|
+
host.session.set = async (next) => {
|
|
20
|
+
writes.push(next);
|
|
21
|
+
await set(next);
|
|
22
|
+
};
|
|
23
|
+
return { host, hosting, model, view, writes };
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const idle = (ms = 10) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
27
|
+
|
|
28
|
+
// Stands in for the code editor's controller: commands move the caret through 'marks' offsets, wrapping round.
|
|
29
|
+
function fakeEditor(tab, marks = { change: [], problem: [] }) {
|
|
30
|
+
const document = tab.document,
|
|
31
|
+
caret = () => (document.selection.direction === 'backward' ? document.selection.start : document.selection.end),
|
|
32
|
+
move = (kind, backward) => {
|
|
33
|
+
const list = marks[kind];
|
|
34
|
+
if (!list.length) return false;
|
|
35
|
+
const at = caret(),
|
|
36
|
+
found = backward ? [...list].reverse().find((offset) => offset < at) : list.find((offset) => offset > at);
|
|
37
|
+
document.select({ start: found ?? (backward ? list.at(-1) : list[0]) });
|
|
38
|
+
return true;
|
|
39
|
+
},
|
|
40
|
+
folds = [];
|
|
41
|
+
return {
|
|
42
|
+
baselines: [],
|
|
43
|
+
document,
|
|
44
|
+
fold: (line) => (folds.includes(line) ? false : (folds.push(line), true)),
|
|
45
|
+
folds: () => [...folds],
|
|
46
|
+
host: { isConnected: true },
|
|
47
|
+
nextChange: () => move('change', false),
|
|
48
|
+
nextProblem: () => move('problem', false),
|
|
49
|
+
previousChange: () => move('change', true),
|
|
50
|
+
previousProblem: () => move('problem', true),
|
|
51
|
+
scroller: { scrollLeft: 3, scrollTop: 40 },
|
|
52
|
+
select(selection) {
|
|
53
|
+
document.select(selection);
|
|
54
|
+
},
|
|
55
|
+
setBaseline(text) {
|
|
56
|
+
this.baselines.push(text);
|
|
57
|
+
},
|
|
58
|
+
state: { problems: { errors: marks.problem.length, warnings: 0 } }
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
test('parse keeps well-formed fields and drops what a hand-edited store got wrong', () => {
|
|
63
|
+
assert.equal(parse(null), null);
|
|
64
|
+
assert.equal(parse({ tabs: 'nope' }), null);
|
|
65
|
+
assert.deepEqual(parse({
|
|
66
|
+
active: 5,
|
|
67
|
+
explorer: { expanded: ['src', 7], scroll: -3 },
|
|
68
|
+
tabs: [
|
|
69
|
+
{ path: 'a.ts', folds: [1, 'x', 4], selection: { anchor: '2', head: 1 }, pinned: 'yes', draft: 1 },
|
|
70
|
+
{ nope: true },
|
|
71
|
+
null
|
|
72
|
+
]
|
|
73
|
+
}), {
|
|
74
|
+
active: null,
|
|
75
|
+
explorer: { expanded: ['src'], scroll: 0 },
|
|
76
|
+
tabs: [{ folds: [1, 4], path: 'a.ts', pinned: false, preview: false, scroll: { left: 0, top: 0 }, selection: { anchor: 2, head: 1 } }]
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
test('the session stores tabs, selection, scroll, folds, explorer state and only unsaved drafts', async (t) => {
|
|
81
|
+
const { host, hosting, model, view, writes } = await fixture({ session: null });
|
|
82
|
+
t.after(() => model.dispose());
|
|
83
|
+
const stop = hosting.connect({ addEventListener() {}, ownerDocument: {} });
|
|
84
|
+
t.after(stop);
|
|
85
|
+
await hosting.restore();
|
|
86
|
+
const a = await model.open('src/a.ts'),
|
|
87
|
+
b = await model.open('src/b.ts');
|
|
88
|
+
a.pinned = true;
|
|
89
|
+
a.document.setValue('alpha draft\n');
|
|
90
|
+
a.document.select({ direction: 'backward', end: 5, start: 2 });
|
|
91
|
+
a.scroll = { left: 0, top: 12 };
|
|
92
|
+
const editor = fakeEditor(b);
|
|
93
|
+
editor.fold(2);
|
|
94
|
+
view.shown = { controller: editor, tab: b };
|
|
95
|
+
hosting.explorer.expanded = ['src'];
|
|
96
|
+
hosting.explorer.scroll = 30;
|
|
97
|
+
hosting.flush();
|
|
98
|
+
const saved = writes.at(-1);
|
|
99
|
+
assert.equal(saved.active, 'src/b.ts');
|
|
100
|
+
assert.deepEqual(saved.explorer, { expanded: ['src'], scroll: 30 });
|
|
101
|
+
assert.deepEqual(saved.tabs[0], {
|
|
102
|
+
draft: 'alpha draft\n',
|
|
103
|
+
folds: [],
|
|
104
|
+
path: 'src/a.ts',
|
|
105
|
+
pinned: true,
|
|
106
|
+
preview: false,
|
|
107
|
+
scroll: { left: 0, top: 12 },
|
|
108
|
+
selection: { anchor: 5, head: 2 }
|
|
109
|
+
});
|
|
110
|
+
assert.deepEqual(saved.tabs[1], {
|
|
111
|
+
folds: [2],
|
|
112
|
+
path: 'src/b.ts',
|
|
113
|
+
pinned: false,
|
|
114
|
+
preview: false,
|
|
115
|
+
scroll: { left: 3, top: 40 },
|
|
116
|
+
selection: { anchor: 0, head: 0 }
|
|
117
|
+
});
|
|
118
|
+
// An unchanged session isn't written again.
|
|
119
|
+
hosting.flush();
|
|
120
|
+
assert.equal(writes.length, 1);
|
|
121
|
+
// Typing schedules a debounced write rather than one per keystroke.
|
|
122
|
+
for (let i = 0; i < 5; i++) a.document.replace(0, 0, 'x');
|
|
123
|
+
assert.equal(writes.length, 1);
|
|
124
|
+
await idle();
|
|
125
|
+
assert.equal(writes.length, 2);
|
|
126
|
+
assert.match(writes.at(-1).tabs[0].draft, /^xxxxxalpha draft/);
|
|
127
|
+
assert.ok(host.contents.get('src/a.ts').startsWith('alpha\n'));
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
test('restore brings back tabs, hot-exit drafts against the file on disk and the active tab; nothing is written first', async (t) => {
|
|
131
|
+
const stored = {
|
|
132
|
+
active: 'src/b.ts',
|
|
133
|
+
explorer: { expanded: ['src'], scroll: 24 },
|
|
134
|
+
tabs: [
|
|
135
|
+
{ draft: 'alpha edited\n', folds: [], path: 'src/a.ts', pinned: true, preview: false, scroll: { left: 0, top: 8 }, selection: { anchor: 3, head: 1 } },
|
|
136
|
+
{ folds: [1], path: 'src/b.ts', pinned: false, preview: true, scroll: { left: 0, top: 0 }, selection: { anchor: 2, head: 2 } },
|
|
137
|
+
{ draft: 'kept\n', folds: [], path: 'gone.ts', pinned: false, preview: false, scroll: { left: 0, top: 0 }, selection: { anchor: 0, head: 0 } },
|
|
138
|
+
{ folds: [], path: 'dropped.ts', pinned: false, preview: false, scroll: { left: 0, top: 0 }, selection: { anchor: 0, head: 0 } }
|
|
139
|
+
]
|
|
140
|
+
};
|
|
141
|
+
const { hosting, model, view, writes } = await fixture({ session: stored });
|
|
142
|
+
t.after(() => model.dispose());
|
|
143
|
+
assert.equal(hosting.ready(), false);
|
|
144
|
+
hosting.connect({ addEventListener() {}, ownerDocument: {} });
|
|
145
|
+
await hosting.restore();
|
|
146
|
+
assert.equal(hosting.ready(), true);
|
|
147
|
+
assert.deepEqual(hosting.explorer, { expanded: ['src'], scroll: 24 });
|
|
148
|
+
const [a, b, gone] = model.state.tabs;
|
|
149
|
+
assert.deepEqual(model.state.tabs.map((tab) => tab.path), ['src/a.ts', 'src/b.ts', 'gone.ts']);
|
|
150
|
+
assert.equal(a.document.value, 'alpha edited\n');
|
|
151
|
+
assert.equal(a.saved, FILES['src/a.ts']);
|
|
152
|
+
assert.equal(dirty(a), true);
|
|
153
|
+
assert.equal(a.pinned, true);
|
|
154
|
+
assert.deepEqual(a.scroll, { left: 0, top: 8 });
|
|
155
|
+
assert.deepEqual({ ...a.document.selection }, { direction: 'backward', end: 3, start: 1 });
|
|
156
|
+
assert.equal(b.preview, true);
|
|
157
|
+
assert.equal(dirty(b), false);
|
|
158
|
+
assert.equal(gone.missing, true);
|
|
159
|
+
assert.equal(gone.document.value, 'kept\n');
|
|
160
|
+
assert.equal(model.state.active, b);
|
|
161
|
+
assert.equal(writes.length, 0);
|
|
162
|
+
// Folds wait for the editor to show the tab, and go on it once.
|
|
163
|
+
const editor = fakeEditor(b);
|
|
164
|
+
view.shown = { controller: editor, tab: b };
|
|
165
|
+
hosting.shown(b, editor);
|
|
166
|
+
assert.deepEqual(editor.folds(), [1]);
|
|
167
|
+
hosting.flush();
|
|
168
|
+
assert.equal(writes.length, 1);
|
|
169
|
+
assert.equal(writes[0].tabs[2].draft, 'kept\n');
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
test('a tab opened while the session loads keeps focus; its path is not restored twice', async (t) => {
|
|
173
|
+
const stored = {
|
|
174
|
+
active: 'src/a.ts',
|
|
175
|
+
explorer: { expanded: [], scroll: 0 },
|
|
176
|
+
tabs: [{ folds: [], path: 'src/a.ts', pinned: false, preview: false, scroll: { left: 0, top: 0 }, selection: { anchor: 0, head: 0 } }]
|
|
177
|
+
};
|
|
178
|
+
const { hosting, model } = await fixture({ session: stored });
|
|
179
|
+
t.after(() => model.dispose());
|
|
180
|
+
await model.start();
|
|
181
|
+
const opened = model.open('c.md'),
|
|
182
|
+
restored = hosting.restore();
|
|
183
|
+
await Promise.all([opened, restored]);
|
|
184
|
+
assert.equal(model.state.active.path, 'c.md');
|
|
185
|
+
assert.deepEqual(model.state.tabs.map((tab) => tab.path).sort(), ['c.md', 'src/a.ts']);
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
test('baselines are fetched per open tab, marked when they differ, and fetched again on save and on watch', async (t) => {
|
|
189
|
+
const head = { 'src/a.ts': 'alpha\n', 'src/b.ts': FILES['src/b.ts'] },
|
|
190
|
+
{ host, hosting, model } = await fixture({ head });
|
|
191
|
+
t.after(() => model.dispose());
|
|
192
|
+
hosting.connect({ addEventListener() {}, ownerDocument: {} });
|
|
193
|
+
await hosting.restore();
|
|
194
|
+
let reads = 0;
|
|
195
|
+
const baseline = host.baseline;
|
|
196
|
+
host.baseline = (cwd, path) => {
|
|
197
|
+
reads++;
|
|
198
|
+
return baseline(cwd, path);
|
|
199
|
+
};
|
|
200
|
+
const a = await model.open('src/a.ts');
|
|
201
|
+
await model.open('src/b.ts');
|
|
202
|
+
assert.equal(await hosting.loaded('src/a.ts'), 'alpha\n');
|
|
203
|
+
assert.equal(hosting.baseline('src/a.ts'), 'alpha\n');
|
|
204
|
+
assert.equal(hosting.baseline('src/b.ts'), FILES['src/b.ts']);
|
|
205
|
+
assert.equal(hosting.marks.get('src/a.ts')?.status, 'modified');
|
|
206
|
+
assert.equal(hosting.marks.get('src/b.ts'), undefined);
|
|
207
|
+
const before = reads;
|
|
208
|
+
head['src/a.ts'] = 'alpha\nbeta\n';
|
|
209
|
+
a.document.setValue('alpha\nbeta\n');
|
|
210
|
+
await model.save(a);
|
|
211
|
+
await model.whenIdle();
|
|
212
|
+
assert.ok(reads > before);
|
|
213
|
+
assert.equal(await hosting.loaded('src/a.ts'), 'alpha\nbeta\n');
|
|
214
|
+
hosting.flush();
|
|
215
|
+
assert.equal(hosting.marks.get('src/a.ts'), undefined);
|
|
216
|
+
head['src/b.ts'] = 'one\n';
|
|
217
|
+
host.change('src/b.ts', FILES['src/b.ts']);
|
|
218
|
+
assert.equal(await hosting.loaded('src/b.ts'), 'one\n');
|
|
219
|
+
assert.equal(hosting.marks.get('src/b.ts')?.status, 'modified');
|
|
220
|
+
await model.close('src/b.ts');
|
|
221
|
+
assert.equal(hosting.baseline('src/b.ts'), null);
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
test('without the optional host methods the editor options and tree callbacks stay unset', async (t) => {
|
|
225
|
+
const host = createMemoryWorkspaceHost(FILES),
|
|
226
|
+
model = new EditorWorkspaceModel(host, '/project');
|
|
227
|
+
t.after(() => model.dispose());
|
|
228
|
+
delete host.export;
|
|
229
|
+
delete host.import;
|
|
230
|
+
const hosting = hosted(model, () => undefined);
|
|
231
|
+
assert.equal(hosting.baseline('src/a.ts'), undefined);
|
|
232
|
+
assert.equal(hosting.export, undefined);
|
|
233
|
+
assert.equal(hosting.import, undefined);
|
|
234
|
+
assert.equal(hosting.ready(), false);
|
|
235
|
+
delete host.session;
|
|
236
|
+
assert.equal(hosted(model, () => undefined).ready(), true);
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
test('OS drops import into the dropped-on folder, or the top level, and refresh; files export their text', async (t) => {
|
|
240
|
+
const { host, hosting, model } = await fixture();
|
|
241
|
+
t.after(() => model.dispose());
|
|
242
|
+
await hosting.restore();
|
|
243
|
+
const calls = [],
|
|
244
|
+
imported = host.import;
|
|
245
|
+
host.import = (cwd, target, entries) => {
|
|
246
|
+
calls.push(target);
|
|
247
|
+
return imported(cwd, target, entries);
|
|
248
|
+
};
|
|
249
|
+
await hosting.import({ children: [], id: 'src', name: 'src', type: 'folder' }, [{ file: new File(['new'], 'n.ts'), path: 'n.ts' }]);
|
|
250
|
+
await hosting.import({ id: 'src/a.ts', name: 'a.ts', type: 'file' }, [{ file: null, path: 'assets' }]);
|
|
251
|
+
await hosting.import(null, [{ file: null, path: 'top' }, { file: new File(['x'], 'x.txt'), path: 'top/x.txt' }]);
|
|
252
|
+
assert.deepEqual(calls, ['src', 'src', '']);
|
|
253
|
+
assert.equal(host.contents.get('src/n.ts'), 'new');
|
|
254
|
+
assert.equal(host.contents.get('top/x.txt'), 'x');
|
|
255
|
+
const paths = model.state.entries.map((entry) => entry.path);
|
|
256
|
+
for (const path of ['src/n.ts', 'src/assets', 'top/x.txt']) assert.ok(paths.includes(path), path);
|
|
257
|
+
await hosting.import(null, [{ file: new File(['dup'], 'a.ts'), path: 'src/a.ts' }]);
|
|
258
|
+
assert.match(model.state.status, /Import failed: .*already exists/);
|
|
259
|
+
const exported = hosting.export({ id: 'src/b.ts', name: 'b.ts', type: 'file' });
|
|
260
|
+
assert.equal(exported.name, 'b.ts');
|
|
261
|
+
assert.equal(exported.text, FILES['src/b.ts']);
|
|
262
|
+
assert.equal(decodeURIComponent(exported.url.split(',')[1]), FILES['src/b.ts']);
|
|
263
|
+
assert.equal(hosting.export({ id: 'src', name: 'src', type: 'folder' }), null);
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
test('step reports a move, a wrap round the file, or nothing to move to', async (t) => {
|
|
267
|
+
const { model } = await fixture();
|
|
268
|
+
t.after(() => model.dispose());
|
|
269
|
+
const tab = await model.open('src/a.ts'),
|
|
270
|
+
editor = fakeEditor(tab, { change: [6, 11], problem: [] });
|
|
271
|
+
tab.document.select({ start: 0 });
|
|
272
|
+
assert.equal(step(editor, 'change', false), 'moved');
|
|
273
|
+
assert.equal(step(editor, 'change', false), 'moved');
|
|
274
|
+
assert.equal(step(editor, 'change', false), 'wrapped');
|
|
275
|
+
assert.equal(step(editor, 'change', true), 'wrapped');
|
|
276
|
+
assert.equal(step(editor, 'change', true), 'moved');
|
|
277
|
+
assert.equal(step(editor, 'problem', false), 'none');
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
test('navigation crosses to the next marked file once the shown one has none left, and lands on its first', async (t) => {
|
|
281
|
+
const { hosting, model, view } = await fixture();
|
|
282
|
+
t.after(() => model.dispose());
|
|
283
|
+
await hosting.restore();
|
|
284
|
+
const editors = new Map(),
|
|
285
|
+
show = (tab) => {
|
|
286
|
+
const editor = editors.get(tab.path) ?? fakeEditor(tab, { change: tab.path === 'src/a.ts' ? [6] : [4], problem: [] });
|
|
287
|
+
editors.set(tab.path, editor);
|
|
288
|
+
view.shown = { controller: editor, tab };
|
|
289
|
+
hosting.shown(tab, editor);
|
|
290
|
+
};
|
|
291
|
+
model.subscribe((state) => {
|
|
292
|
+
if (state.active && view.shown?.tab !== state.active) queueMicrotask(() => show(state.active));
|
|
293
|
+
});
|
|
294
|
+
const a = await model.open('src/a.ts');
|
|
295
|
+
show(a);
|
|
296
|
+
const jumps = [],
|
|
297
|
+
tree = {
|
|
298
|
+
next: async (kind) => (jumps.push(kind), { id: 'src/b.ts', name: 'b.ts', type: 'file' }),
|
|
299
|
+
previous: async () => null
|
|
300
|
+
},
|
|
301
|
+
navigation = navigate({ bindings: () => undefined, hosting, model, tree: () => tree });
|
|
302
|
+
a.document.select({ start: 0 });
|
|
303
|
+
assert.equal(await navigation.go('change'), true);
|
|
304
|
+
assert.equal(a.document.selection.start, 6);
|
|
305
|
+
assert.deepEqual(jumps, []);
|
|
306
|
+
// Past the last change in a.ts: on to b.ts, whose first change the caret lands on, while a.ts keeps its caret.
|
|
307
|
+
assert.equal(await navigation.go('change'), true);
|
|
308
|
+
assert.deepEqual(jumps, ['change']);
|
|
309
|
+
assert.equal(model.state.active.path, 'src/b.ts');
|
|
310
|
+
assert.equal(model.state.active.document.selection.start, 4);
|
|
311
|
+
assert.equal(a.document.selection.start, 6);
|
|
312
|
+
// Nothing anywhere: the status says so.
|
|
313
|
+
editors.get('src/b.ts').nextProblem = () => false;
|
|
314
|
+
tree.next = async () => null;
|
|
315
|
+
assert.equal(await navigation.go('problem'), false);
|
|
316
|
+
assert.equal(model.state.status, 'No problems');
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
test('the navigation keys follow the editor keymap, rebindings included, ahead of the editor', async (t) => {
|
|
320
|
+
const { hosting, model } = await fixture();
|
|
321
|
+
t.after(() => model.dispose());
|
|
322
|
+
let bindings,
|
|
323
|
+
handler;
|
|
324
|
+
const runs = [],
|
|
325
|
+
navigation = navigate({ bindings: () => bindings, hosting, model, tree: () => undefined });
|
|
326
|
+
navigation.connect({ addEventListener: (_type, listener) => (handler = listener) });
|
|
327
|
+
const press = (key, extra = {}) => {
|
|
328
|
+
const event = {
|
|
329
|
+
altKey: false, code: key, ctrlKey: false, defaultPrevented: false, isComposing: false, key, metaKey: false, shiftKey: false,
|
|
330
|
+
preventDefault() {
|
|
331
|
+
this.defaultPrevented = true;
|
|
332
|
+
},
|
|
333
|
+
stopPropagation() {
|
|
334
|
+
runs.push(key);
|
|
335
|
+
},
|
|
336
|
+
...extra
|
|
337
|
+
};
|
|
338
|
+
handler(event);
|
|
339
|
+
return event.defaultPrevented;
|
|
340
|
+
};
|
|
341
|
+
assert.equal(press('F8'), true);
|
|
342
|
+
assert.equal(press('F5', { altKey: true }), true);
|
|
343
|
+
assert.equal(press('F5', { altKey: true, shiftKey: true }), true);
|
|
344
|
+
assert.equal(press('F3'), false);
|
|
345
|
+
bindings = { F8: null, F9: 'nextProblem' };
|
|
346
|
+
assert.equal(press('F8'), false);
|
|
347
|
+
assert.equal(press('F9'), true);
|
|
348
|
+
assert.deepEqual(runs, ['F8', 'F5', 'F5', 'F9']);
|
|
349
|
+
});
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import test from 'node:test';
|
|
3
|
+
import './resolve.mjs';
|
|
4
|
+
const { EditorDocument } = await import('../src/components/editor/code/document.ts');
|
|
5
|
+
const { EditorWorkspaceModel } = await import('../src/components/editor/workspace/model.ts');
|
|
6
|
+
const { AUTO_SAVE_MODES, AutoSave, indentation, indentLabel, LANGUAGES, lineEndings } =
|
|
7
|
+
await import('../src/components/editor/workspace/status.ts');
|
|
8
|
+
const { createMemoryWorkspaceHost } = await import('../docs/src/examples/code-editor/fixtures/workspace.ts');
|
|
9
|
+
const deferred = () => {
|
|
10
|
+
let resolve, reject;
|
|
11
|
+
const promise = new Promise((yes, no) => {
|
|
12
|
+
resolve = yes;
|
|
13
|
+
reject = no;
|
|
14
|
+
});
|
|
15
|
+
return { promise, resolve, reject };
|
|
16
|
+
};
|
|
17
|
+
async function fixture(t, preferences = {}) {
|
|
18
|
+
const host = createMemoryWorkspaceHost({ 'a.ts': 'one', 'b.ts': 'two' }),
|
|
19
|
+
model = new EditorWorkspaceModel(host, '/project'),
|
|
20
|
+
writes = [],
|
|
21
|
+
write = host.write;
|
|
22
|
+
host.write = (cwd, path, content) => {
|
|
23
|
+
writes.push([path, content]);
|
|
24
|
+
return write(cwd, path, content);
|
|
25
|
+
};
|
|
26
|
+
await model.start();
|
|
27
|
+
model.setPreferences(preferences);
|
|
28
|
+
await model.whenIdle();
|
|
29
|
+
const autosave = new AutoSave(model),
|
|
30
|
+
disconnect = autosave.connect();
|
|
31
|
+
t.after(() => {
|
|
32
|
+
disconnect();
|
|
33
|
+
model.dispose();
|
|
34
|
+
});
|
|
35
|
+
return { autosave, disconnect, host, model, writes };
|
|
36
|
+
}
|
|
37
|
+
const type = (tab, text) => tab.document.replace(tab.document.value.length, tab.document.value.length, text);
|
|
38
|
+
|
|
39
|
+
test('auto save preferences are validated on construction, load and update', async () => {
|
|
40
|
+
let model = new EditorWorkspaceModel(createMemoryWorkspaceHost({}), '/project', { autoSave: 'always', autoSaveDelay: Number.NaN });
|
|
41
|
+
assert.equal(model.state.preferences.autoSave, 'off');
|
|
42
|
+
assert.equal(model.state.preferences.autoSaveDelay, 1000);
|
|
43
|
+
model.setPreferences({ autoSave: 'focus', autoSaveDelay: 5 });
|
|
44
|
+
assert.equal(model.state.preferences.autoSave, 'focus');
|
|
45
|
+
assert.equal(model.state.preferences.autoSaveDelay, 100);
|
|
46
|
+
model.setPreferences({ autoSave: 1, autoSaveDelay: 1e9 });
|
|
47
|
+
assert.equal(model.state.preferences.autoSave, 'focus');
|
|
48
|
+
assert.equal(model.state.preferences.autoSaveDelay, 60000);
|
|
49
|
+
model.setPreferences({ autoSaveDelay: '200' });
|
|
50
|
+
assert.equal(model.state.preferences.autoSaveDelay, 60000);
|
|
51
|
+
model.dispose();
|
|
52
|
+
const host = createMemoryWorkspaceHost({ 'a.ts': '' }, { autoSave: 'delay', autoSaveDelay: 1499.6 });
|
|
53
|
+
model = new EditorWorkspaceModel(host, '/project');
|
|
54
|
+
await model.start();
|
|
55
|
+
assert.equal(model.state.preferences.autoSave, 'delay');
|
|
56
|
+
assert.equal(model.state.preferences.autoSaveDelay, 1500);
|
|
57
|
+
model.dispose();
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
test('delay mode saves a dirty tab once edits pause for the delay', async (t) => {
|
|
61
|
+
t.mock.timers.enable({ apis: ['setTimeout'] });
|
|
62
|
+
const { autosave, model, writes } = await fixture(t, { autoSave: 'delay', autoSaveDelay: 500 }),
|
|
63
|
+
tab = await model.open('a.ts');
|
|
64
|
+
type(tab, '!');
|
|
65
|
+
assert.equal(autosave.status.phase, 'unsaved');
|
|
66
|
+
t.mock.timers.tick(499);
|
|
67
|
+
type(tab, '?');
|
|
68
|
+
t.mock.timers.tick(499);
|
|
69
|
+
assert.deepEqual(writes, []);
|
|
70
|
+
t.mock.timers.tick(1);
|
|
71
|
+
assert.equal(autosave.status.phase, 'saving');
|
|
72
|
+
await model.whenIdle();
|
|
73
|
+
assert.deepEqual(writes, [['a.ts', 'one!?']]);
|
|
74
|
+
assert.equal(tab.saved, 'one!?');
|
|
75
|
+
assert.equal(autosave.status.phase, 'saved');
|
|
76
|
+
assert.equal(typeof autosave.status.savedAt, 'number');
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
test('undoing back to the saved text cancels a pending delayed save', async (t) => {
|
|
80
|
+
t.mock.timers.enable({ apis: ['setTimeout'] });
|
|
81
|
+
const { autosave, model, writes } = await fixture(t, { autoSave: 'delay', autoSaveDelay: 500 }),
|
|
82
|
+
tab = await model.open('a.ts');
|
|
83
|
+
type(tab, '!');
|
|
84
|
+
tab.document.undo();
|
|
85
|
+
t.mock.timers.tick(1000);
|
|
86
|
+
await model.whenIdle();
|
|
87
|
+
assert.deepEqual(writes, []);
|
|
88
|
+
assert.equal(autosave.status.phase, 'saved');
|
|
89
|
+
assert.equal(autosave.status.savedAt, null);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
test('closing a tab or disconnecting drops its pending save', async (t) => {
|
|
93
|
+
t.mock.timers.enable({ apis: ['setTimeout'] });
|
|
94
|
+
const { disconnect, model, writes } = await fixture(t, { autoSave: 'delay', autoSaveDelay: 500 }),
|
|
95
|
+
a = await model.open('a.ts'),
|
|
96
|
+
b = await model.open('b.ts');
|
|
97
|
+
model.setConfirmation(() => 'discard');
|
|
98
|
+
type(a, '!');
|
|
99
|
+
assert.equal(await model.close('a.ts'), true);
|
|
100
|
+
t.mock.timers.tick(1000);
|
|
101
|
+
await model.whenIdle();
|
|
102
|
+
assert.deepEqual(writes, []);
|
|
103
|
+
type(b, '!');
|
|
104
|
+
disconnect();
|
|
105
|
+
t.mock.timers.tick(1000);
|
|
106
|
+
await model.whenIdle();
|
|
107
|
+
assert.deepEqual(writes, []);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
test('switching to delay mode schedules tabs that are already dirty; off cancels them', async (t) => {
|
|
111
|
+
t.mock.timers.enable({ apis: ['setTimeout'] });
|
|
112
|
+
const { model, writes } = await fixture(t, { autoSaveDelay: 500 }),
|
|
113
|
+
a = await model.open('a.ts'),
|
|
114
|
+
b = await model.open('b.ts');
|
|
115
|
+
type(a, '!');
|
|
116
|
+
t.mock.timers.tick(1000);
|
|
117
|
+
assert.deepEqual(writes, []);
|
|
118
|
+
model.setPreferences({ autoSave: 'delay' });
|
|
119
|
+
type(b, '!');
|
|
120
|
+
model.setPreferences({ autoSave: 'off' });
|
|
121
|
+
t.mock.timers.tick(1000);
|
|
122
|
+
await model.whenIdle();
|
|
123
|
+
assert.deepEqual(writes, []);
|
|
124
|
+
model.setPreferences({ autoSave: 'delay' });
|
|
125
|
+
t.mock.timers.tick(500);
|
|
126
|
+
await model.whenIdle();
|
|
127
|
+
assert.deepEqual(writes.sort(), [['a.ts', 'one!'], ['b.ts', 'two!']]);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
test('focus mode saves on tab change, editor blur and window blur, never a missing file', async (t) => {
|
|
131
|
+
const { autosave, model, writes } = await fixture(t, { autoSave: 'focus' }),
|
|
132
|
+
a = await model.open('a.ts'),
|
|
133
|
+
b = await model.open('b.ts');
|
|
134
|
+
model.activate(a);
|
|
135
|
+
type(a, '1');
|
|
136
|
+
model.activate(b);
|
|
137
|
+
await model.whenIdle();
|
|
138
|
+
assert.deepEqual(writes, [['a.ts', 'one1']]);
|
|
139
|
+
type(b, '2');
|
|
140
|
+
autosave.blur();
|
|
141
|
+
await model.whenIdle();
|
|
142
|
+
assert.deepEqual(writes.at(-1), ['b.ts', 'two2']);
|
|
143
|
+
type(a, '3');
|
|
144
|
+
type(b, '4');
|
|
145
|
+
autosave.blur(true);
|
|
146
|
+
await model.whenIdle();
|
|
147
|
+
assert.deepEqual(writes.slice(2).sort(), [['a.ts', 'one13'], ['b.ts', 'two24']]);
|
|
148
|
+
b.missing = true;
|
|
149
|
+
type(b, '5');
|
|
150
|
+
autosave.blur(true);
|
|
151
|
+
await model.whenIdle();
|
|
152
|
+
assert.equal(writes.length, 4);
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
test('off mode ignores focus changes', async (t) => {
|
|
156
|
+
const { autosave, model, writes } = await fixture(t),
|
|
157
|
+
a = await model.open('a.ts');
|
|
158
|
+
await model.open('b.ts');
|
|
159
|
+
type(a, '!');
|
|
160
|
+
model.activate(a);
|
|
161
|
+
model.activate('b.ts');
|
|
162
|
+
autosave.blur(true);
|
|
163
|
+
await model.whenIdle();
|
|
164
|
+
assert.deepEqual(writes, []);
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
test('the status shows saving while a save is pending and unsaved again when it fails', async (t) => {
|
|
168
|
+
t.mock.timers.enable({ apis: ['setTimeout'] });
|
|
169
|
+
const { autosave, host, model } = await fixture(t, { autoSave: 'delay', autoSaveDelay: 100 }),
|
|
170
|
+
tab = await model.open('a.ts'),
|
|
171
|
+
pending = deferred();
|
|
172
|
+
host.write = () => pending.promise;
|
|
173
|
+
type(tab, '!');
|
|
174
|
+
t.mock.timers.tick(100);
|
|
175
|
+
await Promise.resolve();
|
|
176
|
+
assert.equal(autosave.status.phase, 'saving');
|
|
177
|
+
pending.reject(new Error('disk full'));
|
|
178
|
+
await model.whenIdle();
|
|
179
|
+
assert.equal(autosave.status.phase, 'unsaved');
|
|
180
|
+
assert.equal(autosave.status.savedAt, null);
|
|
181
|
+
assert.match(model.state.status, /disk full/);
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
test('a manual save also stamps the saved time', async (t) => {
|
|
185
|
+
const { autosave, model } = await fixture(t),
|
|
186
|
+
tab = await model.open('a.ts');
|
|
187
|
+
type(tab, '!');
|
|
188
|
+
assert.equal(autosave.status.phase, 'unsaved');
|
|
189
|
+
await model.save(tab);
|
|
190
|
+
assert.equal(autosave.status.phase, 'saved');
|
|
191
|
+
assert.equal(typeof autosave.status.savedAt, 'number');
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
test('line endings convert in one undoable edit and keep carets on their text', () => {
|
|
195
|
+
const document = new EditorDocument('a\nb\r\nc\rd');
|
|
196
|
+
document.selectMany([{ end: 5, start: 5 }, { end: 2, start: 1 }]);
|
|
197
|
+
assert.equal(lineEndings(document, 'crlf'), true);
|
|
198
|
+
assert.equal(document.value, 'a\r\nb\r\nc\r\nd');
|
|
199
|
+
assert.deepEqual(document.selections.map(({ end, start }) => [start, end]), [[6, 6], [1, 3]]);
|
|
200
|
+
assert.equal(document.eol, '\r\n');
|
|
201
|
+
assert.equal(lineEndings(document, 'crlf'), false);
|
|
202
|
+
assert.equal(lineEndings(document, 'lf'), true);
|
|
203
|
+
assert.equal(document.value, 'a\nb\nc\nd');
|
|
204
|
+
assert.equal(document.selection.start, 4);
|
|
205
|
+
document.select({ end: 2, start: 2 });
|
|
206
|
+
document.undo();
|
|
207
|
+
assert.equal(document.value, 'a\r\nb\r\nc\r\nd');
|
|
208
|
+
document.undo();
|
|
209
|
+
assert.equal(document.value, 'a\nb\r\nc\rd');
|
|
210
|
+
assert.equal(lineEndings(new EditorDocument('single line'), 'crlf'), false);
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
test('a caret inside a CRLF lands before its replacement', () => {
|
|
214
|
+
const document = new EditorDocument('ab\r\ncd');
|
|
215
|
+
document.select({ end: 3, start: 3 });
|
|
216
|
+
lineEndings(document, 'lf');
|
|
217
|
+
assert.equal(document.value, 'ab\ncd');
|
|
218
|
+
assert.equal(document.selection.start, 2);
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
test('status choices cover every language, indentation and auto save mode', () => {
|
|
222
|
+
assert.deepEqual(Object.keys(AUTO_SAVE_MODES).sort(), ['delay', 'focus', 'off']);
|
|
223
|
+
assert.equal(LANGUAGES.typescript, 'TypeScript');
|
|
224
|
+
assert.equal(LANGUAGES.plain, 'Plain Text');
|
|
225
|
+
assert.deepEqual(indentation({ size: 2, tabs: false }), { indent: ' ', tabSize: 2 });
|
|
226
|
+
assert.deepEqual(indentation({ size: 8, tabs: true }), { indent: '\t', tabSize: 8 });
|
|
227
|
+
assert.equal(indentLabel({ size: 4, tabs: false }), 'Spaces: 4');
|
|
228
|
+
assert.equal(indentLabel({ size: 4, tabs: true }), 'Tab Size: 4');
|
|
229
|
+
});
|