@jxsuite/studio 4.0.0 → 5.0.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 +1 -1
- package/data/elements-meta.json +5 -15
- package/data/html-meta.json +51 -6
- package/dist/chunks/{2020-xp8vnwma.js → 2020-g79n01v9.js} +14 -14
- package/dist/chunks/action-group-sp6tna8v.js +118 -0
- package/dist/chunks/adapter-nj7tnjfn.js +13 -0
- package/dist/chunks/cf-account-picker-fyf63pmy.js +495 -0
- package/dist/chunks/cf-settings-71bv5zn9.js +20 -0
- package/dist/chunks/color-area-v17df7b8.js +154 -0
- package/dist/chunks/color-field-anwybnkn.js +208 -0
- package/dist/chunks/color-slider-44ez96fc.js +79 -0
- package/dist/chunks/color-xgg3kfw7.js +35 -0
- package/dist/chunks/combobox-5e7jev23.js +236 -0
- package/dist/chunks/components-2w1f35qs.js +18 -0
- package/dist/chunks/content-source-3wqeas45.js +46 -0
- package/dist/chunks/convert-to-repeater-d0cgnb6d.js +639 -0
- package/dist/chunks/dialog-s890b918.js +85 -0
- package/dist/chunks/editor-3qhbg51x.js +35 -0
- package/dist/chunks/entry-commands-d6g50j7s.js +42 -0
- package/dist/chunks/extension-sections-fy7q4fe9.js +651 -0
- package/dist/chunks/file-ops-3btj6st0.js +47 -0
- package/dist/chunks/files-ef8fgs3w.js +72 -0
- package/dist/chunks/format-host-3c33nwr8.js +40 -0
- package/dist/chunks/fs-events-13tj6sex.js +18 -0
- package/dist/chunks/git-panel-4wp2rn9b.js +49 -0
- package/dist/chunks/icons-yy10wk9r.js +402 -0
- package/dist/chunks/iframe-entry-15g3n6xv.js +114 -0
- package/dist/chunks/iframe-entry-b27vq81n.js +203 -0
- package/dist/chunks/iframe-entry-nbyxee1y.js +154 -0
- package/dist/chunks/iframe-host-jgesd924.js +115 -0
- package/dist/chunks/{index-nj44jpzj.js → index-mdmyx6s2.js} +11 -11
- package/dist/chunks/index-n4j7qxyr.js +109 -0
- package/dist/chunks/{javascript-q8kpmfah.js → javascript-xvrfrpkb.js} +8 -9
- package/dist/chunks/{jsonMode-dkr040ga.js → jsonMode-tyx2kj6p.js} +526 -527
- package/dist/chunks/jx-validate-j0wxk72w.js +15 -0
- package/dist/chunks/layers-1nq5evsh.js +29 -0
- package/dist/chunks/layers-panel-ar2gh90g.js +40 -0
- package/dist/chunks/listbox-6v2ac08j.js +44 -0
- package/dist/chunks/lit-html-m244w9nh.js +17 -0
- package/dist/chunks/media-picker-2qbetq73.js +33 -0
- package/dist/chunks/menu-q99sy9rf.js +285 -0
- package/dist/chunks/menu-rf7n72mf.js +14 -0
- package/dist/chunks/{monaco-binding-rj6xpx9y.js → monaco-binding-sw6en4dw.js} +12 -15
- package/dist/chunks/monaco-buffer-bhy3hb6m.js +24 -0
- package/dist/chunks/{monaco-setup-rws7k4br.js → monaco-setup-8r62fj6y.js} +27 -37
- package/dist/chunks/notify-628t0anh.js +21 -0
- package/dist/chunks/number-field-5cndyft8.js +72 -0
- package/dist/chunks/parse-0zx14y15.js +10 -0
- package/dist/chunks/platform-ts9cg1a4.js +15 -0
- package/dist/chunks/popover-47z3ytva.js +25 -0
- package/dist/chunks/publish-panel-98f7sr3g.js +27 -0
- package/dist/chunks/quick-search-srzz83k2.js +45 -0
- package/dist/chunks/references-n553f0e1.js +26 -0
- package/dist/chunks/right-panel-rrgx2dn3.js +45 -0
- package/dist/chunks/section-registry-5pq32t0q.js +25 -0
- package/dist/chunks/select-2r16ez41.js +49 -0
- package/dist/chunks/split-g7nm1rgb.js +191 -0
- package/dist/chunks/studio-0hqbpbd0.js +62 -0
- package/dist/chunks/studio-18avnhjp.js +2430 -0
- package/dist/chunks/{studio-kryvsw6j.js → studio-1k325pwf.js} +48 -48
- package/dist/chunks/{studio-hbtp0eh1.js → studio-25hkdrkw.js} +356 -85
- package/dist/chunks/studio-26d7myd1.js +258 -0
- package/dist/chunks/{studio-p8j86wag.js → studio-38emantv.js} +22 -5
- package/dist/chunks/studio-3gxv60tn.js +422 -0
- package/dist/chunks/{studio-8swrjbny.js → studio-3hxkd92t.js} +275 -163
- package/dist/chunks/studio-4m0haseg.js +185 -0
- package/dist/chunks/{studio-ynxwkrzd.js → studio-4wbb9ct0.js} +1953 -1785
- package/dist/chunks/{studio-gv8vvshc.js → studio-5523bpzt.js} +11 -11
- package/dist/chunks/{studio-5q69gfag.js → studio-57mf66w2.js} +1753 -2484
- package/dist/chunks/studio-5jy81t3s.js +17463 -0
- package/dist/chunks/studio-5rt7sqa0.js +1168 -0
- package/dist/chunks/studio-5te5tqng.js +81 -0
- package/dist/chunks/{studio-p4ngc046.js → studio-6ewqv390.js} +9 -9
- package/dist/chunks/{studio-9ab8gqsm.js → studio-6nzaktvy.js} +7 -7
- package/dist/chunks/studio-6xa21ej9.js +28 -0
- package/dist/chunks/{studio-5ehhackm.js → studio-727xh0e3.js} +19 -19
- package/dist/chunks/{studio-eenfkt4e.js → studio-79y5sz51.js} +52 -38
- package/dist/chunks/{studio-4q0wznzf.js → studio-7e11jpa9.js} +461 -145
- package/dist/chunks/{studio-q7v10cg2.js → studio-7r42c6ca.js} +17 -7
- package/dist/chunks/studio-7xptrg0j.js +954 -0
- package/dist/chunks/{studio-cft9r4r7.js → studio-81390n6f.js} +22 -22
- package/dist/chunks/{studio-q43a5y9h.js → studio-8jn5yhyn.js} +16 -16
- package/dist/chunks/studio-8qtrpzr3.js +839 -0
- package/dist/chunks/{studio-dg7zyt5x.js → studio-98b3z07n.js} +1 -1
- package/dist/chunks/studio-9xxz1q69.js +1356 -0
- package/dist/chunks/studio-akbww0j5.js +13615 -0
- package/dist/chunks/studio-arfpe389.js +195 -0
- package/dist/chunks/{studio-2zkz8evn.js → studio-az3zd49t.js} +473 -281
- package/dist/chunks/studio-cpvb2ed1.js +1171 -0
- package/dist/chunks/{studio-9r6j5ev1.js → studio-d0300636.js} +5078 -19
- package/dist/chunks/{studio-bgxt93ga.js → studio-d055c37e.js} +13 -13
- package/dist/chunks/studio-d1ja2x9r.js +362 -0
- package/dist/chunks/{studio-b9b6t1dg.js → studio-e1f24eff.js} +5664 -5666
- package/dist/chunks/{studio-4pqqxbrt.js → studio-em9nw8eh.js} +301 -112
- package/dist/chunks/studio-erdatzvp.js +1190 -0
- package/dist/chunks/{studio-g1wdche0.js → studio-esrxgwh6.js} +80 -80
- package/dist/chunks/studio-fabxk6r9.js +2811 -0
- package/dist/chunks/{studio-3n4ndrzh.js → studio-h4nvnjvz.js} +303 -303
- package/dist/chunks/studio-hhvs4sdg.js +195 -0
- package/dist/chunks/{studio-68n67094.js → studio-kcgff4r0.js} +15 -18
- package/dist/chunks/{studio-685s0ytq.js → studio-nqgawfks.js} +572 -572
- package/dist/chunks/{studio-xrapxwwc.js → studio-p1dw8wfw.js} +55 -29
- package/dist/chunks/studio-pm6hgy7r.js +4763 -0
- package/dist/chunks/studio-q0a3yk4n.js +33 -0
- package/dist/chunks/{studio-wcy8trfx.js → studio-q3x06vmj.js} +23 -22
- package/dist/chunks/studio-qahxvnan.js +111 -0
- package/dist/chunks/{studio-53n8bp04.js → studio-r6xmmtfh.js} +1 -1
- package/dist/chunks/{studio-kjjsjak4.js → studio-rkstz940.js} +3661 -6136
- package/dist/chunks/{studio-tvgyw9xw.js → studio-rnyf3f8e.js} +83 -250
- package/dist/chunks/studio-rpyah2ew.js +2805 -0
- package/dist/chunks/studio-rs76k67r.js +12 -0
- package/dist/chunks/{studio-yxrkyv8a.js → studio-s6z853aq.js} +12108 -11766
- package/dist/chunks/{studio-sf7zjgv1.js → studio-sgdc5pfc.js} +8 -8
- package/dist/chunks/studio-tb3ev01j.js +763 -0
- package/dist/chunks/{studio-t5wqwzdh.js → studio-tjjk7jvk.js} +1 -1
- package/dist/chunks/studio-vhv5tgxm.js +51 -0
- package/dist/chunks/{studio-htsf0w6m.js → studio-vz68yn9e.js} +31 -154
- package/dist/chunks/studio-wqpngpsk.js +174 -0
- package/dist/chunks/{studio-eesa1myv.js → studio-x3rty6tr.js} +58 -58
- package/dist/chunks/studio-xsykpvsh.js +8448 -0
- package/dist/chunks/{studio-92ab2jqe.js → studio-y9zedyjn.js} +14 -14
- package/dist/chunks/studio-yxa81f45.js +12 -0
- package/dist/chunks/swatch-group-t0n6h2rn.js +139 -0
- package/dist/chunks/tabs-wbp1cdws.js +156 -0
- package/dist/chunks/textfield-abk6qyee.js +73 -0
- package/dist/chunks/toast-780pvfbv.js +27 -0
- package/dist/chunks/toast-host-3sqv46sn.js +116 -0
- package/dist/chunks/toolbar-xbh5bhtr.js +194 -0
- package/dist/chunks/tooltip-eptb614w.js +369 -0
- package/dist/chunks/tree-a73p0pqm.js +367 -0
- package/dist/chunks/{tsMode-76kr53q0.js → tsMode-jy4m86rv.js} +83 -85
- package/dist/chunks/workspace-wrew8zk4.js +69 -0
- package/dist/chunks/{ws-client-6shc5rze.js → ws-client-ny4zc51r.js} +20 -22
- package/dist/iframe-entry.js +1812 -698
- package/dist/manifest.json +7 -0
- package/dist/studio.js +52900 -36573
- package/dist/workers/editor.worker.js +1040 -1085
- package/dist/workers/json.worker.js +1946 -1991
- package/dist/workers/ts.worker.js +4960 -5005
- package/favicon.ico +0 -0
- package/index.html +2 -0
- package/package.json +22 -55
- package/src/about/about-modal.ts +73 -123
- package/src/browse/library-commands.ts +20 -49
- package/src/browse/library-layouts.ts +87 -218
- package/src/browse/library-pane.ts +406 -438
- package/src/canvas/canvas-helpers.ts +0 -49
- package/src/canvas/canvas-live-render.ts +25 -2
- package/src/canvas/canvas-render.ts +666 -231
- package/src/canvas/canvas-surface.ts +0 -1
- package/src/canvas/canvas-utils.ts +310 -117
- package/src/canvas/dialog-path.ts +76 -0
- package/src/canvas/dialog-state.ts +67 -0
- package/src/canvas/diff-marks.ts +252 -0
- package/src/canvas/diff-toolbar.ts +349 -0
- package/src/canvas/diff-view.ts +123 -0
- package/src/canvas/edit-width-drag.ts +187 -0
- package/src/canvas/edit-width.ts +150 -0
- package/src/canvas/iframe-entry.ts +125 -8
- package/src/canvas/iframe-host.ts +271 -15
- package/src/canvas/iframe-interaction.ts +133 -13
- package/src/canvas/iframe-patch.ts +7 -1
- package/src/canvas/iframe-position.ts +5 -6
- package/src/canvas/iframe-protocol.ts +106 -5
- package/src/canvas/iframe-render.ts +373 -5
- package/src/canvas/iframe-slash.ts +2 -2
- package/src/canvas/iframe-subtree.ts +5 -8
- package/src/canvas/path-mapping.ts +25 -3
- package/src/canvas/popover-path.ts +106 -0
- package/src/canvas/popover-state.ts +155 -0
- package/src/canvas/surface-registry.ts +21 -10
- package/src/collab/presence-chips.ts +51 -73
- package/src/commands/app-commands.ts +10 -0
- package/src/commands/budget.ts +12 -0
- package/src/commands/command-args.ts +369 -6
- package/src/commands/defaults.ts +44 -14
- package/src/commands/live-context.ts +11 -5
- package/src/commands/reference.ts +12 -2
- package/src/commands/registry.ts +165 -8
- package/src/content/entry-commands.ts +16 -23
- package/src/content/entry-editor.ts +144 -101
- package/src/editor/canvas-slash-bridge.ts +2 -2
- package/src/editor/context-menu.ts +49 -200
- package/src/editor/convert-to-component.ts +42 -82
- package/src/editor/convert-to-repeater.ts +132 -173
- package/src/editor/inline-edit.ts +11 -0
- package/src/editor/shortcuts.ts +65 -26
- package/src/editor/slash-menu.ts +150 -157
- package/src/files/file-ops.ts +117 -11
- package/src/files/files.ts +949 -664
- package/src/files/json-layout.ts +474 -0
- package/src/files/media-paths.ts +13 -42
- package/src/files/media-usage.ts +41 -131
- package/src/files/serialize-document.ts +8 -1
- package/src/format/convert-file.ts +16 -10
- package/src/format/format-host.ts +50 -1
- package/src/github/github-auth.ts +71 -29
- package/src/github/github-publish.ts +57 -65
- package/src/grid/cell-editors.ts +46 -4
- package/src/grid/cell-popovers.ts +65 -62
- package/src/grid/grid-open.ts +86 -64
- package/src/grid/grid-panel.ts +390 -469
- package/src/grid/redirects-grid.ts +40 -44
- package/src/hosting/document.ts +2 -0
- package/src/hosting/layout.ts +10 -0
- package/src/i18n/i18n-commands.ts +127 -62
- package/src/media/media-pane.ts +83 -133
- package/src/new-project/add-repo-modal.ts +125 -176
- package/src/new-project/import-tab.ts +201 -250
- package/src/new-project/location-fields.ts +101 -165
- package/src/new-project/new-project-modal.ts +376 -367
- package/src/packages/jxsuite-update.ts +76 -18
- package/src/panels/activity-panel.ts +137 -104
- package/src/panels/ai-chat/chat-markdown.ts +15 -13
- package/src/panels/ai-chat/chat-view.ts +307 -472
- package/src/panels/ai-chat/composer.ts +175 -153
- package/src/panels/ai-chat/sessions-view.ts +31 -62
- package/src/panels/ai-panel.ts +210 -185
- package/src/panels/block-action-bar.ts +437 -643
- package/src/panels/bottom-dock.ts +112 -47
- package/src/panels/chat-panel.ts +19 -14
- package/src/panels/data-explorer.ts +141 -102
- package/src/panels/data-grid.ts +183 -150
- package/src/panels/dnd.ts +75 -20
- package/src/panels/editors.ts +26 -19
- package/src/panels/elements-panel.ts +243 -186
- package/src/panels/empty-state.ts +26 -42
- package/src/panels/events-panel.ts +950 -729
- package/src/panels/formula-workspace.ts +434 -207
- package/src/panels/frontmatter-fields.ts +185 -153
- package/src/panels/frontmatter-panel.ts +411 -187
- package/src/panels/git-diff-open.ts +148 -0
- package/src/panels/git-panel.ts +679 -605
- package/src/panels/head-panel.ts +617 -435
- package/src/panels/i18n-panel.ts +153 -133
- package/src/panels/imports-panel.ts +388 -414
- package/src/panels/jump-bar.ts +174 -147
- package/src/panels/layers-panel.ts +785 -671
- package/src/panels/left-panel.ts +166 -94
- package/src/panels/navigator-panels.ts +1 -1
- package/src/panels/pane-context.ts +529 -677
- package/src/panels/pane-grid.ts +265 -241
- package/src/panels/panel-registry.ts +15 -4
- package/src/panels/problems-panel.ts +177 -99
- package/src/panels/properties-panel.ts +1525 -966
- package/src/panels/provenance.ts +31 -113
- package/src/panels/quick-search.ts +217 -172
- package/src/panels/right-panel.ts +135 -169
- package/src/panels/seo-modal.ts +346 -167
- package/src/panels/settings-menu.ts +109 -646
- package/src/panels/settings-pane.ts +102 -86
- package/src/panels/signals-panel.ts +1318 -1172
- package/src/panels/statement-editor.ts +556 -428
- package/src/panels/style-panel.ts +1367 -630
- package/src/panels/style-utils.ts +36 -32
- package/src/panels/stylebook-doc.ts +30 -73
- package/src/panels/stylebook-layers-panel.ts +202 -109
- package/src/panels/stylebook-panel.ts +124 -88
- package/src/panels/tab-strip.ts +385 -287
- package/src/platforms/cloud.ts +347 -86
- package/src/platforms/devserver.ts +13 -0
- package/src/publish/deploy-checklist.ts +124 -78
- package/src/publish/publish-commands.ts +4 -12
- package/src/publish/publish-panel.ts +165 -299
- package/src/services/a11y-report.ts +100 -43
- package/src/services/ai-command-tools.ts +468 -0
- package/src/services/ai-import-tools.ts +50 -12
- package/src/services/ai-models.ts +108 -1
- package/src/services/ai-session-store.ts +6 -0
- package/src/services/ai-system-prompt.ts +110 -18
- package/src/services/ai-tools.ts +28 -143
- package/src/services/ai-write-report.ts +174 -0
- package/src/services/context-manager.ts +12 -1
- package/src/services/document-assistant.ts +50 -2
- package/src/services/idle.ts +16 -14
- package/src/services/live-surfaces.ts +237 -0
- package/src/services/model-uri.ts +75 -0
- package/src/services/notify.ts +63 -6
- package/src/services/popover-report.ts +325 -0
- package/src/services/surface-registry.ts +56 -0
- package/src/services/tool-executor.ts +17 -0
- package/src/settings/contexts-section.ts +301 -299
- package/src/settings/contributed-section.ts +361 -222
- package/src/settings/css-vars-editor.ts +320 -325
- package/src/settings/defs-editor.ts +572 -535
- package/src/settings/dependencies-editor.ts +79 -107
- package/src/settings/extension-commands.ts +379 -0
- package/src/settings/extension-rows.ts +113 -0
- package/src/settings/extensions-section.ts +287 -0
- package/src/settings/general-settings.ts +130 -181
- package/src/settings/head-editor.ts +10 -305
- package/src/settings/locales-section.ts +146 -196
- package/src/settings/preferences-accounts.ts +193 -12
- package/src/settings/preferences-dialog.ts +384 -307
- package/src/settings/project-sections.ts +108 -181
- package/src/settings/schema-field-ui.ts +11 -399
- package/src/settings/section-registry.ts +8 -1
- package/src/settings/settings-document.ts +31 -29
- package/src/shell/tree.ts +42 -87
- package/src/shell.ts +48 -36
- package/src/studio.ts +90 -67
- package/src/style/token-ref.ts +0 -39
- package/src/surfaces/about.json +263 -0
- package/src/surfaces/about.ts +163 -0
- package/src/surfaces/add-repo.json +486 -0
- package/src/surfaces/add-repo.ts +236 -0
- package/src/surfaces/ai-chat.json +2185 -0
- package/src/surfaces/ai-chat.ts +549 -0
- package/src/surfaces/ai-credentials-form.json +332 -0
- package/src/surfaces/ai-credentials-form.ts +151 -0
- package/src/surfaces/ai-managed-connect.json +108 -0
- package/src/surfaces/ai-managed-connect.ts +123 -0
- package/src/surfaces/ai-model-picker.json +114 -0
- package/src/surfaces/ai-model-picker.ts +139 -0
- package/src/surfaces/block-action-bar.json +640 -0
- package/src/surfaces/block-action-bar.ts +368 -0
- package/src/surfaces/bottom-dock.json +154 -0
- package/src/surfaces/bottom-dock.ts +125 -0
- package/src/surfaces/canvas-stage.json +444 -0
- package/src/surfaces/canvas-stage.ts +253 -0
- package/src/surfaces/cf-account-picker.json +300 -0
- package/src/surfaces/cf-account-picker.ts +214 -0
- package/src/surfaces/commandbar.json +984 -0
- package/src/{panels/toolbar.ts → surfaces/commandbar.ts} +414 -389
- package/src/surfaces/convert-repeater.json +309 -0
- package/src/surfaces/convert-repeater.ts +276 -0
- package/src/surfaces/data-actions.json +157 -0
- package/src/surfaces/data-actions.ts +115 -0
- package/src/surfaces/dialog.json +289 -0
- package/src/surfaces/dialog.ts +343 -0
- package/src/surfaces/diff-toolbar.json +266 -0
- package/src/surfaces/diff-toolbar.ts +139 -0
- package/src/surfaces/doc-header.json +739 -0
- package/src/surfaces/doc-header.ts +223 -0
- package/src/surfaces/empty-state.json +152 -0
- package/src/surfaces/empty-state.ts +173 -0
- package/src/surfaces/entry-editor.json +281 -0
- package/src/surfaces/entry-editor.ts +191 -0
- package/src/surfaces/expression-editor.json +977 -0
- package/src/surfaces/expression-editor.ts +266 -0
- package/src/surfaces/files-panel.json +592 -0
- package/src/surfaces/files-panel.ts +301 -0
- package/src/surfaces/formula-palette.json +364 -0
- package/src/surfaces/formula-palette.ts +340 -0
- package/src/surfaces/git-panel.json +1822 -0
- package/src/surfaces/git-panel.ts +272 -0
- package/src/surfaces/github-auth.json +112 -0
- package/src/surfaces/github-auth.ts +139 -0
- package/src/surfaces/github-publish.json +206 -0
- package/src/surfaces/github-publish.ts +169 -0
- package/src/surfaces/grid-cell.json +218 -0
- package/src/surfaces/grid-cell.ts +120 -0
- package/src/surfaces/grid-open.json +147 -0
- package/src/surfaces/grid-open.ts +87 -0
- package/src/surfaces/grid-panel.json +706 -0
- package/src/surfaces/grid-panel.ts +206 -0
- package/src/surfaces/grid-replace.json +179 -0
- package/src/surfaces/grid-replace.ts +89 -0
- package/src/surfaces/grid-views.json +446 -0
- package/src/surfaces/grid-views.ts +172 -0
- package/src/surfaces/inspector-dock.json +187 -0
- package/src/surfaces/inspector-dock.ts +161 -0
- package/src/surfaces/jump-bar.json +243 -0
- package/src/surfaces/jump-bar.ts +129 -0
- package/src/surfaces/jxsuite-update.json +146 -0
- package/src/surfaces/jxsuite-update.ts +149 -0
- package/src/surfaces/library-pane.json +1509 -0
- package/src/surfaces/library-pane.ts +363 -0
- package/src/surfaces/logic-panel.json +1949 -0
- package/src/surfaces/logic-panel.ts +369 -0
- package/src/surfaces/logic-workspace.json +685 -0
- package/src/surfaces/logic-workspace.ts +238 -0
- package/src/surfaces/media-browser.json +303 -0
- package/src/surfaces/media-browser.ts +145 -0
- package/src/surfaces/media-field.json +163 -0
- package/src/surfaces/media-field.ts +116 -0
- package/src/surfaces/media-pane.json +513 -0
- package/src/surfaces/media-pane.ts +197 -0
- package/src/surfaces/menu.json +232 -0
- package/src/surfaces/menu.ts +375 -0
- package/src/surfaces/navigator-dock.json +113 -0
- package/src/surfaces/navigator-dock.ts +130 -0
- package/src/surfaces/new-project.json +1654 -0
- package/src/surfaces/new-project.ts +411 -0
- package/src/surfaces/palette.json +535 -0
- package/src/surfaces/pane-context.json +1497 -0
- package/src/surfaces/pane-context.ts +513 -0
- package/src/surfaces/pane-grid.json +188 -0
- package/src/surfaces/pane-grid.ts +250 -0
- package/src/surfaces/panel-activity.json +563 -0
- package/src/surfaces/panel-activity.ts +187 -0
- package/src/surfaces/panel-data.json +141 -0
- package/src/surfaces/panel-data.ts +156 -0
- package/src/surfaces/panel-deploy-checklist.json +283 -0
- package/src/surfaces/panel-deploy-checklist.ts +175 -0
- package/src/surfaces/panel-elements.json +367 -0
- package/src/surfaces/panel-elements.ts +175 -0
- package/src/surfaces/panel-i18n.json +569 -0
- package/src/surfaces/panel-i18n.ts +212 -0
- package/src/surfaces/panel-imports.json +780 -0
- package/src/surfaces/panel-imports.ts +209 -0
- package/src/surfaces/panel-outline.json +734 -0
- package/src/surfaces/panel-outline.ts +326 -0
- package/src/surfaces/panel-page.json +1017 -0
- package/src/surfaces/panel-page.ts +240 -0
- package/src/surfaces/panel-problems.json +497 -0
- package/src/surfaces/panel-problems.ts +157 -0
- package/src/surfaces/panel-signals.json +1973 -0
- package/src/surfaces/panel-signals.ts +436 -0
- package/src/surfaces/panel-stylebook-layers.json +317 -0
- package/src/surfaces/panel-stylebook-layers.ts +155 -0
- package/src/surfaces/preferences.json +850 -0
- package/src/surfaces/preferences.ts +332 -0
- package/src/surfaces/progress-modal.json +110 -0
- package/src/surfaces/progress-modal.ts +150 -0
- package/src/surfaces/properties-panel.json +1578 -0
- package/src/surfaces/properties-panel.ts +337 -0
- package/src/surfaces/publish.json +945 -0
- package/src/surfaces/publish.ts +392 -0
- package/src/surfaces/push-plan.json +110 -0
- package/src/surfaces/push-plan.ts +87 -0
- package/src/surfaces/rail.json +255 -0
- package/src/surfaces/rail.ts +206 -0
- package/src/surfaces/reference-field.json +191 -0
- package/src/surfaces/reference-field.ts +168 -0
- package/src/surfaces/schema-builder.json +1011 -0
- package/src/surfaces/schema-builder.ts +181 -0
- package/src/surfaces/schema-form.json +1013 -0
- package/src/surfaces/schema-form.ts +287 -0
- package/src/surfaces/secret-field.json +60 -0
- package/src/surfaces/secret-field.ts +146 -0
- package/src/surfaces/seo.json +932 -0
- package/src/surfaces/seo.ts +334 -0
- package/src/surfaces/settings-contexts.json +538 -0
- package/src/surfaces/settings-contexts.ts +196 -0
- package/src/surfaces/settings-contributed.json +489 -0
- package/src/surfaces/settings-contributed.ts +199 -0
- package/src/surfaces/settings-css-vars.json +820 -0
- package/src/surfaces/settings-css-vars.ts +199 -0
- package/src/surfaces/settings-defs.json +1363 -0
- package/src/surfaces/settings-defs.ts +232 -0
- package/src/surfaces/settings-deploy.json +108 -0
- package/src/surfaces/settings-deploy.ts +135 -0
- package/src/surfaces/settings-extensions.json +486 -0
- package/src/surfaces/settings-extensions.ts +201 -0
- package/src/surfaces/settings-head.json +779 -0
- package/src/surfaces/settings-head.ts +397 -0
- package/src/surfaces/settings-locales.json +420 -0
- package/src/surfaces/settings-locales.ts +137 -0
- package/src/surfaces/settings-overview.json +423 -0
- package/src/surfaces/settings-overview.ts +218 -0
- package/src/surfaces/settings-packages.json +549 -0
- package/src/surfaces/settings-packages.ts +158 -0
- package/src/surfaces/settings-pane.json +147 -0
- package/src/surfaces/settings-pane.ts +150 -0
- package/src/surfaces/settings-rawjson.json +104 -0
- package/src/surfaces/settings-rawjson.ts +107 -0
- package/src/surfaces/shell.json +99 -0
- package/src/surfaces/shell.ts +30 -0
- package/src/surfaces/slash-menu.json +180 -0
- package/src/surfaces/slash-menu.ts +272 -0
- package/src/surfaces/statements.json +607 -0
- package/src/surfaces/statements.ts +238 -0
- package/src/surfaces/statusbar.json +94 -0
- package/src/{panels → surfaces}/statusbar.ts +163 -90
- package/src/surfaces/style-panel.json +1643 -0
- package/src/surfaces/style-panel.ts +338 -0
- package/src/surfaces/stylebook-chrome.json +122 -0
- package/src/surfaces/stylebook-chrome.ts +122 -0
- package/src/surfaces/tab-strip.json +448 -0
- package/src/surfaces/tab-strip.ts +200 -0
- package/src/surfaces/target-line.json +419 -0
- package/src/surfaces/target-line.ts +349 -0
- package/src/surfaces/toasts.json +189 -0
- package/src/surfaces/welcome.json +571 -0
- package/src/surfaces/welcome.ts +338 -0
- package/src/tabs/project-config.ts +71 -15
- package/src/tabs/tab.ts +52 -1
- package/src/types.ts +49 -3
- package/src/ui/ai-credentials-form.ts +104 -100
- package/src/ui/ai-managed-connect.ts +116 -49
- package/src/ui/ai-model-picker.ts +102 -47
- package/src/ui/cf-account-picker.ts +135 -0
- package/src/ui/color-selector.ts +80 -301
- package/src/ui/dynamic-slot.ts +43 -283
- package/src/ui/expression-editor.ts +797 -576
- package/src/ui/field-input.ts +8 -181
- package/src/ui/form-controls.ts +838 -366
- package/src/ui/formula-chips.ts +80 -85
- package/src/ui/kit.ts +33 -0
- package/src/ui/layers.ts +293 -593
- package/src/ui/media-picker.ts +203 -284
- package/src/ui/panel-resize.ts +251 -64
- package/src/ui/popover-surface.ts +153 -0
- package/src/ui/progress-modal.ts +22 -60
- package/src/ui/regions.ts +13 -7
- package/src/ui/schema-form.ts +906 -440
- package/src/ui/surface.ts +122 -0
- package/src/ui/unit-selector.ts +15 -131
- package/src/ui/value-source.ts +14 -0
- package/src/ui/virtual-window.ts +88 -9
- package/src/utils/canvas-media.ts +72 -0
- package/src/utils/edit-display.ts +7 -2
- package/src/utils/element-selectors.ts +69 -0
- package/src/utils/link-target.ts +2 -2
- package/src/utils/studio-utils.ts +0 -10
- package/src/view.ts +15 -0
- package/src/workspace/pane-derive.ts +36 -14
- package/src/workspace/workspace.ts +15 -6
- package/styles/canvas.css +72 -467
- package/styles/forced-colors.css +48 -82
- package/styles/forced-colors.json +41 -0
- package/styles/inspector.css +2 -1301
- package/styles/overlays.css +96 -2823
- package/styles/panels.css +6 -1423
- package/styles/shell-frame.css +272 -0
- package/styles/shell-frame.json +227 -0
- package/styles/shell.css +0 -1532
- package/styles/tokens.css +65 -136
- package/styles/tokens.json +84 -0
- package/dist/chunks/Overlay.dev-723bv0df.js +0 -23
- package/dist/chunks/adapter-jkcyhgtr.js +0 -14
- package/dist/chunks/cf-settings-45fgyx8y.js +0 -21
- package/dist/chunks/components-zmx10t62.js +0 -21
- package/dist/chunks/content-source-t88vb2dr.js +0 -49
- package/dist/chunks/convert-to-repeater-dhw1nrz9.js +0 -268
- package/dist/chunks/editor-cptq5jp1.js +0 -37
- package/dist/chunks/entry-commands-6z6bhxg0.js +0 -46
- package/dist/chunks/extension-sections-3ydgjbdy.js +0 -311
- package/dist/chunks/file-ops-rskmhxyq.js +0 -48
- package/dist/chunks/files-0cratsr0.js +0 -92
- package/dist/chunks/flow-qbfgrpeh.js +0 -634
- package/dist/chunks/focus-trap.esm-ggawf1hy.js +0 -1024
- package/dist/chunks/focus-visible-6eg70z18.js +0 -167
- package/dist/chunks/format-host-tgcmfs4p.js +0 -43
- package/dist/chunks/fs-events-hrrg328g.js +0 -21
- package/dist/chunks/git-panel-0yywyk76.js +0 -58
- package/dist/chunks/index-zqxmqxmh.js +0 -109
- package/dist/chunks/jx-validate-8q2g05x1.js +0 -19
- package/dist/chunks/layers-panel-z3tqe5cd.js +0 -67
- package/dist/chunks/layers-q75tj2mf.js +0 -45
- package/dist/chunks/lit-html-j055mkh8.js +0 -22
- package/dist/chunks/monaco-buffer-dqw0xxpx.js +0 -25
- package/dist/chunks/notify-yjm79n4s.js +0 -30
- package/dist/chunks/parse-24d0gay3.js +0 -19
- package/dist/chunks/platform-ba1j1gbh.js +0 -16
- package/dist/chunks/publish-panel-54jvhskq.js +0 -28
- package/dist/chunks/quick-search-cgfmjwq5.js +0 -65
- package/dist/chunks/references-3qx8fkyp.js +0 -29
- package/dist/chunks/right-panel-cqp8bc4v.js +0 -46
- package/dist/chunks/section-registry-sx1ykvkw.js +0 -30
- package/dist/chunks/sp-overlay.dev-yztmtrs1.js +0 -18
- package/dist/chunks/sp-popover.dev-n2etmqdp.js +0 -9
- package/dist/chunks/sp-progress-circle.dev-hryhj0es.js +0 -15
- package/dist/chunks/sp-tooltip.dev-xcvpnqr0.js +0 -15
- package/dist/chunks/sp-tray.dev-tkbscm06.js +0 -199
- package/dist/chunks/studio-0a5qrh01.js +0 -3
- package/dist/chunks/studio-18j3bmcz.js +0 -14
- package/dist/chunks/studio-1hbqnt19.js +0 -1823
- package/dist/chunks/studio-4rzyrtjz.js +0 -426
- package/dist/chunks/studio-5rywrkxz.js +0 -1903
- package/dist/chunks/studio-7afd21nw.js +0 -67
- package/dist/chunks/studio-7nte2hj4.js +0 -613
- package/dist/chunks/studio-8jpzqk5s.js +0 -128
- package/dist/chunks/studio-8q517dfr.js +0 -24
- package/dist/chunks/studio-9c4k4vhv.js +0 -357
- package/dist/chunks/studio-9n4mrmnb.js +0 -184
- package/dist/chunks/studio-a0tswy0w.js +0 -58
- package/dist/chunks/studio-ahjfdy6e.js +0 -387
- package/dist/chunks/studio-ahnzd9rg.js +0 -23
- package/dist/chunks/studio-bw5dz6km.js +0 -608
- package/dist/chunks/studio-cb12yz9w.js +0 -15055
- package/dist/chunks/studio-d1ks410h.js +0 -175
- package/dist/chunks/studio-eqq1w638.js +0 -113
- package/dist/chunks/studio-ex8zyp98.js +0 -1813
- package/dist/chunks/studio-h4rxscfc.js +0 -10
- package/dist/chunks/studio-kyh9avvv.js +0 -28
- package/dist/chunks/studio-kyk2v92a.js +0 -659
- package/dist/chunks/studio-m3hwn7y1.js +0 -120
- package/dist/chunks/studio-mmv72a27.js +0 -4344
- package/dist/chunks/studio-n8b9wqwy.js +0 -291
- package/dist/chunks/studio-pdfjntbk.js +0 -6939
- package/dist/chunks/studio-qq6jym04.js +0 -53
- package/dist/chunks/studio-r1r7afxx.js +0 -1066
- package/dist/chunks/studio-rdx8jcxy.js +0 -83
- package/dist/chunks/studio-rn9ta2mz.js +0 -111
- package/dist/chunks/studio-t7qb9db8.js +0 -665
- package/dist/chunks/studio-tmc5emrw.js +0 -8
- package/dist/chunks/studio-txwkm6p9.js +0 -12
- package/dist/chunks/studio-v38hmvx1.js +0 -390
- package/dist/chunks/studio-vadzgkrz.js +0 -318
- package/dist/chunks/studio-wx5609xd.js +0 -341
- package/dist/chunks/studio-z6nw2ek2.js +0 -18
- package/dist/chunks/studio-zczps70q.js +0 -378
- package/dist/chunks/workspace-xpres40v.js +0 -89
- package/src/panels/activity-bar.ts +0 -251
- package/src/panels/panel-scheduler.ts +0 -219
- package/src/panels/style-inputs.ts +0 -237
- package/src/panels/target-line.ts +0 -274
- package/src/panels/welcome-screen.ts +0 -346
- package/src/ui/button-group.ts +0 -102
- package/src/ui/choice-field.ts +0 -72
- package/src/ui/field-row.ts +0 -249
- package/src/ui/formula-palette.ts +0 -213
- package/src/ui/icons.ts +0 -52
- package/src/ui/jx-theme.ts +0 -130
- package/src/ui/spectrum.ts +0 -340
- package/src/ui/value-selector.ts +0 -174
- package/src/ui/widgets.ts +0 -172
- /package/dist/chunks/{javascript-s56a8dpk.css → javascript-4abzjcy9.css} +0 -0
- /package/dist/chunks/{jsonMode-zr9sw0c7.css → jsonMode-vvmpmk34.css} +0 -0
- /package/dist/chunks/{monaco-setup-pav68602.css → monaco-setup-8vbyqnhr.css} +0 -0
- /package/dist/chunks/{tsMode-ef187txx.css → tsMode-hnxxb73h.css} +0 -0
package/src/files/files.ts
CHANGED
|
@@ -1,32 +1,43 @@
|
|
|
1
1
|
/// <reference lib="dom" />
|
|
2
2
|
/// <reference lib="dom.iterable" />
|
|
3
3
|
/**
|
|
4
|
-
* File tree management — project loading, file
|
|
4
|
+
* File tree management — project loading, file CRUD, and the flow behind the Navigator's Files
|
|
5
|
+
* panel.
|
|
5
6
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
7
|
+
* **The body is a Jx document** (`surfaces/files-panel.json`, mounted by
|
|
8
|
+
* `surfaces/files-panel.ts`), so this module draws no markup: it projects. What stays here is
|
|
9
|
+
* everything that is a DECISION — which directories are listed, which entries `.gitignore` masks,
|
|
10
|
+
* how the flat row model is built and where the window falls on it, what a click and a key MEAN,
|
|
11
|
+
* what the per-row menu offers, and what each verb does to the filesystem. The surface reads
|
|
12
|
+
* values.
|
|
13
|
+
*
|
|
14
|
+
* Every name the user supplies (new file, rename) is collected with the prompt dialog from
|
|
15
|
+
* ui/layers.ts — never a native browser prompt (studio-ui-guidelines.md §8.7).
|
|
9
16
|
*
|
|
10
17
|
* **The tree is a flat list of rows, and the DOM holds a window onto it** ({@link FileRow},
|
|
11
18
|
* `ui/virtual-window.ts`). It used to recurse a template per directory level, which is why it drew
|
|
12
19
|
* every expanded row of every expanded directory — a `node_modules` expanded by accident is tens of
|
|
13
|
-
* thousands of
|
|
14
|
-
*
|
|
15
|
-
*
|
|
20
|
+
* thousands of icon custom elements, built synchronously, on every repaint. A recursion has no row
|
|
21
|
+
* list to window, so the recursion moved into {@link collectFileRows}, which produces the rows in
|
|
22
|
+
* display order and nothing else; the projection is then a window over that array.
|
|
16
23
|
*
|
|
17
24
|
* Flattening costs the `role="group"` wrappers, and pays for them with `aria-level` +
|
|
18
25
|
* `aria-posinset` / `aria-setsize` on every row — the same shape the Outline has always had, and
|
|
19
26
|
* the only shape that stays TRUE when the tree draws eleven rows out of ten thousand.
|
|
20
27
|
*
|
|
28
|
+
* **Four facts about a row are ONE scope field each**, not fields of the row: the selected path,
|
|
29
|
+
* the dragged path, the drop target and the roving tab stop. The document compares each against
|
|
30
|
+
* `$map.item.path`, so moving the selection or dragging a file re-evaluates one attribute per drawn
|
|
31
|
+
* row instead of rebuilding the list — which is what lets a drag-over highlight cost nothing, and
|
|
32
|
+
* what stops a window sliding out from under the drag sources pragmatic-dnd is holding.
|
|
33
|
+
*
|
|
21
34
|
* @docs studio/interface
|
|
22
35
|
*/
|
|
23
36
|
|
|
24
|
-
import {
|
|
37
|
+
import { nothing } from "lit-html";
|
|
25
38
|
import { errorMessage } from "@jxsuite/schema/parse";
|
|
26
39
|
import { localeLabel, localeOfPath, resolveI18n } from "@jxsuite/schema/locale";
|
|
27
|
-
import {
|
|
28
|
-
import { ref } from "lit-html/directives/ref.js";
|
|
29
|
-
import { renderPopover, showPromptDialog } from "../ui/layers";
|
|
40
|
+
import { showPromptDialog } from "../ui/layers";
|
|
30
41
|
import { projectState, requireProjectState, setProjectState } from "../store";
|
|
31
42
|
import { getPlatform } from "../platform";
|
|
32
43
|
import { disarmPreviewOverlay } from "../preview/preview-overlay";
|
|
@@ -64,6 +75,8 @@ import { isViewableMedia, openMediaTab } from "../media/media-open";
|
|
|
64
75
|
import { activeRegistry } from "../commands/active-registry";
|
|
65
76
|
import { collectionOfPath } from "../content/entry-model";
|
|
66
77
|
import { confirmFileDelete, parseSourceForPath, renamePromptMessage } from "./file-ops";
|
|
78
|
+
import { parseJsonDocument } from "./json-layout";
|
|
79
|
+
import type { JsonLayout } from "./json-layout";
|
|
67
80
|
import { invalidateUsages } from "../services/references";
|
|
68
81
|
import {
|
|
69
82
|
documentExtensions,
|
|
@@ -80,31 +93,21 @@ import { markSessionRestored, persistedSession, resetProjectShell, setActivityTa
|
|
|
80
93
|
import { restoreSession } from "../workspace/session";
|
|
81
94
|
import { cleanupGitPanel } from "../panels/git-panel";
|
|
82
95
|
import { addRecentProject, trackRecentFile } from "../recent-projects";
|
|
83
|
-
import {
|
|
84
|
-
listWindow,
|
|
85
|
-
measuredRowHeight,
|
|
86
|
-
revealListRow,
|
|
87
|
-
watchListWindow,
|
|
88
|
-
} from "../ui/virtual-window";
|
|
89
|
-
import type { TemplateResult } from "lit-html";
|
|
96
|
+
import { listWindow, revealListRow, watchListWindow } from "../ui/virtual-window";
|
|
90
97
|
import type { JxMutableNode } from "@jxsuite/schema/types";
|
|
91
98
|
import type { ResolvedI18n } from "@jxsuite/schema/locale";
|
|
92
|
-
import type { ChoiceOption } from "../ui/
|
|
99
|
+
import type { ChoiceOption } from "../ui/layers";
|
|
100
|
+
import { emptyFilesPanelValues, mountFilesPanelSurface } from "../surfaces/files-panel";
|
|
101
|
+
import { openMenu } from "../surfaces/menu";
|
|
102
|
+
import type {
|
|
103
|
+
FileRowView,
|
|
104
|
+
FilesPanelActions,
|
|
105
|
+
FilesPanelSurfaceHandle,
|
|
106
|
+
FilesPanelValues,
|
|
107
|
+
} from "../surfaces/files-panel";
|
|
108
|
+
import type { MenuHandle, MenuRowProjection } from "../surfaces/menu";
|
|
93
109
|
import type { DirEntry, RenameResult } from "../types";
|
|
94
110
|
import type { ListWindowWatch } from "../ui/virtual-window";
|
|
95
|
-
import { rectOf } from "../utils/geometry";
|
|
96
|
-
import { repeat } from "lit-html/directives/repeat.js";
|
|
97
|
-
|
|
98
|
-
// ─── File icon map ────────────────────────────────────────────────────────────
|
|
99
|
-
|
|
100
|
-
const fileIconMap = {
|
|
101
|
-
"sp-icon-document": html`<sp-icon-document></sp-icon-document>`,
|
|
102
|
-
"sp-icon-file-code": html`<sp-icon-file-code></sp-icon-file-code>`,
|
|
103
|
-
"sp-icon-file-txt": html`<sp-icon-file-txt></sp-icon-file-txt>`,
|
|
104
|
-
"sp-icon-folder": html`<sp-icon-folder></sp-icon-folder>`,
|
|
105
|
-
"sp-icon-folder-open": html`<sp-icon-folder-open></sp-icon-folder-open>`,
|
|
106
|
-
"sp-icon-image": html`<sp-icon-image></sp-icon-image>`,
|
|
107
|
-
} as Record<string, TemplateResult>;
|
|
108
111
|
|
|
109
112
|
// ─── File management ──────────────────────────────────────────────────────────
|
|
110
113
|
|
|
@@ -416,160 +419,66 @@ export async function openLastSessionOrHome(): Promise<boolean> {
|
|
|
416
419
|
return false;
|
|
417
420
|
}
|
|
418
421
|
|
|
419
|
-
// ───
|
|
422
|
+
// ─── Row icons ────────────────────────────────────────────────────────────────
|
|
420
423
|
|
|
421
|
-
|
|
422
|
-
|
|
424
|
+
/**
|
|
425
|
+
* The kit glyph one row draws, by NAME rather than by tag.
|
|
426
|
+
*
|
|
427
|
+
* It used to be a map of six `sp-icon-*` templates built once at module load, which is a
|
|
428
|
+
* `TemplateResult` per icon whether or not the tree was ever opened. A name is a string the
|
|
429
|
+
* document hands `jx-icon`, and the manifest is what resolves it — so a row costs nothing until it
|
|
430
|
+
* is drawn, and `scripts/check-icons.ts` checks the key against the same manifest the rail's does.
|
|
431
|
+
*/
|
|
432
|
+
function fileIconName(name: string, type: string, expanded: boolean): string {
|
|
423
433
|
if (type === "directory") {
|
|
424
|
-
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
case "css": {
|
|
442
|
-
tag = "sp-icon-file-code";
|
|
443
|
-
break;
|
|
444
|
-
}
|
|
445
|
-
default: {
|
|
446
|
-
// Every image extension the media layer knows about, so an uploaded .avif/.ico gets the
|
|
447
|
-
// Same icon as a .png instead of falling through to the generic document glyph.
|
|
448
|
-
tag = ext && isImage(ext) ? "sp-icon-image" : "sp-icon-document";
|
|
449
|
-
break;
|
|
450
|
-
}
|
|
434
|
+
return expanded ? "folder-open" : "folder";
|
|
435
|
+
}
|
|
436
|
+
const ext = name.split(".").pop()?.toLowerCase();
|
|
437
|
+
switch (ext) {
|
|
438
|
+
case "css":
|
|
439
|
+
case "js":
|
|
440
|
+
case "json":
|
|
441
|
+
case "ts": {
|
|
442
|
+
return "file-code";
|
|
443
|
+
}
|
|
444
|
+
case "md": {
|
|
445
|
+
return "file-text";
|
|
446
|
+
}
|
|
447
|
+
default: {
|
|
448
|
+
// Every image extension the media layer knows about, so an uploaded .avif/.ico gets the
|
|
449
|
+
// Same icon as a .png instead of falling through to the generic document glyph.
|
|
450
|
+
return ext !== undefined && isImage(ext) ? "image" : "file";
|
|
451
451
|
}
|
|
452
452
|
}
|
|
453
|
-
return fileIconMap[tag] || fileIconMap["sp-icon-document"];
|
|
454
453
|
}
|
|
455
454
|
|
|
456
455
|
/**
|
|
457
|
-
*
|
|
456
|
+
* The Navigator no longer draws this panel with lit.
|
|
457
|
+
*
|
|
458
|
+
* The record below returns `nothing` and mounts `surfaces/files-panel.json` in `afterRender`, so
|
|
459
|
+
* this is a stub: it survives only because `NavigatorPanelDeps` still declares the injection and
|
|
460
|
+
* `studio.ts` still passes it. Both go in the change that deletes this.
|
|
458
461
|
*
|
|
459
|
-
* @
|
|
460
|
-
* openProject: () => void;
|
|
461
|
-
* openFileFromTree: (path: string) => void;
|
|
462
|
-
* renderLeftPanel: () => void;
|
|
463
|
-
* }} ctx
|
|
462
|
+
* @deprecated The panel is `surfaces/files-panel.json`; call {@link mountFilesPanel}.
|
|
464
463
|
*/
|
|
465
|
-
export function renderFilesTemplate({
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
renderLeftPanel,
|
|
469
|
-
}: {
|
|
470
|
-
openProject: () => void;
|
|
471
|
-
openFileFromTree: (path: string) => void;
|
|
472
|
-
renderLeftPanel: () => void;
|
|
473
|
-
}) {
|
|
474
|
-
if (!projectState) {
|
|
475
|
-
return html`<div class="file-tree-empty">No project loaded</div>`;
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
// No project selected in a monorepo — show welcome prompt
|
|
479
|
-
if (!projectState.isSiteProject && projectState.projectRoot === ".") {
|
|
480
|
-
return html`<div class="file-tree-empty">
|
|
481
|
-
<p style="margin:0 0 12px">Open a project folder to get started.</p>
|
|
482
|
-
<sp-button variant="accent" size="s" @click=${openProjectFn}>Open Project</sp-button>
|
|
483
|
-
</div>`;
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
const showingIgnored = showIgnoredFiles();
|
|
464
|
+
export function renderFilesTemplate(): typeof nothing {
|
|
465
|
+
return nothing;
|
|
466
|
+
}
|
|
487
467
|
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
<sp-action-button
|
|
503
|
-
size="xs"
|
|
504
|
-
label="New File"
|
|
505
|
-
@click=${() => createNewFile(".", renderLeftPanel)}
|
|
506
|
-
>
|
|
507
|
-
<sp-icon-add slot="icon"></sp-icon-add>
|
|
508
|
-
</sp-action-button>
|
|
509
|
-
<sp-action-button
|
|
510
|
-
size="xs"
|
|
511
|
-
label="Refresh"
|
|
512
|
-
@click=${async () => {
|
|
513
|
-
requireProjectState().dirs.clear();
|
|
514
|
-
/* The rules go with the listings. Refresh is what an author reaches for after editing a
|
|
515
|
-
`.gitignore` by hand, and a tree that came back still hiding by the old rules would
|
|
516
|
-
read as the button not having worked. */
|
|
517
|
-
resetIgnoreCache();
|
|
518
|
-
await loadDirectory(".");
|
|
519
|
-
for (const dir of requireProjectState().expanded) {
|
|
520
|
-
await loadDirectory(dir);
|
|
521
|
-
}
|
|
522
|
-
renderLeftPanel();
|
|
523
|
-
}}
|
|
524
|
-
>
|
|
525
|
-
<sp-icon-refresh slot="icon"></sp-icon-refresh>
|
|
526
|
-
</sp-action-button>
|
|
527
|
-
<sp-action-button
|
|
528
|
-
size="xs"
|
|
529
|
-
label=${showingIgnored ? "Hide ignored files" : "Show ignored files"}
|
|
530
|
-
?selected=${showingIgnored}
|
|
531
|
-
@click=${() => {
|
|
532
|
-
/* A repaint and nothing else: the ignored entries were never dropped from
|
|
533
|
-
`projectState.dirs`, only from the rows built out of it. */
|
|
534
|
-
setShowIgnoredFiles(!showingIgnored);
|
|
535
|
-
renderLeftPanel();
|
|
536
|
-
}}
|
|
537
|
-
>
|
|
538
|
-
${
|
|
539
|
-
showingIgnored
|
|
540
|
-
? html`<sp-icon-visibility slot="icon"></sp-icon-visibility>`
|
|
541
|
-
: html`<sp-icon-visibility-off slot="icon"></sp-icon-visibility-off>`
|
|
542
|
-
}
|
|
543
|
-
</sp-action-button>
|
|
544
|
-
</sp-action-group>
|
|
545
|
-
<sp-search
|
|
546
|
-
size="s"
|
|
547
|
-
quiet
|
|
548
|
-
placeholder="Filter files…"
|
|
549
|
-
value=${requireProjectState().searchQuery}
|
|
550
|
-
@input=${(e: Event) => {
|
|
551
|
-
requireProjectState().searchQuery = (e.target as HTMLInputElement).value;
|
|
552
|
-
renderLeftPanel();
|
|
553
|
-
}}
|
|
554
|
-
@submit=${(e: Event) => e.preventDefault()}
|
|
555
|
-
></sp-search>
|
|
556
|
-
</div>
|
|
557
|
-
<div
|
|
558
|
-
class="file-tree"
|
|
559
|
-
role="tree"
|
|
560
|
-
aria-label="Project files"
|
|
561
|
-
@keydown=${(e: KeyboardEvent) => {
|
|
562
|
-
onFileTreeKeydown(e, e.currentTarget as HTMLElement);
|
|
563
|
-
}}
|
|
564
|
-
${ref((el) => {
|
|
565
|
-
if (el) {
|
|
566
|
-
afterFileTreeRender(el as HTMLElement);
|
|
567
|
-
}
|
|
568
|
-
})}
|
|
569
|
-
>
|
|
570
|
-
${fileTreeBodyTemplate({ openFileFn, renderLeftPanel })}
|
|
571
|
-
</div>
|
|
572
|
-
`;
|
|
468
|
+
/**
|
|
469
|
+
* Drag-and-drop is registered against the row elements the DOCUMENT creates, as they are created.
|
|
470
|
+
*
|
|
471
|
+
* The pass this replaced ran on a `requestAnimationFrame` after every repaint, found the tree and
|
|
472
|
+
* its rows by class, and re-registered every one of them — which is exactly the acquisition
|
|
473
|
+
* `studio-ui-guidelines.md` §9.4 objects to, and which a WINDOWED list makes wrong rather than
|
|
474
|
+
* merely wasteful: the rows are re-used for different files as the window slides, so a pass that
|
|
475
|
+
* arrives one frame late hands a file's drag source to whichever file is standing in its place.
|
|
476
|
+
* {@link mountFilesPanel} adopts each row through `onNodeCreated` instead.
|
|
477
|
+
*
|
|
478
|
+
* @deprecated Registration is `onNodeCreated`; this exists for the deps entry alone.
|
|
479
|
+
*/
|
|
480
|
+
export function registerFileTreeDnD(_ctx: { renderLeftPanel: () => void }): void {
|
|
481
|
+
// Intentionally nothing: see the note above.
|
|
573
482
|
}
|
|
574
483
|
|
|
575
484
|
// ─── The row model, and the window onto it ───────────────────────────────────
|
|
@@ -583,7 +492,7 @@ export function renderFilesTemplate({
|
|
|
583
492
|
*/
|
|
584
493
|
interface FileRow {
|
|
585
494
|
/**
|
|
586
|
-
*
|
|
495
|
+
* The `$map` key the document reconciles by.
|
|
587
496
|
*
|
|
588
497
|
* Keyed, where the recursive form was positional: a windowed list re-uses its DOM nodes for
|
|
589
498
|
* DIFFERENT rows as the window slides, so positional reuse would leave the keyboard focused on an
|
|
@@ -613,7 +522,7 @@ interface FileRow {
|
|
|
613
522
|
}
|
|
614
523
|
|
|
615
524
|
/**
|
|
616
|
-
* The declared height of one row —
|
|
525
|
+
* The declared height of one row — the `--jx-control-h` the document gives `[part="row"]`.
|
|
617
526
|
*
|
|
618
527
|
* The first paint of a session windows by this constant, because nothing has been laid out yet to
|
|
619
528
|
* measure; {@link fileRowHeight} measures a real row from then on and believes the measurement.
|
|
@@ -622,18 +531,58 @@ export const FILE_ROW_HEIGHT = 24;
|
|
|
622
531
|
|
|
623
532
|
/** The rows the tree last built, in display order. */
|
|
624
533
|
let _fileRows: FileRow[] = [];
|
|
625
|
-
/** The
|
|
534
|
+
/** The tree element, adopted through the document's `onNodeCreated` so it is never re-found. */
|
|
626
535
|
let _fileList: HTMLElement | null = null;
|
|
536
|
+
/**
|
|
537
|
+
* Every DRAWN row's element, by path.
|
|
538
|
+
*
|
|
539
|
+
* Held rather than queried, which is the §9.4 rule and, for a windowed list, the only correct
|
|
540
|
+
* answer: the nodes are re-used for different files as the window slides, so a selector run a frame
|
|
541
|
+
* later resolves to whichever file is standing there now. Entries whose element has left the
|
|
542
|
+
* document are swept on the next projection.
|
|
543
|
+
*/
|
|
544
|
+
const _fileRowEls = new Map<string, HTMLElement>();
|
|
627
545
|
/** The scroll watch that repaints the tree as its scroller moves. */
|
|
628
546
|
let _fileWatch: ListWindowWatch | null = null;
|
|
629
547
|
/** The Navigator repaint, captured per render so the scroll watch never holds a stale one. */
|
|
630
548
|
let _filesRerender: (() => void) | null = null;
|
|
631
|
-
/** A keyboard jump that had to scroll first, spent by the repaint it provoked. */
|
|
632
|
-
let _pendingFocusPath: string | null = null;
|
|
633
549
|
|
|
634
|
-
/**
|
|
550
|
+
/**
|
|
551
|
+
* The height one row actually has; the declared constant until a row has been laid out.
|
|
552
|
+
*
|
|
553
|
+
* Measured off a row this module already holds. The DECLARED height is what lets the FIRST render
|
|
554
|
+
* window anything at all, before any row exists; the MEASUREMENT is what stops that constant
|
|
555
|
+
* becoming a lie the day the density setting changes it, a user zooms, or a locale's font raises
|
|
556
|
+
* the line box.
|
|
557
|
+
*/
|
|
635
558
|
function fileRowHeight(): number {
|
|
636
|
-
|
|
559
|
+
for (const el of _fileRowEls.values()) {
|
|
560
|
+
if (el.isConnected && el.offsetHeight > 0) {
|
|
561
|
+
return el.offsetHeight;
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
return FILE_ROW_HEIGHT;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
/** Forget the rows the window has taken away, and release what was registered against them. */
|
|
568
|
+
function sweepRowElements(): void {
|
|
569
|
+
for (const [path, el] of _fileRowEls) {
|
|
570
|
+
if (!el.isConnected) {
|
|
571
|
+
_fileRowEls.delete(path);
|
|
572
|
+
releaseRowDnD(el);
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
/** The rendered row for a path, or null when the window does not currently hold it. */
|
|
578
|
+
function fileRowElement(path: string): HTMLElement | null {
|
|
579
|
+
const el = _fileRowEls.get(path);
|
|
580
|
+
return el?.isConnected === true ? el : null;
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
/** The model row for a path, or undefined. A "Loading…" row is keyed apart and never matches. */
|
|
584
|
+
function fileRowAt(path: string): FileRow | undefined {
|
|
585
|
+
return _fileRows.find((row) => !row.loading && row.path === path);
|
|
637
586
|
}
|
|
638
587
|
|
|
639
588
|
/**
|
|
@@ -646,12 +595,11 @@ function collectFileRows(
|
|
|
646
595
|
dirPath: string,
|
|
647
596
|
depth: number,
|
|
648
597
|
rows: FileRow[],
|
|
649
|
-
ctx: { renderLeftPanel: () => void },
|
|
650
598
|
i18n: ResolvedI18n | null,
|
|
651
599
|
): void {
|
|
652
600
|
const entries = requireProjectState().dirs.get(dirPath);
|
|
653
601
|
if (!entries) {
|
|
654
|
-
void loadDirectory(dirPath).then(() =>
|
|
602
|
+
void loadDirectory(dirPath).then(() => repaintFiles());
|
|
655
603
|
rows.push({
|
|
656
604
|
depth,
|
|
657
605
|
expanded: false,
|
|
@@ -705,7 +653,7 @@ function collectFileRows(
|
|
|
705
653
|
type: entry.type,
|
|
706
654
|
});
|
|
707
655
|
if (isExpanded) {
|
|
708
|
-
collectFileRows(entry.path, depth + 1, rows,
|
|
656
|
+
collectFileRows(entry.path, depth + 1, rows, i18n);
|
|
709
657
|
}
|
|
710
658
|
}
|
|
711
659
|
}
|
|
@@ -725,277 +673,428 @@ function fileStep(index: number, step: 1 | -1): number {
|
|
|
725
673
|
return -1;
|
|
726
674
|
}
|
|
727
675
|
|
|
676
|
+
/**
|
|
677
|
+
* The row at `index`'s parent: the nearest row above it at a shallower depth; -1 at the top level.
|
|
678
|
+
*
|
|
679
|
+
* Over the MODEL, which is the whole reason `jx-tree` asks rather than answering. The element's own
|
|
680
|
+
* `ArrowLeft` climbs to the nearest DRAWN row at a shallower level, and a directory whose contents
|
|
681
|
+
* fill the viewport is precisely the case where its own row is the one scrolled off the top.
|
|
682
|
+
*/
|
|
683
|
+
function fileParentIndex(index: number): number {
|
|
684
|
+
const row = _fileRows[index];
|
|
685
|
+
if (!row) {
|
|
686
|
+
return -1;
|
|
687
|
+
}
|
|
688
|
+
for (let i = index - 1; i >= 0; i--) {
|
|
689
|
+
const above = _fileRows[i]!;
|
|
690
|
+
if (!above.loading && above.depth < row.depth) {
|
|
691
|
+
return i;
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
return -1;
|
|
695
|
+
}
|
|
696
|
+
|
|
728
697
|
/**
|
|
729
698
|
* Repaint the tree because its window changed.
|
|
730
699
|
*
|
|
731
|
-
* Deferred to a microtask so a scroll arriving mid-commit cannot re-enter the
|
|
732
|
-
* rows, and skipped during a drag:
|
|
733
|
-
*
|
|
700
|
+
* Deferred to a microtask so a scroll arriving mid-commit cannot re-enter the projection producing
|
|
701
|
+
* the rows, and skipped during a drag: a window that slid under pragmatic-dnd would hand its
|
|
702
|
+
* registrations to a different set of rows halfway through the gesture. `_dragPath` is what says a
|
|
703
|
+
* drag is in flight — a state this module holds, where it used to be a class on a node it then had
|
|
704
|
+
* to go and look for.
|
|
734
705
|
*/
|
|
735
706
|
function fileWindowChanged(): void {
|
|
736
|
-
if (_fileList?.isConnected !== true ||
|
|
707
|
+
if (_fileList?.isConnected !== true || _dragPath !== "") {
|
|
737
708
|
return;
|
|
738
709
|
}
|
|
739
|
-
queueMicrotask(
|
|
710
|
+
queueMicrotask(repaintFiles);
|
|
740
711
|
}
|
|
741
712
|
|
|
742
713
|
/**
|
|
743
|
-
* Adopt the
|
|
744
|
-
* the row a jump asked for once that row exists.
|
|
714
|
+
* Adopt the tree: keep it watching whatever scrolls it.
|
|
745
715
|
*
|
|
746
|
-
*
|
|
747
|
-
*
|
|
748
|
-
*
|
|
749
|
-
*
|
|
716
|
+
* Called after every projection rather than once at mount, and that is not belt-and-braces. The
|
|
717
|
+
* tree element is created ONE time — the document re-uses it for the life of the panel — and at
|
|
718
|
+
* that instant it holds no rows, so it does not yet overflow and `watchListWindow` correctly
|
|
719
|
+
* resolves no scroller at all. The first paint draws every row, because nothing can be measured
|
|
720
|
+
* before it exists; the watch's opening measurement is what asks for the second, windowed pass.
|
|
721
|
+
* Idempotent by construction — `watchListWindow` hands back the same watch for the same element and
|
|
722
|
+
* scroller — so calling it again costs a comparison.
|
|
750
723
|
*/
|
|
751
|
-
function adoptFileTree(
|
|
752
|
-
|
|
724
|
+
function adoptFileTree(): void {
|
|
725
|
+
const tree = _fileList;
|
|
726
|
+
if (tree === null) {
|
|
727
|
+
return;
|
|
728
|
+
}
|
|
753
729
|
_fileWatch = watchListWindow(_fileWatch, tree, {
|
|
754
730
|
count: () => _fileRows.length,
|
|
755
731
|
onChange: fileWindowChanged,
|
|
756
732
|
rowHeight: fileRowHeight,
|
|
757
733
|
});
|
|
758
|
-
const wanted = _pendingFocusPath;
|
|
759
|
-
if (wanted !== null) {
|
|
760
|
-
// One shot: a focus request that outlived its own repaint is stale, and moving the keyboard
|
|
761
|
-
// Later is worse than never having moved it.
|
|
762
|
-
_pendingFocusPath = null;
|
|
763
|
-
fileRowElement(tree, wanted)?.focus();
|
|
764
|
-
}
|
|
765
734
|
}
|
|
766
735
|
|
|
767
|
-
|
|
768
|
-
* Adopt the tree once its rows are in the document.
|
|
769
|
-
*
|
|
770
|
-
* Deferred by a microtask on purpose, exactly as the Outline's `afterTreeRender` is: a `ref` on the
|
|
771
|
-
* tree element commits BEFORE the child part holding the rows, so on a first render the callback
|
|
772
|
-
* would otherwise measure an empty tree.
|
|
773
|
-
*/
|
|
774
|
-
function afterFileTreeRender(tree: HTMLElement): void {
|
|
775
|
-
queueMicrotask(() => adoptFileTree(tree));
|
|
776
|
-
}
|
|
736
|
+
// ─── What the document draws ─────────────────────────────────────────────────
|
|
777
737
|
|
|
778
|
-
/**
|
|
779
|
-
function
|
|
780
|
-
|
|
738
|
+
/** One model row, as the document reads it: every field a string, and nothing left to decide. */
|
|
739
|
+
function fileRowView(row: FileRow): FileRowView {
|
|
740
|
+
const level = String(row.depth + 1);
|
|
741
|
+
if (row.loading) {
|
|
742
|
+
return {
|
|
743
|
+
ariaExpanded: "",
|
|
744
|
+
depth: String(row.depth),
|
|
745
|
+
icon: "",
|
|
746
|
+
key: row.key,
|
|
747
|
+
kind: "loading",
|
|
748
|
+
level,
|
|
749
|
+
locale: "",
|
|
750
|
+
localeState: "hidden",
|
|
751
|
+
name: row.name,
|
|
752
|
+
path: row.path,
|
|
753
|
+
posInSet: "",
|
|
754
|
+
setSize: "",
|
|
755
|
+
type: row.type,
|
|
756
|
+
};
|
|
757
|
+
}
|
|
758
|
+
/* `""` for a file, and it is not "no answer": an empty `expanded` is what tells `jx-tree-item` the
|
|
759
|
+
row is a LEAF, so it draws no twisty, writes no `aria-expanded`, and `ArrowRight` on it does
|
|
760
|
+
nothing rather than stepping into a directory the row does not have. */
|
|
761
|
+
const isDir = row.type === "directory";
|
|
762
|
+
return {
|
|
763
|
+
ariaExpanded: isDir ? String(row.expanded) : "",
|
|
764
|
+
depth: String(row.depth),
|
|
765
|
+
icon: fileIconName(row.path, row.type, row.expanded),
|
|
766
|
+
key: row.key,
|
|
767
|
+
kind: "item",
|
|
768
|
+
level,
|
|
769
|
+
locale: row.locale === undefined ? "" : localeLabel(row.locale),
|
|
770
|
+
localeState: row.locale === undefined ? "hidden" : "shown",
|
|
771
|
+
name: row.name,
|
|
772
|
+
path: row.path,
|
|
773
|
+
posInSet: String(row.posInSet),
|
|
774
|
+
setSize: String(row.setSize),
|
|
775
|
+
type: row.type,
|
|
776
|
+
};
|
|
781
777
|
}
|
|
782
778
|
|
|
783
779
|
/**
|
|
784
|
-
*
|
|
780
|
+
* Everything the Files document draws right now.
|
|
785
781
|
*
|
|
786
|
-
*
|
|
787
|
-
*
|
|
782
|
+
* Three shapes, discriminated by one word, because "there is no project", "this is a monorepo root
|
|
783
|
+
* that has not been pointed at a site" and "here is a tree" are three different things to say and
|
|
784
|
+
* the first two have different offers. The rows are the WINDOW, and the scroll of everything either
|
|
785
|
+
* side of it is reserved by the two spacers — so the array this hands over is a dozen rows whether
|
|
786
|
+
* the project holds twelve files or ten thousand.
|
|
788
787
|
*/
|
|
789
|
-
function
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
788
|
+
function filesPanelValues(): FilesPanelValues {
|
|
789
|
+
sweepRowElements();
|
|
790
|
+
if (!projectState) {
|
|
791
|
+
_fileRows = [];
|
|
792
|
+
const values: FilesPanelValues = { ...emptyFilesPanelValues(), view: "none" };
|
|
793
|
+
_lastValues = values;
|
|
794
|
+
return values;
|
|
795
|
+
}
|
|
796
|
+
if (!projectState.isSiteProject && projectState.projectRoot === ".") {
|
|
797
|
+
_fileRows = [];
|
|
798
|
+
const values: FilesPanelValues = { ...emptyFilesPanelValues(), view: "welcome" };
|
|
799
|
+
_lastValues = values;
|
|
800
|
+
return values;
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
const state = requireProjectState();
|
|
796
804
|
_fileRows = [];
|
|
797
|
-
// Resolved once for the whole tree, not once per row: this
|
|
805
|
+
// Resolved once for the whole tree, not once per row: this runs on EVERY repaint of the
|
|
798
806
|
// Navigator, and `resolveI18n` canonicalizes every declared tag through `Intl.Locale`.
|
|
799
|
-
const { i18n } = resolveI18n(
|
|
800
|
-
collectFileRows(".", 0, _fileRows,
|
|
801
|
-
// Windowed against the
|
|
802
|
-
//
|
|
807
|
+
const { i18n } = resolveI18n(state.projectConfig ?? {});
|
|
808
|
+
collectFileRows(".", 0, _fileRows, i18n);
|
|
809
|
+
// Windowed against the element the document holds, which is the only one that exists while this
|
|
810
|
+
// Is being built. There is none before the first mount, and `listWindow` then answers "all of
|
|
811
|
+
// Them".
|
|
803
812
|
const range = listWindow(_fileList, { count: _fileRows.length, rowHeight: fileRowHeight() });
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
813
|
+
const drawn = _fileRows.slice(range.start, range.end);
|
|
814
|
+
/* The caret is a SEED, not a clamp. `jx-tree` owns it, keeps it across every repaint that does
|
|
815
|
+
not change `current`, and falls back to the first drawn row for the TAB STOP on its own — so a
|
|
816
|
+
reader whose row has scrolled three hundred rows away keeps their place and still has a way
|
|
817
|
+
back in with Tab. What this replaced recomputed the stop from the selection on every paint and
|
|
818
|
+
clamped it into the window, which moved the reader on a wheel.
|
|
819
|
+
|
|
820
|
+
It must still NAME a row, and the fallback is what guarantees it rather than tidiness: `move`
|
|
821
|
+
reports the caret's own row as `from`, and a tree nobody has touched would report `""` and send
|
|
822
|
+
every ↓ off the bottom of the window back to the first row of the project. */
|
|
823
|
+
const caret =
|
|
824
|
+
(state.selectedPath !== null && fileRowAt(state.selectedPath) ? state.selectedPath : "") ||
|
|
825
|
+
drawn.find((row) => !row.loading)?.path ||
|
|
826
|
+
"";
|
|
827
|
+
const showingIgnored = showIgnoredFiles();
|
|
828
|
+
|
|
829
|
+
const values: FilesPanelValues = {
|
|
830
|
+
currentPath: caret,
|
|
831
|
+
dragPath: _dragPath,
|
|
832
|
+
dropPath: _dropPath,
|
|
833
|
+
headerState: state.isSiteProject ? "shown" : "hidden",
|
|
834
|
+
ignoredIcon: showingIgnored ? "eye" : "eye-slash",
|
|
835
|
+
ignoredLabel: showingIgnored ? "Hide ignored files" : "Show ignored files",
|
|
836
|
+
ignoredSelected: showingIgnored,
|
|
837
|
+
padBottom: range.padBottom,
|
|
838
|
+
padTop: range.padTop,
|
|
839
|
+
projectName: state.projectConfig?.name || state.name,
|
|
840
|
+
query: state.searchQuery,
|
|
841
|
+
rootDrop: _rootDrop,
|
|
842
|
+
rows: drawn.map((row) => fileRowView(row)),
|
|
843
|
+
selectedPath: state.selectedPath ?? "",
|
|
844
|
+
view: "tree",
|
|
845
|
+
};
|
|
846
|
+
_lastValues = values;
|
|
847
|
+
return values;
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
/**
|
|
851
|
+
* Say only what a DRAG changed, without rebuilding the row model.
|
|
852
|
+
*
|
|
853
|
+
* `onDrag` fires per pointer move. Re-projecting from scratch would re-walk every listed directory,
|
|
854
|
+
* re-resolve the locales and re-slice the window on each of them, so the three fields a drag
|
|
855
|
+
* actually moves are written over the last projection instead — and because the document compares
|
|
856
|
+
* each of them against `$map.item.path`, what reaches the DOM is one attribute per drawn row.
|
|
857
|
+
*/
|
|
858
|
+
function syncFilesDragState(): void {
|
|
859
|
+
if (!_standingFiles || !_lastValues) {
|
|
860
|
+
return;
|
|
837
861
|
}
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
style="padding-left:${8 + row.depth * 16}px"
|
|
846
|
-
role="treeitem"
|
|
847
|
-
aria-level=${row.depth + 1}
|
|
848
|
-
aria-posinset=${row.posInSet}
|
|
849
|
-
aria-setsize=${row.setSize}
|
|
850
|
-
tabindex=${tabStop ? "0" : "-1"}
|
|
851
|
-
data-path=${row.path}
|
|
852
|
-
data-type=${row.type}
|
|
853
|
-
aria-expanded=${isDir ? String(row.expanded) : nothing}
|
|
854
|
-
@click=${async (e: MouseEvent) => {
|
|
855
|
-
e.stopPropagation();
|
|
856
|
-
if (isDir) {
|
|
857
|
-
await toggleTreeDirectory(row.path);
|
|
858
|
-
ctx.renderLeftPanel();
|
|
859
|
-
} else {
|
|
860
|
-
ctx.openFileFn(row.path);
|
|
861
|
-
}
|
|
862
|
-
}}
|
|
863
|
-
@contextmenu=${(e: MouseEvent) => {
|
|
864
|
-
e.preventDefault();
|
|
865
|
-
e.stopPropagation();
|
|
866
|
-
showFileContextMenu(e, { name: row.name, path: row.path, type: row.type }, ctx);
|
|
867
|
-
}}
|
|
868
|
-
>
|
|
869
|
-
${
|
|
870
|
-
isDir
|
|
871
|
-
? html`<span class="file-tree-toggle">${row.expanded ? "▼" : "▶"}</span>`
|
|
872
|
-
: html`<span class="file-tree-toggle empty"> </span>`
|
|
873
|
-
}
|
|
874
|
-
<span class="file-tree-icon">${fileTypeIconTpl(row.path, row.type)}</span>
|
|
875
|
-
<span class="file-tree-name">${row.name}</span>
|
|
876
|
-
${
|
|
877
|
-
row.locale === undefined
|
|
878
|
-
? nothing
|
|
879
|
-
: html`<span class="file-tree-locale">${localeLabel(row.locale)}</span>`
|
|
880
|
-
}
|
|
881
|
-
</div>
|
|
882
|
-
`;
|
|
862
|
+
_lastValues = {
|
|
863
|
+
..._lastValues,
|
|
864
|
+
dragPath: _dragPath,
|
|
865
|
+
dropPath: _dropPath,
|
|
866
|
+
rootDrop: _rootDrop,
|
|
867
|
+
};
|
|
868
|
+
_standingFiles.handle.update(_lastValues);
|
|
883
869
|
}
|
|
884
870
|
|
|
885
|
-
/**
|
|
886
|
-
|
|
871
|
+
/** Repaint the Navigator, which is what brings a new projection to the mounted document. */
|
|
872
|
+
function repaintFiles(): void {
|
|
873
|
+
_filesRerender?.();
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
// ─── The panel's own verbs ───────────────────────────────────────────────────
|
|
877
|
+
|
|
878
|
+
/** Re-read every listed directory, and the `.gitignore` rules with them. */
|
|
879
|
+
async function refreshFileTree(): Promise<void> {
|
|
887
880
|
const state = requireProjectState();
|
|
888
|
-
|
|
889
|
-
|
|
881
|
+
state.dirs.clear();
|
|
882
|
+
/* The rules go with the listings. Refresh is what an author reaches for after editing a
|
|
883
|
+
`.gitignore` by hand, and a tree that came back still hiding by the old rules would read as
|
|
884
|
+
the button not having worked. */
|
|
885
|
+
resetIgnoreCache();
|
|
886
|
+
await loadDirectory(".");
|
|
887
|
+
for (const dir of state.expanded) {
|
|
888
|
+
await loadDirectory(dir);
|
|
889
|
+
}
|
|
890
|
+
repaintFiles();
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
/**
|
|
894
|
+
* What a click or Enter on a row MEANS.
|
|
895
|
+
*
|
|
896
|
+
* One verb for both kinds of row, decided here rather than in the document: a directory opens, a
|
|
897
|
+
* file opens in a tab, and a row whose model has since gone does nothing at all.
|
|
898
|
+
*/
|
|
899
|
+
function activateFileRow(path: string): void {
|
|
900
|
+
const row = fileRowAt(path);
|
|
901
|
+
if (!row) {
|
|
890
902
|
return;
|
|
891
903
|
}
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
904
|
+
if (row.type === "directory") {
|
|
905
|
+
void toggleTreeDirectory(path).then(() => repaintFiles());
|
|
906
|
+
return;
|
|
895
907
|
}
|
|
908
|
+
void openFileInTab(path);
|
|
896
909
|
}
|
|
897
910
|
|
|
898
|
-
|
|
899
|
-
*
|
|
911
|
+
/**
|
|
912
|
+
* `jx-tree` says a row should be OPENED or CLOSED; this is what that means to a directory.
|
|
900
913
|
*
|
|
901
|
-
*
|
|
902
|
-
*
|
|
903
|
-
*
|
|
904
|
-
*
|
|
905
|
-
* binding and swaps it rather than stacking it.
|
|
914
|
+
* One entry point for the twisty, `ArrowRight` and `ArrowLeft` alike, because the element resolves
|
|
915
|
+
* all three into the state the row should be PUT INTO before it asks. The guard is still load
|
|
916
|
+
* bearing: a leaf's twisty box is drawn empty and still answers a click, so a file can arrive here
|
|
917
|
+
* asking to be expanded and must be told nothing happens.
|
|
906
918
|
*/
|
|
919
|
+
function expandFileRow(path: string, expanded: boolean): void {
|
|
920
|
+
const state = requireProjectState();
|
|
921
|
+
if (fileRowAt(path)?.type !== "directory" || state.expanded.has(path) === expanded) {
|
|
922
|
+
return;
|
|
923
|
+
}
|
|
924
|
+
if (!expanded) {
|
|
925
|
+
state.expanded.delete(path);
|
|
926
|
+
// It used to leave the repaint to "the caller who sets up keyboard", and there was no such
|
|
927
|
+
// Caller: ← changed the state and left the children on screen until something else happened to
|
|
928
|
+
// Redraw the panel.
|
|
929
|
+
repaintFiles();
|
|
930
|
+
return;
|
|
931
|
+
}
|
|
932
|
+
// The expansion repaints THROUGH the panel. It used to synthesise a click on the focused row to
|
|
933
|
+
// Get a repaint, which ran that row's own toggle a second time and only did the right thing
|
|
934
|
+
// Because the handler's captured `isExpanded` was already stale.
|
|
935
|
+
void toggleTreeDirectory(path).then(() => repaintFiles());
|
|
936
|
+
}
|
|
907
937
|
|
|
908
938
|
/**
|
|
909
|
-
* The
|
|
939
|
+
* The reader meant that row.
|
|
910
940
|
*
|
|
911
|
-
*
|
|
912
|
-
*
|
|
913
|
-
*
|
|
914
|
-
*
|
|
915
|
-
*
|
|
941
|
+
* The tree is single-select, so `jx-tree` has already resolved every modifier to one replace before
|
|
942
|
+
* this is reached. Selection follows the caret here where it used to lag behind it: the tab stop
|
|
943
|
+
* was computed FROM `selectedPath`, so an arrow key moved the focus and left the highlight on the
|
|
944
|
+
* row the reader had left.
|
|
945
|
+
*
|
|
946
|
+
* The selection is also the only thing this module remembers about where the caret IS. It does not
|
|
947
|
+
* need a second variable: `jx-tree` owns the caret and keeps it across every repaint that does not
|
|
948
|
+
* change `current`, so what the projection owes it is a SEED — a row to start on, and a row to come
|
|
949
|
+
* back to when the one it was on has gone.
|
|
916
950
|
*/
|
|
917
|
-
function
|
|
918
|
-
|
|
919
|
-
if (!focused) {
|
|
951
|
+
function selectFileRow(path: string): void {
|
|
952
|
+
if (!projectState || requireProjectState().selectedPath === path) {
|
|
920
953
|
return;
|
|
921
954
|
}
|
|
922
|
-
|
|
955
|
+
requireProjectState().selectedPath = path;
|
|
956
|
+
repaintFiles();
|
|
957
|
+
}
|
|
923
958
|
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
959
|
+
/**
|
|
960
|
+
* The caret has to reach a row the window did not draw.
|
|
961
|
+
*
|
|
962
|
+
* `jx-tree` walks the DRAWN rows and stops at the ends of the slice; when a pad says the model
|
|
963
|
+
* continues that way it dispatches this instead of performing anything, because where the row is
|
|
964
|
+
* and how far to scroll are facts about the model. Each key is answered here exactly as the element
|
|
965
|
+
* would have answered it over a slice that held everything.
|
|
966
|
+
*/
|
|
967
|
+
function moveFileCaret(from: string, key: string): void {
|
|
968
|
+
const index = fileIndexOfPath(from);
|
|
969
|
+
let target: number;
|
|
970
|
+
switch (key) {
|
|
971
|
+
case "Home": {
|
|
972
|
+
target = fileStep(-1, 1);
|
|
929
973
|
break;
|
|
930
974
|
}
|
|
931
|
-
case "
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
void toggleTreeDirectory(path).then(() => _filesRerender?.());
|
|
938
|
-
}
|
|
975
|
+
case "End": {
|
|
976
|
+
target = fileStep(_fileRows.length, -1);
|
|
977
|
+
break;
|
|
978
|
+
}
|
|
979
|
+
case "ArrowUp": {
|
|
980
|
+
target = fileStep(index, -1);
|
|
939
981
|
break;
|
|
940
982
|
}
|
|
941
983
|
case "ArrowLeft": {
|
|
942
|
-
|
|
943
|
-
if (path !== null) {
|
|
944
|
-
requireProjectState().expanded.delete(path);
|
|
945
|
-
// It used to leave the repaint to "the caller who sets up keyboard", and there was no such
|
|
946
|
-
// Caller: ← changed the state and left the children on screen until something else
|
|
947
|
-
// Happened to redraw the panel.
|
|
948
|
-
_filesRerender?.();
|
|
949
|
-
}
|
|
984
|
+
target = fileParentIndex(index);
|
|
950
985
|
break;
|
|
951
986
|
}
|
|
952
|
-
|
|
953
|
-
|
|
987
|
+
// ↓ and → both ask for the next drawn row; over the model they are the same step.
|
|
988
|
+
case "ArrowDown":
|
|
989
|
+
case "ArrowRight": {
|
|
990
|
+
target = fileStep(index, 1);
|
|
954
991
|
break;
|
|
955
992
|
}
|
|
956
993
|
default: {
|
|
957
|
-
|
|
994
|
+
return;
|
|
958
995
|
}
|
|
959
996
|
}
|
|
960
|
-
|
|
961
|
-
e.preventDefault();
|
|
962
|
-
}
|
|
997
|
+
focusFileRow(target);
|
|
963
998
|
}
|
|
964
999
|
|
|
965
|
-
/**
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
1000
|
+
/**
|
|
1001
|
+
* A printable character on a windowed tree: find the model row it names, and go there.
|
|
1002
|
+
*
|
|
1003
|
+
* `jx-tree` resolves typeahead itself only when the drawn rows ARE the model; past that it
|
|
1004
|
+
* dispatches, and the reason is sharper than the one behind `move`. A move off the end of the slice
|
|
1005
|
+
* announces itself — there is nothing to land on. A letter never does: the element's search over
|
|
1006
|
+
* the drawn rows always answers, and over `node_modules` the answer is whichever of the eleven
|
|
1007
|
+
* painted rows happened to start with that letter.
|
|
1008
|
+
*
|
|
1009
|
+
* The search is the element's own, moved onto the full list: forward from the caret, wrapping once,
|
|
1010
|
+
* matching the row's NAME — which is the string the row draws and announces, so the caret can never
|
|
1011
|
+
* land somewhere the reader was not told about — and skipping the "Loading…" placeholders, which
|
|
1012
|
+
* are not tree items and which the arrows already step over.
|
|
1013
|
+
*
|
|
1014
|
+
* @param {string} from The row the caret is on
|
|
1015
|
+
* @param {string} char The character typed, lowercased
|
|
1016
|
+
*/
|
|
1017
|
+
function typeaheadFileCaret(from: string, char: string): void {
|
|
1018
|
+
const start = fileIndexOfPath(from);
|
|
1019
|
+
const total = _fileRows.length;
|
|
1020
|
+
for (let step = 1; step <= total; step++) {
|
|
1021
|
+
const at = (start + step + total) % total;
|
|
1022
|
+
const row = _fileRows[at];
|
|
1023
|
+
if (row && !row.loading && row.name.trim().toLowerCase().startsWith(char)) {
|
|
1024
|
+
focusFileRow(at);
|
|
1025
|
+
return;
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
979
1028
|
}
|
|
980
1029
|
|
|
981
|
-
/**
|
|
982
|
-
|
|
1030
|
+
/**
|
|
1031
|
+
* Reveal the model row at `index` and put the caret on it.
|
|
1032
|
+
*
|
|
1033
|
+
* The SELECTION moves with it, and that is not a flourish: `jx-tree` raises `select` alongside
|
|
1034
|
+
* `change` on every arrow it can perform itself, so a step the window could not satisfy must not be
|
|
1035
|
+
* the one step that silently does not. It is also what moves the CARET, because the projection
|
|
1036
|
+
* seeds `currentPath` from the selection — and that write is the whole of this panel's side of the
|
|
1037
|
+
* handoff.
|
|
1038
|
+
*
|
|
1039
|
+
* **The keyboard is deliberately not touched here.** This is the answer to a `move` or a
|
|
1040
|
+
* `typeahead` the tree could not perform, and `jx-tree` keeps the keyboard across both: it focuses
|
|
1041
|
+
* the caret row once its own sync has written the roving `tabindex` onto the revealed element,
|
|
1042
|
+
* which is the only moment focusing it does anything. What this function used to do instead was
|
|
1043
|
+
* pend the path and spend the request from `onNodeCreated` — one reconcile step before the row had
|
|
1044
|
+
* a `tabindex` at all — so the `focus()` was a silent no-op and the caret jump never landed.
|
|
1045
|
+
*/
|
|
1046
|
+
function focusFileRow(index: number): void {
|
|
983
1047
|
const row = _fileRows[index];
|
|
984
1048
|
if (!row) {
|
|
985
1049
|
return;
|
|
986
1050
|
}
|
|
987
|
-
|
|
988
|
-
if (
|
|
989
|
-
|
|
1051
|
+
selectFileRow(row.path);
|
|
1052
|
+
if (fileRowElement(row.path)) {
|
|
1053
|
+
return;
|
|
1054
|
+
}
|
|
1055
|
+
revealListRow(_fileList, index, fileRowHeight());
|
|
1056
|
+
repaintFiles();
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1059
|
+
/** Expand or collapse one directory, listing it the first time it is opened. */
|
|
1060
|
+
async function toggleTreeDirectory(path: string): Promise<void> {
|
|
1061
|
+
const state = requireProjectState();
|
|
1062
|
+
if (state.expanded.has(path)) {
|
|
1063
|
+
state.expanded.delete(path);
|
|
990
1064
|
return;
|
|
991
1065
|
}
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
1066
|
+
state.expanded.add(path);
|
|
1067
|
+
if (!state.dirs.has(path)) {
|
|
1068
|
+
await loadDirectory(path);
|
|
995
1069
|
}
|
|
996
1070
|
}
|
|
997
1071
|
|
|
998
|
-
|
|
1072
|
+
// ─── Drag and drop: the island the document draws a home for ─────────────────
|
|
1073
|
+
|
|
1074
|
+
/**
|
|
1075
|
+
* What is registered against each drawn row, so it can be released when the row leaves the window.
|
|
1076
|
+
*
|
|
1077
|
+
* Keyed by the ELEMENT rather than by the path: a windowed list re-uses nodes, and the question
|
|
1078
|
+
* this map answers is "has this node's registration already been taken back", which is about the
|
|
1079
|
+
* node.
|
|
1080
|
+
*/
|
|
1081
|
+
const _rowDnd = new Map<HTMLElement, () => void>();
|
|
1082
|
+
/** What is registered against the tree itself: the project root's two drop targets, and the monitor. */
|
|
1083
|
+
let _treeDnd: { element: HTMLElement; cleanup: () => void } | null = null;
|
|
1084
|
+
/** The row being dragged, the row a drag is over, and whether the background is. */
|
|
1085
|
+
let _dragPath = "";
|
|
1086
|
+
/**
|
|
1087
|
+
* The row the pointer is over, whether or not it will take the drop.
|
|
1088
|
+
*
|
|
1089
|
+
* Two facts, not one, because the tree background is a drop target that CONTAINS every row: a
|
|
1090
|
+
* refused row still has to occlude it, or a drop the row said no to lands in the project root.
|
|
1091
|
+
* {@link _dropPath} is the row that will take the drop; this is the row that is in the way.
|
|
1092
|
+
*/
|
|
1093
|
+
let _overRow = "";
|
|
1094
|
+
let _dropPath = "";
|
|
1095
|
+
/** Whether the tree background is under the drag; {@link _rootDrop} is what that projects to. */
|
|
1096
|
+
let _overRoot = false;
|
|
1097
|
+
let _rootDrop = "";
|
|
999
1098
|
|
|
1000
1099
|
/** Whether a drag carries OS files (as opposed to a pragmatic in-app drag). */
|
|
1001
1100
|
export function isFileDrag(e: DragEvent): boolean {
|
|
@@ -1003,15 +1102,19 @@ export function isFileDrag(e: DragEvent): boolean {
|
|
|
1003
1102
|
}
|
|
1004
1103
|
|
|
1005
1104
|
/**
|
|
1006
|
-
* Attach external-file drop handling to one
|
|
1105
|
+
* Attach external-file drop handling to one element. Pragmatic-dnd only sees pragmatic sources, so
|
|
1007
1106
|
* an OS file drag needs the native listeners; `dir` is where a drop lands (the row itself for a
|
|
1008
1107
|
* directory, its parent for a file, `.` for the tree background).
|
|
1108
|
+
*
|
|
1109
|
+
* The affordance is reported rather than drawn: `setActive` writes the state the document renders
|
|
1110
|
+
* from, where this used to add and remove a class. That is the same correction the Library made — a
|
|
1111
|
+
* highlight a handler adds is a highlight another handler has to remember to take away, and a drag
|
|
1112
|
+
* that left the window never fired the handler that would have.
|
|
1009
1113
|
*/
|
|
1010
1114
|
function registerFileDropTarget(
|
|
1011
1115
|
element: HTMLElement,
|
|
1012
1116
|
dir: string,
|
|
1013
|
-
|
|
1014
|
-
renderLeftPanel: () => void,
|
|
1117
|
+
setActive: (active: boolean) => void,
|
|
1015
1118
|
): () => void {
|
|
1016
1119
|
const onDragOver = (e: DragEvent) => {
|
|
1017
1120
|
if (!isFileDrag(e)) {
|
|
@@ -1022,18 +1125,18 @@ function registerFileDropTarget(
|
|
|
1022
1125
|
if (e.dataTransfer) {
|
|
1023
1126
|
e.dataTransfer.dropEffect = "copy";
|
|
1024
1127
|
}
|
|
1025
|
-
|
|
1128
|
+
setActive(true);
|
|
1026
1129
|
};
|
|
1027
|
-
const onDragLeave = () =>
|
|
1130
|
+
const onDragLeave = () => setActive(false);
|
|
1028
1131
|
const onDrop = (e: DragEvent) => {
|
|
1029
|
-
|
|
1132
|
+
setActive(false);
|
|
1030
1133
|
const files = e.dataTransfer?.files;
|
|
1031
1134
|
if (!files?.length) {
|
|
1032
1135
|
return;
|
|
1033
1136
|
}
|
|
1034
1137
|
e.preventDefault();
|
|
1035
1138
|
e.stopPropagation();
|
|
1036
|
-
void uploadFilesToDir(files, dir,
|
|
1139
|
+
void uploadFilesToDir(files, dir, repaintFiles);
|
|
1037
1140
|
};
|
|
1038
1141
|
element.addEventListener("dragover", onDragOver);
|
|
1039
1142
|
element.addEventListener("dragleave", onDragLeave);
|
|
@@ -1045,6 +1148,72 @@ function registerFileDropTarget(
|
|
|
1045
1148
|
};
|
|
1046
1149
|
}
|
|
1047
1150
|
|
|
1151
|
+
/**
|
|
1152
|
+
* Whether the tree will move `srcPath` into `targetDir` — the ONE predicate behind every answer the
|
|
1153
|
+
* drag gives: which rows light up, which drops the monitor performs, and whether the background
|
|
1154
|
+
* offers the project root.
|
|
1155
|
+
*
|
|
1156
|
+
* Four refusals, and the third is the one nothing used to say. A directory is not a place inside
|
|
1157
|
+
* itself; an entry already in a directory (at any depth) has nowhere to go by being dropped on it;
|
|
1158
|
+
* a directory may not be moved into its own descendant, which is a rename onto a path underneath
|
|
1159
|
+
* the thing being renamed and which the tree happily offered until the server answered 500; and an
|
|
1160
|
+
* entry already directly in the target is a no-op — the case that spelled `.` for the root.
|
|
1161
|
+
*
|
|
1162
|
+
* Both sides are normalised first: `assets\logo.png` and `assets/logo.png` name one entry, and a
|
|
1163
|
+
* predicate that agreed with itself only on one of the two spellings is a predicate with a hole.
|
|
1164
|
+
*/
|
|
1165
|
+
export function canMoveInto(srcPath: string, targetDir: string): boolean {
|
|
1166
|
+
const src = srcPath.replaceAll("\\", "/");
|
|
1167
|
+
const dir = targetDir.replaceAll("\\", "/");
|
|
1168
|
+
if (!src || src === dir) {
|
|
1169
|
+
return false;
|
|
1170
|
+
}
|
|
1171
|
+
if (src.startsWith(`${dir}/`) || dir.startsWith(`${src}/`)) {
|
|
1172
|
+
return false;
|
|
1173
|
+
}
|
|
1174
|
+
return parentDir(src) !== dir;
|
|
1175
|
+
}
|
|
1176
|
+
|
|
1177
|
+
/** {@link canMoveInto} for a ROW: only a directory has an inside to move something into. */
|
|
1178
|
+
function acceptsDrop(srcPath: unknown, targetPath: string, targetType: string): boolean {
|
|
1179
|
+
return (
|
|
1180
|
+
targetType === "directory" && typeof srcPath === "string" && canMoveInto(srcPath, targetPath)
|
|
1181
|
+
);
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
/**
|
|
1185
|
+
* Say which row the drag is over and whether that row will take it, and let the document redraw.
|
|
1186
|
+
*
|
|
1187
|
+
* The root affordance is DERIVED here rather than set alongside: a drag over a row is never also a
|
|
1188
|
+
* drag over the background, and the two flags used to be written independently — so a row that
|
|
1189
|
+
* refused the drop left the tree lit up saying the project root would take it, which after the
|
|
1190
|
+
* refusal became final is no longer true either.
|
|
1191
|
+
*/
|
|
1192
|
+
function setRowUnderDrag(row: string, accepted: boolean): void {
|
|
1193
|
+
const dropPath = accepted ? row : "";
|
|
1194
|
+
if (_overRow === row && _dropPath === dropPath) {
|
|
1195
|
+
return;
|
|
1196
|
+
}
|
|
1197
|
+
_overRow = row;
|
|
1198
|
+
_dropPath = dropPath;
|
|
1199
|
+
syncRootDrop();
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1202
|
+
/** Say whether a drag is over the tree background, which is the project root. */
|
|
1203
|
+
function setRootUnderDrag(active: boolean): void {
|
|
1204
|
+
if (_overRoot === active) {
|
|
1205
|
+
return;
|
|
1206
|
+
}
|
|
1207
|
+
_overRoot = active;
|
|
1208
|
+
syncRootDrop();
|
|
1209
|
+
}
|
|
1210
|
+
|
|
1211
|
+
/** Recompute the background's affordance from the two facts, and project both. */
|
|
1212
|
+
function syncRootDrop(): void {
|
|
1213
|
+
_rootDrop = _overRoot && _overRow === "" ? "true" : "";
|
|
1214
|
+
syncFilesDragState();
|
|
1215
|
+
}
|
|
1216
|
+
|
|
1048
1217
|
/**
|
|
1049
1218
|
* Upload files into `dir` and reveal them: expand the target directory so the new entries are
|
|
1050
1219
|
* visible. The listing refresh itself runs in the shared post-upload handler.
|
|
@@ -1066,7 +1235,7 @@ export async function uploadFilesToDir(
|
|
|
1066
1235
|
|
|
1067
1236
|
/**
|
|
1068
1237
|
* Open the OS file picker and upload the choice into `dir` (the tree's "Upload Files…" item). The
|
|
1069
|
-
* input is created per invocation and discarded after — the tree
|
|
1238
|
+
* input is created per invocation and discarded after — the tree is re-rendered often.
|
|
1070
1239
|
*/
|
|
1071
1240
|
export function pickAndUploadTo(dir: string, renderLeftPanel: () => void): void {
|
|
1072
1241
|
const input = document.createElement("input");
|
|
@@ -1082,158 +1251,181 @@ export function pickAndUploadTo(dir: string, renderLeftPanel: () => void): void
|
|
|
1082
1251
|
}
|
|
1083
1252
|
|
|
1084
1253
|
/**
|
|
1085
|
-
*
|
|
1254
|
+
* Adopt one row element the document has just created: remember it, make it a drag source, and give
|
|
1255
|
+
* it the two drop behaviours its KIND earns.
|
|
1086
1256
|
*
|
|
1087
|
-
*
|
|
1257
|
+
* Every row is a source, an external-file target and an in-app target. Only a DIRECTORY accepts an
|
|
1258
|
+
* in-app drop, because a file has no inside to move something into — but a file row registers the
|
|
1259
|
+
* target anyway and refuses in its data, because a row that is not a target at all is a row the
|
|
1260
|
+
* drop falls straight through, onto the tree, which is the project root. The registration happens
|
|
1261
|
+
* as the node is created, which is the one moment at which "this element is that path" is certainly
|
|
1262
|
+
* true.
|
|
1088
1263
|
*/
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
// So dropping next to a sibling puts the upload beside it.
|
|
1126
|
-
registerFileDropTarget(
|
|
1127
|
-
row,
|
|
1128
|
-
type === "directory" ? path : parentDir(path),
|
|
1129
|
-
"drag-over",
|
|
1130
|
-
renderLeftPanel,
|
|
1131
|
-
),
|
|
1132
|
-
];
|
|
1133
|
-
|
|
1134
|
-
if (type === "directory") {
|
|
1135
|
-
cleanups.push(
|
|
1136
|
-
dropTargetForElements({
|
|
1137
|
-
canDrop({ source }) {
|
|
1138
|
-
if (source.data.type !== "file-tree") {
|
|
1139
|
-
return false;
|
|
1140
|
-
}
|
|
1141
|
-
const srcPath = source.data.path as string;
|
|
1142
|
-
if (srcPath === path) {
|
|
1143
|
-
return false;
|
|
1144
|
-
}
|
|
1145
|
-
if (srcPath.startsWith(`${path}/`)) {
|
|
1146
|
-
return false;
|
|
1147
|
-
}
|
|
1148
|
-
const srcParent = parentDir(srcPath);
|
|
1149
|
-
if (srcParent === path) {
|
|
1150
|
-
return false;
|
|
1151
|
-
}
|
|
1152
|
-
return true;
|
|
1153
|
-
},
|
|
1154
|
-
element: row,
|
|
1155
|
-
getData() {
|
|
1156
|
-
return { targetDir: path, type: "file-tree-target" };
|
|
1157
|
-
},
|
|
1158
|
-
onDrag() {
|
|
1159
|
-
if (!row.classList.contains("drag-over")) {
|
|
1160
|
-
row.classList.add("drag-over");
|
|
1161
|
-
}
|
|
1162
|
-
},
|
|
1163
|
-
onDragEnter() {
|
|
1164
|
-
row.classList.add("drag-over");
|
|
1165
|
-
},
|
|
1166
|
-
onDragLeave() {
|
|
1167
|
-
row.classList.remove("drag-over");
|
|
1168
|
-
},
|
|
1169
|
-
onDrop() {
|
|
1170
|
-
row.classList.remove("drag-over");
|
|
1171
|
-
},
|
|
1172
|
-
}),
|
|
1173
|
-
);
|
|
1174
|
-
}
|
|
1175
|
-
|
|
1176
|
-
_fileTreeDndCleanups.push(combine(...cleanups));
|
|
1177
|
-
}
|
|
1178
|
-
|
|
1179
|
-
// Root-level drop target (move to project root)
|
|
1180
|
-
const rootCleanup = dropTargetForElements({
|
|
1264
|
+
function adoptFileRow(element: HTMLElement, path: string, type: string): void {
|
|
1265
|
+
releaseRowDnD(element);
|
|
1266
|
+
_fileRowEls.set(path, element);
|
|
1267
|
+
|
|
1268
|
+
const cleanups = [
|
|
1269
|
+
draggable({
|
|
1270
|
+
element,
|
|
1271
|
+
getInitialData() {
|
|
1272
|
+
return { entryType: type, path, type: "file-tree" };
|
|
1273
|
+
},
|
|
1274
|
+
onDragStart() {
|
|
1275
|
+
_dragPath = path;
|
|
1276
|
+
syncFilesDragState();
|
|
1277
|
+
},
|
|
1278
|
+
onDrop() {
|
|
1279
|
+
_dragPath = "";
|
|
1280
|
+
setRowUnderDrag("", false);
|
|
1281
|
+
syncFilesDragState();
|
|
1282
|
+
},
|
|
1283
|
+
}),
|
|
1284
|
+
// Files dropped from the OS land in the row's own directory; a file row targets its parent so
|
|
1285
|
+
// Dropping next to a sibling puts the upload beside it.
|
|
1286
|
+
registerFileDropTarget(element, type === "directory" ? path : parentDir(path), (active) => {
|
|
1287
|
+
setRowUnderDrag(active ? path : "", active);
|
|
1288
|
+
}),
|
|
1289
|
+
/**
|
|
1290
|
+
* The in-app target — on EVERY row, accepting or not.
|
|
1291
|
+
*
|
|
1292
|
+
* A row that answered `canDrop: false` was not a drop target at all, and pragmatic-dnd
|
|
1293
|
+
* documents what happens next: "blocking dropping on a drop target will not block dropping on
|
|
1294
|
+
* child or parent drop targets". The next target up is the tree element, whose target IS the
|
|
1295
|
+
* project root — so a refused drop became a move to the root, silently, with no affordance
|
|
1296
|
+
* anywhere on screen to warn the reader it would. Answering `true` and carrying the verdict in
|
|
1297
|
+
* the DATA keeps the innermost target innermost, which is what makes a refusal final.
|
|
1298
|
+
*/
|
|
1299
|
+
dropTargetForElements({
|
|
1181
1300
|
canDrop({ source }) {
|
|
1182
|
-
|
|
1183
|
-
return false;
|
|
1184
|
-
}
|
|
1185
|
-
const srcPath = source.data.path as string;
|
|
1186
|
-
return parentDir(srcPath) !== ".";
|
|
1301
|
+
return source.data.type === "file-tree";
|
|
1187
1302
|
},
|
|
1188
|
-
element
|
|
1189
|
-
getData() {
|
|
1190
|
-
return
|
|
1303
|
+
element,
|
|
1304
|
+
getData({ source }) {
|
|
1305
|
+
return acceptsDrop(source.data.path, path, type)
|
|
1306
|
+
? { targetDir: path, type: "file-tree-target" }
|
|
1307
|
+
: { type: "file-tree-refused" };
|
|
1191
1308
|
},
|
|
1192
|
-
|
|
1193
|
-
|
|
1309
|
+
onDrag({ source }) {
|
|
1310
|
+
setRowUnderDrag(path, acceptsDrop(source.data.path, path, type));
|
|
1311
|
+
},
|
|
1312
|
+
onDragEnter({ source }) {
|
|
1313
|
+
setRowUnderDrag(path, acceptsDrop(source.data.path, path, type));
|
|
1194
1314
|
},
|
|
1195
1315
|
onDragLeave() {
|
|
1196
|
-
|
|
1316
|
+
setRowUnderDrag("", false);
|
|
1197
1317
|
},
|
|
1198
1318
|
onDrop() {
|
|
1199
|
-
|
|
1319
|
+
setRowUnderDrag("", false);
|
|
1200
1320
|
},
|
|
1201
|
-
})
|
|
1202
|
-
|
|
1203
|
-
// StopPropagation, so a drop on a row never also fires here.
|
|
1204
|
-
_fileTreeDndCleanups.push(
|
|
1205
|
-
rootCleanup,
|
|
1206
|
-
registerFileDropTarget(tree, ".", "drag-over-root", renderLeftPanel),
|
|
1207
|
-
);
|
|
1321
|
+
}),
|
|
1322
|
+
];
|
|
1208
1323
|
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
onDrop({ source, location }) {
|
|
1212
|
-
const [target] = location.current.dropTargets;
|
|
1213
|
-
if (!target) {
|
|
1214
|
-
return;
|
|
1215
|
-
}
|
|
1216
|
-
if (source.data.type !== "file-tree") {
|
|
1217
|
-
return;
|
|
1218
|
-
}
|
|
1219
|
-
if (target.data.type !== "file-tree-target") {
|
|
1220
|
-
return;
|
|
1221
|
-
}
|
|
1324
|
+
_rowDnd.set(element, combine(...cleanups));
|
|
1325
|
+
}
|
|
1222
1326
|
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1327
|
+
/** Take back everything registered against one row element. */
|
|
1328
|
+
function releaseRowDnD(element: HTMLElement): void {
|
|
1329
|
+
const cleanup = _rowDnd.get(element);
|
|
1330
|
+
if (cleanup) {
|
|
1331
|
+
cleanup();
|
|
1332
|
+
_rowDnd.delete(element);
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1227
1335
|
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1336
|
+
/**
|
|
1337
|
+
* Adopt the tree element: the window's scroller, the project root's drop target, and the monitor
|
|
1338
|
+
* that turns a completed drag into a move.
|
|
1339
|
+
*
|
|
1340
|
+
* Registered once, against the element the document created. The pass this replaced ran on every
|
|
1341
|
+
* repaint and re-registered every row from scratch, which is what made a drag mid-scroll drop its
|
|
1342
|
+
* own sources.
|
|
1343
|
+
*/
|
|
1344
|
+
function adoptFileTreeElement(element: HTMLElement): void {
|
|
1345
|
+
if (_treeDnd?.element === element) {
|
|
1346
|
+
return;
|
|
1347
|
+
}
|
|
1348
|
+
releaseFileTreeDnD();
|
|
1349
|
+
_fileList = element;
|
|
1231
1350
|
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1351
|
+
/* The background keeps an honest `canDrop`: it is the OUTERMOST target, so there is nothing
|
|
1352
|
+
inside it for a refusal here to leak to. Its affordance is suppressed while a row is under the
|
|
1353
|
+
pointer — {@link syncRootDrop} — because the row is what the drop will reach. */
|
|
1354
|
+
const rootCleanup = dropTargetForElements({
|
|
1355
|
+
canDrop({ source }) {
|
|
1356
|
+
return source.data.type === "file-tree" && canMoveInto(source.data.path as string, ".");
|
|
1357
|
+
},
|
|
1358
|
+
element,
|
|
1359
|
+
getData() {
|
|
1360
|
+
return { targetDir: ".", type: "file-tree-target" };
|
|
1361
|
+
},
|
|
1362
|
+
onDragEnter() {
|
|
1363
|
+
setRootUnderDrag(true);
|
|
1364
|
+
},
|
|
1365
|
+
onDragLeave() {
|
|
1366
|
+
setRootUnderDrag(false);
|
|
1367
|
+
},
|
|
1368
|
+
onDrop() {
|
|
1369
|
+
setRootUnderDrag(false);
|
|
1370
|
+
},
|
|
1236
1371
|
});
|
|
1372
|
+
|
|
1373
|
+
const monitorCleanup = monitorForElements({
|
|
1374
|
+
onDrop({ source, location }) {
|
|
1375
|
+
const [target] = location.current.dropTargets;
|
|
1376
|
+
if (!target) {
|
|
1377
|
+
return;
|
|
1378
|
+
}
|
|
1379
|
+
if (source.data.type !== "file-tree") {
|
|
1380
|
+
return;
|
|
1381
|
+
}
|
|
1382
|
+
/* The INNERMOST target and no other. `dropTargets` is bubble-ordered, so reading [0] and
|
|
1383
|
+
then refusing what it says is what keeps a row's "no" from becoming the tree's "yes". */
|
|
1384
|
+
if (target.data.type !== "file-tree-target") {
|
|
1385
|
+
return;
|
|
1386
|
+
}
|
|
1387
|
+
|
|
1388
|
+
const srcPath = source.data.path as string;
|
|
1389
|
+
const targetDirPath = target.data.targetDir as string;
|
|
1390
|
+
if (!canMoveInto(srcPath, targetDirPath)) {
|
|
1391
|
+
return;
|
|
1392
|
+
}
|
|
1393
|
+
const fileName = srcPath.split("/").pop();
|
|
1394
|
+
const newPath = targetDirPath === "." ? fileName : `${targetDirPath}/${fileName}`;
|
|
1395
|
+
|
|
1396
|
+
void moveFileEntry(srcPath, newPath!, repaintFiles);
|
|
1397
|
+
},
|
|
1398
|
+
});
|
|
1399
|
+
|
|
1400
|
+
_treeDnd = {
|
|
1401
|
+
cleanup: combine(
|
|
1402
|
+
rootCleanup,
|
|
1403
|
+
monitorCleanup,
|
|
1404
|
+
// The tree background is the project root's drop target for OS files. Row handlers
|
|
1405
|
+
// StopPropagation, so a drop on a row never also fires here.
|
|
1406
|
+
registerFileDropTarget(element, ".", setRootUnderDrag),
|
|
1407
|
+
),
|
|
1408
|
+
element,
|
|
1409
|
+
};
|
|
1410
|
+
adoptFileTree();
|
|
1411
|
+
}
|
|
1412
|
+
|
|
1413
|
+
/** Take back the tree's own registrations and its scroll watch. */
|
|
1414
|
+
function releaseFileTreeDnD(): void {
|
|
1415
|
+
_treeDnd?.cleanup();
|
|
1416
|
+
_treeDnd = null;
|
|
1417
|
+
for (const cleanup of _rowDnd.values()) {
|
|
1418
|
+
cleanup();
|
|
1419
|
+
}
|
|
1420
|
+
_rowDnd.clear();
|
|
1421
|
+
_fileWatch?.window.destroy();
|
|
1422
|
+
_fileWatch = null;
|
|
1423
|
+
_fileList = null;
|
|
1424
|
+
_dragPath = "";
|
|
1425
|
+
_overRow = "";
|
|
1426
|
+
_dropPath = "";
|
|
1427
|
+
_overRoot = false;
|
|
1428
|
+
_rootDrop = "";
|
|
1237
1429
|
}
|
|
1238
1430
|
|
|
1239
1431
|
/**
|
|
@@ -1297,23 +1489,11 @@ function parentDir(path: string) {
|
|
|
1297
1489
|
|
|
1298
1490
|
// ─── Context menu ─────────────────────────────────────────────────────────────
|
|
1299
1491
|
|
|
1300
|
-
let
|
|
1492
|
+
let _fileMenu: MenuHandle | null = null;
|
|
1301
1493
|
|
|
1302
|
-
function dismissFileContextMenu() {
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
_fileCtxHandle = null;
|
|
1306
|
-
}
|
|
1307
|
-
}
|
|
1308
|
-
|
|
1309
|
-
/** One row of the file menu. The divider is the em-dash label; `disabled` rows explain themselves. */
|
|
1310
|
-
interface FileMenuItem {
|
|
1311
|
-
label: string;
|
|
1312
|
-
action?: () => void;
|
|
1313
|
-
danger?: boolean;
|
|
1314
|
-
disabled?: boolean;
|
|
1315
|
-
/** The `requires` sentence, printed under a disabled row. */
|
|
1316
|
-
reason?: string;
|
|
1494
|
+
function dismissFileContextMenu(): void {
|
|
1495
|
+
_fileMenu?.close();
|
|
1496
|
+
_fileMenu = null;
|
|
1317
1497
|
}
|
|
1318
1498
|
|
|
1319
1499
|
/**
|
|
@@ -1361,6 +1541,16 @@ function fileRowFacts(entry: { path: string; type: string }): Record<string, unk
|
|
|
1361
1541
|
return facts;
|
|
1362
1542
|
}
|
|
1363
1543
|
|
|
1544
|
+
/** One of the tree's OWN verbs, as the kit menu reads a row. */
|
|
1545
|
+
function treeMenuRow(
|
|
1546
|
+
id: string,
|
|
1547
|
+
title: string,
|
|
1548
|
+
run: () => void,
|
|
1549
|
+
extra: Partial<MenuRowProjection> = {},
|
|
1550
|
+
): MenuRowProjection {
|
|
1551
|
+
return { destructive: false, disabled: false, dividerAbove: false, id, run, title, ...extra };
|
|
1552
|
+
}
|
|
1553
|
+
|
|
1364
1554
|
/**
|
|
1365
1555
|
* The declared `context/file` commands this row can offer.
|
|
1366
1556
|
*
|
|
@@ -1368,13 +1558,13 @@ function fileRowFacts(entry: { path: string; type: string }): Record<string, unk
|
|
|
1368
1558
|
* `group`), whether it is enabled and the sentence saying why not. Nothing here names a command, so
|
|
1369
1559
|
* a new `context/file` record appears in the tree with no edit to this file.
|
|
1370
1560
|
*/
|
|
1371
|
-
function
|
|
1561
|
+
function placedFileRows(entry: { path: string; type: string }): MenuRowProjection[] {
|
|
1372
1562
|
const registry = activeRegistry();
|
|
1373
1563
|
if (!registry) {
|
|
1374
1564
|
return [];
|
|
1375
1565
|
}
|
|
1376
1566
|
const facts = fileRowFacts(entry);
|
|
1377
|
-
const
|
|
1567
|
+
const rows: MenuRowProjection[] = [];
|
|
1378
1568
|
for (const command of registry.forPlacement("context/file")) {
|
|
1379
1569
|
const schema = command.args as
|
|
1380
1570
|
| { properties?: Record<string, unknown>; required?: readonly string[] }
|
|
@@ -1389,128 +1579,111 @@ function placedFileItems(entry: { path: string; type: string }): FileMenuItem[]
|
|
|
1389
1579
|
}
|
|
1390
1580
|
}
|
|
1391
1581
|
const reason = registry.disabledReason(command.id);
|
|
1392
|
-
|
|
1582
|
+
rows.push(
|
|
1393
1583
|
reason === undefined
|
|
1394
|
-
? {
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1584
|
+
? treeMenuRow(command.id, command.title, () => {
|
|
1585
|
+
void registry.run(command.id, args);
|
|
1586
|
+
})
|
|
1587
|
+
: {
|
|
1588
|
+
destructive: false,
|
|
1589
|
+
disabled: true,
|
|
1590
|
+
dividerAbove: false,
|
|
1591
|
+
id: command.id,
|
|
1592
|
+
// A disabled row says what it needs, the same sentence the palette and the agent
|
|
1593
|
+
// Print — `requires`, off the record, never re-worded here.
|
|
1594
|
+
requires: reason,
|
|
1595
|
+
title: command.title,
|
|
1596
|
+
},
|
|
1401
1597
|
);
|
|
1402
1598
|
}
|
|
1403
|
-
return
|
|
1599
|
+
return rows;
|
|
1404
1600
|
}
|
|
1405
1601
|
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
)
|
|
1411
|
-
|
|
1412
|
-
|
|
1602
|
+
/**
|
|
1603
|
+
* Everything one row can be asked to do, in the order it is offered.
|
|
1604
|
+
*
|
|
1605
|
+
* The declared rows sit between what the TREE does to a file (open it, create in it, upload to it)
|
|
1606
|
+
* and what it does to the file's existence (rename, delete) — and the boundary between the last two
|
|
1607
|
+
* groups is the `dividerAbove` on Rename, which is what the `"—"` sentinel row used to stand for.
|
|
1608
|
+
*/
|
|
1609
|
+
function fileMenuRows(entry: { name: string; path: string; type: string }): MenuRowProjection[] {
|
|
1413
1610
|
const isDir = entry.type === "directory";
|
|
1414
|
-
|
|
1415
|
-
const items: FileMenuItem[] = [];
|
|
1416
|
-
|
|
1417
|
-
if (!isDir) {
|
|
1418
|
-
items.push({ action: () => ctx.openFileFn(entry.path), label: "Open" });
|
|
1419
|
-
}
|
|
1611
|
+
const rows: MenuRowProjection[] = [];
|
|
1420
1612
|
if (isDir) {
|
|
1421
|
-
|
|
1422
|
-
{
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
label: "Upload Files\u2026",
|
|
1429
|
-
},
|
|
1613
|
+
rows.push(
|
|
1614
|
+
treeMenuRow("files.newFile", "New File\u2026", () => {
|
|
1615
|
+
void createNewFile(entry.path, repaintFiles);
|
|
1616
|
+
}),
|
|
1617
|
+
treeMenuRow("files.upload", "Upload Files\u2026", () => {
|
|
1618
|
+
pickAndUploadTo(entry.path, repaintFiles);
|
|
1619
|
+
}),
|
|
1430
1620
|
);
|
|
1431
1621
|
if (entry.path === "pages" || entry.path.endsWith("/pages")) {
|
|
1432
1622
|
// The one hand-built row left: no command declares "open the pages grid". `grid-open.ts`'s
|
|
1433
1623
|
// `collection.editInGrid` has no pages sibling, so there is nothing here to render yet.
|
|
1434
|
-
|
|
1435
|
-
|
|
1624
|
+
rows.push(
|
|
1625
|
+
treeMenuRow("files.pagesGrid", "Edit Pages in Grid", () => {
|
|
1436
1626
|
openPagesGrid();
|
|
1437
|
-
},
|
|
1438
|
-
|
|
1439
|
-
});
|
|
1627
|
+
}),
|
|
1628
|
+
);
|
|
1440
1629
|
}
|
|
1630
|
+
} else {
|
|
1631
|
+
rows.push(
|
|
1632
|
+
treeMenuRow("files.open", "Open", () => {
|
|
1633
|
+
void openFileInTab(entry.path);
|
|
1634
|
+
}),
|
|
1635
|
+
);
|
|
1441
1636
|
}
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1637
|
+
rows.push(
|
|
1638
|
+
...placedFileRows(entry),
|
|
1639
|
+
treeMenuRow(
|
|
1640
|
+
"files.rename",
|
|
1641
|
+
"Rename\u2026",
|
|
1642
|
+
() => {
|
|
1643
|
+
void renameFile(entry, repaintFiles);
|
|
1644
|
+
},
|
|
1645
|
+
{ dividerAbove: true },
|
|
1646
|
+
),
|
|
1647
|
+
treeMenuRow(
|
|
1648
|
+
"files.delete",
|
|
1649
|
+
"Delete",
|
|
1650
|
+
() => {
|
|
1651
|
+
void deleteFile(entry, repaintFiles);
|
|
1652
|
+
},
|
|
1653
|
+
{ destructive: true },
|
|
1654
|
+
),
|
|
1456
1655
|
);
|
|
1656
|
+
return rows;
|
|
1657
|
+
}
|
|
1457
1658
|
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
});
|
|
1481
|
-
})}
|
|
1482
|
-
>
|
|
1483
|
-
<sp-menu>
|
|
1484
|
-
${items.map((item) =>
|
|
1485
|
-
item.label === "\u2014"
|
|
1486
|
-
? html`<sp-menu-divider></sp-menu-divider>`
|
|
1487
|
-
: html`<sp-menu-item
|
|
1488
|
-
style=${item.danger ? "color: var(--danger)" : ""}
|
|
1489
|
-
?disabled=${item.disabled === true}
|
|
1490
|
-
aria-disabled=${item.disabled === true ? "true" : "false"}
|
|
1491
|
-
@click=${() => {
|
|
1492
|
-
if (item.disabled === true) {
|
|
1493
|
-
return;
|
|
1494
|
-
}
|
|
1495
|
-
dismissFileContextMenu();
|
|
1496
|
-
void item.action?.();
|
|
1497
|
-
}}
|
|
1498
|
-
>${item.label}${
|
|
1499
|
-
// A disabled row says what it needs, the same sentence the palette and the agent
|
|
1500
|
-
// Print — `requires`, off the record, never re-worded here.
|
|
1501
|
-
item.reason ? html`<span slot="description">Needs ${item.reason}</span>` : nothing
|
|
1502
|
-
}</sp-menu-item
|
|
1503
|
-
>`,
|
|
1504
|
-
)}
|
|
1505
|
-
</sp-menu>
|
|
1506
|
-
</sp-popover>`,
|
|
1507
|
-
{
|
|
1508
|
-
dismissOnOutsideClick: true,
|
|
1509
|
-
onDismiss: () => {
|
|
1510
|
-
_fileCtxHandle = null;
|
|
1511
|
-
},
|
|
1659
|
+
/**
|
|
1660
|
+
* Open the file menu at the pointer.
|
|
1661
|
+
*
|
|
1662
|
+
* The KIT menu, not a popover of this module's own: `openMenu()` owns the panel, the roving focus,
|
|
1663
|
+
* the typeahead, the light dismissal and Escape, and it is the answer this shell already settled on
|
|
1664
|
+
* (§8.4). What went with the `sp-popover` it replaces is the hand-written clamp — a `ref` that
|
|
1665
|
+
* measured the panel a frame after it opened and moved it back inside the viewport — because the
|
|
1666
|
+
* kit does that for every menu instead of this one doing it for itself.
|
|
1667
|
+
*/
|
|
1668
|
+
function showFileContextMenu(path: string, x: number, y: number): void {
|
|
1669
|
+
const row = fileRowAt(path);
|
|
1670
|
+
if (!row) {
|
|
1671
|
+
return;
|
|
1672
|
+
}
|
|
1673
|
+
dismissFileContextMenu();
|
|
1674
|
+
const opener = fileRowElement(path);
|
|
1675
|
+
_fileMenu = openMenu({
|
|
1676
|
+
label: "File actions",
|
|
1677
|
+
onClosed: (handle) => {
|
|
1678
|
+
if (_fileMenu === handle) {
|
|
1679
|
+
_fileMenu = null;
|
|
1680
|
+
}
|
|
1512
1681
|
},
|
|
1513
|
-
|
|
1682
|
+
opener,
|
|
1683
|
+
origin: { x, y },
|
|
1684
|
+
region: "files",
|
|
1685
|
+
rows: fileMenuRows({ name: row.name, path: row.path, type: row.type }),
|
|
1686
|
+
});
|
|
1514
1687
|
}
|
|
1515
1688
|
|
|
1516
1689
|
// ─── File CRUD ────────────────────────────────────────────────────────────────
|
|
@@ -1910,10 +2083,12 @@ function renameStatus(newName: string, report: RenameResult): string {
|
|
|
1910
2083
|
*
|
|
1911
2084
|
* The dialog above a rename states, in a modal the user has to accept, that N references "will be
|
|
1912
2085
|
* updated automatically. Nothing else changes." The engine keeps that promise for every document it
|
|
1913
|
-
* can write
|
|
1914
|
-
* deliberately no serializer,
|
|
1915
|
-
*
|
|
1916
|
-
*
|
|
2086
|
+
* can write, and it can write more than it round-trips: a `.csv` collection has a parser and
|
|
2087
|
+
* deliberately no serializer, but declares the narrower `rewrite` capability, so a reference in one
|
|
2088
|
+
* is repaired cell by cell. What is left over is a document that fails to parse, and a tag rename
|
|
2089
|
+
* inside a format with no serializer. In those `applyRename` names the file rather than dropping
|
|
2090
|
+
* it, and this is the half that makes the naming reach a person. Silence here is what turns a
|
|
2091
|
+
* stated promise into a false one.
|
|
1917
2092
|
*
|
|
1918
2093
|
* A drag-move makes no promise at all — it has no dialog — which is exactly why it needs this more,
|
|
1919
2094
|
* not less. A format CONVERSION makes the strongest promise of the three, and shares this for that
|
|
@@ -2172,13 +2347,16 @@ export async function openFileInTab(path: string, opts: OpenFileOpts = {}) {
|
|
|
2172
2347
|
await loadFormats();
|
|
2173
2348
|
let document: Record<string, unknown>;
|
|
2174
2349
|
let frontmatter: Record<string, unknown> | undefined;
|
|
2350
|
+
// The layout the JSON was written in, so a save reproduces it (`json-layout.ts`, issue 308). A
|
|
2351
|
+
// Format-class file has none: its serializer owns its layout.
|
|
2352
|
+
let layout: JsonLayout | null = null;
|
|
2175
2353
|
const format = formatForPath(path);
|
|
2176
2354
|
if (format) {
|
|
2177
2355
|
const result = await parseSourceForPath(path, content);
|
|
2178
2356
|
({ document } = result);
|
|
2179
2357
|
({ frontmatter } = result);
|
|
2180
2358
|
} else if (path.endsWith(".json")) {
|
|
2181
|
-
document =
|
|
2359
|
+
({ document, layout } = parseJsonDocument(content));
|
|
2182
2360
|
} else {
|
|
2183
2361
|
throw noFormatError(path);
|
|
2184
2362
|
}
|
|
@@ -2189,6 +2367,7 @@ export async function openFileInTab(path: string, opts: OpenFileOpts = {}) {
|
|
|
2189
2367
|
documentPath: path,
|
|
2190
2368
|
document,
|
|
2191
2369
|
...(frontmatter != null && { frontmatter }),
|
|
2370
|
+
layout,
|
|
2192
2371
|
sourceFormat: format?.name ?? null,
|
|
2193
2372
|
...(opts.paneId !== undefined && { paneId: opts.paneId }),
|
|
2194
2373
|
...(opts.preview === true && { preview: true }),
|
|
@@ -2261,7 +2440,10 @@ export async function reloadFileInTab(path: string) {
|
|
|
2261
2440
|
tab.doc.document = document;
|
|
2262
2441
|
tab.doc.content.frontmatter = frontmatter;
|
|
2263
2442
|
} else if (path.endsWith(".json")) {
|
|
2264
|
-
tab
|
|
2443
|
+
// The file changed under the tab, so its layout is whatever the new text says.
|
|
2444
|
+
const parsed = parseJsonDocument(content);
|
|
2445
|
+
tab.doc.document = parsed.document as JxMutableNode;
|
|
2446
|
+
tab.doc.layout = parsed.layout;
|
|
2265
2447
|
}
|
|
2266
2448
|
tab.doc.dirty = false;
|
|
2267
2449
|
} catch (error) {
|
|
@@ -2291,10 +2473,113 @@ export function registerFilesPanel(): void {
|
|
|
2291
2473
|
title: "Files",
|
|
2292
2474
|
level: "project",
|
|
2293
2475
|
dock: "navigator",
|
|
2294
|
-
icon: "
|
|
2295
|
-
|
|
2296
|
-
afterRender
|
|
2297
|
-
|
|
2476
|
+
icon: "folder",
|
|
2477
|
+
// The body is a document, so lit draws nothing and the mount happens against the painted DOM.
|
|
2478
|
+
// `afterRender` runs on every repaint; {@link mountFilesPanel} is idempotent.
|
|
2479
|
+
render: () => nothing,
|
|
2480
|
+
afterRender: (ctx, host) => {
|
|
2481
|
+
mountFilesPanel(host, ctx.rerender);
|
|
2298
2482
|
},
|
|
2299
2483
|
});
|
|
2300
2484
|
}
|
|
2485
|
+
|
|
2486
|
+
// ─── The mount ───────────────────────────────────────────────────────────────
|
|
2487
|
+
|
|
2488
|
+
/** Everything a control on the surface can ask for, defined once. */
|
|
2489
|
+
const FILE_ACTIONS: FilesPanelActions = {
|
|
2490
|
+
activate: activateFileRow,
|
|
2491
|
+
contextMenu: showFileContextMenu,
|
|
2492
|
+
expand: expandFileRow,
|
|
2493
|
+
move: moveFileCaret,
|
|
2494
|
+
newFile: () => {
|
|
2495
|
+
void createNewFile(".", repaintFiles);
|
|
2496
|
+
},
|
|
2497
|
+
openProject: () => {
|
|
2498
|
+
/* The DECLARED command, run through the registry — never a second opener of this surface's own
|
|
2499
|
+
(§12.5). It is the one the ⌘O chord, the palette and the status bar's PROJECT field already
|
|
2500
|
+
run, and it is the only one that knows about the picker modal and the "new window" target. */
|
|
2501
|
+
void activeRegistry()?.run("project.open");
|
|
2502
|
+
},
|
|
2503
|
+
refresh: () => {
|
|
2504
|
+
void refreshFileTree();
|
|
2505
|
+
},
|
|
2506
|
+
rowHost: adoptFileRow,
|
|
2507
|
+
search: (value) => {
|
|
2508
|
+
requireProjectState().searchQuery = value;
|
|
2509
|
+
repaintFiles();
|
|
2510
|
+
},
|
|
2511
|
+
select: selectFileRow,
|
|
2512
|
+
toggleIgnored: () => {
|
|
2513
|
+
/* A repaint and nothing else: the ignored entries were never dropped from `projectState.dirs`,
|
|
2514
|
+
only from the rows built out of it. */
|
|
2515
|
+
setShowIgnoredFiles(!showIgnoredFiles());
|
|
2516
|
+
repaintFiles();
|
|
2517
|
+
},
|
|
2518
|
+
treeHost: adoptFileTreeElement,
|
|
2519
|
+
typeahead: typeaheadFileCaret,
|
|
2520
|
+
};
|
|
2521
|
+
|
|
2522
|
+
/** The mounted document, and the node it was mounted into. */
|
|
2523
|
+
let _standingFiles: { handle: FilesPanelSurfaceHandle; host: HTMLElement } | null = null;
|
|
2524
|
+
/** The last projection, so a drag can move three fields without rebuilding the row model. */
|
|
2525
|
+
let _lastValues: FilesPanelValues | null = null;
|
|
2526
|
+
|
|
2527
|
+
/**
|
|
2528
|
+
* Draw the panel — mounting the document the first time, and re-projecting into it every time
|
|
2529
|
+
* after.
|
|
2530
|
+
*
|
|
2531
|
+
* The document goes into `.panel-content`, not into the `.panel-body` this is handed, for the
|
|
2532
|
+
* reason `panels/git-panel.ts` states: only one of them is the node lit renders this panel's body
|
|
2533
|
+
* into, and appending to the other would leave the panel drawn under whatever the Navigator paints
|
|
2534
|
+
* next.
|
|
2535
|
+
*
|
|
2536
|
+
* The repaint stays the NAVIGATOR'S. Source Control owns an `effect()` because its inputs are the
|
|
2537
|
+
* reactive `shell.git` record; the tree's inputs are a `Map` of directory listings, a `Set` of
|
|
2538
|
+
* expanded paths and a roaming setting, none of which is reactive — so `ctx.rerender` is what this
|
|
2539
|
+
* surface has always been redrawn by, and it stays that way rather than growing a second scheduler
|
|
2540
|
+
* that could disagree with it.
|
|
2541
|
+
*
|
|
2542
|
+
* @param host - The painted `.panel-body`
|
|
2543
|
+
* @param rerender - The Navigator's repaint
|
|
2544
|
+
*/
|
|
2545
|
+
export function mountFilesPanel(host: HTMLElement, rerender: () => void): void {
|
|
2546
|
+
const container = host.querySelector<HTMLElement>(".panel-content") ?? host;
|
|
2547
|
+
// Captured per paint, so the scroll watch and every awaited flow repaint through the CURRENT
|
|
2548
|
+
// Navigator scheduler rather than through a closure from an earlier one.
|
|
2549
|
+
_filesRerender = rerender;
|
|
2550
|
+
if (_standingFiles && (_standingFiles.host !== container || !_standingFiles.handle.connected())) {
|
|
2551
|
+
unmountFilesPanel();
|
|
2552
|
+
}
|
|
2553
|
+
const values = filesPanelValues();
|
|
2554
|
+
if (_standingFiles) {
|
|
2555
|
+
_standingFiles.handle.update(values);
|
|
2556
|
+
} else {
|
|
2557
|
+
const handle = mountFilesPanelSurface(container, values, FILE_ACTIONS);
|
|
2558
|
+
_standingFiles = { handle, host: container };
|
|
2559
|
+
/* The FIRST paint is the one nothing else follows, and the tree element it announces through
|
|
2560
|
+
`onNodeCreated` is still detached — the document is appended when its mount resolves. A watch
|
|
2561
|
+
armed against a detached element resolves no scroller, so the window would answer "all of
|
|
2562
|
+
them" for the life of the panel. This is where the tree is finally in the document. */
|
|
2563
|
+
void handle.ready.then(adoptFileTree);
|
|
2564
|
+
}
|
|
2565
|
+
/* One microtask later, because the projection above has only just been written: the rows reach
|
|
2566
|
+
the DOM as the scope's effects run, and a watch armed before they exist measures a tree that
|
|
2567
|
+
does not overflow yet. */
|
|
2568
|
+
queueMicrotask(adoptFileTree);
|
|
2569
|
+
}
|
|
2570
|
+
|
|
2571
|
+
/**
|
|
2572
|
+
* Take the panel down: the document, the drag registrations, the scroll watch and the row handles.
|
|
2573
|
+
*
|
|
2574
|
+
* Exported because a project close has to reach it — the tree it is showing belongs to the project
|
|
2575
|
+
* being left behind, exactly as `cleanupGitPanel` is for the working tree.
|
|
2576
|
+
*/
|
|
2577
|
+
export function unmountFilesPanel(): void {
|
|
2578
|
+
dismissFileContextMenu();
|
|
2579
|
+
_standingFiles?.handle.dispose();
|
|
2580
|
+
_standingFiles = null;
|
|
2581
|
+
_lastValues = null;
|
|
2582
|
+
releaseFileTreeDnD();
|
|
2583
|
+
_fileRowEls.clear();
|
|
2584
|
+
_fileRows = [];
|
|
2585
|
+
}
|