@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
|
@@ -1,1903 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
listWindow,
|
|
3
|
-
measuredRowHeight,
|
|
4
|
-
revealListRow,
|
|
5
|
-
watchListWindow
|
|
6
|
-
} from "./studio-4r1pv6zf.js";
|
|
7
|
-
import {
|
|
8
|
-
formatBytes,
|
|
9
|
-
loadMediaMeta,
|
|
10
|
-
peekMediaMeta,
|
|
11
|
-
recordImageSize
|
|
12
|
-
} from "./studio-1wagb550.js";
|
|
13
|
-
import {
|
|
14
|
-
autoSyncProjectOnOpen,
|
|
15
|
-
cleanupGitPanel,
|
|
16
|
-
maybePromptJxsuiteUpdate,
|
|
17
|
-
shouldInstallAutomation
|
|
18
|
-
} from "./studio-gfgb8pe6.js";
|
|
19
|
-
import {
|
|
20
|
-
collectionOfPath
|
|
21
|
-
} from "./studio-6yw4y3my.js";
|
|
22
|
-
import {
|
|
23
|
-
openCsvGridTab,
|
|
24
|
-
openPagesGrid
|
|
25
|
-
} from "./studio-3bqpr0zh.js";
|
|
26
|
-
import {
|
|
27
|
-
confirmFileDelete,
|
|
28
|
-
disarmPreviewOverlay,
|
|
29
|
-
loadMediaUsages,
|
|
30
|
-
mediaUsageHeadline,
|
|
31
|
-
parseSourceForPath,
|
|
32
|
-
peekMediaUsages,
|
|
33
|
-
renamePromptMessage
|
|
34
|
-
} from "./studio-cmb03bg5.js";
|
|
35
|
-
import {
|
|
36
|
-
ensureIgnoreLayers,
|
|
37
|
-
isIgnoredEntry,
|
|
38
|
-
markLocalMutation,
|
|
39
|
-
resetIgnoreCache
|
|
40
|
-
} from "./studio-q43a5y9h.js";
|
|
41
|
-
import {
|
|
42
|
-
extensionOf,
|
|
43
|
-
isImage,
|
|
44
|
-
isMediaFile,
|
|
45
|
-
mediaKind,
|
|
46
|
-
mediaSiteUrl,
|
|
47
|
-
previewFileSrc,
|
|
48
|
-
uploadAccept,
|
|
49
|
-
uploadAssets
|
|
50
|
-
} from "./studio-qjy2z9bv.js";
|
|
51
|
-
import {
|
|
52
|
-
invalidateUsages
|
|
53
|
-
} from "./studio-cft9r4r7.js";
|
|
54
|
-
import {
|
|
55
|
-
showProgressModal
|
|
56
|
-
} from "./studio-4n2b5gzb.js";
|
|
57
|
-
import {
|
|
58
|
-
rectOf,
|
|
59
|
-
registerPanel
|
|
60
|
-
} from "./studio-2b946z26.js";
|
|
61
|
-
import {
|
|
62
|
-
markSessionRestored,
|
|
63
|
-
persistedSession,
|
|
64
|
-
resetProjectShell,
|
|
65
|
-
restoreSession,
|
|
66
|
-
setActivityTab
|
|
67
|
-
} from "./studio-msd847zn.js";
|
|
68
|
-
import {
|
|
69
|
-
activateTab,
|
|
70
|
-
collectionForDirectory,
|
|
71
|
-
collectionForFile,
|
|
72
|
-
isCollabPath,
|
|
73
|
-
localeLabel,
|
|
74
|
-
localeOfPath,
|
|
75
|
-
moveTabToPane,
|
|
76
|
-
openTab,
|
|
77
|
-
paneOfTab,
|
|
78
|
-
receivingPane,
|
|
79
|
-
renameTab,
|
|
80
|
-
replaceAllTabs,
|
|
81
|
-
resolveI18n,
|
|
82
|
-
setWorkspaceProject,
|
|
83
|
-
workspace
|
|
84
|
-
} from "./studio-trxrabqf.js";
|
|
85
|
-
import {
|
|
86
|
-
classMap
|
|
87
|
-
} from "./studio-m3hwn7y1.js";
|
|
88
|
-
import {
|
|
89
|
-
combine,
|
|
90
|
-
draggable,
|
|
91
|
-
dropTargetForElements,
|
|
92
|
-
monitorForElements
|
|
93
|
-
} from "./studio-g1wdche0.js";
|
|
94
|
-
import {
|
|
95
|
-
loadComponentRegistry
|
|
96
|
-
} from "./studio-bgxt93ga.js";
|
|
97
|
-
import {
|
|
98
|
-
projectState,
|
|
99
|
-
requireProjectState,
|
|
100
|
-
setProjectState
|
|
101
|
-
} from "./studio-p4ngc046.js";
|
|
102
|
-
import {
|
|
103
|
-
activeRegistry,
|
|
104
|
-
paneRegion,
|
|
105
|
-
renderPopover,
|
|
106
|
-
showPromptDialog
|
|
107
|
-
} from "./studio-t7qb9db8.js";
|
|
108
|
-
import {
|
|
109
|
-
errorMessage
|
|
110
|
-
} from "./studio-9n4mrmnb.js";
|
|
111
|
-
import {
|
|
112
|
-
SETTINGS,
|
|
113
|
-
readStoredSetting,
|
|
114
|
-
setSetting
|
|
115
|
-
} from "./studio-92ab2jqe.js";
|
|
116
|
-
import {
|
|
117
|
-
effect,
|
|
118
|
-
effectScope,
|
|
119
|
-
notify,
|
|
120
|
-
now
|
|
121
|
-
} from "./studio-xrapxwwc.js";
|
|
122
|
-
import {
|
|
123
|
-
ref,
|
|
124
|
-
repeat
|
|
125
|
-
} from "./studio-4rzyrtjz.js";
|
|
126
|
-
import {
|
|
127
|
-
html,
|
|
128
|
-
nothing,
|
|
129
|
-
render
|
|
130
|
-
} from "./studio-kryvsw6j.js";
|
|
131
|
-
import {
|
|
132
|
-
documentExtensions,
|
|
133
|
-
formatByExtension,
|
|
134
|
-
formatForPath,
|
|
135
|
-
getFormats,
|
|
136
|
-
loadFormats,
|
|
137
|
-
noFormatError,
|
|
138
|
-
refreshExtensionUi,
|
|
139
|
-
refreshFormats
|
|
140
|
-
} from "./studio-ahn3pdgx.js";
|
|
141
|
-
import {
|
|
142
|
-
getPlatform,
|
|
143
|
-
hasPlatform
|
|
144
|
-
} from "./studio-9ab8gqsm.js";
|
|
145
|
-
import {
|
|
146
|
-
__require
|
|
147
|
-
} from "./studio-a0tswy0w.js";
|
|
148
|
-
|
|
149
|
-
// src/packages/ensure-deps.ts
|
|
150
|
-
async function ensureDependenciesInstalled() {
|
|
151
|
-
if (shouldInstallAutomation(location.search)) {
|
|
152
|
-
return false;
|
|
153
|
-
}
|
|
154
|
-
const platform = getPlatform();
|
|
155
|
-
if (!platform.dependenciesNeedInstall || !platform.installDependencies) {
|
|
156
|
-
return false;
|
|
157
|
-
}
|
|
158
|
-
let needs = false;
|
|
159
|
-
try {
|
|
160
|
-
needs = await platform.dependenciesNeedInstall();
|
|
161
|
-
} catch {
|
|
162
|
-
return false;
|
|
163
|
-
}
|
|
164
|
-
if (!needs) {
|
|
165
|
-
return false;
|
|
166
|
-
}
|
|
167
|
-
const progress = showProgressModal({
|
|
168
|
-
status: "Running bun install…",
|
|
169
|
-
title: "Installing dependencies"
|
|
170
|
-
});
|
|
171
|
-
try {
|
|
172
|
-
const result = await platform.installDependencies();
|
|
173
|
-
if (result.ok) {
|
|
174
|
-
progress.done();
|
|
175
|
-
return true;
|
|
176
|
-
}
|
|
177
|
-
progress.fail(result.log ?? "bun install failed");
|
|
178
|
-
} catch (error) {
|
|
179
|
-
progress.fail(error instanceof Error ? error.message : String(error));
|
|
180
|
-
}
|
|
181
|
-
return false;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
// src/media/media-pane.ts
|
|
185
|
-
var MEDIA_MODE = "media";
|
|
186
|
-
var FONT_EXTENSIONS = new Set([".woff", ".woff2", ".ttf", ".otf"]);
|
|
187
|
-
var SPECIMEN = "The quick brown fox jumps over the lazy dog";
|
|
188
|
-
var SPECIMEN_SIZES = [48, 32, 24, 18, 14];
|
|
189
|
-
var _active = new Map;
|
|
190
|
-
function activeIn(paneId) {
|
|
191
|
-
return _active.get(paneId) ?? null;
|
|
192
|
-
}
|
|
193
|
-
function mediaPaneMounted(paneId, tab) {
|
|
194
|
-
const panel = activeIn(paneId);
|
|
195
|
-
return panel !== null && panel.tabId === tab.id && panel.wrap.isConnected;
|
|
196
|
-
}
|
|
197
|
-
function detachMediaPane(paneId) {
|
|
198
|
-
const panel = _active.get(paneId);
|
|
199
|
-
if (!panel) {
|
|
200
|
-
return;
|
|
201
|
-
}
|
|
202
|
-
panel.scope.stop();
|
|
203
|
-
_active.delete(paneId);
|
|
204
|
-
}
|
|
205
|
-
function assetTpl(path, src, redraw) {
|
|
206
|
-
const ext = extensionOf(path);
|
|
207
|
-
const kind = mediaKind({ name: path });
|
|
208
|
-
if (FONT_EXTENSIONS.has(ext)) {
|
|
209
|
-
const family = `jx-specimen-${path.replaceAll(/[^a-zA-Z0-9]/g, "-")}`;
|
|
210
|
-
return html`
|
|
211
|
-
<style>
|
|
212
|
-
@font-face {
|
|
213
|
-
font-family: "${family}";
|
|
214
|
-
src: url("${src}");
|
|
215
|
-
}
|
|
216
|
-
</style>
|
|
217
|
-
<div class="media-specimen" style="font-family: '${family}', system-ui, sans-serif">
|
|
218
|
-
${SPECIMEN_SIZES.map((size) => html`<p class="media-specimen-line" style="font-size: ${size}px">
|
|
219
|
-
${SPECIMEN}
|
|
220
|
-
</p>`)}
|
|
221
|
-
</div>
|
|
222
|
-
`;
|
|
223
|
-
}
|
|
224
|
-
switch (kind) {
|
|
225
|
-
case "image": {
|
|
226
|
-
return html`<img
|
|
227
|
-
class="media-image"
|
|
228
|
-
src=${src}
|
|
229
|
-
alt=""
|
|
230
|
-
@load=${(e) => {
|
|
231
|
-
const img = e.target;
|
|
232
|
-
if (recordImageSize(path, img.naturalWidth, img.naturalHeight)) {
|
|
233
|
-
redraw();
|
|
234
|
-
}
|
|
235
|
-
}}
|
|
236
|
-
/>`;
|
|
237
|
-
}
|
|
238
|
-
case "video": {
|
|
239
|
-
return html`<video class="media-video" src=${src} controls></video>`;
|
|
240
|
-
}
|
|
241
|
-
case "audio": {
|
|
242
|
-
return html`<audio class="media-audio" src=${src} controls></audio>`;
|
|
243
|
-
}
|
|
244
|
-
default: {
|
|
245
|
-
return ext === ".pdf" ? html`<embed class="media-embed" src=${src} type="application/pdf" />` : html`<div class="media-unviewable">
|
|
246
|
-
<p>Jx has no viewer for <code>${ext || "this file"}</code>.</p>
|
|
247
|
-
<p class="media-note">The file is in the project and builds normally.</p>
|
|
248
|
-
</div>`;
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
function factsTpl(path, meta) {
|
|
253
|
-
const facts = [mediaKind({ name: path })];
|
|
254
|
-
if (meta?.width != null && meta.height != null) {
|
|
255
|
-
facts.push(`${meta.width} × ${meta.height}`);
|
|
256
|
-
}
|
|
257
|
-
if (meta?.bytes != null) {
|
|
258
|
-
facts.push(formatBytes(meta.bytes));
|
|
259
|
-
}
|
|
260
|
-
if (meta?.modified) {
|
|
261
|
-
facts.push(`modified ${meta.modified.slice(0, 10)}`);
|
|
262
|
-
}
|
|
263
|
-
return html`<p class="media-facts">${facts.join(" · ")}</p>`;
|
|
264
|
-
}
|
|
265
|
-
function refTpl(path) {
|
|
266
|
-
const ref2 = mediaSiteUrl(path);
|
|
267
|
-
return html`
|
|
268
|
-
<div class="media-ref">
|
|
269
|
-
<code class="media-ref-value">${ref2}</code>
|
|
270
|
-
<sp-action-button
|
|
271
|
-
size="s"
|
|
272
|
-
quiet
|
|
273
|
-
title="Copy the reference"
|
|
274
|
-
@click=${() => {
|
|
275
|
-
navigator.clipboard?.writeText(ref2);
|
|
276
|
-
}}
|
|
277
|
-
>Copy</sp-action-button
|
|
278
|
-
>
|
|
279
|
-
</div>
|
|
280
|
-
`;
|
|
281
|
-
}
|
|
282
|
-
function usageTpl(usage) {
|
|
283
|
-
const headline = mediaUsageHeadline(usage);
|
|
284
|
-
if (headline === null) {
|
|
285
|
-
return nothing;
|
|
286
|
-
}
|
|
287
|
-
const files = usage?.status === "ready" ? usage.result.files : [];
|
|
288
|
-
return html`
|
|
289
|
-
<div class="media-usage">
|
|
290
|
-
<h4 class="media-usage-title">Used by</h4>
|
|
291
|
-
<p class="media-usage-headline">${headline}</p>
|
|
292
|
-
${files.length === 0 ? nothing : html`<ul class="media-usage-list">
|
|
293
|
-
${files.map((file) => html`<li>
|
|
294
|
-
<button
|
|
295
|
-
type="button"
|
|
296
|
-
class="media-usage-link"
|
|
297
|
-
@click=${() => {
|
|
298
|
-
openDocument(file.path);
|
|
299
|
-
}}
|
|
300
|
-
>
|
|
301
|
-
${file.path}
|
|
302
|
-
</button>
|
|
303
|
-
<span class="media-usage-count">${file.count}</span>
|
|
304
|
-
</li>`)}
|
|
305
|
-
</ul>`}
|
|
306
|
-
</div>
|
|
307
|
-
`;
|
|
308
|
-
}
|
|
309
|
-
async function openDocument(path) {
|
|
310
|
-
const { openFileInTab } = await import("./files-3kfkwhk4.js");
|
|
311
|
-
await openFileInTab(path);
|
|
312
|
-
}
|
|
313
|
-
function renderMediaMode(surface, tab) {
|
|
314
|
-
const { paneId, wrap: canvasWrap } = surface;
|
|
315
|
-
if (mediaPaneMounted(paneId, tab)) {
|
|
316
|
-
return;
|
|
317
|
-
}
|
|
318
|
-
detachMediaPane(paneId);
|
|
319
|
-
const scope = effectScope();
|
|
320
|
-
const panel = { paneId, scope, tabId: tab.id, wrap: canvasWrap };
|
|
321
|
-
_active.set(paneId, panel);
|
|
322
|
-
const path = tab.documentPath ?? "";
|
|
323
|
-
const redraw = () => {
|
|
324
|
-
if (activeIn(paneId) === panel) {
|
|
325
|
-
draw();
|
|
326
|
-
}
|
|
327
|
-
};
|
|
328
|
-
const draw = () => {
|
|
329
|
-
const meta = peekMediaMeta(path);
|
|
330
|
-
const usage = peekMediaUsages(path);
|
|
331
|
-
if (meta === null) {
|
|
332
|
-
loadMediaMeta(path).then(redraw);
|
|
333
|
-
}
|
|
334
|
-
if (usage === null || usage.status === "pending") {
|
|
335
|
-
loadMediaUsages(path).then(redraw);
|
|
336
|
-
}
|
|
337
|
-
render(html`
|
|
338
|
-
<div class="media-viewer" data-jx-region=${paneRegion(paneId, "media")}>
|
|
339
|
-
<div class="media-stage">${assetTpl(path, previewFileSrc(path), redraw)}</div>
|
|
340
|
-
<div class="media-details">
|
|
341
|
-
<h3 class="media-name">${path.split("/").pop()}</h3>
|
|
342
|
-
${factsTpl(path, meta)} ${refTpl(path)} ${usageTpl(usage)}
|
|
343
|
-
</div>
|
|
344
|
-
</div>
|
|
345
|
-
`, canvasWrap);
|
|
346
|
-
};
|
|
347
|
-
scope.run(() => {
|
|
348
|
-
effect(() => {
|
|
349
|
-
if (activeIn(paneId) !== panel) {
|
|
350
|
-
return;
|
|
351
|
-
}
|
|
352
|
-
tab.documentPath;
|
|
353
|
-
draw();
|
|
354
|
-
});
|
|
355
|
-
});
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
// src/media/media-open.ts
|
|
359
|
-
var MEDIA_STUB_DOCUMENT = { children: [], tagName: "div" };
|
|
360
|
-
function isViewableMedia(path) {
|
|
361
|
-
return isMediaFile(path);
|
|
362
|
-
}
|
|
363
|
-
function mediaTabModes(path) {
|
|
364
|
-
return extensionOf(path) === ".svg" ? [MEDIA_MODE, "source"] : [MEDIA_MODE];
|
|
365
|
-
}
|
|
366
|
-
function openMediaTab(path) {
|
|
367
|
-
const existing = workspace.tabs.get(path);
|
|
368
|
-
if (existing) {
|
|
369
|
-
activateTab(path);
|
|
370
|
-
return existing;
|
|
371
|
-
}
|
|
372
|
-
return openTab({
|
|
373
|
-
capabilities: { modes: mediaTabModes(path) },
|
|
374
|
-
document: structuredClone(MEDIA_STUB_DOCUMENT),
|
|
375
|
-
documentPath: path,
|
|
376
|
-
id: path,
|
|
377
|
-
sourceFormat: null
|
|
378
|
-
});
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
// src/format/format-choices.ts
|
|
382
|
-
var DOCUMENT_KINDS = ["page", "component"];
|
|
383
|
-
var DOCUMENT_ROOTS = { components: "component", pages: "page" };
|
|
384
|
-
function normalize(path) {
|
|
385
|
-
return path.replaceAll("\\", "/").replace(/^\.\//, "");
|
|
386
|
-
}
|
|
387
|
-
function documentRootOf(path) {
|
|
388
|
-
const lower = normalize(path).toLowerCase();
|
|
389
|
-
for (const [dir, kind] of Object.entries(DOCUMENT_ROOTS)) {
|
|
390
|
-
if (lower.startsWith(`${dir}/`)) {
|
|
391
|
-
return kind;
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
return null;
|
|
395
|
-
}
|
|
396
|
-
function declaresDocumentKind(kinds) {
|
|
397
|
-
return DOCUMENT_KINDS.some((kind) => kinds.includes(kind));
|
|
398
|
-
}
|
|
399
|
-
function isLayoutPath(path) {
|
|
400
|
-
const declared = projectState?.projectConfig?.layout;
|
|
401
|
-
if (typeof declared !== "string") {
|
|
402
|
-
return false;
|
|
403
|
-
}
|
|
404
|
-
return normalize(declared).toLowerCase() === normalize(path).toLowerCase();
|
|
405
|
-
}
|
|
406
|
-
function creationFormats(kind) {
|
|
407
|
-
const rows = [{ ext: ".json", label: "JSON (.json)" }];
|
|
408
|
-
for (const ext of documentExtensions(kind)) {
|
|
409
|
-
const reader = formatByExtension(ext, "parse");
|
|
410
|
-
if (reader && formatByExtension(ext, "serialize")) {
|
|
411
|
-
rows.push({ ext, label: `${reader.name} (${ext})` });
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
return rows;
|
|
415
|
-
}
|
|
416
|
-
function knownDocumentExtensions() {
|
|
417
|
-
return new Set([".json", ...getFormats().flatMap((format) => format.extensions)]);
|
|
418
|
-
}
|
|
419
|
-
function convertTargets(path) {
|
|
420
|
-
if (path === null || path === undefined || path === "") {
|
|
421
|
-
return [];
|
|
422
|
-
}
|
|
423
|
-
const root = documentRootOf(path);
|
|
424
|
-
if (root === null || isLayoutPath(path) || collectionForFile(path)) {
|
|
425
|
-
return [];
|
|
426
|
-
}
|
|
427
|
-
const source = formatForPath(path);
|
|
428
|
-
const readable = source ? Boolean(source.capabilities.parse) && declaresDocumentKind(source.documentKinds) : normalize(path).toLowerCase().endsWith(".json");
|
|
429
|
-
if (!readable) {
|
|
430
|
-
return [];
|
|
431
|
-
}
|
|
432
|
-
const rows = [];
|
|
433
|
-
if (source) {
|
|
434
|
-
rows.push({ ext: ".json", label: "JSON (.json)" });
|
|
435
|
-
}
|
|
436
|
-
for (const ext of documentExtensions()) {
|
|
437
|
-
const writer = formatByExtension(ext, "serialize");
|
|
438
|
-
if (!writer || writer.name === source?.name || !declaresDocumentKind(writer.documentKinds) || !writer.documentKinds.includes(root)) {
|
|
439
|
-
continue;
|
|
440
|
-
}
|
|
441
|
-
rows.push({ ext, label: `${writer.name} (${ext})` });
|
|
442
|
-
}
|
|
443
|
-
return rows;
|
|
444
|
-
}
|
|
445
|
-
function convertTargetExtensions() {
|
|
446
|
-
const exts = new Set([".json"]);
|
|
447
|
-
for (const format of getFormats()) {
|
|
448
|
-
if (!format.capabilities.serialize || !declaresDocumentKind(format.documentKinds)) {
|
|
449
|
-
continue;
|
|
450
|
-
}
|
|
451
|
-
for (const ext of format.extensions) {
|
|
452
|
-
exts.add(ext);
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
return [...exts].toSorted();
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
// src/recent-projects.ts
|
|
459
|
-
var STORAGE_KEY = "jx-studio-recent-projects";
|
|
460
|
-
var FILES_STORAGE_KEY = "jx-studio-recent-files";
|
|
461
|
-
var MAX_RECENT = 8;
|
|
462
|
-
var MAX_RECENT_FILES = 10;
|
|
463
|
-
var cache = [];
|
|
464
|
-
function backend() {
|
|
465
|
-
if (!hasPlatform()) {
|
|
466
|
-
return null;
|
|
467
|
-
}
|
|
468
|
-
const platform = getPlatform();
|
|
469
|
-
return platform.getRecentProjects && platform.saveRecentProjects ? platform : null;
|
|
470
|
-
}
|
|
471
|
-
function loadFromLocalStorage() {
|
|
472
|
-
try {
|
|
473
|
-
const raw = localStorage.getItem(STORAGE_KEY);
|
|
474
|
-
if (!raw) {
|
|
475
|
-
return [];
|
|
476
|
-
}
|
|
477
|
-
const parsed = JSON.parse(raw);
|
|
478
|
-
return Array.isArray(parsed) ? parsed : [];
|
|
479
|
-
} catch {
|
|
480
|
-
return [];
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
function currentList() {
|
|
484
|
-
return backend() ? cache : loadFromLocalStorage();
|
|
485
|
-
}
|
|
486
|
-
function commit(list) {
|
|
487
|
-
cache = list;
|
|
488
|
-
const store = backend();
|
|
489
|
-
if (store) {
|
|
490
|
-
store.saveRecentProjects(list);
|
|
491
|
-
} else {
|
|
492
|
-
try {
|
|
493
|
-
localStorage.setItem(STORAGE_KEY, JSON.stringify(list));
|
|
494
|
-
} catch {}
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
|
-
async function hydrateRecentProjects() {
|
|
498
|
-
const store = backend();
|
|
499
|
-
if (!store) {
|
|
500
|
-
return;
|
|
501
|
-
}
|
|
502
|
-
try {
|
|
503
|
-
cache = await store.getRecentProjects();
|
|
504
|
-
} catch {
|
|
505
|
-
cache = [];
|
|
506
|
-
}
|
|
507
|
-
}
|
|
508
|
-
function getRecentProjects() {
|
|
509
|
-
return currentList().toSorted((a, b) => b.timestamp - a.timestamp);
|
|
510
|
-
}
|
|
511
|
-
function addRecentProject(name, root) {
|
|
512
|
-
const projects = currentList().filter((p) => p.root !== root);
|
|
513
|
-
projects.unshift({ name, root, timestamp: now() });
|
|
514
|
-
if (projects.length > MAX_RECENT) {
|
|
515
|
-
projects.length = MAX_RECENT;
|
|
516
|
-
}
|
|
517
|
-
commit(projects);
|
|
518
|
-
}
|
|
519
|
-
function removeRecentProject(root) {
|
|
520
|
-
commit(currentList().filter((p) => p.root !== root));
|
|
521
|
-
}
|
|
522
|
-
function clearRecentProjects() {
|
|
523
|
-
cache = [];
|
|
524
|
-
const store = backend();
|
|
525
|
-
if (store) {
|
|
526
|
-
store.saveRecentProjects([]);
|
|
527
|
-
} else {
|
|
528
|
-
localStorage.removeItem(STORAGE_KEY);
|
|
529
|
-
}
|
|
530
|
-
}
|
|
531
|
-
function loadRecentFiles() {
|
|
532
|
-
try {
|
|
533
|
-
const raw = localStorage.getItem(FILES_STORAGE_KEY);
|
|
534
|
-
if (!raw) {
|
|
535
|
-
return [];
|
|
536
|
-
}
|
|
537
|
-
const parsed = JSON.parse(raw);
|
|
538
|
-
return Array.isArray(parsed) ? parsed : [];
|
|
539
|
-
} catch {
|
|
540
|
-
return [];
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
function getRecentFiles(root) {
|
|
544
|
-
const all = loadRecentFiles().toSorted((a, b) => b.timestamp - a.timestamp);
|
|
545
|
-
return root == null ? all : all.filter((f) => f.root === root);
|
|
546
|
-
}
|
|
547
|
-
function trackRecentFile(file) {
|
|
548
|
-
const all = loadRecentFiles().filter((f) => !(f.root === file.root && f.path === file.path));
|
|
549
|
-
all.unshift({ name: file.name, path: file.path, root: file.root, timestamp: now() });
|
|
550
|
-
const perRoot = new Map;
|
|
551
|
-
const kept = [];
|
|
552
|
-
for (const f of all.toSorted((a, b) => b.timestamp - a.timestamp)) {
|
|
553
|
-
const n = (perRoot.get(f.root) ?? 0) + 1;
|
|
554
|
-
perRoot.set(f.root, n);
|
|
555
|
-
if (n <= MAX_RECENT_FILES) {
|
|
556
|
-
kept.push(f);
|
|
557
|
-
}
|
|
558
|
-
}
|
|
559
|
-
localStorage.setItem(FILES_STORAGE_KEY, JSON.stringify(kept));
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
// src/files/files.ts
|
|
563
|
-
var fileIconMap = {
|
|
564
|
-
"sp-icon-document": html`<sp-icon-document></sp-icon-document>`,
|
|
565
|
-
"sp-icon-file-code": html`<sp-icon-file-code></sp-icon-file-code>`,
|
|
566
|
-
"sp-icon-file-txt": html`<sp-icon-file-txt></sp-icon-file-txt>`,
|
|
567
|
-
"sp-icon-folder": html`<sp-icon-folder></sp-icon-folder>`,
|
|
568
|
-
"sp-icon-folder-open": html`<sp-icon-folder-open></sp-icon-folder-open>`,
|
|
569
|
-
"sp-icon-image": html`<sp-icon-image></sp-icon-image>`
|
|
570
|
-
};
|
|
571
|
-
async function loadDirectory(dirPath) {
|
|
572
|
-
if (!projectState) {
|
|
573
|
-
return;
|
|
574
|
-
}
|
|
575
|
-
try {
|
|
576
|
-
const platform = getPlatform();
|
|
577
|
-
const [entries] = await Promise.all([
|
|
578
|
-
platform.listDirectory(dirPath),
|
|
579
|
-
ensureIgnoreLayers(dirPath)
|
|
580
|
-
]);
|
|
581
|
-
projectState.dirs.set(dirPath, entries);
|
|
582
|
-
} catch {
|
|
583
|
-
projectState.dirs.set(dirPath, []);
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
function showIgnoredFiles() {
|
|
587
|
-
return readStoredSetting(SETTINGS.showIgnoredFiles) === "true";
|
|
588
|
-
}
|
|
589
|
-
function setShowIgnoredFiles(show) {
|
|
590
|
-
setSetting(SETTINGS.showIgnoredFiles, show ? "true" : "");
|
|
591
|
-
}
|
|
592
|
-
async function loadProject() {
|
|
593
|
-
try {
|
|
594
|
-
const platform = getPlatform();
|
|
595
|
-
const result = await platform.probeRootProject();
|
|
596
|
-
if (!result) {
|
|
597
|
-
return;
|
|
598
|
-
}
|
|
599
|
-
const { meta, info } = result;
|
|
600
|
-
refreshFormats();
|
|
601
|
-
loadFormats();
|
|
602
|
-
refreshExtensionUi(platform);
|
|
603
|
-
resetIgnoreCache();
|
|
604
|
-
setProjectState({
|
|
605
|
-
dirs: new Map,
|
|
606
|
-
expanded: new Set,
|
|
607
|
-
isSiteProject: info.isSiteProject,
|
|
608
|
-
name: info.isSiteProject ? info.projectConfig?.name || meta.name : meta.name,
|
|
609
|
-
projectConfig: (info.isSiteProject ? info.projectConfig : null) || null,
|
|
610
|
-
projectDirs: info.directories || [],
|
|
611
|
-
projectRoot: ".",
|
|
612
|
-
root: meta.root,
|
|
613
|
-
searchQuery: "",
|
|
614
|
-
selectedPath: null
|
|
615
|
-
});
|
|
616
|
-
if (info.isSiteProject) {
|
|
617
|
-
setWorkspaceProject(meta.root || ".", info.projectConfig || null);
|
|
618
|
-
}
|
|
619
|
-
if (info.isSiteProject) {
|
|
620
|
-
addRecentProject(requireProjectState().name, meta.root);
|
|
621
|
-
await autoSyncProjectOnOpen();
|
|
622
|
-
if (await ensureDependenciesInstalled()) {
|
|
623
|
-
refreshFormats();
|
|
624
|
-
await loadFormats();
|
|
625
|
-
refreshExtensionUi(platform);
|
|
626
|
-
}
|
|
627
|
-
await loadDirectory(".");
|
|
628
|
-
await loadComponentRegistry();
|
|
629
|
-
await openLastSessionOrHome();
|
|
630
|
-
maybePromptJxsuiteUpdate(meta.root);
|
|
631
|
-
}
|
|
632
|
-
} catch {}
|
|
633
|
-
}
|
|
634
|
-
async function openProject({
|
|
635
|
-
renderLeftPanel
|
|
636
|
-
}) {
|
|
637
|
-
try {
|
|
638
|
-
const platform = getPlatform();
|
|
639
|
-
const result = await platform.openProject();
|
|
640
|
-
if (!result) {
|
|
641
|
-
return false;
|
|
642
|
-
}
|
|
643
|
-
const { config, handle } = result;
|
|
644
|
-
replaceAllTabs({
|
|
645
|
-
document: { children: [], tagName: "div" },
|
|
646
|
-
id: "initial"
|
|
647
|
-
});
|
|
648
|
-
disarmPreviewOverlay();
|
|
649
|
-
refreshFormats();
|
|
650
|
-
loadFormats();
|
|
651
|
-
refreshExtensionUi(platform);
|
|
652
|
-
resetIgnoreCache();
|
|
653
|
-
setProjectState({
|
|
654
|
-
...projectState,
|
|
655
|
-
dirs: new Map,
|
|
656
|
-
expanded: new Set,
|
|
657
|
-
isSiteProject: true,
|
|
658
|
-
name: config.name || handle.name,
|
|
659
|
-
projectConfig: config,
|
|
660
|
-
projectRoot: handle.root,
|
|
661
|
-
searchQuery: "",
|
|
662
|
-
selectedPath: null
|
|
663
|
-
});
|
|
664
|
-
setWorkspaceProject(handle.root, config);
|
|
665
|
-
await autoSyncProjectOnOpen();
|
|
666
|
-
if (await ensureDependenciesInstalled()) {
|
|
667
|
-
refreshFormats();
|
|
668
|
-
await loadFormats();
|
|
669
|
-
refreshExtensionUi(platform);
|
|
670
|
-
}
|
|
671
|
-
await loadDirectory(".");
|
|
672
|
-
await loadComponentRegistry();
|
|
673
|
-
const conventionalDirs = new Set([
|
|
674
|
-
"pages",
|
|
675
|
-
"layouts",
|
|
676
|
-
"components",
|
|
677
|
-
"content",
|
|
678
|
-
"data",
|
|
679
|
-
"public",
|
|
680
|
-
"styles"
|
|
681
|
-
]);
|
|
682
|
-
const entries = requireProjectState().dirs.get(".") || [];
|
|
683
|
-
const foundDirs = [];
|
|
684
|
-
for (const e of entries) {
|
|
685
|
-
if (e.type === "directory" && conventionalDirs.has(e.name)) {
|
|
686
|
-
foundDirs.push(e.name);
|
|
687
|
-
requireProjectState().expanded.add(e.path || e.name);
|
|
688
|
-
await loadDirectory(e.path || e.name);
|
|
689
|
-
}
|
|
690
|
-
}
|
|
691
|
-
requireProjectState().projectDirs = foundDirs;
|
|
692
|
-
cleanupGitPanel();
|
|
693
|
-
resetProjectShell();
|
|
694
|
-
setActivityTab("files");
|
|
695
|
-
addRecentProject(requireProjectState().name, requireProjectState().projectRoot);
|
|
696
|
-
renderLeftPanel();
|
|
697
|
-
await openLastSessionOrHome();
|
|
698
|
-
maybePromptJxsuiteUpdate(requireProjectState().projectRoot);
|
|
699
|
-
return true;
|
|
700
|
-
} catch (error) {
|
|
701
|
-
notify.error("Could not open the project.", {
|
|
702
|
-
detail: errorMessage(error),
|
|
703
|
-
source: "Open Project"
|
|
704
|
-
});
|
|
705
|
-
return false;
|
|
706
|
-
}
|
|
707
|
-
}
|
|
708
|
-
async function initProjectRepo(root) {
|
|
709
|
-
const platform = getPlatform();
|
|
710
|
-
if (platform.createDestination !== "path") {
|
|
711
|
-
return false;
|
|
712
|
-
}
|
|
713
|
-
try {
|
|
714
|
-
await platform.activate(root);
|
|
715
|
-
const status = await platform.gitStatus();
|
|
716
|
-
if (status.isRepo) {
|
|
717
|
-
return false;
|
|
718
|
-
}
|
|
719
|
-
await platform.gitInit();
|
|
720
|
-
notify.success("Initialized a git repository for this project.");
|
|
721
|
-
return true;
|
|
722
|
-
} catch (error) {
|
|
723
|
-
notify.warn("Could not initialize a git repository — the project itself was written.", {
|
|
724
|
-
detail: errorMessage(error),
|
|
725
|
-
source: "Source Control"
|
|
726
|
-
});
|
|
727
|
-
return false;
|
|
728
|
-
}
|
|
729
|
-
}
|
|
730
|
-
async function findHomePage() {
|
|
731
|
-
await loadFormats();
|
|
732
|
-
const exts = [...documentExtensions("page"), ".json"];
|
|
733
|
-
let entries;
|
|
734
|
-
try {
|
|
735
|
-
entries = await getPlatform().listDirectory("pages");
|
|
736
|
-
} catch {
|
|
737
|
-
return null;
|
|
738
|
-
}
|
|
739
|
-
const files = new Set(entries.filter((e) => e.type === "file").map((e) => e.name));
|
|
740
|
-
for (const ext of exts) {
|
|
741
|
-
if (files.has(`index${ext}`)) {
|
|
742
|
-
return `pages/index${ext}`;
|
|
743
|
-
}
|
|
744
|
-
}
|
|
745
|
-
return null;
|
|
746
|
-
}
|
|
747
|
-
async function openHomePage() {
|
|
748
|
-
const home = await findHomePage();
|
|
749
|
-
if (home) {
|
|
750
|
-
await openFileInTab(home);
|
|
751
|
-
}
|
|
752
|
-
}
|
|
753
|
-
async function openLastSessionOrHome() {
|
|
754
|
-
const session = persistedSession(workspace.projectRoot);
|
|
755
|
-
markSessionRestored(workspace.projectRoot);
|
|
756
|
-
if (session) {
|
|
757
|
-
const opened = await restoreSession(session, {
|
|
758
|
-
ensureSecondPane: () => {
|
|
759
|
-
receivingPane();
|
|
760
|
-
},
|
|
761
|
-
openFile: (path, paneId) => openFileInTab(path, { focus: false, paneId })
|
|
762
|
-
});
|
|
763
|
-
if (opened > 0) {
|
|
764
|
-
return true;
|
|
765
|
-
}
|
|
766
|
-
}
|
|
767
|
-
await openHomePage();
|
|
768
|
-
return false;
|
|
769
|
-
}
|
|
770
|
-
function fileTypeIconTpl(name, type) {
|
|
771
|
-
let tag;
|
|
772
|
-
if (type === "directory") {
|
|
773
|
-
tag = projectState?.expanded?.has(name) ? "sp-icon-folder-open" : "sp-icon-folder";
|
|
774
|
-
} else {
|
|
775
|
-
const ext = name.split(".").pop()?.toLowerCase();
|
|
776
|
-
switch (ext) {
|
|
777
|
-
case "json": {
|
|
778
|
-
tag = "sp-icon-file-code";
|
|
779
|
-
break;
|
|
780
|
-
}
|
|
781
|
-
case "md": {
|
|
782
|
-
tag = "sp-icon-file-txt";
|
|
783
|
-
break;
|
|
784
|
-
}
|
|
785
|
-
case "js":
|
|
786
|
-
case "ts": {
|
|
787
|
-
tag = "sp-icon-file-code";
|
|
788
|
-
break;
|
|
789
|
-
}
|
|
790
|
-
case "css": {
|
|
791
|
-
tag = "sp-icon-file-code";
|
|
792
|
-
break;
|
|
793
|
-
}
|
|
794
|
-
default: {
|
|
795
|
-
tag = ext && isImage(ext) ? "sp-icon-image" : "sp-icon-document";
|
|
796
|
-
break;
|
|
797
|
-
}
|
|
798
|
-
}
|
|
799
|
-
}
|
|
800
|
-
return fileIconMap[tag] || fileIconMap["sp-icon-document"];
|
|
801
|
-
}
|
|
802
|
-
function renderFilesTemplate({
|
|
803
|
-
openProject: openProjectFn,
|
|
804
|
-
openFileFromTree: openFileFn,
|
|
805
|
-
renderLeftPanel
|
|
806
|
-
}) {
|
|
807
|
-
if (!projectState) {
|
|
808
|
-
return html`<div class="file-tree-empty">No project loaded</div>`;
|
|
809
|
-
}
|
|
810
|
-
if (!projectState.isSiteProject && projectState.projectRoot === ".") {
|
|
811
|
-
return html`<div class="file-tree-empty">
|
|
812
|
-
<p style="margin:0 0 12px">Open a project folder to get started.</p>
|
|
813
|
-
<sp-button variant="accent" size="s" @click=${openProjectFn}>Open Project</sp-button>
|
|
814
|
-
</div>`;
|
|
815
|
-
}
|
|
816
|
-
const showingIgnored = showIgnoredFiles();
|
|
817
|
-
return html`
|
|
818
|
-
${projectState.isSiteProject ? html`
|
|
819
|
-
<div class="project-header">
|
|
820
|
-
<span class="project-name"
|
|
821
|
-
>${projectState.projectConfig?.name || projectState.name}</span
|
|
822
|
-
>
|
|
823
|
-
</div>
|
|
824
|
-
` : nothing}
|
|
825
|
-
<div class="files-toolbar">
|
|
826
|
-
<sp-action-group size="xs" compact quiet>
|
|
827
|
-
<sp-action-button
|
|
828
|
-
size="xs"
|
|
829
|
-
label="New File"
|
|
830
|
-
@click=${() => createNewFile(".", renderLeftPanel)}
|
|
831
|
-
>
|
|
832
|
-
<sp-icon-add slot="icon"></sp-icon-add>
|
|
833
|
-
</sp-action-button>
|
|
834
|
-
<sp-action-button
|
|
835
|
-
size="xs"
|
|
836
|
-
label="Refresh"
|
|
837
|
-
@click=${async () => {
|
|
838
|
-
requireProjectState().dirs.clear();
|
|
839
|
-
resetIgnoreCache();
|
|
840
|
-
await loadDirectory(".");
|
|
841
|
-
for (const dir of requireProjectState().expanded) {
|
|
842
|
-
await loadDirectory(dir);
|
|
843
|
-
}
|
|
844
|
-
renderLeftPanel();
|
|
845
|
-
}}
|
|
846
|
-
>
|
|
847
|
-
<sp-icon-refresh slot="icon"></sp-icon-refresh>
|
|
848
|
-
</sp-action-button>
|
|
849
|
-
<sp-action-button
|
|
850
|
-
size="xs"
|
|
851
|
-
label=${showingIgnored ? "Hide ignored files" : "Show ignored files"}
|
|
852
|
-
?selected=${showingIgnored}
|
|
853
|
-
@click=${() => {
|
|
854
|
-
setShowIgnoredFiles(!showingIgnored);
|
|
855
|
-
renderLeftPanel();
|
|
856
|
-
}}
|
|
857
|
-
>
|
|
858
|
-
${showingIgnored ? html`<sp-icon-visibility slot="icon"></sp-icon-visibility>` : html`<sp-icon-visibility-off slot="icon"></sp-icon-visibility-off>`}
|
|
859
|
-
</sp-action-button>
|
|
860
|
-
</sp-action-group>
|
|
861
|
-
<sp-search
|
|
862
|
-
size="s"
|
|
863
|
-
quiet
|
|
864
|
-
placeholder="Filter files…"
|
|
865
|
-
value=${requireProjectState().searchQuery}
|
|
866
|
-
@input=${(e) => {
|
|
867
|
-
requireProjectState().searchQuery = e.target.value;
|
|
868
|
-
renderLeftPanel();
|
|
869
|
-
}}
|
|
870
|
-
@submit=${(e) => e.preventDefault()}
|
|
871
|
-
></sp-search>
|
|
872
|
-
</div>
|
|
873
|
-
<div
|
|
874
|
-
class="file-tree"
|
|
875
|
-
role="tree"
|
|
876
|
-
aria-label="Project files"
|
|
877
|
-
@keydown=${(e) => {
|
|
878
|
-
onFileTreeKeydown(e, e.currentTarget);
|
|
879
|
-
}}
|
|
880
|
-
${ref((el) => {
|
|
881
|
-
if (el) {
|
|
882
|
-
afterFileTreeRender(el);
|
|
883
|
-
}
|
|
884
|
-
})}
|
|
885
|
-
>
|
|
886
|
-
${fileTreeBodyTemplate({ openFileFn, renderLeftPanel })}
|
|
887
|
-
</div>
|
|
888
|
-
`;
|
|
889
|
-
}
|
|
890
|
-
var FILE_ROW_HEIGHT = 24;
|
|
891
|
-
var _fileRows = [];
|
|
892
|
-
var _fileList = null;
|
|
893
|
-
var _fileWatch = null;
|
|
894
|
-
var _filesRerender = null;
|
|
895
|
-
var _pendingFocusPath = null;
|
|
896
|
-
function fileRowHeight() {
|
|
897
|
-
return measuredRowHeight(_fileList, ".file-tree-item", FILE_ROW_HEIGHT);
|
|
898
|
-
}
|
|
899
|
-
function collectFileRows(dirPath, depth, rows, ctx, i18n) {
|
|
900
|
-
const entries = requireProjectState().dirs.get(dirPath);
|
|
901
|
-
if (!entries) {
|
|
902
|
-
loadDirectory(dirPath).then(() => ctx.renderLeftPanel());
|
|
903
|
-
rows.push({
|
|
904
|
-
depth,
|
|
905
|
-
expanded: false,
|
|
906
|
-
key: `loading:${dirPath}`,
|
|
907
|
-
loading: true,
|
|
908
|
-
name: "Loading…",
|
|
909
|
-
path: dirPath,
|
|
910
|
-
posInSet: 1,
|
|
911
|
-
setSize: 1,
|
|
912
|
-
type: "file"
|
|
913
|
-
});
|
|
914
|
-
return;
|
|
915
|
-
}
|
|
916
|
-
const sorted = [...entries].toSorted((a, b) => {
|
|
917
|
-
if (a.type === "directory" && b.type !== "directory") {
|
|
918
|
-
return -1;
|
|
919
|
-
}
|
|
920
|
-
if (a.type !== "directory" && b.type === "directory") {
|
|
921
|
-
return 1;
|
|
922
|
-
}
|
|
923
|
-
return a.name.localeCompare(b.name);
|
|
924
|
-
});
|
|
925
|
-
const visible = showIgnoredFiles() ? sorted : sorted.filter((e) => !isIgnoredEntry(dirPath, e.path, e.type === "directory"));
|
|
926
|
-
const query = requireProjectState().searchQuery.toLowerCase();
|
|
927
|
-
const filtered = query ? visible.filter((e) => e.type === "directory" || e.name.toLowerCase().includes(query)) : visible;
|
|
928
|
-
for (const [index, entry] of filtered.entries()) {
|
|
929
|
-
const isDir = entry.type === "directory";
|
|
930
|
-
const isExpanded = isDir && requireProjectState().expanded.has(entry.path);
|
|
931
|
-
rows.push({
|
|
932
|
-
depth,
|
|
933
|
-
expanded: isExpanded,
|
|
934
|
-
key: entry.path,
|
|
935
|
-
loading: false,
|
|
936
|
-
name: entry.name,
|
|
937
|
-
path: entry.path,
|
|
938
|
-
locale: localeOfPath(entry.path, i18n) ?? undefined,
|
|
939
|
-
posInSet: index + 1,
|
|
940
|
-
setSize: filtered.length,
|
|
941
|
-
type: entry.type
|
|
942
|
-
});
|
|
943
|
-
if (isExpanded) {
|
|
944
|
-
collectFileRows(entry.path, depth + 1, rows, ctx, i18n);
|
|
945
|
-
}
|
|
946
|
-
}
|
|
947
|
-
}
|
|
948
|
-
function fileIndexOfPath(path) {
|
|
949
|
-
return path === undefined ? -1 : _fileRows.findIndex((row) => !row.loading && row.path === path);
|
|
950
|
-
}
|
|
951
|
-
function fileStep(index, step) {
|
|
952
|
-
for (let i = index + step;i >= 0 && i < _fileRows.length; i += step) {
|
|
953
|
-
if (!_fileRows[i].loading) {
|
|
954
|
-
return i;
|
|
955
|
-
}
|
|
956
|
-
}
|
|
957
|
-
return -1;
|
|
958
|
-
}
|
|
959
|
-
function fileWindowChanged() {
|
|
960
|
-
if (_fileList?.isConnected !== true || _fileList.querySelector(".file-tree-item.dragging")) {
|
|
961
|
-
return;
|
|
962
|
-
}
|
|
963
|
-
queueMicrotask(() => _filesRerender?.());
|
|
964
|
-
}
|
|
965
|
-
function adoptFileTree(tree) {
|
|
966
|
-
_fileList = tree;
|
|
967
|
-
_fileWatch = watchListWindow(_fileWatch, tree, {
|
|
968
|
-
count: () => _fileRows.length,
|
|
969
|
-
onChange: fileWindowChanged,
|
|
970
|
-
rowHeight: fileRowHeight
|
|
971
|
-
});
|
|
972
|
-
const wanted = _pendingFocusPath;
|
|
973
|
-
if (wanted !== null) {
|
|
974
|
-
_pendingFocusPath = null;
|
|
975
|
-
fileRowElement(tree, wanted)?.focus();
|
|
976
|
-
}
|
|
977
|
-
}
|
|
978
|
-
function afterFileTreeRender(tree) {
|
|
979
|
-
queueMicrotask(() => adoptFileTree(tree));
|
|
980
|
-
}
|
|
981
|
-
function fileRowElement(tree, path) {
|
|
982
|
-
return tree.querySelector(`.file-tree-item[data-path="${CSS.escape(path)}"]`);
|
|
983
|
-
}
|
|
984
|
-
function fileTreeBodyTemplate(ctx) {
|
|
985
|
-
_filesRerender = ctx.renderLeftPanel;
|
|
986
|
-
_fileRows = [];
|
|
987
|
-
const { i18n } = resolveI18n(projectState?.projectConfig ?? {});
|
|
988
|
-
collectFileRows(".", 0, _fileRows, ctx, i18n);
|
|
989
|
-
const range = listWindow(_fileList, { count: _fileRows.length, rowHeight: fileRowHeight() });
|
|
990
|
-
const wanted = Math.max(0, fileIndexOfPath(requireProjectState().selectedPath ?? undefined));
|
|
991
|
-
const tabStop = Math.min(Math.max(wanted, range.start), Math.max(range.start, range.end - 1));
|
|
992
|
-
const slice = _fileRows.slice(range.start, range.end).map((row, offset) => ({ row, tabStop: range.start + offset === tabStop }));
|
|
993
|
-
return html`
|
|
994
|
-
<div style="height:${range.padTop}px" aria-hidden="true"></div>
|
|
995
|
-
${repeat(slice, (entry) => entry.row.key, (entry) => fileRowTemplate(entry.row, entry.tabStop, ctx))}
|
|
996
|
-
<div style="height:${range.padBottom}px" aria-hidden="true"></div>
|
|
997
|
-
`;
|
|
998
|
-
}
|
|
999
|
-
function fileRowTemplate(row, tabStop, ctx) {
|
|
1000
|
-
if (row.loading) {
|
|
1001
|
-
return html`<div
|
|
1002
|
-
class="file-tree-item"
|
|
1003
|
-
style="padding-left:${8 + row.depth * 16}px;color:var(--fg-dim);font-style:italic"
|
|
1004
|
-
>
|
|
1005
|
-
Loading…
|
|
1006
|
-
</div>`;
|
|
1007
|
-
}
|
|
1008
|
-
const isDir = row.type === "directory";
|
|
1009
|
-
return html`
|
|
1010
|
-
<div
|
|
1011
|
-
class=${classMap({
|
|
1012
|
-
"file-tree-item": true,
|
|
1013
|
-
selected: requireProjectState().selectedPath === row.path
|
|
1014
|
-
})}
|
|
1015
|
-
style="padding-left:${8 + row.depth * 16}px"
|
|
1016
|
-
role="treeitem"
|
|
1017
|
-
aria-level=${row.depth + 1}
|
|
1018
|
-
aria-posinset=${row.posInSet}
|
|
1019
|
-
aria-setsize=${row.setSize}
|
|
1020
|
-
tabindex=${tabStop ? "0" : "-1"}
|
|
1021
|
-
data-path=${row.path}
|
|
1022
|
-
data-type=${row.type}
|
|
1023
|
-
aria-expanded=${isDir ? String(row.expanded) : nothing}
|
|
1024
|
-
@click=${async (e) => {
|
|
1025
|
-
e.stopPropagation();
|
|
1026
|
-
if (isDir) {
|
|
1027
|
-
await toggleTreeDirectory(row.path);
|
|
1028
|
-
ctx.renderLeftPanel();
|
|
1029
|
-
} else {
|
|
1030
|
-
ctx.openFileFn(row.path);
|
|
1031
|
-
}
|
|
1032
|
-
}}
|
|
1033
|
-
@contextmenu=${(e) => {
|
|
1034
|
-
e.preventDefault();
|
|
1035
|
-
e.stopPropagation();
|
|
1036
|
-
showFileContextMenu(e, { name: row.name, path: row.path, type: row.type }, ctx);
|
|
1037
|
-
}}
|
|
1038
|
-
>
|
|
1039
|
-
${isDir ? html`<span class="file-tree-toggle">${row.expanded ? "▼" : "▶"}</span>` : html`<span class="file-tree-toggle empty"> </span>`}
|
|
1040
|
-
<span class="file-tree-icon">${fileTypeIconTpl(row.path, row.type)}</span>
|
|
1041
|
-
<span class="file-tree-name">${row.name}</span>
|
|
1042
|
-
${row.locale === undefined ? nothing : html`<span class="file-tree-locale">${localeLabel(row.locale)}</span>`}
|
|
1043
|
-
</div>
|
|
1044
|
-
`;
|
|
1045
|
-
}
|
|
1046
|
-
async function toggleTreeDirectory(path) {
|
|
1047
|
-
const state = requireProjectState();
|
|
1048
|
-
if (state.expanded.has(path)) {
|
|
1049
|
-
state.expanded.delete(path);
|
|
1050
|
-
return;
|
|
1051
|
-
}
|
|
1052
|
-
state.expanded.add(path);
|
|
1053
|
-
if (!state.dirs.has(path)) {
|
|
1054
|
-
await loadDirectory(path);
|
|
1055
|
-
}
|
|
1056
|
-
}
|
|
1057
|
-
function onFileTreeKeydown(e, tree) {
|
|
1058
|
-
const focused = tree.querySelector(".file-tree-item:focus");
|
|
1059
|
-
if (!focused) {
|
|
1060
|
-
return;
|
|
1061
|
-
}
|
|
1062
|
-
let handled = true;
|
|
1063
|
-
switch (e.key) {
|
|
1064
|
-
case "ArrowDown":
|
|
1065
|
-
case "ArrowUp": {
|
|
1066
|
-
const from = fileIndexOfPath(focused.dataset.path);
|
|
1067
|
-
focusFileRow(tree, fileStep(from, e.key === "ArrowDown" ? 1 : -1));
|
|
1068
|
-
break;
|
|
1069
|
-
}
|
|
1070
|
-
case "ArrowRight": {
|
|
1071
|
-
const path = collapsedDirectoryAt(focused);
|
|
1072
|
-
if (path !== null) {
|
|
1073
|
-
toggleTreeDirectory(path).then(() => _filesRerender?.());
|
|
1074
|
-
}
|
|
1075
|
-
break;
|
|
1076
|
-
}
|
|
1077
|
-
case "ArrowLeft": {
|
|
1078
|
-
const path = expandedDirectoryAt(focused);
|
|
1079
|
-
if (path !== null) {
|
|
1080
|
-
requireProjectState().expanded.delete(path);
|
|
1081
|
-
_filesRerender?.();
|
|
1082
|
-
}
|
|
1083
|
-
break;
|
|
1084
|
-
}
|
|
1085
|
-
case "Enter": {
|
|
1086
|
-
focused.click();
|
|
1087
|
-
break;
|
|
1088
|
-
}
|
|
1089
|
-
default: {
|
|
1090
|
-
handled = false;
|
|
1091
|
-
}
|
|
1092
|
-
}
|
|
1093
|
-
if (handled) {
|
|
1094
|
-
e.preventDefault();
|
|
1095
|
-
}
|
|
1096
|
-
}
|
|
1097
|
-
function collapsedDirectoryAt(row) {
|
|
1098
|
-
const { path, type } = row.dataset;
|
|
1099
|
-
return type === "directory" && path !== undefined && !requireProjectState().expanded.has(path) ? path : null;
|
|
1100
|
-
}
|
|
1101
|
-
function expandedDirectoryAt(row) {
|
|
1102
|
-
const { path, type } = row.dataset;
|
|
1103
|
-
return type === "directory" && path !== undefined && requireProjectState().expanded.has(path) ? path : null;
|
|
1104
|
-
}
|
|
1105
|
-
function focusFileRow(tree, index) {
|
|
1106
|
-
const row = _fileRows[index];
|
|
1107
|
-
if (!row) {
|
|
1108
|
-
return;
|
|
1109
|
-
}
|
|
1110
|
-
const el = fileRowElement(tree, row.path);
|
|
1111
|
-
if (el) {
|
|
1112
|
-
el.focus();
|
|
1113
|
-
return;
|
|
1114
|
-
}
|
|
1115
|
-
if (revealListRow(_fileList, index, fileRowHeight())) {
|
|
1116
|
-
_pendingFocusPath = row.path;
|
|
1117
|
-
_filesRerender?.();
|
|
1118
|
-
}
|
|
1119
|
-
}
|
|
1120
|
-
var _fileTreeDndCleanups = [];
|
|
1121
|
-
function isFileDrag(e) {
|
|
1122
|
-
return [...e.dataTransfer?.types ?? []].includes("Files");
|
|
1123
|
-
}
|
|
1124
|
-
function registerFileDropTarget(element, dir, activeClass, renderLeftPanel) {
|
|
1125
|
-
const onDragOver = (e) => {
|
|
1126
|
-
if (!isFileDrag(e)) {
|
|
1127
|
-
return;
|
|
1128
|
-
}
|
|
1129
|
-
e.preventDefault();
|
|
1130
|
-
e.stopPropagation();
|
|
1131
|
-
if (e.dataTransfer) {
|
|
1132
|
-
e.dataTransfer.dropEffect = "copy";
|
|
1133
|
-
}
|
|
1134
|
-
element.classList.add(activeClass);
|
|
1135
|
-
};
|
|
1136
|
-
const onDragLeave = () => element.classList.remove(activeClass);
|
|
1137
|
-
const onDrop = (e) => {
|
|
1138
|
-
element.classList.remove(activeClass);
|
|
1139
|
-
const files = e.dataTransfer?.files;
|
|
1140
|
-
if (!files?.length) {
|
|
1141
|
-
return;
|
|
1142
|
-
}
|
|
1143
|
-
e.preventDefault();
|
|
1144
|
-
e.stopPropagation();
|
|
1145
|
-
uploadFilesToDir(files, dir, renderLeftPanel);
|
|
1146
|
-
};
|
|
1147
|
-
element.addEventListener("dragover", onDragOver);
|
|
1148
|
-
element.addEventListener("dragleave", onDragLeave);
|
|
1149
|
-
element.addEventListener("drop", onDrop);
|
|
1150
|
-
return () => {
|
|
1151
|
-
element.removeEventListener("dragover", onDragOver);
|
|
1152
|
-
element.removeEventListener("dragleave", onDragLeave);
|
|
1153
|
-
element.removeEventListener("drop", onDrop);
|
|
1154
|
-
};
|
|
1155
|
-
}
|
|
1156
|
-
async function uploadFilesToDir(files, dir, renderLeftPanel) {
|
|
1157
|
-
const uploaded = await uploadAssets([...files], { dir });
|
|
1158
|
-
if (uploaded.length === 0) {
|
|
1159
|
-
return;
|
|
1160
|
-
}
|
|
1161
|
-
if (dir !== ".") {
|
|
1162
|
-
requireProjectState().expanded.add(dir);
|
|
1163
|
-
}
|
|
1164
|
-
renderLeftPanel();
|
|
1165
|
-
}
|
|
1166
|
-
function pickAndUploadTo(dir, renderLeftPanel) {
|
|
1167
|
-
const input = document.createElement("input");
|
|
1168
|
-
input.type = "file";
|
|
1169
|
-
input.multiple = true;
|
|
1170
|
-
input.accept = uploadAccept();
|
|
1171
|
-
input.addEventListener("change", () => {
|
|
1172
|
-
if (input.files?.length) {
|
|
1173
|
-
uploadFilesToDir(input.files, dir, renderLeftPanel);
|
|
1174
|
-
}
|
|
1175
|
-
});
|
|
1176
|
-
input.click();
|
|
1177
|
-
}
|
|
1178
|
-
function registerFileTreeDnD({ renderLeftPanel }) {
|
|
1179
|
-
for (const fn of _fileTreeDndCleanups) {
|
|
1180
|
-
fn();
|
|
1181
|
-
}
|
|
1182
|
-
_fileTreeDndCleanups = [];
|
|
1183
|
-
requestAnimationFrame(() => {
|
|
1184
|
-
const tree = document.querySelector(".file-tree");
|
|
1185
|
-
if (!tree) {
|
|
1186
|
-
return;
|
|
1187
|
-
}
|
|
1188
|
-
const items = tree.querySelectorAll(".file-tree-item");
|
|
1189
|
-
for (const row of items) {
|
|
1190
|
-
const { path } = row.dataset;
|
|
1191
|
-
const { type } = row.dataset;
|
|
1192
|
-
if (!path) {
|
|
1193
|
-
continue;
|
|
1194
|
-
}
|
|
1195
|
-
const cleanups = [
|
|
1196
|
-
draggable({
|
|
1197
|
-
element: row,
|
|
1198
|
-
getInitialData() {
|
|
1199
|
-
return { entryType: type, path, type: "file-tree" };
|
|
1200
|
-
},
|
|
1201
|
-
onDragStart() {
|
|
1202
|
-
row.classList.add("dragging");
|
|
1203
|
-
},
|
|
1204
|
-
onDrop() {
|
|
1205
|
-
row.classList.remove("dragging");
|
|
1206
|
-
}
|
|
1207
|
-
}),
|
|
1208
|
-
registerFileDropTarget(row, type === "directory" ? path : parentDir(path), "drag-over", renderLeftPanel)
|
|
1209
|
-
];
|
|
1210
|
-
if (type === "directory") {
|
|
1211
|
-
cleanups.push(dropTargetForElements({
|
|
1212
|
-
canDrop({ source }) {
|
|
1213
|
-
if (source.data.type !== "file-tree") {
|
|
1214
|
-
return false;
|
|
1215
|
-
}
|
|
1216
|
-
const srcPath = source.data.path;
|
|
1217
|
-
if (srcPath === path) {
|
|
1218
|
-
return false;
|
|
1219
|
-
}
|
|
1220
|
-
if (srcPath.startsWith(`${path}/`)) {
|
|
1221
|
-
return false;
|
|
1222
|
-
}
|
|
1223
|
-
const srcParent = parentDir(srcPath);
|
|
1224
|
-
if (srcParent === path) {
|
|
1225
|
-
return false;
|
|
1226
|
-
}
|
|
1227
|
-
return true;
|
|
1228
|
-
},
|
|
1229
|
-
element: row,
|
|
1230
|
-
getData() {
|
|
1231
|
-
return { targetDir: path, type: "file-tree-target" };
|
|
1232
|
-
},
|
|
1233
|
-
onDrag() {
|
|
1234
|
-
if (!row.classList.contains("drag-over")) {
|
|
1235
|
-
row.classList.add("drag-over");
|
|
1236
|
-
}
|
|
1237
|
-
},
|
|
1238
|
-
onDragEnter() {
|
|
1239
|
-
row.classList.add("drag-over");
|
|
1240
|
-
},
|
|
1241
|
-
onDragLeave() {
|
|
1242
|
-
row.classList.remove("drag-over");
|
|
1243
|
-
},
|
|
1244
|
-
onDrop() {
|
|
1245
|
-
row.classList.remove("drag-over");
|
|
1246
|
-
}
|
|
1247
|
-
}));
|
|
1248
|
-
}
|
|
1249
|
-
_fileTreeDndCleanups.push(combine(...cleanups));
|
|
1250
|
-
}
|
|
1251
|
-
const rootCleanup = dropTargetForElements({
|
|
1252
|
-
canDrop({ source }) {
|
|
1253
|
-
if (source.data.type !== "file-tree") {
|
|
1254
|
-
return false;
|
|
1255
|
-
}
|
|
1256
|
-
const srcPath = source.data.path;
|
|
1257
|
-
return parentDir(srcPath) !== ".";
|
|
1258
|
-
},
|
|
1259
|
-
element: tree,
|
|
1260
|
-
getData() {
|
|
1261
|
-
return { targetDir: ".", type: "file-tree-target" };
|
|
1262
|
-
},
|
|
1263
|
-
onDragEnter() {
|
|
1264
|
-
tree.classList.add("drag-over-root");
|
|
1265
|
-
},
|
|
1266
|
-
onDragLeave() {
|
|
1267
|
-
tree.classList.remove("drag-over-root");
|
|
1268
|
-
},
|
|
1269
|
-
onDrop() {
|
|
1270
|
-
tree.classList.remove("drag-over-root");
|
|
1271
|
-
}
|
|
1272
|
-
});
|
|
1273
|
-
_fileTreeDndCleanups.push(rootCleanup, registerFileDropTarget(tree, ".", "drag-over-root", renderLeftPanel));
|
|
1274
|
-
const monitorCleanup = monitorForElements({
|
|
1275
|
-
onDrop({ source, location: location2 }) {
|
|
1276
|
-
const [target] = location2.current.dropTargets;
|
|
1277
|
-
if (!target) {
|
|
1278
|
-
return;
|
|
1279
|
-
}
|
|
1280
|
-
if (source.data.type !== "file-tree") {
|
|
1281
|
-
return;
|
|
1282
|
-
}
|
|
1283
|
-
if (target.data.type !== "file-tree-target") {
|
|
1284
|
-
return;
|
|
1285
|
-
}
|
|
1286
|
-
const srcPath = source.data.path;
|
|
1287
|
-
const targetDirPath = target.data.targetDir;
|
|
1288
|
-
const fileName = srcPath.split("/").pop();
|
|
1289
|
-
const newPath = targetDirPath === "." ? fileName : `${targetDirPath}/${fileName}`;
|
|
1290
|
-
if (newPath === srcPath) {
|
|
1291
|
-
return;
|
|
1292
|
-
}
|
|
1293
|
-
moveFileEntry(srcPath, newPath, renderLeftPanel);
|
|
1294
|
-
}
|
|
1295
|
-
});
|
|
1296
|
-
_fileTreeDndCleanups.push(monitorCleanup);
|
|
1297
|
-
});
|
|
1298
|
-
}
|
|
1299
|
-
async function moveFileEntry(oldPath, newPath, renderLeftPanel) {
|
|
1300
|
-
const platform = getPlatform();
|
|
1301
|
-
markLocalMutation(oldPath, newPath);
|
|
1302
|
-
try {
|
|
1303
|
-
const report = await platform.renameFile(oldPath, newPath);
|
|
1304
|
-
invalidateUsages();
|
|
1305
|
-
for (const [id] of workspace.tabs.entries()) {
|
|
1306
|
-
if (id === oldPath) {
|
|
1307
|
-
renameTab(oldPath, newPath, newPath);
|
|
1308
|
-
} else if (id.startsWith(`${oldPath}/`)) {
|
|
1309
|
-
const newTabPath = newPath + id.slice(oldPath.length);
|
|
1310
|
-
renameTab(id, newTabPath, newTabPath);
|
|
1311
|
-
}
|
|
1312
|
-
}
|
|
1313
|
-
const oldParent = parentDir(oldPath);
|
|
1314
|
-
const newParent = parentDir(newPath);
|
|
1315
|
-
await loadDirectory(oldParent);
|
|
1316
|
-
if (newParent !== oldParent) {
|
|
1317
|
-
await loadDirectory(newParent);
|
|
1318
|
-
}
|
|
1319
|
-
if (newParent !== ".") {
|
|
1320
|
-
requireProjectState().expanded.add(newParent);
|
|
1321
|
-
}
|
|
1322
|
-
reloadRewrittenTabs(report, newPath);
|
|
1323
|
-
renderLeftPanel();
|
|
1324
|
-
notifyMoveOutcome(`Moved to ${newPath}`, report, newPath);
|
|
1325
|
-
} catch (error) {
|
|
1326
|
-
notify.error(`Could not move ${oldPath}.`, {
|
|
1327
|
-
detail: errorMessage(error),
|
|
1328
|
-
path: oldPath,
|
|
1329
|
-
source: "Files"
|
|
1330
|
-
});
|
|
1331
|
-
}
|
|
1332
|
-
}
|
|
1333
|
-
function parentDir(path) {
|
|
1334
|
-
const normalized = path.replaceAll("\\", "/");
|
|
1335
|
-
const lastSlash = normalized.lastIndexOf("/");
|
|
1336
|
-
return lastSlash === -1 ? "." : normalized.slice(0, lastSlash);
|
|
1337
|
-
}
|
|
1338
|
-
var _fileCtxHandle = null;
|
|
1339
|
-
function dismissFileContextMenu() {
|
|
1340
|
-
if (_fileCtxHandle) {
|
|
1341
|
-
_fileCtxHandle.dismiss();
|
|
1342
|
-
_fileCtxHandle = null;
|
|
1343
|
-
}
|
|
1344
|
-
}
|
|
1345
|
-
function fileRowFacts(entry) {
|
|
1346
|
-
const facts = {};
|
|
1347
|
-
if (entry.type === "directory") {
|
|
1348
|
-
const collection = collectionForDirectory(entry.path);
|
|
1349
|
-
if (collection?.isSourceRoot === true && !collection.fileBacked) {
|
|
1350
|
-
facts.name = collection.name;
|
|
1351
|
-
}
|
|
1352
|
-
return facts;
|
|
1353
|
-
}
|
|
1354
|
-
if (collectionOfPath(entry.path)) {
|
|
1355
|
-
facts.path = entry.path;
|
|
1356
|
-
}
|
|
1357
|
-
if (convertTargets(entry.path).length > 0) {
|
|
1358
|
-
facts.source = entry.path;
|
|
1359
|
-
}
|
|
1360
|
-
return facts;
|
|
1361
|
-
}
|
|
1362
|
-
function placedFileItems(entry) {
|
|
1363
|
-
const registry = activeRegistry();
|
|
1364
|
-
if (!registry) {
|
|
1365
|
-
return [];
|
|
1366
|
-
}
|
|
1367
|
-
const facts = fileRowFacts(entry);
|
|
1368
|
-
const items = [];
|
|
1369
|
-
for (const command of registry.forPlacement("context/file")) {
|
|
1370
|
-
const schema = command.args;
|
|
1371
|
-
if (!(schema?.required ?? []).every((key) => (key in facts))) {
|
|
1372
|
-
continue;
|
|
1373
|
-
}
|
|
1374
|
-
const args = {};
|
|
1375
|
-
for (const key of Object.keys(schema?.properties ?? {})) {
|
|
1376
|
-
if (key in facts) {
|
|
1377
|
-
args[key] = facts[key];
|
|
1378
|
-
}
|
|
1379
|
-
}
|
|
1380
|
-
const reason = registry.disabledReason(command.id);
|
|
1381
|
-
items.push(reason === undefined ? {
|
|
1382
|
-
action: () => {
|
|
1383
|
-
registry.run(command.id, args);
|
|
1384
|
-
},
|
|
1385
|
-
label: command.title
|
|
1386
|
-
} : { disabled: true, label: command.title, reason });
|
|
1387
|
-
}
|
|
1388
|
-
return items;
|
|
1389
|
-
}
|
|
1390
|
-
function showFileContextMenu(e, entry, ctx) {
|
|
1391
|
-
e.preventDefault();
|
|
1392
|
-
dismissFileContextMenu();
|
|
1393
|
-
const isDir = entry.type === "directory";
|
|
1394
|
-
const items = [];
|
|
1395
|
-
if (!isDir) {
|
|
1396
|
-
items.push({ action: () => ctx.openFileFn(entry.path), label: "Open" });
|
|
1397
|
-
}
|
|
1398
|
-
if (isDir) {
|
|
1399
|
-
items.push({
|
|
1400
|
-
action: () => createNewFile(entry.path, ctx.renderLeftPanel),
|
|
1401
|
-
label: "New File…"
|
|
1402
|
-
}, {
|
|
1403
|
-
action: () => pickAndUploadTo(entry.path, ctx.renderLeftPanel),
|
|
1404
|
-
label: "Upload Files…"
|
|
1405
|
-
});
|
|
1406
|
-
if (entry.path === "pages" || entry.path.endsWith("/pages")) {
|
|
1407
|
-
items.push({
|
|
1408
|
-
action: () => {
|
|
1409
|
-
openPagesGrid();
|
|
1410
|
-
},
|
|
1411
|
-
label: "Edit Pages in Grid"
|
|
1412
|
-
});
|
|
1413
|
-
}
|
|
1414
|
-
}
|
|
1415
|
-
items.push(...placedFileItems(entry), { label: "—" }, {
|
|
1416
|
-
action: () => renameFile(entry, ctx.renderLeftPanel),
|
|
1417
|
-
label: "Rename…"
|
|
1418
|
-
}, {
|
|
1419
|
-
action: () => deleteFile(entry, ctx.renderLeftPanel),
|
|
1420
|
-
danger: true,
|
|
1421
|
-
label: "Delete"
|
|
1422
|
-
});
|
|
1423
|
-
let x = e.clientX;
|
|
1424
|
-
let y = e.clientY;
|
|
1425
|
-
_fileCtxHandle = renderPopover(html`<sp-popover
|
|
1426
|
-
open
|
|
1427
|
-
style="position:fixed;z-index:10000;left:${x}px;top:${y}px"
|
|
1428
|
-
${ref((el) => {
|
|
1429
|
-
if (!el) {
|
|
1430
|
-
return;
|
|
1431
|
-
}
|
|
1432
|
-
requestAnimationFrame(() => {
|
|
1433
|
-
const popover = el;
|
|
1434
|
-
const menuRect = rectOf(popover);
|
|
1435
|
-
if (x + menuRect.width > window.innerWidth) {
|
|
1436
|
-
x = window.innerWidth - menuRect.width - 4;
|
|
1437
|
-
}
|
|
1438
|
-
if (y + menuRect.height > window.innerHeight) {
|
|
1439
|
-
y = window.innerHeight - menuRect.height - 4;
|
|
1440
|
-
}
|
|
1441
|
-
popover.style.left = `${x}px`;
|
|
1442
|
-
popover.style.top = `${y}px`;
|
|
1443
|
-
});
|
|
1444
|
-
})}
|
|
1445
|
-
>
|
|
1446
|
-
<sp-menu>
|
|
1447
|
-
${items.map((item) => item.label === "—" ? html`<sp-menu-divider></sp-menu-divider>` : html`<sp-menu-item
|
|
1448
|
-
style=${item.danger ? "color: var(--danger)" : ""}
|
|
1449
|
-
?disabled=${item.disabled === true}
|
|
1450
|
-
aria-disabled=${item.disabled === true ? "true" : "false"}
|
|
1451
|
-
@click=${() => {
|
|
1452
|
-
if (item.disabled === true) {
|
|
1453
|
-
return;
|
|
1454
|
-
}
|
|
1455
|
-
dismissFileContextMenu();
|
|
1456
|
-
item.action?.();
|
|
1457
|
-
}}
|
|
1458
|
-
>${item.label}${item.reason ? html`<span slot="description">Needs ${item.reason}</span>` : nothing}</sp-menu-item
|
|
1459
|
-
>`)}
|
|
1460
|
-
</sp-menu>
|
|
1461
|
-
</sp-popover>`, {
|
|
1462
|
-
dismissOnOutsideClick: true,
|
|
1463
|
-
onDismiss: () => {
|
|
1464
|
-
_fileCtxHandle = null;
|
|
1465
|
-
}
|
|
1466
|
-
});
|
|
1467
|
-
}
|
|
1468
|
-
var BLANK_DOCUMENT = JSON.stringify({ children: [{ children: [], tagName: "p" }], tagName: "div" }, null, 2);
|
|
1469
|
-
var OTHER_FORMAT = "__other__";
|
|
1470
|
-
function slugify(input) {
|
|
1471
|
-
return input.trim().toLowerCase().replaceAll(/\s+/g, "-").replaceAll(/[^a-z\d-]/g, "");
|
|
1472
|
-
}
|
|
1473
|
-
function extensionOfName(name) {
|
|
1474
|
-
const dot = name.lastIndexOf(".");
|
|
1475
|
-
return dot > 0 ? name.slice(dot) : "";
|
|
1476
|
-
}
|
|
1477
|
-
function formatRowsFor(choice) {
|
|
1478
|
-
const rows = choice.kind === "locked" ? [
|
|
1479
|
-
{
|
|
1480
|
-
ext: choice.ext,
|
|
1481
|
-
label: `${formatByExtension(choice.ext)?.name ?? choice.ext} (${choice.ext})`
|
|
1482
|
-
}
|
|
1483
|
-
] : creationFormats(choice.docKind);
|
|
1484
|
-
return [
|
|
1485
|
-
...rows.map((row) => ({ label: row.label, value: row.ext })),
|
|
1486
|
-
{ dividerBefore: true, label: "Other…", value: OTHER_FORMAT }
|
|
1487
|
-
];
|
|
1488
|
-
}
|
|
1489
|
-
function initialPickFor(choice, rows, suggested) {
|
|
1490
|
-
const stated = choice.kind === "choose" ? choice.defaultExt : choice.ext;
|
|
1491
|
-
if (stated !== undefined && rows.some((row) => row.value === stated)) {
|
|
1492
|
-
return stated;
|
|
1493
|
-
}
|
|
1494
|
-
const fromPrefill = extensionOfName(suggested);
|
|
1495
|
-
if (fromPrefill !== "" && rows.some((row) => row.value === fromPrefill)) {
|
|
1496
|
-
return fromPrefill;
|
|
1497
|
-
}
|
|
1498
|
-
return rows[0]?.value ?? OTHER_FORMAT;
|
|
1499
|
-
}
|
|
1500
|
-
async function createFileIn(request) {
|
|
1501
|
-
const { dir, format: choice, source = "Files" } = request;
|
|
1502
|
-
await loadFormats();
|
|
1503
|
-
let taken = new Set;
|
|
1504
|
-
try {
|
|
1505
|
-
const listing = await getPlatform().listDirectory(dir);
|
|
1506
|
-
taken = new Set(listing.map((entry) => entry.name.toLowerCase()));
|
|
1507
|
-
} catch {}
|
|
1508
|
-
const picker = choice !== undefined && choice.kind !== "fixed" ? choice : null;
|
|
1509
|
-
const rows = picker === null ? null : formatRowsFor(picker);
|
|
1510
|
-
const initialPick = picker === null || rows === null ? "" : initialPickFor(picker, rows, request.suggestedName ?? "");
|
|
1511
|
-
const fileNameFor = (input, picked2) => {
|
|
1512
|
-
const trimmed = input.trim();
|
|
1513
|
-
if (choice === undefined || picked2 === OTHER_FORMAT) {
|
|
1514
|
-
return trimmed;
|
|
1515
|
-
}
|
|
1516
|
-
if (choice.kind === "fixed") {
|
|
1517
|
-
const slug = slugify(trimmed);
|
|
1518
|
-
return slug === "" ? "" : `${slug}${choice.ext}`;
|
|
1519
|
-
}
|
|
1520
|
-
return trimmed.toLowerCase().endsWith(picked2.toLowerCase()) ? trimmed : `${trimmed}${picked2}`;
|
|
1521
|
-
};
|
|
1522
|
-
const known = knownDocumentExtensions();
|
|
1523
|
-
const validate = (value, picked2) => {
|
|
1524
|
-
const trimmed = value.trim();
|
|
1525
|
-
if (!trimmed) {
|
|
1526
|
-
return choice?.kind === "fixed" ? "Enter a name." : "Enter a file name.";
|
|
1527
|
-
}
|
|
1528
|
-
if (choice?.kind === "fixed" && slugify(trimmed) === "") {
|
|
1529
|
-
return "Enter at least one letter or number.";
|
|
1530
|
-
}
|
|
1531
|
-
const normalized = trimmed.replaceAll("\\", "/");
|
|
1532
|
-
if (normalized.startsWith("/") || normalized.endsWith("/")) {
|
|
1533
|
-
return "Enter a name, not a path that starts or ends with a slash.";
|
|
1534
|
-
}
|
|
1535
|
-
if (normalized.split("/").includes("..")) {
|
|
1536
|
-
return "A name cannot step outside the destination folder.";
|
|
1537
|
-
}
|
|
1538
|
-
if (normalized.includes("/") && choice !== undefined && picked2 !== OTHER_FORMAT) {
|
|
1539
|
-
return `Pick Other… to create a file in a subfolder of ${dir === "." ? "the project root" : dir}.`;
|
|
1540
|
-
}
|
|
1541
|
-
const typedExt = extensionOfName(normalized);
|
|
1542
|
-
if (picked2 !== "" && picked2 !== OTHER_FORMAT && typedExt !== "" && typedExt.toLowerCase() !== picked2.toLowerCase() && known.has(typedExt.toLowerCase())) {
|
|
1543
|
-
const label = rows?.find((row) => row.value === picked2)?.label ?? picked2;
|
|
1544
|
-
return `You picked ${label}; this name ends in ${typedExt}.`;
|
|
1545
|
-
}
|
|
1546
|
-
if (choice?.kind === "locked" && picked2 === OTHER_FORMAT) {
|
|
1547
|
-
const foreign = typedExt !== "" && typedExt.toLowerCase() !== choice.ext.toLowerCase();
|
|
1548
|
-
if (foreign && known.has(typedExt.toLowerCase())) {
|
|
1549
|
-
return choice.because;
|
|
1550
|
-
}
|
|
1551
|
-
}
|
|
1552
|
-
const candidate = fileNameFor(value, picked2);
|
|
1553
|
-
return taken.has(candidate.toLowerCase()) ? `${candidate} already exists in ${dir}/.` : "";
|
|
1554
|
-
};
|
|
1555
|
-
let picked = initialPick;
|
|
1556
|
-
const entered = await showPromptDialog(request.title ?? "New File", {
|
|
1557
|
-
...rows === null ? {} : {
|
|
1558
|
-
choice: {
|
|
1559
|
-
initial: initialPick,
|
|
1560
|
-
label: "Format",
|
|
1561
|
-
onChange: (next) => {
|
|
1562
|
-
picked = next;
|
|
1563
|
-
},
|
|
1564
|
-
options: () => rows
|
|
1565
|
-
}
|
|
1566
|
-
},
|
|
1567
|
-
confirmLabel: "Create",
|
|
1568
|
-
message: dir === "." ? "Creating in the project root." : `Creating in ${dir}/`,
|
|
1569
|
-
...request.suggestedName === undefined ? {} : { placeholder: request.suggestedName },
|
|
1570
|
-
select: rows === null ? "stem" : "all",
|
|
1571
|
-
validate,
|
|
1572
|
-
value: request.suggestedName ?? "untitled.json"
|
|
1573
|
-
});
|
|
1574
|
-
if (!entered) {
|
|
1575
|
-
return null;
|
|
1576
|
-
}
|
|
1577
|
-
const fileName = fileNameFor(entered, picked);
|
|
1578
|
-
const path = dir === "." ? fileName : `${dir}/${fileName}`;
|
|
1579
|
-
markLocalMutation(path);
|
|
1580
|
-
const format = formatForPath(fileName);
|
|
1581
|
-
const suppliedBody = typeof request.content === "function" ? await request.content(extensionOfName(fileName), fileName) : request.content;
|
|
1582
|
-
const chosenAsDocument = choice !== undefined && picked !== OTHER_FORMAT;
|
|
1583
|
-
const content = suppliedBody ?? format?.studio?.newFileTemplate ?? (format ? "" : fileName.toLowerCase().endsWith(".json") ? chosenAsDocument ? BLANK_DOCUMENT : `{}
|
|
1584
|
-
` : "");
|
|
1585
|
-
try {
|
|
1586
|
-
await getPlatform().writeFile(path, content);
|
|
1587
|
-
await loadDirectory(dir);
|
|
1588
|
-
notify.success(`Created ${path}`);
|
|
1589
|
-
return path;
|
|
1590
|
-
} catch (error) {
|
|
1591
|
-
notify.error(`Could not create ${path}.`, {
|
|
1592
|
-
detail: errorMessage(error),
|
|
1593
|
-
path,
|
|
1594
|
-
source
|
|
1595
|
-
});
|
|
1596
|
-
return null;
|
|
1597
|
-
}
|
|
1598
|
-
}
|
|
1599
|
-
async function createNewFile(dirPath, renderLeftPanel) {
|
|
1600
|
-
await loadFormats();
|
|
1601
|
-
const collection = collectionForDirectory(dirPath);
|
|
1602
|
-
if (collection?.unresolvedFormat != null) {
|
|
1603
|
-
notify.error(`New files in ${dirPath}/ cannot be constrained to the collection's format.`, {
|
|
1604
|
-
detail: `The "${collection.name}" content type declares format "${collection.unresolvedFormat}", ` + "which no installed extension provides. Install the extension that supplies it, or correct " + "the name in Project Settings › Content Types.",
|
|
1605
|
-
path: dirPath,
|
|
1606
|
-
source: "Files"
|
|
1607
|
-
});
|
|
1608
|
-
}
|
|
1609
|
-
const constrained = collection?.ext != null && collection.unresolvedFormat === null;
|
|
1610
|
-
const seedable = constrained && collection.isSourceRoot && collection.def.schema !== undefined;
|
|
1611
|
-
let created;
|
|
1612
|
-
if (seedable) {
|
|
1613
|
-
const { createEntry } = await import("./entry-commands-e63f1xc0.js");
|
|
1614
|
-
created = await createEntry(collection.name, { dir: dirPath });
|
|
1615
|
-
} else {
|
|
1616
|
-
created = await createFileIn({
|
|
1617
|
-
dir: dirPath,
|
|
1618
|
-
format: constrained && collection.ext !== null ? {
|
|
1619
|
-
because: `${collection.name} entries are ${collection.ext} files, so a document of another format here would not be one.`,
|
|
1620
|
-
ext: collection.ext,
|
|
1621
|
-
kind: "locked"
|
|
1622
|
-
} : { defaultExt: ".json", kind: "choose" },
|
|
1623
|
-
suggestedName: "untitled"
|
|
1624
|
-
});
|
|
1625
|
-
}
|
|
1626
|
-
if (created !== null) {
|
|
1627
|
-
renderLeftPanel();
|
|
1628
|
-
}
|
|
1629
|
-
}
|
|
1630
|
-
async function showRenameFileDialog(currentName, path) {
|
|
1631
|
-
const message = await renamePromptMessage(path);
|
|
1632
|
-
return showPromptDialog("Rename", {
|
|
1633
|
-
confirmLabel: "Rename",
|
|
1634
|
-
...message === undefined ? {} : { message },
|
|
1635
|
-
select: "stem",
|
|
1636
|
-
validate: (v) => v.trim() ? "" : "Enter a file name.",
|
|
1637
|
-
value: currentName
|
|
1638
|
-
});
|
|
1639
|
-
}
|
|
1640
|
-
function renameStatus(newName, report) {
|
|
1641
|
-
const refs = report.references;
|
|
1642
|
-
const tagNote = report.tag ? `; tag → <${report.tag.to}> (${report.tag.refsUpdated})` : "";
|
|
1643
|
-
if (refs && refs.refsUpdated > 0) {
|
|
1644
|
-
return `Renamed to ${newName}; updated ${refs.refsUpdated} reference(s) in ${refs.filesChanged} file(s)${tagNote}`;
|
|
1645
|
-
}
|
|
1646
|
-
if (tagNote) {
|
|
1647
|
-
return `Renamed to ${newName}${tagNote}`;
|
|
1648
|
-
}
|
|
1649
|
-
return `Renamed to ${newName}`;
|
|
1650
|
-
}
|
|
1651
|
-
function notifyMoveOutcome(headline, report, path) {
|
|
1652
|
-
const stuck = report.errors ?? [];
|
|
1653
|
-
if (stuck.length === 0) {
|
|
1654
|
-
notify.success(headline);
|
|
1655
|
-
return;
|
|
1656
|
-
}
|
|
1657
|
-
const files = stuck.length === 1 ? "1 file" : `${stuck.length} files`;
|
|
1658
|
-
notify.warn(`${headline} — references in ${files} could not be updated`, {
|
|
1659
|
-
detail: stuck.map((e) => `${e.path}: ${e.error}`).join(`
|
|
1660
|
-
`),
|
|
1661
|
-
path,
|
|
1662
|
-
source: "Files"
|
|
1663
|
-
});
|
|
1664
|
-
}
|
|
1665
|
-
function reloadRewrittenTabs(report, skipPath) {
|
|
1666
|
-
for (const f of report.references?.files ?? []) {
|
|
1667
|
-
if (f.path !== skipPath && workspace.tabs.has(f.path)) {
|
|
1668
|
-
reloadFileInTab(f.path);
|
|
1669
|
-
}
|
|
1670
|
-
}
|
|
1671
|
-
}
|
|
1672
|
-
function parentDirOf(path) {
|
|
1673
|
-
const normalized = path.replaceAll("\\", "/");
|
|
1674
|
-
return normalized.includes("/") ? normalized.slice(0, normalized.lastIndexOf("/")) : ".";
|
|
1675
|
-
}
|
|
1676
|
-
async function settleRename(from, to, report) {
|
|
1677
|
-
invalidateUsages();
|
|
1678
|
-
const fromDir = parentDirOf(from);
|
|
1679
|
-
const toDir = parentDirOf(to);
|
|
1680
|
-
await loadDirectory(fromDir);
|
|
1681
|
-
if (toDir !== fromDir) {
|
|
1682
|
-
await loadDirectory(toDir);
|
|
1683
|
-
}
|
|
1684
|
-
if (requireProjectState().selectedPath === from) {
|
|
1685
|
-
requireProjectState().selectedPath = to;
|
|
1686
|
-
}
|
|
1687
|
-
reloadRewrittenTabs(report, to);
|
|
1688
|
-
}
|
|
1689
|
-
async function renameFile(entry, renderLeftPanel) {
|
|
1690
|
-
const newName = await showRenameFileDialog(entry.name, entry.path);
|
|
1691
|
-
if (!newName || newName === entry.name) {
|
|
1692
|
-
return;
|
|
1693
|
-
}
|
|
1694
|
-
const parentDirPath = parentDirOf(entry.path);
|
|
1695
|
-
const newPath = parentDirPath === "." ? newName : `${parentDirPath}/${newName}`;
|
|
1696
|
-
markLocalMutation(entry.path, newPath);
|
|
1697
|
-
try {
|
|
1698
|
-
const platform = getPlatform();
|
|
1699
|
-
const report = await platform.renameFile(entry.path, newPath);
|
|
1700
|
-
if (workspace.tabs.has(entry.path)) {
|
|
1701
|
-
renameTab(entry.path, newPath, newPath);
|
|
1702
|
-
}
|
|
1703
|
-
await settleRename(entry.path, newPath, report);
|
|
1704
|
-
renderLeftPanel();
|
|
1705
|
-
notifyMoveOutcome(renameStatus(newName, report), report, newPath);
|
|
1706
|
-
} catch (error) {
|
|
1707
|
-
notify.error(`Could not rename ${entry.name}.`, {
|
|
1708
|
-
detail: errorMessage(error),
|
|
1709
|
-
path: entry.path,
|
|
1710
|
-
source: "Files"
|
|
1711
|
-
});
|
|
1712
|
-
}
|
|
1713
|
-
}
|
|
1714
|
-
async function deleteFile(entry, renderLeftPanel) {
|
|
1715
|
-
const confirmed = await confirmFileDelete(entry);
|
|
1716
|
-
if (!confirmed) {
|
|
1717
|
-
return;
|
|
1718
|
-
}
|
|
1719
|
-
try {
|
|
1720
|
-
const platform = getPlatform();
|
|
1721
|
-
markLocalMutation(entry.path);
|
|
1722
|
-
await platform.deleteFile(entry.path);
|
|
1723
|
-
invalidateUsages();
|
|
1724
|
-
const delPath = entry.path.replaceAll("\\", "/");
|
|
1725
|
-
const parentDirPath = delPath.includes("/") ? delPath.slice(0, delPath.lastIndexOf("/")) : ".";
|
|
1726
|
-
await loadDirectory(parentDirPath);
|
|
1727
|
-
if (requireProjectState().selectedPath === entry.path) {
|
|
1728
|
-
requireProjectState().selectedPath = null;
|
|
1729
|
-
}
|
|
1730
|
-
renderLeftPanel();
|
|
1731
|
-
notify.success(`Deleted ${entry.name}`);
|
|
1732
|
-
} catch (error) {
|
|
1733
|
-
notify.error(`Could not delete ${entry.name}.`, {
|
|
1734
|
-
detail: errorMessage(error),
|
|
1735
|
-
path: entry.path,
|
|
1736
|
-
source: "Files"
|
|
1737
|
-
});
|
|
1738
|
-
}
|
|
1739
|
-
}
|
|
1740
|
-
function revealOpenTab(tabId, opts) {
|
|
1741
|
-
const wanted = opts.paneId;
|
|
1742
|
-
const holder = paneOfTab(tabId);
|
|
1743
|
-
if (wanted !== undefined && holder && holder.id !== wanted) {
|
|
1744
|
-
if (holder.activeTabId === tabId) {
|
|
1745
|
-
return;
|
|
1746
|
-
}
|
|
1747
|
-
moveTabToPane(tabId, wanted);
|
|
1748
|
-
}
|
|
1749
|
-
activateTab(tabId, { focus: opts.focus !== false });
|
|
1750
|
-
}
|
|
1751
|
-
async function openFileInTab(path, opts = {}) {
|
|
1752
|
-
const follows = opts.focus !== false;
|
|
1753
|
-
for (const [id, tab] of workspace.tabs.entries()) {
|
|
1754
|
-
if (tab.documentPath === path) {
|
|
1755
|
-
revealOpenTab(id, opts);
|
|
1756
|
-
if (follows) {
|
|
1757
|
-
requireProjectState().selectedPath = path;
|
|
1758
|
-
}
|
|
1759
|
-
return;
|
|
1760
|
-
}
|
|
1761
|
-
}
|
|
1762
|
-
if (isViewableMedia(path)) {
|
|
1763
|
-
openMediaTab(path);
|
|
1764
|
-
if (follows) {
|
|
1765
|
-
requireProjectState().selectedPath = path;
|
|
1766
|
-
}
|
|
1767
|
-
trackRecentFile({
|
|
1768
|
-
name: path.split("/").pop() || path,
|
|
1769
|
-
path,
|
|
1770
|
-
root: requireProjectState().projectRoot
|
|
1771
|
-
});
|
|
1772
|
-
return;
|
|
1773
|
-
}
|
|
1774
|
-
if (path.toLowerCase().endsWith(".csv")) {
|
|
1775
|
-
try {
|
|
1776
|
-
await openCsvGridTab(path);
|
|
1777
|
-
requireProjectState().selectedPath = path;
|
|
1778
|
-
trackRecentFile({
|
|
1779
|
-
name: path.split("/").pop() || path,
|
|
1780
|
-
path,
|
|
1781
|
-
root: requireProjectState().projectRoot
|
|
1782
|
-
});
|
|
1783
|
-
} catch (error) {
|
|
1784
|
-
notify.error(`Could not open ${path}.`, {
|
|
1785
|
-
detail: errorMessage(error),
|
|
1786
|
-
path,
|
|
1787
|
-
source: "Open File"
|
|
1788
|
-
});
|
|
1789
|
-
}
|
|
1790
|
-
return;
|
|
1791
|
-
}
|
|
1792
|
-
const platform = getPlatform();
|
|
1793
|
-
try {
|
|
1794
|
-
const content = await platform.readFile(path);
|
|
1795
|
-
if (!content) {
|
|
1796
|
-
await loadFormats();
|
|
1797
|
-
if (!formatForPath(path) && !path.toLowerCase().endsWith(".json")) {
|
|
1798
|
-
throw noFormatError(path);
|
|
1799
|
-
}
|
|
1800
|
-
return;
|
|
1801
|
-
}
|
|
1802
|
-
await loadFormats();
|
|
1803
|
-
let document2;
|
|
1804
|
-
let frontmatter;
|
|
1805
|
-
const format = formatForPath(path);
|
|
1806
|
-
if (format) {
|
|
1807
|
-
const result = await parseSourceForPath(path, content);
|
|
1808
|
-
({ document: document2 } = result);
|
|
1809
|
-
({ frontmatter } = result);
|
|
1810
|
-
} else if (path.endsWith(".json")) {
|
|
1811
|
-
document2 = JSON.parse(content);
|
|
1812
|
-
} else {
|
|
1813
|
-
throw noFormatError(path);
|
|
1814
|
-
}
|
|
1815
|
-
const id = path;
|
|
1816
|
-
openTab({
|
|
1817
|
-
id,
|
|
1818
|
-
documentPath: path,
|
|
1819
|
-
document: document2,
|
|
1820
|
-
...frontmatter != null && { frontmatter },
|
|
1821
|
-
sourceFormat: format?.name ?? null,
|
|
1822
|
-
...opts.paneId !== undefined && { paneId: opts.paneId },
|
|
1823
|
-
...opts.preview === true && { preview: true },
|
|
1824
|
-
...opts.focus === false && { focus: false }
|
|
1825
|
-
});
|
|
1826
|
-
if (follows) {
|
|
1827
|
-
requireProjectState().selectedPath = path;
|
|
1828
|
-
}
|
|
1829
|
-
trackRecentFile({
|
|
1830
|
-
name: path.split("/").pop() || path,
|
|
1831
|
-
path,
|
|
1832
|
-
root: requireProjectState().projectRoot
|
|
1833
|
-
});
|
|
1834
|
-
} catch (error) {
|
|
1835
|
-
notify.error(`Could not open ${path}.`, {
|
|
1836
|
-
detail: errorMessage(error),
|
|
1837
|
-
path,
|
|
1838
|
-
source: "Open File"
|
|
1839
|
-
});
|
|
1840
|
-
}
|
|
1841
|
-
}
|
|
1842
|
-
async function openFileInPane(paneId, path) {
|
|
1843
|
-
await openFileInTab(path, { focus: false, paneId, preview: true });
|
|
1844
|
-
}
|
|
1845
|
-
function reloadCleanTab(path) {
|
|
1846
|
-
if (isCollabPath(path)) {
|
|
1847
|
-
return;
|
|
1848
|
-
}
|
|
1849
|
-
for (const [, tab] of workspace.tabs.entries()) {
|
|
1850
|
-
if (tab.documentPath === path && !tab.doc.dirty) {
|
|
1851
|
-
reloadFileInTab(path);
|
|
1852
|
-
return;
|
|
1853
|
-
}
|
|
1854
|
-
}
|
|
1855
|
-
}
|
|
1856
|
-
async function reloadFileInTab(path) {
|
|
1857
|
-
for (const [, tab] of workspace.tabs.entries()) {
|
|
1858
|
-
if (tab.documentPath === path) {
|
|
1859
|
-
const platform = getPlatform();
|
|
1860
|
-
try {
|
|
1861
|
-
const content = await platform.readFile(path);
|
|
1862
|
-
if (!content) {
|
|
1863
|
-
return;
|
|
1864
|
-
}
|
|
1865
|
-
await loadFormats();
|
|
1866
|
-
if (formatForPath(path)) {
|
|
1867
|
-
const { document: document2, frontmatter } = await parseSourceForPath(path, content);
|
|
1868
|
-
tab.doc.document = document2;
|
|
1869
|
-
tab.doc.content.frontmatter = frontmatter;
|
|
1870
|
-
} else if (path.endsWith(".json")) {
|
|
1871
|
-
tab.doc.document = JSON.parse(content);
|
|
1872
|
-
}
|
|
1873
|
-
tab.doc.dirty = false;
|
|
1874
|
-
} catch (error) {
|
|
1875
|
-
notify.error(`Could not reload ${path} after it changed on disk.`, {
|
|
1876
|
-
detail: errorMessage(error),
|
|
1877
|
-
key: `reload:${path}`,
|
|
1878
|
-
path,
|
|
1879
|
-
source: "Files"
|
|
1880
|
-
});
|
|
1881
|
-
}
|
|
1882
|
-
return;
|
|
1883
|
-
}
|
|
1884
|
-
}
|
|
1885
|
-
}
|
|
1886
|
-
function registerFilesPanel() {
|
|
1887
|
-
registerPanel({
|
|
1888
|
-
id: "files",
|
|
1889
|
-
title: "Files",
|
|
1890
|
-
level: "project",
|
|
1891
|
-
dock: "navigator",
|
|
1892
|
-
icon: "sp-icon-folder",
|
|
1893
|
-
render: (ctx) => ctx.deps.renderFilesTemplate(),
|
|
1894
|
-
afterRender: (ctx) => {
|
|
1895
|
-
ctx.deps.registerFileTreeDnD({ renderLeftPanel: ctx.rerender });
|
|
1896
|
-
}
|
|
1897
|
-
});
|
|
1898
|
-
}
|
|
1899
|
-
|
|
1900
|
-
export { ensureDependenciesInstalled, mediaPaneMounted, detachMediaPane, renderMediaMode, convertTargets, convertTargetExtensions, hydrateRecentProjects, getRecentProjects, addRecentProject, removeRecentProject, clearRecentProjects, getRecentFiles, trackRecentFile, loadDirectory, showIgnoredFiles, setShowIgnoredFiles, loadProject, openProject, initProjectRepo, findHomePage, openHomePage, openLastSessionOrHome, renderFilesTemplate, FILE_ROW_HEIGHT, isFileDrag, uploadFilesToDir, pickAndUploadTo, registerFileTreeDnD, OTHER_FORMAT, createFileIn, notifyMoveOutcome, parentDirOf, settleRename, openFileInTab, openFileInPane, reloadCleanTab, reloadFileInTab, registerFilesPanel };
|
|
1901
|
-
|
|
1902
|
-
//# debugId=F11FCA2F7EB309F464756E2164756E21
|
|
1903
|
-
//# sourceMappingURL=studio-5myknm0a.js.map
|