@jxsuite/studio 4.1.0 → 5.1.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-n6tfwnda.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-qwkm9zrf.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-vj72gqtq.js +20 -0
- package/dist/chunks/content-source-5mex4x1h.js +46 -0
- package/dist/chunks/convert-to-repeater-n64h8znc.js +639 -0
- package/dist/chunks/dialog-s890b918.js +85 -0
- package/dist/chunks/editor-3qhbg51x.js +35 -0
- package/dist/chunks/entry-commands-234hjnqw.js +42 -0
- package/dist/chunks/extension-sections-3hpcambp.js +651 -0
- package/dist/chunks/file-ops-8yhd83xr.js +47 -0
- package/dist/chunks/files-hnxqxtsg.js +72 -0
- package/dist/chunks/format-host-779sfp2n.js +40 -0
- package/dist/chunks/fs-events-b88z7g4h.js +18 -0
- package/dist/chunks/git-panel-xwj8fpab.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-syr0f9sb.js +115 -0
- package/dist/chunks/{index-wcnt3r9g.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-ff81wthn.js +30 -0
- package/dist/chunks/layers-panel-pnnghw12.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-cqhhxhhe.js +33 -0
- package/dist/chunks/menu-9p2w46gj.js +15 -0
- package/dist/chunks/menu-q99sy9rf.js +285 -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-vx9bhp1d.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-5zt840sy.js +27 -0
- package/dist/chunks/quick-search-3748564r.js +45 -0
- package/dist/chunks/references-qvvxej7h.js +26 -0
- package/dist/chunks/right-panel-eccz92qt.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-kryvsw6j.js → studio-1k325pwf.js} +48 -48
- package/dist/chunks/{studio-b55y6ewx.js → studio-1knfqgy7.js} +58 -58
- package/dist/chunks/{studio-2b946z26.js → studio-1z1kcjv4.js} +3628 -6095
- package/dist/chunks/studio-3773086z.js +111 -0
- package/dist/chunks/{studio-4r1pv6zf.js → studio-38emantv.js} +22 -5
- package/dist/chunks/{studio-x813zp48.js → studio-3rz5md06.js} +30 -30
- package/dist/chunks/{studio-ynxwkrzd.js → studio-4wbb9ct0.js} +1953 -1785
- package/dist/chunks/studio-5te5tqng.js +81 -0
- package/dist/chunks/studio-5wt9nvhd.js +4763 -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-gcye7qka.js → studio-7e11jpa9.js} +21 -21
- package/dist/chunks/{studio-q7v10cg2.js → studio-7r42c6ca.js} +17 -7
- package/dist/chunks/studio-7xnmgv66.js +13615 -0
- package/dist/chunks/studio-8scdew0e.js +258 -0
- package/dist/chunks/{studio-fbf92ckf.js → studio-93zafjcm.js} +275 -163
- package/dist/chunks/{studio-dg7zyt5x.js → studio-98b3z07n.js} +1 -1
- package/dist/chunks/studio-a79k90n9.js +1162 -0
- package/dist/chunks/studio-aj37eer3.js +422 -0
- package/dist/chunks/studio-b0k5tqgp.js +2432 -0
- package/dist/chunks/studio-b4s9eykd.js +2811 -0
- package/dist/chunks/{studio-f3wqjtk5.js → studio-d0300636.js} +5076 -18
- package/dist/chunks/{studio-b9b6t1dg.js → studio-e1f24eff.js} +5664 -5666
- package/dist/chunks/studio-e1pgga3k.js +839 -0
- package/dist/chunks/{studio-g1wdche0.js → studio-esrxgwh6.js} +80 -80
- package/dist/chunks/{studio-q43a5y9h.js → studio-g3jevyjt.js} +16 -16
- package/dist/chunks/studio-gb13095a.js +2806 -0
- package/dist/chunks/{studio-3n4ndrzh.js → studio-h4nvnjvz.js} +303 -303
- package/dist/chunks/{studio-dm19q43r.js → studio-hhvs4sdg.js} +10 -10
- package/dist/chunks/{studio-x4qkdat5.js → studio-js8nv53n.js} +1749 -2481
- package/dist/chunks/{studio-qjy2z9bv.js → studio-jxp12rnj.js} +32 -137
- package/dist/chunks/{studio-trxrabqf.js → studio-k75n7vhp.js} +527 -283
- package/dist/chunks/{studio-q9jd1a60.js → studio-kcgff4r0.js} +15 -18
- package/dist/chunks/studio-kkqkcp3d.js +17668 -0
- package/dist/chunks/studio-mhhyamxf.js +763 -0
- package/dist/chunks/{studio-cft9r4r7.js → studio-nq5yf5mp.js} +22 -22
- package/dist/chunks/{studio-685s0ytq.js → studio-nqgawfks.js} +572 -572
- package/dist/chunks/studio-nzzpvzx9.js +185 -0
- package/dist/chunks/{studio-xrapxwwc.js → studio-p1dw8wfw.js} +55 -29
- package/dist/chunks/{studio-3bqpr0zh.js → studio-pxbgypmg.js} +299 -110
- package/dist/chunks/studio-q0a3yk4n.js +33 -0
- package/dist/chunks/{studio-wcy8trfx.js → studio-q3x06vmj.js} +23 -22
- package/dist/chunks/{studio-6yw4y3my.js → studio-qhhm6hbt.js} +8 -8
- package/dist/chunks/studio-qk4bfsq2.js +362 -0
- package/dist/chunks/{studio-msd847zn.js → studio-qk90fgqm.js} +361 -90
- package/dist/chunks/{studio-jkftxyvz.js → studio-r6nvacqs.js} +5861 -2154
- package/dist/chunks/{studio-53n8bp04.js → studio-r6xmmtfh.js} +1 -1
- package/dist/chunks/{studio-tvgyw9xw.js → studio-rnyf3f8e.js} +83 -250
- package/dist/chunks/studio-rs76k67r.js +12 -0
- package/dist/chunks/studio-sbjyc8bt.js +954 -0
- package/dist/chunks/{studio-1wagb550.js → studio-syg2tadj.js} +11 -11
- package/dist/chunks/{studio-t5wqwzdh.js → studio-tjjk7jvk.js} +1 -1
- package/dist/chunks/studio-tqgryxwg.js +1171 -0
- package/dist/chunks/studio-try13h8c.js +8448 -0
- package/dist/chunks/studio-vfq8qpjt.js +1219 -0
- package/dist/chunks/studio-vhv5tgxm.js +51 -0
- package/dist/chunks/{studio-ahn3pdgx.js → studio-vw7mzp6z.js} +52 -38
- package/dist/chunks/studio-wqpngpsk.js +174 -0
- package/dist/chunks/studio-wqz6dggm.js +1356 -0
- package/dist/chunks/{studio-92ab2jqe.js → studio-y9zedyjn.js} +14 -14
- package/dist/chunks/studio-yxa81f45.js +12 -0
- package/dist/chunks/studio-zdn2g6dt.js +148 -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-t55jdjbx.js +69 -0
- package/dist/chunks/{ws-client-6shc5rze.js → ws-client-ny4zc51r.js} +20 -22
- package/dist/iframe-entry.js +1873 -673
- package/dist/studio.js +52757 -36535
- 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/index.html +1 -0
- package/package.json +18 -52
- package/src/about/about-modal.ts +72 -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 +333 -113
- 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 +404 -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 +177 -10
- package/src/commands/run-reported.ts +120 -0
- 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 +76 -49
- package/src/editor/slash-menu.ts +150 -157
- package/src/files/components.ts +39 -0
- package/src/files/file-ops.ts +117 -11
- package/src/files/files.ts +944 -660
- package/src/files/json-layout.ts +474 -0
- 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/layout.ts +2 -0
- package/src/i18n/i18n-commands.ts +137 -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 +181 -252
- package/src/new-project/location-fields.ts +93 -160
- package/src/new-project/new-project-modal.ts +376 -367
- package/src/packages/jxsuite-update.ts +76 -18
- package/src/packages/pull-package-sync.ts +5 -1
- 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 -163
- package/src/panels/ai-chat/sessions-view.ts +31 -62
- package/src/panels/ai-panel.ts +213 -185
- package/src/panels/block-action-bar.ts +444 -645
- 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 +148 -135
- package/src/panels/imports-panel.ts +388 -414
- package/src/panels/jump-bar.ts +175 -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 +181 -99
- package/src/panels/properties-panel.ts +1525 -966
- package/src/panels/provenance.ts +31 -113
- package/src/panels/quick-search.ts +223 -184
- package/src/panels/right-panel.ts +135 -169
- package/src/panels/seo-modal.ts +346 -167
- package/src/panels/settings-menu.ts +114 -661
- 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 +386 -288
- package/src/platforms/cloud.ts +106 -16
- 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 +134 -328
- package/src/services/a11y-report.ts +100 -43
- package/src/services/ai-command-tools.ts +538 -0
- package/src/services/ai-project-tools.ts +8 -2
- package/src/services/ai-session-store.ts +6 -0
- package/src/services/ai-system-prompt.ts +112 -24
- package/src/services/ai-tools.ts +36 -212
- package/src/services/ai-write-report.ts +174 -0
- package/src/services/document-assistant.ts +59 -8
- 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 +6 -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 +1 -1
- package/src/settings/preferences-dialog.ts +350 -330
- 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 +104 -69
- 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 +985 -0
- package/src/{panels/toolbar.ts → surfaces/commandbar.ts} +417 -391
- 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 +164 -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 +111 -21
- package/src/tabs/tab.ts +52 -1
- package/src/types.ts +22 -0
- package/src/ui/ai-credentials-form.ts +104 -100
- package/src/ui/ai-managed-connect.ts +54 -36
- package/src/ui/ai-model-picker.ts +75 -47
- package/src/ui/cf-account-picker.ts +76 -141
- 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 +296 -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 +75 -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 -1568
- package/styles/tokens.css +65 -136
- package/styles/tokens.json +84 -0
- package/dist/chunks/Overlay.dev-etqjwyf9.js +0 -23
- package/dist/chunks/adapter-jkcyhgtr.js +0 -14
- package/dist/chunks/cf-account-picker-en86v7x7.js +0 -163
- package/dist/chunks/cf-settings-45fgyx8y.js +0 -21
- package/dist/chunks/components-zmx10t62.js +0 -21
- package/dist/chunks/content-source-48xg86wj.js +0 -49
- package/dist/chunks/convert-to-repeater-43tfn7cs.js +0 -268
- package/dist/chunks/editor-cptq5jp1.js +0 -37
- package/dist/chunks/entry-commands-e63f1xc0.js +0 -46
- package/dist/chunks/extension-sections-txv08xxg.js +0 -311
- package/dist/chunks/file-ops-wbh4hhsx.js +0 -48
- package/dist/chunks/files-3kfkwhk4.js +0 -93
- package/dist/chunks/flow-qbfgrpeh.js +0 -634
- package/dist/chunks/focus-trap.esm-9t2drp0g.js +0 -1025
- package/dist/chunks/focus-visible-6eg70z18.js +0 -167
- package/dist/chunks/format-host-w16q81tf.js +0 -43
- package/dist/chunks/fs-events-hrrg328g.js +0 -21
- package/dist/chunks/git-panel-532whr1y.js +0 -59
- package/dist/chunks/index-zqxmqxmh.js +0 -109
- package/dist/chunks/jx-validate-8er6gbxy.js +0 -19
- package/dist/chunks/layers-panel-07hm7g5j.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-v9st96ja.js +0 -29
- package/dist/chunks/quick-search-zccjp6gv.js +0 -66
- package/dist/chunks/references-3qx8fkyp.js +0 -29
- package/dist/chunks/right-panel-vm3b6kwy.js +0 -46
- package/dist/chunks/section-registry-sx1ykvkw.js +0 -30
- package/dist/chunks/sp-overlay.dev-qgvhnxf4.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-4sastdnw.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-0bq6eh7v.js +0 -12
- package/dist/chunks/studio-18j3bmcz.js +0 -14
- package/dist/chunks/studio-1ngbejft.js +0 -181
- package/dist/chunks/studio-4b5z1x43.js +0 -424
- package/dist/chunks/studio-4n2b5gzb.js +0 -357
- package/dist/chunks/studio-4rzyrtjz.js +0 -426
- package/dist/chunks/studio-5fx3g9jg.js +0 -4325
- package/dist/chunks/studio-5myknm0a.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-950k0dx6.js +0 -6939
- package/dist/chunks/studio-9n4mrmnb.js +0 -184
- package/dist/chunks/studio-a0tswy0w.js +0 -58
- package/dist/chunks/studio-ahnzd9rg.js +0 -23
- package/dist/chunks/studio-bgxt93ga.js +0 -62
- package/dist/chunks/studio-cmb03bg5.js +0 -13890
- package/dist/chunks/studio-d1ks410h.js +0 -175
- package/dist/chunks/studio-ef49pnzx.js +0 -387
- package/dist/chunks/studio-eqq1w638.js +0 -113
- package/dist/chunks/studio-ew0djmhg.js +0 -341
- package/dist/chunks/studio-gfgb8pe6.js +0 -1652
- package/dist/chunks/studio-h4rxscfc.js +0 -10
- package/dist/chunks/studio-jc994dnr.js +0 -1066
- package/dist/chunks/studio-kyh9avvv.js +0 -28
- package/dist/chunks/studio-m3hwn7y1.js +0 -120
- package/dist/chunks/studio-mtfnaqs9.js +0 -659
- package/dist/chunks/studio-n6j9t10q.js +0 -318
- package/dist/chunks/studio-n8b9wqwy.js +0 -291
- package/dist/chunks/studio-qcy05dp8.js +0 -1743
- package/dist/chunks/studio-qq6jym04.js +0 -53
- 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-z6nw2ek2.js +0 -18
- package/dist/chunks/studio-zczps70q.js +0 -378
- package/dist/chunks/studio-zqazsct2.js +0 -1823
- package/dist/chunks/workspace-fjx52ryv.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";
|
|
@@ -62,8 +73,11 @@ import {
|
|
|
62
73
|
import { openCsvGridTab, openPagesGrid } from "../grid/grid-open";
|
|
63
74
|
import { isViewableMedia, openMediaTab } from "../media/media-open";
|
|
64
75
|
import { activeRegistry } from "../commands/active-registry";
|
|
76
|
+
import { runActiveReported, runReported } from "../commands/run-reported";
|
|
65
77
|
import { collectionOfPath } from "../content/entry-model";
|
|
66
78
|
import { confirmFileDelete, parseSourceForPath, renamePromptMessage } from "./file-ops";
|
|
79
|
+
import { parseJsonDocument } from "./json-layout";
|
|
80
|
+
import type { JsonLayout } from "./json-layout";
|
|
67
81
|
import { invalidateUsages } from "../services/references";
|
|
68
82
|
import {
|
|
69
83
|
documentExtensions,
|
|
@@ -80,31 +94,21 @@ import { markSessionRestored, persistedSession, resetProjectShell, setActivityTa
|
|
|
80
94
|
import { restoreSession } from "../workspace/session";
|
|
81
95
|
import { cleanupGitPanel } from "../panels/git-panel";
|
|
82
96
|
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";
|
|
97
|
+
import { listWindow, revealListRow, watchListWindow } from "../ui/virtual-window";
|
|
90
98
|
import type { JxMutableNode } from "@jxsuite/schema/types";
|
|
91
99
|
import type { ResolvedI18n } from "@jxsuite/schema/locale";
|
|
92
|
-
import type { ChoiceOption } from "../ui/
|
|
100
|
+
import type { ChoiceOption } from "../ui/layers";
|
|
101
|
+
import { emptyFilesPanelValues, mountFilesPanelSurface } from "../surfaces/files-panel";
|
|
102
|
+
import { openMenu } from "../surfaces/menu";
|
|
103
|
+
import type {
|
|
104
|
+
FileRowView,
|
|
105
|
+
FilesPanelActions,
|
|
106
|
+
FilesPanelSurfaceHandle,
|
|
107
|
+
FilesPanelValues,
|
|
108
|
+
} from "../surfaces/files-panel";
|
|
109
|
+
import type { MenuHandle, MenuRowProjection } from "../surfaces/menu";
|
|
93
110
|
import type { DirEntry, RenameResult } from "../types";
|
|
94
111
|
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
112
|
|
|
109
113
|
// ─── File management ──────────────────────────────────────────────────────────
|
|
110
114
|
|
|
@@ -416,160 +420,66 @@ export async function openLastSessionOrHome(): Promise<boolean> {
|
|
|
416
420
|
return false;
|
|
417
421
|
}
|
|
418
422
|
|
|
419
|
-
// ───
|
|
423
|
+
// ─── Row icons ────────────────────────────────────────────────────────────────
|
|
420
424
|
|
|
421
|
-
|
|
422
|
-
|
|
425
|
+
/**
|
|
426
|
+
* The kit glyph one row draws, by NAME rather than by tag.
|
|
427
|
+
*
|
|
428
|
+
* It used to be a map of six `sp-icon-*` templates built once at module load, which is a
|
|
429
|
+
* `TemplateResult` per icon whether or not the tree was ever opened. A name is a string the
|
|
430
|
+
* document hands `jx-icon`, and the manifest is what resolves it — so a row costs nothing until it
|
|
431
|
+
* is drawn, and `scripts/check-icons.ts` checks the key against the same manifest the rail's does.
|
|
432
|
+
*/
|
|
433
|
+
function fileIconName(name: string, type: string, expanded: boolean): string {
|
|
423
434
|
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
|
-
}
|
|
435
|
+
return expanded ? "folder-open" : "folder";
|
|
436
|
+
}
|
|
437
|
+
const ext = name.split(".").pop()?.toLowerCase();
|
|
438
|
+
switch (ext) {
|
|
439
|
+
case "css":
|
|
440
|
+
case "js":
|
|
441
|
+
case "json":
|
|
442
|
+
case "ts": {
|
|
443
|
+
return "file-code";
|
|
444
|
+
}
|
|
445
|
+
case "md": {
|
|
446
|
+
return "file-text";
|
|
447
|
+
}
|
|
448
|
+
default: {
|
|
449
|
+
// Every image extension the media layer knows about, so an uploaded .avif/.ico gets the
|
|
450
|
+
// Same icon as a .png instead of falling through to the generic document glyph.
|
|
451
|
+
return ext !== undefined && isImage(ext) ? "image" : "file";
|
|
451
452
|
}
|
|
452
453
|
}
|
|
453
|
-
return fileIconMap[tag] || fileIconMap["sp-icon-document"];
|
|
454
454
|
}
|
|
455
455
|
|
|
456
456
|
/**
|
|
457
|
-
*
|
|
457
|
+
* The Navigator no longer draws this panel with lit.
|
|
458
|
+
*
|
|
459
|
+
* The record below returns `nothing` and mounts `surfaces/files-panel.json` in `afterRender`, so
|
|
460
|
+
* this is a stub: it survives only because `NavigatorPanelDeps` still declares the injection and
|
|
461
|
+
* `studio.ts` still passes it. Both go in the change that deletes this.
|
|
458
462
|
*
|
|
459
|
-
* @
|
|
460
|
-
* openProject: () => void;
|
|
461
|
-
* openFileFromTree: (path: string) => void;
|
|
462
|
-
* renderLeftPanel: () => void;
|
|
463
|
-
* }} ctx
|
|
463
|
+
* @deprecated The panel is `surfaces/files-panel.json`; call {@link mountFilesPanel}.
|
|
464
464
|
*/
|
|
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();
|
|
465
|
+
export function renderFilesTemplate(): typeof nothing {
|
|
466
|
+
return nothing;
|
|
467
|
+
}
|
|
487
468
|
|
|
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
|
-
`;
|
|
469
|
+
/**
|
|
470
|
+
* Drag-and-drop is registered against the row elements the DOCUMENT creates, as they are created.
|
|
471
|
+
*
|
|
472
|
+
* The pass this replaced ran on a `requestAnimationFrame` after every repaint, found the tree and
|
|
473
|
+
* its rows by class, and re-registered every one of them — which is exactly the acquisition
|
|
474
|
+
* `studio-ui-guidelines.md` §9.4 objects to, and which a WINDOWED list makes wrong rather than
|
|
475
|
+
* merely wasteful: the rows are re-used for different files as the window slides, so a pass that
|
|
476
|
+
* arrives one frame late hands a file's drag source to whichever file is standing in its place.
|
|
477
|
+
* {@link mountFilesPanel} adopts each row through `onNodeCreated` instead.
|
|
478
|
+
*
|
|
479
|
+
* @deprecated Registration is `onNodeCreated`; this exists for the deps entry alone.
|
|
480
|
+
*/
|
|
481
|
+
export function registerFileTreeDnD(_ctx: { renderLeftPanel: () => void }): void {
|
|
482
|
+
// Intentionally nothing: see the note above.
|
|
573
483
|
}
|
|
574
484
|
|
|
575
485
|
// ─── The row model, and the window onto it ───────────────────────────────────
|
|
@@ -583,7 +493,7 @@ export function renderFilesTemplate({
|
|
|
583
493
|
*/
|
|
584
494
|
interface FileRow {
|
|
585
495
|
/**
|
|
586
|
-
*
|
|
496
|
+
* The `$map` key the document reconciles by.
|
|
587
497
|
*
|
|
588
498
|
* Keyed, where the recursive form was positional: a windowed list re-uses its DOM nodes for
|
|
589
499
|
* DIFFERENT rows as the window slides, so positional reuse would leave the keyboard focused on an
|
|
@@ -613,7 +523,7 @@ interface FileRow {
|
|
|
613
523
|
}
|
|
614
524
|
|
|
615
525
|
/**
|
|
616
|
-
* The declared height of one row —
|
|
526
|
+
* The declared height of one row — the `--jx-control-h` the document gives `[part="row"]`.
|
|
617
527
|
*
|
|
618
528
|
* The first paint of a session windows by this constant, because nothing has been laid out yet to
|
|
619
529
|
* measure; {@link fileRowHeight} measures a real row from then on and believes the measurement.
|
|
@@ -622,18 +532,58 @@ export const FILE_ROW_HEIGHT = 24;
|
|
|
622
532
|
|
|
623
533
|
/** The rows the tree last built, in display order. */
|
|
624
534
|
let _fileRows: FileRow[] = [];
|
|
625
|
-
/** The
|
|
535
|
+
/** The tree element, adopted through the document's `onNodeCreated` so it is never re-found. */
|
|
626
536
|
let _fileList: HTMLElement | null = null;
|
|
537
|
+
/**
|
|
538
|
+
* Every DRAWN row's element, by path.
|
|
539
|
+
*
|
|
540
|
+
* Held rather than queried, which is the §9.4 rule and, for a windowed list, the only correct
|
|
541
|
+
* answer: the nodes are re-used for different files as the window slides, so a selector run a frame
|
|
542
|
+
* later resolves to whichever file is standing there now. Entries whose element has left the
|
|
543
|
+
* document are swept on the next projection.
|
|
544
|
+
*/
|
|
545
|
+
const _fileRowEls = new Map<string, HTMLElement>();
|
|
627
546
|
/** The scroll watch that repaints the tree as its scroller moves. */
|
|
628
547
|
let _fileWatch: ListWindowWatch | null = null;
|
|
629
548
|
/** The Navigator repaint, captured per render so the scroll watch never holds a stale one. */
|
|
630
549
|
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
550
|
|
|
634
|
-
/**
|
|
551
|
+
/**
|
|
552
|
+
* The height one row actually has; the declared constant until a row has been laid out.
|
|
553
|
+
*
|
|
554
|
+
* Measured off a row this module already holds. The DECLARED height is what lets the FIRST render
|
|
555
|
+
* window anything at all, before any row exists; the MEASUREMENT is what stops that constant
|
|
556
|
+
* becoming a lie the day the density setting changes it, a user zooms, or a locale's font raises
|
|
557
|
+
* the line box.
|
|
558
|
+
*/
|
|
635
559
|
function fileRowHeight(): number {
|
|
636
|
-
|
|
560
|
+
for (const el of _fileRowEls.values()) {
|
|
561
|
+
if (el.isConnected && el.offsetHeight > 0) {
|
|
562
|
+
return el.offsetHeight;
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
return FILE_ROW_HEIGHT;
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
/** Forget the rows the window has taken away, and release what was registered against them. */
|
|
569
|
+
function sweepRowElements(): void {
|
|
570
|
+
for (const [path, el] of _fileRowEls) {
|
|
571
|
+
if (!el.isConnected) {
|
|
572
|
+
_fileRowEls.delete(path);
|
|
573
|
+
releaseRowDnD(el);
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
/** The rendered row for a path, or null when the window does not currently hold it. */
|
|
579
|
+
function fileRowElement(path: string): HTMLElement | null {
|
|
580
|
+
const el = _fileRowEls.get(path);
|
|
581
|
+
return el?.isConnected === true ? el : null;
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
/** The model row for a path, or undefined. A "Loading…" row is keyed apart and never matches. */
|
|
585
|
+
function fileRowAt(path: string): FileRow | undefined {
|
|
586
|
+
return _fileRows.find((row) => !row.loading && row.path === path);
|
|
637
587
|
}
|
|
638
588
|
|
|
639
589
|
/**
|
|
@@ -646,12 +596,11 @@ function collectFileRows(
|
|
|
646
596
|
dirPath: string,
|
|
647
597
|
depth: number,
|
|
648
598
|
rows: FileRow[],
|
|
649
|
-
ctx: { renderLeftPanel: () => void },
|
|
650
599
|
i18n: ResolvedI18n | null,
|
|
651
600
|
): void {
|
|
652
601
|
const entries = requireProjectState().dirs.get(dirPath);
|
|
653
602
|
if (!entries) {
|
|
654
|
-
void loadDirectory(dirPath).then(() =>
|
|
603
|
+
void loadDirectory(dirPath).then(() => repaintFiles());
|
|
655
604
|
rows.push({
|
|
656
605
|
depth,
|
|
657
606
|
expanded: false,
|
|
@@ -705,7 +654,7 @@ function collectFileRows(
|
|
|
705
654
|
type: entry.type,
|
|
706
655
|
});
|
|
707
656
|
if (isExpanded) {
|
|
708
|
-
collectFileRows(entry.path, depth + 1, rows,
|
|
657
|
+
collectFileRows(entry.path, depth + 1, rows, i18n);
|
|
709
658
|
}
|
|
710
659
|
}
|
|
711
660
|
}
|
|
@@ -725,277 +674,428 @@ function fileStep(index: number, step: 1 | -1): number {
|
|
|
725
674
|
return -1;
|
|
726
675
|
}
|
|
727
676
|
|
|
677
|
+
/**
|
|
678
|
+
* The row at `index`'s parent: the nearest row above it at a shallower depth; -1 at the top level.
|
|
679
|
+
*
|
|
680
|
+
* Over the MODEL, which is the whole reason `jx-tree` asks rather than answering. The element's own
|
|
681
|
+
* `ArrowLeft` climbs to the nearest DRAWN row at a shallower level, and a directory whose contents
|
|
682
|
+
* fill the viewport is precisely the case where its own row is the one scrolled off the top.
|
|
683
|
+
*/
|
|
684
|
+
function fileParentIndex(index: number): number {
|
|
685
|
+
const row = _fileRows[index];
|
|
686
|
+
if (!row) {
|
|
687
|
+
return -1;
|
|
688
|
+
}
|
|
689
|
+
for (let i = index - 1; i >= 0; i--) {
|
|
690
|
+
const above = _fileRows[i]!;
|
|
691
|
+
if (!above.loading && above.depth < row.depth) {
|
|
692
|
+
return i;
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
return -1;
|
|
696
|
+
}
|
|
697
|
+
|
|
728
698
|
/**
|
|
729
699
|
* Repaint the tree because its window changed.
|
|
730
700
|
*
|
|
731
|
-
* Deferred to a microtask so a scroll arriving mid-commit cannot re-enter the
|
|
732
|
-
* rows, and skipped during a drag:
|
|
733
|
-
*
|
|
701
|
+
* Deferred to a microtask so a scroll arriving mid-commit cannot re-enter the projection producing
|
|
702
|
+
* the rows, and skipped during a drag: a window that slid under pragmatic-dnd would hand its
|
|
703
|
+
* registrations to a different set of rows halfway through the gesture. `_dragPath` is what says a
|
|
704
|
+
* drag is in flight — a state this module holds, where it used to be a class on a node it then had
|
|
705
|
+
* to go and look for.
|
|
734
706
|
*/
|
|
735
707
|
function fileWindowChanged(): void {
|
|
736
|
-
if (_fileList?.isConnected !== true ||
|
|
708
|
+
if (_fileList?.isConnected !== true || _dragPath !== "") {
|
|
737
709
|
return;
|
|
738
710
|
}
|
|
739
|
-
queueMicrotask(
|
|
711
|
+
queueMicrotask(repaintFiles);
|
|
740
712
|
}
|
|
741
713
|
|
|
742
714
|
/**
|
|
743
|
-
* Adopt the
|
|
744
|
-
* the row a jump asked for once that row exists.
|
|
715
|
+
* Adopt the tree: keep it watching whatever scrolls it.
|
|
745
716
|
*
|
|
746
|
-
*
|
|
747
|
-
*
|
|
748
|
-
*
|
|
749
|
-
*
|
|
717
|
+
* Called after every projection rather than once at mount, and that is not belt-and-braces. The
|
|
718
|
+
* tree element is created ONE time — the document re-uses it for the life of the panel — and at
|
|
719
|
+
* that instant it holds no rows, so it does not yet overflow and `watchListWindow` correctly
|
|
720
|
+
* resolves no scroller at all. The first paint draws every row, because nothing can be measured
|
|
721
|
+
* before it exists; the watch's opening measurement is what asks for the second, windowed pass.
|
|
722
|
+
* Idempotent by construction — `watchListWindow` hands back the same watch for the same element and
|
|
723
|
+
* scroller — so calling it again costs a comparison.
|
|
750
724
|
*/
|
|
751
|
-
function adoptFileTree(
|
|
752
|
-
|
|
725
|
+
function adoptFileTree(): void {
|
|
726
|
+
const tree = _fileList;
|
|
727
|
+
if (tree === null) {
|
|
728
|
+
return;
|
|
729
|
+
}
|
|
753
730
|
_fileWatch = watchListWindow(_fileWatch, tree, {
|
|
754
731
|
count: () => _fileRows.length,
|
|
755
732
|
onChange: fileWindowChanged,
|
|
756
733
|
rowHeight: fileRowHeight,
|
|
757
734
|
});
|
|
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
735
|
}
|
|
766
736
|
|
|
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
|
-
}
|
|
737
|
+
// ─── What the document draws ─────────────────────────────────────────────────
|
|
777
738
|
|
|
778
|
-
/**
|
|
779
|
-
function
|
|
780
|
-
|
|
739
|
+
/** One model row, as the document reads it: every field a string, and nothing left to decide. */
|
|
740
|
+
function fileRowView(row: FileRow): FileRowView {
|
|
741
|
+
const level = String(row.depth + 1);
|
|
742
|
+
if (row.loading) {
|
|
743
|
+
return {
|
|
744
|
+
ariaExpanded: "",
|
|
745
|
+
depth: String(row.depth),
|
|
746
|
+
icon: "",
|
|
747
|
+
key: row.key,
|
|
748
|
+
kind: "loading",
|
|
749
|
+
level,
|
|
750
|
+
locale: "",
|
|
751
|
+
localeState: "hidden",
|
|
752
|
+
name: row.name,
|
|
753
|
+
path: row.path,
|
|
754
|
+
posInSet: "",
|
|
755
|
+
setSize: "",
|
|
756
|
+
type: row.type,
|
|
757
|
+
};
|
|
758
|
+
}
|
|
759
|
+
/* `""` for a file, and it is not "no answer": an empty `expanded` is what tells `jx-tree-item` the
|
|
760
|
+
row is a LEAF, so it draws no twisty, writes no `aria-expanded`, and `ArrowRight` on it does
|
|
761
|
+
nothing rather than stepping into a directory the row does not have. */
|
|
762
|
+
const isDir = row.type === "directory";
|
|
763
|
+
return {
|
|
764
|
+
ariaExpanded: isDir ? String(row.expanded) : "",
|
|
765
|
+
depth: String(row.depth),
|
|
766
|
+
icon: fileIconName(row.path, row.type, row.expanded),
|
|
767
|
+
key: row.key,
|
|
768
|
+
kind: "item",
|
|
769
|
+
level,
|
|
770
|
+
locale: row.locale === undefined ? "" : localeLabel(row.locale),
|
|
771
|
+
localeState: row.locale === undefined ? "hidden" : "shown",
|
|
772
|
+
name: row.name,
|
|
773
|
+
path: row.path,
|
|
774
|
+
posInSet: String(row.posInSet),
|
|
775
|
+
setSize: String(row.setSize),
|
|
776
|
+
type: row.type,
|
|
777
|
+
};
|
|
781
778
|
}
|
|
782
779
|
|
|
783
780
|
/**
|
|
784
|
-
*
|
|
781
|
+
* Everything the Files document draws right now.
|
|
785
782
|
*
|
|
786
|
-
*
|
|
787
|
-
*
|
|
783
|
+
* Three shapes, discriminated by one word, because "there is no project", "this is a monorepo root
|
|
784
|
+
* that has not been pointed at a site" and "here is a tree" are three different things to say and
|
|
785
|
+
* the first two have different offers. The rows are the WINDOW, and the scroll of everything either
|
|
786
|
+
* side of it is reserved by the two spacers — so the array this hands over is a dozen rows whether
|
|
787
|
+
* the project holds twelve files or ten thousand.
|
|
788
788
|
*/
|
|
789
|
-
function
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
789
|
+
function filesPanelValues(): FilesPanelValues {
|
|
790
|
+
sweepRowElements();
|
|
791
|
+
if (!projectState) {
|
|
792
|
+
_fileRows = [];
|
|
793
|
+
const values: FilesPanelValues = { ...emptyFilesPanelValues(), view: "none" };
|
|
794
|
+
_lastValues = values;
|
|
795
|
+
return values;
|
|
796
|
+
}
|
|
797
|
+
if (!projectState.isSiteProject && projectState.projectRoot === ".") {
|
|
798
|
+
_fileRows = [];
|
|
799
|
+
const values: FilesPanelValues = { ...emptyFilesPanelValues(), view: "welcome" };
|
|
800
|
+
_lastValues = values;
|
|
801
|
+
return values;
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
const state = requireProjectState();
|
|
796
805
|
_fileRows = [];
|
|
797
|
-
// Resolved once for the whole tree, not once per row: this
|
|
806
|
+
// Resolved once for the whole tree, not once per row: this runs on EVERY repaint of the
|
|
798
807
|
// Navigator, and `resolveI18n` canonicalizes every declared tag through `Intl.Locale`.
|
|
799
|
-
const { i18n } = resolveI18n(
|
|
800
|
-
collectFileRows(".", 0, _fileRows,
|
|
801
|
-
// Windowed against the
|
|
802
|
-
//
|
|
808
|
+
const { i18n } = resolveI18n(state.projectConfig ?? {});
|
|
809
|
+
collectFileRows(".", 0, _fileRows, i18n);
|
|
810
|
+
// Windowed against the element the document holds, which is the only one that exists while this
|
|
811
|
+
// Is being built. There is none before the first mount, and `listWindow` then answers "all of
|
|
812
|
+
// Them".
|
|
803
813
|
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
|
-
|
|
814
|
+
const drawn = _fileRows.slice(range.start, range.end);
|
|
815
|
+
/* The caret is a SEED, not a clamp. `jx-tree` owns it, keeps it across every repaint that does
|
|
816
|
+
not change `current`, and falls back to the first drawn row for the TAB STOP on its own — so a
|
|
817
|
+
reader whose row has scrolled three hundred rows away keeps their place and still has a way
|
|
818
|
+
back in with Tab. What this replaced recomputed the stop from the selection on every paint and
|
|
819
|
+
clamped it into the window, which moved the reader on a wheel.
|
|
820
|
+
|
|
821
|
+
It must still NAME a row, and the fallback is what guarantees it rather than tidiness: `move`
|
|
822
|
+
reports the caret's own row as `from`, and a tree nobody has touched would report `""` and send
|
|
823
|
+
every ↓ off the bottom of the window back to the first row of the project. */
|
|
824
|
+
const caret =
|
|
825
|
+
(state.selectedPath !== null && fileRowAt(state.selectedPath) ? state.selectedPath : "") ||
|
|
826
|
+
drawn.find((row) => !row.loading)?.path ||
|
|
827
|
+
"";
|
|
828
|
+
const showingIgnored = showIgnoredFiles();
|
|
829
|
+
|
|
830
|
+
const values: FilesPanelValues = {
|
|
831
|
+
currentPath: caret,
|
|
832
|
+
dragPath: _dragPath,
|
|
833
|
+
dropPath: _dropPath,
|
|
834
|
+
headerState: state.isSiteProject ? "shown" : "hidden",
|
|
835
|
+
ignoredIcon: showingIgnored ? "eye" : "eye-slash",
|
|
836
|
+
ignoredLabel: showingIgnored ? "Hide ignored files" : "Show ignored files",
|
|
837
|
+
ignoredSelected: showingIgnored,
|
|
838
|
+
padBottom: range.padBottom,
|
|
839
|
+
padTop: range.padTop,
|
|
840
|
+
projectName: state.projectConfig?.name || state.name,
|
|
841
|
+
query: state.searchQuery,
|
|
842
|
+
rootDrop: _rootDrop,
|
|
843
|
+
rows: drawn.map((row) => fileRowView(row)),
|
|
844
|
+
selectedPath: state.selectedPath ?? "",
|
|
845
|
+
view: "tree",
|
|
846
|
+
};
|
|
847
|
+
_lastValues = values;
|
|
848
|
+
return values;
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
/**
|
|
852
|
+
* Say only what a DRAG changed, without rebuilding the row model.
|
|
853
|
+
*
|
|
854
|
+
* `onDrag` fires per pointer move. Re-projecting from scratch would re-walk every listed directory,
|
|
855
|
+
* re-resolve the locales and re-slice the window on each of them, so the three fields a drag
|
|
856
|
+
* actually moves are written over the last projection instead — and because the document compares
|
|
857
|
+
* each of them against `$map.item.path`, what reaches the DOM is one attribute per drawn row.
|
|
858
|
+
*/
|
|
859
|
+
function syncFilesDragState(): void {
|
|
860
|
+
if (!_standingFiles || !_lastValues) {
|
|
861
|
+
return;
|
|
837
862
|
}
|
|
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
|
-
`;
|
|
863
|
+
_lastValues = {
|
|
864
|
+
..._lastValues,
|
|
865
|
+
dragPath: _dragPath,
|
|
866
|
+
dropPath: _dropPath,
|
|
867
|
+
rootDrop: _rootDrop,
|
|
868
|
+
};
|
|
869
|
+
_standingFiles.handle.update(_lastValues);
|
|
883
870
|
}
|
|
884
871
|
|
|
885
|
-
/**
|
|
886
|
-
|
|
872
|
+
/** Repaint the Navigator, which is what brings a new projection to the mounted document. */
|
|
873
|
+
function repaintFiles(): void {
|
|
874
|
+
_filesRerender?.();
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
// ─── The panel's own verbs ───────────────────────────────────────────────────
|
|
878
|
+
|
|
879
|
+
/** Re-read every listed directory, and the `.gitignore` rules with them. */
|
|
880
|
+
async function refreshFileTree(): Promise<void> {
|
|
887
881
|
const state = requireProjectState();
|
|
888
|
-
|
|
889
|
-
|
|
882
|
+
state.dirs.clear();
|
|
883
|
+
/* The rules go with the listings. Refresh is what an author reaches for after editing a
|
|
884
|
+
`.gitignore` by hand, and a tree that came back still hiding by the old rules would read as
|
|
885
|
+
the button not having worked. */
|
|
886
|
+
resetIgnoreCache();
|
|
887
|
+
await loadDirectory(".");
|
|
888
|
+
for (const dir of state.expanded) {
|
|
889
|
+
await loadDirectory(dir);
|
|
890
|
+
}
|
|
891
|
+
repaintFiles();
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
/**
|
|
895
|
+
* What a click or Enter on a row MEANS.
|
|
896
|
+
*
|
|
897
|
+
* One verb for both kinds of row, decided here rather than in the document: a directory opens, a
|
|
898
|
+
* file opens in a tab, and a row whose model has since gone does nothing at all.
|
|
899
|
+
*/
|
|
900
|
+
function activateFileRow(path: string): void {
|
|
901
|
+
const row = fileRowAt(path);
|
|
902
|
+
if (!row) {
|
|
890
903
|
return;
|
|
891
904
|
}
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
905
|
+
if (row.type === "directory") {
|
|
906
|
+
void toggleTreeDirectory(path).then(() => repaintFiles());
|
|
907
|
+
return;
|
|
895
908
|
}
|
|
909
|
+
void openFileInTab(path);
|
|
896
910
|
}
|
|
897
911
|
|
|
898
|
-
|
|
899
|
-
*
|
|
912
|
+
/**
|
|
913
|
+
* `jx-tree` says a row should be OPENED or CLOSED; this is what that means to a directory.
|
|
900
914
|
*
|
|
901
|
-
*
|
|
902
|
-
*
|
|
903
|
-
*
|
|
904
|
-
*
|
|
905
|
-
* binding and swaps it rather than stacking it.
|
|
915
|
+
* One entry point for the twisty, `ArrowRight` and `ArrowLeft` alike, because the element resolves
|
|
916
|
+
* all three into the state the row should be PUT INTO before it asks. The guard is still load
|
|
917
|
+
* bearing: a leaf's twisty box is drawn empty and still answers a click, so a file can arrive here
|
|
918
|
+
* asking to be expanded and must be told nothing happens.
|
|
906
919
|
*/
|
|
920
|
+
function expandFileRow(path: string, expanded: boolean): void {
|
|
921
|
+
const state = requireProjectState();
|
|
922
|
+
if (fileRowAt(path)?.type !== "directory" || state.expanded.has(path) === expanded) {
|
|
923
|
+
return;
|
|
924
|
+
}
|
|
925
|
+
if (!expanded) {
|
|
926
|
+
state.expanded.delete(path);
|
|
927
|
+
// It used to leave the repaint to "the caller who sets up keyboard", and there was no such
|
|
928
|
+
// Caller: ← changed the state and left the children on screen until something else happened to
|
|
929
|
+
// Redraw the panel.
|
|
930
|
+
repaintFiles();
|
|
931
|
+
return;
|
|
932
|
+
}
|
|
933
|
+
// The expansion repaints THROUGH the panel. It used to synthesise a click on the focused row to
|
|
934
|
+
// Get a repaint, which ran that row's own toggle a second time and only did the right thing
|
|
935
|
+
// Because the handler's captured `isExpanded` was already stale.
|
|
936
|
+
void toggleTreeDirectory(path).then(() => repaintFiles());
|
|
937
|
+
}
|
|
907
938
|
|
|
908
939
|
/**
|
|
909
|
-
* The
|
|
940
|
+
* The reader meant that row.
|
|
910
941
|
*
|
|
911
|
-
*
|
|
912
|
-
*
|
|
913
|
-
*
|
|
914
|
-
*
|
|
915
|
-
*
|
|
942
|
+
* The tree is single-select, so `jx-tree` has already resolved every modifier to one replace before
|
|
943
|
+
* this is reached. Selection follows the caret here where it used to lag behind it: the tab stop
|
|
944
|
+
* was computed FROM `selectedPath`, so an arrow key moved the focus and left the highlight on the
|
|
945
|
+
* row the reader had left.
|
|
946
|
+
*
|
|
947
|
+
* The selection is also the only thing this module remembers about where the caret IS. It does not
|
|
948
|
+
* need a second variable: `jx-tree` owns the caret and keeps it across every repaint that does not
|
|
949
|
+
* change `current`, so what the projection owes it is a SEED — a row to start on, and a row to come
|
|
950
|
+
* back to when the one it was on has gone.
|
|
916
951
|
*/
|
|
917
|
-
function
|
|
918
|
-
|
|
919
|
-
if (!focused) {
|
|
952
|
+
function selectFileRow(path: string): void {
|
|
953
|
+
if (!projectState || requireProjectState().selectedPath === path) {
|
|
920
954
|
return;
|
|
921
955
|
}
|
|
922
|
-
|
|
956
|
+
requireProjectState().selectedPath = path;
|
|
957
|
+
repaintFiles();
|
|
958
|
+
}
|
|
923
959
|
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
960
|
+
/**
|
|
961
|
+
* The caret has to reach a row the window did not draw.
|
|
962
|
+
*
|
|
963
|
+
* `jx-tree` walks the DRAWN rows and stops at the ends of the slice; when a pad says the model
|
|
964
|
+
* continues that way it dispatches this instead of performing anything, because where the row is
|
|
965
|
+
* and how far to scroll are facts about the model. Each key is answered here exactly as the element
|
|
966
|
+
* would have answered it over a slice that held everything.
|
|
967
|
+
*/
|
|
968
|
+
function moveFileCaret(from: string, key: string): void {
|
|
969
|
+
const index = fileIndexOfPath(from);
|
|
970
|
+
let target: number;
|
|
971
|
+
switch (key) {
|
|
972
|
+
case "Home": {
|
|
973
|
+
target = fileStep(-1, 1);
|
|
929
974
|
break;
|
|
930
975
|
}
|
|
931
|
-
case "
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
void toggleTreeDirectory(path).then(() => _filesRerender?.());
|
|
938
|
-
}
|
|
976
|
+
case "End": {
|
|
977
|
+
target = fileStep(_fileRows.length, -1);
|
|
978
|
+
break;
|
|
979
|
+
}
|
|
980
|
+
case "ArrowUp": {
|
|
981
|
+
target = fileStep(index, -1);
|
|
939
982
|
break;
|
|
940
983
|
}
|
|
941
984
|
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
|
-
}
|
|
985
|
+
target = fileParentIndex(index);
|
|
950
986
|
break;
|
|
951
987
|
}
|
|
952
|
-
|
|
953
|
-
|
|
988
|
+
// ↓ and → both ask for the next drawn row; over the model they are the same step.
|
|
989
|
+
case "ArrowDown":
|
|
990
|
+
case "ArrowRight": {
|
|
991
|
+
target = fileStep(index, 1);
|
|
954
992
|
break;
|
|
955
993
|
}
|
|
956
994
|
default: {
|
|
957
|
-
|
|
995
|
+
return;
|
|
958
996
|
}
|
|
959
997
|
}
|
|
960
|
-
|
|
961
|
-
e.preventDefault();
|
|
962
|
-
}
|
|
998
|
+
focusFileRow(target);
|
|
963
999
|
}
|
|
964
1000
|
|
|
965
|
-
/**
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
1001
|
+
/**
|
|
1002
|
+
* A printable character on a windowed tree: find the model row it names, and go there.
|
|
1003
|
+
*
|
|
1004
|
+
* `jx-tree` resolves typeahead itself only when the drawn rows ARE the model; past that it
|
|
1005
|
+
* dispatches, and the reason is sharper than the one behind `move`. A move off the end of the slice
|
|
1006
|
+
* announces itself — there is nothing to land on. A letter never does: the element's search over
|
|
1007
|
+
* the drawn rows always answers, and over `node_modules` the answer is whichever of the eleven
|
|
1008
|
+
* painted rows happened to start with that letter.
|
|
1009
|
+
*
|
|
1010
|
+
* The search is the element's own, moved onto the full list: forward from the caret, wrapping once,
|
|
1011
|
+
* matching the row's NAME — which is the string the row draws and announces, so the caret can never
|
|
1012
|
+
* land somewhere the reader was not told about — and skipping the "Loading…" placeholders, which
|
|
1013
|
+
* are not tree items and which the arrows already step over.
|
|
1014
|
+
*
|
|
1015
|
+
* @param {string} from The row the caret is on
|
|
1016
|
+
* @param {string} char The character typed, lowercased
|
|
1017
|
+
*/
|
|
1018
|
+
function typeaheadFileCaret(from: string, char: string): void {
|
|
1019
|
+
const start = fileIndexOfPath(from);
|
|
1020
|
+
const total = _fileRows.length;
|
|
1021
|
+
for (let step = 1; step <= total; step++) {
|
|
1022
|
+
const at = (start + step + total) % total;
|
|
1023
|
+
const row = _fileRows[at];
|
|
1024
|
+
if (row && !row.loading && row.name.trim().toLowerCase().startsWith(char)) {
|
|
1025
|
+
focusFileRow(at);
|
|
1026
|
+
return;
|
|
1027
|
+
}
|
|
1028
|
+
}
|
|
979
1029
|
}
|
|
980
1030
|
|
|
981
|
-
/**
|
|
982
|
-
|
|
1031
|
+
/**
|
|
1032
|
+
* Reveal the model row at `index` and put the caret on it.
|
|
1033
|
+
*
|
|
1034
|
+
* The SELECTION moves with it, and that is not a flourish: `jx-tree` raises `select` alongside
|
|
1035
|
+
* `change` on every arrow it can perform itself, so a step the window could not satisfy must not be
|
|
1036
|
+
* the one step that silently does not. It is also what moves the CARET, because the projection
|
|
1037
|
+
* seeds `currentPath` from the selection — and that write is the whole of this panel's side of the
|
|
1038
|
+
* handoff.
|
|
1039
|
+
*
|
|
1040
|
+
* **The keyboard is deliberately not touched here.** This is the answer to a `move` or a
|
|
1041
|
+
* `typeahead` the tree could not perform, and `jx-tree` keeps the keyboard across both: it focuses
|
|
1042
|
+
* the caret row once its own sync has written the roving `tabindex` onto the revealed element,
|
|
1043
|
+
* which is the only moment focusing it does anything. What this function used to do instead was
|
|
1044
|
+
* pend the path and spend the request from `onNodeCreated` — one reconcile step before the row had
|
|
1045
|
+
* a `tabindex` at all — so the `focus()` was a silent no-op and the caret jump never landed.
|
|
1046
|
+
*/
|
|
1047
|
+
function focusFileRow(index: number): void {
|
|
983
1048
|
const row = _fileRows[index];
|
|
984
1049
|
if (!row) {
|
|
985
1050
|
return;
|
|
986
1051
|
}
|
|
987
|
-
|
|
988
|
-
if (
|
|
989
|
-
|
|
1052
|
+
selectFileRow(row.path);
|
|
1053
|
+
if (fileRowElement(row.path)) {
|
|
1054
|
+
return;
|
|
1055
|
+
}
|
|
1056
|
+
revealListRow(_fileList, index, fileRowHeight());
|
|
1057
|
+
repaintFiles();
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1060
|
+
/** Expand or collapse one directory, listing it the first time it is opened. */
|
|
1061
|
+
async function toggleTreeDirectory(path: string): Promise<void> {
|
|
1062
|
+
const state = requireProjectState();
|
|
1063
|
+
if (state.expanded.has(path)) {
|
|
1064
|
+
state.expanded.delete(path);
|
|
990
1065
|
return;
|
|
991
1066
|
}
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
1067
|
+
state.expanded.add(path);
|
|
1068
|
+
if (!state.dirs.has(path)) {
|
|
1069
|
+
await loadDirectory(path);
|
|
995
1070
|
}
|
|
996
1071
|
}
|
|
997
1072
|
|
|
998
|
-
|
|
1073
|
+
// ─── Drag and drop: the island the document draws a home for ─────────────────
|
|
1074
|
+
|
|
1075
|
+
/**
|
|
1076
|
+
* What is registered against each drawn row, so it can be released when the row leaves the window.
|
|
1077
|
+
*
|
|
1078
|
+
* Keyed by the ELEMENT rather than by the path: a windowed list re-uses nodes, and the question
|
|
1079
|
+
* this map answers is "has this node's registration already been taken back", which is about the
|
|
1080
|
+
* node.
|
|
1081
|
+
*/
|
|
1082
|
+
const _rowDnd = new Map<HTMLElement, () => void>();
|
|
1083
|
+
/** What is registered against the tree itself: the project root's two drop targets, and the monitor. */
|
|
1084
|
+
let _treeDnd: { element: HTMLElement; cleanup: () => void } | null = null;
|
|
1085
|
+
/** The row being dragged, the row a drag is over, and whether the background is. */
|
|
1086
|
+
let _dragPath = "";
|
|
1087
|
+
/**
|
|
1088
|
+
* The row the pointer is over, whether or not it will take the drop.
|
|
1089
|
+
*
|
|
1090
|
+
* Two facts, not one, because the tree background is a drop target that CONTAINS every row: a
|
|
1091
|
+
* refused row still has to occlude it, or a drop the row said no to lands in the project root.
|
|
1092
|
+
* {@link _dropPath} is the row that will take the drop; this is the row that is in the way.
|
|
1093
|
+
*/
|
|
1094
|
+
let _overRow = "";
|
|
1095
|
+
let _dropPath = "";
|
|
1096
|
+
/** Whether the tree background is under the drag; {@link _rootDrop} is what that projects to. */
|
|
1097
|
+
let _overRoot = false;
|
|
1098
|
+
let _rootDrop = "";
|
|
999
1099
|
|
|
1000
1100
|
/** Whether a drag carries OS files (as opposed to a pragmatic in-app drag). */
|
|
1001
1101
|
export function isFileDrag(e: DragEvent): boolean {
|
|
@@ -1003,15 +1103,19 @@ export function isFileDrag(e: DragEvent): boolean {
|
|
|
1003
1103
|
}
|
|
1004
1104
|
|
|
1005
1105
|
/**
|
|
1006
|
-
* Attach external-file drop handling to one
|
|
1106
|
+
* Attach external-file drop handling to one element. Pragmatic-dnd only sees pragmatic sources, so
|
|
1007
1107
|
* an OS file drag needs the native listeners; `dir` is where a drop lands (the row itself for a
|
|
1008
1108
|
* directory, its parent for a file, `.` for the tree background).
|
|
1109
|
+
*
|
|
1110
|
+
* The affordance is reported rather than drawn: `setActive` writes the state the document renders
|
|
1111
|
+
* from, where this used to add and remove a class. That is the same correction the Library made — a
|
|
1112
|
+
* highlight a handler adds is a highlight another handler has to remember to take away, and a drag
|
|
1113
|
+
* that left the window never fired the handler that would have.
|
|
1009
1114
|
*/
|
|
1010
1115
|
function registerFileDropTarget(
|
|
1011
1116
|
element: HTMLElement,
|
|
1012
1117
|
dir: string,
|
|
1013
|
-
|
|
1014
|
-
renderLeftPanel: () => void,
|
|
1118
|
+
setActive: (active: boolean) => void,
|
|
1015
1119
|
): () => void {
|
|
1016
1120
|
const onDragOver = (e: DragEvent) => {
|
|
1017
1121
|
if (!isFileDrag(e)) {
|
|
@@ -1022,18 +1126,18 @@ function registerFileDropTarget(
|
|
|
1022
1126
|
if (e.dataTransfer) {
|
|
1023
1127
|
e.dataTransfer.dropEffect = "copy";
|
|
1024
1128
|
}
|
|
1025
|
-
|
|
1129
|
+
setActive(true);
|
|
1026
1130
|
};
|
|
1027
|
-
const onDragLeave = () =>
|
|
1131
|
+
const onDragLeave = () => setActive(false);
|
|
1028
1132
|
const onDrop = (e: DragEvent) => {
|
|
1029
|
-
|
|
1133
|
+
setActive(false);
|
|
1030
1134
|
const files = e.dataTransfer?.files;
|
|
1031
1135
|
if (!files?.length) {
|
|
1032
1136
|
return;
|
|
1033
1137
|
}
|
|
1034
1138
|
e.preventDefault();
|
|
1035
1139
|
e.stopPropagation();
|
|
1036
|
-
void uploadFilesToDir(files, dir,
|
|
1140
|
+
void uploadFilesToDir(files, dir, repaintFiles);
|
|
1037
1141
|
};
|
|
1038
1142
|
element.addEventListener("dragover", onDragOver);
|
|
1039
1143
|
element.addEventListener("dragleave", onDragLeave);
|
|
@@ -1045,6 +1149,72 @@ function registerFileDropTarget(
|
|
|
1045
1149
|
};
|
|
1046
1150
|
}
|
|
1047
1151
|
|
|
1152
|
+
/**
|
|
1153
|
+
* Whether the tree will move `srcPath` into `targetDir` — the ONE predicate behind every answer the
|
|
1154
|
+
* drag gives: which rows light up, which drops the monitor performs, and whether the background
|
|
1155
|
+
* offers the project root.
|
|
1156
|
+
*
|
|
1157
|
+
* Four refusals, and the third is the one nothing used to say. A directory is not a place inside
|
|
1158
|
+
* itself; an entry already in a directory (at any depth) has nowhere to go by being dropped on it;
|
|
1159
|
+
* a directory may not be moved into its own descendant, which is a rename onto a path underneath
|
|
1160
|
+
* the thing being renamed and which the tree happily offered until the server answered 500; and an
|
|
1161
|
+
* entry already directly in the target is a no-op — the case that spelled `.` for the root.
|
|
1162
|
+
*
|
|
1163
|
+
* Both sides are normalised first: `assets\logo.png` and `assets/logo.png` name one entry, and a
|
|
1164
|
+
* predicate that agreed with itself only on one of the two spellings is a predicate with a hole.
|
|
1165
|
+
*/
|
|
1166
|
+
export function canMoveInto(srcPath: string, targetDir: string): boolean {
|
|
1167
|
+
const src = srcPath.replaceAll("\\", "/");
|
|
1168
|
+
const dir = targetDir.replaceAll("\\", "/");
|
|
1169
|
+
if (!src || src === dir) {
|
|
1170
|
+
return false;
|
|
1171
|
+
}
|
|
1172
|
+
if (src.startsWith(`${dir}/`) || dir.startsWith(`${src}/`)) {
|
|
1173
|
+
return false;
|
|
1174
|
+
}
|
|
1175
|
+
return parentDir(src) !== dir;
|
|
1176
|
+
}
|
|
1177
|
+
|
|
1178
|
+
/** {@link canMoveInto} for a ROW: only a directory has an inside to move something into. */
|
|
1179
|
+
function acceptsDrop(srcPath: unknown, targetPath: string, targetType: string): boolean {
|
|
1180
|
+
return (
|
|
1181
|
+
targetType === "directory" && typeof srcPath === "string" && canMoveInto(srcPath, targetPath)
|
|
1182
|
+
);
|
|
1183
|
+
}
|
|
1184
|
+
|
|
1185
|
+
/**
|
|
1186
|
+
* Say which row the drag is over and whether that row will take it, and let the document redraw.
|
|
1187
|
+
*
|
|
1188
|
+
* The root affordance is DERIVED here rather than set alongside: a drag over a row is never also a
|
|
1189
|
+
* drag over the background, and the two flags used to be written independently — so a row that
|
|
1190
|
+
* refused the drop left the tree lit up saying the project root would take it, which after the
|
|
1191
|
+
* refusal became final is no longer true either.
|
|
1192
|
+
*/
|
|
1193
|
+
function setRowUnderDrag(row: string, accepted: boolean): void {
|
|
1194
|
+
const dropPath = accepted ? row : "";
|
|
1195
|
+
if (_overRow === row && _dropPath === dropPath) {
|
|
1196
|
+
return;
|
|
1197
|
+
}
|
|
1198
|
+
_overRow = row;
|
|
1199
|
+
_dropPath = dropPath;
|
|
1200
|
+
syncRootDrop();
|
|
1201
|
+
}
|
|
1202
|
+
|
|
1203
|
+
/** Say whether a drag is over the tree background, which is the project root. */
|
|
1204
|
+
function setRootUnderDrag(active: boolean): void {
|
|
1205
|
+
if (_overRoot === active) {
|
|
1206
|
+
return;
|
|
1207
|
+
}
|
|
1208
|
+
_overRoot = active;
|
|
1209
|
+
syncRootDrop();
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1212
|
+
/** Recompute the background's affordance from the two facts, and project both. */
|
|
1213
|
+
function syncRootDrop(): void {
|
|
1214
|
+
_rootDrop = _overRoot && _overRow === "" ? "true" : "";
|
|
1215
|
+
syncFilesDragState();
|
|
1216
|
+
}
|
|
1217
|
+
|
|
1048
1218
|
/**
|
|
1049
1219
|
* Upload files into `dir` and reveal them: expand the target directory so the new entries are
|
|
1050
1220
|
* visible. The listing refresh itself runs in the shared post-upload handler.
|
|
@@ -1066,7 +1236,7 @@ export async function uploadFilesToDir(
|
|
|
1066
1236
|
|
|
1067
1237
|
/**
|
|
1068
1238
|
* 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
|
|
1239
|
+
* input is created per invocation and discarded after — the tree is re-rendered often.
|
|
1070
1240
|
*/
|
|
1071
1241
|
export function pickAndUploadTo(dir: string, renderLeftPanel: () => void): void {
|
|
1072
1242
|
const input = document.createElement("input");
|
|
@@ -1082,158 +1252,181 @@ export function pickAndUploadTo(dir: string, renderLeftPanel: () => void): void
|
|
|
1082
1252
|
}
|
|
1083
1253
|
|
|
1084
1254
|
/**
|
|
1085
|
-
*
|
|
1255
|
+
* Adopt one row element the document has just created: remember it, make it a drag source, and give
|
|
1256
|
+
* it the two drop behaviours its KIND earns.
|
|
1086
1257
|
*
|
|
1087
|
-
*
|
|
1258
|
+
* Every row is a source, an external-file target and an in-app target. Only a DIRECTORY accepts an
|
|
1259
|
+
* in-app drop, because a file has no inside to move something into — but a file row registers the
|
|
1260
|
+
* target anyway and refuses in its data, because a row that is not a target at all is a row the
|
|
1261
|
+
* drop falls straight through, onto the tree, which is the project root. The registration happens
|
|
1262
|
+
* as the node is created, which is the one moment at which "this element is that path" is certainly
|
|
1263
|
+
* true.
|
|
1088
1264
|
*/
|
|
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({
|
|
1265
|
+
function adoptFileRow(element: HTMLElement, path: string, type: string): void {
|
|
1266
|
+
releaseRowDnD(element);
|
|
1267
|
+
_fileRowEls.set(path, element);
|
|
1268
|
+
|
|
1269
|
+
const cleanups = [
|
|
1270
|
+
draggable({
|
|
1271
|
+
element,
|
|
1272
|
+
getInitialData() {
|
|
1273
|
+
return { entryType: type, path, type: "file-tree" };
|
|
1274
|
+
},
|
|
1275
|
+
onDragStart() {
|
|
1276
|
+
_dragPath = path;
|
|
1277
|
+
syncFilesDragState();
|
|
1278
|
+
},
|
|
1279
|
+
onDrop() {
|
|
1280
|
+
_dragPath = "";
|
|
1281
|
+
setRowUnderDrag("", false);
|
|
1282
|
+
syncFilesDragState();
|
|
1283
|
+
},
|
|
1284
|
+
}),
|
|
1285
|
+
// Files dropped from the OS land in the row's own directory; a file row targets its parent so
|
|
1286
|
+
// Dropping next to a sibling puts the upload beside it.
|
|
1287
|
+
registerFileDropTarget(element, type === "directory" ? path : parentDir(path), (active) => {
|
|
1288
|
+
setRowUnderDrag(active ? path : "", active);
|
|
1289
|
+
}),
|
|
1290
|
+
/**
|
|
1291
|
+
* The in-app target — on EVERY row, accepting or not.
|
|
1292
|
+
*
|
|
1293
|
+
* A row that answered `canDrop: false` was not a drop target at all, and pragmatic-dnd
|
|
1294
|
+
* documents what happens next: "blocking dropping on a drop target will not block dropping on
|
|
1295
|
+
* child or parent drop targets". The next target up is the tree element, whose target IS the
|
|
1296
|
+
* project root — so a refused drop became a move to the root, silently, with no affordance
|
|
1297
|
+
* anywhere on screen to warn the reader it would. Answering `true` and carrying the verdict in
|
|
1298
|
+
* the DATA keeps the innermost target innermost, which is what makes a refusal final.
|
|
1299
|
+
*/
|
|
1300
|
+
dropTargetForElements({
|
|
1181
1301
|
canDrop({ source }) {
|
|
1182
|
-
|
|
1183
|
-
return false;
|
|
1184
|
-
}
|
|
1185
|
-
const srcPath = source.data.path as string;
|
|
1186
|
-
return parentDir(srcPath) !== ".";
|
|
1302
|
+
return source.data.type === "file-tree";
|
|
1187
1303
|
},
|
|
1188
|
-
element
|
|
1189
|
-
getData() {
|
|
1190
|
-
return
|
|
1304
|
+
element,
|
|
1305
|
+
getData({ source }) {
|
|
1306
|
+
return acceptsDrop(source.data.path, path, type)
|
|
1307
|
+
? { targetDir: path, type: "file-tree-target" }
|
|
1308
|
+
: { type: "file-tree-refused" };
|
|
1191
1309
|
},
|
|
1192
|
-
|
|
1193
|
-
|
|
1310
|
+
onDrag({ source }) {
|
|
1311
|
+
setRowUnderDrag(path, acceptsDrop(source.data.path, path, type));
|
|
1312
|
+
},
|
|
1313
|
+
onDragEnter({ source }) {
|
|
1314
|
+
setRowUnderDrag(path, acceptsDrop(source.data.path, path, type));
|
|
1194
1315
|
},
|
|
1195
1316
|
onDragLeave() {
|
|
1196
|
-
|
|
1317
|
+
setRowUnderDrag("", false);
|
|
1197
1318
|
},
|
|
1198
1319
|
onDrop() {
|
|
1199
|
-
|
|
1320
|
+
setRowUnderDrag("", false);
|
|
1200
1321
|
},
|
|
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
|
-
);
|
|
1322
|
+
}),
|
|
1323
|
+
];
|
|
1208
1324
|
|
|
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
|
-
}
|
|
1325
|
+
_rowDnd.set(element, combine(...cleanups));
|
|
1326
|
+
}
|
|
1222
1327
|
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1328
|
+
/** Take back everything registered against one row element. */
|
|
1329
|
+
function releaseRowDnD(element: HTMLElement): void {
|
|
1330
|
+
const cleanup = _rowDnd.get(element);
|
|
1331
|
+
if (cleanup) {
|
|
1332
|
+
cleanup();
|
|
1333
|
+
_rowDnd.delete(element);
|
|
1334
|
+
}
|
|
1335
|
+
}
|
|
1227
1336
|
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1337
|
+
/**
|
|
1338
|
+
* Adopt the tree element: the window's scroller, the project root's drop target, and the monitor
|
|
1339
|
+
* that turns a completed drag into a move.
|
|
1340
|
+
*
|
|
1341
|
+
* Registered once, against the element the document created. The pass this replaced ran on every
|
|
1342
|
+
* repaint and re-registered every row from scratch, which is what made a drag mid-scroll drop its
|
|
1343
|
+
* own sources.
|
|
1344
|
+
*/
|
|
1345
|
+
function adoptFileTreeElement(element: HTMLElement): void {
|
|
1346
|
+
if (_treeDnd?.element === element) {
|
|
1347
|
+
return;
|
|
1348
|
+
}
|
|
1349
|
+
releaseFileTreeDnD();
|
|
1350
|
+
_fileList = element;
|
|
1231
1351
|
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1352
|
+
/* The background keeps an honest `canDrop`: it is the OUTERMOST target, so there is nothing
|
|
1353
|
+
inside it for a refusal here to leak to. Its affordance is suppressed while a row is under the
|
|
1354
|
+
pointer — {@link syncRootDrop} — because the row is what the drop will reach. */
|
|
1355
|
+
const rootCleanup = dropTargetForElements({
|
|
1356
|
+
canDrop({ source }) {
|
|
1357
|
+
return source.data.type === "file-tree" && canMoveInto(source.data.path as string, ".");
|
|
1358
|
+
},
|
|
1359
|
+
element,
|
|
1360
|
+
getData() {
|
|
1361
|
+
return { targetDir: ".", type: "file-tree-target" };
|
|
1362
|
+
},
|
|
1363
|
+
onDragEnter() {
|
|
1364
|
+
setRootUnderDrag(true);
|
|
1365
|
+
},
|
|
1366
|
+
onDragLeave() {
|
|
1367
|
+
setRootUnderDrag(false);
|
|
1368
|
+
},
|
|
1369
|
+
onDrop() {
|
|
1370
|
+
setRootUnderDrag(false);
|
|
1371
|
+
},
|
|
1236
1372
|
});
|
|
1373
|
+
|
|
1374
|
+
const monitorCleanup = monitorForElements({
|
|
1375
|
+
onDrop({ source, location }) {
|
|
1376
|
+
const [target] = location.current.dropTargets;
|
|
1377
|
+
if (!target) {
|
|
1378
|
+
return;
|
|
1379
|
+
}
|
|
1380
|
+
if (source.data.type !== "file-tree") {
|
|
1381
|
+
return;
|
|
1382
|
+
}
|
|
1383
|
+
/* The INNERMOST target and no other. `dropTargets` is bubble-ordered, so reading [0] and
|
|
1384
|
+
then refusing what it says is what keeps a row's "no" from becoming the tree's "yes". */
|
|
1385
|
+
if (target.data.type !== "file-tree-target") {
|
|
1386
|
+
return;
|
|
1387
|
+
}
|
|
1388
|
+
|
|
1389
|
+
const srcPath = source.data.path as string;
|
|
1390
|
+
const targetDirPath = target.data.targetDir as string;
|
|
1391
|
+
if (!canMoveInto(srcPath, targetDirPath)) {
|
|
1392
|
+
return;
|
|
1393
|
+
}
|
|
1394
|
+
const fileName = srcPath.split("/").pop();
|
|
1395
|
+
const newPath = targetDirPath === "." ? fileName : `${targetDirPath}/${fileName}`;
|
|
1396
|
+
|
|
1397
|
+
void moveFileEntry(srcPath, newPath!, repaintFiles);
|
|
1398
|
+
},
|
|
1399
|
+
});
|
|
1400
|
+
|
|
1401
|
+
_treeDnd = {
|
|
1402
|
+
cleanup: combine(
|
|
1403
|
+
rootCleanup,
|
|
1404
|
+
monitorCleanup,
|
|
1405
|
+
// The tree background is the project root's drop target for OS files. Row handlers
|
|
1406
|
+
// StopPropagation, so a drop on a row never also fires here.
|
|
1407
|
+
registerFileDropTarget(element, ".", setRootUnderDrag),
|
|
1408
|
+
),
|
|
1409
|
+
element,
|
|
1410
|
+
};
|
|
1411
|
+
adoptFileTree();
|
|
1412
|
+
}
|
|
1413
|
+
|
|
1414
|
+
/** Take back the tree's own registrations and its scroll watch. */
|
|
1415
|
+
function releaseFileTreeDnD(): void {
|
|
1416
|
+
_treeDnd?.cleanup();
|
|
1417
|
+
_treeDnd = null;
|
|
1418
|
+
for (const cleanup of _rowDnd.values()) {
|
|
1419
|
+
cleanup();
|
|
1420
|
+
}
|
|
1421
|
+
_rowDnd.clear();
|
|
1422
|
+
_fileWatch?.window.destroy();
|
|
1423
|
+
_fileWatch = null;
|
|
1424
|
+
_fileList = null;
|
|
1425
|
+
_dragPath = "";
|
|
1426
|
+
_overRow = "";
|
|
1427
|
+
_dropPath = "";
|
|
1428
|
+
_overRoot = false;
|
|
1429
|
+
_rootDrop = "";
|
|
1237
1430
|
}
|
|
1238
1431
|
|
|
1239
1432
|
/**
|
|
@@ -1297,23 +1490,11 @@ function parentDir(path: string) {
|
|
|
1297
1490
|
|
|
1298
1491
|
// ─── Context menu ─────────────────────────────────────────────────────────────
|
|
1299
1492
|
|
|
1300
|
-
let
|
|
1493
|
+
let _fileMenu: MenuHandle | null = null;
|
|
1301
1494
|
|
|
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;
|
|
1495
|
+
function dismissFileContextMenu(): void {
|
|
1496
|
+
_fileMenu?.close();
|
|
1497
|
+
_fileMenu = null;
|
|
1317
1498
|
}
|
|
1318
1499
|
|
|
1319
1500
|
/**
|
|
@@ -1361,6 +1542,16 @@ function fileRowFacts(entry: { path: string; type: string }): Record<string, unk
|
|
|
1361
1542
|
return facts;
|
|
1362
1543
|
}
|
|
1363
1544
|
|
|
1545
|
+
/** One of the tree's OWN verbs, as the kit menu reads a row. */
|
|
1546
|
+
function treeMenuRow(
|
|
1547
|
+
id: string,
|
|
1548
|
+
title: string,
|
|
1549
|
+
run: () => void,
|
|
1550
|
+
extra: Partial<MenuRowProjection> = {},
|
|
1551
|
+
): MenuRowProjection {
|
|
1552
|
+
return { destructive: false, disabled: false, dividerAbove: false, id, run, title, ...extra };
|
|
1553
|
+
}
|
|
1554
|
+
|
|
1364
1555
|
/**
|
|
1365
1556
|
* The declared `context/file` commands this row can offer.
|
|
1366
1557
|
*
|
|
@@ -1368,13 +1559,13 @@ function fileRowFacts(entry: { path: string; type: string }): Record<string, unk
|
|
|
1368
1559
|
* `group`), whether it is enabled and the sentence saying why not. Nothing here names a command, so
|
|
1369
1560
|
* a new `context/file` record appears in the tree with no edit to this file.
|
|
1370
1561
|
*/
|
|
1371
|
-
function
|
|
1562
|
+
function placedFileRows(entry: { path: string; type: string }): MenuRowProjection[] {
|
|
1372
1563
|
const registry = activeRegistry();
|
|
1373
1564
|
if (!registry) {
|
|
1374
1565
|
return [];
|
|
1375
1566
|
}
|
|
1376
1567
|
const facts = fileRowFacts(entry);
|
|
1377
|
-
const
|
|
1568
|
+
const rows: MenuRowProjection[] = [];
|
|
1378
1569
|
for (const command of registry.forPlacement("context/file")) {
|
|
1379
1570
|
const schema = command.args as
|
|
1380
1571
|
| { properties?: Record<string, unknown>; required?: readonly string[] }
|
|
@@ -1389,128 +1580,111 @@ function placedFileItems(entry: { path: string; type: string }): FileMenuItem[]
|
|
|
1389
1580
|
}
|
|
1390
1581
|
}
|
|
1391
1582
|
const reason = registry.disabledReason(command.id);
|
|
1392
|
-
|
|
1583
|
+
rows.push(
|
|
1393
1584
|
reason === undefined
|
|
1394
|
-
? {
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1585
|
+
? treeMenuRow(command.id, command.title, () => {
|
|
1586
|
+
void runReported(registry, command.id, args, "Files");
|
|
1587
|
+
})
|
|
1588
|
+
: {
|
|
1589
|
+
destructive: false,
|
|
1590
|
+
disabled: true,
|
|
1591
|
+
dividerAbove: false,
|
|
1592
|
+
id: command.id,
|
|
1593
|
+
// A disabled row says what it needs, the same sentence the palette and the agent
|
|
1594
|
+
// Print — `requires`, off the record, never re-worded here.
|
|
1595
|
+
requires: reason,
|
|
1596
|
+
title: command.title,
|
|
1597
|
+
},
|
|
1401
1598
|
);
|
|
1402
1599
|
}
|
|
1403
|
-
return
|
|
1600
|
+
return rows;
|
|
1404
1601
|
}
|
|
1405
1602
|
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
)
|
|
1411
|
-
|
|
1412
|
-
|
|
1603
|
+
/**
|
|
1604
|
+
* Everything one row can be asked to do, in the order it is offered.
|
|
1605
|
+
*
|
|
1606
|
+
* The declared rows sit between what the TREE does to a file (open it, create in it, upload to it)
|
|
1607
|
+
* and what it does to the file's existence (rename, delete) — and the boundary between the last two
|
|
1608
|
+
* groups is the `dividerAbove` on Rename, which is what the `"—"` sentinel row used to stand for.
|
|
1609
|
+
*/
|
|
1610
|
+
function fileMenuRows(entry: { name: string; path: string; type: string }): MenuRowProjection[] {
|
|
1413
1611
|
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
|
-
}
|
|
1612
|
+
const rows: MenuRowProjection[] = [];
|
|
1420
1613
|
if (isDir) {
|
|
1421
|
-
|
|
1422
|
-
{
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
label: "Upload Files\u2026",
|
|
1429
|
-
},
|
|
1614
|
+
rows.push(
|
|
1615
|
+
treeMenuRow("files.newFile", "New File\u2026", () => {
|
|
1616
|
+
void createNewFile(entry.path, repaintFiles);
|
|
1617
|
+
}),
|
|
1618
|
+
treeMenuRow("files.upload", "Upload Files\u2026", () => {
|
|
1619
|
+
pickAndUploadTo(entry.path, repaintFiles);
|
|
1620
|
+
}),
|
|
1430
1621
|
);
|
|
1431
1622
|
if (entry.path === "pages" || entry.path.endsWith("/pages")) {
|
|
1432
1623
|
// The one hand-built row left: no command declares "open the pages grid". `grid-open.ts`'s
|
|
1433
1624
|
// `collection.editInGrid` has no pages sibling, so there is nothing here to render yet.
|
|
1434
|
-
|
|
1435
|
-
|
|
1625
|
+
rows.push(
|
|
1626
|
+
treeMenuRow("files.pagesGrid", "Edit Pages in Grid", () => {
|
|
1436
1627
|
openPagesGrid();
|
|
1437
|
-
},
|
|
1438
|
-
|
|
1439
|
-
});
|
|
1628
|
+
}),
|
|
1629
|
+
);
|
|
1440
1630
|
}
|
|
1631
|
+
} else {
|
|
1632
|
+
rows.push(
|
|
1633
|
+
treeMenuRow("files.open", "Open", () => {
|
|
1634
|
+
void openFileInTab(entry.path);
|
|
1635
|
+
}),
|
|
1636
|
+
);
|
|
1441
1637
|
}
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1638
|
+
rows.push(
|
|
1639
|
+
...placedFileRows(entry),
|
|
1640
|
+
treeMenuRow(
|
|
1641
|
+
"files.rename",
|
|
1642
|
+
"Rename\u2026",
|
|
1643
|
+
() => {
|
|
1644
|
+
void renameFile(entry, repaintFiles);
|
|
1645
|
+
},
|
|
1646
|
+
{ dividerAbove: true },
|
|
1647
|
+
),
|
|
1648
|
+
treeMenuRow(
|
|
1649
|
+
"files.delete",
|
|
1650
|
+
"Delete",
|
|
1651
|
+
() => {
|
|
1652
|
+
void deleteFile(entry, repaintFiles);
|
|
1653
|
+
},
|
|
1654
|
+
{ destructive: true },
|
|
1655
|
+
),
|
|
1456
1656
|
);
|
|
1657
|
+
return rows;
|
|
1658
|
+
}
|
|
1457
1659
|
|
|
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
|
-
},
|
|
1660
|
+
/**
|
|
1661
|
+
* Open the file menu at the pointer.
|
|
1662
|
+
*
|
|
1663
|
+
* The KIT menu, not a popover of this module's own: `openMenu()` owns the panel, the roving focus,
|
|
1664
|
+
* the typeahead, the light dismissal and Escape, and it is the answer this shell already settled on
|
|
1665
|
+
* (§8.4). What went with the `sp-popover` it replaces is the hand-written clamp — a `ref` that
|
|
1666
|
+
* measured the panel a frame after it opened and moved it back inside the viewport — because the
|
|
1667
|
+
* kit does that for every menu instead of this one doing it for itself.
|
|
1668
|
+
*/
|
|
1669
|
+
function showFileContextMenu(path: string, x: number, y: number): void {
|
|
1670
|
+
const row = fileRowAt(path);
|
|
1671
|
+
if (!row) {
|
|
1672
|
+
return;
|
|
1673
|
+
}
|
|
1674
|
+
dismissFileContextMenu();
|
|
1675
|
+
const opener = fileRowElement(path);
|
|
1676
|
+
_fileMenu = openMenu({
|
|
1677
|
+
label: "File actions",
|
|
1678
|
+
onClosed: (handle) => {
|
|
1679
|
+
if (_fileMenu === handle) {
|
|
1680
|
+
_fileMenu = null;
|
|
1681
|
+
}
|
|
1512
1682
|
},
|
|
1513
|
-
|
|
1683
|
+
opener,
|
|
1684
|
+
origin: { x, y },
|
|
1685
|
+
region: "files",
|
|
1686
|
+
rows: fileMenuRows({ name: row.name, path: row.path, type: row.type }),
|
|
1687
|
+
});
|
|
1514
1688
|
}
|
|
1515
1689
|
|
|
1516
1690
|
// ─── File CRUD ────────────────────────────────────────────────────────────────
|
|
@@ -2174,13 +2348,16 @@ export async function openFileInTab(path: string, opts: OpenFileOpts = {}) {
|
|
|
2174
2348
|
await loadFormats();
|
|
2175
2349
|
let document: Record<string, unknown>;
|
|
2176
2350
|
let frontmatter: Record<string, unknown> | undefined;
|
|
2351
|
+
// The layout the JSON was written in, so a save reproduces it (`json-layout.ts`, issue 308). A
|
|
2352
|
+
// Format-class file has none: its serializer owns its layout.
|
|
2353
|
+
let layout: JsonLayout | null = null;
|
|
2177
2354
|
const format = formatForPath(path);
|
|
2178
2355
|
if (format) {
|
|
2179
2356
|
const result = await parseSourceForPath(path, content);
|
|
2180
2357
|
({ document } = result);
|
|
2181
2358
|
({ frontmatter } = result);
|
|
2182
2359
|
} else if (path.endsWith(".json")) {
|
|
2183
|
-
document =
|
|
2360
|
+
({ document, layout } = parseJsonDocument(content));
|
|
2184
2361
|
} else {
|
|
2185
2362
|
throw noFormatError(path);
|
|
2186
2363
|
}
|
|
@@ -2191,6 +2368,7 @@ export async function openFileInTab(path: string, opts: OpenFileOpts = {}) {
|
|
|
2191
2368
|
documentPath: path,
|
|
2192
2369
|
document,
|
|
2193
2370
|
...(frontmatter != null && { frontmatter }),
|
|
2371
|
+
layout,
|
|
2194
2372
|
sourceFormat: format?.name ?? null,
|
|
2195
2373
|
...(opts.paneId !== undefined && { paneId: opts.paneId }),
|
|
2196
2374
|
...(opts.preview === true && { preview: true }),
|
|
@@ -2263,7 +2441,10 @@ export async function reloadFileInTab(path: string) {
|
|
|
2263
2441
|
tab.doc.document = document;
|
|
2264
2442
|
tab.doc.content.frontmatter = frontmatter;
|
|
2265
2443
|
} else if (path.endsWith(".json")) {
|
|
2266
|
-
tab
|
|
2444
|
+
// The file changed under the tab, so its layout is whatever the new text says.
|
|
2445
|
+
const parsed = parseJsonDocument(content);
|
|
2446
|
+
tab.doc.document = parsed.document as JxMutableNode;
|
|
2447
|
+
tab.doc.layout = parsed.layout;
|
|
2267
2448
|
}
|
|
2268
2449
|
tab.doc.dirty = false;
|
|
2269
2450
|
} catch (error) {
|
|
@@ -2293,10 +2474,113 @@ export function registerFilesPanel(): void {
|
|
|
2293
2474
|
title: "Files",
|
|
2294
2475
|
level: "project",
|
|
2295
2476
|
dock: "navigator",
|
|
2296
|
-
icon: "
|
|
2297
|
-
|
|
2298
|
-
afterRender
|
|
2299
|
-
|
|
2477
|
+
icon: "folder",
|
|
2478
|
+
// The body is a document, so lit draws nothing and the mount happens against the painted DOM.
|
|
2479
|
+
// `afterRender` runs on every repaint; {@link mountFilesPanel} is idempotent.
|
|
2480
|
+
render: () => nothing,
|
|
2481
|
+
afterRender: (ctx, host) => {
|
|
2482
|
+
mountFilesPanel(host, ctx.rerender);
|
|
2300
2483
|
},
|
|
2301
2484
|
});
|
|
2302
2485
|
}
|
|
2486
|
+
|
|
2487
|
+
// ─── The mount ───────────────────────────────────────────────────────────────
|
|
2488
|
+
|
|
2489
|
+
/** Everything a control on the surface can ask for, defined once. */
|
|
2490
|
+
const FILE_ACTIONS: FilesPanelActions = {
|
|
2491
|
+
activate: activateFileRow,
|
|
2492
|
+
contextMenu: showFileContextMenu,
|
|
2493
|
+
expand: expandFileRow,
|
|
2494
|
+
move: moveFileCaret,
|
|
2495
|
+
newFile: () => {
|
|
2496
|
+
void createNewFile(".", repaintFiles);
|
|
2497
|
+
},
|
|
2498
|
+
openProject: () => {
|
|
2499
|
+
/* The DECLARED command, run through the registry — never a second opener of this surface's own
|
|
2500
|
+
(§12.5). It is the one the ⌘O chord, the palette and the status bar's PROJECT field already
|
|
2501
|
+
run, and it is the only one that knows about the picker modal and the "new window" target. */
|
|
2502
|
+
void runActiveReported("project.open", undefined, "Files");
|
|
2503
|
+
},
|
|
2504
|
+
refresh: () => {
|
|
2505
|
+
void refreshFileTree();
|
|
2506
|
+
},
|
|
2507
|
+
rowHost: adoptFileRow,
|
|
2508
|
+
search: (value) => {
|
|
2509
|
+
requireProjectState().searchQuery = value;
|
|
2510
|
+
repaintFiles();
|
|
2511
|
+
},
|
|
2512
|
+
select: selectFileRow,
|
|
2513
|
+
toggleIgnored: () => {
|
|
2514
|
+
/* A repaint and nothing else: the ignored entries were never dropped from `projectState.dirs`,
|
|
2515
|
+
only from the rows built out of it. */
|
|
2516
|
+
setShowIgnoredFiles(!showIgnoredFiles());
|
|
2517
|
+
repaintFiles();
|
|
2518
|
+
},
|
|
2519
|
+
treeHost: adoptFileTreeElement,
|
|
2520
|
+
typeahead: typeaheadFileCaret,
|
|
2521
|
+
};
|
|
2522
|
+
|
|
2523
|
+
/** The mounted document, and the node it was mounted into. */
|
|
2524
|
+
let _standingFiles: { handle: FilesPanelSurfaceHandle; host: HTMLElement } | null = null;
|
|
2525
|
+
/** The last projection, so a drag can move three fields without rebuilding the row model. */
|
|
2526
|
+
let _lastValues: FilesPanelValues | null = null;
|
|
2527
|
+
|
|
2528
|
+
/**
|
|
2529
|
+
* Draw the panel — mounting the document the first time, and re-projecting into it every time
|
|
2530
|
+
* after.
|
|
2531
|
+
*
|
|
2532
|
+
* The document goes into `.panel-content`, not into the `.panel-body` this is handed, for the
|
|
2533
|
+
* reason `panels/git-panel.ts` states: only one of them is the node lit renders this panel's body
|
|
2534
|
+
* into, and appending to the other would leave the panel drawn under whatever the Navigator paints
|
|
2535
|
+
* next.
|
|
2536
|
+
*
|
|
2537
|
+
* The repaint stays the NAVIGATOR'S. Source Control owns an `effect()` because its inputs are the
|
|
2538
|
+
* reactive `shell.git` record; the tree's inputs are a `Map` of directory listings, a `Set` of
|
|
2539
|
+
* expanded paths and a roaming setting, none of which is reactive — so `ctx.rerender` is what this
|
|
2540
|
+
* surface has always been redrawn by, and it stays that way rather than growing a second scheduler
|
|
2541
|
+
* that could disagree with it.
|
|
2542
|
+
*
|
|
2543
|
+
* @param host - The painted `.panel-body`
|
|
2544
|
+
* @param rerender - The Navigator's repaint
|
|
2545
|
+
*/
|
|
2546
|
+
export function mountFilesPanel(host: HTMLElement, rerender: () => void): void {
|
|
2547
|
+
const container = host.querySelector<HTMLElement>(".panel-content") ?? host;
|
|
2548
|
+
// Captured per paint, so the scroll watch and every awaited flow repaint through the CURRENT
|
|
2549
|
+
// Navigator scheduler rather than through a closure from an earlier one.
|
|
2550
|
+
_filesRerender = rerender;
|
|
2551
|
+
if (_standingFiles && (_standingFiles.host !== container || !_standingFiles.handle.connected())) {
|
|
2552
|
+
unmountFilesPanel();
|
|
2553
|
+
}
|
|
2554
|
+
const values = filesPanelValues();
|
|
2555
|
+
if (_standingFiles) {
|
|
2556
|
+
_standingFiles.handle.update(values);
|
|
2557
|
+
} else {
|
|
2558
|
+
const handle = mountFilesPanelSurface(container, values, FILE_ACTIONS);
|
|
2559
|
+
_standingFiles = { handle, host: container };
|
|
2560
|
+
/* The FIRST paint is the one nothing else follows, and the tree element it announces through
|
|
2561
|
+
`onNodeCreated` is still detached — the document is appended when its mount resolves. A watch
|
|
2562
|
+
armed against a detached element resolves no scroller, so the window would answer "all of
|
|
2563
|
+
them" for the life of the panel. This is where the tree is finally in the document. */
|
|
2564
|
+
void handle.ready.then(adoptFileTree);
|
|
2565
|
+
}
|
|
2566
|
+
/* One microtask later, because the projection above has only just been written: the rows reach
|
|
2567
|
+
the DOM as the scope's effects run, and a watch armed before they exist measures a tree that
|
|
2568
|
+
does not overflow yet. */
|
|
2569
|
+
queueMicrotask(adoptFileTree);
|
|
2570
|
+
}
|
|
2571
|
+
|
|
2572
|
+
/**
|
|
2573
|
+
* Take the panel down: the document, the drag registrations, the scroll watch and the row handles.
|
|
2574
|
+
*
|
|
2575
|
+
* Exported because a project close has to reach it — the tree it is showing belongs to the project
|
|
2576
|
+
* being left behind, exactly as `cleanupGitPanel` is for the working tree.
|
|
2577
|
+
*/
|
|
2578
|
+
export function unmountFilesPanel(): void {
|
|
2579
|
+
dismissFileContextMenu();
|
|
2580
|
+
_standingFiles?.handle.dispose();
|
|
2581
|
+
_standingFiles = null;
|
|
2582
|
+
_lastValues = null;
|
|
2583
|
+
releaseFileTreeDnD();
|
|
2584
|
+
_fileRowEls.clear();
|
|
2585
|
+
_fileRows = [];
|
|
2586
|
+
}
|